security/nss/lib/libpkix/include/pkix.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 the public API for libpkix. These are the top-level
michael@0 6 * functions in the library. They perform the primary operations of this
michael@0 7 * library: building and validating chains of X.509 certificates.
michael@0 8 *
michael@0 9 */
michael@0 10
michael@0 11 #ifndef _PKIX_H
michael@0 12 #define _PKIX_H
michael@0 13
michael@0 14 #include "pkixt.h"
michael@0 15 #include "pkix_util.h"
michael@0 16 #include "pkix_results.h"
michael@0 17 #include "pkix_certstore.h"
michael@0 18 #include "pkix_certsel.h"
michael@0 19 #include "pkix_crlsel.h"
michael@0 20 #include "pkix_checker.h"
michael@0 21 #include "pkix_revchecker.h"
michael@0 22 #include "pkix_pl_system.h"
michael@0 23 #include "pkix_pl_pki.h"
michael@0 24 #include "pkix_params.h"
michael@0 25
michael@0 26 #ifdef __cplusplus
michael@0 27 extern "C" {
michael@0 28 #endif
michael@0 29
michael@0 30 /* General
michael@0 31 *
michael@0 32 * Please refer to the libpkix Programmer's Guide for detailed information
michael@0 33 * about how to use the libpkix library. Certain key warnings and notices from
michael@0 34 * that document are repeated here for emphasis.
michael@0 35 *
michael@0 36 * All identifiers in this file (and all public identifiers defined in
michael@0 37 * libpkix) begin with "PKIX_". Private identifiers only intended for use
michael@0 38 * within the library begin with "pkix_".
michael@0 39 *
michael@0 40 * A function returns NULL upon success, and a PKIX_Error pointer upon failure.
michael@0 41 *
michael@0 42 * Unless otherwise noted, for all accessor (gettor) functions that return a
michael@0 43 * PKIX_PL_Object pointer, callers should assume that this pointer refers to a
michael@0 44 * shared object. Therefore, the caller should treat this shared object as
michael@0 45 * read-only and should not modify this shared object. When done using the
michael@0 46 * shared object, the caller should release the reference to the object by
michael@0 47 * using the PKIX_PL_Object_DecRef function.
michael@0 48 *
michael@0 49 * While a function is executing, if its arguments (or anything referred to by
michael@0 50 * its arguments) are modified, free'd, or destroyed, the function's behavior
michael@0 51 * is undefined.
michael@0 52 *
michael@0 53 */
michael@0 54
michael@0 55 /*
michael@0 56 * FUNCTION: PKIX_Initialize
michael@0 57 * DESCRIPTION:
michael@0 58 *
michael@0 59 * No PKIX_* types and functions should be used before this function is called
michael@0 60 * and returns successfully. This function should only be called once. If it
michael@0 61 * is called more than once, the behavior is undefined.
michael@0 62 *
michael@0 63 * NSS applications are expected to call NSS_Init, and need not know that
michael@0 64 * NSS will call this function (with "platformInitNeeded" set to PKIX_FALSE).
michael@0 65 * PKIX applications are expected instead to call this function with
michael@0 66 * "platformInitNeeded" set to PKIX_TRUE.
michael@0 67 *
michael@0 68 * This function initializes data structures critical to the operation of
michael@0 69 * libpkix. It also ensures that the API version (major.minor) desired by the
michael@0 70 * caller (the "desiredMajorVersion", "minDesiredMinorVersion", and
michael@0 71 * "maxDesiredMinorVersion") is compatible with the API version supported by
michael@0 72 * the library. As such, the library must support the "desiredMajorVersion"
michael@0 73 * of the API and must support a minor version that falls between
michael@0 74 * "minDesiredMinorVersion" and "maxDesiredMinorVersion", inclusive. If
michael@0 75 * compatibility exists, the function returns NULL and stores the library's
michael@0 76 * actual minor version at "pActualMinorVersion" (which may be greater than
michael@0 77 * "desiredMinorVersion"). If no compatibility exists, the function returns a
michael@0 78 * PKIX_Error pointer. If the caller wishes to specify that the largest
michael@0 79 * minor version available should be used, then maxDesiredMinorVersion should
michael@0 80 * be set to the macro PKIX_MAX_MINOR_VERSION (defined in pkixt.h).
michael@0 81 *
michael@0 82 * PARAMETERS:
michael@0 83 * "platformInitNeeded"
michael@0 84 * Boolean indicating whether the platform layer initialization code
michael@0 85 * has previously been run, or should be called from this function.
michael@0 86 * "desiredMajorVersion"
michael@0 87 * The major version of the libpkix API the application wishes to use.
michael@0 88 * "minDesiredMinorVersion"
michael@0 89 * The minimum minor version of the libpkix API the application wishes
michael@0 90 * to use.
michael@0 91 * "maxDesiredMinorVersion"
michael@0 92 * The maximum minor version of the libpkix API the application wishes
michael@0 93 * to use.
michael@0 94 * "pActualMinorVersion"
michael@0 95 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 96 * "pPlContext"
michael@0 97 * Address at which platform-specific context pointer is stored. Must
michael@0 98 * be non-NULL.
michael@0 99 * THREAD SAFETY:
michael@0 100 * Not Thread Safe
michael@0 101 * RETURNS:
michael@0 102 * Returns NULL if the function succeeds.
michael@0 103 * Returns an Initialize Error if the function fails in a non-fatal way.
michael@0 104 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 105 */
michael@0 106 PKIX_Error *
michael@0 107 PKIX_Initialize(
michael@0 108 PKIX_Boolean platformInitNeeded,
michael@0 109 PKIX_UInt32 desiredMajorVersion,
michael@0 110 PKIX_UInt32 minDesiredMinorVersion,
michael@0 111 PKIX_UInt32 maxDesiredMinorVersion,
michael@0 112 PKIX_UInt32 *pActualMinorVersion,
michael@0 113 void **pPlContext);
michael@0 114
michael@0 115 /*
michael@0 116 * FUNCTION: PKIX_Shutdown
michael@0 117 * DESCRIPTION:
michael@0 118 *
michael@0 119 * This function deallocates any memory used by libpkix and shuts down any
michael@0 120 * ongoing operations. This function should only be called once. If it is
michael@0 121 * called more than once, the behavior is undefined.
michael@0 122 *
michael@0 123 * No PKIX_* types and functions should be used after this function is called
michael@0 124 * and returns successfully.
michael@0 125 * PARAMETERS:
michael@0 126 * "plContext" - Platform-specific context pointer.
michael@0 127 * THREAD SAFETY:
michael@0 128 * Not Thread Safe
michael@0 129 * RETURNS:
michael@0 130 * Returns NULL if the function succeeds.
michael@0 131 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 132 */
michael@0 133 PKIX_Error *
michael@0 134 PKIX_Shutdown(void *plContext);
michael@0 135
michael@0 136 /*
michael@0 137 * FUNCTION: PKIX_ValidateChain
michael@0 138 * DESCRIPTION:
michael@0 139 *
michael@0 140 * This function attempts to validate the CertChain that has been set in the
michael@0 141 * ValidateParams pointed to by "params" using an RFC 3280-compliant
michael@0 142 * algorithm. If successful, this function returns NULL and stores the
michael@0 143 * ValidateResult at "pResult", which holds additional information, such as
michael@0 144 * the policy tree and the target's public key. If unsuccessful, an Error is
michael@0 145 * returned. Note: This function does not currently support non-blocking I/O.
michael@0 146 *
michael@0 147 * If "pVerifyTree" is non-NULL, a chain of VerifyNodes is created which
michael@0 148 * tracks the results of the validation. That is, either each node in the
michael@0 149 * chain has a NULL Error component, or the last node contains an Error
michael@0 150 * which indicates why the validation failed.
michael@0 151 *
michael@0 152 * PARAMETERS:
michael@0 153 * "params"
michael@0 154 * Address of ValidateParams used to validate CertChain. Must be non-NULL.
michael@0 155 * "pResult"
michael@0 156 * Address where object pointer will be stored. Must be non-NULL.
michael@0 157 * "pVerifyTree"
michael@0 158 * Address where a VerifyTree is stored, if non-NULL.
michael@0 159 * "plContext"
michael@0 160 * Platform-specific context pointer.
michael@0 161 * THREAD SAFETY:
michael@0 162 * Thread Safe (See Thread Safety Definitions in Programmer's Guide)
michael@0 163 * RETURNS:
michael@0 164 * Returns NULL if the function succeeds.
michael@0 165 * Returns a Validate Error if the function fails in a non-fatal way.
michael@0 166 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 167 */
michael@0 168 PKIX_Error *
michael@0 169 PKIX_ValidateChain(
michael@0 170 PKIX_ValidateParams *params,
michael@0 171 PKIX_ValidateResult **pResult,
michael@0 172 PKIX_VerifyNode **pVerifyTree,
michael@0 173 void *plContext);
michael@0 174
michael@0 175 /*
michael@0 176 * FUNCTION: PKIX_ValidateChain_NB
michael@0 177 * DESCRIPTION:
michael@0 178 *
michael@0 179 * This function is the equivalent of PKIX_ValidateChain, except that it
michael@0 180 * supports non-blocking I/O. When called with "pNBIOContext" pointing to NULL
michael@0 181 * it initiates a new chain validation as in PKIX_ValidateChain, ignoring the
michael@0 182 * value in all input variables except "params". If forced to suspend
michael@0 183 * processing by a WOULDBLOCK return from some operation, such as a CertStore
michael@0 184 * request, it stores the platform-dependent I/O context at "pNBIOContext" and
michael@0 185 * stores other intermediate variables at "pCertIndex", "pAnchorIndex",
michael@0 186 * "pCheckerIndex", "pRevChecking", and "pCheckers".
michael@0 187 *
michael@0 188 * When called subsequently with that non-NULL value at "pNBIOContext", it
michael@0 189 * relies on those intermediate values to be untouched, and it resumes chain
michael@0 190 * validation where it left off. Its behavior is undefined if any of the
michael@0 191 * intermediate values was not preserved.
michael@0 192 *
michael@0 193 * PARAMETERS:
michael@0 194 * "params"
michael@0 195 * Address of ValidateParams used to validate CertChain. Must be non-NULL.
michael@0 196 * "pCertIndex"
michael@0 197 * The UInt32 value of the index to the Cert chain, indicating which Cert
michael@0 198 * is currently being processed.
michael@0 199 * "pAnchorIndex"
michael@0 200 * The UInt32 value of the index to the Anchor chain, indicating which
michael@0 201 * Trust Anchor is currently being processed.
michael@0 202 * "pCheckerIndex"
michael@0 203 * The UInt32 value of the index to the List of CertChainCheckers,
michael@0 204 * indicating which Checker is currently processing.
michael@0 205 * "pRevChecking"
michael@0 206 * The Boolean flag indicating whether normal checking or revocation
michael@0 207 * checking is occurring for the Cert indicated by "pCertIndex".
michael@0 208 * "pCheckers"
michael@0 209 * The address of the List of CertChainCheckers. Must be non-NULL.
michael@0 210 * "pNBIOContext"
michael@0 211 * The address of the platform-dependend I/O context. Must be a non-NULL
michael@0 212 * pointer to a NULL value for the call to initiate chain validation.
michael@0 213 * "pResult"
michael@0 214 * Address where ValidateResult object pointer will be stored. Must be
michael@0 215 * non-NULL.
michael@0 216 * "pVerifyTree"
michael@0 217 * Address where a VerifyTree is stored, if non-NULL.
michael@0 218 * "plContext"
michael@0 219 * Platform-specific context pointer.
michael@0 220 * THREAD SAFETY:
michael@0 221 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 222 * RETURNS:
michael@0 223 * Returns NULL if the function succeeds.
michael@0 224 * Returns a VALIDATE Error if the function fails in a non-fatal way.
michael@0 225 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 226 */PKIX_Error *
michael@0 227 PKIX_ValidateChain_NB(
michael@0 228 PKIX_ValidateParams *params,
michael@0 229 PKIX_UInt32 *pCertIndex,
michael@0 230 PKIX_UInt32 *pAnchorIndex,
michael@0 231 PKIX_UInt32 *pCheckerIndex,
michael@0 232 PKIX_Boolean *pRevChecking,
michael@0 233 PKIX_List **pCheckers,
michael@0 234 void **pNBIOContext,
michael@0 235 PKIX_ValidateResult **pResult,
michael@0 236 PKIX_VerifyNode **pVerifyTree,
michael@0 237 void *plContext);
michael@0 238
michael@0 239 /*
michael@0 240 * FUNCTION: PKIX_BuildChain
michael@0 241 * DESCRIPTION:
michael@0 242 *
michael@0 243 * If called with a NULL "state", this function attempts to build and validate
michael@0 244 * a CertChain according to the ProcessingParams pointed to by "params", using
michael@0 245 * an RFC 3280-compliant validation algorithm. If successful, this function
michael@0 246 * returns NULL and stores the BuildResult at "pResult", which holds the built
michael@0 247 * CertChain, as well as additional information, such as the policy tree and
michael@0 248 * the target's public key. If unsuccessful, an Error is returned.
michael@0 249 *
michael@0 250 * If the chain building is blocked by a CertStore using non-blocking I/O, this
michael@0 251 * function stores platform-dependent non-blocking I/O context at
michael@0 252 * "pNBIOContext", its state at "pState", and NULL at "pResult". The caller
michael@0 253 * may be able to determine, in a platform-dependent way, when the I/O has
michael@0 254 * completed. In any case, calling the function again with "pState" containing
michael@0 255 * the returned value will allow the chain building to resume.
michael@0 256 *
michael@0 257 * If chain building is completed, either successfully or unsuccessfully, NULL
michael@0 258 * is stored at "pNBIOContext".
michael@0 259 *
michael@0 260 * If "pVerifyTree" is non-NULL, a tree of VerifyNodes is created which
michael@0 261 * tracks the results of the building. That is, each node of the tree either
michael@0 262 * has a NULL Error component, or it is a leaf node and it contains an Error
michael@0 263 * which indicates why the chain building could not proceed on this branch.
michael@0 264 *
michael@0 265 * PARAMETERS:
michael@0 266 * "params"
michael@0 267 * Address of ProcessingParams used to build and validate CertChain.
michael@0 268 * Must be non-NULL.
michael@0 269 * "pNBIOContext"
michael@0 270 * Address where platform-dependent information is store if the build
michael@0 271 * is suspended waiting for non-blocking I/O. Must be non-NULL.
michael@0 272 * "pState"
michael@0 273 * Address of BuildChain state. Must be NULL on initial call, and the
michael@0 274 * value previously returned on subsequent calls.
michael@0 275 * "pResult"
michael@0 276 * Address where object pointer will be stored. Must be non-NULL.
michael@0 277 * "pVerifyTree"
michael@0 278 * Address where a VerifyTree is stored, if non-NULL.
michael@0 279 * "plContext"
michael@0 280 * Platform-specific context pointer.
michael@0 281 * THREAD SAFETY:
michael@0 282 * Thread Safe (See Thread Safety Definitions in Programmer's Guide)
michael@0 283 * RETURNS:
michael@0 284 * Returns NULL if the function succeeds.
michael@0 285 * Returns a Build Error if the function fails in a non-fatal way.
michael@0 286 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 287 */
michael@0 288 PKIX_Error *
michael@0 289 PKIX_BuildChain(
michael@0 290 PKIX_ProcessingParams *params,
michael@0 291 void **pNBIOContext,
michael@0 292 void **pState,
michael@0 293 PKIX_BuildResult **pResult,
michael@0 294 PKIX_VerifyNode **pVerifyNode,
michael@0 295 void *plContext);
michael@0 296
michael@0 297 #ifdef __cplusplus
michael@0 298 }
michael@0 299 #endif
michael@0 300
michael@0 301 #endif /* _PKIX_H */

mercurial