]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Decrement hmac_sha*_vector() maximum num_elem value to 11
authorJouni Malinen <quic_jouni@quicinc.com>
Fri, 25 Aug 2023 08:34:14 +0000 (11:34 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 25 Aug 2023 08:34:14 +0000 (11:34 +0300)
This replaces the earlier commit 4c079dcc64da ("Increment
hmac_sha*_vector() maximum num_elem value to 25") with a smaller
increment of just one extra element since the updated FTE MIC
calculation design does not use separate elements. This reduces stack
memory need. In addition, this starts using a define value for the
maximum number of vector elements to make this easier to change and to
make the code more readable.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/crypto/crypto.h
src/crypto/sha256.c
src/crypto/sha384.c
src/crypto/sha512.c

index ff0869c49692e03058862f519f70c23f09c35ff3..0ac8fc19476aca127ff7a3f2aca3338feb4cc7bd 100644 (file)
@@ -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
index 8e57efc01505900d54671a731eba5a8de645b93a..1e8a122176c8e8a8488f5254871418f3cd1c401c 100644 (file)
@@ -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).
index 8fd69e2d8bbd8cf374b81520aba42ce2115debe7..be07e9c84c2f5c8734b478c1ac09e174bb6315b6 100644 (file)
@@ -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).
index d0b123fb6c6568d604b3c083a393fad4a98ba878..73b54c73b691993cf97cf3d4f575946ca02d3ab5 100644 (file)
@@ -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).