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.
This commit is contained in:
Ashin Walpola
2026-09-24 10:56:05 +02:00
parent 2f60623e18
commit d107534eb2
9781 changed files with 1560475 additions and 17 deletions
+187
View File
@@ -0,0 +1,187 @@
#pragma once
#include "keys.hpp"
#include "sha.hpp"
#include <vanetza/asn1/asn1c_wrapper.hpp>
#include <vanetza/asn1/security/EtsiTs102941Data.h>
#include <vanetza/common/byte_buffer.hpp>
#include <cstring>
// forward declaration
typedef struct OCTET_STRING OCTET_STRING_t;
namespace vanetza
{
namespace pki
{
ByteBuffer copy(const OCTET_STRING_t&);
const OCTET_STRING_t* get_signed_payload(const Vanetza_Security_Ieee1609Dot2Content_t*);
class MgmtData : public asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs102941Data_t>
{
public:
using wrapper = asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs102941Data_t>;
MgmtData() : asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs102941Data_t>(asn_DEF_Vanetza_Security_EtsiTs102941Data)
{
}
using wrapper::decode;
bool decode(const Vanetza_Security_Opaque_t&);
protected:
/**
* Decode and assert the content variant matches `expected`.
*
* \throws DecodingFailure on decode failure or unexpected content variant
*/
static MgmtData decode_expecting(const void* buffer, std::size_t size,
Vanetza_Security_EtsiTs102941DataContent_PR expected);
static MgmtData decode_expecting(const Vanetza_Security_Opaque_t&,
Vanetza_Security_EtsiTs102941DataContent_PR expected);
};
// Management data known to carry a TLM certificate trust list.
class TlmCtlData : public MgmtData
{
public:
TlmCtlData() = default;
static TlmCtlData from_buffer(const void* buffer, std::size_t size);
static TlmCtlData from_opaque(const Vanetza_Security_Opaque_t&);
private:
explicit TlmCtlData(MgmtData&& base) : MgmtData(std::move(base))
{
}
};
// Management data known to carry an RCA certificate trust list.
class RcaCtlData : public MgmtData
{
public:
RcaCtlData() = default;
static RcaCtlData from_buffer(const void* buffer, std::size_t size);
static RcaCtlData from_opaque(const Vanetza_Security_Opaque_t&);
private:
explicit RcaCtlData(MgmtData&& base) : MgmtData(std::move(base))
{
}
};
// Management data known to carry an enrolment response.
class EnrolmentResponseData : public MgmtData
{
public:
EnrolmentResponseData() = default;
static EnrolmentResponseData from_buffer(const void* buffer, std::size_t size);
static EnrolmentResponseData from_opaque(const Vanetza_Security_Opaque_t&);
private:
explicit EnrolmentResponseData(MgmtData&& base) : MgmtData(std::move(base))
{
}
};
// Management data known to carry an authorization response.
class AuthorizationResponseData : public MgmtData
{
public:
AuthorizationResponseData() = default;
static AuthorizationResponseData from_buffer(const void* buffer, std::size_t size);
static AuthorizationResponseData from_opaque(const Vanetza_Security_Opaque_t&);
private:
explicit AuthorizationResponseData(MgmtData&& base) : MgmtData(std::move(base))
{
}
};
void fill_curve_point(const PublicKey&, Vanetza_Security_EccP256CurvePoint_t&);
void fill_curve_point(const PublicKey&, Vanetza_Security_EccP384CurvePoint_t&);
void copy(const OCTET_STRING_t& src, ByteBuffer& dst);
void copy(const ByteBuffer& src, OCTET_STRING_t& dst);
void copy_left_padded(const ByteBuffer& src, OCTET_STRING_t& dst, std::size_t len);
Vanetza_Security_HashAlgorithm_t convert(HashAlgorithm);
ByteBuffer to_buffer(const OCTET_STRING_t&);
std::string to_string(const OCTET_STRING_t&);
/**
* \brief strong-typed wrapper around asn1c-generated enum
*
* \tparam Tag generated C enum
* \tparam T underlying type
*/
template<typename Tag, typename T = long> struct asn1c_enum
{
T value;
constexpr explicit asn1c_enum(T v = T {}) : value(v)
{
}
};
template<typename Tag, typename T> constexpr bool operator==(asn1c_enum<Tag, T> l, asn1c_enum<Tag, T> r)
{
return l.value == r.value;
}
template<typename Tag, typename T> constexpr bool operator!=(asn1c_enum<Tag, T> l, asn1c_enum<Tag, T> r)
{
return l.value != r.value;
}
template<typename Tag, typename T> constexpr bool operator==(asn1c_enum<Tag, T> l, Tag r)
{
return l.value == static_cast<T>(r);
}
template<typename Tag, typename T> constexpr bool operator!=(asn1c_enum<Tag, T> l, Tag r)
{
return l.value != static_cast<T>(r);
}
template<typename Tag, typename T> constexpr bool operator==(Tag l, asn1c_enum<Tag, T> r)
{
return static_cast<T>(l) == r.value;
}
template<typename Tag, typename T> constexpr bool operator!=(Tag l, asn1c_enum<Tag, T> r)
{
return static_cast<T>(l) != r.value;
}
bool operator==(const OCTET_STRING_t&, const ByteBuffer&);
bool operator!=(const OCTET_STRING_t&, const ByteBuffer&);
bool operator==(const ByteBuffer&, const OCTET_STRING_t&);
bool operator!=(const ByteBuffer&, const OCTET_STRING_t&);
template<std::size_t N> bool operator==(const OCTET_STRING_t& lhs, const std::array<std::uint8_t, N>& rhs)
{
return lhs.size == N && std::memcmp(lhs.buf, rhs.data(), N) == 0;
}
template<std::size_t N> bool operator!=(const OCTET_STRING_t& lhs, const std::array<std::uint8_t, N>& rhs)
{
return !(lhs == rhs);
}
template<std::size_t N> bool operator==(const std::array<std::uint8_t, N>& lhs, const OCTET_STRING_t& rhs)
{
return rhs == lhs;
}
template<std::size_t N> bool operator!=(const std::array<std::uint8_t, N>& lhs, const OCTET_STRING_t& rhs)
{
return !(rhs == lhs);
}
} // namespace pki
} // namespace vanetza