Vanetza
 
Loading...
Searching...
No Matches
trust_store.cpp
1#include <vanetza/security/v2/trust_store.hpp>
2#include <stdexcept>
3
4namespace vanetza
5{
6namespace security
7{
8namespace v2
9{
10
11void TrustStore::insert(const Certificate& certificate)
12{
13 if (certificate.subject_info.subject_type != SubjectType::Root_CA) {
14 throw std::runtime_error("Only root certificate authorities may be added to the trust store");
15 }
16
17 HashedId8 id = calculate_hash(certificate);
18 m_certificates.insert(std::make_pair(id, certificate));
19}
20
21std::list<Certificate> TrustStore::lookup(HashedId8 id) const
22{
23 using iterator = std::multimap<HashedId8, Certificate>::const_iterator;
24 std::pair<iterator, iterator> range = m_certificates.equal_range(id);
25
26 std::list<Certificate> matches;
27 for (auto item = range.first; item != range.second; ++item) {
28 matches.push_back(item->second);
29 }
30 return matches;
31}
32
33} // namespace v2
34} // namespace security
35} // namespace vanetza
std::list< Certificate > lookup(HashedId8 id) const
Definition: trust_store.cpp:21
void insert(const Certificate &trusted_certificate)
Definition: trust_store.cpp:11
described in TS 103 097 v1.2.1 (2015-06), section 6.1
Definition: certificate.hpp:28