8

Situation

I'm on FreeBSD 11.2 without GUI. I'm brand new to BSD systems.

Suppose we have a SHA512SUM file generated on FreeBSD with:

sha512 encrypt-file-aes256 decrypt-file-aes256 > SHA512SUM

It looks different from the Linux format, which from Linux can be generated using --tag switch:

SHA512 (encrypt-file-aes256) = 9170caaa45303d2e5f04c21732500980f3b06fc361018f953127506b56d3f2f46c95efdc291e160dd80e39b5304f327d83fe72c625ab5f31660db9c99dbfd017
SHA512 (decrypt-file-aes256) = 893693eec618542b0b95051952f9258824fe7004c360f8e6056a51638592510a704e27b707b9176febca655b7df581c9a6e2220b6511e8426c1501f6b2dd48a9

Question

How do I check this file? There is no --check option in the man page.


Progress

So far, I am only able to manually test a single file with hard-coding the hash sum:

sha512 -c "9170caaa45303d2e5f04c21732500980f3b06fc361018f953127506b56d3f2f46c95efdc291e160dd80e39b5304f327d83fe72c625ab5f31660db9c99dbfd017" encrypt-file-aes256 && echo $?

Scripting-wise, I don't yet see a way of checking the whole SHA512SUM file automatically.

Note, that it may contain many more files than the two as in my case.

9

You can use the shasum (man page) tool, which has a -c option to check against a checksum file and is a front-end to several checksum algorithms including SHA-512.

You can use a command like the one below to check both files:

$ shasum -a 512 -c SHA512SUM.sha512sum

The shasum tool is only able to parse the output format compatible with the one produced by sha512sum (the tool usually shipped in Linux distributions.)

You can convert from a BSD style checksum file to a Linux style one with a simple sed command:

$ sed -ne 's/^SHA512 (\(.*\)) = \(.*\)/\2  \1/p' SHA512SUM >SHA512SUM.sha512sum

(Though if you're generating the checksums yourself, then also using shasum to generate them is a good option, also compatible with the tools found on Linux.)

The shasum tool is provided by the FreeBSD port p5-Digest-SHA and can be installed with pkg by running:

$ sudo pkg install p5-Digest-SHA
  • 2
    Just FYI, shasum is not included in the FreeBSD base, it is provided by the port p5-Digest-SHA and can be installed with pkg by running pkg install p5-Digest-SHA – Harold Fischer May 12 at 1:29
  • @HaroldFischer Updated the answer to include the information about how to install it. Thanks for the pointer to the correct package! – filbranden May 12 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.