summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_pmeth.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c
index fd567658c2..4132d06639 100644
--- a/src/lib/libcrypto/rsa/rsa_pmeth.c
+++ b/src/lib/libcrypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pmeth.c,v 1.25 2019/10/31 12:32:48 jsing Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.26 2019/10/31 12:46:02 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -149,11 +149,12 @@ pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
149static int 149static int
150setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk) 150setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk)
151{ 151{
152 if (ctx->tbuf) 152 if (ctx->tbuf != NULL)
153 return 1; 153 return 1;
154 ctx->tbuf = malloc(EVP_PKEY_size(pk->pkey)); 154 if ((ctx->tbuf = calloc(1, EVP_PKEY_size(pk->pkey))) == NULL) {
155 if (!ctx->tbuf) 155 RSAerror(ERR_R_MALLOC_FAILURE);
156 return 0; 156 return 0;
157 }
157 return 1; 158 return 1;
158} 159}
159 160
@@ -635,19 +636,20 @@ pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
635 BN_GENCB *pcb, cb; 636 BN_GENCB *pcb, cb;
636 int ret; 637 int ret;
637 638
638 if (!rctx->pub_exp) { 639 if (rctx->pub_exp == NULL) {
639 rctx->pub_exp = BN_new(); 640 if ((rctx->pub_exp = BN_new()) == NULL)
640 if (!rctx->pub_exp || !BN_set_word(rctx->pub_exp, RSA_F4)) 641 return 0;
642 if (!BN_set_word(rctx->pub_exp, RSA_F4))
641 return 0; 643 return 0;
642 } 644 }
643 rsa = RSA_new(); 645 if ((rsa = RSA_new()) == NULL)
644 if (!rsa)
645 return 0; 646 return 0;
646 if (ctx->pkey_gencb) { 647 if (ctx->pkey_gencb != NULL) {
647 pcb = &cb; 648 pcb = &cb;
648 evp_pkey_set_cb_translate(pcb, ctx); 649 evp_pkey_set_cb_translate(pcb, ctx);
649 } else 650 } else {
650 pcb = NULL; 651 pcb = NULL;
652 }
651 ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb); 653 ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb);
652 if (ret > 0) 654 if (ret > 0)
653 EVP_PKEY_assign_RSA(pkey, rsa); 655 EVP_PKEY_assign_RSA(pkey, rsa);