Enable HMAC-DRBG in driver-only hashes component

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2023-03-20 10:44:44 +01:00
parent fbaf4e98d8
commit d111fbdad1
6 changed files with 943 additions and 921 deletions

View file

@ -2642,7 +2642,6 @@ config_psa_crypto_hash_use_psa () {
if [ "$DRIVER_ONLY" -eq 1 ]; then
scripts/config.py unset MBEDTLS_MD_C
fi
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC
scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_DETERMINISTIC_ECDSA

View file

@ -41,6 +41,8 @@ void hmac_drbg_entropy_usage(int md_alg)
size_t default_entropy_len;
size_t expected_consumed_entropy = 0;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
memset(buf, 0, sizeof(buf));
memset(out, 0, sizeof(out));
@ -118,6 +120,7 @@ void hmac_drbg_entropy_usage(int md_alg)
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
@ -127,6 +130,8 @@ void hmac_drbg_seed_file(int md_alg, char *path, int ret)
const mbedtls_md_info_t *md_info;
mbedtls_hmac_drbg_context ctx;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
md_info = mbedtls_md_info_from_type(md_alg);
@ -141,6 +146,7 @@ void hmac_drbg_seed_file(int md_alg, char *path, int ret)
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
@ -153,6 +159,8 @@ void hmac_drbg_buf(int md_alg)
mbedtls_hmac_drbg_context ctx;
size_t i;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
memset(buf, 0, sizeof(buf));
memset(out, 0, sizeof(out));
@ -171,6 +179,7 @@ void hmac_drbg_buf(int md_alg)
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
@ -185,6 +194,8 @@ void hmac_drbg_no_reseed(int md_alg, data_t *entropy,
const mbedtls_md_info_t *md_info;
mbedtls_hmac_drbg_context ctx;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
p_entropy.p = entropy->x;
@ -219,6 +230,7 @@ void hmac_drbg_no_reseed(int md_alg, data_t *entropy,
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
@ -232,6 +244,8 @@ void hmac_drbg_nopr(int md_alg, data_t *entropy, data_t *custom,
const mbedtls_md_info_t *md_info;
mbedtls_hmac_drbg_context ctx;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
p_entropy.p = entropy->x;
@ -252,6 +266,7 @@ void hmac_drbg_nopr(int md_alg, data_t *entropy, data_t *custom,
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
@ -264,6 +279,8 @@ void hmac_drbg_pr(int md_alg, data_t *entropy, data_t *custom,
const mbedtls_md_info_t *md_info;
mbedtls_hmac_drbg_context ctx;
MD_PSA_INIT();
mbedtls_hmac_drbg_init(&ctx);
p_entropy.p = entropy->x;
@ -284,12 +301,18 @@ void hmac_drbg_pr(int md_alg, data_t *entropy, data_t *custom,
exit:
mbedtls_hmac_drbg_free(&ctx);
MD_PSA_DONE();
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void hmac_drbg_selftest()
{
MD_PSA_INIT();
TEST_ASSERT(mbedtls_hmac_drbg_self_test(1) == 0);
exit:
MD_PSA_DONE();
}
/* END_CASE */

View file

@ -1,81 +1,81 @@
HMAC_DRBG entropy usage SHA-1
depends_on:MBEDTLS_SHA1_C
depends_on:MBEDTLS_MD_CAN_SHA1
hmac_drbg_entropy_usage:MBEDTLS_MD_SHA1
HMAC_DRBG entropy usage SHA-224
depends_on:MBEDTLS_SHA224_C
depends_on:MBEDTLS_MD_CAN_SHA224
hmac_drbg_entropy_usage:MBEDTLS_MD_SHA224
HMAC_DRBG entropy usage SHA-256
depends_on:MBEDTLS_SHA256_C
depends_on:MBEDTLS_MD_CAN_SHA256
hmac_drbg_entropy_usage:MBEDTLS_MD_SHA256
HMAC_DRBG entropy usage SHA-384
depends_on:MBEDTLS_SHA384_C
depends_on:MBEDTLS_MD_CAN_SHA384
hmac_drbg_entropy_usage:MBEDTLS_MD_SHA384
HMAC_DRBG entropy usage SHA-512
depends_on:MBEDTLS_SHA512_C
depends_on:MBEDTLS_MD_CAN_SHA512
hmac_drbg_entropy_usage:MBEDTLS_MD_SHA512
HMAC_DRBG write/update seed file SHA-1 [#1]
depends_on:MBEDTLS_SHA1_C
depends_on:MBEDTLS_MD_CAN_SHA1
hmac_drbg_seed_file:MBEDTLS_MD_SHA1:"data_files/hmac_drbg_seed":0
HMAC_DRBG write/update seed file SHA-1 [#2]
depends_on:MBEDTLS_SHA1_C
depends_on:MBEDTLS_MD_CAN_SHA1
hmac_drbg_seed_file:MBEDTLS_MD_SHA1:"no_such_dir/file":MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
HMAC_DRBG write/update seed file SHA-224 [#1]
depends_on:MBEDTLS_SHA224_C
depends_on:MBEDTLS_MD_CAN_SHA224
hmac_drbg_seed_file:MBEDTLS_MD_SHA224:"data_files/hmac_drbg_seed":0
HMAC_DRBG write/update seed file SHA-224 [#2]
depends_on:MBEDTLS_SHA224_C
depends_on:MBEDTLS_MD_CAN_SHA224
hmac_drbg_seed_file:MBEDTLS_MD_SHA224:"no_such_dir/file":MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
HMAC_DRBG write/update seed file SHA-256 [#1]
depends_on:MBEDTLS_SHA256_C
depends_on:MBEDTLS_MD_CAN_SHA256
hmac_drbg_seed_file:MBEDTLS_MD_SHA256:"data_files/hmac_drbg_seed":0
HMAC_DRBG write/update seed file SHA-256 [#2]
depends_on:MBEDTLS_SHA256_C
depends_on:MBEDTLS_MD_CAN_SHA256
hmac_drbg_seed_file:MBEDTLS_MD_SHA256:"no_such_dir/file":MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
HMAC_DRBG write/update seed file SHA-384 [#1]
depends_on:MBEDTLS_SHA384_C
depends_on:MBEDTLS_MD_CAN_SHA384
hmac_drbg_seed_file:MBEDTLS_MD_SHA384:"data_files/hmac_drbg_seed":0
HMAC_DRBG write/update seed file SHA-384 [#2]
depends_on:MBEDTLS_SHA384_C
depends_on:MBEDTLS_MD_CAN_SHA384
hmac_drbg_seed_file:MBEDTLS_MD_SHA384:"no_such_dir/file":MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
HMAC_DRBG write/update seed file SHA-512 [#1]
depends_on:MBEDTLS_SHA512_C
depends_on:MBEDTLS_MD_CAN_SHA512
hmac_drbg_seed_file:MBEDTLS_MD_SHA512:"data_files/hmac_drbg_seed":0
HMAC_DRBG write/update seed file SHA-512 [#2]
depends_on:MBEDTLS_SHA512_C
depends_on:MBEDTLS_MD_CAN_SHA512
hmac_drbg_seed_file:MBEDTLS_MD_SHA512:"no_such_dir/file":MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
HMAC_DRBG from buffer SHA-1
depends_on:MBEDTLS_SHA1_C
depends_on:MBEDTLS_MD_CAN_SHA1
hmac_drbg_buf:MBEDTLS_MD_SHA1
HMAC_DRBG from buffer SHA-224
depends_on:MBEDTLS_SHA224_C
depends_on:MBEDTLS_MD_CAN_SHA224
hmac_drbg_buf:MBEDTLS_MD_SHA224
HMAC_DRBG from buffer SHA-256
depends_on:MBEDTLS_SHA256_C
depends_on:MBEDTLS_MD_CAN_SHA256
hmac_drbg_buf:MBEDTLS_MD_SHA256
HMAC_DRBG from buffer SHA-384
depends_on:MBEDTLS_SHA384_C
depends_on:MBEDTLS_MD_CAN_SHA384
hmac_drbg_buf:MBEDTLS_MD_SHA384
HMAC_DRBG from buffer SHA-512
depends_on:MBEDTLS_SHA512_C
depends_on:MBEDTLS_MD_CAN_SHA512
hmac_drbg_buf:MBEDTLS_MD_SHA512
HMAC_DRBG self test

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff