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.
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/common/byte_sequence.hpp>
|
|
#include <vanetza/security/v2/ecc_point.hpp>
|
|
#include <vanetza/security/v2/public_key.hpp>
|
|
#include <vanetza/security/v2/tests/check_ecc_point.hpp>
|
|
|
|
using vanetza::ByteBuffer;
|
|
using namespace vanetza::security;
|
|
using namespace vanetza::security::v2;
|
|
using namespace vanetza;
|
|
using namespace std;
|
|
|
|
static const std::size_t length = field_size(PublicKeyAlgorithm::ECDSA_NISTP256_With_SHA256);
|
|
|
|
EccPoint serialize_roundtrip(const EccPoint& point)
|
|
{
|
|
EccPoint outPoint;
|
|
std::stringstream stream;
|
|
OutputArchive oa(stream);
|
|
serialize(oa, point, PublicKeyAlgorithm::ECDSA_NISTP256_With_SHA256);
|
|
InputArchive ia(stream);
|
|
deserialize(ia, outPoint, PublicKeyAlgorithm::ECDSA_NISTP256_With_SHA256);
|
|
return outPoint;
|
|
}
|
|
|
|
TEST(EccPoint, uncompressed)
|
|
{
|
|
EccPoint point = Uncompressed { random_byte_sequence(length, 1), random_byte_sequence(length, 2) };
|
|
EccPoint outPoint = serialize_roundtrip(point);
|
|
check(point, outPoint);
|
|
EXPECT_EQ(EccPointType::Uncompressed, get_type(outPoint));
|
|
}
|
|
|
|
TEST(EccPoint, Compressed_Lsb_Y_0)
|
|
{
|
|
EccPoint point = Compressed_Lsb_Y_0 { random_byte_sequence(length, 3) };
|
|
EccPoint outPoint = serialize_roundtrip(point);
|
|
check(point, outPoint);
|
|
EXPECT_EQ(EccPointType::Compressed_Lsb_Y_0, get_type(outPoint));
|
|
}
|
|
|
|
TEST(EccPoint, X_Coordinate_Only)
|
|
{
|
|
EccPoint point = X_Coordinate_Only { random_byte_sequence(length, 4) };
|
|
EccPoint outPoint = serialize_roundtrip(point);
|
|
check(point, outPoint);
|
|
EXPECT_EQ(EccPointType::X_Coordinate_Only, get_type(outPoint));
|
|
}
|
|
|