summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rsa')
-rw-r--r--src/lib/libcrypto/rsa/rsa_eay.c26
-rw-r--r--src/lib/libcrypto/rsa/rsa_saos.c12
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c16
3 files changed, 33 insertions, 21 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c
index 128269a81a..f9f620ae23 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.47 2017/04/28 22:38:51 beck Exp $ */ 1/* $OpenBSD: rsa_eay.c,v 1.48 2017/04/28 22:46:40 beck 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 *
@@ -244,8 +244,10 @@ err:
244 BN_CTX_end(ctx); 244 BN_CTX_end(ctx);
245 BN_CTX_free(ctx); 245 BN_CTX_free(ctx);
246 } 246 }
247 freezero(buf, num); 247 if (buf != NULL) {
248 248 explicit_bzero(buf, num);
249 free(buf);
250 }
249 return r; 251 return r;
250} 252}
251 253
@@ -466,8 +468,10 @@ err:
466 BN_CTX_end(ctx); 468 BN_CTX_end(ctx);
467 BN_CTX_free(ctx); 469 BN_CTX_free(ctx);
468 } 470 }
469 freezero(buf, num); 471 if (buf != NULL) {
470 472 explicit_bzero(buf, num);
473 free(buf);
474 }
471 return r; 475 return r;
472} 476}
473 477
@@ -593,8 +597,10 @@ err:
593 BN_CTX_end(ctx); 597 BN_CTX_end(ctx);
594 BN_CTX_free(ctx); 598 BN_CTX_free(ctx);
595 } 599 }
596 freezero(buf, num); 600 if (buf != NULL) {
597 601 explicit_bzero(buf, num);
602 free(buf);
603 }
598 return r; 604 return r;
599} 605}
600 606
@@ -694,8 +700,10 @@ err:
694 BN_CTX_end(ctx); 700 BN_CTX_end(ctx);
695 BN_CTX_free(ctx); 701 BN_CTX_free(ctx);
696 } 702 }
697 freezero(buf, num); 703 if (buf != NULL) {
698 704 explicit_bzero(buf, num);
705 free(buf);
706 }
699 return r; 707 return r;
700} 708}
701 709
diff --git a/src/lib/libcrypto/rsa/rsa_saos.c b/src/lib/libcrypto/rsa/rsa_saos.c
index 50522b972a..10184b6c18 100644
--- a/src/lib/libcrypto/rsa/rsa_saos.c
+++ b/src/lib/libcrypto/rsa/rsa_saos.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_saos.c,v 1.21 2017/04/28 22:38:51 beck Exp $ */ 1/* $OpenBSD: rsa_saos.c,v 1.22 2017/04/28 22:46:40 beck 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 *
@@ -96,8 +96,8 @@ RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m, unsigned int m_len,
96 else 96 else
97 *siglen = i; 97 *siglen = i;
98 98
99 freezero(s, (unsigned int)j + 1); 99 explicit_bzero(s, (unsigned int)j + 1);
100 100 free(s);
101 return ret; 101 return ret;
102} 102}
103 103
@@ -137,7 +137,9 @@ RSA_verify_ASN1_OCTET_STRING(int dtype, const unsigned char *m,
137 ret = 1; 137 ret = 1;
138err: 138err:
139 ASN1_OCTET_STRING_free(sig); 139 ASN1_OCTET_STRING_free(sig);
140 freezero(s, siglen); 140 if (s != NULL) {
141 141 explicit_bzero(s, (unsigned int)siglen);
142 free(s);
143 }
142 return ret; 144 return ret;
143} 145}
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 618ec155cc..818b88c604 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_sign.c,v 1.27 2017/04/28 22:38:51 beck Exp $ */ 1/* $OpenBSD: rsa_sign.c,v 1.28 2017/04/28 22:46:40 beck 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 *
@@ -135,9 +135,10 @@ RSA_sign(int type, const unsigned char *m, unsigned int m_len,
135 else 135 else
136 *siglen = i; 136 *siglen = i;
137 137
138 if (type != NID_md5_sha1) 138 if (type != NID_md5_sha1) {
139 freezero(tmps, (unsigned int)j + 1); 139 explicit_bzero(tmps, (unsigned int)j + 1);
140 140 free(tmps);
141 }
141 return (ret); 142 return (ret);
142} 143}
143 144
@@ -233,9 +234,10 @@ int_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len,
233err: 234err:
234 if (sig != NULL) 235 if (sig != NULL)
235 X509_SIG_free(sig); 236 X509_SIG_free(sig);
236 237 if (s != NULL) {
237 freezero(s, (unsigned int)siglen); 238 explicit_bzero(s, (unsigned int)siglen);
238 239 free(s);
240 }
239 return ret; 241 return ret;
240} 242}
241 243