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.
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/common/byte_sequence.hpp>
|
|
#include <vanetza/security/public_key.hpp>
|
|
#include <vanetza/security/v2/public_key.hpp>
|
|
#include <vanetza/security/v2/tests/check_public_key.hpp>
|
|
|
|
using namespace vanetza;
|
|
using namespace vanetza::security;
|
|
using namespace std;
|
|
|
|
v2::PublicKey serialize(v2::PublicKey key)
|
|
{
|
|
std::stringstream stream;
|
|
OutputArchive oa(stream);
|
|
serialize(oa, key);
|
|
|
|
v2::PublicKey deKey;
|
|
InputArchive ia(stream);
|
|
deserialize(ia, deKey);
|
|
return deKey;
|
|
}
|
|
|
|
TEST(PublicKey, Field_Size)
|
|
{
|
|
EXPECT_EQ(32, field_size(v2::PublicKeyAlgorithm::ECDSA_NISTP256_With_SHA256));
|
|
EXPECT_EQ(32, field_size(v2::PublicKeyAlgorithm::ECIES_NISTP256));
|
|
}
|
|
|
|
TEST(PublicKey, ECIES_NISTP256)
|
|
{
|
|
v2::ecies_nistp256 ecies;
|
|
ecies.public_key = Uncompressed { random_byte_sequence(32, 1), random_byte_sequence(32, 2) };
|
|
ecies.supported_symm_alg = v2::SymmetricAlgorithm::AES128_CCM;
|
|
v2::PublicKey key = ecies;
|
|
|
|
v2::PublicKey deKey = serialize(key);
|
|
check(key, deKey);
|
|
EXPECT_EQ(v2::PublicKeyAlgorithm::ECIES_NISTP256, get_type(deKey));
|
|
EXPECT_EQ(67, get_size(deKey));
|
|
}
|
|
|
|
TEST(PublicKey, ECDSA_NISTP256_With_SHA256)
|
|
{
|
|
v2::ecdsa_nistp256_with_sha256 ecdsa;
|
|
ecdsa.public_key = X_Coordinate_Only { random_byte_sequence(32, 1) };
|
|
v2::PublicKey key = ecdsa;
|
|
|
|
v2::PublicKey deKey = serialize(key);
|
|
check(key, deKey);
|
|
EXPECT_EQ(v2::PublicKeyAlgorithm::ECDSA_NISTP256_With_SHA256, get_type(deKey));
|
|
EXPECT_EQ(34, get_size(deKey));
|
|
}
|