Files
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now
came from the colleague's microbu-esp32c5 tree beside the repository and was
not tracked here, so a clone of this repository could not build the firmware
it ships. The library alone is now part of obu-firmware, as
obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit
cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from
there by default; -DVANETZA_IDF_DIR still points the build elsewhere.

The rest of the colleague's tree (their own VAM firmware, PKI tooling,
station-link Python tools, the V2X2MAP bridge) stays out of this repository
and gitignored; nothing is pushed to their repository. NOTES.md, docs/06,
TODO.md and the pcap verifier's usage line point at the new location.
2026-09-24 10:56:05 +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 */