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