int RiverKeyak_Initialize(Keyak_Instance *instance, const unsigned char *key, unsigned int keySizeInBits, const unsigned char *nonce) { int result = Keccak_DuplexInitialize(&(instance->duplex), 548, 252); if (result != 0) return result; instance->phase = Keyak_Phase_FeedingAssociatedData; return Keyak_Initialize(&(instance->duplex), key, keySizeInBits, nonce); }
// CHANGE namespace added int ParallelKeyak_Initialize(Oceankeyakv1_raw::Keyak_Instance *instance, const unsigned char *key, unsigned int keySizeInBits, const unsigned char *nonce) { int result = Keccak_ParallelDuplexInitializeAll(&(instance->duplex), 1348, 252); if (result != 0) return result; instance->phase = Keyak_Phase_FeedingAssociatedData; return Keyak_Initialize(&(instance->duplex), key, keySizeInBits, nonce); }
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 ) { Keyak_Instance instance; Keyak_Initialize( &instance, k, 16, npub, 150, 0, 0, 0, 0 ); Keyak_Wrap( &instance, m, c, (size_t)mlen, ad, (size_t)adlen, c+mlen, 0, 0 ); *clen = mlen + 16; return 0; }
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 ) { Keyak_Instance instance; unsigned long long mlen_; if (clen < 16) return -1; Keyak_Initialize( &instance, k, 16, npub, 150, 0, 0, 1, 0 ); mlen_ = clen - 16; *mlen = mlen_; if ( Keyak_Wrap( &instance, c, m, (size_t)mlen_, ad, (size_t)adlen, (unsigned char*)c+mlen_, 1, 0 ) == 1 ) return 0; return -1; }