Use the newer/more sensible names for EVP_MD_CTX_* functions.
authorjsing <jsing@openbsd.org>
Wed, 5 Sep 2018 16:58:59 +0000 (16:58 +0000)
committerjsing <jsing@openbsd.org>
Wed, 5 Sep 2018 16:58:59 +0000 (16:58 +0000)
 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
lib/libssl/ssl_clnt.c
lib/libssl/ssl_lib.c
lib/libssl/t1_enc.c
lib/libssl/t1_hash.c

index 0c436f1..9515763 100644 (file)
@@ -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);
index cf055d3..77211b6 100644 (file)
@@ -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);
index 44d11d4..d8415bc 100644 (file)
@@ -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) {
index 39f5422..01ff059 100644 (file)
@@ -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;
        }
index aef6e65..a7e4660 100644 (file)
@@ -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 <jsing@openbsd.org>
  *
@@ -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;
 }