Vanetza
Loading...
Searching...
No Matches
certificate_cache.cpp
1
#include <vanetza/security/v3/certificate_cache.hpp>
2
#include <boost/optional/optional.hpp>
3
4
namespace
vanetza
5
{
6
namespace
security
7
{
8
namespace
v3
9
{
10
11
const
Certificate
*
CertificateCache::lookup
(
const
HashedId8& digest)
const
12
{
13
auto
found = m_storage.find(digest);
14
if
(found != m_storage.end()) {
15
return
&found->second;
16
}
else
{
17
return
nullptr
;
18
}
19
}
20
21
const
Certificate
*
CertificateCache::lookup
(
const
HashedId3& digest)
const
22
{
23
auto
found = m_short_digests.find(digest);
24
if
(found != m_short_digests.end()) {
25
return
&found->second->second;
26
}
else
{
27
return
nullptr
;
28
}
29
}
30
31
void
CertificateCache::store
(
Certificate
cert)
32
{
33
auto
maybe_hash = cert.
calculate_digest
();
34
if
(maybe_hash) {
35
CertificateMap::iterator it;
36
bool
inserted;
37
std::tie(it, inserted) = m_storage.emplace(*maybe_hash, std::move(cert));
38
if
(inserted) {
39
m_short_digests.emplace(truncate(*maybe_hash), it);
40
m_digests.insert(*maybe_hash);
41
}
42
}
43
}
44
45
bool
CertificateCache::announce
(
const
HashedId8& digest)
46
{
47
bool
inserted =
false
;
48
std::tie(std::ignore, inserted) = m_digests.insert(digest);
49
return
inserted;
50
}
51
52
bool
CertificateCache::is_known
(
const
HashedId8& digest)
const
53
{
54
return
m_digests.find(digest) != m_digests.end();
55
}
56
57
}
// namespace v3
58
}
// namespace security
59
}
// namespace vanetza
vanetza::security::v3::CertificateCache::is_known
bool is_known(const HashedId8 &digest) const
Definition
certificate_cache.cpp:52
vanetza::security::v3::CertificateCache::announce
bool announce(const HashedId8 &digest)
Definition
certificate_cache.cpp:45
vanetza::security::v3::CertificateCache::lookup
const Certificate * lookup(const HashedId8 &digest) const
Definition
certificate_cache.cpp:11
vanetza::security::v3::CertificateCache::store
void store(Certificate cert)
Definition
certificate_cache.cpp:31
vanetza::security::v3::CertificateView::calculate_digest
boost::optional< HashedId8 > calculate_digest() const
Definition
certificate.cpp:83
vanetza::security::v3::Certificate
Definition
certificate.hpp:134
vanetza
security
v3
certificate_cache.cpp
Generated on
for Vanetza by
1.14.0