1 /// RSA key pair components. 2 pub struct Components<Public, Private = Public> 3 where 4 Public: AsRef<[u8]> + core::fmt::Debug, 5 { 6 /// The public key components. 7 pub public_key: super::super::public::Components<Public>, 8 9 /// The private exponent. 10 pub d: Private, 11 12 /// The first prime factor of `d`. 13 pub p: Private, 14 15 /// The second prime factor of `d`. 16 pub q: Private, 17 18 /// `p`'s public Chinese Remainder Theorem exponent. 19 pub dP: Private, 20 21 /// `q`'s public Chinese Remainder Theorem exponent. 22 pub dQ: Private, 23 24 /// `q**-1 mod p`. 25 pub qInv: Private, 26 } 27 28 impl<Public, Private> Copy for Components<Public, Private> 29 where 30 Public: AsRef<[u8]> + Copy + core::fmt::Debug, 31 Private: Copy, 32 { 33 } 34 35 impl<Public, Private> Clone for Components<Public, Private> 36 where 37 Public: AsRef<[u8]> + Clone + core::fmt::Debug, 38 Private: Clone, 39 { clone(&self) -> Self40 fn clone(&self) -> Self { 41 Self { 42 public_key: self.public_key.clone(), 43 d: self.d.clone(), 44 p: self.p.clone(), 45 q: self.q.clone(), 46 dP: self.dP.clone(), 47 dQ: self.dQ.clone(), 48 qInv: self.qInv.clone(), 49 } 50 } 51 } 52 53 impl<Public, Private> core::fmt::Debug for Components<Public, Private> 54 where 55 Public: AsRef<[u8]> + core::fmt::Debug, 56 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error>57 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { 58 // Non-public components are intentionally skipped 59 f.debug_struct("Components") 60 .field("public_key", &self.public_key) 61 .finish() 62 } 63 } 64