Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: nss/lib/certdb/cert.h

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 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 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/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 /* 5 /*
6 * cert.h - public data structures and prototypes for the certificate library 6 * cert.h - public data structures and prototypes for the certificate library
7 */ 7 */
8 8
9 #ifndef _CERT_H_ 9 #ifndef _CERT_H_
10 #define _CERT_H_ 10 #define _CERT_H_
11 11
12 #include "utilrename.h" 12 #include "utilrename.h"
13 #include "plarena.h" 13 #include "plarena.h"
14 #include "plhash.h" 14 #include "plhash.h"
15 #include "prlong.h" 15 #include "prlong.h"
16 #include "prlog.h" 16 #include "prlog.h"
17 17
18 #include "seccomon.h" 18 #include "seccomon.h"
19 #include "secdert.h" 19 #include "secdert.h"
20 #include "secoidt.h" 20 #include "secoidt.h"
21 #include "keyt.h" 21 #include "keyt.h"
22 #include "certt.h" 22 #include "certt.h"
23 23
24 SEC_BEGIN_PROTOS 24 SEC_BEGIN_PROTOS
25 25
26 /**************************************************************************** 26 /****************************************************************************
27 * 27 *
28 * RFC1485 ascii to/from X.? RelativeDistinguishedName (aka CERTName) 28 * RFC1485 ascii to/from X.? RelativeDistinguishedName (aka CERTName)
29 * 29 *
30 ****************************************************************************/ 30 ****************************************************************************/
31 31
32 /* 32 /*
33 ** Convert an ascii RFC1485 encoded name into its CERTName equivalent. 33 ** Convert an ascii RFC1485 encoded name into its CERTName equivalent.
34 */ 34 */
35 extern CERTName *CERT_AsciiToName(const char *string); 35 extern CERTName *CERT_AsciiToName(const char *string);
36 36
37 /* 37 /*
38 ** Convert an CERTName into its RFC1485 encoded equivalent. 38 ** Convert an CERTName into its RFC1485 encoded equivalent.
39 ** Returns a string that must be freed with PORT_Free(). 39 ** Returns a string that must be freed with PORT_Free().
40 ** This version produces a string for maximum human readability, 40 ** This version produces a string for maximum human readability,
41 ** not for strict RFC compliance. 41 ** not for strict RFC compliance.
42 */ 42 */
43 extern char *CERT_NameToAscii(CERTName *name); 43 extern char *CERT_NameToAscii(CERTName *name);
44 44
45 /* 45 /*
46 ** Convert an CERTName into its RFC1485 encoded equivalent. 46 ** Convert an CERTName into its RFC1485 encoded equivalent.
47 ** Returns a string that must be freed with PORT_Free(). 47 ** Returns a string that must be freed with PORT_Free().
48 ** Caller chooses encoding rules. 48 ** Caller chooses encoding rules.
49 */ 49 */
50 extern char *CERT_NameToAsciiInvertible(CERTName *name, 50 extern char *CERT_NameToAsciiInvertible(CERTName *name,
51 CertStrictnessLevel strict); 51 CertStrictnessLevel strict);
52 52
53 extern CERTAVA *CERT_CopyAVA(PLArenaPool *arena, CERTAVA *src); 53 extern CERTAVA *CERT_CopyAVA(PLArenaPool *arena, CERTAVA *src);
54 54
55 /* convert an OID to dotted-decimal representation */ 55 /* convert an OID to dotted-decimal representation */
56 /* Returns a string that must be freed with PR_smprintf_free(). */ 56 /* Returns a string that must be freed with PR_smprintf_free(). */
57 extern char * CERT_GetOidString(const SECItem *oid); 57 extern char *CERT_GetOidString(const SECItem *oid);
58 58
59 /* 59 /*
60 ** Examine an AVA and return the tag that refers to it. The AVA tags are 60 ** Examine an AVA and return the tag that refers to it. The AVA tags are
61 ** defined as SEC_OID_AVA*. 61 ** defined as SEC_OID_AVA*.
62 */ 62 */
63 extern SECOidTag CERT_GetAVATag(CERTAVA *ava); 63 extern SECOidTag CERT_GetAVATag(CERTAVA *ava);
64 64
65 /* 65 /*
66 ** Compare two AVA's, returning the difference between them. 66 ** Compare two AVA's, returning the difference between them.
67 */ 67 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 extern SECStatus CERT_AddRDN(CERTName *name, CERTRDN *rdn); 119 extern SECStatus CERT_AddRDN(CERTName *name, CERTRDN *rdn);
120 120
121 /* 121 /*
122 ** Compare two names, returning the difference between them. 122 ** Compare two names, returning the difference between them.
123 */ 123 */
124 extern SECComparison CERT_CompareName(const CERTName *a, const CERTName *b); 124 extern SECComparison CERT_CompareName(const CERTName *a, const CERTName *b);
125 125
126 /* 126 /*
127 ** Convert a CERTName into something readable 127 ** Convert a CERTName into something readable
128 */ 128 */
129 extern char *CERT_FormatName (CERTName *name); 129 extern char *CERT_FormatName(CERTName *name);
130 130
131 /* 131 /*
132 ** Convert a der-encoded integer to a hex printable string form. 132 ** Convert a der-encoded integer to a hex printable string form.
133 ** Perhaps this should be a SEC function but it's only used for certs. 133 ** Perhaps this should be a SEC function but it's only used for certs.
134 */ 134 */
135 extern char *CERT_Hexify (SECItem *i, int do_colon); 135 extern char *CERT_Hexify(SECItem *i, int do_colon);
136 136
137 /* 137 /*
138 ** Converts DER string (with explicit length) into zString, if destination 138 ** Converts DER string (with explicit length) into zString, if destination
139 ** buffer is big enough to receive it. Does quoting and/or escaping as 139 ** buffer is big enough to receive it. Does quoting and/or escaping as
140 ** specified in RFC 1485. Input string must be single or multi-byte DER 140 ** specified in RFC 1485. Input string must be single or multi-byte DER
141 ** character set, (ASCII, UTF8, or ISO 8851-x) not a wide character set. 141 ** character set, (ASCII, UTF8, or ISO 8851-x) not a wide character set.
142 ** Returns SECSuccess or SECFailure with error code set. If output buffer 142 ** Returns SECSuccess or SECFailure with error code set. If output buffer
143 ** is too small, sets error code SEC_ERROR_OUTPUT_LEN. 143 ** is too small, sets error code SEC_ERROR_OUTPUT_LEN.
144 */ 144 */
145 extern SECStatus 145 extern SECStatus CERT_RFC1485_EscapeAndQuote(char *dst, int dstlen, char *src,
146 CERT_RFC1485_EscapeAndQuote(char *dst, int dstlen, char *src, int srclen); 146 int srclen);
147 147
148 /****************************************************************************** 148 /******************************************************************************
149 * 149 *
150 * Certificate handling operations 150 * Certificate handling operations
151 * 151 *
152 *****************************************************************************/ 152 *****************************************************************************/
153 153
154 /* 154 /*
155 ** Create a new validity object given two unix time values. 155 ** Create a new validity object given two unix time values.
156 ** "notBefore" the time before which the validity is not valid 156 ** "notBefore" the time before which the validity is not valid
157 ** "notAfter" the time after which the validity is not valid 157 ** "notAfter" the time after which the validity is not valid
158 */ 158 */
159 extern CERTValidity *CERT_CreateValidity(PRTime notBefore, PRTime notAfter); 159 extern CERTValidity *CERT_CreateValidity(PRTime notBefore, PRTime notAfter);
160 160
161 /* 161 /*
162 ** Destroy a validity object. 162 ** Destroy a validity object.
163 ** "v" the validity to destroy 163 ** "v" the validity to destroy
164 ** "freeit" if PR_TRUE then free the object as well as its sub-objects 164 ** "freeit" if PR_TRUE then free the object as well as its sub-objects
165 */ 165 */
166 extern void CERT_DestroyValidity(CERTValidity *v); 166 extern void CERT_DestroyValidity(CERTValidity *v);
167 167
168 /* 168 /*
169 ** Copy the "src" object to "dest". Memory is allocated in "dest" for 169 ** Copy the "src" object to "dest". Memory is allocated in "dest" for
170 ** each of the appropriate sub-objects. Memory in "dest" is not freed 170 ** each of the appropriate sub-objects. Memory in "dest" is not freed
171 ** before memory is allocated (use CERT_DestroyValidity(v, PR_FALSE) to do 171 ** before memory is allocated (use CERT_DestroyValidity(v, PR_FALSE) to do
172 ** that). 172 ** that).
173 */ 173 */
174 extern SECStatus CERT_CopyValidity 174 extern SECStatus CERT_CopyValidity(PLArenaPool *arena, CERTValidity *dest,
175 (PLArenaPool *arena, CERTValidity *dest, CERTValidity *src); 175 CERTValidity *src);
176 176
177 /* 177 /*
178 ** The cert lib considers a cert or CRL valid if the "notBefore" time is 178 ** The cert lib considers a cert or CRL valid if the "notBefore" time is
179 ** in the not-too-distant future, e.g. within the next 24 hours. This 179 ** in the not-too-distant future, e.g. within the next 24 hours. This
180 ** prevents freshly issued certificates from being considered invalid 180 ** prevents freshly issued certificates from being considered invalid
181 ** because the local system's time zone is incorrectly set. 181 ** because the local system's time zone is incorrectly set.
182 ** The amount of "pending slop time" is adjustable by the application. 182 ** The amount of "pending slop time" is adjustable by the application.
183 ** Units of SlopTime are seconds. Default is 86400 (24 hours). 183 ** Units of SlopTime are seconds. Default is 86400 (24 hours).
184 ** Negative SlopTime values are not allowed. 184 ** Negative SlopTime values are not allowed.
185 */ 185 */
186 PRInt32 CERT_GetSlopTime(void); 186 PRInt32 CERT_GetSlopTime(void);
187 187
188 SECStatus CERT_SetSlopTime(PRInt32 slop); 188 SECStatus CERT_SetSlopTime(PRInt32 slop);
189 189
190 /* 190 /*
191 ** Create a new certificate object. The result must be wrapped with an 191 ** Create a new certificate object. The result must be wrapped with an
192 ** CERTSignedData to create a signed certificate. 192 ** CERTSignedData to create a signed certificate.
193 ** "serialNumber" the serial number 193 ** "serialNumber" the serial number
194 ** "issuer" the name of the certificate issuer 194 ** "issuer" the name of the certificate issuer
195 ** "validity" the validity period of the certificate 195 ** "validity" the validity period of the certificate
196 ** "req" the certificate request that prompted the certificate issuance 196 ** "req" the certificate request that prompted the certificate issuance
197 */ 197 */
198 extern CERTCertificate * 198 extern CERTCertificate *CERT_CreateCertificate(unsigned long serialNumber,
199 CERT_CreateCertificate (unsigned long serialNumber, CERTName *issuer, 199 CERTName *issuer,
200 » » » CERTValidity *validity, CERTCertificateRequest *req); 200 CERTValidity *validity,
201 CERTCertificateRequest *req);
201 202
202 /* 203 /*
203 ** Destroy a certificate object 204 ** Destroy a certificate object
204 ** "cert" the certificate to destroy 205 ** "cert" the certificate to destroy
205 ** NOTE: certificate's are reference counted. This call decrements the 206 ** NOTE: certificate's are reference counted. This call decrements the
206 ** reference count, and if the result is zero, then the object is destroyed 207 ** reference count, and if the result is zero, then the object is destroyed
207 ** and optionally freed. 208 ** and optionally freed.
208 */ 209 */
209 extern void CERT_DestroyCertificate(CERTCertificate *cert); 210 extern void CERT_DestroyCertificate(CERTCertificate *cert);
210 211
211 /* 212 /*
212 ** Make a shallow copy of a certificate "c". Just increments the 213 ** Make a shallow copy of a certificate "c". Just increments the
213 ** reference count on "c". 214 ** reference count on "c".
214 */ 215 */
215 extern CERTCertificate *CERT_DupCertificate(CERTCertificate *c); 216 extern CERTCertificate *CERT_DupCertificate(CERTCertificate *c);
216 217
217 /* 218 /*
218 ** Create a new certificate request. This result must be wrapped with an 219 ** Create a new certificate request. This result must be wrapped with an
219 ** CERTSignedData to create a signed certificate request. 220 ** CERTSignedData to create a signed certificate request.
220 ** "name" the subject name (who the certificate request is from) 221 ** "name" the subject name (who the certificate request is from)
221 ** "spki" describes/defines the public key the certificate is for 222 ** "spki" describes/defines the public key the certificate is for
222 ** "attributes" if non-zero, some optional attribute data 223 ** "attributes" if non-zero, some optional attribute data
223 */ 224 */
224 extern CERTCertificateRequest * 225 extern CERTCertificateRequest *CERT_CreateCertificateRequest(
225 CERT_CreateCertificateRequest (CERTName *name, CERTSubjectPublicKeyInfo *spki, 226 CERTName *name, CERTSubjectPublicKeyInfo *spki, SECItem **attributes);
226 » » » SECItem **attributes);
227 227
228 /* 228 /*
229 ** Destroy a certificate-request object 229 ** Destroy a certificate-request object
230 ** "r" the certificate-request to destroy 230 ** "r" the certificate-request to destroy
231 ** "freeit" if PR_TRUE then free the object as well as its sub-objects 231 ** "freeit" if PR_TRUE then free the object as well as its sub-objects
232 */ 232 */
233 extern void CERT_DestroyCertificateRequest(CERTCertificateRequest *r); 233 extern void CERT_DestroyCertificateRequest(CERTCertificateRequest *r);
234 234
235 /* 235 /*
236 ** Start adding extensions to a certificate request. 236 ** Start adding extensions to a certificate request.
237 */ 237 */
238 void * 238 void *CERT_StartCertificateRequestAttributes(CERTCertificateRequest *req);
239 CERT_StartCertificateRequestAttributes(CERTCertificateRequest *req);
240 239
241 /* 240 /*
242 ** Reformat the certificate extension list into a CertificateRequest 241 ** Reformat the certificate extension list into a CertificateRequest
243 ** attribute list. 242 ** attribute list.
244 */ 243 */
245 SECStatus 244 SECStatus CERT_FinishCertificateRequestAttributes(CERTCertificateRequest *req);
246 CERT_FinishCertificateRequestAttributes(CERTCertificateRequest *req);
247 245
248 /* 246 /*
249 ** Extract the Extension Requests from a DER CertRequest attribute list. 247 ** Extract the Extension Requests from a DER CertRequest attribute list.
250 */ 248 */
251 SECStatus 249 SECStatus CERT_GetCertificateRequestExtensions(CERTCertificateRequest *req,
252 CERT_GetCertificateRequestExtensions(CERTCertificateRequest *req, 250 CERTCertExtension ***exts);
253 CERTCertExtension ***exts);
254 251
255 /* 252 /*
256 ** Extract a public key object from a certificate 253 ** Extract a public key object from a certificate
257 */ 254 */
258 extern SECKEYPublicKey *CERT_ExtractPublicKey(CERTCertificate *cert); 255 extern SECKEYPublicKey *CERT_ExtractPublicKey(CERTCertificate *cert);
259 256
260 /* 257 /*
261 ** Retrieve the Key Type associated with the cert we're dealing with 258 ** Retrieve the Key Type associated with the cert we're dealing with
262 */ 259 */
263 260
264 extern KeyType CERT_GetCertKeyType (const CERTSubjectPublicKeyInfo *spki); 261 extern KeyType CERT_GetCertKeyType(const CERTSubjectPublicKeyInfo *spki);
265 262
266 /* 263 /*
267 ** Initialize the certificate database. This is called to create 264 ** Initialize the certificate database. This is called to create
268 ** the initial list of certificates in the database. 265 ** the initial list of certificates in the database.
269 */ 266 */
270 extern SECStatus CERT_InitCertDB(CERTCertDBHandle *handle); 267 extern SECStatus CERT_InitCertDB(CERTCertDBHandle *handle);
271 268
272 extern int CERT_GetDBContentVersion(CERTCertDBHandle *handle); 269 extern int CERT_GetDBContentVersion(CERTCertDBHandle *handle);
273 270
274 /* 271 /*
275 ** Default certificate database routines 272 ** Default certificate database routines
276 */ 273 */
277 extern void CERT_SetDefaultCertDB(CERTCertDBHandle *handle); 274 extern void CERT_SetDefaultCertDB(CERTCertDBHandle *handle);
278 275
279 extern CERTCertDBHandle *CERT_GetDefaultCertDB(void); 276 extern CERTCertDBHandle *CERT_GetDefaultCertDB(void);
280 277
281 extern CERTCertList *CERT_GetCertChainFromCert(CERTCertificate *cert, 278 extern CERTCertList *CERT_GetCertChainFromCert(CERTCertificate *cert,
282 » » » » » PRTime time, 279 PRTime time, SECCertUsage usage);
283 » » » » » SECCertUsage usage); 280 extern CERTCertificate *CERT_NewTempCertificate(CERTCertDBHandle *handle,
284 extern CERTCertificate * 281 SECItem *derCert,
285 CERT_NewTempCertificate (CERTCertDBHandle *handle, SECItem *derCert, 282 char *nickname, PRBool isperm,
286 char *nickname, PRBool isperm, PRBool copyDER); 283 PRBool copyDER);
287
288 284
289 /****************************************************************************** 285 /******************************************************************************
290 * 286 *
291 * X.500 Name handling operations 287 * X.500 Name handling operations
292 * 288 *
293 *****************************************************************************/ 289 *****************************************************************************/
294 290
295 /* 291 /*
296 ** Create an AVA (attribute-value-assertion) 292 ** Create an AVA (attribute-value-assertion)
297 ** "arena" the memory arena to alloc from 293 ** "arena" the memory arena to alloc from
298 ** "kind" is one of SEC_OID_AVA_* 294 ** "kind" is one of SEC_OID_AVA_*
299 ** "valueType" is one of DER_PRINTABLE_STRING, DER_IA5_STRING, or 295 ** "valueType" is one of DER_PRINTABLE_STRING, DER_IA5_STRING, or
300 ** DER_T61_STRING 296 ** DER_T61_STRING
301 ** "value" is the null terminated string containing the value 297 ** "value" is the null terminated string containing the value
302 */ 298 */
303 extern CERTAVA *CERT_CreateAVA 299 extern CERTAVA *CERT_CreateAVA(PLArenaPool *arena, SECOidTag kind,
304 (PLArenaPool *arena, SECOidTag kind, int valueType, char *value); 300 int valueType, char *value);
305 301
306 /* 302 /*
307 ** Extract the Distinguished Name from a DER encoded certificate 303 ** Extract the Distinguished Name from a DER encoded certificate
308 ** "derCert" is the DER encoded certificate 304 ** "derCert" is the DER encoded certificate
309 ** "derName" is the SECItem that the name is returned in 305 ** "derName" is the SECItem that the name is returned in
310 */ 306 */
311 extern SECStatus CERT_NameFromDERCert(SECItem *derCert, SECItem *derName); 307 extern SECStatus CERT_NameFromDERCert(SECItem *derCert, SECItem *derName);
312 308
313 /* 309 /*
314 ** Extract the Issuers Distinguished Name from a DER encoded certificate 310 ** Extract the Issuers Distinguished Name from a DER encoded certificate
315 ** "derCert" is the DER encoded certificate 311 ** "derCert" is the DER encoded certificate
316 ** "derName" is the SECItem that the name is returned in 312 ** "derName" is the SECItem that the name is returned in
317 */ 313 */
318 extern SECStatus CERT_IssuerNameFromDERCert(SECItem *derCert, 314 extern SECStatus CERT_IssuerNameFromDERCert(SECItem *derCert, SECItem *derName);
319 » » » » » SECItem *derName);
320 315
321 extern SECItem * 316 extern SECItem *CERT_EncodeGeneralName(CERTGeneralName *genName, SECItem *dest,
322 CERT_EncodeGeneralName(CERTGeneralName *genName, SECItem *dest, 317 PLArenaPool *arena);
323 » » PLArenaPool *arena);
324 318
325 extern CERTGeneralName * 319 extern CERTGeneralName *CERT_DecodeGeneralName(PLArenaPool *reqArena,
326 CERT_DecodeGeneralName(PLArenaPool *reqArena, SECItem *encodedName, 320 SECItem *encodedName,
327 » » CERTGeneralName *genName); 321 CERTGeneralName *genName);
328
329
330 322
331 /* 323 /*
332 ** Generate a database search key for a certificate, based on the 324 ** Generate a database search key for a certificate, based on the
333 ** issuer and serial number. 325 ** issuer and serial number.
334 ** "arena" the memory arena to alloc from 326 ** "arena" the memory arena to alloc from
335 ** "derCert" the DER encoded certificate 327 ** "derCert" the DER encoded certificate
336 ** "key" the returned key 328 ** "key" the returned key
337 */ 329 */
338 extern SECStatus CERT_KeyFromDERCert(PLArenaPool *reqArena, SECItem *derCert, 330 extern SECStatus CERT_KeyFromDERCert(PLArenaPool *reqArena, SECItem *derCert,
339 SECItem *key); 331 SECItem *key);
340 332
341 extern SECStatus CERT_KeyFromIssuerAndSN(PLArenaPool *arena, SECItem *issuer, 333 extern SECStatus CERT_KeyFromIssuerAndSN(PLArenaPool *arena, SECItem *issuer,
342 » » » » » SECItem *sn, SECItem *key); 334 SECItem *sn, SECItem *key);
343 335
344 extern SECStatus CERT_SerialNumberFromDERCert(SECItem *derCert, 336 extern SECStatus CERT_SerialNumberFromDERCert(SECItem *derCert,
345 » » » » » » SECItem *derName); 337 SECItem *derName);
346
347 338
348 /* 339 /*
349 ** Generate a database search key for a crl, based on the 340 ** Generate a database search key for a crl, based on the
350 ** issuer. 341 ** issuer.
351 ** "arena" the memory arena to alloc from 342 ** "arena" the memory arena to alloc from
352 ** "derCrl" the DER encoded crl 343 ** "derCrl" the DER encoded crl
353 ** "key" the returned key 344 ** "key" the returned key
354 */ 345 */
355 extern SECStatus CERT_KeyFromDERCrl(PLArenaPool *arena, SECItem *derCrl, SECItem *key); 346 extern SECStatus CERT_KeyFromDERCrl(PLArenaPool *arena, SECItem *derCrl,
347 SECItem *key);
356 348
357 /* 349 /*
358 ** Open the certificate database. Use callback to get name of database. 350 ** Open the certificate database. Use callback to get name of database.
359 */ 351 */
360 extern SECStatus CERT_OpenCertDB(CERTCertDBHandle *handle, PRBool readOnly, 352 extern SECStatus CERT_OpenCertDB(CERTCertDBHandle *handle, PRBool readOnly,
361 » » » » CERTDBNameFunc namecb, void *cbarg); 353 CERTDBNameFunc namecb, void *cbarg);
362 354
363 /* Open the certificate database. Use given filename for database. */ 355 /* Open the certificate database. Use given filename for database. */
364 extern SECStatus CERT_OpenCertDBFilename(CERTCertDBHandle *handle, 356 extern SECStatus CERT_OpenCertDBFilename(CERTCertDBHandle *handle,
365 » » » » » char *certdbname, PRBool readOnly); 357 char *certdbname, PRBool readOnly);
366 358
367 /* 359 /*
368 ** Open and initialize a cert database that is entirely in memory. This 360 ** Open and initialize a cert database that is entirely in memory. This
369 ** can be used when the permanent database can not be opened or created. 361 ** can be used when the permanent database can not be opened or created.
370 */ 362 */
371 extern SECStatus CERT_OpenVolatileCertDB(CERTCertDBHandle *handle); 363 extern SECStatus CERT_OpenVolatileCertDB(CERTCertDBHandle *handle);
372 364
373 /* 365 /*
374 ** Extract the list of host names, host name patters, IP address strings 366 ** Extract the list of host names, host name patters, IP address strings
375 ** this cert is valid for. 367 ** this cert is valid for.
376 ** This function does NOT return nicknames. 368 ** This function does NOT return nicknames.
377 ** Type CERTCertNicknames is being used because it's a convenient 369 ** Type CERTCertNicknames is being used because it's a convenient
378 ** data structure to carry a list of strings and its count. 370 ** data structure to carry a list of strings and its count.
379 */ 371 */
380 extern CERTCertNicknames * 372 extern CERTCertNicknames *CERT_GetValidDNSPatternsFromCert(
381 CERT_GetValidDNSPatternsFromCert(CERTCertificate *cert); 373 CERTCertificate *cert);
382 374
383 /* 375 /*
384 ** Check the hostname to make sure that it matches the shexp that 376 ** Check the hostname to make sure that it matches the shexp that
385 ** is given in the common name of the certificate. 377 ** is given in the common name of the certificate.
386 */ 378 */
387 extern SECStatus CERT_VerifyCertName(const CERTCertificate *cert, 379 extern SECStatus CERT_VerifyCertName(const CERTCertificate *cert,
388 const char *hostname); 380 const char *hostname);
389 381
390 /* 382 /*
391 ** Add a domain name to the list of names that the user has explicitly 383 ** Add a domain name to the list of names that the user has explicitly
392 ** allowed (despite cert name mismatches) for use with a server cert. 384 ** allowed (despite cert name mismatches) for use with a server cert.
393 */ 385 */
394 extern SECStatus CERT_AddOKDomainName(CERTCertificate *cert, const char *hostnam e); 386 extern SECStatus CERT_AddOKDomainName(CERTCertificate *cert,
387 const char *hostname);
395 388
396 /* 389 /*
397 ** Decode a DER encoded certificate into an CERTCertificate structure 390 ** Decode a DER encoded certificate into an CERTCertificate structure
398 ** "derSignedCert" is the DER encoded signed certificate 391 ** "derSignedCert" is the DER encoded signed certificate
399 ** "copyDER" is true if the DER should be copied, false if the 392 ** "copyDER" is true if the DER should be copied, false if the
400 ** existing copy should be referenced 393 ** existing copy should be referenced
401 ** "nickname" is the nickname to use in the database. If it is NULL 394 ** "nickname" is the nickname to use in the database. If it is NULL
402 ** then a temporary nickname is generated. 395 ** then a temporary nickname is generated.
403 */ 396 */
404 extern CERTCertificate * 397 extern CERTCertificate *CERT_DecodeDERCertificate(SECItem *derSignedCert,
405 CERT_DecodeDERCertificate (SECItem *derSignedCert, PRBool copyDER, char *nicknam e); 398 PRBool copyDER,
399 char *nickname);
406 /* 400 /*
407 ** Decode a DER encoded CRL into a CERTSignedCrl structure 401 ** Decode a DER encoded CRL into a CERTSignedCrl structure
408 ** "derSignedCrl" is the DER encoded signed CRL. 402 ** "derSignedCrl" is the DER encoded signed CRL.
409 ** "type" must be SEC_CRL_TYPE. 403 ** "type" must be SEC_CRL_TYPE.
410 */ 404 */
411 #define SEC_CRL_TYPE» 1 405 #define SEC_CRL_TYPE 1
412 #define SEC_KRL_TYPE» 0 /* deprecated */ 406 #define SEC_KRL_TYPE 0 /* deprecated */
413 407
414 extern CERTSignedCrl * 408 extern CERTSignedCrl *CERT_DecodeDERCrl(PLArenaPool *arena,
415 CERT_DecodeDERCrl (PLArenaPool *arena, SECItem *derSignedCrl,int type); 409 SECItem *derSignedCrl, int type);
416 410
417 /* 411 /*
418 * same as CERT_DecodeDERCrl, plus allow options to be passed in 412 * same as CERT_DecodeDERCrl, plus allow options to be passed in
419 */ 413 */
420 414
421 extern CERTSignedCrl * 415 extern CERTSignedCrl *CERT_DecodeDERCrlWithFlags(PLArenaPool *narena,
422 CERT_DecodeDERCrlWithFlags(PLArenaPool *narena, SECItem *derSignedCrl, 416 SECItem *derSignedCrl,
423 int type, PRInt32 options); 417 int type, PRInt32 options);
424 418
425 /* CRL options to pass */ 419 /* CRL options to pass */
426 420
427 #define CRL_DECODE_DEFAULT_OPTIONS 0x00000000 421 #define CRL_DECODE_DEFAULT_OPTIONS 0x00000000
428 422
429 /* when CRL_DECODE_DONT_COPY_DER is set, the DER is not copied . The 423 /* when CRL_DECODE_DONT_COPY_DER is set, the DER is not copied . The
430 application must then keep derSignedCrl until it destroys the 424 application must then keep derSignedCrl until it destroys the
431 CRL . Ideally, it should allocate derSignedCrl in an arena 425 CRL . Ideally, it should allocate derSignedCrl in an arena
432 and pass that arena in as the first argument to 426 and pass that arena in as the first argument to
433 CERT_DecodeDERCrlWithFlags */ 427 CERT_DecodeDERCrlWithFlags */
434 428
435 #define CRL_DECODE_DONT_COPY_DER 0x00000001 429 #define CRL_DECODE_DONT_COPY_DER 0x00000001
436 #define CRL_DECODE_SKIP_ENTRIES 0x00000002 430 #define CRL_DECODE_SKIP_ENTRIES 0x00000002
437 #define CRL_DECODE_KEEP_BAD_CRL 0x00000004 431 #define CRL_DECODE_KEEP_BAD_CRL 0x00000004
438 #define CRL_DECODE_ADOPT_HEAP_DER 0x00000008 432 #define CRL_DECODE_ADOPT_HEAP_DER 0x00000008
439 433
440 /* complete the decoding of a partially decoded CRL, ie. decode the 434 /* complete the decoding of a partially decoded CRL, ie. decode the
441 entries. Note that entries is an optional field in a CRL, so the 435 entries. Note that entries is an optional field in a CRL, so the
442 "entries" pointer in CERTCrlStr may still be NULL even after 436 "entries" pointer in CERTCrlStr may still be NULL even after
443 function returns SECSuccess */ 437 function returns SECSuccess */
444 438
445 extern SECStatus CERT_CompleteCRLDecodeEntries(CERTSignedCrl* crl); 439 extern SECStatus CERT_CompleteCRLDecodeEntries(CERTSignedCrl *crl);
446 440
447 /* Validate CRL then import it to the dbase. If there is already a CRL with the 441 /* Validate CRL then import it to the dbase. If there is already a CRL with the
448 * same CA in the dbase, it will be replaced if derCRL is more up to date. 442 * same CA in the dbase, it will be replaced if derCRL is more up to date.
449 * If the process successes, a CRL will be returned. Otherwise, a NULL will 443 * If the process successes, a CRL will be returned. Otherwise, a NULL will
450 * be returned. The caller should call PORT_GetError() for the exactly error 444 * be returned. The caller should call PORT_GetError() for the exactly error
451 * code. 445 * code.
452 */ 446 */
453 extern CERTSignedCrl * 447 extern CERTSignedCrl *CERT_ImportCRL(CERTCertDBHandle *handle, SECItem *derCRL,
454 CERT_ImportCRL (CERTCertDBHandle *handle, SECItem *derCRL, char *url, 448 char *url, int type, void *wincx);
455 » » » » » » int type, void * wincx);
456 449
457 extern void CERT_DestroyCrl (CERTSignedCrl *crl); 450 extern void CERT_DestroyCrl(CERTSignedCrl *crl);
458 451
459 /* this is a hint to flush the CRL cache. crlKey is the DER subject of 452 /* this is a hint to flush the CRL cache. crlKey is the DER subject of
460 the issuer (CA). */ 453 the issuer (CA). */
461 void CERT_CRLCacheRefreshIssuer(CERTCertDBHandle* dbhandle, SECItem* crlKey); 454 void CERT_CRLCacheRefreshIssuer(CERTCertDBHandle *dbhandle, SECItem *crlKey);
462 455
463 /* add the specified DER CRL object to the CRL cache. Doing so will allow 456 /* add the specified DER CRL object to the CRL cache. Doing so will allow
464 certificate verification functions (such as CERT_VerifyCertificate) 457 certificate verification functions (such as CERT_VerifyCertificate)
465 to automatically find and make use of this CRL object. 458 to automatically find and make use of this CRL object.
466 Once a CRL is added to the CRL cache, the application must hold on to 459 Once a CRL is added to the CRL cache, the application must hold on to
467 the object's memory, because the cache will reference it directly. The 460 the object's memory, because the cache will reference it directly. The
468 application can only free the object after it calls CERT_UncacheCRL to 461 application can only free the object after it calls CERT_UncacheCRL to
469 remove it from the CRL cache. 462 remove it from the CRL cache.
470 */ 463 */
471 SECStatus CERT_CacheCRL(CERTCertDBHandle* dbhandle, SECItem* newcrl); 464 SECStatus CERT_CacheCRL(CERTCertDBHandle *dbhandle, SECItem *newcrl);
472 465
473 /* remove a previously added CRL object from the CRL cache. It is OK 466 /* remove a previously added CRL object from the CRL cache. It is OK
474 for the application to free the memory after a successful removal 467 for the application to free the memory after a successful removal
475 */ 468 */
476 SECStatus CERT_UncacheCRL(CERTCertDBHandle* dbhandle, SECItem* oldcrl); 469 SECStatus CERT_UncacheCRL(CERTCertDBHandle *dbhandle, SECItem *oldcrl);
477 470
478 /* 471 /*
479 ** Find a certificate in the database 472 ** Find a certificate in the database
480 ** "key" is the database key to look for 473 ** "key" is the database key to look for
481 */ 474 */
482 extern CERTCertificate *CERT_FindCertByKey(CERTCertDBHandle *handle, SECItem *ke y); 475 extern CERTCertificate *CERT_FindCertByKey(CERTCertDBHandle *handle,
476 SECItem *key);
483 477
484 /* 478 /*
485 ** Find a certificate in the database by name 479 ** Find a certificate in the database by name
486 ** "name" is the distinguished name to look up 480 ** "name" is the distinguished name to look up
487 */ 481 */
488 extern CERTCertificate * 482 extern CERTCertificate *CERT_FindCertByName(CERTCertDBHandle *handle,
489 CERT_FindCertByName (CERTCertDBHandle *handle, SECItem *name); 483 SECItem *name);
490 484
491 /* 485 /*
492 ** Find a certificate in the database by name 486 ** Find a certificate in the database by name
493 ** "name" is the distinguished name to look up (in ascii) 487 ** "name" is the distinguished name to look up (in ascii)
494 */ 488 */
495 extern CERTCertificate * 489 extern CERTCertificate *CERT_FindCertByNameString(CERTCertDBHandle *handle,
496 CERT_FindCertByNameString (CERTCertDBHandle *handle, char *name); 490 char *name);
497 491
498 /* 492 /*
499 ** Find a certificate in the database by name and keyid 493 ** Find a certificate in the database by name and keyid
500 ** "name" is the distinguished name to look up 494 ** "name" is the distinguished name to look up
501 ** "keyID" is the value of the subjectKeyID to match 495 ** "keyID" is the value of the subjectKeyID to match
502 */ 496 */
503 extern CERTCertificate * 497 extern CERTCertificate *CERT_FindCertByKeyID(CERTCertDBHandle *handle,
504 CERT_FindCertByKeyID (CERTCertDBHandle *handle, SECItem *name, SECItem *keyID); 498 SECItem *name, SECItem *keyID);
505 499
506 /* 500 /*
507 ** Generate a certificate key from the issuer and serialnumber, then look it 501 ** Generate a certificate key from the issuer and serialnumber, then look it
508 ** up in the database. Return the cert if found. 502 ** up in the database. Return the cert if found.
509 ** "issuerAndSN" is the issuer and serial number to look for 503 ** "issuerAndSN" is the issuer and serial number to look for
510 */ 504 */
511 extern CERTCertificate * 505 extern CERTCertificate *CERT_FindCertByIssuerAndSN(
512 CERT_FindCertByIssuerAndSN (CERTCertDBHandle *handle, CERTIssuerAndSN *issuerAnd SN); 506 CERTCertDBHandle *handle, CERTIssuerAndSN *issuerAndSN);
513 507
514 /* 508 /*
515 ** Find a certificate in the database by a subject key ID 509 ** Find a certificate in the database by a subject key ID
516 ** "subjKeyID" is the subject Key ID to look for 510 ** "subjKeyID" is the subject Key ID to look for
517 */ 511 */
518 extern CERTCertificate * 512 extern CERTCertificate *CERT_FindCertBySubjectKeyID(CERTCertDBHandle *handle,
519 CERT_FindCertBySubjectKeyID (CERTCertDBHandle *handle, SECItem *subjKeyID); 513 SECItem *subjKeyID);
520 514
521 /* 515 /*
522 ** Encode Certificate SKID (Subject Key ID) extension. 516 ** Encode Certificate SKID (Subject Key ID) extension.
523 ** 517 **
524 */ 518 */
525 extern SECStatus 519 extern SECStatus CERT_EncodeSubjectKeyID(PLArenaPool *arena,
526 CERT_EncodeSubjectKeyID(PLArenaPool *arena, const SECItem* srcString, 520 const SECItem *srcString,
527 SECItem *encodedValue); 521 SECItem *encodedValue);
528 522
529 /* 523 /*
530 ** Find a certificate in the database by a nickname 524 ** Find a certificate in the database by a nickname
531 ** "nickname" is the ascii string nickname to look for 525 ** "nickname" is the ascii string nickname to look for
532 */ 526 */
533 extern CERTCertificate * 527 extern CERTCertificate *CERT_FindCertByNickname(CERTCertDBHandle *handle,
534 CERT_FindCertByNickname (CERTCertDBHandle *handle, const char *nickname); 528 const char *nickname);
535 529
536 /* 530 /*
537 ** Find a certificate in the database by a DER encoded certificate 531 ** Find a certificate in the database by a DER encoded certificate
538 ** "derCert" is the DER encoded certificate 532 ** "derCert" is the DER encoded certificate
539 */ 533 */
540 extern CERTCertificate * 534 extern CERTCertificate *CERT_FindCertByDERCert(CERTCertDBHandle *handle,
541 CERT_FindCertByDERCert(CERTCertDBHandle *handle, SECItem *derCert); 535 SECItem *derCert);
542 536
543 /* 537 /*
544 ** Find a certificate in the database by a email address 538 ** Find a certificate in the database by a email address
545 ** "emailAddr" is the email address to look up 539 ** "emailAddr" is the email address to look up
546 */ 540 */
547 CERTCertificate * 541 CERTCertificate *CERT_FindCertByEmailAddr(CERTCertDBHandle *handle,
548 CERT_FindCertByEmailAddr(CERTCertDBHandle *handle, char *emailAddr); 542 char *emailAddr);
549 543
550 /* 544 /*
551 ** Find a certificate in the database by a email address or nickname 545 ** Find a certificate in the database by a email address or nickname
552 ** "name" is the email address or nickname to look up 546 ** "name" is the email address or nickname to look up
553 */ 547 */
554 CERTCertificate * 548 CERTCertificate *CERT_FindCertByNicknameOrEmailAddr(CERTCertDBHandle *handle,
555 CERT_FindCertByNicknameOrEmailAddr(CERTCertDBHandle *handle, const char *name); 549 const char *name);
556 550
557 /* 551 /*
558 ** Find a certificate in the database by a email address or nickname 552 ** Find a certificate in the database by a email address or nickname
559 ** and require it to have the given usage. 553 ** and require it to have the given usage.
560 ** "name" is the email address or nickname to look up 554 ** "name" is the email address or nickname to look up
561 */ 555 */
562 CERTCertificate * 556 CERTCertificate *CERT_FindCertByNicknameOrEmailAddrForUsage(
563 CERT_FindCertByNicknameOrEmailAddrForUsage(CERTCertDBHandle *handle, 557 CERTCertDBHandle *handle, const char *name, SECCertUsage lookingForUsage);
564 const char *name,
565 SECCertUsage lookingForUsage);
566 558
567 /* 559 /*
568 ** Find a certificate in the database by a digest of a subject public key 560 ** Find a certificate in the database by a digest of a subject public key
569 ** "spkDigest" is the digest to look up 561 ** "spkDigest" is the digest to look up
570 */ 562 */
571 extern CERTCertificate * 563 extern CERTCertificate *CERT_FindCertBySPKDigest(CERTCertDBHandle *handle,
572 CERT_FindCertBySPKDigest(CERTCertDBHandle *handle, SECItem *spkDigest); 564 SECItem *spkDigest);
573 565
574 /* 566 /*
575 * Find the issuer of a cert 567 * Find the issuer of a cert
576 */ 568 */
577 CERTCertificate * 569 CERTCertificate *CERT_FindCertIssuer(CERTCertificate *cert, PRTime validTime,
578 CERT_FindCertIssuer(CERTCertificate *cert, PRTime validTime, SECCertUsage usage) ; 570 SECCertUsage usage);
579 571
580 /* 572 /*
581 ** Check the validity times of a certificate vs. time 't', allowing 573 ** Check the validity times of a certificate vs. time 't', allowing
582 ** some slop for broken clocks and stuff. 574 ** some slop for broken clocks and stuff.
583 ** "cert" is the certificate to be checked 575 ** "cert" is the certificate to be checked
584 ** "t" is the time to check against 576 ** "t" is the time to check against
585 ** "allowOverride" if true then check to see if the invalidity has 577 ** "allowOverride" if true then check to see if the invalidity has
586 ** been overridden by the user. 578 ** been overridden by the user.
587 */ 579 */
588 extern SECCertTimeValidity CERT_CheckCertValidTimes(const CERTCertificate *cert, 580 extern SECCertTimeValidity CERT_CheckCertValidTimes(const CERTCertificate *cert,
589 » » » » » » PRTime t, 581 PRTime t,
590 » » » » » » PRBool allowOverride); 582 PRBool allowOverride);
591 583
592 /* 584 /*
593 ** WARNING - this function is deprecated, and will either go away or have 585 ** WARNING - this function is deprecated, and will either go away or have
594 ** a new API in the near future. 586 ** a new API in the near future.
595 ** 587 **
596 ** Check the validity times of a certificate vs. the current time, allowing 588 ** Check the validity times of a certificate vs. the current time, allowing
597 ** some slop for broken clocks and stuff. 589 ** some slop for broken clocks and stuff.
598 ** "cert" is the certificate to be checked 590 ** "cert" is the certificate to be checked
599 */ 591 */
600 extern SECStatus CERT_CertTimesValid(CERTCertificate *cert); 592 extern SECStatus CERT_CertTimesValid(CERTCertificate *cert);
601 593
602 /* 594 /*
603 ** Extract the validity times from a certificate 595 ** Extract the validity times from a certificate
604 ** "c" is the certificate 596 ** "c" is the certificate
605 ** "notBefore" is the start of the validity period 597 ** "notBefore" is the start of the validity period
606 ** "notAfter" is the end of the validity period 598 ** "notAfter" is the end of the validity period
607 */ 599 */
608 extern SECStatus 600 extern SECStatus CERT_GetCertTimes(const CERTCertificate *c, PRTime *notBefore,
609 CERT_GetCertTimes (const CERTCertificate *c, PRTime *notBefore, 601 PRTime *notAfter);
610 » » PRTime *notAfter);
611 602
612 /* 603 /*
613 ** Extract the issuer and serial number from a certificate 604 ** Extract the issuer and serial number from a certificate
614 */ 605 */
615 extern CERTIssuerAndSN *CERT_GetCertIssuerAndSN(PLArenaPool *, 606 extern CERTIssuerAndSN *CERT_GetCertIssuerAndSN(PLArenaPool *,
616 » » » » » » » CERTCertificate *); 607 CERTCertificate *);
617 608
618 /* 609 /*
619 ** verify the signature of a signed data object with a given certificate 610 ** verify the signature of a signed data object with a given certificate
620 ** "sd" the signed data object to be verified 611 ** "sd" the signed data object to be verified
621 ** "cert" the certificate to use to check the signature 612 ** "cert" the certificate to use to check the signature
622 */ 613 */
623 extern SECStatus CERT_VerifySignedData(CERTSignedData *sd, 614 extern SECStatus CERT_VerifySignedData(CERTSignedData *sd,
624 » » » » CERTCertificate *cert, 615 CERTCertificate *cert, PRTime t,
625 » » » » PRTime t, 616 void *wincx);
626 » » » » void *wincx);
627 /* 617 /*
628 ** verify the signature of a signed data object with the given DER publickey 618 ** verify the signature of a signed data object with the given DER publickey
629 */ 619 */
630 extern SECStatus 620 extern SECStatus CERT_VerifySignedDataWithPublicKeyInfo(
631 CERT_VerifySignedDataWithPublicKeyInfo(CERTSignedData *sd, 621 CERTSignedData *sd, CERTSubjectPublicKeyInfo *pubKeyInfo, void *wincx);
632 CERTSubjectPublicKeyInfo *pubKeyInfo,
633 void *wincx);
634 622
635 /* 623 /*
636 ** verify the signature of a signed data object with a SECKEYPublicKey. 624 ** verify the signature of a signed data object with a SECKEYPublicKey.
637 */ 625 */
638 extern SECStatus 626 extern SECStatus CERT_VerifySignedDataWithPublicKey(const CERTSignedData *sd,
639 CERT_VerifySignedDataWithPublicKey(const CERTSignedData *sd, 627 SECKEYPublicKey *pubKey,
640 SECKEYPublicKey *pubKey, void *wincx); 628 void *wincx);
641 629
642 /* 630 /*
643 ** NEW FUNCTIONS with new bit-field-FIELD SECCertificateUsage - please use 631 ** NEW FUNCTIONS with new bit-field-FIELD SECCertificateUsage - please use
644 ** verify a certificate by checking validity times against a certain time, 632 ** verify a certificate by checking validity times against a certain time,
645 ** that we trust the issuer, and that the signature on the certificate is 633 ** that we trust the issuer, and that the signature on the certificate is
646 ** valid. 634 ** valid.
647 ** "cert" the certificate to verify 635 ** "cert" the certificate to verify
648 ** "checkSig" only check signatures if true 636 ** "checkSig" only check signatures if true
649 */ 637 */
650 extern SECStatus 638 extern SECStatus CERT_VerifyCertificate(CERTCertDBHandle *handle,
651 CERT_VerifyCertificate(CERTCertDBHandle *handle, CERTCertificate *cert, 639 CERTCertificate *cert, PRBool checkSig,
652 » » PRBool checkSig, SECCertificateUsage requiredUsages, 640 SECCertificateUsage requiredUsages,
653 PRTime t, void *wincx, CERTVerifyLog *log, 641 PRTime t, void *wincx,
654 SECCertificateUsage* returnedUsages); 642 CERTVerifyLog *log,
643 SECCertificateUsage *returnedUsages);
655 644
656 /* same as above, but uses current time */ 645 /* same as above, but uses current time */
657 extern SECStatus 646 extern SECStatus CERT_VerifyCertificateNow(CERTCertDBHandle *handle,
658 CERT_VerifyCertificateNow(CERTCertDBHandle *handle, CERTCertificate *cert, 647 CERTCertificate *cert,
659 » » PRBool checkSig, SECCertificateUsage requiredUsages, 648 PRBool checkSig,
660 void *wincx, SECCertificateUsage* returnedUsages); 649 SECCertificateUsage requiredUsages,
650 void *wincx,
651 SECCertificateUsage *returnedUsages);
661 652
662 /* 653 /*
663 ** Verify that a CA cert can certify some (unspecified) leaf cert for a given 654 ** Verify that a CA cert can certify some (unspecified) leaf cert for a given
664 ** purpose. This is used by UI code to help identify where a chain may be 655 ** purpose. This is used by UI code to help identify where a chain may be
665 ** broken and why. This takes identical parameters to CERT_VerifyCert 656 ** broken and why. This takes identical parameters to CERT_VerifyCert
666 */ 657 */
667 extern SECStatus 658 extern SECStatus CERT_VerifyCACertForUsage(CERTCertDBHandle *handle,
668 CERT_VerifyCACertForUsage(CERTCertDBHandle *handle, CERTCertificate *cert, 659 CERTCertificate *cert,
669 » » PRBool checkSig, SECCertUsage certUsage, PRTime t, 660 PRBool checkSig,
670 » » void *wincx, CERTVerifyLog *log); 661 SECCertUsage certUsage, PRTime t,
662 void *wincx, CERTVerifyLog *log);
671 663
672 /* 664 /*
673 ** OLD OBSOLETE FUNCTIONS with enum SECCertUsage - DO NOT USE FOR NEW CODE 665 ** OLD OBSOLETE FUNCTIONS with enum SECCertUsage - DO NOT USE FOR NEW CODE
674 ** verify a certificate by checking validity times against a certain time, 666 ** verify a certificate by checking validity times against a certain time,
675 ** that we trust the issuer, and that the signature on the certificate is 667 ** that we trust the issuer, and that the signature on the certificate is
676 ** valid. 668 ** valid.
677 ** "cert" the certificate to verify 669 ** "cert" the certificate to verify
678 ** "checkSig" only check signatures if true 670 ** "checkSig" only check signatures if true
679 */ 671 */
680 extern SECStatus 672 extern SECStatus CERT_VerifyCert(CERTCertDBHandle *handle,
681 CERT_VerifyCert(CERTCertDBHandle *handle, CERTCertificate *cert, 673 CERTCertificate *cert, PRBool checkSig,
682 » » PRBool checkSig, SECCertUsage certUsage, PRTime t, 674 SECCertUsage certUsage, PRTime t, void *wincx,
683 » » void *wincx, CERTVerifyLog *log); 675 CERTVerifyLog *log);
684 676
685 /* same as above, but uses current time */ 677 /* same as above, but uses current time */
686 extern SECStatus 678 extern SECStatus CERT_VerifyCertNow(CERTCertDBHandle *handle,
687 CERT_VerifyCertNow(CERTCertDBHandle *handle, CERTCertificate *cert, 679 CERTCertificate *cert, PRBool checkSig,
688 » » PRBool checkSig, SECCertUsage certUsage, void *wincx); 680 SECCertUsage certUsage, void *wincx);
689 681
690 SECStatus 682 SECStatus CERT_VerifyCertChain(CERTCertDBHandle *handle, CERTCertificate *cert,
691 CERT_VerifyCertChain(CERTCertDBHandle *handle, CERTCertificate *cert, 683 PRBool checkSig, SECCertUsage certUsage,
692 » » PRBool checkSig, SECCertUsage certUsage, PRTime t, 684 PRTime t, void *wincx, CERTVerifyLog *log);
693 » » void *wincx, CERTVerifyLog *log);
694 685
695 /* 686 /*
696 ** Read a base64 ascii encoded DER certificate and convert it to our 687 ** Read a base64 ascii encoded DER certificate and convert it to our
697 ** internal format. 688 ** internal format.
698 ** "certstr" is a null-terminated string containing the certificate 689 ** "certstr" is a null-terminated string containing the certificate
699 */ 690 */
700 extern CERTCertificate *CERT_ConvertAndDecodeCertificate(char *certstr); 691 extern CERTCertificate *CERT_ConvertAndDecodeCertificate(char *certstr);
701 692
702 /* 693 /*
703 ** Read a certificate in some foreign format, and convert it to our 694 ** Read a certificate in some foreign format, and convert it to our
704 ** internal format. 695 ** internal format.
705 ** "certbuf" is the buffer containing the certificate 696 ** "certbuf" is the buffer containing the certificate
706 ** "certlen" is the length of the buffer 697 ** "certlen" is the length of the buffer
707 ** NOTE - currently supports netscape base64 ascii encoded raw certs 698 ** NOTE - currently supports netscape base64 ascii encoded raw certs
708 ** and netscape binary DER typed files. 699 ** and netscape binary DER typed files.
709 */ 700 */
710 extern CERTCertificate *CERT_DecodeCertFromPackage(char *certbuf, int certlen); 701 extern CERTCertificate *CERT_DecodeCertFromPackage(char *certbuf, int certlen);
711 702
712 extern SECStatus 703 extern SECStatus CERT_ImportCAChain(SECItem *certs, int numcerts,
713 CERT_ImportCAChain (SECItem *certs, int numcerts, SECCertUsage certUsage); 704 SECCertUsage certUsage);
714 705
715 extern SECStatus 706 extern SECStatus CERT_ImportCAChainTrusted(SECItem *certs, int numcerts,
716 CERT_ImportCAChainTrusted(SECItem *certs, int numcerts, SECCertUsage certUsage); 707 SECCertUsage certUsage);
717 708
718 /* 709 /*
719 ** Read a certificate chain in some foreign format, and pass it to a 710 ** Read a certificate chain in some foreign format, and pass it to a
720 ** callback function. 711 ** callback function.
721 ** "certbuf" is the buffer containing the certificate 712 ** "certbuf" is the buffer containing the certificate
722 ** "certlen" is the length of the buffer 713 ** "certlen" is the length of the buffer
723 ** "f" is the callback function 714 ** "f" is the callback function
724 ** "arg" is the callback argument 715 ** "arg" is the callback argument
725 */ 716 */
726 typedef SECStatus (PR_CALLBACK *CERTImportCertificateFunc) 717 typedef SECStatus(PR_CALLBACK *CERTImportCertificateFunc)(void *arg,
727 (void *arg, SECItem **certs, int numcerts); 718 SECItem **certs,
719 int numcerts);
728 720
729 extern SECStatus 721 extern SECStatus CERT_DecodeCertPackage(char *certbuf, int certlen,
730 CERT_DecodeCertPackage(char *certbuf, int certlen, CERTImportCertificateFunc f, 722 CERTImportCertificateFunc f, void *arg);
731 » » void *arg);
732 723
733 /* 724 /*
734 ** Returns the value of an AVA. This was a formerly static 725 ** Returns the value of an AVA. This was a formerly static
735 ** function that has been exposed due to the need to decode 726 ** function that has been exposed due to the need to decode
736 ** and convert unicode strings to UTF8. 727 ** and convert unicode strings to UTF8.
737 ** 728 **
738 ** XXX This function resides in certhtml.c, should it be 729 ** XXX This function resides in certhtml.c, should it be
739 ** moved elsewhere? 730 ** moved elsewhere?
740 */ 731 */
741 extern SECItem *CERT_DecodeAVAValue(const SECItem *derAVAValue); 732 extern SECItem *CERT_DecodeAVAValue(const SECItem *derAVAValue);
742 733
743
744
745 /* 734 /*
746 ** extract various element strings from a distinguished name. 735 ** extract various element strings from a distinguished name.
747 ** "name" the distinguished name 736 ** "name" the distinguished name
748 */ 737 */
749 738
750 extern char *CERT_GetCertificateEmailAddress(CERTCertificate *cert); 739 extern char *CERT_GetCertificateEmailAddress(CERTCertificate *cert);
751 740
752 extern char *CERT_GetCertEmailAddress(const CERTName *name); 741 extern char *CERT_GetCertEmailAddress(const CERTName *name);
753 742
754 extern const char * CERT_GetFirstEmailAddress(CERTCertificate * cert); 743 extern const char *CERT_GetFirstEmailAddress(CERTCertificate *cert);
755 744
756 extern const char * CERT_GetNextEmailAddress(CERTCertificate * cert, 745 extern const char *CERT_GetNextEmailAddress(CERTCertificate *cert,
757 const char * prev); 746 const char *prev);
758 747
759 /* The return value must be freed with PORT_Free. */ 748 /* The return value must be freed with PORT_Free. */
760 extern char *CERT_GetCommonName(const CERTName *name); 749 extern char *CERT_GetCommonName(const CERTName *name);
761 750
762 extern char *CERT_GetCountryName(const CERTName *name); 751 extern char *CERT_GetCountryName(const CERTName *name);
763 752
764 extern char *CERT_GetLocalityName(const CERTName *name); 753 extern char *CERT_GetLocalityName(const CERTName *name);
765 754
766 extern char *CERT_GetStateName(const CERTName *name); 755 extern char *CERT_GetStateName(const CERTName *name);
767 756
768 extern char *CERT_GetOrgName(const CERTName *name); 757 extern char *CERT_GetOrgName(const CERTName *name);
769 758
770 extern char *CERT_GetOrgUnitName(const CERTName *name); 759 extern char *CERT_GetOrgUnitName(const CERTName *name);
771 760
772 extern char *CERT_GetDomainComponentName(const CERTName *name); 761 extern char *CERT_GetDomainComponentName(const CERTName *name);
773 762
774 extern char *CERT_GetCertUid(const CERTName *name); 763 extern char *CERT_GetCertUid(const CERTName *name);
775 764
776 /* manipulate the trust parameters of a certificate */ 765 /* manipulate the trust parameters of a certificate */
777 766
778 extern SECStatus CERT_GetCertTrust(const CERTCertificate *cert, 767 extern SECStatus CERT_GetCertTrust(const CERTCertificate *cert,
779 CERTCertTrust *trust); 768 CERTCertTrust *trust);
780 769
781 extern SECStatus 770 extern SECStatus CERT_ChangeCertTrust(CERTCertDBHandle *handle,
782 CERT_ChangeCertTrust (CERTCertDBHandle *handle, CERTCertificate *cert, 771 CERTCertificate *cert,
783 » » CERTCertTrust *trust); 772 CERTCertTrust *trust);
784 773
785 extern SECStatus 774 extern SECStatus CERT_ChangeCertTrustByUsage(CERTCertDBHandle *certdb,
786 CERT_ChangeCertTrustByUsage(CERTCertDBHandle *certdb, CERTCertificate *cert, 775 CERTCertificate *cert,
787 » » » SECCertUsage usage); 776 SECCertUsage usage);
788 777
789 /************************************************************************* 778 /*************************************************************************
790 * 779 *
791 * manipulate the extensions of a certificate 780 * manipulate the extensions of a certificate
792 * 781 *
793 ************************************************************************/ 782 ************************************************************************/
794 783
795 /* 784 /*
796 ** Set up a cert for adding X509v3 extensions. Returns an opaque handle 785 ** Set up a cert for adding X509v3 extensions. Returns an opaque handle
797 ** used by the next two routines. 786 ** used by the next two routines.
798 ** "cert" is the certificate we are adding extensions to 787 ** "cert" is the certificate we are adding extensions to
799 */ 788 */
800 extern void *CERT_StartCertExtensions(CERTCertificate *cert); 789 extern void *CERT_StartCertExtensions(CERTCertificate *cert);
801 790
802 /* 791 /*
803 ** Add an extension to a certificate. 792 ** Add an extension to a certificate.
804 ** "exthandle" is the handle returned by the previous function 793 ** "exthandle" is the handle returned by the previous function
805 ** "idtag" is the integer tag for the OID that should ID this extension 794 ** "idtag" is the integer tag for the OID that should ID this extension
806 ** "value" is the value of the extension 795 ** "value" is the value of the extension
807 ** "critical" is the critical extension flag 796 ** "critical" is the critical extension flag
808 ** "copyData" is a flag indicating whether the value data should be 797 ** "copyData" is a flag indicating whether the value data should be
809 ** copied. 798 ** copied.
810 */ 799 */
811 extern SECStatus CERT_AddExtension (void *exthandle, int idtag, 800 extern SECStatus CERT_AddExtension(void *exthandle, int idtag, SECItem *value,
812 » » » SECItem *value, PRBool critical, PRBool copyData); 801 PRBool critical, PRBool copyData);
813 802
814 extern SECStatus CERT_AddExtensionByOID (void *exthandle, SECItem *oid, 803 extern SECStatus CERT_AddExtensionByOID(void *exthandle, SECItem *oid,
815 » » » SECItem *value, PRBool critical, PRBool copyData); 804 SECItem *value, PRBool critical,
805 PRBool copyData);
816 806
817 extern SECStatus CERT_EncodeAndAddExtension 807 extern SECStatus CERT_EncodeAndAddExtension(void *exthandle, int idtag,
818 (void *exthandle, int idtag, void *value, PRBool critical, 808 void *value, PRBool critical,
819 const SEC_ASN1Template *atemplate); 809 const SEC_ASN1Template *atemplate);
820 810
821 extern SECStatus CERT_EncodeAndAddBitStrExtension 811 extern SECStatus CERT_EncodeAndAddBitStrExtension(void *exthandle, int idtag,
822 (void *exthandle, int idtag, SECItem *value, PRBool critical); 812 SECItem *value,
813 PRBool critical);
823 814
824 815 extern SECStatus CERT_EncodeAltNameExtension(PLArenaPool *arena,
825 extern SECStatus 816 CERTGeneralName *value,
826 CERT_EncodeAltNameExtension(PLArenaPool *arena, CERTGeneralName *value, SECIte m *encodedValue); 817 SECItem *encodedValue);
827
828 818
829 /* 819 /*
830 ** Finish adding cert extensions. Does final processing on extension 820 ** Finish adding cert extensions. Does final processing on extension
831 ** data, putting it in the right format, and freeing any temporary 821 ** data, putting it in the right format, and freeing any temporary
832 ** storage. 822 ** storage.
833 ** "exthandle" is the handle used to add extensions to a certificate 823 ** "exthandle" is the handle used to add extensions to a certificate
834 */ 824 */
835 extern SECStatus CERT_FinishExtensions(void *exthandle); 825 extern SECStatus CERT_FinishExtensions(void *exthandle);
836 826
837 /* 827 /*
838 ** Merge an external list of extensions into a cert's extension list, adding one 828 ** Merge an external list of extensions into a cert's extension list, adding one
839 ** only when its OID matches none of the cert's existing extensions. Call this 829 ** only when its OID matches none of the cert's existing extensions. Call this
840 ** immediately before calling CERT_FinishExtensions(). 830 ** immediately before calling CERT_FinishExtensions().
841 */ 831 */
842 SECStatus 832 SECStatus CERT_MergeExtensions(void *exthandle, CERTCertExtension **exts);
843 CERT_MergeExtensions(void *exthandle, CERTCertExtension **exts);
844 833
845 /* If the extension is found, return its criticality and value. 834 /* If the extension is found, return its criticality and value.
846 ** This allocate storage for the returning extension value. 835 ** This allocate storage for the returning extension value.
847 */ 836 */
848 extern SECStatus CERT_GetExtenCriticality 837 extern SECStatus CERT_GetExtenCriticality(CERTCertExtension **extensions,
849 (CERTCertExtension **extensions, int tag, PRBool *isCritical); 838 int tag, PRBool *isCritical);
850 839
851 extern void 840 extern void CERT_DestroyOidSequence(CERTOidSequence *oidSeq);
852 CERT_DestroyOidSequence(CERTOidSequence *oidSeq);
853 841
854 /**************************************************************************** 842 /****************************************************************************
855 * 843 *
856 * DER encode and decode extension values 844 * DER encode and decode extension values
857 * 845 *
858 ****************************************************************************/ 846 ****************************************************************************/
859 847
860 /* Encode the value of the basicConstraint extension. 848 /* Encode the value of the basicConstraint extension.
861 ** arena - where to allocate memory for the encoded value. 849 ** arena - where to allocate memory for the encoded value.
862 ** value - extension value to encode 850 ** value - extension value to encode
863 ** encodedValue - output encoded value 851 ** encodedValue - output encoded value
864 */ 852 */
865 extern SECStatus CERT_EncodeBasicConstraintValue 853 extern SECStatus CERT_EncodeBasicConstraintValue(PLArenaPool *arena,
866 (PLArenaPool *arena, CERTBasicConstraints *value, SECItem *encodedValue); 854 CERTBasicConstraints *value,
855 SECItem *encodedValue);
867 856
868 /* 857 /*
869 ** Encode the value of the authorityKeyIdentifier extension. 858 ** Encode the value of the authorityKeyIdentifier extension.
870 */ 859 */
871 extern SECStatus CERT_EncodeAuthKeyID 860 extern SECStatus CERT_EncodeAuthKeyID(PLArenaPool *arena, CERTAuthKeyID *value,
872 (PLArenaPool *arena, CERTAuthKeyID *value, SECItem *encodedValue); 861 SECItem *encodedValue);
873 862
874 /* 863 /*
875 ** Encode the value of the crlDistributionPoints extension. 864 ** Encode the value of the crlDistributionPoints extension.
876 */ 865 */
877 extern SECStatus CERT_EncodeCRLDistributionPoints 866 extern SECStatus CERT_EncodeCRLDistributionPoints(
878 (PLArenaPool *arena, CERTCrlDistributionPoints *value,SECItem *derValue); 867 PLArenaPool *arena, CERTCrlDistributionPoints *value, SECItem *derValue);
879 868
880 /* 869 /*
881 ** Decodes a DER encoded basicConstaint extension value into a readable format 870 ** Decodes a DER encoded basicConstaint extension value into a readable format
882 ** value - decoded value 871 ** value - decoded value
883 ** encodedValue - value to decoded 872 ** encodedValue - value to decoded
884 */ 873 */
885 extern SECStatus CERT_DecodeBasicConstraintValue 874 extern SECStatus CERT_DecodeBasicConstraintValue(CERTBasicConstraints *value,
886 (CERTBasicConstraints *value, const SECItem *encodedValue); 875 const SECItem *encodedValue);
887 876
888 /* Decodes a DER encoded authorityKeyIdentifier extension value into a 877 /* Decodes a DER encoded authorityKeyIdentifier extension value into a
889 ** readable format. 878 ** readable format.
890 ** arena - where to allocate memory for the decoded value 879 ** arena - where to allocate memory for the decoded value
891 ** encodedValue - value to be decoded 880 ** encodedValue - value to be decoded
892 ** Returns a CERTAuthKeyID structure which contains the decoded value 881 ** Returns a CERTAuthKeyID structure which contains the decoded value
893 */ 882 */
894 extern CERTAuthKeyID *CERT_DecodeAuthKeyID 883 extern CERTAuthKeyID *CERT_DecodeAuthKeyID(PLArenaPool *arena,
895 » » » (PLArenaPool *arena, const SECItem *encodedValue); 884 const SECItem *encodedValue);
896 885
897 /* Decodes a DER encoded crlDistributionPoints extension value into a 886 /* Decodes a DER encoded crlDistributionPoints extension value into a
898 ** readable format. 887 ** readable format.
899 ** arena - where to allocate memory for the decoded value 888 ** arena - where to allocate memory for the decoded value
900 ** der - value to be decoded 889 ** der - value to be decoded
901 **» Returns a CERTCrlDistributionPoints structure which contains the 890 **» Returns a CERTCrlDistributionPoints structure which contains the
902 ** decoded value 891 ** decoded value
903 */ 892 */
904 extern CERTCrlDistributionPoints * CERT_DecodeCRLDistributionPoints 893 extern CERTCrlDistributionPoints *CERT_DecodeCRLDistributionPoints(
905 (PLArenaPool *arena, SECItem *der); 894 PLArenaPool *arena, SECItem *der);
906 895
907 /* Extract certain name type from a generalName */ 896 /* Extract certain name type from a generalName */
908 extern void *CERT_GetGeneralNameByType 897 extern void *CERT_GetGeneralNameByType(CERTGeneralName *genNames,
909 (CERTGeneralName *genNames, CERTGeneralNameType type, PRBool derFormat); 898 CERTGeneralNameType type,
899 PRBool derFormat);
910 900
911 901 extern CERTOidSequence *CERT_DecodeOidSequence(const SECItem *seqItem);
912 extern CERTOidSequence *
913 CERT_DecodeOidSequence(const SECItem *seqItem);
914
915
916
917 902
918 /**************************************************************************** 903 /****************************************************************************
919 * 904 *
920 * Find extension values of a certificate 905 * Find extension values of a certificate
921 * 906 *
922 ***************************************************************************/ 907 ***************************************************************************/
923 908
924 extern SECStatus CERT_FindCertExtension 909 extern SECStatus CERT_FindCertExtension(const CERTCertificate *cert, int tag,
925 (const CERTCertificate *cert, int tag, SECItem *value); 910 SECItem *value);
926 911
927 extern SECStatus CERT_FindNSCertTypeExtension 912 extern SECStatus CERT_FindNSCertTypeExtension(CERTCertificate *cert,
928 (CERTCertificate *cert, SECItem *value); 913 SECItem *value);
929 914
930 extern char * CERT_FindNSStringExtension (CERTCertificate *cert, int oidtag); 915 extern char *CERT_FindNSStringExtension(CERTCertificate *cert, int oidtag);
931 916
932 extern SECStatus CERT_FindCertExtensionByOID 917 extern SECStatus CERT_FindCertExtensionByOID(CERTCertificate *cert,
933 (CERTCertificate *cert, SECItem *oid, SECItem *value); 918 SECItem *oid, SECItem *value);
934 919
935 /* Returns the decoded value of the authKeyID extension. 920 /* Returns the decoded value of the authKeyID extension.
936 ** Note that this uses passed in the arena to allocate storage for the result 921 ** Note that this uses passed in the arena to allocate storage for the result
937 */ 922 */
938 extern CERTAuthKeyID * CERT_FindAuthKeyIDExten (PLArenaPool *arena,CERTCertifica te *cert); 923 extern CERTAuthKeyID *CERT_FindAuthKeyIDExten(PLArenaPool *arena,
924 CERTCertificate *cert);
939 925
940 /* Returns the decoded value of the basicConstraint extension. 926 /* Returns the decoded value of the basicConstraint extension.
941 */ 927 */
942 extern SECStatus CERT_FindBasicConstraintExten 928 extern SECStatus CERT_FindBasicConstraintExten(CERTCertificate *cert,
943 (CERTCertificate *cert, CERTBasicConstraints *value); 929 CERTBasicConstraints *value);
944 930
945 /* Returns the decoded value of the crlDistributionPoints extension. 931 /* Returns the decoded value of the crlDistributionPoints extension.
946 ** Note that the arena in cert is used to allocate storage for the result 932 ** Note that the arena in cert is used to allocate storage for the result
947 */ 933 */
948 extern CERTCrlDistributionPoints * CERT_FindCRLDistributionPoints 934 extern CERTCrlDistributionPoints *CERT_FindCRLDistributionPoints(
949 (CERTCertificate *cert); 935 CERTCertificate *cert);
950 936
951 /* Returns value of the keyUsage extension. This uses PR_Alloc to allocate 937 /* Returns value of the keyUsage extension. This uses PR_Alloc to allocate
952 ** buffer for the decoded value. The caller should free up the storage 938 ** buffer for the decoded value. The caller should free up the storage
953 ** allocated in value->data. 939 ** allocated in value->data.
954 */ 940 */
955 extern SECStatus CERT_FindKeyUsageExtension (CERTCertificate *cert, 941 extern SECStatus CERT_FindKeyUsageExtension(CERTCertificate *cert,
956 » » » » » » » SECItem *value); 942 SECItem *value);
957 943
958 /* Return the decoded value of the subjectKeyID extension. The caller should 944 /* Return the decoded value of the subjectKeyID extension. The caller should
959 ** free up the storage allocated in retItem->data. 945 ** free up the storage allocated in retItem->data.
960 */ 946 */
961 extern SECStatus CERT_FindSubjectKeyIDExtension (CERTCertificate *cert, 947 extern SECStatus CERT_FindSubjectKeyIDExtension(CERTCertificate *cert,
962 » » » » » » » SECItem *retItem); 948 SECItem *retItem);
963 949
964 /* 950 /*
965 ** If cert is a v3 certificate, and a critical keyUsage extension is included, 951 ** If cert is a v3 certificate, and a critical keyUsage extension is included,
966 ** then check the usage against the extension value. If a non-critical 952 ** then check the usage against the extension value. If a non-critical
967 ** keyUsage extension is included, this will return SECSuccess without 953 ** keyUsage extension is included, this will return SECSuccess without
968 ** checking, since the extension is an advisory field, not a restriction. 954 ** checking, since the extension is an advisory field, not a restriction.
969 ** If cert is not a v3 certificate, this will return SECSuccess. 955 ** If cert is not a v3 certificate, this will return SECSuccess.
970 ** cert - certificate 956 ** cert - certificate
971 ** usage - one of the x.509 v3 the Key Usage Extension flags 957 ** usage - one of the x.509 v3 the Key Usage Extension flags
972 */ 958 */
973 extern SECStatus CERT_CheckCertUsage (CERTCertificate *cert, 959 extern SECStatus CERT_CheckCertUsage(CERTCertificate *cert,
974 » » » » » » » unsigned char usage); 960 unsigned char usage);
975 961
976 /**************************************************************************** 962 /****************************************************************************
977 * 963 *
978 * CRL v2 Extensions supported routines 964 * CRL v2 Extensions supported routines
979 * 965 *
980 ****************************************************************************/ 966 ****************************************************************************/
981 967
982 extern SECStatus CERT_FindCRLExtensionByOID 968 extern SECStatus CERT_FindCRLExtensionByOID(CERTCrl *crl, SECItem *oid,
983 (CERTCrl *crl, SECItem *oid, SECItem *value); 969 SECItem *value);
984 970
985 extern SECStatus CERT_FindCRLExtension 971 extern SECStatus CERT_FindCRLExtension(CERTCrl *crl, int tag, SECItem *value);
986 (CERTCrl *crl, int tag, SECItem *value);
987 972
988 extern SECStatus 973 extern SECStatus CERT_FindInvalidDateExten(CERTCrl *crl, PRTime *value);
989 CERT_FindInvalidDateExten (CERTCrl *crl, PRTime *value);
990 974
991 /* 975 /*
992 ** Set up a crl for adding X509v3 extensions. Returns an opaque handle 976 ** Set up a crl for adding X509v3 extensions. Returns an opaque handle
993 ** used by routines that take an exthandle (void*) argument . 977 ** used by routines that take an exthandle (void*) argument .
994 ** "crl" is the CRL we are adding extensions to 978 ** "crl" is the CRL we are adding extensions to
995 */ 979 */
996 extern void *CERT_StartCRLExtensions(CERTCrl *crl); 980 extern void *CERT_StartCRLExtensions(CERTCrl *crl);
997 981
998 /* 982 /*
999 ** Set up a crl entry for adding X509v3 extensions. Returns an opaque handle 983 ** Set up a crl entry for adding X509v3 extensions. Returns an opaque handle
1000 ** used by routines that take an exthandle (void*) argument . 984 ** used by routines that take an exthandle (void*) argument .
1001 ** "crl" is the crl we are adding certs entries to 985 ** "crl" is the crl we are adding certs entries to
1002 ** "entry" is the crl entry we are adding extensions to 986 ** "entry" is the crl entry we are adding extensions to
1003 */ 987 */
1004 extern void *CERT_StartCRLEntryExtensions(CERTCrl *crl, CERTCrlEntry *entry); 988 extern void *CERT_StartCRLEntryExtensions(CERTCrl *crl, CERTCrlEntry *entry);
1005 989
1006 extern CERTCertNicknames *CERT_GetCertNicknames (CERTCertDBHandle *handle, 990 extern CERTCertNicknames *CERT_GetCertNicknames(CERTCertDBHandle *handle,
1007 » » » » » » int what, void *wincx); 991 int what, void *wincx);
1008 992
1009 /* 993 /*
1010 ** Finds the crlNumber extension and decodes its value into 'value' 994 ** Finds the crlNumber extension and decodes its value into 'value'
1011 */ 995 */
1012 extern SECStatus CERT_FindCRLNumberExten (PLArenaPool *arena, CERTCrl *crl, 996 extern SECStatus CERT_FindCRLNumberExten(PLArenaPool *arena, CERTCrl *crl,
1013 SECItem *value); 997 SECItem *value);
1014 998
1015 extern SECStatus CERT_FindCRLEntryReasonExten (CERTCrlEntry *crlEntry, 999 extern SECStatus CERT_FindCRLEntryReasonExten(CERTCrlEntry *crlEntry,
1016 » » » » » CERTCRLEntryReasonCode *value); 1000 CERTCRLEntryReasonCode *value);
1017 1001
1018 extern void CERT_FreeNicknames(CERTCertNicknames *nicknames); 1002 extern void CERT_FreeNicknames(CERTCertNicknames *nicknames);
1019 1003
1020 extern PRBool CERT_CompareCerts(const CERTCertificate *c1, 1004 extern PRBool CERT_CompareCerts(const CERTCertificate *c1,
1021 const CERTCertificate *c2); 1005 const CERTCertificate *c2);
1022 1006
1023 extern PRBool CERT_CompareCertsForRedirection(CERTCertificate *c1, 1007 extern PRBool CERT_CompareCertsForRedirection(CERTCertificate *c1,
1024 » » » » » » » CERTCertificate *c2); 1008 CERTCertificate *c2);
1025 1009
1026 /* 1010 /*
1027 ** Generate an array of the Distinguished Names that the given cert database 1011 ** Generate an array of the Distinguished Names that the given cert database
1028 ** "trusts" 1012 ** "trusts"
1029 */ 1013 */
1030 extern CERTDistNames *CERT_GetSSLCACerts(CERTCertDBHandle *handle); 1014 extern CERTDistNames *CERT_GetSSLCACerts(CERTCertDBHandle *handle);
1031 1015
1032 extern void CERT_FreeDistNames(CERTDistNames *names); 1016 extern void CERT_FreeDistNames(CERTDistNames *names);
1033 1017
1034 /* Duplicate distinguished name array */ 1018 /* Duplicate distinguished name array */
1035 extern CERTDistNames *CERT_DupDistNames(CERTDistNames *orig); 1019 extern CERTDistNames *CERT_DupDistNames(CERTDistNames *orig);
1036 1020
1037 /* 1021 /*
1038 ** Generate an array of Distinguished names from an array of nicknames 1022 ** Generate an array of Distinguished names from an array of nicknames
1039 */ 1023 */
1040 extern CERTDistNames *CERT_DistNamesFromNicknames 1024 extern CERTDistNames *CERT_DistNamesFromNicknames(CERTCertDBHandle *handle,
1041 (CERTCertDBHandle *handle, char **nicknames, int nnames); 1025 char **nicknames, int nnames);
1042 1026
1043 /* 1027 /*
1044 ** Generate an array of Distinguished names from a list of certs. 1028 ** Generate an array of Distinguished names from a list of certs.
1045 */ 1029 */
1046 extern CERTDistNames *CERT_DistNamesFromCertList(CERTCertList *list); 1030 extern CERTDistNames *CERT_DistNamesFromCertList(CERTCertList *list);
1047 1031
1048 /* 1032 /*
1049 ** Generate a certificate chain from a certificate. 1033 ** Generate a certificate chain from a certificate.
1050 */ 1034 */
1051 extern CERTCertificateList * 1035 extern CERTCertificateList *CERT_CertChainFromCert(CERTCertificate *cert,
1052 CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage, 1036 SECCertUsage usage,
1053 » » PRBool includeRoot); 1037 PRBool includeRoot);
1054 1038
1055 extern CERTCertificateList * 1039 extern CERTCertificateList *CERT_CertListFromCert(CERTCertificate *cert);
1056 CERT_CertListFromCert(CERTCertificate *cert);
1057 1040
1058 extern CERTCertificateList * 1041 extern CERTCertificateList *CERT_DupCertList(
1059 CERT_DupCertList(const CERTCertificateList * oldList); 1042 const CERTCertificateList *oldList);
1060 1043
1061 extern void CERT_DestroyCertificateList(CERTCertificateList *list); 1044 extern void CERT_DestroyCertificateList(CERTCertificateList *list);
1062 1045
1063 /* 1046 /*
1064 ** is cert a user cert? i.e. does it have CERTDB_USER trust, 1047 ** is cert a user cert? i.e. does it have CERTDB_USER trust,
1065 ** i.e. a private key? 1048 ** i.e. a private key?
1066 */ 1049 */
1067 PRBool CERT_IsUserCert(CERTCertificate* cert); 1050 PRBool CERT_IsUserCert(CERTCertificate *cert);
1068 1051
1069 /* is cert a newer than cert b? */ 1052 /* is cert a newer than cert b? */
1070 PRBool CERT_IsNewer(CERTCertificate *certa, CERTCertificate *certb); 1053 PRBool CERT_IsNewer(CERTCertificate *certa, CERTCertificate *certb);
1071 1054
1072 /* currently a stub for address book */ 1055 /* currently a stub for address book */
1073 PRBool 1056 PRBool CERT_IsCertRevoked(CERTCertificate *cert);
1074 CERT_IsCertRevoked(CERTCertificate *cert); 1057
1075 1058 void CERT_DestroyCertArray(CERTCertificate **certs, unsigned int ncerts);
1076 void
1077 CERT_DestroyCertArray(CERTCertificate **certs, unsigned int ncerts);
1078 1059
1079 /* convert an email address to lower case */ 1060 /* convert an email address to lower case */
1080 char *CERT_FixupEmailAddr(const char *emailAddr); 1061 char *CERT_FixupEmailAddr(const char *emailAddr);
1081 1062
1082 /* decode string representation of trust flags into trust struct */ 1063 /* decode string representation of trust flags into trust struct */
1083 SECStatus 1064 SECStatus CERT_DecodeTrustString(CERTCertTrust *trust, const char *trusts);
1084 CERT_DecodeTrustString(CERTCertTrust *trust, const char *trusts);
1085 1065
1086 /* encode trust struct into string representation of trust flags */ 1066 /* encode trust struct into string representation of trust flags */
1087 char * 1067 char *CERT_EncodeTrustString(CERTCertTrust *trust);
1088 CERT_EncodeTrustString(CERTCertTrust *trust);
1089 1068
1090 /* find the next or prev cert in a subject list */ 1069 /* find the next or prev cert in a subject list */
1091 CERTCertificate * 1070 CERTCertificate *CERT_PrevSubjectCert(CERTCertificate *cert);
1092 CERT_PrevSubjectCert(CERTCertificate *cert); 1071 CERTCertificate *CERT_NextSubjectCert(CERTCertificate *cert);
1093 CERTCertificate *
1094 CERT_NextSubjectCert(CERTCertificate *cert);
1095 1072
1096 /* 1073 /*
1097 * import a collection of certs into the temporary or permanent cert 1074 * import a collection of certs into the temporary or permanent cert
1098 * database 1075 * database
1099 */ 1076 */
1100 SECStatus 1077 SECStatus CERT_ImportCerts(CERTCertDBHandle *certdb, SECCertUsage usage,
1101 CERT_ImportCerts(CERTCertDBHandle *certdb, SECCertUsage usage, 1078 unsigned int ncerts, SECItem **derCerts,
1102 » » unsigned int ncerts, SECItem **derCerts, 1079 CERTCertificate ***retCerts, PRBool keepCerts,
1103 » » CERTCertificate ***retCerts, PRBool keepCerts, 1080 PRBool caOnly, char *nickname);
1104 » » PRBool caOnly, char *nickname); 1081
1105 1082 char *CERT_MakeCANickname(CERTCertificate *cert);
1106 char * 1083
1107 CERT_MakeCANickname(CERTCertificate *cert); 1084 PRBool CERT_IsCACert(CERTCertificate *cert, unsigned int *rettype);
1108 1085
1109 PRBool 1086 PRBool CERT_IsCADERCert(SECItem *derCert, unsigned int *rettype);
1110 CERT_IsCACert(CERTCertificate *cert, unsigned int *rettype); 1087
1111 1088 PRBool CERT_IsRootDERCert(SECItem *derCert);
1112 PRBool 1089
1113 CERT_IsCADERCert(SECItem *derCert, unsigned int *rettype); 1090 SECStatus CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
1114 1091 SECItem *profileTime);
1115 PRBool
1116 CERT_IsRootDERCert(SECItem *derCert);
1117
1118 SECStatus
1119 CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
1120 » » SECItem *profileTime);
1121 1092
1122 /* 1093 /*
1123 * find the smime symmetric capabilities profile for a given cert 1094 * find the smime symmetric capabilities profile for a given cert
1124 */ 1095 */
1125 SECItem * 1096 SECItem *CERT_FindSMimeProfile(CERTCertificate *cert);
1126 CERT_FindSMimeProfile(CERTCertificate *cert); 1097
1127 1098 SECStatus CERT_AddNewCerts(CERTCertDBHandle *handle);
1128 SECStatus 1099
1129 CERT_AddNewCerts(CERTCertDBHandle *handle); 1100 CERTCertificatePolicies *CERT_DecodeCertificatePoliciesExtension(
1130 1101 const SECItem *extnValue);
1131 CERTCertificatePolicies * 1102
1132 CERT_DecodeCertificatePoliciesExtension(const SECItem *extnValue); 1103 void CERT_DestroyCertificatePoliciesExtension(
1133 1104 CERTCertificatePolicies *policies);
1134 void 1105
1135 CERT_DestroyCertificatePoliciesExtension(CERTCertificatePolicies *policies); 1106 CERTCertificatePolicyMappings *CERT_DecodePolicyMappingsExtension(
1136 1107 SECItem *encodedCertPolicyMaps);
1137 CERTCertificatePolicyMappings * 1108
1138 CERT_DecodePolicyMappingsExtension(SECItem *encodedCertPolicyMaps); 1109 SECStatus CERT_DestroyPolicyMappingsExtension(
1139 1110 CERTCertificatePolicyMappings *mappings);
1140 SECStatus 1111
1141 CERT_DestroyPolicyMappingsExtension(CERTCertificatePolicyMappings *mappings); 1112 SECStatus CERT_DecodePolicyConstraintsExtension(
1142
1143 SECStatus
1144 CERT_DecodePolicyConstraintsExtension(
1145 CERTCertificatePolicyConstraints *decodedValue, 1113 CERTCertificatePolicyConstraints *decodedValue,
1146 const SECItem *encodedValue); 1114 const SECItem *encodedValue);
1147 1115
1148 SECStatus CERT_DecodeInhibitAnyExtension 1116 SECStatus CERT_DecodeInhibitAnyExtension(
1149 (CERTCertificateInhibitAny *decodedValue, SECItem *extnValue); 1117 CERTCertificateInhibitAny *decodedValue, SECItem *extnValue);
1150 1118
1151 CERTUserNotice * 1119 CERTUserNotice *CERT_DecodeUserNotice(SECItem *noticeItem);
1152 CERT_DecodeUserNotice(SECItem *noticeItem); 1120
1153 1121 extern CERTGeneralName *CERT_DecodeAltNameExtension(PLArenaPool *reqArena,
1154 extern CERTGeneralName * 1122 SECItem *EncodedAltName);
1155 CERT_DecodeAltNameExtension(PLArenaPool *reqArena, SECItem *EncodedAltName); 1123
1156 1124 extern CERTNameConstraints *CERT_DecodeNameConstraintsExtension(
1157 extern CERTNameConstraints * 1125 PLArenaPool *arena, const SECItem *encodedConstraints);
1158 CERT_DecodeNameConstraintsExtension(PLArenaPool *arena,
1159 const SECItem *encodedConstraints);
1160 1126
1161 /* returns addr of a NULL termainated array of pointers to CERTAuthInfoAccess */ 1127 /* returns addr of a NULL termainated array of pointers to CERTAuthInfoAccess */
1162 extern CERTAuthInfoAccess ** 1128 extern CERTAuthInfoAccess **CERT_DecodeAuthInfoAccessExtension(
1163 CERT_DecodeAuthInfoAccessExtension(PLArenaPool *reqArena, 1129 PLArenaPool *reqArena, const SECItem *encodedExtension);
1164 » » » » const SECItem *encodedExtension); 1130
1165 1131 extern CERTPrivKeyUsagePeriod *CERT_DecodePrivKeyUsagePeriodExtension(
1166 extern CERTPrivKeyUsagePeriod * 1132 PLArenaPool *arena, SECItem *extnValue);
1167 CERT_DecodePrivKeyUsagePeriodExtension(PLArenaPool *arena, SECItem *extnValue); 1133
1168 1134 extern CERTGeneralName *CERT_GetNextGeneralName(CERTGeneralName *current);
1169 extern CERTGeneralName * 1135
1170 CERT_GetNextGeneralName(CERTGeneralName *current); 1136 extern CERTGeneralName *CERT_GetPrevGeneralName(CERTGeneralName *current);
1171
1172 extern CERTGeneralName *
1173 CERT_GetPrevGeneralName(CERTGeneralName *current);
1174 1137
1175 /* 1138 /*
1176 * Look up name constraints for some certs that do not include name constraints 1139 * Look up name constraints for some certs that do not include name constraints
1177 * (Most importantly, root certificates) 1140 * (Most importantly, root certificates)
1178 * 1141 *
1179 * If a matching subject is found, |extensions| will be populated with a copy of the 1142 * If a matching subject is found, |extensions| will be populated with a copy of
1180 * DER-encoded name constraints extension. The data in |extensions| will point t o 1143 * the
1144 * DER-encoded name constraints extension. The data in |extensions| will point
1145 * to
1181 * memory that the caller owns. 1146 * memory that the caller owns.
1182 * 1147 *
1183 * There is no mechanism to configure imposed name constraints right now. All 1148 * There is no mechanism to configure imposed name constraints right now. All
1184 * imposed name constraints are built into NSS. 1149 * imposed name constraints are built into NSS.
1185 */ 1150 */
1186 SECStatus 1151 SECStatus CERT_GetImposedNameConstraints(const SECItem *derSubject,
1187 CERT_GetImposedNameConstraints(const SECItem *derSubject, SECItem *extensions); 1152 SECItem *extensions);
1188 1153
1189 CERTNameConstraint * 1154 CERTNameConstraint *CERT_GetNextNameConstraint(CERTNameConstraint *current);
1190 CERT_GetNextNameConstraint(CERTNameConstraint *current); 1155
1191 1156 CERTNameConstraint *CERT_GetPrevNameConstraint(CERTNameConstraint *current);
1192 CERTNameConstraint * 1157
1193 CERT_GetPrevNameConstraint(CERTNameConstraint *current); 1158 void CERT_DestroyUserNotice(CERTUserNotice *userNotice);
1194 1159
1195 void 1160 typedef char *(*CERTPolicyStringCallback)(char *org, unsigned long noticeNumber,
1196 CERT_DestroyUserNotice(CERTUserNotice *userNotice); 1161 void *arg);
1197 1162 void CERT_SetCAPolicyStringCallback(CERTPolicyStringCallback cb, void *cbarg);
1198 typedef char * (* CERTPolicyStringCallback)(char *org, 1163
1199 » » » » » unsigned long noticeNumber, 1164 char *CERT_GetCertCommentString(CERTCertificate *cert);
1200 » » » » » void *arg); 1165
1201 void 1166 PRBool CERT_GovtApprovedBitSet(CERTCertificate *cert);
1202 CERT_SetCAPolicyStringCallback(CERTPolicyStringCallback cb, void *cbarg); 1167
1203 1168 SECStatus CERT_AddPermNickname(CERTCertificate *cert, char *nickname);
1204 char * 1169
1205 CERT_GetCertCommentString(CERTCertificate *cert); 1170 CERTCertList *CERT_MatchUserCert(CERTCertDBHandle *handle, SECCertUsage usage,
1206 1171 int nCANames, char **caNames, void *proto_win);
1207 PRBool 1172
1208 CERT_GovtApprovedBitSet(CERTCertificate *cert); 1173 CERTCertList *CERT_NewCertList(void);
1209
1210 SECStatus
1211 CERT_AddPermNickname(CERTCertificate *cert, char *nickname);
1212
1213 CERTCertList *
1214 CERT_MatchUserCert(CERTCertDBHandle *handle,
1215 » » SECCertUsage usage,
1216 » » int nCANames, char **caNames,
1217 » » void *proto_win);
1218
1219 CERTCertList *
1220 CERT_NewCertList(void);
1221 1174
1222 /* free the cert list and all the certs in the list */ 1175 /* free the cert list and all the certs in the list */
1223 void 1176 void CERT_DestroyCertList(CERTCertList *certs);
1224 CERT_DestroyCertList(CERTCertList *certs);
1225 1177
1226 /* remove the node and free the cert */ 1178 /* remove the node and free the cert */
1227 void 1179 void CERT_RemoveCertListNode(CERTCertListNode *node);
1228 CERT_RemoveCertListNode(CERTCertListNode *node);
1229 1180
1230 /* equivalent to CERT_AddCertToListTailWithData(certs, cert, NULL) */ 1181 /* equivalent to CERT_AddCertToListTailWithData(certs, cert, NULL) */
1231 SECStatus 1182 SECStatus CERT_AddCertToListTail(CERTCertList *certs, CERTCertificate *cert);
1232 CERT_AddCertToListTail(CERTCertList *certs, CERTCertificate *cert);
1233 1183
1234 /* equivalent to CERT_AddCertToListHeadWithData(certs, cert, NULL) */ 1184 /* equivalent to CERT_AddCertToListHeadWithData(certs, cert, NULL) */
1235 SECStatus 1185 SECStatus CERT_AddCertToListHead(CERTCertList *certs, CERTCertificate *cert);
1236 CERT_AddCertToListHead(CERTCertList *certs, CERTCertificate *cert);
1237 1186
1238 /* 1187 /*
1239 * The new cert list node takes ownership of "cert". "cert" is freed 1188 * The new cert list node takes ownership of "cert". "cert" is freed
1240 * when the list node is removed. 1189 * when the list node is removed.
1241 */ 1190 */
1242 SECStatus 1191 SECStatus CERT_AddCertToListTailWithData(CERTCertList *certs,
1243 CERT_AddCertToListTailWithData(CERTCertList *certs, CERTCertificate *cert, 1192 CERTCertificate *cert, void *appData);
1244 » » » » » » » void *appData);
1245 1193
1246 /* 1194 /*
1247 * The new cert list node takes ownership of "cert". "cert" is freed 1195 * The new cert list node takes ownership of "cert". "cert" is freed
1248 * when the list node is removed. 1196 * when the list node is removed.
1249 */ 1197 */
1250 SECStatus 1198 SECStatus CERT_AddCertToListHeadWithData(CERTCertList *certs,
1251 CERT_AddCertToListHeadWithData(CERTCertList *certs, CERTCertificate *cert, 1199 CERTCertificate *cert, void *appData);
1252 » » » » » » » void *appData); 1200
1253 1201 typedef PRBool (*CERTSortCallback)(CERTCertificate *certa,
1254 typedef PRBool (* CERTSortCallback)(CERTCertificate *certa, 1202 CERTCertificate *certb, void *arg);
1255 » » » » CERTCertificate *certb, 1203 SECStatus CERT_AddCertToListSorted(CERTCertList *certs, CERTCertificate *cert,
1256 » » » » void *arg); 1204 CERTSortCallback f, void *arg);
1257 SECStatus
1258 CERT_AddCertToListSorted(CERTCertList *certs, CERTCertificate *cert,
1259 » » » CERTSortCallback f, void *arg);
1260 1205
1261 /* callback for CERT_AddCertToListSorted that sorts based on validity 1206 /* callback for CERT_AddCertToListSorted that sorts based on validity
1262 * period and a given time. 1207 * period and a given time.
1263 */ 1208 */
1264 PRBool 1209 PRBool CERT_SortCBValidity(CERTCertificate *certa, CERTCertificate *certb,
1265 CERT_SortCBValidity(CERTCertificate *certa, 1210 void *arg);
1266 » » CERTCertificate *certb, 1211
1267 » » void *arg); 1212 SECStatus CERT_CheckForEvilCert(CERTCertificate *cert);
1268 1213
1269 SECStatus 1214 CERTGeneralName *CERT_GetCertificateNames(CERTCertificate *cert,
1270 CERT_CheckForEvilCert(CERTCertificate *cert); 1215 PLArenaPool *arena);
1271 1216
1272 CERTGeneralName * 1217 CERTGeneralName *CERT_GetConstrainedCertificateNames(
1273 CERT_GetCertificateNames(CERTCertificate *cert, PLArenaPool *arena); 1218 const CERTCertificate *cert, PLArenaPool *arena,
1274 1219 PRBool includeSubjectCommonName);
1275 CERTGeneralName *
1276 CERT_GetConstrainedCertificateNames(const CERTCertificate *cert,
1277 PLArenaPool *arena,
1278 PRBool includeSubjectCommonName);
1279 1220
1280 /* 1221 /*
1281 * Creates or adds to a list of all certs with a give subject name, sorted by 1222 * Creates or adds to a list of all certs with a give subject name, sorted by
1282 * validity time, newest first. Invalid certs are considered older than 1223 * validity time, newest first. Invalid certs are considered older than
1283 * valid certs. If validOnly is set, do not include invalid certs on list. 1224 * valid certs. If validOnly is set, do not include invalid certs on list.
1284 */ 1225 */
1285 CERTCertList * 1226 CERTCertList *CERT_CreateSubjectCertList(CERTCertList *certList,
1286 CERT_CreateSubjectCertList(CERTCertList *certList, CERTCertDBHandle *handle, 1227 CERTCertDBHandle *handle,
1287 » » » const SECItem *name, PRTime sorttime, 1228 const SECItem *name, PRTime sorttime,
1288 » » » PRBool validOnly); 1229 PRBool validOnly);
1289 1230
1290 /* 1231 /*
1291 * remove certs from a list that don't have keyUsage and certType 1232 * remove certs from a list that don't have keyUsage and certType
1292 * that match the given usage. 1233 * that match the given usage.
1293 */ 1234 */
1294 SECStatus 1235 SECStatus CERT_FilterCertListByUsage(CERTCertList *certList, SECCertUsage usage,
1295 CERT_FilterCertListByUsage(CERTCertList *certList, SECCertUsage usage, 1236 PRBool ca);
1296 » » » PRBool ca);
1297 1237
1298 /* 1238 /*
1299 * check the key usage of a cert against a set of required values 1239 * check the key usage of a cert against a set of required values
1300 */ 1240 */
1301 SECStatus 1241 SECStatus CERT_CheckKeyUsage(CERTCertificate *cert, unsigned int requiredUsage);
1302 CERT_CheckKeyUsage(CERTCertificate *cert, unsigned int requiredUsage);
1303 1242
1304 /* 1243 /*
1305 * return required key usage and cert type based on cert usage 1244 * return required key usage and cert type based on cert usage
1306 */ 1245 */
1307 SECStatus 1246 SECStatus CERT_KeyUsageAndTypeForCertUsage(SECCertUsage usage, PRBool ca,
1308 CERT_KeyUsageAndTypeForCertUsage(SECCertUsage usage, 1247 unsigned int *retKeyUsage,
1309 » » » » PRBool ca, 1248 unsigned int *retCertType);
1310 » » » » unsigned int *retKeyUsage,
1311 » » » » unsigned int *retCertType);
1312 /* 1249 /*
1313 * return required trust flags for various cert usages for CAs 1250 * return required trust flags for various cert usages for CAs
1314 */ 1251 */
1315 SECStatus 1252 SECStatus CERT_TrustFlagsForCACertUsage(SECCertUsage usage,
1316 CERT_TrustFlagsForCACertUsage(SECCertUsage usage, 1253 unsigned int *retFlags,
1317 » » » unsigned int *retFlags, 1254 SECTrustType *retTrustType);
1318 » » » SECTrustType *retTrustType);
1319 1255
1320 /* 1256 /*
1321 * Find all user certificates that match the given criteria. 1257 * Find all user certificates that match the given criteria.
1322 * 1258 *
1323 * "handle" - database to search 1259 * "handle" - database to search
1324 * "usage" - certificate usage to match 1260 * "usage" - certificate usage to match
1325 * "oneCertPerName" - if set then only return the "best" cert per 1261 * "oneCertPerName" - if set then only return the "best" cert per
1326 * name 1262 * name
1327 * "validOnly" - only return certs that are curently valid 1263 * "validOnly" - only return certs that are curently valid
1328 * "proto_win" - window handle passed to pkcs11 1264 * "proto_win" - window handle passed to pkcs11
1329 */ 1265 */
1330 CERTCertList * 1266 CERTCertList *CERT_FindUserCertsByUsage(CERTCertDBHandle *handle,
1331 CERT_FindUserCertsByUsage(CERTCertDBHandle *handle, 1267 SECCertUsage usage,
1332 » » » SECCertUsage usage, 1268 PRBool oneCertPerName, PRBool validOnly,
1333 » » » PRBool oneCertPerName, 1269 void *proto_win);
1334 » » » PRBool validOnly,
1335 » » » void *proto_win);
1336 1270
1337 /* 1271 /*
1338 * Find a user certificate that matchs the given criteria. 1272 * Find a user certificate that matchs the given criteria.
1339 * 1273 *
1340 * "handle" - database to search 1274 * "handle" - database to search
1341 * "nickname" - nickname to match 1275 * "nickname" - nickname to match
1342 * "usage" - certificate usage to match 1276 * "usage" - certificate usage to match
1343 * "validOnly" - only return certs that are curently valid 1277 * "validOnly" - only return certs that are curently valid
1344 * "proto_win" - window handle passed to pkcs11 1278 * "proto_win" - window handle passed to pkcs11
1345 */ 1279 */
1346 CERTCertificate * 1280 CERTCertificate *CERT_FindUserCertByUsage(CERTCertDBHandle *handle,
1347 CERT_FindUserCertByUsage(CERTCertDBHandle *handle, 1281 const char *nickname,
1348 » » » const char *nickname, 1282 SECCertUsage usage, PRBool validOnly,
1349 » » » SECCertUsage usage, 1283 void *proto_win);
1350 » » » PRBool validOnly,
1351 » » » void *proto_win);
1352 1284
1353 /* 1285 /*
1354 * Filter a list of certificates, removing those certs that do not have 1286 * Filter a list of certificates, removing those certs that do not have
1355 * one of the named CA certs somewhere in their cert chain. 1287 * one of the named CA certs somewhere in their cert chain.
1356 * 1288 *
1357 * "certList" - the list of certificates to filter 1289 * "certList" - the list of certificates to filter
1358 * "nCANames" - number of CA names 1290 * "nCANames" - number of CA names
1359 * "caNames" - array of CA names in string(rfc 1485) form 1291 * "caNames" - array of CA names in string(rfc 1485) form
1360 * "usage" - what use the certs are for, this is used when 1292 * "usage" - what use the certs are for, this is used when
1361 * selecting CA certs 1293 * selecting CA certs
1362 */ 1294 */
1363 SECStatus 1295 SECStatus CERT_FilterCertListByCANames(CERTCertList *certList, int nCANames,
1364 CERT_FilterCertListByCANames(CERTCertList *certList, int nCANames, 1296 char **caNames, SECCertUsage usage);
1365 » » » char **caNames, SECCertUsage usage);
1366 1297
1367 /* 1298 /*
1368 * Filter a list of certificates, removing those certs that aren't user certs 1299 * Filter a list of certificates, removing those certs that aren't user certs
1369 */ 1300 */
1370 SECStatus 1301 SECStatus CERT_FilterCertListForUserCerts(CERTCertList *certList);
1371 CERT_FilterCertListForUserCerts(CERTCertList *certList);
1372 1302
1373 /* 1303 /*
1374 * Collect the nicknames from all certs in a CertList. If the cert is not 1304 * Collect the nicknames from all certs in a CertList. If the cert is not
1375 * valid, append a string to that nickname. 1305 * valid, append a string to that nickname.
1376 * 1306 *
1377 * "certList" - the list of certificates 1307 * "certList" - the list of certificates
1378 * "expiredString" - the string to append to the nickname of any expired cert 1308 * "expiredString" - the string to append to the nickname of any expired cert
1379 * "notYetGoodString" - the string to append to the nickname of any cert 1309 * "notYetGoodString" - the string to append to the nickname of any cert
1380 * that is not yet valid 1310 * that is not yet valid
1381 */ 1311 */
1382 CERTCertNicknames * 1312 CERTCertNicknames *CERT_NicknameStringsFromCertList(CERTCertList *certList,
1383 CERT_NicknameStringsFromCertList(CERTCertList *certList, char *expiredString, 1313 char *expiredString,
1384 » » » » char *notYetGoodString); 1314 char *notYetGoodString);
1385 1315
1386 /* 1316 /*
1387 * Extract the nickname from a nickmake string that may have either 1317 * Extract the nickname from a nickmake string that may have either
1388 * expiredString or notYetGoodString appended. 1318 * expiredString or notYetGoodString appended.
1389 * 1319 *
1390 * Args: 1320 * Args:
1391 * "namestring" - the string containing the nickname, and possibly 1321 * "namestring" - the string containing the nickname, and possibly
1392 * one of the validity label strings 1322 * one of the validity label strings
1393 * "expiredString" - the expired validity label string 1323 * "expiredString" - the expired validity label string
1394 * "notYetGoodString" - the not yet good validity label string 1324 * "notYetGoodString" - the not yet good validity label string
1395 * 1325 *
1396 * Returns the raw nickname 1326 * Returns the raw nickname
1397 */ 1327 */
1398 char * 1328 char *CERT_ExtractNicknameString(char *namestring, char *expiredString,
1399 CERT_ExtractNicknameString(char *namestring, char *expiredString, 1329 char *notYetGoodString);
1400 » » » char *notYetGoodString);
1401 1330
1402 /* 1331 /*
1403 * Given a certificate, return a string containing the nickname, and possibly 1332 * Given a certificate, return a string containing the nickname, and possibly
1404 * one of the validity strings, based on the current validity state of the 1333 * one of the validity strings, based on the current validity state of the
1405 * certificate. 1334 * certificate.
1406 * 1335 *
1407 * "arena" - arena to allocate returned string from. If NULL, then heap 1336 * "arena" - arena to allocate returned string from. If NULL, then heap
1408 * is used. 1337 * is used.
1409 * "cert" - the cert to get nickname from 1338 * "cert" - the cert to get nickname from
1410 * "expiredString" - the string to append to the nickname if the cert is 1339 * "expiredString" - the string to append to the nickname if the cert is
1411 * expired. 1340 * expired.
1412 * "notYetGoodString" - the string to append to the nickname if the cert is 1341 * "notYetGoodString" - the string to append to the nickname if the cert is
1413 * not yet good. 1342 * not yet good.
1414 */ 1343 */
1415 char * 1344 char *CERT_GetCertNicknameWithValidity(PLArenaPool *arena,
1416 CERT_GetCertNicknameWithValidity(PLArenaPool *arena, CERTCertificate *cert, 1345 CERTCertificate *cert,
1417 » » » » char *expiredString, char *notYetGoodString); 1346 char *expiredString,
1347 char *notYetGoodString);
1418 1348
1419 /* 1349 /*
1420 * Return the string representation of a DER encoded distinguished name 1350 * Return the string representation of a DER encoded distinguished name
1421 * "dername" - The DER encoded name to convert 1351 * "dername" - The DER encoded name to convert
1422 */ 1352 */
1423 char * 1353 char *CERT_DerNameToAscii(SECItem *dername);
1424 CERT_DerNameToAscii(SECItem *dername);
1425 1354
1426 /* 1355 /*
1427 * Supported usage values and types: 1356 * Supported usage values and types:
1428 * certUsageSSLClient 1357 * certUsageSSLClient
1429 * certUsageSSLServer 1358 * certUsageSSLServer
1430 * certUsageSSLServerWithStepUp 1359 * certUsageSSLServerWithStepUp
1431 * certUsageEmailSigner 1360 * certUsageEmailSigner
1432 * certUsageEmailRecipient 1361 * certUsageEmailRecipient
1433 * certUsageObjectSigner 1362 * certUsageObjectSigner
1434 */ 1363 */
1435 1364
1436 CERTCertificate * 1365 CERTCertificate *CERT_FindMatchingCert(CERTCertDBHandle *handle,
1437 CERT_FindMatchingCert(CERTCertDBHandle *handle, SECItem *derName, 1366 SECItem *derName, CERTCertOwner owner,
1438 » » CERTCertOwner owner, SECCertUsage usage, 1367 SECCertUsage usage, PRBool preferTrusted,
1439 » » PRBool preferTrusted, PRTime validTime, PRBool validOnly); 1368 PRTime validTime, PRBool validOnly);
1440 1369
1441 /* 1370 /*
1442 * Acquire the global lock on the cert database. 1371 * Acquire the global lock on the cert database.
1443 * This lock is currently used for the following operations: 1372 * This lock is currently used for the following operations:
1444 * adding or deleting a cert to either the temp or perm databases 1373 * adding or deleting a cert to either the temp or perm databases
1445 * converting a temp to perm or perm to temp 1374 * converting a temp to perm or perm to temp
1446 * changing(maybe just adding?) the trust of a cert 1375 * changing(maybe just adding?) the trust of a cert
1447 * adjusting the reference count of a cert 1376 * adjusting the reference count of a cert
1448 */ 1377 */
1449 void 1378 void CERT_LockDB(CERTCertDBHandle *handle);
1450 CERT_LockDB(CERTCertDBHandle *handle);
1451 1379
1452 /* 1380 /*
1453 * Free the global cert database lock. 1381 * Free the global cert database lock.
1454 */ 1382 */
1455 void 1383 void CERT_UnlockDB(CERTCertDBHandle *handle);
1456 CERT_UnlockDB(CERTCertDBHandle *handle);
1457 1384
1458 /* 1385 /*
1459 * Get the certificate status checking configuratino data for 1386 * Get the certificate status checking configuratino data for
1460 * the certificate database 1387 * the certificate database
1461 */ 1388 */
1462 CERTStatusConfig * 1389 CERTStatusConfig *CERT_GetStatusConfig(CERTCertDBHandle *handle);
1463 CERT_GetStatusConfig(CERTCertDBHandle *handle);
1464 1390
1465 /* 1391 /*
1466 * Set the certificate status checking information for the 1392 * Set the certificate status checking information for the
1467 * database. The input structure becomes part of the certificate 1393 * database. The input structure becomes part of the certificate
1468 * database and will be freed by calling the 'Destroy' function in 1394 * database and will be freed by calling the 'Destroy' function in
1469 * the configuration object. 1395 * the configuration object.
1470 */ 1396 */
1471 void 1397 void CERT_SetStatusConfig(CERTCertDBHandle *handle, CERTStatusConfig *config);
1472 CERT_SetStatusConfig(CERTCertDBHandle *handle, CERTStatusConfig *config);
1473
1474
1475 1398
1476 /* 1399 /*
1477 * Acquire the cert reference count lock 1400 * Acquire the cert reference count lock
1478 * There is currently one global lock for all certs, but I'm putting a cert 1401 * There is currently one global lock for all certs, but I'm putting a cert
1479 * arg here so that it will be easy to make it per-cert in the future if 1402 * arg here so that it will be easy to make it per-cert in the future if
1480 * that turns out to be necessary. 1403 * that turns out to be necessary.
1481 */ 1404 */
1482 void 1405 void CERT_LockCertRefCount(CERTCertificate *cert);
1483 CERT_LockCertRefCount(CERTCertificate *cert);
1484 1406
1485 /* 1407 /*
1486 * Free the cert reference count lock 1408 * Free the cert reference count lock
1487 */ 1409 */
1488 void 1410 void CERT_UnlockCertRefCount(CERTCertificate *cert);
1489 CERT_UnlockCertRefCount(CERTCertificate *cert);
1490 1411
1491 /* 1412 /*
1492 * Acquire the cert trust lock 1413 * Acquire the cert trust lock
1493 * There is currently one global lock for all certs, but I'm putting a cert 1414 * There is currently one global lock for all certs, but I'm putting a cert
1494 * arg here so that it will be easy to make it per-cert in the future if 1415 * arg here so that it will be easy to make it per-cert in the future if
1495 * that turns out to be necessary. 1416 * that turns out to be necessary.
1496 */ 1417 */
1497 void 1418 void CERT_LockCertTrust(const CERTCertificate *cert);
1498 CERT_LockCertTrust(const CERTCertificate *cert);
1499 1419
1500 /* 1420 /*
1501 * Free the cert trust lock 1421 * Free the cert trust lock
1502 */ 1422 */
1503 void 1423 void CERT_UnlockCertTrust(const CERTCertificate *cert);
1504 CERT_UnlockCertTrust(const CERTCertificate *cert);
1505 1424
1506 /* 1425 /*
1507 * Digest the cert's subject public key using the specified algorithm. 1426 * Digest the cert's subject public key using the specified algorithm.
1508 * NOTE: this digests the value of the BIT STRING subjectPublicKey (excluding 1427 * NOTE: this digests the value of the BIT STRING subjectPublicKey (excluding
1509 * the tag, length, and number of unused bits) rather than the whole 1428 * the tag, length, and number of unused bits) rather than the whole
1510 * subjectPublicKeyInfo field. 1429 * subjectPublicKeyInfo field.
1511 * 1430 *
1512 * The necessary storage for the digest data is allocated. If "fill" is 1431 * The necessary storage for the digest data is allocated. If "fill" is
1513 * non-null, the data is put there, otherwise a SECItem is allocated. 1432 * non-null, the data is put there, otherwise a SECItem is allocated.
1514 * Allocation from "arena" if it is non-null, heap otherwise. Any problem 1433 * Allocation from "arena" if it is non-null, heap otherwise. Any problem
1515 * results in a NULL being returned (and an appropriate error set). 1434 * results in a NULL being returned (and an appropriate error set).
1516 */ 1435 */
1517 extern SECItem * 1436 extern SECItem *CERT_GetSubjectPublicKeyDigest(PLArenaPool *arena,
1518 CERT_GetSubjectPublicKeyDigest(PLArenaPool *arena, const CERTCertificate *cert, 1437 const CERTCertificate *cert,
1519 SECOidTag digestAlg, SECItem *fill); 1438 SECOidTag digestAlg,
1439 SECItem *fill);
1520 1440
1521 /* 1441 /*
1522 * Digest the cert's subject name using the specified algorithm. 1442 * Digest the cert's subject name using the specified algorithm.
1523 */ 1443 */
1524 extern SECItem * 1444 extern SECItem *CERT_GetSubjectNameDigest(PLArenaPool *arena,
1525 CERT_GetSubjectNameDigest(PLArenaPool *arena, const CERTCertificate *cert, 1445 const CERTCertificate *cert,
1526 SECOidTag digestAlg, SECItem *fill); 1446 SECOidTag digestAlg, SECItem *fill);
1527 1447
1528 SECStatus CERT_CheckCRL(CERTCertificate* cert, CERTCertificate* issuer, 1448 SECStatus CERT_CheckCRL(CERTCertificate *cert, CERTCertificate *issuer,
1529 const SECItem* dp, PRTime t, void* wincx); 1449 const SECItem *dp, PRTime t, void *wincx);
1530
1531 1450
1532 /* 1451 /*
1533 * Add a CERTNameConstraint to the CERTNameConstraint list 1452 * Add a CERTNameConstraint to the CERTNameConstraint list
1534 */ 1453 */
1535 extern CERTNameConstraint * 1454 extern CERTNameConstraint *CERT_AddNameConstraint(
1536 CERT_AddNameConstraint(CERTNameConstraint *list, 1455 CERTNameConstraint *list, CERTNameConstraint *constraint);
1537 » » CERTNameConstraint *constraint);
1538 1456
1539 /* 1457 /*
1540 * Allocate space and copy CERTNameConstraint from src to dest. 1458 * Allocate space and copy CERTNameConstraint from src to dest.
1541 * Arena is used to allocate result(if dest eq NULL) and its members 1459 * Arena is used to allocate result(if dest eq NULL) and its members
1542 * SECItem data. 1460 * SECItem data.
1543 */ 1461 */
1544 extern CERTNameConstraint * 1462 extern CERTNameConstraint *CERT_CopyNameConstraint(PLArenaPool *arena,
1545 CERT_CopyNameConstraint(PLArenaPool *arena, 1463 CERTNameConstraint *dest,
1546 » » » CERTNameConstraint *dest, 1464 CERTNameConstraint *src);
1547 » » » CERTNameConstraint *src);
1548 1465
1549 /* 1466 /*
1550 * Verify name against all the constraints relevant to that type of 1467 * Verify name against all the constraints relevant to that type of
1551 * the name. 1468 * the name.
1552 */ 1469 */
1553 extern SECStatus 1470 extern SECStatus CERT_CheckNameSpace(PLArenaPool *arena,
1554 CERT_CheckNameSpace(PLArenaPool *arena, 1471 const CERTNameConstraints *constraints,
1555 » » const CERTNameConstraints *constraints, 1472 const CERTGeneralName *currentName);
1556 » » const CERTGeneralName *currentName);
1557 1473
1558 /* 1474 /*
1559 * Extract and allocate the name constraints extension from the CA cert. 1475 * Extract and allocate the name constraints extension from the CA cert.
1560 * If the certificate contains no name constraints extension, but 1476 * If the certificate contains no name constraints extension, but
1561 * CERT_GetImposedNameConstraints returns a name constraints extension 1477 * CERT_GetImposedNameConstraints returns a name constraints extension
1562 * for the subject of the certificate, then that extension will be returned. 1478 * for the subject of the certificate, then that extension will be returned.
1563 */ 1479 */
1564 extern SECStatus 1480 extern SECStatus CERT_FindNameConstraintsExten(
1565 CERT_FindNameConstraintsExten(PLArenaPool *arena, 1481 PLArenaPool *arena, CERTCertificate *cert,
1566 » » » CERTCertificate *cert, 1482 CERTNameConstraints **constraints);
1567 » » » CERTNameConstraints **constraints);
1568 1483
1569 /* 1484 /*
1570 * Initialize a new GERTGeneralName fields (link) 1485 * Initialize a new GERTGeneralName fields (link)
1571 */ 1486 */
1572 extern CERTGeneralName * 1487 extern CERTGeneralName *CERT_NewGeneralName(PLArenaPool *arena,
1573 CERT_NewGeneralName(PLArenaPool *arena, CERTGeneralNameType type); 1488 CERTGeneralNameType type);
1574 1489
1575 /* 1490 /*
1576 * Lookup a CERTGeneralNameType constant by its human readable string. 1491 * Lookup a CERTGeneralNameType constant by its human readable string.
1577 */ 1492 */
1578 extern CERTGeneralNameType 1493 extern CERTGeneralNameType CERT_GetGeneralNameTypeFromString(
1579 CERT_GetGeneralNameTypeFromString(const char *string); 1494 const char *string);
1580 1495
1581 /* 1496 /*
1582 * PKIX extension encoding routines 1497 * PKIX extension encoding routines
1583 */ 1498 */
1584 extern SECStatus 1499 extern SECStatus CERT_EncodePolicyConstraintsExtension(
1585 CERT_EncodePolicyConstraintsExtension(PLArenaPool *arena, 1500 PLArenaPool *arena, CERTCertificatePolicyConstraints *constr,
1586 CERTCertificatePolicyConstraints *constr, 1501 SECItem *dest);
1587 SECItem *dest); 1502 extern SECStatus CERT_EncodeInhibitAnyExtension(
1588 extern SECStatus 1503 PLArenaPool *arena, CERTCertificateInhibitAny *inhibitAny, SECItem *dest);
1589 CERT_EncodeInhibitAnyExtension(PLArenaPool *arena, 1504 extern SECStatus CERT_EncodePolicyMappingExtension(
1590 CERTCertificateInhibitAny *inhibitAny, 1505 PLArenaPool *arena, CERTCertificatePolicyMappings *maps, SECItem *dest);
1591 SECItem *dest);
1592 extern SECStatus
1593 CERT_EncodePolicyMappingExtension(PLArenaPool *arena,
1594 CERTCertificatePolicyMappings *maps,
1595 SECItem *dest);
1596 1506
1597 extern SECStatus CERT_EncodeInfoAccessExtension(PLArenaPool *arena, 1507 extern SECStatus CERT_EncodeInfoAccessExtension(PLArenaPool *arena,
1598 CERTAuthInfoAccess **info, 1508 CERTAuthInfoAccess **info,
1599 SECItem *dest); 1509 SECItem *dest);
1600 extern SECStatus 1510 extern SECStatus CERT_EncodeUserNotice(PLArenaPool *arena,
1601 CERT_EncodeUserNotice(PLArenaPool *arena, 1511 CERTUserNotice *notice, SECItem *dest);
1602 CERTUserNotice *notice,
1603 SECItem *dest);
1604 1512
1605 extern SECStatus 1513 extern SECStatus CERT_EncodeDisplayText(PLArenaPool *arena, SECItem *text,
1606 CERT_EncodeDisplayText(PLArenaPool *arena, 1514 SECItem *dest);
1607 SECItem *text,
1608 SECItem *dest);
1609 1515
1610 extern SECStatus 1516 extern SECStatus CERT_EncodeCertPoliciesExtension(PLArenaPool *arena,
1611 CERT_EncodeCertPoliciesExtension(PLArenaPool *arena, 1517 CERTPolicyInfo **info,
1612 CERTPolicyInfo **info, 1518 SECItem *dest);
1613 SECItem *dest); 1519 extern SECStatus CERT_EncodeNoticeReference(PLArenaPool *arena,
1614 extern SECStatus 1520 CERTNoticeReference *reference,
1615 CERT_EncodeNoticeReference(PLArenaPool *arena, 1521 SECItem *dest);
1616 CERTNoticeReference *reference,
1617 SECItem *dest);
1618 1522
1619 /* 1523 /*
1620 * Returns a pointer to a static structure. 1524 * Returns a pointer to a static structure.
1621 */ 1525 */
1622 extern const CERTRevocationFlags* 1526 extern const CERTRevocationFlags *CERT_GetPKIXVerifyNistRevocationPolicy(void);
1623 CERT_GetPKIXVerifyNistRevocationPolicy(void);
1624 1527
1625 /* 1528 /*
1626 * Returns a pointer to a static structure. 1529 * Returns a pointer to a static structure.
1627 */ 1530 */
1628 extern const CERTRevocationFlags* 1531 extern const CERTRevocationFlags *CERT_GetClassicOCSPEnabledSoftFailurePolicy(
1629 CERT_GetClassicOCSPEnabledSoftFailurePolicy(void); 1532 void);
1630 1533
1631 /* 1534 /*
1632 * Returns a pointer to a static structure. 1535 * Returns a pointer to a static structure.
1633 */ 1536 */
1634 extern const CERTRevocationFlags* 1537 extern const CERTRevocationFlags *CERT_GetClassicOCSPEnabledHardFailurePolicy(
1635 CERT_GetClassicOCSPEnabledHardFailurePolicy(void); 1538 void);
1636 1539
1637 /* 1540 /*
1638 * Returns a pointer to a static structure. 1541 * Returns a pointer to a static structure.
1639 */ 1542 */
1640 extern const CERTRevocationFlags* 1543 extern const CERTRevocationFlags *CERT_GetClassicOCSPDisabledPolicy(void);
1641 CERT_GetClassicOCSPDisabledPolicy(void);
1642 1544
1643 /* 1545 /*
1644 * Verify a Cert with libpkix 1546 * Verify a Cert with libpkix
1645 * paramsIn control the verification options. If a value isn't specified 1547 * paramsIn control the verification options. If a value isn't specified
1646 * in paramsIn, it reverts to the application default. 1548 * in paramsIn, it reverts to the application default.
1647 * paramsOut specifies the parameters the caller would like to get back. 1549 * paramsOut specifies the parameters the caller would like to get back.
1648 * the caller may pass NULL, in which case no parameters are returned. 1550 * the caller may pass NULL, in which case no parameters are returned.
1649 */ 1551 */
1650 extern SECStatus CERT_PKIXVerifyCert( 1552 extern SECStatus CERT_PKIXVerifyCert(CERTCertificate *cert,
1651 » CERTCertificate *cert, 1553 SECCertificateUsage usages,
1652 » SECCertificateUsage usages, 1554 CERTValInParam *paramsIn,
1653 » CERTValInParam *paramsIn, 1555 CERTValOutParam *paramsOut, void *wincx);
1654 » CERTValOutParam *paramsOut,
1655 » void *wincx);
1656 1556
1657 /* Makes old cert validation APIs(CERT_VerifyCert, CERT_VerifyCertificate) 1557 /* Makes old cert validation APIs(CERT_VerifyCert, CERT_VerifyCertificate)
1658 * to use libpkix validation engine. The function should be called ones at 1558 * to use libpkix validation engine. The function should be called ones at
1659 * application initialization time. 1559 * application initialization time.
1660 * Function is not thread safe.*/ 1560 * Function is not thread safe.*/
1661 extern SECStatus CERT_SetUsePKIXForValidation(PRBool enable); 1561 extern SECStatus CERT_SetUsePKIXForValidation(PRBool enable);
1662 1562
1663 /* The function return PR_TRUE if cert validation should use 1563 /* The function return PR_TRUE if cert validation should use
1664 * libpkix cert validation engine. */ 1564 * libpkix cert validation engine. */
1665 extern PRBool CERT_GetUsePKIXForValidation(void); 1565 extern PRBool CERT_GetUsePKIXForValidation(void);
1666 1566
1667 /* 1567 /*
1668 * Allocate a parameter container of type CERTRevocationFlags, 1568 * Allocate a parameter container of type CERTRevocationFlags,
1669 * and allocate the inner arrays of the given sizes. 1569 * and allocate the inner arrays of the given sizes.
1670 * To cleanup call CERT_DestroyCERTRevocationFlags. 1570 * To cleanup call CERT_DestroyCERTRevocationFlags.
1671 */ 1571 */
1672 extern CERTRevocationFlags * 1572 extern CERTRevocationFlags *CERT_AllocCERTRevocationFlags(
1673 CERT_AllocCERTRevocationFlags(
1674 PRUint32 number_leaf_methods, PRUint32 number_leaf_pref_methods, 1573 PRUint32 number_leaf_methods, PRUint32 number_leaf_pref_methods,
1675 PRUint32 number_chain_methods, PRUint32 number_chain_pref_methods); 1574 PRUint32 number_chain_methods, PRUint32 number_chain_pref_methods);
1676 1575
1677 /* 1576 /*
1678 * Destroy the arrays inside flags, 1577 * Destroy the arrays inside flags,
1679 * and destroy the object pointed to by flags, too. 1578 * and destroy the object pointed to by flags, too.
1680 */ 1579 */
1681 extern void 1580 extern void CERT_DestroyCERTRevocationFlags(CERTRevocationFlags *flags);
1682 CERT_DestroyCERTRevocationFlags(CERTRevocationFlags *flags);
1683 1581
1684 SEC_END_PROTOS 1582 SEC_END_PROTOS
1685 1583
1686 #endif /* _CERT_H_ */ 1584 #endif /* _CERT_H_ */
OLDNEW
« no previous file with comments | « nss/lib/certdb/alg1485.c ('k') | nss/lib/certdb/certdb.h » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698