Files
MicrOBU/obu-firmware/external/vanetza-idf/tools/pki/encrypted_data.hpp
T
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

51 lines
1.7 KiB
C++

#pragma once
#include "security_module.hpp"
#include <vanetza/asn1/asn1c_wrapper.hpp>
#include <vanetza/asn1/security/EtsiTs103097Data-Encrypted.h>
namespace vanetza
{
namespace pki
{
// forward declarations
struct HashedId8;
class SecurityModule;
class EncryptedData : public asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs103097Data_Encrypted_85P0_t>
{
public:
using wrapper = asn1::asn1c_oer_wrapper<Vanetza_Security_EtsiTs103097Data_Encrypted_85P0_t>;
EncryptedData(std::shared_ptr<SecurityModule::EciesContext> ecies);
void generate_ciphertext(const ByteBuffer& payload);
void add_recipient_info(const HashedId8&);
const OCTET_STRING_t* get_nonce() const;
const OCTET_STRING_t* get_ciphertext() const;
/**
* \brief Decrypt a PKI response that reuses the request's symmetric AES key.
*
* Call on the same EncryptedData instance that built the request, after
* decode()-ing the response body into it. The AA/EA encrypts its response
* with the request's AES key referenced via pskRecipInfo
* (TS 102 941 §6.2.3.3.2 for AT, §6.2.3.2.2 for EC).
* \throws DecodingFailure if the ciphertext or pskRecipInfo is missing
*/
ByteBuffer decrypt();
// Lower-level builders that mutate an EtsiTs103097Data-Encrypted value in-place
static void init(asn1c_type& dest);
static void set_aes_ccm_ciphertext(asn1c_type& dest, SecurityModule::EciesContext& ecies,
const ByteBuffer& plaintext);
static void append_recipient_info(asn1c_type& dest, const SecurityModule::EciesContext& ecies,
const HashedId8& recipient);
private:
bool has_psk_recipient() const;
std::shared_ptr<SecurityModule::EciesContext> m_ecies;
};
} // namespace pki
} // namespace vanetza