From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PULL v1 3/3] crypto: don't open-code qcrypto_hash_supports
Date: Thu, 21 Jul 2016 11:09:57 +0100 [thread overview]
Message-ID: <1469095797-5098-4-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1469095797-5098-1-git-send-email-berrange@redhat.com>
Call the existing qcrypto_hash_supports method from
qcrypto_hash_bytesv instead of open-coding it again.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
crypto/hash-gcrypt.c | 3 +--
crypto/hash-glib.c | 3 +--
crypto/hash-nettle.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c
index ed6f842..7690690 100644
--- a/crypto/hash-gcrypt.c
+++ b/crypto/hash-gcrypt.c
@@ -55,8 +55,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
gcry_md_hd_t md;
unsigned char *digest;
- if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) ||
- qcrypto_hash_alg_map[alg] == GCRY_MD_NONE) {
+ if (!qcrypto_hash_supports(alg)) {
error_setg(errp,
"Unknown hash algorithm %d",
alg);
diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c
index cb68a3b..ec99ac9 100644
--- a/crypto/hash-glib.c
+++ b/crypto/hash-glib.c
@@ -57,8 +57,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
int i, ret;
GChecksum *cs;
- if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) ||
- qcrypto_hash_alg_map[alg] == -1) {
+ if (!qcrypto_hash_supports(alg)) {
error_setg(errp,
"Unknown hash algorithm %d",
alg);
diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c
index 4c6f50b..6a206dc 100644
--- a/crypto/hash-nettle.c
+++ b/crypto/hash-nettle.c
@@ -113,8 +113,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
int i;
union qcrypto_hash_ctx ctx;
- if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) ||
- qcrypto_hash_alg_map[alg].init == NULL) {
+ if (!qcrypto_hash_supports(alg)) {
error_setg(errp,
"Unknown hash algorithm %d",
alg);
--
2.7.4
next prev parent reply other threads:[~2016-07-21 10:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-21 10:09 [Qemu-devel] [PULL v1 0/3] Merge qcrypto-next 2016/07/21 Daniel P. Berrange
2016-07-21 10:09 ` [Qemu-devel] [PULL v1 1/3] crypto: use /dev/[u]random as a final fallback random source Daniel P. Berrange
2016-07-21 10:09 ` [Qemu-devel] [PULL v1 2/3] crypto: use glib as fallback for hash algorithm Daniel P. Berrange
2016-07-21 10:09 ` Daniel P. Berrange [this message]
2016-07-21 11:42 ` [Qemu-devel] [PULL v1 0/3] Merge qcrypto-next 2016/07/21 Peter Maydell
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=1469095797-5098-4-git-send-email-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).