#include #include namespace vanetza { namespace security { namespace v2 { void TrustStore::insert(const Certificate& certificate) { if (certificate.subject_info.subject_type != SubjectType::Root_CA) { throw std::runtime_error("Only root certificate authorities may be added to the trust store"); } HashedId8 id = calculate_hash(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 v2 } // namespace security } // namespace vanetza