Do key usage policy extension when loading keys
Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
parent
edf2df84ba
commit
43110b6b2c
@ -392,15 +392,19 @@ static inline psa_key_lifetime_t psa_get_key_lifetime(
|
|||||||
return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) );
|
return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void psa_set_key_usage_flags( psa_key_attributes_t *attributes,
|
static inline void psa_extend_key_usage_flags( psa_key_usage_t *usage_flags )
|
||||||
psa_key_usage_t usage_flags )
|
|
||||||
{
|
{
|
||||||
if( usage_flags & PSA_KEY_USAGE_SIGN_HASH )
|
if( *usage_flags & PSA_KEY_USAGE_SIGN_HASH )
|
||||||
usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
|
*usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
|
||||||
|
|
||||||
if( usage_flags & PSA_KEY_USAGE_VERIFY_HASH )
|
if( *usage_flags & PSA_KEY_USAGE_VERIFY_HASH )
|
||||||
usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
|
*usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
|
||||||
|
psa_key_usage_t usage_flags)
|
||||||
|
{
|
||||||
|
psa_extend_key_usage_flags( &usage_flags );
|
||||||
attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) = usage_flags;
|
attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) = usage_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,6 +391,10 @@ psa_status_t psa_get_and_lock_key_slot( mbedtls_svc_key_id_t key,
|
|||||||
if( status == PSA_ERROR_DOES_NOT_EXIST )
|
if( status == PSA_ERROR_DOES_NOT_EXIST )
|
||||||
status = PSA_ERROR_INVALID_HANDLE;
|
status = PSA_ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
/* Do the key usage policy extension. */
|
||||||
|
psa_extend_key_usage_flags( &(*p_slot)->attr.policy.usage );
|
||||||
|
|
||||||
return( status );
|
return( status );
|
||||||
#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
|
#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C || MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
|
||||||
return( PSA_ERROR_INVALID_HANDLE );
|
return( PSA_ERROR_INVALID_HANDLE );
|
||||||
|
Loading…
Reference in New Issue
Block a user