/* the code for the cipher implementation goes here, generating a ciphertext c[0],c[1],...,c[*clen-1] from a plaintext m[0],m[1],...,m[mlen-1] and associated data ad[0],ad[1],...,ad[adlen-1] and secret message number nsec[0],nsec[1],... and public message number npub[0],npub[1],... and secret key k[0],k[1],... */ 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 ) { size_t outlen = 0; norx_aead_encrypt(c, &outlen, ad, adlen, m, mlen, NULL, 0, npub, k); *clen = outlen; (void)nsec; /* avoid warning */ return 0; }
static std::vector<uint8_t> encrypt( const std::vector<uint8_t> header, const std::vector<uint8_t> plain, const std::vector<uint8_t> footer, const std::array<uint8_t, 16>& nonce, const std::array<uint8_t, 16>& key) { std::vector<uint8_t> cipher; cipher.resize(plain.size() + 128); unsigned char* c = cipher.data(); size_t cLen = cipher.size(); const unsigned char* h = header.empty() ? 0 : header.data(); size_t hLen = header.size(); const unsigned char* p = plain.data(); size_t pLen = plain.size(); const unsigned char* t = footer.empty() ? 0 : footer.data(); size_t tLen = footer.size(); norx_aead_encrypt(c, &cLen, h, hLen, p, pLen, t, tLen, nonce.data(), key.data()); cipher.resize(cLen); return cipher; }