mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-20 03:39:58 +00:00
Test OID lookup for every hash algorithm
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
6cc1734f3e
commit
8dda131a0a
@ -1,6 +1,8 @@
|
||||
/* BEGIN_HEADER */
|
||||
#include "mbedtls/md.h"
|
||||
#include "../library/md_psa.h"
|
||||
#include "mbedtls/oid.h"
|
||||
#include "mbedtls/asn1.h"
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
@ -30,12 +32,23 @@ void mbedtls_md_list()
|
||||
TEST_EQUAL(0, mbedtls_md_finish(&ctx, out));
|
||||
mbedtls_md_free(&ctx);
|
||||
|
||||
#if defined MBEDTLS_PSA_CRYPTO_C
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
/* Ensure that we can convert to and from a psa_algorithm_t */
|
||||
psa_algorithm_t p = mbedtls_md_psa_alg_from_type(*md_type_ptr);
|
||||
TEST_ASSERT(p != PSA_ALG_NONE);
|
||||
TEST_EQUAL(*md_type_ptr, mbedtls_md_type_from_psa_alg(p));
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_OID_C)
|
||||
mbedtls_asn1_buf asn1;
|
||||
/* Check that we have an OID definition */
|
||||
TEST_EQUAL(mbedtls_oid_get_oid_by_md((mbedtls_md_type_t) *md_type_ptr,
|
||||
(const char **) &asn1.p, &asn1.len), 0);
|
||||
/* Check that this OID definition maps back to the correct mbedtls_md_type_t */
|
||||
mbedtls_md_type_t m;
|
||||
TEST_EQUAL(mbedtls_oid_get_md_alg(&asn1, &m), 0);
|
||||
TEST_EQUAL(m, *md_type_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
exit:
|
||||
|
Loading…
x
Reference in New Issue
Block a user