Commit 353cf4db authored by garciay's avatar garciay
Browse files

Enahance certificate loader

parent cab6e9e7
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -951,7 +951,7 @@ namespace LibItsSecurity__Functions
    return TRUE;
    return TRUE;
  }
  }


  BOOLEAN fx__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__key__compressed, const INTEGER& p__public__key__compressed__mode, const OCTETSTRING& p__hashid8, const OCTETSTRING& p__issuer, const OCTETSTRING_template& p__private__enc__key, const OCTETSTRING_template& p__public__enc__key__x, const OCTETSTRING_template& p__public__enc__key__y, const OCTETSTRING_template& p__public__enc__compressed__key, const INTEGER_template& p__public__enc__key__compressed__mode) {
  BOOLEAN fx__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__key__compressed, const INTEGER& p__public__key__compressed__mode, const OCTETSTRING& p__hash, const OCTETSTRING& p__hashid8, const OCTETSTRING& p__issuer, const OCTETSTRING_template& p__private__enc__key, const OCTETSTRING_template& p__public__enc__key__x, const OCTETSTRING_template& p__public__enc__key__y, const OCTETSTRING_template& p__public__enc__compressed__key, const INTEGER_template& p__public__enc__key__compressed__mode) {
    loggers::get_instance().log(">>> fx__store__certificate: '%s'", static_cast<const char*>(p__cert__id));
    loggers::get_instance().log(">>> fx__store__certificate: '%s'", static_cast<const char*>(p__cert__id));


    int result;
    int result;
@@ -959,9 +959,9 @@ namespace LibItsSecurity__Functions
      const OCTETSTRING private_enc_key = p__private__enc__key.valueof();
      const OCTETSTRING private_enc_key = p__private__enc__key.valueof();
      const OCTETSTRING public_enc_key_x = p__public__enc__key__x.valueof();
      const OCTETSTRING public_enc_key_x = p__public__enc__key__x.valueof();
      const OCTETSTRING public_enc_key_y = p__public__enc__key__y.valueof();
      const OCTETSTRING public_enc_key_y = p__public__enc__key__y.valueof();
      result = security_services::get_instance().store_certificate(p__cert__id, p__cert, p__private__key, p__public__key__x, p__public__key__y, p__public__key__compressed, p__public__key__compressed__mode, p__hashid8, p__issuer, p__private__enc__key.valueof(), p__public__enc__key__x.valueof(), p__public__enc__key__y.valueof(), p__public__enc__compressed__key.valueof(), p__public__enc__key__compressed__mode.valueof());
      result = security_services::get_instance().store_certificate(p__cert__id, p__cert, p__private__key, p__public__key__x, p__public__key__y, p__public__key__compressed, p__public__key__compressed__mode, p__hash, p__hashid8, p__issuer, p__private__enc__key.valueof(), p__public__enc__key__x.valueof(), p__public__enc__key__y.valueof(), p__public__enc__compressed__key.valueof(), p__public__enc__key__compressed__mode.valueof());
    } else {
    } else {
      result = security_services::get_instance().store_certificate(p__cert__id, p__cert, p__private__key, p__public__key__x, p__public__key__y, p__public__key__compressed, p__public__key__compressed__mode, p__hashid8, p__issuer, OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), INTEGER(-1));
      result = security_services::get_instance().store_certificate(p__cert__id, p__cert, p__private__key, p__public__key__x, p__public__key__y, p__public__key__compressed, p__public__key__compressed__mode, p__hash, p__hashid8, p__issuer, OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), OCTETSTRING(0, nullptr), INTEGER(-1));
    }
    }
    
    
    return (result == 0);
    return (result == 0);
+138 −333

File changed.

Preview size limit exceeded, changes collapsed.

+6 −11
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <experimental/filesystem>
#include <experimental/filesystem>


#include "security_db_record.hh"
#include "security_db_record.hh"
#include "security_ecc.hh"


namespace IEEE1609dot2BaseTypes {
namespace IEEE1609dot2BaseTypes {
  class EccP256CurvePoint; //! Declare TITAN class
  class EccP256CurvePoint; //! Declare TITAN class
@@ -34,12 +35,6 @@ class certificates_loader {
  std::string _certificateExt;                    //! COER encoding certificate extension. Default: .oer
  std::string _certificateExt;                    //! COER encoding certificate extension. Default: .oer
  std::string _privateKeyExt;                     //! Private signing key extension. Default: .vkey
  std::string _privateKeyExt;                     //! Private signing key extension. Default: .vkey
  std::string _privateEncKeyExt;                  //! Private cyphering key extension. Default: .ekey
  std::string _privateEncKeyExt;                  //! Private cyphering key extension. Default: .ekey
  std::string _publicKeysExt;
  std::string _publicCompKeysExt;
  std::string _publicEncKeysExt;
  std::string _hashedidDigestExt;
  std::string _issuerDigestExt;
  std::string _publicEncCompKeysExt;
  std::experimental::filesystem::path _full_path; //! The full folder path to load certificates
  std::experimental::filesystem::path _full_path; //! The full folder path to load certificates
  bool _is_cache_initialized;                     //! Set to true when certificates are successfully loaded from file system
  bool _is_cache_initialized;                     //! Set to true when certificates are successfully loaded from file system
  std::set<std::string> _directory_filter;        //! Directory filter (for local development purposes only)
  std::set<std::string> _directory_filter;        //! Directory filter (for local development purposes only)
@@ -80,6 +75,6 @@ private:


  int build_certificates_cache(std::set<std::experimental::filesystem::path>& p_files, std::map<std::string, std::unique_ptr<security_db_record> >& p_certificates, std::map<OCTETSTRING, std::string>& p_hashed_id8s);
  int build_certificates_cache(std::set<std::experimental::filesystem::path>& p_files, std::map<std::string, std::unique_ptr<security_db_record> >& p_certificates, std::map<OCTETSTRING, std::string>& p_hashed_id8s);
  
  
  void fill_public_key_vectors(const IEEE1609dot2BaseTypes::EccP256CurvePoint& p_ecc_point, OCTETSTRING& p_public_comp_key, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y);
  void fill_public_key_vectors(const ec_elliptic_curves p_elliptic_curve, const IEEE1609dot2BaseTypes::EccP256CurvePoint& p_ecc_point, OCTETSTRING& p_public_comp_key, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y);
  void fill_public_key_vectors(const IEEE1609dot2BaseTypes::EccP384CurvePoint& p_ecc_point, OCTETSTRING& p_public_comp_key, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y);
  void fill_public_key_vectors(const ec_elliptic_curves p_elliptic_curve, const IEEE1609dot2BaseTypes::EccP384CurvePoint& p_ecc_point, OCTETSTRING& p_public_comp_key, OCTETSTRING& p_public_key_x, OCTETSTRING& p_public_key_y);
}; // End of class certificates_loader
}; // End of class certificates_loader
+5 −3
Original line number Original line Diff line number Diff line
@@ -211,11 +211,11 @@ bool security_cache::fill_vector(OCTETSTRING& p_vector, const OCTETSTRING& p_org
  return false;
  return false;
}
}


int security_cache::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_hashed_id8, 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) {
int security_cache::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_hashed_id8, 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) {
  loggers::get_instance().log_msg(">>> security_cache::store_certificate: ", p_cert_id);
  loggers::get_instance().log_msg(">>> security_cache::store_certificate: ", p_cert_id);


  std::string key(static_cast<const char*>(p_cert_id));
  std::string key(static_cast<const char*>(p_cert_id));
  OCTETSTRING cert, private_key, public_key_x, public_key_y, public_comp_key, hashed_id8, issuer;
  OCTETSTRING cert, private_key, public_key_x, public_key_y, public_comp_key, hash, hashed_id8, issuer;
  OCTETSTRING private_enc_key, public_enc_key_x, public_enc_key_y, public_enc_comp_key;
  OCTETSTRING private_enc_key, public_enc_key_x, public_enc_key_y, public_enc_comp_key;


  security_cache::fill_vector(cert, p_cert);
  security_cache::fill_vector(cert, p_cert);
@@ -228,6 +228,7 @@ int security_cache::store_certificate(const CHARSTRING& p_cert_id, const OCTETST
    loggers::get_instance().log_msg("security_cache::store_certificate: public_comp_key: ", public_comp_key);
    loggers::get_instance().log_msg("security_cache::store_certificate: public_comp_key: ", public_comp_key);
  }
  }


  security_cache::fill_vector(hash, p_hash);
  security_cache::fill_vector(hashed_id8, p_hashed_id8);
  security_cache::fill_vector(hashed_id8, p_hashed_id8);
  security_cache::fill_vector(issuer, p_issuer);
  security_cache::fill_vector(issuer, p_issuer);
  
  
@@ -248,7 +249,8 @@ int security_cache::store_certificate(const CHARSTRING& p_cert_id, const OCTETST
                                                 cert,               // Certificate
                                                 cert,               // Certificate
                                                 decoded_certificate,
                                                 decoded_certificate,
                                                 issuer,             // Hashed ID for the issuer
                                                 issuer,             // Hashed ID for the issuer
                                                 hashed_id8,         // Hashed ID
                                                 hash,               // Whole-certificate hash
                                                 hashed_id8,         // Whole-certificate hashed ID
                                                 private_key,        // Private key
                                                 private_key,        // Private key
                                                 public_key_x,       // Public key X-coordinate
                                                 public_key_x,       // Public key X-coordinate
                                                 public_key_y,       // Public key Y-coordinate
                                                 public_key_y,       // Public key Y-coordinate
+1 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ public: /*! \publicsection */
  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_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;
  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 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);


  virtual int clear();
  virtual int clear();
  
  
Loading