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.
93 lines
2.9 KiB
C++
93 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "hashed_id8.hpp"
|
|
#include "keys.hpp"
|
|
#include <vanetza/asn1/asn1c_wrapper.hpp>
|
|
#include <vanetza/asn1/security/Certificate.h>
|
|
#include <vanetza/asn1/security/EtsiTs103097Certificate.h>
|
|
#include <vanetza/common/clock.hpp>
|
|
|
|
// asn1c quirk: complete the struct tags it forward-declares but never defines.
|
|
struct Vanetza_Security_Certificate : Vanetza_Security_CertificateBase
|
|
{
|
|
};
|
|
|
|
struct Vanetza_Security_EtsiTs103097Certificate : Vanetza_Security_ExplicitCertificate_t
|
|
{
|
|
};
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace pki
|
|
{
|
|
|
|
class SecurityModule;
|
|
|
|
class Certificate
|
|
{
|
|
public:
|
|
Certificate();
|
|
explicit Certificate(const Vanetza_Security_EtsiTs103097Certificate_t&);
|
|
|
|
HashedId8 calculate_hashed_id8(SecurityModule&) const;
|
|
bool is_canonical() const;
|
|
std::string get_name() const;
|
|
PublicKey get_public_key() const;
|
|
Clock::time_point valid_since() const;
|
|
Clock::time_point valid_until() const;
|
|
boost::optional<PublicKey> get_encryption_key() const;
|
|
|
|
bool decode(const char* data, std::size_t length);
|
|
bool decode(const std::string&);
|
|
bool decode(const ByteBuffer&);
|
|
ByteBuffer encode() const;
|
|
|
|
const Vanetza_Security_EtsiTs103097Certificate_t& raw() const
|
|
{
|
|
return *m_asn1;
|
|
}
|
|
|
|
void print() const;
|
|
|
|
private:
|
|
vanetza::asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs103097Certificate_t> m_asn1;
|
|
};
|
|
|
|
bool is_currently_valid(const Certificate&, Clock::time_point);
|
|
|
|
/**
|
|
* Check if certificate is a compliant Root CA certificate.
|
|
* Rules are given by section 7.3.2 in TS 103 097 V1.3.1
|
|
*
|
|
* \param cert
|
|
* \return true if certificate complies
|
|
*/
|
|
bool is_root_ca(const Certificate&);
|
|
|
|
// PKI role inferred from issuer, permissions and CertificateId per TS 103 097 V2.1.1 §7.2.
|
|
enum class CertificateRole
|
|
{
|
|
RootCa, // §7.2.3: self-issued CA
|
|
EnrolmentAuthority, // §7.2.4: sub-CA whose issuing scope grants SCR
|
|
AuthorizationAuthority, // §7.2.4: sub-CA whose issuing scope grants services
|
|
EnrolmentCredential, // §7.2.2: end entity with CertificateId name
|
|
AuthorizationTicket, // §7.2.1: end entity with CertificateId none
|
|
Tlm, // §7.2.5: self-issued, signs CTL, no certIssuePermissions
|
|
Unknown, // matches no profile above
|
|
};
|
|
|
|
// Classify the certificate's PKI role. Never throws.
|
|
CertificateRole certificate_role(const Certificate&);
|
|
|
|
Sha256Hash calculate_sha256_hash(SecurityModule&, const Certificate&);
|
|
Sha384Hash calculate_sha384_hash(SecurityModule&, const Certificate&);
|
|
Sha256Hash calculate_sha256_hash(SecurityModule&, const Vanetza_Security_Certificate_t&);
|
|
Sha384Hash calculate_sha384_hash(SecurityModule&, const Vanetza_Security_Certificate_t&);
|
|
HashedId8 calculate_hashed_id8(SecurityModule&, const Vanetza_Security_Certificate_t&);
|
|
PublicKey get_public_key(const Vanetza_Security_Certificate_t&);
|
|
std::string get_name(const Vanetza_Security_Certificate_t&);
|
|
bool is_canonical(const Vanetza_Security_Certificate_t&);
|
|
|
|
} // namespace pki
|
|
} // namespace vanetza
|