mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-20 18:56:39 +02:00
cksum: add support for SHA-3
* src/digest.c: Include sha3.h. (BLAKE2B_MAX_LEN): Rename to DIGEST_MAX_LEN since it is also used for SHA-3. (sha3_sum_stream): New function. (enum Algorithm, algorithm_args, algorithm_args, algorithm_types) algorithm_tags, algorithm_bits, cksumfns, cksum_output_fns): Add entries for SHA-3. (usage): Mention that SHA-3 is supported. Mention requirements for --length with SHA-3. (split_3): Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Determine the length of the digest for SHA-3. Make sure it is 224, 256, 384, or 512. (digest_file): Set the digest length in bytes. Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Always append the digest length to SHA3 in the output. (main): Allow the use of --length with 'cksum -a sha3'. Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Make sure it is 224, 256, 384, or 512. * tests/cksum/cksum-base64.pl (@pairs): Add expected sha3 output. (fmt): Modify the output to use SHA3-512 since that is the default. (@Tests): Modify arguments for sha3 to use --length=512. * tests/cksum/cksum-sha3.sh: New test, based on tests/cksum/b2sum.sh. * tests/local.mk (all_tests): Add the test. * bootstrap.conf: Add crypto/sha3. * gnulib: Update to latest commit. * NEWS: Mention the change. * doc/coreutils.texi (cksum general options): Mention sha3 as a supported argument to the -a option. Mention that 'cksum -a sha3' supports the --length option. Mention that SHA-3 is considered secure.
This commit is contained in:
@@ -4151,6 +4151,7 @@ Supported more modern digest algorithms are:
|
||||
@samp{sha256} equivalent to @command{sha256sum}
|
||||
@samp{sha384} equivalent to @command{sha384sum}
|
||||
@samp{sha512} equivalent to @command{sha512sum}
|
||||
@samp{sha3} only available through @command{cksum}
|
||||
@samp{blake2b} equivalent to @command{b2sum}
|
||||
@samp{sm3} only available through @command{cksum}
|
||||
@end example
|
||||
@@ -4174,18 +4175,19 @@ input digest string as what is output. I.e., removing or adding any
|
||||
Output extra information to standard error,
|
||||
like the checksum implementation being used.
|
||||
|
||||
@macro cksumLengthOption
|
||||
@item -l
|
||||
@itemx --length
|
||||
@opindex -l
|
||||
@opindex --length
|
||||
@cindex BLAKE2 hash length
|
||||
Change (shorten) the default digest length.
|
||||
This is specified in bits and thus must be a multiple of 8.
|
||||
@cindex SHA-3 hash length
|
||||
Specify the digest size used with @option{-a sha3} or @option{-a blake2b}.
|
||||
For @samp{blake2b} this is optional, with 512 being the default. If the
|
||||
option is given it must be a multiple of 8. For @samp{sha3} this option
|
||||
is required, and the @var{length} must be one of 224, 256, 384, or 512.
|
||||
|
||||
This option is ignored when @option{--check} is specified,
|
||||
as the length is automatically determined when checking.
|
||||
@end macro
|
||||
@cksumLengthOption
|
||||
|
||||
@item --raw
|
||||
@opindex --raw
|
||||
@@ -4368,7 +4370,7 @@ against malicious tampering: although finding a file with a given \hash\
|
||||
fingerprint is considered infeasible at the moment, it is known how
|
||||
to modify certain files, including digital certificates, so that they
|
||||
appear valid when signed with an \hash\ digest. For more secure hashes,
|
||||
consider using SHA-2 or @command{b2sum}.
|
||||
consider using SHA-2, SHA-3, or @command{b2sum}.
|
||||
@xref{sha2 utilities}. @xref{b2sum invocation}.
|
||||
@end macro
|
||||
@weakHash{MD5}
|
||||
@@ -4411,7 +4413,19 @@ The program accepts @ref{cksum common options}. Also see @ref{Common options}.
|
||||
In addition @command{b2sum} supports the following options.
|
||||
|
||||
@table @samp
|
||||
@cksumLengthOption
|
||||
|
||||
@item -l
|
||||
@itemx --length
|
||||
@opindex -l
|
||||
@opindex --length
|
||||
@cindex BLAKE2 hash length
|
||||
Specify the digest size used by the algorithm. This option is optional.
|
||||
By default a 512 bit digest will be used. If the option is given it
|
||||
must be a multiple of 8.
|
||||
|
||||
This option is ignored when @option{--check} is specified,
|
||||
as the length is automatically determined when checking.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user