Skip to content

Commit 37a8c0c

Browse files
authored
Merge pull request #27 from hanno-arm/crypto_submodule_update_prs_6_18_19_sibling
PSA integration sibling: Update crypto submodule (Hash clone, Key Policy Init, Key slot alloc)
2 parents 4d69cf1 + 2169a5e commit 37a8c0c

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

library/cipher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx,
308308
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
309309

310310
/* Allocate a key slot to use. */
311-
status = psa_allocate_key( key_type, key_bitlen, &cipher_psa->slot );
311+
status = psa_allocate_key( &cipher_psa->slot );
312312
if( status != PSA_SUCCESS )
313313
return( MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED );
314314

@@ -322,7 +322,7 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx,
322322
* mbedtls_cipher_free() needs to be called in any case. */
323323

324324
/* Setup policy for the new key slot. */
325-
psa_key_policy_init( &key_policy );
325+
key_policy = psa_key_policy_init();
326326

327327
/* Mbed TLS' cipher layer doesn't enforce the mode of operation
328328
* (encrypt vs. decrypt): it is possible to setup a key for encryption

library/pk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,11 @@ int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
576576
mbedtls_psa_parse_tls_ecc_group ( curve_id ) );
577577

578578
/* allocate a key slot */
579-
if( PSA_SUCCESS != psa_allocate_key( key_type, d_len * 8, &key ) )
579+
if( PSA_SUCCESS != psa_allocate_key( &key ) )
580580
return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
581581

582582
/* set policy */
583-
psa_key_policy_init( &policy );
583+
policy = psa_key_policy_init();
584584
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN,
585585
PSA_ALG_ECDSA(hash_alg) );
586586
if( PSA_SUCCESS != psa_set_key_policy( key, &policy ) )

library/pk_wrap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,10 @@ static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
577577
psa_sig_md = PSA_ALG_ECDSA( psa_md );
578578
psa_type = PSA_KEY_TYPE_ECC_PUBLIC_KEY( curve );
579579

580-
if( ( ret = psa_allocate_key( psa_type,
581-
MBEDTLS_PSA_ECC_KEY_BITS_OF_CURVE(curve),
582-
&key_slot ) ) != PSA_SUCCESS )
580+
if( ( ret = psa_allocate_key( &key_slot ) ) != PSA_SUCCESS )
583581
return( mbedtls_psa_err_translate_pk( ret ) );
584582

585-
psa_key_policy_init( &policy );
583+
policy = psa_key_policy_init();
586584
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, psa_sig_md );
587585
if( ( ret = psa_set_key_policy( key_slot, &policy ) ) != PSA_SUCCESS )
588586
{

programs/ssl/ssl_client2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,14 +1594,14 @@ int main( int argc, char *argv[] )
15941594
if( opt.psk_opaque != 0 )
15951595
{
15961596
/* The algorithm has already been determined earlier. */
1597-
status = psa_allocate_key( PSA_KEY_TYPE_DERIVE, psk_len * 8, &slot );
1597+
status = psa_allocate_key( &slot );
15981598
if( status != PSA_SUCCESS )
15991599
{
16001600
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
16011601
goto exit;
16021602
}
16031603

1604-
psa_key_policy_init( &policy );
1604+
policy = psa_key_policy_init();
16051605
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
16061606

16071607
status = psa_set_key_policy( slot, &policy );

programs/ssl/ssl_server2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ static psa_status_t psa_setup_psk_key_slot( psa_key_handle_t slot,
12391239
psa_status_t status;
12401240
psa_key_policy_t policy;
12411241

1242-
psa_key_policy_init( &policy );
1242+
policy = psa_key_policy_init();
12431243
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
12441244

12451245
status = psa_set_key_policy( slot, &policy );
@@ -2667,7 +2667,7 @@ int main( int argc, char *argv[] )
26672667
#if defined(MBEDTLS_USE_PSA_CRYPTO)
26682668
if( opt.psk_opaque != 0 )
26692669
{
2670-
status = psa_allocate_key( PSA_KEY_TYPE_DERIVE, psk_len * 8, &psk_slot );
2670+
status = psa_allocate_key( &psk_slot );
26712671
if( status != PSA_SUCCESS )
26722672
{
26732673
fprintf( stderr, "ALLOC FAIL\n" );
@@ -2711,7 +2711,7 @@ int main( int argc, char *argv[] )
27112711
psk_entry *cur_psk;
27122712
for( cur_psk = psk_info; cur_psk != NULL; cur_psk = cur_psk->next )
27132713
{
2714-
status = psa_allocate_key( PSA_KEY_TYPE_DERIVE, cur_psk->key_len * 8, &cur_psk->slot );
2714+
status = psa_allocate_key( &cur_psk->slot );
27152715
if( status != PSA_SUCCESS )
27162716
{
27172717
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;

tests/suites/test_suite_pk.function

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ psa_key_handle_t pk_psa_genkey( void )
8484
psa_key_policy_t policy;
8585

8686
/* Allocate a key slot */
87-
if( PSA_SUCCESS != psa_allocate_key( type, bits, &key ) )
87+
if( PSA_SUCCESS != psa_allocate_key( &key ) )
8888
return( PK_PSA_INVALID_SLOT );
8989

9090
/* set up policy on key slot */
91-
psa_key_policy_init( &policy );
91+
policy = psa_key_policy_init();
9292
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN,
9393
PSA_ALG_ECDSA(PSA_ALG_SHA_256) );
9494
if( PSA_SUCCESS != psa_set_key_policy( key, &policy ) )

0 commit comments

Comments
 (0)