Skip to content

Commit d918cb5

Browse files
committed
spki: impl From<AlgorithmIdentifierRef> for Any
1 parent e28a8ea commit d918cb5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spki/src/algorithm.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<'a> AlgorithmIdentifierRef<'a> {
175175
#[cfg(feature = "alloc")]
176176
mod allocating {
177177
use super::*;
178-
use der::referenced::*;
178+
use der::{referenced::*, Tag};
179179

180180
impl<'a> RefToOwned<'a> for AlgorithmIdentifierRef<'a> {
181181
type Owned = AlgorithmIdentifierOwned;
@@ -196,4 +196,12 @@ mod allocating {
196196
}
197197
}
198198
}
199+
200+
impl From<&AlgorithmIdentifierRef<'_>> for Any {
201+
fn from(alg: &AlgorithmIdentifierRef<'_>) -> Any {
202+
let bytes = alg.to_der().expect("Algorithm invariant violated");
203+
204+
Any::new(Tag::Sequence, bytes).expect("Algorithm invariant violated")
205+
}
206+
}
199207
}

0 commit comments

Comments
 (0)