From a5c985e230900b912bf77863af72eb609854be74 Mon Sep 17 00:00:00 2001 From: oech3 <> Date: Wed, 24 Dec 2025 00:33:54 +0900 Subject: [PATCH] hashsum: Drop flags for non GNU bins --- src/uu/hashsum/locales/en-US.ftl | 9 ------- src/uu/hashsum/locales/fr-FR.ftl | 9 ------- src/uu/hashsum/src/hashsum.rs | 43 +------------------------------- tests/by-util/test_hashsum.rs | 8 ------ 4 files changed, 1 insertion(+), 68 deletions(-) diff --git a/src/uu/hashsum/locales/en-US.ftl b/src/uu/hashsum/locales/en-US.ftl index 1c9e40f66e0..4536e320442 100644 --- a/src/uu/hashsum/locales/en-US.ftl +++ b/src/uu/hashsum/locales/en-US.ftl @@ -18,7 +18,6 @@ hashsum-help-ignore-missing = don't fail or report status for missing files hashsum-help-warn = warn about improperly formatted checksum lines hashsum-help-zero = end each output line with NUL, not newline hashsum-help-length = digest length in bits; must not exceed the max for the blake2 algorithm and must be a multiple of 8 -hashsum-help-bits = set the size of the output (only for SHAKE) # Algorithm help messages hashsum-help-md5 = work with MD5 @@ -27,15 +26,7 @@ hashsum-help-sha224 = work with SHA224 hashsum-help-sha256 = work with SHA256 hashsum-help-sha384 = work with SHA384 hashsum-help-sha512 = work with SHA512 -hashsum-help-sha3 = work with SHA3 -hashsum-help-sha3-224 = work with SHA3-224 -hashsum-help-sha3-256 = work with SHA3-256 -hashsum-help-sha3-384 = work with SHA3-384 -hashsum-help-sha3-512 = work with SHA3-512 -hashsum-help-shake128 = work with SHAKE128 using BITS for the output size -hashsum-help-shake256 = work with SHAKE256 using BITS for the output size hashsum-help-b2sum = work with BLAKE2 -hashsum-help-b3sum = work with BLAKE3 # Error messages hashsum-error-failed-to-read-input = failed to read input diff --git a/src/uu/hashsum/locales/fr-FR.ftl b/src/uu/hashsum/locales/fr-FR.ftl index 87065c6143a..dfb7addea5f 100644 --- a/src/uu/hashsum/locales/fr-FR.ftl +++ b/src/uu/hashsum/locales/fr-FR.ftl @@ -15,7 +15,6 @@ hashsum-help-ignore-missing = ne pas échouer ou rapporter le statut pour les fi hashsum-help-warn = avertir des lignes de somme de contrôle mal formatées hashsum-help-zero = terminer chaque ligne de sortie avec NUL, pas de retour à la ligne hashsum-help-length = longueur de l'empreinte en bits ; ne doit pas dépasser le maximum pour l'algorithme blake2 et doit être un multiple de 8 -hashsum-help-bits = définir la taille de la sortie (uniquement pour SHAKE) # Messages d'aide des algorithmes hashsum-help-md5 = travailler avec MD5 @@ -24,15 +23,7 @@ hashsum-help-sha224 = travailler avec SHA224 hashsum-help-sha256 = travailler avec SHA256 hashsum-help-sha384 = travailler avec SHA384 hashsum-help-sha512 = travailler avec SHA512 -hashsum-help-sha3 = travailler avec SHA3 -hashsum-help-sha3-224 = travailler avec SHA3-224 -hashsum-help-sha3-256 = travailler avec SHA3-256 -hashsum-help-sha3-384 = travailler avec SHA3-384 -hashsum-help-sha3-512 = travailler avec SHA3-512 -hashsum-help-shake128 = travailler avec SHAKE128 en utilisant BITS pour la taille de sortie -hashsum-help-shake256 = travailler avec SHAKE256 en utilisant BITS pour la taille de sortie hashsum-help-b2sum = travailler avec BLAKE2 -hashsum-help-b3sum = travailler avec BLAKE3 # Messages d'erreur hashsum-error-failed-to-read-input = échec de la lecture de l'entrée diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index 19e8ad9db04..4955a2da84e 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -18,10 +18,7 @@ use uucore::checksum::compute::{ use uucore::checksum::validate::{ ChecksumValidateOptions, ChecksumVerbose, perform_checksum_validation, }; -use uucore::checksum::{ - AlgoKind, ChecksumError, SizedAlgoKind, calculate_blake2b_length_str, - sanitize_sha2_sha3_length_str, -}; +use uucore::checksum::{AlgoKind, ChecksumError, SizedAlgoKind, calculate_blake2b_length_str}; use uucore::error::UResult; use uucore::line_ending::LineEnding; use uucore::{format_usage, translate}; @@ -72,36 +69,6 @@ fn create_algorithm_from_flags(matches: &ArgMatches) -> UResult<(AlgoKind, Optio if matches.get_flag("b2sum") { set_or_err((AlgoKind::Blake2b, None))?; } - if matches.get_flag("b3sum") { - set_or_err((AlgoKind::Blake3, None))?; - } - if matches.get_flag("sha3") { - match matches.get_one::(options::LENGTH) { - Some(len) => set_or_err(( - AlgoKind::Sha3, - Some(sanitize_sha2_sha3_length_str(AlgoKind::Sha3, len)?), - ))?, - None => return Err(ChecksumError::LengthRequired("SHA3".into()).into()), - } - } - if matches.get_flag("sha3-224") { - set_or_err((AlgoKind::Sha3, Some(224)))?; - } - if matches.get_flag("sha3-256") { - set_or_err((AlgoKind::Sha3, Some(256)))?; - } - if matches.get_flag("sha3-384") { - set_or_err((AlgoKind::Sha3, Some(384)))?; - } - if matches.get_flag("sha3-512") { - set_or_err((AlgoKind::Sha3, Some(512)))?; - } - if matches.get_flag("shake128") { - set_or_err((AlgoKind::Shake128, Some(128)))?; - } - if matches.get_flag("shake256") { - set_or_err((AlgoKind::Shake256, Some(256)))?; - } if alg.is_none() { return Err(ChecksumError::NeedAlgorithmToHash.into()); @@ -372,15 +339,7 @@ pub fn uu_app_custom() -> Command { ("sha256", translate!("hashsum-help-sha256")), ("sha384", translate!("hashsum-help-sha384")), ("sha512", translate!("hashsum-help-sha512")), - ("sha3", translate!("hashsum-help-sha3")), - ("sha3-224", translate!("hashsum-help-sha3-224")), - ("sha3-256", translate!("hashsum-help-sha3-256")), - ("sha3-384", translate!("hashsum-help-sha3-384")), - ("sha3-512", translate!("hashsum-help-sha3-512")), - ("shake128", translate!("hashsum-help-shake128")), - ("shake256", translate!("hashsum-help-shake256")), ("b2sum", translate!("hashsum-help-b2sum")), - ("b3sum", translate!("hashsum-help-b3sum")), ]; for (name, desc) in algorithms { diff --git a/tests/by-util/test_hashsum.rs b/tests/by-util/test_hashsum.rs index 2f1719b0eca..d4f4d4b5390 100644 --- a/tests/by-util/test_hashsum.rs +++ b/tests/by-util/test_hashsum.rs @@ -203,18 +203,10 @@ macro_rules! test_digest_with_len { test_digest! {md5, md5} test_digest! {sha1, sha1} -test_digest! {b3sum, b3sum} -test_digest! {shake128, shake128} -test_digest! {shake256, shake256} - test_digest_with_len! {sha224, sha224, 224} test_digest_with_len! {sha256, sha256, 256} test_digest_with_len! {sha384, sha384, 384} test_digest_with_len! {sha512, sha512, 512} -test_digest_with_len! {sha3_224, sha3, 224} -test_digest_with_len! {sha3_256, sha3, 256} -test_digest_with_len! {sha3_384, sha3, 384} -test_digest_with_len! {sha3_512, sha3, 512} test_digest_with_len! {b2sum, b2sum, 512} #[test]