You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by sc...@apache.org on 2017/12/05 19:27:33 UTC

svn commit: r1817224 - in /santuario/xml-security-cpp/trunk/xsec: dsig/ tools/cipher/ tools/xtest/ utils/ xenc/ xenc/impl/

Author: scantor
Date: Tue Dec  5 19:27:33 2017
New Revision: 1817224

URL: http://svn.apache.org/viewvc?rev=1817224&view=rev
Log:
Eliminate legacy encryptionMethod enum.

Modified:
    santuario/xml-security-cpp/trunk/xsec/dsig/DSIGConstants.hpp
    santuario/xml-security-cpp/trunk/xsec/tools/cipher/cipher.cpp
    santuario/xml-security-cpp/trunk/xsec/tools/xtest/xtest.cpp
    santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.cpp
    santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.hpp
    santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipher.hpp
    santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipherData.hpp
    santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.cpp
    santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.hpp
    santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.cpp
    santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.hpp

Modified: santuario/xml-security-cpp/trunk/xsec/dsig/DSIGConstants.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/dsig/DSIGConstants.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/dsig/DSIGConstants.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/dsig/DSIGConstants.hpp Tue Dec  5 19:27:33 2017
@@ -210,28 +210,6 @@ enum xpathFilterType {
 
 };
 
-enum encryptionMethod {
-
-	ENCRYPT_NONE			= 0,				// No method defined
-	ENCRYPT_3DES_CBC		= 1,				// Use 3DES
-	ENCRYPT_AES128_CBC		= 2,				// 128 bit AES in CBC mode
-	ENCRYPT_AES192_CBC		= 3,				// 192 bit AES in CBC mode
-	ENCRYPT_AES256_CBC		= 4,				// 256 bit AES in CBC mode
-	ENCRYPT_KW_AES128		= 5,				// KeyWrap - AES128
-	ENCRYPT_KW_AES192		= 6,				// KeyWrap - AES192
-	ENCRYPT_KW_AES256		= 7,				// KeyWrap - AES256
-	ENCRYPT_KW_3DES			= 8,
-	ENCRYPT_RSA_15			= 9,				// RSA with PKCS 1.5 padding
-	ENCRYPT_RSA_OAEP_MGFP1	= 10,				// RSA with OAEP and MGFP1
-    ENCRYPT_RSA_OAEP	    = 11,				// RSA with OAEP
-	ENCRYPT_AES128_GCM		= 12,				// 128 bit AES in GCM
-    ENCRYPT_AES192_GCM		= 13,				// 192 bit AES in GCM
-	ENCRYPT_AES256_GCM		= 14,				// 256 bit AES in GCM
-	ENCRYPT_KW_AES128_PAD	= 15,				// KeyWrap - AES128 with padding
-	ENCRYPT_KW_AES192_PAD	= 16,				// KeyWrap - AES192 with padding
-	ENCRYPT_KW_AES256_PAD	= 17				// KeyWrap - AES256 with padding
-};
-
 enum maskGenerationFunc {
     MGF_NONE                = 0,                // No MGF defined
     MGF1_SHA1               = 1,                // MGF1-SHA1
@@ -410,106 +388,6 @@ bool hashMethod2URI(safeBuffer &uri, has
 		return false;
 
 	}
-
-	return true;
-
-}
-
-inline
-bool encryptionMethod2URI(safeBuffer &uri, encryptionMethod em) {
-
-	switch (em) {
-
-	case (ENCRYPT_3DES_CBC) :
-
-		uri = URI_ID_3DES_CBC;
-		break;
-
-	case (ENCRYPT_AES128_CBC) :
-
-		uri = URI_ID_AES128_CBC;
-		break;
-
-	case (ENCRYPT_AES192_CBC) :
-
-		uri = URI_ID_AES192_CBC;
-		break;
-
-	case (ENCRYPT_AES256_CBC) :
-
-		uri = URI_ID_AES256_CBC;
-		break;
-
-	case (ENCRYPT_KW_AES128) :
-
-		uri = URI_ID_KW_AES128;
-		break;
-
-	case (ENCRYPT_KW_AES192) :
-
-		uri = URI_ID_KW_AES192;
-		break;
-
-	case (ENCRYPT_KW_AES256) :
-
-		uri = URI_ID_KW_AES256;
-		break;
-
-	case (ENCRYPT_KW_3DES) :
-
-		uri = URI_ID_KW_3DES;
-		break;
-
-	case (ENCRYPT_RSA_15) :
-
-		uri = URI_ID_RSA_1_5;
-		break;
-
-	case (ENCRYPT_RSA_OAEP_MGFP1) :
-
-		uri = URI_ID_RSA_OAEP_MGFP1;
-		break;
-
-	case (ENCRYPT_RSA_OAEP) :
-
-		uri = URI_ID_RSA_OAEP;
-		break;
-
-	case (ENCRYPT_AES128_GCM) :
-
-		uri = URI_ID_AES128_GCM;
-		break;
-
-	case (ENCRYPT_AES192_GCM) :
-
-		uri = URI_ID_AES192_GCM;
-		break;
-
-    case (ENCRYPT_AES256_GCM) :
-
-		uri = URI_ID_AES256_GCM;
-		break;
-
-	case (ENCRYPT_KW_AES128_PAD) :
-
-		uri = URI_ID_KW_AES128_PAD;
-		break;
-
-	case (ENCRYPT_KW_AES192_PAD) :
-
-		uri = URI_ID_KW_AES192_PAD;
-		break;
-
-	case (ENCRYPT_KW_AES256_PAD) :
-
-		uri = URI_ID_KW_AES256_PAD;
-		break;
-
-    default:
-
-		return false;
-
-	}
 
 	return true;
 

Modified: santuario/xml-security-cpp/trunk/xsec/tools/cipher/cipher.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/tools/cipher/cipher.cpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/tools/cipher/cipher.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/tools/cipher/cipher.cpp Tue Dec  5 19:27:33 2017
@@ -226,8 +226,8 @@ int evaluate(int argc, char ** argv) {
     XSECCryptoKey           * kek = NULL;
     XSECCryptoKey           * key = NULL;
     int                     keyLen = 0;
-    encryptionMethod        kekAlg = ENCRYPT_NONE;
-    encryptionMethod        keyAlg = ENCRYPT_NONE;
+    const XMLCh*            kekAlg = NULL;
+    const XMLCh*            keyAlg = NULL;
     DOMDocument             *doc;
     unsigned char           keyBuf[24];
     XMLFormatTarget         *formatTarget ;
@@ -345,45 +345,45 @@ int evaluate(int argc, char ** argv) {
                 case '\0' :
                     keyLen = 24;
                     loadKeyAs = XSECCryptoSymmetricKey::KEY_3DES_192;
-                    keyAlg = ENCRYPT_3DES_CBC;
+                    keyAlg = DSIGConstants::s_unicodeStrURI3DES_CBC;
                     break;
                 case '2' :
                     keyLen = 16;
                     loadKeyAs = XSECCryptoSymmetricKey::KEY_AES_128;
                     if (isKEK) {
-                        kekAlg = ENCRYPT_KW_AES128;
+                        kekAlg = DSIGConstants::s_unicodeStrURIKW_AES128;
                     }
                     else if (strlen(argv[paramCount]) == 6) {
-                        keyAlg = ENCRYPT_AES128_CBC;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES128_CBC;
                     }
                     else {
-                        keyAlg = ENCRYPT_AES128_GCM;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES128_GCM;
                     }
                     break;
                 case '9' :
                     keyLen = 24;
                     loadKeyAs = XSECCryptoSymmetricKey::KEY_AES_192;
                     if (isKEK) {
-                        kekAlg = ENCRYPT_KW_AES192;
+                        kekAlg = DSIGConstants::s_unicodeStrURIKW_AES192;
                     }
                     else if (strlen(argv[paramCount]) == 6) {
-                        keyAlg = ENCRYPT_AES192_CBC;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES192_CBC;
                     }
                     else {
-                        keyAlg = ENCRYPT_AES192_GCM;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES192_GCM;
                     }
                     break;
                 case '5' :
                     keyLen = 32;
                     loadKeyAs = XSECCryptoSymmetricKey::KEY_AES_256;
                     if (isKEK) {
-                        kekAlg = ENCRYPT_KW_AES256;
+                        kekAlg = DSIGConstants::s_unicodeStrURIKW_AES256;
                     }
                     else if (strlen(argv[paramCount]) == 6) {
-                        keyAlg = ENCRYPT_AES256_CBC;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES256_CBC;
                     }
                     else {
-                        keyAlg = ENCRYPT_AES256_GCM;
+                        keyAlg = DSIGConstants::s_unicodeStrURIAES256_GCM;
                     }
                     break;
                 }
@@ -462,7 +462,7 @@ int evaluate(int argc, char ** argv) {
                 }
 
                 kek = new OpenSSLCryptoKeyRSA(pkey);
-                kekAlg = ENCRYPT_RSA_15;
+                kekAlg = DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1;
                 EVP_PKEY_free(pkey);
                 BIO_free(bioKey);
                 paramCount += 3;
@@ -531,7 +531,7 @@ int evaluate(int argc, char ** argv) {
                 }
 
                 kek = new OpenSSLCryptoKeyRSA(pkey);
-                kekAlg = ENCRYPT_RSA_15;
+                kekAlg = DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1;
 
                 // Clean up
 
@@ -729,7 +729,7 @@ int evaluate(int argc, char ** argv) {
                     XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_3DES_192);
                 k->setKey(keyBuf, 24);
                 cipher->setKey(k);
-                keyAlg = ENCRYPT_3DES_CBC;
+                keyAlg = DSIGConstants::s_unicodeStrURI3DES_CBC;
                 keyStr = keyBuf;
                 keyLen = 24;
             }

Modified: santuario/xml-security-cpp/trunk/xsec/tools/xtest/xtest.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/tools/xtest/xtest.cpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/tools/xtest/xtest.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/tools/xtest/xtest.cpp Tue Dec  5 19:27:33 2017
@@ -133,6 +133,7 @@ bool	 g_useWinCAPI = false;
 bool	 g_useNSS = false;
 bool g_haveAES = true;
 
+
 // --------------------------------------------------------------------------------
 //           Known "Good" Values
 // --------------------------------------------------------------------------------
@@ -994,33 +995,6 @@ void unitTestRSASig(DOMImplementation *
 
 		cerr << "OK";
 
-#if 0
-#if defined XSEC_HAVE_OPENSSL
-
-		if (g_useWinCAPI || g_useNSS) {
-
-			cerr << " ... validate against OpenSSL" << endl;
-
-			BIO * bioMem = BIO_new(BIO_s_mem());
-			BIO_puts(bioMem, s_tstRSAPrivateKey);
-			EVP_PKEY * pk = PEM_read_bio_PrivateKey(bioMem, NULL, NULL, NULL);
-
-			OpenSSLCryptoKeyRSA * rsaKey = new OpenSSLCryptoKeyRSA(pk);
-
-			sig->setSigningKey(rsaKey);
-			if (!sig->verify()) {
-				cerr << "bad verify!" << endl;
-				exit (1);
-			}
-
-			cerr << "OK";
-
-			BIO_free(bioMem);
-			EVP_PKEY_free(pk);
-		}
-#endif
-#endif
-
 		cerr << "\n";	
 
 		outputDoc(impl, doc);
@@ -1649,7 +1623,7 @@ void unitTestCipherReference(DOMImplemen
 }
 
 
-void unitTestElementContentEncrypt(DOMImplementation *impl, XSECCryptoKey * key, encryptionMethod em, bool doElementContent) {
+void unitTestElementContentEncrypt(DOMImplementation *impl, XSECCryptoKey * key, const XMLCh* algorithm, bool doElementContent) {
 
 	if (doElementContent)
 		cerr << "Encrypting Element Content ... ";
@@ -1688,9 +1662,9 @@ void unitTestElementContentEncrypt(DOMIm
 	
 		// Now encrypt!
 		if (doElementContent)
-			cipher->encryptElementContent(doc->getDocumentElement(), em);
+			cipher->encryptElementContent(doc->getDocumentElement(), algorithm);
 		else
-			cipher->encryptElement((DOMElement *) categoryNode, em);
+			cipher->encryptElement((DOMElement *) categoryNode, algorithm);
 
 		cerr << "done ... check encrypted ... ";
 
@@ -1798,7 +1772,7 @@ void unitTestSmallElement(DOMImplementat
 		cipher->setKey(ks->clone());
 	
 		// Now encrypt!
-		cipher->encryptElementContent(productNode, ENCRYPT_3DES_CBC);
+		cipher->encryptElementContent(productNode, DSIGConstants::s_unicodeStrURI3DES_CBC);
 
 		cerr << "done ... check encrypted ... ";
 
@@ -1866,7 +1840,7 @@ void unitTestSmallElement(DOMImplementat
 }
 
 
-void unitTestKeyEncrypt(DOMImplementation *impl, XSECCryptoKey * k, encryptionMethod em) {
+void unitTestKeyEncrypt(DOMImplementation *impl, XSECCryptoKey * k, const XMLCh* algorithm) {
 
 	// Create a document that we will embed the encrypted key in
 	DOMDocument *doc = impl->createDocument(
@@ -1897,7 +1871,7 @@ void unitTestKeyEncrypt(DOMImplementatio
 		cipher->setKEK(k);
 
 		XENCEncryptedKey * encryptedKey;
-		encryptedKey = cipher->encryptKey(toEncryptStr, (unsigned int) strlen((char *) toEncryptStr), em);
+		encryptedKey = cipher->encryptKey(toEncryptStr, (unsigned int) strlen((char *) toEncryptStr), algorithm);
 		Janitor<XENCEncryptedKey> j_encryptedKey(encryptedKey);
 
 		rootElem->appendChild(encryptedKey->getElement());
@@ -1979,17 +1953,20 @@ void unitTestEncrypt(DOMImplementation *
 
 			OpenSSLCryptoKeyRSA * k = new OpenSSLCryptoKeyRSA(pk);
 
-			unitTestKeyEncrypt(impl, k, ENCRYPT_RSA_15);
+			unitTestKeyEncrypt(impl, k, DSIGConstants::s_unicodeStrURIRSA_1_5);
 
 			cerr << "RSA OAEP key wrap... ";
 			k = new OpenSSLCryptoKeyRSA(pk);
-			unitTestKeyEncrypt(impl, k, ENCRYPT_RSA_OAEP_MGFP1);
+			unitTestKeyEncrypt(impl, k, DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1);
 
 			cerr << "RSA OAEP key wrap + params... ";
 			k = new OpenSSLCryptoKeyRSA(pk);
 			k->setOAEPparams(s_tstOAEPparams, (unsigned int) strlen((char *) s_tstOAEPparams));
+			unitTestKeyEncrypt(impl, k, DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1);
 
-			unitTestKeyEncrypt(impl, k, ENCRYPT_RSA_OAEP_MGFP1);
+            cerr << "RSA OAEP 1.1 key wrap... ";
+            k = new OpenSSLCryptoKeyRSA(pk);
+            unitTestKeyEncrypt(impl, k, DSIGConstants::s_unicodeStrURIRSA_OAEP);
 
 			BIO_free(bioMem);
 			EVP_PKEY_free(pk);
@@ -2004,12 +1981,16 @@ void unitTestEncrypt(DOMImplementation *
 			HCRYPTPROV p = cp->getApacheKeyStore();
 			
 			WinCAPICryptoKeyRSA * rsaKey = new WinCAPICryptoKeyRSA(p, AT_KEYEXCHANGE, true);
-			unitTestKeyEncrypt(impl, rsaKey, ENCRYPT_RSA_15);
+			unitTestKeyEncrypt(impl, rsaKey, DSIGConstants::s_unicodeStrURIRSA_1_5);
 
 			cerr << "RSA OAEP key wrap... ";
 			rsaKey = new WinCAPICryptoKeyRSA(p, AT_KEYEXCHANGE, true);
-			unitTestKeyEncrypt(impl, rsaKey, ENCRYPT_RSA_OAEP_MGFP1);
-		}
+			unitTestKeyEncrypt(impl, rsaKey, DSIGConstants::s_unicodeStrURIRSA_OAEP_MGFP1);
+
+            cerr << "RSA OAEP 1.1 key wrap... ";
+            rsaKey = new WinCAPICryptoKeyRSA(p, AT_KEYEXCHANGE, true);
+            unitTestKeyEncrypt(impl, rsaKey, DSIGConstants::s_unicodeStrURIRSA_OAEP);
+        }
 
 #endif
 
@@ -2045,7 +2026,7 @@ void unitTestEncrypt(DOMImplementation *
 
 			// Now use the key!
 			NSSCryptoKeyRSA * rsaKey = new NSSCryptoKeyRSA(pubKey, prvKey);
-			unitTestKeyEncrypt(impl, rsaKey, ENCRYPT_RSA_15);
+			unitTestKeyEncrypt(impl, rsaKey, DSIGConstants::s_unicodeStrURIRSA_1_5);
 
 			if (slot) 
 				// Actual keys will be deleted by the provider
@@ -2064,21 +2045,21 @@ void unitTestEncrypt(DOMImplementation *
 			ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_128);
 			ks->setKey((unsigned char *) s_keyStr, 16);
 		
-			unitTestKeyEncrypt(impl, ks, ENCRYPT_KW_AES128);
+			unitTestKeyEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIKW_AES128);
 
 			cerr << "AES 192 key wrap... ";
 
 			ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_192);
 			ks->setKey((unsigned char *) s_keyStr, 24);
 		
-			unitTestKeyEncrypt(impl, ks, ENCRYPT_KW_AES192);
+			unitTestKeyEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIKW_AES192);
 
 			cerr << "AES 256 key wrap... ";
 
 			ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_256);
 			ks->setKey((unsigned char *) s_keyStr, 32);
 		
-			unitTestKeyEncrypt(impl, ks, ENCRYPT_KW_AES256);
+			unitTestKeyEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIKW_AES256);
 		}
 
 		else 
@@ -2089,7 +2070,7 @@ void unitTestEncrypt(DOMImplementation *
 		ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_3DES_192);
 		ks->setKey((unsigned char *) s_keyStr, 24);
 		
-		unitTestKeyEncrypt(impl, ks, ENCRYPT_KW_3DES);
+		unitTestKeyEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIKW_3DES);
 
 		// Now do Element encrypts
 
@@ -2099,24 +2080,24 @@ void unitTestEncrypt(DOMImplementation *
 			ks->setKey((unsigned char *) s_keyStr, 16);
 
 			cerr << "Unit testing AES 128 bit CBC encryption" << endl;
-			unitTestElementContentEncrypt(impl, ks->clone(), ENCRYPT_AES128_CBC, false);
-			unitTestElementContentEncrypt(impl, ks, ENCRYPT_AES128_CBC, true);
+			unitTestElementContentEncrypt(impl, ks->clone(), DSIGConstants::s_unicodeStrURIAES128_CBC, false);
+			unitTestElementContentEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIAES128_CBC, true);
 
 			//192 AES
 			ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_192);
 			ks->setKey((unsigned char *) s_keyStr, 24);
 
 			cerr << "Unit testing AES 192 bit CBC encryption" << endl;
-			unitTestElementContentEncrypt(impl, ks->clone(), ENCRYPT_AES192_CBC, false);
-			unitTestElementContentEncrypt(impl, ks, ENCRYPT_AES192_CBC, true);
+			unitTestElementContentEncrypt(impl, ks->clone(), DSIGConstants::s_unicodeStrURIAES192_CBC, false);
+			unitTestElementContentEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIAES192_CBC, true);
 
 		// 256 AES
 			ks = XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_256);
 			ks->setKey((unsigned char *) s_keyStr, 32);
 
 			cerr << "Unit testing AES 256 bit CBC encryption" << endl;
-			unitTestElementContentEncrypt(impl, ks->clone(), ENCRYPT_AES256_CBC, false);
-			unitTestElementContentEncrypt(impl, ks, ENCRYPT_AES256_CBC, true);
+			unitTestElementContentEncrypt(impl, ks->clone(), DSIGConstants::s_unicodeStrURIAES256_CBC, false);
+			unitTestElementContentEncrypt(impl, ks, DSIGConstants::s_unicodeStrURIAES256_CBC, true);
 		}
 
 		else
@@ -2127,8 +2108,8 @@ void unitTestEncrypt(DOMImplementation *
 		ks->setKey((unsigned char *) s_keyStr, 24);
 
 		cerr << "Unit testing 3DES CBC encryption" << endl;
-		unitTestElementContentEncrypt(impl, ks->clone(), ENCRYPT_3DES_CBC, false);
-		unitTestElementContentEncrypt(impl, ks, ENCRYPT_3DES_CBC, true);
+		unitTestElementContentEncrypt(impl, ks->clone(), DSIGConstants::s_unicodeStrURI3DES_CBC, false);
+		unitTestElementContentEncrypt(impl, ks, DSIGConstants::s_unicodeStrURI3DES_CBC, true);
 #ifdef XSEC_HAVE_XALAN
 		if (g_haveAES) {
 			cerr << "Unit testing CipherReference creation and decryption" << endl;
@@ -2205,7 +2186,7 @@ void testEncrypt(DOMImplementation *impl
 	
 		// Now encrypt!
 		cerr << "Performing 3DES encryption on <category> element ... ";
-		cipher->encryptElement((DOMElement *) categoryNode, ENCRYPT_3DES_CBC);
+		cipher->encryptElement((DOMElement *) categoryNode, DSIGConstants::s_unicodeStrURI3DES_CBC);
 
 		// Add a KeyInfo
 		cerr << "done\nAppending a <KeyName> ... ";
@@ -2253,9 +2234,9 @@ void testEncrypt(DOMImplementation *impl
 
 		XENCEncryptedKey * encryptedKey;
 		if (g_haveAES)
-			encryptedKey = cipher->encryptKey(randomBuffer, 24, ENCRYPT_KW_AES128);
+			encryptedKey = cipher->encryptKey(randomBuffer, 24, DSIGConstants::s_unicodeStrURIKW_AES128);
 		else
-			encryptedKey = cipher->encryptKey(randomBuffer, 24, ENCRYPT_KW_3DES);
+			encryptedKey = cipher->encryptKey(randomBuffer, 24, DSIGConstants::s_unicodeStrURIKW_3DES);
 		cerr << "done!" << endl;
 
 		cerr << "Adding CarriedKeyName and Recipient to encryptedKey ... " << endl;

Modified: santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.cpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.cpp Tue Dec  5 19:27:33 2017
@@ -150,7 +150,7 @@ int attNodeCount(DOMElement * d) {
 
 }
 
-void XSECNameSpaceExpander::expandNameSpaces(void) {
+void XSECNameSpaceExpander::expandNameSpaces() {
 
 	if (m_expanded)
 		return;				// Don't do this twice!
@@ -174,7 +174,7 @@ void XSECNameSpaceExpander::expandNameSp
 }
 
 
-void XSECNameSpaceExpander::deleteAddedNamespaces(void) {
+void XSECNameSpaceExpander::deleteAddedNamespaces() {
 
 	NameSpaceEntryListVectorType::size_type size = m_lst.size();
 	XSECNameSpaceEntry *e;
@@ -203,7 +203,7 @@ void XSECNameSpaceExpander::deleteAddedN
 
 }
 
-bool XSECNameSpaceExpander::nodeWasAdded(DOMNode *n) {
+bool XSECNameSpaceExpander::nodeWasAdded(DOMNode *n) const {
 
 	NameSpaceEntryListVectorType::size_type size = m_lst.size();
 	XSECNameSpaceEntry *e;

Modified: santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/utils/XSECNameSpaceExpander.hpp Tue Dec  5 19:27:33 2017
@@ -140,7 +140,7 @@ public:
 	 * Perform the expansion operation and create a list of all added nodes.
 	 */
 
-	void expandNameSpaces(void);
+	void expandNameSpaces();
 
 	/**
 	 * \brief Collapse name-spaces
@@ -149,14 +149,14 @@ public:
 	 * was created at that time
 	 */
 
-	void deleteAddedNamespaces(void);
+	void deleteAddedNamespaces();
 
 	// Check if a node is an added node
-	bool nodeWasAdded(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n);
+	bool nodeWasAdded(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n) const;
 
 private:  // Functions
 
-	XSECNameSpaceExpander(void);					// No default constructor
+	XSECNameSpaceExpander();					// No default constructor
 	void recurse(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *n);
 
 	// data

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipher.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipher.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipher.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipher.hpp Tue Dec  5 19:27:33 2017
@@ -150,7 +150,7 @@ public:
 	 * not a valid EncryptedData DOM structure.
 	 */
 
-	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * decryptElement(void) = 0;
+	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * decryptElement() = 0;
 
 	/**
 	 * \brief Decrypt currently loaded element without replacing it.
@@ -170,7 +170,7 @@ public:
 	 * not a valid EncryptedData DOM structure.
 	 */
 
-	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * decryptElementDetached(void) = 0;
+	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * decryptElementDetached() = 0;
 	
 	/**
 	 * \brief Decrypt the nominated element and put the output to an InputStream.
@@ -240,12 +240,7 @@ public:
 	 * is replaced with an EncryptedData element
 	 *
 	 * @param element Element (and children) to encrypt
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI If ENCRYPT_NONE is passed in, this will be
-	 * used to set the algorithm URI.  If this is also NULL - no
-	 * EncryptionMethod will be set.  <b>NULL Value Unsupported if em not
-	 * set!  It's use could cause problems!</b>
+	 * @param algorithmURI algorithm URI to set
 	 *
 	 * @returns The owning document with the element replaced, or NULL
 	 * if the decryption fails for some reason (normally an exception).
@@ -254,8 +249,7 @@ public:
 
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * encryptElement(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 
 	/**
@@ -266,21 +260,15 @@ public:
 	 * the passed in document and the original document is untouched.
 	 *
 	 * @param element Element (and children) to encrypt
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI If ENCRYPT_NONE is passed in, this will be
-	 * used to set the algorithm URI.  If this is also NULL - no
-	 * EncryptionMethod will be set.  <b>NULL Value Unsupported if em not
-	 * set!  It's use could cause problems!</b>
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns The resulting document fragment containing the encrypted data.
 	 * @throws XSECException if the encryption fails.
 	 */
 
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * encryptElementDetached(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 	
 	/**
@@ -291,13 +279,8 @@ public:
 	 * EncryptedData node of type #content
 	 *
 	 * @param element Element whose children are to be encrypted
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI If ENCRYPT_NONE is passed in, this will be
-	 * used to set the algorithm URI.  If this is also NULL - no
-	 * EncryptionMethod will be set.  <b>NULL Value Unsupported if em not
-	 * set!  It's use could cause problems!</b>
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns The owning document with the element's children replaced, or NULL
 	 * if the decryption fails for some reason (normally an exception).
 	 * @throws XSECException if the encryption fails.
@@ -305,8 +288,7 @@ public:
 
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * encryptElementContent(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 
 	/**
@@ -318,13 +300,8 @@ public:
 	 * data.
 	 *
 	 * @param element Element whose children are to be encrypted
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI If ENCRYPT_NONE is passed in, this will be
-	 * used to set the algorithm URI.  If this is also NULL - no
-	 * EncryptionMethod will be set.  <b>NULL Value Unsupported if em not
-	 * set!  It's use could cause problems!</b>
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns The resulting (orphaned) sub-tree from the passed in document
 	 * containing the encrypted data.
 	 * @throws XSECException if the encryption fails.
@@ -332,8 +309,7 @@ public:
 
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * encryptElementContentDetached(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 	
 	/**
@@ -343,19 +319,15 @@ public:
 	 *
 	 * @param keyBuffer The key data to encrypt
 	 * @param keyLen Bytes to encrypt
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI If ENCRYPT_NONE is used for em, this will be
-	 * used as the algorithm URI.
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns The EncryptedKey element
 	 */
 
 	virtual XENCEncryptedKey * encryptKey(
 		const unsigned char * keyBuffer,
 		unsigned int keyLen,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 
 	/**
@@ -365,18 +337,14 @@ public:
 	 * directly into a new EncryptedData element that contains a CipherValue
 	 *
 	 * @param plainText The InputStream to read the plain text from
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI if ENCRYPT_NONE is used for em, this will be used
-	 * as the algorithm URI
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns the EncryptedData element containing the CipherValue of the data
 	 */
 
 	virtual XENCEncryptedData * encryptBinInputStream(
 		XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream * plainText,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 
 	/**
@@ -389,18 +357,14 @@ public:
 	 * and is provided for flexibility.  The "formal" method is encryptBinInputStream
 	 *
 	 * @param plainText The TXFMChain to read the plain text from
-	 * @param em The encryptionMethod to use for this encryption.  Use
-	 * ENCRYPT_NONE if a user defined type is required.
-	 * @param algorithmURI if ENCRYPT_NONE is used for em, this will be used
-	 * as the algorithm URI
-	 *
+     * @param algorithmURI algorithm URI to set
+     *
 	 * @returns the EncryptedData element containing the CipherValue of the data
 	 */
 
 	virtual XENCEncryptedData * encryptTXFMChain(
 		TXFMChain * plainText,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	) = 0;
 
 	//@}
@@ -416,7 +380,7 @@ public:
 	 * @returns The DOMDocument that is used by this object
 	 */
 
-	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument(void) = 0;
+	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument() const = 0;
 
 	/**
 	 * \brief Get namespace prefix for XENC nodes
@@ -427,7 +391,7 @@ public:
 	 * @returns XENC namespace prefix
 	 */
 
-	virtual const XMLCh * getXENCNSPrefix(void) const = 0;
+	virtual const XMLCh * getXENCNSPrefix() const = 0;
 
 	/**
 	 * \brief Get the EncryptedData element
@@ -438,7 +402,7 @@ public:
 	 * @returns The last used EncryptedData
 	 */
 
-	virtual XENCEncryptedData * getEncryptedData(void) = 0;
+	virtual XENCEncryptedData * getEncryptedData() const = 0;
 
 	/**
 	 * \brief Tell caller whether PrettyPrinting is active
@@ -446,7 +410,7 @@ public:
 	 * @returns True if Pretty Printing is active, false if not
 	 */
 
-	virtual bool getPrettyPrint(void) = 0;
+	virtual bool getPrettyPrint() const = 0;
 
 	/**
 	 * \brief Tell caller whether the serialisation routines will
@@ -461,7 +425,7 @@ public:
 	 * @returns True if Exclusive c14n will be used, false if standard
 	 */
 
-	virtual bool getExclusiveC14nSerialisation(void) = 0;
+	virtual bool getExclusiveC14nSerialisation() const = 0;
 
 	//@}
 

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipherData.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipherData.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipherData.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/XENCCipherData.hpp Tue Dec  5 19:27:33 2017
@@ -106,7 +106,7 @@ public:
 	 * @returns The type of CipherData
 	 */
 
-	virtual XENCCipherDataType getCipherDataType(void) = 0;
+	virtual XENCCipherDataType getCipherDataType(void) const = 0;
 
 	/**
 	 * \brief Get the CipherValue element
@@ -114,7 +114,7 @@ public:
 	 * @returns the CipherValue element, or NULL if one is not held
 	 */
 
-	virtual XENCCipherValue * getCipherValue(void) = 0;
+	virtual XENCCipherValue * getCipherValue(void) const = 0;
 
 	/**
 	 * \brief Get the CipherReference element
@@ -122,7 +122,7 @@ public:
 	 * @returns the CipherReference element, or NULL if one is not held
 	 */
 
-	virtual XENCCipherReference * getCipherReference(void) = 0;
+	virtual XENCCipherReference * getCipherReference(void) const = 0;
 
 	/**
 	 * \brief Get the DOM Node of this structure
@@ -130,7 +130,7 @@ public:
 	 * @returns the DOM Node representing the \<CipherData\> element
 	 */
 
-	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) = 0;
+	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const = 0;
 
 	//@}
 

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.cpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.cpp Tue Dec  5 19:27:33 2017
@@ -242,19 +242,19 @@ DOMElement * XENCCipherDataImpl::createB
 // --------------------------------------------------------------------------------
 
 	// Interface methods
-XENCCipherDataImpl::XENCCipherDataType XENCCipherDataImpl::getCipherDataType(void) {
+XENCCipherDataImpl::XENCCipherDataType XENCCipherDataImpl::getCipherDataType(void) const {
 
 	return m_cipherDataType;
 
 }
 
-XENCCipherValue * XENCCipherDataImpl::getCipherValue(void) {
+XENCCipherValue * XENCCipherDataImpl::getCipherValue(void) const {
 
 	return mp_cipherValue;
 
 }
 
-XENCCipherReference * XENCCipherDataImpl::getCipherReference(void) {
+XENCCipherReference * XENCCipherDataImpl::getCipherReference(void) const {
 
 	return mp_cipherReference;
 

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherDataImpl.hpp Tue Dec  5 19:27:33 2017
@@ -61,10 +61,10 @@ public:
 
 
 	// Interface methods
-	virtual XENCCipherDataType getCipherDataType(void);
-	virtual XENCCipherValue * getCipherValue(void);
-	virtual XENCCipherReference * getCipherReference(void);
-	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void)
+	virtual XENCCipherDataType getCipherDataType(void) const;
+	virtual XENCCipherValue * getCipherValue(void) const;
+	virtual XENCCipherReference * getCipherReference(void) const;
+	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const
 		{return mp_cipherDataElement;}
 
 

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.cpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.cpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.cpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.cpp Tue Dec  5 19:27:33 2017
@@ -176,7 +176,7 @@ void XENCCipherImpl::setKeyInfoResolver(
 //			Key Info resolvers
 // --------------------------------------------------------------------------------
 
-XENCEncryptedData * XENCCipherImpl::getEncryptedData(void) {
+XENCEncryptedData * XENCCipherImpl::getEncryptedData() const {
 
     return mp_encryptedData;
 
@@ -442,7 +442,7 @@ DOMNode * XENCCipherImpl::decryptElement
 
 }
 
-DOMNode * XENCCipherImpl::decryptElementDetached(void) {
+DOMNode * XENCCipherImpl::decryptElementDetached() {
 
     XSECAlgorithmHandler *handler;
 
@@ -534,7 +534,7 @@ DOMNode * XENCCipherImpl::decryptElement
 
 }
 
-DOMDocument * XENCCipherImpl::decryptElement(void) {
+DOMDocument * XENCCipherImpl::decryptElement() {
 
     // Call the worker
     DOMElement * element = mp_encryptedData->getElement();
@@ -757,7 +757,6 @@ XENCEncryptedKey * XENCCipherImpl::loadE
 
 XENCEncryptedData * XENCCipherImpl::encryptBinInputStream(
     XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream * plainText,
-    encryptionMethod em,
     const XMLCh * algorithmURI) {
 
     TXFMURL * uri;
@@ -766,7 +765,7 @@ XENCEncryptedData * XENCCipherImpl::encr
     uri->setInput(plainText);
     TXFMChain c(uri);
 
-    return encryptTXFMChain(&c, em, algorithmURI);
+    return encryptTXFMChain(&c, algorithmURI);
 
 }
 
@@ -774,24 +773,14 @@ XENCEncryptedData * XENCCipherImpl::encr
 //			Encrypt a TXFMChain
 // --------------------------------------------------------------------------------
 
-XENCEncryptedData * XENCCipherImpl::encryptTXFMChain(TXFMChain * plainText, encryptionMethod em, const XMLCh * algorithmURI) {
+XENCEncryptedData * XENCCipherImpl::encryptTXFMChain(TXFMChain * plainText, const XMLCh * algorithmURI) {
 
     // Make sure we have a key before we do anything too drastic
     if (mp_key == NULL) {
-        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptElement - No key set");
+        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptTXFMChain - No key set");
     }
-
-    // Map the encryption method to a URI
-    safeBuffer algorithmSB;
-    const XMLCh * algorithm;
-
-    if (em == ENCRYPT_NONE) {
-        algorithm = algorithmURI;
-    } else {
-        if (encryptionMethod2URI(algorithmSB, em) != true) {
-            throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptElement - Unknown encryption method");
-        }
-        algorithm = algorithmSB.sbStrToXMLCh();
+    else if (algorithmURI == NULL) {
+        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptTXFMChain - No algorithm set");
     }
 
     // Create the element with a dummy encrypted value
@@ -802,39 +791,21 @@ XENCEncryptedData * XENCCipherImpl::encr
     }
 
     XSECnew(mp_encryptedData, XENCEncryptedDataImpl(mp_env));
-    mp_encryptedData->createBlankEncryptedData(XENCCipherData::VALUE_TYPE, algorithm, s_noData);
+    mp_encryptedData->createBlankEncryptedData(XENCCipherData::VALUE_TYPE, algorithmURI, s_noData);
 
     // Perform the encryption
-    XSECAlgorithmHandler *handler;
-
-    if (algorithm != NULL) {
-
-        handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithm);
-
-    }
-
-    else {
-
-        handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(XSECAlgorithmMapper::s_defaultEncryptionMapping);
-
-    }
-
-    safeBuffer sb;
-
-    if (handler != NULL) {
-
-        handler->encryptToSafeBuffer(plainText, mp_encryptedData->getEncryptionMethod(), mp_key, mp_env->getParentDocument(),
-            sb);
-    } else {
-
+    XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
+    if (!handler) {
         // Very strange if we get here - any problems should throw an
         // exception in the AlgorithmMapper.
 
         throw XSECException(XSECException::CipherError,
             "XENCCipherImpl::encryptTXFMChain - Error retrieving a handler for algorithm");
-
     }
 
+    safeBuffer sb;
+    handler->encryptToSafeBuffer(plainText, mp_encryptedData->getEncryptionMethod(), mp_key, mp_env->getParentDocument(), sb);
+
     // Set the value
     XENCCipherValue * val = mp_encryptedData->getCipherData()->getCipherValue();
 
@@ -848,24 +819,13 @@ XENCEncryptedData * XENCCipherImpl::encr
 //			Encrypt a key
 // --------------------------------------------------------------------------------
 
-XENCEncryptedKey * XENCCipherImpl::encryptKey(const unsigned char * keyBuffer, unsigned int keyLen, encryptionMethod em,
-    const XMLCh * algorithmURI) {
+XENCEncryptedKey * XENCCipherImpl::encryptKey(const unsigned char * keyBuffer, unsigned int keyLen, const XMLCh * algorithmURI) {
 
     if (mp_kek == NULL) {
         throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptKey - No KEK set");
     }
-
-    // Map the encryption method to a URI
-    safeBuffer algorithmSB;
-    const XMLCh * algorithm;
-
-    if (em == ENCRYPT_NONE) {
-        algorithm = algorithmURI;
-    } else {
-        if (encryptionMethod2URI(algorithmSB, em) != true) {
-            throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptKey - Unknown encryption method");
-        }
-        algorithm = algorithmSB.sbStrToXMLCh();
+    else if (algorithmURI == NULL) {
+        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptKey - No algorithm set");
     }
 
     // Create the element with a dummy encrypted value
@@ -875,7 +835,7 @@ XENCEncryptedKey * XENCCipherImpl::encry
     XSECnew(encryptedKey, XENCEncryptedKeyImpl(mp_env));
     Janitor<XENCEncryptedKeyImpl> j_encryptedKey(encryptedKey);
 
-    encryptedKey->createBlankEncryptedKey(XENCCipherData::VALUE_TYPE, algorithm, s_noData);
+    encryptedKey->createBlankEncryptedKey(XENCCipherData::VALUE_TYPE, algorithmURI, s_noData);
 
     // Create a transform chain to do pass the key to the encrypto
 
@@ -893,34 +853,17 @@ XENCEncryptedKey * XENCCipherImpl::encry
     tsb->setInput(rawKey, keyLen);
 
     // Perform the encryption
-    XSECAlgorithmHandler *handler;
-
-    if (algorithm != NULL) {
-
-        handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithm);
-
-    }
-
-    else {
-
-        handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(XSECAlgorithmMapper::s_defaultEncryptionMapping);
-
-    }
-
-    safeBuffer sb;
-
-    if (handler != NULL) {
-
-        handler->encryptToSafeBuffer(c, encryptedKey->getEncryptionMethod(), mp_kek, mp_env->getParentDocument(), sb);
-    } else {
-
+    XSECAlgorithmHandler *handler = XSECPlatformUtils::g_algorithmMapper->mapURIToHandler(algorithmURI);
+    if (!handler) {
         // Very strange if we get here - any problems should throw an
         // exception in the AlgorithmMapper.
 
         throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptKey - Error retrieving a handler for algorithm");
-
     }
 
+    safeBuffer sb;
+    handler->encryptToSafeBuffer(c, encryptedKey->getEncryptionMethod(), mp_kek, mp_env->getParentDocument(), sb);
+
     // Set the value
     XENCCipherValue * val = encryptedKey->getCipherData()->getCipherValue();
 
@@ -954,12 +897,15 @@ XENCEncryptedData * XENCCipherImpl::crea
 //			Encrypt an element
 // --------------------------------------------------------------------------------
 
-DOMNode * XENCCipherImpl::encryptElementDetached(DOMElement * element, encryptionMethod em, const XMLCh * algorithmURI) {
+DOMNode * XENCCipherImpl::encryptElementDetached(DOMElement * element, const XMLCh * algorithmURI) {
 
     // Make sure we have a key before we do anything too drastic
     if (mp_key == NULL) {
         throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptElement - No key set");
     }
+    else if (algorithmURI == NULL) {
+        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptElement - No algorithm set");
+    }
 
     // Create a transform chain to do the encryption
     TXFMDocObject * tdocObj;
@@ -971,7 +917,7 @@ DOMNode * XENCCipherImpl::encryptElement
 
     tdocObj->setInput(mp_doc, element);
 
-    // Now need to serialise the element - easiest to just use a canonicaliser
+    // Now need to serialise the element - easiest to just use a canonicalizer
     TXFMC14n *tc14n;
     XSECnew(tc14n, TXFMC14n(mp_doc));
     c->appendTxfm(tc14n);
@@ -982,17 +928,17 @@ DOMNode * XENCCipherImpl::encryptElement
 
     // Do the hard work
 
-    encryptTXFMChain(c, em, algorithmURI);
+    encryptTXFMChain(c, algorithmURI);
 
     mp_encryptedData->setType(DSIGConstants::s_unicodeStrURIXENC_ELEMENT);
     return mp_encryptedData->getElement();
 
 }
 
-DOMDocument * XENCCipherImpl::encryptElement(DOMElement * element, encryptionMethod em, const XMLCh * algorithmURI) {
+DOMDocument * XENCCipherImpl::encryptElement(DOMElement * element, const XMLCh * algorithmURI) {
 
     // Do the actual encryption work
-    encryptElementDetached(element, em, algorithmURI);
+    encryptElementDetached(element, algorithmURI);
 
     // Replace original element
     DOMNode * p = element->getParentNode();
@@ -1016,11 +962,10 @@ DOMDocument * XENCCipherImpl::encryptEle
 
 DOMDocument * XENCCipherImpl::encryptElementContent(
     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-    encryptionMethod em,
     const XMLCh * algorithmURI) {
 
     // Do the work
-    encryptElementContentDetached(element, em, algorithmURI);
+    encryptElementContentDetached(element, algorithmURI);
 
     // Delete current children
     DOMNode * n = element->getFirstChild();
@@ -1042,13 +987,15 @@ DOMDocument * XENCCipherImpl::encryptEle
 
 DOMNode * XENCCipherImpl::encryptElementContentDetached(
     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-    encryptionMethod em,
     const XMLCh * algorithmURI) {
 
     // Make sure we have a key before we do anything too drastic
     if (mp_key == NULL) {
         throw XSECException(XSECException::CipherError,
-            "XENCCipherImpl::encryptElement - No key set");
+            "XENCCipherImpl::encryptElementContentDetached - No key set");
+    }
+    else if (algorithmURI == NULL) {
+        throw XSECException(XSECException::CipherError, "XENCCipherImpl::encryptElementContentDetached - No algorithm set");
     }
 
     // Create a transform chain to do the encryption
@@ -1089,7 +1036,7 @@ DOMNode * XENCCipherImpl::encryptElement
 
     }
 
-    encryptTXFMChain(c, em, algorithmURI);
+    encryptTXFMChain(c, algorithmURI);
 
     mp_encryptedData->setType(DSIGConstants::s_unicodeStrURIXENC_CONTENT);
 
@@ -1106,7 +1053,7 @@ void XENCCipherImpl::setExclusiveC14nSer
     m_useExcC14nSerialisation = flag;
 }
 
-bool XENCCipherImpl::getExclusiveC14nSerialisation(void) {
+bool XENCCipherImpl::getExclusiveC14nSerialisation() const {
 
     return m_useExcC14nSerialisation;
 
@@ -1122,7 +1069,7 @@ void XENCCipherImpl::setPrettyPrint(bool
 
 }
 
-bool XENCCipherImpl::getPrettyPrint(void) {
+bool XENCCipherImpl::getPrettyPrint(void) const {
 
     return mp_env->getPrettyPrintFlag();
 

Modified: santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.hpp
URL: http://svn.apache.org/viewvc/santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.hpp?rev=1817224&r1=1817223&r2=1817224&view=diff
==============================================================================
--- santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.hpp (original)
+++ santuario/xml-security-cpp/trunk/xsec/xenc/impl/XENCCipherImpl.hpp Tue Dec  5 19:27:33 2017
@@ -59,9 +59,9 @@ public:
 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * 
 		decryptElementDetached(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element);
 	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * 
-		decryptElement(void);
+		decryptElement();
 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * 
-		decryptElementDetached(void);
+		decryptElementDetached();
 	XSECBinTXFMInputStream * decryptToBinInputStream(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element
 	);
@@ -80,47 +80,40 @@ public:
 	// Implementation for encryption Elements
 	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * encryptElement(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * uri = NULL);
+		const XMLCh * uri);
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * encryptElementContent(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL);
+		const XMLCh * algorithmURI);
 	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * encryptElementDetached(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * uri = NULL);
+		const XMLCh * uri);
 	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * encryptElementContentDetached(
 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL);
+		const XMLCh * algorithmURI);
 
 	// Encrypt a key
 	virtual XENCEncryptedKey * encryptKey(
 		const unsigned char * keyBuffer,
 		unsigned int keyLen,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	);
 	// Encrypt octet streams
 	virtual XENCEncryptedData * encryptBinInputStream(
 		XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream * plainText,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	);
 	virtual XENCEncryptedData * encryptTXFMChain(
 		TXFMChain * plainText,
-		encryptionMethod em,
-		const XMLCh * algorithmURI = NULL
+		const XMLCh * algorithmURI
 	);
 
 	// Getter methods
-	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument(void) 
+	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument() const
 		{return mp_doc;}
-	const XMLCh * getXENCNSPrefix(void) const;
-	virtual XENCEncryptedData * getEncryptedData(void);
-	bool getPrettyPrint(void);
-	bool getExclusiveC14nSerialisation(void);
+	const XMLCh * getXENCNSPrefix() const;
+	virtual XENCEncryptedData * getEncryptedData() const;
+	bool getPrettyPrint() const;
+	bool getExclusiveC14nSerialisation() const;
 
 	// Setter methods
 	void setKey(XSECCryptoKey * key);