@@ -17,6 +17,7 @@ use parsec_interface::requests::Response;
17
17
use parsec_interface:: requests:: ResponseStatus ;
18
18
use parsec_interface:: requests:: { request:: RequestHeader , Request } ;
19
19
use parsec_interface:: requests:: { AuthType , BodyType , Opcode } ;
20
+ use parsec_interface:: secrecy:: { ExposeSecret , Secret } ;
20
21
use std:: collections:: HashSet ;
21
22
use std:: io:: ErrorKind ;
22
23
@@ -118,7 +119,9 @@ fn list_opcodes_test() {
118
119
119
120
#[ test]
120
121
fn 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
+ ) ) ) ) ;
122
125
123
126
let res = client
124
127
. psa_destroy_key ( String :: from ( "random key" ) )
@@ -129,7 +132,9 @@ fn no_crypto_provider_test() {
129
132
130
133
#[ test]
131
134
fn 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
+ ) ) ) ) ;
133
138
134
139
client. set_implicit_provider ( ProviderID :: Core ) ;
135
140
let res = client
@@ -168,7 +173,7 @@ fn psa_generate_key_test() {
168
173
} ;
169
174
170
175
client
171
- . psa_generate_key ( key_name. clone ( ) , key_attrs. clone ( ) )
176
+ . psa_generate_key ( key_name. clone ( ) , key_attrs)
172
177
. expect ( "failed to generate key" ) ;
173
178
174
179
// Check request:
@@ -236,15 +241,15 @@ fn psa_import_key_test() {
236
241
} ;
237
242
let key_data = vec ! [ 0xff_u8 ; 128 ] ;
238
243
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)
240
245
. unwrap ( ) ;
241
246
242
247
// Check request:
243
248
let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
244
249
if let NativeOperation :: PsaImportKey ( op) = op {
245
250
assert_eq ! ( op. attributes, key_attrs) ;
246
251
assert_eq ! ( op. key_name, key_name) ;
247
- assert_eq ! ( op. data, key_data) ;
252
+ assert_eq ! ( op. data. expose_secret ( ) , & key_data) ;
248
253
} else {
249
254
panic ! ( "Got wrong operation type: {:?}" , op) ;
250
255
}
@@ -259,7 +264,7 @@ fn psa_export_public_key_test() {
259
264
let key_data = vec ! [ 0xa5 ; 128 ] ;
260
265
client. set_mock_read ( & get_response_bytes_from_result (
261
266
NativeResult :: PsaExportPublicKey ( operations:: psa_export_public_key:: Result {
262
- data : key_data. clone ( ) ,
267
+ data : key_data. clone ( ) . into ( ) ,
263
268
} ) ,
264
269
) ) ;
265
270
@@ -292,14 +297,14 @@ fn psa_sign_hash_test() {
292
297
let signature = vec ! [ 0x33_u8 ; 128 ] ;
293
298
client. set_mock_read ( & get_response_bytes_from_result ( NativeResult :: PsaSignHash (
294
299
operations:: psa_sign_hash:: Result {
295
- signature : signature. clone ( ) ,
300
+ signature : signature. clone ( ) . into ( ) ,
296
301
} ,
297
302
) ) ) ;
298
303
299
304
// Check response:
300
305
assert_eq ! (
301
306
client
302
- . psa_sign_hash( key_name. clone( ) , hash. clone ( ) , sign_algorithm. clone ( ) )
307
+ . psa_sign_hash( key_name. clone( ) , & hash, sign_algorithm)
303
308
. expect( "Failed to sign hash" ) ,
304
309
signature
305
310
) ;
@@ -308,7 +313,7 @@ fn psa_sign_hash_test() {
308
313
let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
309
314
if let NativeOperation :: PsaSignHash ( op) = op {
310
315
assert_eq ! ( op. key_name, key_name) ;
311
- assert_eq ! ( op. hash, hash) ;
316
+ assert_eq ! ( op. hash. to_vec ( ) , hash) ;
312
317
assert_eq ! ( op. alg, sign_algorithm) ;
313
318
} else {
314
319
panic ! ( "Got wrong operation type: {:?}" , op) ;
@@ -329,21 +334,16 @@ fn verify_hash_test() {
329
334
) ) ;
330
335
331
336
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)
338
338
. expect ( "Failed to sign hash" ) ;
339
339
340
340
// Check request:
341
341
let op = get_operation_from_req_bytes ( client. get_mock_write ( ) ) ;
342
342
if let NativeOperation :: PsaVerifyHash ( op) = op {
343
343
assert_eq ! ( op. key_name, key_name) ;
344
- assert_eq ! ( op. hash, hash) ;
344
+ assert_eq ! ( op. hash. to_vec ( ) , hash) ;
345
345
assert_eq ! ( op. alg, sign_algorithm) ;
346
- assert_eq ! ( op. signature, signature) ;
346
+ assert_eq ! ( op. signature. to_vec ( ) , signature) ;
347
347
} else {
348
348
panic ! ( "Got wrong operation type: {:?}" , op) ;
349
349
}
@@ -423,7 +423,7 @@ fn auth_value_test() {
423
423
424
424
let req = get_req_from_bytes ( client. get_mock_write ( ) ) ;
425
425
assert_eq ! (
426
- String :: from_utf8( req. auth. bytes ( ) . to_owned( ) ) . unwrap( ) ,
426
+ String :: from_utf8( req. auth. buffer . expose_secret ( ) . to_owned( ) ) . unwrap( ) ,
427
427
String :: from( DEFAULT_APP_NAME )
428
428
) ;
429
429
}
0 commit comments