mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
b2sum: moved 0 case into None arm
This commit is contained in:
parent
c4d637125c
commit
fdbebfad9d
1 changed files with 3 additions and 7 deletions
|
@ -66,16 +66,14 @@ fn detect_algo(
|
||||||
"sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<dyn Digest>, 384),
|
"sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box<dyn Digest>, 384),
|
||||||
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<dyn Digest>, 512),
|
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<dyn Digest>, 512),
|
||||||
"b2sum" => match matches.get_one::<usize>("length") {
|
"b2sum" => match matches.get_one::<usize>("length") {
|
||||||
|
// by default, blake2 uses 64 bytes (512 bits)
|
||||||
|
// --length=0 falls back to default behavior
|
||||||
|
Some(0) | None => ("BLAKE2", Box::new(Blake2b::new()) as Box<dyn Digest>, 512),
|
||||||
Some(length_in_bits) => {
|
Some(length_in_bits) => {
|
||||||
if *length_in_bits > 512 {
|
if *length_in_bits > 512 {
|
||||||
crash!(1, "Invalid length (maximum digest length is 512 bits)")
|
crash!(1, "Invalid length (maximum digest length is 512 bits)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// --length=0 falls back to default behavior
|
|
||||||
if *length_in_bits == 0 {
|
|
||||||
return ("BLAKE2", Box::new(Blake2b::new()) as Box<dyn Digest>, 512);
|
|
||||||
}
|
|
||||||
|
|
||||||
// blake2 output size must be a multiple of 8 bits
|
// blake2 output size must be a multiple of 8 bits
|
||||||
if length_in_bits % 8 == 0 {
|
if length_in_bits % 8 == 0 {
|
||||||
let length_in_bytes = length_in_bits / 8;
|
let length_in_bytes = length_in_bits / 8;
|
||||||
|
@ -88,8 +86,6 @@ fn detect_algo(
|
||||||
crash!(1, "Invalid length (expected a multiple of 8)")
|
crash!(1, "Invalid length (expected a multiple of 8)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// by default, blake2 uses 64 bytes (512 bits)
|
|
||||||
None => ("BLAKE2", Box::new(Blake2b::new()) as Box<dyn Digest>, 512),
|
|
||||||
},
|
},
|
||||||
"b3sum" => ("BLAKE3", Box::new(Blake3::new()) as Box<dyn Digest>, 256),
|
"b3sum" => ("BLAKE3", Box::new(Blake3::new()) as Box<dyn Digest>, 256),
|
||||||
"sha3sum" => match matches.get_one::<usize>("bits") {
|
"sha3sum" => match matches.get_one::<usize>("bits") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue