Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/security/v2/naive_certificate_provider.hpp
T
Ashin Walpola 0e9525162d 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).
2026-09-23 17:46:40 +02:00

111 lines
2.8 KiB
C++

#ifndef NAIVE_CERTIFICATE_PROVIDER_HPP_MTULFLKX
#define NAIVE_CERTIFICATE_PROVIDER_HPP_MTULFLKX
#include <memory>
#include <string>
#include <vanetza/common/runtime.hpp>
#include <vanetza/security/backend.hpp>
#include <vanetza/security/v2/certificate.hpp>
#include <vanetza/security/v2/certificate_provider.hpp>
namespace vanetza
{
namespace security
{
namespace v2
{
/**
* \brief A very simplistic certificate provider
*
* This certificate provider signs its certificates with a randomly generated root certificate. This means the
* signatures produced based on this certificate provider can't be verified by other parties.
*
* It's intended for experimenting with secured messages without validating signatures.
*/
class NaiveCertificateProvider : public CertificateProvider
{
public:
NaiveCertificateProvider(const Runtime&);
/**
* \brief get own certificate for signing
* \return own certificate
*/
const Certificate& own_certificate() override;
/**
* Get own certificate chain, excluding the leaf certificate and root CA
* \return own certificate chain
*/
std::list<Certificate> own_chain() override;
/**
* \brief get own private key
* \return private key
*/
const ecdsa256::PrivateKey& own_private_key() override;
/**
* \brief get ticket signer certificate (same for all instances)
* \return signing authorization authority certificate
*/
const Certificate& aa_certificate();
/**
* \brief get root certificate (same for all instances)
* \return signing root certificate
*/
const Certificate& root_certificate();
/**
* \brief generate an authorization ticket
* \return generated certificate
*/
Certificate generate_authorization_ticket();
/**
* \brief sign an authorization ticket
* \param certificate certificate to sign
*/
void sign_authorization_ticket(Certificate& certificate);
private:
/**
* \brief get root key (same for all instances)
* \return root key
*/
const ecdsa256::KeyPair& aa_key_pair();
/**
* \brief get root key (same for all instances)
* \return root key
*/
const ecdsa256::KeyPair& root_key_pair();
/**
* \brief generate a authorization authority certificate
*
* \return generated certificate
*/
Certificate generate_aa_certificate(const std::string& subject_name);
/**
* \brief generate a root certificate
*
* \return generated certificate
*/
Certificate generate_root_certificate(const std::string& subject_name);
std::unique_ptr<Backend> m_crypto_backend;
const Runtime& m_runtime;
const ecdsa256::KeyPair m_own_key_pair;
Certificate m_own_certificate;
};
} // namespace v2
} // namespace security
} // namespace vanetza
#endif /* NAIVE_CERTIFICATE_PROVIDER_HPP_MTULFLKX */