1#include <vanetza/security/sha.hpp>
2#include <vanetza/security/v3/certificate.hpp>
3#include <boost/optional/optional.hpp>
17ByteBuffer fetch_octets(
const OCTET_STRING_t& octets);
20Certificate::Certificate() :
28 if (indicator.present != VerificationKeyIndicator_PR_verificationKey) {
32 ByteBuffer buffer = asn1::encode_oer(asn_DEF_EtsiTs103097Certificate, &cert);
33 switch (indicator.choice.verificationKey.present)
35 case PublicVerificationKey_PR_ecdsaNistP256:
36 case PublicVerificationKey_PR_ecdsaBrainpoolP256r1:
37 return create_hashed_id8(calculate_sha256_digest(buffer.data(), buffer.size()));
39 case PublicVerificationKey_PR_ecdsaBrainpoolP384r1:
40 return create_hashed_id8(calculate_sha384_digest(buffer.data(), buffer.size()));
51 if (indicator.present != VerificationKeyIndicator_PR_verificationKey) {
57 switch (input.present) {
58 case PublicVerificationKey_PR_ecdsaNistP256:
59 output.type = KeyType::NistP256;
60 if (copy_curve_point(output, input.choice.ecdsaNistP256)) {
66 case PublicVerificationKey_PR_ecdsaBrainpoolP256r1:
67 output.type = KeyType::BrainpoolP256r1;
68 if (copy_curve_point(output, input.choice.ecdsaBrainpoolP256r1)) {
74 case PublicVerificationKey_PR_ecdsaBrainpoolP384r1:
75 output.type = KeyType::BrainpoolP384r1;
76 if (copy_curve_point(output, input.choice.ecdsaBrainpoolP384r1)) {
93 for (
int i = 0; i < seq->list.count; ++i) {
94 if (seq->list.array[i]->psid == aid && seq->list.array[i]->ssp !=
nullptr) {
96 if (ssp.present == ServiceSpecificPermissions_PR_bitmapSsp) {
97 const BitmapSsp_t& bitmap = ssp.choice.bitmapSsp;
98 perms.assign(bitmap.buf, bitmap.buf + bitmap.size);
113 switch (from.present) {
114 case EccP256CurvePoint_PR_compressed_y_0:
115 to.compression = KeyCompression::Y0;
116 to.x = fetch_octets(from.choice.compressed_y_0);
118 case EccP256CurvePoint_PR_compressed_y_1:
119 to.compression = KeyCompression::Y1;
120 to.x = fetch_octets(from.choice.compressed_y_1);
122 case EccP256CurvePoint_PR_uncompressedP256:
123 to.compression = KeyCompression::NoCompression;
124 to.x = fetch_octets(from.choice.uncompressedP256.x);
125 to.y = fetch_octets(from.choice.uncompressedP256.y);
138 switch (from.present) {
139 case EccP384CurvePoint_PR_compressed_y_0:
140 to.compression = KeyCompression::Y0;
141 to.x = fetch_octets(from.choice.compressed_y_0);
143 case EccP384CurvePoint_PR_compressed_y_1:
144 to.compression = KeyCompression::Y1;
145 to.x = fetch_octets(from.choice.compressed_y_1);
147 case EccP384CurvePoint_PR_uncompressedP384:
148 to.compression = KeyCompression::NoCompression;
149 to.x = fetch_octets(from.choice.uncompressedP384.x);
150 to.y = fetch_octets(from.choice.uncompressedP384.y);
160ByteBuffer fetch_octets(
const OCTET_STRING_t& octets)
162 ByteBuffer buffer(octets.size);
163 std::memcpy(buffer.data(), octets.buf, octets.size);