Vanetza
Loading...
Searching...
No Matches
decap_service.hpp
1#ifndef F815BB22_3075_4A9D_9385_07876D800765
2#define F815BB22_3075_4A9D_9385_07876D800765
3
4#include <vanetza/common/its_aid.hpp>
5#include <vanetza/net/packet_variant.hpp>
6#include <vanetza/security/certificate_validity.hpp>
7#include <vanetza/security/hashed_id.hpp>
8#include <vanetza/security/secured_message.hpp>
9#include <vanetza/security/verify_service.hpp>
10#include <boost/optional/optional.hpp>
11#include <boost/variant/variant.hpp>
12
13namespace vanetza
14{
15namespace security
16{
17
18/**
19 * \brief Input data for decapsulating a secured message.
20 *
21 * The structure is equivalent to VerifyRequest, however, decapsulation may
22 * also deal with decryption in future versions.
23 *
24 * \see TS 102 723-8 v1.1.1 SN-DECAP.request
25 */
26struct DecapRequest
27{
28 DecapRequest(SecuredMessageView sec_msg_view) : sec_packet(sec_msg_view) {}
29 SecuredMessageView sec_packet;
30};
31
32/**
33 * \brief SN-DECAP.confirm report codes
34 * \see TS 102 723-8 v1.1.1 table 27 (report field)
35 *
36 * Instead of duplicating VerificationReport values and the linked burden keeping
37 * these values consistent, DecapReport is a variant incorporating VerificationReport.
38 * When decryption is implemented, a DecryptionReport may be added to the variant.
39 *
40 * The boost::blank entry indicates that the SecuredMessage was neither signed nor encrypted.
41 */
42using DecapReport = boost::variant<boost::blank, VerificationReport>;
43
44/**
45 * \brief Check if report indicates a successful decapsulation.
46 *
47 * Either verification or decryption needs to be successful.
48 * An unsecured message cannot lead to a succesful decapsulation result.
49 *
50 * \param report to check
51 * \return true if either verification or decryption was successful
52 */
53bool is_successful(const DecapReport& report);
54
55/**
56 * \brief Check if decapsulation report matches a particular verification report.
57 *
58 * \param decap decapsulation report
59 * \param verification verification report
60 * \return true if decapsulation matches verification
61 */
62bool operator==(const DecapReport& decap, VerificationReport verification);
63bool operator==(VerificationReport verification, const DecapReport& decap);
64
65/**
66 * \brief SN-DECAP.confirm
67 * \see TS 102 723-8 v1.1.1 table 27
68 */
70{
71 /**
72 * Build DecapConfirm from verify outcome and secured message.
73 *
74 * \param verify_confirm outcome of verification
75 * \param msg_view view of secured message
76 * \return decapsulation confirmation
77 */
78 static DecapConfirm from(VerifyConfirm&& verify_confirm, const SecuredMessageView& msg_view);
79
80 PacketVariant plaintext_payload; // mandatory (plaintext_packet_length also covered by data type)
81 DecapReport report; // mandatory
82 CertificateValidity certificate_validity; // non-standard extension
83 boost::optional<HashedId8> certificate_id; // optional
84 ItsAid its_aid; // mandatory (its_ait_lenth also covered by data type)
85 ByteBuffer permissions; // mandatory
86};
87
88} // namespace security
89} // namespace vanetza
90
91#endif /* F815BB22_3075_4A9D_9385_07876D800765 */
static DecapConfirm from(VerifyConfirm &&verify_confirm, const SecuredMessageView &msg_view)