references/kyber-submission-nist-round2/NIST-PQ-Submission-Kyber-20190330/Reference_Implementation/crypto_kem/kyber768/poly.c
/*************************************************
* Name:        poly_frommsg
*
* Description: Convert 32-byte message to polynomial
*
* Arguments:   - poly *r:                  pointer to output polynomial
*              - const unsigned char *msg: pointer to input message
**************************************************/
poly_frommsg
Description: Convert 32-byte message to polynomial

- poly *r:                  pointer to output polynomial
const unsigned char *msg: pointer to input message
poly_frommsg Description : Convert 32 - byte message to polynomial - poly * r : pointer to output polynomial const unsigned char * msg : pointer to input message
void poly_frommsg(poly *r, const unsigned char msg[KYBER_SYMBYTES])
{
  int i,j;
  uint16_t mask;
  for(i=0;i<KYBER_SYMBYTES;i++)
  {
    for(j=0;j<8;j++)
    {
      mask = -((msg[i] >> j)&1);
      r->coeffs[8*i+j] = mask & ((KYBER_Q+1)/2);
    }
  }
}
void poly_frommsg ( poly * r , const unsigned char msg [ KYBER_SYMBYTES ] ) { int i , j ; uint16_t mask ; for ( i = 0 ; i < KYBER_SYMBYTES ; i ++ ) { for ( j = 0 ; j < 8 ; j ++ ) { mask = - ( ( msg [ i ] >> j ) & 1 ) ; r -> coeffs [ 8 * i + j ] = mask & ( ( KYBER_Q + 1 ) / 2 ) ; } } }
Name:        poly_frommsg
Description: Convert 32-byte message to polynomial
Name : poly_frommsg Description : Convert 32 - byte message to polynomial