mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-28 08:37:25 +00:00
Make psa_get_mac_output_length testable and test it
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
7d4b0d778f
commit
58c94d39ae
@ -564,9 +564,10 @@ static inline size_t psa_get_key_slot_bits( const psa_key_slot_t *slot )
|
|||||||
* \p algorithm tries to truncate the MAC to a size which would be
|
* \p algorithm tries to truncate the MAC to a size which would be
|
||||||
* larger than the underlying algorithm's maximum output length.
|
* larger than the underlying algorithm's maximum output length.
|
||||||
*/
|
*/
|
||||||
static psa_status_t psa_get_mac_output_length( psa_algorithm_t algorithm,
|
MBEDTLS_STATIC_TESTABLE psa_status_t psa_get_mac_output_length(
|
||||||
psa_key_type_t key_type,
|
psa_algorithm_t algorithm,
|
||||||
size_t *length )
|
psa_key_type_t key_type,
|
||||||
|
size_t *length )
|
||||||
{
|
{
|
||||||
/* Get the default length for the algorithm and key combination. None of the
|
/* Get the default length for the algorithm and key combination. None of the
|
||||||
* currently supported algorithms have a default output length dependent on
|
* currently supported algorithms have a default output length dependent on
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include "mbedtls/entropy.h"
|
#include "mbedtls/entropy.h"
|
||||||
|
|
||||||
@ -76,4 +77,10 @@ psa_status_t mbedtls_psa_crypto_configure_entropy_sources(
|
|||||||
void (* entropy_free )( mbedtls_entropy_context *ctx ) );
|
void (* entropy_free )( mbedtls_entropy_context *ctx ) );
|
||||||
#endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
|
#endif /* !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C)
|
||||||
|
psa_status_t psa_get_mac_output_length( psa_algorithm_t algorithm,
|
||||||
|
psa_key_type_t key_type,
|
||||||
|
size_t *length );
|
||||||
|
#endif /* MBEDTLS_TEST_HOOKS && MBEDTLS_PSA_CRYPTO_C */
|
||||||
|
|
||||||
#endif /* PSA_CRYPTO_INVASIVE_H */
|
#endif /* PSA_CRYPTO_INVASIVE_H */
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
|
#include "psa_crypto_invasive.h"
|
||||||
|
|
||||||
/* Flags for algorithm classification macros. There is a flag for every
|
/* Flags for algorithm classification macros. There is a flag for every
|
||||||
* algorithm classification macro PSA_ALG_IS_xxx except for the
|
* algorithm classification macro PSA_ALG_IS_xxx except for the
|
||||||
@ -158,6 +159,12 @@ void mac_algorithm_core( psa_algorithm_t alg, int classification_flags,
|
|||||||
/* Length */
|
/* Length */
|
||||||
TEST_EQUAL( length, PSA_MAC_LENGTH( key_type, key_bits, alg ) );
|
TEST_EQUAL( length, PSA_MAC_LENGTH( key_type, key_bits, alg ) );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS) && defined(MBEDTLS_PSA_CRYPTO_C)
|
||||||
|
size_t output_length = 0;
|
||||||
|
PSA_ASSERT( psa_get_mac_output_length( alg, key_type, &output_length ) );
|
||||||
|
TEST_EQUAL( length, output_length );
|
||||||
|
#endif
|
||||||
|
|
||||||
exit: ;
|
exit: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user