Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#include "crl_store.hpp"
|
||||
#include "certificate_revocation_list.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "hexstring.hpp"
|
||||
#include "security_module.hpp"
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
namespace pki
|
||||
{
|
||||
|
||||
CrlFilesystemStore::CrlFilesystemStore(std::shared_ptr<SecurityModule> security, const std::filesystem::path& root) :
|
||||
m_security(security), m_root(root)
|
||||
{
|
||||
std::filesystem::create_directories(m_root);
|
||||
for (const auto& entry : std::filesystem::directory_iterator(m_root)) {
|
||||
if (!entry.is_regular_file() || entry.path().extension() != ".crl") {
|
||||
continue;
|
||||
}
|
||||
ByteBuffer buf = read(entry.path());
|
||||
CertificateRevocationList crl;
|
||||
if (crl.decode(buf)) {
|
||||
index(crl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CrlFilesystemStore::store(const CertificateRevocationList& crl)
|
||||
{
|
||||
auto issuer = index(crl);
|
||||
if (!issuer) {
|
||||
return false;
|
||||
}
|
||||
write(filename(*issuer), crl.encode());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CrlFilesystemStore::is_revoked(const security::HashedId8& issuer, const security::HashedId8& cert) const
|
||||
{
|
||||
auto it = m_revoked.find(issuer);
|
||||
if (it == m_revoked.end()) {
|
||||
return false;
|
||||
}
|
||||
return it->second.count(cert) != 0;
|
||||
}
|
||||
|
||||
std::filesystem::path CrlFilesystemStore::filename(const HashedId8& id) const
|
||||
{
|
||||
return m_root / (hexstring(id.octets) + ".crl");
|
||||
}
|
||||
|
||||
boost::optional<HashedId8> CrlFilesystemStore::index(const CertificateRevocationList& crl)
|
||||
{
|
||||
auto issuer = crl.get_hashed_id8(*m_security);
|
||||
if (!issuer) {
|
||||
return boost::none;
|
||||
}
|
||||
auto entries = crl.revoked_entries();
|
||||
if (!entries) {
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
// Empty CRL is valid: it withdraws any prior revocations from this issuer.
|
||||
// Erase the existing bucket and only create a new one if there's content.
|
||||
m_revoked.erase(issuer->octets);
|
||||
if (!entries->empty()) {
|
||||
auto& bucket = m_revoked[issuer->octets];
|
||||
for (const auto& cert : *entries) {
|
||||
bucket.insert(cert.octets);
|
||||
}
|
||||
}
|
||||
return issuer;
|
||||
}
|
||||
|
||||
} // namespace pki
|
||||
} // namespace vanetza
|
||||
Reference in New Issue
Block a user