The crypto_aead_decrypt function used in many implementations has a minor const correctness code quality issue that will result in warnings (at least for SDCC). The fix is just adding const.
int crypto_aead_decrypt(unsigned char* m, unsigned long long* mlen,
unsigned char* nsec, const unsigned char* c,
unsigned long long clen, const unsigned char* ad,
unsigned long long adlen, const unsigned char* npub,
const unsigned char* k) {
(void)nsec;
if (clen < CRYPTO_ABYTES) return -1;
/* set plaintext size */
*mlen = clen - CRYPTO_ABYTES;
uint8_t* t = (uint8_t*)c + *mlen; // Change this line to "uint8_t* t = (uint8_t*)c + *mlen;" or "const uint8_t* t = c + *mlen;"
print("decrypt\n");
printbytes("k", k, CRYPTO_KEYBYTES);
printbytes("n", npub, CRYPTO_NPUBBYTES);
printbytes("a", ad, adlen);
printbytes("c", c, *mlen);
printbytes("t", t, CRYPTO_ABYTES);
/* ascon decryption */
int result = ascon_aead_decrypt(m, t, c, *mlen, ad, adlen, npub, k);
printbytes("m", m, *mlen);
print("\n");
return result;
}
The type uint8_t, if it exists, is by definition the same as unsigned char, so IMO, one could also just omit the cast (it is currently only needed to remove the const qualifier on the target, but we don't want to actually do that).
The crypto_aead_decrypt function used in many implementations has a minor const correctness code quality issue that will result in warnings (at least for SDCC). The fix is just adding const.
The type uint8_t, if it exists, is by definition the same as unsigned char, so IMO, one could also just omit the cast (it is currently only needed to remove the const qualifier on the target, but we don't want to actually do that).