Skip to content

Commit

Permalink
Replace memset and Async callback compilation changes.
Browse files Browse the repository at this point in the history
- Replace memset with OPENSSL_zalloc.
- Make changes in identifying Async callback mechanism
  availability in the OpenSSL to use in engine.

Change-Id: I20e1c01fb55ce8c1aa701aa834fe13dc28cc8dc8
Signed-off-by: Steve Linsell <stevenx.linsell@intel.com>
  • Loading branch information
Yogaraj-Alamenda authored and stevelinsell committed Feb 25, 2020
1 parent d2f59b4 commit 2fc0979
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .tools/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ then
fi

#check callback in openssl
if test "`grep -nr ASYNC_WAIT_CTX_get_callback $with_openssl_dir`" = ""
if test "`grep -nr ASYNC_WAIT_CTX_get_callback $with_openssl_dir/util/libcrypto.num`" = ""
then
#do nothing
cflags_SSL_QAT_use_async_callback=""
Expand Down
2 changes: 1 addition & 1 deletion multi_thread_qaememutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static void qae_make_key()
/* init the head node of a linked list*/
static void init_pool(qae_slab_pool *list)
{
memset(list,0,sizeof(qae_slab_pool));
memset(list, 0, sizeof(qae_slab_pool));
list->next = (qae_slab *)list;
list->prev = (qae_slab *)list;
list->slot_size = 0;
Expand Down
2 changes: 1 addition & 1 deletion qae_mem_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static qae_slab_pool available_slab_list[NUM_SLOT_SIZE];
/* init the head node of a linked list */
static void init_pool(qae_slab_pool *list)
{
memset(list,0,sizeof(qae_slab_pool));
memset(list, 0, sizeof(qae_slab_pool));
list->next = (qae_slab *)list;
list->prev = (qae_slab *)list;
list->slot_size = 0;
Expand Down
8 changes: 2 additions & 6 deletions qat_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,13 @@ int qat_dh_generate_key(DH *dh)
DH_get0_key(dh, &temp_pub_key, &temp_priv_key);

opData = (CpaCyDhPhase1KeyGenOpData *)
OPENSSL_malloc(sizeof(CpaCyDhPhase1KeyGenOpData));
OPENSSL_zalloc(sizeof(CpaCyDhPhase1KeyGenOpData));
if (opData == NULL) {
WARN("Failure allocating memory for opData\n");
QATerr(QAT_F_QAT_DH_GENERATE_KEY, QAT_R_OPDATA_MALLOC_FAILURE);
return ok;
}

memset(opData, 0, sizeof(CpaCyDhPhase1KeyGenOpData));

opData->primeP.pData = NULL;
opData->baseG.pData = NULL;
opData->privateValueX.pData = NULL;
Expand Down Expand Up @@ -587,15 +585,13 @@ int qat_dh_compute_key(unsigned char *key, const BIGNUM *in_pub_key, DH *dh)
}

opData = (CpaCyDhPhase2SecretKeyGenOpData *)
OPENSSL_malloc(sizeof(CpaCyDhPhase2SecretKeyGenOpData));
OPENSSL_zalloc(sizeof(CpaCyDhPhase2SecretKeyGenOpData));
if (opData == NULL) {
WARN("Failure allocating memory for opData\n");
QATerr(QAT_F_QAT_DH_COMPUTE_KEY, QAT_R_OPDATA_MALLOC_FAILURE);
return ret;
}

memset(opData, 0, sizeof(CpaCyDhPhase2SecretKeyGenOpData));

opData->primeP.pData = NULL;
opData->remoteOctetStringPV.pData = NULL;
opData->privateValueX.pData = NULL;
Expand Down
8 changes: 2 additions & 6 deletions qat_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,13 @@ DSA_SIG *qat_dsa_do_sign(const unsigned char *dgst, int dlen,
}

opData = (CpaCyDsaRSSignOpData *)
OPENSSL_malloc(sizeof(CpaCyDsaRSSignOpData));
OPENSSL_zalloc(sizeof(CpaCyDsaRSSignOpData));
if (opData == NULL) {
WARN("Failed to allocate memory for opData\n");
QATerr(QAT_F_QAT_DSA_DO_SIGN, QAT_R_OPDATA_MALLOC_FAILURE);
return sig;
}

memset(opData, 0, sizeof(CpaCyDsaRSSignOpData));

if ((ctx = BN_CTX_new()) == NULL) {
WARN("Failed to allocate memory for ctx\n");
QATerr(QAT_F_QAT_DSA_DO_SIGN, QAT_R_CTX_MALLOC_FAILURE);
Expand Down Expand Up @@ -729,15 +727,13 @@ int qat_dsa_do_verify(const unsigned char *dgst, int dgst_len,
}

opData = (CpaCyDsaVerifyOpData *)
OPENSSL_malloc(sizeof(CpaCyDsaVerifyOpData));
OPENSSL_zalloc(sizeof(CpaCyDsaVerifyOpData));
if (opData == NULL) {
WARN("Failed to allocate memory for opData\n");
QATerr(QAT_F_QAT_DSA_DO_VERIFY, QAT_R_OPDATA_MALLOC_FAILURE);
return ret;
}

memset(opData, 0, sizeof(CpaCyDsaVerifyOpData));

if ((ctx = BN_CTX_new()) == NULL) {
WARN("Failed to allocate memory for ctx\n");
QATerr(QAT_F_QAT_DSA_DO_VERIFY, QAT_R_CTX_MALLOC_FAILURE);
Expand Down
12 changes: 3 additions & 9 deletions qat_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,13 @@ int qat_ecdh_compute_key(unsigned char **outX, size_t *outlenX,
}

opData = (CpaCyEcPointMultiplyOpData *)
OPENSSL_malloc(sizeof(CpaCyEcPointMultiplyOpData));
OPENSSL_zalloc(sizeof(CpaCyEcPointMultiplyOpData));
if (opData == NULL) {
WARN("Failure to allocate opData\n");
QATerr(QAT_F_QAT_ECDH_COMPUTE_KEY, QAT_R_OPDATA_MALLOC_FAILURE);
return ret;
}

memset(opData, 0, sizeof(CpaCyEcPointMultiplyOpData));

opData->k.pData = NULL;
opData->xg.pData = NULL;
opData->yg.pData = NULL;
Expand Down Expand Up @@ -1080,15 +1078,13 @@ ECDSA_SIG *qat_ecdsa_do_sign(const unsigned char *dgst, int dgst_len,
}

opData = (CpaCyEcdsaSignRSOpData *)
OPENSSL_malloc(sizeof(CpaCyEcdsaSignRSOpData));
OPENSSL_zalloc(sizeof(CpaCyEcdsaSignRSOpData));
if (opData == NULL) {
WARN("Failure to allocate opData\n");
QATerr(QAT_F_QAT_ECDSA_DO_SIGN, QAT_R_OPDATA_MALLOC_FAILURE);
return ret;
}

memset(opData, 0, sizeof(CpaCyEcdsaSignRSOpData));

if ((ret = ECDSA_SIG_new()) == NULL) {
WARN("Failure to allocate ECDSA_SIG\n");
QATerr(QAT_F_QAT_ECDSA_DO_SIGN, QAT_R_ECDSA_SIG_MALLOC_FAILURE);
Expand Down Expand Up @@ -1555,15 +1551,13 @@ int qat_ecdsa_do_verify(const unsigned char *dgst, int dgst_len,
}

opData = (CpaCyEcdsaVerifyOpData *)
OPENSSL_malloc(sizeof(CpaCyEcdsaVerifyOpData));
OPENSSL_zalloc(sizeof(CpaCyEcdsaVerifyOpData));
if (opData == NULL) {
WARN("Failure to allocate opData\n");
QATerr(QAT_F_QAT_ECDSA_DO_VERIFY, QAT_R_OPDATA_MALLOC_FAILURE);
return ret;
}

memset(opData, 0, sizeof(CpaCyEcdsaVerifyOpData));

if ((ctx = BN_CTX_new()) == NULL) {
WARN("Failure to allocate ctx\n");
QATerr(QAT_F_QAT_ECDSA_DO_VERIFY, QAT_R_CTX_MALLOC_FAILURE);
Expand Down
12 changes: 4 additions & 8 deletions qat_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,8 @@ int qat_rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to,
(flen, from, to, rsa, padding);
}

/* set output all 0xff if failed */
if (!sts)
memset(to, 0xff, rsa_len);
OPENSSL_cleanse(to, rsa_len);

/* Return an error */
return 0;
Expand Down Expand Up @@ -1171,9 +1170,8 @@ int qat_rsa_priv_dec(int flen, const unsigned char *from,
(flen, from, to, rsa, padding);
}

/* set output all 0xff if failed */
if (!sts)
memset(to, 0xff, rsa_len);
OPENSSL_cleanse(to, rsa_len);

/* Return an error */
return 0;
Expand Down Expand Up @@ -1266,9 +1264,8 @@ int qat_rsa_pub_enc(int flen, const unsigned char *from,
(flen, from, to, rsa, padding);
}

/* set output all 0xff if failed */
if (!sts)
memset(to, 0xff, rsa_len);
OPENSSL_cleanse(to, rsa_len);
return 0;
}

Expand Down Expand Up @@ -1394,9 +1391,8 @@ int qat_rsa_pub_dec(int flen, const unsigned char *from, unsigned char *to,
(flen, from, to, rsa, padding);
}

/* set output all 0xff if failed */
if (!sts)
memset(to, 0xff, rsa_len);
OPENSSL_cleanse(to, rsa_len);
return 0;
}

Expand Down

0 comments on commit 2fc0979

Please sign in to comment.