Vanetza
 
Loading...
Searching...
No Matches
recipient_info.hpp
1#ifndef RECIPIENT_INFO_HPP_IENLXEUN
2#define RECIPIENT_INFO_HPP_IENLXEUN
3
4#include <vanetza/security/v2/basic_elements.hpp>
5#include <vanetza/security/v2/public_key.hpp>
6#include <boost/variant/variant.hpp>
7
8namespace vanetza
9{
10namespace security
11{
12namespace v2
13{
14
15/// EciesEncryptedKey specified in TS 103 097 v1.2.1, section 5.9
17{
18 EccPoint v;
19 ByteBuffer c;
20 std::array<uint8_t, 16> t;
21};
22
23/// OpaqueKey specified in TS 103 097 v1.2.1, section 5.8
25{
26 ByteBuffer data;
27};
28
29/// Key specified in TS 103 097 v1.2.1, section 5.8 (in RecipientInfo)
30typedef boost::variant<EciesEncryptedKey, OpaqueKey> Key;
31
32/// RecipientInfo specified in TS 103 097 v1.2.1, section 5.8
34{
35 HashedId8 cert_id;
36 Key enc_key;
37
38 PublicKeyAlgorithm pk_encryption() const;
39};
40
41/**
42 * \brief Determines applicable PublicKeyAlgorithm
43 * \param key Algorithm has to fit this kind of key
44 * \return PublicKeyAlgorithm
45 */
46PublicKeyAlgorithm get_type(const Key&);
47
48/**
49 * Calculates size of a RecipientInfo
50 * \param info
51 * \return number of octets needed to serialize the RecipientInfo
52 */
53size_t get_size(const RecipientInfo&);
54
55/**
56 * \brief Serializes a RecipientInfo into a binary archive
57 * \param ar Destination of serialized object
58 * \param info RecipientInfo to serialize
59 * \param sym Applicable symmetric algorithm
60 */
61void serialize(OutputArchive&, const RecipientInfo&, SymmetricAlgorithm);
62
63/**
64 * \brief Deserialize a RecipientInfo
65 * \param ar Input starting with serialized RecipientInfo
66 * \param info Deserialized RecipientInfo
67 * \param sym Symmetric algorithm required to deserialize encrypted key
68 * \return size of the deserialized RecipientInfo in bytes
69 */
70size_t deserialize(InputArchive&, RecipientInfo&, const SymmetricAlgorithm&);
71
72} // namespace v2
73} // namespace security
74} // namespace vanetza
75
76#endif /* RECIPIENT_INFO_HPP_IENLXEUN */
EciesEncryptedKey specified in TS 103 097 v1.2.1, section 5.9.
OpaqueKey specified in TS 103 097 v1.2.1, section 5.8.
RecipientInfo specified in TS 103 097 v1.2.1, section 5.8.