X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2FSAMLConfig.cpp;h=12e60e1d706811ffbfa7204b3cd5f247b4eccfb9;hb=840b05eda26529a8c06790960bbb227162523309;hp=66f8b8ac3544619b8e5e9d3963af2b71960bfc5b;hpb=d8a4f024b89272eae00618fc39e6127b6c191edd;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/SAMLConfig.cpp b/saml/SAMLConfig.cpp index 66f8b8a..12e60e1 100644 --- a/saml/SAMLConfig.cpp +++ b/saml/SAMLConfig.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -217,29 +218,7 @@ XMLCh* SAMLInternalConfig::generateIdentifier() string SAMLInternalConfig::hashSHA1(const char* s, bool toHex) { - static char DIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - auto_ptr hasher(XSECPlatformUtils::g_cryptoProvider->hashSHA1()); - if (hasher.get()) { - unsigned char buf[21]; - hasher->hash(reinterpret_cast(const_cast(s)),strlen(s)); - if (hasher->finish(buf,20)==20) { - string ret; - if (toHex) { - for (unsigned int i=0; i<20; i++) { - ret+=(DIGITS[((unsigned char)(0xF0 & buf[i])) >> 4 ]); - ret+=(DIGITS[0x0F & buf[i]]); - } - } - else { - for (unsigned int i=0; i<20; i++) { - ret+=buf[i]; - } - } - return ret; - } - } - throw XMLSecurityException("Unable to generate SHA-1 hash."); + return SecurityHelper::doHash("SHA1", s, strlen(s), toHex); } SignableObject::SignableObject()