pkcs1/private_key/
other_prime_info.rs1use der::{
4 asn1::UintRef, DecodeValue, Encode, EncodeValue, Header, Length, Reader, Sequence, Writer,
5};
6
7#[derive(Clone)]
21pub struct OtherPrimeInfo<'a> {
22 pub prime: UintRef<'a>,
24
25 pub exponent: UintRef<'a>,
27
28 pub coefficient: UintRef<'a>,
30}
31
32impl<'a> DecodeValue<'a> for OtherPrimeInfo<'a> {
33 fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> der::Result<Self> {
34 reader.read_nested(header.length, |reader| {
35 Ok(Self {
36 prime: reader.decode()?,
37 exponent: reader.decode()?,
38 coefficient: reader.decode()?,
39 })
40 })
41 }
42}
43
44impl EncodeValue for OtherPrimeInfo<'_> {
45 fn value_len(&self) -> der::Result<Length> {
46 self.prime.encoded_len()? + self.exponent.encoded_len()? + self.coefficient.encoded_len()?
47 }
48
49 fn encode_value(&self, writer: &mut impl Writer) -> der::Result<()> {
50 self.prime.encode(writer)?;
51 self.exponent.encode(writer)?;
52 self.coefficient.encode(writer)?;
53 Ok(())
54 }
55}
56
57impl<'a> Sequence<'a> for OtherPrimeInfo<'a> {}