summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeck <>2017-04-28 22:46:40 +0000
committerbeck <>2017-04-28 22:46:40 +0000
commit0e8cbd9898a13fec69ddf5721cdf1137fe077ca5 (patch)
tree3d1f17028c1d6966d7d9ab06847304c2fbde6b98
parent56efd82fd673bfdc68211c3fedb80c9ce8fdf05b (diff)
downloadopenbsd-0e8cbd9898a13fec69ddf5721cdf1137fe077ca5.tar.gz
openbsd-0e8cbd9898a13fec69ddf5721cdf1137fe077ca5.tar.bz2
openbsd-0e8cbd9898a13fec69ddf5721cdf1137fe077ca5.zip
revert previous accidental commit
-rw-r--r--src/lib/libcrypto/malloc-wrapper.c5
-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
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c12
5 files changed, 46 insertions, 25 deletions
diff --git a/src/lib/libcrypto/malloc-wrapper.c b/src/lib/libcrypto/malloc-wrapper.c
index d69b025173..6ba0aad7e4 100644
--- a/src/lib/libcrypto/malloc-wrapper.c
+++ b/src/lib/libcrypto/malloc-wrapper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc-wrapper.c,v 1.4 2017/04/28 22:38:51 beck Exp $ */ 1/* $OpenBSD: malloc-wrapper.c,v 1.5 2017/04/28 22:46:40 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Bob Beck 3 * Copyright (c) 2014 Bob Beck
4 * 4 *
@@ -165,7 +165,8 @@ CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file,
165 ret = malloc(num); 165 ret = malloc(num);
166 if (ret && ptr && old_len > 0) { 166 if (ret && ptr && old_len > 0) {
167 memcpy(ret, ptr, old_len); 167 memcpy(ret, ptr, old_len);
168 freezero(ptr, old_len); 168 explicit_bzero(ptr, old_len);
169 free(ptr);
169 } 170 }
170 return ret; 171 return ret;
171} 172}
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
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index 09d33d4cf1..8c2f5b66db 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vfy.c,v 1.62 2017/04/28 22:38:51 beck Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.63 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 *
@@ -541,7 +541,15 @@ X509_verify_cert(X509_STORE_CTX *ctx)
541 /* Safety net, error returns must set ctx->error */ 541 /* Safety net, error returns must set ctx->error */
542 if (ok <= 0 && ctx->error == X509_V_OK) 542 if (ok <= 0 && ctx->error == X509_V_OK)
543 ctx->error = X509_V_ERR_UNSPECIFIED; 543 ctx->error = X509_V_ERR_UNSPECIFIED;
544 return ok; 544
545 /*
546 * Safety net, if user provided verify callback indicates sucess
547 * make sure they have set error to X509_V_OK
548 */
549 if (ctx->verify_cb != null_callback && ok == 1)
550 ctx->error = X509_V_OK;
551
552 return(ctx->error == X509_V_OK);
545} 553}
546 554
547/* Given a STACK_OF(X509) find the issuer of cert (if any) 555/* Given a STACK_OF(X509) find the issuer of cert (if any)