/src/mozilla-central/security/nss/lib/freebl/loader.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * loader.c - load platform dependent DSO containing freebl implementation. |
3 | | * |
4 | | * This Source Code Form is subject to the terms of the Mozilla Public |
5 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | | |
8 | | #include "loader.h" |
9 | | #include "prmem.h" |
10 | | #include "prerror.h" |
11 | | #include "prinit.h" |
12 | | #include "prenv.h" |
13 | | #include "blname.c" |
14 | | |
15 | | #include "prio.h" |
16 | | #include "prprf.h" |
17 | | #include <stdio.h> |
18 | | #include "prsystem.h" |
19 | | |
20 | | static const char *NameOfThisSharedLib = |
21 | | SHLIB_PREFIX "softokn" SOFTOKEN_SHLIB_VERSION "." SHLIB_SUFFIX; |
22 | | |
23 | | static PRLibrary *blLib = NULL; |
24 | | |
25 | 0 | #define LSB(x) ((x)&0xff) |
26 | 0 | #define MSB(x) ((x) >> 8) |
27 | | |
28 | | static const FREEBLVector *vector; |
29 | | static const char *libraryName = NULL; |
30 | | |
31 | | #include "genload.c" |
32 | | |
33 | | /* This function must be run only once. */ |
34 | | /* determine if hybrid platform, then actually load the DSO. */ |
35 | | static PRStatus |
36 | | freebl_LoadDSO(void) |
37 | 0 | { |
38 | 0 | PRLibrary *handle; |
39 | 0 | const char *name = getLibName(); |
40 | 0 |
|
41 | 0 | if (!name) { |
42 | 0 | PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); |
43 | 0 | return PR_FAILURE; |
44 | 0 | } |
45 | 0 |
|
46 | 0 | handle = loader_LoadLibrary(name); |
47 | 0 | if (handle) { |
48 | 0 | PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); |
49 | 0 | if (address) { |
50 | 0 | FREEBLGetVectorFn *getVector = (FREEBLGetVectorFn *)address; |
51 | 0 | const FREEBLVector *dsoVector = getVector(); |
52 | 0 | if (dsoVector) { |
53 | 0 | unsigned short dsoVersion = dsoVector->version; |
54 | 0 | unsigned short myVersion = FREEBL_VERSION; |
55 | 0 | if (MSB(dsoVersion) == MSB(myVersion) && |
56 | 0 | LSB(dsoVersion) >= LSB(myVersion) && |
57 | 0 | dsoVector->length >= sizeof(FREEBLVector)) { |
58 | 0 | vector = dsoVector; |
59 | 0 | libraryName = name; |
60 | 0 | blLib = handle; |
61 | 0 | return PR_SUCCESS; |
62 | 0 | } |
63 | 0 | } |
64 | 0 | } |
65 | | #ifdef DEBUG |
66 | | if (blLib) { |
67 | | PRStatus status = PR_UnloadLibrary(blLib); |
68 | | PORT_Assert(PR_SUCCESS == status); |
69 | | } |
70 | | #else |
71 | 0 | if (blLib) |
72 | 0 | PR_UnloadLibrary(blLib); |
73 | 0 | #endif |
74 | 0 | } |
75 | 0 | return PR_FAILURE; |
76 | 0 | } |
77 | | |
78 | | static const PRCallOnceType pristineCallOnce; |
79 | | static PRCallOnceType loadFreeBLOnce; |
80 | | |
81 | | static PRStatus |
82 | | freebl_RunLoaderOnce(void) |
83 | 0 | { |
84 | 0 | PRStatus status; |
85 | 0 |
|
86 | 0 | status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); |
87 | 0 | return status; |
88 | 0 | } |
89 | | |
90 | | SECStatus |
91 | | BL_Init(void) |
92 | 0 | { |
93 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
94 | 0 | return SECFailure; |
95 | 0 | return (vector->p_BL_Init)(); |
96 | 0 | } |
97 | | |
98 | | RSAPrivateKey * |
99 | | RSA_NewKey(int keySizeInBits, SECItem *publicExponent) |
100 | 0 | { |
101 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
102 | 0 | return NULL; |
103 | 0 | return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); |
104 | 0 | } |
105 | | |
106 | | SECStatus |
107 | | RSA_PublicKeyOp(RSAPublicKey *key, |
108 | | unsigned char *output, |
109 | | const unsigned char *input) |
110 | 0 | { |
111 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
112 | 0 | return SECFailure; |
113 | 0 | return (vector->p_RSA_PublicKeyOp)(key, output, input); |
114 | 0 | } |
115 | | |
116 | | SECStatus |
117 | | RSA_PrivateKeyOp(RSAPrivateKey *key, |
118 | | unsigned char *output, |
119 | | const unsigned char *input) |
120 | 0 | { |
121 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
122 | 0 | return SECFailure; |
123 | 0 | return (vector->p_RSA_PrivateKeyOp)(key, output, input); |
124 | 0 | } |
125 | | |
126 | | SECStatus |
127 | | RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, |
128 | | unsigned char *output, |
129 | | const unsigned char *input) |
130 | 0 | { |
131 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
132 | 0 | return SECFailure; |
133 | 0 | return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); |
134 | 0 | } |
135 | | |
136 | | SECStatus |
137 | | RSA_PrivateKeyCheck(const RSAPrivateKey *key) |
138 | 0 | { |
139 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
140 | 0 | return SECFailure; |
141 | 0 | return (vector->p_RSA_PrivateKeyCheck)(key); |
142 | 0 | } |
143 | | |
144 | | SECStatus |
145 | | DSA_NewKey(const PQGParams *params, DSAPrivateKey **privKey) |
146 | 0 | { |
147 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
148 | 0 | return SECFailure; |
149 | 0 | return (vector->p_DSA_NewKey)(params, privKey); |
150 | 0 | } |
151 | | |
152 | | SECStatus |
153 | | DSA_SignDigest(DSAPrivateKey *key, SECItem *signature, const SECItem *digest) |
154 | 0 | { |
155 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
156 | 0 | return SECFailure; |
157 | 0 | return (vector->p_DSA_SignDigest)(key, signature, digest); |
158 | 0 | } |
159 | | |
160 | | SECStatus |
161 | | DSA_VerifyDigest(DSAPublicKey *key, const SECItem *signature, |
162 | | const SECItem *digest) |
163 | 0 | { |
164 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
165 | 0 | return SECFailure; |
166 | 0 | return (vector->p_DSA_VerifyDigest)(key, signature, digest); |
167 | 0 | } |
168 | | |
169 | | SECStatus |
170 | | DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char *seed, |
171 | | DSAPrivateKey **privKey) |
172 | 0 | { |
173 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
174 | 0 | return SECFailure; |
175 | 0 | return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); |
176 | 0 | } |
177 | | |
178 | | SECStatus |
179 | | DSA_SignDigestWithSeed(DSAPrivateKey *key, SECItem *signature, |
180 | | const SECItem *digest, const unsigned char *seed) |
181 | 0 | { |
182 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
183 | 0 | return SECFailure; |
184 | 0 | return (vector->p_DSA_SignDigestWithSeed)(key, signature, digest, seed); |
185 | 0 | } |
186 | | |
187 | | SECStatus |
188 | | DSA_NewRandom(PLArenaPool *arena, const SECItem *q, SECItem *seed) |
189 | 0 | { |
190 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
191 | 0 | return SECFailure; |
192 | 0 | return (vector->p_DSA_NewRandom)(arena, q, seed); |
193 | 0 | } |
194 | | |
195 | | SECStatus |
196 | | DH_GenParam(int primeLen, DHParams **params) |
197 | 0 | { |
198 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
199 | 0 | return SECFailure; |
200 | 0 | return (vector->p_DH_GenParam)(primeLen, params); |
201 | 0 | } |
202 | | |
203 | | SECStatus |
204 | | DH_NewKey(DHParams *params, DHPrivateKey **privKey) |
205 | 0 | { |
206 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
207 | 0 | return SECFailure; |
208 | 0 | return (vector->p_DH_NewKey)(params, privKey); |
209 | 0 | } |
210 | | |
211 | | SECStatus |
212 | | DH_Derive(SECItem *publicValue, SECItem *prime, SECItem *privateValue, |
213 | | SECItem *derivedSecret, unsigned int maxOutBytes) |
214 | 0 | { |
215 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
216 | 0 | return SECFailure; |
217 | 0 | return (vector->p_DH_Derive)(publicValue, prime, privateValue, |
218 | 0 | derivedSecret, maxOutBytes); |
219 | 0 | } |
220 | | |
221 | | SECStatus |
222 | | KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, |
223 | | SECItem *private1, SECItem *private2, SECItem *derivedSecret) |
224 | 0 | { |
225 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
226 | 0 | return SECFailure; |
227 | 0 | return (vector->p_KEA_Derive)(prime, public1, public2, |
228 | 0 | private1, private2, derivedSecret); |
229 | 0 | } |
230 | | |
231 | | PRBool |
232 | | KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) |
233 | 0 | { |
234 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
235 | 0 | return PR_FALSE; |
236 | 0 | return (vector->p_KEA_Verify)(Y, prime, subPrime); |
237 | 0 | } |
238 | | |
239 | | RC4Context * |
240 | | RC4_CreateContext(const unsigned char *key, int len) |
241 | 0 | { |
242 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
243 | 0 | return NULL; |
244 | 0 | return (vector->p_RC4_CreateContext)(key, len); |
245 | 0 | } |
246 | | |
247 | | void |
248 | | RC4_DestroyContext(RC4Context *cx, PRBool freeit) |
249 | 0 | { |
250 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
251 | 0 | return; |
252 | 0 | (vector->p_RC4_DestroyContext)(cx, freeit); |
253 | 0 | } |
254 | | |
255 | | SECStatus |
256 | | RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, |
257 | | unsigned int maxOutputLen, const unsigned char *input, |
258 | | unsigned int inputLen) |
259 | 0 | { |
260 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
261 | 0 | return SECFailure; |
262 | 0 | return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
263 | 0 | inputLen); |
264 | 0 | } |
265 | | |
266 | | SECStatus |
267 | | RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, |
268 | | unsigned int maxOutputLen, const unsigned char *input, |
269 | | unsigned int inputLen) |
270 | 0 | { |
271 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
272 | 0 | return SECFailure; |
273 | 0 | return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
274 | 0 | inputLen); |
275 | 0 | } |
276 | | |
277 | | RC2Context * |
278 | | RC2_CreateContext(const unsigned char *key, unsigned int len, |
279 | | const unsigned char *iv, int mode, unsigned effectiveKeyLen) |
280 | 0 | { |
281 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
282 | 0 | return NULL; |
283 | 0 | return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); |
284 | 0 | } |
285 | | |
286 | | void |
287 | | RC2_DestroyContext(RC2Context *cx, PRBool freeit) |
288 | 0 | { |
289 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
290 | 0 | return; |
291 | 0 | (vector->p_RC2_DestroyContext)(cx, freeit); |
292 | 0 | } |
293 | | |
294 | | SECStatus |
295 | | RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, |
296 | | unsigned int maxOutputLen, const unsigned char *input, |
297 | | unsigned int inputLen) |
298 | 0 | { |
299 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
300 | 0 | return SECFailure; |
301 | 0 | return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
302 | 0 | inputLen); |
303 | 0 | } |
304 | | |
305 | | SECStatus |
306 | | RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, |
307 | | unsigned int maxOutputLen, const unsigned char *input, |
308 | | unsigned int inputLen) |
309 | 0 | { |
310 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
311 | 0 | return SECFailure; |
312 | 0 | return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
313 | 0 | inputLen); |
314 | 0 | } |
315 | | |
316 | | RC5Context * |
317 | | RC5_CreateContext(const SECItem *key, unsigned int rounds, |
318 | | unsigned int wordSize, const unsigned char *iv, int mode) |
319 | 0 | { |
320 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
321 | 0 | return NULL; |
322 | 0 | return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); |
323 | 0 | } |
324 | | |
325 | | void |
326 | | RC5_DestroyContext(RC5Context *cx, PRBool freeit) |
327 | 0 | { |
328 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
329 | 0 | return; |
330 | 0 | (vector->p_RC5_DestroyContext)(cx, freeit); |
331 | 0 | } |
332 | | |
333 | | SECStatus |
334 | | RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, |
335 | | unsigned int maxOutputLen, const unsigned char *input, |
336 | | unsigned int inputLen) |
337 | 0 | { |
338 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
339 | 0 | return SECFailure; |
340 | 0 | return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
341 | 0 | inputLen); |
342 | 0 | } |
343 | | |
344 | | SECStatus |
345 | | RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, |
346 | | unsigned int maxOutputLen, const unsigned char *input, |
347 | | unsigned int inputLen) |
348 | 0 | { |
349 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
350 | 0 | return SECFailure; |
351 | 0 | return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
352 | 0 | inputLen); |
353 | 0 | } |
354 | | |
355 | | DESContext * |
356 | | DES_CreateContext(const unsigned char *key, const unsigned char *iv, |
357 | | int mode, PRBool encrypt) |
358 | 0 | { |
359 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
360 | 0 | return NULL; |
361 | 0 | return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); |
362 | 0 | } |
363 | | |
364 | | void |
365 | | DES_DestroyContext(DESContext *cx, PRBool freeit) |
366 | 0 | { |
367 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
368 | 0 | return; |
369 | 0 | (vector->p_DES_DestroyContext)(cx, freeit); |
370 | 0 | } |
371 | | |
372 | | SECStatus |
373 | | DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, |
374 | | unsigned int maxOutputLen, const unsigned char *input, |
375 | | unsigned int inputLen) |
376 | 0 | { |
377 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
378 | 0 | return SECFailure; |
379 | 0 | return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
380 | 0 | inputLen); |
381 | 0 | } |
382 | | |
383 | | SECStatus |
384 | | DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, |
385 | | unsigned int maxOutputLen, const unsigned char *input, |
386 | | unsigned int inputLen) |
387 | 0 | { |
388 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
389 | 0 | return SECFailure; |
390 | 0 | return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
391 | 0 | inputLen); |
392 | 0 | } |
393 | | SEEDContext * |
394 | | SEED_CreateContext(const unsigned char *key, const unsigned char *iv, |
395 | | int mode, PRBool encrypt) |
396 | 0 | { |
397 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
398 | 0 | return NULL; |
399 | 0 | return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); |
400 | 0 | } |
401 | | |
402 | | void |
403 | | SEED_DestroyContext(SEEDContext *cx, PRBool freeit) |
404 | 0 | { |
405 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
406 | 0 | return; |
407 | 0 | (vector->p_SEED_DestroyContext)(cx, freeit); |
408 | 0 | } |
409 | | |
410 | | SECStatus |
411 | | SEED_Encrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, |
412 | | unsigned int maxOutputLen, const unsigned char *input, |
413 | | unsigned int inputLen) |
414 | 0 | { |
415 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
416 | 0 | return SECFailure; |
417 | 0 | return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
418 | 0 | inputLen); |
419 | 0 | } |
420 | | |
421 | | SECStatus |
422 | | SEED_Decrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, |
423 | | unsigned int maxOutputLen, const unsigned char *input, |
424 | | unsigned int inputLen) |
425 | 0 | { |
426 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
427 | 0 | return SECFailure; |
428 | 0 | return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
429 | 0 | inputLen); |
430 | 0 | } |
431 | | |
432 | | AESContext * |
433 | | AES_CreateContext(const unsigned char *key, const unsigned char *iv, |
434 | | int mode, int encrypt, |
435 | | unsigned int keylen, unsigned int blocklen) |
436 | 0 | { |
437 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
438 | 0 | return NULL; |
439 | 0 | return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, |
440 | 0 | blocklen); |
441 | 0 | } |
442 | | |
443 | | void |
444 | | AES_DestroyContext(AESContext *cx, PRBool freeit) |
445 | 0 | { |
446 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
447 | 0 | return; |
448 | 0 | (vector->p_AES_DestroyContext)(cx, freeit); |
449 | 0 | } |
450 | | |
451 | | SECStatus |
452 | | AES_Encrypt(AESContext *cx, unsigned char *output, |
453 | | unsigned int *outputLen, unsigned int maxOutputLen, |
454 | | const unsigned char *input, unsigned int inputLen) |
455 | 0 | { |
456 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
457 | 0 | return SECFailure; |
458 | 0 | return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, |
459 | 0 | input, inputLen); |
460 | 0 | } |
461 | | |
462 | | SECStatus |
463 | | AES_Decrypt(AESContext *cx, unsigned char *output, |
464 | | unsigned int *outputLen, unsigned int maxOutputLen, |
465 | | const unsigned char *input, unsigned int inputLen) |
466 | 0 | { |
467 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
468 | 0 | return SECFailure; |
469 | 0 | return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, |
470 | 0 | input, inputLen); |
471 | 0 | } |
472 | | |
473 | | SECStatus |
474 | | MD5_Hash(unsigned char *dest, const char *src) |
475 | 0 | { |
476 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
477 | 0 | return SECFailure; |
478 | 0 | return (vector->p_MD5_Hash)(dest, src); |
479 | 0 | } |
480 | | |
481 | | SECStatus |
482 | | MD5_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
483 | 0 | { |
484 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
485 | 0 | return SECFailure; |
486 | 0 | return (vector->p_MD5_HashBuf)(dest, src, src_length); |
487 | 0 | } |
488 | | |
489 | | MD5Context * |
490 | | MD5_NewContext(void) |
491 | 0 | { |
492 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
493 | 0 | return NULL; |
494 | 0 | return (vector->p_MD5_NewContext)(); |
495 | 0 | } |
496 | | |
497 | | void |
498 | | MD5_DestroyContext(MD5Context *cx, PRBool freeit) |
499 | 0 | { |
500 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
501 | 0 | return; |
502 | 0 | (vector->p_MD5_DestroyContext)(cx, freeit); |
503 | 0 | } |
504 | | |
505 | | void |
506 | | MD5_Begin(MD5Context *cx) |
507 | 0 | { |
508 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
509 | 0 | return; |
510 | 0 | (vector->p_MD5_Begin)(cx); |
511 | 0 | } |
512 | | |
513 | | void |
514 | | MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen) |
515 | 0 | { |
516 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
517 | 0 | return; |
518 | 0 | (vector->p_MD5_Update)(cx, input, inputLen); |
519 | 0 | } |
520 | | |
521 | | void |
522 | | MD5_End(MD5Context *cx, unsigned char *digest, |
523 | | unsigned int *digestLen, unsigned int maxDigestLen) |
524 | 0 | { |
525 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
526 | 0 | return; |
527 | 0 | (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); |
528 | 0 | } |
529 | | |
530 | | unsigned int |
531 | | MD5_FlattenSize(MD5Context *cx) |
532 | 0 | { |
533 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
534 | 0 | return 0; |
535 | 0 | return (vector->p_MD5_FlattenSize)(cx); |
536 | 0 | } |
537 | | |
538 | | SECStatus |
539 | | MD5_Flatten(MD5Context *cx, unsigned char *space) |
540 | 0 | { |
541 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
542 | 0 | return SECFailure; |
543 | 0 | return (vector->p_MD5_Flatten)(cx, space); |
544 | 0 | } |
545 | | |
546 | | MD5Context * |
547 | | MD5_Resurrect(unsigned char *space, void *arg) |
548 | 0 | { |
549 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
550 | 0 | return NULL; |
551 | 0 | return (vector->p_MD5_Resurrect)(space, arg); |
552 | 0 | } |
553 | | |
554 | | void |
555 | | MD5_TraceState(MD5Context *cx) |
556 | 0 | { |
557 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
558 | 0 | return; |
559 | 0 | (vector->p_MD5_TraceState)(cx); |
560 | 0 | } |
561 | | |
562 | | SECStatus |
563 | | MD2_Hash(unsigned char *dest, const char *src) |
564 | 0 | { |
565 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
566 | 0 | return SECFailure; |
567 | 0 | return (vector->p_MD2_Hash)(dest, src); |
568 | 0 | } |
569 | | |
570 | | MD2Context * |
571 | | MD2_NewContext(void) |
572 | 0 | { |
573 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
574 | 0 | return NULL; |
575 | 0 | return (vector->p_MD2_NewContext)(); |
576 | 0 | } |
577 | | |
578 | | void |
579 | | MD2_DestroyContext(MD2Context *cx, PRBool freeit) |
580 | 0 | { |
581 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
582 | 0 | return; |
583 | 0 | (vector->p_MD2_DestroyContext)(cx, freeit); |
584 | 0 | } |
585 | | |
586 | | void |
587 | | MD2_Begin(MD2Context *cx) |
588 | 0 | { |
589 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
590 | 0 | return; |
591 | 0 | (vector->p_MD2_Begin)(cx); |
592 | 0 | } |
593 | | |
594 | | void |
595 | | MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen) |
596 | 0 | { |
597 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
598 | 0 | return; |
599 | 0 | (vector->p_MD2_Update)(cx, input, inputLen); |
600 | 0 | } |
601 | | |
602 | | void |
603 | | MD2_End(MD2Context *cx, unsigned char *digest, |
604 | | unsigned int *digestLen, unsigned int maxDigestLen) |
605 | 0 | { |
606 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
607 | 0 | return; |
608 | 0 | (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); |
609 | 0 | } |
610 | | |
611 | | unsigned int |
612 | | MD2_FlattenSize(MD2Context *cx) |
613 | 0 | { |
614 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
615 | 0 | return 0; |
616 | 0 | return (vector->p_MD2_FlattenSize)(cx); |
617 | 0 | } |
618 | | |
619 | | SECStatus |
620 | | MD2_Flatten(MD2Context *cx, unsigned char *space) |
621 | 0 | { |
622 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
623 | 0 | return SECFailure; |
624 | 0 | return (vector->p_MD2_Flatten)(cx, space); |
625 | 0 | } |
626 | | |
627 | | MD2Context * |
628 | | MD2_Resurrect(unsigned char *space, void *arg) |
629 | 0 | { |
630 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
631 | 0 | return NULL; |
632 | 0 | return (vector->p_MD2_Resurrect)(space, arg); |
633 | 0 | } |
634 | | |
635 | | SECStatus |
636 | | SHA1_Hash(unsigned char *dest, const char *src) |
637 | 0 | { |
638 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
639 | 0 | return SECFailure; |
640 | 0 | return (vector->p_SHA1_Hash)(dest, src); |
641 | 0 | } |
642 | | |
643 | | SECStatus |
644 | | SHA1_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
645 | 0 | { |
646 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
647 | 0 | return SECFailure; |
648 | 0 | return (vector->p_SHA1_HashBuf)(dest, src, src_length); |
649 | 0 | } |
650 | | |
651 | | SHA1Context * |
652 | | SHA1_NewContext(void) |
653 | 0 | { |
654 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
655 | 0 | return NULL; |
656 | 0 | return (vector->p_SHA1_NewContext)(); |
657 | 0 | } |
658 | | |
659 | | void |
660 | | SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) |
661 | 0 | { |
662 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
663 | 0 | return; |
664 | 0 | (vector->p_SHA1_DestroyContext)(cx, freeit); |
665 | 0 | } |
666 | | |
667 | | void |
668 | | SHA1_Begin(SHA1Context *cx) |
669 | 0 | { |
670 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
671 | 0 | return; |
672 | 0 | (vector->p_SHA1_Begin)(cx); |
673 | 0 | } |
674 | | |
675 | | void |
676 | | SHA1_Update(SHA1Context *cx, const unsigned char *input, |
677 | | unsigned int inputLen) |
678 | 0 | { |
679 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
680 | 0 | return; |
681 | 0 | (vector->p_SHA1_Update)(cx, input, inputLen); |
682 | 0 | } |
683 | | |
684 | | void |
685 | | SHA1_End(SHA1Context *cx, unsigned char *digest, |
686 | | unsigned int *digestLen, unsigned int maxDigestLen) |
687 | 0 | { |
688 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
689 | 0 | return; |
690 | 0 | (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); |
691 | 0 | } |
692 | | |
693 | | void |
694 | | SHA1_TraceState(SHA1Context *cx) |
695 | 0 | { |
696 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
697 | 0 | return; |
698 | 0 | (vector->p_SHA1_TraceState)(cx); |
699 | 0 | } |
700 | | |
701 | | unsigned int |
702 | | SHA1_FlattenSize(SHA1Context *cx) |
703 | 0 | { |
704 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
705 | 0 | return 0; |
706 | 0 | return (vector->p_SHA1_FlattenSize)(cx); |
707 | 0 | } |
708 | | |
709 | | SECStatus |
710 | | SHA1_Flatten(SHA1Context *cx, unsigned char *space) |
711 | 0 | { |
712 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
713 | 0 | return SECFailure; |
714 | 0 | return (vector->p_SHA1_Flatten)(cx, space); |
715 | 0 | } |
716 | | |
717 | | SHA1Context * |
718 | | SHA1_Resurrect(unsigned char *space, void *arg) |
719 | 0 | { |
720 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
721 | 0 | return NULL; |
722 | 0 | return (vector->p_SHA1_Resurrect)(space, arg); |
723 | 0 | } |
724 | | |
725 | | SECStatus |
726 | | RNG_RNGInit(void) |
727 | 0 | { |
728 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
729 | 0 | return SECFailure; |
730 | 0 | return (vector->p_RNG_RNGInit)(); |
731 | 0 | } |
732 | | |
733 | | SECStatus |
734 | | RNG_RandomUpdate(const void *data, size_t bytes) |
735 | 0 | { |
736 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
737 | 0 | return SECFailure; |
738 | 0 | return (vector->p_RNG_RandomUpdate)(data, bytes); |
739 | 0 | } |
740 | | |
741 | | SECStatus |
742 | | RNG_GenerateGlobalRandomBytes(void *dest, size_t len) |
743 | 0 | { |
744 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
745 | 0 | return SECFailure; |
746 | 0 | return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); |
747 | 0 | } |
748 | | |
749 | | void |
750 | | RNG_RNGShutdown(void) |
751 | 0 | { |
752 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
753 | 0 | return; |
754 | 0 | (vector->p_RNG_RNGShutdown)(); |
755 | 0 | } |
756 | | |
757 | | SECStatus |
758 | | PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) |
759 | 0 | { |
760 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
761 | 0 | return SECFailure; |
762 | 0 | return (vector->p_PQG_ParamGen)(j, pParams, pVfy); |
763 | 0 | } |
764 | | |
765 | | SECStatus |
766 | | PQG_ParamGenSeedLen(unsigned int j, unsigned int seedBytes, |
767 | | PQGParams **pParams, PQGVerify **pVfy) |
768 | 0 | { |
769 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
770 | 0 | return SECFailure; |
771 | 0 | return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); |
772 | 0 | } |
773 | | |
774 | | SECStatus |
775 | | PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, |
776 | | SECStatus *result) |
777 | 0 | { |
778 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
779 | 0 | return SECFailure; |
780 | 0 | return (vector->p_PQG_VerifyParams)(params, vfy, result); |
781 | 0 | } |
782 | | |
783 | | void |
784 | | PQG_DestroyParams(PQGParams *params) |
785 | 0 | { |
786 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
787 | 0 | return; |
788 | 0 | (vector->p_PQG_DestroyParams)(params); |
789 | 0 | } |
790 | | |
791 | | void |
792 | | PQG_DestroyVerify(PQGVerify *vfy) |
793 | 0 | { |
794 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
795 | 0 | return; |
796 | 0 | (vector->p_PQG_DestroyVerify)(vfy); |
797 | 0 | } |
798 | | |
799 | | void |
800 | | BL_Cleanup(void) |
801 | 0 | { |
802 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
803 | 0 | return; |
804 | 0 | (vector->p_BL_Cleanup)(); |
805 | 0 | } |
806 | | |
807 | | void |
808 | | BL_Unload(void) |
809 | 0 | { |
810 | 0 | /* This function is not thread-safe, but doesn't need to be, because it is |
811 | 0 | * only called from functions that are also defined as not thread-safe, |
812 | 0 | * namely C_Finalize in softoken, and the SSL bypass shutdown callback called |
813 | 0 | * from NSS_Shutdown. */ |
814 | 0 | char *disableUnload = NULL; |
815 | 0 | vector = NULL; |
816 | 0 | disableUnload = PR_GetEnvSecure("NSS_DISABLE_UNLOAD"); |
817 | 0 | if (blLib && !disableUnload) { |
818 | | #ifdef DEBUG |
819 | | PRStatus status = PR_UnloadLibrary(blLib); |
820 | | PORT_Assert(PR_SUCCESS == status); |
821 | | #else |
822 | | PR_UnloadLibrary(blLib); |
823 | 0 | #endif |
824 | 0 | } |
825 | 0 | blLib = NULL; |
826 | 0 | loadFreeBLOnce = pristineCallOnce; |
827 | 0 | } |
828 | | |
829 | | /* ============== New for 3.003 =============================== */ |
830 | | |
831 | | SECStatus |
832 | | SHA256_Hash(unsigned char *dest, const char *src) |
833 | 0 | { |
834 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
835 | 0 | return SECFailure; |
836 | 0 | return (vector->p_SHA256_Hash)(dest, src); |
837 | 0 | } |
838 | | |
839 | | SECStatus |
840 | | SHA256_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
841 | 0 | { |
842 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
843 | 0 | return SECFailure; |
844 | 0 | return (vector->p_SHA256_HashBuf)(dest, src, src_length); |
845 | 0 | } |
846 | | |
847 | | SHA256Context * |
848 | | SHA256_NewContext(void) |
849 | 0 | { |
850 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
851 | 0 | return NULL; |
852 | 0 | return (vector->p_SHA256_NewContext)(); |
853 | 0 | } |
854 | | |
855 | | void |
856 | | SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) |
857 | 0 | { |
858 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
859 | 0 | return; |
860 | 0 | (vector->p_SHA256_DestroyContext)(cx, freeit); |
861 | 0 | } |
862 | | |
863 | | void |
864 | | SHA256_Begin(SHA256Context *cx) |
865 | 0 | { |
866 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
867 | 0 | return; |
868 | 0 | (vector->p_SHA256_Begin)(cx); |
869 | 0 | } |
870 | | |
871 | | void |
872 | | SHA256_Update(SHA256Context *cx, const unsigned char *input, |
873 | | unsigned int inputLen) |
874 | 0 | { |
875 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
876 | 0 | return; |
877 | 0 | (vector->p_SHA256_Update)(cx, input, inputLen); |
878 | 0 | } |
879 | | |
880 | | void |
881 | | SHA256_End(SHA256Context *cx, unsigned char *digest, |
882 | | unsigned int *digestLen, unsigned int maxDigestLen) |
883 | 0 | { |
884 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
885 | 0 | return; |
886 | 0 | (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); |
887 | 0 | } |
888 | | |
889 | | void |
890 | | SHA256_TraceState(SHA256Context *cx) |
891 | 0 | { |
892 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
893 | 0 | return; |
894 | 0 | (vector->p_SHA256_TraceState)(cx); |
895 | 0 | } |
896 | | |
897 | | unsigned int |
898 | | SHA256_FlattenSize(SHA256Context *cx) |
899 | 0 | { |
900 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
901 | 0 | return 0; |
902 | 0 | return (vector->p_SHA256_FlattenSize)(cx); |
903 | 0 | } |
904 | | |
905 | | SECStatus |
906 | | SHA256_Flatten(SHA256Context *cx, unsigned char *space) |
907 | 0 | { |
908 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
909 | 0 | return SECFailure; |
910 | 0 | return (vector->p_SHA256_Flatten)(cx, space); |
911 | 0 | } |
912 | | |
913 | | SHA256Context * |
914 | | SHA256_Resurrect(unsigned char *space, void *arg) |
915 | 0 | { |
916 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
917 | 0 | return NULL; |
918 | 0 | return (vector->p_SHA256_Resurrect)(space, arg); |
919 | 0 | } |
920 | | |
921 | | SECStatus |
922 | | SHA512_Hash(unsigned char *dest, const char *src) |
923 | 0 | { |
924 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
925 | 0 | return SECFailure; |
926 | 0 | return (vector->p_SHA512_Hash)(dest, src); |
927 | 0 | } |
928 | | |
929 | | SECStatus |
930 | | SHA512_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
931 | 0 | { |
932 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
933 | 0 | return SECFailure; |
934 | 0 | return (vector->p_SHA512_HashBuf)(dest, src, src_length); |
935 | 0 | } |
936 | | |
937 | | SHA512Context * |
938 | | SHA512_NewContext(void) |
939 | 0 | { |
940 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
941 | 0 | return NULL; |
942 | 0 | return (vector->p_SHA512_NewContext)(); |
943 | 0 | } |
944 | | |
945 | | void |
946 | | SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) |
947 | 0 | { |
948 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
949 | 0 | return; |
950 | 0 | (vector->p_SHA512_DestroyContext)(cx, freeit); |
951 | 0 | } |
952 | | |
953 | | void |
954 | | SHA512_Begin(SHA512Context *cx) |
955 | 0 | { |
956 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
957 | 0 | return; |
958 | 0 | (vector->p_SHA512_Begin)(cx); |
959 | 0 | } |
960 | | |
961 | | void |
962 | | SHA512_Update(SHA512Context *cx, const unsigned char *input, |
963 | | unsigned int inputLen) |
964 | 0 | { |
965 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
966 | 0 | return; |
967 | 0 | (vector->p_SHA512_Update)(cx, input, inputLen); |
968 | 0 | } |
969 | | |
970 | | void |
971 | | SHA512_End(SHA512Context *cx, unsigned char *digest, |
972 | | unsigned int *digestLen, unsigned int maxDigestLen) |
973 | 0 | { |
974 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
975 | 0 | return; |
976 | 0 | (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); |
977 | 0 | } |
978 | | |
979 | | void |
980 | | SHA512_TraceState(SHA512Context *cx) |
981 | 0 | { |
982 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
983 | 0 | return; |
984 | 0 | (vector->p_SHA512_TraceState)(cx); |
985 | 0 | } |
986 | | |
987 | | unsigned int |
988 | | SHA512_FlattenSize(SHA512Context *cx) |
989 | 0 | { |
990 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
991 | 0 | return 0; |
992 | 0 | return (vector->p_SHA512_FlattenSize)(cx); |
993 | 0 | } |
994 | | |
995 | | SECStatus |
996 | | SHA512_Flatten(SHA512Context *cx, unsigned char *space) |
997 | 0 | { |
998 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
999 | 0 | return SECFailure; |
1000 | 0 | return (vector->p_SHA512_Flatten)(cx, space); |
1001 | 0 | } |
1002 | | |
1003 | | SHA512Context * |
1004 | | SHA512_Resurrect(unsigned char *space, void *arg) |
1005 | 0 | { |
1006 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1007 | 0 | return NULL; |
1008 | 0 | return (vector->p_SHA512_Resurrect)(space, arg); |
1009 | 0 | } |
1010 | | |
1011 | | SECStatus |
1012 | | SHA384_Hash(unsigned char *dest, const char *src) |
1013 | 0 | { |
1014 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1015 | 0 | return SECFailure; |
1016 | 0 | return (vector->p_SHA384_Hash)(dest, src); |
1017 | 0 | } |
1018 | | |
1019 | | SECStatus |
1020 | | SHA384_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
1021 | 0 | { |
1022 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1023 | 0 | return SECFailure; |
1024 | 0 | return (vector->p_SHA384_HashBuf)(dest, src, src_length); |
1025 | 0 | } |
1026 | | |
1027 | | SHA384Context * |
1028 | | SHA384_NewContext(void) |
1029 | 0 | { |
1030 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1031 | 0 | return NULL; |
1032 | 0 | return (vector->p_SHA384_NewContext)(); |
1033 | 0 | } |
1034 | | |
1035 | | void |
1036 | | SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) |
1037 | 0 | { |
1038 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1039 | 0 | return; |
1040 | 0 | (vector->p_SHA384_DestroyContext)(cx, freeit); |
1041 | 0 | } |
1042 | | |
1043 | | void |
1044 | | SHA384_Begin(SHA384Context *cx) |
1045 | 0 | { |
1046 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1047 | 0 | return; |
1048 | 0 | (vector->p_SHA384_Begin)(cx); |
1049 | 0 | } |
1050 | | |
1051 | | void |
1052 | | SHA384_Update(SHA384Context *cx, const unsigned char *input, |
1053 | | unsigned int inputLen) |
1054 | 0 | { |
1055 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1056 | 0 | return; |
1057 | 0 | (vector->p_SHA384_Update)(cx, input, inputLen); |
1058 | 0 | } |
1059 | | |
1060 | | void |
1061 | | SHA384_End(SHA384Context *cx, unsigned char *digest, |
1062 | | unsigned int *digestLen, unsigned int maxDigestLen) |
1063 | 0 | { |
1064 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1065 | 0 | return; |
1066 | 0 | (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); |
1067 | 0 | } |
1068 | | |
1069 | | void |
1070 | | SHA384_TraceState(SHA384Context *cx) |
1071 | 0 | { |
1072 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1073 | 0 | return; |
1074 | 0 | (vector->p_SHA384_TraceState)(cx); |
1075 | 0 | } |
1076 | | |
1077 | | unsigned int |
1078 | | SHA384_FlattenSize(SHA384Context *cx) |
1079 | 0 | { |
1080 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1081 | 0 | return 0; |
1082 | 0 | return (vector->p_SHA384_FlattenSize)(cx); |
1083 | 0 | } |
1084 | | |
1085 | | SECStatus |
1086 | | SHA384_Flatten(SHA384Context *cx, unsigned char *space) |
1087 | 0 | { |
1088 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1089 | 0 | return SECFailure; |
1090 | 0 | return (vector->p_SHA384_Flatten)(cx, space); |
1091 | 0 | } |
1092 | | |
1093 | | SHA384Context * |
1094 | | SHA384_Resurrect(unsigned char *space, void *arg) |
1095 | 0 | { |
1096 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1097 | 0 | return NULL; |
1098 | 0 | return (vector->p_SHA384_Resurrect)(space, arg); |
1099 | 0 | } |
1100 | | |
1101 | | AESKeyWrapContext * |
1102 | | AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv, |
1103 | | int encrypt, unsigned int keylen) |
1104 | 0 | { |
1105 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1106 | 0 | return NULL; |
1107 | 0 | return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); |
1108 | 0 | } |
1109 | | |
1110 | | void |
1111 | | AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) |
1112 | 0 | { |
1113 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1114 | 0 | return; |
1115 | 0 | vector->p_AESKeyWrap_DestroyContext(cx, freeit); |
1116 | 0 | } |
1117 | | |
1118 | | SECStatus |
1119 | | AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, |
1120 | | unsigned int *outputLen, unsigned int maxOutputLen, |
1121 | | const unsigned char *input, unsigned int inputLen) |
1122 | 0 | { |
1123 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1124 | 0 | return SECFailure; |
1125 | 0 | return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, |
1126 | 0 | input, inputLen); |
1127 | 0 | } |
1128 | | SECStatus |
1129 | | AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, |
1130 | | unsigned int *outputLen, unsigned int maxOutputLen, |
1131 | | const unsigned char *input, unsigned int inputLen) |
1132 | 0 | { |
1133 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1134 | 0 | return SECFailure; |
1135 | 0 | return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, |
1136 | 0 | input, inputLen); |
1137 | 0 | } |
1138 | | |
1139 | | PRBool |
1140 | | BLAPI_SHVerify(const char *name, PRFuncPtr addr) |
1141 | 0 | { |
1142 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1143 | 0 | return PR_FALSE; |
1144 | 0 | return vector->p_BLAPI_SHVerify(name, addr); |
1145 | 0 | } |
1146 | | |
1147 | | /* |
1148 | | * The Caller is expected to pass NULL as the name, which will |
1149 | | * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. Pass the real |
1150 | | * name of the shared library we loaded (the static libraryName set |
1151 | | * in freebl_LoadDSO) to p_BLAPI_VerifySelf. |
1152 | | */ |
1153 | | PRBool |
1154 | | BLAPI_VerifySelf(const char *name) |
1155 | 0 | { |
1156 | 0 | PORT_Assert(!name); |
1157 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1158 | 0 | return PR_FALSE; |
1159 | 0 | return vector->p_BLAPI_VerifySelf(libraryName); |
1160 | 0 | } |
1161 | | |
1162 | | /* ============== New for 3.006 =============================== */ |
1163 | | |
1164 | | SECStatus |
1165 | | EC_NewKey(ECParams *params, ECPrivateKey **privKey) |
1166 | 0 | { |
1167 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1168 | 0 | return SECFailure; |
1169 | 0 | return (vector->p_EC_NewKey)(params, privKey); |
1170 | 0 | } |
1171 | | |
1172 | | SECStatus |
1173 | | EC_NewKeyFromSeed(ECParams *params, ECPrivateKey **privKey, |
1174 | | const unsigned char *seed, int seedlen) |
1175 | 0 | { |
1176 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1177 | 0 | return SECFailure; |
1178 | 0 | return (vector->p_EC_NewKeyFromSeed)(params, privKey, seed, seedlen); |
1179 | 0 | } |
1180 | | |
1181 | | SECStatus |
1182 | | EC_ValidatePublicKey(ECParams *params, SECItem *publicValue) |
1183 | 0 | { |
1184 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1185 | 0 | return SECFailure; |
1186 | 0 | return (vector->p_EC_ValidatePublicKey)(params, publicValue); |
1187 | 0 | } |
1188 | | |
1189 | | SECStatus |
1190 | | ECDH_Derive(SECItem *publicValue, ECParams *params, SECItem *privateValue, |
1191 | | PRBool withCofactor, SECItem *derivedSecret) |
1192 | 0 | { |
1193 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1194 | 0 | return SECFailure; |
1195 | 0 | return (vector->p_ECDH_Derive)(publicValue, params, privateValue, |
1196 | 0 | withCofactor, derivedSecret); |
1197 | 0 | } |
1198 | | |
1199 | | SECStatus |
1200 | | ECDSA_SignDigest(ECPrivateKey *key, SECItem *signature, |
1201 | | const SECItem *digest) |
1202 | 0 | { |
1203 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1204 | 0 | return SECFailure; |
1205 | 0 | return (vector->p_ECDSA_SignDigest)(key, signature, digest); |
1206 | 0 | } |
1207 | | |
1208 | | SECStatus |
1209 | | ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, |
1210 | | const SECItem *digest) |
1211 | 0 | { |
1212 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1213 | 0 | return SECFailure; |
1214 | 0 | return (vector->p_ECDSA_VerifyDigest)(key, signature, digest); |
1215 | 0 | } |
1216 | | |
1217 | | SECStatus |
1218 | | ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, |
1219 | | const SECItem *digest, const unsigned char *seed, const int seedlen) |
1220 | 0 | { |
1221 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1222 | 0 | return SECFailure; |
1223 | 0 | return (vector->p_ECDSA_SignDigestWithSeed)(key, signature, digest, |
1224 | 0 | seed, seedlen); |
1225 | 0 | } |
1226 | | |
1227 | | /* ============== New for 3.008 =============================== */ |
1228 | | |
1229 | | AESContext * |
1230 | | AES_AllocateContext(void) |
1231 | 0 | { |
1232 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1233 | 0 | return NULL; |
1234 | 0 | return (vector->p_AES_AllocateContext)(); |
1235 | 0 | } |
1236 | | |
1237 | | AESKeyWrapContext * |
1238 | | AESKeyWrap_AllocateContext(void) |
1239 | 0 | { |
1240 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1241 | 0 | return NULL; |
1242 | 0 | return (vector->p_AESKeyWrap_AllocateContext)(); |
1243 | 0 | } |
1244 | | |
1245 | | DESContext * |
1246 | | DES_AllocateContext(void) |
1247 | 0 | { |
1248 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1249 | 0 | return NULL; |
1250 | 0 | return (vector->p_DES_AllocateContext)(); |
1251 | 0 | } |
1252 | | |
1253 | | RC2Context * |
1254 | | RC2_AllocateContext(void) |
1255 | 0 | { |
1256 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1257 | 0 | return NULL; |
1258 | 0 | return (vector->p_RC2_AllocateContext)(); |
1259 | 0 | } |
1260 | | |
1261 | | RC4Context * |
1262 | | RC4_AllocateContext(void) |
1263 | 0 | { |
1264 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1265 | 0 | return NULL; |
1266 | 0 | return (vector->p_RC4_AllocateContext)(); |
1267 | 0 | } |
1268 | | |
1269 | | SECStatus |
1270 | | AES_InitContext(AESContext *cx, const unsigned char *key, |
1271 | | unsigned int keylen, const unsigned char *iv, int mode, |
1272 | | unsigned int encrypt, unsigned int blocklen) |
1273 | 0 | { |
1274 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1275 | 0 | return SECFailure; |
1276 | 0 | return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, |
1277 | 0 | blocklen); |
1278 | 0 | } |
1279 | | |
1280 | | SECStatus |
1281 | | AESKeyWrap_InitContext(AESKeyWrapContext *cx, const unsigned char *key, |
1282 | | unsigned int keylen, const unsigned char *iv, int mode, |
1283 | | unsigned int encrypt, unsigned int blocklen) |
1284 | 0 | { |
1285 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1286 | 0 | return SECFailure; |
1287 | 0 | return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, |
1288 | 0 | encrypt, blocklen); |
1289 | 0 | } |
1290 | | |
1291 | | SECStatus |
1292 | | DES_InitContext(DESContext *cx, const unsigned char *key, |
1293 | | unsigned int keylen, const unsigned char *iv, int mode, |
1294 | | unsigned int encrypt, unsigned int xtra) |
1295 | 0 | { |
1296 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1297 | 0 | return SECFailure; |
1298 | 0 | return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); |
1299 | 0 | } |
1300 | | |
1301 | | SECStatus |
1302 | | SEED_InitContext(SEEDContext *cx, const unsigned char *key, |
1303 | | unsigned int keylen, const unsigned char *iv, int mode, |
1304 | | unsigned int encrypt, unsigned int xtra) |
1305 | 0 | { |
1306 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1307 | 0 | return SECFailure; |
1308 | 0 | return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); |
1309 | 0 | } |
1310 | | |
1311 | | SECStatus |
1312 | | RC2_InitContext(RC2Context *cx, const unsigned char *key, |
1313 | | unsigned int keylen, const unsigned char *iv, int mode, |
1314 | | unsigned int effectiveKeyLen, unsigned int xtra) |
1315 | 0 | { |
1316 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1317 | 0 | return SECFailure; |
1318 | 0 | return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, |
1319 | 0 | effectiveKeyLen, xtra); |
1320 | 0 | } |
1321 | | |
1322 | | SECStatus |
1323 | | RC4_InitContext(RC4Context *cx, const unsigned char *key, |
1324 | | unsigned int keylen, const unsigned char *x1, int x2, |
1325 | | unsigned int x3, unsigned int x4) |
1326 | 0 | { |
1327 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1328 | 0 | return SECFailure; |
1329 | 0 | return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); |
1330 | 0 | } |
1331 | | |
1332 | | void |
1333 | | MD2_Clone(MD2Context *dest, MD2Context *src) |
1334 | 0 | { |
1335 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1336 | 0 | return; |
1337 | 0 | (vector->p_MD2_Clone)(dest, src); |
1338 | 0 | } |
1339 | | |
1340 | | void |
1341 | | MD5_Clone(MD5Context *dest, MD5Context *src) |
1342 | 0 | { |
1343 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1344 | 0 | return; |
1345 | 0 | (vector->p_MD5_Clone)(dest, src); |
1346 | 0 | } |
1347 | | |
1348 | | void |
1349 | | SHA1_Clone(SHA1Context *dest, SHA1Context *src) |
1350 | 0 | { |
1351 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1352 | 0 | return; |
1353 | 0 | (vector->p_SHA1_Clone)(dest, src); |
1354 | 0 | } |
1355 | | |
1356 | | void |
1357 | | SHA256_Clone(SHA256Context *dest, SHA256Context *src) |
1358 | 0 | { |
1359 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1360 | 0 | return; |
1361 | 0 | (vector->p_SHA256_Clone)(dest, src); |
1362 | 0 | } |
1363 | | |
1364 | | void |
1365 | | SHA384_Clone(SHA384Context *dest, SHA384Context *src) |
1366 | 0 | { |
1367 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1368 | 0 | return; |
1369 | 0 | (vector->p_SHA384_Clone)(dest, src); |
1370 | 0 | } |
1371 | | |
1372 | | void |
1373 | | SHA512_Clone(SHA512Context *dest, SHA512Context *src) |
1374 | 0 | { |
1375 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1376 | 0 | return; |
1377 | 0 | (vector->p_SHA512_Clone)(dest, src); |
1378 | 0 | } |
1379 | | |
1380 | | SECStatus |
1381 | | TLS_PRF(const SECItem *secret, const char *label, |
1382 | | SECItem *seed, SECItem *result, PRBool isFIPS) |
1383 | 0 | { |
1384 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1385 | 0 | return SECFailure; |
1386 | 0 | return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); |
1387 | 0 | } |
1388 | | |
1389 | | const SECHashObject * |
1390 | | HASH_GetRawHashObject(HASH_HashType hashType) |
1391 | 0 | { |
1392 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1393 | 0 | return NULL; |
1394 | 0 | return (vector->p_HASH_GetRawHashObject)(hashType); |
1395 | 0 | } |
1396 | | |
1397 | | void |
1398 | | HMAC_Destroy(HMACContext *cx, PRBool freeit) |
1399 | 0 | { |
1400 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1401 | 0 | return; |
1402 | 0 | (vector->p_HMAC_Destroy)(cx, freeit); |
1403 | 0 | } |
1404 | | |
1405 | | HMACContext * |
1406 | | HMAC_Create(const SECHashObject *hashObj, const unsigned char *secret, |
1407 | | unsigned int secret_len, PRBool isFIPS) |
1408 | 0 | { |
1409 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1410 | 0 | return NULL; |
1411 | 0 | return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); |
1412 | 0 | } |
1413 | | |
1414 | | SECStatus |
1415 | | HMAC_Init(HMACContext *cx, const SECHashObject *hashObj, |
1416 | | const unsigned char *secret, unsigned int secret_len, PRBool isFIPS) |
1417 | 0 | { |
1418 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1419 | 0 | return SECFailure; |
1420 | 0 | return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); |
1421 | 0 | } |
1422 | | |
1423 | | void |
1424 | | HMAC_Begin(HMACContext *cx) |
1425 | 0 | { |
1426 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1427 | 0 | return; |
1428 | 0 | (vector->p_HMAC_Begin)(cx); |
1429 | 0 | } |
1430 | | |
1431 | | void |
1432 | | HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) |
1433 | 0 | { |
1434 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1435 | 0 | return; |
1436 | 0 | (vector->p_HMAC_Update)(cx, data, data_len); |
1437 | 0 | } |
1438 | | |
1439 | | SECStatus |
1440 | | HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, |
1441 | | unsigned int max_result_len) |
1442 | 0 | { |
1443 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1444 | 0 | return SECFailure; |
1445 | 0 | return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); |
1446 | 0 | } |
1447 | | |
1448 | | HMACContext * |
1449 | | HMAC_Clone(HMACContext *cx) |
1450 | 0 | { |
1451 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1452 | 0 | return NULL; |
1453 | 0 | return (vector->p_HMAC_Clone)(cx); |
1454 | 0 | } |
1455 | | |
1456 | | void |
1457 | | RNG_SystemInfoForRNG(void) |
1458 | 0 | { |
1459 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1460 | 0 | return; |
1461 | 0 | (vector->p_RNG_SystemInfoForRNG)(); |
1462 | 0 | } |
1463 | | |
1464 | | SECStatus |
1465 | | FIPS186Change_GenerateX(unsigned char *XKEY, const unsigned char *XSEEDj, |
1466 | | unsigned char *x_j) |
1467 | 0 | { |
1468 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1469 | 0 | return SECFailure; |
1470 | 0 | return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); |
1471 | 0 | } |
1472 | | |
1473 | | SECStatus |
1474 | | FIPS186Change_ReduceModQForDSA(const unsigned char *w, |
1475 | | const unsigned char *q, |
1476 | | unsigned char *xj) |
1477 | 0 | { |
1478 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1479 | 0 | return SECFailure; |
1480 | 0 | return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); |
1481 | 0 | } |
1482 | | |
1483 | | /* === new for Camellia === */ |
1484 | | SECStatus |
1485 | | Camellia_InitContext(CamelliaContext *cx, const unsigned char *key, |
1486 | | unsigned int keylen, const unsigned char *iv, int mode, |
1487 | | unsigned int encrypt, unsigned int unused) |
1488 | 0 | { |
1489 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1490 | 0 | return SECFailure; |
1491 | 0 | return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, |
1492 | 0 | unused); |
1493 | 0 | } |
1494 | | |
1495 | | CamelliaContext * |
1496 | | Camellia_AllocateContext(void) |
1497 | 0 | { |
1498 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1499 | 0 | return NULL; |
1500 | 0 | return (vector->p_Camellia_AllocateContext)(); |
1501 | 0 | } |
1502 | | |
1503 | | CamelliaContext * |
1504 | | Camellia_CreateContext(const unsigned char *key, const unsigned char *iv, |
1505 | | int mode, int encrypt, |
1506 | | unsigned int keylen) |
1507 | 0 | { |
1508 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1509 | 0 | return NULL; |
1510 | 0 | return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); |
1511 | 0 | } |
1512 | | |
1513 | | void |
1514 | | Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) |
1515 | 0 | { |
1516 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1517 | 0 | return; |
1518 | 0 | (vector->p_Camellia_DestroyContext)(cx, freeit); |
1519 | 0 | } |
1520 | | |
1521 | | SECStatus |
1522 | | Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, |
1523 | | unsigned int *outputLen, unsigned int maxOutputLen, |
1524 | | const unsigned char *input, unsigned int inputLen) |
1525 | 0 | { |
1526 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1527 | 0 | return SECFailure; |
1528 | 0 | return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen, |
1529 | 0 | input, inputLen); |
1530 | 0 | } |
1531 | | |
1532 | | SECStatus |
1533 | | Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, |
1534 | | unsigned int *outputLen, unsigned int maxOutputLen, |
1535 | | const unsigned char *input, unsigned int inputLen) |
1536 | 0 | { |
1537 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1538 | 0 | return SECFailure; |
1539 | 0 | return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen, |
1540 | 0 | input, inputLen); |
1541 | 0 | } |
1542 | | |
1543 | | void |
1544 | | BL_SetForkState(PRBool forked) |
1545 | 0 | { |
1546 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1547 | 0 | return; |
1548 | 0 | (vector->p_BL_SetForkState)(forked); |
1549 | 0 | } |
1550 | | |
1551 | | SECStatus |
1552 | | PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, |
1553 | | const PRUint8 *nonce, unsigned int nonce_len, |
1554 | | const PRUint8 *personal_string, unsigned int ps_len) |
1555 | 0 | { |
1556 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1557 | 0 | return SECFailure; |
1558 | 0 | return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, |
1559 | 0 | nonce, nonce_len, |
1560 | 0 | personal_string, ps_len); |
1561 | 0 | } |
1562 | | |
1563 | | SECStatus |
1564 | | PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, |
1565 | | const PRUint8 *additional, unsigned int additional_len) |
1566 | 0 | { |
1567 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1568 | 0 | return SECFailure; |
1569 | 0 | return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, |
1570 | 0 | additional, additional_len); |
1571 | 0 | } |
1572 | | |
1573 | | SECStatus |
1574 | | PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, |
1575 | | const PRUint8 *additional, unsigned int additional_len) |
1576 | 0 | { |
1577 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1578 | 0 | return SECFailure; |
1579 | 0 | return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, |
1580 | 0 | additional, additional_len); |
1581 | 0 | } |
1582 | | |
1583 | | SECStatus |
1584 | | PRNGTEST_Uninstantiate() |
1585 | 0 | { |
1586 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1587 | 0 | return SECFailure; |
1588 | 0 | return (vector->p_PRNGTEST_Uninstantiate)(); |
1589 | 0 | } |
1590 | | |
1591 | | SECStatus |
1592 | | RSA_PopulatePrivateKey(RSAPrivateKey *key) |
1593 | 0 | { |
1594 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1595 | 0 | return SECFailure; |
1596 | 0 | return (vector->p_RSA_PopulatePrivateKey)(key); |
1597 | 0 | } |
1598 | | |
1599 | | SECStatus |
1600 | | JPAKE_Sign(PLArenaPool *arena, const PQGParams *pqg, HASH_HashType hashType, |
1601 | | const SECItem *signerID, const SECItem *x, |
1602 | | const SECItem *testRandom, const SECItem *gxIn, SECItem *gxOut, |
1603 | | SECItem *gv, SECItem *r) |
1604 | 0 | { |
1605 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1606 | 0 | return SECFailure; |
1607 | 0 | return (vector->p_JPAKE_Sign)(arena, pqg, hashType, signerID, x, |
1608 | 0 | testRandom, gxIn, gxOut, gv, r); |
1609 | 0 | } |
1610 | | |
1611 | | SECStatus |
1612 | | JPAKE_Verify(PLArenaPool *arena, const PQGParams *pqg, |
1613 | | HASH_HashType hashType, const SECItem *signerID, |
1614 | | const SECItem *peerID, const SECItem *gx, |
1615 | | const SECItem *gv, const SECItem *r) |
1616 | 0 | { |
1617 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1618 | 0 | return SECFailure; |
1619 | 0 | return (vector->p_JPAKE_Verify)(arena, pqg, hashType, signerID, peerID, |
1620 | 0 | gx, gv, r); |
1621 | 0 | } |
1622 | | |
1623 | | SECStatus |
1624 | | JPAKE_Round2(PLArenaPool *arena, const SECItem *p, const SECItem *q, |
1625 | | const SECItem *gx1, const SECItem *gx3, const SECItem *gx4, |
1626 | | SECItem *base, const SECItem *x2, const SECItem *s, SECItem *x2s) |
1627 | 0 | { |
1628 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1629 | 0 | return SECFailure; |
1630 | 0 | return (vector->p_JPAKE_Round2)(arena, p, q, gx1, gx3, gx4, base, x2, s, x2s); |
1631 | 0 | } |
1632 | | |
1633 | | SECStatus |
1634 | | JPAKE_Final(PLArenaPool *arena, const SECItem *p, const SECItem *q, |
1635 | | const SECItem *x2, const SECItem *gx4, const SECItem *x2s, |
1636 | | const SECItem *B, SECItem *K) |
1637 | 0 | { |
1638 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1639 | 0 | return SECFailure; |
1640 | 0 | return (vector->p_JPAKE_Final)(arena, p, q, x2, gx4, x2s, B, K); |
1641 | 0 | } |
1642 | | |
1643 | | SECStatus |
1644 | | TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, const char *label, |
1645 | | SECItem *seed, SECItem *result, PRBool isFIPS) |
1646 | 0 | { |
1647 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1648 | 0 | return SECFailure; |
1649 | 0 | return (vector->p_TLS_P_hash)(hashAlg, secret, label, seed, result, isFIPS); |
1650 | 0 | } |
1651 | | |
1652 | | SECStatus |
1653 | | SHA224_Hash(unsigned char *dest, const char *src) |
1654 | 0 | { |
1655 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1656 | 0 | return SECFailure; |
1657 | 0 | return (vector->p_SHA224_Hash)(dest, src); |
1658 | 0 | } |
1659 | | |
1660 | | SECStatus |
1661 | | SHA224_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) |
1662 | 0 | { |
1663 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1664 | 0 | return SECFailure; |
1665 | 0 | return (vector->p_SHA224_HashBuf)(dest, src, src_length); |
1666 | 0 | } |
1667 | | |
1668 | | SHA224Context * |
1669 | | SHA224_NewContext(void) |
1670 | 0 | { |
1671 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1672 | 0 | return NULL; |
1673 | 0 | return (vector->p_SHA224_NewContext)(); |
1674 | 0 | } |
1675 | | |
1676 | | void |
1677 | | SHA224_DestroyContext(SHA224Context *cx, PRBool freeit) |
1678 | 0 | { |
1679 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1680 | 0 | return; |
1681 | 0 | (vector->p_SHA224_DestroyContext)(cx, freeit); |
1682 | 0 | } |
1683 | | |
1684 | | void |
1685 | | SHA224_Begin(SHA256Context *cx) |
1686 | 0 | { |
1687 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1688 | 0 | return; |
1689 | 0 | (vector->p_SHA224_Begin)(cx); |
1690 | 0 | } |
1691 | | |
1692 | | void |
1693 | | SHA224_Update(SHA224Context *cx, const unsigned char *input, |
1694 | | unsigned int inputLen) |
1695 | 0 | { |
1696 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1697 | 0 | return; |
1698 | 0 | (vector->p_SHA224_Update)(cx, input, inputLen); |
1699 | 0 | } |
1700 | | |
1701 | | void |
1702 | | SHA224_End(SHA224Context *cx, unsigned char *digest, |
1703 | | unsigned int *digestLen, unsigned int maxDigestLen) |
1704 | 0 | { |
1705 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1706 | 0 | return; |
1707 | 0 | (vector->p_SHA224_End)(cx, digest, digestLen, maxDigestLen); |
1708 | 0 | } |
1709 | | |
1710 | | void |
1711 | | SHA224_TraceState(SHA224Context *cx) |
1712 | 0 | { |
1713 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1714 | 0 | return; |
1715 | 0 | (vector->p_SHA224_TraceState)(cx); |
1716 | 0 | } |
1717 | | |
1718 | | unsigned int |
1719 | | SHA224_FlattenSize(SHA224Context *cx) |
1720 | 0 | { |
1721 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1722 | 0 | return 0; |
1723 | 0 | return (vector->p_SHA224_FlattenSize)(cx); |
1724 | 0 | } |
1725 | | |
1726 | | SECStatus |
1727 | | SHA224_Flatten(SHA224Context *cx, unsigned char *space) |
1728 | 0 | { |
1729 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1730 | 0 | return SECFailure; |
1731 | 0 | return (vector->p_SHA224_Flatten)(cx, space); |
1732 | 0 | } |
1733 | | |
1734 | | SHA224Context * |
1735 | | SHA224_Resurrect(unsigned char *space, void *arg) |
1736 | 0 | { |
1737 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1738 | 0 | return NULL; |
1739 | 0 | return (vector->p_SHA224_Resurrect)(space, arg); |
1740 | 0 | } |
1741 | | |
1742 | | void |
1743 | | SHA224_Clone(SHA224Context *dest, SHA224Context *src) |
1744 | 0 | { |
1745 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1746 | 0 | return; |
1747 | 0 | (vector->p_SHA224_Clone)(dest, src); |
1748 | 0 | } |
1749 | | |
1750 | | PRBool |
1751 | | BLAPI_SHVerifyFile(const char *name) |
1752 | 0 | { |
1753 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1754 | 0 | return PR_FALSE; |
1755 | 0 | return vector->p_BLAPI_SHVerifyFile(name); |
1756 | 0 | } |
1757 | | |
1758 | | /* === new for DSA-2 === */ |
1759 | | SECStatus |
1760 | | PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes, |
1761 | | PQGParams **pParams, PQGVerify **pVfy) |
1762 | 0 | { |
1763 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1764 | 0 | return SECFailure; |
1765 | 0 | return (vector->p_PQG_ParamGenV2)(L, N, seedBytes, pParams, pVfy); |
1766 | 0 | } |
1767 | | |
1768 | | SECStatus |
1769 | | PRNGTEST_RunHealthTests(void) |
1770 | 0 | { |
1771 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1772 | 0 | return SECFailure; |
1773 | 0 | return vector->p_PRNGTEST_RunHealthTests(); |
1774 | 0 | } |
1775 | | |
1776 | | SECStatus |
1777 | | SSLv3_MAC_ConstantTime( |
1778 | | unsigned char *result, |
1779 | | unsigned int *resultLen, |
1780 | | unsigned int maxResultLen, |
1781 | | const SECHashObject *hashObj, |
1782 | | const unsigned char *secret, |
1783 | | unsigned int secretLen, |
1784 | | const unsigned char *header, |
1785 | | unsigned int headerLen, |
1786 | | const unsigned char *body, |
1787 | | unsigned int bodyLen, |
1788 | | unsigned int bodyTotalLen) |
1789 | 0 | { |
1790 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1791 | 0 | return SECFailure; |
1792 | 0 | return (vector->p_SSLv3_MAC_ConstantTime)( |
1793 | 0 | result, resultLen, maxResultLen, |
1794 | 0 | hashObj, |
1795 | 0 | secret, secretLen, |
1796 | 0 | header, headerLen, |
1797 | 0 | body, bodyLen, bodyTotalLen); |
1798 | 0 | } |
1799 | | |
1800 | | SECStatus |
1801 | | HMAC_ConstantTime( |
1802 | | unsigned char *result, |
1803 | | unsigned int *resultLen, |
1804 | | unsigned int maxResultLen, |
1805 | | const SECHashObject *hashObj, |
1806 | | const unsigned char *secret, |
1807 | | unsigned int secretLen, |
1808 | | const unsigned char *header, |
1809 | | unsigned int headerLen, |
1810 | | const unsigned char *body, |
1811 | | unsigned int bodyLen, |
1812 | | unsigned int bodyTotalLen) |
1813 | 0 | { |
1814 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1815 | 0 | return SECFailure; |
1816 | 0 | return (vector->p_HMAC_ConstantTime)( |
1817 | 0 | result, resultLen, maxResultLen, |
1818 | 0 | hashObj, |
1819 | 0 | secret, secretLen, |
1820 | 0 | header, headerLen, |
1821 | 0 | body, bodyLen, bodyTotalLen); |
1822 | 0 | } |
1823 | | |
1824 | | SECStatus |
1825 | | RSA_SignRaw(RSAPrivateKey *key, |
1826 | | unsigned char *output, |
1827 | | unsigned int *outputLen, |
1828 | | unsigned int maxOutputLen, |
1829 | | const unsigned char *input, |
1830 | | unsigned int inputLen) |
1831 | 0 | { |
1832 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1833 | 0 | return SECFailure; |
1834 | 0 | return (vector->p_RSA_SignRaw)(key, output, outputLen, maxOutputLen, input, |
1835 | 0 | inputLen); |
1836 | 0 | } |
1837 | | |
1838 | | SECStatus |
1839 | | RSA_CheckSignRaw(RSAPublicKey *key, |
1840 | | const unsigned char *sig, |
1841 | | unsigned int sigLen, |
1842 | | const unsigned char *hash, |
1843 | | unsigned int hashLen) |
1844 | 0 | { |
1845 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1846 | 0 | return SECFailure; |
1847 | 0 | return (vector->p_RSA_CheckSignRaw)(key, sig, sigLen, hash, hashLen); |
1848 | 0 | } |
1849 | | |
1850 | | SECStatus |
1851 | | RSA_CheckSignRecoverRaw(RSAPublicKey *key, |
1852 | | unsigned char *data, |
1853 | | unsigned int *dataLen, |
1854 | | unsigned int maxDataLen, |
1855 | | const unsigned char *sig, |
1856 | | unsigned int sigLen) |
1857 | 0 | { |
1858 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1859 | 0 | return SECFailure; |
1860 | 0 | return (vector->p_RSA_CheckSignRecoverRaw)(key, data, dataLen, maxDataLen, |
1861 | 0 | sig, sigLen); |
1862 | 0 | } |
1863 | | |
1864 | | SECStatus |
1865 | | RSA_EncryptRaw(RSAPublicKey *key, |
1866 | | unsigned char *output, |
1867 | | unsigned int *outputLen, |
1868 | | unsigned int maxOutputLen, |
1869 | | const unsigned char *input, |
1870 | | unsigned int inputLen) |
1871 | 0 | { |
1872 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1873 | 0 | return SECFailure; |
1874 | 0 | return (vector->p_RSA_EncryptRaw)(key, output, outputLen, maxOutputLen, |
1875 | 0 | input, inputLen); |
1876 | 0 | } |
1877 | | |
1878 | | SECStatus |
1879 | | RSA_DecryptRaw(RSAPrivateKey *key, |
1880 | | unsigned char *output, |
1881 | | unsigned int *outputLen, |
1882 | | unsigned int maxOutputLen, |
1883 | | const unsigned char *input, |
1884 | | unsigned int inputLen) |
1885 | 0 | { |
1886 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1887 | 0 | return SECFailure; |
1888 | 0 | return (vector->p_RSA_DecryptRaw)(key, output, outputLen, maxOutputLen, |
1889 | 0 | input, inputLen); |
1890 | 0 | } |
1891 | | |
1892 | | SECStatus |
1893 | | RSA_EncryptOAEP(RSAPublicKey *key, |
1894 | | HASH_HashType hashAlg, |
1895 | | HASH_HashType maskHashAlg, |
1896 | | const unsigned char *label, |
1897 | | unsigned int labelLen, |
1898 | | const unsigned char *seed, |
1899 | | unsigned int seedLen, |
1900 | | unsigned char *output, |
1901 | | unsigned int *outputLen, |
1902 | | unsigned int maxOutputLen, |
1903 | | const unsigned char *input, |
1904 | | unsigned int inputLen) |
1905 | 0 | { |
1906 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1907 | 0 | return SECFailure; |
1908 | 0 | return (vector->p_RSA_EncryptOAEP)(key, hashAlg, maskHashAlg, label, |
1909 | 0 | labelLen, seed, seedLen, output, |
1910 | 0 | outputLen, maxOutputLen, input, inputLen); |
1911 | 0 | } |
1912 | | |
1913 | | SECStatus |
1914 | | RSA_DecryptOAEP(RSAPrivateKey *key, |
1915 | | HASH_HashType hashAlg, |
1916 | | HASH_HashType maskHashAlg, |
1917 | | const unsigned char *label, |
1918 | | unsigned int labelLen, |
1919 | | unsigned char *output, |
1920 | | unsigned int *outputLen, |
1921 | | unsigned int maxOutputLen, |
1922 | | const unsigned char *input, |
1923 | | unsigned int inputLen) |
1924 | 0 | { |
1925 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1926 | 0 | return SECFailure; |
1927 | 0 | return (vector->p_RSA_DecryptOAEP)(key, hashAlg, maskHashAlg, label, |
1928 | 0 | labelLen, output, outputLen, |
1929 | 0 | maxOutputLen, input, inputLen); |
1930 | 0 | } |
1931 | | |
1932 | | SECStatus |
1933 | | RSA_EncryptBlock(RSAPublicKey *key, |
1934 | | unsigned char *output, |
1935 | | unsigned int *outputLen, |
1936 | | unsigned int maxOutputLen, |
1937 | | const unsigned char *input, |
1938 | | unsigned int inputLen) |
1939 | 0 | { |
1940 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1941 | 0 | return SECFailure; |
1942 | 0 | return (vector->p_RSA_EncryptBlock)(key, output, outputLen, maxOutputLen, |
1943 | 0 | input, inputLen); |
1944 | 0 | } |
1945 | | |
1946 | | SECStatus |
1947 | | RSA_DecryptBlock(RSAPrivateKey *key, |
1948 | | unsigned char *output, |
1949 | | unsigned int *outputLen, |
1950 | | unsigned int maxOutputLen, |
1951 | | const unsigned char *input, |
1952 | | unsigned int inputLen) |
1953 | 0 | { |
1954 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1955 | 0 | return SECFailure; |
1956 | 0 | return (vector->p_RSA_DecryptBlock)(key, output, outputLen, maxOutputLen, |
1957 | 0 | input, inputLen); |
1958 | 0 | } |
1959 | | |
1960 | | SECStatus |
1961 | | RSA_SignPSS(RSAPrivateKey *key, |
1962 | | HASH_HashType hashAlg, |
1963 | | HASH_HashType maskHashAlg, |
1964 | | const unsigned char *salt, |
1965 | | unsigned int saltLen, |
1966 | | unsigned char *output, |
1967 | | unsigned int *outputLen, |
1968 | | unsigned int maxOutputLen, |
1969 | | const unsigned char *input, |
1970 | | unsigned int inputLen) |
1971 | 0 | { |
1972 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1973 | 0 | return SECFailure; |
1974 | 0 | return (vector->p_RSA_SignPSS)(key, hashAlg, maskHashAlg, salt, saltLen, |
1975 | 0 | output, outputLen, maxOutputLen, input, |
1976 | 0 | inputLen); |
1977 | 0 | } |
1978 | | |
1979 | | SECStatus |
1980 | | RSA_CheckSignPSS(RSAPublicKey *key, |
1981 | | HASH_HashType hashAlg, |
1982 | | HASH_HashType maskHashAlg, |
1983 | | unsigned int saltLen, |
1984 | | const unsigned char *sig, |
1985 | | unsigned int sigLen, |
1986 | | const unsigned char *hash, |
1987 | | unsigned int hashLen) |
1988 | 0 | { |
1989 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
1990 | 0 | return SECFailure; |
1991 | 0 | return (vector->p_RSA_CheckSignPSS)(key, hashAlg, maskHashAlg, saltLen, |
1992 | 0 | sig, sigLen, hash, hashLen); |
1993 | 0 | } |
1994 | | |
1995 | | SECStatus |
1996 | | RSA_Sign(RSAPrivateKey *key, |
1997 | | unsigned char *output, |
1998 | | unsigned int *outputLen, |
1999 | | unsigned int maxOutputLen, |
2000 | | const unsigned char *input, |
2001 | | unsigned int inputLen) |
2002 | 0 | { |
2003 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2004 | 0 | return SECFailure; |
2005 | 0 | return (vector->p_RSA_Sign)(key, output, outputLen, maxOutputLen, input, |
2006 | 0 | inputLen); |
2007 | 0 | } |
2008 | | |
2009 | | SECStatus |
2010 | | RSA_CheckSign(RSAPublicKey *key, |
2011 | | const unsigned char *sig, |
2012 | | unsigned int sigLen, |
2013 | | const unsigned char *data, |
2014 | | unsigned int dataLen) |
2015 | 0 | { |
2016 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2017 | 0 | return SECFailure; |
2018 | 0 | return (vector->p_RSA_CheckSign)(key, sig, sigLen, data, dataLen); |
2019 | 0 | } |
2020 | | |
2021 | | SECStatus |
2022 | | RSA_CheckSignRecover(RSAPublicKey *key, |
2023 | | unsigned char *output, |
2024 | | unsigned int *outputLen, |
2025 | | unsigned int maxOutputLen, |
2026 | | const unsigned char *sig, |
2027 | | unsigned int sigLen) |
2028 | 0 | { |
2029 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2030 | 0 | return SECFailure; |
2031 | 0 | return (vector->p_RSA_CheckSignRecover)(key, output, outputLen, maxOutputLen, |
2032 | 0 | sig, sigLen); |
2033 | 0 | } |
2034 | | |
2035 | | SECStatus |
2036 | | EC_FillParams(PLArenaPool *arena, |
2037 | | const SECItem *encodedParams, |
2038 | | ECParams *params) |
2039 | 0 | { |
2040 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2041 | 0 | return SECFailure; |
2042 | 0 | return (vector->p_EC_FillParams)(arena, encodedParams, params); |
2043 | 0 | } |
2044 | | |
2045 | | SECStatus |
2046 | | EC_DecodeParams(const SECItem *encodedParams, |
2047 | | ECParams **ecparams) |
2048 | 0 | { |
2049 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2050 | 0 | return SECFailure; |
2051 | 0 | return (vector->p_EC_DecodeParams)(encodedParams, ecparams); |
2052 | 0 | } |
2053 | | |
2054 | | SECStatus |
2055 | | EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, |
2056 | | const ECParams *srcParams) |
2057 | 0 | { |
2058 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2059 | 0 | return SECFailure; |
2060 | 0 | return (vector->p_EC_CopyParams)(arena, dstParams, srcParams); |
2061 | 0 | } |
2062 | | |
2063 | | SECStatus |
2064 | | ChaCha20Poly1305_InitContext(ChaCha20Poly1305Context *ctx, |
2065 | | const unsigned char *key, unsigned int keyLen, |
2066 | | unsigned int tagLen) |
2067 | 0 | { |
2068 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2069 | 0 | return SECFailure; |
2070 | 0 | return (vector->p_ChaCha20Poly1305_InitContext)(ctx, key, keyLen, tagLen); |
2071 | 0 | } |
2072 | | |
2073 | | ChaCha20Poly1305Context * |
2074 | | ChaCha20Poly1305_CreateContext(const unsigned char *key, unsigned int keyLen, |
2075 | | unsigned int tagLen) |
2076 | 0 | { |
2077 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2078 | 0 | return NULL; |
2079 | 0 | return (vector->p_ChaCha20Poly1305_CreateContext)(key, keyLen, tagLen); |
2080 | 0 | } |
2081 | | |
2082 | | void |
2083 | | ChaCha20Poly1305_DestroyContext(ChaCha20Poly1305Context *ctx, PRBool freeit) |
2084 | 0 | { |
2085 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2086 | 0 | return; |
2087 | 0 | (vector->p_ChaCha20Poly1305_DestroyContext)(ctx, freeit); |
2088 | 0 | } |
2089 | | |
2090 | | SECStatus |
2091 | | ChaCha20Poly1305_Seal(const ChaCha20Poly1305Context *ctx, |
2092 | | unsigned char *output, unsigned int *outputLen, |
2093 | | unsigned int maxOutputLen, |
2094 | | const unsigned char *input, unsigned int inputLen, |
2095 | | const unsigned char *nonce, unsigned int nonceLen, |
2096 | | const unsigned char *ad, unsigned int adLen) |
2097 | 0 | { |
2098 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2099 | 0 | return SECFailure; |
2100 | 0 | return (vector->p_ChaCha20Poly1305_Seal)( |
2101 | 0 | ctx, output, outputLen, maxOutputLen, input, inputLen, |
2102 | 0 | nonce, nonceLen, ad, adLen); |
2103 | 0 | } |
2104 | | |
2105 | | SECStatus |
2106 | | ChaCha20Poly1305_Open(const ChaCha20Poly1305Context *ctx, |
2107 | | unsigned char *output, unsigned int *outputLen, |
2108 | | unsigned int maxOutputLen, |
2109 | | const unsigned char *input, unsigned int inputLen, |
2110 | | const unsigned char *nonce, unsigned int nonceLen, |
2111 | | const unsigned char *ad, unsigned int adLen) |
2112 | 0 | { |
2113 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2114 | 0 | return SECFailure; |
2115 | 0 | return (vector->p_ChaCha20Poly1305_Open)( |
2116 | 0 | ctx, output, outputLen, maxOutputLen, input, inputLen, |
2117 | 0 | nonce, nonceLen, ad, adLen); |
2118 | 0 | } |
2119 | | |
2120 | | int |
2121 | | EC_GetPointSize(const ECParams *params) |
2122 | 0 | { |
2123 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) |
2124 | 0 | return SECFailure; |
2125 | 0 | return (vector->p_EC_GetPointSize)(params); |
2126 | 0 | } |
2127 | | |
2128 | | SECStatus |
2129 | | BLAKE2B_Hash(unsigned char *dest, const char *src) |
2130 | 0 | { |
2131 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2132 | 0 | return SECFailure; |
2133 | 0 | } |
2134 | 0 | return (vector->p_BLAKE2B_Hash)(dest, src); |
2135 | 0 | } |
2136 | | |
2137 | | SECStatus |
2138 | | BLAKE2B_HashBuf(unsigned char *output, const unsigned char *input, PRUint32 inlen) |
2139 | 0 | { |
2140 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2141 | 0 | return SECFailure; |
2142 | 0 | } |
2143 | 0 | return (vector->p_BLAKE2B_HashBuf)(output, input, inlen); |
2144 | 0 | } |
2145 | | |
2146 | | SECStatus |
2147 | | BLAKE2B_MAC_HashBuf(unsigned char *output, const unsigned char *input, |
2148 | | unsigned int inlen, const unsigned char *key, |
2149 | | unsigned int keylen) |
2150 | 0 | { |
2151 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2152 | 0 | return SECFailure; |
2153 | 0 | } |
2154 | 0 | return (vector->p_BLAKE2B_MAC_HashBuf)(output, input, inlen, key, keylen); |
2155 | 0 | } |
2156 | | |
2157 | | BLAKE2BContext * |
2158 | | BLAKE2B_NewContext(void) |
2159 | 0 | { |
2160 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2161 | 0 | return NULL; |
2162 | 0 | } |
2163 | 0 | return (vector->p_BLAKE2B_NewContext)(); |
2164 | 0 | } |
2165 | | |
2166 | | void |
2167 | | BLAKE2B_DestroyContext(BLAKE2BContext *ctx, PRBool freeit) |
2168 | 0 | { |
2169 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2170 | 0 | return; |
2171 | 0 | } |
2172 | 0 | (vector->p_BLAKE2B_DestroyContext)(ctx, freeit); |
2173 | 0 | } |
2174 | | |
2175 | | SECStatus |
2176 | | BLAKE2B_Begin(BLAKE2BContext *ctx) |
2177 | 0 | { |
2178 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2179 | 0 | return SECFailure; |
2180 | 0 | } |
2181 | 0 | return (vector->p_BLAKE2B_Begin)(ctx); |
2182 | 0 | } |
2183 | | |
2184 | | SECStatus |
2185 | | BLAKE2B_MAC_Begin(BLAKE2BContext *ctx, const PRUint8 *key, const size_t keylen) |
2186 | 0 | { |
2187 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2188 | 0 | return SECFailure; |
2189 | 0 | } |
2190 | 0 | return (vector->p_BLAKE2B_MAC_Begin)(ctx, key, keylen); |
2191 | 0 | } |
2192 | | |
2193 | | SECStatus |
2194 | | BLAKE2B_Update(BLAKE2BContext *ctx, const unsigned char *in, unsigned int inlen) |
2195 | 0 | { |
2196 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2197 | 0 | return SECFailure; |
2198 | 0 | } |
2199 | 0 | return (vector->p_BLAKE2B_Update)(ctx, in, inlen); |
2200 | 0 | } |
2201 | | |
2202 | | SECStatus |
2203 | | BLAKE2B_End(BLAKE2BContext *ctx, unsigned char *out, |
2204 | | unsigned int *digestLen, size_t maxDigestLen) |
2205 | 0 | { |
2206 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2207 | 0 | return SECFailure; |
2208 | 0 | } |
2209 | 0 | return (vector->p_BLAKE2B_End)(ctx, out, digestLen, maxDigestLen); |
2210 | 0 | } |
2211 | | |
2212 | | unsigned int |
2213 | | BLAKE2B_FlattenSize(BLAKE2BContext *ctx) |
2214 | 0 | { |
2215 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2216 | 0 | return 0; |
2217 | 0 | } |
2218 | 0 | return (vector->p_BLAKE2B_FlattenSize)(ctx); |
2219 | 0 | } |
2220 | | |
2221 | | SECStatus |
2222 | | BLAKE2B_Flatten(BLAKE2BContext *ctx, unsigned char *space) |
2223 | 0 | { |
2224 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2225 | 0 | return SECFailure; |
2226 | 0 | } |
2227 | 0 | return (vector->p_BLAKE2B_Flatten)(ctx, space); |
2228 | 0 | } |
2229 | | |
2230 | | BLAKE2BContext * |
2231 | | BLAKE2B_Resurrect(unsigned char *space, void *arg) |
2232 | 0 | { |
2233 | 0 | if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { |
2234 | 0 | return NULL; |
2235 | 0 | } |
2236 | 0 | return (vector->p_BLAKE2B_Resurrect)(space, arg); |
2237 | 0 | } |