references/kyber-submission-nist-round2/NIST-PQ-Submission-Kyber-20190330/Reference_Implementation/crypto_kem/kyber768/aes256ctr.c
/*************************************************
* Name:        aes256xof_absorb
*
* Description: AES256 CTR used as a replacement for a XOF; this function
*              "absorbs" a 32-byte key and two additional bytes that are zero-padded
*              to a 12-byte nonce
*
* Arguments:   - aes256xof_ctx *s:          pointer to state to "absorb" key and IV into
*              - const unsigned char *key:  pointer to 32-byte key
*              - unsigned char x:           first additional byte to "absorb"
*              - unsigned char y:           second additional byte to "absorb"
**************************************************/
aes256xof_absorb
Description: AES256 CTR used as a replacement for a XOF; this function
"absorbs" a 32-byte key and two additional bytes that are zero-padded
to a 12-byte nonce


aes256xof_absorb Description : AES256 CTR used as a replacement for a XOF ; this function " absorbs " a 32 - byte key and two additional bytes that are zero - padded to a 12 - byte nonce
void aes256xof_absorb(aes256xof_ctx *s, const unsigned char *key, unsigned char x, unsigned char y)
{
	uint64_t skey[30];
  unsigned char iv[12];
  br_aes_ct64_keysched(skey, key);
	br_aes_ct64_skey_expand(s->sk_exp, skey);
  for(int i=2;i<12;i++)
    iv[i] = 0;
  iv[0] = x;
  iv[1] = y;
	br_range_dec32le(s->ivw, 3, iv);
	memcpy(s->ivw +  4, s->ivw, 3 * sizeof(uint32_t));
	memcpy(s->ivw +  8, s->ivw, 3 * sizeof(uint32_t));
	memcpy(s->ivw + 12, s->ivw, 3 * sizeof(uint32_t));
  s->ivw[ 3] = br_swap32(0);
	s->ivw[ 7] = br_swap32(1);
	s->ivw[11] = br_swap32(2);
	s->ivw[15] = br_swap32(3);
}
void aes256xof_absorb ( aes256xof_ctx * s , const unsigned char * key , unsigned char x , unsigned char y ) { uint64_t skey [ 30 ] ; unsigned char iv [ 12 ] ; br_aes_ct64_keysched ( skey , key ) ; br_aes_ct64_skey_expand ( s -> sk_exp , skey ) ; for ( int i = 2 ; i < 12 ; i ++ ) iv [ i ] = 0 ; iv [ 0 ] = x ; iv [ 1 ] = y ; br_range_dec32le ( s -> ivw , 3 , iv ) ; memcpy ( s -> ivw + 4 , s -> ivw , 3 * sizeof ( uint32_t ) ) ; memcpy ( s -> ivw + 8 , s -> ivw , 3 * sizeof ( uint32_t ) ) ; memcpy ( s -> ivw + 12 , s -> ivw , 3 * sizeof ( uint32_t ) ) ; s -> ivw [ 3 ] = br_swap32 ( 0 ) ; s -> ivw [ 7 ] = br_swap32 ( 1 ) ; s -> ivw [ 11 ] = br_swap32 ( 2 ) ; s -> ivw [ 15 ] = br_swap32 ( 3 ) ; }
Name:        aes256xof_absorb
Description: AES256 CTR used as a replacement for a XOF; this function
"absorbs" a 32-byte key and two additional bytes that are zero-padded
to a 12-byte nonce
Name : aes256xof_absorb Description : AES256 CTR used as a replacement for a XOF ; this function " absorbs " a 32 - byte key and two additional bytes that are zero - padded to a 12 - byte nonce