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

81 lines
2.3 KiB
C++

#ifndef BACKEND_OPENSSL_HPP_CRRV8DCH
#define BACKEND_OPENSSL_HPP_CRRV8DCH
#include <vanetza/security/backend.hpp>
#include <array>
#include <cstdint>
namespace vanetza
{
namespace security
{
// forward declaration
namespace openssl
{
class Key;
class Point;
class Signature;
} // namespace openssl
/**
* \brief Backend implementation based on OpenSSL
*/
class BackendOpenSsl : public Backend
{
public:
static constexpr auto backend_name = "OpenSSL";
BackendOpenSsl();
/// \see Backend::sign_data
EcdsaSignature sign_data(const ecdsa256::PrivateKey& private_key, const ByteBuffer& data_buffer) override;
/// \see Backend::sign_digest
Signature sign_digest(const PrivateKey&, const ByteBuffer& digest) override;
/// \see Backend::verify_data
bool verify_data(const ecdsa256::PublicKey& public_key, const ByteBuffer& data, const EcdsaSignature& sig) override;
/// \see Backend::verify_digest
bool verify_digest(const PublicKey&, const ByteBuffer& digest, const Signature&) override;
ByteBuffer calculate_hash(HashAlgorithm, const ByteBuffer&) override;
/// \see Backend::decompress_point
boost::optional<Uncompressed> decompress_point(const EccPoint& ecc_point) override;
/// \see Backend::generate_key_pair
ecdsa256::KeyPair generate_key_pair() override;
private:
/// calculate SHA256 digest of data buffer
std::array<uint8_t, 32> calculate_sha256_digest(const ByteBuffer& data) const;
/// calculate SHA384 digest of data buffer
std::array<uint8_t, 48> calculate_sha384_digest(const ByteBuffer& data) const;
/// convert to internal format of private key
openssl::Key internal_private_key(const ecdsa256::PrivateKey&) const;
openssl::Key internal_private_key(const PrivateKey&) const;
/// convert to internal format of public key
openssl::Key internal_public_key(const ecdsa256::PublicKey&) const;
openssl::Key internal_public_key(const PublicKey&) const;
/// convert to internal format of an EC point
openssl::Point internal_ec_point(const PublicKey&) const;
};
namespace openssl
{
/// Derive the public key from a private key (pub = priv * G), on the key's own curve.
PublicKey derive_public_key(const PrivateKey& private_key);
} // namespace openssl
} // namespace security
} // namespace vanetza
#endif /* BACKEND_OPENSSL_HPP_CRRV8DCH */