Skip to content

Commit 672ab4f

Browse files
authored
spki: simplify bounds for *AlgorithmIdentifier traits (#980)
Makes the associated type bounds `Tagged + EncodeValue` which means the blanket impls will always work.
1 parent 9adb377 commit 672ab4f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

spki/src/traits.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Traits for encoding/decoding SPKI public keys.
22
33
use crate::{AlgorithmIdentifier, Error, Result, SubjectPublicKeyInfoRef};
4+
use der::{EncodeValue, Tagged};
45

56
#[cfg(feature = "alloc")]
67
use {
78
crate::AlgorithmIdentifierOwned,
8-
der::{Any, Document, EncodeValue, Tagged},
9+
der::{Any, Document},
910
};
1011

1112
#[cfg(feature = "pem")]
@@ -102,7 +103,7 @@ pub trait EncodePublicKey {
102103
/// This is useful for e.g. keys for digital signature algorithms.
103104
pub trait AssociatedAlgorithmIdentifier {
104105
/// Algorithm parameters.
105-
type Params: der::Encode;
106+
type Params: Tagged + EncodeValue;
106107

107108
/// `AlgorithmIdentifier` for this structure.
108109
const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params>;
@@ -121,7 +122,6 @@ pub trait DynAssociatedAlgorithmIdentifier {
121122
impl<T> DynAssociatedAlgorithmIdentifier for T
122123
where
123124
T: AssociatedAlgorithmIdentifier,
124-
T::Params: Tagged + EncodeValue,
125125
{
126126
fn algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned> {
127127
Ok(AlgorithmIdentifierOwned {
@@ -141,7 +141,7 @@ where
141141
/// private keys.
142142
pub trait SignatureAlgorithmIdentifier {
143143
/// Algorithm parameters.
144-
type Params: der::Encode;
144+
type Params: Tagged + EncodeValue;
145145

146146
/// `AlgorithmIdentifier` for the corresponding singature system.
147147
const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params>;
@@ -161,7 +161,6 @@ pub trait DynSignatureAlgorithmIdentifier {
161161
impl<T> DynSignatureAlgorithmIdentifier for T
162162
where
163163
T: SignatureAlgorithmIdentifier,
164-
T::Params: Tagged + EncodeValue,
165164
{
166165
fn signature_algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned> {
167166
Ok(AlgorithmIdentifierOwned {

0 commit comments

Comments
 (0)