x509_certificate/
rfc8017.rs1use bcder::{
8 decode::{Constructed, DecodeError, Source},
9 encode::{self, PrimitiveContent, Values},
10 Unsigned,
11};
12
13#[derive(Clone, Debug, Eq, PartialEq)]
22pub struct RsaPublicKey {
23 pub modulus: Unsigned,
24 pub public_exponent: Unsigned,
25}
26
27impl RsaPublicKey {
28 pub fn take_from<S: Source>(cons: &mut Constructed<S>) -> Result<Self, DecodeError<S::Error>> {
29 cons.take_sequence(|cons| {
30 let modulus = Unsigned::take_from(cons)?;
31 let public_exponent = Unsigned::take_from(cons)?;
32
33 Ok(Self {
34 modulus,
35 public_exponent,
36 })
37 })
38 }
39
40 pub fn encode_ref(&self) -> impl Values + '_ {
41 encode::sequence((self.modulus.encode(), self.public_exponent.encode()))
42 }
43}