security/nss/lib/libpkix/include/pkix_sample_modules.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 * This file defines functions associated with CertStore types.
michael@0 6 *
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef _PKIX_SAMPLEMODULES_H
michael@0 11 #define _PKIX_SAMPLEMODULES_H
michael@0 12
michael@0 13 #include "pkix_pl_common.h"
michael@0 14
michael@0 15 #ifdef __cplusplus
michael@0 16 extern "C" {
michael@0 17 #endif
michael@0 18
michael@0 19 /* General
michael@0 20 *
michael@0 21 * Please refer to the libpkix Programmer's Guide for detailed information
michael@0 22 * about how to use the libpkix library. Certain key warnings and notices from
michael@0 23 * that document are repeated here for emphasis.
michael@0 24 *
michael@0 25 * All identifiers in this file (and all public identifiers defined in
michael@0 26 * libpkix) begin with "PKIX_". Private identifiers only intended for use
michael@0 27 * within the library begin with "pkix_".
michael@0 28 *
michael@0 29 * A function returns NULL upon success, and a PKIX_Error pointer upon failure.
michael@0 30 *
michael@0 31 * Unless otherwise noted, for all accessor (gettor) functions that return a
michael@0 32 * PKIX_PL_Object pointer, callers should assume that this pointer refers to a
michael@0 33 * shared object. Therefore, the caller should treat this shared object as
michael@0 34 * read-only and should not modify this shared object. When done using the
michael@0 35 * shared object, the caller should release the reference to the object by
michael@0 36 * using the PKIX_PL_Object_DecRef function.
michael@0 37 *
michael@0 38 * While a function is executing, if its arguments (or anything referred to by
michael@0 39 * its arguments) are modified, free'd, or destroyed, the function's behavior
michael@0 40 * is undefined.
michael@0 41 *
michael@0 42 */
michael@0 43
michael@0 44 /* PKIX_PL_CollectionCertStore
michael@0 45 *
michael@0 46 * A PKIX_CollectionCertStore provides an example for showing how to retrieve
michael@0 47 * certificates and CRLs from a repository, such as a directory in the system.
michael@0 48 * It is expected the directory is an absolute directory which contains CRL
michael@0 49 * and Cert data files. CRL files are expected to have the suffix of .crl
michael@0 50 * and Cert files are expected to have the suffix of .crt .
michael@0 51 *
michael@0 52 * Once the caller has created the CollectionCertStoreContext object, the caller
michael@0 53 * then can call pkix_pl_CollectionCertStore_GetCert or
michael@0 54 * pkix_pl_CollectionCertStore_GetCRL to obtain Lists of PKIX_PL_Cert or
michael@0 55 * PKIX_PL_CRL objects, respectively.
michael@0 56 */
michael@0 57
michael@0 58 /*
michael@0 59 * FUNCTION: PKIX_PL_CollectionCertStore_Create
michael@0 60 * DESCRIPTION:
michael@0 61 *
michael@0 62 * Creates a new CollectionCertStore and returns it at
michael@0 63 * "pColCertStore".
michael@0 64 *
michael@0 65 * PARAMETERS:
michael@0 66 * "storeDir"
michael@0 67 * The absolute path where *.crl files are located.
michael@0 68 * "pColCertStoreContext"
michael@0 69 * Address where object pointer will be stored. Must be non-NULL.
michael@0 70 * "plContext"
michael@0 71 * Platform-specific context pointer.
michael@0 72 * THREAD SAFETY:
michael@0 73 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 74 * RETURNS:
michael@0 75 * Returns NULL if the function succeeds.
michael@0 76 * Returns a CollectionCertStoreContext Error if the function fails in
michael@0 77 * a non-fatal way.
michael@0 78 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 79 */
michael@0 80 PKIX_Error *
michael@0 81 PKIX_PL_CollectionCertStore_Create(
michael@0 82 PKIX_PL_String *storeDir,
michael@0 83 PKIX_CertStore **pCertStore,
michael@0 84 void *plContext);
michael@0 85
michael@0 86 /* PKIX_PL_PK11CertStore
michael@0 87 *
michael@0 88 * A PKIX_PL_PK11CertStore retrieves certificates and CRLs from a PKCS11
michael@0 89 * database. The directory that contains the cert8.db, key3.db, and secmod.db
michael@0 90 * files that comprise a PKCS11 database are specified in NSS initialization.
michael@0 91 *
michael@0 92 * Once the caller has created the Pk11CertStore object, the caller can call
michael@0 93 * pkix_pl_Pk11CertStore_GetCert or pkix_pl_Pk11CertStore_GetCert to obtain
michael@0 94 * a List of PKIX_PL_Certs or PKIX_PL_CRL objects, respectively.
michael@0 95 */
michael@0 96
michael@0 97 /*
michael@0 98 * FUNCTION: PKIX_PL_Pk11CertStore_Create
michael@0 99 * DESCRIPTION:
michael@0 100 *
michael@0 101 * Creates a new Pk11CertStore and returns it at "pPk11CertStore".
michael@0 102 *
michael@0 103 * PARAMETERS:
michael@0 104 * "pPk11CertStore"
michael@0 105 * Address where object pointer will be stored. Must be non-NULL.
michael@0 106 * "plContext"
michael@0 107 * Platform-specific context pointer.
michael@0 108 * THREAD SAFETY:
michael@0 109 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 110 * RETURNS:
michael@0 111 * Returns NULL if the function succeeds.
michael@0 112 * Returns a CertStore Error if the function fails in a non-fatal way.
michael@0 113 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 114 */
michael@0 115 PKIX_Error *
michael@0 116 PKIX_PL_Pk11CertStore_Create(
michael@0 117 PKIX_CertStore **pPk11CertStore,
michael@0 118 void *plContext);
michael@0 119
michael@0 120 #ifndef NSS_PKIX_NO_LDAP
michael@0 121 /* PKIX_PL_LdapCertStore
michael@0 122 *
michael@0 123 * A PKIX_PL_LdapCertStore retrieves certificates and CRLs from an LDAP server
michael@0 124 * over a socket connection. It used the LDAP protocol as described in RFC1777.
michael@0 125 *
michael@0 126 * Once the caller has created the LdapCertStore object, the caller can call
michael@0 127 * pkix_pl_LdapCertStore_GetCert or pkix_pl_LdapCertStore_GetCert to obtain
michael@0 128 * a List of PKIX_PL_Certs or PKIX_PL_CRL objects, respectively.
michael@0 129 */
michael@0 130
michael@0 131 /*
michael@0 132 * FUNCTION: PKIX_PL_LdapDefaultClient_Create
michael@0 133 * DESCRIPTION:
michael@0 134 *
michael@0 135 * Creates an LdapDefaultClient using the PRNetAddr poined to by "sockaddr",
michael@0 136 * with a timeout value of "timeout", and a BindAPI pointed to by "bindAPI";
michael@0 137 * and stores the address of the default LdapClient at "pClient".
michael@0 138 *
michael@0 139 * At the time of this version, there are unresolved questions about the LDAP
michael@0 140 * protocol. Although RFC1777 describes a BIND and UNBIND message, it is not
michael@0 141 * clear whether they are appropriate to this application. We have tested only
michael@0 142 * using servers that do not expect authentication, and that reject BIND
michael@0 143 * messages. It is not clear what values might be appropriate for the bindname
michael@0 144 * and authentication fields, which are currently implemented as char strings
michael@0 145 * supplied by the caller. (If this changes, the API and possibly the templates
michael@0 146 * will have to change.) Therefore the Client_Create API contains a BindAPI
michael@0 147 * structure, a union, which will have to be revised and extended when this
michael@0 148 * area of the protocol is better understood.
michael@0 149 *
michael@0 150 * PARAMETERS:
michael@0 151 * "sockaddr"
michael@0 152 * Address of the PRNetAddr to be used for the socket connection. Must be
michael@0 153 * non-NULL.
michael@0 154 * "timeout"
michael@0 155 * The PRIntervalTime value to be used as a timeout value in socket calls;
michael@0 156 * a zero value indicates non-blocking I/O is to be used.
michael@0 157 * "bindAPI"
michael@0 158 * The address of a BindAPI to be used if a BIND message is required. If
michael@0 159 * this argument is NULL, no Bind (or Unbind) will be sent.
michael@0 160 * "pClient"
michael@0 161 * Address where object pointer will be stored. Must be non-NULL.
michael@0 162 * "plContext"
michael@0 163 * Platform-specific context pointer.
michael@0 164 * THREAD SAFETY:
michael@0 165 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 166 * RETURNS:
michael@0 167 * Returns NULL if the function succeeds.
michael@0 168 * Returns a CertStore Error if the function fails in a non-fatal way.
michael@0 169 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 170 */
michael@0 171 PKIX_Error *
michael@0 172 PKIX_PL_LdapDefaultClient_Create(
michael@0 173 PRNetAddr *sockaddr,
michael@0 174 PRIntervalTime timeout,
michael@0 175 LDAPBindAPI *bindAPI,
michael@0 176 PKIX_PL_LdapDefaultClient **pClient,
michael@0 177 void *plContext);
michael@0 178
michael@0 179 /*
michael@0 180 * FUNCTION: PKIX_PL_LdapDefaultClient_CreateByName
michael@0 181 * DESCRIPTION:
michael@0 182 *
michael@0 183 * Creates an LdapDefaultClient using the hostname poined to by "hostname",
michael@0 184 * with a timeout value of "timeout", and a BindAPI pointed to by "bindAPI";
michael@0 185 * and stores the address of the default LdapClient at "pClient".
michael@0 186 *
michael@0 187 * At the time of this version, there are unresolved questions about the LDAP
michael@0 188 * protocol. Although RFC1777 describes a BIND and UNBIND message, it is not
michael@0 189 * clear whether they are appropriate to this application. We have tested only
michael@0 190 * using servers that do not expect authentication, and that reject BIND
michael@0 191 * messages. It is not clear what values might be appropriate for the bindname
michael@0 192 * and authentication fields, which are currently implemented as char strings
michael@0 193 * supplied by the caller. (If this changes, the API and possibly the templates
michael@0 194 * will have to change.) Therefore the Client_Create API contains a BindAPI
michael@0 195 * structure, a union, which will have to be revised and extended when this
michael@0 196 * area of the protocol is better understood.
michael@0 197 *
michael@0 198 * PARAMETERS:
michael@0 199 * "hostname"
michael@0 200 * Address of the hostname to be used for the socket connection. Must be
michael@0 201 * non-NULL.
michael@0 202 * "timeout"
michael@0 203 * The PRIntervalTime value to be used as a timeout value in socket calls;
michael@0 204 * a zero value indicates non-blocking I/O is to be used.
michael@0 205 * "bindAPI"
michael@0 206 * The address of a BindAPI to be used if a BIND message is required. If
michael@0 207 * this argument is NULL, no Bind (or Unbind) will be sent.
michael@0 208 * "pClient"
michael@0 209 * Address where object pointer will be stored. Must be non-NULL.
michael@0 210 * "plContext"
michael@0 211 * Platform-specific context pointer.
michael@0 212 * THREAD SAFETY:
michael@0 213 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 214 * RETURNS:
michael@0 215 * Returns NULL if the function succeeds.
michael@0 216 * Returns a CertStore Error if the function fails in a non-fatal way.
michael@0 217 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 218 */
michael@0 219 PKIX_Error *
michael@0 220 PKIX_PL_LdapDefaultClient_CreateByName(
michael@0 221 char *hostname,
michael@0 222 PRIntervalTime timeout,
michael@0 223 LDAPBindAPI *bindAPI,
michael@0 224 PKIX_PL_LdapDefaultClient **pClient,
michael@0 225 void *plContext);
michael@0 226
michael@0 227 /*
michael@0 228 * FUNCTION: PKIX_PL_LdapCertStore_Create
michael@0 229 * DESCRIPTION:
michael@0 230 *
michael@0 231 * Creates a new LdapCertStore using the LdapClient pointed to by "client",
michael@0 232 * and stores the address of the CertStore at "pCertStore".
michael@0 233 *
michael@0 234 * PARAMETERS:
michael@0 235 * "client"
michael@0 236 * Address of the LdapClient to be used. Must be non-NULL.
michael@0 237 * "pCertStore"
michael@0 238 * Address where object pointer will be stored. Must be non-NULL.
michael@0 239 * "plContext"
michael@0 240 * Platform-specific context pointer.
michael@0 241 * THREAD SAFETY:
michael@0 242 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 243 * RETURNS:
michael@0 244 * Returns NULL if the function succeeds.
michael@0 245 * Returns a CertStore Error if the function fails in a non-fatal way.
michael@0 246 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 247 */
michael@0 248 PKIX_Error *
michael@0 249 PKIX_PL_LdapCertStore_Create(
michael@0 250 PKIX_PL_LdapClient *client,
michael@0 251 PKIX_CertStore **pCertStore,
michael@0 252 void *plContext);
michael@0 253 #endif /* !NSS_PKIX_NO_LDAP */
michael@0 254
michael@0 255 /* PKIX_PL_NssContext
michael@0 256 *
michael@0 257 * A PKIX_PL_NssContext provides an example showing how the "plContext"
michael@0 258 * argument, that is part of every libpkix function call, can be used.
michael@0 259 * The "plContext" is the Portability Layer Context, which can be used
michael@0 260 * to communicate layer-specific information from the application to the
michael@0 261 * underlying Portability Layer (while bypassing the Portable Code, which
michael@0 262 * blindly passes the plContext on to every function call).
michael@0 263 *
michael@0 264 * In this case, NSS serves as both the application and the Portability Layer.
michael@0 265 * We define an NSS-specific structure, which includes an arena and a number
michael@0 266 * of SECCertificateUsage bit flags encoded as a PKIX_UInt32. A third argument,
michael@0 267 * wincx, is used on Windows platforms for PKCS11 access, and should be set to
michael@0 268 * NULL for other platforms.
michael@0 269 * Before calling any of the libpkix functions, the caller should create the NSS
michael@0 270 * context, by calling PKIX_PL_NssContext_Create, and provide that NSS context
michael@0 271 * as the "plContext" argument in every libpkix function call the caller makes.
michael@0 272 * When the caller is finished using the NSS context (usually just after he
michael@0 273 * calls PKIX_Shutdown), the caller should call PKIX_PL_NssContext_Destroy to
michael@0 274 * free the NSS context structure.
michael@0 275 */
michael@0 276
michael@0 277 /*
michael@0 278 * FUNCTION: PKIX_PL_NssContext_Create
michael@0 279 * DESCRIPTION:
michael@0 280 *
michael@0 281 * Creates a new NssContext using the certificate usage(s) specified by
michael@0 282 * "certUsage" and stores it at "pNssContext". This function also internally
michael@0 283 * creates an arena and stores it as part of the NssContext structure. Unlike
michael@0 284 * most other libpkix API functions, this function does not take a "plContext"
michael@0 285 * parameter.
michael@0 286 *
michael@0 287 * PARAMETERS:
michael@0 288 * "certUsage"
michael@0 289 * The desired SECCertificateUsage(s).
michael@0 290 * "useNssArena"
michael@0 291 * Boolean flag indicates NSS Arena is used for memory allocation.
michael@0 292 * "wincx"
michael@0 293 * A Windows-dependent pointer for PKCS11 token handling.
michael@0 294 * "pNssContext"
michael@0 295 * Address where object pointer will be stored. Must be non-NULL.
michael@0 296 * THREAD SAFETY:
michael@0 297 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 298 * RETURNS:
michael@0 299 * Returns NULL if the function succeeds.
michael@0 300 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 301 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 302 */
michael@0 303 PKIX_Error *
michael@0 304 PKIX_PL_NssContext_Create(
michael@0 305 PKIX_UInt32 certificateUsage,
michael@0 306 PKIX_Boolean useNssArena,
michael@0 307 void *wincx,
michael@0 308 void **pNssContext);
michael@0 309
michael@0 310 /*
michael@0 311 * FUNCTION: PKIX_PL_NssContext_Destroy
michael@0 312 * DESCRIPTION:
michael@0 313 *
michael@0 314 * Frees the structure pointed to by "nssContext" along with any of its
michael@0 315 * associated memory. Unlike most other libpkix API functions, this function
michael@0 316 * does not take a "plContext" parameter.
michael@0 317 *
michael@0 318 * PARAMETERS:
michael@0 319 * "nssContext"
michael@0 320 * Address of NssContext to be destroyed. Must be non-NULL.
michael@0 321 * THREAD SAFETY:
michael@0 322 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 323 * RETURNS:
michael@0 324 * Returns NULL if the function succeeds.
michael@0 325 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 326 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 327 */
michael@0 328 PKIX_Error *
michael@0 329 PKIX_PL_NssContext_Destroy(
michael@0 330 void *nssContext);
michael@0 331
michael@0 332 /*
michael@0 333 * FUNCTION: PKIX_PL_NssContext_SetTimeout
michael@0 334 * DESCRIPTION:
michael@0 335 *
michael@0 336 * Sets IO timeout for network operations like OCSP response and cert
michael@0 337 * fetching.
michael@0 338 *
michael@0 339 * PARAMETERS:
michael@0 340 * "nssContext"
michael@0 341 * Address of NssContext to be destroyed. Must be non-NULL.
michael@0 342 * THREAD SAFETY:
michael@0 343 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 344 * RETURNS:
michael@0 345 * Returns NULL if the function succeeds.
michael@0 346 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 347 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 348 */
michael@0 349 PKIX_Error *
michael@0 350 PKIX_PL_NssContext_SetTimeout(PKIX_UInt32 timeout, PKIX_PL_NssContext *nssContext);
michael@0 351
michael@0 352 /*
michael@0 353 * FUNCTION: PKIX_PL_NssContext_SetMaxResponseLen
michael@0 354 * DESCRIPTION:
michael@0 355 *
michael@0 356 * Sets maximum responce length allowed during network IO operations.
michael@0 357 *
michael@0 358 * PARAMETERS:
michael@0 359 * "nssContext"
michael@0 360 * Address of NssContext to be destroyed. Must be non-NULL.
michael@0 361 * THREAD SAFETY:
michael@0 362 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 363 * RETURNS:
michael@0 364 * Returns NULL if the function succeeds.
michael@0 365 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 366 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 367 */
michael@0 368 PKIX_Error *
michael@0 369 PKIX_PL_NssContext_SetMaxResponseLen(PKIX_UInt32 len, PKIX_PL_NssContext *nssContext);
michael@0 370
michael@0 371 /*
michael@0 372 * FUNCTION: PKIX_PL_NssContext_SetCrlReloadDelay
michael@0 373 * DESCRIPTION:
michael@0 374 *
michael@0 375 * Sets user defined timeout between attempts to load crl using
michael@0 376 * CRLDP.
michael@0 377 *
michael@0 378 * PARAMETERS:
michael@0 379 * "delaySeconds"
michael@0 380 * Reload delay in seconds.
michael@0 381 * "nssContext"
michael@0 382 * Address of NssContext to be destroyed. Must be non-NULL.
michael@0 383 * THREAD SAFETY:
michael@0 384 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 385 * RETURNS:
michael@0 386 * Returns NULL if the function succeeds.
michael@0 387 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 388 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 389 */
michael@0 390 PKIX_Error *
michael@0 391 PKIX_PL_NssContext_SetCrlReloadDelay(PKIX_UInt32 delaySeconds,
michael@0 392 PKIX_PL_NssContext *nssContext);
michael@0 393
michael@0 394 /*
michael@0 395 * FUNCTION: PKIX_PL_NssContext_SetBadDerCrlReloadDelay
michael@0 396 * DESCRIPTION:
michael@0 397 *
michael@0 398 * Sets user defined timeout between attempts to load crls
michael@0 399 * that failed to decode.
michael@0 400 *
michael@0 401 * PARAMETERS:
michael@0 402 * "delaySeconds"
michael@0 403 * Reload delay in seconds.
michael@0 404 * "nssContext"
michael@0 405 * Address of NssContext to be destroyed. Must be non-NULL.
michael@0 406 * THREAD SAFETY:
michael@0 407 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 408 * RETURNS:
michael@0 409 * Returns NULL if the function succeeds.
michael@0 410 * Returns a Context Error if the function fails in a non-fatal way.
michael@0 411 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 412 */
michael@0 413 PKIX_Error *
michael@0 414 PKIX_PL_NssContext_SetBadDerCrlReloadDelay(PKIX_UInt32 delaySeconds,
michael@0 415 PKIX_PL_NssContext *nssContext);
michael@0 416 #ifdef __cplusplus
michael@0 417 }
michael@0 418 #endif
michael@0 419
michael@0 420 #endif /* _PKIX_SAMPLEMODULES_H */

mercurial