@@ -5,7 +5,7 @@ use crate::{AlgorithmIdentifier, Error, Result, SubjectPublicKeyInfoRef};
5
5
#[ cfg( feature = "alloc" ) ]
6
6
use {
7
7
crate :: AlgorithmIdentifierOwned ,
8
- der:: { Any , Document } ,
8
+ der:: { Any , Document , EncodeValue , Tagged } ,
9
9
} ;
10
10
11
11
#[ cfg( feature = "pem" ) ]
@@ -114,20 +114,24 @@ pub trait AssociatedAlgorithmIdentifier {
114
114
#[ cfg( feature = "alloc" ) ]
115
115
pub trait DynAssociatedAlgorithmIdentifier {
116
116
/// `AlgorithmIdentifier` for this structure.
117
- fn algorithm_identifier ( & self ) -> AlgorithmIdentifierOwned ;
117
+ fn algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > ;
118
118
}
119
119
120
120
#[ cfg( feature = "alloc" ) ]
121
121
impl < T > DynAssociatedAlgorithmIdentifier for T
122
122
where
123
123
T : AssociatedAlgorithmIdentifier ,
124
- T :: Params : Into < Any > ,
124
+ T :: Params : Tagged + EncodeValue ,
125
125
{
126
- fn algorithm_identifier ( & self ) -> AlgorithmIdentifierOwned {
127
- AlgorithmIdentifierOwned {
126
+ fn algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > {
127
+ Ok ( AlgorithmIdentifierOwned {
128
128
oid : T :: ALGORITHM_IDENTIFIER . oid ,
129
- parameters : T :: ALGORITHM_IDENTIFIER . parameters . map ( Into :: into) ,
130
- }
129
+ parameters : T :: ALGORITHM_IDENTIFIER
130
+ . parameters
131
+ . as_ref ( )
132
+ . map ( Any :: encode_from)
133
+ . transpose ( ) ?,
134
+ } )
131
135
}
132
136
}
133
137
@@ -150,19 +154,23 @@ pub trait SignatureAlgorithmIdentifier {
150
154
#[ cfg( feature = "alloc" ) ]
151
155
pub trait DynSignatureAlgorithmIdentifier {
152
156
/// `AlgorithmIdentifier` for the corresponding singature system.
153
- fn signature_algorithm_identifier ( & self ) -> AlgorithmIdentifierOwned ;
157
+ fn signature_algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > ;
154
158
}
155
159
156
160
#[ cfg( feature = "alloc" ) ]
157
161
impl < T > DynSignatureAlgorithmIdentifier for T
158
162
where
159
163
T : SignatureAlgorithmIdentifier ,
160
- T :: Params : Into < Any > ,
164
+ T :: Params : Tagged + EncodeValue ,
161
165
{
162
- fn signature_algorithm_identifier ( & self ) -> AlgorithmIdentifierOwned {
163
- AlgorithmIdentifierOwned {
166
+ fn signature_algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > {
167
+ Ok ( AlgorithmIdentifierOwned {
164
168
oid : T :: SIGNATURE_ALGORITHM_IDENTIFIER . oid ,
165
- parameters : T :: SIGNATURE_ALGORITHM_IDENTIFIER . parameters . map ( Into :: into) ,
166
- }
169
+ parameters : T :: SIGNATURE_ALGORITHM_IDENTIFIER
170
+ . parameters
171
+ . as_ref ( )
172
+ . map ( Any :: encode_from)
173
+ . transpose ( ) ?,
174
+ } )
167
175
}
168
176
}
0 commit comments