blautenb    2003/11/20 01:11:25

  Modified:    c/src/tools/xtest xtest.cpp
               c/src/utils XSECDOMUtils.cpp XSECDOMUtils.hpp
               c/src/xenc XENCEncryptionMethod.hpp
               c/src/xenc/impl XENCEncryptedTypeImpl.cpp
                        XENCEncryptionMethodImpl.cpp
                        XENCEncryptionMethodImpl.hpp
  Log:
  Cleaned up EncryptionMethod code
  
  Revision  Changes    Path
  1.35      +14 -1     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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- xtest.cpp 10 Nov 2003 22:10:37 -0000      1.34
  +++ xtest.cpp 20 Nov 2003 09:11:25 -0000      1.35
  @@ -127,6 +127,7 @@
   #include <xsec/xenc/XENCCipher.hpp>
   #include <xsec/xenc/XENCEncryptedData.hpp>
   #include <xsec/xenc/XENCEncryptedKey.hpp>
  +#include <xsec/xenc/XENCEncryptionMethod.hpp>
   
   #include <xsec/enc/XSECCryptoSymmetricKey.hpp>
   
  @@ -1347,6 +1348,10 @@
                encryptedData->setEncodingURI(s_tstEncoding);
                encryptedData->setMimeType(s_tstMimeType);
   
  +             // Set a KeySize
  +             cerr << "done\nSetting <KeySize> ... ";
  +             encryptedData->getEncryptionMethod()->setKeySize(192);
  +
                cerr << "done\nSearching for <category> ... ";
   
                DOMNode * t = findNode(doc, MAKE_UNICODE_STRING("category"));
  @@ -1484,6 +1489,14 @@
                }
                if (encryptedData->getEncodingURI() == NULL || 
!strEquals(encryptedData->getEncodingURI(), s_tstEncoding)) {
                        cerr << "Bad Encoding" << endl;
  +                     exit(1);
  +             }
  +
  +             cerr << "OK" << endl;
  +
  +             cerr << "Checking KeySize in EncryptionMethod ... ";
  +             if (encryptedData->getEncryptionMethod() == NULL || 
encryptedData->getEncryptionMethod()->getKeySize() != 192) {
  +                     cerr << "Bad KeySize" << endl;
                        exit(1);
                }
   
  
  
  
  1.15      +31 -0     xml-security/c/src/utils/XSECDOMUtils.cpp
  
  Index: XSECDOMUtils.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/utils/XSECDOMUtils.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XSECDOMUtils.cpp  11 Sep 2003 11:11:05 -0000      1.14
  +++ XSECDOMUtils.cpp  20 Nov 2003 09:11:25 -0000      1.15
  @@ -225,6 +225,37 @@
   
   }
   
  +DOMElement *findFirstElementChild(DOMNode *n) {
  +
  +     DOMNode *c;
  +
  +     if (n == NULL) 
  +             return NULL;
  +
  +     c = n->getFirstChild();
  +
  +     while (c != NULL && c->getNodeType() != DOMNode::ELEMENT_NODE)
  +             c = c->getNextSibling();
  +
  +     return (DOMElement *) c;
  +
  +}
  +
  +DOMElement * findNextElementChild(DOMNode *n) {
  +
  +     DOMNode * s = n;
  +
  +     if (s == NULL)
  +             return NULL;
  +
  +     do {
  +             s = s->getNextSibling();
  +     } while (s != NULL && s->getNodeType() != DOMNode::ELEMENT_NODE);
  +
  +     return (DOMElement *) s;
  +
  +}
  +
   // 
--------------------------------------------------------------------------------
   //           Make a QName
   // 
--------------------------------------------------------------------------------
  
  
  
  1.13      +4 -1      xml-security/c/src/utils/XSECDOMUtils.hpp
  
  Index: XSECDOMUtils.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/utils/XSECDOMUtils.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XSECDOMUtils.hpp  11 Sep 2003 11:11:05 -0000      1.12
  +++ XSECDOMUtils.hpp  20 Nov 2003 09:11:25 -0000      1.13
  @@ -136,6 +136,9 @@
   XERCES_CPP_NAMESPACE_QUALIFIER DOMNode DSIG_EXPORT * 
findFirstChildOfType(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n, 
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::NodeType t);
   XERCES_CPP_NAMESPACE_QUALIFIER DOMNode DSIG_EXPORT * 
findNextChildOfType(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n, 
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode::NodeType t);
   
  +XERCES_CPP_NAMESPACE_QUALIFIER DOMElement DSIG_EXPORT * 
findFirstElementChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n);
  +XERCES_CPP_NAMESPACE_QUALIFIER DOMElement DSIG_EXPORT * 
findNextElementChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n);
  +
   // 
--------------------------------------------------------------------------------
   //           Make a QName
   // 
--------------------------------------------------------------------------------
  
  
  
  1.5       +37 -4     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XENCEncryptionMethod.hpp  4 Nov 2003 05:22:17 -0000       1.4
  +++ XENCEncryptionMethod.hpp  20 Nov 2003 09:11:25 -0000      1.5
  @@ -89,6 +89,17 @@
    * this information, otherwise the library will not be able to
    * decrypt the data.
    *
  + * It is defined as :
  + *
  + * <complexType name='EncryptionMethodType' mixed='true'>
  + *   <sequence>
  + *     <element name='KeySize' minOccurs='0' type='xenc:KeySizeType'/>
  + *     <element name='OAEPparams' minOccurs='0' type='base64Binary'/>
  + *     <any namespace='##other' minOccurs='0' maxOccurs='unbounded'/>
  + *   </sequence>
  + *   <attribute name='Algorithm' type='anyURI' use='required'/>
  + * </complexType>
  + *
    */
   
   
  @@ -137,12 +148,22 @@
        virtual const XMLCh * getOAEPparams(void) = 0;
   
        /**
  -      * \brief Get the DOM Node of this structure
  +      * \brief Get the KeySize that was set in this EncryptionMethod.
         *
  -      * @returns the DOM Node representing the <EncryptionMethod> element
  +      * This field would not normally be used for the encryption algorithms
  +      * explicitly referenced in the XML Encryption standard.  It is provided
  +      * mainly for stream ciphers that have a variable key length
         */
   
  -     virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void) = 0;
  +     virtual int getKeySize(void) = 0;
  +
  +     /**
  +      * \brief Get the DOM Element Node of this structure
  +      *
  +      * @returns the DOM Element Node representing the <EncryptionMethod> 
element
  +      */
  +
  +     virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) = 
0;
   
   
        //@}
  @@ -173,6 +194,18 @@
         */
   
        virtual void setOAEPparams(const XMLCh * params) = 0;
  +
  +     /**
  +      * \brief Set the KeySize that in this EncryptionMethod.
  +      *
  +      * This field would not normally be used for the encryption algorithms
  +      * explicitly referenced in the XML Encryption standard.  It is provided
  +      * mainly for stream ciphers that have a variable key length
  +      */
  +
  +     virtual void setKeySize(int size) = 0;
  +
  +     //@}
   
   private:
   
  
  
  
  1.12      +5 -5      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XENCEncryptedTypeImpl.cpp 10 Nov 2003 22:10:37 -0000      1.11
  +++ XENCEncryptedTypeImpl.cpp 20 Nov 2003 09:11:25 -0000      1.12
  @@ -251,14 +251,14 @@
        // Don't know what the node name should be (held by super class), 
        // so go straight to the children
        
  -     DOMNode *tmpElt = findFirstChildOfType(mp_encryptedTypeNode, 
DOMNode::ELEMENT_NODE);
  +     DOMElement *tmpElt = (DOMElement *) 
findFirstChildOfType(mp_encryptedTypeNode, DOMNode::ELEMENT_NODE);
   
        if (tmpElt != NULL && strEquals(getXENCLocalName(tmpElt), 
s_EncryptionMethod)) {
   
                XSECnew(mp_encryptionMethod, XENCEncryptionMethodImpl(mp_env, 
tmpElt));
                mp_encryptionMethod->load();
   
  -             tmpElt = findNextChildOfType(tmpElt, DOMNode::ELEMENT_NODE);
  +             tmpElt = (DOMElement *) findNextChildOfType(tmpElt, 
DOMNode::ELEMENT_NODE);
   
        }
   
  @@ -270,7 +270,7 @@
   
                // Find the next node
   
  -             tmpElt = findNextChildOfType(tmpElt, DOMNode::ELEMENT_NODE);
  +             tmpElt = (DOMElement *) findNextChildOfType(tmpElt, 
DOMNode::ELEMENT_NODE);
   
        }
   
  @@ -280,7 +280,7 @@
   
                XSECnew(mp_cipherData, XENCCipherDataImpl(mp_env, tmpElt));
                mp_cipherData->load();
  -             tmpElt = findNextChildOfType(tmpElt, DOMNode::ELEMENT_NODE);
  +             tmpElt = (DOMElement *) findNextChildOfType(tmpElt, 
DOMNode::ELEMENT_NODE);
   
        }
   
  
  
  
  1.3       +143 -76   xml-security/c/src/xenc/impl/XENCEncryptionMethodImpl.cpp
  
  Index: XENCEncryptionMethodImpl.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-security/c/src/xenc/impl/XENCEncryptionMethodImpl.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XENCEncryptionMethodImpl.cpp      4 Nov 2003 05:22:17 -0000       1.2
  +++ XENCEncryptionMethodImpl.cpp      20 Nov 2003 09:11:25 -0000      1.3
  @@ -135,34 +135,46 @@
        chNull
   };
   
  +static XMLCh s_KeySize [] = {
  +
  +     chLatin_K,
  +     chLatin_e,
  +     chLatin_y,
  +     chLatin_S,
  +     chLatin_i,
  +     chLatin_z,
  +     chLatin_e,
  +     chNull
  +};
  +
   // 
--------------------------------------------------------------------------------
   //                   Constructors and Destructors
   // 
--------------------------------------------------------------------------------
   
   XENCEncryptionMethodImpl::XENCEncryptionMethodImpl(const XSECEnv * env) :
   mp_env(env),
  -mp_encryptionMethodNode(NULL),
  -mp_algorithm(NULL),
  -mp_digestAlgorithmAttributeNode(NULL),
  -mp_oaepParamsTextNode(NULL) {
  +mp_encryptionMethodElement(NULL),
  +mp_algorithmAttr(NULL),
  +mp_digestAlgorithmAttr(NULL),
  +mp_oaepParamsTextNode(NULL),
  +mp_keySizeTextNode(NULL) {
   
   }
   
   XENCEncryptionMethodImpl::XENCEncryptionMethodImpl(
                const XSECEnv * env, 
  -             DOMNode * node) :
  +             DOMElement * element) :
   mp_env(env),
  -mp_encryptionMethodNode(node),
  -mp_algorithm(NULL),
  -mp_digestAlgorithmAttributeNode(NULL),
  -mp_oaepParamsTextNode(NULL) {
  +mp_encryptionMethodElement(element),
  +mp_algorithmAttr(NULL),
  +mp_digestAlgorithmAttr(NULL),
  +mp_oaepParamsTextNode(NULL),
  +mp_keySizeTextNode(NULL) {
   
   }
   
   XENCEncryptionMethodImpl::~XENCEncryptionMethodImpl() {
   
  -     if (mp_algorithm != NULL)
  -             delete[] mp_algorithm;
   
   }
   
  @@ -174,7 +186,7 @@
   
   void XENCEncryptionMethodImpl::load() {
   
  -     if (mp_encryptionMethodNode == NULL) {
  +     if (mp_encryptionMethodElement == NULL) {
   
                // Attempt to load an empty encryptedType element
                throw XSECException(XSECException::EncryptionMethodError,
  @@ -182,7 +194,7 @@
   
        }
   
  -     if (!strEquals(getXENCLocalName(mp_encryptionMethodNode), 
s_EncryptionMethod)) {
  +     if (!strEquals(getXENCLocalName(mp_encryptionMethodElement), 
s_EncryptionMethod)) {
   
                // Attempt to load an empty encryptedData element
                throw XSECException(XSECException::EncryptionMethodError,
  @@ -190,39 +202,22 @@
   
        }
   
  -     // Clean up
  -     if (mp_algorithm != NULL)
  -             delete[] mp_algorithm;
  -
        // Find the type
  -     DOMNamedNodeMap * tmpAtts = mp_encryptionMethodNode->getAttributes();
  -
  -     if (tmpAtts != NULL) {
  -
  -             DOMNode * att = 
tmpAtts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm);
  -
  -             if (att != NULL) {
  -
  -                     mp_algorithm = 
XMLString::replicate(att->getNodeValue());
  -
  -             }
  -
  -     }
  +     mp_algorithmAttr = 
  +             mp_encryptionMethodElement->getAttributeNodeNS(NULL, 
  +                     DSIGConstants::s_unicodeStrAlgorithm);
   
        // Check for known children
  -     DOMNode * c = findFirstChildOfType(mp_encryptionMethodNode, 
DOMNode::ELEMENT_NODE);
  +     DOMElement * c = findFirstElementChild(mp_encryptionMethodElement);
   
        while (c != NULL) {
   
                if (strEquals(getDSIGLocalName(c), s_DigestMethod)) {
   
  -                     mp_digestAlgorithmAttributeNode = NULL;
  -                     tmpAtts = c->getAttributes();
  -
  -                     if (tmpAtts != NULL)
  -                             mp_digestAlgorithmAttributeNode = 
tmpAtts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm);
  +                     mp_digestAlgorithmAttr = c->getAttributeNodeNS(NULL, 
  +                             DSIGConstants::s_unicodeStrAlgorithm);
   
  -                     if (mp_digestAlgorithmAttributeNode == NULL) {
  +                     if (mp_digestAlgorithmAttr == NULL) {
                                throw 
XSECException(XSECException::EncryptionMethodError,
                                        "XENCEncryptionMethod::load - Cannot 
find Algorithm Attribute in DigestMethod element");
                        }
  @@ -240,9 +235,18 @@
   
                }
   
  -             do {
  -                     c = c->getNextSibling();
  -             } while (c != NULL && c->getNodeType() != 
DOMNode::ELEMENT_NODE);
  +             else if (strEquals(getXENCLocalName(c), s_KeySize)) {
  +
  +                     mp_keySizeTextNode = NULL;
  +                     mp_keySizeTextNode = findFirstChildOfType(c, 
DOMNode::TEXT_NODE);
  +
  +                     if (mp_keySizeTextNode == NULL) {
  +                             throw 
XSECException(XSECException::EncryptionMethodError,
  +                                     "XENCEncryptionMethod::load - Cannot 
find text value of KeySize node");
  +                     }
  +
  +             }
  +             c = findNextElementChild(c);
        }
   }
   
  @@ -252,12 +256,6 @@
   
   DOMElement * XENCEncryptionMethodImpl::createBlankEncryptedMethod(const 
XMLCh * algorithm) {
   
  -     // Reset
  -     if (mp_algorithm != NULL) {
  -             delete[] mp_algorithm;
  -             mp_algorithm = NULL;
  -     }
  -
        // Get some setup values
        safeBuffer str;
        DOMDocument *doc = mp_env->getParentDocument();
  @@ -265,20 +263,21 @@
   
        makeQName(str, prefix, s_EncryptionMethod);
   
  -     DOMElement *ret = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
  -     mp_encryptionMethodNode = ret;
  +     mp_encryptionMethodElement = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
   
        // Set the algorithm attribute
   
        if (algorithm != NULL) {
  -             ret->setAttributeNS(DSIGConstants::s_unicodeStrURIXENC,
  +             mp_encryptionMethodElement->setAttributeNS(NULL,
                                                        
DSIGConstants::s_unicodeStrAlgorithm,
                                                        algorithm);
  -             mp_algorithm = XMLString::replicate(algorithm);
  +             mp_algorithmAttr = 
  +                     mp_encryptionMethodElement->getAttributeNodeNS(NULL, 
  +                                                                             
                                   DSIGConstants::s_unicodeStrAlgorithm);
   
        }
   
  -     return ret;
  +     return mp_encryptionMethodElement;
   
   }
   // 
--------------------------------------------------------------------------------
  @@ -287,8 +286,8 @@
   
   const XMLCh * XENCEncryptionMethodImpl::getDigestMethod(void) {
   
  -     if (mp_digestAlgorithmAttributeNode != NULL)
  -             return mp_digestAlgorithmAttributeNode->getNodeValue();
  +     if (mp_digestAlgorithmAttr != NULL)
  +             return mp_digestAlgorithmAttr->getNodeValue();
   
        return NULL;
   
  @@ -304,17 +303,46 @@
   
   }
   
  +const XMLCh * XENCEncryptionMethodImpl::getAlgorithm(void) {
  +
  +     if (mp_algorithmAttr != NULL) {
  +             return mp_algorithmAttr->getNodeValue();
  +     }
  +
  +     return NULL;
  +
  +}
  +
  +int XENCEncryptionMethodImpl::getKeySize(void) {
  +
  +     if(mp_keySizeTextNode != NULL) {
  +
  +             const XMLCh * keyVal = mp_keySizeTextNode->getNodeValue();
  +             unsigned int res = 0;
  +             if (!XMLString::textToBin(keyVal, res) || res < 0) {
  +                     throw 
XSECException(XSECException::EncryptionMethodError,
  +                             "XENCEncryptionMethod::getKeySize - Cannot 
convert KeySize to integer");
  +             }
  +
  +             return (int) res;
  +
  +     }
  +
  +     return 0;
  +
  +}
  +
   // 
--------------------------------------------------------------------------------
   //                   Setter functions
   // 
--------------------------------------------------------------------------------
   
   void XENCEncryptionMethodImpl::setDigestMethod(const XMLCh * method) {
   
  -     if (mp_digestAlgorithmAttributeNode == NULL) {
  +     if (mp_digestAlgorithmAttr == NULL) {
   
                // Need to create
                if (mp_oaepParamsTextNode == NULL) {
  -                     mp_env->doPrettyPrint(mp_encryptionMethodNode);
  +                     mp_env->doPrettyPrint(mp_encryptionMethodElement);
                }
   
                // Get some setup values
  @@ -326,20 +354,21 @@
   
                DOMElement *e = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
                if (mp_oaepParamsTextNode != NULL) {
  -                     mp_encryptionMethodNode->insertBefore(e, 
mp_oaepParamsTextNode->getParentNode());
  +                     mp_encryptionMethodElement->insertBefore(e, 
mp_oaepParamsTextNode->getParentNode());
                        if (mp_env->getPrettyPrintFlag())
  -                             
mp_encryptionMethodNode->insertBefore(doc->createTextNode(DSIGConstants::s_unicodeStrNL),
 mp_oaepParamsTextNode->getParentNode());
  +                             
mp_encryptionMethodElement->insertBefore(doc->createTextNode(DSIGConstants::s_unicodeStrNL),
 mp_oaepParamsTextNode->getParentNode());
                }
                else {
  -                     mp_encryptionMethodNode->appendChild(e);
  -                     mp_env->doPrettyPrint(mp_encryptionMethodNode);
  +                     mp_encryptionMethodElement->appendChild(e);
  +                     mp_env->doPrettyPrint(mp_encryptionMethodElement);
                }
   
  -             e->setAttributeNS(DSIGConstants::s_unicodeStrURIDSIG,
  -                                                     
DSIGConstants::s_unicodeStrAlgorithm,
  -                                                     method);
  +             e->setAttributeNS(NULL,
  +                                     DSIGConstants::s_unicodeStrAlgorithm,
  +                                     method);
   
                // Set namespace
  +
                if (prefix[0] == XERCES_CPP_NAMESPACE::chNull) {
                        str.sbTranscodeIn("xmlns");
                }
  @@ -353,15 +382,11 @@
                                                                
DSIGConstants::s_unicodeStrURIXENC);
   
                // Now retrieve for later use
  -             DOMNamedNodeMap * tmpAtts = e->getAttributes();
  -
  -             if (tmpAtts != NULL) {
  -
  -                     mp_digestAlgorithmAttributeNode = 
tmpAtts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm);
  -
  -             }
  +             mp_digestAlgorithmAttr =
  +                     e->getAttributeNodeNS(NULL, 
  +                             DSIGConstants::s_unicodeStrAlgorithm);
   
  -             if (mp_digestAlgorithmAttributeNode == NULL) {
  +             if (mp_digestAlgorithmAttr == NULL) {
   
                        throw 
XSECException(XSECException::EncryptionMethodError,
                                "XENCEncryptionMethod::setDigestMethod - Error 
creating Algorithm Attribute");
  @@ -370,7 +395,7 @@
        
        else {
   
  -             mp_digestAlgorithmAttributeNode->setNodeValue(method);
  +             mp_digestAlgorithmAttr->setNodeValue(method);
   
        }
   
  @@ -381,8 +406,8 @@
        if (mp_oaepParamsTextNode == NULL) {
   
                // Need to create
  -             if (mp_digestAlgorithmAttributeNode == NULL) {
  -                     mp_env->doPrettyPrint(mp_encryptionMethodNode);
  +             if (mp_digestAlgorithmAttr == NULL) {
  +                     mp_env->doPrettyPrint(mp_encryptionMethodElement);
                }
   
                // Get some setup values
  @@ -393,8 +418,8 @@
                makeQName(str, prefix, s_OAEPparams);
   
                DOMElement *e = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
  -             mp_encryptionMethodNode->appendChild(e);
  -             mp_env->doPrettyPrint(mp_encryptionMethodNode);
  +             mp_encryptionMethodElement->appendChild(e);
  +             mp_env->doPrettyPrint(mp_encryptionMethodElement);
   
                mp_oaepParamsTextNode = doc->createTextNode(params);
                e->appendChild(mp_oaepParamsTextNode);
  @@ -409,3 +434,45 @@
   
   }
   
  +
  +void XENCEncryptionMethodImpl::setKeySize(int size) {
  +
  +     // First map the int to an XMLCh string
  +     XMLCh sizeXMLCh[10];
  +     XMLString::binToText((unsigned int) size, sizeXMLCh, 9, 10);
  +
  +     if (mp_keySizeTextNode == NULL) {
  +
  +             // Get some setup values
  +             safeBuffer str;
  +             DOMDocument *doc = mp_env->getParentDocument();
  +             const XMLCh * prefix = mp_env->getXENCNSPrefix();
  +
  +             makeQName(str, prefix, s_KeySize);
  +
  +             DOMElement *e = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIXENC, str.rawXMLChBuffer());
  +             if (mp_oaepParamsTextNode != NULL) {
  +                     // Need to insert before
  +                     DOMNode * oaepNode = 
mp_oaepParamsTextNode->getParentNode();
  +                     mp_encryptionMethodElement->insertBefore(e, oaepNode);
  +                     if (mp_env->getPrettyPrintFlag()) {
  +                             
mp_encryptionMethodElement->insertBefore(doc->createTextNode(DSIGConstants::s_unicodeStrNL),
  +                                                                             
                                 oaepNode);
  +                     }
  +             }
  +             else {
  +                     mp_env->doPrettyPrint(mp_encryptionMethodElement);
  +                     mp_encryptionMethodElement->appendChild(e);
  +                     mp_env->doPrettyPrint(mp_encryptionMethodElement);
  +             }
  +
  +             e->appendChild(doc->createTextNode(sizeXMLCh));
  +     } 
  +     
  +     else {
  +
  +             mp_keySizeTextNode->setNodeValue(sizeXMLCh);
  +
  +     }
  +
  +}
  
  
  
  1.4       +15 -10    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XENCEncryptionMethodImpl.hpp      4 Nov 2003 05:22:17 -0000       1.3
  +++ XENCEncryptionMethodImpl.hpp      20 Nov 2003 09:11:25 -0000      1.4
  @@ -85,7 +85,7 @@
        XENCEncryptionMethodImpl(const XSECEnv * env);
        XENCEncryptionMethodImpl(
                const XSECEnv * env, 
  -             XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node
  +             XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * element
        );
        virtual ~XENCEncryptionMethodImpl();
   
  @@ -97,13 +97,15 @@
                                                const XMLCh * algorithm);
   
        // Interface
  -     const XMLCh * getAlgorithm(void) {return mp_algorithm;}
  -     virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
  -             {return mp_encryptionMethodNode;}
  +     const XMLCh * getAlgorithm(void);
  +     virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void)
  +             {return mp_encryptionMethodElement;}
        virtual const XMLCh * getDigestMethod(void);
        virtual const XMLCh * getOAEPparams(void);
  +     virtual int getKeySize(void);
        virtual void setDigestMethod(const XMLCh * method);
        virtual void setOAEPparams(const XMLCh * params);
  +     virtual void setKeySize(int size);
   
   
   
  @@ -115,13 +117,16 @@
        XENCEncryptionMethodImpl & operator = (const XENCEncryptionMethodImpl 
&);
   
        const XSECEnv                           * mp_env;
  +     XERCES_CPP_NAMESPACE_QUALIFIER DOMElement                               
        
  +                                                             * 
mp_encryptionMethodElement;   // Node at head of structure
  +     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  +                                                             * 
mp_algorithmAttr;
        XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                                  
  -                                                             * 
mp_encryptionMethodNode;      // Node at head of structure
  -     XMLCh                                           * mp_algorithm;
  -     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                                  
  -                                                             * 
mp_digestAlgorithmAttributeNode;
  -     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode                                  
  +                                                             * 
mp_digestAlgorithmAttr;
  +     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
                                                                * 
mp_oaepParamsTextNode;
  +     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  +                                                             * 
mp_keySizeTextNode;
   };
   
   #endif /* XENCENCRYPTIONMETHODIMPL_INCLUDE */
  
  
  

Reply via email to