@@ -17,6 +17,7 @@ use parsec_interface::requests::Response;
1717use parsec_interface:: requests:: ResponseStatus ;
1818use parsec_interface:: requests:: { request:: RequestHeader , Request } ;
1919use parsec_interface:: requests:: { AuthType , BodyType , Opcode } ;
20+ use parsec_interface:: secrecy:: { ExposeSecret , Secret } ;
2021use std:: collections:: HashSet ;
2122use std:: io:: ErrorKind ;
2223
@@ -118,7 +119,9 @@ fn list_opcodes_test() {
118119
119120#[ test]
120121fn no_crypto_provider_test ( ) {
121- let client = BasicClient :: new ( AuthenticationData :: AppIdentity ( String :: from ( "oops" ) ) ) ;
122+ let client = BasicClient :: new ( AuthenticationData :: AppIdentity ( Secret :: new ( String :: from (
123+ "oops" ,
124+ ) ) ) ) ;
122125
123126 let res = client
124127 . psa_destroy_key ( String :: from ( "random key" ) )
@@ -129,7 +132,9 @@ fn no_crypto_provider_test() {
129132
130133#[ test]
131134fn core_provider_for_crypto_test ( ) {
132- let mut client = BasicClient :: new ( AuthenticationData :: AppIdentity ( String :: from ( "oops" ) ) ) ;
135+ let mut client = BasicClient :: new ( AuthenticationData :: AppIdentity ( Secret :: new ( String :: from (
136+ "oops" ,
137+ ) ) ) ) ;
133138
134139 client. set_implicit_provider ( ProviderID :: Core ) ;
135140 let res = client
@@ -168,7 +173,7 @@ fn psa_generate_key_test() {
168173 } ;
169174
170175 client
171- . psa_generate_key ( key_name. clone ( ) , key_attrs. clone ( ) )
176+ . psa_generate_key ( key_name. clone ( ) , key_attrs)
172177 . expect ( "failed to generate key" ) ;
173178
174179 // Check request:
@@ -236,15 +241,15 @@ fn psa_import_key_test() {
236241 } ;
237242 let key_data = vec ! [ 0xff_u8 ; 128 ] ;
238243 client
239- . psa_import_key ( key_name. clone ( ) , key_data. clone ( ) , key_attrs. clone ( ) )
244+ . psa_import_key ( key_name. clone ( ) , & key_data, key_attrs)
240245 . unwrap ( ) ;
241246
242247 // Check request:
243248 let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
244249 if let NativeOperation :: PsaImportKey ( op) = op {
245250 assert_eq ! ( op. attributes, key_attrs) ;
246251 assert_eq ! ( op. key_name, key_name) ;
247- assert_eq ! ( op. data, key_data) ;
252+ assert_eq ! ( op. data. expose_secret ( ) , & key_data) ;
248253 } else {
249254 panic ! ( "Got wrong operation type: {:?}" , op) ;
250255 }
@@ -259,7 +264,7 @@ fn psa_export_public_key_test() {
259264 let key_data = vec ! [ 0xa5 ; 128 ] ;
260265 client. set_mock_read ( & get_response_bytes_from_result (
261266 NativeResult :: PsaExportPublicKey ( operations:: psa_export_public_key:: Result {
262- data : key_data. clone ( ) ,
267+ data : key_data. clone ( ) . into ( ) ,
263268 } ) ,
264269 ) ) ;
265270
@@ -292,14 +297,14 @@ fn psa_sign_hash_test() {
292297 let signature = vec ! [ 0x33_u8 ; 128 ] ;
293298 client. set_mock_read ( & get_response_bytes_from_result ( NativeResult :: PsaSignHash (
294299 operations:: psa_sign_hash:: Result {
295- signature : signature. clone ( ) ,
300+ signature : signature. clone ( ) . into ( ) ,
296301 } ,
297302 ) ) ) ;
298303
299304 // Check response:
300305 assert_eq ! (
301306 client
302- . psa_sign_hash( key_name. clone( ) , hash. clone ( ) , sign_algorithm. clone ( ) )
307+ . psa_sign_hash( key_name. clone( ) , & hash, sign_algorithm)
303308 . expect( "Failed to sign hash" ) ,
304309 signature
305310 ) ;
@@ -308,7 +313,7 @@ fn psa_sign_hash_test() {
308313 let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
309314 if let NativeOperation :: PsaSignHash ( op) = op {
310315 assert_eq ! ( op. key_name, key_name) ;
311- assert_eq ! ( op. hash, hash) ;
316+ assert_eq ! ( op. hash. to_vec ( ) , hash) ;
312317 assert_eq ! ( op. alg, sign_algorithm) ;
313318 } else {
314319 panic ! ( "Got wrong operation type: {:?}" , op) ;
@@ -329,21 +334,16 @@ fn verify_hash_test() {
329334 ) ) ;
330335
331336 client
332- . psa_verify_hash (
333- key_name. clone ( ) ,
334- hash. clone ( ) ,
335- sign_algorithm. clone ( ) ,
336- signature. clone ( ) ,
337- )
337+ . psa_verify_hash ( key_name. clone ( ) , & hash, sign_algorithm, & signature)
338338 . expect ( "Failed to sign hash" ) ;
339339
340340 // Check request:
341341 let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
342342 if let NativeOperation :: PsaVerifyHash ( op) = op {
343343 assert_eq ! ( op. key_name, key_name) ;
344- assert_eq ! ( op. hash, hash) ;
344+ assert_eq ! ( op. hash. to_vec ( ) , hash) ;
345345 assert_eq ! ( op. alg, sign_algorithm) ;
346- assert_eq ! ( op. signature, signature) ;
346+ assert_eq ! ( op. signature. to_vec ( ) , signature) ;
347347 } else {
348348 panic ! ( "Got wrong operation type: {:?}" , op) ;
349349 }
@@ -423,7 +423,7 @@ fn auth_value_test() {
423423
424424 let req = get_req_from_bytes ( client. get_mock_write ( ) ) ;
425425 assert_eq ! (
426- String :: from_utf8( req. auth. bytes ( ) . to_owned( ) ) . unwrap( ) ,
426+ String :: from_utf8( req. auth. buffer . expose_secret ( ) . to_owned( ) ) . unwrap( ) ,
427427 String :: from( DEFAULT_APP_NAME )
428428 ) ;
429429}
0 commit comments