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 */
ecdsa_nistp256_with_sha256 specified in TS 103 097 v1.2.1, section 4.2.4
Definition: public_key.hpp:29
ecies_nistp256 specified in TS 103 097 v1.2.1, section 4.2.4
Definition: public_key.hpp:35