Vanetza
 
Loading...
Searching...
No Matches
certificate_cache.hpp
1#pragma once
2#include <vanetza/security/hashed_id.hpp>
3#include <vanetza/security/v3/certificate.hpp>
4#include <unordered_map>
5
6namespace vanetza
7{
8namespace security
9{
10namespace v3
11{
12
13/**
14 * CertificateCache stores validated v1.3.1 certificates for later lookup.
15 * Required for checking messages' signatures containing only a certificate digest.
16 */
18{
19public:
20 /**
21 * Lookup certificate based on given digest
22 * \param digest certificate digest
23 * \return certificate matching digest
24 */
25 const Certificate* lookup(const HashedId8& digest) const;
26
27 /**
28 * Store a (pre-validated) certificate in cache
29 * \param cert certificate
30 */
31 void store(const Certificate& cert);
32
33 size_t size() const { return m_storage.size(); }
34
35private:
36 // TODO add bounded capacity and automatic removal of expired certificates
37 std::unordered_map<HashedId8, Certificate> m_storage;
38};
39
40} // namespace v3
41} // namespace security
42} // namespace vanetza
const Certificate * lookup(const HashedId8 &digest) const
void store(const Certificate &cert)