Vanetza
Loading...
Searching...
No Matches
hash.hpp
1#pragma once
2#include <vanetza/common/byte_buffer.hpp>
3#include <vanetza/security/hash_algorithm.hpp>
4#include <vanetza/security/key_type.hpp>
5
6namespace vanetza
7{
8namespace security
9{
10
11// forward declarations
12class Backend;
13
14namespace v3
15{
16
17// forward declarations
18class CertificateView;
19
20/**
21 * Calculate message hash (combination of hashes).
22 *
23 * This function creates the message hash according to IEEE 1609.2 cause 5.3.1.2.2
24 * for verification type "certificate", i.e. not "self-signed" messages.
25 *
26 * \param backend backend for cryptographic operations
27 * \param algo hash algorithm
28 * \param data message payload (data to be signed)
29 * \param signing certificate used for signing
30 * \return message digest
31 */
32ByteBuffer calculate_message_hash(Backend&, HashAlgorithm, const ByteBuffer& data, const CertificateView& signing);
33
34/**
35 * Determine the hash algorithm for a given key type.
36 * \see IEEE 1609.2 clause 5.3.1.2.2 rule a)
37 * \param key_type key type
38 * \return suitable hash algorithm
39 */
40HashAlgorithm specified_hash_algorithm(KeyType key_type);
41
42} // namespace v3
43} // namespace security
44} // namespace vanetza
virtual Signature sign_digest(const PrivateKey &, const ByteBuffer &digest)=0
calculate signature for given digest and private key
virtual bool verify_digest(const PublicKey &public_key, const ByteBuffer &digest, const Signature &sig)=0
try to verify digest using public key and signature
virtual ByteBuffer calculate_hash(HashAlgorithm algo, const ByteBuffer &data)=0
calculate hash value of data
boost::optional< Certificate > canonicalize() const
boost::optional< HashedId8 > calculate_digest() const
boost::optional< HashedId8 > issuer_digest() const