2 # Autodetect possible commandlines for various hashes. Example usage:
3 # meta4ra-{create,check} -hashes "$(meta4ra-hashes-detect)" ...
12 if [ -n "$desired" ] && [ $desired != "$name" ] ; then return 1 ; fi
15 [ "$cmd" != "builtin" ] || cmd="meta4ra-hash -hashes $name:builtin"
16 our=$(echo -n hello world | sh -e -c "$cmd" | { read h rem ; printf %s "$h"; })
17 [ $HSH = "$our" ] && hashes="$hashes,$name:$cmdline"
20 HSH=d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24
21 check blake3-256 b3sum || # https://github.com/BLAKE3-team/BLAKE3
22 check blake3-256 builtin || :
24 HSH=021ced8799296ceca557832ab941a50b4a11f83478cf141f51f933f653ab9fbcc05a037cddbed06e309bf334942c4e58cdf1a46e237911ccd7fcf9787cbc7fd0
25 check blake2b-512 b2sum || # https://blake2.net/, GNU Coreutils
26 check blake2b-512 "openssl blake2b512 -r" ||
27 check blake2b-512 builtin || :
29 HSH=256c83b297114d201b30179f3f0ef0cace9783622da5974326b436178aeef610
30 check blake2b-256 "b2sum -l 256" ||
31 check blake2b-512 builtin || :
33 HSH=8b4830244fc36daa11177311dc6bf7636376180dce2d29193335878142e7d6f5e9016beba729e0a353dd2fd421c8b2022ee8927f0bce6b88631bb01be2e0f5ba
34 check skein-512 skein512 || # FreeBSD's out-of-box command
35 check skein-512 builtin || :
37 HSH=3a9159f071e4dd1c8c4f968607c30942e120d8156b8b1e72e0d376e8871cb8b8
38 check shake128 goshake128 || # go.stargrave.org/gosha3
39 check shake128 "sha3sum -a 128000 | dd bs=1 count=64 2>/dev/null" || # p5-Digest-SHA3
40 check shake128 builtin || :
41 # openssl shake128 -- useless, as it outputs only 128 bits
43 HSH=369771bb2cb9d2b04c1d54cca487e372d9f187f73f7ba3f65b95c8ee7798c527f4f3c2d55c2d46a29f2e945d469c3df27853a8735271f5cc2d9e889544357116
44 check shake256 goshake256 ||
45 check shake256 "sha3sum -a 256000 | dd bs=1 count=128 2>/dev/null" ||
46 check shake256 builtin || :
48 HSH=309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
49 check sha-512 sha512 ||
50 check sha-512 sha512sum ||
51 check sha-512 "libressl dgst -sha512" ||
52 check sha-512 "openssl sha512 -r" ||
53 check sha-512 builtin || :
55 HSH=b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
56 check sha-256 sha256 ||
57 check sha-256 sha256sum ||
58 check sha-256 "libressl dgst -sha256" ||
59 check sha-256 "openssl sha256 -r" ||
60 check sha-256 builtin || :
63 unhexdump="hexdump -v -e '/1 \"%02x\"' ; echo"
64 HSH=84d883ede9fa6ce855d82d8c278ecd9f5fc88bf0602831ae0c38b9b506ea3cb02f3fa076b8f5664adf1ff862c0157da4cc9a83e141b738ff9268a9ba3ed6f563
65 check streebog-512 "nettle-hash --algorithm=streebog512 --raw | $unxxd" ||
66 check streebog-512 "nettle-hash --algorithm=streebog512 --raw | $unhexdump" ||
67 check streebog-512 "libressl dgst -streebog512" ||
68 check streebog-512 streebog512 $hsh || # go.cypherpunks.ru/gogost
69 check streebog-512 builtin || :
71 HSH=c600fd9dd049cf8abd2f5b32e840d2cb0e41ea44de1c155dcd88dc84fe58a855
72 check streebog-256 "nettle-hash --algorithm=streebog256 --raw | $unxxd" ||
73 check streebog-256 "nettle-hash --algorithm=streebog256 --raw | $unhexdump" ||
74 check streebog-256 "libressl dgst -streebog256" ||
75 check streebog-256 streebog256 ||
76 check streebog-256 builtin || :
78 HSH=df8d09e93f874900a99b8775cc15b6c7
79 check xxh3-128 "xxhsum -H128" || # https://cyan4973.github.io/xxHash/
80 check xxh3-128 builtin || :