1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

change hmac context to use statically allocated memory

1. removed dynamic allocation of stack context
2. moved ipad to stack
3. added defines for maximal sizes
This commit is contained in:
Nir Sonnenschein
2018-06-07 16:20:17 +03:00
committed by itayzafrir
parent 0c9ec53a10
commit 35dfbf4601
2 changed files with 15 additions and 17 deletions

View File

@@ -45,6 +45,14 @@
#include "mbedtls/sha256.h"
#include "mbedtls/sha512.h"
#if defined(MBEDTLS_SHA512_C)
#define PSA_CRYPTO_MD_MAX_SIZE 64
#define PSA_CRYPTO_MD_BLOCK_SIZE 128
#else
#define PSA_CRYPTO_MD_MAX_SIZE 32
#define PSA_CRYPTO_MD_BLOCK_SIZE 64
#endif
struct psa_hash_operation_s
{
psa_algorithm_t alg;
@@ -77,11 +85,10 @@ struct psa_hash_operation_s
typedef struct {
unsigned int block_size;
/** The hash context. */
struct psa_hash_operation_s hash_ctx;
/** The HMAC part of the context. */
void *hmac_ctx;
char hmac_ctx[PSA_CRYPTO_MD_BLOCK_SIZE];
} psa_hmac_internal_data;