2 * Licensed to UCAID under one or more contributor license agreements.
3 * See the NOTICE file distributed with this work for additional information
4 * regarding copyright ownership. The ASF licenses this file to you under
5 * the Apache License, Version 2.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy of the
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * XMLToolingConfig.cpp
21 * Library configuration.
25 #include "exceptions.h"
27 #include "XMLToolingConfig.h"
28 #include "encryption/Encryption.h"
29 #include "encryption/Encrypter.h"
30 #include "impl/UnknownElement.h"
31 #include "io/HTTPResponse.h"
32 #include "security/TrustEngine.h"
33 #include "security/OpenSSLCryptoX509CRL.h"
34 #include "security/CredentialResolver.h"
35 #include "security/KeyInfoResolver.h"
36 #include "signature/KeyInfo.h"
37 #include "signature/Signature.h"
38 #include "soap/SOAP.h"
40 #include "util/PathResolver.h"
41 #include "util/ReplayCache.h"
42 #include "util/StorageService.h"
43 #include "util/TemplateEngine.h"
44 #include "util/Threads.h"
45 #include "util/URLEncoder.h"
46 #include "validation/ValidatorSuite.h"
53 #if defined(XMLTOOLING_LOG4SHIB)
54 # include <log4shib/PropertyConfigurator.hh>
55 # include <log4shib/OstreamAppender.hh>
56 #elif defined(XMLTOOLING_LOG4CPP)
57 # include <log4cpp/PropertyConfigurator.hh>
58 # include <log4cpp/OstreamAppender.hh>
60 #include <xercesc/util/PlatformUtils.hpp>
61 #include <xercesc/util/XMLUniDefs.hpp>
62 #ifndef XMLTOOLING_NO_XMLSEC
63 # include <curl/curl.h>
64 # include <openssl/err.h>
65 # include <openssl/evp.h>
66 # include <xsec/framework/XSECAlgorithmMapper.hpp>
67 # include <xsec/framework/XSECException.hpp>
68 # include <xsec/framework/XSECProvider.hpp>
69 # include <xsec/transformers/TXFMBase.hpp>
72 using namespace soap11;
73 using namespace xmltooling::logging;
74 using namespace xmltooling;
75 using namespace xercesc;
79 # if (OPENSSL_VERSION_NUMBER >= 0x00908000)
80 # define XMLTOOLING_OPENSSL_HAVE_SHA2 1
85 DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLParserException,xmltooling);
86 DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLObjectException,xmltooling);
87 DECL_XMLTOOLING_EXCEPTION_FACTORY(MarshallingException,xmltooling);
88 DECL_XMLTOOLING_EXCEPTION_FACTORY(UnmarshallingException,xmltooling);
89 DECL_XMLTOOLING_EXCEPTION_FACTORY(UnknownElementException,xmltooling);
90 DECL_XMLTOOLING_EXCEPTION_FACTORY(UnknownAttributeException,xmltooling);
91 DECL_XMLTOOLING_EXCEPTION_FACTORY(UnknownExtensionException,xmltooling);
92 DECL_XMLTOOLING_EXCEPTION_FACTORY(ValidationException,xmltooling);
93 DECL_XMLTOOLING_EXCEPTION_FACTORY(IOException,xmltooling);
95 #ifndef XMLTOOLING_NO_XMLSEC
96 using namespace xmlencryption;
97 using namespace xmlsignature;
98 DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLSecurityException,xmltooling);
99 DECL_XMLTOOLING_EXCEPTION_FACTORY(SignatureException,xmlsignature);
100 DECL_XMLTOOLING_EXCEPTION_FACTORY(EncryptionException,xmlencryption);
104 static XMLToolingInternalConfig g_config;
105 #ifndef XMLTOOLING_NO_XMLSEC
106 static vector<Mutex*> g_openssl_locks;
108 extern "C" void openssl_locking_callback(int mode,int n,const char *file,int line)
110 if (mode & CRYPTO_LOCK)
111 g_openssl_locks[n]->lock();
113 g_openssl_locks[n]->unlock();
117 extern "C" unsigned long openssl_thread_id(void)
119 return (unsigned long)(pthread_self());
123 # ifdef XMLTOOLING_XMLSEC_DEBUGLOGGING
124 class TXFMOutputLog : public TXFMBase {
127 TXFMOutputLog(DOMDocument* doc) : TXFMBase(doc), m_log(Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger")) {
131 m_log.debug("\n----- END SIGNATURE DEBUG -----\n");
134 void setInput(TXFMBase *newInput) {
136 if (newInput->getOutputType() != TXFMBase::BYTE_STREAM)
137 throw XSECException(XSECException::TransformInputOutputFail, "OutputLog transform requires BYTE_STREAM input");
138 keepComments = input->getCommentsStatus();
139 m_log.debug("\n----- BEGIN SIGNATURE DEBUG -----\n");
142 TXFMBase::ioType getInputType() {
143 return TXFMBase::BYTE_STREAM;
145 TXFMBase::ioType getOutputType() {
146 return TXFMBase::BYTE_STREAM;
148 TXFMBase::nodeType getNodeType() {
149 return TXFMBase::DOM_NODE_NONE;
152 unsigned int readBytes(XMLByte * const toFill, const unsigned int maxToFill) {
153 unsigned int sz = input->readBytes(toFill, maxToFill);
154 m_log.debug(string(reinterpret_cast<char* const>(toFill), sz));
158 DOMDocument* getDocument() {
161 DOMNode* getFragmentNode() {
164 const XMLCh* getFragmentId() {
172 TXFMBase* TXFMOutputLogFactory(DOMDocument* doc) {
173 if (Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger").isDebugEnabled())
174 return new TXFMOutputLog(doc);
183 LPCSTR lpUNCServerName,
189 LPCSTR messages[] = {message, nullptr};
191 HANDLE hElog = RegisterEventSource(lpUNCServerName, "OpenSAML XMLTooling Library");
192 BOOL res = ReportEvent(hElog, wType, 0, dwEventID, lpUserSid, 1, 0, messages, nullptr);
193 return (DeregisterEventSource(hElog) && res);
198 XMLToolingConfig& XMLToolingConfig::getConfig()
203 XMLToolingInternalConfig& XMLToolingInternalConfig::getInternalConfig()
208 #ifndef XMLTOOLING_NO_XMLSEC
209 XMLToolingConfig::XMLToolingConfig()
210 : m_keyInfoResolver(nullptr), m_replayCache(nullptr), m_pathResolver(nullptr), m_templateEngine(nullptr), m_urlEncoder(nullptr), clock_skew_secs(180)
212 XMLToolingConfig::XMLToolingConfig()
213 : m_pathResolver(nullptr), m_templateEngine(nullptr), m_urlEncoder(nullptr), clock_skew_secs(180)
218 XMLToolingConfig::~XMLToolingConfig()
222 #ifndef XMLTOOLING_LITE
223 const KeyInfoResolver* XMLToolingConfig::getKeyInfoResolver() const
225 return m_keyInfoResolver;
228 ReplayCache* XMLToolingConfig::getReplayCache() const
230 return m_replayCache;
233 void XMLToolingConfig::setKeyInfoResolver(xmltooling::KeyInfoResolver *keyInfoResolver)
235 delete m_keyInfoResolver;
236 m_keyInfoResolver = keyInfoResolver;
239 void XMLToolingConfig::setReplayCache(ReplayCache* replayCache)
241 delete m_replayCache;
242 m_replayCache = replayCache;
246 PathResolver* XMLToolingConfig::getPathResolver() const
248 return m_pathResolver;
251 TemplateEngine* XMLToolingConfig::getTemplateEngine() const
253 return m_templateEngine;
256 const URLEncoder* XMLToolingConfig::getURLEncoder() const
261 void XMLToolingConfig::setPathResolver(PathResolver* pathResolver)
263 delete m_pathResolver;
264 m_pathResolver = pathResolver;
267 void XMLToolingConfig::setTemplateEngine(TemplateEngine* templateEngine)
269 delete m_templateEngine;
270 m_templateEngine = templateEngine;
273 void XMLToolingConfig::setURLEncoder(URLEncoder* urlEncoder)
276 m_urlEncoder = urlEncoder;
279 XMLToolingInternalConfig::XMLToolingInternalConfig() :
280 #ifndef XMLTOOLING_NO_XMLSEC
281 m_xsecProvider(nullptr),
283 m_initCount(0), m_lock(Mutex::create()), m_parserPool(nullptr), m_validatingPool(nullptr)
287 XMLToolingInternalConfig::~XMLToolingInternalConfig()
292 bool XMLToolingInternalConfig::log_config(const char* config)
295 if (!config || !*config)
296 config=getenv("XMLTOOLING_LOG_CONFIG");
297 if (!config || !*config)
301 Category& root = Category::getRoot();
302 if (!strcmp(config,"DEBUG")) {
303 root.setPriority(Priority::DEBUG);
306 else if (!strcmp(config,"INFO")) {
307 root.setPriority(Priority::INFO);
310 else if (!strcmp(config,"NOTICE")) {
311 root.setPriority(Priority::NOTICE);
314 else if (!strcmp(config,"WARN")) {
315 root.setPriority(Priority::WARN);
318 else if (!strcmp(config,"ERROR")) {
319 root.setPriority(Priority::ERROR);
322 else if (!strcmp(config,"CRIT")) {
323 root.setPriority(Priority::CRIT);
326 else if (!strcmp(config,"ALERT")) {
327 root.setPriority(Priority::ALERT);
330 else if (!strcmp(config,"EMERG")) {
331 root.setPriority(Priority::EMERG);
334 else if (!strcmp(config,"FATAL")) {
335 root.setPriority(Priority::FATAL);
339 root.setAppender(new OstreamAppender("default",&cerr));
343 PropertyConfigurator::configure(m_pathResolver ? m_pathResolver->resolve(path, PathResolver::XMLTOOLING_CFG_FILE) : path);
346 #ifndef XMLTOOLING_NO_XMLSEC
347 Category::getInstance(XMLTOOLING_LOGCAT".Signature.Debugger").setAdditivity(false);
350 catch (const ConfigureFailure& e) {
351 string msg = string("failed to configure logging: ") + e.what();
352 Category::getInstance(XMLTOOLING_LOGCAT".Logging").crit(msg);
354 LogEvent(nullptr, EVENTLOG_ERROR_TYPE, 2100, nullptr, msg.c_str());
362 bool XMLToolingInternalConfig::init()
365 xmltooling::NDC ndc("init");
367 Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Config");
369 Lock initLock(m_lock);
371 if (m_initCount == INT_MAX) {
372 log.crit("library initialized too many times");
376 if (m_initCount >= 1) {
382 log.debug("library initialization started");
384 #ifndef XMLTOOLING_NO_XMLSEC
385 if (curl_global_init(CURL_GLOBAL_ALL)) {
386 log.fatal("failed to initialize libcurl, OpenSSL, or Winsock");
389 curl_version_info_data* curlver = curl_version_info(CURLVERSION_NOW);
391 log.debug("libcurl %s initialization complete", curlver->version);
392 if (!(curlver->features & CURL_VERSION_SSL)) {
393 log.warn("libcurl lacks TLS/SSL support, this will greatly limit functionality");
397 log.debug("libcurl %s initialization complete", LIBCURL_VERSION);
401 XMLPlatformUtils::Initialize();
402 log.debug("Xerces %s initialization complete", XERCES_FULLVERSIONDOT);
404 #ifndef XMLTOOLING_NO_XMLSEC
405 XSECPlatformUtils::Initialise();
406 # ifdef XMLTOOLING_XMLSEC_DEBUGLOGGING
407 XSECPlatformUtils::SetReferenceLoggingSink(TXFMOutputLogFactory);
409 m_xsecProvider=new XSECProvider();
410 log.debug("XML-Security %s initialization complete", XSEC_FULLVERSIONDOT);
413 m_parserPool=new ParserPool();
414 m_validatingPool=new ParserPool(true,true);
416 // Load catalogs from path.
417 if (!catalog_path.empty()) {
418 char* catpath=strdup(catalog_path.c_str());
421 while (start && *start) {
422 sep=strchr(start,PATH_SEPARATOR_CHAR);
425 auto_ptr_XMLCh temp(start);
426 m_validatingPool->loadCatalog(temp.get());
427 start = sep ? sep + 1 : nullptr;
432 // default registrations
433 XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
435 registerSOAPClasses();
437 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(XMLParserException,xmltooling);
438 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(XMLObjectException,xmltooling);
439 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(MarshallingException,xmltooling);
440 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(UnmarshallingException,xmltooling);
441 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(UnknownElementException,xmltooling);
442 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(UnknownAttributeException,xmltooling);
443 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ValidationException,xmltooling);
444 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(IOException,xmltooling);
446 #ifndef XMLTOOLING_NO_XMLSEC
447 XMLObjectBuilder::registerBuilder(QName(xmlconstants::XMLSIG_NS,Signature::LOCAL_NAME),new SignatureBuilder());
448 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(XMLSecurityException,xmltooling);
449 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(SignatureException,xmlsignature);
450 REGISTER_XMLTOOLING_EXCEPTION_FACTORY(EncryptionException,xmlencryption);
451 registerKeyInfoClasses();
452 registerEncryptionClasses();
453 registerKeyInfoResolvers();
454 registerCredentialResolvers();
455 registerTrustEngines();
456 registerXMLAlgorithms();
457 registerSOAPTransports();
458 initSOAPTransports();
459 registerStorageServices();
460 m_keyInfoResolver = KeyInfoResolverManager.newPlugin(INLINE_KEYINFO_RESOLVER,nullptr);
463 m_pathResolver = new PathResolver();
464 m_urlEncoder = new URLEncoder();
466 HTTPResponse::getAllowedSchemes().push_back("https");
467 HTTPResponse::getAllowedSchemes().push_back("http");
469 // Register xml:id as an ID attribute.
470 static const XMLCh xmlid[] = UNICODE_LITERAL_2(i,d);
471 AttributeExtensibleXMLObject::registerIDAttribute(QName(xmlconstants::XML_NS, xmlid));
473 catch (const xercesc::XMLException&) {
474 log.fatal("caught exception while initializing Xerces");
475 #ifndef XMLTOOLING_NO_XMLSEC
476 curl_global_cleanup();
481 #ifndef XMLTOOLING_NO_XMLSEC
482 // Set up OpenSSL locking.
483 for (int i=0; i<CRYPTO_num_locks(); i++)
484 g_openssl_locks.push_back(Mutex::create());
485 CRYPTO_set_locking_callback(openssl_locking_callback);
487 CRYPTO_set_id_callback(openssl_thread_id);
491 log.info("%s library initialization complete", PACKAGE_STRING);
496 void XMLToolingInternalConfig::term()
499 xmltooling::NDC ndc("term");
502 Lock initLock(m_lock);
503 if (m_initCount == 0) {
504 Category::getInstance(XMLTOOLING_LOGCAT".Config").crit("term without corresponding init");
507 else if (--m_initCount > 0) {
511 #ifndef XMLTOOLING_NO_XMLSEC
512 CRYPTO_set_locking_callback(nullptr);
513 for_each(g_openssl_locks.begin(), g_openssl_locks.end(), xmltooling::cleanup<Mutex>());
514 g_openssl_locks.clear();
517 SchemaValidators.destroyValidators();
518 XMLObjectBuilder::destroyBuilders();
519 XMLToolingException::deregisterFactories();
520 AttributeExtensibleXMLObject::deregisterIDAttributes();
522 #ifndef XMLTOOLING_NO_XMLSEC
523 StorageServiceManager.deregisterFactories();
524 termSOAPTransports();
525 SOAPTransportManager.deregisterFactories();
526 TrustEngineManager.deregisterFactories();
527 CredentialResolverManager.deregisterFactories();
528 KeyInfoResolverManager.deregisterFactories();
529 m_algorithmMap.clear();
531 delete m_keyInfoResolver;
532 m_keyInfoResolver = nullptr;
534 delete m_replayCache;
535 m_replayCache = nullptr;
538 delete m_pathResolver;
539 m_pathResolver = nullptr;
541 delete m_templateEngine;
542 m_templateEngine = nullptr;
545 m_urlEncoder = nullptr;
547 for (vector<void*>::reverse_iterator i=m_libhandles.rbegin(); i!=m_libhandles.rend(); i++) {
549 FARPROC fn=GetProcAddress(static_cast<HMODULE>(*i),"xmltooling_extension_term");
552 FreeLibrary(static_cast<HMODULE>(*i));
553 #elif defined(HAVE_DLFCN_H)
554 void (*fn)()=(void (*)())dlsym(*i,"xmltooling_extension_term");
559 # error "Don't know about dynamic loading on this platform!"
562 m_libhandles.clear();
565 m_parserPool=nullptr;
566 delete m_validatingPool;
567 m_validatingPool=nullptr;
569 #ifndef XMLTOOLING_NO_XMLSEC
570 delete m_xsecProvider;
571 m_xsecProvider=nullptr;
572 XSECPlatformUtils::Terminate();
575 XMLPlatformUtils::Terminate();
577 #ifndef XMLTOOLING_NO_XMLSEC
578 curl_global_cleanup();
580 Category::getInstance(XMLTOOLING_LOGCAT".Config").info("%s library shutdown complete", PACKAGE_STRING);
583 Lockable* XMLToolingInternalConfig::lock()
589 void XMLToolingInternalConfig::unlock()
594 bool XMLToolingInternalConfig::load_library(const char* path, void* context)
597 xmltooling::NDC ndc("LoadLibrary");
599 Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Config");
600 log.info("loading extension: %s", path);
604 string resolved(path);
605 m_pathResolver->resolve(resolved, PathResolver::XMLTOOLING_LIB_FILE);
608 HMODULE handle=nullptr;
609 for (string::iterator i = resolved.begin(); i != resolved.end(); ++i)
613 UINT em=SetErrorMode(SEM_FAILCRITICALERRORS);
615 handle=LoadLibraryEx(resolved.c_str(),nullptr,LOAD_WITH_ALTERED_SEARCH_PATH);
617 handle=LoadLibraryEx(resolved.c_str(),nullptr,0);
619 throw runtime_error(string("unable to load extension library: ") + resolved);
620 FARPROC fn=GetProcAddress(handle,"xmltooling_extension_init");
622 throw runtime_error(string("unable to locate xmltooling_extension_init entry point: ") + resolved);
623 if (reinterpret_cast<int(*)(void*)>(fn)(context)!=0)
624 throw runtime_error(string("detected error in xmltooling_extension_init: ") + resolved);
634 #elif defined(HAVE_DLFCN_H)
635 void* handle=dlopen(resolved.c_str(),RTLD_LAZY);
637 throw runtime_error(string("unable to load extension library '") + resolved + "': " + dlerror());
638 int (*fn)(void*)=(int (*)(void*))(dlsym(handle,"xmltooling_extension_init"));
642 string("unable to locate xmltooling_extension_init entry point in '") + resolved + "': " +
643 (dlerror() ? dlerror() : "unknown error")
648 throw runtime_error(string("detected error in xmltooling_extension_init in ") + resolved);
656 # error "Don't know about dynamic loading on this platform!"
658 m_libhandles.push_back(handle);
659 log.info("loaded extension: %s", resolved.c_str());
663 #ifndef XMLTOOLING_NO_XMLSEC
665 void xmltooling::log_openssl()
671 unsigned long code=ERR_get_error_line_data(&file,&line,&data,&flags);
673 Category& log=Category::getInstance("OpenSSL");
674 log.errorStream() << "error code: " << code << " in " << file << ", line " << line << logging::eol;
675 if (data && (flags & ERR_TXT_STRING))
676 log.errorStream() << "error data: " << data << logging::eol;
677 code=ERR_get_error_line_data(&file,&line,&data,&flags);
681 XSECCryptoX509CRL* XMLToolingInternalConfig::X509CRL() const
683 return new OpenSSLCryptoX509CRL();
686 pair<const char*,unsigned int> XMLToolingInternalConfig::mapXMLAlgorithmToKeyAlgorithm(const XMLCh* xmlAlgorithm) const
688 for (algmap_t::const_iterator i = m_algorithmMap.begin(); i != m_algorithmMap.end(); ++i) {
689 algmap_t::value_type::second_type::const_iterator j = i->second.find(xmlAlgorithm);
690 if (j != i->second.end())
691 return pair<const char*,unsigned int>(j->second.first.c_str(), j->second.second);
693 return pair<const char*,unsigned int>(nullptr, 0);
696 void XMLToolingInternalConfig::registerXMLAlgorithm(
697 const XMLCh* xmlAlgorithm, const char* keyAlgorithm, unsigned int size, XMLSecurityAlgorithmType type
700 m_algorithmMap[type][xmlAlgorithm] = pair<string,unsigned int>((keyAlgorithm ? keyAlgorithm : ""), size);
703 bool XMLToolingInternalConfig::isXMLAlgorithmSupported(const XMLCh* xmlAlgorithm, XMLSecurityAlgorithmType type)
706 // First check for basic support from the xmlsec layer.
707 if (XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(xmlAlgorithm)) {
708 // Make sure the algorithm is registered.
709 algmap_t::const_iterator i = m_algorithmMap.find(type);
710 if (i != m_algorithmMap.end()) {
711 algmap_t::value_type::second_type::const_iterator j = i->second.find(xmlAlgorithm);
712 if (j != i->second.end())
717 catch (XSECException&) {
722 void XMLToolingInternalConfig::registerXMLAlgorithms()
724 // The deal with all the macros is to try and figure out with no false positives whether
725 // the OpenSSL version *and* the XML-Security version support the algorithms.
727 // With ECDSA, XML-Security exports a public macro for OpenSSL's support, and any
728 // versions of XML-Security that didn't provide the macro don't handle ECDSA anyway.
730 // With AES, all supported XML-Security versions export a macro for OpenSSL's support.
732 // With SHA2, only the very latest XML-Security exports a macro, but all the versions
733 // will handle SHA2 *if* OpenSSL does. So we use our own macro to check OpenSSL's
734 // support, and then add checks to see if specific versions are compiled out.
736 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIMD5, nullptr, 0, ALGTYPE_DIGEST);
737 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURISHA1, nullptr, 0, ALGTYPE_DIGEST);
738 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA256)
739 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURISHA224, nullptr, 0, ALGTYPE_DIGEST);
740 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURISHA256, nullptr, 0, ALGTYPE_DIGEST);
742 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA512)
743 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURISHA384, nullptr, 0, ALGTYPE_DIGEST);
744 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURISHA512, nullptr, 0, ALGTYPE_DIGEST);
747 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIDSA_SHA1, "DSA", 0, ALGTYPE_SIGN);
748 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_MD5, "RSA", 0, ALGTYPE_SIGN);
749 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_SHA1, "RSA", 0, ALGTYPE_SIGN);
750 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA256)
751 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_SHA224, "RSA", 0, ALGTYPE_SIGN);
752 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_SHA256, "RSA", 0, ALGTYPE_SIGN);
754 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA512)
755 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_SHA384, "RSA", 0, ALGTYPE_SIGN);
756 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_SHA512, "RSA", 0, ALGTYPE_SIGN);
759 #ifdef XSEC_OPENSSL_HAVE_EC
760 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIECDSA_SHA1, "EC", 0, ALGTYPE_SIGN);
761 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA256)
762 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIECDSA_SHA256, "EC", 0, ALGTYPE_SIGN);
764 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA512)
765 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIECDSA_SHA384, "EC", 0, ALGTYPE_SIGN);
766 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIECDSA_SHA512, "EC", 0, ALGTYPE_SIGN);
770 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIHMAC_SHA1, "HMAC", 0, ALGTYPE_SIGN);
771 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA256)
772 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIHMAC_SHA224, "HMAC", 0, ALGTYPE_SIGN);
773 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIHMAC_SHA256, "HMAC", 0, ALGTYPE_SIGN);
775 #if defined(XMLTOOLING_OPENSSL_HAVE_SHA2) && !defined(OPENSSL_NO_SHA512)
776 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIHMAC_SHA384, "HMAC", 0, ALGTYPE_SIGN);
777 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIHMAC_SHA512, "HMAC", 0, ALGTYPE_SIGN);
780 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_1_5, "RSA", 0, ALGTYPE_KEYENCRYPT);
781 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1, "RSA", 0, ALGTYPE_KEYENCRYPT);
783 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURI3DES_CBC, "DESede", 192, ALGTYPE_ENCRYPT);
784 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIKW_3DES, "DESede", 192, ALGTYPE_KEYENCRYPT);
786 #ifdef XSEC_OPENSSL_HAVE_AES
787 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIAES128_CBC, "AES", 128, ALGTYPE_ENCRYPT);
788 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIKW_AES128, "AES", 128, ALGTYPE_KEYENCRYPT);
790 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIAES192_CBC, "AES", 192, ALGTYPE_ENCRYPT);
791 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIKW_AES192, "AES", 192, ALGTYPE_KEYENCRYPT);
793 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIAES256_CBC, "AES", 256, ALGTYPE_ENCRYPT);
794 registerXMLAlgorithm(DSIGConstants::s_unicodeStrURIKW_AES256, "AES", 256, ALGTYPE_KEYENCRYPT);
802 extern "C" __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
804 if (fdwReason == DLL_THREAD_DETACH || fdwReason == DLL_PROCESS_DETACH)
805 ThreadKey::onDetach();