diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2016-03-11 18:33:08 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2016-07-04 15:52:36 +0100 |
commit | 9164b89762224db414676973172c26994aa9e2e5 (patch) | |
tree | db509ee669f5195c4d240b45929854ab7a06a1f3 /crypto/hash-nettle.c | |
parent | 0c16c056a4f9dec18fdd56feec82a5db9ff3c15e (diff) |
crypto: implement sha224, sha384, sha512 and ripemd160 hashes
Wire up the nettle and gcrypt hash backends so that they can
support the sha224, sha384, sha512 and ripemd160 hash algorithms.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'crypto/hash-nettle.c')
-rw-r--r-- | crypto/hash-nettle.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 8ec5572aff..4c6f50b65d 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -23,6 +23,7 @@ #include "crypto/hash.h" #include <nettle/md5.h> #include <nettle/sha.h> +#include <nettle/ripemd160.h> typedef void (*qcrypto_nettle_init)(void *ctx); typedef void (*qcrypto_nettle_write)(void *ctx, @@ -35,7 +36,11 @@ typedef void (*qcrypto_nettle_result)(void *ctx, union qcrypto_hash_ctx { struct md5_ctx md5; struct sha1_ctx sha1; + struct sha224_ctx sha224; struct sha256_ctx sha256; + struct sha384_ctx sha384; + struct sha512_ctx sha512; + struct ripemd160_ctx ripemd160; }; struct qcrypto_hash_alg { @@ -56,12 +61,36 @@ struct qcrypto_hash_alg { .result = (qcrypto_nettle_result)sha1_digest, .len = SHA1_DIGEST_SIZE, }, + [QCRYPTO_HASH_ALG_SHA224] = { + .init = (qcrypto_nettle_init)sha224_init, + .write = (qcrypto_nettle_write)sha224_update, + .result = (qcrypto_nettle_result)sha224_digest, + .len = SHA224_DIGEST_SIZE, + }, [QCRYPTO_HASH_ALG_SHA256] = { .init = (qcrypto_nettle_init)sha256_init, .write = (qcrypto_nettle_write)sha256_update, .result = (qcrypto_nettle_result)sha256_digest, .len = SHA256_DIGEST_SIZE, }, + [QCRYPTO_HASH_ALG_SHA384] = { + .init = (qcrypto_nettle_init)sha384_init, + .write = (qcrypto_nettle_write)sha384_update, + .result = (qcrypto_nettle_result)sha384_digest, + .len = SHA384_DIGEST_SIZE, + }, + [QCRYPTO_HASH_ALG_SHA512] = { + .init = (qcrypto_nettle_init)sha512_init, + .write = (qcrypto_nettle_write)sha512_update, + .result = (qcrypto_nettle_result)sha512_digest, + .len = SHA512_DIGEST_SIZE, + }, + [QCRYPTO_HASH_ALG_RIPEMD160] = { + .init = (qcrypto_nettle_init)ripemd160_init, + .write = (qcrypto_nettle_write)ripemd160_update, + .result = (qcrypto_nettle_result)ripemd160_digest, + .len = RIPEMD160_DIGEST_SIZE, + }, }; gboolean qcrypto_hash_supports(QCryptoHashAlgorithm alg) |