blautenb 2003/10/03 02:50:52
Added: c/src/xenc XENCEncryptedKey.hpp
c/src/xenc/impl XENCEncryptedKeyImpl.cpp
XENCEncryptedKeyImpl.hpp
Log:
Updates to support creating an EncryptedKey (AES KeyWrap)
Revision Changes Path
1.1 xml-security/c/src/xenc/XENCEncryptedKey.hpp
Index: XENCEncryptedKey.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002-2003 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
*
* XENCEncryptedKey := Definition for holder object for EncryptedKey
*
* $Id: XENCEncryptedKey.hpp,v 1.1 2003/10/03 09:50:51 blautenb Exp $
*
*/
#ifndef XENCENCRYPTEDKEY_INCLUDE
#define XENCENCRYPTEDKEY_INCLUDE
// XSEC Includes
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/dsig/DSIGKeyInfo.hpp>
#include <xsec/xenc/XENCEncryptedType.hpp>
#include <xsec/xenc/XENCCipherData.hpp>
/**
* @ingroup xenc
* @{
*/
/**
* @brief Interface definition for the EncryptedKey object
*
* The \<EncryptedKey\> element is an abstract type which builds
* on the EncryptedType element for encrypted data (as opposed to
* encrypted data).
*
* In general, this class should not be used directly. For most
* applications, callers will want to use the XENCCipher class
* instead.
*/
class XENCEncryptedKey : public XENCEncryptedType, public DSIGKeyInfo {
/** @name Constructors and Destructors */
//@{
protected:
// Because we inherit from KeyInfo, we need to implement a slightly
different
// constructor.
XENCEncryptedKey(const XSECEnv * env) : DSIGKeyInfo(env) {};
public:
virtual ~XENCEncryptedKey() {};
/** @name Get Interface Methods */
//@{
//@}
private:
// Unimplemented
XENCEncryptedKey(const XENCEncryptedKey &);
XENCEncryptedKey & operator = (const XENCEncryptedKey &);
};
#endif /* XENCENCRYPTEDKEY_INCLUDE */
1.1 xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.cpp
Index: XENCEncryptedKeyImpl.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002-2003 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
*
* XENCEncryptedKeyImpl := Implementation for holder object for EncryptedKeys
*
* $Id: XENCEncryptedKeyImpl.cpp,v 1.1 2003/10/03 09:50:51 blautenb Exp $
*
*/
#include <xsec/framework/XSECDefs.hpp>
#include "XENCCipherImpl.hpp"
#include "XENCEncryptedKeyImpl.hpp"
#include "XENCCipherDataImpl.hpp"
#include <xsec/framework/XSECError.hpp>
#include <xsec/utils/XSECDOMUtils.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
XERCES_CPP_NAMESPACE_USE
//
--------------------------------------------------------------------------------
// UNICODE Strings
//
--------------------------------------------------------------------------------
static XMLCh s_EncryptedKey[] = {
chLatin_E,
chLatin_n,
chLatin_c,
chLatin_r,
chLatin_y,
chLatin_p,
chLatin_t,
chLatin_e,
chLatin_d,
chLatin_K,
chLatin_e,
chLatin_y,
chNull,
};
//
--------------------------------------------------------------------------------
// Construct/Destruct
//
--------------------------------------------------------------------------------
XENCEncryptedKeyImpl::XENCEncryptedKeyImpl(const XSECEnv * env) :
XENCEncryptedTypeImpl(env),
XENCEncryptedKey(env) {
}
XENCEncryptedKeyImpl::XENCEncryptedKeyImpl(const XSECEnv * env, DOMNode *
node) :
XENCEncryptedTypeImpl(env, node),
XENCEncryptedKey(env) {
}
XENCEncryptedKeyImpl::~XENCEncryptedKeyImpl() {
}
//
--------------------------------------------------------------------------------
// Load
//
--------------------------------------------------------------------------------
void XENCEncryptedKeyImpl::load(void) {
if (mp_encryptedTypeNode == NULL) {
// Attempt to load an empty encryptedData element
throw XSECException(XSECException::EncryptedTypeError,
"XENCEncryptedKey::load - called on empty DOM");
}
if (!strEquals(getXENCLocalName(mp_encryptedTypeNode), s_EncryptedKey))
{
// Attempt to load an empty encryptedKey element
throw XSECException(XSECException::EncryptedTypeError,
"XENCEncryptedKey::load - called on non EncryptedData
node");
}
// Now call the virtual function we overloaded to get here.
XENCEncryptedTypeImpl::load();
// Set up the keyInfo node
mp_keyInfoDOMNode = mp_encryptedTypeNode;
}
//
--------------------------------------------------------------------------------
// Create from scratch
//
--------------------------------------------------------------------------------
DOMElement * XENCEncryptedKeyImpl::createBlankEncryptedKey(
XENCCipherData::XENCCipherDataType type,
const
XMLCh * algorithm,
const
XMLCh * value) {
DOMElement * ret = createBlankEncryptedType(s_EncryptedKey, type,
algorithm, value);
// Set up the KeyInfo information
mp_keyInfoDOMNode = mp_encryptedTypeNode;
return ret;
}
//
--------------------------------------------------------------------------------
// Interface Methods
//
--------------------------------------------------------------------------------
1.1 xml-security/c/src/xenc/impl/XENCEncryptedKeyImpl.hpp
Index: XENCEncryptedKeyImpl.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002-2003 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
*
* XENCEncryptedKeyImpl := Implementation for holder object for EncryptedKey
*
* $Id: XENCEncryptedKeyImpl.hpp,v 1.1 2003/10/03 09:50:51 blautenb Exp $
*
*/
#ifndef XENCENCRYPTEDKEYIMPL_INCLUDE
#define XENCENCRYPTEDKEYIMPL_INCLUDE
// XSEC Includes
#include <xsec/framework/XSECDefs.hpp>
#include <xsec/xenc/XENCEncryptedKey.hpp>
#include "XENCCipherImpl.hpp"
#include "XENCEncryptedTypeImpl.hpp"
XSEC_DECLARE_XERCES_CLASS(DOMNode);
class XENCEncryptedKeyImpl : public XENCEncryptedKey, public
XENCEncryptedTypeImpl {
public:
XENCEncryptedKeyImpl(const XSECEnv * env);
XENCEncryptedKeyImpl(
const XSECEnv * env,
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node
);
virtual ~XENCEncryptedKeyImpl();
void load(void);
// Create a blank EncryptedKey DOM structure
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
createBlankEncryptedKey(XENCCipherData::XENCCipherDataType
type,
const XMLCh *
algorithm,
const XMLCh *
value);
// KeyInfo Interface methods
virtual const XMLCh * getKeyName(void) {return NULL;}
virtual keyInfoType getKeyInfoType(void) {return
DSIGKeyInfo::KEYINFO_ENCRYPTEDKEY;}
// Inherited from XENCEncryptedData - need to re-implement
virtual XENCCipherData * getCipherData(void)
{return XENCEncryptedTypeImpl::getCipherData();}
virtual DSIGKeyInfoList * getKeyInfoList(void)
{return XENCEncryptedTypeImpl::getKeyInfoList();}
virtual XENCEncryptionMethod * getEncryptionMethod(void)
{return XENCEncryptedTypeImpl::getEncryptionMethod();}
virtual void clearKeyInfo(void)
{XENCEncryptedTypeImpl::clearKeyInfo();}
virtual DSIGKeyInfoName * appendKeyName(const XMLCh * name, bool
isDName = false)
{return XENCEncryptedTypeImpl::appendKeyName(name, isDName);}
virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getDOMNode(void)
{return XENCEncryptedTypeImpl::getDOMNode();}
virtual void appendEncryptedKey(XENCEncryptedKey * encryptedKey)
{XENCEncryptedTypeImpl::appendEncryptedKey(encryptedKey);}
private:
// Unimplemented
XENCEncryptedKeyImpl(void);
XENCEncryptedKeyImpl(const XENCEncryptedKeyImpl &);
XENCEncryptedKeyImpl & operator = (const XENCEncryptedKeyImpl &);
};
#endif /* XENCENCRYPTEDKEYIMPL_INCLUDE */