all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 42020@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#42020] [PATCH 3/4] daemon: Recognize SHA3 and BLAKE2s.
Date: Tue, 23 Jun 2020 17:55:46 +0200	[thread overview]
Message-ID: <20200623155547.15886-3-ludo@gnu.org> (raw)
In-Reply-To: <20200623155547.15886-1-ludo@gnu.org>

* nix/libutil/hash.hh (HashType): Add htSHA3_256, htSHA3_512, and
htBLAKE2s_256.
* nix/libutil/hash.cc (parseHashType, printHashType): Recognize them.
* tests/store.scm ("add-to-store"): Test these algorithms.
---
 nix/libutil/hash.cc | 6 ++++++
 nix/libutil/hash.hh | 5 ++++-
 tests/store.scm     | 4 ++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/nix/libutil/hash.cc b/nix/libutil/hash.cc
index 20d2e4b724..7853acdd49 100644
--- a/nix/libutil/hash.cc
+++ b/nix/libutil/hash.cc
@@ -321,6 +321,9 @@ HashType parseHashType(const string & s)
     else if (s == "sha1") return htSHA1;
     else if (s == "sha256") return htSHA256;
     else if (s == "sha512") return htSHA512;
+    else if (s == "sha3-256") return htSHA3_256;
+    else if (s == "sha3-512") return htSHA3_512;
+    else if (s == "blake2s-256") return htBLAKE2s_256;
     else return htUnknown;
 }
 
@@ -331,6 +334,9 @@ string printHashType(HashType ht)
     else if (ht == htSHA1) return "sha1";
     else if (ht == htSHA256) return "sha256";
     else if (ht == htSHA512) return "sha512";
+    else if (ht == htSHA3_256) return "sha3-256";
+    else if (ht == htSHA3_512) return "sha3-512";
+    else if (ht == htBLAKE2s_256) return "blake2s-256";
     else throw Error("cannot print unknown hash type");
 }
 
diff --git a/nix/libutil/hash.hh b/nix/libutil/hash.hh
index 7357a34e1d..ac58651a02 100644
--- a/nix/libutil/hash.hh
+++ b/nix/libutil/hash.hh
@@ -16,7 +16,10 @@ typedef enum {
     htMD5 = GCRY_MD_MD5,
     htSHA1 = GCRY_MD_SHA1,
     htSHA256 = GCRY_MD_SHA256,
-    htSHA512 = GCRY_MD_SHA512
+    htSHA512 = GCRY_MD_SHA512,
+    htSHA3_256 = GCRY_MD_SHA3_256,
+    htSHA3_512 = GCRY_MD_SHA3_512,
+    htBLAKE2s_256 = GCRY_MD_BLAKE2S_256
 } HashType;
 
 struct Hash
diff --git a/tests/store.scm b/tests/store.scm
index 06f7939657..ee3e01f33b 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -116,7 +116,7 @@
     (list (stat:uid s) (stat:perms s))))
 
 (test-equal "add-to-store"
-  '("sha1" "sha256" "sha512")
+  '("sha1" "sha256" "sha512" "sha3-256" "sha3-512" "blake2s-256")
   (let* ((file    (search-path %load-path "guix.scm"))
          (content (call-with-input-file file get-bytevector-all)))
     (map (lambda (hash-algo)
@@ -125,7 +125,7 @@
                   (bytevector=? (call-with-input-file file get-bytevector-all)
                                 content)
                   hash-algo)))
-         '("sha1" "sha256" "sha512"))))
+         '("sha1" "sha256" "sha512" "sha3-256" "sha3-512" "blake2s-256"))))
 
 (test-equal "add-data-to-store"
   #vu8(1 2 3 4 5)
-- 
2.26.2





  parent reply	other threads:[~2020-06-23 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 15:36 [bug#42020] [PATCH 0/4] Add daemon support for SHA3 and BLAKE2s Ludovic Courtès
2020-06-23 15:55 ` [bug#42020] [PATCH 1/4] daemon: Map directly to gcrypt hash functions Ludovic Courtès
2020-06-23 15:55   ` [bug#42020] [PATCH 2/4] daemon: Remove OpenSSL hash compatibility wrappers Ludovic Courtès
2020-06-23 15:55   ` Ludovic Courtès [this message]
2020-06-23 15:55   ` [bug#42020] [PATCH 4/4] packages: Recognize SHA3 and BLAKE2s for 'content-hash' Ludovic Courtès
2020-06-27 21:44 ` bug#42020: [PATCH 0/4] Add daemon support for SHA3 and BLAKE2s Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623155547.15886-3-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=42020@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.