Skip to content

Commit

Permalink
Eighth import of some freebsd 13-stable features from Oct 28
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Oct 30, 2024
1 parent f80fb8f commit ce4a8c5
Show file tree
Hide file tree
Showing 2,048 changed files with 85,135 additions and 75,336 deletions.
38 changes: 14 additions & 24 deletions lib/libmd/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
*/

#include <sys/cdefs.h>

/*-
SPDX-License-Identifier: RSA-MD
Expand Down Expand Up @@ -92,8 +91,8 @@ static unsigned char PADDING[64] = {

/* MD4 initialization. Begins an MD4 operation, writing a new context.
*/
void MD4Init (context)
MD4_CTX *context; /* context */
void
MD4Init(MD4_CTX *context)
{
context->count[0] = context->count[1] = 0;

Expand All @@ -109,10 +108,8 @@ MD4_CTX *context; /* context */
operation, processing another message block, and updating the
context.
*/
void MD4Update (context, in, inputLen)
MD4_CTX *context; /* context */
const void *in; /* input block */
unsigned int inputLen; /* length of input block */
void
MD4Update(MD4_CTX *context, const void *in, unsigned int inputLen)
{
unsigned int i, idx, partLen;
const unsigned char *input = in;
Expand Down Expand Up @@ -148,8 +145,8 @@ unsigned int inputLen; /* length of input block */
}

/* MD4 padding. */
void MD4Pad (context)
MD4_CTX *context; /* context */
void
MD4Pad(MD4_CTX *context)
{
unsigned char bits[8];
unsigned int idx, padLen;
Expand All @@ -170,9 +167,8 @@ MD4_CTX *context; /* context */
/* MD4 finalization. Ends an MD4 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void MD4Final (digest, context)
unsigned char digest[16]; /* message digest */
MD4_CTX *context; /* context */
void
MD4Final(unsigned char digest[16], MD4_CTX *context)
{
/* Do padding */
MD4Pad (context);
Expand All @@ -187,9 +183,8 @@ MD4_CTX *context; /* context */

/* MD4 basic transformation. Transforms state based on block.
*/
static void MD4Transform (state, block)
UINT4 state[4];
const unsigned char block[64];
static void
MD4Transform(UINT4 state[4], const unsigned char block[64])
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];

Expand Down Expand Up @@ -262,10 +257,8 @@ const unsigned char block[64];
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
static void
Encode(unsigned char *output, UINT4 *input, unsigned int len)
{
unsigned int i, j;

Expand All @@ -280,11 +273,8 @@ unsigned int len;
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)

UINT4 *output;
const unsigned char *input;
unsigned int len;
static void
Decode(UINT4 *output, const unsigned char *input, unsigned int len)
{
unsigned int i, j;

Expand Down
1 change: 0 additions & 1 deletion lib/libmd/md5c.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/

#include <sys/cdefs.h>

#include <sys/types.h>

#ifdef _KERNEL
Expand Down
35 changes: 26 additions & 9 deletions lib/libmd/mdX.3
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
.\"
.Dd July 20, 2018
.Dd May 21, 2019
.Dt MDX 3
.Os
.Sh NAME
Expand Down Expand Up @@ -94,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
Expand Down Expand Up @@ -143,6 +141,26 @@ after use.
If the
.Fa buf
argument is non-null it must point to at least 33 characters of buffer space.
.Sh ERRORS
The
.Fn MDXEnd
function called with a null buf argument may fail and return NULL if:
.Bl -tag -width Er
.It Bq Er ENOMEM
Insufficient storage space is available.
.El
.Pp
The
.Fn MDXFile
and
.Fn MDXFileChunk
may return NULL when underlying
.Xr open 2 ,
.Xr fstat 2 ,
.Xr lseek 2 ,
or
.Xr MDXEnd 2
fail.
.Sh SEE ALSO
.Xr md4 3 ,
.Xr md5 3 ,
Expand Down Expand Up @@ -180,13 +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 [email protected] .
.Pp
Phk ristede runen.
.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.
There is on the other hand no guarantee that such a method does not exist.
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.
1 change: 0 additions & 1 deletion lib/libmd/mdXhl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

#include <sys/cdefs.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down
1 change: 0 additions & 1 deletion lib/libmd/mddriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* documentation and/or software. */

#include <sys/cdefs.h>

#include <sys/types.h>

#include <stdio.h>
Expand Down
27 changes: 22 additions & 5 deletions lib/libmd/ripemd.3
Original file line number Diff line number Diff line change
Expand Up @@ -74,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
Expand Down Expand Up @@ -123,6 +122,26 @@ after use.
If the
.Fa buf
argument is non-null it must point to at least 41 characters of buffer space.
.Sh ERRORS
The
.Fn RIPEMD160_End
function called with a null buf argument may fail and return NULL if:
.Bl -tag -width Er
.It Bq Er ENOMEM
Insufficient storage space is available.
.El
.Pp
The
.Fn RIPEMD160_File
and
.Fn RIPEMD160_FileChunk
may return NULL when underlying
.Xr open 2 ,
.Xr fstat 2 ,
.Xr lseek 2 ,
or
.Xr RIPEMD160_End 2
fail.
.Sh SEE ALSO
.Xr md4 3 ,
.Xr md5 3 ,
Expand All @@ -135,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.
Expand Down
1 change: 0 additions & 1 deletion lib/libmd/rmd160c.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
*/

#include <sys/cdefs.h>

#include <sys/types.h>

#include <stdio.h>
Expand Down
1 change: 0 additions & 1 deletion lib/libmd/rmddriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* documentation and/or software. */

#include <sys/cdefs.h>

#include <sys/types.h>

#include <stdio.h>
Expand Down
59 changes: 29 additions & 30 deletions lib/libmd/sha.3
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
.\"
.Dd July 20, 2018
.Dd February 6, 2023
.Dt SHA 3
.Os
.Sh NAME
Expand Down Expand Up @@ -75,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 ,
Expand All @@ -108,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
Expand Down Expand Up @@ -154,6 +146,26 @@ after use.
If the
.Fa buf
argument is non-null it must point to at least 41 characters of buffer space.
.Sh ERRORS
The
.Fn SHA1_End
function called with a null buf argument may fail and return NULL if:
.Bl -tag -width Er
.It Bq Er ENOMEM
Insufficient storage space is available.
.El
.Pp
The
.Fn SHA1_File
and
.Fn SHA1_FileChunk
may return NULL when underlying
.Xr open 2 ,
.Xr fstat 2 ,
.Xr lseek 2 ,
or
.Xr SHA1_End 2
fail.
.Sh SEE ALSO
.Xr md4 3 ,
.Xr md5 3 ,
Expand All @@ -167,21 +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
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.
There is on the other hand no guarantee that such a method does not exist.
.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.)
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.
1 change: 0 additions & 1 deletion lib/libmd/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
* 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.]
*
*/

#ifndef _SHA_H_
Expand Down
1 change: 0 additions & 1 deletion lib/libmd/sha0c.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
*/

#include <sys/cdefs.h>

#include <sys/types.h>

#include <stdio.h>
Expand Down
1 change: 0 additions & 1 deletion lib/libmd/sha1c.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
*/

#include <sys/cdefs.h>

#include <sys/types.h>

#include <stdio.h>
Expand Down
Loading

0 comments on commit ce4a8c5

Please sign in to comment.