You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2003/09/17 12:10:22 UTC

cvs commit: xml-security/c/src/xenc/impl XENCCipherDataImpl.hpp XENCCipherImpl.cpp XENCCipherImpl.hpp XENCCipherValueImpl.hpp XENCEncryptedDataImpl.hpp XENCEncryptedTypeImpl.cpp XENCEncryptedTypeImpl.hpp XENCEncryptionMethodImpl.hpp

blautenb    2003/09/17 03:10:22

  Modified:    c/src/dsig DSIGKeyInfoList.cpp DSIGKeyInfoList.hpp
                        DSIGSignature.cpp
               c/src/tools/xtest xtest.cpp
               c/src/xenc XENCCipher.hpp XENCCipherData.hpp
                        XENCCipherValue.hpp XENCEncryptedType.hpp
                        XENCEncryptionMethod.hpp
               c/src/xenc/impl XENCCipherDataImpl.hpp XENCCipherImpl.cpp
                        XENCCipherImpl.hpp XENCCipherValueImpl.hpp
                        XENCEncryptedDataImpl.hpp XENCEncryptedTypeImpl.cpp
                        XENCEncryptedTypeImpl.hpp
                        XENCEncryptionMethodImpl.hpp
  Log:
  Integrate DSIG KeyInfo creation into XENC
  
  Revision  Changes    Path
  1.12      +198 -3    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DSIGKeyInfoList.cpp	15 Sep 2003 11:57:44 -0000	1.11
  +++ DSIGKeyInfoList.cpp	17 Sep 2003 10:10:21 -0000	1.12
  @@ -90,7 +90,8 @@
   XERCES_CPP_NAMESPACE_USE
   
   DSIGKeyInfoList::DSIGKeyInfoList(const XSECEnv * env) :
  -mp_env(env) {}
  +mp_env(env),
  +mp_keyInfoNode(NULL) {}
   
   DSIGKeyInfoList::~DSIGKeyInfoList() {
   
  @@ -420,4 +421,198 @@
   	}
   
   	return true;
  -}
  \ No newline at end of file
  +}
  +
  +// --------------------------------------------------------------------------------
  +//           Create new KeyInfo elements
  +// --------------------------------------------------------------------------------
  +
  +DOMElement * DSIGKeyInfoList::createKeyInfo(void) {
  +
  +	// Assume that someone else has looked after the DOM
  +	empty();
  +
  +	safeBuffer str;
  +	DOMDocument * doc = mp_env->getParentDocument();
  +
  +	makeQName(str, mp_env->getDSIGNSPrefix(), "KeyInfo");
  +
  +	DOMElement * ret = doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
  +
  +	mp_keyInfoNode = ret;
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	return ret;	
  +
  +}
  +
  +
  +DSIGKeyInfoValue * DSIGKeyInfoList::appendDSAKeyValue(const XMLCh * P, 
  +						   const XMLCh * Q, 
  +						   const XMLCh * G, 
  +						   const XMLCh * Y) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create DSAKeyValue before creating KeyInfo");
  +
  +	}
  +
  +	// Create the new element
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoValue * v;
  +	XSECnew(v, DSIGKeyInfoValue(mp_env));
  +
  +	mp_keyInfoNode->appendChild(v->createBlankDSAKeyValue(P, Q, G, Y));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	// Add to the list
  +	addKeyInfo(v);
  +
  +	return v;
  +
  +}
  +
  +DSIGKeyInfoValue * DSIGKeyInfoList::appendRSAKeyValue(const XMLCh * modulus, 
  +						   const XMLCh * exponent) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create RSAKeyValue before creating KeyInfo");
  +
  +	}
  +
  +	// Create the new element
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoValue * v;
  +	XSECnew(v, DSIGKeyInfoValue(mp_env));
  +
  +	mp_keyInfoNode->appendChild(v->createBlankRSAKeyValue(modulus, exponent));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	// Add to the list
  +	addKeyInfo(v);
  +
  +	return v;
  +
  +}
  +
  +
  +DSIGKeyInfoX509 * DSIGKeyInfoList::appendX509Data(void) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create X509Data before creating KeyInfo");
  +
  +	}
  +
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoX509 * x;
  +
  +	XSECnew(x, DSIGKeyInfoX509(mp_env));
  +
  +	mp_keyInfoNode->appendChild(x->createBlankX509Data());
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	// Add to the list
  +	addKeyInfo(x);
  +
  +	return x;
  +
  +}
  +
  +DSIGKeyInfoName * DSIGKeyInfoList::appendKeyName(const XMLCh * name, bool isDName) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create KeyName before creating KeyInfo");
  +
  +	}
  +
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoName * n;
  +
  +	XSECnew(n, DSIGKeyInfoName(mp_env));
  +
  +	mp_keyInfoNode->appendChild(n->createBlankKeyName(name, isDName));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	// Add to the list
  +	addKeyInfo(n);
  +
  +	return n;
  +
  +}
  +
  +DSIGKeyInfoPGPData * DSIGKeyInfoList::appendPGPData(const XMLCh * id, const XMLCh * packet) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create PGPData before creating KeyInfo");
  +
  +	}
  +
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoPGPData * p;
  +
  +	XSECnew(p, DSIGKeyInfoPGPData(mp_env));
  +
  +	mp_keyInfoNode->appendChild(p->createBlankPGPData(id, packet));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	addKeyInfo(p);
  +
  +	return p;
  +
  +}
  +
  +DSIGKeyInfoSPKIData * DSIGKeyInfoList::appendSPKIData(const XMLCh * sexp) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create SPKIData before creating KeyInfo");
  +
  +	}
  +
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoSPKIData * s;
  +
  +	XSECnew(s, DSIGKeyInfoSPKIData(mp_env));
  +
  +	mp_keyInfoNode->appendChild(s->createBlankSPKIData(sexp));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	addKeyInfo(s);
  +
  +	return s;
  +
  +}
  +
  +DSIGKeyInfoMgmtData * DSIGKeyInfoList::appendMgmtData(const XMLCh * data) {
  +
  +	if (mp_keyInfoNode == NULL) {
  +
  +		throw XSECException(XSECException::KeyInfoError, 
  +			"KeyInfoList - Attempt to create MgmtData before creating KeyInfo");
  +
  +	}
  +
  +	DOMDocument * doc = mp_env->getParentDocument();
  +	DSIGKeyInfoMgmtData * m;
  +
  +	XSECnew(m, DSIGKeyInfoMgmtData(mp_env));
  +
  +	mp_keyInfoNode->appendChild(m->createBlankMgmtData(data));
  +	mp_keyInfoNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +	addKeyInfo(m);
  +
  +	return m;
  +
  +}
  
  
  
  1.7       +114 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DSIGKeyInfoList.hpp	15 Sep 2003 11:57:44 -0000	1.6
  +++ DSIGKeyInfoList.hpp	17 Sep 2003 10:10:21 -0000	1.7
  @@ -82,6 +82,13 @@
   // General includes
   #include <vector>
   
  +// Forward definitions
  +class DSIGKeyInfoValue;
  +class DSIGKeyInfoX509;
  +class DSIGKeyInfoName;
  +class DSIGKeyInfoPGPData;
  +class DSIGKeyInfoSPKIData;
  +class DSIGKeyInfoMgmtData;
   class DSIGSignature;
   
   /**
  @@ -243,12 +250,118 @@
   
   	//@}
   
  +	/** @name Create new KeyInfo elements */
  +	//@{
  +
  +	/**
  +	 * \brief Create basic KeyInfo element.
  +	 *
  +	 * Creates the basic KeyInfo node that can then be used to
  +	 * embed specific KeyInfo types
  +	 */
  +
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 
  +		DSIGKeyInfoList::createKeyInfo(void);
  +
  +	/**
  +	 * \brief Append a DSA KeyValue element 
  +	 *
  +	 * Add a new KeyInfo element for a DSA Value
  +	 *
  +	 * @param P Base64 encoded value of P
  +	 * @param Q Base64 encoded value of Q
  +	 * @param G Base64 encoded value of G
  +	 * @param Y Base64 encoded value of Y
  +	 * @returns A pointer to the created object.
  +	 */
  +
  +	DSIGKeyInfoValue * appendDSAKeyValue(const XMLCh * P, 
  +						   const XMLCh * Q, 
  +						   const XMLCh * G, 
  +						   const XMLCh * Y);
  +
  +	/**
  +	 * \brief Append a RSA KeyValue element 
  +	 *
  +	 * Add a new KeyInfo element for a RSA Value
  +	 *
  +	 * @param modulus Base64 encoded value of the modulus
  +	 * @param exponent Base64 encoded value of exponent
  +	 * @returns A pointer to the created object.
  +	 */
  +
  +	DSIGKeyInfoValue * appendRSAKeyValue(const XMLCh * modulus, 
  +						   const XMLCh * exponent);
  +
  +	/**
  +	 * \brief Append a X509Data element.
  +	 *
  +	 * Add a new KeyInfo element for X509 data.
  +	 *
  +	 * @note The added element is empty.  The caller must make use of the
  +	 * returned object to set the required values.
  +	 *
  +	 * @returns A pointer to the created object.
  +	 */
  +
  +	DSIGKeyInfoX509 * appendX509Data(void);
  +
  +	/**
  +	 * \brief Append a KeyName element.
  +	 *
  +	 * Add a new KeyInfo element for a key name.
  +	 *
  +	 * @param name The name of the key to set in the XML
  +	 * @param isDName Treat the name as a Distinguished name and encode accordingly
  +	 * @returns A pointer to the created object
  +	 */
  +
  +	DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false);
  +
  +	/**
  +	 * \brief Append a PGPData element.
  +	 *
  +	 * Add a new KeyInfo element for a PGP key.
  +	 *
  +	 * @param id The ID of the key to set in the XML (base64 encoded - NULL if none)
  +	 * @param packet The Packet information to set in the XML (base64 encoded -
  +	 * NULL if none)
  +	 * @returns A pointer to the created object
  +	 */
  +
  +	DSIGKeyInfoPGPData * appendPGPData(const XMLCh * id, const XMLCh * packet);
  +
  +	/**
  +	 * \brief Append a SPKIData element
  +	 *
  +	 * Add a new KeyInfo element for a set of SPKI S-expressions
  +	 *
  +	 * @param sexp The initial S-expression to set in the SPKIData element
  +	 * @returns A pointer to the created object
  +	 */
  +
  +	DSIGKeyInfoSPKIData * appendSPKIData(const XMLCh * sexp);
  +
  +	/**
  +	 * \brief Append a MgmtData element
  +	 *
  +	 * Add a new KeyInfo element for Management Data
  +	 *
  +	 * @param data The string to set in the MgmtData element
  +	 * @returns A pointer to the created object
  +	 */
  +
  +	DSIGKeyInfoMgmtData * appendMgmtData(const XMLCh * data);
  +
  +	//@}
  +
   private:
   
   	DSIGKeyInfoList();
   
   	KeyInfoListVectorType					m_keyInfoList;
   	const XSECEnv							* mp_env;
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode	* mp_keyInfoNode;
   	// KeyInfoListVectorType::iterator			m_iterator;
   };
   
  
  
  
  1.25      +9 -87     xml-security/c/src/dsig/DSIGSignature.cpp
  
  Index: DSIGSignature.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.cpp,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- DSIGSignature.cpp	15 Sep 2003 11:57:44 -0000	1.24
  +++ DSIGSignature.cpp	17 Sep 2003 10:10:21 -0000	1.25
  @@ -596,7 +596,7 @@
   
   	makeQName(str, mp_env->getDSIGNSPrefix(), "KeyInfo");
   
  -	mp_KeyInfoNode = mp_doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
  +	mp_KeyInfoNode = m_keyInfoList.createKeyInfo();
   
   	// Append the node to the end of the signature
   	
  @@ -614,30 +614,15 @@
   			afterSignatureValue);
   	}
   
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -	
  -
   }
   
  -
   DSIGKeyInfoValue * DSIGSignature::appendDSAKeyValue(const XMLCh * P, 
   						   const XMLCh * Q, 
   						   const XMLCh * G, 
   						   const XMLCh * Y) {
   
   	createKeyInfoElement();
  -
  -	// Create the new element
  -	DSIGKeyInfoValue * v;
  -	XSECnew(v, DSIGKeyInfoValue(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(v->createBlankDSAKeyValue(P, Q, G, Y));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	// Add to the list
  -	m_keyInfoList.addKeyInfo(v);
  -
  -	return v;
  +	return m_keyInfoList.appendDSAKeyValue(P, Q, G, Y);
   
   }
   
  @@ -645,18 +630,7 @@
   						   const XMLCh * exponent) {
   
   	createKeyInfoElement();
  -
  -	// Create the new element
  -	DSIGKeyInfoValue * v;
  -	XSECnew(v, DSIGKeyInfoValue(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(v->createBlankRSAKeyValue(modulus, exponent));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	// Add to the list
  -	m_keyInfoList.addKeyInfo(v);
  -
  -	return v;
  +	return m_keyInfoList.appendRSAKeyValue(modulus, exponent);
   
   }
   
  @@ -664,87 +638,35 @@
   DSIGKeyInfoX509 * DSIGSignature::appendX509Data(void) {
   
   	createKeyInfoElement();
  -
  -	DSIGKeyInfoX509 * x;
  -
  -	XSECnew(x, DSIGKeyInfoX509(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(x->createBlankX509Data());
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	// Add to the list
  -	m_keyInfoList.addKeyInfo(x);
  -
  -	return x;
  +	return m_keyInfoList.appendX509Data();
   
   }
   
   DSIGKeyInfoName * DSIGSignature::appendKeyName(const XMLCh * name, bool isDName) {
   
   	createKeyInfoElement();
  -
  -	DSIGKeyInfoName * n;
  -
  -	XSECnew(n, DSIGKeyInfoName(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(n->createBlankKeyName(name, isDName));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	// Add to the list
  -	m_keyInfoList.addKeyInfo(n);
  -
  -	return n;
  +	return m_keyInfoList.appendKeyName(name, isDName);
   
   }
   
   DSIGKeyInfoPGPData * DSIGSignature::appendPGPData(const XMLCh * id, const XMLCh * packet) {
   
   	createKeyInfoElement();
  -
  -	DSIGKeyInfoPGPData * p;
  -
  -	XSECnew(p, DSIGKeyInfoPGPData(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(p->createBlankPGPData(id, packet));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	m_keyInfoList.addKeyInfo(p);
  -
  -	return p;
  +	return m_keyInfoList.appendPGPData(id, packet);
   
   }
   
   DSIGKeyInfoSPKIData * DSIGSignature::appendSPKIData(const XMLCh * sexp) {
   
   	createKeyInfoElement();
  -
  -	DSIGKeyInfoSPKIData * s;
  -
  -	XSECnew(s, DSIGKeyInfoSPKIData(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(s->createBlankSPKIData(sexp));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	m_keyInfoList.addKeyInfo(s);
  -
  -	return s;
  +	return m_keyInfoList.appendSPKIData(sexp);
   
   }
   
   DSIGKeyInfoMgmtData * DSIGSignature::appendMgmtData(const XMLCh * data) {
   
   	createKeyInfoElement();
  -
  -	DSIGKeyInfoMgmtData * m;
  -
  -	XSECnew(m, DSIGKeyInfoMgmtData(mp_env));
  -
  -	mp_KeyInfoNode->appendChild(m->createBlankMgmtData(data));
  -	mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -	m_keyInfoList.addKeyInfo(m);
  -
  -	return m;
  +	return m_keyInfoList.appendMgmtData(data);
   
   }
   
  
  
  
  1.20      +49 -2     xml-security/c/src/tools/xtest/xtest.cpp
  
  Index: xtest.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/tools/xtest/xtest.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- xtest.cpp	15 Sep 2003 11:55:03 -0000	1.19
  +++ xtest.cpp	17 Sep 2003 10:10:21 -0000	1.20
  @@ -208,6 +208,13 @@
   
   };
   
  +XMLCh s_tstKeyName[] = {
  +
  +	chLatin_F, chLatin_r, chLatin_e, chLatin_d, chSingleQuote,
  +	chLatin_s, chSpace, chLatin_n, chLatin_a, chLatin_m,
  +	chLatin_e, chNull
  +};
  +
   XMLCh s_tstPGPKeyID[] = {
   
   	chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
  @@ -783,6 +790,11 @@
   		// Now encrypt!
   		cerr << "Performing 3DES encryption on <category> element ... ";
   		cipher->encryptElement((DOMElement *) categoryNode, ENCRYPT_3DES_CBC);
  +
  +		// Add a KeyInfo
  +		cerr << "done\nAppending a <KeyName> ... ";
  +		XENCEncryptedData * encryptedData = cipher->getEncryptedData();
  +		encryptedData->appendKeyName(s_tstKeyName);
   		cerr << "done\nSearching for <category> ... ";
   
   		DOMNode * t = findNode(doc, MAKE_UNICODE_STRING("category"));
  @@ -809,7 +821,7 @@
   		cipher2->setKey(k2);
   
   		cerr << "Decrypting ... ";
  -		cipher->decryptElement(static_cast<DOMElement *>(n));
  +		cipher2->decryptElement(static_cast<DOMElement *>(n));
   		cerr << "done" << endl;
   
   		cerr << "Checking for <category> element ... ";
  @@ -824,6 +836,41 @@
   		}
   		else
   			cerr << "found" << endl;
  +
  +		cerr << "Checking <KeyName> element is set correctly ... ";
  +
  +		encryptedData = cipher2->getEncryptedData();
  +
  +		if (encryptedData == NULL) {
  +			cerr << "no - cannot access EncryptedData element" << endl;
  +			exit(1);
  +		}
  +
  +		DSIGKeyInfoList * kil = encryptedData->getKeyInfoList();
  +		int nki = kil->getSize();
  +		bool foundNameOK = false;
  +
  +		for (int i = 0; i < nki; ++i) {
  +
  +			if (kil->item(i)->getKeyInfoType() == DSIGKeyInfo::KEYINFO_NAME) {
  +
  +				DSIGKeyInfoName *n = dynamic_cast<DSIGKeyInfoName *>(kil->item(i));
  +				if (!strEquals(n->getKeyName(), s_tstKeyName)) {
  +					
  +					cerr << "no!" << endl;
  +					exit (1);
  +				}
  +				foundNameOK = true;
  +				break;
  +			}
  +		}
  +
  +		if (foundNameOK == false) {
  +			cerr << "no!" << endl;
  +			exit(1);
  +		}
  +		else
  +			cerr << "yes." << endl;
   
   	}
   	catch (XSECException &e)
  
  
  
  1.5       +12 -1     xml-security/c/src/xenc/XENCCipher.hpp
  
  Index: XENCCipher.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCCipher.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCCipher.hpp	15 Sep 2003 11:54:03 -0000	1.4
  +++ XENCCipher.hpp	17 Sep 2003 10:10:21 -0000	1.5
  @@ -204,6 +204,17 @@
   
   	virtual const XMLCh * getXENCNSPrefix(void) const = 0;
   
  +	/**
  +	 * \brief Get the EncryptedData element
  +	 *
  +	 * Allows the user to get the EncryptedData element that was last processed/
  +	 * created by this XENCCipher object.
  +	 *
  +	 * @returns The last used EncryptedData
  +	 */
  +
  +	virtual XENCEncryptedData * getEncryptedData(void) = 0;
  +
   	//@}
   
   	/** @name Setter Functions */
  
  
  
  1.3       +9 -1      xml-security/c/src/xenc/XENCCipherData.hpp
  
  Index: XENCCipherData.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCCipherData.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XENCCipherData.hpp	8 Sep 2003 12:07:49 -0000	1.2
  +++ XENCCipherData.hpp	17 Sep 2003 10:10:21 -0000	1.3
  @@ -145,6 +145,14 @@
   
   	virtual XENCCipherValue * getCipherValue(void) = 0;
   
  +	/**
  +	 * \brief Get the DOM Node of this structure
  +	 *
  +	 * @returns the DOM Node representing the <CipherData> element
  +	 */
  +
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void) = 0;
  +
   	//@}
   
   private:
  
  
  
  1.3       +11 -1     xml-security/c/src/xenc/XENCCipherValue.hpp
  
  Index: XENCCipherValue.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCCipherValue.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XENCCipherValue.hpp	15 Sep 2003 11:54:03 -0000	1.2
  +++ XENCCipherValue.hpp	17 Sep 2003 10:10:21 -0000	1.3
  @@ -73,6 +73,8 @@
   
   #include <xsec/framework/XSECDefs.hpp>
   
  +XSEC_DECLARE_XERCES_CLASS(DOMNode);
  +
   /**
    * @ingroup xenc
    * @{
  @@ -114,6 +116,14 @@
   	 */
   
   	virtual const XMLCh * getCipherString(void) = 0;
  +
  +	/**
  +	 * \brief Get the DOM Node of this structure
  +	 *
  +	 * @returns the DOM Node representing the <CipherValue> element
  +	 */
  +
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void) = 0;
   
   	//@}
   
  
  
  
  1.5       +25 -2     xml-security/c/src/xenc/XENCEncryptedType.hpp
  
  Index: XENCEncryptedType.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCEncryptedType.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCEncryptedType.hpp	15 Sep 2003 11:54:03 -0000	1.4
  +++ XENCEncryptedType.hpp	17 Sep 2003 10:10:21 -0000	1.5
  @@ -78,6 +78,7 @@
   
   class XENCCipherData;
   class DSIGKeyInfoList;
  +class DSIGKeyInfoName;
   class XENCEncryptionMethod;
   
   /**
  @@ -151,7 +152,7 @@
   	 * @returns the DOMNode that heads up this structure
   	 */
   
  -	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getDOMNode() = 0;
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode() = 0;
   
   	//@}
   
  @@ -175,6 +176,28 @@
   	 */
   	
   	virtual DSIGKeyInfoList * getKeyInfoList(void) = 0;
  +
  +	/**
  +	 * \brief Clear out all KeyInfo elements in the signature.
  +	 *
  +	 * This function will delete all KeyInfo elements from both the EncryptedType
  +	 * object <em>and the associated DOM</em>.
  +	 *
  +	 */
  +
  +	virtual void clearKeyInfo(void) = 0;
  +
  +	/**
  +	 * \brief Append a KeyName element.
  +	 *
  +	 * Add a new KeyInfo element for a key name.
  +	 *
  +	 * @param name The name of the key to set in the XML
  +	 * @param isDName Treat the name as a Distinguished name and encode accordingly
  +	 * @returns A pointer to the created object
  +	 */
  +
  +	virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false) = 0;
   
   	//@}
   
  
  
  
  1.3       +10 -1     xml-security/c/src/xenc/XENCEncryptionMethod.hpp
  
  Index: XENCEncryptionMethod.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCEncryptionMethod.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XENCEncryptionMethod.hpp	15 Sep 2003 11:54:03 -0000	1.2
  +++ XENCEncryptionMethod.hpp	17 Sep 2003 10:10:21 -0000	1.3
  @@ -114,6 +114,15 @@
   
   	virtual const XMLCh * getAlgorithm(void) = 0;
   
  +	/**
  +	 * \brief Get the DOM Node of this structure
  +	 *
  +	 * @returns the DOM Node representing the <EncryptionMethod> element
  +	 */
  +
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void) = 0;
  +
  +
   	//@}
   
   private:
  
  
  
  1.5       +3 -1      xml-security/c/src/xenc/impl/XENCCipherDataImpl.hpp
  
  Index: XENCCipherDataImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCCipherDataImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCCipherDataImpl.hpp	15 Sep 2003 11:53:09 -0000	1.4
  +++ XENCCipherDataImpl.hpp	17 Sep 2003 10:10:22 -0000	1.5
  @@ -102,6 +102,8 @@
   	// Interface methods
   	virtual XENCCipherDataType getCipherDataType(void);
   	virtual XENCCipherValue * getCipherValue(void);
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  +		{return mp_cipherDataNode;}
   
   
   private:
  
  
  
  1.5       +19 -2     xml-security/c/src/xenc/impl/XENCCipherImpl.cpp
  
  Index: XENCCipherImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCCipherImpl.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCCipherImpl.cpp	15 Sep 2003 11:53:09 -0000	1.4
  +++ XENCCipherImpl.cpp	17 Sep 2003 10:10:22 -0000	1.5
  @@ -129,6 +129,12 @@
   	chNull
   };
   
  +const XMLCh s_ds[] = {
  +	chLatin_d,
  +	chLatin_s,
  +	chNull
  +};
  +
   // --------------------------------------------------------------------------------
   //			Constructors
   // --------------------------------------------------------------------------------
  @@ -140,6 +146,7 @@
   mp_keyInfoResolver(NULL) {
   
   	XSECnew(mp_env, XSECEnv(doc));
  +	mp_env->setDSIGNSPrefix(s_ds);
   
   }
   
  @@ -202,6 +209,16 @@
   }
   
   // --------------------------------------------------------------------------------
  +//			Key Info resolvers
  +// --------------------------------------------------------------------------------
  +
  +XENCEncryptedData * XENCCipherImpl::getEncryptedData(void) {
  +
  +	return mp_encryptedData;
  +
  +}
  +
  +// --------------------------------------------------------------------------------
   //			Serialise/Deserialise an element
   // --------------------------------------------------------------------------------
   
  @@ -423,7 +440,7 @@
   
   	}
   
  -	return NULL;
  +	return mp_env->getParentDocument();
   
   }
   
  
  
  
  1.6       +2 -1      xml-security/c/src/xenc/impl/XENCCipherImpl.hpp
  
  Index: XENCCipherImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCCipherImpl.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XENCCipherImpl.hpp	15 Sep 2003 11:53:09 -0000	1.5
  +++ XENCCipherImpl.hpp	17 Sep 2003 10:10:22 -0000	1.6
  @@ -106,6 +106,7 @@
   	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * getDocument(void) 
   		{return mp_doc;}
   	const XMLCh * getXENCNSPrefix(void) const;
  +	virtual XENCEncryptedData * getEncryptedData(void);
   
   	// Setter methods
   	void setKey(XSECCryptoKey * key) {mp_key = key;}
  
  
  
  1.5       +3 -1      xml-security/c/src/xenc/impl/XENCCipherValueImpl.hpp
  
  Index: XENCCipherValueImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCCipherValueImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCCipherValueImpl.hpp	15 Sep 2003 11:53:09 -0000	1.4
  +++ XENCCipherValueImpl.hpp	17 Sep 2003 10:10:22 -0000	1.5
  @@ -103,6 +103,8 @@
   
   	virtual const XMLCh * getCipherString(void);
   	virtual void setCipherString(const XMLCh * value);
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  +		{return mp_cipherValueNode;}
   
   private:
   
  
  
  
  1.5       +7 -3      xml-security/c/src/xenc/impl/XENCEncryptedDataImpl.hpp
  
  Index: XENCEncryptedDataImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptedDataImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCEncryptedDataImpl.hpp	15 Sep 2003 11:53:09 -0000	1.4
  +++ XENCEncryptedDataImpl.hpp	17 Sep 2003 10:10:22 -0000	1.5
  @@ -104,12 +104,16 @@
   	// Inherited from XENCEncryptedData - need to re-implement
   	virtual XENCCipherData * getCipherData(void) 
   		{return XENCEncryptedTypeImpl::getCipherData();}
  -	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getDOMNode()
  -		{return XENCEncryptedTypeImpl::getDOMNode();}
   	virtual DSIGKeyInfoList * getKeyInfoList(void)
   		{return XENCEncryptedTypeImpl::getKeyInfoList();}
   	virtual XENCEncryptionMethod * getEncryptionMethod(void)
   		{return XENCEncryptedTypeImpl::getEncryptionMethod();}
  +	virtual void clearKeyInfo(void)
  +		{XENCEncryptedTypeImpl::clearKeyInfo();}
  +	virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false)
  +		{return XENCEncryptedTypeImpl::appendKeyName(name, isDName);}
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  +		{return XENCEncryptedTypeImpl::getDOMNode();}
   
   private:
   
  
  
  
  1.5       +78 -9     xml-security/c/src/xenc/impl/XENCEncryptedTypeImpl.cpp
  
  Index: XENCEncryptedTypeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptedTypeImpl.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCEncryptedTypeImpl.cpp	15 Sep 2003 11:53:09 -0000	1.4
  +++ XENCEncryptedTypeImpl.cpp	17 Sep 2003 10:10:22 -0000	1.5
  @@ -145,6 +145,8 @@
   XENCEncryptedTypeImpl::XENCEncryptedTypeImpl(const XSECEnv * env) :
   mp_env(env),
   mp_encryptedTypeNode(NULL),
  +mp_keyInfoNode(NULL),
  +mp_cipherDataNode(NULL),
   mp_cipherData(NULL),
   mp_encryptionMethod(NULL),
   m_keyInfoList(env) {
  @@ -155,6 +157,8 @@
   XENCEncryptedTypeImpl::XENCEncryptedTypeImpl(const XSECEnv * env, DOMNode * node) :
   mp_env(env),
   mp_encryptedTypeNode(node),
  +mp_keyInfoNode(NULL),
  +mp_cipherDataNode(NULL),
   mp_cipherData(NULL),
   mp_encryptionMethod(NULL),
   m_keyInfoList(env) {
  @@ -213,6 +217,8 @@
   
   	if (tmpElt != NULL && strEquals(getXENCLocalName(tmpElt), s_CipherData)) {
   
  +		mp_cipherDataNode = tmpElt;
  +
   		XSECnew(mp_cipherData, XENCCipherDataImpl(mp_env, tmpElt));
   		mp_cipherData->load();
   		tmpElt = findNextChildOfType(tmpElt, DOMNode::ELEMENT_NODE);
  @@ -280,10 +286,10 @@
   
   	// Create the cipher Data
   	XSECnew(mp_cipherData, XENCCipherDataImpl(mp_env));
  -	DOMNode * cipherDataNode = mp_cipherData->createBlankCipherData(type, value);
  +	mp_cipherDataNode = mp_cipherData->createBlankCipherData(type, value);
   
   	// Add to EncryptedType
  -	ret->appendChild(cipherDataNode);
  +	ret->appendChild(mp_cipherDataNode);
   
   	return ret;
   
  @@ -343,16 +349,79 @@
   
   }
   
  -DOMElement * XENCEncryptedTypeImpl::getDOMNode() {
  +XENCEncryptionMethod * XENCEncryptedTypeImpl::getEncryptionMethod(void) {
  +	
  +	return mp_encryptionMethod;
  +
  +}
  +
  +// --------------------------------------------------------------------------------
  +//			KeyInfo elements
  +// --------------------------------------------------------------------------------
  +
  +void XENCEncryptedTypeImpl::clearKeyInfo(void) {
  +
  +	if (mp_keyInfoNode == NULL)
  +		return;
   
  -	if (mp_encryptedTypeNode->getNodeType() == DOMNode::ELEMENT_NODE)
  -		return static_cast<DOMElement*>(mp_encryptedTypeNode);
  +	if (mp_encryptedTypeNode->removeChild(mp_keyInfoNode) != mp_keyInfoNode) {
  +
  +		throw XSECException(XSECException::ExpectedDSIGChildNotFound,
  +			"Attempted to remove KeyInfo node but it is no longer a child of <EncryptedType>");
  +
  +	}
  +
  +	mp_keyInfoNode->release();		// No longer required
  +
  +	mp_keyInfoNode = NULL;
  +
  +	// Clear out the list
  +	m_keyInfoList.empty();
   
  -	return NULL;
   }
   
  -XENCEncryptionMethod * XENCEncryptedTypeImpl::getEncryptionMethod(void) {
  +void XENCEncryptedTypeImpl::createKeyInfoElement(void) {
  +
  +	if (mp_keyInfoNode != NULL)
  +		return;
  +
  +	safeBuffer str;
  +
  +	const XMLCh * prefixNS = mp_env->getDSIGNSPrefix();
  +	makeQName(str, prefixNS, "KeyInfo");
  +
  +	mp_keyInfoNode = m_keyInfoList.createKeyInfo();
  +
  +	// Place the node before the CipherData node
  +	if (mp_cipherDataNode == NULL) {
  +
  +		throw XSECException(XSECException::EncryptedTypeError,
  +			"XENCEncryptedTypeImpl::createKeyInfoElement - unable to find CipherData node");
  +
  +	}
  +
  +	mp_encryptedTypeNode->insertBefore(mp_keyInfoNode, mp_cipherDataNode);
   	
  -	return mp_encryptionMethod;
  +	// Need to add the DS namespace
  +
  +	if (prefixNS[0] == '\0') {
  +		str.sbTranscodeIn("xmlns");
  +	}
  +	else {
  +		str.sbTranscodeIn("xmlns:");
  +		str.sbXMLChCat(prefixNS);
  +	}
  +
  +	static_cast<DOMElement *>(mp_keyInfoNode)->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS, 
  +							str.rawXMLChBuffer(), 
  +							DSIGConstants::s_unicodeStrURIDSIG);
  +
  +}
  +
  +
  +DSIGKeyInfoName * XENCEncryptedTypeImpl::appendKeyName(const XMLCh * name, bool isDName) {
  +
  +	createKeyInfoElement();
  +	return m_keyInfoList.appendKeyName(name, isDName);
   
   }
  
  
  
  1.6       +11 -2     xml-security/c/src/xenc/impl/XENCEncryptedTypeImpl.hpp
  
  Index: XENCEncryptedTypeImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptedTypeImpl.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XENCEncryptedTypeImpl.hpp	15 Sep 2003 11:53:09 -0000	1.5
  +++ XENCEncryptedTypeImpl.hpp	17 Sep 2003 10:10:22 -0000	1.6
  @@ -110,9 +110,13 @@
   
   	// Interface Methods
   	virtual XENCCipherData * getCipherData(void);
  -	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getDOMNode();
  +	//virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getDOMNode();
   	virtual DSIGKeyInfoList * getKeyInfoList(void) {return &m_keyInfoList;}
   	virtual XENCEncryptionMethod * getEncryptionMethod(void);
  +	virtual void clearKeyInfo(void);
  +	virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool isDName = false);
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  +		{return mp_encryptedTypeNode;}
   
   
   protected:
  @@ -122,11 +126,16 @@
   
   	TXFMChain * createCipherTXFMChain(void);
   
  +	// Worker function to start building the KeyInfo list
  +	void createKeyInfoElement(void);
  +
   	const XSECEnv				* mp_env;
   	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode					
   								* mp_encryptedTypeNode;		// Node at head of structure
   	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
   								* mp_keyInfoNode;			// Any underlying KeyInfo
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  +								* mp_cipherDataNode;		// CipherData structure
   	XENCCipherDataImpl			* mp_cipherData;
   	XENCEncryptionMethodImpl	* mp_encryptionMethod;
   
  
  
  
  1.2       +3 -1      xml-security/c/src/xenc/impl/XENCEncryptionMethodImpl.hpp
  
  Index: XENCEncryptionMethodImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptionMethodImpl.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XENCEncryptionMethodImpl.hpp	15 Sep 2003 11:52:35 -0000	1.1
  +++ XENCEncryptionMethodImpl.hpp	17 Sep 2003 10:10:22 -0000	1.2
  @@ -98,6 +98,8 @@
   
   	// Interface
   	const XMLCh * getAlgorithm(void) {return mp_algorithm;}
  +	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  +		{return mp_encryptionMethodNode;}
   
   private: