Skip to content

Commit

Permalink
crypto: don't open-code qcrypto_hash_supports
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
berrange committed Jul 21, 2016
1 parent 2165477 commit 7603289
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions crypto/hash-gcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions crypto/hash-glib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions crypto/hash-nettle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7603289

Please sign in to comment.