aboutsummaryrefslogtreecommitdiff
path: root/nix/libutil/hash.hh
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-06-23 11:46:05 +0200
committerLudovic Courtès <ludo@gnu.org>2020-06-27 23:42:20 +0200
commit3fb6b8f30444d41963ba5bdd441123a6d2df17bd (patch)
tree0159dc3f3ceefdbe75e42587afc6d711a7c460dc /nix/libutil/hash.hh
parent4b4f890cb03d7c5b958fe08553dfad2f39a1d4f2 (diff)
downloadguix-3fb6b8f30444d41963ba5bdd441123a6d2df17bd.tar
guix-3fb6b8f30444d41963ba5bdd441123a6d2df17bd.tar.gz
daemon: Map directly to gcrypt hash functions.
* nix/libutil/hash.hh (HashType): Map directly to GCRY_MD_ values. (md5HashSize, sha1HashSize, sha256HashSize, sha512HashSize): Remove. * nix/libutil/hash.cc (Hash::Hash): Use 'gcry_md_get_algo_dlen'.
Diffstat (limited to 'nix/libutil/hash.hh')
-rw-r--r--nix/libutil/hash.hh17
1 files changed, 9 insertions, 8 deletions
diff --git a/nix/libutil/hash.hh b/nix/libutil/hash.hh
index 6b5e47cd8a..7357a34e1d 100644
--- a/nix/libutil/hash.hh
+++ b/nix/libutil/hash.hh
@@ -1,5 +1,7 @@
#pragma once
+#include <gcrypt.h>
+
#include "types.hh"
#include "serialise.hh"
@@ -7,16 +9,15 @@
namespace nix {
-typedef enum { htUnknown, htMD5, htSHA1, htSHA256, htSHA512 } HashType;
-
-
-const int md5HashSize = 16;
-const int sha1HashSize = 20;
-const int sha256HashSize = 32;
-const int sha512HashSize = 64;
-
extern const string base32Chars;
+typedef enum {
+ htUnknown = 0,
+ htMD5 = GCRY_MD_MD5,
+ htSHA1 = GCRY_MD_SHA1,
+ htSHA256 = GCRY_MD_SHA256,
+ htSHA512 = GCRY_MD_SHA512
+} HashType;
struct Hash
{