crypto/ringlwe/ringlwe_key.c
/* Allocate public key / private key pair data structure */
Allocate public key / private key pair data structure
Allocate public key / private key pair data structure
RLWE_PAIR *RLWE_PAIR_new(RLWE_CTX *ctx) {
  RLWE_PAIR *pair;
  if (ctx == NULL) {
    RINGLWEerr(RINGLWE_F_RLWE_PAIR_NEW, ERR_R_PASSED_NULL_PARAMETER);
    return (NULL);
  }
  if (ctx->param_data == NULL) {
    RINGLWEerr(RINGLWE_F_RLWE_PAIR_NEW, ERR_R_PASSED_NULL_PARAMETER);
    return (NULL);
  }
  pair = (RLWE_PAIR *)OPENSSL_malloc(sizeof(RLWE_PAIR));
  if (pair == NULL) {
    RINGLWEerr(RINGLWE_F_RLWE_PAIR_NEW, ERR_R_MALLOC_FAILURE);
    return (NULL);
  }
  pair->param_data = ctx->param_data;
  memcpy(pair->descriptor, ctx->descriptor, _RLWE_DESCRIPTOR_LEN);
  pair->keys_set = 0;
  pair->pub = (RLWE_PUB *)RLWE_PUB_new(ctx);
  pair->s = (RINGELT *) OPENSSL_malloc(2 * ctx->param_data->m * sizeof(RINGELT));
  if ((pair->pub == NULL) || (pair->s == NULL)) {
    RINGLWEerr(RINGLWE_F_RLWE_PAIR_NEW, ERR_R_MALLOC_FAILURE);
    RLWE_PAIR_free(pair);
    return (NULL);
  }
  return (pair);
}
RLWE_PAIR * RLWE_PAIR_new ( RLWE_CTX * ctx ) { RLWE_PAIR * pair ; if ( ctx == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PAIR_NEW , ERR_R_PASSED_NULL_PARAMETER ) ; return ( NULL ) ; } if ( ctx -> param_data == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PAIR_NEW , ERR_R_PASSED_NULL_PARAMETER ) ; return ( NULL ) ; } pair = ( RLWE_PAIR * ) OPENSSL_malloc ( sizeof ( RLWE_PAIR ) ) ; if ( pair == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PAIR_NEW , ERR_R_MALLOC_FAILURE ) ; return ( NULL ) ; } pair -> param_data = ctx -> param_data ; memcpy ( pair -> descriptor , ctx -> descriptor , _RLWE_DESCRIPTOR_LEN ) ; pair -> keys_set = 0 ; pair -> pub = ( RLWE_PUB * ) RLWE_PUB_new ( ctx ) ; pair -> s = ( RINGELT * ) OPENSSL_malloc ( 2 * ctx -> param_data -> m * sizeof ( RINGELT ) ) ; if ( ( pair -> pub == NULL ) || ( pair -> s == NULL ) ) { RINGLWEerr ( RINGLWE_F_RLWE_PAIR_NEW , ERR_R_MALLOC_FAILURE ) ; RLWE_PAIR_free ( pair ) ; return ( NULL ) ; } return ( pair ) ; }
Allocate public key / private key pair data structure
Allocate public key / private key pair data structure