commit:     0a4e9cae78046c174c008fd7944937881a6786b2
Author:     Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 13 16:19:13 2020 +0000
Commit:     Rick Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Thu Feb 13 16:20:46 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0a4e9cae

add blake2 support

support blake2 for hash and digest functions.
per jmbsvicetto, adjusting default digest from "sha512 whirlpool" to
"blake2 sha512" for now
additionally add blake2 sums for iso verification

Signed-off-by: Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo.org>

 catalyst/hash_utils.py        | 10 ++++++----
 etc/catalyst.conf             |  6 +++---
 targets/support/create-iso.sh |  8 +++++---
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 1134f502..05279b2c 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -11,6 +11,7 @@ from catalyst.support import CatalystError
 # fields = ["func", "cmd", "args", "id"]
 HASH_DEFINITIONS = {
        "adler32"  :["calc_hash2", "shash", ["-a", "ADLER32"], "ADLER32"],
+       "blake2"   :["calc_hash", "b2sum", [ ], "BLAKE2"],
        "crc32"    :["calc_hash2", "shash", ["-a", "CRC32"], "CRC32"],
        "crc32b"   :["calc_hash2", "shash", ["-a", "CRC32B"], "CRC32B"],
        "gost"     :["calc_hash2", "shash", ["-a", "GOST"], "GOST"],
@@ -94,11 +95,12 @@ class HashMap(object):
                args = [_hash.cmd]
                args.extend(_hash.args)
                args.append(file_)
+               log.debug('args = %r', args)
                source = Popen(args, stdout=PIPE)
-               mylines = source.communicate()[0]
-               mylines=mylines[0].split()
-               result=mylines[0]
-               log.info('%s (%s) = %s', _hash.id, file_, result)
+               output = source.communicate()
+               mylines = output[0].decode('ascii')
+               log.info('%s (%s) = %s', _hash.id, file_, mylines)
+               result = "# " + _hash.id + " (b2sum) HASH\n" + mylines
                return result
 
 

diff --git a/etc/catalyst.conf b/etc/catalyst.conf
index 5a5eedba..dd34fae3 100644
--- a/etc/catalyst.conf
+++ b/etc/catalyst.conf
@@ -8,11 +8,11 @@
 # special "auto" keyword will skip digests that the system does not support,
 # and if it's the only keyword given, will default to enabling all digests.
 # Supported hashes:
-# adler32, crc32, crc32b, gost, haval128, haval160, haval192, haval224,
+# adler32, blake2, crc32, crc32b, gost, haval128, haval160, haval192, haval224,
 # haval256, md2, md4, md5, ripemd128, ripemd160, ripemd256, ripemd320, sha1,
 # sha224, sha256, sha384, sha512, snefru128, snefru256, tiger, tiger128,
 # tiger160, whirlpool
-digests="sha512 whirlpool"
+digests="blake2 sha512"
 
 # Creates a .CONTENTS file listing the contents of the file. Pick from any of
 # the supported options below:
@@ -40,7 +40,7 @@ envscript="/etc/catalyst/catalystrc"
 # seedcache, etc.  The default and fastest is crc32.  You should not ever need
 # to change this unless your OS does not support it.
 # Supported hashes:
-# adler32, crc32, crc32b, gost, haval128, haval160, haval192, haval224,
+# adler32, blake2, crc32, crc32b, gost, haval128, haval160, haval192, haval224,
 # haval256, md2, md4, md5, ripemd128, ripemd160, ripemd256, ripemd320, sha1,
 # sha224, sha256, sha384, sha512, snefru128, snefru256, tiger, tiger128,
 # tiger160, whirlpool

diff --git a/targets/support/create-iso.sh b/targets/support/create-iso.sh
index 8338e301..92efaa8b 100755
--- a/targets/support/create-iso.sh
+++ b/targets/support/create-iso.sh
@@ -94,12 +94,14 @@ else
        mkisofs_zisofs_opts=""
 fi
 
-#we want to create a sha512sum for every file on the iso so we can verify it
-#from genkernel during boot.  Here we make a function to create the sha512sums
+#we want to create a checksum for every file on the iso so we can verify it
+#from genkernel during boot.  Here we make a function to create the 
sha512sums, and blake2sums
 isoroot_checksum() {
        echo "Creating checksums for all files included in the iso, please 
wait..."
-       find "${clst_target_path}" -type f ! -name 'isoroot_checksums' ! -name 
'isolinux.bin' -exec sha512sum {} + > "${clst_target_path}"/isoroot_checksums
+       find "${clst_target_path}" -type f ! -name 'isoroot_checksums' ! -name 
'isolinux.bin' ! -name 'isoroot_b2sums' -exec sha512sum {} + > 
"${clst_target_path}"/isoroot_checksums
        ${clst_sed} -i "s#${clst_target_path}/\?##" 
"${clst_target_path}"/isoroot_checksums
+       find "${clst_target_path}" -type f ! -name 'isoroot_checksums' ! -name 
'isolinux.bin' ! -name 'isoroot_b2sums' -exec b2sum {} + > 
"${clst_target_path}"/isoroot_b2sums
+       ${clst_sed} -i "s#${clst_target_path}/\?##" 
"${clst_target_path}"/isoroot_b2sums
 }
 
 run_mkisofs() {

Reply via email to