security/manager/ssl/src/nsNSSCertificate.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:271368ccc350
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef _NS_NSSCERTIFICATE_H_
7 #define _NS_NSSCERTIFICATE_H_
8
9 #include "nsIX509Cert.h"
10 #include "nsIX509Cert2.h"
11 #include "nsIX509Cert3.h"
12 #include "nsIX509CertDB.h"
13 #include "nsIX509CertList.h"
14 #include "nsIASN1Object.h"
15 #include "nsISMimeCert.h"
16 #include "nsIIdentityInfo.h"
17 #include "nsCOMPtr.h"
18 #include "nsNSSShutDown.h"
19 #include "nsISimpleEnumerator.h"
20 #include "nsISerializable.h"
21 #include "nsIClassInfo.h"
22 #include "pkix/pkixtypes.h"
23 #include "certt.h"
24
25 class nsAutoString;
26 class nsINSSComponent;
27 class nsIASN1Sequence;
28
29 class nsNSSCertificate : public nsIX509Cert3,
30 public nsIIdentityInfo,
31 public nsISMimeCert,
32 public nsISerializable,
33 public nsIClassInfo,
34 public nsNSSShutDownObject
35 {
36 public:
37 NS_DECL_THREADSAFE_ISUPPORTS
38 NS_DECL_NSIX509CERT
39 NS_DECL_NSIX509CERT2
40 NS_DECL_NSIX509CERT3
41 NS_DECL_NSIIDENTITYINFO
42 NS_DECL_NSISMIMECERT
43 NS_DECL_NSISERIALIZABLE
44 NS_DECL_NSICLASSINFO
45
46 friend class nsNSSCertificateFakeTransport;
47
48 nsNSSCertificate(CERTCertificate* cert, SECOidTag* evOidPolicy = nullptr);
49 nsNSSCertificate();
50 virtual ~nsNSSCertificate();
51 nsresult FormatUIStrings(const nsAutoString& nickname,
52 nsAutoString& nickWithSerial,
53 nsAutoString& details);
54 static nsNSSCertificate* Create(CERTCertificate*cert = nullptr,
55 SECOidTag* evOidPolicy = nullptr);
56 static nsNSSCertificate* ConstructFromDER(char* certDER, int derLen);
57
58 private:
59 mozilla::pkix::ScopedCERTCertificate mCert;
60 bool mPermDelete;
61 uint32_t mCertType;
62 nsresult CreateASN1Struct(nsIASN1Object** aRetVal);
63 nsresult CreateTBSCertificateASN1Struct(nsIASN1Sequence** retSequence,
64 nsINSSComponent* nssComponent);
65 nsresult GetSortableDate(PRTime aTime, nsAString& _aSortableDate);
66 virtual void virtualDestroyNSSReference();
67 void destructorSafeDestroyNSSReference();
68 bool InitFromDER(char* certDER, int derLen); // return false on failure
69
70 enum {
71 ev_status_invalid = 0, ev_status_valid = 1, ev_status_unknown = 2
72 } mCachedEVStatus;
73 SECOidTag mCachedEVOidTag;
74 nsresult hasValidEVOidTag(SECOidTag& resultOidTag, bool& validEV);
75 nsresult getValidEVOidTag(SECOidTag& resultOidTag, bool& validEV);
76 };
77
78 class nsNSSCertList: public nsIX509CertList,
79 public nsNSSShutDownObject
80 {
81 public:
82 NS_DECL_THREADSAFE_ISUPPORTS
83 NS_DECL_NSIX509CERTLIST
84
85 // certList is adopted
86 nsNSSCertList(mozilla::pkix::ScopedCERTCertList& certList,
87 const nsNSSShutDownPreventionLock& proofOfLock);
88
89 nsNSSCertList();
90
91 static CERTCertList* DupCertList(CERTCertList* aCertList,
92 const nsNSSShutDownPreventionLock&
93 proofOfLock);
94 private:
95 virtual ~nsNSSCertList();
96 virtual void virtualDestroyNSSReference();
97 void destructorSafeDestroyNSSReference();
98
99 mozilla::pkix::ScopedCERTCertList mCertList;
100
101 nsNSSCertList(const nsNSSCertList&) MOZ_DELETE;
102 void operator=(const nsNSSCertList&) MOZ_DELETE;
103 };
104
105 class nsNSSCertListEnumerator: public nsISimpleEnumerator,
106 public nsNSSShutDownObject
107 {
108 public:
109 NS_DECL_THREADSAFE_ISUPPORTS
110 NS_DECL_NSISIMPLEENUMERATOR
111
112 nsNSSCertListEnumerator(CERTCertList* certList,
113 const nsNSSShutDownPreventionLock& proofOfLock);
114 private:
115 virtual ~nsNSSCertListEnumerator();
116 virtual void virtualDestroyNSSReference();
117 void destructorSafeDestroyNSSReference();
118
119 mozilla::pkix::ScopedCERTCertList mCertList;
120
121 nsNSSCertListEnumerator(const nsNSSCertListEnumerator&) MOZ_DELETE;
122 void operator=(const nsNSSCertListEnumerator&) MOZ_DELETE;
123 };
124
125
126 #define NS_NSS_LONG 4
127 #define NS_NSS_GET_LONG(x) ((((unsigned long)((x)[0])) << 24) | \
128 (((unsigned long)((x)[1])) << 16) | \
129 (((unsigned long)((x)[2])) << 8) | \
130 ((unsigned long)((x)[3])) )
131 #define NS_NSS_PUT_LONG(src,dest) (dest)[0] = (((src) >> 24) & 0xff); \
132 (dest)[1] = (((src) >> 16) & 0xff); \
133 (dest)[2] = (((src) >> 8) & 0xff); \
134 (dest)[3] = ((src) & 0xff);
135
136 #define NS_X509CERT_CID { /* 660a3226-915c-4ffb-bb20-8985a632df05 */ \
137 0x660a3226, \
138 0x915c, \
139 0x4ffb, \
140 { 0xbb, 0x20, 0x89, 0x85, 0xa6, 0x32, 0xdf, 0x05 } \
141 }
142
143 #endif // _NS_NSSCERTIFICATE_H_

mercurial