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.
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
#ifndef BACKEND_CRYPTOPP_HPP_JQWA9MLZ
|
|
#define BACKEND_CRYPTOPP_HPP_JQWA9MLZ
|
|
|
|
#include <vanetza/security/backend.hpp>
|
|
#include <cryptopp/eccrypto.h>
|
|
#include <cryptopp/osrng.h>
|
|
#include <cryptopp/sha.h>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace security
|
|
{
|
|
|
|
class BackendCryptoPP : public Backend
|
|
{
|
|
public:
|
|
using Ecdsa256 = CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>;
|
|
using Ecdsa384 = CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA384>;
|
|
|
|
static constexpr auto backend_name = "CryptoPP";
|
|
|
|
BackendCryptoPP();
|
|
|
|
/// \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;
|
|
|
|
/// \see Backend::decompress_point
|
|
boost::optional<Uncompressed> decompress_point(const EccPoint& ecc_point) override;
|
|
|
|
/// \see Backend::calculate_hash
|
|
ByteBuffer calculate_hash(HashAlgorithm, const ByteBuffer&) override;
|
|
|
|
/// \see Backend::generate_key_pair
|
|
ecdsa256::KeyPair generate_key_pair() override;
|
|
|
|
private:
|
|
/// internal sign method using crypto++ private key
|
|
EcdsaSignature sign_data(const Ecdsa256::PrivateKey& key, const ByteBuffer& data);
|
|
|
|
/// internal verify method using crypto++ public key
|
|
bool verify_data(const Ecdsa256::PublicKey& key, const ByteBuffer& data, const ByteBuffer& sig);
|
|
|
|
/// create private key
|
|
Ecdsa256::PrivateKey generate_private_key();
|
|
|
|
/// derive public key from private key
|
|
Ecdsa256::PublicKey generate_public_key(const Ecdsa256::PrivateKey&);
|
|
|
|
/// adapt generic public key to internal structure
|
|
Ecdsa256::PublicKey internal_public_key(const ecdsa256::PublicKey&);
|
|
|
|
/// adapt generic private key to internal structure
|
|
Ecdsa256::PrivateKey internal_private_key(const ecdsa256::PrivateKey&);
|
|
|
|
CryptoPP::AutoSeededRandomPool m_prng;
|
|
};
|
|
|
|
namespace cryptopp
|
|
{
|
|
/// 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 cryptopp
|
|
|
|
} // namespace security
|
|
} // namespace vanetza
|
|
|
|
#endif /* BACKEND_CRYPTOPP_HPP_JQWA9MLZ */
|