Vanetza
Loading...
Searching...
No Matches
ecc_point.hpp
1#ifndef CFE4DC34_AD31_47E8_9EB2_1B98C6FB0887
2#define CFE4DC34_AD31_47E8_9EB2_1B98C6FB0887
3
4#include <vanetza/common/byte_buffer.hpp>
5#include <boost/variant/variant.hpp>
6
7namespace vanetza
8{
9namespace security
10{
11
12// forward declarations
13struct PublicKey;
14namespace ecdsa256 { struct PublicKey; }
15
16/// X_Coordinate_Only specified in TS 103 097 v1.2.1 in section 4.2.5
18{
19 ByteBuffer x;
20};
21
22/// Compressed_Lsb_Y_0 specified in TS 103 097 v1.2.1 in section 4.2.5
24{
25 ByteBuffer x;
26};
27
28/// Compressed_Lsb_Y_1 specified in TS 103 097 v1.2.1 in section 4.2.5
30{
31 ByteBuffer x;
32};
33
34/// Uncompressed specified in TS 103 097 v1.2.1 in section 4.2.5
36{
37 ByteBuffer x;
38 ByteBuffer y;
39};
40
41/// EccPoint specified in TS 103 097 v1.2.1 in section 4.2.5
42using EccPoint = boost::variant<
47>;
48
49/**
50 * \brief calculate byte length of ECC point structure
51 * \param ecc_point
52 * \return length in bytes
53 */
54std::size_t get_length(const EccPoint& ecc_point);
55
56/**
57 * \brief Convert EccPoint for signature calculation
58 * Uses ecc_point.x as relevant field for signatures.
59 *
60 * \param ecc_point
61 * \return binary representation of ECC point
62 */
63ByteBuffer convert_for_signing(const EccPoint& ecc_point);
64
65/**
66 * \brief Convert a public key into an ECC point, preserving its compression
67 * \param public_key public key (uncompressed or compressed)
68 * \return ECC point matching the key's own point format
69 */
70EccPoint make_ecc_point(const PublicKey& public_key);
71
72/**
73 * \brief Compressed ECC point from public key
74 * \param public_key
75 * \return compressed ECC point
76 */
77EccPoint compress_public_key(const PublicKey& public_key);
78EccPoint compress_public_key(const ecdsa256::PublicKey& public_key);
79
80} // namespace security
81} // namespace vanetza
82
83#endif /* CFE4DC34_AD31_47E8_9EB2_1B98C6FB0887 */
ChunckPacket is a packet consisting of several memory chunks.
ByteBufferConvertible & operator[](OsiLayer ol)
ChunkPacket & merge(ChunkPacket &packet, OsiLayer from, OsiLayer to)
std::size_t size() const
const ByteBufferConvertible & layer(OsiLayer ol) const
const ByteBufferConvertible & operator[](OsiLayer ol) const
ByteBufferConvertible & layer(OsiLayer ol)
std::size_t size(OsiLayer from, OsiLayer to) const
ChunkPacket extract(OsiLayer from, OsiLayer to)
std::size_t size(OsiLayer from, OsiLayer to) const
buffer_const_range operator[](OsiLayer layer) const
std::size_t size() const
void set_boundary(OsiLayer, unsigned bytes)
const ByteBuffer & buffer() const
CohesivePacket(const ByteBuffer &buffer, OsiLayer layer)
void trim(OsiLayer from, unsigned bytes)
std::size_t size(OsiLayer single_layer) const
Result create(const std::string &name, Args... args) const
Definition factory.hpp:31
bool configure_default(const std::string &name)
Definition factory.hpp:70
bool add(const std::string &name, Function f)
Definition factory.hpp:60
Result create(Args... args) const
Definition factory.hpp:45
value_type operator[](size_type) const
Definition byte_view.cpp:48
byte_view_range(ByteBuffer &&)
Definition byte_view.cpp:37
byte_view_range(const ByteBuffer::const_iterator &, const ByteBuffer::const_iterator &)
Definition byte_view.cpp:27
ByteBuffer::const_pointer data() const
Definition byte_view.cpp:42
void encode(units::Duration)
Definition lifetime.cpp:45
units::Duration decode() const
Definition lifetime.cpp:59
bool after(const Timestamp &other) const
Definition timestamp.cpp:76
bool before(const Timestamp &other) const
Definition timestamp.cpp:71
virtual ecdsa256::KeyPair generate_key_pair()=0
generate a private key and the corresponding public key
virtual boost::optional< Uncompressed > decompress_point(const EccPoint &ecc_point)=0
decompress a possibly compressed elliptic curve point
virtual Signature sign_digest(const PrivateKey &, const ByteBuffer &digest)=0
calculate signature for given digest and private key
virtual EcdsaSignature sign_data(const ecdsa256::PrivateKey &private_key, const ByteBuffer &data)=0
calculate signature for given data and private key
virtual bool verify_data(const ecdsa256::PublicKey &public_key, const ByteBuffer &data, const EcdsaSignature &sig)=0
try to verify data using public key and signature
virtual bool verify_digest(const PublicKey &public_key, const ByteBuffer &digest, const Signature &sig)=0
try to verify digest using public key and signature
virtual ByteBuffer calculate_hash(HashAlgorithm algo, const ByteBuffer &data)=0
calculate hash value of data
static CertificateValidity valid()
Create CertificateValidity signalling a valid certificate This method is equivalent to default constr...
CertificateValidity(CertificateInvalidReason reason)
CertificateInvalidReason reason() const
Get reason for certificate invalidity This call is only safe if reason is available,...
IntX specified in TS 103 097 v1.2.1, section 4.2.1.
Definition int_x.hpp:21
Compressed_Lsb_Y_0 specified in TS 103 097 v1.2.1 in section 4.2.5.
Definition ecc_point.hpp:24
Compressed_Lsb_Y_1 specified in TS 103 097 v1.2.1 in section 4.2.5.
Definition ecc_point.hpp:30
static DecapConfirm from(VerifyConfirm &&verify_confirm, const SecuredMessageView &msg_view)
Input data for decapsulating a secured message.
EcdsaSignature specified in TS 103 097 v1.2.1, section 4.2.9.
Definition signature.hpp:17
Uncompressed specified in TS 103 097 v1.2.1 in section 4.2.5.
Definition ecc_point.hpp:36
X_Coordinate_Only specified in TS 103 097 v1.2.1 in section 4.2.5.
Definition ecc_point.hpp:18
described in TS 103 097 v1.2.1 (2015-06), section 6.1
void add_permission(ItsAid aid, const ByteBuffer &ssp)
const ValidityRestriction * get_restriction(ValidityRestrictionType type) const
const SubjectAttribute * get_attribute(SubjectAttributeType type) const
void remove_attribute(SubjectAttributeType type)
const validity_restriction_type< T > * get_restriction() const
const subject_attribute_type< T > * get_attribute() const
void remove_restriction(ValidityRestrictionType type)
Payload specified in TS 103 097 v1.2.1, section 5.2.
Definition payload.hpp:28
SecuredMessage as specified in TS 103 097 v1.2.1, section 5.1.
HeaderField * header_field(HeaderFieldType)
const TrailerField * trailer_field(TrailerFieldType type) const
const HeaderField * header_field(HeaderFieldType type) const
TrailerField * trailer_field(TrailerFieldType)
described in TS 103 097 v1.2.1, section 6.2
ThreeDLocation specified in TS 103 097 v1.2.1, section 4.2.19.
Definition region.hpp:21
Time64WithStandardDeviation specified in TS 103 097 v1.2.1, section 4.2.16.
resolve type for matching HeaderFieldType
resolve type for matching TrailerFieldType