Skip to content

Commit 0892d0f

Browse files
committed
Initialize key bits to max size + 1 in psa_import_key
In psa_import_key, the key bits value was uninitialized before calling the secure element driver import function. There is a potential issue if the driver returns PSA_SUCCESS without setting the key bits. This shouldn't happen, but shouldn't be discounted either, so we initialize the key bits to an invalid issue.
1 parent 74c932e commit 0892d0f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/psa_crypto.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,9 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
18351835
if( driver != NULL )
18361836
{
18371837
const psa_drv_se_t *drv = psa_get_se_driver_methods( driver );
1838-
size_t bits;
1838+
/* The driver should set the number of key bits, however in
1839+
* case it doesn't, we initialize bits to an invalid value. */
1840+
size_t bits = PSA_MAX_KEY_BITS + 1;
18391841
if( drv->key_management == NULL ||
18401842
drv->key_management->p_import == NULL )
18411843
{

0 commit comments

Comments
 (0)