Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/tools/pki/signed_builder.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

48 lines
1.6 KiB
C++

#pragma once
#include "keys.hpp"
#include "signed_data.hpp"
#include <vanetza/common/byte_buffer.hpp>
#include <vanetza/security/hash_algorithm.hpp>
#include <cstdint>
namespace vanetza
{
namespace pki
{
class Certificate;
class SecurityModule;
using security::HashAlgorithm;
// TS 103 097 protocol version that we emit on every constructed EtsiTs103097Data.
inline constexpr std::uint8_t ieee1609dot2_protocol_version = 3;
/**
* Build an EtsiTs103097Data-Signed envelope carrying `payload` as inline
* `unsecuredData`, signed with `signing_key`. PSID is fixed to SCR.
*
* \param signer_cert selects the SignerIdentifier variant per IEEE 1609.2 §5.3.1:
* nullptr → signer = self (hash of signer is hash of empty string)
* non-null → signer = digest with HashedId8(cert); hash of signer is hash
* of the OER-encoded signer certificate.
*/
SignedData create_signed(const ByteBuffer& payload, SecurityModule& security,
const PublicKey& signing_key, HashAlgorithm hash_algo, const Certificate* signer_cert);
/**
* Build an EtsiTs103097Data-SignedExternalPayload (TS 102 941 §6.2.3.3.1) used
* for the EC-signed proof inside an AT request: SignedData with
* `extDataHash = hash_algo(external_payload)` and no inline data.
*
* The same `hash_algo` covers both the external-payload hash placed in
* extDataHash and the signature hash chain. Other parameters mirror
* create_signed(); PSID is fixed to SCR.
*/
SignedData create_external_signed(const ByteBuffer& external_payload, SecurityModule& security,
const PublicKey& signing_key, HashAlgorithm hash_algo, const Certificate* signer_cert);
} // namespace pki
} // namespace vanetza