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).
51 lines
1.7 KiB
C++
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
|