Vanetza
Loading...
Searching...
No Matches
persistence.hpp
1#ifndef VANETZA_SECURITY_PERSISTENCE_HPP
2#define VANETZA_SECURITY_PERSISTENCE_HPP
3
4#include <vanetza/security/ecdsa256.hpp>
5#include <vanetza/security/v2/certificate.hpp>
6#include <vanetza/security/v2/public_key.hpp>
7#include <iosfwd>
8
9namespace vanetza
10{
11namespace security
12{
13namespace v2
14{
15
16/**
17 * \brief Loads a private key from a file
18 * \param key_path file to load the key from
19 * \return loaded key
20 */
21ecdsa256::KeyPair load_private_key_from_file(const std::string& key_path);
22
23/**
24 * \brief Save a private key pair to a stream in PKCS#8 DER format (secp256r1)
25 * \param os destination stream
26 * \param key_pair key pair to be stored
27 * \return true if successfully written
28 */
29bool save_private_key_pkcs8_der(std::ostream& os, const ecdsa256::KeyPair& key_pair);
30
31/**
32 * \brief Loads a public key from a file
33 * \param key_path file to load the key from
34 * \return loaded key
35 */
36PublicKey load_public_key_from_file(const std::string& key_path);
37
38/**
39 * \brief Saves a public key to a file
40 * \param key_path file to save the key to
41 * \param public_key key to save
42 */
43void save_public_key_to_file(const std::string& key_path, const PublicKey& public_key);
44
45/**
46 * \brief Loads a certificate from a file
47 * \param certificate_path file to load the certificate from
48 * \return loaded certificate
49 */
50Certificate load_certificate_from_file(const std::string& certificate_path);
51
52/**
53 * \brief Saves a certificate to a file
54 * \param certificate_path file to save the certificate to
55 * \param certificate certificate to save
56 */
57void save_certificate_to_file(const std::string& certificate_path, const Certificate& certificate);
58
59} // namespace v2
60} // namespace security
61} // namespace vanetza
62
63#endif /* VANETZA_SECURITY_PERSISTENCE_HPP */
described in TS 103 097 v1.2.1 (2015-06), section 6.1