diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-06-23 11:46:05 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-06-27 23:42:20 +0200 |
commit | 3fb6b8f30444d41963ba5bdd441123a6d2df17bd (patch) | |
tree | 0159dc3f3ceefdbe75e42587afc6d711a7c460dc /nix/libutil/hash.cc | |
parent | 4b4f890cb03d7c5b958fe08553dfad2f39a1d4f2 (diff) | |
download | 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.cc')
-rw-r--r-- | nix/libutil/hash.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/nix/libutil/hash.cc b/nix/libutil/hash.cc index ea69aa64f9..251f18f60e 100644 --- a/nix/libutil/hash.cc +++ b/nix/libutil/hash.cc @@ -38,11 +38,9 @@ Hash::Hash() Hash::Hash(HashType type) { this->type = type; - if (type == htMD5) hashSize = md5HashSize; - else if (type == htSHA1) hashSize = sha1HashSize; - else if (type == htSHA256) hashSize = sha256HashSize; - else if (type == htSHA512) hashSize = sha512HashSize; - else throw Error("unknown hash type"); + hashSize = gcry_md_get_algo_dlen(type); + + if (hashSize == 0) throw Error("unknown hash type"); assert(hashSize <= maxHashSize); memset(hash, 0, maxHashSize); } |