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).
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));
|
|
}
|
|
|