summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/eng_rsax.c
diff options
context:
space:
mode:
authorjsing <>2015-02-09 15:49:22 +0000
committerjsing <>2015-02-09 15:49:22 +0000
commit16f790d01f7a6fc6c94e2a033a67b80c8ec5291c (patch)
treed924c624d5eb949a9e7e395dc99d92616e911ce9 /src/lib/libcrypto/engine/eng_rsax.c
parent42f7780549de5b7b5e3e7943cfef87e0e41970fc (diff)
downloadopenbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.tar.gz
openbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.tar.bz2
openbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.zip
BN_CTX_get() can fail - consistently check its return value.
There are currently cases where the return from each call is checked, the return from only the last call is checked and cases where it is not checked at all (including code in bn, ec and engine). Checking the last return value is valid as once the function fails it will continue to return NULL. However, in order to be consistent check each call with the same idiom. This makes it easy to verify. Note there are still a handful of cases that do not follow the idiom - these will be handled separately. ok beck@ doug@
Diffstat (limited to 'src/lib/libcrypto/engine/eng_rsax.c')
-rw-r--r--src/lib/libcrypto/engine/eng_rsax.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libcrypto/engine/eng_rsax.c b/src/lib/libcrypto/engine/eng_rsax.c
index c33a776707..784b74a22f 100644
--- a/src/lib/libcrypto/engine/eng_rsax.c
+++ b/src/lib/libcrypto/engine/eng_rsax.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_rsax.c,v 1.12 2014/11/19 13:35:37 krw Exp $ */ 1/* $OpenBSD: eng_rsax.c,v 1.13 2015/02/09 15:49:22 jsing Exp $ */
2/* Copyright (c) 2010-2010 Intel Corp. 2/* Copyright (c) 2010-2010 Intel Corp.
3 * Author: Vinodh.Gopal@intel.com 3 * Author: Vinodh.Gopal@intel.com
4 * Jim Guilford 4 * Jim Guilford
@@ -519,9 +519,12 @@ e_rsax_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
519 int ret = 0; 519 int ret = 0;
520 520
521 BN_CTX_start(ctx); 521 BN_CTX_start(ctx);
522 r1 = BN_CTX_get(ctx); 522 if ((r1 = BN_CTX_get(ctx)) == NULL)
523 m1 = BN_CTX_get(ctx); 523 goto err;
524 vrfy = BN_CTX_get(ctx); 524 if ((m1 = BN_CTX_get(ctx)) == NULL)
525 goto err;
526 if ((vrfy = BN_CTX_get(ctx)) == NULL)
527 goto err;
525 528
526 { 529 {
527 BIGNUM local_p, local_q; 530 BIGNUM local_p, local_q;