#include #include #include namespace vanetza { namespace security { namespace v3 { void TrustStore::insert(const Certificate& certificate) { if (!certificate.issuer_is_self()) { throw std::runtime_error("Only root certificate authorities may be added to the trust store"); } auto id = certificate.calculate_digest(); if (!id) { throw std::runtime_error("Cannot calculate hash for certificate"); } m_certificates.insert(std::make_pair(*id, certificate)); } std::list TrustStore::lookup(HashedId8 id) const { using iterator = std::multimap::const_iterator; std::pair range = m_certificates.equal_range(id); std::list matches; for (auto item = range.first; item != range.second; ++item) { matches.push_back(item->second); } return matches; } } // namespace v3 } // namespace security } // namespace vanetza