|
Mixe for Privacy and Anonymity in the Internet
|
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 __CAASYMCIPHER__ 00029 #define __CAASYMCIPHER__ 00030 #include "CACertificate.hpp" 00031 00032 #define RSA_SIZE 128 00033 00034 class CAASymCipher 00035 { 00036 public: 00037 CAASymCipher(); 00038 ~CAASymCipher(); 00039 SINT32 destroy(); 00040 SINT32 decrypt(const UINT8* from,UINT8* to); 00041 SINT32 decryptOAEP(const UINT8* from,UINT8* to,UINT32* len); 00042 SINT32 encrypt(const UINT8* from,UINT8* to); 00043 SINT32 encryptOAEP(const UINT8* from,UINT32 fromlen,UINT8* to,UINT32* len); 00044 SINT32 encryptPKCS1(const UINT8* from,UINT32 fromlen,UINT8* to,UINT32* len); 00045 SINT32 generateKeyPair(UINT32 size); 00046 //SINT32 getPublicKey(UINT8* buff,UINT32 *len); 00047 #ifndef ONLY_LOCAL_PROXY 00048 private: 00049 SINT32 addKeyPart(DOMElement* elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* docOwner,const char* partName,BIGNUM* part); 00050 public: 00051 SINT32 getPublicKeyAsXML(UINT8* buff,UINT32* len); 00052 SINT32 getPublicKeyAsDOMElement(DOMElement* & elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* docOwner); 00053 #ifdef EXPORT_ASYM_PRIVATE_KEY 00054 SINT32 getPrivateKeyAsXML(UINT8* buff,UINT32* len); 00055 SINT32 getPrivateKeyAsDOMElement(DOMElement* & elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* docOwner); 00056 SINT32 setPrivateKeyAsXML(const UINT8* buff,UINT32 len); 00057 SINT32 setPrivateKeyAsDOMNode(DOMNode* node); 00058 #endif 00059 //SINT32 getPublicKeySize(); 00060 //SINT32 setPublicKey(UINT8* buff,UINT32* len); 00061 SINT32 setPublicKey(const CACertificate* pCert); 00062 SINT32 setPublicKeyAsXML(const UINT8* buff,UINT32 len); 00063 #endif 00064 private: 00065 SINT32 getKeyPart(BIGNUM** part,DOMNode* node); 00066 public: 00067 SINT32 setPublicKeyAsDOMNode(DOMNode* node); 00068 00069 //Set the public key from a Base64 encodes exponent and modulus 00070 SINT32 setPublicKey(const UINT8* modulus,UINT32 moduluslen,const UINT8* exponent,UINT32 exponentlen); 00071 00072 static SINT32 testSpeed(); 00073 private: 00074 RSA* m_pRSA; 00075 }; 00076 00077 #endif
1.7.6.1