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/11/04 12:28:36 UTC

cvs commit: xml-security/c/src/xenc/impl XENCCipherDataImpl.cpp XENCCipherImpl.cpp XENCCipherImpl.hpp XENCEncryptedKeyImpl.cpp XENCEncryptedKeyImpl.hpp

blautenb    2003/11/04 03:28:36

  Modified:    c/src/tools/cipher MerlinFiveInteropResolver.cpp
                        MerlinFiveInteropResolver.hpp cipher.cpp
               c/src/tools/xtest xtest.cpp
               c/src/xenc XENCCipher.hpp XENCEncryptedKey.hpp
               c/src/xenc/impl XENCCipherDataImpl.cpp XENCCipherImpl.cpp
                        XENCCipherImpl.hpp XENCEncryptedKeyImpl.cpp
                        XENCEncryptedKeyImpl.hpp
  Log:
  Implemented support for CarriedKeyName and Recipient
  
  Revision  Changes    Path
  1.9       +59 -3     xml-security/c/src/tools/cipher/MerlinFiveInteropResolver.cpp
  
  Index: MerlinFiveInteropResolver.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/tools/cipher/MerlinFiveInteropResolver.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MerlinFiveInteropResolver.cpp	4 Nov 2003 05:22:17 -0000	1.8
  +++ MerlinFiveInteropResolver.cpp	4 Nov 2003 11:28:36 -0000	1.9
  @@ -72,10 +72,13 @@
   #include "MerlinFiveInteropResolver.hpp"
   
   #include <xsec/framework/XSECDefs.hpp>
  +#include <xsec/framework/XSECProvider.hpp>
   #include <xsec/enc/XSECKeyInfoResolver.hpp>
   #include <xsec/dsig/DSIGKeyInfoName.hpp>
   #include <xsec/dsig/DSIGKeyInfoX509.hpp>
   #include <xsec/utils/XSECDOMUtils.hpp>
  +#include <xsec/xenc/XENCCipher.hpp>
  +#include <xsec/xenc/XENCEncryptedKey.hpp>
   #include <xercesc/util/Janitor.hpp>
   #include <xercesc/util/XMLUniDefs.hpp>
   
  @@ -143,7 +146,7 @@
   // --------------------------------------------------------------------------------
   
   
  -MerlinFiveInteropResolver::MerlinFiveInteropResolver(const XMLCh * baseURI) {
  +MerlinFiveInteropResolver::MerlinFiveInteropResolver(DOMDocument * doc, const XMLCh * baseURI) {
   
   	if (baseURI != NULL)
   		mp_baseURI = XMLString::replicate(baseURI);
  @@ -154,6 +157,8 @@
   	m_fcount = 0;
   #endif
   
  +	mp_doc = doc;
  +
   }
   
   
  @@ -295,6 +300,57 @@
   				return k;
   			}
   
  +			// If we get this far, we don't know it.  So look for EncryptedKey elements
  +			// containing this name as a CarriedKeyName
  +
  +			DOMNode * c = mp_doc->getDocumentElement()->getFirstChild();
  +			while (c != NULL) {
  +
  +				if (c->getNodeType() == DOMNode::ELEMENT_NODE &&
  +					strEquals(getDSIGLocalName(c), MAKE_UNICODE_STRING("KeyInfo"))) {
  +
  +					DOMNode * ek = c->getFirstChild();
  +					while (ek != NULL) {
  +
  +						if (ek->getNodeType() == DOMNode::ELEMENT_NODE &&
  +							strEquals(getXENCLocalName(ek), MAKE_UNICODE_STRING("EncryptedKey"))) {
  +
  +							// Load
  +							XSECProvider prov;
  +							XENCCipher * cipher = prov.newCipher(mp_doc);
  +
  +							XENCEncryptedKey * xek = cipher->loadEncryptedKey(static_cast<DOMElement*>(ek));
  +							Janitor<XENCEncryptedKey> j_xek(xek);
  +
  +							if (strEquals(xek->getCarriedKeyName(), name) &&
  +								strEquals(xek->getRecipient(), MAKE_UNICODE_STRING("you"))) {
  +
  +								// This is it!
  +								cipher->setKeyInfoResolver(this);
  +								unsigned char keyBuf[1024];
  +								int sz = cipher->decryptKey(xek, keyBuf, 1024);
  +
  +								if (sz > 0) {
  +									XSECCryptoSymmetricKey * k = 
  +										XSECPlatformUtils::g_cryptoProvider->keySymmetric(XSECCryptoSymmetricKey::KEY_AES_256);
  +									try {
  +										k->setKey(keyBuf, sz);
  +									} catch (...) {
  +										delete k;
  +										throw;
  +									}
  +
  +									return k;
  +								}
  +							}
  +						}
  +						ek = ek->getNextSibling();
  +					}
  +				}
  +				
  +				c = c->getNextSibling();
  +			}
  +
   		}
   
   		else if (ki->getKeyInfoType() == DSIGKeyInfo::KEYINFO_X509) {
  @@ -361,7 +417,7 @@
   
   XSECKeyInfoResolver * MerlinFiveInteropResolver::clone(void) const {
   
  -	return new MerlinFiveInteropResolver(mp_baseURI);
  +	return new MerlinFiveInteropResolver(mp_doc, mp_baseURI);
   
   }
   
  
  
  
  1.3       +4 -2      xml-security/c/src/tools/cipher/MerlinFiveInteropResolver.hpp
  
  Index: MerlinFiveInteropResolver.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/tools/cipher/MerlinFiveInteropResolver.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MerlinFiveInteropResolver.hpp	13 Oct 2003 11:08:02 -0000	1.2
  +++ MerlinFiveInteropResolver.hpp	4 Nov 2003 11:28:36 -0000	1.3
  @@ -85,7 +85,7 @@
   
   public :
   
  -	MerlinFiveInteropResolver(const XMLCh * baseURI);
  +	MerlinFiveInteropResolver(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc, const XMLCh * baseURI);
   	~MerlinFiveInteropResolver();
   
   	// Interface functions
  @@ -100,6 +100,8 @@
   	XSECCryptoSymmetricKey * makeSymmetricKey(XSECCryptoSymmetricKey::SymmetricKeyType);
   
   	XMLCh *			mp_baseURI;
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument 
  +					*mp_doc;
   
   #if defined (_WIN32)
   	_finddata_t		m_finder;
  
  
  
  1.11      +2 -2      xml-security/c/src/tools/cipher/cipher.cpp
  
  Index: cipher.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/tools/cipher/cipher.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- cipher.cpp	4 Nov 2003 05:22:17 -0000	1.10
  +++ cipher.cpp	4 Nov 2003 11:28:36 -0000	1.11
  @@ -647,7 +647,7 @@
   
   				XMLUri uri(MAKE_UNICODE_STRING(baseURI));
   
  -				MerlinFiveInteropResolver ires(&(uri.getUriText()[8]));
  +				MerlinFiveInteropResolver ires(doc, &(uri.getUriText()[8]));
   				cipher->setKeyInfoResolver(&ires);
   
   			}
  
  
  
  1.32      +54 -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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- xtest.cpp	4 Nov 2003 05:22:17 -0000	1.31
  +++ xtest.cpp	4 Nov 2003 11:28:36 -0000	1.32
  @@ -260,6 +260,21 @@
   
   };
   
  +XMLCh s_tstCarriedKeyName[] = {
  +
  +	chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
  +	chLatin_C, chLatin_a, chLatin_r, chLatin_r, chLatin_y, chNull
  +
  +};
  +
  +XMLCh s_tstRecipient[] = {
  +
  +	chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
  +	chLatin_R, chLatin_e, chLatin_c, chLatin_i, chLatin_p,
  +	chLatin_i, chLatin_e, chLatin_n, chLatin_t, chNull
  +
  +};
  +
   XMLCh s_tstEncoding[] = {
   	chLatin_B, chLatin_a, chLatin_s, chLatin_e, chDigit_6, chDigit_4, chNull
   };
  @@ -1106,6 +1121,11 @@
   
   		cerr << "done!" << endl;
   
  +		cerr << "Adding CarriedKeyName and Recipient to encryptedKey ... " << endl;
  +		encryptedKey->setCarriedKeyName(s_tstCarriedKeyName);
  +		encryptedKey->setRecipient(s_tstRecipient);
  +		cerr << "done!" << endl;
  +
   		encryptedData->appendEncryptedKey(encryptedKey);
   
   		outputDoc(impl, doc);
  @@ -1151,7 +1171,8 @@
   		int nki = kil->getSize();
   		bool foundNameOK = false;
   
  -		for (int i = 0; i < nki; ++i) {
  +		int i;
  +		for (i = 0; i < nki; ++i) {
   
   			if (kil->item(i)->getKeyInfoType() == DSIGKeyInfo::KEYINFO_NAME) {
   
  @@ -1164,6 +1185,7 @@
   				foundNameOK = true;
   				break;
   			}
  +
   		}
   
   		if (foundNameOK == false) {
  @@ -1172,6 +1194,36 @@
   		}
   		else
   			cerr << "yes." << endl;
  +
  +		cerr << "Checking CarriedKeyName and Recipient values ... ";
  +		bool foundCCN = false;
  +		bool foundRecipient = false;
  +
  +		for (i = 0; i < nki; ++i) {
  +
  +			if (kil->item(i)->getKeyInfoType() == DSIGKeyInfo::KEYINFO_ENCRYPTEDKEY) {
  +
  +				XENCEncryptedKey * xek = dynamic_cast<XENCEncryptedKey*>(kil->item(i));
  +
  +				if (strEquals(xek->getCarriedKeyName(), s_tstCarriedKeyName)) {
  +
  +					foundCCN = true;
  +				}
  +				
  +				if (strEquals(xek->getRecipient(), s_tstRecipient)) {
  +
  +					foundRecipient = true;
  +				}
  +			}
  +		}
  +
  +		if (foundCCN == false || foundRecipient == false) {
  +			cerr << "no!" << endl;
  +			exit(1);
  +		}
  +		else {
  +			cerr << "OK" << endl;
  +		}
   
   		cerr << "Checking MimeType and Encoding ... ";
   		if (encryptedData->getMimeType() == NULL || !strEquals(encryptedData->getMimeType(), s_tstMimeType)) {
  
  
  
  1.10      +17 -2     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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XENCCipher.hpp	25 Oct 2003 10:29:15 -0000	1.9
  +++ XENCCipher.hpp	4 Nov 2003 11:28:36 -0000	1.10
  @@ -422,7 +422,7 @@
   
   	//@}
   
  -	/** @name Creation Functions */
  +	/** @name Creation and loading Functions */
   	//@{
   
   	/**
  @@ -447,6 +447,21 @@
   	virtual XENCEncryptedData * createEncryptedData(XENCCipherData::XENCCipherDataType type,
   													const XMLCh * algorithm,
   													const XMLCh * value) = 0;
  +
  +	/**
  +	 * \brief Load an EncryptedKey element
  +	 *
  +	 * Take a passed in EncryptedKey DOMNode and return a loaded XENCEncryptedKey
  +	 * object based on the DOMNode from the passed in element.
  +	 *
  +	 * @param keyNode Element node to load EncryptedKey from
  +	 * @returns An XENCEncryptedKey structure (owned by the caller) based on the 
  +	 * node.
  +	 */
  +
  +	virtual XENCEncryptedKey * loadEncryptedKey(
  +		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * keyNode
  +		) = 0;
   
   	//@}
   
  
  
  
  1.2       +66 -2     xml-security/c/src/xenc/XENCEncryptedKey.hpp
  
  Index: XENCEncryptedKey.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/XENCEncryptedKey.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XENCEncryptedKey.hpp	3 Oct 2003 09:50:51 -0000	1.1
  +++ XENCEncryptedKey.hpp	4 Nov 2003 11:28:36 -0000	1.2
  @@ -110,9 +110,73 @@
   
   	virtual ~XENCEncryptedKey() {};
   
  -	/** @name Get Interface Methods */
  +	/** @name EncryptedKey Specific Getter Methods */
   	//@{
   
  +	/**
  +	 * \brief Get the CarriedKeyName
  +	 *
  +	 * EncryptedKey elements MAY have a CarriedKeyName element that links
  +	 * the EncryptedKey to a KeyName KeyInfo element in another EncryptedKey
  +	 * or EncryptedData element.
  +	 * 
  +	 * This method allows applications to retrieve the Carried Key Name for
  +	 * the particular EncryptedKey
  +	 *
  +	 * @returns A pointer (owned by the library) to the CarriedKeyName string 
  +	 * (or NULL if none)
  +	 */
  +
  +	virtual const XMLCh * getCarriedKeyName(void) = 0;
  +
  +	/**
  +	 * \brief Get the Recipient name
  +	 *
  +	 * EncryptedKey elements MAY have a Recipient Attribute on the main
  +	 * EncryptedKey element that provide a hint to the application as to who
  +	 * the recipient of the key is.
  +	 *
  +	 * This method returns this string in cases where it has been provided
  +	 *
  +	 * @returns A pointer (owned by the library) to the Recipient string
  +	 * (or NULL if none provided).
  +	 */
  +
  +	virtual const XMLCh * getRecipient(void) = 0;
  +
  +	//@}
  +
  +	/** @name EncryptedKey Specific Setter Methods */
  +	//@{
  +
  +	/**
  +	 * \brief Set the CarriedKeyName
  +	 *
  +	 * EncryptedKey elements MAY have a CarriedKeyName element that links
  +	 * the EncryptedKey to a KeyName KeyInfo element in another EncryptedKey
  +	 * or EncryptedData element.
  +	 * 
  +	 * This method allows applications to set the Carried Key Name for
  +	 * the particular EncryptedKey
  +	 *
  +	 * @param name String to set in the CarriedKeyName element
  +	 */
  +
  +	virtual void setCarriedKeyName(const XMLCh * name) = 0;
  +
  +	/**
  +	 * \brief Set the Recipient name
  +	 *
  +	 * EncryptedKey elements MAY have a Recipient Attribute on the main
  +	 * EncryptedKey element that provide a hint to the application as to who
  +	 * the recipient of the key is.
  +	 *
  +	 * This method sets the Recipient string
  +	 *
  +	 * @param recipient String to set in the Recipient attribute
  +	 */
  +
  +	virtual void setRecipient(const XMLCh * recipient) = 0;
   
   	//@}
   
  
  
  
  1.7       +2 -3      xml-security/c/src/xenc/impl/XENCCipherDataImpl.cpp
  
  Index: XENCCipherDataImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCCipherDataImpl.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XENCCipherDataImpl.cpp	19 Oct 2003 10:58:59 -0000	1.6
  +++ XENCCipherDataImpl.cpp	4 Nov 2003 11:28:36 -0000	1.7
  @@ -34,8 +34,7 @@
    *    permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  
  
  
  1.14      +13 -4     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XENCCipherImpl.cpp	4 Nov 2003 05:22:17 -0000	1.13
  +++ XENCCipherImpl.cpp	4 Nov 2003 11:28:36 -0000	1.14
  @@ -725,6 +725,16 @@
   		int maxKeySize
   		) {
   
  +	XENCEncryptedKey * encryptedKey = loadEncryptedKey(keyNode);
  +	Janitor<XENCEncryptedKey> j_encryptedKey(encryptedKey);
  +
  +	// Now decrypt!
  +	return decryptKey(encryptedKey, rawKey, maxKeySize);
  +
  +}
  +
  +XENCEncryptedKey * XENCCipherImpl::loadEncryptedKey(DOMElement * keyNode) {
  +
   	XENCEncryptedKeyImpl * encryptedKey;
   	XSECnew(encryptedKey, 
   		XENCEncryptedKeyImpl(mp_env, dynamic_cast<DOMNode *>(keyNode)));
  @@ -733,11 +743,10 @@
   	// Load
   	encryptedKey->load();
   
  -	// Now decrypt!
  -	return decryptKey(encryptedKey, rawKey, maxKeySize);
  +	j_encryptedKey.release();
  +	return encryptedKey;
   
   }
  -
   // --------------------------------------------------------------------------------
   //			Encrypt a BinInputStream
   // --------------------------------------------------------------------------------
  
  
  
  1.12      +4 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XENCCipherImpl.hpp	25 Oct 2003 10:29:15 -0000	1.11
  +++ XENCCipherImpl.hpp	4 Nov 2003 11:28:36 -0000	1.12
  @@ -156,6 +156,9 @@
   	XENCEncryptedData * createEncryptedData(XENCCipherData::XENCCipherDataType type,
   											const XMLCh * algorithm,
   											const XMLCh * value);
  +	virtual XENCEncryptedKey * loadEncryptedKey(
  +		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * keyNode
  +		);
   
   protected:
   
  
  
  
  1.2       +150 -4    xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.cpp
  
  Index: XENCEncryptedKeyImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XENCEncryptedKeyImpl.cpp	3 Oct 2003 09:50:51 -0000	1.1
  +++ XENCEncryptedKeyImpl.cpp	4 Nov 2003 11:28:36 -0000	1.2
  @@ -73,6 +73,7 @@
   #include "XENCCipherDataImpl.hpp"
   
   #include <xsec/framework/XSECError.hpp>
  +#include <xsec/framework/XSECEnv.hpp>
   #include <xsec/utils/XSECDOMUtils.hpp>
   
   #include <xercesc/util/XMLUniDefs.hpp>
  @@ -97,7 +98,40 @@
   	chLatin_K,
   	chLatin_e,
   	chLatin_y,
  -	chNull,
  +	chNull
  +};
  +
  +static XMLCh s_CarriedKeyName[] = {
  +
  +	chLatin_C,
  +	chLatin_a,
  +	chLatin_r,
  +	chLatin_r,
  +	chLatin_i,
  +	chLatin_e,
  +	chLatin_d,
  +	chLatin_K,
  +	chLatin_e,
  +	chLatin_y,
  +	chLatin_N,
  +	chLatin_a,
  +	chLatin_m,
  +	chLatin_e,
  +	chNull
  +};
  +
  +static XMLCh s_Recipient[] = {
  +
  +	chLatin_R,
  +	chLatin_e,
  +	chLatin_c,
  +	chLatin_i,
  +	chLatin_p,
  +	chLatin_i,
  +	chLatin_e,
  +	chLatin_n,
  +	chLatin_t,
  +	chNull
   };
   
   // --------------------------------------------------------------------------------
  @@ -107,13 +141,17 @@
   
   XENCEncryptedKeyImpl::XENCEncryptedKeyImpl(const XSECEnv * env) :
   XENCEncryptedTypeImpl(env),
  -XENCEncryptedKey(env) {
  +XENCEncryptedKey(env),
  +mp_carriedKeyNameTextNode(NULL),
  +mp_recipientAttributeNode(NULL) {
   	
   }
   
   XENCEncryptedKeyImpl::XENCEncryptedKeyImpl(const XSECEnv * env, DOMNode * node) :
   XENCEncryptedTypeImpl(env, node),
  -XENCEncryptedKey(env) {
  +XENCEncryptedKey(env),
  +mp_carriedKeyNameTextNode(NULL),
  +mp_recipientAttributeNode(NULL) {
   
   }
   
  @@ -149,6 +187,31 @@
   	// Set up the keyInfo node
   	mp_keyInfoDOMNode = mp_encryptedTypeNode;
   
  +	// Find the Recipient Attribute
  +	DOMNamedNodeMap * tmpAtts = mp_encryptedTypeNode->getAttributes();
  +
  +	if (tmpAtts != NULL) {
  +
  +		mp_recipientAttributeNode = tmpAtts->getNamedItem(s_Recipient);
  +
  +	}
  +
  +	// Now load specific EncryptedKey elements
  +	DOMNode * c = findFirstChildOfType(mp_encryptedTypeNode, DOMNode::ELEMENT_NODE);
  +
  +	while (c != NULL) {
  +
  +		if (strEquals(getXENCLocalName(c), s_CarriedKeyName)) {
  +
  +			// Have a CarriedKeyName node
  +			mp_carriedKeyNameTextNode = findFirstChildOfType(c, DOMNode::TEXT_NODE);
  +
  +		}
  +
  +		c = findNextChildOfType(c, DOMNode::ELEMENT_NODE);
  +
  +	}
  +
   }
   // --------------------------------------------------------------------------------
   //			Create from scratch
  @@ -172,4 +235,87 @@
   //			Interface Methods
   // --------------------------------------------------------------------------------
   
  +
  +const XMLCh * XENCEncryptedKeyImpl::getCarriedKeyName(void) {
  +
  +	if (mp_carriedKeyNameTextNode != NULL)
  +		return mp_carriedKeyNameTextNode->getNodeValue();
  +
  +	return NULL;
  +
  +}
  +
  +const XMLCh * XENCEncryptedKeyImpl::getRecipient(void) {
  +
  +	if (mp_recipientAttributeNode != NULL)
  +		return mp_recipientAttributeNode->getNodeValue();
  +
  +	return NULL;
  +
  +}
  +
  +void XENCEncryptedKeyImpl::setCarriedKeyName(const XMLCh * name) {
  +
  +	if (mp_carriedKeyNameTextNode == NULL) {
  +
  +		// Get some setup values
  +		safeBuffer str;
  +		DOMDocument *doc = XENCEncryptedTypeImpl::mp_env->getParentDocument();
  +		const XMLCh * prefix = XENCEncryptedTypeImpl::mp_env->getXENCNSPrefix();
  +
  +		makeQName(str, prefix, s_CarriedKeyName);
  +
  +		DOMElement *e = doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
  +
  +		mp_encryptedTypeNode->appendChild(e);
  +		XENCEncryptedTypeImpl::mp_env->doPrettyPrint(mp_encryptedTypeNode);
  +
  +		mp_carriedKeyNameTextNode = doc->createTextNode(name);
  +		e->appendChild(mp_carriedKeyNameTextNode);
  +
  +	} 
  +	
  +	else {
  +
  +		mp_carriedKeyNameTextNode->setNodeValue(name);
  +
  +	}
  +}
  +
  +void XENCEncryptedKeyImpl::setRecipient(const XMLCh * recipient) {
  +
  +	if (mp_recipientAttributeNode == NULL) {
  +
  +		if (mp_encryptedTypeNode->getNodeType() != DOMNode::ELEMENT_NODE) {
  +			throw XSECException(XSECException::EncryptedTypeError,
  +				"XENCEncryptedKeyImpl::setRecipient - encryptedTypeNode is not an Element");
  +		}
  +
  +		DOMElement * e = static_cast<DOMElement*> (mp_encryptedTypeNode);
  +		e->setAttributeNS(DSIGConstants::s_unicodeStrURIXENC, 
  +											 s_Recipient,
  +											 recipient);
  +		// Now retrieve for later use
  +		DOMNamedNodeMap * tmpAtts = e->getAttributes();
  +
  +		if (tmpAtts != NULL) {
  +
  +			mp_recipientAttributeNode = tmpAtts->getNamedItem(s_Recipient);
  +
  +		}
  +
  +		if (mp_recipientAttributeNode == NULL) {
  +
  +			throw XSECException(XSECException::EncryptionMethodError,
  +				"XENCEncryptionKey::setRecipient - Error creating Recipient Attribute");
  +		}
  +	} 
  +	
  +	else {
  +
  +		mp_recipientAttributeNode->setNodeValue(recipient);
  +
  +	}
  +
  +}
   
  
  
  
  1.4       +15 -1     xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.hpp
  
  Index: XENCEncryptedKeyImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XENCEncryptedKeyImpl.hpp	26 Oct 2003 11:33:13 -0000	1.3
  +++ XENCEncryptedKeyImpl.hpp	4 Nov 2003 11:28:36 -0000	1.4
  @@ -136,12 +136,26 @@
   	virtual void setEncodingURI(const XMLCh * uri)
   		{XENCEncryptedTypeImpl::setEncodingURI(uri);}
   
  +	// EncryptedKey specific Getter Methods
  +	virtual const XMLCh * getCarriedKeyName(void);
  +	virtual const XMLCh * getRecipient(void);
  +
  +	// EncryptedKey specific setter methods
  +	virtual void setCarriedKeyName(const XMLCh * name);
  +	virtual void setRecipient(const XMLCh * recipient);
  +
  +
   private:
   
   	// Unimplemented
   	XENCEncryptedKeyImpl(void);
   	XENCEncryptedKeyImpl(const XENCEncryptedKeyImpl &);
   	XENCEncryptedKeyImpl & operator = (const XENCEncryptedKeyImpl &);
  +
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  +								* mp_carriedKeyNameTextNode;
  +	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  +								* mp_recipientAttributeNode;
   
   };