On 05/10/2025 01:32, Collin Funk wrote:
I was looking at changing announce-gen to use SHA-256 and SHA3-256
instead of SHA-1 and SHA-256. That lead me to discovering the following:

     $ cksum -a sha3 --length=256 --base64 --untagged \
         Makefile > Makefile.sum
     $ cksum -a sha3 --check Makefile.sum
     cksum: Makefile.sum: no properly formatted checksum lines found

The same issue exists for --algorithm=sha2. This patch fixes it:

     $ ./src/cksum -a sha3 --check Makefile.sum
     Makefile: OK
     $ sed 's|[[:graph:]]  Makefile$|  Makefile|g' \
         Makefile.sum > truncated
     $ ./src/cksum -a sha3 --check truncated
     cksum: truncated: no properly formatted checksum lines found

I left the behavior the same for blake2b since 'b2sum' does not support
--base64. I'm not sure if 'cksum -a blake2b' and 'b2sum' should differ
in this case...

Nice one.

Re blake2b we probably should auto determine digest_hex_bytes
in the base64 case too, so that all length adjustable algorithms
are supported in untagged format. (like b2sum, sha256sum also
does not support --base64).

Since this isn't a regression, but rather an oversight since --base64 was added,
if the blake2b case is addressed, then the NEWS could be generalized to say:

  'cksum --check' now supports base64 encoded input in untagged format,
  for all length adjustable algorithms (blake2b, sha2, sha3).
  [bug introduced in coreutils-9.2]


I'd use `tr -d '='` rather than `sed 's|[[:graph:]]...` in the test
as it's more obvious and also I'm not sure how portable the :graph: is.

You left a debugging cp ... $HOME in the test.

Otherwise it looks good.

thanks!
Padraig

p.s. I notice another edge case with checking untagged base64 format.
Theoretically a base64 checksum could start with SHA256 etc.
which would currently cause cksum to treat it as misformatted line.

Reply via email to