@@ -86,8 +86,8 @@ pub trait ShaPrecomputedValues<T> {
8686 // these should be appropriately sized for the config
8787 fn get_invalid_carry_a ( round_num : usize ) -> & ' static [ u32 ] ;
8888 fn get_invalid_carry_e ( round_num : usize ) -> & ' static [ u32 ] ;
89- fn get_k ( ) -> & ' static [ T ] ;
90- fn get_h ( ) -> & ' static [ T ] ;
89+ fn get_k ( ) -> & ' static [ Self :: Word ] ;
90+ fn get_h ( ) -> & ' static [ Self :: Word ] ;
9191}
9292
9393#[ derive( Clone ) ]
@@ -110,6 +110,19 @@ impl ShaConfig for Sha256Config {
110110 const HASH_WORDS : usize = 8 ;
111111 /// Number of vars needed to encode the row index with [Encoder]
112112 const ROW_VAR_CNT : usize = 5 ;
113+
114+ fn get_invalid_carry_a ( round_num : usize ) -> & ' static [ u32 ] {
115+ & SHA256_INVALID_CARRY_A [ round_num]
116+ }
117+ fn get_invalid_carry_e ( round_num : usize ) -> & ' static [ u32 ] {
118+ & SHA256_INVALID_CARRY_E [ round_num]
119+ }
120+ fn get_k ( ) -> & ' static [ u32 ] {
121+ & SHA256_K
122+ }
123+ fn get_h ( ) -> & ' static [ u32 ] {
124+ & SHA256_H
125+ }
113126}
114127
115128pub const SHA256_INVALID_CARRY_A : [ [ u32 ; Sha256Config :: WORD_U16S ] ; Sha256Config :: ROUNDS_PER_ROW ] = [
@@ -141,21 +154,6 @@ pub const SHA256_H: [u32; 8] = [
141154 0x6a09e667 , 0xbb67ae85 , 0x3c6ef372 , 0xa54ff53a , 0x510e527f , 0x9b05688c , 0x1f83d9ab , 0x5be0cd19 ,
142155] ;
143156
144- impl ShaPrecomputedValues < u32 > for Sha256Config {
145- fn get_invalid_carry_a ( round_num : usize ) -> & ' static [ u32 ] {
146- & SHA256_INVALID_CARRY_A [ round_num]
147- }
148- fn get_invalid_carry_e ( round_num : usize ) -> & ' static [ u32 ] {
149- & SHA256_INVALID_CARRY_E [ round_num]
150- }
151- fn get_k ( ) -> & ' static [ u32 ] {
152- & SHA256_K
153- }
154- fn get_h ( ) -> & ' static [ u32 ] {
155- & SHA256_H
156- }
157- }
158-
159157#[ derive( Clone ) ]
160158pub struct Sha512Config ;
161159
@@ -176,6 +174,19 @@ impl ShaConfig for Sha512Config {
176174 const HASH_WORDS : usize = 8 ;
177175 /// Number of vars needed to encode the row index with [Encoder]
178176 const ROW_VAR_CNT : usize = 6 ;
177+
178+ fn get_invalid_carry_a ( round_num : usize ) -> & ' static [ u32 ] {
179+ & SHA512_INVALID_CARRY_A [ round_num]
180+ }
181+ fn get_invalid_carry_e ( round_num : usize ) -> & ' static [ u32 ] {
182+ & SHA512_INVALID_CARRY_E [ round_num]
183+ }
184+ fn get_k ( ) -> & ' static [ u64 ] {
185+ & SHA512_K
186+ }
187+ fn get_h ( ) -> & ' static [ u64 ] {
188+ & SHA512_H
189+ }
179190}
180191
181192pub ( crate ) const SHA512_INVALID_CARRY_A : [ [ u32 ; Sha512Config :: WORD_U16S ] ;
@@ -289,21 +300,6 @@ pub const SHA512_H: [u64; 8] = [
289300 0x5be0cd19137e2179 ,
290301] ;
291302
292- impl ShaPrecomputedValues < u64 > for Sha512Config {
293- fn get_invalid_carry_a ( round_num : usize ) -> & ' static [ u32 ] {
294- & SHA512_INVALID_CARRY_A [ round_num]
295- }
296- fn get_invalid_carry_e ( round_num : usize ) -> & ' static [ u32 ] {
297- & SHA512_INVALID_CARRY_E [ round_num]
298- }
299- fn get_k ( ) -> & ' static [ u64 ] {
300- & SHA512_K
301- }
302- fn get_h ( ) -> & ' static [ u64 ] {
303- & SHA512_H
304- }
305- }
306-
307303// Needed to avoid compile errors in utils.rs
308304// not sure why this doesn't inf loop
309305pub trait RotateRight {
0 commit comments