summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2014-07-10 07:43:11 +0000
committerjsing <>2014-07-10 07:43:11 +0000
commita4e67b1c13f505b2c40c8ea01a2d2c2d80b07750 (patch)
tree73c2d1cfd1c9669b272f8aeaa3441a982874c635 /src/lib
parenta056a5f9321e4e7d039f49d894e59dff155713aa (diff)
downloadopenbsd-a4e67b1c13f505b2c40c8ea01a2d2c2d80b07750.tar.gz
openbsd-a4e67b1c13f505b2c40c8ea01a2d2c2d80b07750.tar.bz2
openbsd-a4e67b1c13f505b2c40c8ea01a2d2c2d80b07750.zip
BN_free, BN_clear_free, BN_CTX_free, BN_BLINDING_free and BN_MONT_CTX_free
all have implicit NULL checks, so we do not need them here. ok miod@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_chk.c22
-rw-r--r--src/lib/libcrypto/rsa/rsa_crpt.c8
-rw-r--r--src/lib/libcrypto/rsa/rsa_depr.c9
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c11
-rw-r--r--src/lib/libcrypto/rsa/rsa_lib.c32
-rw-r--r--src/lib/libcrypto/rsa/rsa_pmeth.c5
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_chk.c22
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_crpt.c8
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_depr.c9
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_eay.c11
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_lib.c32
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_pmeth.c5
12 files changed, 64 insertions, 110 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c
index 0f9e0944db..c247a8d80e 100644
--- a/src/lib/libcrypto/rsa/rsa_chk.c
+++ b/src/lib/libcrypto/rsa/rsa_chk.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_chk.c,v 1.8 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_chk.c,v 1.9 2014/07/10 07:43:11 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -52,7 +52,6 @@
52#include <openssl/err.h> 52#include <openssl/err.h>
53#include <openssl/rsa.h> 53#include <openssl/rsa.h>
54 54
55
56int 55int
57RSA_check_key(const RSA *key) 56RSA_check_key(const RSA *key)
58{ 57{
@@ -203,17 +202,12 @@ RSA_check_key(const RSA *key)
203 } 202 }
204 203
205err: 204err:
206 if (i != NULL) 205 BN_free(i);
207 BN_free(i); 206 BN_free(j);
208 if (j != NULL) 207 BN_free(k);
209 BN_free(j); 208 BN_free(l);
210 if (k != NULL) 209 BN_free(m);
211 BN_free(k); 210 BN_CTX_free(ctx);
212 if (l != NULL) 211
213 BN_free(l);
214 if (m != NULL)
215 BN_free(m);
216 if (ctx != NULL)
217 BN_CTX_free(ctx);
218 return (ret); 212 return (ret);
219} 213}
diff --git a/src/lib/libcrypto/rsa/rsa_crpt.c b/src/lib/libcrypto/rsa/rsa_crpt.c
index fb09d235e1..c216c1bae4 100644
--- a/src/lib/libcrypto/rsa/rsa_crpt.c
+++ b/src/lib/libcrypto/rsa/rsa_crpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_crpt.c,v 1.6 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_crpt.c,v 1.7 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -110,10 +110,8 @@ RSA_flags(const RSA *r)
110void 110void
111RSA_blinding_off(RSA *rsa) 111RSA_blinding_off(RSA *rsa)
112{ 112{
113 if (rsa->blinding != NULL) { 113 BN_BLINDING_free(rsa->blinding);
114 BN_BLINDING_free(rsa->blinding); 114 rsa->blinding = NULL;
115 rsa->blinding = NULL;
116 }
117 rsa->flags &= ~RSA_FLAG_BLINDING; 115 rsa->flags &= ~RSA_FLAG_BLINDING;
118 rsa->flags |= RSA_FLAG_NO_BLINDING; 116 rsa->flags |= RSA_FLAG_NO_BLINDING;
119} 117}
diff --git a/src/lib/libcrypto/rsa/rsa_depr.c b/src/lib/libcrypto/rsa/rsa_depr.c
index 7a3ecca666..f66c832b2a 100644
--- a/src/lib/libcrypto/rsa/rsa_depr.c
+++ b/src/lib/libcrypto/rsa/rsa_depr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_depr.c,v 1.5 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_depr.c,v 1.6 2014/07/10 07:43:11 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -91,10 +91,9 @@ RSA_generate_key(int bits, unsigned long e_value,
91 return rsa; 91 return rsa;
92 } 92 }
93err: 93err:
94 if (e) 94 BN_free(e);
95 BN_free(e); 95 RSA_free(rsa);
96 if (rsa) 96
97 RSA_free(rsa);
98 return 0; 97 return 0;
99} 98}
100#endif 99#endif
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index ede772cb83..9b390fb8c0 100644
--- a/src/lib/libcrypto/rsa/rsa_eay.c
+++ b/src/lib/libcrypto/rsa/rsa_eay.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_eay.c,v 1.31 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_eay.c,v 1.32 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -898,12 +898,9 @@ RSA_eay_init(RSA *rsa)
898static int 898static int
899RSA_eay_finish(RSA *rsa) 899RSA_eay_finish(RSA *rsa)
900{ 900{
901 if (rsa->_method_mod_n != NULL) 901 BN_MONT_CTX_free(rsa->_method_mod_n);
902 BN_MONT_CTX_free(rsa->_method_mod_n); 902 BN_MONT_CTX_free(rsa->_method_mod_p);
903 if (rsa->_method_mod_p != NULL) 903 BN_MONT_CTX_free(rsa->_method_mod_q);
904 BN_MONT_CTX_free(rsa->_method_mod_p);
905 if (rsa->_method_mod_q != NULL)
906 BN_MONT_CTX_free(rsa->_method_mod_q);
907 904
908 return 1; 905 return 1;
909} 906}
diff --git a/src/lib/libcrypto/rsa/rsa_lib.c b/src/lib/libcrypto/rsa/rsa_lib.c
index 5afed37825..6f378ba0c0 100644
--- a/src/lib/libcrypto/rsa/rsa_lib.c
+++ b/src/lib/libcrypto/rsa/rsa_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_lib.c,v 1.25 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_lib.c,v 1.26 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -214,26 +214,16 @@ RSA_free(RSA *r)
214 214
215 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); 215 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
216 216
217 if (r->n != NULL) 217 BN_clear_free(r->n);
218 BN_clear_free(r->n); 218 BN_clear_free(r->e);
219 if (r->e != NULL) 219 BN_clear_free(r->d);
220 BN_clear_free(r->e); 220 BN_clear_free(r->p);
221 if (r->d != NULL) 221 BN_clear_free(r->q);
222 BN_clear_free(r->d); 222 BN_clear_free(r->dmp1);
223 if (r->p != NULL) 223 BN_clear_free(r->dmq1);
224 BN_clear_free(r->p); 224 BN_clear_free(r->iqmp);
225 if (r->q != NULL) 225 BN_BLINDING_free(r->blinding);
226 BN_clear_free(r->q); 226 BN_BLINDING_free(r->mt_blinding);
227 if (r->dmp1 != NULL)
228 BN_clear_free(r->dmp1);
229 if (r->dmq1 != NULL)
230 BN_clear_free(r->dmq1);
231 if (r->iqmp != NULL)
232 BN_clear_free(r->iqmp);
233 if (r->blinding != NULL)
234 BN_BLINDING_free(r->blinding);
235 if (r->mt_blinding != NULL)
236 BN_BLINDING_free(r->mt_blinding);
237 free(r); 227 free(r);
238} 228}
239 229
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c
index f35b5800ab..e083ded40c 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.10 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.11 2014/07/10 07:43:11 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 */
@@ -151,8 +151,7 @@ pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)
151 RSA_PKEY_CTX *rctx = ctx->data; 151 RSA_PKEY_CTX *rctx = ctx->data;
152 152
153 if (rctx) { 153 if (rctx) {
154 if (rctx->pub_exp) 154 BN_free(rctx->pub_exp);
155 BN_free(rctx->pub_exp);
156 free(rctx->tbuf); 155 free(rctx->tbuf);
157 free(rctx); 156 free(rctx);
158 } 157 }
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_chk.c b/src/lib/libssl/src/crypto/rsa/rsa_chk.c
index 0f9e0944db..c247a8d80e 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_chk.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_chk.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_chk.c,v 1.8 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_chk.c,v 1.9 2014/07/10 07:43:11 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -52,7 +52,6 @@
52#include <openssl/err.h> 52#include <openssl/err.h>
53#include <openssl/rsa.h> 53#include <openssl/rsa.h>
54 54
55
56int 55int
57RSA_check_key(const RSA *key) 56RSA_check_key(const RSA *key)
58{ 57{
@@ -203,17 +202,12 @@ RSA_check_key(const RSA *key)
203 } 202 }
204 203
205err: 204err:
206 if (i != NULL) 205 BN_free(i);
207 BN_free(i); 206 BN_free(j);
208 if (j != NULL) 207 BN_free(k);
209 BN_free(j); 208 BN_free(l);
210 if (k != NULL) 209 BN_free(m);
211 BN_free(k); 210 BN_CTX_free(ctx);
212 if (l != NULL) 211
213 BN_free(l);
214 if (m != NULL)
215 BN_free(m);
216 if (ctx != NULL)
217 BN_CTX_free(ctx);
218 return (ret); 212 return (ret);
219} 213}
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_crpt.c b/src/lib/libssl/src/crypto/rsa/rsa_crpt.c
index fb09d235e1..c216c1bae4 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_crpt.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_crpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_crpt.c,v 1.6 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_crpt.c,v 1.7 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -110,10 +110,8 @@ RSA_flags(const RSA *r)
110void 110void
111RSA_blinding_off(RSA *rsa) 111RSA_blinding_off(RSA *rsa)
112{ 112{
113 if (rsa->blinding != NULL) { 113 BN_BLINDING_free(rsa->blinding);
114 BN_BLINDING_free(rsa->blinding); 114 rsa->blinding = NULL;
115 rsa->blinding = NULL;
116 }
117 rsa->flags &= ~RSA_FLAG_BLINDING; 115 rsa->flags &= ~RSA_FLAG_BLINDING;
118 rsa->flags |= RSA_FLAG_NO_BLINDING; 116 rsa->flags |= RSA_FLAG_NO_BLINDING;
119} 117}
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_depr.c b/src/lib/libssl/src/crypto/rsa/rsa_depr.c
index 7a3ecca666..f66c832b2a 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_depr.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_depr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_depr.c,v 1.5 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_depr.c,v 1.6 2014/07/10 07:43:11 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -91,10 +91,9 @@ RSA_generate_key(int bits, unsigned long e_value,
91 return rsa; 91 return rsa;
92 } 92 }
93err: 93err:
94 if (e) 94 BN_free(e);
95 BN_free(e); 95 RSA_free(rsa);
96 if (rsa) 96
97 RSA_free(rsa);
98 return 0; 97 return 0;
99} 98}
100#endif 99#endif
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_eay.c b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
index ede772cb83..9b390fb8c0 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_eay.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_eay.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_eay.c,v 1.31 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_eay.c,v 1.32 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -898,12 +898,9 @@ RSA_eay_init(RSA *rsa)
898static int 898static int
899RSA_eay_finish(RSA *rsa) 899RSA_eay_finish(RSA *rsa)
900{ 900{
901 if (rsa->_method_mod_n != NULL) 901 BN_MONT_CTX_free(rsa->_method_mod_n);
902 BN_MONT_CTX_free(rsa->_method_mod_n); 902 BN_MONT_CTX_free(rsa->_method_mod_p);
903 if (rsa->_method_mod_p != NULL) 903 BN_MONT_CTX_free(rsa->_method_mod_q);
904 BN_MONT_CTX_free(rsa->_method_mod_p);
905 if (rsa->_method_mod_q != NULL)
906 BN_MONT_CTX_free(rsa->_method_mod_q);
907 904
908 return 1; 905 return 1;
909} 906}
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_lib.c b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
index 5afed37825..6f378ba0c0 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_lib.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_lib.c,v 1.25 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_lib.c,v 1.26 2014/07/10 07:43:11 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -214,26 +214,16 @@ RSA_free(RSA *r)
214 214
215 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); 215 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
216 216
217 if (r->n != NULL) 217 BN_clear_free(r->n);
218 BN_clear_free(r->n); 218 BN_clear_free(r->e);
219 if (r->e != NULL) 219 BN_clear_free(r->d);
220 BN_clear_free(r->e); 220 BN_clear_free(r->p);
221 if (r->d != NULL) 221 BN_clear_free(r->q);
222 BN_clear_free(r->d); 222 BN_clear_free(r->dmp1);
223 if (r->p != NULL) 223 BN_clear_free(r->dmq1);
224 BN_clear_free(r->p); 224 BN_clear_free(r->iqmp);
225 if (r->q != NULL) 225 BN_BLINDING_free(r->blinding);
226 BN_clear_free(r->q); 226 BN_BLINDING_free(r->mt_blinding);
227 if (r->dmp1 != NULL)
228 BN_clear_free(r->dmp1);
229 if (r->dmq1 != NULL)
230 BN_clear_free(r->dmq1);
231 if (r->iqmp != NULL)
232 BN_clear_free(r->iqmp);
233 if (r->blinding != NULL)
234 BN_BLINDING_free(r->blinding);
235 if (r->mt_blinding != NULL)
236 BN_BLINDING_free(r->mt_blinding);
237 free(r); 227 free(r);
238} 228}
239 229
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c b/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
index f35b5800ab..e083ded40c 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pmeth.c,v 1.10 2014/07/09 19:51:38 jsing Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.11 2014/07/10 07:43:11 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 */
@@ -151,8 +151,7 @@ pkey_rsa_cleanup(EVP_PKEY_CTX *ctx)
151 RSA_PKEY_CTX *rctx = ctx->data; 151 RSA_PKEY_CTX *rctx = ctx->data;
152 152
153 if (rctx) { 153 if (rctx) {
154 if (rctx->pub_exp) 154 BN_free(rctx->pub_exp);
155 BN_free(rctx->pub_exp);
156 free(rctx->tbuf); 155 free(rctx->tbuf);
157 free(rctx); 156 free(rctx);
158 } 157 }