PageRenderTime 67ms CodeModel.GetById 7ms app.highlight 50ms RepoModel.GetById 1ms app.codeStats 1ms

/security/nss/lib/libpkix/pkix/util/pkix_tools.h

http://github.com/zpao/v8monkey
C Header | 1622 lines | 1355 code | 170 blank | 97 comment | 104 complexity | 46fbed003697f5f762a168e1c6bcf739 MD5 | raw file
   1/* ***** BEGIN LICENSE BLOCK *****
   2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
   3 *
   4 * The contents of this file are subject to the Mozilla Public License Version
   5 * 1.1 (the "License"); you may not use this file except in compliance with
   6 * the License. You may obtain a copy of the License at
   7 * http://www.mozilla.org/MPL/
   8 *
   9 * Software distributed under the License is distributed on an "AS IS" basis,
  10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11 * for the specific language governing rights and limitations under the
  12 * License.
  13 *
  14 * The Original Code is the PKIX-C library.
  15 *
  16 * The Initial Developer of the Original Code is
  17 * Sun Microsystems, Inc.
  18 * Portions created by the Initial Developer are
  19 * Copyright 2004-2007 Sun Microsystems, Inc.  All Rights Reserved.
  20 *
  21 * Contributor(s):
  22 *   Sun Microsystems, Inc.
  23 *   Red Hat, Inc.
  24 *
  25 * Alternatively, the contents of this file may be used under the terms of
  26 * either the GNU General Public License Version 2 or later (the "GPL"), or
  27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28 * in which case the provisions of the GPL or the LGPL are applicable instead
  29 * of those above. If you wish to allow use of your version of this file only
  30 * under the terms of either the GPL or the LGPL, and not to allow others to
  31 * use your version of this file under the terms of the MPL, indicate your
  32 * decision by deleting the provisions above and replace them with the notice
  33 * and other provisions required by the GPL or the LGPL. If you do not delete
  34 * the provisions above, a recipient may use your version of this file under
  35 * the terms of any one of the MPL, the GPL or the LGPL.
  36 *
  37 * ***** END LICENSE BLOCK ***** */
  38/*
  39 * pkix_tools.h
  40 *
  41 * Header for Utility Functions and Macros
  42 *
  43 */
  44
  45#ifndef _PKIX_TOOLS_H
  46#define _PKIX_TOOLS_H
  47
  48#include "pkix.h"
  49#include <stddef.h>
  50#include <stdio.h>
  51#include "secport.h"
  52#include "prlong.h"
  53
  54/* private PKIX system headers */
  55#include "pkix_basicconstraintschecker.h"
  56#include "pkix_buildresult.h"
  57#include "pkix_certchainchecker.h"
  58#include "pkix_certselector.h"
  59#include "pkix_comcertselparams.h"
  60#include "pkix_comcrlselparams.h"
  61#include "pkix_crlselector.h"
  62#include "pkix_error.h"
  63#include "pkix_expirationchecker.h"
  64#include "pkix_list.h"
  65#include "pkix_logger.h"
  66#include "pkix_namechainingchecker.h"
  67#include "pkix_nameconstraintschecker.h"
  68#include "pkix_policychecker.h"
  69#include "pkix_policynode.h"
  70#include "pkix_procparams.h"
  71#include "pkix_resourcelimits.h"
  72#include "pkix_revocationmethod.h"
  73#include "pkix_revocationchecker.h"
  74#include "pkix_crlchecker.h"
  75#include "pkix_ocspchecker.h"
  76#include "pkix_signaturechecker.h"
  77#include "pkix_store.h"
  78#include "pkix_targetcertchecker.h"
  79#include "pkix_validate.h"
  80#include "pkix_valresult.h"
  81#include "pkix_verifynode.h"
  82
  83#ifdef __cplusplus
  84extern "C" {
  85#endif
  86
  87typedef struct pkixStdVarsStr {
  88    const char        *aMyFuncName;
  89    PKIX_Error        *aPkixErrorResult;
  90    PKIX_Error        *aPkixTempResult;
  91    PKIX_Error        *aPkixReturnResult;
  92    PKIX_ERRORCODE     aPkixErrorCode;
  93    PKIX_Boolean       aPkixErrorReceived;
  94    PKIX_Boolean       aPkixTempErrorReceived;
  95    PKIX_ERRORCLASS    aPkixErrorClass;
  96    PKIX_UInt32        aPkixType;
  97    PKIX_PL_Object    *aLockedObject;
  98    PKIX_List         *aPkixErrorList;
  99} PKIX_StdVars;
 100
 101#ifdef PKIX_STDVARS_POINTER
 102#define myFuncName                  stdVars->aMyFuncName
 103#define pkixErrorResult             stdVars->aPkixErrorResult
 104#define pkixTempResult              stdVars->aPkixTempResult
 105#define pkixReturnResult            stdVars->aPkixReturnResult
 106#define pkixErrorCode               stdVars->aPkixErrorCode
 107#define pkixErrorReceived           stdVars->aPkixErrorReceived
 108#define pkixTempErrorReceived       stdVars->aPkixTempErrorReceived 
 109#define pkixErrorClass              stdVars->aPkixErrorClass
 110#define pkixType                    stdVars->aPkixType
 111#define lockedObject                stdVars->aLockedObject
 112#define pkixErrorList               stdVars->aPkixErrorList
 113#define stdVarsPtr                  stdVars
 114#else
 115#define myFuncName                  stdVars.aMyFuncName
 116#define pkixErrorResult             stdVars.aPkixErrorResult
 117#define pkixTempResult              stdVars.aPkixTempResult
 118#define pkixReturnResult            stdVars.aPkixReturnResult
 119#define pkixErrorCode               stdVars.aPkixErrorCode
 120#define pkixErrorReceived           stdVars.aPkixErrorReceived
 121#define pkixTempErrorReceived       stdVars.aPkixTempErrorReceived 
 122#define pkixErrorClass              stdVars.aPkixErrorClass
 123#define pkixType                    stdVars.aPkixType
 124#define lockedObject                stdVars.aLockedObject
 125#define pkixErrorList               stdVars.aPkixErrorList
 126#define stdVarsPtr                  &stdVars
 127#endif
 128
 129extern PKIX_Error * PKIX_DoReturn(PKIX_StdVars * stdVars, 
 130                                  PKIX_ERRORCLASS errClass, 
 131                                  PKIX_Boolean doLogger,
 132                                  void * plContext);
 133
 134extern PKIX_Error * PKIX_DoThrow(PKIX_StdVars * stdVars, 
 135                                 PKIX_ERRORCLASS errClass, 
 136                                 PKIX_ERRORCODE errCode,
 137                                 PKIX_ERRORCLASS overrideClass, 
 138                                 void * plContext);
 139
 140extern void PKIX_DoAddError(PKIX_StdVars * stdVars, 
 141                            PKIX_Error * error,
 142                            void * plContext);
 143
 144#ifdef PKIX_OBJECT_LEAK_TEST
 145extern PKIX_Error * pkix_CheckForGeneratedError(PKIX_StdVars * stdVars, 
 146                                                PKIX_ERRORCLASS errClass, 
 147                                                char * fnName,
 148                                                PKIX_Boolean *errorStateSet,
 149                                                void * plContext);
 150#endif /* PKIX_OBJECT_LEAK_TEST */
 151
 152extern const PKIX_StdVars zeroStdVars;
 153
 154extern PRLogModuleInfo *pkixLog;
 155
 156/*
 157 * UTILITY MACROS
 158 * Documentation for these common utility macros can be found in the
 159 * Implementation Guidelines document (Section 4.3)
 160 *
 161 * In general, macros with multiple statements (or a single "if" statement)
 162 * use the "do {<body>} while (0)" technique in order to convert the multiple
 163 * statements into one statement, thus avoiding the dangling else problem.
 164 * For macros which ALWAYS exit with a "return" or "goto", there is no
 165 * need to use this technique (and it yields compiler warnings of "statement
 166 * not reached"), so we just use "{<body>}" to group the statements together.
 167 */
 168
 169#if !defined (PKIX_OBJECT_LEAK_TEST)
 170
 171#define PKIX_STD_VARS(funcName) \
 172    static const char cMyFuncName[] = {funcName}; \
 173    PKIX_StdVars      stdVars = zeroStdVars; \
 174    myFuncName = cMyFuncName
 175
 176
 177#else /* PKIX_OBJECT_LEAK_TEST */
 178
 179extern char **fnStackNameArr;
 180extern PKIX_UInt32 *fnStackInvCountArr;
 181extern PKIX_UInt32  stackPosition;
 182extern PKIX_Boolean noErrorState;
 183extern PKIX_Boolean errorGenerated;
 184extern PKIX_Boolean runningLeakTest;
 185extern PLHashTable *fnInvTable;
 186extern PKIX_UInt32 testStartFnStackPosition;
 187extern char *errorFnStackString;
 188
 189extern PLHashNumber PR_CALLBACK pkix_ErrorGen_Hash (const void *key);
 190
 191#define PKIX_STD_VARS(funcName) \
 192    static const char cMyFuncName[] = {funcName}; \
 193    PKIX_StdVars      stdVars = zeroStdVars; \
 194    PKIX_Boolean      errorSetFlag = PKIX_FALSE; \
 195    myFuncName = cMyFuncName; \
 196    if (runningLeakTest) { \
 197        if (fnStackNameArr) { \
 198            fnStackInvCountArr[stackPosition] += 1; \
 199            stackPosition += 1; \
 200            fnStackInvCountArr[stackPosition] = 0; \
 201            fnStackNameArr[stackPosition] = (char*)myFuncName; \
 202            fnStackNameArr[stackPosition + 1] = NULL; \
 203            PR_LOG(pkixLog, 5, \
 204                    ("%s%*s+> %s(%d) - %s\n", (errorGenerated ? "*" : " "), \
 205                             stackPosition, " ", fnStackNameArr[stackPosition], \
 206                             stackPosition, myFuncName)); \
 207        } \
 208        do { \
 209            pkixErrorResult = pkix_CheckForGeneratedError(&stdVars, PKIX_MEM_ERROR, \
 210                                                          funcName, &errorSetFlag, \
 211                                                          plContext); \
 212            if (pkixErrorResult) { \
 213                 PR_LOG(pkixLog, 5, \
 214                    ("%s%*s<- %s(%d) - %s\n", (errorGenerated ? "*" : " "), \
 215                              stackPosition, " ", fnStackNameArr[stackPosition], \
 216                              stackPosition, myFuncName)); \
 217                 fnStackNameArr[stackPosition--] = NULL; \
 218                 if (errorSetFlag) { \
 219                       noErrorState = (noErrorState) ? PKIX_FALSE : PKIX_TRUE; \
 220                 } \
 221                 return pkixErrorResult; \
 222            } \
 223        } while (0); \
 224    }
 225#endif /* PKIX_OBJECT_LEAK_TEST */
 226
 227#ifdef DEBUG
 228#define _PKIX_DEBUG_TRACE(cond, prefix, level) \
 229    do { \
 230	if (cond) { \
 231	    pkix_Logger_Check(pkixLoggersDebugTrace, myFuncName, \
 232	                      prefix, pkixType, level, plContext); \
 233	} \
 234    } while (0)
 235#else
 236#define _PKIX_DEBUG_TRACE(cond, prefix, level) 
 237#endif
 238
 239#define _PKIX_LOG_ERROR(code, level) \
 240    { \
 241	if (pkixLoggersErrors) { \
 242	    pkix_Logger_CheckWithCode(pkixLoggersErrors, code, \
 243	                      NULL, pkixType, level, plContext); \
 244	} \
 245    }
 246
 247#define PKIX_ENTER(type, funcName) \
 248    PKIX_STD_VARS(funcName); \
 249    pkixType = PKIX_ ## type ## _ERROR; \
 250    PKIX_DEBUG_ENTER(type); \
 251    _PKIX_DEBUG_TRACE(pkixLoggersDebugTrace, ">>>", PKIX_LOGGER_LEVEL_TRACE);
 252
 253#define PKIX_ENTER_NO_LOGGER(type, funcName) \
 254    PKIX_STD_VARS(funcName); \
 255    pkixType = PKIX_ ## type ## _ERROR; \
 256    PKIX_DEBUG_ENTER(type);
 257
 258#define PKIX_DEBUG_ENTER(type) \
 259    PKIX_ ## type ## _DEBUG_ARG("( Entering %s).\n", myFuncName)
 260
 261#define PKIX_DEBUG_EXIT(type) \
 262    PKIX_ ## type ## _DEBUG_ARG("( Exiting %s).\n", myFuncName)
 263
 264#define PKIX_OBJECT_UNLOCK(obj) \
 265    do { \
 266	if (obj && lockedObject == (PKIX_PL_Object *)(obj)){ \
 267	    pkixTempResult = \
 268		    PKIX_PL_Object_Unlock \
 269		    ((PKIX_PL_Object *)(obj), plContext); \
 270	    if (pkixTempResult) { \
 271		PKIX_DoAddError(stdVarsPtr, pkixTempResult, plContext); \
 272		pkixTempResult = NULL; \
 273	    } \
 274	    lockedObject = NULL; \
 275	} else { \
 276	    PORT_Assert(lockedObject == NULL); \
 277	} \
 278    } while (0)
 279
 280#define PKIX_DECREF(obj) \
 281    do { \
 282	if (obj){ \
 283	    pkixTempResult = PKIX_PL_Object_DecRef \
 284			((PKIX_PL_Object *)(obj), plContext); \
 285	    if (pkixTempResult) { \
 286		PKIX_DoAddError(stdVarsPtr, pkixTempResult, plContext); \
 287		pkixTempResult = NULL; \
 288	    } \
 289	    obj = NULL; \
 290	} \
 291    } while (0)
 292
 293#define PKIX_THROW(type, descNum) \
 294    return PKIX_DoThrow(&stdVars, (PKIX_ ## type ## _ERROR), descNum, \
 295                        pkixErrorClass, plContext);
 296
 297#ifdef PKIX_OBJECT_LEAK_TEST
 298#define PKIX_RETURN(type) \
 299    if (runningLeakTest && fnStackNameArr) { \
 300        PR_LOG(pkixLog, 5, \
 301               ("%s%*s<- %s(%d) - %s\n", (errorGenerated ? "*" : " "), \
 302               stackPosition, " ", fnStackNameArr[stackPosition], \
 303               stackPosition, myFuncName)); \
 304        fnStackNameArr[stackPosition--] = NULL; \
 305        if (errorSetFlag) noErrorState = (noErrorState) ? PKIX_FALSE : PKIX_TRUE; \
 306    } \
 307    return PKIX_DoReturn(&stdVars, (PKIX_ ## type ## _ERROR), PKIX_TRUE, plContext);
 308#else
 309#define PKIX_RETURN(type) \
 310    return PKIX_DoReturn(&stdVars, (PKIX_ ## type ## _ERROR), PKIX_TRUE, plContext);
 311#endif /* PKIX_OBJECT_LEAK_TEST */
 312
 313
 314#if defined(DEBUG) && !defined(DEBUG_nb95248)
 315#define PKIX_RETURN_NO_LOGGER(type) \
 316    { \
 317	PKIX_OBJECT_UNLOCK(lockedObject); \
 318	if ((pkixErrorReceived) || (pkixErrorResult) || pkixErrorList) \
 319	    PKIX_THROW(type, pkixErrorCode); \
 320	PKIX_DEBUG_EXIT(type); \
 321	return NULL; \
 322    }
 323#else
 324#define PKIX_RETURN_NO_LOGGER(type) \
 325    return PKIX_DoReturn(&stdVars, (PKIX_ ## type ## _ERROR), PKIX_FALSE, plContext);
 326#endif
 327
 328/* disable to disable ;-) */
 329/* #define WANT_TRACE_CHECK_FAILURES */
 330
 331#ifdef WANT_TRACE_CHECK_FAILURES
 332#define TRACE_CHECK_FAILURE(what, errorstring) \
 333    if (pkixLog) { \
 334      PR_LOG(pkixLog, PR_LOG_DEBUG, \
 335        ("====> [%s] failed: %s\n", #what, errorstring)); \
 336    }
 337#else
 338#define TRACE_CHECK_FAILURE(what, errorstring)
 339#endif
 340
 341#define PKIX_CHECK(func, descNum) \
 342    do { \
 343	pkixErrorResult = (func); \
 344	if (pkixErrorResult) { \
 345            TRACE_CHECK_FAILURE((func), PKIX_ErrorText[descNum]) \
 346	    pkixErrorClass = pkixErrorResult->errClass; \
 347	    pkixErrorCode = descNum; \
 348	    goto cleanup; \
 349	} \
 350    } while (0)
 351
 352/* like PKIX_CHECK but without goto cleanup */
 353#define PKIX_CHECK_NO_GOTO(func, descNum) \
 354    do { \
 355	pkixErrorResult = (func); \
 356	if (pkixErrorResult) { \
 357            TRACE_CHECK_FAILURE((func), PKIX_ErrorText[descNum]) \
 358	    pkixErrorClass = pkixErrorResult->errClass; \
 359	    pkixErrorCode = descNum; \
 360	} \
 361    } while (0)
 362
 363#define PKIX_CHECK_ONLY_FATAL(func, descNum) \
 364    do { \
 365	pkixTempErrorReceived = PKIX_FALSE; \
 366	pkixErrorResult = (func); \
 367	if (pkixErrorResult) { \
 368            TRACE_CHECK_FAILURE((func), PKIX_ErrorText[descNum]) \
 369	    pkixTempErrorReceived = PKIX_TRUE; \
 370	    pkixErrorClass = pkixErrorResult->errClass; \
 371            if (pkixErrorClass == PKIX_FATAL_ERROR) { \
 372	         goto cleanup; \
 373	    } \
 374	    PKIX_DECREF(pkixErrorResult); \
 375	} \
 376    } while (0)
 377
 378#define PKIX_LOG_ERROR(descNum) \
 379    _PKIX_LOG_ERROR(descNum, PKIX_LOGGER_LEVEL_ERROR)
 380
 381#define PKIX_ERROR(descNum) \
 382    { \
 383	PKIX_LOG_ERROR(descNum) \
 384	pkixErrorReceived = PKIX_TRUE; \
 385	pkixErrorCode = descNum; \
 386	goto cleanup; \
 387    }
 388
 389#define PKIX_ERROR_ALLOC_ERROR() \
 390    { \
 391	PKIX_LOG_ERROR(PKIX_ALLOCERROR) \
 392	pkixErrorReceived = PKIX_TRUE; \
 393	pkixErrorResult = PKIX_ALLOC_ERROR(); \
 394	goto cleanup; \
 395    }
 396
 397#define PKIX_ERROR_FATAL(descNum) \
 398    { \
 399	pkixErrorReceived = PKIX_TRUE; \
 400	pkixErrorCode = descNum; \
 401	pkixErrorClass = PKIX_FATAL_ERROR; \
 402	_PKIX_LOG_ERROR(pkixErrorCode, PKIX_LOGGER_LEVEL_FATALERROR); \
 403	goto cleanup; \
 404    }
 405
 406#define PKIX_CHECK_FATAL(func, descNum) \
 407    do { \
 408	pkixErrorResult = (func); \
 409	if (pkixErrorResult) { \
 410                TRACE_CHECK_FAILURE((func), PKIX_ErrorText[descNum]) \
 411		pkixErrorReceived = PKIX_TRUE; \
 412		pkixErrorCode = descNum; \
 413		pkixErrorClass = PKIX_FATAL_ERROR; \
 414		_PKIX_LOG_ERROR(pkixErrorCode, PKIX_LOGGER_LEVEL_FATALERROR); \
 415		goto fatal; \
 416	} \
 417    } while (0)
 418
 419#define PKIX_NULLCHECK_ONE(a) \
 420    do { \
 421	if ((a) == NULL){ \
 422	    pkixErrorReceived = PKIX_TRUE; \
 423	    pkixErrorCode = PKIX_NULLARGUMENT; \
 424	    PKIX_RETURN(FATAL); \
 425	} \
 426    } while (0)
 427
 428#define PKIX_NULLCHECK_TWO(a, b) \
 429    do { \
 430	if (((a) == NULL) || ((b) == NULL)){ \
 431	    pkixErrorReceived = PKIX_TRUE; \
 432	    pkixErrorCode = PKIX_NULLARGUMENT; \
 433	    PKIX_RETURN(FATAL); \
 434	} \
 435    } while (0)
 436
 437#define PKIX_NULLCHECK_THREE(a, b, c) \
 438    do { \
 439	if (((a) == NULL) || ((b) == NULL) || ((c) == NULL)){ \
 440	    pkixErrorReceived = PKIX_TRUE; \
 441	    pkixErrorCode = PKIX_NULLARGUMENT; \
 442	    PKIX_RETURN(FATAL); \
 443	} \
 444    } while (0)
 445
 446#define PKIX_NULLCHECK_FOUR(a, b, c, d) \
 447    do { \
 448	if (((a) == NULL) || ((b) == NULL) || \
 449	    ((c) == NULL) || ((d) == NULL)){ \
 450	    pkixErrorReceived = PKIX_TRUE; \
 451	    pkixErrorCode = PKIX_NULLARGUMENT; \
 452	    PKIX_RETURN(FATAL); \
 453	} \
 454    } while (0)
 455
 456#define PKIX_OBJECT_LOCK(obj) \
 457    do { \
 458	if (obj) { \
 459	    pkixTempResult = \
 460		PKIX_PL_Object_Lock((PKIX_PL_Object*)(obj), plContext); \
 461	    if (pkixTempResult) { \
 462		PKIX_DoAddError(stdVarsPtr, pkixTempResult, plContext); \
 463		pkixTempResult = NULL; \
 464		pkixErrorCode = PKIX_OBJECTLOCKFAILED; \
 465		goto cleanup; \
 466	    } \
 467	    lockedObject = (PKIX_PL_Object *)(obj); \
 468	} \
 469    } while (0)
 470
 471#define PKIX_ERROR_CREATE(type, descNum, error) \
 472    { \
 473	pkixTempResult = (PKIX_Error*)pkix_Throw \
 474		(PKIX_ ## type ## _ERROR,  myFuncName, \
 475		descNum, PKIX_ ## type ## _ERROR, pkixErrorResult, \
 476		&error, plContext); \
 477	if (pkixTempResult) { \
 478	    error = pkixTempResult; \
 479	    pkixTempResult = NULL; \
 480	} \
 481    }
 482		
 483
 484#define PKIX_ERROR_RECEIVED \
 485    (pkixErrorReceived || pkixErrorResult || pkixTempErrorReceived || \
 486     pkixErrorList)
 487
 488#define PKIX_INCREF(obj) \
 489    do { \
 490	if (obj){ \
 491	    pkixTempResult = PKIX_PL_Object_IncRef \
 492			((PKIX_PL_Object *)(obj), plContext); \
 493	    if (pkixTempResult) { \
 494		PKIX_DoAddError(&stdVars, pkixTempResult, plContext); \
 495		pkixTempResult = NULL; \
 496		goto cleanup; \
 497	    } \
 498	} \
 499    } while (0)
 500
 501#define PKIX_FREE(obj) \
 502    do { \
 503	if (obj) { \
 504	    pkixTempResult = PKIX_PL_Free((obj), plContext); \
 505	    if (pkixTempResult) { \
 506		PKIX_DoAddError(&stdVars, pkixTempResult, plContext); \
 507		pkixTempResult = NULL; \
 508	    } \
 509	    obj = NULL; \
 510	} \
 511    } while (0)
 512
 513#define PKIX_EXACTLY_ONE_NULL(a, b) (((a) && !(b)) || ((b) && !(a)))
 514
 515/* DIGIT MACROS */
 516
 517#define PKIX_ISDIGIT(c) (((c) >= '0') && ((c) <= '9'))
 518
 519#define PKIX_ISXDIGIT(c) \
 520    (PKIX_ISDIGIT(c) || ( (((c)|0x20) >= 'a') && (((c)|0x20) <= 'f') ))
 521
 522#define PKIX_TOSTRING(a, b, c, d) \
 523    do { \
 524	int descNum; \
 525	if ((a) != NULL) { \
 526	    pkixErrorResult =  \
 527		PKIX_PL_Object_ToString((PKIX_PL_Object *)(a), (b), (c)); \
 528	    descNum = (d); \
 529	} else { \
 530	    pkixErrorResult =  \
 531		PKIX_PL_String_Create(PKIX_ESCASCII, "(null)", 0, (b), (c)); \
 532	    descNum = PKIX_STRINGCREATEFAILED; \
 533	} \
 534	PKIX_CHECK(pkixErrorResult, descNum); \
 535    } while (0)
 536
 537#define PKIX_EQUALS(a, b, c, d, e) \
 538    do { \
 539	if ((a) != NULL && (b) != NULL) { \
 540	    PKIX_CHECK(PKIX_PL_Object_Equals\
 541			((PKIX_PL_Object *)(a), \
 542			(PKIX_PL_Object*)(b), \
 543			(c), \
 544			(d)), \
 545			(e)); \
 546	} else if ((a) == NULL && (b) == NULL) { \
 547	    *(c) = PKIX_TRUE; \
 548	} else { \
 549	    *(c) = PKIX_FALSE; \
 550	} \
 551    } while (0)
 552
 553#define PKIX_HASHCODE(a, b, c, d) \
 554    do { \
 555	if ((a) != NULL) { \
 556	    PKIX_CHECK(PKIX_PL_Object_Hashcode\
 557		((PKIX_PL_Object *)(a), (b), (c)), (d)); \
 558	} else { \
 559	    *(b) = 0; \
 560	} \
 561    } while (0)
 562
 563#define PKIX_DUPLICATE(a, b, c, d) \
 564    do { \
 565	if ((a) != NULL) { \
 566	    PKIX_CHECK(PKIX_PL_Object_Duplicate\
 567			((PKIX_PL_Object *)(a), \
 568			(PKIX_PL_Object **)(b), \
 569			(c)), \
 570			(d)); \
 571	} else { \
 572	    *(b) = (a); \
 573	} \
 574    } while (0)
 575
 576/*
 577 * DEBUG MACROS
 578 *
 579 * Each type has an associated debug flag, which can
 580 * be set on the compiler line using "-D<debugflag>". For convenience,
 581 * "-DPKIX_DEBUGALL" turns on debug for all the components.
 582 *
 583 * If a type's debug flag is defined, then its two associated macros
 584 * are defined: PKIX_type_DEBUG(expr) and PKIX_type_DEBUG_ARG(expr, arg),
 585 * which call PKIX_DEBUG(expr) and PKIX_DEBUG_ARG(expr, arg) respectively,
 586 * which, in turn, enable standard and consistently formatted output.
 587 *
 588 * If a type's debug flag is not defined, the two associated macros
 589 * are defined as a NO-OP. As such, any PKIX_type_DEBUG or PKIX_type_DEBUG_ARG
 590 * macros for an undefined type will be stripped from the code during
 591 * pre-processing, thereby reducing code size.
 592 */
 593
 594#ifdef PKIX_DEBUGALL
 595#define PKIX_REFCOUNTDEBUG                        1
 596#define PKIX_MEMDEBUG                             1
 597#define PKIX_MUTEXDEBUG                           1
 598#define PKIX_OBJECTDEBUG                          1
 599#define PKIX_STRINGDEBUG                          1
 600#define PKIX_OIDDEBUG                             1
 601#define PKIX_LISTDEBUG                            1
 602#define PKIX_ERRORDEBUG                           1
 603#define PKIX_BYTEARRAYDEBUG                       1
 604#define PKIX_RWLOCKDEBUG                          1
 605#define PKIX_BIGINTDEBUG                          1
 606#define PKIX_HASHTABLEDEBUG                       1
 607#define PKIX_X500NAMEDEBUG                        1
 608#define PKIX_GENERALNAMEDEBUG                     1
 609#define PKIX_PUBLICKEYDEBUG                       1
 610#define PKIX_CERTDEBUG                            1
 611#define PKIX_HTTPCLIENTDEBUG                      1
 612#define PKIX_DATEDEBUG                            1
 613#define PKIX_TRUSTANCHORDEBUG                     1
 614#define PKIX_PROCESSINGPARAMSDEBUG                1
 615#define PKIX_VALIDATEPARAMSDEBUG                  1
 616#define PKIX_VALIDATERESULTDEBUG                  1
 617#define PKIX_VALIDATEDEBUG                        1
 618#define PKIX_CERTCHAINCHECKERDEBUG                1
 619#define PKIX_REVOCATIONCHECKERDEBUG               1
 620#define PKIX_CERTSELECTORDEBUG                    1
 621#define PKIX_COMCERTSELPARAMSDEBUG                1
 622#define PKIX_TARGETCERTCHECKERSTATEDEBUG          1
 623#define PKIX_INITIALIZEPARAMSDEBUG                1
 624#define PKIX_CERTBASICCONSTRAINTSDEBUG            1
 625#define PKIX_CERTNAMECONSTRAINTSDEBUG             1
 626#define PKIX_CERTNAMECONSTRAINTSCHECKERSTATEDEBUG 1
 627#define PKIX_SUBJALTNAMECHECKERSTATEDEBUG         1
 628
 629#define PKIX_CERTPOLICYQUALIFIERDEBUG             1
 630#define PKIX_CERTPOLICYINFODEBUG                  1
 631#define PKIX_CERTPOLICYNODEDEBUG                  1
 632#define PKIX_CERTPOLICYCHECKERSTATEDEBUG          1
 633#define PKIX_LIFECYCLEDEBUG                       1
 634#define PKIX_BASICCONSTRAINTSCHECKERSTATEDEBUG    1
 635#define PKIX_CRLDEBUG                             1
 636#define PKIX_CRLENTRYDEBUG                        1
 637#define PKIX_CRLSELECTORDEBUG                     1
 638#define PKIX_COMCRLSELPARAMSDEBUG                 1
 639#define PKIX_CERTSTOREDEBUG                       1
 640#define PKIX_COLLECTIONCERTSTORECONTEXTDEBUG      1
 641#define PKIX_DEFAULTCRLCHECKERSTATEDEBUG          1
 642#define PKIX_CERTPOLICYMAPDEBUG                   1
 643#define PKIX_BUILDDEBUG                           1
 644#define PKIX_BUILDRESULTDEBUG                     1
 645#define PKIX_FORWARDBUILDERSTATEDEBUG             1
 646#define PKIX_SIGNATURECHECKERSTATEDEBUG           1
 647#define PKIX_USERDEFINEDMODULESDEBUG              1
 648#define PKIX_CONTEXTDEBUG                         1
 649#define PKIX_DEFAULTREVOCATIONCHECKERDEBUG        1
 650#define PKIX_LDAPREQUESTDEBUG                     1
 651#define PKIX_LDAPRESPONSEDEBUG                    1
 652#define PKIX_LDAPCLIENTDEBUG                      1
 653#define PKIX_LDAPDEFAULTCLIENTDEBUG               1
 654#define PKIX_SOCKETDEBUG                          1
 655#define PKIX_RESOURCELIMITSDEBUG                  1
 656#define PKIX_LOGGERDEBUG                          1
 657#define PKIX_MONITORLOCKDEBUG                     1
 658#define PKIX_INFOACCESSDEBUG                      1
 659#define PKIX_AIAMGRDEBUG                          1
 660#define PKIX_OCSPCHECKERDEBUG                     1
 661#define PKIX_OCSPREQUESTDEBUG                     1
 662#define PKIX_OCSPRESPONSEDEBUG                    1
 663#define PKIX_HTTPDEFAULTCLIENTDEBUG               1
 664#define PKIX_HTTPCERTSTORECONTEXTDEBUG            1
 665#define PKIX_VERIFYNODEDEBUG                      1
 666#endif
 667
 668/*
 669 * XXX Both PKIX_DEBUG and PKIX_DEBUG_ARG currently use printf.
 670 * This needs to be replaced with Loggers.
 671 */
 672
 673#ifdef DEBUG
 674#define PKIX_DEBUG(expr) \
 675    do { \
 676	_PKIX_DEBUG_TRACE(pkixLoggersErrors, expr, PKIX_LOGGER_LEVEL_DEBUG); \
 677	(void) fprintf(stderr, "(%s: ", myFuncName); \
 678        (void) fprintf(stderr, expr);                \
 679    } while (0)
 680#else
 681#define PKIX_DEBUG(expr)
 682#endif
 683
 684/* Logging doesn't support DEBUG with ARG: cannot convert control and arg */
 685#define PKIX_DEBUG_ARG(expr, arg) \
 686    do { \
 687	(void) printf("(%s: ", myFuncName); \
 688	(void) printf(expr, arg); \
 689    } while (0)
 690
 691#if PKIX_FATALDEBUG
 692#define PKIX_FATAL_DEBUG(expr) \
 693        PKIX_DEBUG(expr)
 694#define PKIX_FATAL_DEBUG_ARG(expr, arg) \
 695        PKIX_DEBUG_ARG(expr, arg)
 696#else
 697#define PKIX_FATAL_DEBUG(expr)
 698#define PKIX_FATAL_DEBUG_ARG(expr, arg)
 699#endif
 700
 701#if PKIX_REFCOUNTDEBUG
 702#define PKIX_REF_COUNT_DEBUG(expr) \
 703        PKIX_DEBUG(expr)
 704#define PKIX_REF_COUNT_DEBUG_ARG(expr, arg) \
 705        PKIX_DEBUG_ARG(expr, arg)
 706#else
 707#define PKIX_REF_COUNT_DEBUG(expr)
 708#define PKIX_REF_COUNT_DEBUG_ARG(expr, arg)
 709#endif
 710
 711#if PKIX_MEMDEBUG
 712#define PKIX_MEM_DEBUG(expr) \
 713        PKIX_DEBUG(expr)
 714#define PKIX_MEM_DEBUG_ARG(expr, arg) \
 715        PKIX_DEBUG_ARG(expr, arg)
 716#else
 717#define PKIX_MEM_DEBUG(expr)
 718#define PKIX_MEM_DEBUG_ARG(expr, arg)
 719#endif
 720
 721#if PKIX_MUTEXDEBUG
 722#define PKIX_MUTEX_DEBUG(expr) \
 723        PKIX_DEBUG(expr)
 724#define PKIX_MUTEX_DEBUG_ARG(expr, arg) \
 725        PKIX_DEBUG_ARG(expr, arg)
 726#else
 727#define PKIX_MUTEX_DEBUG(expr)
 728#define PKIX_MUTEX_DEBUG_ARG(expr, arg)
 729#endif
 730
 731#if PKIX_OBJECTDEBUG
 732#define PKIX_OBJECT_DEBUG(expr) \
 733        PKIX_DEBUG(expr)
 734#define PKIX_OBJECT_DEBUG_ARG(expr, arg) \
 735        PKIX_DEBUG_ARG(expr, arg)
 736#else
 737#define PKIX_OBJECT_DEBUG(expr)
 738#define PKIX_OBJECT_DEBUG_ARG(expr, arg)
 739#endif
 740
 741#if PKIX_ERRORDEBUG
 742#define PKIX_ERROR_DEBUG(expr) \
 743        PKIX_DEBUG(expr)
 744#define PKIX_ERROR_DEBUG_ARG(expr, arg) \
 745        PKIX_DEBUG_ARG(expr, arg)
 746#else
 747#define PKIX_ERROR_DEBUG(expr)
 748#define PKIX_ERROR_DEBUG_ARG(expr, arg)
 749#endif
 750
 751#if PKIX_STRINGDEBUG
 752#define PKIX_STRING_DEBUG(expr) \
 753        PKIX_DEBUG(expr)
 754#define PKIX_STRING_DEBUG_ARG(expr, arg) \
 755        PKIX_DEBUG_ARG(expr, arg)
 756#else
 757#define PKIX_STRING_DEBUG(expr)
 758#define PKIX_STRING_DEBUG_ARG(expr, arg)
 759#endif
 760
 761#if PKIX_OIDDEBUG
 762#define PKIX_OID_DEBUG(expr) \
 763        PKIX_DEBUG(expr)
 764#define PKIX_OID_DEBUG_ARG(expr, arg) \
 765        PKIX_DEBUG_ARG(expr, arg)
 766#else
 767#define PKIX_OID_DEBUG(expr)
 768#define PKIX_OID_DEBUG_ARG(expr, arg)
 769#endif
 770
 771#if PKIX_LISTDEBUG
 772#define PKIX_LIST_DEBUG(expr) \
 773        PKIX_DEBUG(expr)
 774#define PKIX_LIST_DEBUG_ARG(expr, arg) \
 775        PKIX_DEBUG_ARG(expr, arg)
 776#else
 777#define PKIX_LIST_DEBUG(expr)
 778#define PKIX_LIST_DEBUG_ARG(expr, arg)
 779#endif
 780
 781#if PKIX_RWLOCKDEBUG
 782#define PKIX_RWLOCK_DEBUG(expr) \
 783        PKIX_DEBUG(expr)
 784#define PKIX_RWLOCK_DEBUG_ARG(expr, arg) \
 785        PKIX_DEBUG_ARG(expr, arg)
 786#else
 787#define PKIX_RWLOCK_DEBUG(expr)
 788#define PKIX_RWLOCK_DEBUG_ARG(expr, arg)
 789#endif
 790
 791#if PKIX_BYTEARRAYDEBUG
 792#define PKIX_BYTEARRAY_DEBUG(expr) \
 793        PKIX_DEBUG(expr)
 794#define PKIX_BYTEARRAY_DEBUG_ARG(expr, arg) \
 795        PKIX_DEBUG_ARG(expr, arg)
 796#else
 797#define PKIX_BYTEARRAY_DEBUG(expr)
 798#define PKIX_BYTEARRAY_DEBUG_ARG(expr, arg)
 799#endif
 800
 801#if PKIX_HASHTABLEDEBUG
 802#define PKIX_HASHTABLE_DEBUG(expr) \
 803        PKIX_DEBUG(expr)
 804#define PKIX_HASHTABLE_DEBUG_ARG(expr, arg) \
 805        PKIX_DEBUG_ARG(expr, arg)
 806#else
 807#define PKIX_HASHTABLE_DEBUG(expr)
 808#define PKIX_HASHTABLE_DEBUG_ARG(expr, arg)
 809#endif
 810
 811#if PKIX_X500NAMEDEBUG
 812#define PKIX_X500NAME_DEBUG(expr) \
 813        PKIX_DEBUG(expr)
 814#define PKIX_X500NAME_DEBUG_ARG(expr, arg) \
 815        PKIX_DEBUG_ARG(expr, arg)
 816#else
 817#define PKIX_X500NAME_DEBUG(expr)
 818#define PKIX_X500NAME_DEBUG_ARG(expr, arg)
 819#endif
 820
 821#if PKIX_GENERALNAMEDEBUG
 822#define PKIX_GENERALNAME_DEBUG(expr) \
 823        PKIX_DEBUG(expr)
 824#define PKIX_GENERALNAME_DEBUG_ARG(expr, arg) \
 825        PKIX_DEBUG_ARG(expr, arg)
 826#else
 827#define PKIX_GENERALNAME_DEBUG(expr)
 828#define PKIX_GENERALNAME_DEBUG_ARG(expr, arg)
 829#endif
 830
 831#if PKIX_PUBLICKEYDEBUG
 832#define PKIX_PUBLICKEY_DEBUG(expr) \
 833        PKIX_DEBUG(expr)
 834#define PKIX_PUBLICKEY_DEBUG_ARG(expr, arg) \
 835        PKIX_DEBUG_ARG(expr, arg)
 836#else
 837#define PKIX_PUBLICKEY_DEBUG(expr)
 838#define PKIX_PUBLICKEY_DEBUG_ARG(expr, arg)
 839#endif
 840
 841#if PKIX_CERTDEBUG
 842#define PKIX_CERT_DEBUG(expr) \
 843        PKIX_DEBUG(expr)
 844#define PKIX_CERT_DEBUG_ARG(expr, arg) \
 845        PKIX_DEBUG_ARG(expr, arg)
 846#else
 847#define PKIX_CERT_DEBUG(expr)
 848#define PKIX_CERT_DEBUG_ARG(expr, arg)
 849#endif
 850
 851#if PKIX_CRLDPDEBUG
 852#define PKIX_CRLDP_DEBUG(expr) \
 853        PKIX_DEBUG(expr)
 854#define PKIX_CRLDP_DEBUG_ARG(expr, arg) \
 855        PKIX_DEBUG_ARG(expr, arg)
 856#else
 857#define PKIX_CRLDP_DEBUG(expr)
 858#define PKIX_CRLDP_DEBUG_ARG(expr, arg)
 859#endif
 860
 861#if PKIX_HTTPCLIENTDEBUG
 862#define PKIX_HTTPCLIENT_DEBUG(expr) \
 863        PKIX_DEBUG(expr)
 864#define PKIX_HTTPCLIENT_DEBUG_ARG(expr, arg) \
 865        PKIX_DEBUG_ARG(expr, arg)
 866#else
 867#define PKIX_HTTPCLIENT_DEBUG(expr)
 868#define PKIX_HTTPCLIENT_DEBUG_ARG(expr, arg)
 869#endif
 870
 871#if PKIX_BIGINTDEBUG
 872#define PKIX_BIGINT_DEBUG(expr) \
 873        PKIX_DEBUG(expr)
 874#define PKIX_BIGINT_DEBUG_ARG(expr, arg) \
 875        PKIX_DEBUG_ARG(expr, arg)
 876#else
 877#define PKIX_BIGINT_DEBUG(expr)
 878#define PKIX_BIGINT_DEBUG_ARG(expr, arg)
 879#endif
 880
 881#if PKIX_DATEDEBUG
 882#define PKIX_DATE_DEBUG(expr) \
 883        PKIX_DEBUG(expr)
 884#define PKIX_DATE_DEBUG_ARG(expr, arg) \
 885        PKIX_DEBUG_ARG(expr, arg)
 886#else
 887#define PKIX_DATE_DEBUG(expr)
 888#define PKIX_DATE_DEBUG_ARG(expr, arg)
 889#endif
 890
 891#if PKIX_TRUSTANCHORDEBUG
 892#define PKIX_TRUSTANCHOR_DEBUG(expr) \
 893        PKIX_DEBUG(expr)
 894#define PKIX_TRUSTANCHOR_DEBUG_ARG(expr, arg) \
 895        PKIX_DEBUG_ARG(expr, arg)
 896#else
 897#define PKIX_TRUSTANCHOR_DEBUG(expr)
 898#define PKIX_TRUSTANCHOR_DEBUG_ARG(expr, arg)
 899#endif
 900
 901#if PKIX_PROCESSINGPARAMSDEBUG
 902#define PKIX_PROCESSINGPARAMS_DEBUG(expr) \
 903        PKIX_DEBUG(expr)
 904#define PKIX_PROCESSINGPARAMS_DEBUG_ARG(expr, arg) \
 905        PKIX_DEBUG_ARG(expr, arg)
 906#else
 907#define PKIX_PROCESSINGPARAMS_DEBUG(expr)
 908#define PKIX_PROCESSINGPARAMS_DEBUG_ARG(expr, arg)
 909#endif
 910
 911#if PKIX_VALIDATEPARAMSDEBUG
 912#define PKIX_VALIDATEPARAMS_DEBUG(expr) \
 913        PKIX_DEBUG(expr)
 914#define PKIX_VALIDATEPARAMS_DEBUG_ARG(expr, arg) \
 915        PKIX_DEBUG_ARG(expr, arg)
 916#else
 917#define PKIX_VALIDATEPARAMS_DEBUG(expr)
 918#define PKIX_VALIDATEPARAMS_DEBUG_ARG(expr, arg)
 919#endif
 920
 921#if PKIX_VALIDATERESULTDEBUG
 922#define PKIX_VALIDATERESULT_DEBUG(expr) \
 923        PKIX_DEBUG(expr)
 924#define PKIX_VALIDATERESULT_DEBUG_ARG(expr, arg) \
 925        PKIX_DEBUG_ARG(expr, arg)
 926#else
 927#define PKIX_VALIDATERESULT_DEBUG(expr)
 928#define PKIX_VALIDATERESULT_DEBUG_ARG(expr, arg)
 929#endif
 930
 931#if PKIX_VALIDATEDEBUG
 932#define PKIX_VALIDATE_DEBUG(expr) \
 933        PKIX_DEBUG(expr)
 934#define PKIX_VALIDATE_DEBUG_ARG(expr, arg) \
 935        PKIX_DEBUG_ARG(expr, arg)
 936#else
 937#define PKIX_VALIDATE_DEBUG(expr)
 938#define PKIX_VALIDATE_DEBUG_ARG(expr, arg)
 939#endif
 940
 941#if PKIX_BUILDDEBUG
 942#define PKIX_BUILD_DEBUG(expr) \
 943        PKIX_DEBUG(expr)
 944#define PKIX_BUILD_DEBUG_ARG(expr, arg) \
 945        PKIX_DEBUG_ARG(expr, arg)
 946#else
 947#define PKIX_BUILD_DEBUG(expr)
 948#define PKIX_BUILD_DEBUG_ARG(expr, arg)
 949#endif
 950
 951#if PKIX_CERTCHAINCHECKERDEBUG
 952#define PKIX_CERTCHAINCHECKER_DEBUG(expr) \
 953        PKIX_DEBUG(expr)
 954#define PKIX_CERTCHAINCHECKER_DEBUG_ARG(expr, arg) \
 955        PKIX_DEBUG_ARG(expr, arg)
 956#else
 957#define PKIX_CERTCHAINCHECKER_DEBUG(expr)
 958#define PKIX_CERTCHAINCHECKER_DEBUG_ARG(expr, arg)
 959#endif
 960
 961#if PKIX_REVOCATIONCHECKERDEBUG
 962#define PKIX_REVOCATIONCHECKER_DEBUG(expr) \
 963        PKIX_DEBUG(expr)
 964#define PKIX_REVOCATIONCHECKER_DEBUG_ARG(expr, arg) \
 965        PKIX_DEBUG_ARG(expr, arg)
 966#else
 967#define PKIX_REVOCATIONCHECKER_DEBUG(expr)
 968#define PKIX_REVOCATIONCHECKER_DEBUG_ARG(expr, arg)
 969#endif
 970
 971#if PKIX_REVOCATIONMETHODDEBUG
 972#define PKIX_REVOCATIONMETHOD_DEBUG(expr) \
 973        PKIX_DEBUG(expr)
 974#define PKIX_REVOCATIONMETHOD_DEBUG_ARG(expr, arg) \
 975        PKIX_DEBUG_ARG(expr, arg)
 976#else
 977#define PKIX_REVOCATIONMETHOD_DEBUG(expr)
 978#define PKIX_REVOCATIONMETHOD_DEBUG_ARG(expr, arg)
 979#endif
 980
 981#if PKIX_CERTSELECTORDEBUG
 982#define PKIX_CERTSELECTOR_DEBUG(expr) \
 983        PKIX_DEBUG(expr)
 984#define PKIX_CERTSELECTOR_DEBUG_ARG(expr, arg) \
 985        PKIX_DEBUG_ARG(expr, arg)
 986#else
 987#define PKIX_CERTSELECTOR_DEBUG(expr)
 988#define PKIX_CERTSELECTOR_DEBUG_ARG(expr, arg)
 989#endif
 990
 991#if PKIX_COMCERTSELPARAMSDEBUG
 992#define PKIX_COMCERTSELPARAMS_DEBUG(expr) \
 993        PKIX_DEBUG(expr)
 994#define PKIX_COMCERTSELPARAMS_DEBUG_ARG(expr, arg) \
 995        PKIX_DEBUG_ARG(expr, arg)
 996#else
 997#define PKIX_COMCERTSELPARAMS_DEBUG(expr)
 998#define PKIX_COMCERTSELPARAMS_DEBUG_ARG(expr, arg)
 999#endif
1000
1001#if PKIX_TARGETCERTCHECKERSTATEDEBUG
1002#define PKIX_TARGETCERTCHECKERSTATE_DEBUG(expr) \
1003        PKIX_DEBUG(expr)
1004#define PKIX_TARGETCERTCHECKERSTATE_DEBUG_ARG(expr, arg) \
1005        PKIX_DEBUG_ARG(expr, arg)
1006#else
1007#define PKIX_TARGETCERTCHECKERSTATE_DEBUG(expr)
1008#define PKIX_TARGETCERTCHECKERSTATE_DEBUG_ARG(expr, arg)
1009#endif
1010
1011#if PKIX_BASICCONSTRAINTSCHECKERSTATEDEBUG
1012#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG(expr) \
1013        PKIX_DEBUG(expr)
1014#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg) \
1015        PKIX_DEBUG_ARG(expr, arg)
1016#else
1017#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG(expr)
1018#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg)
1019#endif
1020
1021#if PKIX_INITIALIZEPARAMSDEBUG
1022#define PKIX_INITIALIZEPARAMS_DEBUG(expr) \
1023        PKIX_DEBUG(expr)
1024#define PKIX_INITIALIZEPARAMS_DEBUG_ARG(expr, arg) \
1025        PKIX_DEBUG_ARG(expr, arg)
1026#else
1027#define PKIX_INITIALIZEPARAMS_DEBUG(expr)
1028#define PKIX_INITIALIZEPARAMS_DEBUG_ARG(expr, arg)
1029#endif
1030
1031#if PKIX_CERTBASICCONSTRAINTSDEBUG
1032#define PKIX_CERTBASICCONSTRAINTS_DEBUG(expr) \
1033        PKIX_DEBUG(expr)
1034#define PKIX_CERTBASICCONSTRAINTS_DEBUG_ARG(expr, arg) \
1035        PKIX_DEBUG_ARG(expr, arg)
1036#else
1037#define PKIX_CERTBASICCONSTRAINTS_DEBUG(expr)
1038#define PKIX_CERTBASICCONSTRAINTS_DEBUG_ARG(expr, arg)
1039#endif
1040
1041#if PKIX_CERTNAMECONSTRAINTSDEBUG
1042#define PKIX_CERTNAMECONSTRAINTS_DEBUG(expr) \
1043        PKIX_DEBUG(expr)
1044#define PKIX_CERTNAMECONSTRAINTS_DEBUG_ARG(expr, arg) \
1045        PKIX_DEBUG_ARG(expr, arg)
1046#else
1047#define PKIX_CERTNAMECONSTRAINTS_DEBUG(expr)
1048#define PKIX_CERTNAMECONSTRAINTS_DEBUG_ARG(expr, arg)
1049#endif
1050
1051#if PKIX_CERTNAMECONSTRAINTSCHECKERSTATEDEBUG
1052#define PKIX_CERTNAMECONSTRAINTSCHECKERSTATE_DEBUG(expr) \
1053        PKIX_DEBUG(expr)
1054#define PKIX_CERTNAMECONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg) \
1055        PKIX_DEBUG_ARG(expr, arg)
1056#else
1057#define PKIX_CERTNAMECONSTRAINTSCHECKERSTATE_DEBUG(expr)
1058#define PKIX_CERTNAMECONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg)
1059#endif
1060
1061#if PKIX_SUBJALTNAMECHECKERSTATEDEBUG
1062#define PKIX_SUBJALTNAMECHECKERSTATE_DEBUG(expr) \
1063        PKIX_DEBUG(expr)
1064#define PKIX_SUBJALTNAMECHECKERSTATE_DEBUG_ARG(expr, arg) \
1065        PKIX_DEBUG_ARG(expr, arg)
1066#else
1067#define PKIX_SUBJALTNAMECHECKERSTATE_DEBUG(expr)
1068#define PKIX_SUBJALTNAMECHECKERSTATE_DEBUG_ARG(expr, arg)
1069#endif
1070
1071#if PKIX_CERTPOLICYQUALIFIERDEBUG
1072#define PKIX_CERTPOLICYQUALIFIER_DEBUG(expr) \
1073        PKIX_DEBUG(expr)
1074#define PKIX_CERTPOLICYQUALIFIER_DEBUG_ARG(expr, arg) \
1075        PKIX_DEBUG_ARG(expr, arg)
1076#else
1077#define PKIX_CERTPOLICYQUALIFIER_DEBUG(expr)
1078#define PKIX_CERTPOLICYQUALIFIER_DEBUG_ARG(expr, arg)
1079#endif
1080
1081#if PKIX_CERTPOLICYINFODEBUG
1082#define PKIX_CERTPOLICYINFO_DEBUG(expr) \
1083        PKIX_DEBUG(expr)
1084#define PKIX_CERTPOLICYINFO_DEBUG_ARG(expr, arg) \
1085        PKIX_DEBUG_ARG(expr, arg)
1086#else
1087#define PKIX_CERTPOLICYINFO_DEBUG(expr)
1088#define PKIX_CERTPOLICYINFO_DEBUG_ARG(expr, arg)
1089#endif
1090
1091#if PKIX_CERTPOLICYNODEDEBUG
1092#define PKIX_CERTPOLICYNODE_DEBUG(expr) \
1093        PKIX_DEBUG(expr)
1094#define PKIX_CERTPOLICYNODE_DEBUG_ARG(expr, arg) \
1095        PKIX_DEBUG_ARG(expr, arg)
1096#else
1097#define PKIX_CERTPOLICYNODE_DEBUG(expr)
1098#define PKIX_CERTPOLICYNODE_DEBUG_ARG(expr, arg)
1099#endif
1100
1101#if PKIX_CERTPOLICYCHECKERSTATEDEBUG
1102#define PKIX_CERTPOLICYCHECKERSTATE_DEBUG(expr) \
1103        PKIX_DEBUG(expr)
1104#define PKIX_CERTPOLICYCHECKERSTATE_DEBUG_ARG(expr, arg) \
1105        PKIX_DEBUG_ARG(expr, arg)
1106#else
1107#define PKIX_CERTPOLICYCHECKERSTATE_DEBUG(expr)
1108#define PKIX_CERTPOLICYCHECKERSTATE_DEBUG_ARG(expr, arg)
1109#endif
1110
1111#if PKIX_LIFECYCLEDEBUG
1112#define PKIX_LIFECYCLE_DEBUG(expr) \
1113        PKIX_DEBUG(expr)
1114#define PKIX_LIFECYCLE_DEBUG_ARG(expr, arg) \
1115        PKIX_DEBUG_ARG(expr, arg)
1116#else
1117#define PKIX_LIFECYCLE_DEBUG(expr)
1118#define PKIX_LIFECYCLE_DEBUG_ARG(expr, arg)
1119#endif
1120
1121#if PKIX_BASICCONSTRAINTSCHECKERSTATEDEBUG
1122#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG(expr) \
1123        PKIX_DEBUG(expr)
1124#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg) \
1125        PKIX_DEBUG_ARG(expr, arg)
1126#else
1127#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG(expr)
1128#define PKIX_BASICCONSTRAINTSCHECKERSTATE_DEBUG_ARG(expr, arg)
1129#endif
1130
1131#if PKIX_CRLDEBUG
1132#define PKIX_CRL_DEBUG(expr) \
1133        PKIX_DEBUG(expr)
1134#define PKIX_CRL_DEBUG_ARG(expr, arg) \
1135        PKIX_DEBUG_ARG(expr, arg)
1136#else
1137#define PKIX_CRL_DEBUG(expr)
1138#define PKIX_CRL_DEBUG_ARG(expr, arg)
1139#endif
1140
1141#if PKIX_CRLENTRYDEBUG
1142#define PKIX_CRLENTRY_DEBUG(expr) \
1143        PKIX_DEBUG(expr)
1144#define PKIX_CRLENTRY_DEBUG_ARG(expr, arg) \
1145        PKIX_DEBUG_ARG(expr, arg)
1146#else
1147#define PKIX_CRLENTRY_DEBUG(expr)
1148#define PKIX_CRLENTRY_DEBUG_ARG(expr, arg)
1149#endif
1150
1151#if PKIX_CRLSELECTORDEBUG
1152#define PKIX_CRLSELECTOR_DEBUG(expr) \
1153        PKIX_DEBUG(expr)
1154#define PKIX_CRLSELECTOR_DEBUG_ARG(expr, arg) \
1155        PKIX_DEBUG_ARG(expr, arg)
1156#else
1157#define PKIX_CRLSELECTOR_DEBUG(expr)
1158#define PKIX_CRLSELECTOR_DEBUG_ARG(expr, arg)
1159#endif
1160
1161#if PKIX_COMCRLSELPARAMSDEBUG
1162#define PKIX_COMCRLSELPARAMS_DEBUG(expr) \
1163        PKIX_DEBUG(expr)
1164#define PKIX_COMCRLSELPARAMS_DEBUG_ARG(expr, arg) \
1165        PKIX_DEBUG_ARG(expr, arg)
1166#else
1167#define PKIX_COMCRLSELPARAMS_DEBUG(expr)
1168#define PKIX_COMCRLSELPARAMS_DEBUG_ARG(expr, arg)
1169#endif
1170
1171#if PKIX_CERTSTOREDEBUG
1172#define PKIX_CERTSTORE_DEBUG(expr) \
1173        PKIX_DEBUG(expr)
1174#define PKIX_CERTSTORE_DEBUG_ARG(expr, arg) \
1175        PKIX_DEBUG_ARG(expr, arg)
1176#else
1177#define PKIX_CERTSTORE_DEBUG(expr)
1178#define PKIX_CERTSTORE_DEBUG_ARG(expr, arg)
1179#endif
1180
1181#if PKIX_COLLECTIONCERTSTORECONTEXTDEBUG
1182#define PKIX_COLLECTIONCERTSTORECONTEXT_DEBUG(expr) \
1183        PKIX_DEBUG(expr)
1184#define PKIX_COLLECTIONCERTSTORECONTEXT_DEBUG_ARG(expr, arg) \
1185        PKIX_DEBUG_ARG(expr, arg)
1186#else
1187#define PKIX_COLLECTIONCERTSTORECONTEXT_DEBUG(expr)
1188#define PKIX_COLLECTIONCERTSTORECONTEXT_DEBUG_ARG(expr, arg)
1189#endif
1190
1191#if PKIX_CRLCHECKERDEBUG
1192#define PKIX_CRLCHECKER_DEBUG(expr) \
1193        PKIX_DEBUG(expr)
1194#define PKIX_CRLCHECKER_DEBUG_ARG(expr, arg) \
1195        PKIX_DEBUG_ARG(expr, arg)
1196#else
1197#define PKIX_CRLCHECKER_DEBUG(expr)
1198#define PKIX_CRLCHECKER_DEBUG_ARG(expr, arg)
1199#endif
1200
1201#if PKIX_CERTPOLICYMAPDEBUG
1202#define PKIX_CERTPOLICYMAP_DEBUG(expr) \
1203        PKIX_DEBUG(expr)
1204#define PKIX_CERTPOLICYMAP_DEBUG_ARG(expr, arg) \
1205        PKIX_DEBUG_ARG(expr, arg)
1206#else
1207#define PKIX_CERTPOLICYMAP_DEBUG(expr)
1208#define PKIX_CERTPOLICYMAP_DEBUG_ARG(expr, arg)
1209#endif
1210
1211#if PKIX_BUILDRESULTDEBUG
1212#define PKIX_BUILDRESULT_DEBUG(expr) \
1213        PKIX_DEBUG(expr)
1214#define PKIX_BUILDRESULT_DEBUG_ARG(expr, arg) \
1215        PKIX_DEBUG_ARG(expr, arg)
1216#else
1217#define PKIX_BUILDRESULT_DEBUG(expr)
1218#define PKIX_BUILDRESULT_DEBUG_ARG(expr, arg)
1219#endif
1220
1221#if PKIX_FORWARDBUILDERSTATEDEBUG
1222#define PKIX_FORWARDBUILDERSTATE_DEBUG(expr) \
1223        PKIX_DEBUG(expr)
1224#define PKIX_FORWARDBUILDERSTATE_DEBUG_ARG(expr, arg) \
1225        PKIX_DEBUG_ARG(expr, arg)
1226#else
1227#define PKIX_FORWARDBUILDERSTATE_DEBUG(expr)
1228#define PKIX_FORWARDBUILDERSTATE_DEBUG_ARG(expr, arg)
1229#endif
1230
1231#if PKIX_SIGNATURECHECKERSTATEDEBUG
1232#define PKIX_SIGNATURECHECKERSTATE_DEBUG(expr) \
1233        PKIX_DEBUG(expr)
1234#define PKIX_SIGNATURECHECKERSTATE_DEBUG_ARG(expr, arg) \
1235        PKIX_DEBUG_ARG(expr, arg)
1236#else
1237#define PKIX_SIGNATURECHECKERSTATE_DEBUG(expr)
1238#define PKIX_SIGNATURECHECKERSTATE_DEBUG_ARG(expr, arg)
1239#endif
1240
1241#if PKIX_USERDEFINEDMODULESDEBUG
1242#define PKIX_USERDEFINEDMODULES_DEBUG(expr) \
1243        PKIX_DEBUG(expr)
1244#define PKIX_USERDEFINEDMODULES_DEBUG_ARG(expr, arg) \
1245        PKIX_DEBUG_ARG(expr, arg)
1246#else
1247#define PKIX_USERDEFINEDMODULES_DEBUG(expr)
1248#define PKIX_USERDEFINEDMODULES_DEBUG_ARG(expr, arg)
1249#endif
1250
1251#if PKIX_CONTEXTDEBUG
1252#define PKIX_CONTEXT_DEBUG(expr) \
1253        PKIX_DEBUG(expr)
1254#define PKIX_CONTEXT_DEBUG_ARG(expr, arg) \
1255        PKIX_DEBUG_ARG(expr, arg)
1256#else
1257#define PKIX_CONTEXT_DEBUG(expr)
1258#define PKIX_CONTEXT_DEBUG_ARG(expr, arg)
1259#endif
1260
1261#if PKIX_REVOCATIONCHECKERDEBUG
1262#define PKIX_REVOCATIONCHECKER_DEBUG(expr) \
1263        PKIX_DEBUG(expr)
1264#define PKIX_REVOCATIONCHECKER_DEBUG_ARG(expr, arg) \
1265        PKIX_DEBUG_ARG(expr, arg)
1266#else
1267#define PKIX_REVOCATIONCHECKER_DEBUG(expr)
1268#define PKIX_REVOCATIONCHECKER_DEBUG_ARG(expr, arg)
1269#endif
1270
1271#if PKIX_LDAPREQUESTDEBUG
1272#define PKIX_LDAPREQUEST_DEBUG(expr) \
1273        PKIX_DEBUG(expr)
1274#define PKIX_LDAPREQUEST_DEBUG_ARG(expr, arg) \
1275        PKIX_DEBUG_ARG(expr, arg)
1276#else
1277#define PKIX_LDAPREQUEST_DEBUG(expr)
1278#define PKIX_LDAPREQUEST_DEBUG_ARG(expr, arg)
1279#endif
1280
1281#if PKIX_LDAPRESPONSEDEBUG
1282#define PKIX_LDAPRESPONSE_DEBUG(expr) \
1283        PKIX_DEBUG(expr)
1284#define PKIX_LDAPRESPONSE_DEBUG_ARG(expr, arg) \
1285        PKIX_DEBUG_ARG(expr, arg)
1286#else
1287#define PKIX_LDAPRESPONSE_DEBUG(expr)
1288#define PKIX_LDAPRESPONSE_DEBUG_ARG(expr, arg)
1289#endif
1290
1291#if PKIX_LDAPCLIENTDEBUG
1292#define PKIX_LDAPCLIENT_DEBUG(expr) \
1293        PKIX_DEBUG(expr)
1294#define PKIX_LDAPCLIENT_DEBUG_ARG(expr, arg) \
1295        PKIX_DEBUG_ARG(expr, arg)
1296#else
1297#define PKIX_LDAPCLIENT_DEBUG(expr)
1298#define PKIX_LDAPCLIENT_DEBUG_ARG(expr, arg)
1299#endif
1300
1301#if PKIX_LDAPDEFAULTCLIENTDEBUG
1302#define PKIX_LDAPDEFAULTCLIENT_DEBUG(expr) \
1303        PKIX_DEBUG(expr)
1304#define PKIX_LDAPDEFAULTCLIENT_DEBUG_ARG(expr, arg) \
1305        PKIX_DEBUG_ARG(expr, arg)
1306#else
1307#define PKIX_LDAPDEFAULTCLIENT_DEBUG(expr)
1308#define PKIX_LDAPDEFAULTCLIENT_DEBUG_ARG(expr, arg)
1309#endif
1310
1311#if PKIX_SOCKETDEBUG
1312#define PKIX_SOCKET_DEBUG(expr) \
1313        PKIX_DEBUG(expr)
1314#define PKIX_SOCKET_DEBUG_ARG(expr, arg) \
1315        PKIX_DEBUG_ARG(expr, arg)
1316#else
1317#define PKIX_SOCKET_DEBUG(expr)
1318#define PKIX_SOCKET_DEBUG_ARG(expr, arg)
1319#endif
1320
1321#if PKIX_RESOURCELIMITSDEBUG
1322#define PKIX_RESOURCELIMITS_DEBUG(expr) \
1323        PKIX_DEBUG(expr)
1324#define PKIX_RESOURCELIMITS_DEBUG_ARG(expr, arg) \
1325        PKIX_DEBUG_ARG(expr, arg)
1326#else
1327#define PKIX_RESOURCELIMITS_DEBUG(expr)
1328#define PKIX_RESOURCELIMITS_DEBUG_ARG(expr, arg)
1329#endif
1330
1331#if PKIX_LOGGERDEBUG
1332#define PKIX_LOGGER_DEBUG(expr) \
1333        PKIX_DEBUG(expr)
1334#define PKIX_LOGGER_DEBUG_ARG(expr, arg) \
1335        PKIX_DEBUG_ARG(expr, arg)
1336#else
1337#define PKIX_LOGGER_DEBUG(expr)
1338#define PKIX_LOGGER_DEBUG_ARG(expr, arg)
1339#endif
1340
1341#if PKIX_MONITORLOCKDEBUG
1342#define PKIX_MONITORLOCK_DEBUG(expr) \
1343        PKIX_DEBUG(expr)
1344#define PKIX_MONITORLOCK_DEBUG_ARG(expr, arg) \
1345        PKIX_DEBUG_ARG(expr, arg)
1346#else
1347#define PKIX_MONITORLOCK_DEBUG(expr)
1348#define PKIX_MONITORLOCK_DEBUG_ARG(expr, arg)
1349#endif
1350
1351#if PKIX_INFOACCESSDEBUG
1352#define PKIX_INFOACCESS_DEBUG(expr) \
1353        PKIX_DEBUG(expr)
1354#define PKIX_INFOACCESS_DEBUG_ARG(expr, arg) \
1355        PKIX_DEBUG_ARG(expr, arg)
1356#else
1357#define PKIX_INFOACCESS_DEBUG(expr)
1358#define PKIX_INFOACCESS_DEBUG_ARG(expr, arg)
1359#endif
1360
1361#if PKIX_AIAMGRDEBUG
1362#define PKIX_AIAMGR_DEBUG(expr) \
1363        PKIX_DEBUG(expr)
1364#define PKIX_AIAMGR_DEBUG_ARG(expr, arg) \
1365        PKIX_DEBUG_ARG(expr, arg)
1366#else
1367#define PKIX_AIAMGR_DEBUG(expr)
1368#define PKIX_AIAMGR_DEBUG_ARG(expr, arg)
1369#endif
1370
1371#if PKIX_OCSPCHECKERDEBUG
1372#define PKIX_OCSPCHECKER_DEBUG(expr) \
1373        PKIX_DEBUG(expr)
1374#define PKIX_OCSPCHECKER_DEBUG_ARG(expr, arg) \
1375        PKIX_DEBUG_ARG(expr, arg)
1376#else
1377#define PKIX_OCSPCHECKER_DEBUG(expr)
1378#define PKIX_OCSPCHECKER_DEBUG_ARG(expr, arg)
1379#endif
1380
1381#if PKIX_OCSPCERTIDDEBUG
1382#define PKIX_OCSPCERTID_DEBUG(expr) \
1383        PKIX_DEBUG(expr)
1384#define PKIX_OCSPCERTID_DEBUG_ARG(expr, arg) \
1385        PKIX_DEBUG_ARG(expr, arg)
1386#else
1387#define PKIX_OCSPCERTID_DEBUG(expr)
1388#define PKIX_OCSPCERTID_DEBUG_ARG(expr, arg)
1389#endif
1390
1391#if PKIX_OCSPREQUESTDEBUG
1392#define PKIX_OCSPREQUEST_DEBUG(expr) \
1393        PKIX_DEBUG(expr)
1394#define PKIX_OCSPREQUEST_DEBUG_ARG(expr, arg) \
1395        PKIX_DEBUG_ARG(expr, arg)
1396#else
1397#define PKIX_OCSPREQUEST_DEBUG(expr)
1398#define PKIX_OCSPREQUEST_DEBUG_ARG(expr, arg)
1399#endif
1400
1401#if PKIX_OCSPRESPONSEDEBUG
1402#define PKIX_OCSPRESPONSE_DEBUG(expr) \
1403        PKIX_DEBUG(expr)
1404#define PKIX_OCSPRESPONSE_DEBUG_ARG(expr, arg) \
1405        PKIX_DEBUG_ARG(expr, arg)
1406#else
1407#define PKIX_OCSPRESPONSE_DEBUG(expr)
1408#define PKIX_OCSPRESPONSE_DEBUG_ARG(expr, arg)
1409#endif
1410
1411#if PKIX_HTTPDEFAULTCLIENTDEBUG
1412#define PKIX_HTTPDEFAULTCLIENT_DEBUG(expr) \
1413        PKIX_DEBUG(expr)
1414#define PKIX_HTTPDEFAULTCLIENT_DEBUG_ARG(expr, arg) \
1415        PKIX_DEBUG_ARG(expr, arg)
1416#else
1417#define PKIX_HTTPDEFAULTCLIENT_DEBUG(expr)
1418#define PKIX_HTTPDEFAULTCLIENT_DEBUG_ARG(expr, arg)
1419#endif
1420
1421#if PKIX_HTTPCERTSTORECONTEXTDEBUG
1422#define PKIX_HTTPCERTSTORECONTEXT_DEBUG(expr) \
1423        PKIX_DEBUG(expr)
1424#define PKIX_HTTPCERTSTORECONTEXT_DEBUG_ARG(expr, arg) \
1425        PKIX_DEBUG_ARG(expr, arg)
1426#else
1427#define PKIX_HTTPCERTSTORECONTEXT_DEBUG(expr)
1428#define PKIX_HTTPCERTSTORECONTEXT_DEBUG_ARG(expr, arg)
1429#endif
1430
1431#if PKIX_VERIFYNODEDEBUG
1432#define PKIX_VERIFYNODE_DEBUG(expr) \
1433        PKIX_DEBUG(expr)
1434#define PKIX_VERIFYNODE_DEBUG_ARG(expr, arg) \
1435        PKIX_DEBUG_ARG(expr, arg)
1436#else
1437#define PKIX_VERIFYNODE_DEBUG(expr)
1438#define PKIX_VERIFYNODE_DEBUG_ARG(expr, arg)
1439#endif
1440
1441#if PKIX_EKUCHECKER
1442#define PKIX_EKUCHECKER_DEBUG(expr) \
1443        PKIX_DEBUG(expr)
1444#define PKIX_EKUCHECKER_DEBUG_ARG(expr, arg) \
1445        PKIX_DEBUG_ARG(expr, arg)
1446#else
1447#define PKIX_EKUCHECKER_DEBUG(expr)
1448#define PKIX_EKUCHECKER_DEBUG_ARG(expr, arg)
1449#endif
1450
1451#if PKIX_CERTVFYPKIXDEBUG
1452#define PKIX_CERTVFYPKIX_DEBUG(expr) \
1453        PKIX_DEBUG(expr)
1454#define PKIX_CERTVFYPKIX_DEBUG_ARG(expr, arg) \
1455        PKIX_DEBUG_ARG(expr, arg)
1456#else
1457#define PKIX_CERTVFYPKIX_DEBUG(expr)
1458#define PKIX_CERTVFYPKIX_DEBUG_ARG(expr, arg)
1459#endif
1460
1461/*
1462 * All object types register themselves with the system using a
1463 * pkix_ClassTable_Entry, which consists of a set of functions for that
1464 * type and an ASCII string (char *) which is used by the default
1465 * ToStringCallback (if necessary). System types register themselves directly
1466 * when their respective PKIX_"type"_RegisterSelf functions are called.
1467 * User-defined types can be registered using PKIX_PL_Object_RegisterType.
1468 * (see comments in pkix_pl_system.h)
1469 */
1470
1471typedef struct pkix_ClassTable_EntryStruct pkix_ClassTable_Entry;
1472struct pkix_ClassTable_EntryStruct {
1473        char *description;
1474        PKIX_Int32 objCounter;
1475        PKIX_Int32 typeObjectSize;
1476        PKIX_PL_DestructorCallback destructor;
1477        PKIX_PL_EqualsCallback equalsFunction;
1478        PKIX_PL_HashcodeCallback hashcodeFunction;
1479        PKIX_PL_ToStringCallback toStringFunction;
1480        PKIX_PL_ComparatorCallback comparator;
1481        PKIX_PL_DuplicateCallback duplicateFunction;
1482};
1483
1484/*
1485 * PKIX_ERRORCLASSNAMES is an array of strings, with each string holding a
1486 * descriptive name for an error code. This is used by the default
1487 * PKIX_PL_Error_ToString function.
1488 */
1489extern const char *PKIX_ERRORCLASSNAMES[PKIX_NUMERRORCLASSES];
1490
1491#define MAX_STACK_DEPTH         1000
1492
1493extern PRLogModuleInfo *pkixLog;
1494
1495#define PKIX_MAGIC_HEADER           LL_INIT(0xFEEDC0FF, 0xEEFACADE)
1496#define PKIX_MAGIC_HEADER_DESTROYED LL_INIT(0xBAADF00D, 0xDEADBEEF)
1497
1498/* see source file for function documentation */
1499
1500PKIX_Error *
1501pkix_IsCertSelfIssued(
1502        PKIX_PL_Cert *cert,
1503        PKIX_Boolean *pSelfIssued,
1504        void *plContext);
1505
1506PKIX_Error *
1507pkix_Throw(
1508        PKIX_ERRORCLASS errClass,
1509        const char *funcName,
1510        PKIX_ERRORCODE errorTextCode,
1511        PKIX_ERRORCLASS overrideClass,
1512        PKIX_Error *cause,
1513        PKIX_Error **pError,
1514        void *plContext);
1515
1516PKIX_Error *
1517pkix_CheckTypes(
1518        PKIX_PL_Object *first,
1519        PKIX_PL_Object *second,
1520        PKIX_UInt32 type,
1521        void *plContext);
1522
1523PKIX_Error *
1524pkix_CheckType(
1525        PKIX_PL_Object *object,
1526        PKIX_UInt32 type,
1527        void *plContext);
1528
1529PKIX_Error *
1530pkix_hash(
1531        const unsigned char *bytes,
1532        PKIX_UInt32 length,
1533        PKIX_UInt32 *hash,
1534        void *plContext);
1535
1536PKIX_Error *
1537pkix_duplicateImmutable(
1538        PKIX_PL_Object *object,
1539        PKIX_PL_Object **pNewObject,
1540        void *plContext);
1541
1542PKIX_UInt32
1543pkix_countArray(void **array);
1544
1545PKIX_UInt32
1546pkix_hex2i(char c);
1547
1548char
1549pkix_i2hex(char c);
1550
1551PKIX_Boolean
1552pkix_isPlaintext(unsigned char c, PKIX_Boolean debug);
1553
1554PKIX_Error *
1555pkix_CacheCertChain_Lookup(
1556        PKIX_PL_Cert* targetCert,
1557        PKIX_List* anchors,
1558        PKIX_PL_Date *testDate,
1559        PKIX_Boolean *pFound,
1560        PKIX_BuildResult **pBuildResult,
1561        void *plContext);
1562
1563PKIX_Error *
1564pkix_CacheCertChain_Remove(
1565        PKIX_PL_Cert* targetCert,
1566        PKIX_List* anchors,
1567        void *plContext);
1568
1569PKIX_Error *
1570pkix_CacheCertChain_Add(
1571        PKIX_PL_Cert* targetCert,
1572        PKIX_List* anchors,
1573        PKIX_PL_Date *validityDate,
1574        PKIX_BuildResult *buildResult,
1575        void *plContext);
1576
1577PKIX_Error *
1578pkix_CacheCert_Lookup(
1579        PKIX_CertStore *store,
1580        PKIX_ComCertSelParams *certSelParams,
1581        PKIX_PL_Date *testDate,
1582        PKIX_Boolean *pFound,
1583        PKIX_List** pCerts,
1584        void *plContext);
1585
1586PKIX_Error *
1587pkix_CacheCert_Add(
1588        PKIX_CertStore *store,
1589        PKIX_ComCertSelParams *certSelParams,
1590        PKIX_List* certs,
1591        void *plContext);
1592
1593PKIX_Error *
1594pkix_CacheCrlEntry_Lookup(
1595        PKIX_CertStore *store,
1596        PKIX_PL_X500Name *certIssuer,
1597        PKIX_PL_BigInt *certSerialNumber,
1598        PKIX_Boolean *pFound,
1599        PKIX_List** pCrlEntryList,
1600        void *plContext);
1601
1602PKIX_Error *
1603pkix_CacheCrlEntry_Add(
1604        PKIX_CertStore *store,
1605        PKIX_PL_X500Name *certIssuer,
1606        PKIX_PL_BigInt *certSerialNumber,
1607        PKIX_List* crlEntryList,
1608        void *plContext);
1609
1610#ifdef PR_LOGGING
1611void
1612pkix_trace_dump_cert(
1613        const char *info, 
1614        PKIX_PL_Cert *cert, 
1615        void *plContext);
1616#endif
1617
1618#ifdef __cplusplus
1619}
1620#endif
1621
1622#endif /* _PKIX_TOOLS_H */