Rev

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

Rev Author Line No. Line
3342 garciay 1
/*!
2
 * \file      security_cache.hh
3
 * \brief     Header file for a certificates caching storage mechanism.
4
 *            It is used to store certificates received from neighbors and not present in the data base
5
 * \author    ETSI STF525
6
 * \copyright ETSI Copyright Notification
7
 *            No part may be reproduced except as authorized by written permission.
8
 *            The copyright and the foregoing restriction extend to reproduction in all media.
9
 *            All rights reserved.
10
 * \version   0.1
11
 */
3227 filatov 12
#pragma once
13
 
14
#include <string>
15
#include <memory>
16
#include <map>
3349 garciay 17
#include <vector>
3227 filatov 18
 
19
#include "security_db_record.hh"
20
 
3342 garciay 21
class OCTETSTRING; //! TITAN forward declaration
22
class INTEGER; //! TITAN forward declaration
23
class CHARSTRING; //! TITAN forward declaration
3227 filatov 24
 
3350 garciay 25
struct security_cache_comp {
3349 garciay 26
  bool operator()(const OCTETSTRING& p_lhs, const OCTETSTRING& p_rhs) const;
3350 garciay 27
};
3349 garciay 28
 
3227 filatov 29
/*!
30
 * \class security_cache
31
 * \brief This class provides security record description for in memory security database. In memory mens there is no disk load/save mechanism
32
 */
33
class security_cache {
3342 garciay 34
  static bool fill_vector(OCTETSTRING& p_vector, const OCTETSTRING& p_org);
35
 
3227 filatov 36
protected: /*! \protectedsection */
37
  // TODO Enforce with const security_cache_record, and const std::string
38
  std::map<std::string, std::unique_ptr<security_db_record> > _certificates; //! List of the certificates indexed by the certificate identifier
3350 garciay 39
  std::map<OCTETSTRING, std::string, security_cache_comp> _hashed_id8s; //! List of the certificates indexed by the HashedId8
40
  //std::map<std::vector<unsigned char>, std::string> _hashed_id8s; //! List of the certificates indexed by the HashedId8
3227 filatov 41
 
42
public: /*! \publicsection */
43
  /*!
44
   * \brief Default ctor
45
   */
46
  security_cache();
47
  /*!
48
   * \brief Default private dtor
49
   */
50
  virtual ~security_cache();
51
 
52
  int get_certificate_id(const OCTETSTRING& p_hashed_id8, std::string& p_certificate_id) const;
53
  int get_certificate(const std::string& p_certificate_id, OCTETSTRING& p_certificate) const;
54
  int get_certificate(const std::string& p_certificate_id, IEEE1609dot2::CertificateBase& p_certificate) const;
55
  int get_issuer(const std::string& p_certificate_id, OCTETSTRING& p_hashed_id_issuer) const;
56
  int get_hashed_id(const std::string& p_certificate_id, OCTETSTRING& p_hashed_id) const;
57
  int get_hash(const std::string& p_certificate_id, OCTETSTRING& p_hash) const;
58
  int get_private_key(const std::string& p_certificate_id, OCTETSTRING& p_private_key) const;
59
  int get_public_keys(const std::string& p_certificate_id, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y) const;
60
  int get_public_comp_key(const std::string& p_certificate_id, OCTETSTRING& p_public_comp_key, INTEGER& p_comp_mode) const;
61
  int get_private_enc_key(const std::string& p_certificate_id, OCTETSTRING& p_private_enc_key) const;
62
  int get_public_enc_keys(const std::string& p_certificate_id, OCTETSTRING& p_public_enc_key_x, OCTETSTRING& p_public_enc_key_y) const;
3256 garciay 63
  int get_public_enc_comp_key(const std::string& p_certificate_id, OCTETSTRING& p_public_enc_comp_key, INTEGER& p_enc_comp_mode) const;
3227 filatov 64
 
3347 garciay 65
  virtual int store_certificate(const CHARSTRING& p_cert_id, const OCTETSTRING& p_cert, const OCTETSTRING& p_private_key, const OCTETSTRING& p_public_key_x, const OCTETSTRING& p_public_key_y, const OCTETSTRING& p_public_compressed_key, const INTEGER& p_public_compressed_key_mode, const OCTETSTRING& p_hash, const OCTETSTRING& p_hashid8, const OCTETSTRING& p_issuer, const OCTETSTRING& p_private_enc_key, const OCTETSTRING& p_public_enc_key_x, const OCTETSTRING& p_public_enc_key_y, const OCTETSTRING& p_public_enc_compressed_key, const INTEGER& p_public_enc_compressed_key_mode);
3227 filatov 66
 
67
  virtual int clear();
68
 
69
  void dump() const;
70
 
71
}; // End of class security_cache