@@ -9,8 +9,8 @@ use core::ops::RangeInclusive;
99
1010/// The modulus (n) of an RSA public key.
1111#[ derive( Clone ) ]
12- pub struct PublicModulus {
13- value : bigint :: BoxedIntoMont < N , RR > ,
12+ pub struct PublicModulus < S > {
13+ value : S ,
1414}
1515
1616/*
@@ -68,27 +68,48 @@ impl<'a> ValidatedInput<'a> {
6868 self . input . len_bits ( )
6969 }
7070
71- pub ( super ) fn build ( & self , cpu_features : cpu:: Features ) -> PublicModulus {
71+ pub ( super ) fn build_boxed_into_mont (
72+ & self ,
73+ cpu_features : cpu:: Features ,
74+ ) -> PublicModulus < bigint:: BoxedIntoMont < N , RR > > {
7275 PublicModulus {
7376 value : self . input . build_boxed_into_mont ( cpu_features) ,
7477 }
7578 }
79+
80+ pub ( super ) fn build < ' o > (
81+ & self ,
82+ out : & ' o mut bigint:: OversizedUninit < 2 > ,
83+ cpu_features : cpu:: Features ,
84+ ) -> PublicModulus < bigint:: IntoMont < ' o , N , RR > > {
85+ PublicModulus {
86+ value : self . input . build_into_mont ( out, cpu_features) ,
87+ }
88+ }
89+ }
90+
91+ impl PublicModulus < bigint:: BoxedIntoMont < N , RR > > {
92+ pub fn reborrow ( & self ) -> PublicModulus < bigint:: IntoMont < ' _ , N , RR > > {
93+ PublicModulus {
94+ value : self . value . reborrow ( ) ,
95+ }
96+ }
7697}
7798
78- impl PublicModulus {
99+ impl PublicModulus < bigint :: IntoMont < ' _ , N , RR > > {
79100 /// The big-endian encoding of the modulus.
80101 ///
81102 /// There are no leading zeros.
82103 pub fn be_bytes ( & self ) -> impl ExactSizeIterator < Item = u8 > + Clone + ' _ {
83- self . value . reborrow ( ) . be_bytes ( )
104+ self . value . be_bytes ( )
84105 }
85106
86107 /// The length of the modulus in bits.
87108 pub fn len_bits ( & self ) -> bits:: BitLength {
88- self . value . reborrow ( ) . len_bits ( )
109+ self . value . len_bits ( )
89110 }
90111
91- pub ( in super :: super ) fn value ( & self ) -> bigint:: IntoMont < ' _ , N , RR > {
92- self . value . reborrow ( )
112+ pub ( in super :: super ) fn value ( & self ) -> & bigint:: IntoMont < ' _ , N , RR > {
113+ & self . value
93114 }
94115}
0 commit comments