Commit be17c52e authored by YannGarcia's avatar YannGarcia
Browse files

Validate XML envelopped signature mechanism

parent 3c00b81c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -366,6 +366,15 @@ public:
   */
  std::vector<std::string> split_arguments_line(const std::string& p_value);

  /*!
   * \brief Replace string or character into the the provided string
   * \param[in] p_value The original string value
   * \param[in] p_from The pattern to be replaced
   * \param[in] p_to The new pattern
   * \return The modified string
   */
  std::string replace(const std::string& p_value, const std::string& p_from, const std::string& p_to);

  /*!
   * \brief Convert the provided buffer into a Base64
   * \param[in] p_value The buffer value
+10 −0
Original line number Diff line number Diff line
@@ -187,6 +187,16 @@ static std::string insert_linebreaks(std::string str, size_t distance) {
    return str;
}

std::string converter::replace(const std::string& p_value, const std::string& p_from, const std::string& p_to) {
  size_t start_pos = 0;
  std::string str(p_value);
  while((start_pos = str.find(p_from, start_pos)) != std::string::npos) {
      str.replace(start_pos, p_from.length(), p_to);
      start_pos += p_to.length(); // Handles case where 'p_to' is a substring of 'p_from'
  }
  return str; 
}

std::vector<unsigned char> converter::buffer_to_base64(const std::vector<unsigned char> &p_value, const bool p_is_url) {
  const std::string& base64_enc_map_ = converter::base64_enc_map[(p_is_url) ? 1 : 0];
  const unsigned char trailing_char = (p_is_url) ? '.' : '=';
+5 −0
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ public: /*! \publicsection */

  void dump() const;

  const std::string cert_to_string(const std::string& p_certificate_id);

  int publickey_to_string(const EVP_PKEY* p_public_kep, std::vector<unsigned char>& p_buffer);


private: /*! \privatesection */
  /*!
   * \fn int load_certificate(const std::string& p_certificate_name, const std::string& p_private_key_name, const std::string& p_private_key_passwd, const certs_db_record** p_record);
+1 −0
Original line number Diff line number Diff line
@@ -62,5 +62,6 @@ public: /*! \publicsection */
  inline const EVP_PKEY* private_key() const { return _private_key; };
  inline const EVP_PKEY* public_key() const { return ::X509_get_pubkey(_certificate); };
  inline const X509_NAME* subject_name() const { return ::X509_get_subject_name(_certificate); };
  inline const X509_NAME* issuer() const { return ::X509_get_issuer_name(_certificate); };
  inline const std::string& pem() const { return _pem; };
}; // End of class certs_db_record
+2 −5
Original line number Diff line number Diff line
@@ -45,10 +45,7 @@ public: /*! \publicsection */
   * \fn int do_sign(const OCTETSTRING& p_encoded_message, const CHARSTRING& p_certificate_name, const CHARSTRING& p_private_key_name, const CHARSTRING& p_private_key_passwd, OCTETSTRING& p_signature, OCTETSTRING& p_digest, CHARSTRING& p_x509_certificate_subject, CHARSTRING& p_x509_certificate_pem);
   * \brief Sign message
   * \param[in] p_encoded_message The raw message to be signed
   * \param[in] p_encoded_message The raw message to be signed
   * \param[in] p_encoded_message The raw message to be signed
   * \param[in] p_encoded_message The raw message to be signed
   * \param[in] p_encoded_message The raw message to be signed
   * \param[in] TODO The raw message to be signed
   * \return 0 on success, -1 otherwise
   */
  int do_sign(const OCTETSTRING& p_encoded_message, const CHARSTRING& p_certificate_name, const CHARSTRING& p_private_key_name, const CHARSTRING& p_private_key_passwd, OCTETSTRING& p_signature, OCTETSTRING& p_digest, CHARSTRING& p_x509_certificate_subject, CHARSTRING& p_x509_certificate_pem, CHARSTRING& p_pull_request_signed_canonicalized);
@@ -59,5 +56,5 @@ public: /*! \publicsection */
   * \param[in] TODO
   * \return true on success, false otherwise
   */
  bool do_sign_verify(const CHARSTRING& p_message, const UNIVERSAL_CHARSTRING& p_canonicalization_method, const UNIVERSAL_CHARSTRING& p_signature_method, const UNIVERSAL_CHARSTRING& p_digest_method, const UNIVERSAL_CHARSTRING& p_digest_value, const UNIVERSAL_CHARSTRING& p_signature_value, const UNIVERSAL_CHARSTRING& p_subject_name, const UNIVERSAL_CHARSTRING& p_certificate);
  bool do_sign_verify(const CHARSTRING& p_message, const UNIVERSAL_CHARSTRING& p_canonicalization_method, const UNIVERSAL_CHARSTRING& p_signature_method, const UNIVERSAL_CHARSTRING& p_digest_method, const UNIVERSAL_CHARSTRING& p_digest_value, const UNIVERSAL_CHARSTRING& p_signature_value, const UNIVERSAL_CHARSTRING& p_subject_name, const UNIVERSAL_CHARSTRING& p_certificate, const CHARSTRING& p_debug_message);
};
 No newline at end of file
Loading