1#ifndef SECURED_MESSAGE_HPP_DCBC74AC
2#define SECURED_MESSAGE_HPP_DCBC74AC
4#include <vanetza/asn1/asn1c_wrapper.hpp>
5#include <vanetza/asn1/security/EtsiTs103097Data.h>
6#include <vanetza/common/archives.hpp>
7#include <vanetza/common/its_aid.hpp>
8#include <vanetza/net/packet_variant.hpp>
9#include <vanetza/security/hash_algorithm.hpp>
10#include <vanetza/security/hashed_id.hpp>
11#include <vanetza/security/signature.hpp>
12#include <vanetza/security/v3/asn1_types.hpp>
13#include <vanetza/security/v3/certificate.hpp>
15#include <boost/optional/optional_fwd.hpp>
16#include <boost/variant/variant_fwd.hpp>
30 using Time64 = std::uint64_t;
31 using SignerIdentifier = boost::variant<
const asn1::HashedId8*,
const asn1::Certificate*>;
38 uint8_t protocol_version()
const;
39 ItsAid its_aid()
const;
40 PacketVariant payload()
const;
41 bool is_signed()
const;
42 bool is_encrypted()
const;
43 boost::optional<Time64> generation_time()
const;
44 boost::optional<
Signature> signature()
const;
45 SignerIdentifier signer_identifier()
const;
46 ByteBuffer signing_payload()
const;
47 HashAlgorithm hash_id()
const;
49 void set_its_aid(ItsAid its_aid);
50 void set_generation_time(Time64 time);
51 void set_generation_location(
const asn1::ThreeDLocation& location);
52 void set_payload(
const ByteBuffer& payload);
53 void set_external_payload_hash(
const Sha256Digest& hash);
54 void set_hash_id(HashAlgorithm);
55 void set_signature(
const Signature& signature);
56 std::list<HashedId3> get_inline_p2pcd_request()
const;
57 void set_inline_p2pcd_request(std::list<HashedId3> requests);
58 void add_inline_p2pcd_request(HashedId3 unkown_certificate_digest);
59 void set_signature(
const SomeEcdsaSignature& signature);
60 void set_dummy_signature();
61 void set_signer_identifier_self();
62 void set_signer_identifier(
const HashedId8&);
66 void get_aes_ccm_ciphertext(ByteBuffer& ccm_ciphertext, std::array<uint8_t, 12>& nonce)
const;
67 void set_aes_ccm_ciphertext(
const ByteBuffer& ccm_ciphertext,
const std::array<uint8_t, 12>& nonce);
68 void set_cert_recip_info(
const HashedId8& recipient_id,
69 const KeyType curve_type,
70 const std::array<uint8_t, 16>& ecies_ciphertext,
71 const std::array<uint8_t, 16>& ecies_tag,
72 const ecdsa256::
PublicKey& ecies_pub_key);
73 bool check_psk_match(
const std::array<uint8_t, 16>& psk)
const;
77
78
79
80
84
85
86
87
88
92
93
94
95
96
97
100ByteBuffer get_payload(
const asn1::Opaque*);
101ByteBuffer get_payload(
const asn1::SignedData*);
102void set_payload(asn1::Opaque* unsecured,
const ByteBuffer& buffer);
103ByteBuffer convert_to_payload(vanetza::
ChunkPacket packet);
105boost::optional<HashedId8> get_certificate_id(
const SecuredMessage::SignerIdentifier&);
108
109
110
111
112bool contains_certificate(
const SecuredMessage::SignerIdentifier& signer_identifier);
ChunckPacket is a packet consisting of several memory chunks.
ByteBufferConvertible & operator[](OsiLayer ol)
ChunkPacket & merge(ChunkPacket &packet, OsiLayer from, OsiLayer to)
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
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
value_type operator[](size_type) const
byte_view_range(ByteBuffer &&)
byte_view_range(const ByteBuffer::const_iterator &, const ByteBuffer::const_iterator &)
ByteBuffer::const_pointer data() const
void encode(units::Duration)
units::Duration decode() const
bool after(const Timestamp &other) const
bool before(const Timestamp &other) const
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,...
std::chrono::seconds to_seconds() const
IntX specified in TS 103 097 v1.2.1, section 4.2.1.
Compressed_Lsb_Y_0 specified in TS 103 097 v1.2.1 in section 4.2.5.
Compressed_Lsb_Y_1 specified in TS 103 097 v1.2.1 in section 4.2.5.
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.
Uncompressed specified in TS 103 097 v1.2.1 in section 4.2.5.
X_Coordinate_Only specified in TS 103 097 v1.2.1 in section 4.2.5.
described in TS 103 097 v1.2.1, section 4.2.10
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)
void add_permission(ItsAid aid)
CircularRegion specified in TS 103 097 v1.2.1, section 4.2.22.
EciesEncryptedKey specified in TS 103 097 v1.2.1, section 5.9.
EncryptionKey specified in TS 103 097 v1.2.1, section 6.4.
IdentifiedRegion specified in TS 103 097 v1.2.1, section 4.2.25.
ItsAidSsp specified in TS 103 097 v1.2.1, section 6.9.
Specified in TS 103 097 v1.2.1, section 4.2.20.
OpaqueKey specified in TS 103 097 v1.2.1, section 5.8.
Payload specified in TS 103 097 v1.2.1, section 5.2.
RecipientInfo specified in TS 103 097 v1.2.1, section 5.8.
RectangularRegion specified in TS 103 097 v1.2.1, section 4.2.23.
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)
SubjectAssurance specified in TS 103 097 v1.2.1 in section 6.6 and 7.4.1.
described in TS 103 097 v1.2.1, section 6.2
ThreeDLocation specified in TS 103 097 v1.2.1, section 4.2.19.
Time64WithStandardDeviation specified in TS 103 097 v1.2.1, section 4.2.16.
TwoDLocation specified in TS 103 097 v1.2.1, section 4.2.18.
VerificationKey specified in TS 103 097 v1.2.1, section 6.4.
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 TrailerFieldType