Check when usage == 0 in mbedtls_pk_can_do_ext()

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
Neil Armstrong 2022-05-20 09:26:16 +02:00
parent b80785f1a4
commit 81d391f773

View file

@ -256,7 +256,8 @@ int mbedtls_pk_can_do_ext( const mbedtls_pk_context *ctx, psa_algorithm_t alg,
return( 0 ); return( 0 );
/* Filter out non allowed usage flags */ /* Filter out non allowed usage flags */
if( ( usage & ~( PSA_KEY_USAGE_SIGN_HASH | if( usage == 0 ||
( usage & ~( PSA_KEY_USAGE_SIGN_HASH |
PSA_KEY_USAGE_DECRYPT | PSA_KEY_USAGE_DECRYPT |
PSA_KEY_USAGE_DERIVE ) ) != 0 ) PSA_KEY_USAGE_DERIVE ) ) != 0 )
return( 0 ); return( 0 );