File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -203,10 +203,22 @@ impl Hash {
203
203
"shake128" => return Ok ( Shake128 ( Default :: default ( ) , output_length) ) ,
204
204
"shake256" => return Ok ( Shake256 ( Default :: default ( ) , output_length) ) ,
205
205
"sha256" => {
206
- return Ok ( Hash :: FixedSize ( Box :: new ( ring_sha2:: RingSha256 :: new ( ) ) ) )
206
+ let digest = ring_sha2:: RingSha256 :: new ( ) ;
207
+ if let Some ( length) = output_length {
208
+ if length != digest. output_size ( ) {
209
+ return Err ( HashError :: OutputLengthMismatch ) ;
210
+ }
211
+ }
212
+ return Ok ( Hash :: FixedSize ( Box :: new ( digest) ) ) ;
207
213
}
208
214
"sha512" => {
209
- return Ok ( Hash :: FixedSize ( Box :: new ( ring_sha2:: RingSha512 :: new ( ) ) ) )
215
+ let digest = ring_sha2:: RingSha512 :: new ( ) ;
216
+ if let Some ( length) = output_length {
217
+ if length != digest. output_size ( ) {
218
+ return Err ( HashError :: OutputLengthMismatch ) ;
219
+ }
220
+ }
221
+ return Ok ( Hash :: FixedSize ( Box :: new ( digest) ) ) ;
210
222
}
211
223
_ => { }
212
224
}
You can’t perform that action at this time.
0 commit comments