New upstream version 5.2.5188

This commit is contained in:
geos_one
2025-08-08 12:40:03 +02:00
parent b1e9cf955b
commit e8b2c75644
5730 changed files with 1430965 additions and 238433 deletions

12
3rdparty/BLAKE2/b2sum/README.md vendored Normal file
View File

@@ -0,0 +1,12 @@
# b2sum #
This is a simple tool to create BLAKE2 hashes of files or streams. For more usage information refer to the manpage, e.g., `man b2sum.1`.
## Building and Installing ##
To build `b2sum`, just run `make`. To install, run `make install`. The install path can be altered using the `PREFIX` variable, which defaults to `/usr/local`. Use `PREFIX=/some/path make install` to install somewhere else.
`b2sum` makes use of OpenMP by default. Some compilers do not support this technology, in which case `b2sum` can be built without it using the `NO_OPENMP` variable. Use `NO_OPENMP=1 make` to build without OpenMP.
For OS X, there is a prebuilt [Homebrew formula](https://github.com/Homebrew/homebrew-core/commit/e016cda47dfa298c6628de3e9d0fd976eecd91be) which may be installed with `brew install b2sum`.

93
3rdparty/BLAKE2/b2sum/b2sum.1 vendored Normal file
View File

@@ -0,0 +1,93 @@
.Dd February 20, 2016
.Dt B2SUM 1
.Os
.Sh NAME
.Nm b2sum
.Nd generate checksums using the BLAKE2 hash function
.Sh SYNOPSIS
.Nm
.Op Fl a Ar algorithm
.Op Fl l Ar length
.Op Fl -tag
.Op Ar file ...
.Nm
.Op Fl -help
.Sh DESCRIPTION
The
.Nm
command generates checksums for files using the BLAKE2 cryptographic
hash function and writes them to standard output.
.Pp
When
.Op Ar file ...
is empty or -,
.Nm
reads from standard input.
.Bl -tag -width Ar
.It Fl a Ar algorithm
Specify a variant of BLAKE2 to use when generating checksums. The
variants are listed under the algorithms section, and the default
is blake2b.
.It Fl l Ar length
Specify the digest length in bits. It must not exceed the maximum
for the variant of BLAKE2 being used, and must be a multiple of 8.
.It Fl -tag
Prepend the checksums with
.Qq "ALGORITHM-NAME (file) =" ,
a format common on BSD systems.
.It Fl -help
Display usage.
.El
.Sh ALGORITHMS
.Bl -tag -width blake2xx
.It blake2b
optimized for 64-bit platforms and NEON-enabled ARMs, produces digests
of any size between 1 and 64 bytes
.It blake2s
optimized for 8 to 32-bit platforms, produces digests of any size
between 1 and 32 bytes
.It blake2bp
4-way parallel BLAKE2b
.It blake2sp
8-way parallel BLAKE2s
.El
.Sh SEE ALSO
.Xr shasum 1
.Sh STANDARDS
.Bl -tag -width "RFC XXXX"
.It RFC 7693
The BLAKE2 Cryptographic Hash and Message Authentication Code
.El
.Sh AUTHORS
.Nm
is part of the
.Em BLAKE2
official implementation. BLAKE2 was designed by
.An -nosplit
.An "Jean-Philippe Aumasson" ,
.An "Samuel Neves" ,
.An "Zooko Wilcox-O'Hearn" , and
.An "Christian Winnerlein" .
.Pp
BLAKE2 is based on the SHA-3 proposal
.Em BLAKE
which was designed by
.An "Jean-Philippe Aumasson" ,
.An "Luca Henzen" ,
.An "Willi Meier" , and
.An "Raphael C.-W. Phan" .
.Pp
BLAKE2, like BLAKE, relies on the
.Em ChaCha20
stream cipher, designed by
.An Daniel J. Bernstein .
.Pp
A mailing list for BLAKE2 can be subscribed to by sending an empty
message to
.Mt info-subscribe@blake2.net .
.Pp
The four designers of BLAKE2 can be contacted at
.Mt contact@blake2.net .
.Pp
This manual page was written by
.Lk https://github.com/Scarletts Scarlett .

387
3rdparty/BLAKE2/b2sum/b2sum.c vendored Normal file
View File

@@ -0,0 +1,387 @@
/*
BLAKE2 reference source code package - b2sum tool
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
#include <stdbool.h>
#include "blake2.h"
/* This will help compatibility with coreutils */
int blake2s_stream( FILE *stream, void *resstream, size_t outbytes )
{
int ret = -1;
size_t sum, n;
blake2s_state S[1];
static const size_t buffer_length = 32768;
uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
if( !buffer ) return -1;
blake2s_init( S, outbytes );
while( 1 )
{
sum = 0;
while( 1 )
{
n = fread( buffer + sum, 1, buffer_length - sum, stream );
sum += n;
if( buffer_length == sum )
break;
if( 0 == n )
{
if( ferror( stream ) )
goto cleanup_buffer;
goto final_process;
}
if( feof( stream ) )
goto final_process;
}
blake2s_update( S, buffer, buffer_length );
}
final_process:;
if( sum > 0 ) blake2s_update( S, buffer, sum );
blake2s_final( S, resstream, outbytes );
ret = 0;
cleanup_buffer:
free( buffer );
return ret;
}
int blake2b_stream( FILE *stream, void *resstream, size_t outbytes )
{
int ret = -1;
size_t sum, n;
blake2b_state S[1];
static const size_t buffer_length = 32768;
uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
if( !buffer ) return -1;
blake2b_init( S, outbytes );
while( 1 )
{
sum = 0;
while( 1 )
{
n = fread( buffer + sum, 1, buffer_length - sum, stream );
sum += n;
if( buffer_length == sum )
break;
if( 0 == n )
{
if( ferror( stream ) )
goto cleanup_buffer;
goto final_process;
}
if( feof( stream ) )
goto final_process;
}
blake2b_update( S, buffer, buffer_length );
}
final_process:;
if( sum > 0 ) blake2b_update( S, buffer, sum );
blake2b_final( S, resstream, outbytes );
ret = 0;
cleanup_buffer:
free( buffer );
return ret;
}
int blake2sp_stream( FILE *stream, void *resstream, size_t outbytes )
{
int ret = -1;
size_t sum, n;
blake2sp_state S[1];
static const size_t buffer_length = 16 * ( 1UL << 20 );
uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
if( !buffer ) return -1;
blake2sp_init( S, outbytes );
while( 1 )
{
sum = 0;
while( 1 )
{
n = fread( buffer + sum, 1, buffer_length - sum, stream );
sum += n;
if( buffer_length == sum )
break;
if( 0 == n )
{
if( ferror( stream ) )
goto cleanup_buffer;
goto final_process;
}
if( feof( stream ) )
goto final_process;
}
blake2sp_update( S, buffer, buffer_length );
}
final_process:;
if( sum > 0 ) blake2sp_update( S, buffer, sum );
blake2sp_final( S, resstream, outbytes );
ret = 0;
cleanup_buffer:
free( buffer );
return ret;
}
int blake2bp_stream( FILE *stream, void *resstream, size_t outbytes )
{
int ret = -1;
size_t sum, n;
blake2bp_state S[1];
static const size_t buffer_length = 16 * ( 1UL << 20 );
uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
if( !buffer ) return -1;
blake2bp_init( S, outbytes );
while( 1 )
{
sum = 0;
while( 1 )
{
n = fread( buffer + sum, 1, buffer_length - sum, stream );
sum += n;
if( buffer_length == sum )
break;
if( 0 == n )
{
if( ferror( stream ) )
goto cleanup_buffer;
goto final_process;
}
if( feof( stream ) )
goto final_process;
}
blake2bp_update( S, buffer, buffer_length );
}
final_process:;
if( sum > 0 ) blake2bp_update( S, buffer, sum );
blake2bp_final( S, resstream, outbytes );
ret = 0;
cleanup_buffer:
free( buffer );
return ret;
}
typedef int ( *blake2fn )( FILE *, void *, size_t );
static void usage( char **argv, int errcode )
{
FILE *out = errcode ? stderr : stdout;
fprintf( out, "Usage: %s [OPTION]... [FILE]...\n", argv[0] );
fprintf( out, "\n" );
fprintf( out, "With no FILE, or when FILE is -, read standard input.\n" );
fprintf( out, "\n" );
fprintf( out, " -a <algo> hash algorithm (blake2b is default): \n"
" [blake2b|blake2s|blake2bp|blake2sp]\n" );
fprintf( out, " -l <length> digest length in bits, must not exceed the maximum for\n"
" the selected algorithm and must be a multiple of 8\n" );
fprintf( out, " --tag create a BSD-style checksum\n" );
fprintf( out, " --help display this help and exit\n" );
exit( errcode );
}
int main( int argc, char **argv )
{
blake2fn blake2_stream = blake2b_stream;
unsigned long maxbytes = BLAKE2B_OUTBYTES;
const char *algorithm = "BLAKE2b";
unsigned long outbytes = 0;
unsigned char hash[BLAKE2B_OUTBYTES] = {0};
bool bsdstyle = false;
int c, i;
opterr = 1;
while( 1 )
{
int option_index = 0;
char *end = NULL;
unsigned long outbits;
static struct option long_options[] = {
{ "help", no_argument, 0, 0 },
{ "tag", no_argument, 0, 0 },
{ NULL, 0, NULL, 0 }
};
c = getopt_long( argc, argv, "a:l:", long_options, &option_index );
if( c == -1 ) break;
switch( c )
{
case 'a':
if( 0 == strcmp( optarg, "blake2b" ) )
{
blake2_stream = blake2b_stream;
maxbytes = BLAKE2B_OUTBYTES;
algorithm = "BLAKE2b";
}
else if ( 0 == strcmp( optarg, "blake2s" ) )
{
blake2_stream = blake2s_stream;
maxbytes = BLAKE2S_OUTBYTES;
algorithm = "BLAKE2s";
}
else if ( 0 == strcmp( optarg, "blake2bp" ) )
{
blake2_stream = blake2bp_stream;
maxbytes = BLAKE2B_OUTBYTES;
algorithm = "BLAKE2bp";
}
else if ( 0 == strcmp( optarg, "blake2sp" ) )
{
blake2_stream = blake2sp_stream;
maxbytes = BLAKE2S_OUTBYTES;
algorithm = "BLAKE2sp";
}
else
{
printf( "Invalid function name: `%s'\n", optarg );
usage( argv, 111 );
}
break;
case 'l':
outbits = strtoul(optarg, &end, 10);
if( !end || *end != '\0' || outbits % 8 != 0)
{
printf( "Invalid length argument: `%s'\n", optarg);
usage( argv, 111 );
}
outbytes = outbits / 8;
break;
case 0:
if( 0 == strcmp( "help", long_options[option_index].name ) )
usage( argv, 0 );
else if( 0 == strcmp( "tag", long_options[option_index].name ) )
bsdstyle = true;
break;
case '?':
usage( argv, 1 );
break;
}
}
if(outbytes > maxbytes)
{
printf( "Invalid length argument: %lu\n", outbytes * 8 );
printf( "Maximum digest length for %s is %lu\n", algorithm, maxbytes * 8 );
usage( argv, 111 );
}
else if( outbytes == 0 )
outbytes = maxbytes;
if( optind == argc )
argv[argc++] = (char *) "-";
for( i = optind; i < argc; ++i )
{
FILE *f = NULL;
if( argv[i][0] == '-' && argv[i][1] == '\0' )
f = stdin;
else
f = fopen( argv[i], "rb" );
if( !f )
{
fprintf( stderr, "Could not open `%s': %s\n", argv[i], strerror( errno ) );
continue;
}
if( blake2_stream( f, hash, outbytes ) < 0 )
{
fprintf( stderr, "Failed to hash `%s'\n", argv[i] );
}
else
{
size_t j;
if( bsdstyle )
{
if( outbytes < maxbytes )
printf( "%s-%lu (%s) = ", algorithm, outbytes * 8, argv[i] );
else
printf( "%s (%s) = ", algorithm, argv[i] );
}
for( j = 0; j < outbytes; ++j )
printf( "%02x", hash[j] );
if( bsdstyle )
printf( "\n" );
else
printf( " %s\n", argv[i] );
}
if( f != stdin ) fclose( f );
}
return 0;
}

24
3rdparty/BLAKE2/b2sum/makefile vendored Normal file
View File

@@ -0,0 +1,24 @@
PROG=b2sum
PREFIX?=/usr/local
MANDIR?=$(PREFIX)/man
NO_OPENMP?=0
NO_OPENMP_0=-fopenmp
NO_OPENMP_1=
CC?=gcc
CFLAGS?=-O3 -march=native
CFLAGS+=-std=c89 -Wall -Wextra -pedantic -Wno-long-long -I../sse
CFLAGS+=$(NO_OPENMP_$(NO_OPENMP))
LIBS=
#FILES=b2sum.c ../ref/blake2b-ref.c ../ref/blake2s-ref.c ../ref/blake2bp-ref.c ../ref/blake2sp-ref.c
FILES=b2sum.c ../sse/blake2b.c ../sse/blake2s.c ../sse/blake2bp.c ../sse/blake2sp.c
all: $(FILES)
$(CC) $(FILES) $(CFLAGS) $(LIBS) -o $(PROG)
clean:
rm -f $(PROG)
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(MANDIR)/man1
install -m 755 $(PROG) $(DESTDIR)$(PREFIX)/bin
install -m 644 b2sum.1 $(DESTDIR)$(MANDIR)/man1/$(PROG).1