@@ -45,8 +45,8 @@ use parsec_client::core::interface::operations::list_authenticators::Authenticat
45
45
use parsec_client:: core:: interface:: operations:: list_keys:: KeyInfo ;
46
46
use parsec_client:: core:: interface:: operations:: list_providers:: ProviderInfo ;
47
47
use parsec_client:: core:: interface:: operations:: psa_algorithm:: {
48
- Aead , AeadWithDefaultLengthTag , Algorithm , AsymmetricEncryption , AsymmetricSignature , Hash ,
49
- KeyAgreement , RawKeyAgreement ,
48
+ Aead , AeadWithDefaultLengthTag , Algorithm , AsymmetricEncryption , AsymmetricSignature , Cipher ,
49
+ Hash , KeyAgreement , RawKeyAgreement ,
50
50
} ;
51
51
use parsec_client:: core:: interface:: operations:: psa_key_attributes:: {
52
52
Attributes , EccFamily , Lifetime , Policy , Type , UsageFlags ,
@@ -390,6 +390,19 @@ impl TestClient {
390
390
self . import_key ( key_name, attributes, data)
391
391
}
392
392
393
+ /// Import an AES key.
394
+ pub fn import_aes_key_cipher (
395
+ & mut self ,
396
+ key_name : String ,
397
+ data : Vec < u8 > ,
398
+ encryption_alg : Cipher ,
399
+ ) -> Result < ( ) > {
400
+ let mut attributes = TestClient :: default_encrypt_aes_attrs ( ) ;
401
+ attributes. bits = 0 ;
402
+ attributes. policy . permitted_algorithms = encryption_alg. into ( ) ;
403
+ self . import_key ( key_name, attributes, data)
404
+ }
405
+
393
406
/// Import ECC key pair with secp R1 curve family.
394
407
/// The key can only be used for key agreement with Ecdh algorithm.
395
408
pub fn import_ecc_pair_secp_r1_key ( & mut self , key_name : String , data : Vec < u8 > ) -> Result < ( ) > {
@@ -762,6 +775,28 @@ impl TestClient {
762
775
. map_err ( convert_error)
763
776
}
764
777
778
+ pub fn cipher_encrypt_message (
779
+ & mut self ,
780
+ key_name : String ,
781
+ alg : Cipher ,
782
+ plaintext : & [ u8 ] ,
783
+ ) -> Result < Vec < u8 > > {
784
+ self . basic_client
785
+ . psa_cipher_encrypt ( key_name, alg, plaintext)
786
+ . map_err ( convert_error)
787
+ }
788
+
789
+ pub fn cipher_decrypt_message (
790
+ & mut self ,
791
+ key_name : String ,
792
+ alg : Cipher ,
793
+ ciphertext : & [ u8 ] ,
794
+ ) -> Result < Vec < u8 > > {
795
+ self . basic_client
796
+ . psa_cipher_decrypt ( key_name, alg, ciphertext)
797
+ . map_err ( convert_error)
798
+ }
799
+
765
800
pub fn hash_compute ( & mut self , alg : Hash , input : & [ u8 ] ) -> Result < Vec < u8 > > {
766
801
self . basic_client
767
802
. psa_hash_compute ( alg, input)
0 commit comments