Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/softoken/legacydb/pcert.h @ 3:150b72113545
Add DBM and legacydb support
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 05 Aug 2014 18:32:02 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:a945361df361 | 3:150b72113545 |
---|---|
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 | |
5 #ifndef _PCERTDB_H_ | |
6 #define _PCERTDB_H_ | |
7 | |
8 #include "plarena.h" | |
9 #include "prlong.h" | |
10 #include "pcertt.h" | |
11 | |
12 #include "lowkeyti.h" /* for struct NSSLOWKEYPublicKeyStr */ | |
13 | |
14 SEC_BEGIN_PROTOS | |
15 | |
16 /* | |
17 * initialize any global certificate locks | |
18 */ | |
19 SECStatus nsslowcert_InitLocks(void); | |
20 | |
21 /* | |
22 ** Add a DER encoded certificate to the permanent database. | |
23 ** "derCert" is the DER encoded certificate. | |
24 ** "nickname" is the nickname to use for the cert | |
25 ** "trust" is the trust parameters for the cert | |
26 */ | |
27 SECStatus nsslowcert_AddPermCert(NSSLOWCERTCertDBHandle *handle, | |
28 NSSLOWCERTCertificate *cert, | |
29 char *nickname, NSSLOWCERTCertTrust *trust); | |
30 SECStatus nsslowcert_AddPermNickname(NSSLOWCERTCertDBHandle *dbhandle, | |
31 NSSLOWCERTCertificate *cert, char *nickname); | |
32 | |
33 SECStatus nsslowcert_DeletePermCertificate(NSSLOWCERTCertificate *cert); | |
34 | |
35 typedef SECStatus (PR_CALLBACK * PermCertCallback)(NSSLOWCERTCertificate *cert, | |
36 SECItem *k, void *pdata); | |
37 /* | |
38 ** Traverse the entire permanent database, and pass the certs off to a | |
39 ** user supplied function. | |
40 ** "certfunc" is the user function to call for each certificate | |
41 ** "udata" is the user's data, which is passed through to "certfunc" | |
42 */ | |
43 SECStatus | |
44 nsslowcert_TraversePermCerts(NSSLOWCERTCertDBHandle *handle, | |
45 PermCertCallback certfunc, | |
46 void *udata ); | |
47 | |
48 PRBool | |
49 nsslowcert_CertDBKeyConflict(SECItem *derCert, NSSLOWCERTCertDBHandle *handle); | |
50 | |
51 certDBEntryRevocation * | |
52 nsslowcert_FindCrlByKey(NSSLOWCERTCertDBHandle *handle, | |
53 SECItem *crlKey, PRBool isKRL); | |
54 | |
55 SECStatus | |
56 nsslowcert_DeletePermCRL(NSSLOWCERTCertDBHandle *handle,const SECItem *derName, | |
57 PRBool isKRL); | |
58 SECStatus | |
59 nsslowcert_AddCrl(NSSLOWCERTCertDBHandle *handle, SECItem *derCrl , | |
60 SECItem *derKey, char *url, PRBool isKRL); | |
61 | |
62 NSSLOWCERTCertDBHandle *nsslowcert_GetDefaultCertDB(); | |
63 NSSLOWKEYPublicKey *nsslowcert_ExtractPublicKey(NSSLOWCERTCertificate *); | |
64 | |
65 NSSLOWCERTCertificate * | |
66 nsslowcert_NewTempCertificate(NSSLOWCERTCertDBHandle *handle, SECItem *derCert, | |
67 char *nickname, PRBool isperm, PRBool copyDER); | |
68 NSSLOWCERTCertificate * | |
69 nsslowcert_DupCertificate(NSSLOWCERTCertificate *cert); | |
70 void nsslowcert_DestroyCertificate(NSSLOWCERTCertificate *cert); | |
71 void nsslowcert_DestroyTrust(NSSLOWCERTTrust *Trust); | |
72 | |
73 /* | |
74 * Lookup a certificate in the databases without locking | |
75 * "certKey" is the database key to look for | |
76 * | |
77 * XXX - this should be internal, but pkcs 11 needs to call it during a | |
78 * traversal. | |
79 */ | |
80 NSSLOWCERTCertificate * | |
81 nsslowcert_FindCertByKey(NSSLOWCERTCertDBHandle *handle, const SECItem *certKey); | |
82 | |
83 /* | |
84 * Lookup trust for a certificate in the databases without locking | |
85 * "certKey" is the database key to look for | |
86 * | |
87 * XXX - this should be internal, but pkcs 11 needs to call it during a | |
88 * traversal. | |
89 */ | |
90 NSSLOWCERTTrust * | |
91 nsslowcert_FindTrustByKey(NSSLOWCERTCertDBHandle *handle, const SECItem *certKey); | |
92 | |
93 /* | |
94 ** Generate a certificate key from the issuer and serialnumber, then look it | |
95 ** up in the database. Return the cert if found. | |
96 ** "issuerAndSN" is the issuer and serial number to look for | |
97 */ | |
98 extern NSSLOWCERTCertificate * | |
99 nsslowcert_FindCertByIssuerAndSN (NSSLOWCERTCertDBHandle *handle, NSSLOWCERTIssuerAndSN *issuerAndSN); | |
100 | |
101 /* | |
102 ** Generate a certificate key from the issuer and serialnumber, then look it | |
103 ** up in the database. Return the cert if found. | |
104 ** "issuerAndSN" is the issuer and serial number to look for | |
105 */ | |
106 extern NSSLOWCERTTrust * | |
107 nsslowcert_FindTrustByIssuerAndSN (NSSLOWCERTCertDBHandle *handle, NSSLOWCERTIssuerAndSN *issuerAndSN); | |
108 | |
109 /* | |
110 ** Find a certificate in the database by a DER encoded certificate | |
111 ** "derCert" is the DER encoded certificate | |
112 */ | |
113 extern NSSLOWCERTCertificate * | |
114 nsslowcert_FindCertByDERCert(NSSLOWCERTCertDBHandle *handle, SECItem *derCert); | |
115 | |
116 /* convert an email address to lower case */ | |
117 char *nsslowcert_FixupEmailAddr(char *emailAddr); | |
118 | |
119 /* | |
120 ** Decode a DER encoded certificate into an NSSLOWCERTCertificate structure | |
121 ** "derSignedCert" is the DER encoded signed certificate | |
122 ** "copyDER" is true if the DER should be copied, false if the | |
123 ** existing copy should be referenced | |
124 ** "nickname" is the nickname to use in the database. If it is NULL | |
125 ** then a temporary nickname is generated. | |
126 */ | |
127 extern NSSLOWCERTCertificate * | |
128 nsslowcert_DecodeDERCertificate (SECItem *derSignedCert, char *nickname); | |
129 | |
130 SECStatus | |
131 nsslowcert_KeyFromDERCert(PLArenaPool *arena, SECItem *derCert, SECItem *key); | |
132 | |
133 certDBEntrySMime * | |
134 nsslowcert_ReadDBSMimeEntry(NSSLOWCERTCertDBHandle *certHandle, | |
135 char *emailAddr); | |
136 void | |
137 nsslowcert_DestroyDBEntry(certDBEntry *entry); | |
138 | |
139 SECStatus | |
140 nsslowcert_OpenCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly, | |
141 const char *domain, const char *prefix, | |
142 NSSLOWCERTDBNameFunc namecb, void *cbarg, PRBool openVolatile); | |
143 | |
144 void | |
145 nsslowcert_ClosePermCertDB(NSSLOWCERTCertDBHandle *handle); | |
146 | |
147 /* | |
148 * is certa newer than certb? If one is expired, pick the other one. | |
149 */ | |
150 PRBool | |
151 nsslowcert_IsNewer(NSSLOWCERTCertificate *certa, NSSLOWCERTCertificate *certb); | |
152 | |
153 | |
154 SECStatus | |
155 nsslowcert_TraverseDBEntries(NSSLOWCERTCertDBHandle *handle, | |
156 certDBEntryType type, | |
157 SECStatus (* callback)(SECItem *data, SECItem *key, | |
158 certDBEntryType type, void *pdata), | |
159 void *udata ); | |
160 SECStatus | |
161 nsslowcert_TraversePermCertsForSubject(NSSLOWCERTCertDBHandle *handle, | |
162 SECItem *derSubject, | |
163 NSSLOWCERTCertCallback cb, void *cbarg); | |
164 int | |
165 nsslowcert_NumPermCertsForSubject(NSSLOWCERTCertDBHandle *handle, | |
166 SECItem *derSubject); | |
167 SECStatus | |
168 nsslowcert_TraversePermCertsForNickname(NSSLOWCERTCertDBHandle *handle, | |
169 char *nickname, NSSLOWCERTCertCallback cb, void *cbarg); | |
170 | |
171 int | |
172 nsslowcert_NumPermCertsForNickname(NSSLOWCERTCertDBHandle *handle, | |
173 char *nickname); | |
174 SECStatus | |
175 nsslowcert_GetCertTrust(NSSLOWCERTCertificate *cert, | |
176 NSSLOWCERTCertTrust *trust); | |
177 | |
178 SECStatus | |
179 nsslowcert_SaveSMimeProfile(NSSLOWCERTCertDBHandle *dbhandle, char *emailAddr, | |
180 SECItem *derSubject, SECItem *emailProfile, SECItem *profileTime); | |
181 | |
182 /* | |
183 * Change the trust attributes of a certificate and make them permanent | |
184 * in the database. | |
185 */ | |
186 SECStatus | |
187 nsslowcert_ChangeCertTrust(NSSLOWCERTCertDBHandle *handle, | |
188 NSSLOWCERTCertificate *cert, NSSLOWCERTCertTrust *trust); | |
189 | |
190 PRBool | |
191 nsslowcert_needDBVerify(NSSLOWCERTCertDBHandle *handle); | |
192 | |
193 void | |
194 nsslowcert_setDBVerify(NSSLOWCERTCertDBHandle *handle, PRBool value); | |
195 | |
196 PRBool | |
197 nsslowcert_hasTrust(NSSLOWCERTCertTrust *trust); | |
198 | |
199 void | |
200 nsslowcert_DestroyFreeLists(void); | |
201 | |
202 void | |
203 nsslowcert_DestroyGlobalLocks(void); | |
204 | |
205 void | |
206 pkcs11_freeNickname(char *nickname, char *space); | |
207 | |
208 char * | |
209 pkcs11_copyNickname(char *nickname, char *space, int spaceLen); | |
210 | |
211 void | |
212 pkcs11_freeStaticData(unsigned char *data, unsigned char *space); | |
213 | |
214 unsigned char * | |
215 pkcs11_allocStaticData(int datalen, unsigned char *space, int spaceLen); | |
216 | |
217 unsigned char * | |
218 pkcs11_copyStaticData(unsigned char *data, int datalen, unsigned char *space, | |
219 int spaceLen); | |
220 NSSLOWCERTCertificate * | |
221 nsslowcert_CreateCert(void); | |
222 | |
223 certDBEntry * | |
224 nsslowcert_DecodeAnyDBEntry(SECItem *dbData, const SECItem *dbKey, | |
225 certDBEntryType entryType, void *pdata); | |
226 | |
227 SEC_END_PROTOS | |
228 | |
229 #endif /* _PCERTDB_H_ */ |