diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index ff0869c49..0ac8fc194 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -21,6 +21,8 @@ #ifndef CRYPTO_H #define CRYPTO_H +#define HMAC_VECTOR_MAX_ELEM 11 + /** * md4_vector - MD4 hash for data vector * @num_elem: Number of elements in the data vector diff --git a/src/crypto/sha256.c b/src/crypto/sha256.c index 8e57efc01..1e8a12217 100644 --- a/src/crypto/sha256.c +++ b/src/crypto/sha256.c @@ -28,11 +28,11 @@ int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, { unsigned char k_pad[64]; /* padding - key XORd with ipad/opad */ unsigned char tk[32]; - const u8 *_addr[26]; - size_t _len[26], i; + const u8 *_addr[HMAC_VECTOR_MAX_ELEM + 1]; + size_t _len[HMAC_VECTOR_MAX_ELEM + 1], i; int ret; - if (num_elem > 25) { + if (num_elem > HMAC_VECTOR_MAX_ELEM) { /* * Fixed limit on the number of fragments to avoid having to * allocate memory (which could fail). diff --git a/src/crypto/sha384.c b/src/crypto/sha384.c index 8fd69e2d8..be07e9c84 100644 --- a/src/crypto/sha384.c +++ b/src/crypto/sha384.c @@ -28,10 +28,10 @@ int hmac_sha384_vector(const u8 *key, size_t key_len, size_t num_elem, { unsigned char k_pad[128]; /* padding - key XORd with ipad/opad */ unsigned char tk[48]; - const u8 *_addr[26]; - size_t _len[26], i; + const u8 *_addr[HMAC_VECTOR_MAX_ELEM + 1]; + size_t _len[HMAC_VECTOR_MAX_ELEM + 1], i; - if (num_elem > 25) { + if (num_elem > HMAC_VECTOR_MAX_ELEM) { /* * Fixed limit on the number of fragments to avoid having to * allocate memory (which could fail). diff --git a/src/crypto/sha512.c b/src/crypto/sha512.c index d0b123fb6..73b54c73b 100644 --- a/src/crypto/sha512.c +++ b/src/crypto/sha512.c @@ -28,10 +28,10 @@ int hmac_sha512_vector(const u8 *key, size_t key_len, size_t num_elem, { unsigned char k_pad[128]; /* padding - key XORd with ipad/opad */ unsigned char tk[64]; - const u8 *_addr[26]; - size_t _len[26], i; + const u8 *_addr[HMAC_VECTOR_MAX_ELEM + 1]; + size_t _len[HMAC_VECTOR_MAX_ELEM + 1], i; - if (num_elem > 25) { + if (num_elem > HMAC_VECTOR_MAX_ELEM) { /* * Fixed limit on the number of fragments to avoid having to * allocate memory (which could fail).