]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/hashes.cc
methods/gpgv: Warn about SHA1 (and RIPEMD-160)
[apt.git] / apt-pkg / contrib / hashes.cc
index 4481321c4e0aad9ff83ae1ec59d0ec6bb07d0b0e..f2b91501e5a5aed23e2cab77ad666eec1485ea1b 100644 (file)
@@ -129,6 +129,15 @@ APT_PURE bool HashString::empty() const                                    /*{{{*/
    return (Type.empty() || Hash.empty());
 }
                                                                        /*}}}*/
+APT_PURE bool HashString::usable() const                               /*{{{*/
+{
+   return (
+      (Type != "Checksum-FileSize") &&
+      (Type != "MD5Sum") &&
+      (Type != "SHA1")
+   );
+}
+                                                                       /*}}}*/
 std::string HashString::toStr() const                                  /*{{{*/
 {
    return Type + ":" + Hash;
@@ -151,10 +160,10 @@ bool HashStringList::usable() const                                       /*{{{*/
    std::string const forcedType = _config->Find("Acquire::ForceHash", "");
    if (forcedType.empty() == true)
    {
-      // FileSize alone isn't usable
-      for (std::vector<HashString>::const_iterator hs = list.begin(); hs != list.end(); ++hs)
-        if (hs->HashType() != "Checksum-FileSize")
-           return true;
+      // See if there is at least one usable hash
+      for (auto const &hs: list)
+         if (hs.usable())
+            return true;
       return false;
    }
    return find(forcedType) != NULL;