security/nss/lib/libpkix/include/pkix_pl_system.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 several platform independent functions to make system
michael@0 6 * calls in a portable manner.
michael@0 7 *
michael@0 8 */
michael@0 9
michael@0 10 #ifndef _PKIX_PL_SYSTEM_H
michael@0 11 #define _PKIX_PL_SYSTEM_H
michael@0 12
michael@0 13 #include "pkixt.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 /*
michael@0 45 * FUNCTION: PKIX_PL_Initialize
michael@0 46 * DESCRIPTION:
michael@0 47 *
michael@0 48 * XXX If this function is really only meant to be used by PKIX_Initialize,
michael@0 49 * why don't we just put it in a private header file rather than the public
michael@0 50 * API. I think it may confuse users.
michael@0 51 *
michael@0 52 * This function should NOT be called by applications. It is only meant to
michael@0 53 * be used internally. The application needs only to call PKIX_Initialize,
michael@0 54 * which in turn will call this function.
michael@0 55 *
michael@0 56 * This function initializes data structures critical to the operation of
michael@0 57 * libpkix. If initialization is not successful, an Error pointer is
michael@0 58 * returned. This function should only be called once. If it is called more
michael@0 59 * than once, the behavior is undefined.
michael@0 60 *
michael@0 61 * No PKIX_* types and functions should be used before this function is
michael@0 62 * called and returns successfully.
michael@0 63 *
michael@0 64 * PARAMETERS:
michael@0 65 * "platformInitNeeded"
michael@0 66 * Boolean indicating whether platform initialization is to be called
michael@0 67 * "useArenas"
michael@0 68 * Boolean indicating whether allocation is to be done using arenas or
michael@0 69 * individual allocation (malloc).
michael@0 70 * "pPlContext"
michael@0 71 * Address at which platform-specific context pointer is stored. Must be
michael@0 72 * non-NULL.
michael@0 73 * THREAD SAFETY:
michael@0 74 * Not Thread Safe
michael@0 75 *
michael@0 76 * This function assumes that no other thread is calling this function while
michael@0 77 * it is executing.
michael@0 78 * RETURNS:
michael@0 79 * Returns NULL if the function succeeds.
michael@0 80 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 81 */
michael@0 82 PKIX_Error *
michael@0 83 PKIX_PL_Initialize(
michael@0 84 PKIX_Boolean platformInitNeeded,
michael@0 85 PKIX_Boolean useArenas,
michael@0 86 void **pPlContext);
michael@0 87
michael@0 88 /*
michael@0 89 * FUNCTION: PKIX_PL_Shutdown
michael@0 90 * DESCRIPTION:
michael@0 91 *
michael@0 92 * XXX If this function is really only meant to be used by PKIX_Shutdown,
michael@0 93 * why don't we just put it in a private header file rather than the public
michael@0 94 * API. I think it may confuse users.
michael@0 95 *
michael@0 96 * This function should NOT be called by applications. It is only meant to
michael@0 97 * be used internally. The application needs only to call PKIX_Shutdown,
michael@0 98 * which in turn will call this function.
michael@0 99 *
michael@0 100 * This function deallocates any memory used by the Portability Layer (PL)
michael@0 101 * component of the libpkix library and shuts down any ongoing operations.
michael@0 102 * This function should only be called once. If it is called more than once,
michael@0 103 * the behavior is undefined.
michael@0 104 *
michael@0 105 * No PKIX_* types and functions should be used after this function is called
michael@0 106 * and returns successfully.
michael@0 107 *
michael@0 108 * PARAMETERS:
michael@0 109 * "platformInitNeeded"
michael@0 110 * Boolean value of whether PKIX initialized NSS: PKIX_TRUE if we
michael@0 111 * called nssInit, PKIX_FALSE otherwise
michael@0 112 * "plContext"
michael@0 113 * Platform-specific context pointer.
michael@0 114 * THREAD SAFETY:
michael@0 115 * Not Thread Safe
michael@0 116 *
michael@0 117 * This function makes use of global variables and should only be called once.
michael@0 118 * RETURNS:
michael@0 119 * Returns NULL if the function succeeds.
michael@0 120 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 121 */
michael@0 122 PKIX_Error *
michael@0 123 PKIX_PL_Shutdown(void *plContext);
michael@0 124
michael@0 125 /* standard memory management operations (not reference-counted) */
michael@0 126
michael@0 127 /*
michael@0 128 * FUNCTION: PKIX_PL_Malloc
michael@0 129 * DESCRIPTION:
michael@0 130 *
michael@0 131 * Allocates a block of "size" bytes. The bytes are not initialized. A
michael@0 132 * pointer to the newly allocated memory will be stored at "pMemory". The
michael@0 133 * memory allocated by PKIX_PL_Malloc() may only be freed by PKIX_PL_Free().
michael@0 134 * If "size" equals zero, this function stores NULL at "pMemory".
michael@0 135 *
michael@0 136 * PARAMETERS:
michael@0 137 * "size"
michael@0 138 * Number of bytes to allocate.
michael@0 139 * "pMemory"
michael@0 140 * Address where newly allocated pointer will be stored. Must be non-NULL.
michael@0 141 * "plContext"
michael@0 142 * Platform-specific context pointer.
michael@0 143 * THREAD SAFETY:
michael@0 144 * Thread safety depends on underlying thread safety of platform used by PL.
michael@0 145 * RETURNS:
michael@0 146 * Returns NULL if the function succeeds.
michael@0 147 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 148 */
michael@0 149 PKIX_Error *
michael@0 150 PKIX_PL_Malloc(
michael@0 151 PKIX_UInt32 size,
michael@0 152 void **pMemory,
michael@0 153 void *plContext);
michael@0 154
michael@0 155 /*
michael@0 156 * FUNCTION: PKIX_PL_Calloc
michael@0 157 * DESCRIPTION:
michael@0 158 *
michael@0 159 * Allocates memory for an array of "nElem" elements, with each element
michael@0 160 * requiring "elSize" bytes, and with all the bits initialized to zero. A
michael@0 161 * pointer to the newly allocated memory will be stored at "pMemory". The
michael@0 162 * memory allocated by PKIX_PL_Calloc() may only be freed by PKIX_PL_Free().
michael@0 163 * If "nElem" equals zero or "elSize" equals zero, this function stores NULL
michael@0 164 * at "pMemory".
michael@0 165 *
michael@0 166 * PARAMETERS:
michael@0 167 * "nElem"
michael@0 168 * Number of elements needed.
michael@0 169 * "elSize"
michael@0 170 * Number of bytes needed per element.
michael@0 171 * "pMemory"
michael@0 172 * Address where newly allocated pointer will be stored. Must be non-NULL.
michael@0 173 * "plContext"
michael@0 174 * Platform-specific context pointer.
michael@0 175 * THREAD SAFETY:
michael@0 176 * Thread safety depends on underlying thread safety of platform used by PL.
michael@0 177 * RETURNS:
michael@0 178 * Returns NULL if the function succeeds.
michael@0 179 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 180 */
michael@0 181 PKIX_Error *
michael@0 182 PKIX_PL_Calloc(
michael@0 183 PKIX_UInt32 nElem,
michael@0 184 PKIX_UInt32 elSize,
michael@0 185 void **pMemory,
michael@0 186 void *plContext);
michael@0 187
michael@0 188 /*
michael@0 189 * FUNCTION: PKIX_PL_Realloc
michael@0 190 * DESCRIPTION:
michael@0 191 *
michael@0 192 * Resizes an existing block of memory (pointed to by "ptr") to "size" bytes.
michael@0 193 * Stores a pointer to the resized memory at "pNewPtr". The "ptr" must
michael@0 194 * originate from either PKIX_PL_Malloc(), PKIX_PL_Realloc(), or
michael@0 195 * PKIX_PL_Calloc(). If "ptr" is NULL, this function behaves as if
michael@0 196 * PKIX_PL_Malloc were called. If "ptr" is not NULL and "size" equals zero,
michael@0 197 * the memory pointed to by "ptr" is deallocated and this function stores
michael@0 198 * NULL at "pPtr".
michael@0 199 *
michael@0 200 * PARAMETERS:
michael@0 201 * "ptr"
michael@0 202 * A pointer to an existing block of memory.
michael@0 203 * "size"
michael@0 204 * New size in bytes.
michael@0 205 * "pPtr"
michael@0 206 * Address where newly allocated pointer will be stored. Must be non-NULL.
michael@0 207 * "plContext"
michael@0 208 * Platform-specific context pointer.
michael@0 209 * THREAD SAFETY:
michael@0 210 * Thread safety depends on underlying thread safety of platform used by PL.
michael@0 211 * RETURNS:
michael@0 212 * Returns NULL if the function succeeds.
michael@0 213 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 214 */
michael@0 215 PKIX_Error *
michael@0 216 PKIX_PL_Realloc(
michael@0 217 void *ptr,
michael@0 218 PKIX_UInt32 size,
michael@0 219 void **pNewPtr,
michael@0 220 void *plContext);
michael@0 221
michael@0 222 /*
michael@0 223 * FUNCTION: PKIX_PL_Free
michael@0 224 * DESCRIPTION:
michael@0 225 *
michael@0 226 * Frees a block of memory pointed to by "ptr". This value must originate with
michael@0 227 * either PKIX_PL_Malloc(), PKIX_PL_Calloc, or PKIX_PL_Realloc(). If "ptr" is
michael@0 228 * NULL, the function has no effect.
michael@0 229 *
michael@0 230 * PARAMETERS:
michael@0 231 * "ptr"
michael@0 232 * A pointer to an existing block of memory.
michael@0 233 * "plContext"
michael@0 234 * Platform-specific context pointer.
michael@0 235 * THREAD SAFETY:
michael@0 236 * Thread safety depends on underlying thread safety of platform used by PL.
michael@0 237 * RETURNS:
michael@0 238 * Returns NULL always.
michael@0 239 */
michael@0 240 PKIX_Error *
michael@0 241 PKIX_PL_Free(
michael@0 242 void *ptr,
michael@0 243 void *plContext);
michael@0 244
michael@0 245 /* Callback Types
michael@0 246 *
michael@0 247 * The next few typedefs define function pointer types for the standard
michael@0 248 * functions associated with every object type. See the Implementation
michael@0 249 * Guidelines or the comments below for more information.
michael@0 250 */
michael@0 251
michael@0 252 /*
michael@0 253 * TYPE: PKIX_PL_DestructorCallback
michael@0 254 * DESCRIPTION:
michael@0 255 *
michael@0 256 * This callback function destroys (or DecRef's) any pointers contained in
michael@0 257 * the user data for the Object pointed to by "object" before the Object is
michael@0 258 * destroyed.
michael@0 259 *
michael@0 260 * PARAMETERS:
michael@0 261 * "object"
michael@0 262 * Address of Object to destroy. Must be non-NULL.
michael@0 263 * "plContext"
michael@0 264 * Platform-specific context pointer.
michael@0 265 * THREAD SAFETY:
michael@0 266 * Thread Safe
michael@0 267 *
michael@0 268 * Multiple threads must be able to safely call this function without
michael@0 269 * worrying about conflicts (as long as they're not operating on the same
michael@0 270 * object and nobody else is performing an operation on the object at the
michael@0 271 * same time). Both of these conditions should be guaranteed by the fact that
michael@0 272 * the object's ref count was reduced to 0 in a lock that's still held when
michael@0 273 * this callback is called.
michael@0 274 * RETURNS:
michael@0 275 * Returns NULL if the function succeeds.
michael@0 276 * Returns an error if the function fails in a non-fatal way.
michael@0 277 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 278 */
michael@0 279 typedef PKIX_Error *
michael@0 280 (*PKIX_PL_DestructorCallback)(
michael@0 281 PKIX_PL_Object *object,
michael@0 282 void *plContext);
michael@0 283
michael@0 284 /*
michael@0 285 * TYPE: PKIX_PL_EqualsCallback
michael@0 286 * DESCRIPTION:
michael@0 287 *
michael@0 288 * This callback function compares the Object pointed to by "firstObject" with
michael@0 289 * the Object pointed to by "secondObject" for equality and stores the result
michael@0 290 * at "pResult" (PKIX_TRUE if equal; PKIX_FALSE if not).
michael@0 291 *
michael@0 292 * PARAMETERS:
michael@0 293 * "firstObject"
michael@0 294 * Address of first object to compare. Must be non-NULL.
michael@0 295 * "secondObject"
michael@0 296 * Address of second object to compare. Must be non-NULL.
michael@0 297 * "pResult"
michael@0 298 * Address where Boolean will be stored. Must be non-NULL.
michael@0 299 * "plContext"
michael@0 300 * Platform-specific context pointer.
michael@0 301 * THREAD SAFETY:
michael@0 302 * Thread Safe
michael@0 303 *
michael@0 304 * Multiple threads must be able to safely call this function without
michael@0 305 * worrying about conflicts, even if they're operating on the same objects.
michael@0 306 * RETURNS:
michael@0 307 * Returns NULL if the function succeeds.
michael@0 308 * Returns an error if the function fails in a non-fatal way.
michael@0 309 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 310 */
michael@0 311 typedef PKIX_Error *
michael@0 312 (*PKIX_PL_EqualsCallback)(
michael@0 313 PKIX_PL_Object *firstObject,
michael@0 314 PKIX_PL_Object *secondObject,
michael@0 315 PKIX_Boolean *pResult,
michael@0 316 void *plContext);
michael@0 317
michael@0 318 /*
michael@0 319 * TYPE: PKIX_PL_HashcodeCallback
michael@0 320 * DESCRIPTION:
michael@0 321 *
michael@0 322 * This callback function computes the hashcode of the Object pointed to by
michael@0 323 * "object" and stores the result at "pValue".
michael@0 324 *
michael@0 325 * PARAMETERS:
michael@0 326 * "object"
michael@0 327 * Address of Object whose hashcode is desired. Must be non-NULL.
michael@0 328 * "pValue"
michael@0 329 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 330 * "plContext"
michael@0 331 * Platform-specific context pointer.
michael@0 332 * THREAD SAFETY:
michael@0 333 * Thread Safe
michael@0 334 *
michael@0 335 * Multiple threads must be able to safely call this function without
michael@0 336 * worrying about conflicts, even if they're operating on the same object.
michael@0 337 * RETURNS:
michael@0 338 * Returns NULL if the function succeeds.
michael@0 339 * Returns an error if the function fails in a non-fatal way.
michael@0 340 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 341 */
michael@0 342 typedef PKIX_Error *
michael@0 343 (*PKIX_PL_HashcodeCallback)(
michael@0 344 PKIX_PL_Object *object,
michael@0 345 PKIX_UInt32 *pValue,
michael@0 346 void *plContext);
michael@0 347
michael@0 348 /*
michael@0 349 * TYPE: PKIX_PL_ToStringCallback
michael@0 350 * DESCRIPTION:
michael@0 351 *
michael@0 352 * This callback function converts the Object pointed to by "object" to a
michael@0 353 * string representation and stores the result at "pString".
michael@0 354 *
michael@0 355 * PARAMETERS:
michael@0 356 * "object"
michael@0 357 * Object to get a string representation from. Must be non-NULL.
michael@0 358 * "pString"
michael@0 359 * Address where object pointer will be stored. Must be non-NULL.
michael@0 360 * "plContext"
michael@0 361 * Platform-specific context pointer.
michael@0 362 * THREAD SAFETY:
michael@0 363 * Thread Safe
michael@0 364 *
michael@0 365 * Multiple threads must be able to safely call this function without
michael@0 366 * worrying about conflicts, even if they're operating on the same object.
michael@0 367 * RETURNS:
michael@0 368 * Returns NULL if the function succeeds.
michael@0 369 * Returns an error if the function fails in a non-fatal way.
michael@0 370 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 371 */
michael@0 372 typedef PKIX_Error *
michael@0 373 (*PKIX_PL_ToStringCallback)(
michael@0 374 PKIX_PL_Object *object,
michael@0 375 PKIX_PL_String **pString,
michael@0 376 void *plContext);
michael@0 377
michael@0 378 /*
michael@0 379 * TYPE: PKIX_PL_ComparatorCallback
michael@0 380 * DESCRIPTION:
michael@0 381 *
michael@0 382 * This callback function determines how the Object pointed to by
michael@0 383 * "firstObject" compares to the Object pointed to by "secondObject" and
michael@0 384 * stores the result at "pResult".
michael@0 385 *
michael@0 386 * Result is less than 0 if firstObject < secondObject
michael@0 387 * Result equals 0 if firstObject = secondObject
michael@0 388 * Result is greater than 0 if firstObject > secondObject
michael@0 389 *
michael@0 390 * PARAMETERS:
michael@0 391 * "firstObject"
michael@0 392 * Address of the first Object to compare. Must be non-NULL.
michael@0 393 * "secondObject"
michael@0 394 * Address of the second Object to compare. Must be non-NULL.
michael@0 395 * "pResult"
michael@0 396 * Address where PKIX_Int32 will be stored. Must be non-NULL.
michael@0 397 * "plContext"
michael@0 398 * Platform-specific context pointer.
michael@0 399 * THREAD SAFETY:
michael@0 400 * Thread Safe
michael@0 401 *
michael@0 402 * Multiple threads must be able to safely call this function without
michael@0 403 * worrying about conflicts, even if they're operating on the same objects.
michael@0 404 * RETURNS:
michael@0 405 * Returns NULL if the function succeeds.
michael@0 406 * Returns an error if the function fails in a non-fatal way.
michael@0 407 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 408 */
michael@0 409 typedef PKIX_Error *
michael@0 410 (*PKIX_PL_ComparatorCallback)(
michael@0 411 PKIX_PL_Object *firstObject,
michael@0 412 PKIX_PL_Object *secondObject,
michael@0 413 PKIX_Int32 *pResult,
michael@0 414 void *plContext);
michael@0 415
michael@0 416 /*
michael@0 417 * TYPE: PKIX_PL_DuplicateCallback
michael@0 418 * DESCRIPTION:
michael@0 419 *
michael@0 420 * This callback function creates a copy of the Object pointed to by "object"
michael@0 421 * and stores it at "pNewObject". Changes to the copy will not affect the
michael@0 422 * original and vice versa.
michael@0 423 *
michael@0 424 * Note that if "object" is immutable, the Duplicate callback function simply
michael@0 425 * needs to increment the reference count on "object" and return a reference
michael@0 426 * to "object".
michael@0 427 *
michael@0 428 * PARAMETERS:
michael@0 429 * "object"
michael@0 430 * Address of the object to be copied. Must be non-NULL.
michael@0 431 * "pNewObject"
michael@0 432 * Address where object pointer will be stored. Must be non-NULL.
michael@0 433 * "plContext"
michael@0 434 * Platform-specific context pointer.
michael@0 435 * THREAD SAFETY:
michael@0 436 * Thread Safe
michael@0 437 *
michael@0 438 * Multiple threads must be able to safely call this function without
michael@0 439 * worrying about conflicts, even if they're operating on the same object.
michael@0 440 * RETURNS:
michael@0 441 * Returns NULL if the function succeeds.
michael@0 442 * Returns an error if the function fails in a non-fatal way.
michael@0 443 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 444 */
michael@0 445 typedef PKIX_Error *
michael@0 446 (*PKIX_PL_DuplicateCallback)(
michael@0 447 PKIX_PL_Object *object,
michael@0 448 PKIX_PL_Object **pNewObject,
michael@0 449 void *plContext);
michael@0 450
michael@0 451 /* reference-counted objects */
michael@0 452
michael@0 453 /*
michael@0 454 * FUNCTION: PKIX_PL_Object_Alloc
michael@0 455 * DESCRIPTION:
michael@0 456 *
michael@0 457 * Allocates a new Object of type "type" with "size" bytes and stores the
michael@0 458 * resulting pointer at "pObject". The reference count of the newly
michael@0 459 * allocated object will be initialized to 1. To improve performance, each
michael@0 460 * object maintains a small cache for the results of Hashcode and ToString.
michael@0 461 * Mutable objects should call InvalidateCache whenever changes are made to
michael@0 462 * the object's state (after creation). If an error occurs during allocation,
michael@0 463 * "pObject" will be set to NULL. If "size" equals zero, this function creates
michael@0 464 * an Object with a reference count of 1, and places a pointer to unallocated
michael@0 465 * memory at "pMemory".
michael@0 466 *
michael@0 467 * PARAMETERS:
michael@0 468 * "type"
michael@0 469 * The type code of this object. See pkixt.h for codes. The type code
michael@0 470 * must be previously registered with PKIX_PL_Object_RegisterType().
michael@0 471 * "size"
michael@0 472 * The number of bytes needed for this object.
michael@0 473 * "pMemory"
michael@0 474 * Address where object pointer will be stored. Must be non-NULL.
michael@0 475 * "plContext"
michael@0 476 * Platform-specific context pointer.
michael@0 477 * THREAD SAFETY:
michael@0 478 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 479 * RETURNS:
michael@0 480 * Returns NULL if the function succeeds.
michael@0 481 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 482 */
michael@0 483 PKIX_Error *
michael@0 484 PKIX_PL_Object_Alloc(
michael@0 485 PKIX_TYPENUM type,
michael@0 486 PKIX_UInt32 size,
michael@0 487 PKIX_PL_Object **pObject,
michael@0 488 void *plContext);
michael@0 489
michael@0 490 /*
michael@0 491 * FUNCTION: PKIX_PL_Object_IsTypeRegistered
michael@0 492 * DESCRIPTION:
michael@0 493 *
michael@0 494 * Checks whether "type" has been registered by a previous call to
michael@0 495 * PKIX_PL_Object_RegisterType() and stores the Boolean result at "pBool".
michael@0 496 * This function will typically only be called by constructors for specific
michael@0 497 * types.
michael@0 498 *
michael@0 499 * PARAMETERS:
michael@0 500 * "type"
michael@0 501 * The type code to check if valid.
michael@0 502 * "pBool"
michael@0 503 * Address where Boolean will be stored. Must be non-NULL.
michael@0 504 * "plContext"
michael@0 505 * Platform-specific context pointer.
michael@0 506 * THREAD SAFETY:
michael@0 507 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 508 * RETURNS:
michael@0 509 * Returns NULL if the function succeeds.
michael@0 510 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 511 */
michael@0 512 PKIX_Error *
michael@0 513 PKIX_PL_Object_IsTypeRegistered(
michael@0 514 PKIX_UInt32 type,
michael@0 515 PKIX_Boolean *pBool,
michael@0 516 void *plContext);
michael@0 517
michael@0 518 #ifdef PKIX_USER_OBJECT_TYPE
michael@0 519 /*
michael@0 520 * FUNCTION: PKIX_PL_Object_RegisterType
michael@0 521 * DESCRIPTION:
michael@0 522 *
michael@0 523 * Registers a new Object with type value "type" and associates it with a set
michael@0 524 * of functions ("destructor", "equalsFunction", "hashcodeFunction",
michael@0 525 * "toStringFunction", "comparator", "duplicateFunction"). The new type value
michael@0 526 * is also associated with a string pointed to by "description", which is used
michael@0 527 * by the default ToStringCallback. This function may only be called with a
michael@0 528 * particular "type" value once. If "destructor", "equalsFunction",
michael@0 529 * "hashcodeFunction", or "toStringFunction" are NULL, default functions will
michael@0 530 * be registered. However, if "comparator" and "duplicateFunction" are NULL,
michael@0 531 * no functions will be registered and calls to PKIX_PL_Object_Compare and
michael@0 532 * PKIX_PL_Object_Duplicate will result in an error.
michael@0 533 *
michael@0 534 * PARAMETERS:
michael@0 535 * "type"
michael@0 536 * The type code.
michael@0 537 * "description"
michael@0 538 * The string used by the default ToStringCallback. Default used if NULL.
michael@0 539 * "destructor"
michael@0 540 * The DestructorCallback function to be set. Default used if NULL.
michael@0 541 * "equalsFunction"
michael@0 542 * The EqualsCallback function to be set. Default used if NULL.
michael@0 543 * "hashcodeFunction"
michael@0 544 * The HashcodeCallback function to be set. Default used if NULL.
michael@0 545 * "toStringFunction"
michael@0 546 * The ToStringCallback function to be set. Default used if NULL.
michael@0 547 * "comparator"
michael@0 548 * The ComparatorCallback function to be set. None set if NULL. If no
michael@0 549 * callback function is set in this field, calls to
michael@0 550 * PKIX_PL_Object_Compare() will result in an error.
michael@0 551 * "duplicateFunction"
michael@0 552 * The DuplicateCallback function to be set. None set if NULL. If no
michael@0 553 * callback function is set in this field, calls to
michael@0 554 * PKIX_PL_Object_Duplicate() will result in an error.
michael@0 555 * "plContext"
michael@0 556 * Platform-specific context pointer.
michael@0 557 * THREAD SAFETY:
michael@0 558 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 559 * RETURNS:
michael@0 560 * Returns NULL if the function succeeds.
michael@0 561 * Returns an Object Error if "type" is already registered.
michael@0 562 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 563 */
michael@0 564 PKIX_Error *
michael@0 565 PKIX_PL_Object_RegisterType(
michael@0 566 PKIX_UInt32 type,
michael@0 567 char *description,
michael@0 568 PKIX_PL_DestructorCallback destructor,
michael@0 569 PKIX_PL_EqualsCallback equalsFunction,
michael@0 570 PKIX_PL_HashcodeCallback hashcodeFunction,
michael@0 571 PKIX_PL_ToStringCallback toStringFunction,
michael@0 572 PKIX_PL_ComparatorCallback comparator,
michael@0 573 PKIX_PL_DuplicateCallback duplicateFunction,
michael@0 574 void *plContext);
michael@0 575
michael@0 576 #endif
michael@0 577 /*
michael@0 578 * FUNCTION: PKIX_PL_Object_InvalidateCache
michael@0 579 * DESCRIPTION:
michael@0 580 *
michael@0 581 * Invalidates the cache of the Object pointed to by "object". The cache
michael@0 582 * contains results of Hashcode and ToString. This function should be used by
michael@0 583 * mutable objects whenever changes are made to the Object's state (after
michael@0 584 * creation).
michael@0 585 *
michael@0 586 * For example, if ToString is called on a mutable Object, the result will be
michael@0 587 * computed, cached, and returned. If the Object's state does not change, a
michael@0 588 * subsequent call to ToString will recognize that the relevant result is
michael@0 589 * cached and will simply return the result (without calling the Object's
michael@0 590 * ToStringCallback to recompute it). However, when the Object's state
michael@0 591 * changes, the cache needs to be invalidated in order to force a subsequent
michael@0 592 * call to ToString to recompute the result.
michael@0 593 *
michael@0 594 * PARAMETERS:
michael@0 595 * "object"
michael@0 596 * Address of Object whose cache is to be invalidated. Must be non-NULL.
michael@0 597 * "plContext"
michael@0 598 * Platform-specific context pointer.
michael@0 599 *
michael@0 600 * THREAD SAFETY
michael@0 601 * Thread Safe - Object Type Table is locked during modification.
michael@0 602 *
michael@0 603 * Multiple threads can safely call this function without worrying about
michael@0 604 * conflicts, even if they're operating on the same object.
michael@0 605 * RETURNS:
michael@0 606 * Returns NULL if the function succeeds.
michael@0 607 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 608 */
michael@0 609 PKIX_Error *
michael@0 610 PKIX_PL_Object_InvalidateCache(
michael@0 611 PKIX_PL_Object *object,
michael@0 612 void *plContext);
michael@0 613
michael@0 614 /*
michael@0 615 * FUNCTION: PKIX_PL_Object_IncRef
michael@0 616 * DESCRIPTION:
michael@0 617 *
michael@0 618 * Increments the reference count of the Object pointed to by "object".
michael@0 619 *
michael@0 620 * PARAMETERS:
michael@0 621 * "object"
michael@0 622 * Address of Object whose reference count is to be incremented.
michael@0 623 * Must be non-NULL.
michael@0 624 * "plContext"
michael@0 625 * Platform-specific context pointer.
michael@0 626 * THREAD SAFETY:
michael@0 627 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 628 * RETURNS:
michael@0 629 * Returns NULL if the function succeeds.
michael@0 630 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 631 */
michael@0 632 PKIX_Error *
michael@0 633 PKIX_PL_Object_IncRef(
michael@0 634 PKIX_PL_Object *object,
michael@0 635 void *plContext);
michael@0 636
michael@0 637 /*
michael@0 638 * FUNCTION: PKIX_PL_Object_DecRef
michael@0 639 * DESCRIPTION:
michael@0 640 *
michael@0 641 * Decrements the reference count of the Object pointed to by "object". If the
michael@0 642 * resulting reference count is zero, the destructor (if any) registered for
michael@0 643 * the Object's type (by PKIX_PL_RegisterType) will be called and then the
michael@0 644 * Object will be destroyed.
michael@0 645 *
michael@0 646 * PARAMETERS:
michael@0 647 * "object"
michael@0 648 * Address of Object whose reference count is to be decremented.
michael@0 649 * Must be non-NULL.
michael@0 650 * "plContext"
michael@0 651 * Platform-specific context pointer.
michael@0 652 * THREAD SAFETY:
michael@0 653 * If destructor is not called, multiple threads can safely call this function
michael@0 654 * without worrying about conflicts, even if they're operating on the same
michael@0 655 * object. If destructor is called, thread safety depends on the callback
michael@0 656 * defined by PKIX_PL_RegisterType().
michael@0 657 * RETURNS:
michael@0 658 * Returns NULL if the function succeeds.
michael@0 659 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 660 */
michael@0 661 PKIX_Error *
michael@0 662 PKIX_PL_Object_DecRef(
michael@0 663 PKIX_PL_Object *object,
michael@0 664 void *plContext);
michael@0 665
michael@0 666 /*
michael@0 667 * FUNCTION: PKIX_PL_Object_Equals
michael@0 668 * DESCRIPTION:
michael@0 669 *
michael@0 670 * Compares the Object pointed to by "firstObject" with the Object pointed to
michael@0 671 * by "secondObject" for equality using the callback function registered for
michael@0 672 * "firstObject"'s type, and stores the Boolean result at "pResult". While
michael@0 673 * typical callbacks will return PKIX_FALSE if the objects are of different
michael@0 674 * types, other callbacks may be capable of comparing objects of different
michael@0 675 * types [which may correctly result in cases where Equals(first, second)
michael@0 676 * differs from Equals(second, first)].
michael@0 677 *
michael@0 678 * PARAMETERS:
michael@0 679 * "firstObject"
michael@0 680 * Address of the first Object to compare. Must be non-NULL.
michael@0 681 * The EqualsCallback for this Object will be called.
michael@0 682 * "secondObject"
michael@0 683 * Address of the second Object to compare. Must be non-NULL.
michael@0 684 * "pResult"
michael@0 685 * Address where Boolean will be stored. Must be non-NULL.
michael@0 686 * "plContext"
michael@0 687 * Platform-specific context pointer.
michael@0 688 * THREAD SAFETY:
michael@0 689 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
michael@0 690 * RETURNS:
michael@0 691 * Returns NULL if the function succeeds.
michael@0 692 * Returns an Object Error if the function fails in a non-fatal way.
michael@0 693 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 694 */
michael@0 695 PKIX_Error *
michael@0 696 PKIX_PL_Object_Equals(
michael@0 697 PKIX_PL_Object *firstObject,
michael@0 698 PKIX_PL_Object *secondObject,
michael@0 699 PKIX_Boolean *pResult,
michael@0 700 void *plContext);
michael@0 701
michael@0 702 /*
michael@0 703 * FUNCTION: PKIX_PL_Object_Hashcode
michael@0 704 * DESCRIPTION:
michael@0 705 *
michael@0 706 * Computes a hashcode of the Object pointed to by "object" using the
michael@0 707 * callback registered for "object"'s type and stores it at "pValue". Two
michael@0 708 * objects which are equal should have the same hashcode. Once a call to
michael@0 709 * Hashcode has been made, the results are cached and subsequent calls to
michael@0 710 * Hashcode will return the cached value. For mutable objects, an
michael@0 711 * InvalidateCache function is provided, which should be called whenever
michael@0 712 * changes are made to the object's state (after creation).
michael@0 713 *
michael@0 714 * PARAMETERS:
michael@0 715 * "object"
michael@0 716 * Address of the Object whose hashcode is desired. Must be non-NULL.
michael@0 717 * The HashcodeCallback for this object will be called.
michael@0 718 * "pValue"
michael@0 719 * Address where PKIX_Int32 will be stored. Must be non-NULL.
michael@0 720 * "plContext"
michael@0 721 * Platform-specific context pointer.
michael@0 722 *
michael@0 723 * THREAD SAFETY:
michael@0 724 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
michael@0 725 * RETURNS:
michael@0 726 * Returns NULL if the function succeeds.
michael@0 727 * Returns an Object Error if the function fails in a non-fatal way.
michael@0 728 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 729 */
michael@0 730 PKIX_Error *
michael@0 731 PKIX_PL_Object_Hashcode(
michael@0 732 PKIX_PL_Object *object,
michael@0 733 PKIX_UInt32 *pValue,
michael@0 734 void *plContext);
michael@0 735
michael@0 736 /*
michael@0 737 * FUNCTION: PKIX_PL_Object_ToString
michael@0 738 * DESCRIPTION:
michael@0 739 *
michael@0 740 * Creates a string representation of the Object pointed to by "object" using
michael@0 741 * the callback registered for "object"'s type and stores it at "pString".
michael@0 742 * Once a call to ToString has been made, the results are cached and
michael@0 743 * subsequent calls to ToString will return the cached value. For mutable
michael@0 744 * objects, an InvalidateCache function is provided, which should be called
michael@0 745 * whenever changes are made to the object's state (after creation).
michael@0 746 *
michael@0 747 * PARAMETERS:
michael@0 748 * "object"
michael@0 749 * Address of Object whose string representation is desired.
michael@0 750 * Must be non-NULL. The ToStringCallback for this object will be called.
michael@0 751 * "pString"
michael@0 752 * Address where object pointer will be stored. Must be non-NULL.
michael@0 753 * "plContext"
michael@0 754 * Platform-specific context pointer.
michael@0 755 * THREAD SAFETY:
michael@0 756 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
michael@0 757 * RETURNS:
michael@0 758 * Returns NULL if the function succeeds.
michael@0 759 * Returns an Object Error if the function fails in a non-fatal way.
michael@0 760 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 761 */
michael@0 762 PKIX_Error *
michael@0 763 PKIX_PL_Object_ToString(
michael@0 764 PKIX_PL_Object *object,
michael@0 765 PKIX_PL_String **pString,
michael@0 766 void *plContext);
michael@0 767
michael@0 768 /*
michael@0 769 * FUNCTION: PKIX_PL_Object_Compare
michael@0 770 * DESCRIPTION:
michael@0 771 *
michael@0 772 * Compares the Object pointed to by "firstObject" and the Object pointed to
michael@0 773 * by "secondObject" using the comparator registered for "firstObject"'s type
michael@0 774 * and stores the result at "pResult". Different types may be compared. This
michael@0 775 * may correctly result in cases where Compare(first, second) is not the
michael@0 776 * opposite of Compare(second, first). The PKIX_Int32 value stored at
michael@0 777 * "pResult" will be:
michael@0 778 * Less than 0 if "firstObject" < "secondObject"
michael@0 779 * Equals to 0 if "firstObject" = "secondObject"
michael@0 780 * Greater than 0 if "firstObject" > "secondObject"
michael@0 781 *
michael@0 782 * PARAMETERS:
michael@0 783 * "firstObject"
michael@0 784 * Address of first Object to compare. Must be non-NULL.
michael@0 785 * The ComparatorCallback for this object will be called.
michael@0 786 * "secondObject"
michael@0 787 * Address of second object to compare. Must be non-NULL.
michael@0 788 * "pResult
michael@0 789 * Address where PKIX_Int32 will be stored. Must be non-NULL.
michael@0 790 * "plContext"
michael@0 791 * Platform-specific context pointer.
michael@0 792 * THREAD SAFETY:
michael@0 793 * Thread safety depends on the comparator defined by PKIX_PL_RegisterType().
michael@0 794 * RETURNS:
michael@0 795 * Returns NULL if the function succeeds.
michael@0 796 * Returns an Object Error if the function fails in a non-fatal way.
michael@0 797 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 798 */
michael@0 799 PKIX_Error *
michael@0 800 PKIX_PL_Object_Compare(
michael@0 801 PKIX_PL_Object *firstObject,
michael@0 802 PKIX_PL_Object *secondObject,
michael@0 803 PKIX_Int32 *pResult,
michael@0 804 void *plContext);
michael@0 805
michael@0 806 /*
michael@0 807 * FUNCTION: PKIX_PL_Object_Duplicate
michael@0 808 * DESCRIPTION:
michael@0 809 *
michael@0 810 * Creates a duplicate copy of the Object pointed to by "object" using the
michael@0 811 * callback registered for "object"'s type and stores the copy at
michael@0 812 * "pNewObject". Changes to the new object will not affect the original and
michael@0 813 * vice versa.
michael@0 814 *
michael@0 815 * Note that if "object" is immutable, the Duplicate callback function simply
michael@0 816 * needs to increment the reference count on "object" and return a reference
michael@0 817 * to "object".
michael@0 818 *
michael@0 819 * PARAMETERS:
michael@0 820 * "object"
michael@0 821 * Address of Object to be duplicated. Must be non-NULL.
michael@0 822 * The DuplicateCallback for this Object will be called.
michael@0 823 * "pNewObject"
michael@0 824 * Address where object pointer will be stored. Must be non-NULL.
michael@0 825 * "plContext"
michael@0 826 * Platform-specific context pointer.
michael@0 827 * THREAD SAFETY:
michael@0 828 * Thread safety depends on the callback defined by PKIX_PL_RegisterType().
michael@0 829 * RETURNS:
michael@0 830 * Returns NULL if the function succeeds.
michael@0 831 * Returns an Object Error if the function fails in a non-fatal way.
michael@0 832 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 833 */
michael@0 834 PKIX_Error *
michael@0 835 PKIX_PL_Object_Duplicate(
michael@0 836 PKIX_PL_Object *object,
michael@0 837 PKIX_PL_Object **pNewObject,
michael@0 838 void *plContext);
michael@0 839
michael@0 840 /*
michael@0 841 * FUNCTION: PKIX_PL_Object_GetType
michael@0 842 * DESCRIPTION:
michael@0 843 *
michael@0 844 * Retrieves the type code of the Object pointed to by "object" and stores it
michael@0 845 * at "pType". See pkixt.h for type codes.
michael@0 846 *
michael@0 847 * PARAMETERS:
michael@0 848 * "object"
michael@0 849 * Address of Object whose type is desired. Must be non-NULL.
michael@0 850 * "pType"
michael@0 851 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 852 * "plContext"
michael@0 853 * Platform-specific context pointer.
michael@0 854 * THREAD SAFETY:
michael@0 855 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 856 * RETURNS:
michael@0 857 * Returns NULL if the function succeeds.
michael@0 858 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 859 */
michael@0 860 PKIX_Error *
michael@0 861 PKIX_PL_Object_GetType(
michael@0 862 PKIX_PL_Object *object,
michael@0 863 PKIX_UInt32 *pType,
michael@0 864 void *plContext);
michael@0 865
michael@0 866 /*
michael@0 867 * FUNCTION: PKIX_PL_Object_Lock
michael@0 868 * DESCRIPTION:
michael@0 869 *
michael@0 870 * Locks the Mutex associated with the Object pointed to by "object". When an
michael@0 871 * object is created, it is associated with an object-specific Mutex to allow
michael@0 872 * for synchronization when the fields of the object are modified.
michael@0 873 *
michael@0 874 * PARAMETERS:
michael@0 875 * "object"
michael@0 876 * Address of Object whose Mutex is to be locked. Must be non-NULL.
michael@0 877 * "plContext"
michael@0 878 * Platform-specific context pointer.
michael@0 879 * THREAD SAFETY:
michael@0 880 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 881 * RETURNS:
michael@0 882 * Returns NULL if the function succeeds.
michael@0 883 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 884 */
michael@0 885 PKIX_Error *
michael@0 886 PKIX_PL_Object_Lock(
michael@0 887 PKIX_PL_Object *object,
michael@0 888 void *plContext);
michael@0 889
michael@0 890 /*
michael@0 891 * FUNCTION: PKIX_PL_Object_Unlock
michael@0 892 * DESCRIPTION:
michael@0 893 *
michael@0 894 * Unlocks the Mutex associated with the Object pointed to by "object". When
michael@0 895 * an object is created, it is associated with an object-specific Mutex to
michael@0 896 * allow for synchronization when the fields of the object are modified.
michael@0 897 *
michael@0 898 * PARAMETERS:
michael@0 899 * "object"
michael@0 900 * Address of Object whose Mutex is to be unlocked. Must be non-NULL.
michael@0 901 * "plContext"
michael@0 902 * Platform-specific context pointer.
michael@0 903 * THREAD SAFETY:
michael@0 904 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 905 * RETURNS:
michael@0 906 * Returns NULL if the function succeeds.
michael@0 907 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 908 */
michael@0 909 PKIX_Error *
michael@0 910 PKIX_PL_Object_Unlock(
michael@0 911 PKIX_PL_Object *object,
michael@0 912 void *plContext);
michael@0 913
michael@0 914 /* mutexes (locks) */
michael@0 915
michael@0 916 /*
michael@0 917 * FUNCTION: PKIX_PL_Mutex_Create
michael@0 918 * DESCRIPTION:
michael@0 919 *
michael@0 920 * Creates a new Mutex and stores it at "pNewLock".
michael@0 921 *
michael@0 922 * PARAMETERS:
michael@0 923 * "pNewLock"
michael@0 924 * Address where object pointer will be stored. Must be non-NULL.
michael@0 925 * "plContext"
michael@0 926 * Platform-specific context pointer.
michael@0 927 * THREAD SAFETY:
michael@0 928 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 929 * RETURNS:
michael@0 930 * Returns NULL if the function succeeds.
michael@0 931 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 932 */
michael@0 933 PKIX_Error *
michael@0 934 PKIX_PL_Mutex_Create(
michael@0 935 PKIX_PL_Mutex **pNewLock,
michael@0 936 void *plContext);
michael@0 937
michael@0 938 /*
michael@0 939 * FUNCTION: PKIX_PL_Mutex_Lock
michael@0 940 * DESCRIPTION:
michael@0 941 *
michael@0 942 * Locks the Mutex pointed to by "lock". If the Mutex is already locked, this
michael@0 943 * function will block the current thread until the mutex can be locked by
michael@0 944 * this thread.
michael@0 945 *
michael@0 946 * PARAMETERS:
michael@0 947 * "lock"
michael@0 948 * Address of Mutex to lock. Must be non-NULL.
michael@0 949 * "plContext"
michael@0 950 * Platform-specific context pointer.
michael@0 951 * THREAD SAFETY:
michael@0 952 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 953 * RETURNS:
michael@0 954 * Returns NULL if the function succeeds.
michael@0 955 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 956 */
michael@0 957 PKIX_Error *
michael@0 958 PKIX_PL_Mutex_Lock(
michael@0 959 PKIX_PL_Mutex *lock,
michael@0 960 void *plContext);
michael@0 961
michael@0 962 /*
michael@0 963 * FUNCTION: PKIX_PL_Mutex_Unlock
michael@0 964 * DESCRIPTION:
michael@0 965 *
michael@0 966 * Unlocks the Mutex pointed to by "lock" if the current thread holds the
michael@0 967 * Mutex.
michael@0 968 *
michael@0 969 * PARAMETERS:
michael@0 970 * "lock"
michael@0 971 * Address of Mutex to unlock. Must be non-NULL.
michael@0 972 * "plContext"
michael@0 973 * Platform-specific context pointer.
michael@0 974 * THREAD SAFETY:
michael@0 975 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 976 * RETURNS:
michael@0 977 * Returns NULL if the function succeeds.
michael@0 978 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 979 */
michael@0 980 PKIX_Error *
michael@0 981 PKIX_PL_Mutex_Unlock(
michael@0 982 PKIX_PL_Mutex *lock,
michael@0 983 void *plContext);
michael@0 984
michael@0 985 /* monitor (locks) */
michael@0 986
michael@0 987 /*
michael@0 988 * FUNCTION: PKIX_PL_MonitorLock_Create
michael@0 989 * DESCRIPTION:
michael@0 990 *
michael@0 991 * Creates a new PKIX_PL_MonitorLock and stores it at "pNewLock".
michael@0 992 *
michael@0 993 * PARAMETERS:
michael@0 994 * "pNewLock"
michael@0 995 * Address where object pointer will be stored. Must be non-NULL.
michael@0 996 * "plContext"
michael@0 997 * Platform-specific context pointer.
michael@0 998 * THREAD SAFETY:
michael@0 999 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1000 * RETURNS:
michael@0 1001 * Returns NULL if the function succeeds.
michael@0 1002 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1003 */
michael@0 1004 PKIX_Error *
michael@0 1005 PKIX_PL_MonitorLock_Create(
michael@0 1006 PKIX_PL_MonitorLock **pNewLock,
michael@0 1007 void *plContext);
michael@0 1008
michael@0 1009 /*
michael@0 1010 * FUNCTION: PKIX_PL_MonitorLock_Enter
michael@0 1011 * DESCRIPTION:
michael@0 1012 *
michael@0 1013 * Locks the MonitorLock pointed to by "lock". If the MonitorLock is already
michael@0 1014 * locked by other thread, this function will block the current thread. If
michael@0 1015 * the "lock" had been locked by current thread, this function will NOT block.
michael@0 1016 *
michael@0 1017 * PARAMETERS:
michael@0 1018 * "lock"
michael@0 1019 * Address of MonitorLock to lock. Must be non-NULL.
michael@0 1020 * "plContext"
michael@0 1021 * Platform-specific context pointer.
michael@0 1022 * THREAD SAFETY:
michael@0 1023 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1024 * RETURNS:
michael@0 1025 * Returns NULL if the function succeeds.
michael@0 1026 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1027 */
michael@0 1028 PKIX_Error *
michael@0 1029 PKIX_PL_MonitorLock_Enter(
michael@0 1030 PKIX_PL_MonitorLock *lock,
michael@0 1031 void *plContext);
michael@0 1032
michael@0 1033 /*
michael@0 1034 * FUNCTION: PKIX_PL_MonitorLock_Exit
michael@0 1035 * DESCRIPTION:
michael@0 1036 *
michael@0 1037 * Unlocks the MonitorLock pointed to by "lock" if the lock counter of
michael@0 1038 * current thread holds the MonitorLock reach 0, the lock is released.
michael@0 1039 *
michael@0 1040 * PARAMETERS:
michael@0 1041 * "lock"
michael@0 1042 * Address of MonitorLock to unlock. Must be non-NULL.
michael@0 1043 * "plContext"
michael@0 1044 * Platform-specific context pointer.
michael@0 1045 * THREAD SAFETY:
michael@0 1046 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1047 * RETURNS:
michael@0 1048 * Returns NULL if the function succeeds.
michael@0 1049 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1050 */
michael@0 1051 PKIX_Error *
michael@0 1052 PKIX_PL_MonitorLock_Exit(
michael@0 1053 PKIX_PL_MonitorLock *lock,
michael@0 1054 void *plContext);
michael@0 1055
michael@0 1056 /* strings and formatted printing */
michael@0 1057
michael@0 1058 /*
michael@0 1059 * FUNCTION: PKIX_PL_String_Create
michael@0 1060 * DESCRIPTION:
michael@0 1061 *
michael@0 1062 * Creates a new String using the data pointed to by "pString", the
michael@0 1063 * PKIX_UInt32 pointed to by "stringLen", and the PKIX_UInt32 pointed to by
michael@0 1064 * "fmtIndicator" and stores it at "pString". If the format is PKIX_ESCASCII
michael@0 1065 * the "stringLen" parameter is ignored and the string extends until a zero
michael@0 1066 * byte is found. Once created, a String object is immutable.
michael@0 1067 *
michael@0 1068 * Valid formats are:
michael@0 1069 * PKIX_ESCASCII
michael@0 1070 * PKIX_ESCASCII_DEBUG
michael@0 1071 * PKIX_UTF8
michael@0 1072 * PKIX_UTF8_NULL_TERM
michael@0 1073 * PKIX_UTF16
michael@0 1074 *
michael@0 1075 * PARAMETERS:
michael@0 1076 * "fmtIndicator"
michael@0 1077 * Format that "stringRep" is encoded with. Must be non-NULL.
michael@0 1078 * "stringRep"
michael@0 1079 * Address of encoded string representation. Must be non-NULL.
michael@0 1080 * "stringLen"
michael@0 1081 * Length of data stored at stringRep.
michael@0 1082 * "pString"
michael@0 1083 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1084 * "plContext"
michael@0 1085 * Platform-specific context pointer.
michael@0 1086 * THREAD SAFETY:
michael@0 1087 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1088 * RETURNS:
michael@0 1089 * Returns NULL if the function succeeds.
michael@0 1090 * Returns a String Error if the function fails in a non-fatal way.
michael@0 1091 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1092 */
michael@0 1093 PKIX_Error *
michael@0 1094 PKIX_PL_String_Create(
michael@0 1095 PKIX_UInt32 fmtIndicator,
michael@0 1096 const void *stringRep,
michael@0 1097 PKIX_UInt32 stringLen,
michael@0 1098 PKIX_PL_String **pString,
michael@0 1099 void *plContext);
michael@0 1100
michael@0 1101 /*
michael@0 1102 * FUNCTION: PKIX_PL_Sprintf
michael@0 1103 * DESCRIPTION:
michael@0 1104 *
michael@0 1105 * Creates a formatted string at "pOut" using the given format "fmt" and a
michael@0 1106 * variable length list of arguments. The format flags are identical to
michael@0 1107 * standard C with the exception that %s expects a PKIX_PL_String*, rather
michael@0 1108 * than a char *, and that {%d, %i, %o, %u, %x, %X} expect PKIX_UInt32 or
michael@0 1109 * PKIX_Int32 instead of int or unsigned int.
michael@0 1110 *
michael@0 1111 * PARAMETERS:
michael@0 1112 * "pOut"
michael@0 1113 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1114 * "plContext"
michael@0 1115 * Platform-specific context pointer.
michael@0 1116 * "fmt"
michael@0 1117 * Address of format string. Must be non-NULL.
michael@0 1118 * THREAD SAFETY:
michael@0 1119 * Not Thread Safe - Caller must have exclusive access to all arguments.
michael@0 1120 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 1121 * RETURNS:
michael@0 1122 * Returns NULL if the function succeeds.
michael@0 1123 * Returns a String Error if the function fails in a non-fatal way.
michael@0 1124 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1125 */
michael@0 1126 PKIX_Error *
michael@0 1127 PKIX_PL_Sprintf(
michael@0 1128 PKIX_PL_String **pOut,
michael@0 1129 void *plContext,
michael@0 1130 const PKIX_PL_String *fmt, ...);
michael@0 1131
michael@0 1132 /*
michael@0 1133 * FUNCTION: PKIX_PL_GetString
michael@0 1134 * DESCRIPTION:
michael@0 1135 *
michael@0 1136 * Retrieves the String associated with the value of "stringID" (if any) and
michael@0 1137 * stores it at "pString". If no such string is associated with "stringID",
michael@0 1138 * this function uses "defaultString" to create a String and stores it at
michael@0 1139 * "pString".
michael@0 1140 *
michael@0 1141 * PARAMETERS:
michael@0 1142 * "stringID"
michael@0 1143 * PKIX_UInt32 valud of string identifier.
michael@0 1144 * "defaultString"
michael@0 1145 * Address of a PKIX_ESCASCII encoded string representation.
michael@0 1146 * Must be non-NULL.
michael@0 1147 * "pString"
michael@0 1148 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1149 * "plContext"
michael@0 1150 * Platform-specific context pointer.
michael@0 1151 * THREAD SAFETY:
michael@0 1152 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1153 * RETURNS:
michael@0 1154 * Returns NULL if the function succeeds.
michael@0 1155 * Returns a String Error if the function fails in a non-fatal way.
michael@0 1156 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1157 */
michael@0 1158 PKIX_Error *
michael@0 1159 PKIX_PL_GetString(
michael@0 1160 PKIX_UInt32 stringID,
michael@0 1161 char *defaultString,
michael@0 1162 PKIX_PL_String **pString,
michael@0 1163 void *plContext);
michael@0 1164
michael@0 1165 /*
michael@0 1166 * FUNCTION: PKIX_PL_String_GetEncoded
michael@0 1167 * DESCRIPTION:
michael@0 1168 *
michael@0 1169 * Retrieves the value of the String pointed to by "string" in the encoding
michael@0 1170 * specified by "fmtIndicator" and stores the result in "pStringRep" and
michael@0 1171 * "pLength", respectively. Note that "pStringRep" is not reference counted
michael@0 1172 * and will need to be freed with PKIX_PL_Free().
michael@0 1173 *
michael@0 1174 * PARAMETERS:
michael@0 1175 * "string"
michael@0 1176 * Address of String whose encoded value is desired. Must be non-NULL.
michael@0 1177 * "fmtIndicator"
michael@0 1178 * Format of encoding. Supported formats are:
michael@0 1179 * PKIX_ESCASCII, PKIX_ESCASII_DEBUG, PKIX_UTF8, PKIX_UTF8_NULL_TERM, and
michael@0 1180 * PKIX_UTF16. XXX Where are these documented?
michael@0 1181 * "pStringRep"
michael@0 1182 * Address where pointer to encoded value will be stored.
michael@0 1183 * Must be non-NULL.
michael@0 1184 * "pLength"
michael@0 1185 * Address where byte length of encoded value will be stored.
michael@0 1186 * "plContext"
michael@0 1187 * Platform-specific context pointer.
michael@0 1188 * THREAD SAFETY:
michael@0 1189 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1190 * RETURNS:
michael@0 1191 * Returns NULL if the function succeeds.
michael@0 1192 * Returns a String Error if the function fails in a non-fatal way.
michael@0 1193 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1194 */
michael@0 1195 PKIX_Error *
michael@0 1196 PKIX_PL_String_GetEncoded(
michael@0 1197 PKIX_PL_String *string,
michael@0 1198 PKIX_UInt32 fmtIndicator,
michael@0 1199 void **pStringRep,
michael@0 1200 PKIX_UInt32 *pLength,
michael@0 1201 void *plContext);
michael@0 1202
michael@0 1203 /*
michael@0 1204 * Hashtable
michael@0 1205 *
michael@0 1206 * A hashtable is a very efficient data structure used for mapping keys to
michael@0 1207 * values. Any non-null PKIX_PL_Object can be used as a key or as a value,
michael@0 1208 * provided that it correctly implements the PKIX_PL_EqualsCallback and the
michael@0 1209 * PKIX_PL_HashcodeCallback. A hashtable consists of several buckets, with
michael@0 1210 * each bucket capable of holding a linked list of key/value mappings. When
michael@0 1211 * adding, retrieving, or deleting a value, the hashcode of the key is used to
michael@0 1212 * determine which bucket's linked list is relevant. The corresponding
michael@0 1213 * key/value pair is then appended, retrieved, or deleted.
michael@0 1214 */
michael@0 1215
michael@0 1216 /*
michael@0 1217 * FUNCTION: PKIX_PL_HashTable_Create
michael@0 1218 * DESCRIPTION:
michael@0 1219 *
michael@0 1220 * Creates a new Hashtable with an initial capacity of "numBuckets" buckets
michael@0 1221 * and "maxEntriesPerBucket" of entries limit for each bucket and stores it
michael@0 1222 * at "pResult".
michael@0 1223 *
michael@0 1224 * PARAMETERS:
michael@0 1225 * "numBuckets"
michael@0 1226 * The initial number of hash table buckets. Must be non-zero.
michael@0 1227 * "maxEntriesPerBucket"
michael@0 1228 * The limit of entries per bucket. Zero means no limit.
michael@0 1229 * "pResult"
michael@0 1230 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1231 * "plContext"
michael@0 1232 * Platform-specific context pointer.
michael@0 1233 * THREAD SAFETY:
michael@0 1234 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1235 * RETURNS:
michael@0 1236 * Returns NULL if the function succeeds.
michael@0 1237 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1238 */
michael@0 1239 PKIX_Error *
michael@0 1240 PKIX_PL_HashTable_Create(
michael@0 1241 PKIX_UInt32 numBuckets,
michael@0 1242 PKIX_UInt32 maxEntriesPerBucket,
michael@0 1243 PKIX_PL_HashTable **pResult,
michael@0 1244 void *plContext);
michael@0 1245
michael@0 1246 /*
michael@0 1247 * FUNCTION: PKIX_PL_HashTable_Add
michael@0 1248 * DESCRIPTION:
michael@0 1249 *
michael@0 1250 * Adds a key/value mapping using the Objects pointed to by "key" and "value"
michael@0 1251 * to the Hashtable pointed to by "ht".
michael@0 1252 *
michael@0 1253 * Function increments key/value reference counts. Caller is responsible to
michael@0 1254 * to decrement(destroy) key/value ref counts(objects).
michael@0 1255 *
michael@0 1256 * PARAMETERS:
michael@0 1257 * "ht"
michael@0 1258 * Address of Hashtable to be added to. Must be non-NULL.
michael@0 1259 * "key"
michael@0 1260 * Address of Object to be associated with "value". Must be non-NULL.
michael@0 1261 * "value"
michael@0 1262 * Address of Object to be added to Hashtable. Must be non-NULL.
michael@0 1263 * "plContext"
michael@0 1264 * Platform-specific context pointer.
michael@0 1265 * THREAD SAFETY:
michael@0 1266 * Not Thread Safe - assumes exclusive access to "ht"
michael@0 1267 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 1268 * RETURNS:
michael@0 1269 * Returns NULL if the function succeeds.
michael@0 1270 * Returns a Hashtable Error if the function fails in a non-fatal way.
michael@0 1271 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1272 */
michael@0 1273 PKIX_Error *
michael@0 1274 PKIX_PL_HashTable_Add(
michael@0 1275 PKIX_PL_HashTable *ht,
michael@0 1276 PKIX_PL_Object *key,
michael@0 1277 PKIX_PL_Object *value,
michael@0 1278 void *plContext);
michael@0 1279
michael@0 1280 /*
michael@0 1281 * FUNCTION: PKIX_PL_HashTable_Remove
michael@0 1282 * DESCRIPTION:
michael@0 1283 *
michael@0 1284 * Removes the Object value whose key is equal to the Object pointed to by
michael@0 1285 * "key" from the Hashtable pointed to by "ht". If no such object exists,
michael@0 1286 * this function throws an Error.
michael@0 1287 *
michael@0 1288 * Function frees "value" object. Caller is responsible to free "key"
michael@0 1289 * object.
michael@0 1290 *
michael@0 1291 * PARAMETERS:
michael@0 1292 * "ht"
michael@0 1293 * Address of Hashtable to remove object from. Must be non-NULL.
michael@0 1294 * "key"
michael@0 1295 * Address of Object used for lookup. Must be non-NULL.
michael@0 1296 * "plContext"
michael@0 1297 * Platform-specific context pointer.
michael@0 1298 * THREAD SAFETY:
michael@0 1299 * Not Thread Safe - assumes exclusive access to "ht"
michael@0 1300 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 1301 * RETURNS:
michael@0 1302 * Returns NULL if the function succeeds.
michael@0 1303 * Returns a Hashtable Error if the function fails in a non-fatal way.
michael@0 1304 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1305 */
michael@0 1306 PKIX_Error *
michael@0 1307 PKIX_PL_HashTable_Remove(
michael@0 1308 PKIX_PL_HashTable *ht,
michael@0 1309 PKIX_PL_Object *key,
michael@0 1310 void *plContext);
michael@0 1311
michael@0 1312 /*
michael@0 1313 * FUNCTION: PKIX_PL_HashTable_Lookup
michael@0 1314 * DESCRIPTION:
michael@0 1315 *
michael@0 1316 * Retrieves the Object whose key equals the Object pointed to by "key" from
michael@0 1317 * the Hashtable associated with "ht" and stores it at "pResult". If no
michael@0 1318 * Object is found, this function stores NULL at "pResult".
michael@0 1319 *
michael@0 1320 * PARAMETERS:
michael@0 1321 * "ht"
michael@0 1322 * Address of Hashtable to lookup Object from. Must be non-NULL.
michael@0 1323 * "key"
michael@0 1324 * Address of key Object used for lookup. Must be non-NULL.
michael@0 1325 * "pResult"
michael@0 1326 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1327 * "plContext"
michael@0 1328 * Platform-specific context pointer.
michael@0 1329 * THREAD SAFETY:
michael@0 1330 * Conditionally Thread Safe
michael@0 1331 * (see Thread Safety Definitions in Programmer's Guide)
michael@0 1332 * RETURNS:
michael@0 1333 * Returns NULL if the function succeeds.
michael@0 1334 * Returns a Hashtable Error if the function fails in a non-fatal way.
michael@0 1335 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1336 */
michael@0 1337 PKIX_Error *
michael@0 1338 PKIX_PL_HashTable_Lookup(
michael@0 1339 PKIX_PL_HashTable *ht,
michael@0 1340 PKIX_PL_Object *key,
michael@0 1341 PKIX_PL_Object **pResult,
michael@0 1342 void *plContext);
michael@0 1343
michael@0 1344 /*
michael@0 1345 * FUNCTION: PKIX_PL_ByteArray_Create
michael@0 1346 * DESCRIPTION:
michael@0 1347 *
michael@0 1348 * Creates a new ByteArray using "length" bytes of data pointed to by "array"
michael@0 1349 * and stores it at "pByteArray". Once created, a ByteArray is immutable.
michael@0 1350 *
michael@0 1351 * PARAMETERS:
michael@0 1352 * "array"
michael@0 1353 * Address of source data.
michael@0 1354 * "length"
michael@0 1355 * Number of bytes to copy.
michael@0 1356 * "pByteArray"
michael@0 1357 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1358 * "plContext"
michael@0 1359 * Platform-specific context pointer.
michael@0 1360 * THREAD SAFETY:
michael@0 1361 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1362 * RETURNS:
michael@0 1363 * Returns NULL if the function succeeds.
michael@0 1364 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1365 */
michael@0 1366 PKIX_Error *
michael@0 1367 PKIX_PL_ByteArray_Create(
michael@0 1368 void *array,
michael@0 1369 PKIX_UInt32 length,
michael@0 1370 PKIX_PL_ByteArray **pByteArray,
michael@0 1371 void *plContext);
michael@0 1372
michael@0 1373 /*
michael@0 1374 * FUNCTION: PKIX_PL_ByteArray_GetPointer
michael@0 1375 * DESCRIPTION:
michael@0 1376 *
michael@0 1377 * Allocates enough memory to hold the contents of the ByteArray pointed to
michael@0 1378 * by "byteArray", copies the data from the ByteArray pointed to by
michael@0 1379 * "byteArray" into the newly allocated memory, and stores a pointer to the
michael@0 1380 * memory at "pArray". Note that "pArray" is not reference counted. It will
michael@0 1381 * need to be freed with PKIX_PL_Free().
michael@0 1382 *
michael@0 1383 * PARAMETERS:
michael@0 1384 * "byteArray"
michael@0 1385 * Address of ByteArray whose data is desired. Must be non-NULL.
michael@0 1386 * "pArray"
michael@0 1387 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1388 * "plContext"
michael@0 1389 * Platform-specific context pointer.
michael@0 1390 * THREAD SAFETY:
michael@0 1391 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1392 * RETURNS:
michael@0 1393 * Returns NULL if the function succeeds.
michael@0 1394 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1395 */
michael@0 1396 PKIX_Error *
michael@0 1397 PKIX_PL_ByteArray_GetPointer(
michael@0 1398 PKIX_PL_ByteArray *byteArray,
michael@0 1399 void **pArray,
michael@0 1400 void *plContext);
michael@0 1401
michael@0 1402 /*
michael@0 1403 * FUNCTION: PKIX_PL_ByteArray_GetLength
michael@0 1404 * DESCRIPTION:
michael@0 1405 *
michael@0 1406 * Retrieves the length of the ByteArray pointed to by "byteArray" and stores
michael@0 1407 * the length at "pLength".
michael@0 1408 *
michael@0 1409 * PARAMETERS:
michael@0 1410 * "byteArray"
michael@0 1411 * Address of ByteArray whose length is desired. Must be non-NULL.
michael@0 1412 * "pLength"
michael@0 1413 * Address where PKIX_UInt32 will be stored. Must be non-NULL.
michael@0 1414 * "plContext"
michael@0 1415 * Platform-specific context pointer.
michael@0 1416 * THREAD SAFETY:
michael@0 1417 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1418 * RETURNS:
michael@0 1419 * Returns NULL if the function succeeds.
michael@0 1420 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1421 */
michael@0 1422 PKIX_Error *
michael@0 1423 PKIX_PL_ByteArray_GetLength(
michael@0 1424 PKIX_PL_ByteArray *byteArray,
michael@0 1425 PKIX_UInt32 *pLength,
michael@0 1426 void *plContext);
michael@0 1427
michael@0 1428 /*
michael@0 1429 * FUNCTION: PKIX_PL_OID_Create
michael@0 1430 * DESCRIPTION:
michael@0 1431 *
michael@0 1432 * Creates a new OID using NSS oid tag.
michael@0 1433 *
michael@0 1434 * PARAMETERS:
michael@0 1435 * "idtag"
michael@0 1436 * nss oid id tag.
michael@0 1437 * "pOID"
michael@0 1438 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1439 * "plContext"
michael@0 1440 * Platform-specific context pointer.
michael@0 1441 * THREAD SAFETY:
michael@0 1442 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1443 * RETURNS:
michael@0 1444 * Returns NULL if the function succeeds.
michael@0 1445 * Returns an OID Error if the function fails in a non-fatal way.
michael@0 1446 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1447 */
michael@0 1448 PKIX_Error *
michael@0 1449 PKIX_PL_OID_Create(
michael@0 1450 SECOidTag idtag,
michael@0 1451 PKIX_PL_OID **pOID,
michael@0 1452 void *plContext);
michael@0 1453
michael@0 1454 /*
michael@0 1455 * FUNCTION: PKIX_PL_OID_CreateBySECItem
michael@0 1456 * DESCRIPTION:
michael@0 1457 *
michael@0 1458 * Creates a new OID using a DER encoded OID stored as SECItem.
michael@0 1459 *
michael@0 1460 * PARAMETERS:
michael@0 1461 * "derOid"
michael@0 1462 * Address of SECItem that holds DER encoded OID.
michael@0 1463 * "pOID"
michael@0 1464 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1465 * "plContext"
michael@0 1466 * Platform-specific context pointer.
michael@0 1467 * THREAD SAFETY:
michael@0 1468 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1469 * RETURNS:
michael@0 1470 * Returns NULL if the function succeeds.
michael@0 1471 * Returns an OID Error if the function fails in a non-fatal way.
michael@0 1472 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1473 */
michael@0 1474 PKIX_Error *
michael@0 1475 PKIX_PL_OID_CreateBySECItem(
michael@0 1476 SECItem *derOid,
michael@0 1477 PKIX_PL_OID **pOID,
michael@0 1478 void *plContext);
michael@0 1479
michael@0 1480 /*
michael@0 1481 * FUNCTION: PKIX_PL_BigInt_Create
michael@0 1482 * DESCRIPTION:
michael@0 1483 *
michael@0 1484 * Creates a new BigInt using the source String pointed to by "stringRep" and
michael@0 1485 * stores it at "pBigInt". Valid source Strings consist of an even number of
michael@0 1486 * hexadecimal digits, which are always interpreted as a positive number.
michael@0 1487 * Once created, a BigInt is immutable.
michael@0 1488 *
michael@0 1489 * The regexp format is:
michael@0 1490 * HexDigit ::= [0-9] | [A-F] | [a-f]
michael@0 1491 * DoubleHex ::= HexDigit HexDigit
michael@0 1492 * BigIntSrc ::= (DoubleHex)+
michael@0 1493 *
michael@0 1494 * Note that since we are using DoubleHex, the number of characters in the
michael@0 1495 * source MUST be even. Additionally, the first DoubleHex MUST NOT be "00"
michael@0 1496 * unless it is the only DoubleHex.
michael@0 1497 *
michael@0 1498 * Valid : "09"
michael@0 1499 * Valid : "00" (special case where first and only DoubleHex is "00")
michael@0 1500 * Invalid: "9" (not DoubleHex: odd number of characters)
michael@0 1501 * Invalid: "0009" (first DoubleHex is "00")
michael@0 1502 *
michael@0 1503 * XXX Why does this take a String object while OID_Create takes a char* ?
michael@0 1504 * Perhaps because OID_Create is often used with constant strings and
michael@0 1505 * this function isn't. That's a good reason, but we should explain it
michael@0 1506 * (if it's right)
michael@0 1507 * PARAMETERS:
michael@0 1508 * "stringRep"
michael@0 1509 * Address of String representing a BigInt. Must be non-NULL.
michael@0 1510 * "pBigInt"
michael@0 1511 * Address where object pointer will be stored. Must be non-NULL.
michael@0 1512 * "plContext"
michael@0 1513 * Platform-specific context pointer.
michael@0 1514 * THREAD SAFETY:
michael@0 1515 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1516 * RETURNS:
michael@0 1517 * Returns NULL if the function succeeds.
michael@0 1518 * Returns a BigInt Error if the function fails in a non-fatal way.
michael@0 1519 * Returns a Fatal Error if the function fails in an unrecoverable way.
michael@0 1520 */
michael@0 1521 PKIX_Error *
michael@0 1522 PKIX_PL_BigInt_Create(
michael@0 1523 PKIX_PL_String *stringRep,
michael@0 1524 PKIX_PL_BigInt **pBigInt,
michael@0 1525 void *plContext);
michael@0 1526
michael@0 1527 #ifdef __cplusplus
michael@0 1528 }
michael@0 1529 #endif
michael@0 1530
michael@0 1531 /*
michael@0 1532 * FUNCTION: PKIX_PL_GetPLErrorCode
michael@0 1533 * DESCRIPTION:
michael@0 1534 *
michael@0 1535 * Returns error code from PL layer.
michael@0 1536 *
michael@0 1537 * THREAD SAFETY:
michael@0 1538 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
michael@0 1539 * RETURNS:
michael@0 1540 * PL layer error code.
michael@0 1541 */
michael@0 1542 int
michael@0 1543 PKIX_PL_GetPLErrorCode();
michael@0 1544
michael@0 1545 #endif /* _LIBPKIX_SYSTEM_H */

mercurial