@@ -6,7 +6,7 @@ use base64ct::{Base64, Encoding};
6
6
use sentc_crypto_common:: crypto:: { EncryptedHead , GeneratedSymKeyHeadServerOutput } ;
7
7
use sentc_crypto_common:: user:: UserPublicKeyData ;
8
8
use sentc_crypto_core:: cryptomat:: { CryptoAlg , SymKeyComposer , SymKeyGen } ;
9
- use sentc_crypto_utils:: cryptomat:: { PkFromUserKeyWrapper , PkWrapper , SkWrapper , SymKeyComposerWrapper , SymKeyGenWrapper , SymKeyWrapper } ;
9
+ use sentc_crypto_utils:: cryptomat:: { PkFromUserKeyWrapper , SkWrapper , SymKeyComposerWrapper , SymKeyGenWrapper , SymKeyWrapper } ;
10
10
use serde:: { Deserialize , Serialize } ;
11
11
12
12
use crate :: util:: public:: handle_server_response;
@@ -186,7 +186,7 @@ impl<SGen: SymKeyGenWrapper, SC: SymKeyComposerWrapper, P: PkFromUserKeyWrapper>
186
186
{
187
187
let public_key = P :: from_user_key ( reply_public_key) ?;
188
188
189
- let ( encrypted_key, key) = SGen :: KeyGen :: generate_symmetric_with_public_key ( public_key. get_key ( ) ) ?;
189
+ let ( encrypted_key, key) = SGen :: KeyGen :: generate_symmetric_with_public_key ( & public_key) ?;
190
190
191
191
let encrypted_key_string = Base64 :: encode_string ( & encrypted_key) ;
192
192
@@ -195,7 +195,7 @@ impl<SGen: SymKeyGenWrapper, SC: SymKeyComposerWrapper, P: PkFromUserKeyWrapper>
195
195
let server_output = GeneratedSymKeyHeadServerOutput {
196
196
alg : sym_key_format. get_key ( ) . get_alg_str ( ) . to_string ( ) ,
197
197
encrypted_key_string,
198
- master_key_id : public_key . get_id ( ) . to_string ( ) ,
198
+ master_key_id : reply_public_key . public_key_id . to_string ( ) ,
199
199
key_id : "non_registered" . to_string ( ) ,
200
200
time : 0 ,
201
201
} ;
@@ -209,20 +209,22 @@ mod test
209
209
{
210
210
use sentc_crypto_utils:: cryptomat:: { PkFromUserKeyWrapper , SkCryptoWrapper , SymKeyCrypto } ;
211
211
212
- use crate :: crypto:: mimic_keys:: FakeSignKeyWrapper ;
213
212
use crate :: group:: test_fn:: create_group;
214
213
use crate :: user:: test_fn:: create_user;
215
214
216
215
#[ cfg( feature = "std_keys" ) ]
217
216
pub type TestKeyGenerator = crate :: keys:: std:: StdKeyGenerator ;
218
217
#[ cfg( all( feature = "fips_keys" , not( feature = "std_keys" ) ) ) ]
219
218
pub type TestKeyGenerator = crate :: keys:: fips:: FipsKeyGenerator ;
219
+ #[ cfg( all( feature = "rec_keys" , not( feature = "std_keys" ) ) ) ]
220
+ pub type TestKeyGenerator = crate :: keys:: rec:: RecKeyGenerator ;
220
221
221
222
#[ cfg( feature = "std_keys" ) ]
222
223
pub type TestPublicKey = sentc_crypto_std_keys:: util:: PublicKey ;
223
-
224
224
#[ cfg( all( feature = "fips_keys" , not( feature = "std_keys" ) ) ) ]
225
225
pub type TestPublicKey = sentc_crypto_fips_keys:: util:: PublicKey ;
226
+ #[ cfg( all( feature = "rec_keys" , not( feature = "std_keys" ) ) ) ]
227
+ pub type TestPublicKey = sentc_crypto_rec_keys:: util:: PublicKey ;
226
228
227
229
#[ test]
228
230
fn test_encrypt_decrypt_sym_raw ( )
@@ -235,9 +237,7 @@ mod test
235
237
//now start encrypt and decrypt with the group master key
236
238
let text = "123*+^êéèüöß@€&$" ;
237
239
238
- let ( head, encrypted) = group_key
239
- . encrypt_raw ( text. as_bytes ( ) , None :: < & FakeSignKeyWrapper > )
240
- . unwrap ( ) ;
240
+ let ( head, encrypted) = group_key. encrypt_raw ( text. as_bytes ( ) , None ) . unwrap ( ) ;
241
241
242
242
let decrypted = group_key. decrypt_raw ( & encrypted, & head, None ) . unwrap ( ) ;
243
243
@@ -280,7 +280,7 @@ mod test
280
280
let payload = b"payload1234567891011121314151617" ;
281
281
282
282
let ( head, encrypted) = group_key
283
- . encrypt_raw_with_aad ( text. as_bytes ( ) , payload, None :: < & FakeSignKeyWrapper > )
283
+ . encrypt_raw_with_aad ( text. as_bytes ( ) , payload, None )
284
284
. unwrap ( ) ;
285
285
286
286
let decrypted = group_key
@@ -325,12 +325,7 @@ mod test
325
325
let text = "123*+^êéèüöß@€&$" ;
326
326
let user = create_user ( ) ;
327
327
328
- let ( head, encrypted) = TestPublicKey :: encrypt_raw_with_user_key (
329
- & user. user_keys [ 0 ] . exported_public_key ,
330
- text. as_bytes ( ) ,
331
- None :: < & FakeSignKeyWrapper > ,
332
- )
333
- . unwrap ( ) ;
328
+ let ( head, encrypted) = TestPublicKey :: encrypt_raw_with_user_key ( & user. user_keys [ 0 ] . exported_public_key , text. as_bytes ( ) , None ) . unwrap ( ) ;
334
329
335
330
let decrypted = user. user_keys [ 0 ]
336
331
. private_key
@@ -372,9 +367,7 @@ mod test
372
367
//now start encrypt and decrypt with the group master key
373
368
let text = "123*+^êéèüöß@€&$" ;
374
369
375
- let encrypted = group_key
376
- . encrypt ( text. as_bytes ( ) , None :: < & FakeSignKeyWrapper > )
377
- . unwrap ( ) ;
370
+ let encrypted = group_key. encrypt ( text. as_bytes ( ) , None ) . unwrap ( ) ;
378
371
379
372
let decrypted = group_key. decrypt ( & encrypted, None ) . unwrap ( ) ;
380
373
@@ -393,7 +386,7 @@ mod test
393
386
let payload = b"payload1234567891011121314151617" ;
394
387
395
388
let encrypted = group_key
396
- . encrypt_with_aad ( text. as_bytes ( ) , payload, None :: < & FakeSignKeyWrapper > )
389
+ . encrypt_with_aad ( text. as_bytes ( ) , payload, None )
397
390
. unwrap ( ) ;
398
391
399
392
let decrypted = group_key
@@ -416,7 +409,7 @@ mod test
416
409
let payload2 = b"payload1234567891011121314151618" ;
417
410
418
411
let encrypted = group_key
419
- . encrypt_with_aad ( text. as_bytes ( ) , payload, None :: < & FakeSignKeyWrapper > )
412
+ . encrypt_with_aad ( text. as_bytes ( ) , payload, None )
420
413
. unwrap ( ) ;
421
414
422
415
let decrypted = group_key. decrypt_with_aad ( & encrypted, payload2, None ) ;
@@ -457,12 +450,7 @@ mod test
457
450
//now start encrypt and decrypt with the group master key
458
451
let text = "123*+^êéèüöß@€&$" ;
459
452
460
- let encrypted = TestPublicKey :: encrypt_with_user_key (
461
- & user. user_keys [ 0 ] . exported_public_key ,
462
- text. as_bytes ( ) ,
463
- None :: < & FakeSignKeyWrapper > ,
464
- )
465
- . unwrap ( ) ;
453
+ let encrypted = TestPublicKey :: encrypt_with_user_key ( & user. user_keys [ 0 ] . exported_public_key , text. as_bytes ( ) , None ) . unwrap ( ) ;
466
454
467
455
let decrypted = user. user_keys [ 0 ]
468
456
. private_key
@@ -506,9 +494,7 @@ mod test
506
494
//now start encrypt and decrypt with the group master key
507
495
let text = "123*+^êéèüöß@€&$" ;
508
496
509
- let encrypted = group_key
510
- . encrypt_string ( text, None :: < & FakeSignKeyWrapper > )
511
- . unwrap ( ) ;
497
+ let encrypted = group_key. encrypt_string ( text, None ) . unwrap ( ) ;
512
498
513
499
let decrypted = group_key. decrypt_string ( & encrypted, None ) . unwrap ( ) ;
514
500
@@ -526,7 +512,7 @@ mod test
526
512
let payload = "payload1234567891011121314151617" ;
527
513
528
514
let encrypted = group_key
529
- . encrypt_string_with_aad ( text, payload, None :: < & FakeSignKeyWrapper > )
515
+ . encrypt_string_with_aad ( text, payload, None )
530
516
. unwrap ( ) ;
531
517
532
518
let decrypted = group_key
@@ -566,12 +552,7 @@ mod test
566
552
//now start encrypt and decrypt with the group master key
567
553
let text = "123*+^êéèüöß@€&$" ;
568
554
569
- let encrypted = TestPublicKey :: encrypt_string_with_user_key (
570
- & user. user_keys [ 0 ] . exported_public_key ,
571
- text,
572
- None :: < & FakeSignKeyWrapper > ,
573
- )
574
- . unwrap ( ) ;
555
+ let encrypted = TestPublicKey :: encrypt_string_with_user_key ( & user. user_keys [ 0 ] . exported_public_key , text, None ) . unwrap ( ) ;
575
556
576
557
let decrypted = user. user_keys [ 0 ]
577
558
. private_key
0 commit comments