Rev

Rev 3347 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
3342 garciay 1
/*!
2
 * \file      security_db_record.hh
3
 * \brief     Header file for a storage of certificates mechanism.
4
 * \author    ETSI STF525
5
 * \copyright ETSI Copyright Notification
6
 *            No part may be reproduced except as authorized by written permission.
7
 *            The copyright and the foregoing restriction extend to reproduction in all media.
8
 *            All rights reserved.
9
 * \version   0.1
10
 */
3227 filatov 11
#pragma once
12
 
13
#include <string>
14
 
15
#include "security_ecc.hh"
16
 
3342 garciay 17
class OCTETSTRING; //! TITAN forward declaration
18
 
3227 filatov 19
namespace IEEE1609dot2 {
20
  class CertificateBase;
21
};
22
 
23
/*!
24
 * \class security_db_record
25
 * \brief This class provides security record description for security database
26
 */
27
class security_db_record {
28
 
3342 garciay 29
  ec_elliptic_curves _algorithm;   /*!< Signature . Default: nist_p_256 */
30
  std::string _certificate_id;     /*!< Certificate storage*/
31
  OCTETSTRING _certificate;        /*!< COER storage */
32
  OCTETSTRING _hashed_id_issuer;   /*!< Hash id 8 of the issuer certificate */
3347 garciay 33
  OCTETSTRING _hash;               /*!< Certificate hash storage */ // TODO Check if it's usefull, otherwise remove it
3342 garciay 34
  OCTETSTRING _hashed_id;          /*!< Certificate hash id 8 storage */
35
  OCTETSTRING _pr_key;             /*!< Private key storage */
36
  OCTETSTRING _pu_key_x;           /*!< Public key X-coordinate storage */
37
  OCTETSTRING _pu_key_y;           /*!< Public key Y-coordinate storage */
38
  OCTETSTRING _pu_comp_key;        /*!< Public compressed key storage */
39
  OCTETSTRING _pr_enc_key;         /*!< Private encryption key storage */
40
  OCTETSTRING _pu_enc_key_x;       /*!< Public encryption key X-coordinate storage */
41
  OCTETSTRING _pu_enc_key_y;       /*!< Public encryption key Y-coordinate storage */
42
  OCTETSTRING _pu_enc_comp_key;    /*!< Public compressed encryption key storage */
3343 garciay 43
  bool _to_be_saved;               /*!< Flag to indicate if the record shall be saved, i.e. has been modified */
3227 filatov 44
  IEEE1609dot2::CertificateBase* _decoded_certificate;
45
 
46
public: /*! \publicsection */
47
  /*!
3342 garciay 48
   * \brief Default ctor
3227 filatov 49
   */
3256 garciay 50
  explicit security_db_record(): _algorithm{ec_elliptic_curves::nist_p_256}, _certificate_id(), _certificate(), _hashed_id_issuer(), _hash(), _hashed_id(), _pr_key(), _pu_key_x(), _pu_key_y(), _pu_comp_key(), _pr_enc_key(), _pu_enc_key_x(), _pu_enc_key_y(), _pu_enc_comp_key(), _to_be_saved(false), _decoded_certificate(nullptr) { };
3342 garciay 51
  /*!
52
   * \brief Specialised ctor
53
   * \param[in] p_certificate_id The certificate identifier
54
   * \param[in] p_certificate The COER encoded certificate
55
   * \param[in] p_decoded_certificate The decoded certificate
56
   * \param[in] p_hashed_id_issuer The HashedId of the certificate issuer
3347 garciay 57
   * \param[in] p_hash The whole-certificate hash
3342 garciay 58
   * \param[in] p_hashed_id The whole-certificate hashed id
59
   * \param[in] p_pr_key The private signature key
60
   * \param[in] p_pu_key_x The public X-coordinate signature key
61
   * \param[in] p_pu_key_y The public Y-coordinate signature key
62
   * \param[in] p_pu_comp_key The public compressed coordinate signature key
63
   * \param[in] p_pr_enc_key The private encryption key
64
   * \param[in] p_pu_enc_key_x The public X-coordinate encryption key
65
   * \param[in] p_pu_enc_key_y The public Y-coordinate encryption key
66
   * \param[in] p_pu_enc_comp_key_y The public compressed coordinate encryption key
67
   * \param[in] p_to_be_saved Set to true to save on disk this certificate.Default: true
68
   */
3347 garciay 69
  security_db_record(const std::string& p_certificate_id, const OCTETSTRING& p_certificate, const IEEE1609dot2::CertificateBase& p_decoded_certificate, const OCTETSTRING& p_hashed_id_issuer, const OCTETSTRING& p_hash, const OCTETSTRING& p_hashed_id, const OCTETSTRING& p_pr_key, const OCTETSTRING& p_pu_key_x, const OCTETSTRING& p_pu_key_y, const OCTETSTRING& p_pu_comp_key, const OCTETSTRING& p_pr_enc_key, const OCTETSTRING& p_pu_enc_key_x, const OCTETSTRING& p_pu_enc_key_y, const OCTETSTRING& p_pu_enc_comp_key_y, const bool p_to_be_saved = true);
3227 filatov 70
 
71
  /*!
3342 garciay 72
   * \brief Default dtor
3227 filatov 73
   */
3351 filatov 74
  ~security_db_record();
3227 filatov 75
 
3342 garciay 76
  /*!
77
   * \fn const IEEE1609dot2::CertificateBase& decoded_certificate() const;
78
   * \brief Retrieve the decoded certificate value
79
   * \return The decoded certificate
80
   */
3227 filatov 81
  const IEEE1609dot2::CertificateBase& decoded_certificate() const;
82
 
3342 garciay 83
  /*!
84
   * \inline
85
   * \fn const std::string& certificate_id() const;
86
   * \brief Retrieve the certificate identifier value
87
   * \return The certificate identifier
88
   */
3227 filatov 89
  inline const std::string& certificate_id() const { return _certificate_id; };
3342 garciay 90
  /*!
91
   * \inline
92
   * \fn const OCTETSTRING& certificate() const;
93
   * \brief Retrieve the COER encoded certificate
94
   * \return The COER encoded certificate
95
   */
96
  inline const OCTETSTRING& certificate() const { return _certificate; };
97
  /*!
98
   * \inline
99
   * \fn const OCTETSTRING& hashed_id() const;
100
   * \brief Retrieve the HashedId of the certificate issuer
101
   * \return The HashedId of the certificate issuer
102
   */
103
  inline const OCTETSTRING& hashed_id() const { return _hashed_id; };
104
  /*!
105
   * \inline
106
   * \fn const OCTETSTRING& hash() const;
107
   * \brief Retrieve the whole-certificate hashed id
108
   * \return The whole-certificate hashed id
109
   */
110
  inline const OCTETSTRING& hash() const { return _hash; };
111
  inline const OCTETSTRING& issuer() const { return _hashed_id_issuer; };
112
  inline const OCTETSTRING& private_key() const { return _pr_key; };
113
  inline const OCTETSTRING& public_key_x() const { return _pu_key_x; };
114
  inline const OCTETSTRING& public_key_y() const { return _pu_key_y; };
115
  inline const OCTETSTRING& public_comp_key() const { return _pu_comp_key; };
116
  inline const OCTETSTRING& private_enc_key() const { return _pr_enc_key; };
117
  inline const OCTETSTRING& public_enc_key_x() const { return _pu_enc_key_x; };
118
  inline const OCTETSTRING& public_enc_key_y() const { return _pu_enc_key_y; };
119
  inline const OCTETSTRING& public_enc_comp_key() const { return _pu_enc_comp_key; };
3227 filatov 120
}; // End of class security_db_record