1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /*
5  * pkix_build.h
6  *
7  * Header file for buildChain function
8  *
9  */
10 
11 #ifndef _PKIX_BUILD_H
12 #define _PKIX_BUILD_H
13 #include "pkix_tools.h"
14 #ifndef NSS_PKIX_NO_LDAP
15 #include "pkix_pl_ldapt.h"
16 #endif
17 #include "pkix_ekuchecker.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef enum {
24         BUILD_SHORTCUTPENDING,
25         BUILD_INITIAL,
26         BUILD_TRYAIA,
27         BUILD_AIAPENDING,
28         BUILD_COLLECTINGCERTS,
29         BUILD_GATHERPENDING,
30         BUILD_CERTVALIDATING,
31         BUILD_ABANDONNODE,
32         BUILD_DATEPREP,
33         BUILD_CHECKTRUSTED,
34         BUILD_CHECKTRUSTED2,
35         BUILD_ADDTOCHAIN,
36         BUILD_VALCHAIN,
37         BUILD_VALCHAIN2,
38         BUILD_EXTENDCHAIN,
39         BUILD_GETNEXTCERT
40 } BuildStatus;
41 
42 typedef struct BuildConstantsStruct BuildConstants;
43 
44 /*
45  * These fields (the ones that are objects) are not reference-counted
46  * in *each* state, but only in the root, the state that has no parent.
47  * That saves time in creation and destruction of child states, but is
48  * safe enough since they are constants.
49  */
50 struct BuildConstantsStruct {
51         PKIX_UInt32 numAnchors;
52         PKIX_UInt32 numCertStores;
53         PKIX_UInt32 numHintCerts;
54         PKIX_UInt32 maxDepth;
55         PKIX_UInt32 maxFanout;
56         PKIX_UInt32 maxTime;
57         PKIX_ProcessingParams *procParams;
58         PKIX_PL_Date *testDate;
59         PKIX_PL_Date *timeLimit;
60         PKIX_PL_Cert *targetCert;
61         PKIX_PL_PublicKey *targetPubKey;
62         PKIX_List *certStores;
63         PKIX_List *anchors;
64         PKIX_List *userCheckers;
65         PKIX_List *hintCerts;
66         PKIX_RevocationChecker *revChecker;
67         PKIX_PL_AIAMgr *aiaMgr;
68         PKIX_Boolean useAIAForCertFetching;
69         PKIX_Boolean trustOnlyUserAnchors;
70 };
71 
72 struct PKIX_ForwardBuilderStateStruct{
73         BuildStatus status;
74         PKIX_Int32 traversedCACerts;
75         PKIX_UInt32 certStoreIndex;
76         PKIX_UInt32 numCerts;
77         PKIX_UInt32 numAias;
78         PKIX_UInt32 certIndex;
79         PKIX_UInt32 aiaIndex;
80         PKIX_UInt32 certCheckedIndex;
81         PKIX_UInt32 checkerIndex;
82         PKIX_UInt32 hintCertIndex;
83         PKIX_UInt32 numFanout;
84         PKIX_UInt32 numDepth;
85         PKIX_UInt32 reasonCode;
86         PKIX_Boolean canBeCached;
87         PKIX_Boolean useOnlyLocal;
88         PKIX_Boolean revChecking;
89         PKIX_Boolean usingHintCerts;
90         PKIX_Boolean certLoopingDetected;
91         PKIX_PL_Date *validityDate;
92         PKIX_PL_Cert *prevCert;
93         PKIX_PL_Cert *candidateCert;
94         PKIX_List *traversedSubjNames;
95         PKIX_List *trustChain;
96         PKIX_List *aia;
97         PKIX_List *candidateCerts;
98         PKIX_List *reversedCertChain;
99         PKIX_List *checkedCritExtOIDs;
100         PKIX_List *checkerChain;
101         PKIX_CertSelector *certSel;
102         PKIX_VerifyNode *verifyNode;
103         void *client; /* messageHandler, such as LDAPClient */
104         PKIX_ForwardBuilderState *parentState;
105         BuildConstants buildConstants;
106 };
107 
108 /* --Private-Functions-------------------------------------------- */
109 
110 PKIX_Error *
111 pkix_ForwardBuilderState_RegisterSelf(void *plContext);
112 
113 PKIX_Error *
114 PKIX_Build_GetNBIOContext(void *state, void **pNBIOContext, void *plContext);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* _PKIX_BUILD_H */
121