@@ -966,6 +966,9 @@ psa_status_t psa_get_generator_capacity( const psa_crypto_generator_t *generator
966
966
psa_invec_t in_vec = { & psa_crypto_ipc , sizeof ( psa_crypto_ipc ) };
967
967
psa_outvec_t out_vec = { capacity , sizeof ( * capacity ) };
968
968
969
+ if ( generator -> handle <= 0 )
970
+ return ( PSA_ERROR_INVALID_ARGUMENT );
971
+
969
972
err_call = psa_call ( generator -> handle , & in_vec , 1 , & out_vec , 1 );
970
973
971
974
if ( err_call < 0 )
@@ -982,6 +985,10 @@ psa_status_t psa_generator_read( psa_crypto_generator_t *generator,
982
985
psa_crypto_ipc .func = PSA_GENERATOR_READ ;
983
986
psa_invec_t in_vec = { & psa_crypto_ipc , sizeof ( psa_crypto_ipc ) };
984
987
psa_outvec_t out_vec = { output , output_length };
988
+
989
+ if ( generator -> handle <= 0 )
990
+ return ( PSA_ERROR_INVALID_ARGUMENT );
991
+
985
992
err_call = psa_call ( generator -> handle , & in_vec , 1 , & out_vec , 1 );
986
993
987
994
if ( err_call < 0 )
@@ -1001,7 +1008,10 @@ psa_status_t psa_generator_import_key( psa_key_slot_t key,
1001
1008
psa_invec_t in_vec [3 ] = { { & psa_crypto_ipc , sizeof ( psa_crypto_ipc ) },
1002
1009
{ & type , sizeof ( type ) },
1003
1010
{ & bits , sizeof ( bits ) } };
1004
-
1011
+
1012
+ if ( generator -> handle <= 0 )
1013
+ return ( PSA_ERROR_INVALID_ARGUMENT );
1014
+
1005
1015
err_call = psa_call ( generator -> handle , in_vec , 3 , NULL , 0 );
1006
1016
1007
1017
if ( err_call < 0 )
0 commit comments