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.
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
#ifndef OPENSSL_WRAPPER_HPP_GUFJGICT
|
||||
#define OPENSSL_WRAPPER_HPP_GUFJGICT
|
||||
|
||||
#include <vanetza/common/byte_buffer.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/err.h>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
namespace security
|
||||
{
|
||||
|
||||
// forward declaration
|
||||
struct EcdsaSignature;
|
||||
struct Signature;
|
||||
|
||||
namespace openssl
|
||||
{
|
||||
|
||||
/**
|
||||
* Check valid condition
|
||||
* \param valid If false stored OpenSSL error will be thrown
|
||||
*/
|
||||
void check(bool valid);
|
||||
|
||||
|
||||
class Exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
using code_type = decltype(ERR_get_error());
|
||||
|
||||
Exception();
|
||||
explicit Exception(code_type err);
|
||||
explicit Exception(const std::string& msg);
|
||||
explicit Exception(code_type, const std::string& msg);
|
||||
~Exception() override = default;
|
||||
|
||||
code_type error_code() const { return m_error; }
|
||||
const char* reason() const;
|
||||
const char* library() const;
|
||||
|
||||
private:
|
||||
code_type m_error = 0;
|
||||
};
|
||||
|
||||
|
||||
class BigNumber : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
BigNumber();
|
||||
~BigNumber();
|
||||
|
||||
BigNumber(const ByteBuffer& buf) :
|
||||
BigNumber(buf.data(), buf.size())
|
||||
{
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
BigNumber(const std::array<uint8_t, N>& bin) :
|
||||
BigNumber(bin.data(), bin.size())
|
||||
{
|
||||
}
|
||||
|
||||
operator BIGNUM*() { return bignum; }
|
||||
|
||||
private:
|
||||
BigNumber(const uint8_t*, std::size_t);
|
||||
|
||||
BIGNUM* bignum;
|
||||
};
|
||||
|
||||
|
||||
class BigNumberContext : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
BigNumberContext();
|
||||
~BigNumberContext();
|
||||
|
||||
operator BN_CTX*() { return ctx; }
|
||||
|
||||
private:
|
||||
BN_CTX* ctx;
|
||||
};
|
||||
|
||||
|
||||
class Group : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit Group(int nid);
|
||||
~Group();
|
||||
|
||||
operator EC_GROUP*() { return group; }
|
||||
|
||||
private:
|
||||
EC_GROUP* group;
|
||||
};
|
||||
|
||||
|
||||
class Point : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit Point(const EC_GROUP* group);
|
||||
Point(Point&&);
|
||||
Point& operator=(Point&&);
|
||||
~Point();
|
||||
|
||||
operator EC_POINT*() { return point; }
|
||||
|
||||
private:
|
||||
EC_POINT* point;
|
||||
};
|
||||
|
||||
|
||||
class Signature : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit Signature(ECDSA_SIG* sig);
|
||||
explicit Signature(const EcdsaSignature& sig);
|
||||
explicit Signature(const security::Signature& sig);
|
||||
Signature(Signature&&);
|
||||
Signature& operator=(Signature&&);
|
||||
~Signature();
|
||||
|
||||
operator const ECDSA_SIG*() { return signature; }
|
||||
const ECDSA_SIG* operator->() const { return signature; }
|
||||
ECDSA_SIG* operator->() { return signature; }
|
||||
operator bool() { return signature != nullptr; }
|
||||
|
||||
private:
|
||||
Signature(const ByteBuffer& r, const ByteBuffer& s);
|
||||
|
||||
ECDSA_SIG* signature;
|
||||
};
|
||||
|
||||
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key();
|
||||
explicit Key(int nid);
|
||||
explicit Key(EC_KEY* key);
|
||||
// non-copyable
|
||||
Key(const Key&) = delete;
|
||||
Key& operator=(const Key&) = delete;
|
||||
// but movable
|
||||
Key(Key&&);
|
||||
Key& operator=(Key&&);
|
||||
~Key();
|
||||
|
||||
operator EC_KEY*() { return eckey; }
|
||||
operator bool() const { return eckey != nullptr; }
|
||||
|
||||
private:
|
||||
EC_KEY* eckey;
|
||||
};
|
||||
|
||||
|
||||
class Bio : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit Bio(BIO* bio);
|
||||
Bio(Bio&&);
|
||||
Bio& operator=(Bio&&);
|
||||
~Bio();
|
||||
|
||||
operator BIO*() { return bio; }
|
||||
operator bool() const { return bio != nullptr; }
|
||||
|
||||
private:
|
||||
BIO* bio;
|
||||
};
|
||||
|
||||
|
||||
class EvpKey : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit EvpKey(EVP_PKEY* pkey);
|
||||
EvpKey(EvpKey&&);
|
||||
EvpKey& operator=(EvpKey&&);
|
||||
~EvpKey();
|
||||
|
||||
operator EVP_PKEY*() { return pkey; }
|
||||
operator bool() const { return pkey != nullptr; }
|
||||
|
||||
private:
|
||||
EVP_PKEY* pkey;
|
||||
};
|
||||
|
||||
} // namespace openssl
|
||||
} // namespace security
|
||||
} // namespace vanetza
|
||||
|
||||
#endif /* OPENSSL_WRAPPER_HPP_GUFJGICT */
|
||||
|
||||
Reference in New Issue
Block a user