Vanetza
Loading...
Searching...
No Matches
public_key.hpp
1#ifndef PUBLIC_KEY_HPP_DRZFSERF
2#define PUBLIC_KEY_HPP_DRZFSERF
3
4#include <vanetza/security/v2/ecc_point.hpp>
5#include <boost/variant/variant.hpp>
6
7namespace vanetza
8{
9namespace security
10{
11namespace v2
12{
13
14/// SymmetricAlgorithm specified in TS 103 097 v1.2.1, section 4.2.3
15enum class SymmetricAlgorithm : uint8_t
16{
17 AES128_CCM = 0
18};
19
20/// PublicKeyAlgorithm specified in TS 103 097 v1.2.1, section 4.2.2
21enum class PublicKeyAlgorithm : uint8_t
22{
23 ECDSA_NISTP256_With_SHA256 = 0,
24 ECIES_NISTP256 = 1
25};
26
27/// ecdsa_nistp256_with_sha256 specified in TS 103 097 v1.2.1, section 4.2.4
29{
30 EccPoint public_key;
31};
32
33/// ecies_nistp256 specified in TS 103 097 v1.2.1, section 4.2.4
35{
36 SymmetricAlgorithm supported_symm_alg;
37 EccPoint public_key;
38};
39
40/// Profile specified in TS 103 097 v1.2.1, section 4.2.4
41using PublicKey = boost::variant<ecdsa_nistp256_with_sha256, ecies_nistp256>;
42
43/**
44 * \brief Determines PublicKeyAlgorithm to a given PublicKey
45 * \param public_key
46 * \return algorithm type
47 */
48PublicKeyAlgorithm get_type(const PublicKey&);
49
50/**
51 * \brief Calculates size of a PublicKey
52 * \param public_key
53 * \return number of octets needed to serialize the PublicKey
54 */
55size_t get_size(const PublicKey&);
56
57/**
58 * \brief Deserializes a PublicKey from a binary archive
59 * \param ar with a serialized PublicKey at the beginning
60 * \param public_key to save deserialized values in
61 * \return size of the deserialized publicKey
62 */
63size_t deserialize(InputArchive&, PublicKey&);
64
65/**
66 * \brief Serializes a PublicKey into a binary archive
67 * \param ar to serialize in
68 * \param public_key to serialize
69 */
70void serialize(OutputArchive&, const PublicKey&);
71
72/**
73 * \brief Determines field size related to algorithm
74 * \param public_key_algorithm
75 * \return required buffer size for related fields
76 * */
77std::size_t field_size(PublicKeyAlgorithm);
78
79/**
80 * \brief Determines field size related to algorithm
81 * \param symmetric_algorithm
82 * \return required buffer size for related fields
83 */
84std::size_t field_size(SymmetricAlgorithm);
85
86} // namespace v2
87} // namespace security
88} // namespace vanetza
89
90#endif /* PUBLIC_KEY_HPP_DRZFSERF */
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(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 boost::optional< Uncompressed > decompress_point(const EccPoint &ecc_point)=0
decompress a possibly compressed elliptic curve point
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.
ecdsa_nistp256_with_sha256 specified in TS 103 097 v1.2.1, section 4.2.4
ecies_nistp256 specified in TS 103 097 v1.2.1, section 4.2.4
resolve type for matching HeaderFieldType
resolve type for matching TrailerFieldType