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).
81 lines
2.3 KiB
C++
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 */
|