diff options
| author | tb <> | 2022-01-14 08:38:06 +0000 |
|---|---|---|
| committer | tb <> | 2022-01-14 08:38:06 +0000 |
| commit | d5bd2d64a9d8dacaf683f88f953d25c96a7009ff (patch) | |
| tree | c82726f940ee4796d12475c7295f11404867aae9 /src/lib/libc | |
| parent | 0264d15b2db8e92add54fc0b024d5430c53683d3 (diff) | |
| download | openbsd-d5bd2d64a9d8dacaf683f88f953d25c96a7009ff.tar.gz openbsd-d5bd2d64a9d8dacaf683f88f953d25c96a7009ff.tar.bz2 openbsd-d5bd2d64a9d8dacaf683f88f953d25c96a7009ff.zip | |
Remove legacy sign/verify from EVP_MD.
This removes m_dss.c, m_dss1.c, and m_ecdsa.c and the corresponding
public API EVP_{dss,dss1,ecdsa}().
This is basically the following OpenSSL commit. The mentioned change in
RSA is already present in rsa/rsa_pmeth.c.
ok inoguchi jsing
commit 7f572e958b13041056f377a62d3219633cfb1e8a
Author: Dr. Stephen Henson <steve@openssl.org>
Date: Wed Dec 2 13:57:04 2015 +0000
Remove legacy sign/verify from EVP_MD.
Remove sign/verify and required_pkey_type fields of EVP_MD: these are a
legacy from when digests were linked to public key types. All signing is
now handled by the corresponding EVP_PKEY_METHOD.
Only allow supported digest types in RSA EVP_PKEY_METHOD: other algorithms
already block unsupported types.
Remove now obsolete EVP_dss1() and EVP_ecdsa().
Reviewed-by: Richard Levitte <levitte@openssl.org>
Plus OpenSSL commit 625a9baf11c1dd94f17e5876b6ee8d6271b3921d for m_dss.c
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/Makefile | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1_item.c | 17 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/c_all.c | 16 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp.h | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp_locl.h | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_dss.c | 119 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_dss1.c | 119 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_ecdsa.c | 168 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_gostr341194.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_md4.c | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_md5.c | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_md5_sha1.c | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_null.c | 7 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_ripemd.c | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_sha1.c | 47 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_sm3.c | 11 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_streebog.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/m_wp.c | 7 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/p_sign.c | 57 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/p_verify.c | 49 |
20 files changed, 62 insertions, 657 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index 6bbe8ad9de..00cd2e0721 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.70 2022/01/14 08:12:31 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.71 2022/01/14 08:38:05 tb Exp $ |
| 2 | 2 | ||
| 3 | LIB= crypto | 3 | LIB= crypto |
| 4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
| @@ -175,8 +175,7 @@ SRCS+= encode.c digest.c evp_enc.c evp_key.c | |||
| 175 | SRCS+= e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c | 175 | SRCS+= e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c |
| 176 | SRCS+= e_rc4.c e_aes.c names.c | 176 | SRCS+= e_rc4.c e_aes.c names.c |
| 177 | SRCS+= e_xcbc_d.c e_rc2.c e_cast.c | 177 | SRCS+= e_xcbc_d.c e_rc2.c e_cast.c |
| 178 | SRCS+= m_null.c m_md4.c m_md5.c m_sha1.c m_sm3.c m_wp.c | 178 | SRCS+= m_null.c m_md4.c m_md5.c m_ripemd.c m_sha1.c m_sm3.c m_wp.c |
| 179 | SRCS+= m_dss.c m_dss1.c m_ripemd.c m_ecdsa.c | ||
| 180 | SRCS+= p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c | 179 | SRCS+= p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c |
| 181 | SRCS+= bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c | 180 | SRCS+= bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c |
| 182 | SRCS+= c_all.c evp_lib.c | 181 | SRCS+= c_all.c evp_lib.c |
diff --git a/src/lib/libcrypto/asn1/asn1_item.c b/src/lib/libcrypto/asn1/asn1_item.c index 7dad8e0df1..108f272b8c 100644 --- a/src/lib/libcrypto/asn1/asn1_item.c +++ b/src/lib/libcrypto/asn1/asn1_item.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: asn1_item.c,v 1.3 2021/12/25 13:17:48 jsing Exp $ */ | 1 | /* $OpenBSD: asn1_item.c,v 1.4 2022/01/14 08:38:05 tb 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 | * |
| @@ -265,15 +265,12 @@ ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, | |||
| 265 | rv = 2; | 265 | rv = 2; |
| 266 | 266 | ||
| 267 | if (rv == 2) { | 267 | if (rv == 2) { |
| 268 | if (type->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { | 268 | if (!pkey->ameth || |
| 269 | if (!pkey->ameth || | 269 | !OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type), |
| 270 | !OBJ_find_sigid_by_algs(&signid, | 270 | pkey->ameth->pkey_id)) { |
| 271 | EVP_MD_nid(type), pkey->ameth->pkey_id)) { | 271 | ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); |
| 272 | ASN1error(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); | 272 | return 0; |
| 273 | return 0; | 273 | } |
| 274 | } | ||
| 275 | } else | ||
| 276 | signid = type->pkey_type; | ||
| 277 | 274 | ||
| 278 | if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) | 275 | if (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) |
| 279 | paramtype = V_ASN1_NULL; | 276 | paramtype = V_ASN1_NULL; |
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c index 9e9d39d5ab..690215c8e8 100644 --- a/src/lib/libcrypto/evp/c_all.c +++ b/src/lib/libcrypto/evp/c_all.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: c_all.c,v 1.26 2019/03/17 18:07:41 tb Exp $ */ | 1 | /* $OpenBSD: c_all.c,v 1.27 2022/01/14 08:38:05 tb 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 | * |
| @@ -263,24 +263,10 @@ OpenSSL_add_all_digests_internal(void) | |||
| 263 | EVP_add_digest_alias(SN_md5, "ssl3-md5"); | 263 | EVP_add_digest_alias(SN_md5, "ssl3-md5"); |
| 264 | #endif | 264 | #endif |
| 265 | 265 | ||
| 266 | #if !defined(OPENSSL_NO_SHA) | ||
| 267 | #ifndef OPENSSL_NO_DSA | ||
| 268 | EVP_add_digest(EVP_dss()); | ||
| 269 | #endif | ||
| 270 | #endif | ||
| 271 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) | 266 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) |
| 272 | EVP_add_digest(EVP_sha1()); | 267 | EVP_add_digest(EVP_sha1()); |
| 273 | EVP_add_digest_alias(SN_sha1, "ssl3-sha1"); | 268 | EVP_add_digest_alias(SN_sha1, "ssl3-sha1"); |
| 274 | EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA); | 269 | EVP_add_digest_alias(SN_sha1WithRSAEncryption, SN_sha1WithRSA); |
| 275 | #ifndef OPENSSL_NO_DSA | ||
| 276 | EVP_add_digest(EVP_dss1()); | ||
| 277 | EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2); | ||
| 278 | EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1"); | ||
| 279 | EVP_add_digest_alias(SN_dsaWithSHA1, "dss1"); | ||
| 280 | #endif | ||
| 281 | #ifndef OPENSSL_NO_ECDSA | ||
| 282 | EVP_add_digest(EVP_ecdsa()); | ||
| 283 | #endif | ||
| 284 | #endif | 270 | #endif |
| 285 | 271 | ||
| 286 | #ifndef OPENSSL_NO_GOST | 272 | #ifndef OPENSSL_NO_GOST |
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index acf0650f9a..a80cf189fc 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp.h,v 1.98 2022/01/14 08:04:14 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.99 2022/01/14 08:38:05 tb 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 | * |
| @@ -128,15 +128,6 @@ extern "C" { | |||
| 128 | #define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single | 128 | #define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single |
| 129 | * block */ | 129 | * block */ |
| 130 | 130 | ||
| 131 | #define EVP_MD_FLAG_PKEY_DIGEST 0x0002 /* digest is a "clone" digest used | ||
| 132 | * which is a copy of an existing | ||
| 133 | * one for a specific public key type. | ||
| 134 | * EVP_dss1() etc */ | ||
| 135 | |||
| 136 | /* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */ | ||
| 137 | |||
| 138 | #define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE 0x0004 | ||
| 139 | |||
| 140 | /* DigestAlgorithmIdentifier flags... */ | 131 | /* DigestAlgorithmIdentifier flags... */ |
| 141 | 132 | ||
| 142 | #define EVP_MD_FLAG_DIGALGID_MASK 0x0018 | 133 | #define EVP_MD_FLAG_DIGALGID_MASK 0x0018 |
| @@ -166,38 +157,6 @@ extern "C" { | |||
| 166 | 157 | ||
| 167 | #define EVP_MD_CTRL_ALG_CTRL 0x1000 | 158 | #define EVP_MD_CTRL_ALG_CTRL 0x1000 |
| 168 | 159 | ||
| 169 | #define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} | ||
| 170 | |||
| 171 | #ifndef OPENSSL_NO_DSA | ||
| 172 | #define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \ | ||
| 173 | (evp_verify_method *)DSA_verify, \ | ||
| 174 | {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ | ||
| 175 | EVP_PKEY_DSA4,0} | ||
| 176 | #else | ||
| 177 | #define EVP_PKEY_DSA_method EVP_PKEY_NULL_method | ||
| 178 | #endif | ||
| 179 | |||
| 180 | #ifndef OPENSSL_NO_ECDSA | ||
| 181 | #define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \ | ||
| 182 | (evp_verify_method *)ECDSA_verify, \ | ||
| 183 | {EVP_PKEY_EC,0,0,0} | ||
| 184 | #else | ||
| 185 | #define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method | ||
| 186 | #endif | ||
| 187 | |||
| 188 | #ifndef OPENSSL_NO_RSA | ||
| 189 | #define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \ | ||
| 190 | (evp_verify_method *)RSA_verify, \ | ||
| 191 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
| 192 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ | ||
| 193 | (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \ | ||
| 194 | (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \ | ||
| 195 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
| 196 | #else | ||
| 197 | #define EVP_PKEY_RSA_method EVP_PKEY_NULL_method | ||
| 198 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method | ||
| 199 | #endif | ||
| 200 | |||
| 201 | #endif /* !EVP_MD */ | 160 | #endif /* !EVP_MD */ |
| 202 | 161 | ||
| 203 | /* values for EVP_MD_CTX flags */ | 162 | /* values for EVP_MD_CTX flags */ |
| @@ -598,9 +557,6 @@ const EVP_MD *EVP_md5_sha1(void); | |||
| 598 | #endif | 557 | #endif |
| 599 | #ifndef OPENSSL_NO_SHA | 558 | #ifndef OPENSSL_NO_SHA |
| 600 | const EVP_MD *EVP_sha1(void); | 559 | const EVP_MD *EVP_sha1(void); |
| 601 | const EVP_MD *EVP_dss(void); | ||
| 602 | const EVP_MD *EVP_dss1(void); | ||
| 603 | const EVP_MD *EVP_ecdsa(void); | ||
| 604 | #endif | 560 | #endif |
| 605 | #ifndef OPENSSL_NO_SHA256 | 561 | #ifndef OPENSSL_NO_SHA256 |
| 606 | const EVP_MD *EVP_sha224(void); | 562 | const EVP_MD *EVP_sha224(void); |
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h index f0b47a497c..c3d9a6a718 100644 --- a/src/lib/libcrypto/evp/evp_locl.h +++ b/src/lib/libcrypto/evp/evp_locl.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_locl.h,v 1.21 2022/01/14 08:04:14 tb Exp $ */ | 1 | /* $OpenBSD: evp_locl.h,v 1.22 2022/01/14 08:38:05 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -116,9 +116,6 @@ struct env_md_st { | |||
| 116 | int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from); | 116 | int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from); |
| 117 | int (*cleanup)(EVP_MD_CTX *ctx); | 117 | int (*cleanup)(EVP_MD_CTX *ctx); |
| 118 | 118 | ||
| 119 | evp_sign_method *sign; | ||
| 120 | evp_verify_method *verify; | ||
| 121 | int required_pkey_type[5]; /*EVP_PKEY_xxx */ | ||
| 122 | int block_size; | 119 | int block_size; |
| 123 | int ctx_size; /* how big does the ctx->md_data need to be */ | 120 | int ctx_size; /* how big does the ctx->md_data need to be */ |
| 124 | /* control function */ | 121 | /* control function */ |
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c deleted file mode 100644 index 45f09dde5d..0000000000 --- a/src/lib/libcrypto/evp/m_dss.c +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | /* $OpenBSD: m_dss.c,v 1.17 2021/12/12 21:30:13 tb Exp $ */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | |||
| 61 | #include <openssl/opensslconf.h> | ||
| 62 | |||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/objects.h> | ||
| 65 | #include <openssl/sha.h> | ||
| 66 | |||
| 67 | #ifndef OPENSSL_NO_DSA | ||
| 68 | #include <openssl/dsa.h> | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #include "evp_locl.h" | ||
| 72 | |||
| 73 | #ifndef OPENSSL_NO_SHA | ||
| 74 | |||
| 75 | static int | ||
| 76 | init(EVP_MD_CTX *ctx) | ||
| 77 | { | ||
| 78 | return SHA1_Init(ctx->md_data); | ||
| 79 | } | ||
| 80 | |||
| 81 | static int | ||
| 82 | update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 83 | { | ||
| 84 | return SHA1_Update(ctx->md_data, data, count); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int | ||
| 88 | final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 89 | { | ||
| 90 | return SHA1_Final(md, ctx->md_data); | ||
| 91 | } | ||
| 92 | |||
| 93 | static const EVP_MD dsa_md = { | ||
| 94 | .type = NID_dsaWithSHA, | ||
| 95 | .pkey_type = NID_dsaWithSHA, | ||
| 96 | .md_size = SHA_DIGEST_LENGTH, | ||
| 97 | .flags = EVP_MD_FLAG_PKEY_DIGEST, | ||
| 98 | .init = init, | ||
| 99 | .update = update, | ||
| 100 | .final = final, | ||
| 101 | .copy = NULL, | ||
| 102 | .cleanup = NULL, | ||
| 103 | #ifndef OPENSSL_NO_DSA | ||
| 104 | .sign = (evp_sign_method *)DSA_sign, | ||
| 105 | .verify = (evp_verify_method *)DSA_verify, | ||
| 106 | .required_pkey_type = { | ||
| 107 | EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0, | ||
| 108 | }, | ||
| 109 | #endif | ||
| 110 | .block_size = SHA_CBLOCK, | ||
| 111 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), | ||
| 112 | }; | ||
| 113 | |||
| 114 | const EVP_MD * | ||
| 115 | EVP_dss(void) | ||
| 116 | { | ||
| 117 | return (&dsa_md); | ||
| 118 | } | ||
| 119 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c deleted file mode 100644 index 283672cc1e..0000000000 --- a/src/lib/libcrypto/evp/m_dss1.c +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | /* $OpenBSD: m_dss1.c,v 1.17 2021/12/12 21:30:13 tb Exp $ */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | |||
| 61 | #include <openssl/opensslconf.h> | ||
| 62 | |||
| 63 | #ifndef OPENSSL_NO_SHA | ||
| 64 | |||
| 65 | #include <openssl/evp.h> | ||
| 66 | #include <openssl/objects.h> | ||
| 67 | #include <openssl/sha.h> | ||
| 68 | |||
| 69 | #ifndef OPENSSL_NO_DSA | ||
| 70 | #include <openssl/dsa.h> | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #include "evp_locl.h" | ||
| 74 | |||
| 75 | static int | ||
| 76 | init(EVP_MD_CTX *ctx) | ||
| 77 | { | ||
| 78 | return SHA1_Init(ctx->md_data); | ||
| 79 | } | ||
| 80 | |||
| 81 | static int | ||
| 82 | update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 83 | { | ||
| 84 | return SHA1_Update(ctx->md_data, data, count); | ||
| 85 | } | ||
| 86 | |||
| 87 | static int | ||
| 88 | final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 89 | { | ||
| 90 | return SHA1_Final(md, ctx->md_data); | ||
| 91 | } | ||
| 92 | |||
| 93 | static const EVP_MD dss1_md = { | ||
| 94 | .type = NID_dsa, | ||
| 95 | .pkey_type = NID_dsaWithSHA1, | ||
| 96 | .md_size = SHA_DIGEST_LENGTH, | ||
| 97 | .flags = EVP_MD_FLAG_PKEY_DIGEST, | ||
| 98 | .init = init, | ||
| 99 | .update = update, | ||
| 100 | .final = final, | ||
| 101 | .copy = NULL, | ||
| 102 | .cleanup = NULL, | ||
| 103 | #ifndef OPENSSL_NO_DSA | ||
| 104 | .sign = (evp_sign_method *)DSA_sign, | ||
| 105 | .verify = (evp_verify_method *)DSA_verify, | ||
| 106 | .required_pkey_type = { | ||
| 107 | EVP_PKEY_DSA, EVP_PKEY_DSA2, EVP_PKEY_DSA3, EVP_PKEY_DSA4, 0, | ||
| 108 | }, | ||
| 109 | #endif | ||
| 110 | .block_size = SHA_CBLOCK, | ||
| 111 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), | ||
| 112 | }; | ||
| 113 | |||
| 114 | const EVP_MD * | ||
| 115 | EVP_dss1(void) | ||
| 116 | { | ||
| 117 | return (&dss1_md); | ||
| 118 | } | ||
| 119 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_ecdsa.c b/src/lib/libcrypto/evp/m_ecdsa.c deleted file mode 100644 index b4bd21f7b0..0000000000 --- a/src/lib/libcrypto/evp/m_ecdsa.c +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 1 | /* $OpenBSD: m_ecdsa.c,v 1.9 2021/12/12 21:30:13 tb Exp $ */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@openssl.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 56 | * All rights reserved. | ||
| 57 | * | ||
| 58 | * This package is an SSL implementation written | ||
| 59 | * by Eric Young (eay@cryptsoft.com). | ||
| 60 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 61 | * | ||
| 62 | * This library is free for commercial and non-commercial use as long as | ||
| 63 | * the following conditions are aheared to. The following conditions | ||
| 64 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 66 | * included with this distribution is covered by the same copyright terms | ||
| 67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 68 | * | ||
| 69 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 70 | * the code are not to be removed. | ||
| 71 | * If this package is used in a product, Eric Young should be given attribution | ||
| 72 | * as the author of the parts of the library used. | ||
| 73 | * This can be in the form of a textual message at program startup or | ||
| 74 | * in documentation (online or textual) provided with the package. | ||
| 75 | * | ||
| 76 | * Redistribution and use in source and binary forms, with or without | ||
| 77 | * modification, are permitted provided that the following conditions | ||
| 78 | * are met: | ||
| 79 | * 1. Redistributions of source code must retain the copyright | ||
| 80 | * notice, this list of conditions and the following disclaimer. | ||
| 81 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 82 | * notice, this list of conditions and the following disclaimer in the | ||
| 83 | * documentation and/or other materials provided with the distribution. | ||
| 84 | * 3. All advertising materials mentioning features or use of this software | ||
| 85 | * must display the following acknowledgement: | ||
| 86 | * "This product includes cryptographic software written by | ||
| 87 | * Eric Young (eay@cryptsoft.com)" | ||
| 88 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 89 | * being used are not cryptographic related :-). | ||
| 90 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 91 | * the apps directory (application code) you must include an acknowledgement: | ||
| 92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 93 | * | ||
| 94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 97 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 98 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 99 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 100 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 101 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 104 | * SUCH DAMAGE. | ||
| 105 | * | ||
| 106 | * The licence and distribution terms for any publically available version or | ||
| 107 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 108 | * copied and put under another distribution licence | ||
| 109 | * [including the GNU Public Licence.] | ||
| 110 | */ | ||
| 111 | |||
| 112 | #include <stdio.h> | ||
| 113 | |||
| 114 | #include <openssl/opensslconf.h> | ||
| 115 | |||
| 116 | #include <openssl/evp.h> | ||
| 117 | #include <openssl/objects.h> | ||
| 118 | #include <openssl/x509.h> | ||
| 119 | |||
| 120 | #include "evp_locl.h" | ||
| 121 | |||
| 122 | #ifndef OPENSSL_NO_SHA | ||
| 123 | |||
| 124 | static int | ||
| 125 | init(EVP_MD_CTX *ctx) | ||
| 126 | { | ||
| 127 | return SHA1_Init(ctx->md_data); | ||
| 128 | } | ||
| 129 | |||
| 130 | static int | ||
| 131 | update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 132 | { | ||
| 133 | return SHA1_Update(ctx->md_data, data, count); | ||
| 134 | } | ||
| 135 | |||
| 136 | static int | ||
| 137 | final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 138 | { | ||
| 139 | return SHA1_Final(md, ctx->md_data); | ||
| 140 | } | ||
| 141 | |||
| 142 | static const EVP_MD ecdsa_md = { | ||
| 143 | .type = NID_ecdsa_with_SHA1, | ||
| 144 | .pkey_type = NID_ecdsa_with_SHA1, | ||
| 145 | .md_size = SHA_DIGEST_LENGTH, | ||
| 146 | .flags = EVP_MD_FLAG_PKEY_DIGEST, | ||
| 147 | .init = init, | ||
| 148 | .update = update, | ||
| 149 | .final = final, | ||
| 150 | .copy = NULL, | ||
| 151 | .cleanup = NULL, | ||
| 152 | #ifndef OPENSSL_NO_ECDSA | ||
| 153 | .sign = (evp_sign_method *)ECDSA_sign, | ||
| 154 | .verify = (evp_verify_method *)ECDSA_verify, | ||
| 155 | .required_pkey_type = { | ||
| 156 | EVP_PKEY_EC, 0, 0, 0, | ||
| 157 | }, | ||
| 158 | #endif | ||
| 159 | .block_size = SHA_CBLOCK, | ||
| 160 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), | ||
| 161 | }; | ||
| 162 | |||
| 163 | const EVP_MD * | ||
| 164 | EVP_ecdsa(void) | ||
| 165 | { | ||
| 166 | return (&ecdsa_md); | ||
| 167 | } | ||
| 168 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_gostr341194.c b/src/lib/libcrypto/evp/m_gostr341194.c index 40de232344..f479675baa 100644 --- a/src/lib/libcrypto/evp/m_gostr341194.c +++ b/src/lib/libcrypto/evp/m_gostr341194.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_gostr341194.c,v 1.3 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_gostr341194.c,v 1.4 2022/01/14 08:38:05 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
| 4 | * Copyright (c) 2005-2006 Cryptocom LTD | 4 | * Copyright (c) 2005-2006 Cryptocom LTD |
| @@ -84,7 +84,7 @@ static const EVP_MD gostr341194_md = { | |||
| 84 | .type = NID_id_GostR3411_94, | 84 | .type = NID_id_GostR3411_94, |
| 85 | .pkey_type = NID_undef, | 85 | .pkey_type = NID_undef, |
| 86 | .md_size = GOSTR341194_LENGTH, | 86 | .md_size = GOSTR341194_LENGTH, |
| 87 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE, | 87 | .flags = 0, |
| 88 | .init = gostr341194_init, | 88 | .init = gostr341194_init, |
| 89 | .update = gostr341194_update, | 89 | .update = gostr341194_update, |
| 90 | .final = gostr341194_final, | 90 | .final = gostr341194_final, |
diff --git a/src/lib/libcrypto/evp/m_md4.c b/src/lib/libcrypto/evp/m_md4.c index 5729807986..977565283f 100644 --- a/src/lib/libcrypto/evp/m_md4.c +++ b/src/lib/libcrypto/evp/m_md4.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_md4.c,v 1.17 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_md4.c,v 1.18 2022/01/14 08:38:05 tb 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 | * |
| @@ -101,13 +101,6 @@ static const EVP_MD md4_md = { | |||
| 101 | .final = final, | 101 | .final = final, |
| 102 | .copy = NULL, | 102 | .copy = NULL, |
| 103 | .cleanup = NULL, | 103 | .cleanup = NULL, |
| 104 | #ifndef OPENSSL_NO_RSA | ||
| 105 | .sign = (evp_sign_method *)RSA_sign, | ||
| 106 | .verify = (evp_verify_method *)RSA_verify, | ||
| 107 | .required_pkey_type = { | ||
| 108 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 109 | }, | ||
| 110 | #endif | ||
| 111 | .block_size = MD4_CBLOCK, | 104 | .block_size = MD4_CBLOCK, |
| 112 | .ctx_size = sizeof(EVP_MD *) + sizeof(MD4_CTX), | 105 | .ctx_size = sizeof(EVP_MD *) + sizeof(MD4_CTX), |
| 113 | }; | 106 | }; |
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c index dbdc567616..daa7aee7b0 100644 --- a/src/lib/libcrypto/evp/m_md5.c +++ b/src/lib/libcrypto/evp/m_md5.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_md5.c,v 1.16 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_md5.c,v 1.17 2022/01/14 08:38:06 tb 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 | * |
| @@ -101,13 +101,6 @@ static const EVP_MD md5_md = { | |||
| 101 | .final = final, | 101 | .final = final, |
| 102 | .copy = NULL, | 102 | .copy = NULL, |
| 103 | .cleanup = NULL, | 103 | .cleanup = NULL, |
| 104 | #ifndef OPENSSL_NO_RSA | ||
| 105 | .sign = (evp_sign_method *)RSA_sign, | ||
| 106 | .verify = (evp_verify_method *)RSA_verify, | ||
| 107 | .required_pkey_type = { | ||
| 108 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 109 | }, | ||
| 110 | #endif | ||
| 111 | .block_size = MD5_CBLOCK, | 104 | .block_size = MD5_CBLOCK, |
| 112 | .ctx_size = sizeof(EVP_MD *) + sizeof(MD5_CTX), | 105 | .ctx_size = sizeof(EVP_MD *) + sizeof(MD5_CTX), |
| 113 | }; | 106 | }; |
diff --git a/src/lib/libcrypto/evp/m_md5_sha1.c b/src/lib/libcrypto/evp/m_md5_sha1.c index aaddbe9c81..f8bec10d18 100644 --- a/src/lib/libcrypto/evp/m_md5_sha1.c +++ b/src/lib/libcrypto/evp/m_md5_sha1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_md5_sha1.c,v 1.3 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_md5_sha1.c,v 1.4 2022/01/14 08:38:06 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -80,13 +80,6 @@ static const EVP_MD md5_sha1_md = { | |||
| 80 | .final = md5_sha1_final, | 80 | .final = md5_sha1_final, |
| 81 | .block_size = MD5_CBLOCK, /* MD5_CBLOCK == SHA_CBLOCK */ | 81 | .block_size = MD5_CBLOCK, /* MD5_CBLOCK == SHA_CBLOCK */ |
| 82 | .ctx_size = sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx), | 82 | .ctx_size = sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx), |
| 83 | #ifndef OPENSSL_NO_RSA | ||
| 84 | .sign = (evp_sign_method *)RSA_sign, | ||
| 85 | .verify = (evp_verify_method *)RSA_verify, | ||
| 86 | .required_pkey_type = { | ||
| 87 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 88 | }, | ||
| 89 | #endif | ||
| 90 | }; | 83 | }; |
| 91 | 84 | ||
| 92 | const EVP_MD * | 85 | const EVP_MD * |
diff --git a/src/lib/libcrypto/evp/m_null.c b/src/lib/libcrypto/evp/m_null.c index 86f5a08688..4334decb99 100644 --- a/src/lib/libcrypto/evp/m_null.c +++ b/src/lib/libcrypto/evp/m_null.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_null.c,v 1.10 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_null.c,v 1.11 2022/01/14 08:38:06 tb 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 | * |
| @@ -92,11 +92,6 @@ static const EVP_MD null_md = { | |||
| 92 | .final = final, | 92 | .final = final, |
| 93 | .copy = NULL, | 93 | .copy = NULL, |
| 94 | .cleanup = NULL, | 94 | .cleanup = NULL, |
| 95 | .sign = NULL, | ||
| 96 | .verify = NULL, | ||
| 97 | .required_pkey_type = { | ||
| 98 | 0, 0, 0, 0, | ||
| 99 | }, | ||
| 100 | .block_size = 0, | 95 | .block_size = 0, |
| 101 | .ctx_size = sizeof(EVP_MD *), | 96 | .ctx_size = sizeof(EVP_MD *), |
| 102 | }; | 97 | }; |
diff --git a/src/lib/libcrypto/evp/m_ripemd.c b/src/lib/libcrypto/evp/m_ripemd.c index b3369ab53f..47397833de 100644 --- a/src/lib/libcrypto/evp/m_ripemd.c +++ b/src/lib/libcrypto/evp/m_ripemd.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_ripemd.c,v 1.13 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_ripemd.c,v 1.14 2022/01/14 08:38:06 tb 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 | * |
| @@ -101,13 +101,6 @@ static const EVP_MD ripemd160_md = { | |||
| 101 | .final = final, | 101 | .final = final, |
| 102 | .copy = NULL, | 102 | .copy = NULL, |
| 103 | .cleanup = NULL, | 103 | .cleanup = NULL, |
| 104 | #ifndef OPENSSL_NO_RSA | ||
| 105 | .sign = (evp_sign_method *)RSA_sign, | ||
| 106 | .verify = (evp_verify_method *)RSA_verify, | ||
| 107 | .required_pkey_type = { | ||
| 108 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 109 | }, | ||
| 110 | #endif | ||
| 111 | .block_size = RIPEMD160_CBLOCK, | 104 | .block_size = RIPEMD160_CBLOCK, |
| 112 | .ctx_size = sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX), | 105 | .ctx_size = sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX), |
| 113 | }; | 106 | }; |
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c index 396f00aa13..a6fb53641e 100644 --- a/src/lib/libcrypto/evp/m_sha1.c +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_sha1.c,v 1.18 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_sha1.c,v 1.19 2022/01/14 08:38:06 tb 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 | * |
| @@ -94,19 +94,12 @@ static const EVP_MD sha1_md = { | |||
| 94 | .type = NID_sha1, | 94 | .type = NID_sha1, |
| 95 | .pkey_type = NID_sha1WithRSAEncryption, | 95 | .pkey_type = NID_sha1WithRSAEncryption, |
| 96 | .md_size = SHA_DIGEST_LENGTH, | 96 | .md_size = SHA_DIGEST_LENGTH, |
| 97 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 97 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 98 | .init = init, | 98 | .init = init, |
| 99 | .update = update, | 99 | .update = update, |
| 100 | .final = final, | 100 | .final = final, |
| 101 | .copy = NULL, | 101 | .copy = NULL, |
| 102 | .cleanup = NULL, | 102 | .cleanup = NULL, |
| 103 | #ifndef OPENSSL_NO_RSA | ||
| 104 | .sign = (evp_sign_method *)RSA_sign, | ||
| 105 | .verify = (evp_verify_method *)RSA_verify, | ||
| 106 | .required_pkey_type = { | ||
| 107 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 108 | }, | ||
| 109 | #endif | ||
| 110 | .block_size = SHA_CBLOCK, | 103 | .block_size = SHA_CBLOCK, |
| 111 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), | 104 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA_CTX), |
| 112 | }; | 105 | }; |
| @@ -151,19 +144,12 @@ static const EVP_MD sha224_md = { | |||
| 151 | .type = NID_sha224, | 144 | .type = NID_sha224, |
| 152 | .pkey_type = NID_sha224WithRSAEncryption, | 145 | .pkey_type = NID_sha224WithRSAEncryption, |
| 153 | .md_size = SHA224_DIGEST_LENGTH, | 146 | .md_size = SHA224_DIGEST_LENGTH, |
| 154 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 147 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 155 | .init = init224, | 148 | .init = init224, |
| 156 | .update = update256, | 149 | .update = update256, |
| 157 | .final = final256, | 150 | .final = final256, |
| 158 | .copy = NULL, | 151 | .copy = NULL, |
| 159 | .cleanup = NULL, | 152 | .cleanup = NULL, |
| 160 | #ifndef OPENSSL_NO_RSA | ||
| 161 | .sign = (evp_sign_method *)RSA_sign, | ||
| 162 | .verify = (evp_verify_method *)RSA_verify, | ||
| 163 | .required_pkey_type = { | ||
| 164 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 165 | }, | ||
| 166 | #endif | ||
| 167 | .block_size = SHA256_CBLOCK, | 153 | .block_size = SHA256_CBLOCK, |
| 168 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), | 154 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), |
| 169 | }; | 155 | }; |
| @@ -178,19 +164,12 @@ static const EVP_MD sha256_md = { | |||
| 178 | .type = NID_sha256, | 164 | .type = NID_sha256, |
| 179 | .pkey_type = NID_sha256WithRSAEncryption, | 165 | .pkey_type = NID_sha256WithRSAEncryption, |
| 180 | .md_size = SHA256_DIGEST_LENGTH, | 166 | .md_size = SHA256_DIGEST_LENGTH, |
| 181 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 167 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 182 | .init = init256, | 168 | .init = init256, |
| 183 | .update = update256, | 169 | .update = update256, |
| 184 | .final = final256, | 170 | .final = final256, |
| 185 | .copy = NULL, | 171 | .copy = NULL, |
| 186 | .cleanup = NULL, | 172 | .cleanup = NULL, |
| 187 | #ifndef OPENSSL_NO_RSA | ||
| 188 | .sign = (evp_sign_method *)RSA_sign, | ||
| 189 | .verify = (evp_verify_method *)RSA_verify, | ||
| 190 | .required_pkey_type = { | ||
| 191 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 192 | }, | ||
| 193 | #endif | ||
| 194 | .block_size = SHA256_CBLOCK, | 173 | .block_size = SHA256_CBLOCK, |
| 195 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), | 174 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA256_CTX), |
| 196 | }; | 175 | }; |
| @@ -231,19 +210,12 @@ static const EVP_MD sha384_md = { | |||
| 231 | .type = NID_sha384, | 210 | .type = NID_sha384, |
| 232 | .pkey_type = NID_sha384WithRSAEncryption, | 211 | .pkey_type = NID_sha384WithRSAEncryption, |
| 233 | .md_size = SHA384_DIGEST_LENGTH, | 212 | .md_size = SHA384_DIGEST_LENGTH, |
| 234 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 213 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 235 | .init = init384, | 214 | .init = init384, |
| 236 | .update = update512, | 215 | .update = update512, |
| 237 | .final = final512, | 216 | .final = final512, |
| 238 | .copy = NULL, | 217 | .copy = NULL, |
| 239 | .cleanup = NULL, | 218 | .cleanup = NULL, |
| 240 | #ifndef OPENSSL_NO_RSA | ||
| 241 | .sign = (evp_sign_method *)RSA_sign, | ||
| 242 | .verify = (evp_verify_method *)RSA_verify, | ||
| 243 | .required_pkey_type = { | ||
| 244 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 245 | }, | ||
| 246 | #endif | ||
| 247 | .block_size = SHA512_CBLOCK, | 219 | .block_size = SHA512_CBLOCK, |
| 248 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), | 220 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), |
| 249 | }; | 221 | }; |
| @@ -258,19 +230,12 @@ static const EVP_MD sha512_md = { | |||
| 258 | .type = NID_sha512, | 230 | .type = NID_sha512, |
| 259 | .pkey_type = NID_sha512WithRSAEncryption, | 231 | .pkey_type = NID_sha512WithRSAEncryption, |
| 260 | .md_size = SHA512_DIGEST_LENGTH, | 232 | .md_size = SHA512_DIGEST_LENGTH, |
| 261 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 233 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 262 | .init = init512, | 234 | .init = init512, |
| 263 | .update = update512, | 235 | .update = update512, |
| 264 | .final = final512, | 236 | .final = final512, |
| 265 | .copy = NULL, | 237 | .copy = NULL, |
| 266 | .cleanup = NULL, | 238 | .cleanup = NULL, |
| 267 | #ifndef OPENSSL_NO_RSA | ||
| 268 | .sign = (evp_sign_method *)RSA_sign, | ||
| 269 | .verify = (evp_verify_method *)RSA_verify, | ||
| 270 | .required_pkey_type = { | ||
| 271 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 272 | }, | ||
| 273 | #endif | ||
| 274 | .block_size = SHA512_CBLOCK, | 239 | .block_size = SHA512_CBLOCK, |
| 275 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), | 240 | .ctx_size = sizeof(EVP_MD *) + sizeof(SHA512_CTX), |
| 276 | }; | 241 | }; |
diff --git a/src/lib/libcrypto/evp/m_sm3.c b/src/lib/libcrypto/evp/m_sm3.c index 614be5d780..ae8b342e82 100644 --- a/src/lib/libcrypto/evp/m_sm3.c +++ b/src/lib/libcrypto/evp/m_sm3.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_sm3.c,v 1.2 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_sm3.c,v 1.3 2022/01/14 08:38:06 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018, Ribose Inc | 3 | * Copyright (c) 2018, Ribose Inc |
| 4 | * | 4 | * |
| @@ -49,19 +49,12 @@ static const EVP_MD sm3_md = { | |||
| 49 | .type = NID_sm3, | 49 | .type = NID_sm3, |
| 50 | .pkey_type = NID_sm3WithRSAEncryption, | 50 | .pkey_type = NID_sm3WithRSAEncryption, |
| 51 | .md_size = SM3_DIGEST_LENGTH, | 51 | .md_size = SM3_DIGEST_LENGTH, |
| 52 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 52 | .flags = EVP_MD_FLAG_DIGALGID_ABSENT, |
| 53 | .init = sm3_init, | 53 | .init = sm3_init, |
| 54 | .update = sm3_update, | 54 | .update = sm3_update, |
| 55 | .final = sm3_final, | 55 | .final = sm3_final, |
| 56 | .copy = NULL, | 56 | .copy = NULL, |
| 57 | .cleanup = NULL, | 57 | .cleanup = NULL, |
| 58 | #ifndef OPENSSL_NO_RSA | ||
| 59 | .sign = (evp_sign_method *)RSA_sign, | ||
| 60 | .verify = (evp_verify_method *)RSA_verify, | ||
| 61 | .required_pkey_type = { | ||
| 62 | EVP_PKEY_RSA, EVP_PKEY_RSA2, 0, 0, | ||
| 63 | }, | ||
| 64 | #endif | ||
| 65 | .block_size = SM3_CBLOCK, | 58 | .block_size = SM3_CBLOCK, |
| 66 | .ctx_size = sizeof(EVP_MD *) + sizeof(SM3_CTX), | 59 | .ctx_size = sizeof(EVP_MD *) + sizeof(SM3_CTX), |
| 67 | }; | 60 | }; |
diff --git a/src/lib/libcrypto/evp/m_streebog.c b/src/lib/libcrypto/evp/m_streebog.c index cd6c312b02..3f825e3a0e 100644 --- a/src/lib/libcrypto/evp/m_streebog.c +++ b/src/lib/libcrypto/evp/m_streebog.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_streebog.c,v 1.3 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_streebog.c,v 1.4 2022/01/14 08:38:06 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
| 4 | * Copyright (c) 2005-2006 Cryptocom LTD | 4 | * Copyright (c) 2005-2006 Cryptocom LTD |
| @@ -99,7 +99,7 @@ static const EVP_MD streebog256_md = { | |||
| 99 | .type = NID_id_tc26_gost3411_2012_256, | 99 | .type = NID_id_tc26_gost3411_2012_256, |
| 100 | .pkey_type = NID_undef, | 100 | .pkey_type = NID_undef, |
| 101 | .md_size = STREEBOG256_LENGTH, | 101 | .md_size = STREEBOG256_LENGTH, |
| 102 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE, | 102 | .flags = 0, |
| 103 | .init = streebog_init256, | 103 | .init = streebog_init256, |
| 104 | .update = streebog_update256, | 104 | .update = streebog_update256, |
| 105 | .final = streebog_final256, | 105 | .final = streebog_final256, |
| @@ -111,7 +111,7 @@ static const EVP_MD streebog512_md = { | |||
| 111 | .type = NID_id_tc26_gost3411_2012_512, | 111 | .type = NID_id_tc26_gost3411_2012_512, |
| 112 | .pkey_type = NID_undef, | 112 | .pkey_type = NID_undef, |
| 113 | .md_size = STREEBOG512_LENGTH, | 113 | .md_size = STREEBOG512_LENGTH, |
| 114 | .flags = EVP_MD_FLAG_PKEY_METHOD_SIGNATURE, | 114 | .flags = 0, |
| 115 | .init = streebog_init512, | 115 | .init = streebog_init512, |
| 116 | .update = streebog_update512, | 116 | .update = streebog_update512, |
| 117 | .final = streebog_final512, | 117 | .final = streebog_final512, |
diff --git a/src/lib/libcrypto/evp/m_wp.c b/src/lib/libcrypto/evp/m_wp.c index dd777565cf..07ae7ca551 100644 --- a/src/lib/libcrypto/evp/m_wp.c +++ b/src/lib/libcrypto/evp/m_wp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: m_wp.c,v 1.9 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: m_wp.c,v 1.10 2022/01/14 08:38:06 tb Exp $ */ |
| 2 | 2 | ||
| 3 | #include <stdio.h> | 3 | #include <stdio.h> |
| 4 | 4 | ||
| @@ -41,11 +41,6 @@ static const EVP_MD whirlpool_md = { | |||
| 41 | .final = final, | 41 | .final = final, |
| 42 | .copy = NULL, | 42 | .copy = NULL, |
| 43 | .cleanup = NULL, | 43 | .cleanup = NULL, |
| 44 | .sign = NULL, | ||
| 45 | .verify = NULL, | ||
| 46 | .required_pkey_type = { | ||
| 47 | 0, 0, 0, 0, | ||
| 48 | }, | ||
| 49 | .block_size = WHIRLPOOL_BBLOCK / 8, | 44 | .block_size = WHIRLPOOL_BBLOCK / 8, |
| 50 | .ctx_size = sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX), | 45 | .ctx_size = sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX), |
| 51 | }; | 46 | }; |
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c index 34dafd87fe..1e33cfbe7f 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.15 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: p_sign.c,v 1.16 2022/01/14 08:38:06 tb 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,9 +71,10 @@ 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 | int i = 0, ok = 0, v; | ||
| 75 | EVP_MD_CTX tmp_ctx; | 74 | EVP_MD_CTX tmp_ctx; |
| 76 | EVP_PKEY_CTX *pkctx = NULL; | 75 | EVP_PKEY_CTX *pkctx = NULL; |
| 76 | size_t sltmp; | ||
| 77 | int ret = 0; | ||
| 77 | 78 | ||
| 78 | *siglen = 0; | 79 | *siglen = 0; |
| 79 | EVP_MD_CTX_init(&tmp_ctx); | 80 | EVP_MD_CTX_init(&tmp_ctx); |
| @@ -83,43 +84,21 @@ EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | |||
| 83 | goto err; | 84 | goto err; |
| 84 | EVP_MD_CTX_cleanup(&tmp_ctx); | 85 | EVP_MD_CTX_cleanup(&tmp_ctx); |
| 85 | 86 | ||
| 86 | if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { | 87 | sltmp = (size_t)EVP_PKEY_size(pkey); |
| 87 | size_t sltmp = (size_t)EVP_PKEY_size(pkey); | ||
| 88 | i = 0; | ||
| 89 | pkctx = EVP_PKEY_CTX_new(pkey, NULL); | ||
| 90 | if (!pkctx) | ||
| 91 | goto err; | ||
| 92 | if (EVP_PKEY_sign_init(pkctx) <= 0) | ||
| 93 | goto err; | ||
| 94 | if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) | ||
| 95 | goto err; | ||
| 96 | if (EVP_PKEY_sign(pkctx, sigret, &sltmp, m, m_len) <= 0) | ||
| 97 | goto err; | ||
| 98 | *siglen = sltmp; | ||
| 99 | i = 1; | ||
| 100 | err: | ||
| 101 | EVP_PKEY_CTX_free(pkctx); | ||
| 102 | return i; | ||
| 103 | } | ||
| 104 | 88 | ||
| 105 | for (i = 0; i < 4; i++) { | 89 | if ((pkctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL) |
| 106 | v = ctx->digest->required_pkey_type[i]; | 90 | goto err; |
| 107 | if (v == 0) | 91 | if (EVP_PKEY_sign_init(pkctx) <= 0) |
| 108 | break; | 92 | goto err; |
| 109 | if (pkey->type == v) { | 93 | if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) |
| 110 | ok = 1; | 94 | goto err; |
| 111 | break; | 95 | if (EVP_PKEY_sign(pkctx, sigret, &sltmp, m, m_len) <= 0) |
| 112 | } | 96 | goto err; |
| 113 | } | 97 | *siglen = sltmp; |
| 114 | if (!ok) { | 98 | |
| 115 | EVPerror(EVP_R_WRONG_PUBLIC_KEY_TYPE); | 99 | ret = 1; |
| 116 | return (0); | ||
| 117 | } | ||
| 118 | 100 | ||
| 119 | if (ctx->digest->sign == NULL) { | 101 | err: |
| 120 | EVPerror(EVP_R_NO_SIGN_FUNCTION_CONFIGURED); | 102 | EVP_PKEY_CTX_free(pkctx); |
| 121 | return (0); | 103 | return ret; |
| 122 | } | ||
| 123 | return(ctx->digest->sign(ctx->digest->type, m, m_len, sigret, siglen, | ||
| 124 | pkey->pkey.ptr)); | ||
| 125 | } | 104 | } |
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c index 6ecdef0787..d51d1b4a0a 100644 --- a/src/lib/libcrypto/evp/p_verify.c +++ b/src/lib/libcrypto/evp/p_verify.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: p_verify.c,v 1.14 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: p_verify.c,v 1.15 2022/01/14 08:38:06 tb 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,9 +71,9 @@ EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, | |||
| 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 | int i = 0, ok = 0, v; | ||
| 75 | EVP_MD_CTX tmp_ctx; | 74 | EVP_MD_CTX tmp_ctx; |
| 76 | EVP_PKEY_CTX *pkctx = NULL; | 75 | EVP_PKEY_CTX *pkctx = NULL; |
| 76 | int ret = 0; | ||
| 77 | 77 | ||
| 78 | EVP_MD_CTX_init(&tmp_ctx); | 78 | EVP_MD_CTX_init(&tmp_ctx); |
| 79 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) | 79 | if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) |
| @@ -82,39 +82,16 @@ EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, | |||
| 82 | goto err; | 82 | goto err; |
| 83 | EVP_MD_CTX_cleanup(&tmp_ctx); | 83 | EVP_MD_CTX_cleanup(&tmp_ctx); |
| 84 | 84 | ||
| 85 | if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) { | 85 | ret = -1; |
| 86 | i = -1; | 86 | if ((pkctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL) |
| 87 | pkctx = EVP_PKEY_CTX_new(pkey, NULL); | 87 | goto err; |
| 88 | if (!pkctx) | 88 | if (EVP_PKEY_verify_init(pkctx) <= 0) |
| 89 | goto err; | 89 | goto err; |
| 90 | if (EVP_PKEY_verify_init(pkctx) <= 0) | 90 | if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) |
| 91 | goto err; | 91 | goto err; |
| 92 | if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0) | 92 | ret = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len); |
| 93 | goto err; | ||
| 94 | i = EVP_PKEY_verify(pkctx, sigbuf, siglen, m, m_len); | ||
| 95 | err: | ||
| 96 | EVP_PKEY_CTX_free(pkctx); | ||
| 97 | return i; | ||
| 98 | } | ||
| 99 | |||
| 100 | for (i = 0; i < 4; i++) { | ||
| 101 | v = ctx->digest->required_pkey_type[i]; | ||
| 102 | if (v == 0) | ||
| 103 | break; | ||
| 104 | if (pkey->type == v) { | ||
| 105 | ok = 1; | ||
| 106 | break; | ||
| 107 | } | ||
| 108 | } | ||
| 109 | if (!ok) { | ||
| 110 | EVPerror(EVP_R_WRONG_PUBLIC_KEY_TYPE); | ||
| 111 | return (-1); | ||
| 112 | } | ||
| 113 | if (ctx->digest->verify == NULL) { | ||
| 114 | EVPerror(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); | ||
| 115 | return (0); | ||
| 116 | } | ||
| 117 | 93 | ||
| 118 | return(ctx->digest->verify(ctx->digest->type, m, m_len, | 94 | err: |
| 119 | sigbuf, siglen, pkey->pkey.ptr)); | 95 | EVP_PKEY_CTX_free(pkctx); |
| 96 | return ret; | ||
| 120 | } | 97 | } |
