Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/security/tests/decap_service.cpp
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

34 lines
1.3 KiB
C++

#include <gtest/gtest.h>
#include <vanetza/common/its_aid.hpp>
#include <vanetza/security/decap_service.hpp>
#include <vanetza/security/v3/secured_message.hpp>
#include "printer.hpp"
using namespace vanetza;
using namespace vanetza::security;
TEST(DecapService, confirm_from_verify_confirm)
{
v3::SecuredMessage v3_msg = v3::SecuredMessage::with_signed_data();
v3_msg.set_payload(ByteBuffer { 0xca, 0xfe });
SecuredMessage msg { std::move(v3_msg) };
const HashedId8 signer { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
VerifyConfirm verify;
verify.report = VerificationReport::Success;
verify.its_aid = aid::CA;
verify.permissions = ByteBuffer { 0x01, 0x02 };
verify.certificate_validity = CertificateValidity::valid();
verify.certificate_id = signer;
DecapConfirm decap = DecapConfirm::from(std::move(verify), SecuredMessageView { msg });
EXPECT_EQ(VerificationReport::Success, decap.report);
EXPECT_EQ(aid::CA, decap.its_aid);
EXPECT_EQ(ByteBuffer({ 0x01, 0x02 }), decap.permissions);
EXPECT_TRUE(decap.certificate_validity);
ASSERT_TRUE(decap.certificate_id);
EXPECT_EQ(signer, *decap.certificate_id);
EXPECT_EQ(2, boost::apply_visitor([](const auto& packet) { return packet.size(); }, decap.plaintext_payload));
}