@@ -8,7 +8,9 @@ use zeroize::Zeroizing;
88
99use super :: KeyStoreInner ;
1010use crate :: {
11- derive_shareable_key, error:: UnsupportedOperation , store:: backend:: StoreBackend , AsymmetricCryptoKey , CryptoError , EncString , KeyId , KeyIds , Result , Signature , SignatureAlgorithm , SignedObject , SigningKey , SymmetricCryptoKey , UnsignedSharedKey
11+ derive_shareable_key, error:: UnsupportedOperation , store:: backend:: StoreBackend ,
12+ AsymmetricCryptoKey , CryptoError , EncString , KeyId , KeyIds , Result , Signature ,
13+ SignatureAlgorithm , SignedObject , SigningKey , SymmetricCryptoKey , UnsignedSharedKey ,
1214} ;
1315
1416/// The context of a crypto operation using [super::KeyStore]
@@ -263,10 +265,7 @@ impl<Ids: KeyIds> KeyStoreContext<'_, Ids> {
263265 }
264266
265267 // Generate a new signature key using the current default algorithm, and store it in the context
266- pub fn make_signing_key (
267- & mut self ,
268- key_id : Ids :: Signing ,
269- ) -> Result < Ids :: Signing > {
268+ pub fn make_signing_key ( & mut self , key_id : Ids :: Signing ) -> Result < Ids :: Signing > {
270269 let key = SigningKey :: make ( SignatureAlgorithm :: default_algorithm ( ) ) ?;
271270 #[ allow( deprecated) ]
272271 self . set_signing_key ( key_id, key) ?;
@@ -421,8 +420,9 @@ impl<Ids: KeyIds> KeyStoreContext<'_, Ids> {
421420 }
422421 }
423422
424- /// Signs the given data using the specified signing key, for the given [crate::SigningNamespace]
425- /// and returns the signature and the serialized message. See [crate::SigningKey::sign]
423+ /// Signs the given data using the specified signing key, for the given
424+ /// [crate::SigningNamespace] and returns the signature and the serialized message. See
425+ /// [crate::SigningKey::sign]
426426 #[ allow( unused) ]
427427 pub ( crate ) fn sign < Message : Serialize > (
428428 & self ,
@@ -434,8 +434,9 @@ impl<Ids: KeyIds> KeyStoreContext<'_, Ids> {
434434 key. sign ( message, namespace)
435435 }
436436
437- /// Signs the given data using the specified signing key, for the given [crate::SigningNamespace]
438- /// and returns the signature and the serialized message. See [crate::SigningKey::sign_detached]
437+ /// Signs the given data using the specified signing key, for the given
438+ /// [crate::SigningNamespace] and returns the signature and the serialized message. See
439+ /// [crate::SigningKey::sign_detached]
439440 #[ allow( unused) ]
440441 pub ( crate ) fn sign_detached < Message : Serialize > (
441442 & self ,
@@ -455,7 +456,9 @@ mod tests {
455456 use serde:: { Deserialize , Serialize } ;
456457
457458 use crate :: {
458- store:: { tests:: DataView , KeyStore } , traits:: tests:: { TestIds , TestSigningKey , TestSymmKey } , CryptoError , Decryptable , Encryptable , SignatureAlgorithm , SigningKey , SymmetricCryptoKey
459+ store:: { tests:: DataView , KeyStore } ,
460+ traits:: tests:: { TestIds , TestSigningKey , TestSymmKey } ,
461+ CryptoError , Decryptable , Encryptable , SignatureAlgorithm , SigningKey , SymmetricCryptoKey ,
459462 } ;
460463
461464 #[ test]
@@ -535,7 +538,6 @@ mod tests {
535538 assert_eq ! ( decrypted1. 0 , decrypted2. 0 ) ;
536539 }
537540
538-
539541 #[ test]
540542 fn test_signing ( ) {
541543 let store: KeyStore < TestIds > = KeyStore :: default ( ) ;
@@ -558,15 +560,32 @@ mod tests {
558560 }
559561 let signed_object = store
560562 . context ( )
561- . sign ( key_a0_id, & TestData { data : "Hello" . to_string ( ) } , & & crate :: SigningNamespace :: ExampleNamespace )
563+ . sign (
564+ key_a0_id,
565+ & TestData {
566+ data : "Hello" . to_string ( ) ,
567+ } ,
568+ & & crate :: SigningNamespace :: ExampleNamespace ,
569+ )
562570 . unwrap ( ) ;
563- let payload: Result < TestData , CryptoError > = verifying_key. get_verified_payload ( & signed_object, & crate :: SigningNamespace :: ExampleNamespace ) ;
571+ let payload: Result < TestData , CryptoError > = verifying_key
572+ . get_verified_payload ( & signed_object, & crate :: SigningNamespace :: ExampleNamespace ) ;
564573 assert ! ( payload. is_ok( ) ) ;
565574
566575 let ( signature, serialized_message) = store
567576 . context ( )
568- . sign_detached ( key_a0_id, & TestData { data : "Hello" . to_string ( ) } , & & crate :: SigningNamespace :: ExampleNamespace )
577+ . sign_detached (
578+ key_a0_id,
579+ & TestData {
580+ data : "Hello" . to_string ( ) ,
581+ } ,
582+ & & crate :: SigningNamespace :: ExampleNamespace ,
583+ )
569584 . unwrap ( ) ;
570- assert ! ( verifying_key. verify_signature( & serialized_message, & crate :: SigningNamespace :: ExampleNamespace , & signature) ) ;
585+ assert ! ( verifying_key. verify_signature(
586+ & serialized_message,
587+ & crate :: SigningNamespace :: ExampleNamespace ,
588+ & signature
589+ ) ) ;
571590 }
572591}
0 commit comments