This repository was archived by the owner on Nov 30, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +31
-0
lines changed
Expand file tree Collapse file tree 8 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ impl HashTrait for Hash {
6767 fn into_inner ( self ) -> Self :: Inner {
6868 self . 0
6969 }
70+
71+ fn from_inner ( inner : Self :: Inner ) -> Self {
72+ Hash ( inner)
73+ }
7074}
7175
7276#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -175,6 +175,10 @@ impl<T: Hash> Hash for Hmac<T> {
175175 fn into_inner ( self ) -> Self :: Inner {
176176 self . 0 . into_inner ( )
177177 }
178+
179+ fn from_inner ( inner : T :: Inner ) -> Self {
180+ Hmac ( T :: from_inner ( inner) )
181+ }
178182}
179183
180184#[ cfg( feature="serde" ) ]
Original file line number Diff line number Diff line change @@ -119,4 +119,7 @@ pub trait Hash: Copy + Clone + PartialEq + Eq + Default + PartialOrd + Ord +
119119
120120 /// Unwraps the hash and returns the underlying byte array
121121 fn into_inner ( self ) -> Self :: Inner ;
122+
123+ /// Constructs a hash from the underlying byte array
124+ fn from_inner ( inner : Self :: Inner ) -> Self ;
122125}
Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ impl HashTrait for Hash {
134134 fn into_inner ( self ) -> Self :: Inner {
135135 self . 0
136136 }
137+
138+ fn from_inner ( inner : Self :: Inner ) -> Self {
139+ Hash ( inner)
140+ }
137141}
138142
139143macro_rules! round(
Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ impl HashTrait for Hash {
113113 fn into_inner ( self ) -> Self :: Inner {
114114 self . 0
115115 }
116+
117+ fn from_inner ( inner : Self :: Inner ) -> Self {
118+ Hash ( inner)
119+ }
116120}
117121
118122impl HashEngine {
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ impl HashTrait for Hash {
127127 fn into_inner ( self ) -> Self :: Inner {
128128 self . 0
129129 }
130+
131+ fn from_inner ( inner : Self :: Inner ) -> Self {
132+ Hash ( inner)
133+ }
130134}
131135
132136macro_rules! Ch ( ( $x: expr, $y: expr, $z: expr) => ( $z ^ ( $x & ( $y ^ $z) ) ) ) ;
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ impl HashTrait for Hash {
6363 fn into_inner ( self ) -> Self :: Inner {
6464 self . 0
6565 }
66+
67+ fn from_inner ( inner : Self :: Inner ) -> Self {
68+ Hash ( inner)
69+ }
6670}
6771
6872#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -184,6 +184,10 @@ impl HashTrait for Hash {
184184 fn into_inner ( self ) -> Self :: Inner {
185185 self . 0
186186 }
187+
188+ fn from_inner ( inner : Self :: Inner ) -> Self {
189+ Hash ( inner)
190+ }
187191}
188192
189193macro_rules! Ch ( ( $x: expr, $y: expr, $z: expr) => ( $z ^ ( $x & ( $y ^ $z) ) ) ) ;
You can’t perform that action at this time.
0 commit comments