blautenb    2003/05/27 05:06:07

  Modified:    c/Projects/VC6.0/xsec/xsec_lib xsec_lib.dsp
               c/src/dsig DSIGKeyInfoList.cpp DSIGSignature.cpp
                        DSIGSignature.hpp
               c/src/tools/xtest xtest.cpp
  Added:       c/src/dsig DSIGKeyInfoSPKIData.cpp DSIGKeyInfoSPKIData.hpp
  Log:
  Implementation of SPKIData KeyInfo elements
  
  Revision  Changes    Path
  1.14      +8 -0      xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
  
  Index: xsec_lib.dsp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- xsec_lib.dsp      25 May 2003 12:19:26 -0000      1.13
  +++ xsec_lib.dsp      27 May 2003 12:06:07 -0000      1.14
  @@ -206,6 +206,14 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoSPKIData.cpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoSPKIData.hpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoValue.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.6       +28 -61    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DSIGKeyInfoList.cpp       25 May 2003 12:19:26 -0000      1.5
  +++ DSIGKeyInfoList.cpp       27 May 2003 12:06:07 -0000      1.6
  @@ -74,6 +74,7 @@
   #include <xsec/dsig/DSIGKeyInfoName.hpp>
   #include <xsec/dsig/DSIGKeyInfoValue.hpp>
   #include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
  +#include <xsec/dsig/DSIGKeyInfoSPKIData.hpp>
   #include <xsec/framework/XSECError.hpp>
   #include <xsec/utils/XSECDOMUtils.hpp>
   #include <xsec/dsig/DSIGSignature.hpp>
  @@ -150,89 +151,55 @@
        if (ki == 0)
                return false;
   
  -     if (strEquals(getDSIGLocalName(ki), "X509Data")) {
  +     DSIGKeyInfo * k;
   
  -             DSIGKeyInfoX509 * k;
  +     if (strEquals(getDSIGLocalName(ki), "X509Data")) {
   
                // Have a certificate!
                XSECnew(k, DSIGKeyInfoX509(mp_parentSignature, ki));
  -             try {
  -                     k->load();
  -             }
  -             catch (...) {
  -                     delete k;
  -                     throw;
  -             }
  -
  -             // Add to the KeyInfo list
  -             this->addKeyInfo(k);
  -
  -             return true;
  -
        }
   
  -     if (strEquals(getDSIGLocalName(ki), "KeyName")) {
  -
  -             DSIGKeyInfoName * k;
  +     else if (strEquals(getDSIGLocalName(ki), "KeyName")) {
   
                XSECnew(k, DSIGKeyInfoName(mp_parentSignature, ki));
  -             
  -             try {
  -                     k->load();
  -             }
  -             catch (...) {
  -                     delete k;
  -                     throw;
  -             }
  -
  -             this->addKeyInfo(k);
  -
  -             return true;
        }
   
  -     if (strEquals(getDSIGLocalName(ki), "KeyValue")) {
  -
  -             DSIGKeyInfoValue * k;
  +     else if (strEquals(getDSIGLocalName(ki), "KeyValue")) {
   
                XSECnew(k, DSIGKeyInfoValue(mp_parentSignature, ki));
  -             
  -             try {
  -                     k->load();
  -             }
  -             catch (...) {
  -                     delete k;
  -                     throw;
  -             }
  -
  -             // Add
  -             this->addKeyInfo(k);
  +     }
   
  -             return true;
  +     else if (strEquals(getDSIGLocalName(ki), "PGPData")) {
   
  +             XSECnew(k, DSIGKeyInfoPGPData(mp_parentSignature, ki));
        }
   
  -     if (strEquals(getDSIGLocalName(ki), "PGPData")) {
  -
  -             DSIGKeyInfoPGPData * p;
  +     else if (strEquals(getDSIGLocalName(ki), "SPKIData")) {
   
  -             XSECnew(p, DSIGKeyInfoPGPData(mp_parentSignature, ki));
  +             XSECnew(k, DSIGKeyInfoSPKIData(mp_parentSignature, ki));
                
  -             try {
  -                     p->load();
  -             }
  -             catch (...) {
  -                     delete p;
  -                     throw;
  -             }
  +     }
  +
  +     else {
   
  -             // Add
  -             this->addKeyInfo(p);
  +             return false;
  +
  +     }
   
  -             return true;
  +     // Now we know what the element type is - do the load and save
   
  +     try {
  +             k->load();
        }
  +     catch (...) {
  +             delete k;
  +             throw;
  +     }
  +
  +     // Add
  +     this->addKeyInfo(k);
   
  -     return false;
  +     return true;
   
   }
   
  
  
  
  1.16      +20 -1     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DSIGSignature.cpp 25 May 2003 12:19:26 -0000      1.15
  +++ DSIGSignature.cpp 27 May 2003 12:06:07 -0000      1.16
  @@ -91,6 +91,7 @@
   #include <xsec/dsig/DSIGKeyInfoX509.hpp>
   #include <xsec/dsig/DSIGKeyInfoName.hpp>
   #include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
  +#include <xsec/dsig/DSIGKeyInfoSPKIData.hpp>
   
   // Xerces includes
   
  @@ -716,6 +717,24 @@
        return p;
   
   }
  +
  +DSIGKeyInfoSPKIData * DSIGSignature::appendSPKIData(const XMLCh * sexp) {
  +
  +     createKeyInfoElement();
  +
  +     DSIGKeyInfoSPKIData * s;
  +
  +     XSECnew(s, DSIGKeyInfoSPKIData(this));
  +
  +     mp_KeyInfoNode->appendChild(s->createBlankSPKIData(sexp));
  +     
mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +     m_keyInfoList.addKeyInfo(s);
  +
  +     return s;
  +
  +}
  +
   // 
--------------------------------------------------------------------------------
   //           Working on Existing templates
   // 
--------------------------------------------------------------------------------
  
  
  
  1.11      +13 -1     xml-security/c/src/dsig/DSIGSignature.hpp
  
  Index: DSIGSignature.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DSIGSignature.hpp 25 May 2003 12:19:26 -0000      1.10
  +++ DSIGSignature.hpp 27 May 2003 12:06:07 -0000      1.11
  @@ -89,6 +89,7 @@
   class DSIGKeyInfoX509;
   class DSIGKeyInfoName;
   class DSIGKeyInfoPGPData;
  +class DSIGKeyInfoSPKIData;
   
   /**
    * @ingroup pubsig
  @@ -638,6 +639,17 @@
         */
   
        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);
   
        //@}
   
  
  
  
  1.1                  xml-security/c/src/dsig/DSIGKeyInfoSPKIData.cpp
  
  Index: DSIGKeyInfoSPKIData.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "<WebSig>" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    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
   * 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
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, Institute for
   * Data Communications Systems, <http://www.nue.et-inf.uni-siegen.de/>.
   * The development of this software was partly funded by the European 
   * Commission in the <WebSig> project in the ISIS Programme. 
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * XSEC
   *
   * DSIGKeyInfoSPKIData := SPKI Information
   *
   * Author(s): Berin Lautenbach
   *
   * $Id: DSIGKeyInfoSPKIData.cpp,v 1.1 2003/05/27 12:06:07 blautenb Exp $
   *
   */
  
  #include <xsec/dsig/DSIGKeyInfoSPKIData.hpp>
  #include <xsec/framework/XSECError.hpp>
  #include <xsec/dsig/DSIGSignature.hpp>
  
  #include <xercesc/dom/DOM.hpp>
  
  XSEC_USING_XERCES(DOMDocument);
  
  // 
--------------------------------------------------------------------------------
  //           Constructors and Destructors
  // 
--------------------------------------------------------------------------------
  
  DSIGKeyInfoSPKIData::DSIGKeyInfoSPKIData(DSIGSignature * sig, DOMNode 
*nameNode) : 
  DSIGKeyInfo(sig) {
  
        mp_keyInfoDOMNode = nameNode;
  
  }
  
  DSIGKeyInfoSPKIData::DSIGKeyInfoSPKIData(DSIGSignature * sig) :
  DSIGKeyInfo(sig) {
  
        mp_keyInfoDOMNode = NULL;
  
  }
  
  DSIGKeyInfoSPKIData::~DSIGKeyInfoSPKIData() {
  
        sexpVectorType::iterator i;
  
        for (i = m_sexpList.begin(); i < m_sexpList.end(); ++i) {
  
                delete *i;
  
        }
  }
  
  // 
--------------------------------------------------------------------------------
  //           Load and get
  // 
--------------------------------------------------------------------------------
  
  void DSIGKeyInfoSPKIData::load(void) {
  
        // Assuming we have a valid DOM_Node to start with, load the signing 
key so that it can
        // be used later on
  
        if (mp_keyInfoDOMNode == NULL) {
  
                // Attempt to load an empty signature element
                throw XSECException(XSECException::ExpectedDSIGChildNotFound,
                        "DSIGKeyInfoSPKIData::load called without node being 
set");
  
        }
  
        if (!strEquals(getDSIGLocalName(mp_keyInfoDOMNode), "SPKIData")) {
  
                throw XSECException(XSECException::ExpectedDSIGChildNotFound,
                        "Expected an <SPKIData> node");
  
        }
  
        // Now find the SPKISexp nodes
        DOMNode * tmpElt = findFirstChildOfType(mp_keyInfoDOMNode, 
DOMNode::ELEMENT_NODE);
  
        while (tmpElt != NULL && strEquals(getDSIGLocalName(tmpElt), 
"SPKISexp")) {
  
                DOMNode * txt = findFirstChildOfType(tmpElt, 
DOMNode::TEXT_NODE);
  
                if (txt == NULL) {
  
                        throw 
XSECException(XSECException::ExpectedDSIGChildNotFound,
                                "Expected text node child of <SPKISexp>");
  
                }
  
                SexpNode * s;
                XSECnew(s, SexpNode);
  
                m_sexpList.push_back(s);
  
                s->mp_expr = txt->getNodeValue();
                s->mp_exprTextNode = txt;
  
                // Find next SPKISexp
                
                do {
  
                        tmpElt = tmpElt->getNextSibling();
  
                } while (tmpElt != NULL && tmpElt->getNodeType() != 
DOMNode::ELEMENT_NODE);
  
        }
  
        /*
         * Note that it is not necessarily an error if non SPKISexp nodes are 
found
         * after the SPKISexp nodes.
         */
  
  }
  
  int DSIGKeyInfoSPKIData::getSexpSize(void) {
  
        return m_sexpList.size();
  
  }
  
  const XMLCh * DSIGKeyInfoSPKIData::getSexp(int index) {
  
        if (index < 0 || index >= m_sexpList.size()) {
  
                throw XSECException(XSECException::KeyInfoError,
                        "DSIGKeyInfoSPKIData::getSexp - index out of range");
  
        }
  
        return m_sexpList[index]->mp_expr;
  
  }
  
  // 
--------------------------------------------------------------------------------
  //           Create and set
  // 
--------------------------------------------------------------------------------
  
  DOMElement * DSIGKeyInfoSPKIData::createBlankSPKIData(const XMLCh * Sexp) {
  
        // Create the DOM Structure
  
        safeBuffer str;
        DOMDocument *doc = mp_parentSignature->getParentDocument();
        const XMLCh * prefix = mp_parentSignature->getDSIGNSPrefix();
  
        makeQName(str, prefix, "SPKIData");
  
        DOMElement * ret = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
        mp_keyInfoDOMNode = ret;
        ret->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  
        appendSexp(Sexp);
  
        return ret;
  
  }
  
  void DSIGKeyInfoSPKIData::appendSexp(const XMLCh * Sexp) {
  
        // First create the new element in the list
        SexpNode *s;
        XSECnew(s, SexpNode);
  
        m_sexpList.push_back(s);
  
        safeBuffer str;
        DOMDocument *doc = mp_parentSignature->getParentDocument();
        const XMLCh * prefix = mp_parentSignature->getDSIGNSPrefix();
  
        makeQName(str, prefix, "SPKISexp");
  
        DOMNode *tmpElt = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
        
        s->mp_exprTextNode = doc->createTextNode(Sexp);
        s->mp_expr = s->mp_exprTextNode->getNodeValue();
  
        tmpElt->appendChild(s->mp_exprTextNode);
  
        mp_keyInfoDOMNode->appendChild(tmpElt);
        
mp_keyInfoDOMNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  
  }
  
  
  
  
  1.1                  xml-security/c/src/dsig/DSIGKeyInfoSPKIData.hpp
  
  Index: DSIGKeyInfoSPKIData.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "<WebSig>" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    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
   * 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
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, Institute for
   * Data Communications Systems, <http://www.nue.et-inf.uni-siegen.de/>.
   * The development of this software was partly funded by the European 
   * Commission in the <WebSig> project in the ISIS Programme. 
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * XSEC
   *
   * DSIGKeyInfoSPKIData := SPKI Information
   *
   * Author(s): Berin Lautenbach
   *
   * $Id: DSIGKeyInfoSPKIData.hpp,v 1.1 2003/05/27 12:06:07 blautenb Exp $
   *
   */
  
  #ifndef DSIGKEYINFOSPKIDATA_INCLUDE
  #define DSIGKEYINFOSPKIDATA_INCLUDE
  
  #include <xsec/dsig/DSIGKeyInfo.hpp>
  #include <xsec/utils/XSECPlatformUtils.hpp>
  
  XSEC_DECLARE_XERCES_CLASS(DOMElement);
  
  #include <vector>
  
  /**
   * @ingroup pubsig
   * @{
   */
  
  /**
   * @brief The class for <SPKIData> nodes in a KeyInfo list.
   *
   * Class for holding information on a SPKIData node as well as setting
   * such a node in a signature.
   *
   */
  
  
  
  class DSIG_EXPORT DSIGKeyInfoSPKIData : public DSIGKeyInfo {
  
  public:
  
        /** @name Constructors and Destructors */
        //@{
  
        /**
         * \brief Constructor used when XML exists.
         *
         * This constructor is used by DSIGSignature objects to load
         * an existing DOM structure into the Name element.
         *
         * @param sig Calling signature object.
         * @param nameNode DOMNode to load information from
         */
  
        DSIGKeyInfoSPKIData(DSIGSignature * sig, DOMNode *nameNode);
  
        /**
         * \brief Constructor used when XML needs to be created.
         *
         * This constructor is used by DSIGSignature objects to
         * create a DSIGKeyInfoSPKIData object that can then be used
         * to create the required XML.
         *
         * @param sig Calling signature object.
         */
  
        DSIGKeyInfoSPKIData(DSIGSignature * sig);
  
        /**
         * \brief Destructor
         */
  
        virtual ~DSIGKeyInfoSPKIData();
  
        //@}
  
        /** @name Load and Get functions */
        //@{
  
        /**
         * \brief Load an existing XML structure into this object.
         */
  
        void load(void);
  
        /**
         * \brief Get the number of S-expressions 
         *
         * Returns the number of S-expressions held for this SPKIData element
         *
         * @returns The number of S-expressions
         */
  
        int getSexpSize(void);
  
        /**
         * \brief returns the indicated SExpression
         *
         * Returns a pointer to a XMLCh buffer holding the required SExpression.
         *
         * @param index The number of the SExpression to return
         * @returns A pointer to the char buffer containing the base64 encoded 
         * S-expression
         */
  
        virtual const XMLCh * getSexp(int index);
  
        /**
         * \Get key name - unimplemented for SPKI packets
         */
  
        virtual const XMLCh * getKeyName(void) {return NULL;}
  
        //@}
  
        /[EMAIL PROTECTED] Create and set functions */
        //@{
        
        
        /**
         * \brief Create a new SPKIData element in the document.
         *
         * Creates a new SPKIData element and sets the first S-expression
         * with the string passed in.
         *
         * @param Sexp Value (base64 encoded string) to set the first 
S-expression
         * @returns The newly created DOMElement with the structure underneath.
         */
  
        DOMElement * createBlankSPKIData(const XMLCh * Sexp);
  
        /**
         * \brief Append a new SPKISexp element to the SPKIData nodes
         *
         * Append a new SPKISexp element to the list of S-expressions that
         * already exists.
         *
         * @param Sexp Value (base64 encoded string) to set the new S-expression
         */
  
        void appendSexp(const XMLCh * Sexp);
  
        //@}
  
        /** @name Information Functions */
        //@{
        
        /**
         * \brief Return type of this KeyInfo element
         */
        
        virtual keyInfoType getKeyInfoType(void) {return 
DSIGKeyInfo::KEYINFO_SPKIDATA;}
  
        //@}
  
  private:
  
        DSIGKeyInfoSPKIData();                                          // 
Non-implemented constructor
  
        struct SexpNode {
                const XMLCh             * mp_expr;
                DOMNode                 * mp_exprTextNode;
        };
  
        typedef std::vector<SexpNode *> sexpVectorType;
  
        sexpVectorType          m_sexpList;
  
  };
  
  
  
  #endif /* #define DSIGKEYSPKIDATA_INCLUDE */
  
  
  
  1.12      +38 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- xtest.cpp 25 May 2003 12:19:26 -0000      1.11
  +++ xtest.cpp 27 May 2003 12:06:07 -0000      1.12
  @@ -120,6 +120,7 @@
   #include <xsec/dsig/DSIGKeyInfoX509.hpp>
   #include <xsec/dsig/DSIGKeyInfoName.hpp>
   #include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
  +#include <xsec/dsig/DSIGKeyInfoSPKIData.hpp>
   
   #if defined (HAVE_OPENSSL)
   #    include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
  @@ -212,6 +213,18 @@
        chLatin_P, chLatin_a, chLatin_c, chLatin_k, chLatin_e, chLatin_t, chNull
   };
   
  +XMLCh s_tstSexp1[] = {
  +
  +     chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
  +     chLatin_S, chLatin_e, chLatin_x, chLatin_p, chDigit_1, chNull
  +};
  +
  +XMLCh s_tstSexp2[] = {
  +
  +     chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
  +     chLatin_S, chLatin_e, chLatin_x, chLatin_p, chDigit_2, chNull
  +};
  +
   // 
--------------------------------------------------------------------------------
   //           Create a key
   // 
--------------------------------------------------------------------------------
  @@ -419,6 +432,10 @@
                // Append a test PGPData element
                sig->appendPGPData(s_tstPGPKeyID, s_tstPGPKeyPacket);
   
  +             // Append an SPKIData element
  +             DSIGKeyInfoSPKIData * spki = sig->appendSPKIData(s_tstSexp1);
  +             spki->appendSexp(s_tstSexp2);
  +
                sig->setSigningKey(createHMACKey((unsigned char *) "secret"));
                sig->sign();
   
  @@ -592,6 +609,26 @@
   
                                if (!(strEquals(p->getKeyID(), s_tstPGPKeyID) &&
                                        strEquals(p->getKeyPacket(), 
s_tstPGPKeyPacket))) {
  +
  +                                     cerr << "no!";
  +                                     exit(1);
  +                             }
  +
  +                             cerr << "yes\n";
  +                     }
  +                     if (kil->item(i)->getKeyInfoType() == 
DSIGKeyInfo::KEYINFO_SPKIDATA) {
  +                             
  +                             cerr << "Validating SPKIData read back OK ... ";
  +
  +                             DSIGKeyInfoSPKIData * s = (DSIGKeyInfoSPKIData 
*)kil->item(i);
  +
  +                             if (s->getSexpSize() != 2) {
  +                                     cerr << "no - expected two 
S-expressions";
  +                                     exit(1);
  +                             }
  +
  +                             if (!(strEquals(s->getSexp(0), s_tstSexp1) &&
  +                                     strEquals(s->getSexp(1), s_tstSexp2))) {
   
                                        cerr << "no!";
                                        exit(1);
  
  
  

Reply via email to