diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 3c3fdd2f9..5678a58b3 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -66,16 +66,14 @@ fn detect_algo( "sha384sum" => ("SHA384", Box::new(Sha384::new()) as Box, 384), "sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box, 512), "b2sum" => match matches.get_one::("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, 512), Some(length_in_bits) => { if *length_in_bits > 512 { 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, 512); - } - // blake2 output size must be a multiple of 8 bits if length_in_bits % 8 == 0 { let length_in_bytes = length_in_bits / 8; @@ -88,8 +86,6 @@ fn detect_algo( 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, 512), }, "b3sum" => ("BLAKE3", Box::new(Blake3::new()) as Box, 256), "sha3sum" => match matches.get_one::("bits") {