Commit c5b76a5e authored by garciay's avatar garciay
Browse files

Crash dump on std::copy, use vector::insert

parent c2317190
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -234,13 +234,14 @@ int certificates_loader::build_certificates_cache(std::set<std::experimental::fi
          }
        }
        
        std::vector<unsigned char> hashed_id(0x00, 8);
        std::vector<unsigned char> hashed_id;
        std::vector<unsigned char> issuer;
        if (decoded_certificate.issuer().ischosen(IEEE1609dot2::IssuerIdentifier::ALT_sha256AndDigest)) {
          std::vector<unsigned char> hash;
          sha256 sha;
          sha.generate(certificate, hash);
          std::copy(hash.cend() - 8, hash.cend(), hashed_id.begin());
          loggers::get_instance().log_to_hexa("certificates_loader::build_certificates_cache: Whole-certificate SHA-256 hash: ", hash.data(), hash.size());
          hashed_id.insert(hashed_id.begin(), hash.cend() - 8, hash.cend());
          issuer.assign(
                        static_cast<const unsigned char*>(decoded_certificate.issuer().sha256AndDigest()),
                        decoded_certificate.issuer().sha256AndDigest().lengthof() + static_cast<const unsigned char*>(decoded_certificate.issuer().sha256AndDigest())
@@ -249,7 +250,8 @@ int certificates_loader::build_certificates_cache(std::set<std::experimental::fi
          std::vector<unsigned char> hash;
          sha384 sha;
          sha.generate(certificate, hash);
          std::copy(hash.cend() - 8, hash.cend(), hashed_id.begin());
          loggers::get_instance().log_to_hexa("certificates_loader::build_certificates_cache: Whole-certificate SHA-384 hash: ", hash.data(), hash.size());
          hashed_id.insert(hashed_id.begin(), hash.cend() - 8, hash.cend());
          issuer.assign(
                        static_cast<const unsigned char*>(decoded_certificate.issuer().sha384AndDigest()),
                        decoded_certificate.issuer().sha384AndDigest().lengthof() + static_cast<const unsigned char*>(decoded_certificate.issuer().sha384AndDigest())
@@ -554,6 +556,8 @@ int certificates_loader::save_certificate(const security_db_record& p_certificat
} // End of method save_certificate

void certificates_loader::fill_public_key_vectors(const IEEE1609dot2BaseTypes::EccP256CurvePoint& p_ecc_point, std::vector<unsigned char>& p_public_comp_key, std::vector<unsigned char>& p_public_key_x, std::vector<unsigned char>& p_public_key_y) {
  loggers::get_instance().log_msg(">>> certificates_loader::fill_public_key_vectors: ", p_ecc_point);
  
  if (p_ecc_point.ischosen(IEEE1609dot2BaseTypes::EccP256CurvePoint::ALT_compressed__y__0)) {
    p_public_comp_key.resize(33);
    p_public_comp_key[0] = 0x02;
@@ -577,6 +581,8 @@ void certificates_loader::fill_public_key_vectors(const IEEE1609dot2BaseTypes::E
  }
}
void certificates_loader::fill_public_key_vectors(const IEEE1609dot2BaseTypes::EccP384CurvePoint& p_ecc_point, std::vector<unsigned char>& p_public_comp_key, std::vector<unsigned char>& p_public_key_x, std::vector<unsigned char>& p_public_key_y) {
  loggers::get_instance().log_msg(">>> certificates_loader::fill_public_key_vectors: ", p_ecc_point);

  if (p_ecc_point.ischosen(IEEE1609dot2BaseTypes::EccP384CurvePoint::ALT_compressed__y__0)) {
    p_public_comp_key.resize(49);
    p_public_comp_key[0] = 0x02;