Mixe for Privacy and Anonymity in the Internet
CACertificate.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 #ifndef __CACERTIFICATE__
29 #define __CACERTIFICATE__
30 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
31 #define CERT_DER 1
32 #define CERT_XML_X509CERTIFICATE 2
33 #define CERT_PKCS12 3
34 #define CERT_X509CERTIFICATE 4
35 class CASignature;
36 class CAASymCipher;
37 class CASSLContext;
38 class CATLSClientSocket;
40  {
41  friend class CASignature;
42  friend class CAASymCipher;
43  friend class CASSLContext;
44  friend class CATLSClientSocket;
45 
46  public:
48  {
49  X509_free(m_pCert);
50  ASN1_OCTET_STRING_free(m_pSKI);
51  AUTHORITY_KEYID_free(m_pAKI);
52  }
54  {
55  X509* x = X509_dup(m_pCert);
56  CACertificate* tmp = new CACertificate(x);
57  return tmp;
58  }
59 
61  static CACertificate* decode(const UINT8* const buff,UINT32 bufflen,UINT32 type,const char* const passwd=NULL);
62  static CACertificate* decode(const DOMNode* node,UINT32 type,const char* passwd=NULL);
63  SINT32 encode(UINT8* buff,UINT32* bufflen,UINT32 type) const;
64  SINT32 encode(DOMElement* & elemRoot,XERCES_CPP_NAMESPACE::DOMDocument* doc) const;
65 
67  {
69  {
70  UINT8 name[] = "X509Certificate";
71  CACertificate::m_spXmlElementName = new UINT8[strlen((char*)name)+1];
72  strcpy((char*)CACertificate::m_spXmlElementName, (char*)name);
73  }
75  }
76 
77  SINT32 getRawSubjectKeyIdentifier(UINT8* r_ski, UINT32* r_skiLen);
78  SINT32 getAuthorityKeyIdentifier(UINT8* r_aki, UINT32* r_akiLen) const;
79  /* LERNGRUPPE */
80  /* SubjectKeyIdentifier Extension handling */
81  SINT32 getSubjectKeyIdentifier(UINT8* r_ski, UINT32 *r_skiLen);
82  SINT32 setSubjectKeyIdentifier( UINT8* a_value, UINT32 a_valueLen );
84  static SINT32 removeColons(const UINT8* a_cSki, UINT32 a_cSkiLen, UINT8 *&r_ski, UINT32 *r_skiLen);
85  SINT32 verify(const CACertificate* a_cert) const;
86  bool isValid() const;
87 
88  private:
89  CACertificate();
90  CACertificate(X509* x);
91  static X509* decode(const UINT8** derX509, UINT32 derX509Len);
92  X509* getX509() const
93  {
94  return m_pCert;
95  }
96  X509* m_pCert;
97  ASN1_OCTET_STRING* m_pSKI;
98  AUTHORITY_KEYID* m_pAKI;
100  };
101 #endif
102 #endif //ONLY_LOCAL_PROXY
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
friend class CASSLContext
SINT32 encode(UINT8 *buff, UINT32 *bufflen, UINT32 type) const
AUTHORITY_KEYID * m_pAKI
static UINT8 * m_spXmlElementName
static UINT8 * getXmlElementName()
X509 * getX509() const
SINT32 getAuthorityKeyIdentifier(UINT8 *r_aki, UINT32 *r_akiLen) const
CACertificate * clone() const
SINT32 setSubjectKeyIdentifier()
LERNGRUPPE Sets the subjectKeyIdentifier extension for this certificate to the hash of the public key...
bool isValid() const
SINT32 verify(const CACertificate *a_cert) const
static X509 * decode(const UINT8 **derX509, UINT32 derX509Len)
SINT32 getSubjectKeyIdentifier(UINT8 *r_ski, UINT32 *r_skiLen)
LERNGRUPPE Accessor method for the subjectKeyIdentifier (SKI) extension stored in this certificate.
static SINT32 removeColons(const UINT8 *a_cSki, UINT32 a_cSkiLen, UINT8 *&r_ski, UINT32 *r_skiLen)
LERNGRUPPE Removes the colons from the string representation of the given SKI.
SINT32 getRawSubjectKeyIdentifier(UINT8 *r_ski, UINT32 *r_skiLen)
static CACertificate * decode(const UINT8 *const buff, UINT32 bufflen, UINT32 type, const char *const passwd=NULL)
Extracts a certificate from an encoded (DER,XML) form.
ASN1_OCTET_STRING * m_pSKI
UINT8 type
Definition: typedefs.hpp:1