1#ifndef OPENSSL_WRAPPER_HPP_GUFJGICT
2#define OPENSSL_WRAPPER_HPP_GUFJGICT
4#include <vanetza/common/byte_buffer.hpp>
5#include <boost/core/noncopyable.hpp>
7#include <openssl/ecdsa.h>
8#include <openssl/err.h>
26
27
28
29void check(
bool valid);
35 using code_type =
decltype(ERR_get_error());
38 explicit Exception(code_type err);
48 BigNumber(
const ByteBuffer& buf) :
53 template<std::size_t N>
54 BigNumber(
const std::array<uint8_t, N>& bin) :
59 operator BIGNUM*() {
return bignum; }
63 BigNumber(
const uint8_t*, std::size_t);
75 operator BN_CTX*() {
return ctx; }
82class Group :
private boost::noncopyable
85 explicit Group(
int nid);
88 operator EC_GROUP*() {
return group; }
95class Point :
private boost::noncopyable
98 explicit Point(
const EC_GROUP* group);
103 operator EC_POINT*() {
return point; }
113 explicit Signature(ECDSA_SIG* sig);
115 explicit Signature(
const security::
Signature& sig);
120 operator
const ECDSA_SIG*() {
return signature; }
121 const ECDSA_SIG* operator->()
const {
return signature; }
122 ECDSA_SIG* operator->() {
return signature; }
123 operator
bool() {
return signature !=
nullptr; }
126 Signature(
const ByteBuffer& r,
const ByteBuffer& s);
128 ECDSA_SIG* signature;
136 explicit Key(
int nid);
138 Key(
const Key&) =
delete;
139 Key& operator=(
const Key&) =
delete;
145 operator EC_KEY*() {
return eckey; }
Backend implementation based on OpenSSL.
std::array< uint8_t, 32 > calculate_sha256_digest(const ByteBuffer &data) const
calculate SHA256 digest of data buffer
bool verify_data(const ecdsa256::PublicKey &public_key, const ByteBuffer &data, const EcdsaSignature &sig) override
bool verify_digest(const PublicKey &, const ByteBuffer &digest, const Signature &) override
std::array< uint8_t, 48 > calculate_sha384_digest(const ByteBuffer &data) const
calculate SHA384 digest of data buffer
openssl::Key internal_public_key(const ecdsa256::PublicKey &) const
convert to internal format of public key
openssl::Point internal_ec_point(const PublicKey &) const
convert to internal format of an EC point
Signature sign_digest(const PrivateKey &, const ByteBuffer &digest) override
EcdsaSignature sign_data(const ecdsa256::PrivateKey &private_key, const ByteBuffer &data_buffer) override
boost::optional< Uncompressed > decompress_point(const EccPoint &ecc_point) override
openssl::Key internal_private_key(const ecdsa256::PrivateKey &) const
convert to internal format of private key
ByteBuffer calculate_hash(HashAlgorithm, const ByteBuffer &) override
calculate hash value of data
Compressed_Lsb_Y_0 specified in TS 103 097 v1.2.1 in section 4.2.5.
Compressed_Lsb_Y_1 specified in TS 103 097 v1.2.1 in section 4.2.5.
EcdsaSignature specified in TS 103 097 v1.2.1, section 4.2.9.
Uncompressed specified in TS 103 097 v1.2.1 in section 4.2.5.
X_Coordinate_Only specified in TS 103 097 v1.2.1 in section 4.2.5.