aboutsummaryrefslogtreecommitdiff
path: root/lib/libmd
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libmd')
-rw-r--r--lib/libmd/Makefile43
-rw-r--r--lib/libmd/Makefile.depend1
-rw-r--r--lib/libmd/i386/rmd160.S1
-rw-r--r--lib/libmd/i386/sha.S1
-rw-r--r--lib/libmd/md4.copyright1
-rw-r--r--lib/libmd/md4.h1
-rw-r--r--lib/libmd/md4c.c2
-rw-r--r--lib/libmd/md5.copyright1
-rw-r--r--lib/libmd/md5.h1
-rw-r--r--lib/libmd/md5c.c3
-rw-r--r--lib/libmd/mdX.314
-rw-r--r--lib/libmd/mdXhl.c3
-rw-r--r--lib/libmd/mddriver.c3
-rw-r--r--lib/libmd/ripemd.310
-rw-r--r--lib/libmd/ripemd.h2
-rw-r--r--lib/libmd/rmd160c.c27
-rw-r--r--lib/libmd/rmddriver.c3
-rw-r--r--lib/libmd/sha.340
-rw-r--r--lib/libmd/sha.h3
-rw-r--r--lib/libmd/sha0c.c24
-rw-r--r--lib/libmd/sha1c.c24
-rw-r--r--lib/libmd/sha256.310
-rw-r--r--lib/libmd/sha512.357
-rw-r--r--lib/libmd/shadriver.c6
-rw-r--r--lib/libmd/skein.37
-rw-r--r--lib/libmd/skeindriver.c3
26 files changed, 120 insertions, 171 deletions
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index c98c33bae3f5..bafcd5b46c19 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -1,4 +1,3 @@
-# $FreeBSD$
SHLIBDIR?= /lib
@@ -13,7 +12,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 +53,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 +79,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
@@ -103,7 +108,7 @@ CFLAGS.skein_block.c+= -DSKEIN_LOOP=995
.PATH: ${SRCTOP}/sys/crypto/skein ${SRCTOP}/sys/crypto/skein/${MACHINE_ARCH}
USE_ASM_SOURCES?=1
-.if defined(BOOTSTRAPPING)
+.if defined(BOOTSTRAPPING) || ${MK_MACHDEP_OPTIMIZATIONS} == no
# Don't build ASM sources when bootstrapping to avoid toolchain dependencies
USE_ASM_SOURCES:=0
.endif
@@ -184,7 +189,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 +340,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 +427,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 +459,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/Makefile.depend b/lib/libmd/Makefile.depend
index 8d409f5263ac..6ef78fac5cbf 100644
--- a/lib/libmd/Makefile.depend
+++ b/lib/libmd/Makefile.depend
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
diff --git a/lib/libmd/i386/rmd160.S b/lib/libmd/i386/rmd160.S
index 7ccfb22daf12..57da14f83a7c 100644
--- a/lib/libmd/i386/rmd160.S
+++ b/lib/libmd/i386/rmd160.S
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* Run the C pre-processor over this file with one of the following defined
* ELF - elf object files,
* OUT - a.out object files,
diff --git a/lib/libmd/i386/sha.S b/lib/libmd/i386/sha.S
index 1e5201f5cb89..3bb54aa9b251 100644
--- a/lib/libmd/i386/sha.S
+++ b/lib/libmd/i386/sha.S
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/* -*- Fundamental -*- Emacs' assembler mode hoses this file */
#ifndef PIC
/* Run the C pre-processor over this file with one of the following defined
diff --git a/lib/libmd/md4.copyright b/lib/libmd/md4.copyright
index e4502073a1ce..7c7af2efb887 100644
--- a/lib/libmd/md4.copyright
+++ b/lib/libmd/md4.copyright
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
.Pp
diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h
index c05c690f80e1..f8d762dbec27 100644
--- a/lib/libmd/md4.h
+++ b/lib/libmd/md4.h
@@ -1,5 +1,4 @@
/* MD4.H - header file for MD4C.C
- * $FreeBSD$
*/
/*-
diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c
index 66d3652465a9..d98221d264fc 100644
--- a/lib/libmd/md4c.c
+++ b/lib/libmd/md4c.c
@@ -2,8 +2,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*-
SPDX-License-Identifier: RSA-MD
diff --git a/lib/libmd/md5.copyright b/lib/libmd/md5.copyright
index b718bf8b5ebe..08bb01166590 100644
--- a/lib/libmd/md5.copyright
+++ b/lib/libmd/md5.copyright
@@ -1,4 +1,3 @@
-.\" $FreeBSD$
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
.Pp
diff --git a/lib/libmd/md5.h b/lib/libmd/md5.h
index 631dec819e79..a4a9f47d4d90 100644
--- a/lib/libmd/md5.h
+++ b/lib/libmd/md5.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
#ifndef _MD5_H_
#define _MD5_H_
diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c
index fc852b913464..56f21f441e2c 100644
--- a/lib/libmd/md5c.c
+++ b/lib/libmd/md5c.c
@@ -28,9 +28,6 @@
* edited for clarity and style only.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#ifdef _KERNEL
diff --git a/lib/libmd/mdX.3 b/lib/libmd/mdX.3
index 30e6f367c662..26c8b2b43c81 100644
--- a/lib/libmd/mdX.3
+++ b/lib/libmd/mdX.3
@@ -6,8 +6,6 @@
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
-.\" $FreeBSD$
-.\"
.Dd May 21, 2019
.Dt MDX 3
.Os
@@ -95,8 +93,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
@@ -162,7 +159,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr MDXEnd 2
+.Xr MDXEnd 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -201,15 +198,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/mdXhl.c b/lib/libmd/mdXhl.c
index 983ea8add989..171b97b38794 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -9,9 +9,6 @@
* ----------------------------------------------------------------------------
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/lib/libmd/mddriver.c b/lib/libmd/mddriver.c
index 6c543974668d..47ff87663bff 100644
--- a/lib/libmd/mddriver.c
+++ b/lib/libmd/mddriver.c
@@ -11,9 +11,6 @@
* These notices must be retained in any copies of any part of this
* documentation and/or software. */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
diff --git a/lib/libmd/ripemd.3 b/lib/libmd/ripemd.3
index d868ae12827b..fcd2ea308791 100644
--- a/lib/libmd/ripemd.3
+++ b/lib/libmd/ripemd.3
@@ -7,7 +7,6 @@
.\" ----------------------------------------------------------------------------
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
-.\" $FreeBSD$
.\"
.Dd July 20, 2018
.Dt RIPEMD 3
@@ -75,8 +74,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
@@ -142,7 +140,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr RIPEMD160_End 2
+.Xr RIPEMD160_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -156,9 +154,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/ripemd.h b/lib/libmd/ripemd.h
index 8f202a53ed84..fa9f513ebfd8 100644
--- a/lib/libmd/ripemd.h
+++ b/lib/libmd/ripemd.h
@@ -57,13 +57,11 @@
*/
/*
- * $FreeBSD$
*/
#ifndef HEADER_RIPEMD_H
#define HEADER_RIPEMD_H
-#include <sys/cdefs.h>
#include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */
#define RIPEMD160_CBLOCK 64
diff --git a/lib/libmd/rmd160c.c b/lib/libmd/rmd160c.c
index fa58b7b8735f..66ba0a5e5c72 100644
--- a/lib/libmd/rmd160c.c
+++ b/lib/libmd/rmd160c.c
@@ -56,9 +56,6 @@
* [including the GNU Public Licence.]
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
@@ -88,8 +85,7 @@ void ripemd160_block_x86(RIPEMD160_CTX *c, const u_int32_t *p,int num);
void ripemd160_block(RIPEMD160_CTX *c, const u_int32_t *p,int num);
#endif
-void RIPEMD160_Init(c)
-RIPEMD160_CTX *c;
+void RIPEMD160_Init(RIPEMD160_CTX *c)
{
c->A=RIPEMD160_A;
c->B=RIPEMD160_B;
@@ -101,10 +97,7 @@ RIPEMD160_CTX *c;
c->num=0;
}
-void RIPEMD160_Update(c, in, len)
-RIPEMD160_CTX *c;
-const void *in;
-size_t len;
+void RIPEMD160_Update(RIPEMD160_CTX *c, const void *in, size_t len)
{
u_int32_t *p;
int sw,sc;
@@ -233,9 +226,7 @@ size_t len;
}
}
-void RIPEMD160_Transform(c,b)
-RIPEMD160_CTX *c;
-unsigned char *b;
+void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b)
{
u_int32_t p[16];
#if BYTE_ORDER != LITTLE_ENDIAN
@@ -272,10 +263,7 @@ unsigned char *b;
#ifndef RMD160_ASM
-void ripemd160_block(ctx, X, num)
-RIPEMD160_CTX *ctx;
-const u_int32_t *X;
-int num;
+void ripemd160_block(RIPEMD160_CTX *ctx, const u_int32_t *X, int num)
{
u_int32_t A,B,C,D,E;
u_int32_t a,b,c,d,e;
@@ -472,9 +460,7 @@ int num;
}
#endif
-void RIPEMD160_Final(md, c)
-unsigned char *md;
-RIPEMD160_CTX *c;
+void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c)
{
int i,j;
u_int32_t l;
@@ -528,8 +514,7 @@ RIPEMD160_CTX *c;
}
#ifdef undef
-int printit(l)
-unsigned long *l;
+int printit(unsigned long *l)
{
int i,ii;
diff --git a/lib/libmd/rmddriver.c b/lib/libmd/rmddriver.c
index 1c03b79b76be..3c37c2866bfd 100644
--- a/lib/libmd/rmddriver.c
+++ b/lib/libmd/rmddriver.c
@@ -11,9 +11,6 @@
* These notices must be retained in any copies of any part of this
* documentation and/or software. */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
diff --git a/lib/libmd/sha.3 b/lib/libmd/sha.3
index 20a1e5639dde..49ee322eacab 100644
--- a/lib/libmd/sha.3
+++ b/lib/libmd/sha.3
@@ -7,9 +7,8 @@
.\" ----------------------------------------------------------------------------
.\"
.\" 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 +75,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 +101,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
@@ -173,7 +164,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr SHA1_End 2
+.Xr SHA1_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -188,23 +179,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/sha.h b/lib/libmd/sha.h
index af32f56bfb5b..6c7b0c0c30b3 100644
--- a/lib/libmd/sha.h
+++ b/lib/libmd/sha.h
@@ -53,14 +53,11 @@
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
- *
- * $FreeBSD$
*/
#ifndef _SHA_H_
#define _SHA_H_ 1
-#include <sys/cdefs.h>
#include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */
#define SHA_CBLOCK 64
diff --git a/lib/libmd/sha0c.c b/lib/libmd/sha0c.c
index 438c3a4852ff..4c39ed842ea9 100644
--- a/lib/libmd/sha0c.c
+++ b/lib/libmd/sha0c.c
@@ -56,9 +56,6 @@
* [including the GNU Public Licence.]
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
@@ -102,8 +99,7 @@ char *SHA_version="SHA part of SSLeay 0.9.0b 11-Oct-1998";
#define M_p_c2nl_p p_c2nl_p
#define M_nl2c nl2c
-void SHA_Init(c)
-SHA_CTX *c;
+void SHA_Init(SHA_CTX *c)
{
c->h0=INIT_DATA_h0;
c->h1=INIT_DATA_h1;
@@ -115,10 +111,7 @@ SHA_CTX *c;
c->num=0;
}
-void SHA_Update(c, in, len)
-SHA_CTX *c;
-const void *in;
-size_t len;
+void SHA_Update(SHA_CTX *c, const void *in, size_t len)
{
u_int32_t *p;
int ew,ec,sw,sc;
@@ -249,9 +242,7 @@ size_t len;
p[sw]=l;
}
-void SHA_Transform(c,b)
-SHA_CTX *c;
-unsigned char *b;
+void SHA_Transform(SHA_CTX *c, unsigned char *b)
{
u_int32_t p[16];
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -286,10 +277,7 @@ unsigned char *b;
sha_block(c,p,64);
}
-void sha_block(c, W, num)
-SHA_CTX *c;
-const u_int32_t *W;
-int num;
+void sha_block(SHA_CTX *c, const u_int32_t *W, int num)
{
u_int32_t A,B,C,D,E,T;
u_int32_t X[16];
@@ -405,9 +393,7 @@ int num;
}
}
-void SHA_Final(md, c)
-unsigned char *md;
-SHA_CTX *c;
+void SHA_Final(unsigned char *md, SHA_CTX *c)
{
int i,j;
u_int32_t l;
diff --git a/lib/libmd/sha1c.c b/lib/libmd/sha1c.c
index 870af2ab1556..299a9149be4a 100644
--- a/lib/libmd/sha1c.c
+++ b/lib/libmd/sha1c.c
@@ -56,9 +56,6 @@
* [including the GNU Public Licence.]
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
@@ -129,8 +126,7 @@ char *SHA1_version="SHA1 part of SSLeay 0.9.0b 11-Oct-1998";
# define M_nl2c nl2c
#endif
-void SHA1_Init(c)
-SHA_CTX *c;
+void SHA1_Init(SHA_CTX *c)
{
c->h0=INIT_DATA_h0;
c->h1=INIT_DATA_h1;
@@ -143,10 +139,7 @@ SHA_CTX *c;
}
void
-SHA1_Update(c, in, len)
- SHA_CTX *c;
- const void *in;
- size_t len;
+SHA1_Update(SHA_CTX *c, const void *in, size_t len)
{
u_int32_t *p;
int ew,ec,sw,sc;
@@ -277,9 +270,7 @@ SHA1_Update(c, in, len)
p[sw]=l;
}
-void SHA1_Transform(c,b)
-SHA_CTX *c;
-unsigned char *b;
+void SHA1_Transform(SHA_CTX *c, unsigned char *b)
{
u_int32_t p[16];
#if BYTE_ORDER != BIG_ENDIAN
@@ -317,10 +308,7 @@ unsigned char *b;
#ifndef SHA1_ASM
void
-sha1_block(c, W, num)
- SHA_CTX *c;
- const u_int32_t *W;
- int num;
+sha1_block(SHA_CTX *c, const u_int32_t *W, int num)
{
u_int32_t A,B,C,D,E,T;
u_int32_t X[16];
@@ -437,9 +425,7 @@ sha1_block(c, W, num)
}
#endif
-void SHA1_Final(md, c)
-unsigned char *md;
-SHA_CTX *c;
+void SHA1_Final(unsigned char *md, SHA_CTX *c)
{
int i,j;
u_int32_t l;
diff --git a/lib/libmd/sha256.3 b/lib/libmd/sha256.3
index d11f2f783557..e22258f40140 100644
--- a/lib/libmd/sha256.3
+++ b/lib/libmd/sha256.3
@@ -7,7 +7,6 @@
.\" ----------------------------------------------------------------------------
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
-.\" $FreeBSD$
.\"
.Dd July 20, 2018
.Dt SHA256 3
@@ -97,8 +96,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
@@ -164,7 +162,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr SHA256_End 2
+.Xr SHA256_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -178,9 +176,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 6a5ed6f887d9..a5c478efa9ae 100644
--- a/lib/libmd/sha512.3
+++ b/lib/libmd/sha512.3
@@ -7,9 +7,8 @@
.\" ----------------------------------------------------------------------------
.\"
.\" 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 +26,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 +77,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 +139,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 +186,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
@@ -208,7 +241,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr SHA512_End 2
+.Xr SHA512_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -223,9 +256,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..42d57ed2016f 100644
--- a/lib/libmd/shadriver.c
+++ b/lib/libmd/shadriver.c
@@ -14,9 +14,6 @@
* These notices must be retained in any copies of any part of this
* documentation and/or software. */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>
@@ -51,6 +48,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 325a1ab4874b..1dff9e2c92dc 100644
--- a/lib/libmd/skein.3
+++ b/lib/libmd/skein.3
@@ -23,8 +23,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.Dd May 21, 2019
.Dt SKEIN 3
.Os
@@ -133,8 +131,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
@@ -206,7 +203,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr SKEIN256_End 2
+.Xr SKEIN256_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
diff --git a/lib/libmd/skeindriver.c b/lib/libmd/skeindriver.c
index ee70ef7cd7dc..874f0c17e500 100644
--- a/lib/libmd/skeindriver.c
+++ b/lib/libmd/skeindriver.c
@@ -14,9 +14,6 @@
* These notices must be retained in any copies of any part of this
* documentation and/or software. */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/types.h>
#include <stdio.h>