22// SPDX-License-Identifier: Apache-2.0
33
44use cryptoki:: object:: { Attribute , AttributeType , KeyType , ObjectClass , ObjectHandle } ;
5- use der:: AnyRef ;
6- use rsa:: {
7- pkcs1,
8- pkcs1v15:: { Signature , VerifyingKey } ,
9- } ;
10- use spki:: { AlgorithmIdentifierRef , AssociatedAlgorithmIdentifier , SignatureAlgorithmIdentifier } ;
5+ use rsa:: pkcs1v15:: { RsaSignatureAssociatedOid , Signature , VerifyingKey } ;
6+ use spki:: { AlgorithmIdentifier , AssociatedAlgorithmIdentifier , SignatureAlgorithmIdentifier } ;
117use std:: convert:: TryFrom ;
128
139use super :: { read_key, DigestSigning , Error } ;
@@ -71,9 +67,14 @@ impl<D: DigestSigning, S: SessionLike> Signer<D, S> {
7167 }
7268}
7369
74- impl < D : DigestSigning , S : SessionLike > AssociatedAlgorithmIdentifier for Signer < D , S > {
75- type Params = AnyRef < ' static > ;
76- const ALGORITHM_IDENTIFIER : AlgorithmIdentifierRef < ' static > = pkcs1:: ALGORITHM_ID ;
70+ impl < D , S > AssociatedAlgorithmIdentifier for Signer < D , S >
71+ where
72+ D : DigestSigning ,
73+ S : SessionLike ,
74+ {
75+ type Params = <VerifyingKey < D > as AssociatedAlgorithmIdentifier >:: Params ;
76+ const ALGORITHM_IDENTIFIER : AlgorithmIdentifier < Self :: Params > =
77+ <VerifyingKey < D > as AssociatedAlgorithmIdentifier >:: ALGORITHM_IDENTIFIER ;
7778}
7879
7980impl < D : DigestSigning , S : SessionLike > signature:: Keypair for Signer < D , S > {
@@ -99,12 +100,13 @@ impl<D: DigestSigning, S: SessionLike> signature::Signer<Signature> for Signer<D
99100 }
100101}
101102
102- impl < D : DigestSigning , S : SessionLike > SignatureAlgorithmIdentifier for Signer < D , S > {
103- type Params = AnyRef < ' static > ;
103+ impl < D , S > SignatureAlgorithmIdentifier for Signer < D , S >
104+ where
105+ S : SessionLike ,
106+ D : DigestSigning + RsaSignatureAssociatedOid ,
107+ {
108+ type Params = <VerifyingKey < D > as SignatureAlgorithmIdentifier >:: Params ;
104109
105- const SIGNATURE_ALGORITHM_IDENTIFIER : AlgorithmIdentifierRef < ' static > =
106- AlgorithmIdentifierRef {
107- oid : D :: OID ,
108- parameters : Some ( AnyRef :: NULL ) ,
109- } ;
110+ const SIGNATURE_ALGORITHM_IDENTIFIER : AlgorithmIdentifier < Self :: Params > =
111+ <VerifyingKey < D > as SignatureAlgorithmIdentifier >:: SIGNATURE_ALGORITHM_IDENTIFIER ;
110112}
0 commit comments