Skip to content

Commit

Permalink
crypto: Define macros for hash algorithm digest lengths
Browse files Browse the repository at this point in the history
Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Dorjoy Chowdhury <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
  • Loading branch information
dorjoy03 authored and berrange committed Sep 9, 2024
1 parent 41162dd commit 5d04de7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crypto/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
#include "hashpriv.h"

static size_t qcrypto_hash_alg_size[QCRYPTO_HASH_ALG__MAX] = {
[QCRYPTO_HASH_ALG_MD5] = 16,
[QCRYPTO_HASH_ALG_SHA1] = 20,
[QCRYPTO_HASH_ALG_SHA224] = 28,
[QCRYPTO_HASH_ALG_SHA256] = 32,
[QCRYPTO_HASH_ALG_SHA384] = 48,
[QCRYPTO_HASH_ALG_SHA512] = 64,
[QCRYPTO_HASH_ALG_RIPEMD160] = 20,
[QCRYPTO_HASH_ALG_MD5] = QCRYPTO_HASH_DIGEST_LEN_MD5,
[QCRYPTO_HASH_ALG_SHA1] = QCRYPTO_HASH_DIGEST_LEN_SHA1,
[QCRYPTO_HASH_ALG_SHA224] = QCRYPTO_HASH_DIGEST_LEN_SHA224,
[QCRYPTO_HASH_ALG_SHA256] = QCRYPTO_HASH_DIGEST_LEN_SHA256,
[QCRYPTO_HASH_ALG_SHA384] = QCRYPTO_HASH_DIGEST_LEN_SHA384,
[QCRYPTO_HASH_ALG_SHA512] = QCRYPTO_HASH_DIGEST_LEN_SHA512,
[QCRYPTO_HASH_ALG_RIPEMD160] = QCRYPTO_HASH_DIGEST_LEN_RIPEMD160,
};

size_t qcrypto_hash_digest_len(QCryptoHashAlgorithm alg)
Expand Down
8 changes: 8 additions & 0 deletions include/crypto/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@

#include "qapi/qapi-types-crypto.h"

#define QCRYPTO_HASH_DIGEST_LEN_MD5 16
#define QCRYPTO_HASH_DIGEST_LEN_SHA1 20
#define QCRYPTO_HASH_DIGEST_LEN_SHA224 28
#define QCRYPTO_HASH_DIGEST_LEN_SHA256 32
#define QCRYPTO_HASH_DIGEST_LEN_SHA384 48
#define QCRYPTO_HASH_DIGEST_LEN_SHA512 64
#define QCRYPTO_HASH_DIGEST_LEN_RIPEMD160 20

/* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */

/**
Expand Down

0 comments on commit 5d04de7

Please sign in to comment.