Encrypting file from source AEAD I am trying to encrypt/decrypt file using source code directly. The issue is how to properly do it after reading the file. 

int crypto_aead_encrypt(
    unsigned char *c, unsigned long long *clen,
    const unsigned char *m, unsigned long long mlen,
    const unsigned char *ad, unsigned long long adlen,
    const unsigned char *nsec,
    const unsigned char *npub,
    const unsigned char *k
)


Working code: (plaintext is char *)

for (start = 0; start &lt; fileLength; start += 32)
    {
        int end = (start + 32);
        end = end &gt; fileLength ? fileLength : end;

        strncpy(msg, plaintext + start, end - start);

        // encrypt
        crypto_aead_encrypt(ct, &amp;clen, msg, mlen, ad, adlen, NULL, nonce, key);

        // decryption

        crypto_aead_decrypt(msg2, &amp;mlen2, NULL, ct, clen, ad, adlen, nonce, key);
}


This is the function, and the max limit of the message m is 32 bits, which would make encrypting/decrypt very long for large files (ex. 1GB). Is there a way to perform the encrypting as fast as if it were from the library. Neglecting the code above, ex. how does OpenSSL do it when -in is provided? 

The way I have it is to read the file, save it to an char * and then take 32 bits and enc each one. So I am wondering if there is a proper more correct way to do it.

Edit: reference implementation like ascon or photon-beetle
I think you're confused here. The GCM algorithm has a 96 bit nonce, and fills the rest of the 128 bit block size with a 32 bit counter. So you have 2^32 full blocks at your disposal, or about 64 GiB. That's - uh - slightly more than 32 bits (well, OK, the counter starts at 2, so you'd have 48 bytes less than that, better keep it at 32 GiB or 48 GiB).