File tree 2 files changed +13
-6
lines changed
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ fake-simd = "0.1"
16
16
opaque-debug = " 0.2"
17
17
sha2-asm = { version =" 0.5" , optional =true }
18
18
19
+ [dependencies .lazy_static ]
20
+ version = " 1.4.0"
21
+ default-features = false
22
+ # no_std feature is an anti-pattern. Why, lazy_static, why?
23
+ # See https://github.com/rust-lang-nursery/lazy-static.rs/issues/150
24
+ features = [" spin_no_std" ]
25
+
19
26
[dev-dependencies ]
20
27
digest = { version = " 0.8" , features = [" dev" ] }
21
28
hex-literal = " 0.1"
Original file line number Diff line number Diff line change @@ -10,25 +10,25 @@ use platform::Implementation;
10
10
type BlockSize = U64 ;
11
11
type Block = GenericArray < u8 , BlockSize > ;
12
12
13
+ lazy_static:: lazy_static! {
14
+ static ref IMPL : Implementation = Implementation :: detect( ) ;
15
+ }
16
+
13
17
/// A structure that represents that state of a digest computation for the
14
18
/// SHA-2 512 family of digest functions
15
19
#[ derive( Clone ) ]
16
20
struct Engine256State {
17
21
h : [ u32 ; 8 ] ,
18
- implementation : Implementation ,
19
22
}
20
23
21
24
impl Engine256State {
22
25
fn new ( h : & [ u32 ; STATE_LEN ] ) -> Engine256State {
23
- Engine256State {
24
- h : * h,
25
- implementation : Implementation :: detect ( ) ,
26
- }
26
+ Engine256State { h : * h }
27
27
}
28
28
29
29
pub fn process_block ( & mut self , block : & Block ) {
30
30
let block = unsafe { & * ( block. as_ptr ( ) as * const [ u8 ; 64 ] ) } ;
31
- self . implementation . compress256 ( & mut self . h , block) ;
31
+ IMPL . compress256 ( & mut self . h , block) ;
32
32
}
33
33
}
34
34
You can’t perform that action at this time.
0 commit comments