1#include <vanetza/security/backend.hpp>
2#include <vanetza/security/v3/certificate.hpp>
3#include <vanetza/security/v3/hash.hpp>
12ByteBuffer calculate_message_hash(
Backend& backend, HashAlgorithm hash_algo,
const ByteBuffer& payload,
const CertificateView& signing_cert)
14 ByteBuffer encoded_cert;
19 if (canonical_signing_cert) {
20 encoded_cert = canonical_signing_cert->encode();
26 ByteBuffer concat_hash;
27 concat_hash.reserve(data_hash.size() + cert_hash.size());
28 concat_hash.insert(concat_hash.end(), data_hash.begin(), data_hash.end());
29 concat_hash.insert(concat_hash.end(), cert_hash.begin(), cert_hash.end());
33HashAlgorithm specified_hash_algorithm(KeyType key_type)
36 case KeyType::NistP256:
37 case KeyType::BrainpoolP256r1:
38 return HashAlgorithm::SHA256;
39 case KeyType::BrainpoolP384r1:
40 return HashAlgorithm::SHA384;
42 return HashAlgorithm::Unspecified;
virtual ByteBuffer calculate_hash(HashAlgorithm algo, const ByteBuffer &data)=0
calculate hash value of data
ByteBuffer encode() const
boost::optional< Certificate > canonicalize() const
bool is_canonical() const