diff --git a/ccsrc/security/src/certs_cache.cc b/ccsrc/security/src/certs_cache.cc index 761fbb0302fe1b2f9ed08a2dde3dd3a18b8b095b..a6b8184faf75c92c41cf71aa980019c81a95dc9e 100644 --- a/ccsrc/security/src/certs_cache.cc +++ b/ccsrc/security/src/certs_cache.cc @@ -241,9 +241,8 @@ const std::string certs_cache::cert_to_string(const std::string& p_certificate_i int certs_cache::publickey_to_string(const EVP_PKEY* p_public_kep, std::vector& p_buffer) { loggers::get_instance().log(">>> certs_cache::publickey_to_string: '%p'", p_public_kep); - unsigned char buffer[512]; - unsigned char* ptr = &buffer[0]; - int ret = ::i2d_PublicKey((EVP_PKEY*)p_public_kep, &ptr); + unsigned char* buffer = nullptr; + int ret = ::i2d_PublicKey((EVP_PKEY*)p_public_kep, &buffer); loggers::get_instance().log("certs_cache::publickey_to_string: ret: '%d'", ret); if (ret < 0) { loggers::get_instance().warning("certs_cache::publickey_to_string: Failed to dunp certificate"); @@ -252,6 +251,7 @@ int certs_cache::publickey_to_string(const EVP_PKEY* p_public_kep, std::vector"); } // End of 'while'statement first = str.find(">", start); while ((first != -1) && (first < stop)) { //loggers::get_instance().log("transform_xslt_workaround: first='%d' ", first); - str = str.substr(0, first - 1) + ">" + str.substr(first + 1, str.length() - 1); + str = str.substr(0, first) + ">" + str.substr(first + 1, str.length() - 1); //loggers::get_instance().log("transform_xslt_workaround: New str (1): '%s'", str.c_str()); first = str.find(">", first); + stop = str.find(""); } // End of 'while'statement first = str.find("\"", start); while ((first != -1) && (first < stop)) { //loggers::get_instance().log("transform_xslt_workaround: first='%d' ", first); - str = str.substr(0, first - 1) + """ + str.substr(first + 1, str.length() - 1); + str = str.substr(0, first) + """ + str.substr(first + 1, str.length() - 1); //loggers::get_instance().log("transform_xslt_workaround: New str (1): '%s'", str.c_str()); first = str.find("\"", first); + stop = str.find(""); } // End of 'while'statement loggers::get_instance().log("<<< transform_xslt_workaround: '%s'", str.c_str()); @@ -176,6 +185,7 @@ INTEGER LibSecurity__Signature::fx__dec__xmldsig(BITSTRING& bs, http__www__w3__o std::string str(static_cast(oct2char(bit2oct(bs)))); loggers::get_instance().log("fx__dec__xmldsig: Before str: '%s'", str.c_str()); + transform_signature_workaround(str); transform_xslt_workaround(str); loggers::get_instance().log("fx__dec__xmldsig: Afer str: '%s'", str.c_str()); diff --git a/ccsrc/security/src/securty_services.cc b/ccsrc/security/src/securty_services.cc index 3c343f902226c593c518c9c526ec80d16faa2af0..5d7bb7f30194c223ccdd4ec71afff4103d149d8f 100644 --- a/ccsrc/security/src/securty_services.cc +++ b/ccsrc/security/src/securty_services.cc @@ -318,10 +318,20 @@ bool security_services::do_sign_verify(const CHARSTRING& p_message, const OCTETS } loggers::get_instance().log("security_services::do_sign_verify: public_key: '%p'", public_key); std::vector buffer; - _certs_db->publickey_to_string(public_key, buffer); + ret = _certs_db->publickey_to_string(public_key, buffer); + if (ret == 1) { + loggers::get_instance().warning("security_services::do_sign_verify: Failed to convert public key into string"); + return false; + } // Update the DigestValue + loggers::get_instance().log("security_services::do_sign_verify: canonicalized: '%s'", canonicalized.c_str()); int i = canonicalized.find(""); + if (i == std::string::npos) { + loggers::get_instance().warning("security_services::do_sign_verify: DigestValue entry not found"); + return false; + } + loggers::get_instance().log("security_services::do_sign_verify: i='%d'", i); canonicalized = canonicalized.substr(0, i + 13) + std::string(to64.cbegin(), to64.cend()) + canonicalized.substr(i + 13, canonicalized.length() - i - 13); OCTETSTRING to_be_signed(char2oct(CHARSTRING(canonicalized.c_str()))); loggers::get_instance().log_msg("security_services::do_sign_verify: to_be_signed: ", to_be_signed); diff --git a/ttcn/LibSecurity/ttcn/http_www_w3_org_2000_09_xmldsig.ttcn b/ttcn/LibSecurity/ttcn/http_www_w3_org_2000_09_xmldsig.ttcn index 5bea6b72d97cc492d9b5f1829a8ab94d402e918d..4be8b0bda07fc6f2df821c14d26a71dfb5b927b3 100644 --- a/ttcn/LibSecurity/ttcn/http_www_w3_org_2000_09_xmldsig.ttcn +++ b/ttcn/LibSecurity/ttcn/http_www_w3_org_2000_09_xmldsig.ttcn @@ -18,10 +18,10 @@ // Contact: http://ttcn.ericsson.se // //////////////////////////////////////////////////////////////////////////////// -// Generated from file(s): -// - signature.xsd -// /* xml version = "1.0" encoding = "utf-8" */ -// /* targetnamespace = "http://www.w3.org/2000/09/xmldsig#" */ +// Generated from file(s): +// - signature.xsd +// /* xml version = "1.0" encoding = "utf-8" */ +// /* targetnamespace = "http://www.w3.org/2000/09/xmldsig#" */ //////////////////////////////////////////////////////////////////////////////// // Modification header(s): //----------------------------------------------------------------------------- @@ -40,37 +40,42 @@ import from XSD all; //import from http_www_cise_eu_sevicemodel_v1_message all; +type record Transform { + XSD.String algorithm, + XSD.String path +} +with { + variant "element"; + variant (algorithm) "name as capitalized"; + variant (algorithm) "attribute"; + variant (path) "untagged"; +} type record Signature { - record { - record { - XSD.String algorithm - } canonicalizationMethod, - record { - XSD.String algorithm - } signatureMethod, - record { - XSD.String uRI, - record { - record { - XSD.String algorithm, - XSD.String path - } transform - } transforms, - record { - XSD.String algorithm - } digestMethod, - XSD.String digestValue - } reference - } signedInfo, - XSD.String signatureValue, - record { - record { - XSD.String x509SubjectName, - XSD.String x509Certificate - } x509Data - } keyInfo + record { + record { + XSD.String algorithm + } canonicalizationMethod, + record { + XSD.String algorithm + } signatureMethod, + record { + XSD.String uRI, + record of Transform transforms, + record { + XSD.String algorithm + } digestMethod, + XSD.String digestValue + } reference + } signedInfo, + XSD.String signatureValue, + record { + record { + XSD.String x509SubjectName, + XSD.String x509Certificate + } x509Data + } keyInfo } with { variant "element"; @@ -85,10 +90,6 @@ with { variant (signedInfo.reference.uRI) "name as capitalized"; variant (signedInfo.reference.uRI) "attribute"; variant (signedInfo.reference.transforms) "name as capitalized"; - variant (signedInfo.reference.transforms.transform) "name as capitalized"; - variant (signedInfo.reference.transforms.transform.algorithm) "name as capitalized"; - variant (signedInfo.reference.transforms.transform.algorithm) "attribute"; - variant (signedInfo.reference.transforms.transform.path) "untagged"; variant (signedInfo.reference.digestMethod) "name as capitalized"; variant (signedInfo.reference.digestMethod.algorithm) "name as capitalized"; variant (signedInfo.reference.digestMethod.algorithm) "attribute";