33use alloc:: vec;
44use core:: fmt;
55use der:: { asn1:: BitString , referenced:: OwnedToRef , Encode } ;
6- use signature:: { rand_core:: CryptoRngCore , Keypair , RandomizedSigner , SignatureEncoding , Signer } ;
6+ use signature:: { rand_core:: CryptoRngCore , Keypair , RandomizedSigner , Signer } ;
77use spki:: {
8- DynSignatureAlgorithmIdentifier , EncodePublicKey , SubjectPublicKeyInfoOwned ,
9- SubjectPublicKeyInfoRef ,
8+ DynSignatureAlgorithmIdentifier , EncodePublicKey , SignatureBitStringEncoding ,
9+ SubjectPublicKeyInfoOwned , SubjectPublicKeyInfoRef ,
1010} ;
1111
1212use crate :: {
@@ -421,12 +421,11 @@ pub trait Builder: Sized {
421421 fn build < Signature > ( mut self ) -> Result < Self :: Output >
422422 where
423423 Self :: Signer : Signer < Signature > ,
424- Signature : SignatureEncoding ,
424+ Signature : SignatureBitStringEncoding ,
425425 {
426426 let blob = self . finalize ( ) ?;
427427
428- let signature = self . signer ( ) . try_sign ( & blob) ?;
429- let signature = BitString :: from_bytes ( signature. to_bytes ( ) . as_ref ( ) ) ?;
428+ let signature = self . signer ( ) . try_sign ( & blob) ?. to_bitstring ( ) ?;
430429
431430 self . assemble ( signature)
432431 }
@@ -435,12 +434,14 @@ pub trait Builder: Sized {
435434 fn build_with_rng < Signature > ( mut self , rng : & mut impl CryptoRngCore ) -> Result < Self :: Output >
436435 where
437436 Self :: Signer : RandomizedSigner < Signature > ,
438- Signature : SignatureEncoding ,
437+ Signature : SignatureBitStringEncoding ,
439438 {
440439 let blob = self . finalize ( ) ?;
441440
442- let signature = self . signer ( ) . try_sign_with_rng ( rng, & blob) ?;
443- let signature = BitString :: from_bytes ( signature. to_bytes ( ) . as_ref ( ) ) ?;
441+ let signature = self
442+ . signer ( )
443+ . try_sign_with_rng ( rng, & blob) ?
444+ . to_bitstring ( ) ?;
444445
445446 self . assemble ( signature)
446447 }
0 commit comments