blautenb 2003/05/25 05:19:26
Modified: c/Projects/VC6.0/xsec/xsec_lib xsec_lib.dsp
c/src/dsig DSIGKeyInfo.hpp DSIGKeyInfoList.cpp
DSIGSignature.cpp DSIGSignature.hpp
c/src/tools/xtest xtest.cpp
Added: c/src/dsig DSIGKeyInfoPGPData.cpp DSIGKeyInfoPGPData.hpp
Log:
Support for PGPData KeyInfo elements
Revision Changes Path
1.13 +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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- xsec_lib.dsp 9 May 2003 12:07:59 -0000 1.12
+++ xsec_lib.dsp 25 May 2003 12:19:26 -0000 1.13
@@ -198,6 +198,14 @@
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoPGPData.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoPGPData.hpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\dsig\DSIGKeyInfoValue.cpp
# End Source File
# Begin Source File
1.5 +5 -2 xml-security/c/src/dsig/DSIGKeyInfo.hpp
Index: DSIGKeyInfo.hpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfo.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSIGKeyInfo.hpp 2 Mar 2003 08:21:01 -0000 1.4
+++ DSIGKeyInfo.hpp 25 May 2003 12:19:26 -0000 1.5
@@ -119,7 +119,10 @@
KEYINFO_X509 = 2, // X509
Certificate (with embedded key)
KEYINFO_VALUE_DSA = 3, // DSA
Key
KEYINFO_VALUE_RSA = 4,
- KEYINFO_NAME = 5
// A name of a key (application dependant)
+ KEYINFO_NAME = 5, // A
name of a key (application dependant)
+ KEYINFO_PGPDATA = 6, // A
PGP key
+ KEYINFO_SPKIDATA = 7,
+ KEYINFO_MGMTDATA = 8
// Management data
};
1.5 +23 -1 xml-security/c/src/dsig/DSIGKeyInfoList.cpp
Index: DSIGKeyInfoList.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/dsig/DSIGKeyInfoList.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DSIGKeyInfoList.cpp 22 Feb 2003 08:47:23 -0000 1.4
+++ DSIGKeyInfoList.cpp 25 May 2003 12:19:26 -0000 1.5
@@ -73,6 +73,7 @@
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/dsig/DSIGKeyInfoName.hpp>
#include <xsec/dsig/DSIGKeyInfoValue.hpp>
+#include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/dsig/DSIGSignature.hpp>
@@ -205,6 +206,27 @@
// Add
this->addKeyInfo(k);
+
+ return true;
+
+ }
+
+ if (strEquals(getDSIGLocalName(ki), "PGPData")) {
+
+ DSIGKeyInfoPGPData * p;
+
+ XSECnew(p, DSIGKeyInfoPGPData(mp_parentSignature, ki));
+
+ try {
+ p->load();
+ }
+ catch (...) {
+ delete p;
+ throw;
+ }
+
+ // Add
+ this->addKeyInfo(p);
return true;
1.15 +17 -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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DSIGSignature.cpp 22 May 2003 11:17:40 -0000 1.14
+++ DSIGSignature.cpp 25 May 2003 12:19:26 -0000 1.15
@@ -90,6 +90,7 @@
#include <xsec/dsig/DSIGKeyInfoValue.hpp>
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/dsig/DSIGKeyInfoName.hpp>
+#include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
// Xerces includes
@@ -699,7 +700,22 @@
}
+DSIGKeyInfoPGPData * DSIGSignature::appendPGPData(const XMLCh * id, const
XMLCh * packet) {
+ createKeyInfoElement();
+
+ DSIGKeyInfoPGPData * p;
+
+ XSECnew(p, DSIGKeyInfoPGPData(this));
+
+ mp_KeyInfoNode->appendChild(p->createBlankPGPData(id, packet));
+
mp_KeyInfoNode->appendChild(mp_doc->createTextNode(DSIGConstants::s_unicodeStrNL));
+
+ m_keyInfoList.addKeyInfo(p);
+
+ return p;
+
+}
//
--------------------------------------------------------------------------------
// Working on Existing templates
//
--------------------------------------------------------------------------------
1.10 +15 -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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DSIGSignature.hpp 22 May 2003 11:17:40 -0000 1.9
+++ DSIGSignature.hpp 25 May 2003 12:19:26 -0000 1.10
@@ -88,6 +88,7 @@
class DSIGKeyInfoValue;
class DSIGKeyInfoX509;
class DSIGKeyInfoName;
+class DSIGKeyInfoPGPData;
/**
* @ingroup pubsig
@@ -624,6 +625,19 @@
*/
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);
//@}
1.1 xml-security/c/src/dsig/DSIGKeyInfoPGPData.cpp
Index: DSIGKeyInfoPGPData.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
*
* DSIGKeyName := Simply a string that names a key for an application to read
*
* Author(s): Berin Lautenbach
*
* $Id: DSIGKeyInfoPGPData.cpp,v 1.1 2003/05/25 12:19:26 blautenb Exp $
*
*/
#include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
#include <xsec/framework/XSECError.hpp>
#include <xsec/utils/XSECPlatformUtils.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xsec/dsig/DSIGSignature.hpp>
#include <xercesc/util/Janitor.hpp>
XSEC_USING_XERCES(ArrayJanitor);
//
--------------------------------------------------------------------------------
// Constructors and Destructors
//
--------------------------------------------------------------------------------
DSIGKeyInfoPGPData::DSIGKeyInfoPGPData(DSIGSignature *sig, DOMNode
*pgpDataNode) :
DSIGKeyInfo(sig),
mp_keyID(NULL),
mp_keyPacket(NULL),
mp_keyIDTextNode(NULL),
mp_keyPacketTextNode(NULL) {
mp_keyInfoDOMNode = pgpDataNode;
}
DSIGKeyInfoPGPData::DSIGKeyInfoPGPData(DSIGSignature *sig) :
DSIGKeyInfo(sig),
mp_keyID(NULL),
mp_keyPacket(NULL),
mp_keyIDTextNode(NULL),
mp_keyPacketTextNode(NULL) {
mp_keyInfoDOMNode = 0;
}
DSIGKeyInfoPGPData::~DSIGKeyInfoPGPData() {
};
//
--------------------------------------------------------------------------------
// Load and Get functions
//
--------------------------------------------------------------------------------
void DSIGKeyInfoPGPData::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::LoadEmptyInfoName);
}
if (!strEquals(getDSIGLocalName(mp_keyInfoDOMNode), "PGPData")) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected a PGPData node");
}
// Now find the first element node containing either KeyID or KeyPacket
DOMNode * tmpElt = findFirstChildOfType(mp_keyInfoDOMNode,
DOMNode::ELEMENT_NODE);
if (tmpElt == 0) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <PGPKeyID> or <PGPKeyPacket> children of
PGPData node");
}
if (strEquals(getDSIGLocalName(tmpElt), "PGPKeyID")) {
// Find the text node
mp_keyIDTextNode = findFirstChildOfType(tmpElt,
DOMNode::TEXT_NODE);
if (mp_keyIDTextNode == NULL) {
throw
XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected a text node beneath PGPKeyID");
}
mp_keyID = mp_keyIDTextNode->getNodeValue();
do {
tmpElt = tmpElt->getNextSibling();
} while (tmpElt != NULL && tmpElt->getNodeType() !=
DOMNode::ELEMENT_NODE);
}
if (tmpElt != NULL && strEquals(getDSIGLocalName(tmpElt),
"PGPKeyPacket")) {
// Find the text node
mp_keyPacketTextNode = findFirstChildOfType(tmpElt,
DOMNode::TEXT_NODE);
if (mp_keyPacketTextNode == NULL) {
throw
XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected a text node beneath PGPKeyPacket");
}
mp_keyPacket = mp_keyPacketTextNode->getNodeValue();
}
if (mp_keyPacketTextNode == NULL && mp_keyIDTextNode == NULL) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <PGPKeyID> or <PGPKeyPacket> children of
PGPData node");
}
}
//
--------------------------------------------------------------------------------
// Create and Set functions
//
--------------------------------------------------------------------------------
DOMElement * DSIGKeyInfoPGPData::createBlankPGPData(const XMLCh * id, const
XMLCh * packet) {
// Create the DOM Structure
safeBuffer str;
DOMDocument *doc = mp_parentSignature->getParentDocument();
const XMLCh * prefix = mp_parentSignature->getDSIGNSPrefix();
makeQName(str, prefix, "PGPData");
DOMElement *ret =
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
mp_keyInfoDOMNode = ret;
ret->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
if (id != NULL) {
makeQName(str, prefix, "PGPKeyID");
DOMElement * t =
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
ret->appendChild(t);
ret->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
mp_keyIDTextNode = doc->createTextNode(id);
t->appendChild(mp_keyIDTextNode);
mp_keyID = mp_keyIDTextNode->getNodeValue();
}
if (packet != NULL) {
makeQName(str, prefix, "PGPKeyPacket");
DOMElement * t =
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
ret->appendChild(t);
ret->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
mp_keyPacketTextNode = doc->createTextNode(packet);
t->appendChild(mp_keyPacketTextNode);
mp_keyPacket = mp_keyPacketTextNode->getNodeValue();
}
return ret;
}
void DSIGKeyInfoPGPData::setKeyID(const XMLCh * id) {
if (mp_keyInfoDOMNode == NULL) {
throw XSECException(XSECException::KeyInfoError,
"DSIGKeyInfoPGPData::setKeyID() called prior to load or
createBlank");
}
if (mp_keyIDTextNode == 0) {
// Need to create
safeBuffer str;
DOMDocument *doc = mp_parentSignature->getParentDocument();
const XMLCh * prefix = mp_parentSignature->getDSIGNSPrefix();
makeQName(str, prefix, "PGPKeyID");
DOMElement * t =
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
DOMNode * pkt = findFirstChildOfType(mp_keyInfoDOMNode,
DOMNode::ELEMENT_NODE);
if (pkt != NULL) {
mp_keyInfoDOMNode->insertBefore(t, pkt);
mp_keyInfoDOMNode->insertBefore(doc->createTextNode(DSIGConstants::s_unicodeStrNL),
pkt);
}
else {
mp_keyInfoDOMNode->appendChild(t);
mp_keyInfoDOMNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
}
mp_keyIDTextNode = doc->createTextNode(id);
t->appendChild(mp_keyIDTextNode);
}
else
mp_keyIDTextNode->setNodeValue(id);
mp_keyID = mp_keyIDTextNode->getNodeValue();
}
void DSIGKeyInfoPGPData::setKeyPacket(const XMLCh * packet) {
if (mp_keyInfoDOMNode == NULL) {
throw XSECException(XSECException::KeyInfoError,
"DSIGKeyInfoPGPData::setKeyID() called prior to load or
createBlank");
}
if (mp_keyPacketTextNode == 0) {
// Need to create
safeBuffer str;
DOMDocument *doc = mp_parentSignature->getParentDocument();
const XMLCh * prefix = mp_parentSignature->getDSIGNSPrefix();
makeQName(str, prefix, "PGPKeyPacket");
DOMElement * t =
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
mp_keyInfoDOMNode->appendChild(t);
mp_keyInfoDOMNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
mp_keyPacketTextNode = doc->createTextNode(packet);
t->appendChild(mp_keyPacketTextNode);
}
else
mp_keyPacketTextNode->setNodeValue(packet);
mp_keyPacket = mp_keyPacketTextNode->getNodeValue();
}
1.1 xml-security/c/src/dsig/DSIGKeyInfoPGPData.hpp
Index: DSIGKeyInfoPGPData.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
*
* DSIGKeyInfoPGPData := Contains a key pointer to a PGP key
*
* Author(s): Berin Lautenbach
*
* $Id: DSIGKeyInfoPGPData.hpp,v 1.1 2003/05/25 12:19:26 blautenb Exp $
*
*/
#ifndef DSIGKEYINFOPGPDATA_INCLUDE
#define DSIGKEYINFOPGPDATA_INCLUDE
#include <xsec/utils/XSECSafeBuffer.hpp>
#include <xsec/dsig/DSIGKeyInfo.hpp>
#include <xsec/utils/XSECPlatformUtils.hpp>
XSEC_DECLARE_XERCES_CLASS(DOMElement);
/**
* @ingroup pubsig
* @{
*/
/**
* @brief The class for <PGPData> nodes in a KeyInfo list.
*
* Class for holding information on a PGP Data node as well as setting
* such a node in a signature.
*
*/
class DSIG_EXPORT DSIGKeyInfoPGPData : 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 PGPData element.
*
* @param sig Calling signature object.
* @param nameNode DOMNode to load information from
*/
DSIGKeyInfoPGPData(DSIGSignature * sig, DOMNode *pgpDataNode);
/**
* \brief Constructor used when XML needs to be created.
*
* This constructor is used by DSIGSignature objects to
* create a DSIGKeyInfoPGPData object that can then be used
* to create the required XML.
*
* @param sig Calling signature object.
*/
DSIGKeyInfoPGPData(DSIGSignature * sig);
/**
* \brief Destructor
*/
virtual ~DSIGKeyInfoPGPData();
//@}
/** @name Load and Get functions */
//@{
/**
* \brief Load an existing XML structure into this object.
*/
virtual void load(void);
/**
* \brief Get the PGP Key ID held in the structure
*
* Returns a pointer to the buffer containing the ID of the PGP key.
*
* @returns A pointer to the char buffer containing the (base 64
encoded)
* PGP Key ID
*/
virtual const XMLCh * getKeyID(void) {return mp_keyID;}
/**
* \brief Get the PGP Key Packet
*
* Returns a pointer to the buffer containing the PGP Key packet.
*
* @returns A pointer to the XMLCh buffer containing the Key Packet in
* base64 encoded format
*/
virtual const XMLCh * getKeyPacket(void) {return mp_keyPacket;}
/**
* \Get key name - unimplemented for PGP packets
*/
virtual const XMLCh * getKeyName(void) {return NULL;}
//@}
/[EMAIL PROTECTED] Create and set functions */
//@{
/**
* \brief Create a new PGPData element in the current document.
*
* Creates a new PGPData element and sets the KeyPacket and KeyID
* with the strings passed in.
*
* @param id Value to set the KeyID as (NULL if not to be set)
* @param packet Value to set the key packet to (NULL if not to be set)
* @returns The newly created DOMElement with the structure underneath.
*/
DOMElement * createBlankPGPData(const XMLCh * id, const XMLCh * packet);
/**
* \brief Set the value of the KeyID to a new string.
*
* Uses the passed in string to set a new value in the DOM structure.
*
* @param id The value to set the KeyID to
*/
void setKeyID(const XMLCh * id);
/**
* \brief Set the value of the KeyPacket to a new string.
*
* Uses the passed in string to set a new value in the DOM structure.
*
* @param packet The value to set the KeyPacket to
*/
void setKeyPacket(const XMLCh * packet);
//@}
/** @name Information Functions */
//@{
/**
* \brief Return type of this KeyInfo element
*/
virtual keyInfoType getKeyInfoType(void) {return
DSIGKeyInfo::KEYINFO_PGPDATA;}
//@}
private:
DSIGKeyInfoPGPData(); //
Non-implemented constructor
const XMLCh * mp_keyID;
// Key ID (from DOM)
const XMLCh * mp_keyPacket; // key
Packet (from DOM)
DOMNode * mp_keyIDTextNode; // Text
node containing the ID
DOMNode * mp_keyPacketTextNode; // Text node
contianing key packet
};
#endif /* #define DSIGKEYINFOPGPDATA_INCLUDE */
1.11 +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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- xtest.cpp 22 May 2003 11:42:06 -0000 1.10
+++ xtest.cpp 25 May 2003 12:19:26 -0000 1.11
@@ -119,6 +119,7 @@
#include <xsec/enc/XSECCryptoException.hpp>
#include <xsec/dsig/DSIGKeyInfoX509.hpp>
#include <xsec/dsig/DSIGKeyInfoName.hpp>
+#include <xsec/dsig/DSIGKeyInfoPGPData.hpp>
#if defined (HAVE_OPENSSL)
# include <xsec/enc/OpenSSL/OpenSSLCryptoKeyHMAC.hpp>
@@ -197,6 +198,24 @@
};
+XMLCh s_tstPGPKeyID[] = {
+
+ chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
+ chLatin_P, chLatin_G, chLatin_P, chSpace,
+ chLatin_I, chLatin_D, chNull
+};
+
+XMLCh s_tstPGPKeyPacket[] = {
+
+ chLatin_D, chLatin_u, chLatin_m, chLatin_m, chLatin_y, chSpace,
+ chLatin_P, chLatin_G, chLatin_P, chSpace,
+ chLatin_P, chLatin_a, chLatin_c, chLatin_k, chLatin_e, chLatin_t, chNull
+};
+
+//
--------------------------------------------------------------------------------
+// Create a key
+//
--------------------------------------------------------------------------------
+
XSECCryptoKeyHMAC * createHMACKey(const unsigned char * str) {
// Create the HMAC key
@@ -397,6 +416,9 @@
DSIGKeyInfoX509 * x509 = sig->appendX509Data();
x509->setX509SubjectName(s_tstDName);
+ // Append a test PGPData element
+ sig->appendPGPData(s_tstPGPKeyID, s_tstPGPKeyPacket);
+
sig->setSigningKey(createHMACKey((unsigned char *) "secret"));
sig->sign();
@@ -561,6 +583,21 @@
cerr << "decoded incorrectly" << endl;;
exit (1);
}
+ }
+ if (kil->item(i)->getKeyInfoType() ==
DSIGKeyInfo::KEYINFO_PGPDATA) {
+
+ cerr << "Validating PGPData read back OK ... ";
+
+ DSIGKeyInfoPGPData * p = (DSIGKeyInfoPGPData
*)kil->item(i);
+
+ if (!(strEquals(p->getKeyID(), s_tstPGPKeyID) &&
+ strEquals(p->getKeyPacket(),
s_tstPGPKeyPacket))) {
+
+ cerr << "no!";
+ exit(1);
+ }
+
+ cerr << "yes\n";
}
}
}