Rev

Rev 3227 | Rev 3347 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | Download | SVN | Bug Tracker

#pragma once

#include <string>
#include <memory>
#include <vector>
#include <map>

#include "security_db_record.hh"

class OCTETSTRING;
class INTEGER;
class CHARSTRING;

/*!
 * \class security_cache
 * \brief This class provides security record description for in memory security database. In memory mens there is no disk load/save mechanism
 */
class security_cache {
protected: /*! \protectedsection */
  // TODO Enforce with const security_cache_record, and const std::string
  std::map<std::string, std::unique_ptr<security_db_record> > _certificates; //! List of the certificates indexed by the certificate identifier
  std::map<std::vector<unsigned char>, std::string> _hashed_id8s; //! List of the certificates indexed by the HashedId8
  
public: /*! \publicsection */
  /*!
   * \brief Default ctor
   */
  security_cache();
  /*!
   * \brief Default private dtor
   */
  virtual ~security_cache();

  int get_certificate_id(const OCTETSTRING& p_hashed_id8, std::string& p_certificate_id) const;
  int get_certificate(const std::string& p_certificate_id, OCTETSTRING& p_certificate) const;
  int get_certificate(const std::string& p_certificate_id, IEEE1609dot2::CertificateBase& p_certificate) const;
  int get_issuer(const std::string& p_certificate_id, OCTETSTRING& p_hashed_id_issuer) const;
  int get_hashed_id(const std::string& p_certificate_id, OCTETSTRING& p_hashed_id) const;
  int get_hash(const std::string& p_certificate_id, OCTETSTRING& p_hash) const;
  int get_private_key(const std::string& p_certificate_id, OCTETSTRING& p_private_key) const;
  int get_public_keys(const std::string& p_certificate_id, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y) const;
  int get_public_comp_key(const std::string& p_certificate_id, OCTETSTRING& p_public_comp_key, INTEGER& p_comp_mode) const;
  int get_private_enc_key(const std::string& p_certificate_id, OCTETSTRING& p_private_enc_key) const;
  int get_public_enc_keys(const std::string& p_certificate_id, OCTETSTRING& p_public_enc_key_x, OCTETSTRING& p_public_enc_key_y) const;
  int get_public_enc_comp_key(const std::string& p_certificate_id, OCTETSTRING& p_public_enc_comp_key, INTEGER& p_enc_comp_mode) const;

  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_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);

  //virtual int store_certificate(const std::sring& p_cert_id, const std::vector<unsigned char>& p_cert, const std::vector<unsigned char>& p_private_key, const std::vector<unsigned char>& p_public_key_x, const std::vector<unsigned char>& p_public_key_y, const std::vector<unsigned char>& p_hashid8, const OCTETSTRING& p_issuer);
  virtual int clear();
  
  void dump() const;
  
}; // End of class security_cache