diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2015-11-25 18:20:50 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2015-11-27 19:04:14 +0000 |
commit | 28ba2541f9f5e61ddef548d3bead494ff6946db2 (patch) | |
tree | 62ce07aee098ea394943f63e20e829a702961ce0 /ssl/ssl_lib.c | |
parent | 2a9b96548afc0d540ab873a31dc1a72c66cba434 (diff) |
PRF and handshake hash revision.
Change handshake hash array into a single digest context simplifying the
handhake hash code. Use EVP_md5_sha1() if needed for handshake hashes in
TLS 1.1 and earlier.
Simplify PRF code to also use a single digest and treat EVP_md5_sha1()
as a special case.
Modify algorithm2 field of ciphers to use a single index value for handshake
hash and PRF instead of a bitmap.
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'ssl/ssl_lib.c')
-rw-r--r-- | ssl/ssl_lib.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index a9370dcb87..12ae35cf8c 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -3335,27 +3335,17 @@ void ssl_clear_hash_ctx(EVP_MD_CTX **hash) /* Retrieve handshake hashes */ int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen) { - unsigned char *p = out; - int idx, ret = 0; - long mask; EVP_MD_CTX ctx; - const EVP_MD *md; + EVP_MD_CTX *hdgst = s->s3->handshake_dgst; + int ret = EVP_MD_CTX_size(hdgst); EVP_MD_CTX_init(&ctx); - for (idx = 0; ssl_get_handshake_digest(idx, &mask, &md); idx++) { - if (mask & ssl_get_algorithm2(s)) { - int hashsize = EVP_MD_size(md); - EVP_MD_CTX *hdgst = s->s3->handshake_dgst[idx]; - if (!hdgst || hashsize < 0 || hashsize > outlen) - goto err; - if (!EVP_MD_CTX_copy_ex(&ctx, hdgst)) - goto err; - if (!EVP_DigestFinal_ex(&ctx, p, NULL)) - goto err; - p += hashsize; - outlen -= hashsize; - } + if (ret < 0 || ret > outlen) { + ret = 0; + goto err; } - ret = p - out; + if (!EVP_MD_CTX_copy_ex(&ctx, hdgst) + || EVP_DigestFinal_ex(&ctx, out, NULL) <= 0) + ret = 0; err: EVP_MD_CTX_cleanup(&ctx); return ret; |