crypto/ringlwe/ringlwe_key.c
/* Make a copy of public key data structure */
Make a copy of public key data structure
Make a copy of public key data structure
RLWE_PUB *RLWE_PUB_dup(const RLWE_PUB *src) {
  RLWE_PUB *dest;
  if (src == NULL) {
    RINGLWEerr(RINGLWE_F_RLWE_PUB_DUP, ERR_R_PASSED_NULL_PARAMETER);
    return NULL;
  }
  dest = (RLWE_PUB *)OPENSSL_malloc(sizeof(RLWE_PUB));
  if (dest == NULL) {
    RINGLWEerr(RINGLWE_F_RLWE_PUB_DUP, ERR_R_MALLOC_FAILURE);
    return (NULL);
  }
  dest->param_data = src->param_data;
  memcpy(dest->descriptor, src->descriptor, _RLWE_DESCRIPTOR_LEN);
  if (src->b && src->param_data) {
    dest->b = (RINGELT *) OPENSSL_malloc(dest->param_data->m * sizeof (RINGELT));
    if (dest->b == NULL) {
      RINGLWEerr(RINGLWE_F_RLWE_PUB_DUP, ERR_R_MALLOC_FAILURE);
      RLWE_PUB_free(dest);
      return (NULL);
    }
    memcpy(dest->b, src->b, src->param_data->m * sizeof(RINGELT));
  }
  return dest;
}
RLWE_PUB * RLWE_PUB_dup ( const RLWE_PUB * src ) { RLWE_PUB * dest ; if ( src == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PUB_DUP , ERR_R_PASSED_NULL_PARAMETER ) ; return NULL ; } dest = ( RLWE_PUB * ) OPENSSL_malloc ( sizeof ( RLWE_PUB ) ) ; if ( dest == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PUB_DUP , ERR_R_MALLOC_FAILURE ) ; return ( NULL ) ; } dest -> param_data = src -> param_data ; memcpy ( dest -> descriptor , src -> descriptor , _RLWE_DESCRIPTOR_LEN ) ; if ( src -> b && src -> param_data ) { dest -> b = ( RINGELT * ) OPENSSL_malloc ( dest -> param_data -> m * sizeof ( RINGELT ) ) ; if ( dest -> b == NULL ) { RINGLWEerr ( RINGLWE_F_RLWE_PUB_DUP , ERR_R_MALLOC_FAILURE ) ; RLWE_PUB_free ( dest ) ; return ( NULL ) ; } memcpy ( dest -> b , src -> b , src -> param_data -> m * sizeof ( RINGELT ) ) ; } return dest ; }
Make a copy of public key data structure
Make a copy of public key data structure
/* copy the parameters */ /* copy the public key */