|
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 __CACERTIFICATE__ 00029 #define __CACERTIFICATE__ 00030 #ifndef ONLY_LOCAL_PROXY 00031 #define CERT_DER 1 00032 #define CERT_XML_X509CERTIFICATE 2 00033 #define CERT_PKCS12 3 00034 #define CERT_X509CERTIFICATE 4 00035 class CASignature; 00036 class CAASymCipher; 00037 class CASSLContext; 00038 class CATLSClientSocket; 00039 class CACertificate 00040 { 00041 friend class CASignature; 00042 friend class CAASymCipher; 00043 friend class CASSLContext; 00044 friend class CATLSClientSocket; 00045 00046 public: 00047 ~CACertificate() 00048 { 00049 X509_free(m_pCert); 00050 ASN1_OCTET_STRING_free(m_pSKI); 00051 AUTHORITY_KEYID_free(m_pAKI); 00052 } 00053 CACertificate* clone() const 00054 { 00055 X509* x = X509_dup(m_pCert); 00056 CACertificate* tmp = new CACertificate(x); 00057 return tmp; 00058 } 00059 00061 static CACertificate* decode(const UINT8* const buff,UINT32 bufflen,UINT32 type,const char* const passwd=NULL); 00062 static CACertificate* decode(const DOMNode* node,UINT32 type,const char* passwd=NULL); 00063 SINT32 encode(UINT8* buff,UINT32* bufflen,UINT32 type) const; 00064 SINT32 encode(DOMElement* & elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* doc) const; 00065 00066 static UINT8 * getXmlElementName() 00067 { 00068 if(!CACertificate::m_spXmlElementName) 00069 { 00070 UINT8 name[] = "X509Certificate"; 00071 CACertificate::m_spXmlElementName = new UINT8[strlen((char*)name)+1]; 00072 strcpy((char*)CACertificate::m_spXmlElementName, (char*)name); 00073 } 00074 return CACertificate::m_spXmlElementName; 00075 } 00076 00077 SINT32 getRawSubjectKeyIdentifier(UINT8* r_ski, UINT32* r_skiLen); 00078 SINT32 getAuthorityKeyIdentifier(UINT8* r_aki, UINT32* r_akiLen) const; 00079 /* LERNGRUPPE */ 00080 /* SubjectKeyIdentifier Extension handling */ 00081 SINT32 getSubjectKeyIdentifier(UINT8* r_ski, UINT32 *r_skiLen); 00082 SINT32 setSubjectKeyIdentifier( UINT8* a_value, UINT32 a_valueLen ); 00083 SINT32 setSubjectKeyIdentifier(); 00084 static SINT32 removeColons(const UINT8* a_cSki, UINT32 a_cSkiLen, UINT8 *&r_ski, UINT32 *r_skiLen); 00085 SINT32 verify(const CACertificate* a_cert) const; 00086 bool isValid() const; 00087 00088 private: 00089 CACertificate(); 00090 CACertificate(X509* x); 00091 static X509* decode(const UINT8** derX509, UINT32 derX509Len); 00092 X509* getX509() const 00093 { 00094 return m_pCert; 00095 } 00096 X509* m_pCert; 00097 ASN1_OCTET_STRING* m_pSKI; 00098 AUTHORITY_KEYID* m_pAKI; 00099 static UINT8 * m_spXmlElementName; 00100 }; 00101 #endif 00102 #endif //ONLY_LOCAL_PROXY
1.7.6.1