Vanetza
Loading...
Searching...
No Matches
backend_openssl.hpp
1#ifndef BACKEND_OPENSSL_HPP_CRRV8DCH
2#define BACKEND_OPENSSL_HPP_CRRV8DCH
3
4#include <vanetza/security/backend.hpp>
5#include <array>
6#include <cstdint>
7
8namespace vanetza
9{
10namespace security
11{
12
13// forward declaration
14namespace openssl
15{
16 class Key;
17 class Point;
18 class Signature;
19} // namespace openssl
20
21
22/**
23 * \brief Backend implementation based on OpenSSL
24 */
25class BackendOpenSsl : public Backend
26{
27public:
28 static constexpr auto backend_name = "OpenSSL";
29
30 BackendOpenSsl();
31
32 /// \see Backend::sign_data
33 EcdsaSignature sign_data(const ecdsa256::PrivateKey& private_key, const ByteBuffer& data_buffer) override;
34
35 /// \see Backend::sign_digest
36 Signature sign_digest(const PrivateKey&, const ByteBuffer& digest) override;
37
38 /// \see Backend::verify_data
39 bool verify_data(const ecdsa256::PublicKey& public_key, const ByteBuffer& data, const EcdsaSignature& sig) override;
40
41 /// \see Backend::verify_digest
42 bool verify_digest(const PublicKey&, const ByteBuffer& digest, const Signature&) override;
43
44 ByteBuffer calculate_hash(HashAlgorithm, const ByteBuffer&) override;
45
46 /// \see Backend::decompress_point
47 boost::optional<Uncompressed> decompress_point(const EccPoint& ecc_point) override;
48
49private:
50 /// calculate SHA256 digest of data buffer
51 std::array<uint8_t, 32> calculate_sha256_digest(const ByteBuffer& data) const;
52
53 /// calculate SHA384 digest of data buffer
54 std::array<uint8_t, 48> calculate_sha384_digest(const ByteBuffer& data) const;
55
56 /// convert to internal format of private key
59
60 /// convert to internal format of public key
63
64 /// convert to internal format of an EC point
66};
67
68} // namespace security
69} // namespace vanetza
70
71#endif /* BACKEND_OPENSSL_HPP_CRRV8DCH */
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
EcdsaSignature specified in TS 103 097 v1.2.1, section 4.2.9.
Definition signature.hpp:17