00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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);
00064 SINT32 encode(DOMElement* & elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* doc);
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);
00079
00080
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);
00086 bool isValid();
00087 private:
00088 CACertificate();
00089 CACertificate(X509* x);
00090 private:
00091 static X509* decode(const UINT8** derX509, UINT32 derX509Len);
00092 X509* getX509(){return m_pCert;}
00093 X509* m_pCert;
00094 ASN1_OCTET_STRING* m_pSKI;
00095 AUTHORITY_KEYID* m_pAKI;
00096 static UINT8 * m_spXmlElementName;
00097 };
00098 #endif
00099 #endif //ONLY_LOCAL_PROXY