Files
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
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.
2026-09-24 10:56:05 +02:00

91 lines
2.2 KiB
C++

#ifndef PUBLIC_KEY_HPP_DRZFSERF
#define PUBLIC_KEY_HPP_DRZFSERF
#include <vanetza/security/v2/ecc_point.hpp>
#include <boost/variant/variant.hpp>
namespace vanetza
{
namespace security
{
namespace v2
{
/// SymmetricAlgorithm specified in TS 103 097 v1.2.1, section 4.2.3
enum class SymmetricAlgorithm : uint8_t
{
AES128_CCM = 0
};
/// PublicKeyAlgorithm specified in TS 103 097 v1.2.1, section 4.2.2
enum class PublicKeyAlgorithm : uint8_t
{
ECDSA_NISTP256_With_SHA256 = 0,
ECIES_NISTP256 = 1
};
/// ecdsa_nistp256_with_sha256 specified in TS 103 097 v1.2.1, section 4.2.4
struct ecdsa_nistp256_with_sha256
{
EccPoint public_key;
};
/// ecies_nistp256 specified in TS 103 097 v1.2.1, section 4.2.4
struct ecies_nistp256
{
SymmetricAlgorithm supported_symm_alg;
EccPoint public_key;
};
/// Profile specified in TS 103 097 v1.2.1, section 4.2.4
using PublicKey = boost::variant<ecdsa_nistp256_with_sha256, ecies_nistp256>;
/**
* \brief Determines PublicKeyAlgorithm to a given PublicKey
* \param public_key
* \return algorithm type
*/
PublicKeyAlgorithm get_type(const PublicKey&);
/**
* \brief Calculates size of a PublicKey
* \param public_key
* \return number of octets needed to serialize the PublicKey
*/
size_t get_size(const PublicKey&);
/**
* \brief Deserializes a PublicKey from a binary archive
* \param ar with a serialized PublicKey at the beginning
* \param public_key to save deserialized values in
* \return size of the deserialized publicKey
*/
size_t deserialize(InputArchive&, PublicKey&);
/**
* \brief Serializes a PublicKey into a binary archive
* \param ar to serialize in
* \param public_key to serialize
*/
void serialize(OutputArchive&, const PublicKey&);
/**
* \brief Determines field size related to algorithm
* \param public_key_algorithm
* \return required buffer size for related fields
* */
std::size_t field_size(PublicKeyAlgorithm);
/**
* \brief Determines field size related to algorithm
* \param symmetric_algorithm
* \return required buffer size for related fields
*/
std::size_t field_size(SymmetricAlgorithm);
} // namespace v2
} // namespace security
} // namespace vanetza
#endif /* PUBLIC_KEY_HPP_DRZFSERF */