Mon Mar 25 14:14:56 2024 UTC (55d)
Pull up following revision(s) (requested by riastradh in ticket #637):
crypto/external/bsd/openssl/dist/providers/implementations/digests/sha2_prov.c: revision 1.2
tests/crypto/libcrypto/t_sha512trunc.c: revision 1.1
tests/crypto/libcrypto/t_sha512trunc.c: revision 1.2
tests/crypto/libcrypto/Makefile: revision 1.16
distrib/sets/lists/tests/mi: revision 1.1311
crypto/external/bsd/openssl/dist/crypto/evp/legacy_sha.c: revision 1.2
distrib/sets/lists/debug/mi: revision 1.430
crypto/external/bsd/openssl/dist/include/crypto/sha.h: revision 1.2
crypto/external/bsd/openssl/lib/libcrypto/libc-sha2xx.c: revision 1.4
libcrypto: Add some trivial tests for truncated SHA-512 variants.
These should use more of the test vectors from
https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing#Testing
but this will do for now to detect the buffer overrun rake we left
lying around for ourselves.
PR lib/58039
libcrypto: Fix buffer overrun in truncated SHA-512 functions.
Further fallout from the libc/openssl sha2 symbol collision.
PR lib/58039
(martin)
diff -r1.1.1.1.2.3 -r1.1.1.1.2.4 src/crypto/external/bsd/openssl/dist/crypto/evp/legacy_sha.c
diff -r1.1.1.1.10.1 -r1.1.1.1.10.2 src/crypto/external/bsd/openssl/dist/include/crypto/sha.h
diff -r1.1.1.1.2.2 -r1.1.1.1.2.3 src/crypto/external/bsd/openssl/dist/providers/implementations/digests/sha2_prov.c
diff -r1.2.6.1 -r1.2.6.2 src/crypto/external/bsd/openssl/lib/libcrypto/libc-sha2xx.c
diff -r1.394.2.5 -r1.394.2.6 src/distrib/sets/lists/debug/mi
diff -r1.1238.2.5 -r1.1238.2.6 src/distrib/sets/lists/tests/mi
diff -r1.14.10.1 -r1.14.10.2 src/tests/crypto/libcrypto/Makefile
diff -r0 -r1.2.2.2 src/tests/crypto/libcrypto/t_sha512trunc.c
--- src/crypto/external/bsd/openssl/dist/crypto/evp/legacy_sha.c 2023/11/02 19:32:10 1.1.1.1.2.3
+++ src/crypto/external/bsd/openssl/dist/crypto/evp/legacy_sha.c 2024/03/25 14:14:55 1.1.1.1.2.4
| @@ -39,29 +39,29 @@ static int nm##_final(EVP_MD_CTX *ctx, u | | | @@ -39,29 +39,29 @@ static int nm##_final(EVP_MD_CTX *ctx, u |
39 | { \ | | 39 | { \ |
40 | return fn##_final(md, EVP_MD_CTX_get0_md_data(ctx)); \ | | 40 | return fn##_final(md, EVP_MD_CTX_get0_md_data(ctx)); \ |
41 | } | | 41 | } |
42 | #define IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(nm, fn, tag) \ | | 42 | #define IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(nm, fn, tag) \ |
43 | static int nm##_init(EVP_MD_CTX *ctx) \ | | 43 | static int nm##_init(EVP_MD_CTX *ctx) \ |
44 | { \ | | 44 | { \ |
45 | return fn##_init(EVP_MD_CTX_get0_md_data(ctx), tag, ctx->digest->md_size * 8); \ | | 45 | return fn##_init(EVP_MD_CTX_get0_md_data(ctx), tag, ctx->digest->md_size * 8); \ |
46 | } \ | | 46 | } \ |
47 | | | 47 | |
48 | #define sha512_224_Init sha512_224_init | | 48 | #define sha512_224_Init sha512_224_init |
49 | #define sha512_256_Init sha512_256_init | | 49 | #define sha512_256_Init sha512_256_init |
50 | | | 50 | |
51 | #define sha512_224_Update SHA512_Update | | 51 | #define sha512_224_Update SHA512_Update |
52 | #define sha512_224_Final SHA512_Final | | 52 | #define sha512_224_Final sha512_224_final /* XXX NetBSD libc sha2 */ |
53 | #define sha512_256_Update SHA512_Update | | 53 | #define sha512_256_Update SHA512_Update |
54 | #define sha512_256_Final SHA512_Final | | 54 | #define sha512_256_Final sha512_256_final /* XXX NetBSD libc sha2 */ |
55 | | | 55 | |
56 | IMPLEMENT_LEGACY_EVP_MD_METH(sha1, SHA1) | | 56 | IMPLEMENT_LEGACY_EVP_MD_METH(sha1, SHA1) |
57 | IMPLEMENT_LEGACY_EVP_MD_METH(sha224, SHA224) | | 57 | IMPLEMENT_LEGACY_EVP_MD_METH(sha224, SHA224) |
58 | IMPLEMENT_LEGACY_EVP_MD_METH(sha256, SHA256) | | 58 | IMPLEMENT_LEGACY_EVP_MD_METH(sha256, SHA256) |
59 | IMPLEMENT_LEGACY_EVP_MD_METH(sha384, SHA384) | | 59 | IMPLEMENT_LEGACY_EVP_MD_METH(sha384, SHA384) |
60 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512, SHA512) | | 60 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512, SHA512) |
61 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512_224_int, sha512_224) | | 61 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512_224_int, sha512_224) |
62 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512_256_int, sha512_256) | | 62 | IMPLEMENT_LEGACY_EVP_MD_METH(sha512_256_int, sha512_256) |
63 | IMPLEMENT_LEGACY_EVP_MD_METH_SHA3(sha3_int, ossl_sha3, '\x06') | | 63 | IMPLEMENT_LEGACY_EVP_MD_METH_SHA3(sha3_int, ossl_sha3, '\x06') |
64 | IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(shake, ossl_sha3, '\x1f') | | 64 | IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(shake, ossl_sha3, '\x1f') |
65 | | | 65 | |
66 | static int sha1_int_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) | | 66 | static int sha1_int_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) |
67 | { | | 67 | { |
--- src/crypto/external/bsd/openssl/dist/include/crypto/sha.h 2023/08/11 13:41:10 1.1.1.1.10.1
+++ src/crypto/external/bsd/openssl/dist/include/crypto/sha.h 2024/03/25 14:14:56 1.1.1.1.10.2
| @@ -6,17 +6,19 @@ | | | @@ -6,17 +6,19 @@ |
6 | * this file except in compliance with the License. You can obtain a copy | | 6 | * this file except in compliance with the License. You can obtain a copy |
7 | * in the file LICENSE in the source distribution or at | | 7 | * in the file LICENSE in the source distribution or at |
8 | * https://www.openssl.org/source/license.html | | 8 | * https://www.openssl.org/source/license.html |
9 | */ | | 9 | */ |
10 | | | 10 | |
11 | #ifndef OSSL_CRYPTO_SHA_H | | 11 | #ifndef OSSL_CRYPTO_SHA_H |
12 | # define OSSL_CRYPTO_SHA_H | | 12 | # define OSSL_CRYPTO_SHA_H |
13 | # pragma once | | 13 | # pragma once |
14 | | | 14 | |
15 | # include <openssl/sha.h> | | 15 | # include <openssl/sha.h> |
16 | | | 16 | |
17 | int sha512_224_init(SHA512_CTX *); | | 17 | int sha512_224_init(SHA512_CTX *); |
18 | int sha512_256_init(SHA512_CTX *); | | 18 | int sha512_256_init(SHA512_CTX *); |
| | | 19 | int sha512_224_final(unsigned char *, SHA512_CTX *); /* XXX NetBSD libc sha2 */ |
| | | 20 | int sha512_256_final(unsigned char *, SHA512_CTX *); /* XXX NetBSD libc sha2 */ |
19 | int ossl_sha1_ctrl(SHA_CTX *ctx, int cmd, int mslen, void *ms); | | 21 | int ossl_sha1_ctrl(SHA_CTX *ctx, int cmd, int mslen, void *ms); |
20 | unsigned char *ossl_sha1(const unsigned char *d, size_t n, unsigned char *md); | | 22 | unsigned char *ossl_sha1(const unsigned char *d, size_t n, unsigned char *md); |
21 | | | 23 | |
22 | #endif | | 24 | #endif |
--- src/crypto/external/bsd/openssl/dist/providers/implementations/digests/sha2_prov.c 2023/08/11 13:41:18 1.1.1.1.2.2
+++ src/crypto/external/bsd/openssl/dist/providers/implementations/digests/sha2_prov.c 2024/03/25 14:14:54 1.1.1.1.2.3
| @@ -76,20 +76,22 @@ IMPLEMENT_digest_functions(sha256, SHA25 | | | @@ -76,20 +76,22 @@ IMPLEMENT_digest_functions(sha256, SHA25 |
76 | /* ossl_sha384_functions */ | | 76 | /* ossl_sha384_functions */ |
77 | IMPLEMENT_digest_functions(sha384, SHA512_CTX, | | 77 | IMPLEMENT_digest_functions(sha384, SHA512_CTX, |
78 | SHA512_CBLOCK, SHA384_DIGEST_LENGTH, SHA2_FLAGS, | | 78 | SHA512_CBLOCK, SHA384_DIGEST_LENGTH, SHA2_FLAGS, |
79 | SHA384_Init, SHA384_Update, SHA384_Final) | | 79 | SHA384_Init, SHA384_Update, SHA384_Final) |
80 | | | 80 | |
81 | /* ossl_sha512_functions */ | | 81 | /* ossl_sha512_functions */ |
82 | IMPLEMENT_digest_functions(sha512, SHA512_CTX, | | 82 | IMPLEMENT_digest_functions(sha512, SHA512_CTX, |
83 | SHA512_CBLOCK, SHA512_DIGEST_LENGTH, SHA2_FLAGS, | | 83 | SHA512_CBLOCK, SHA512_DIGEST_LENGTH, SHA2_FLAGS, |
84 | SHA512_Init, SHA512_Update, SHA512_Final) | | 84 | SHA512_Init, SHA512_Update, SHA512_Final) |
85 | | | 85 | |
86 | /* ossl_sha512_224_functions */ | | 86 | /* ossl_sha512_224_functions */ |
87 | IMPLEMENT_digest_functions(sha512_224, SHA512_CTX, | | 87 | IMPLEMENT_digest_functions(sha512_224, SHA512_CTX, |
88 | SHA512_CBLOCK, SHA224_DIGEST_LENGTH, SHA2_FLAGS, | | 88 | SHA512_CBLOCK, SHA224_DIGEST_LENGTH, SHA2_FLAGS, |
89 | sha512_224_init, SHA512_Update, SHA512_Final) | | 89 | sha512_224_init, SHA512_Update, |
| | | 90 | /* XXX NetBSD libc sha2 */sha512_224_final) |
90 | | | 91 | |
91 | /* ossl_sha512_256_functions */ | | 92 | /* ossl_sha512_256_functions */ |
92 | IMPLEMENT_digest_functions(sha512_256, SHA512_CTX, | | 93 | IMPLEMENT_digest_functions(sha512_256, SHA512_CTX, |
93 | SHA512_CBLOCK, SHA256_DIGEST_LENGTH, SHA2_FLAGS, | | 94 | SHA512_CBLOCK, SHA256_DIGEST_LENGTH, SHA2_FLAGS, |
94 | sha512_256_init, SHA512_Update, SHA512_Final) | | 95 | sha512_256_init, SHA512_Update, |
| | | 96 | /* XXX NetBSD libc sha2 */sha512_256_final) |
95 | | | 97 | |
--- src/crypto/external/bsd/openssl/lib/libcrypto/libc-sha2xx.c 2023/08/11 13:41:55 1.2.6.1
+++ src/crypto/external/bsd/openssl/lib/libcrypto/libc-sha2xx.c 2024/03/25 14:14:56 1.2.6.2
| @@ -37,27 +37,54 @@ sha512_224_init(SHA512_CTX *context) | | | @@ -37,27 +37,54 @@ sha512_224_init(SHA512_CTX *context) |
37 | if (context == NULL) | | 37 | if (context == NULL) |
38 | return 1; | | 38 | return 1; |
39 | | | 39 | |
40 | memcpy(context->state, sha512_224_initial_hash_value, | | 40 | memcpy(context->state, sha512_224_initial_hash_value, |
41 | (size_t)(SHA512_DIGEST_LENGTH)); | | 41 | (size_t)(SHA512_DIGEST_LENGTH)); |
42 | memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH)); | | 42 | memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH)); |
43 | context->bitcount[0] = context->bitcount[1] = 0; | | 43 | context->bitcount[0] = context->bitcount[1] = 0; |
44 | | | 44 | |
45 | return 1; | | 45 | return 1; |
46 | | | 46 | |
47 | } | | 47 | } |
48 | | | 48 | |
49 | extern int | | 49 | extern int |
| | | 50 | sha512_224_final(unsigned char *md, SHA512_CTX *context); |
| | | 51 | int |
| | | 52 | sha512_224_final(unsigned char *md, SHA512_CTX *context) |
| | | 53 | { |
| | | 54 | unsigned char tmp[64]; |
| | | 55 | |
| | | 56 | SHA512_Final(tmp, context); |
| | | 57 | memcpy(md, tmp, 28); |
| | | 58 | explicit_memset(tmp, 0, sizeof(tmp)); |
| | | 59 | return 1; |
| | | 60 | |
| | | 61 | } |
| | | 62 | |
| | | 63 | extern int |
50 | sha512_256_init(SHA512_CTX *context); | | 64 | sha512_256_init(SHA512_CTX *context); |
51 | int | | 65 | int |
52 | sha512_256_init(SHA512_CTX *context) | | 66 | sha512_256_init(SHA512_CTX *context) |
53 | { | | 67 | { |
54 | if (context == NULL) | | 68 | if (context == NULL) |
55 | return 1; | | 69 | return 1; |
56 | | | 70 | |
57 | memcpy(context->state, sha512_256_initial_hash_value, | | 71 | memcpy(context->state, sha512_256_initial_hash_value, |
58 | (size_t)(SHA512_DIGEST_LENGTH)); | | 72 | (size_t)(SHA512_DIGEST_LENGTH)); |
59 | memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH)); | | 73 | memset(context->buffer, 0, (size_t)(SHA512_BLOCK_LENGTH)); |
60 | context->bitcount[0] = context->bitcount[1] = 0; | | 74 | context->bitcount[0] = context->bitcount[1] = 0; |
61 | | | 75 | |
62 | return 1; | | 76 | return 1; |
63 | } | | 77 | } |
| | | 78 | |
| | | 79 | extern int |
| | | 80 | sha512_256_final(unsigned char *md, SHA512_CTX *context); |
| | | 81 | int |
| | | 82 | sha512_256_final(unsigned char *md, SHA512_CTX *context) |
| | | 83 | { |
| | | 84 | unsigned char tmp[64]; |
| | | 85 | |
| | | 86 | SHA512_Final(tmp, context); |
| | | 87 | memcpy(md, tmp, 32); |
| | | 88 | explicit_memset(tmp, 0, sizeof(tmp)); |
| | | 89 | return 1; |
| | | 90 | } |
--- src/distrib/sets/lists/debug/mi 2024/02/25 15:47:59 1.394.2.5
+++ src/distrib/sets/lists/debug/mi 2024/03/25 14:14:55 1.394.2.6
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: mi,v 1.394.2.5 2024/02/25 15:47:59 martin Exp $ | | 1 | # $NetBSD: mi,v 1.394.2.6 2024/03/25 14:14:55 martin Exp $ |
2 | ./etc/mtree/set.debug comp-sys-root | | 2 | ./etc/mtree/set.debug comp-sys-root |
3 | ./usr/lib comp-sys-usr compatdir | | 3 | ./usr/lib comp-sys-usr compatdir |
4 | ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile | | 4 | ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile |
5 | ./usr/lib/i18n/libDECHanyu_g.a comp-c-debuglib debuglib,compatfile | | 5 | ./usr/lib/i18n/libDECHanyu_g.a comp-c-debuglib debuglib,compatfile |
6 | ./usr/lib/i18n/libEUCTW_g.a comp-c-debuglib debuglib,compatfile | | 6 | ./usr/lib/i18n/libEUCTW_g.a comp-c-debuglib debuglib,compatfile |
7 | ./usr/lib/i18n/libEUC_g.a comp-c-debuglib debuglib,compatfile | | 7 | ./usr/lib/i18n/libEUC_g.a comp-c-debuglib debuglib,compatfile |
8 | ./usr/lib/i18n/libGBK2K_g.a comp-c-debuglib debuglib,compatfile | | 8 | ./usr/lib/i18n/libGBK2K_g.a comp-c-debuglib debuglib,compatfile |
9 | ./usr/lib/i18n/libHZ_g.a comp-c-debuglib debuglib,compatfile | | 9 | ./usr/lib/i18n/libHZ_g.a comp-c-debuglib debuglib,compatfile |
10 | ./usr/lib/i18n/libISO2022_g.a comp-c-debuglib debuglib,compatfile | | 10 | ./usr/lib/i18n/libISO2022_g.a comp-c-debuglib debuglib,compatfile |
11 | ./usr/lib/i18n/libJOHAB_g.a comp-c-debuglib debuglib,compatfile | | 11 | ./usr/lib/i18n/libJOHAB_g.a comp-c-debuglib debuglib,compatfile |
12 | ./usr/lib/i18n/libMSKanji_g.a comp-c-debuglib debuglib,compatfile | | 12 | ./usr/lib/i18n/libMSKanji_g.a comp-c-debuglib debuglib,compatfile |
13 | ./usr/lib/i18n/libUES_g.a comp-c-debuglib debuglib,compatfile | | 13 | ./usr/lib/i18n/libUES_g.a comp-c-debuglib debuglib,compatfile |
14 | ./usr/lib/i18n/libUTF1632_g.a comp-c-debuglib debuglib,compatfile | | 14 | ./usr/lib/i18n/libUTF1632_g.a comp-c-debuglib debuglib,compatfile |
| @@ -1644,26 +1644,27 @@ | | | @@ -1644,26 +1644,27 @@ |
1644 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_md5test.debug tests-obsolete obsolete | | 1644 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_md5test.debug tests-obsolete obsolete |
1645 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_mdc2test.debug tests-crypto-debug debug,atf,compattestfile | | 1645 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_mdc2test.debug tests-crypto-debug debug,atf,compattestfile |
1646 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_randtest.debug tests-obsolete obsolete | | 1646 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_randtest.debug tests-obsolete obsolete |
1647 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc2test.debug tests-crypto-debug debug,atf,compattestfile | | 1647 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc2test.debug tests-crypto-debug debug,atf,compattestfile |
1648 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc4test.debug tests-crypto-debug debug,atf,compattestfile | | 1648 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc4test.debug tests-crypto-debug debug,atf,compattestfile |
1649 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc5test.debug tests-crypto-debug debug,atf,compattestfile | | 1649 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rc5test.debug tests-crypto-debug debug,atf,compattestfile |
1650 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_ripemdtest.debug tests-obsolete obsolete | | 1650 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_ripemdtest.debug tests-obsolete obsolete |
1651 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rsatest.debug tests-crypto-debug debug,atf,compattestfile | | 1651 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_rsatest.debug tests-crypto-debug debug,atf,compattestfile |
1652 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_sha1test.debug tests-obsolete obsolete | | 1652 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_sha1test.debug tests-obsolete obsolete |
1653 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_shatest.debug tests-crypto-debug debug,atf,compattestfile,openssl=10 | | 1653 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_shatest.debug tests-crypto-debug debug,atf,compattestfile,openssl=10 |
1654 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_srptest.debug tests-crypto-debug debug,atf,compattestfile | | 1654 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_srptest.debug tests-crypto-debug debug,atf,compattestfile |
1655 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_threadstest.debug tests-crypto-debug debug,atf,compattestfile | | 1655 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_threadstest.debug tests-crypto-debug debug,atf,compattestfile |
1656 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_x509v3test.debug tests-crypto-debug debug,atf,compattestfile,openssl=10 | | 1656 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/h_x509v3test.debug tests-crypto-debug debug,atf,compattestfile,openssl=10 |
| | | 1657 | ./usr/libdata/debug/usr/tests/crypto/libcrypto/t_sha512trunc.debug tests-crypto-debug debug,atf,compattestfile |
1657 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aescbc.debug tests-crypto-debug debug,atf,compattestfile | | 1658 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aescbc.debug tests-crypto-debug debug,atf,compattestfile |
1658 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aesctr1.debug tests-crypto-debug debug,atf,compattestfile | | 1659 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aesctr1.debug tests-crypto-debug debug,atf,compattestfile |
1659 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aesctr2.debug tests-crypto-debug debug,atf,compattestfile | | 1660 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_aesctr2.debug tests-crypto-debug debug,atf,compattestfile |
1660 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_arc4.debug tests-crypto-debug debug,atf,compattestfile | | 1661 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_arc4.debug tests-crypto-debug debug,atf,compattestfile |
1661 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_camellia.debug tests-crypto-debug debug,atf,compattestfile | | 1662 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_camellia.debug tests-crypto-debug debug,atf,compattestfile |
1662 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_cbc3des.debug tests-crypto-debug debug,atf,compattestfile | | 1663 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_cbc3des.debug tests-crypto-debug debug,atf,compattestfile |
1663 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_cbcdes.debug tests-crypto-debug debug,atf,compattestfile | | 1664 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_cbcdes.debug tests-crypto-debug debug,atf,compattestfile |
1664 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp.debug tests-crypto-debug debug,atf,compattestfile | | 1665 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp.debug tests-crypto-debug debug,atf,compattestfile |
1665 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp_zlib.debug tests-crypto-debug debug,atf,compattestfile | | 1666 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp_zlib.debug tests-crypto-debug debug,atf,compattestfile |
1666 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp_zlib_rnd.debug tests-crypto-debug debug,atf,compattestfile | | 1667 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_comp_zlib_rnd.debug tests-crypto-debug debug,atf,compattestfile |
1667 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_gcm.debug tests-crypto-debug debug,atf,compattestfile | | 1668 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_gcm.debug tests-crypto-debug debug,atf,compattestfile |
1668 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_ioctl.debug tests-crypto-debug debug,atf,compattestfile | | 1669 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_ioctl.debug tests-crypto-debug debug,atf,compattestfile |
1669 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_md5.debug tests-crypto-debug debug,atf,compattestfile | | 1670 | ./usr/libdata/debug/usr/tests/crypto/opencrypto/h_md5.debug tests-crypto-debug debug,atf,compattestfile |
--- src/distrib/sets/lists/tests/mi 2023/11/28 13:17:11 1.1238.2.5
+++ src/distrib/sets/lists/tests/mi 2024/03/25 14:14:55 1.1238.2.6
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: mi,v 1.1238.2.5 2023/11/28 13:17:11 martin Exp $ | | 1 | # $NetBSD: mi,v 1.1238.2.6 2024/03/25 14:14:55 martin Exp $ |
2 | # | | 2 | # |
3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | | 3 | # Note: don't delete entries from here - mark them as "obsolete" instead. |
4 | # | | 4 | # |
5 | ./etc/mtree/set.tests tests-sys-root | | 5 | ./etc/mtree/set.tests tests-sys-root |
6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir | | 6 | ./usr/libdata/debug/usr/tests tests-base-debug compattestdir |
7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf | | 7 | ./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf |
8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf | | 8 | ./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf |
9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf | | 9 | ./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf |
10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf | | 10 | ./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf |
11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf | | 11 | ./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf |
12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete | | 12 | ./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete |
13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete | | 13 | ./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete |
14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete | | 14 | ./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete |
| @@ -1455,26 +1455,27 @@ | | | @@ -1455,26 +1455,27 @@ |
1455 | ./usr/tests/crypto/libcrypto/h_shatest comp-obsolete obsolete | | 1455 | ./usr/tests/crypto/libcrypto/h_shatest comp-obsolete obsolete |
1456 | ./usr/tests/crypto/libcrypto/h_shatest tests-crypto-tests compattestfile,atf,openssl=10 | | 1456 | ./usr/tests/crypto/libcrypto/h_shatest tests-crypto-tests compattestfile,atf,openssl=10 |
1457 | ./usr/tests/crypto/libcrypto/h_srptest tests-crypto-tests compattestfile,atf | | 1457 | ./usr/tests/crypto/libcrypto/h_srptest tests-crypto-tests compattestfile,atf |
1458 | ./usr/tests/crypto/libcrypto/h_threadstest tests-crypto-tests compattestfile,atf | | 1458 | ./usr/tests/crypto/libcrypto/h_threadstest tests-crypto-tests compattestfile,atf |
1459 | ./usr/tests/crypto/libcrypto/h_x509v3test comp-obsolete obsolete | | 1459 | ./usr/tests/crypto/libcrypto/h_x509v3test comp-obsolete obsolete |
1460 | ./usr/tests/crypto/libcrypto/h_x509v3test tests-crypto-tests compattestfile,atf,openssl=10 | | 1460 | ./usr/tests/crypto/libcrypto/h_x509v3test tests-crypto-tests compattestfile,atf,openssl=10 |
1461 | ./usr/tests/crypto/libcrypto/rsakey.pem tests-crypto-tests atf,compattestfile,openssl=30 | | 1461 | ./usr/tests/crypto/libcrypto/rsakey.pem tests-crypto-tests atf,compattestfile,openssl=30 |
1462 | ./usr/tests/crypto/libcrypto/t_certs comp-obsolete obsolete | | 1462 | ./usr/tests/crypto/libcrypto/t_certs comp-obsolete obsolete |
1463 | ./usr/tests/crypto/libcrypto/t_certs tests-crypto-tests compattestfile,atf,openssl=10 | | 1463 | ./usr/tests/crypto/libcrypto/t_certs tests-crypto-tests compattestfile,atf,openssl=10 |
1464 | ./usr/tests/crypto/libcrypto/t_ciphers tests-crypto-tests compattestfile,atf | | 1464 | ./usr/tests/crypto/libcrypto/t_ciphers tests-crypto-tests compattestfile,atf |
1465 | ./usr/tests/crypto/libcrypto/t_hashes tests-crypto-tests compattestfile,atf | | 1465 | ./usr/tests/crypto/libcrypto/t_hashes tests-crypto-tests compattestfile,atf |
1466 | ./usr/tests/crypto/libcrypto/t_libcrypto tests-crypto-tests compattestfile,atf | | 1466 | ./usr/tests/crypto/libcrypto/t_libcrypto tests-crypto-tests compattestfile,atf |
1467 | ./usr/tests/crypto/libcrypto/t_pubkey tests-crypto-tests compattestfile,atf | | 1467 | ./usr/tests/crypto/libcrypto/t_pubkey tests-crypto-tests compattestfile,atf |
| | | 1468 | ./usr/tests/crypto/libcrypto/t_sha512trunc tests-crypto-tests compattestfile,atf |
1468 | ./usr/tests/crypto/opencrypto tests-crypto-tests compattestfile,atf | | 1469 | ./usr/tests/crypto/opencrypto tests-crypto-tests compattestfile,atf |
1469 | ./usr/tests/crypto/opencrypto/Atffile tests-crypto-tests compattestfile,atf | | 1470 | ./usr/tests/crypto/opencrypto/Atffile tests-crypto-tests compattestfile,atf |
1470 | ./usr/tests/crypto/opencrypto/Kyuafile tests-crypto-tests compattestfile,atf,kyua | | 1471 | ./usr/tests/crypto/opencrypto/Kyuafile tests-crypto-tests compattestfile,atf,kyua |
1471 | ./usr/tests/crypto/opencrypto/h_aescbc tests-crypto-tests compattestfile,atf | | 1472 | ./usr/tests/crypto/opencrypto/h_aescbc tests-crypto-tests compattestfile,atf |
1472 | ./usr/tests/crypto/opencrypto/h_aesctr1 tests-crypto-tests compattestfile,atf | | 1473 | ./usr/tests/crypto/opencrypto/h_aesctr1 tests-crypto-tests compattestfile,atf |
1473 | ./usr/tests/crypto/opencrypto/h_aesctr2 tests-crypto-tests compattestfile,atf | | 1474 | ./usr/tests/crypto/opencrypto/h_aesctr2 tests-crypto-tests compattestfile,atf |
1474 | ./usr/tests/crypto/opencrypto/h_arc4 tests-crypto-tests compattestfile,atf | | 1475 | ./usr/tests/crypto/opencrypto/h_arc4 tests-crypto-tests compattestfile,atf |
1475 | ./usr/tests/crypto/opencrypto/h_camellia tests-crypto-tests compattestfile,atf | | 1476 | ./usr/tests/crypto/opencrypto/h_camellia tests-crypto-tests compattestfile,atf |
1476 | ./usr/tests/crypto/opencrypto/h_cbc3des tests-crypto-tests compattestfile,atf | | 1477 | ./usr/tests/crypto/opencrypto/h_cbc3des tests-crypto-tests compattestfile,atf |
1477 | ./usr/tests/crypto/opencrypto/h_cbcdes tests-crypto-tests compattestfile,atf | | 1478 | ./usr/tests/crypto/opencrypto/h_cbcdes tests-crypto-tests compattestfile,atf |
1478 | ./usr/tests/crypto/opencrypto/h_comp tests-crypto-tests compattestfile,atf | | 1479 | ./usr/tests/crypto/opencrypto/h_comp tests-crypto-tests compattestfile,atf |
1479 | ./usr/tests/crypto/opencrypto/h_comp_zlib tests-crypto-tests compattestfile,atf | | 1480 | ./usr/tests/crypto/opencrypto/h_comp_zlib tests-crypto-tests compattestfile,atf |
1480 | ./usr/tests/crypto/opencrypto/h_comp_zlib_rnd tests-crypto-tests compattestfile,atf | | 1481 | ./usr/tests/crypto/opencrypto/h_comp_zlib_rnd tests-crypto-tests compattestfile,atf |
--- src/tests/crypto/libcrypto/Makefile 2023/08/11 13:43:42 1.14.10.1
+++ src/tests/crypto/libcrypto/Makefile 2024/03/25 14:14:55 1.14.10.2
| @@ -1,29 +1,33 @@ | | | @@ -1,29 +1,33 @@ |
1 | # $NetBSD: Makefile,v 1.14.10.1 2023/08/11 13:43:42 martin Exp $ | | 1 | # $NetBSD: Makefile,v 1.14.10.2 2024/03/25 14:14:55 martin Exp $ |
2 | | | 2 | |
3 | .include <bsd.own.mk> | | 3 | .include <bsd.own.mk> |
4 | | | 4 | |
5 | SUBDIR+=bf bn cast conf des dh dsa ec engine evp hmac \ | | 5 | SUBDIR+=bf bn cast conf des dh dsa ec engine evp hmac \ |
6 | rc2 rc4 rsa srp threads | | 6 | rc2 rc4 rsa srp threads |
7 | | | 7 | |
8 | .if ${HAVE_OPENSSL} <= 11 | | 8 | .if ${HAVE_OPENSSL} <= 11 |
9 | SUBDIR+= ecdh ecdsa md2 | | 9 | SUBDIR+= ecdh ecdsa md2 |
10 | .endif | | 10 | .endif |
11 | | | 11 | |
12 | SUBDIR+=idea mdc2 | | 12 | SUBDIR+=idea mdc2 |
13 | SUBDIR+=rc5 | | 13 | SUBDIR+=rc5 |
14 | | | 14 | |
15 | .if ${HAVE_OPENSSL} == 10 | | 15 | .if ${HAVE_OPENSSL} == 10 |
16 | SUBDIR += lhash sha x509v3 | | 16 | SUBDIR += lhash sha x509v3 |
17 | .endif | | 17 | .endif |
18 | | | 18 | |
19 | TESTSDIR= ${TESTSBASE}/crypto/libcrypto | | 19 | TESTSDIR= ${TESTSBASE}/crypto/libcrypto |
20 | | | 20 | |
| | | 21 | TESTS_C+= t_sha512trunc |
| | | 22 | DPADD.t_sha512trunc+= ${LIBCRYPTO} |
| | | 23 | LDADD.t_sha512trunc+= -lcrypto |
| | | 24 | |
21 | .if ${HAVE_OPENSSL} == 10 | | 25 | .if ${HAVE_OPENSSL} == 10 |
22 | TESTS_SH= t_certs | | 26 | TESTS_SH= t_certs |
23 | .endif | | 27 | .endif |
24 | TESTS_SH+= t_ciphers | | 28 | TESTS_SH+= t_ciphers |
25 | TESTS_SH+= t_hashes | | 29 | TESTS_SH+= t_hashes |
26 | TESTS_SH+= t_libcrypto | | 30 | TESTS_SH+= t_libcrypto |
27 | TESTS_SH+= t_pubkey | | 31 | TESTS_SH+= t_pubkey |
28 | | | 32 | |
29 | .include <bsd.test.mk> | | 33 | .include <bsd.test.mk> |
/* $NetBSD: t_sha512trunc.c,v 1.2.2.2 2024/03/25 14:14:55 martin Exp $ */
/*-
* Copyright (c) 2024 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_sha512trunc.c,v 1.2.2.2 2024/03/25 14:14:55 martin Exp $");
#include <stddef.h>
#include <atf-c.h>
#include <openssl/evp.h>
#include "h_macros.h"
struct testcase {
const unsigned char in[128];
size_t inlen;
const unsigned char out[32];
};
static void
check(const struct testcase *C, size_t n, size_t digestlen, const EVP_MD *md)
{
enum { C0 = 0xc0, C1 = 0xc1 };
unsigned char *buf, *digest, *p0, *p1;
size_t i;
ATF_REQUIRE_MSG(digestlen <= INT_MAX, "digestlen=%zu", digestlen);
ATF_REQUIRE_EQ_MSG((int)digestlen, EVP_MD_size(md),
"expected %d, got %d", (int)digestlen, EVP_MD_size(md));
ATF_REQUIRE_MSG(digestlen < SIZE_MAX - 2048,
"digestlen=%zu", digestlen);
REQUIRE_LIBC(buf = malloc(digestlen + 2048), NULL);
p0 = buf;
digest = buf + 1;
p1 = buf + 1 + digestlen;
for (i = 0; i < n; i++) {
EVP_MD_CTX *ctx;
unsigned digestlen1;
*p0 = C0;
*p1 = C1;
#define REQUIRE(x) ATF_REQUIRE_MSG((x), "i=%zu", i)
REQUIRE(ctx = EVP_MD_CTX_new());
REQUIRE(EVP_DigestInit_ex(ctx, md, NULL));
REQUIRE(EVP_DigestUpdate(ctx, C->in, C->inlen));
REQUIRE(EVP_DigestFinal_ex(ctx, digest, &digestlen1));
#undef REQUIRE
ATF_CHECK_MSG(digestlen == digestlen1,
"i=%zu: expected %zu got %u", i, digestlen, digestlen1);
EVP_MD_CTX_free(ctx);
ATF_CHECK_MSG(memcmp(digest, C->out, digestlen) == 0,
"i=%zu", i);
ATF_CHECK_EQ_MSG(*p0, C0, "expected 0x%x got 0x%hhx", C0, *p0);
ATF_CHECK_EQ_MSG(*p1, C1, "expected 0x%x got 0x%hhx", C1, *p1);
}
}
/*
* Test vectors from:
*
* https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing#Testing
*/
ATF_TC(sha512_224);
ATF_TC_HEAD(sha512_224, tc)
{
atf_tc_set_md_var(tc, "descr", "Test SHA512-224");
}
ATF_TC_BODY(sha512_224, tc)
{
static const struct testcase C[] = {
[0] = {
.inlen = 0,
.out = {
0x6e,0xd0,0xdd,0x02, 0x80,0x6f,0xa8,0x9e,
0x25,0xde,0x06,0x0c, 0x19,0xd3,0xac,0x86,
0xca,0xbb,0x87,0xd6, 0xa0,0xdd,0xd0,0x5c,
0x33,0x3b,0x84,0xf4,
},
},
[1] = {
.inlen = 1,
.in = {
0xcf,
},
.out = {
0x41,0x99,0x23,0x9e, 0x87,0xd4,0x7b,0x6f,
0xed,0xa0,0x16,0x80, 0x2b,0xf3,0x67,0xfb,
0x6e,0x8b,0x56,0x55, 0xef,0xf6,0x22,0x5c,
0xb2,0x66,0x8f,0x4a,
},
},
};
check(C, __arraycount(C), 28, EVP_sha512_224());
}
ATF_TC(sha512_256);
ATF_TC_HEAD(sha512_256, tc)
{
atf_tc_set_md_var(tc, "descr", "Test SHA512-256");
}
ATF_TC_BODY(sha512_256, tc)
{
static const struct testcase C[] = {
[0] = {
.inlen = 0,
.out = {
0xc6,0x72,0xb8,0xd1, 0xef,0x56,0xed,0x28,
0xab,0x87,0xc3,0x62, 0x2c,0x51,0x14,0x06,
0x9b,0xdd,0x3a,0xd7, 0xb8,0xf9,0x73,0x74,
0x98,0xd0,0xc0,0x1e, 0xce,0xf0,0x96,0x7a,
},
},
[1] = {
.inlen = 1,
.in = {
0xfa,
},
.out = {
0xc4,0xef,0x36,0x92, 0x3c,0x64,0xe5,0x1e,
0x87,0x57,0x20,0xe5, 0x50,0x29,0x8a,0x5a,
0xb8,0xa3,0xf2,0xf8, 0x75,0xb1,0xe1,0xa4,
0xc9,0xb9,0x5b,0xab, 0xf7,0x34,0x4f,0xef,
},
},
};
check(C, __arraycount(C), 32, EVP_sha512_256());
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, sha512_224);
ATF_TP_ADD_TC(tp, sha512_256);
return atf_no_error();
}