pub fn is_hash_algorithm_downgrade(
old_hashes: &BTreeMap<String, String>,
new_hashes: &BTreeMap<String, String>,
) -> boolExpand description
detects whether the hash algorithms in a component were downgraded.
compares the strongest known algorithm in old_hashes against the
strongest known algorithm in new_hashes. Returns true if the new
set’s strongest algorithm is weaker than the old set’s strongest.
returns false when:
- Either hash set is empty (use
missing-hashesfor that) - Neither set contains a recognized algorithm
- The new set is at least as strong as the old set
§Example
use sbom_model::is_hash_algorithm_downgrade;
use std::collections::BTreeMap;
let old: BTreeMap<String, String> = [("sha-256".into(), "abc".into())].into();
let new: BTreeMap<String, String> = [("md5".into(), "def".into())].into();
assert!(is_hash_algorithm_downgrade(&old, &new));
let new_strong: BTreeMap<String, String> = [("sha-512".into(), "ghi".into())].into();
assert!(!is_hash_algorithm_downgrade(&old, &new_strong));