#define GNUPGREVKEYSIG "[GNUPG:] REVKEYSIG"
#define GNUPGNODATA "[GNUPG:] NODATA"
-static const std::array<string, 1> WeakDigests {
- "1", // MD5
-// "2", // SHA1
-// "3", // RIPEMD-160
+struct Digest {
+ enum class State {
+ Untrusted,
+ Weak,
+ Trusted,
+ } state;
+ char name[32];
+};
+
+static constexpr Digest Digests[] = {
+ {Digest::State::Untrusted, "Invalid digest"},
+ {Digest::State::Untrusted, "MD5"},
+ {Digest::State::Weak, "SHA1"},
+ {Digest::State::Weak, "RIPE-MD/160"},
+ {Digest::State::Trusted, "Reserved digest"},
+ {Digest::State::Trusted, "Reserved digest"},
+ {Digest::State::Trusted, "Reserved digest"},
+ {Digest::State::Trusted, "Reserved digest"},
+ {Digest::State::Trusted, "SHA256"},
+ {Digest::State::Trusted, "SHA384"},
+ {Digest::State::Trusted, "SHA512"},
+ {Digest::State::Trusted, "SHA224"},
+};
+
+static Digest FindDigest(std::string const & Digest)
+{
+ int id = atoi(Digest.c_str());
+ if (id >= 0 && static_cast<unsigned>(id) < _count(Digests)) {
+ return Digests[id];
+ } else {
+ return Digests[0];
+ }
+}
+
+struct Signer {
+ std::string key;
+ std::string note;
};
class GPGVMethod : public aptMethod
vector<string> &GoodSigners,
vector<string> &BadSigners,
vector<string> &WorthlessSigners,
+ vector<Signer> &SoonWorthlessSigners,
vector<string> &NoPubKeySigners);
-
protected:
virtual bool URIAcquire(std::string const &Message, FetchItem *Itm) APT_OVERRIDE;
public:
vector<string> &GoodSigners,
vector<string> &BadSigners,
vector<string> &WorthlessSigners,
+ vector<Signer> &SoonWorthlessSigners,
vector<string> &NoPubKeySigners)
{
bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
if (Debug == true)
std::clog << "Got VALIDSIG, key ID: " << sig << std::endl;
// Reject weak digest algorithms
- if (std::find(WeakDigests.begin(), WeakDigests.end(), tokens[7]) != WeakDigests.end())
- BadSigners.push_back(string(sig));
+ Digest digest = FindDigest(tokens[7]);
+ switch (digest.state) {
+ case Digest::State::Weak:
+ // Treat them like an expired key: For that a message about expiry
+ // is emitted, a VALIDSIG, but no GOODSIG.
+ SoonWorthlessSigners.push_back({string(sig), digest.name});
+ break;
+ case Digest::State::Untrusted:
+ // Treat them like an expired key: For that a message about expiry
+ // is emitted, a VALIDSIG, but no GOODSIG.
+ WorthlessSigners.push_back(string(sig));
+ GoodSigners.erase(std::remove(GoodSigners.begin(), GoodSigners.end(), string(sig)));
+ break;
+ case Digest::State::Trusted:
+ break;
+ }
ValidSigners.push_back(string(sig));
}
vector<string> BadSigners;
// a worthless signature is a expired or revoked one
vector<string> WorthlessSigners;
+ vector<Signer> SoonWorthlessSigners;
vector<string> NoPubKeySigners;
FetchResult Res;
// Run apt-key on file, extract contents and get the key ID of the signer
string msg = VerifyGetSigners(Path.c_str(), Itm->DestFile.c_str(), key,
GoodSigners, BadSigners, WorthlessSigners,
- NoPubKeySigners);
+ SoonWorthlessSigners, NoPubKeySigners);
+
+
+ // Check if there are any good signers that are not soon worthless
+ std::vector<std::string> NotWarnAboutSigners(GoodSigners);
+ for (auto const & Signer : SoonWorthlessSigners)
+ NotWarnAboutSigners.erase(std::remove(NotWarnAboutSigners.begin(), NotWarnAboutSigners.end(), "GOODSIG " + Signer.key));
+ // If all signers are soon worthless, report them.
+ if (NotWarnAboutSigners.empty()) {
+ for (auto const & Signer : SoonWorthlessSigners)
+ // TRANSLATORS: The second %s is the reason and is untranslated for repository owners.
+ Warning(_("Weak signature from %s (%s)"), Signer.key.c_str(), Signer.note.c_str());
+ }
+
if (GoodSigners.empty() || !BadSigners.empty() || !NoPubKeySigners.empty())
{
string errmsg;