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