Keep the colleague's microbu-esp32c5 tree in this repository
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).
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