Vanetza
 
Loading...
Searching...
No Matches
backend_null.cpp
1#include <vanetza/common/byte_sequence.hpp>
2#include <vanetza/security/backend_null.hpp>
3#include <vanetza/security/public_key.hpp>
4#include <vanetza/security/signature.hpp>
5
6namespace vanetza
7{
8namespace security
9{
10
12{
13 static const EcdsaSignature fake = fake_signature();
14 return fake;
15}
16
17bool BackendNull::verify_data(const ecdsa256::PublicKey&, const ByteBuffer&, const EcdsaSignature&)
18{
19 // accept everything
20 return true;
21}
22
23bool BackendNull::verify_digest(const PublicKey&, const ByteBuffer&, const Signature&)
24{
25 // accept everything
26 return true;
27}
28
29boost::optional<Uncompressed> BackendNull::decompress_point(const EccPoint& ecc_point)
30{
31 return boost::none;
32}
33
34EcdsaSignature BackendNull::fake_signature() const
35{
36 constexpr std::size_t size = 32;
37 EcdsaSignature signature;
38 X_Coordinate_Only coordinate;
39 coordinate.x = random_byte_sequence(size, 0xdead);
40 signature.R = coordinate;
41 signature.s = random_byte_sequence(size, 0xbeef);
42
43 return signature;
44}
45
46ByteBuffer BackendNull::calculate_hash(KeyType key, const ByteBuffer& buffer)
47{
48 ByteBuffer hash;
49 switch (key) {
50 case KeyType::NistP256:
51 case KeyType::BrainpoolP256r1:
52 hash.resize(32);
53 break;
54 case KeyType::BrainpoolP384r1:
55 hash.resize(48);
56 break;
57 default:
58 break;
59 }
60 return hash;
61}
62
63} // namespace security
64} // namespace vanetza
bool verify_data(const ecdsa256::PublicKey &public_key, const ByteBuffer &data, const EcdsaSignature &sig) override
ByteBuffer calculate_hash(KeyType, const ByteBuffer &) override
bool verify_digest(const PublicKey &, const ByteBuffer &digest, const Signature &) override
EcdsaSignature sign_data(const ecdsa256::PrivateKey &private_key, const ByteBuffer &data_buffer) override
boost::optional< Uncompressed > decompress_point(const EccPoint &ecc_point) override
EcdsaSignature specified in TS 103 097 v1.2.1, section 4.2.9.
Definition: signature.hpp:17
X_Coordinate_Only specified in TS 103 097 v1.2.1 in section 4.2.5.
Definition: ecc_point.hpp:14