Mixe for Privacy and Anonymity in the Internet
CASignature.hpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000, The JAP-Team
00003 All rights reserved.
00004 Redistribution and use in source and binary forms, with or without modification,
00005 are permitted provided that the following conditions are met:
00006 
00007   - Redistributions of source code must retain the above copyright notice,
00008     this list of conditions and the following disclaimer.
00009 
00010   - Redistributions in binary form must reproduce the above copyright notice,
00011     this list of conditions and the following disclaimer in the documentation and/or
00012     other materials provided with the distribution.
00013 
00014   - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
00015     may be used to endorse or promote products derived from this software without specific
00016     prior written permission.
00017 
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
00021 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
00022 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00025 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00027 */
00028 #ifndef __CASIGNATURE__
00029 #define __CASIGNATURE__
00030 #ifndef ONLY_LOCAL_PROXY
00031 #define SIGKEY_XML 1
00032 #define SIGKEY_PKCS12 2
00033 #define SHA1_REFERENCE "http://www.w3.org/2000/09/xmldsig#sha1"
00034 #define DSA_SHA1_REFERENCE "http://www.w3.org/2000/09/xmldsig#dsa-sha1"
00035 #define RSA_SHA1_REFERENCE "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
00036 #define ECDSA_SHA1_REFERENCE "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"
00037 #include "CACertStore.hpp"
00038 class CASSLContext;
00039 
00040 class CASignature
00041   {
00042     public:
00043       CASignature();
00044       ~CASignature();
00045       CASignature* clone();
00046       SINT32 generateSignKey(UINT32 size);
00047       SINT32 setSignKey(const UINT8* buff,UINT32 len,UINT32 type,const char* passwd=NULL);
00048       SINT32 setSignKey(const DOMNode* node,UINT32 type,const char* passwd=NULL);
00050       SINT32 getSignKey(DOMElement* & node,XERCES_CPP_NAMESPACE::DOMDocument* doc);
00051       SINT32 sign(const UINT8* const in,UINT32 inlen,UINT8* sig,UINT32* siglen) const;
00052       //SINT32 signXML(DOMNode* node,CACertStore* pIncludeCerts=NULL);
00053       //SINT32 signXML(UINT8* in,UINT32 inlen,UINT8* out,UINT32* outlen,CACertStore* pIncludeCerts=NULL);
00054       SINT32 setVerifyKey(CACertificate* pCert);
00058       SINT32 setVerifyKey(const DOMElement* xmlKey);
00060       SINT32 getVerifyKey(CACertificate**);
00061       SINT32 getVerifyKeyHash(UINT8* buff,UINT32* len);
00062 
00063       //SINT32 verify(UINT8* in,UINT32 inlen,UINT8* sig,UINT32 siglen);
00064       //SINT32 verifyXML(const UINT8* const in,UINT32 inlen);
00065       SINT32 verifyXML(DOMNode* node,CACertStore* pTrustedCerts=NULL);
00066       SINT32 getSignatureSize() const;
00067       SINT32 encodeRS(UINT8* out,UINT32* outLen,const DSA_SIG* const pdsaSig) const;
00068 
00079       SINT32 decodeRS(const UINT8* const in, const UINT32 inLen, DSA_SIG* pDsaSig) const;
00080       SINT32 verify(const UINT8* const in,UINT32 inlen,DSA_SIG* const dsaSig) const;
00081 
00093       SINT32 verifyDER(UINT8* in, UINT32 inlen, const UINT8 * dsaSig, const UINT32 sigLen);
00094 
00095       //MultiCert
00096       SINT32 verify(UINT8* in, UINT32 inLen, UINT8* sig, const UINT32 sigLen);
00097       bool isDSA() const;
00098       bool isRSA() const;
00099 #ifdef ECC
00100       bool isECDSA() const;
00101 #endif //ECC
00102       UINT8* getSignatureMethod();
00103 
00104       friend class CASSLContext;
00105     private:
00106       DSA* m_pDSA;
00107       DSA* getDSA(){return m_pDSA;}
00108       RSA* m_pRSA;
00109       RSA* getRSA(){ return m_pRSA; }
00110 
00111       SINT32 parseSignKeyXML(const UINT8* buff,UINT32 len);
00112       SINT32 sign(const UINT8* const in,UINT32 inlen,DSA_SIG** dsaSig) const;
00113 
00114       //MultiCert
00115       //friend class CAMultiSignature;
00116       SINT32 signRSA(const UINT8* dgst, const UINT32 dgstLen, UINT8* sig, UINT32* sigLen) const;
00117       SINT32 verifyRSA(const UINT8* dgst, const UINT32 dgstLen, UINT8* sig, UINT32 sigLen) const;
00118       SINT32 verifyDSA(const UINT8* dgst, const UINT32 dgstLen, UINT8* sig, UINT32 sigLen) const;
00119 #ifdef ECC
00120       EC_KEY* m_pEC;
00121       EC_KEY* getECKey(){ return m_pEC; }
00122       SINT32 signECDSA(const UINT8* dgst, const UINT32 dgstLen, UINT8* sig, UINT32* sigLen) const;
00123       SINT32 verifyECDSA(const UINT8* dgst, const UINT32 dgstLen, UINT8* sig, UINT32 sigLen) const;
00124 
00125 #endif //ECC
00126 
00127   };
00128 #endif
00129 #endif //ONLY_LOCAL_PROXY