1#include <vanetza/security/openssl_wrapper.hpp>
2#include <vanetza/security/public_key.hpp>
3#include <vanetza/security/signature.hpp>
25 std::runtime_error(ERR_reason_error_string(err))
31 check(bignum !=
nullptr);
36 BN_bin2bn(arr, len, bignum);
41 BIGNUM* ptr =
nullptr;
42 std::swap(ptr, bignum);
49 BN_clear_free(bignum);
55 check(ctx !=
nullptr);
65Point::Point(
const EC_GROUP* group) : point(EC_POINT_new(group))
67 check(point !=
nullptr);
72 std::swap(point, other.point);
77 std::swap(point, other.point);
86Group::Group(
int nid) : group(EC_GROUP_new_by_curve_name(nid))
88 check(group !=
nullptr);
93 EC_GROUP_clear_free(group);
96Signature::Signature(ECDSA_SIG* sig) : signature(sig)
102 Signature(convert_for_signing(ecdsa.R), ecdsa.s)
111Signature::Signature(
const ByteBuffer& r,
const ByteBuffer& s) :
112 signature(ECDSA_SIG_new())
115#if OPENSSL_API_COMPAT
< 0x10100000L
116 BN_bin2bn(r.data(), r.size(), signature->r);
117 BN_bin2bn(s.data(), s.size(), signature->s);
122 ECDSA_SIG_set0(signature, bn_r.move(), bn_s.move());
128 std::swap(signature, other.signature);
133 std::swap(signature, other.signature);
139 ECDSA_SIG_free(signature);
142Key::Key() : eckey(EC_KEY_new())
147Key::Key(
int nid) : eckey(EC_KEY_new_by_curve_name(nid))
152Key::Key(
Key&& other) : eckey(
nullptr)
154 std::swap(eckey, other.eckey);
159 std::swap(eckey, other.eckey);
EcdsaSignature specified in TS 103 097 v1.2.1, section 4.2.9.