diff options
| author | joshua <> | 2024-03-26 06:08:51 +0000 |
|---|---|---|
| committer | joshua <> | 2024-03-26 06:08:51 +0000 |
| commit | 23099c6b2e4445b6136c78c70647b49f434daad1 (patch) | |
| tree | eb812dfac34c22a113d7a4f73810ef0a471d8d77 /src | |
| parent | 552d4614f7d70b3a4f09def8dc1c5fb051682d47 (diff) | |
| download | openbsd-23099c6b2e4445b6136c78c70647b49f434daad1.tar.gz openbsd-23099c6b2e4445b6136c78c70647b49f434daad1.tar.bz2 openbsd-23099c6b2e4445b6136c78c70647b49f434daad1.zip | |
Clean up use of EVP_MD_CTX_{legacy_clear,cleanup} in EVP_SignFinal
ok jsing@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/p_sign.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c index f6d6e12a30..70290ed216 100644 --- a/src/lib/libcrypto/evp/p_sign.c +++ b/src/lib/libcrypto/evp/p_sign.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: p_sign.c,v 1.20 2024/02/18 15:45:42 tb Exp $ */ | 1 | /* $OpenBSD: p_sign.c,v 1.21 2024/03/26 06:08:51 joshua 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 | * |
| @@ -71,18 +71,19 @@ EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | |||
| 71 | { | 71 | { |
| 72 | unsigned char m[EVP_MAX_MD_SIZE]; | 72 | unsigned char m[EVP_MAX_MD_SIZE]; |
| 73 | unsigned int m_len; | 73 | unsigned int m_len; |
| 74 | EVP_MD_CTX tmp_ctx; | 74 | EVP_MD_CTX *md_ctx; |
| 75 | EVP_PKEY_CTX *pkctx = NULL; | 75 | EVP_PKEY_CTX *pkctx = NULL; |
| 76 | size_t sltmp; | 76 | size_t sltmp; |
| 77 | int ret = 0; | 77 | int ret = 0; |
| 78 | 78 | ||
| 79 | *siglen = 0; | 79 | *siglen = 0; |
| 80 | EVP_MD_CTX_legacy_clear(&tmp_ctx); | 80 | |
| 81 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) | 81 | if ((md_ctx = EVP_MD_CTX_new()) == NULL) |
| 82 | goto err; | ||
| 83 | if (!EVP_MD_CTX_copy_ex(md_ctx, ctx)) | ||
| 82 | goto err; | 84 | goto err; |
| 83 | if (!EVP_DigestFinal_ex(&tmp_ctx, &(m[0]), &m_len)) | 85 | if (!EVP_DigestFinal_ex(md_ctx, &(m[0]), &m_len)) |
| 84 | goto err; | 86 | goto err; |
| 85 | EVP_MD_CTX_cleanup(&tmp_ctx); | ||
| 86 | 87 | ||
| 87 | sltmp = (size_t)EVP_PKEY_size(pkey); | 88 | sltmp = (size_t)EVP_PKEY_size(pkey); |
| 88 | 89 | ||
| @@ -99,6 +100,7 @@ EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | |||
| 99 | ret = 1; | 100 | ret = 1; |
| 100 | 101 | ||
| 101 | err: | 102 | err: |
| 103 | EVP_MD_CTX_free(md_ctx); | ||
| 102 | EVP_PKEY_CTX_free(pkctx); | 104 | EVP_PKEY_CTX_free(pkctx); |
| 103 | return ret; | 105 | return ret; |
| 104 | } | 106 | } |
