summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-04-25 15:48:48 +0000
committertb <>2023-04-25 15:48:48 +0000
commitaa06ff6ff84baafcac76b48d7a0dcd4f9d00d7d2 (patch)
tree8fc6489b768abe5eb7eafc75ed8631756451a226
parent9670fcb7ce8b0f516e7924baa6167b992630dc77 (diff)
downloadopenbsd-aa06ff6ff84baafcac76b48d7a0dcd4f9d00d7d2.tar.gz
openbsd-aa06ff6ff84baafcac76b48d7a0dcd4f9d00d7d2.tar.bz2
openbsd-aa06ff6ff84baafcac76b48d7a0dcd4f9d00d7d2.zip
Wire up truncated SHA-2, SHA-3 and related things
from jsing
-rw-r--r--src/lib/libcrypto/dsa/dsa_pmeth.c7
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c9
-rw-r--r--src/lib/libcrypto/evp/c_all.c10
-rw-r--r--src/lib/libcrypto/hmac/hmac.h4
-rw-r--r--src/lib/libcrypto/rsa/rsa_pmeth.c9
5 files changed, 32 insertions, 7 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c
index 66f4ddbe38..9b03a2fc3a 100644
--- a/src/lib/libcrypto/dsa/dsa_pmeth.c
+++ b/src/lib/libcrypto/dsa/dsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_pmeth.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: dsa_pmeth.c,v 1.17 2023/04/25 15:48:48 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 2006. 3 * project 2006.
4 */ 4 */
@@ -203,6 +203,7 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
203 return 1; 203 return 1;
204 204
205 case EVP_PKEY_CTRL_MD: 205 case EVP_PKEY_CTRL_MD:
206 /* ANSI X9.57 and NIST CSOR. */
206 switch (EVP_MD_type((const EVP_MD *)p2)) { 207 switch (EVP_MD_type((const EVP_MD *)p2)) {
207 case NID_sha1: 208 case NID_sha1:
208 case NID_dsa: 209 case NID_dsa:
@@ -211,6 +212,10 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
211 case NID_sha256: 212 case NID_sha256:
212 case NID_sha384: 213 case NID_sha384:
213 case NID_sha512: 214 case NID_sha512:
215 case NID_sha3_224:
216 case NID_sha3_256:
217 case NID_sha3_384:
218 case NID_sha3_512:
214 break; 219 break;
215 default: 220 default:
216 DSAerror(DSA_R_INVALID_DIGEST_TYPE); 221 DSAerror(DSA_R_INVALID_DIGEST_TYPE);
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 9582224037..d1bb52d9ed 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.17 2023/04/25 15:48:48 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 2006. 3 * project 2006.
4 */ 4 */
@@ -381,12 +381,17 @@ pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
381 return dctx->kdf_ukmlen; 381 return dctx->kdf_ukmlen;
382 382
383 case EVP_PKEY_CTRL_MD: 383 case EVP_PKEY_CTRL_MD:
384 /* RFC 3279, RFC 5758 and NIST CSOR. */
384 if (EVP_MD_type((const EVP_MD *) p2) != NID_sha1 && 385 if (EVP_MD_type((const EVP_MD *) p2) != NID_sha1 &&
385 EVP_MD_type((const EVP_MD *) p2) != NID_ecdsa_with_SHA1 && 386 EVP_MD_type((const EVP_MD *) p2) != NID_ecdsa_with_SHA1 &&
386 EVP_MD_type((const EVP_MD *) p2) != NID_sha224 && 387 EVP_MD_type((const EVP_MD *) p2) != NID_sha224 &&
387 EVP_MD_type((const EVP_MD *) p2) != NID_sha256 && 388 EVP_MD_type((const EVP_MD *) p2) != NID_sha256 &&
388 EVP_MD_type((const EVP_MD *) p2) != NID_sha384 && 389 EVP_MD_type((const EVP_MD *) p2) != NID_sha384 &&
389 EVP_MD_type((const EVP_MD *) p2) != NID_sha512) { 390 EVP_MD_type((const EVP_MD *) p2) != NID_sha512 &&
391 EVP_MD_type((const EVP_MD *) p2) != NID_sha3_224 &&
392 EVP_MD_type((const EVP_MD *) p2) != NID_sha3_256 &&
393 EVP_MD_type((const EVP_MD *) p2) != NID_sha3_384 &&
394 EVP_MD_type((const EVP_MD *) p2) != NID_sha3_512) {
390 ECerror(EC_R_INVALID_DIGEST_TYPE); 395 ECerror(EC_R_INVALID_DIGEST_TYPE);
391 return 0; 396 return 0;
392 } 397 }
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c
index 8fc1aa6a17..936d7e810f 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.28 2022/10/21 13:39:35 tb Exp $ */ 1/* $OpenBSD: c_all.c,v 1.29 2023/04/25 15:48:48 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 *
@@ -290,6 +290,14 @@ OpenSSL_add_all_digests_internal(void)
290#ifndef OPENSSL_NO_SHA512 290#ifndef OPENSSL_NO_SHA512
291 EVP_add_digest(EVP_sha384()); 291 EVP_add_digest(EVP_sha384());
292 EVP_add_digest(EVP_sha512()); 292 EVP_add_digest(EVP_sha512());
293 EVP_add_digest(EVP_sha512_224());
294 EVP_add_digest(EVP_sha512_256());
295#endif
296#ifndef OPENSSL_NO_SHA3
297 EVP_add_digest(EVP_sha3_224());
298 EVP_add_digest(EVP_sha3_256());
299 EVP_add_digest(EVP_sha3_384());
300 EVP_add_digest(EVP_sha3_512());
293#endif 301#endif
294#ifndef OPENSSL_NO_SM3 302#ifndef OPENSSL_NO_SM3
295 EVP_add_digest(EVP_sm3()); 303 EVP_add_digest(EVP_sm3());
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h
index ff01ae26b0..1ce365294c 100644
--- a/src/lib/libcrypto/hmac/hmac.h
+++ b/src/lib/libcrypto/hmac/hmac.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: hmac.h,v 1.16 2022/01/14 08:06:03 tb Exp $ */ 1/* $OpenBSD: hmac.h,v 1.17 2023/04/25 15:48:48 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 *
@@ -66,7 +66,7 @@
66 66
67#include <openssl/evp.h> 67#include <openssl/evp.h>
68 68
69#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */ 69#define HMAC_MAX_MD_CBLOCK 144 /* largest known is SHA3-224 */
70 70
71#ifdef __cplusplus 71#ifdef __cplusplus
72extern "C" { 72extern "C" {
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c
index 688c0d64db..8e06365566 100644
--- a/src/lib/libcrypto/rsa/rsa_pmeth.c
+++ b/src/lib/libcrypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_pmeth.c,v 1.36 2023/04/15 18:48:52 tb Exp $ */ 1/* $OpenBSD: rsa_pmeth.c,v 1.37 2023/04/25 15:48:48 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 2006. 3 * project 2006.
4 */ 4 */
@@ -371,12 +371,19 @@ check_padding_md(const EVP_MD *md, int padding)
371 } 371 }
372 372
373 /* List of all supported RSA digests. */ 373 /* List of all supported RSA digests. */
374 /* RFC 8017 and NIST CSOR. */
374 switch(EVP_MD_type(md)) { 375 switch(EVP_MD_type(md)) {
375 case NID_sha1: 376 case NID_sha1:
376 case NID_sha224: 377 case NID_sha224:
377 case NID_sha256: 378 case NID_sha256:
378 case NID_sha384: 379 case NID_sha384:
379 case NID_sha512: 380 case NID_sha512:
381 case NID_sha512_224:
382 case NID_sha512_256:
383 case NID_sha3_224:
384 case NID_sha3_256:
385 case NID_sha3_384:
386 case NID_sha3_512:
380 case NID_md5: 387 case NID_md5:
381 case NID_md5_sha1: 388 case NID_md5_sha1:
382 case NID_md4: 389 case NID_md4: