From 2768d7056727c414241ebc4b9d26e62dd5460760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 6 Feb 2023 17:57:36 +0100 Subject: [PATCH] libmd / md5: Add SHA-512/224. While there, remove .Tn from man pages. Also remove an obsolete comment about the 80386. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans, allanjude Differential Revision: https://reviews.freebsd.org/D38373 --- lib/libmd/Makefile | 40 ++++++++++++++++-- lib/libmd/mdX.3 | 10 ++--- lib/libmd/ripemd.3 | 7 +--- lib/libmd/sha.3 | 37 ++++------------- lib/libmd/sha256.3 | 7 +--- lib/libmd/sha512.3 | 54 ++++++++++++++++++++----- lib/libmd/shadriver.c | 3 ++ lib/libmd/skein.3 | 3 +- sbin/md5/Makefile | 4 ++ sbin/md5/md5.1 | 21 ++++++---- sbin/md5/md5.c | 17 +++++++- sbin/md5/tests/algorithms.txt | 1 + sbin/md5/tests/self-test.sha512t224.chk | 9 +++++ sbin/md5/tests/sha512t224.digest | 8 ++++ sbin/md5/tests/sha512t224sum.digest | 8 ++++ 15 files changed, 156 insertions(+), 73 deletions(-) create mode 100644 sbin/md5/tests/self-test.sha512t224.chk create mode 100644 sbin/md5/tests/sha512t224.digest create mode 100644 sbin/md5/tests/sha512t224sum.digest diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile index 8d3a05279004..94f38732872c 100644 --- a/lib/libmd/Makefile +++ b/lib/libmd/Makefile @@ -13,7 +13,7 @@ SRCS= md4c.c md5c.c md4hl.c md5hl.c \ sha0c.c sha0hl.c sha1c.c sha1hl.c \ sha224hl.c sha256c.c sha256hl.c \ sha384hl.c \ - sha512c.c sha512hl.c sha512thl.c \ + sha512c.c sha512hl.c sha512t224hl.c sha512t256hl.c \ skein.c skein_block.c \ skein256hl.c skein512hl.c skein1024hl.c INCS= md4.h md5.h ripemd.h sha.h sha224.h sha256.h sha384.h sha512.h \ @@ -54,6 +54,10 @@ MLINKS+=sha512.3 SHA512_Init.3 sha512.3 SHA512_Update.3 MLINKS+=sha512.3 SHA512_Final.3 sha512.3 SHA512_End.3 MLINKS+=sha512.3 SHA512_File.3 sha512.3 SHA512_FileChunk.3 MLINKS+=sha512.3 SHA512_Data.3 +MLINKS+=sha512.3 SHA512_224_Init.3 sha512.3 SHA512_224_Update.3 +MLINKS+=sha512.3 SHA512_224_Final.3 sha512.3 SHA512_224_End.3 +MLINKS+=sha512.3 SHA512_224_File.3 sha512.3 SHA512_224_FileChunk.3 +MLINKS+=sha512.3 SHA512_224_Data.3 MLINKS+=sha512.3 SHA512_256_Init.3 sha512.3 SHA512_256_Update.3 MLINKS+=sha512.3 SHA512_256_Final.3 sha512.3 SHA512_256_End.3 MLINKS+=sha512.3 SHA512_256_File.3 sha512.3 SHA512_256_FileChunk.3 @@ -76,7 +80,9 @@ CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \ sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver \ sha224.ref sha256.ref sha224hl.c sha256hl.c \ sha384hl.c sha384.ref \ - sha512.ref sha512hl.c sha512t256.ref sha512thl.c \ + sha512.ref sha512hl.c \ + sha512t224.ref sha512t224hl.c \ + sha512t256.ref sha512t256hl.c \ skein256hl.c skein512hl.c skein1024hl.c \ skein256.ref skein512.ref skein1024.ref \ skeindriver @@ -184,7 +190,14 @@ sha512hl.c: mdXhl.c -e 's/SHA512__/SHA512_/g' \ ${.ALLSRC}) > ${.TARGET} -sha512thl.c: mdXhl.c +sha512t224hl.c: mdXhl.c + (echo '#define LENGTH 28'; \ + sed -e 's/mdX/sha512t/g' -e 's/MDX/SHA512_224_/g' \ + -e 's/SHA512_224__/SHA512_224_/g' \ + -e 's/SHA512_224_CTX/SHA512_CTX/g' \ + ${.ALLSRC}) > ${.TARGET} + +sha512t256hl.c: mdXhl.c (echo '#define LENGTH 32'; \ sed -e 's/mdX/sha512t/g' -e 's/MDX/SHA512_256_/g' \ -e 's/SHA512_256__/SHA512_256_/g' \ @@ -328,6 +341,21 @@ sha512.ref: @echo 'SHA-512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ '72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843' >> ${.TARGET} +sha512t224.ref: + echo 'SHA-512224 test suite:' > ${.TARGET} + @echo 'SHA-512224 ("") =' \ + '6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4' >> ${.TARGET} + @echo 'SHA-512224 ("abc") =' \ + '4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa' >> ${.TARGET} + @echo 'SHA-512224 ("message digest") =' \ + 'ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564' >> ${.TARGET} + @echo 'SHA-512224 ("abcdefghijklmnopqrstuvwxyz") =' \ + 'ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8' >> ${.TARGET} + @echo 'SHA-512224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + 'a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3' >> ${.TARGET} + @echo 'SHA-512224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + 'ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2' >> ${.TARGET} + sha512t256.ref: echo 'SHA-512256 test suite:' > ${.TARGET} @echo 'SHA-512256 ("") =' \ @@ -400,7 +428,7 @@ skein1024.ref: 'cf21a613620e6c119eca31fdfaad449a8e02f95ca256c21d2a105f8e4157048f9fe1e897893ea18b64e0e37cb07d5ac947f27ba544caf7cbc1ad094e675aed77a366270f7eb7f46543bccfa61c526fd628408058ed00ed566ac35a9761d002e629c4fb0d430b2f4ad016fcc49c44d2981c4002da0eecc42144160e2eaea4855a' >> ${.TARGET} test: md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha224.ref sha256.ref sha384.ref \ - sha512.ref sha512t256.ref skein256.ref skein512.ref skein1024.ref + sha512.ref sha512t224.ref sha512t256.ref skein256.ref skein512.ref skein1024.ref @${ECHO} if any of these test fail, the code produces wrong results @${ECHO} and should NOT be used. ${CC} ${CFLAGS} ${LDFLAGS} -DMD=4 -o mddriver ${.CURDIR}/mddriver.c libmd.a @@ -432,6 +460,10 @@ test: md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha224.ref sha256.ref sha384. ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512 -o shadriver ${.CURDIR}/shadriver.c libmd.a ./shadriver | cmp sha512.ref - @${ECHO} SHA-512 passed test + ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512224 -o shadriver ${.CURDIR}/shadriver.c libmd.a + ./shadriver | cmp sha512t224.ref - + @${ECHO} SHA-512t224 passed test + -rm -f shadriver ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512256 -o shadriver ${.CURDIR}/shadriver.c libmd.a ./shadriver | cmp sha512t256.ref - @${ECHO} SHA-512t256 passed test diff --git a/lib/libmd/mdX.3 b/lib/libmd/mdX.3 index 5631e2d7a1fc..e9462267ddfb 100644 --- a/lib/libmd/mdX.3 +++ b/lib/libmd/mdX.3 @@ -95,8 +95,7 @@ function is a wrapper for .Fn MDXFinal which converts the return value to a 33-character (including the terminating '\e0') -.Tn ASCII -string which represents the 128 bits in hexadecimal. +ASCII string which represents the 128 bits in hexadecimal. .Pp The .Fn MDXFile @@ -201,15 +200,12 @@ These functions appeared in .Fx 2.0 . .Sh AUTHORS The original MDX routines were developed by -.Tn RSA -Data Security, Inc., and published in the above references. +RSA Data Security, Inc., and published in the above references. This code is derived directly from these implementations by .An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . .Pp Phk ristede runen. .Sh BUGS -The -.Tn MD5 -algorithm has been proven to be vulnerable to practical collision +The MD5 algorithm has been proven to be vulnerable to practical collision attacks and should not be relied upon to produce unique outputs, .Em nor should they be used as part of a cryptographic signature scheme. diff --git a/lib/libmd/ripemd.3 b/lib/libmd/ripemd.3 index 5b1ba8d62e5c..b8d3978056c7 100644 --- a/lib/libmd/ripemd.3 +++ b/lib/libmd/ripemd.3 @@ -75,8 +75,7 @@ function is a wrapper for .Fn RIPEMD160_Final which converts the return value to a 41-character (including the terminating '\e0') -.Tn ASCII -string which represents the 160 bits in hexadecimal. +ASCII string which represents the 160 bits in hexadecimal. .Pp The .Fn RIPEMD160_File @@ -156,9 +155,7 @@ These functions appeared in .Fx 4.0 . .Sh AUTHORS The core hash routines were implemented by Eric Young based on the -published -.Tn RIPEMD160 -specification. +published RIPEMD160 specification. .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. diff --git a/lib/libmd/sha.3 b/lib/libmd/sha.3 index c629de77f692..8573896d95d8 100644 --- a/lib/libmd/sha.3 +++ b/lib/libmd/sha.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd May 21, 2019 +.Dd February 6, 2023 .Dt SHA 3 .Os .Sh NAME @@ -76,16 +76,9 @@ a .Dq fingerprint of the input-data, which does not disclose the actual input. .Pp -.Tn SHA -(or -.Tn SHA-0 ) -is the original Secure Hash Algorithm specified in -.Tn FIPS -160. -It was quickly proven insecure, and has been superseded by -.Tn SHA-1 . -.Tn SHA-0 -is included for compatibility purposes only. +SHA (or SHA-0) is the original Secure Hash Algorithm specified in FIPS 160. +It was quickly proven insecure, and has been superseded by SHA-1. +SHA-0 is included for compatibility purposes only. .Pp The .Fn SHA1_Init , @@ -109,8 +102,7 @@ is a wrapper for .Fn SHA1_Final which converts the return value to a 41-character (including the terminating '\e0') -.Tn ASCII -string which represents the 160 bits in hexadecimal. +ASCII string which represents the 160 bits in hexadecimal. .Pp .Fn SHA1_File calculates the digest of a file, and uses @@ -188,23 +180,8 @@ These functions appeared in .Sh AUTHORS The core hash routines were implemented by Eric Young based on the published -.Tn FIPS -standards. +FIPS standards. .Sh BUGS -The -.Tn SHA1 -algorithm has been proven to be vulnerable to practical collision +The SHA1 algorithm has been proven to be vulnerable to practical collision attacks and should not be relied upon to produce unique outputs, .Em nor should it be used as part of a new cryptographic signature scheme. -.Pp -The -.Tn IA32 -(Intel) implementation of -.Tn SHA-1 -makes heavy use of the -.Ql bswapl -instruction, which is not present on the original 80386. -Attempts to use -.Tn SHA-1 -on those processors will cause an illegal instruction trap. -(Arguably, the kernel should simply emulate this instruction.) diff --git a/lib/libmd/sha256.3 b/lib/libmd/sha256.3 index defe2ec45151..b07d51f230e7 100644 --- a/lib/libmd/sha256.3 +++ b/lib/libmd/sha256.3 @@ -97,8 +97,7 @@ is a wrapper for .Fn SHA256_Final which converts the return value to a 65-character (including the terminating '\e0') -.Tn ASCII -string which represents the 256 bits in hexadecimal. +ASCII string which represents the 256 bits in hexadecimal. .Pp .Fn SHA256_File calculates the digest of a file, and uses @@ -178,9 +177,7 @@ These functions appeared in .Fx 6.0 . .Sh AUTHORS The core hash routines were implemented by Colin Percival based on -the published -.Tn FIPS 180-2 -standard. +the published FIPS 180-2 standard. .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. diff --git a/lib/libmd/sha512.3 b/lib/libmd/sha512.3 index 30ea2a0b5eb2..7de503102bc7 100644 --- a/lib/libmd/sha512.3 +++ b/lib/libmd/sha512.3 @@ -9,7 +9,7 @@ .\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp .\" $FreeBSD$ .\" -.Dd May 21, 2019 +.Dd February 3, 2023 .Dt SHA512 3 .Os .Sh NAME @@ -27,6 +27,13 @@ .Nm SHA384_File , .Nm SHA384_FileChunk , .Nm SHA384_Data , +.Nm SHA512_224_Init , +.Nm SHA512_224_Update , +.Nm SHA512_224_Final , +.Nm SHA512_224_End , +.Nm SHA512_224_File , +.Nm SHA512_224_FileChunk , +.Nm SHA512_224_Data .Nm SHA512_256_Init , .Nm SHA512_256_Update , .Nm SHA512_256_Final , @@ -71,6 +78,20 @@ .Fn SHA384_Data "const unsigned char *data" "unsigned int len" "char *buf" .In sha512t.h .Ft void +.Fn SHA512_224_Init "SHA512_CTX *context" +.Ft void +.Fn SHA512_224_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len" +.Ft void +.Fn SHA512_224_Final "unsigned char digest[32]" "SHA512_CTX *context" +.Ft "char *" +.Fn SHA512_224_End "SHA512_CTX *context" "char *buf" +.Ft "char *" +.Fn SHA512_224_File "const char *filename" "char *buf" +.Ft "char *" +.Fn SHA512_224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" +.Ft "char *" +.Fn SHA512_224_Data "const unsigned char *data" "unsigned int len" "char *buf" +.Ft void .Fn SHA512_256_Init "SHA512_CTX *context" .Ft void .Fn SHA512_256_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len" @@ -119,8 +140,7 @@ is a wrapper for .Fn SHA512_Final which converts the return value to a 129-character (including the terminating '\e0') -.Tn ASCII -string which represents the 512 bits in hexadecimal. +ASCII string which represents the 512 bits in hexadecimal. .Pp .Fn SHA512_File calculates the digest of a file, and uses @@ -167,29 +187,43 @@ If the argument is non-null it must point to at least 129 characters of buffer space. .Pp The -.Li SHA384_ +.Li SHA384_ , +.Li SHA512_224 , and .Li SHA512_256_ functions are identical to the .Li SHA512_ functions except they use a different initial hash value and the output is -truncated to 384 bits and 256 bits respectively. +truncated to 384, 224, and 256 bits respectively. .Pp .Fn SHA384_End is a wrapper for .Fn SHA384_Final which converts the return value to a 97-character (including the terminating '\e0') +ASCII string which represents the 384 bits in hexadecimal. +.Pp +.Fn SHA512_224_End +is a wrapper for +.Fn SHA512_Final +which converts the return value to a 57-character +(including the terminating '\e0') +ASCII string which represents the 224 bits in hexadecimal. +.Pp +.Fn SHA512_224_End +is a wrapper for +.Fn SHA512_Final +which converts the return value to a 57-character +(including the terminating '\e0') .Tn ASCII -string which represents the 384 bits in hexadecimal. +string which represents the 224 bits in hexadecimal. .Pp .Fn SHA512_256_End is a wrapper for .Fn SHA512_Final which converts the return value to a 65-character (including the terminating '\e0') -.Tn ASCII -string which represents the 256 bits in hexadecimal. +ASCII string which represents the 256 bits in hexadecimal. .Sh ERRORS The .Fn SHA512_End @@ -223,9 +257,7 @@ These functions appeared in .Fx 9.0 . .Sh AUTHORS The core hash routines were implemented by Colin Percival based on -the published -.Tn FIPS 180-2 -standard. +the published FIPS 180-2 standard. .Sh BUGS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. diff --git a/lib/libmd/shadriver.c b/lib/libmd/shadriver.c index f5026eb3cc5d..3664eab9dbaa 100644 --- a/lib/libmd/shadriver.c +++ b/lib/libmd/shadriver.c @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$"); #elif SHA == 512 #undef SHA_Data #define SHA_Data SHA512_Data +#elif SHA == 512224 +#undef SHA_Data +#define SHA_Data SHA512_224_Data #elif SHA == 512256 #undef SHA_Data #define SHA_Data SHA512_256_Data diff --git a/lib/libmd/skein.3 b/lib/libmd/skein.3 index dd8cedb15027..bce01032be66 100644 --- a/lib/libmd/skein.3 +++ b/lib/libmd/skein.3 @@ -133,8 +133,7 @@ is a wrapper for .Fn SKEIN256_Final which converts the return value to a 33-character (including the terminating '\e0') -.Tn ASCII -string which represents the 256 bits in hexadecimal. +ASCII string which represents the 256 bits in hexadecimal. .Pp .Fn SKEIN256_File calculates the digest of a file, and uses diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile index e499967d23d5..6bda75437275 100644 --- a/sbin/md5/Makefile +++ b/sbin/md5/Makefile @@ -17,6 +17,8 @@ LINKS= ${BINDIR}/md5 ${BINDIR}/md5sum \ ${BINDIR}/md5 ${BINDIR}/sha384sum \ ${BINDIR}/md5 ${BINDIR}/sha512 \ ${BINDIR}/md5 ${BINDIR}/sha512sum \ + ${BINDIR}/md5 ${BINDIR}/sha512t224 \ + ${BINDIR}/md5 ${BINDIR}/sha512t224sum \ ${BINDIR}/md5 ${BINDIR}/sha512t256 \ ${BINDIR}/md5 ${BINDIR}/sha512t256sum \ ${BINDIR}/md5 ${BINDIR}/skein256 \ @@ -39,6 +41,8 @@ MLINKS= md5.1 md5sum.1 \ md5.1 sha384sum.1 \ md5.1 sha512.1 \ md5.1 sha512sum.1 \ + md5.1 sha512t224.1 \ + md5.1 sha512t224sum.1 \ md5.1 sha512t256.1 \ md5.1 sha512t256sum.1 \ md5.1 skein256.1 \ diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index a3db48596606..ba654e131c3c 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -1,12 +1,14 @@ .\" $FreeBSD$ -.Dd July 26, 2022 +.Dd February 6, 2023 .Dt MD5 1 .Os .Sh NAME -.Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 , -.Nm skein256 , skein512 , skein1024 , -.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , -.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , skein1024sum +.Nm md5 , sha1 , sha224 , sha256 , sha384 , +.Nm sha512 , sha512t224 , sha512t256 , +.Nm rmd160 , skein256 , skein512 , skein1024 , +.Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , +.Nm sha512sum , sha512t224sum , sha512t256sum , +.Nm rmd160sum , skein256sum , skein512sum , skein1024sum .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS .Nm @@ -24,8 +26,8 @@ (All other hashes have the same options and usage.) .Sh DESCRIPTION The -.Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t256 , rmd160 , -.Nm skein256 , skein512 , +.Nm md5 , sha1 , sha224 , sha256 , sha384 , sha512 , sha512t224 , sha512t256 , +.Nm rmd160 , skein256 , skein512 , and .Nm skein1024 utilities take as input a message of arbitrary length and produce as @@ -36,7 +38,7 @@ or of the input. The .Nm md5sum , sha1sum , sha224sum , sha256sum , sha384sum , sha512sum , -.Nm sha512t256sum , rmd160sum , skein256sum , skein512sum , +.Nm sha512t224sum , sha512t256sum , rmd160sum , skein256sum , skein512sum , and .Nm skein1024sum utilities do the same, but default to the reversed format of @@ -68,6 +70,9 @@ On 64-bit hardware, this algorithm is approximately 50% faster than SHA-256 but with the same level of security. The hashes are not interchangeable. .Pp +SHA-512t224 is identical to SHA-512t256, but with the digest truncated +to 224 bits. +.Pp It is recommended that all new applications use SHA-512 or SKEIN-512 instead of one of the other hash functions. .Pp diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 97c587efd63c..db4cdd7da1ff 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -20,10 +20,10 @@ #include __FBSDID("$FreeBSD$"); -#include #include #include #include + #include #include #include @@ -75,6 +75,7 @@ extern const char *SHA224_TestOutput[MDTESTCOUNT]; extern const char *SHA256_TestOutput[MDTESTCOUNT]; extern const char *SHA384_TestOutput[MDTESTCOUNT]; extern const char *SHA512_TestOutput[MDTESTCOUNT]; +extern const char *SHA512t224_TestOutput[MDTESTCOUNT]; extern const char *SHA512t256_TestOutput[MDTESTCOUNT]; extern const char *RIPEMD160_TestOutput[MDTESTCOUNT]; extern const char *SKEIN256_TestOutput[MDTESTCOUNT]; @@ -138,6 +139,9 @@ static const struct Algorithm_t Algorithm[] = { { "sha512", "SHA512", &SHA512_TestOutput, (DIGEST_Init*)&SHA512_Init, (DIGEST_Update*)&SHA512_Update, (DIGEST_End*)&SHA512_End, &SHA512_Data, &SHA512_Fd }, + { "sha512t224", "SHA512t224", &SHA512t224_TestOutput, (DIGEST_Init*)&SHA512_224_Init, + (DIGEST_Update*)&SHA512_224_Update, (DIGEST_End*)&SHA512_224_End, + &SHA512_224_Data, &SHA512_224_Fd }, { "sha512t256", "SHA512t256", &SHA512t256_TestOutput, (DIGEST_Init*)&SHA512_256_Init, (DIGEST_Update*)&SHA512_256_Update, (DIGEST_End*)&SHA512_256_End, &SHA512_256_Data, &SHA512_256_Fd }, @@ -585,6 +589,17 @@ const char *SHA512_TestOutput[MDTESTCOUNT] = { "e8a835195e039708b13d9131e025f4441dbdc521ce625f245a436dcd762f54bf5cb298d96235e6c6a304e087ec8189b9512cbdf6427737ea82793460c367b9c3" }; +const char *SHA512t224_TestOutput[MDTESTCOUNT] = { + "6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4", + "d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327", + "4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa", + "ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564", + "ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8", + "a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3", + "ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2", + "b3c3b945249b0c8c94aba76ea887bcaad5401665a1fbeb384af4d06b" +}; + const char *SHA512t256_TestOutput[MDTESTCOUNT] = { "c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a", "455e518824bc0601f9fb858ff5c37d417d67c2f8e0df2babe4808858aea830f8", diff --git a/sbin/md5/tests/algorithms.txt b/sbin/md5/tests/algorithms.txt index 88f0ff5b783a..304d86bd4d4c 100644 --- a/sbin/md5/tests/algorithms.txt +++ b/sbin/md5/tests/algorithms.txt @@ -5,6 +5,7 @@ sha224 sha256 sha384 sha512 +sha512t224 sha512t256 skein1024 skein256 diff --git a/sbin/md5/tests/self-test.sha512t224.chk b/sbin/md5/tests/self-test.sha512t224.chk new file mode 100644 index 000000000000..d0549199f76b --- /dev/null +++ b/sbin/md5/tests/self-test.sha512t224.chk @@ -0,0 +1,9 @@ +SHA512t224 test suite: +SHA512t224 ("") = 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4 - verified correct +SHA512t224 ("a") = d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327 - verified correct +SHA512t224 ("abc") = 4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa - verified correct +SHA512t224 ("message digest") = ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564 - verified correct +SHA512t224 ("abcdefghijklmnopqrstuvwxyz") = ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8 - verified correct +SHA512t224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3 - verified correct +SHA512t224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2 - verified correct +SHA512t224 ("MD5 has not yet (2001-09-03) been broken, but sufficient attacks have been made that its security is in some doubt") = b3c3b945249b0c8c94aba76ea887bcaad5401665a1fbeb384af4d06b - verified correct diff --git a/sbin/md5/tests/sha512t224.digest b/sbin/md5/tests/sha512t224.digest new file mode 100644 index 000000000000..34ad437ed15d --- /dev/null +++ b/sbin/md5/tests/sha512t224.digest @@ -0,0 +1,8 @@ +SHA512t224 (1.inp) = 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4 +SHA512t224 (2.inp) = d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327 +SHA512t224 (3.inp) = 4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa +SHA512t224 (4.inp) = ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564 +SHA512t224 (5.inp) = ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8 +SHA512t224 (6.inp) = a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3 +SHA512t224 (7.inp) = ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2 +SHA512t224 (8.inp) = b3c3b945249b0c8c94aba76ea887bcaad5401665a1fbeb384af4d06b diff --git a/sbin/md5/tests/sha512t224sum.digest b/sbin/md5/tests/sha512t224sum.digest new file mode 100644 index 000000000000..36459078a7b2 --- /dev/null +++ b/sbin/md5/tests/sha512t224sum.digest @@ -0,0 +1,8 @@ +6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4 1.inp +d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327 2.inp +4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa 3.inp +ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564 4.inp +ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8 5.inp +a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3 6.inp +ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2 7.inp +b3c3b945249b0c8c94aba76ea887bcaad5401665a1fbeb384af4d06b 8.inp