diff options
author | jsing <> | 2017-04-10 06:09:32 +0000 |
---|---|---|
committer | jsing <> | 2017-04-10 06:09:32 +0000 |
commit | 723127b1d7bc0d54172ac27f42d44e9c943eb4e3 (patch) | |
tree | b67d942c8c619f8bc411f354015168ea64dddf43 | |
parent | 579a4b73945db7a24a27c2678668b0db5b9f1807 (diff) | |
download | openbsd-723127b1d7bc0d54172ac27f42d44e9c943eb4e3.tar.gz openbsd-723127b1d7bc0d54172ac27f42d44e9c943eb4e3.tar.bz2 openbsd-723127b1d7bc0d54172ac27f42d44e9c943eb4e3.zip |
Convert various client key exchange functions to freezero(3). The memory
contents needs to be made inaccessible - this is simpler and less error
prone than the current "if not NULL, explicit_bzero(); free()" dance.
-rw-r--r-- | src/lib/libssl/ssl_clnt.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 1cdbf86c50..6fb5eca4b3 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_clnt.c,v 1.11 2017/03/10 16:03:27 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.12 2017/04/10 06:09:32 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 | * |
@@ -1999,9 +1999,7 @@ ssl3_send_client_kex_dhe(SSL *s, SESS_CERT *sess_cert, CBB *cbb) | |||
1999 | 1999 | ||
2000 | err: | 2000 | err: |
2001 | DH_free(dh_clnt); | 2001 | DH_free(dh_clnt); |
2002 | if (key != NULL) | 2002 | freezero(key, key_size); |
2003 | explicit_bzero(key, key_size); | ||
2004 | free(key); | ||
2005 | 2003 | ||
2006 | return (ret); | 2004 | return (ret); |
2007 | } | 2005 | } |
@@ -2086,9 +2084,7 @@ ssl3_send_client_kex_ecdhe_ecp(SSL *s, SESS_CERT *sc, CBB *cbb) | |||
2086 | ret = 1; | 2084 | ret = 1; |
2087 | 2085 | ||
2088 | err: | 2086 | err: |
2089 | if (key != NULL) | 2087 | freezero(key, key_size); |
2090 | explicit_bzero(key, key_size); | ||
2091 | free(key); | ||
2092 | 2088 | ||
2093 | BN_CTX_free(bn_ctx); | 2089 | BN_CTX_free(bn_ctx); |
2094 | EC_KEY_free(ecdh); | 2090 | EC_KEY_free(ecdh); |
@@ -2130,14 +2126,9 @@ ssl3_send_client_kex_ecdhe_ecx(SSL *s, SESS_CERT *sc, CBB *cbb) | |||
2130 | ret = 1; | 2126 | ret = 1; |
2131 | 2127 | ||
2132 | err: | 2128 | err: |
2133 | if (private_key != NULL) | ||
2134 | explicit_bzero(private_key, X25519_KEY_LENGTH); | ||
2135 | if (shared_key != NULL) | ||
2136 | explicit_bzero(shared_key, X25519_KEY_LENGTH); | ||
2137 | |||
2138 | free(public_key); | 2129 | free(public_key); |
2139 | free(private_key); | 2130 | freezero(private_key, X25519_KEY_LENGTH); |
2140 | free(shared_key); | 2131 | freezero(shared_key, X25519_KEY_LENGTH); |
2141 | 2132 | ||
2142 | return (ret); | 2133 | return (ret); |
2143 | } | 2134 | } |