Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_nsscontext.c

Issue 2078763002: Delete bundled copy of NSS and replace with README. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss@master
Patch Set: Delete bundled copy of NSS and replace with README. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_pl_nsscontext.c
6 *
7 * NSSContext Function Definitions
8 *
9 */
10
11
12 #include "pkix_pl_nsscontext.h"
13
14 #define PKIX_DEFAULT_MAX_RESPONSE_LENGTH 64 * 1024
15 #define PKIX_DEFAULT_COMM_TIMEOUT_SECONDS 60
16
17 #define PKIX_DEFAULT_CRL_RELOAD_DELAY_SECONDS 6 * 24 * 60 * 60
18 #define PKIX_DEFAULT_BAD_CRL_RELOAD_DELAY_SECONDS 60 * 60
19
20 /* --Public-NSSContext-Functions--------------------------- */
21
22 /*
23 * FUNCTION: PKIX_PL_NssContext_Create
24 * (see comments in pkix_samples_modules.h)
25 */
26 PKIX_Error *
27 PKIX_PL_NssContext_Create(
28 PKIX_UInt32 certificateUsage,
29 PKIX_Boolean useNssArena,
30 void *wincx,
31 void **pNssContext)
32 {
33 PKIX_PL_NssContext *context = NULL;
34 PLArenaPool *arena = NULL;
35 void *plContext = NULL;
36
37 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_Create");
38 PKIX_NULLCHECK_ONE(pNssContext);
39
40 PKIX_CHECK(PKIX_PL_Malloc
41 (sizeof(PKIX_PL_NssContext), (void **)&context, NULL),
42 PKIX_MALLOCFAILED);
43
44 if (useNssArena == PKIX_TRUE) {
45 PKIX_CONTEXT_DEBUG("\t\tCalling PORT_NewArena\n");
46 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
47 }
48
49 context->arena = arena;
50 context->certificateUsage = (SECCertificateUsage)certificateUsage;
51 context->wincx = wincx;
52 context->timeoutSeconds = PKIX_DEFAULT_COMM_TIMEOUT_SECONDS;
53 context->maxResponseLength = PKIX_DEFAULT_MAX_RESPONSE_LENGTH;
54 context->crlReloadDelay = PKIX_DEFAULT_CRL_RELOAD_DELAY_SECONDS;
55 context->badDerCrlReloadDelay =
56 PKIX_DEFAULT_BAD_CRL_RELOAD_DELAY_SECONDS;
57 context->chainVerifyCallback.isChainValid = NULL;
58 context->chainVerifyCallback.isChainValidArg = NULL;
59 *pNssContext = context;
60
61 cleanup:
62
63 PKIX_RETURN(CONTEXT);
64 }
65
66
67 /*
68 * FUNCTION: PKIX_PL_NssContext_Destroy
69 * (see comments in pkix_samples_modules.h)
70 */
71 PKIX_Error *
72 PKIX_PL_NssContext_Destroy(
73 void *nssContext)
74 {
75 void *plContext = NULL;
76 PKIX_PL_NssContext *context = NULL;
77
78 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_Destroy");
79 PKIX_NULLCHECK_ONE(nssContext);
80
81 context = (PKIX_PL_NssContext*)nssContext;
82
83 if (context->arena != NULL) {
84 PKIX_CONTEXT_DEBUG("\t\tCalling PORT_FreeArena\n");
85 PORT_FreeArena(context->arena, PKIX_FALSE);
86 }
87
88 PKIX_PL_Free(nssContext, NULL);
89
90 PKIX_RETURN(CONTEXT);
91 }
92
93 /*
94 * FUNCTION: pkix_pl_NssContext_GetCertUsage
95 * DESCRIPTION:
96 *
97 * This function obtains the platform-dependent SECCertificateUsage parameter
98 * from the context object pointed to by "nssContext", storing the result at
99 * "pCertUsage".
100 *
101 * PARAMETERS:
102 * "nssContext"
103 * The address of the context object whose wincx parameter is to be
104 * obtained. Must be non-NULL.
105 * "pCertUsage"
106 * The address where the result is stored. Must be non-NULL.
107 * THREAD SAFETY:
108 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
109 * RETURNS:
110 * Returns NULL if the function succeeds.
111 * Returns a Fatal Error if the function fails in an unrecoverable way.
112 */
113 PKIX_Error *
114 pkix_pl_NssContext_GetCertUsage(
115 PKIX_PL_NssContext *nssContext,
116 SECCertificateUsage *pCertUsage)
117 {
118 void *plContext = NULL;
119
120 PKIX_ENTER(CONTEXT, "pkix_pl_NssContext_GetCertUsage");
121 PKIX_NULLCHECK_TWO(nssContext, pCertUsage);
122
123 *pCertUsage = nssContext->certificateUsage;
124
125 PKIX_RETURN(CONTEXT);
126 }
127
128 /*
129 * FUNCTION: pkix_pl_NssContext_SetCertUsage
130 * DESCRIPTION:
131 *
132 * This function sets the platform-dependent SECCertificateUsage parameter in
133 * the context object pointed to by "nssContext" to the value provided in
134 * "certUsage".
135 *
136 * PARAMETERS:
137 * "certUsage"
138 * Platform-dependent value to be stored.
139 * "nssContext"
140 * The address of the context object whose wincx parameter is to be
141 * obtained. Must be non-NULL.
142 * THREAD SAFETY:
143 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
144 * RETURNS:
145 * Returns NULL if the function succeeds.
146 * Returns a Fatal Error if the function fails in an unrecoverable way.
147 */
148 PKIX_Error *
149 pkix_pl_NssContext_SetCertUsage(
150 SECCertificateUsage certUsage,
151 PKIX_PL_NssContext *nssContext)
152 {
153 void *plContext = NULL;
154
155 PKIX_ENTER(CONTEXT, "pkix_pl_NssContext_SetCertUsage");
156 PKIX_NULLCHECK_ONE(nssContext);
157
158 nssContext->certificateUsage = certUsage;
159
160 PKIX_RETURN(CONTEXT);
161 }
162
163 /*
164 * FUNCTION: pkix_pl_NssContext_GetWincx
165 * DESCRIPTION:
166 *
167 * This function obtains the platform-dependent wincx parameter from the
168 * context object pointed to by "nssContext", storing the result at "pWincx".
169 *
170 * PARAMETERS:
171 * "nssContext"
172 * The address of the context object whose wincx parameter is to be
173 * obtained. Must be non-NULL.
174 * "pWincx"
175 * The address where the result is stored. Must be non-NULL.
176 * THREAD SAFETY:
177 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
178 * RETURNS:
179 * Returns NULL if the function succeeds.
180 * Returns a Fatal Error if the function fails in an unrecoverable way.
181 */
182 PKIX_Error *
183 pkix_pl_NssContext_GetWincx(
184 PKIX_PL_NssContext *nssContext,
185 void **pWincx)
186 {
187 void *plContext = NULL;
188 PKIX_PL_NssContext *context = NULL;
189
190 PKIX_ENTER(CONTEXT, "pkix_pl_NssContext_GetWincx");
191 PKIX_NULLCHECK_TWO(nssContext, pWincx);
192
193 context = (PKIX_PL_NssContext *)nssContext;
194
195 *pWincx = context->wincx;
196
197 PKIX_RETURN(CONTEXT);
198 }
199
200 /*
201 * FUNCTION: pkix_pl_NssContext_SetWincx
202 * DESCRIPTION:
203 *
204 * This function sets the platform-dependent wincx parameter in the context
205 * object pointed to by "nssContext" to the value provided in "wincx".
206 *
207 * PARAMETERS:
208 * "wincx"
209 * Platform-dependent value to be stored.
210 * "nssContext"
211 * The address of the context object whose wincx parameter is to be
212 * obtained. Must be non-NULL.
213 * THREAD SAFETY:
214 * Thread Safe (see Thread Safety Definitions in Programmer's Guide)
215 * RETURNS:
216 * Returns NULL if the function succeeds.
217 * Returns a Fatal Error if the function fails in an unrecoverable way.
218 */
219 PKIX_Error *
220 pkix_pl_NssContext_SetWincx(
221 void *wincx,
222 PKIX_PL_NssContext *nssContext)
223 {
224 void *plContext = NULL;
225
226 PKIX_ENTER(CONTEXT, "pkix_pl_NssContext_SetWincx");
227 PKIX_NULLCHECK_ONE(nssContext);
228
229 nssContext->wincx = wincx;
230
231 PKIX_RETURN(CONTEXT);
232 }
233
234 /*
235 * FUNCTION: PKIX_PL_NssContext_SetTimeout
236 * DESCRIPTION:
237 *
238 * Sets user defined socket timeout for the validation
239 * session. Default is 60 seconds.
240 *
241 */
242 PKIX_Error *
243 PKIX_PL_NssContext_SetTimeout(PKIX_UInt32 timeout,
244 PKIX_PL_NssContext *nssContext)
245 {
246 void *plContext = NULL;
247
248 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_SetTimeout");
249 PKIX_NULLCHECK_ONE(nssContext);
250
251 nssContext->timeoutSeconds = timeout;
252
253 PKIX_RETURN(CONTEXT);
254 }
255
256 /*
257 * FUNCTION: PKIX_PL_NssContext_SetMaxResponseLen
258 * DESCRIPTION:
259 *
260 * Sets user defined maximum transmission length of a message.
261 *
262 */
263 PKIX_Error *
264 PKIX_PL_NssContext_SetMaxResponseLen(PKIX_UInt32 len,
265 PKIX_PL_NssContext *nssContext)
266 {
267 void *plContext = NULL;
268
269 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_SetMaxResponseLen");
270 PKIX_NULLCHECK_ONE(nssContext);
271
272 nssContext->maxResponseLength = len;
273
274 PKIX_RETURN(CONTEXT);
275 }
276
277 /*
278 * FUNCTION: PKIX_PL_NssContext_SetCrlReloadDelay
279 * DESCRIPTION:
280 *
281 * Sets user defined delay between attempts to load crl using
282 * CRLDP.
283 *
284 */
285 PKIX_Error *
286 PKIX_PL_NssContext_SetCrlReloadDelay(PKIX_UInt32 delay,
287 PKIX_PL_NssContext *nssContext)
288 {
289 void *plContext = NULL;
290
291 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_SetCrlReloadDelay");
292 PKIX_NULLCHECK_ONE(nssContext);
293
294 nssContext->crlReloadDelay = delay;
295
296 PKIX_RETURN(CONTEXT);
297 }
298
299 /*
300 * FUNCTION: PKIX_PL_NssContext_SetBadDerCrlReloadDelay
301 * DESCRIPTION:
302 *
303 * Sets user defined delay between attempts to load crl that
304 * failed to decode.
305 *
306 */
307 PKIX_Error *
308 PKIX_PL_NssContext_SetBadDerCrlReloadDelay(PKIX_UInt32 delay,
309 PKIX_PL_NssContext *nssContext)
310 {
311 void *plContext = NULL;
312
313 PKIX_ENTER(CONTEXT, "PKIX_PL_NssContext_SetBadDerCrlReloadDelay");
314 PKIX_NULLCHECK_ONE(nssContext);
315
316 nssContext->badDerCrlReloadDelay = delay;
317
318 PKIX_RETURN(CONTEXT);
319 }
OLDNEW
« no previous file with comments | « nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_nsscontext.h ('k') | nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_pk11certstore.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698