blautenb 2003/10/03 02:55:03
Modified: c/src/dsig DSIGConstants.cpp DSIGConstants.hpp
DSIGKeyInfo.hpp DSIGKeyInfoList.cpp
DSIGKeyInfoList.hpp
Log:
Updates to handle creating an EncryptedKey (AES KeyWrap)
Revision Changes Path
1.13 +4 -1 xml-security/c/src/dsig/DSIGConstants.cpp
Index: DSIGConstants.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGConstants.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DSIGConstants.cpp 15 Sep 2003 11:57:44 -0000 1.12
+++ DSIGConstants.cpp 3 Oct 2003 09:55:02 -0000 1.13
@@ -101,6 +101,7 @@
const XMLCh * DSIGConstants::s_unicodeStrURIXMLNS;
const XMLCh * DSIGConstants::s_unicodeStrURIMANIFEST;
const XMLCh * DSIGConstants::s_unicodeStrURI3DES_CBC;
+const XMLCh * DSIGConstants::s_unicodeStrURIKW_AES128;
const XMLCh * DSIGConstants::s_unicodeStrPROVOpenSSL;
const XMLCh * DSIGConstants::s_unicodeStrPROVWinCAPI;
@@ -140,6 +141,7 @@
s_unicodeStrURIMANIFEST = XMLString::transcode(URI_ID_MANIFEST);
s_unicodeStrURI3DES_CBC = XMLString::transcode(URI_ID_3DES_CBC);
+ s_unicodeStrURIKW_AES128 = XMLString::transcode(URI_ID_KW_AES128);
s_unicodeStrPROVOpenSSL = XMLString::transcode(PROV_OPENSSL);
s_unicodeStrPROVWinCAPI = XMLString::transcode(PROV_WINCAPI);
@@ -178,6 +180,7 @@
delete[] (XMLCh *) s_unicodeStrURIMANIFEST;
delete[] (XMLCh *) s_unicodeStrURI3DES_CBC;
+ delete[] (XMLCh *) s_unicodeStrURIKW_AES128;
delete[] (XMLCh *) s_unicodeStrPROVOpenSSL;
delete[] (XMLCh *) s_unicodeStrPROVWinCAPI;
1.15 +12 -2 xml-security/c/src/dsig/DSIGConstants.hpp
Index: DSIGConstants.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGConstants.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DSIGConstants.hpp 15 Sep 2003 11:57:44 -0000 1.14
+++ DSIGConstants.hpp 3 Oct 2003 09:55:02 -0000 1.15
@@ -94,6 +94,9 @@
// Encryption Algorithms
#define URI_ID_3DES_CBC "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"
+// Key Wrap Algorithm
+#define URI_ID_KW_AES128 "http://www.w3.org/2001/04/xmlenc#kw-aes128"
+
// Transforms
#define URI_ID_BASE64
"http://www.w3.org/2000/09/xmldsig#base64"
@@ -182,7 +185,8 @@
enum encryptionMethod {
ENCRYPT_NONE = 0, // No
method defined
- ENCRYPT_3DES_CBC = 1
// Use 3DES
+ ENCRYPT_3DES_CBC = 1, // Use
3DES
+ ENCRYPT_KW_AES128 = 2
// KeyWrap - AES128
};
@@ -306,6 +310,11 @@
uri = URI_ID_3DES_CBC;
break;
+ case (ENCRYPT_KW_AES128) :
+
+ uri = URI_ID_KW_AES128;
+ break;
+
default:
return false;
@@ -358,6 +367,7 @@
// URIs for Encryption
static const XMLCh * s_unicodeStrURI3DES_CBC;
+ static const XMLCh * s_unicodeStrURIKW_AES128;
// Internal Crypto Providers
static const XMLCh * s_unicodeStrPROVOpenSSL;
1.9 +4 -3 xml-security/c/src/dsig/DSIGKeyInfo.hpp
Index: DSIGKeyInfo.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfo.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DSIGKeyInfo.hpp 12 Sep 2003 09:47:17 -0000 1.8
+++ DSIGKeyInfo.hpp 3 Oct 2003 09:55:02 -0000 1.9
@@ -123,7 +123,8 @@
KEYINFO_NAME = 5, // A
name of a key (application dependant)
KEYINFO_PGPDATA = 6, // A
PGP key
KEYINFO_SPKIDATA = 7,
- KEYINFO_MGMTDATA = 8
// Management data
+ KEYINFO_MGMTDATA = 8, //
Management data
+ KEYINFO_ENCRYPTEDKEY = 9 // XML
Encryption - Encrypted Key
};
@@ -165,7 +166,7 @@
* \brief Return the DOMNode that heads up this DOMNode
*/
- virtual const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
*getKeyInfoDOMNode()
+ virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *getKeyInfoDOMNode()
{return mp_keyInfoDOMNode;}
/**
1.13 +30 -1 xml-security/c/src/dsig/DSIGKeyInfoList.cpp
Index: DSIGKeyInfoList.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfoList.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DSIGKeyInfoList.cpp 17 Sep 2003 10:10:21 -0000 1.12
+++ DSIGKeyInfoList.cpp 3 Oct 2003 09:55:02 -0000 1.13
@@ -85,6 +85,8 @@
#include <xsec/transformers/TXFMChain.hpp>
#include <xsec/transformers/TXFMBase.hpp>
+#include "../xenc/impl/XENCEncryptedKeyImpl.hpp"
+
#include <xercesc/util/Janitor.hpp>
XERCES_CPP_NAMESPACE_USE
@@ -197,6 +199,12 @@
}
+ else if (strEquals(getXENCLocalName(ki), "EncryptedKey")) {
+
+ XSECnew(k, XENCEncryptedKeyImpl(mp_env, ki));
+
+ }
+
else {
return false;
@@ -616,3 +624,24 @@
return m;
}
+
+//
--------------------------------------------------------------------------------
+// Some helper functions
+//
--------------------------------------------------------------------------------
+
+void DSIGKeyInfoList::addAndInsertKeyInfo(DSIGKeyInfo * ref) {
+
+ if (mp_keyInfoNode == NULL) {
+
+ throw XSECException(XSECException::KeyInfoError,
+ "KeyInfoList - Attempt to create MgmtData before
creating KeyInfo");
+
+ }
+
+ DOMDocument * doc = mp_env->getParentDocument();
+ mp_keyInfoNode->appendChild(ref->getKeyInfoDOMNode());
+
mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
+
+ addKeyInfo(ref);
+
+}
\ No newline at end of file
1.8 +16 -1 xml-security/c/src/dsig/DSIGKeyInfoList.hpp
Index: DSIGKeyInfoList.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfoList.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DSIGKeyInfoList.hpp 17 Sep 2003 10:10:21 -0000 1.7
+++ DSIGKeyInfoList.hpp 3 Oct 2003 09:55:02 -0000 1.8
@@ -176,11 +176,26 @@
* Adds a KeyInfo element that has already been built
* into the list.
*
+ * @note This method does <b>not</b> insert the KeyInfo into the DOM
+ * structure - it assumes it is already there and just adds to the list.
* @param ref The KeyInfo to add
*/
void addKeyInfo(DSIGKeyInfo * ref);
+ /**
+ * \brief Add an already created KeyInfo
+ *
+ * Adds a KeyInfo element that has already been built
+ * into the list.
+ *
+ * @note This method finds the DOM node of the KeyInfo and inserts it
+ * into the <KeyInfo/> list in the DOM.
+ * @param ref The KeyInfo to add
+ */
+
+ void addAndInsertKeyInfo(DSIGKeyInfo * ref);
+
/**
* \brief Read from DOM and create.
*