mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-17 16:13:48 +00:00
test_suite_md: improve md_to_from_psa() test function and related data
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
3d2e0f5f42
commit
2c1070b397
@ -2,8 +2,52 @@
|
||||
MD list
|
||||
mbedtls_md_list:
|
||||
|
||||
MD <-> PSA conversion
|
||||
md_to_from_psa:
|
||||
MD <-> PSA conversion - MD5
|
||||
depends_on:PSA_WANT_ALG_MD5
|
||||
md_to_from_psa:MBEDTLS_MD_MD5:PSA_ALG_MD5
|
||||
|
||||
MD <-> PSA conversion - RIPEMD160
|
||||
depends_on:PSA_WANT_ALG_RIPEMD160
|
||||
md_to_from_psa:MBEDTLS_MD_RIPEMD160:PSA_ALG_RIPEMD160
|
||||
|
||||
MD <-> PSA conversion - SHA1
|
||||
depends_on:PSA_WANT_ALG_SHA_1
|
||||
md_to_from_psa:MBEDTLS_MD_SHA1:PSA_ALG_SHA_1
|
||||
|
||||
MD <-> PSA conversion - SHA224
|
||||
depends_on:PSA_WANT_ALG_SHA_224
|
||||
md_to_from_psa:MBEDTLS_MD_SHA224:PSA_ALG_SHA_224
|
||||
|
||||
MD <-> PSA conversion - SHA256
|
||||
depends_on:PSA_WANT_ALG_SHA_256
|
||||
md_to_from_psa:MBEDTLS_MD_SHA256:PSA_ALG_SHA_256
|
||||
|
||||
MD <-> PSA conversion - SHA384
|
||||
depends_on:PSA_WANT_ALG_SHA_384
|
||||
md_to_from_psa:MBEDTLS_MD_SHA384:PSA_ALG_SHA_384
|
||||
|
||||
MD <-> PSA conversion - SHA512
|
||||
depends_on:PSA_WANT_ALG_SHA_512
|
||||
md_to_from_psa:MBEDTLS_MD_SHA512:PSA_ALG_SHA_512
|
||||
|
||||
MD <-> PSA conversion - SHA3_224
|
||||
depends_on:PSA_WANT_ALG_SHA3_224
|
||||
md_to_from_psa:MBEDTLS_MD_SHA3_224:PSA_ALG_SHA3_224
|
||||
|
||||
MD <-> PSA conversion - SHA3_256
|
||||
depends_on:PSA_WANT_ALG_SHA3_256
|
||||
md_to_from_psa:MBEDTLS_MD_SHA3_256:PSA_ALG_SHA3_256
|
||||
|
||||
MD <-> PSA conversion - SHA3_384
|
||||
depends_on:PSA_WANT_ALG_SHA3_384
|
||||
md_to_from_psa:MBEDTLS_MD_SHA3_384:PSA_ALG_SHA3_384
|
||||
|
||||
MD <-> PSA conversion - SHA3_512
|
||||
depends_on:PSA_WANT_ALG_SHA3_512
|
||||
md_to_from_psa:MBEDTLS_MD_SHA3_512:PSA_ALG_SHA3_512
|
||||
|
||||
MD <-> PSA conversion - NONE
|
||||
md_to_from_psa:MBEDTLS_MD_NONE:PSA_ALG_NONE
|
||||
|
||||
MD NULL/uninitialised arguments
|
||||
md_null_args:
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
#include "mbedtls/oid.h"
|
||||
#include "mbedtls/asn1.h"
|
||||
|
||||
#define MD_PSA(md, psa) \
|
||||
TEST_EQUAL(mbedtls_md_psa_alg_from_type(md), psa); \
|
||||
TEST_EQUAL(mbedtls_md_type_from_psa_alg(psa), md);
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
@ -63,23 +59,13 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_PSA_CRYPTO_C */
|
||||
void md_to_from_psa()
|
||||
void md_to_from_psa(int md_alg_arg, int psa_alg_arg)
|
||||
{
|
||||
/* We use a simplified implementation that relies on numerical values
|
||||
* being aligned, so make sure they remain so. */
|
||||
MD_PSA(MBEDTLS_MD_MD5, PSA_ALG_MD5);
|
||||
MD_PSA(MBEDTLS_MD_RIPEMD160, PSA_ALG_RIPEMD160);
|
||||
MD_PSA(MBEDTLS_MD_SHA1, PSA_ALG_SHA_1);
|
||||
MD_PSA(MBEDTLS_MD_SHA224, PSA_ALG_SHA_224);
|
||||
MD_PSA(MBEDTLS_MD_SHA256, PSA_ALG_SHA_256);
|
||||
MD_PSA(MBEDTLS_MD_SHA384, PSA_ALG_SHA_384);
|
||||
MD_PSA(MBEDTLS_MD_SHA512, PSA_ALG_SHA_512);
|
||||
MD_PSA(MBEDTLS_MD_SHA3_224, PSA_ALG_SHA3_224);
|
||||
MD_PSA(MBEDTLS_MD_SHA3_256, PSA_ALG_SHA3_256);
|
||||
MD_PSA(MBEDTLS_MD_SHA3_384, PSA_ALG_SHA3_384);
|
||||
MD_PSA(MBEDTLS_MD_SHA3_512, PSA_ALG_SHA3_512);
|
||||
mbedtls_md_type_t md_alg = md_alg_arg;
|
||||
psa_algorithm_t psa_alg = psa_alg_arg;
|
||||
|
||||
/* Don't test for NONE<->NONE as this is not guaranteed */
|
||||
TEST_EQUAL(mbedtls_md_psa_alg_from_type(md_alg), psa_alg); \
|
||||
TEST_EQUAL(mbedtls_md_type_from_psa_alg(psa_alg), md_alg);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user