From 48053958a069a6294694e3420876848cdfce2f55 Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 5 Sep 2018 16:58:59 +0000 Subject: [PATCH] Use the newer/more sensible names for EVP_MD_CTX_* functions. EVP_MD_CTX_create -> EVP_MD_CTX_new EVP_MD_CTX_destroy -> EVP_MD_CTX_free This should make the intent more obvious and reduce head scratching during code reviews. Raised by tb@ --- lib/libssl/d1_both.c | 4 ++-- lib/libssl/ssl_clnt.c | 6 +++--- lib/libssl/ssl_lib.c | 6 +++--- lib/libssl/t1_enc.c | 6 +++--- lib/libssl/t1_hash.c | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/libssl/d1_both.c b/lib/libssl/d1_both.c index 0c436f1f319..95157630f50 100644 --- a/lib/libssl/d1_both.c +++ b/lib/libssl/d1_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_both.c,v 1.54 2018/08/30 16:56:16 jsing Exp $ */ +/* $OpenBSD: d1_both.c,v 1.55 2018/09/05 16:58:59 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -213,7 +213,7 @@ dtls1_hm_fragment_free(hm_fragment *frag) if (frag->msg_header.is_ccs) { EVP_CIPHER_CTX_free( frag->msg_header.saved_retransmit_state.enc_write_ctx); - EVP_MD_CTX_destroy( + EVP_MD_CTX_free( frag->msg_header.saved_retransmit_state.write_hash); } free(frag->fragment); diff --git a/lib/libssl/ssl_clnt.c b/lib/libssl/ssl_clnt.c index cf055d3ee1d..77211b622b0 100644 --- a/lib/libssl/ssl_clnt.c +++ b/lib/libssl/ssl_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_clnt.c,v 1.33 2018/08/24 17:30:32 jsing Exp $ */ +/* $OpenBSD: ssl_clnt.c,v 1.34 2018/09/05 16:58:59 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2243,7 +2243,7 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb) /* * Compute shared IV and store it in algorithm-specific context data. */ - ukm_hash = EVP_MD_CTX_create(); + ukm_hash = EVP_MD_CTX_new(); if (ukm_hash == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; @@ -2258,7 +2258,7 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb) EVP_DigestUpdate(ukm_hash, s->s3->client_random, SSL3_RANDOM_SIZE); EVP_DigestUpdate(ukm_hash, s->s3->server_random, SSL3_RANDOM_SIZE); EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len); - EVP_MD_CTX_destroy(ukm_hash); + EVP_MD_CTX_free(ukm_hash); if (EVP_PKEY_CTX_ctrl(pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8, shared_ukm) < 0) { SSLerror(s, SSL_R_LIBRARY_BUG); diff --git a/lib/libssl/ssl_lib.c b/lib/libssl/ssl_lib.c index 44d11d4b164..d8415bcf6d8 100644 --- a/lib/libssl/ssl_lib.c +++ b/lib/libssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.188 2018/09/05 16:48:11 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.189 2018/09/05 16:58:59 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2624,7 +2624,7 @@ ssl_clear_cipher_read_state(SSL *s) { EVP_CIPHER_CTX_free(s->enc_read_ctx); s->enc_read_ctx = NULL; - EVP_MD_CTX_destroy(s->read_hash); + EVP_MD_CTX_free(s->read_hash); s->read_hash = NULL; if (s->internal->aead_read_ctx != NULL) { @@ -2639,7 +2639,7 @@ ssl_clear_cipher_write_state(SSL *s) { EVP_CIPHER_CTX_free(s->internal->enc_write_ctx); s->internal->enc_write_ctx = NULL; - EVP_MD_CTX_destroy(s->internal->write_hash); + EVP_MD_CTX_free(s->internal->write_hash); s->internal->write_hash = NULL; if (s->internal->aead_write_ctx != NULL) { diff --git a/lib/libssl/t1_enc.c b/lib/libssl/t1_enc.c index 39f542215b4..01ff05952c4 100644 --- a/lib/libssl/t1_enc.c +++ b/lib/libssl/t1_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_enc.c,v 1.111 2018/09/05 16:48:11 jsing Exp $ */ +/* $OpenBSD: t1_enc.c,v 1.112 2018/09/05 16:58:59 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -476,7 +476,7 @@ tls1_change_cipher_state_cipher(SSL *s, char is_read, if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->enc_read_ctx = cipher_ctx; - if ((mac_ctx = EVP_MD_CTX_create()) == NULL) + if ((mac_ctx = EVP_MD_CTX_new()) == NULL) goto err; s->read_hash = mac_ctx; } else { @@ -498,7 +498,7 @@ tls1_change_cipher_state_cipher(SSL *s, char is_read, if ((cipher_ctx = EVP_CIPHER_CTX_new()) == NULL) goto err; s->internal->enc_write_ctx = cipher_ctx; - if ((mac_ctx = EVP_MD_CTX_create()) == NULL) + if ((mac_ctx = EVP_MD_CTX_new()) == NULL) goto err; s->internal->write_hash = mac_ctx; } diff --git a/lib/libssl/t1_hash.c b/lib/libssl/t1_hash.c index aef6e65729b..a7e46601e83 100644 --- a/lib/libssl/t1_hash.c +++ b/lib/libssl/t1_hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_hash.c,v 1.2 2017/05/06 16:18:36 jsing Exp $ */ +/* $OpenBSD: t1_hash.c,v 1.3 2018/09/05 16:58:59 jsing Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -33,7 +33,7 @@ tls1_handshake_hash_init(SSL *s) goto err; } - if ((S3I(s)->handshake_hash = EVP_MD_CTX_create()) == NULL) { + if ((S3I(s)->handshake_hash = EVP_MD_CTX_new()) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } @@ -80,7 +80,7 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, if (EVP_MD_CTX_size(S3I(s)->handshake_hash) > len) goto err; - if ((mdctx = EVP_MD_CTX_create()) == NULL) { + if ((mdctx = EVP_MD_CTX_new()) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } @@ -98,7 +98,7 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, ret = 1; err: - EVP_MD_CTX_destroy(mdctx); + EVP_MD_CTX_free(mdctx); return (ret); } @@ -106,6 +106,6 @@ tls1_handshake_hash_value(SSL *s, const unsigned char *out, size_t len, void tls1_handshake_hash_free(SSL *s) { - EVP_MD_CTX_destroy(S3I(s)->handshake_hash); + EVP_MD_CTX_free(S3I(s)->handshake_hash); S3I(s)->handshake_hash = NULL; } -- 2.20.1