1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/freebl/loader.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2121 @@ 1.4 +/* 1.5 + * loader.c - load platform dependent DSO containing freebl implementation. 1.6 + * 1.7 + * This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "loader.h" 1.12 +#include "prmem.h" 1.13 +#include "prerror.h" 1.14 +#include "prinit.h" 1.15 +#include "prenv.h" 1.16 + 1.17 +static const char* default_name = 1.18 + SHLIB_PREFIX"freebl"SHLIB_VERSION"."SHLIB_SUFFIX; 1.19 + 1.20 +/* getLibName() returns the name of the library to load. */ 1.21 + 1.22 +#if defined(SOLARIS) && defined(__sparc) 1.23 +#include <stddef.h> 1.24 +#include <strings.h> 1.25 +#include <sys/systeminfo.h> 1.26 + 1.27 + 1.28 +#if defined(NSS_USE_64) 1.29 + 1.30 +const static char fpu_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; 1.31 +const static char int_hybrid_shared_lib[] = "libfreebl_64int_3.so"; 1.32 +const static char non_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; 1.33 + 1.34 +const static char int_hybrid_isa[] = "sparcv9"; 1.35 +const static char fpu_hybrid_isa[] = "sparcv9+vis"; 1.36 + 1.37 +#else 1.38 + 1.39 +const static char fpu_hybrid_shared_lib[] = "libfreebl_32fpu_3.so"; 1.40 +const static char int_hybrid_shared_lib[] = "libfreebl_32int64_3.so"; 1.41 +/* This was for SPARC V8, now obsolete. */ 1.42 +const static char *const non_hybrid_shared_lib = NULL; 1.43 + 1.44 +const static char int_hybrid_isa[] = "sparcv8plus"; 1.45 +const static char fpu_hybrid_isa[] = "sparcv8plus+vis"; 1.46 + 1.47 +#endif 1.48 + 1.49 +static const char * 1.50 +getLibName(void) 1.51 +{ 1.52 + char * found_int_hybrid; 1.53 + char * found_fpu_hybrid; 1.54 + long buflen; 1.55 + char buf[256]; 1.56 + 1.57 + buflen = sysinfo(SI_ISALIST, buf, sizeof buf); 1.58 + if (buflen <= 0) 1.59 + return NULL; 1.60 + /* sysinfo output is always supposed to be NUL terminated, but ... */ 1.61 + if (buflen < sizeof buf) 1.62 + buf[buflen] = '\0'; 1.63 + else 1.64 + buf[(sizeof buf) - 1] = '\0'; 1.65 + /* The ISA list is a space separated string of names of ISAs and 1.66 + * ISA extensions, in order of decreasing performance. 1.67 + * There are two different ISAs with which NSS's crypto code can be 1.68 + * accelerated. If both are in the list, we take the first one. 1.69 + * If one is in the list, we use it, and if neither then we use 1.70 + * the base unaccelerated code. 1.71 + */ 1.72 + found_int_hybrid = strstr(buf, int_hybrid_isa); 1.73 + found_fpu_hybrid = strstr(buf, fpu_hybrid_isa); 1.74 + if (found_fpu_hybrid && 1.75 + (!found_int_hybrid || 1.76 + (found_int_hybrid - found_fpu_hybrid) >= 0)) { 1.77 + return fpu_hybrid_shared_lib; 1.78 + } 1.79 + if (found_int_hybrid) { 1.80 + return int_hybrid_shared_lib; 1.81 + } 1.82 + return non_hybrid_shared_lib; 1.83 +} 1.84 + 1.85 +#elif defined(HPUX) && !defined(NSS_USE_64) && !defined(__ia64) 1.86 +#include <unistd.h> 1.87 + 1.88 +/* This code tests to see if we're running on a PA2.x CPU. 1.89 +** It returns true (1) if so, and false (0) otherwise. 1.90 +*/ 1.91 +static const char * 1.92 +getLibName(void) 1.93 +{ 1.94 + long cpu = sysconf(_SC_CPU_VERSION); 1.95 + return (cpu == CPU_PA_RISC2_0) 1.96 + ? "libfreebl_32fpu_3.sl" 1.97 + : "libfreebl_32int_3.sl" ; 1.98 +} 1.99 +#else 1.100 +/* default case, for platforms/ABIs that have only one freebl shared lib. */ 1.101 +static const char * getLibName(void) { return default_name; } 1.102 +#endif 1.103 + 1.104 +#include "prio.h" 1.105 +#include "prprf.h" 1.106 +#include <stdio.h> 1.107 +#include "prsystem.h" 1.108 + 1.109 +static const char *NameOfThisSharedLib = 1.110 + SHLIB_PREFIX"softokn"SOFTOKEN_SHLIB_VERSION"."SHLIB_SUFFIX; 1.111 + 1.112 +static PRLibrary* blLib; 1.113 + 1.114 +#define LSB(x) ((x)&0xff) 1.115 +#define MSB(x) ((x)>>8) 1.116 + 1.117 +static const FREEBLVector *vector; 1.118 +static const char *libraryName = NULL; 1.119 + 1.120 +#include "genload.c" 1.121 + 1.122 +/* This function must be run only once. */ 1.123 +/* determine if hybrid platform, then actually load the DSO. */ 1.124 +static PRStatus 1.125 +freebl_LoadDSO( void ) 1.126 +{ 1.127 + PRLibrary * handle; 1.128 + const char * name = getLibName(); 1.129 + 1.130 + if (!name) { 1.131 + PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); 1.132 + return PR_FAILURE; 1.133 + } 1.134 + 1.135 + handle = loader_LoadLibrary(name); 1.136 + if (handle) { 1.137 + PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); 1.138 + PRStatus status; 1.139 + if (address) { 1.140 + FREEBLGetVectorFn * getVector = (FREEBLGetVectorFn *)address; 1.141 + const FREEBLVector * dsoVector = getVector(); 1.142 + if (dsoVector) { 1.143 + unsigned short dsoVersion = dsoVector->version; 1.144 + unsigned short myVersion = FREEBL_VERSION; 1.145 + if (MSB(dsoVersion) == MSB(myVersion) && 1.146 + LSB(dsoVersion) >= LSB(myVersion) && 1.147 + dsoVector->length >= sizeof(FREEBLVector)) { 1.148 + vector = dsoVector; 1.149 + libraryName = name; 1.150 + blLib = handle; 1.151 + return PR_SUCCESS; 1.152 + } 1.153 + } 1.154 + } 1.155 + status = PR_UnloadLibrary(handle); 1.156 + PORT_Assert(PR_SUCCESS == status); 1.157 + } 1.158 + return PR_FAILURE; 1.159 +} 1.160 + 1.161 +static const PRCallOnceType pristineCallOnce; 1.162 +static PRCallOnceType loadFreeBLOnce; 1.163 + 1.164 +static PRStatus 1.165 +freebl_RunLoaderOnce( void ) 1.166 +{ 1.167 + PRStatus status; 1.168 + 1.169 + status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); 1.170 + return status; 1.171 +} 1.172 + 1.173 +SECStatus 1.174 +BL_Init(void) 1.175 +{ 1.176 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.177 + return SECFailure; 1.178 + return (vector->p_BL_Init)(); 1.179 +} 1.180 + 1.181 +RSAPrivateKey * 1.182 +RSA_NewKey(int keySizeInBits, SECItem * publicExponent) 1.183 +{ 1.184 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.185 + return NULL; 1.186 + return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); 1.187 +} 1.188 + 1.189 +SECStatus 1.190 +RSA_PublicKeyOp(RSAPublicKey * key, 1.191 + unsigned char * output, 1.192 + const unsigned char * input) 1.193 +{ 1.194 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.195 + return SECFailure; 1.196 + return (vector->p_RSA_PublicKeyOp)(key, output, input); 1.197 +} 1.198 + 1.199 +SECStatus 1.200 +RSA_PrivateKeyOp(RSAPrivateKey * key, 1.201 + unsigned char * output, 1.202 + const unsigned char * input) 1.203 +{ 1.204 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.205 + return SECFailure; 1.206 + return (vector->p_RSA_PrivateKeyOp)(key, output, input); 1.207 +} 1.208 + 1.209 +SECStatus 1.210 +RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, 1.211 + unsigned char *output, 1.212 + const unsigned char *input) 1.213 +{ 1.214 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.215 + return SECFailure; 1.216 + return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); 1.217 +} 1.218 + 1.219 +SECStatus 1.220 +RSA_PrivateKeyCheck(const RSAPrivateKey *key) 1.221 +{ 1.222 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.223 + return SECFailure; 1.224 + return (vector->p_RSA_PrivateKeyCheck)(key); 1.225 +} 1.226 + 1.227 +SECStatus 1.228 +DSA_NewKey(const PQGParams * params, DSAPrivateKey ** privKey) 1.229 +{ 1.230 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.231 + return SECFailure; 1.232 + return (vector->p_DSA_NewKey)(params, privKey); 1.233 +} 1.234 + 1.235 +SECStatus 1.236 +DSA_SignDigest(DSAPrivateKey * key, SECItem * signature, const SECItem * digest) 1.237 +{ 1.238 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.239 + return SECFailure; 1.240 + return (vector->p_DSA_SignDigest)( key, signature, digest); 1.241 +} 1.242 + 1.243 +SECStatus 1.244 +DSA_VerifyDigest(DSAPublicKey * key, const SECItem * signature, 1.245 + const SECItem * digest) 1.246 +{ 1.247 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.248 + return SECFailure; 1.249 + return (vector->p_DSA_VerifyDigest)( key, signature, digest); 1.250 +} 1.251 + 1.252 +SECStatus 1.253 +DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char * seed, 1.254 + DSAPrivateKey **privKey) 1.255 +{ 1.256 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.257 + return SECFailure; 1.258 + return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); 1.259 +} 1.260 + 1.261 +SECStatus 1.262 +DSA_SignDigestWithSeed(DSAPrivateKey * key, SECItem * signature, 1.263 + const SECItem * digest, const unsigned char * seed) 1.264 +{ 1.265 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.266 + return SECFailure; 1.267 + return (vector->p_DSA_SignDigestWithSeed)( key, signature, digest, seed); 1.268 +} 1.269 + 1.270 +SECStatus 1.271 +DSA_NewRandom(PLArenaPool * arena, const SECItem * q, SECItem * seed) 1.272 +{ 1.273 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.274 + return SECFailure; 1.275 + return (vector->p_DSA_NewRandom)(arena, q, seed); 1.276 +} 1.277 + 1.278 +SECStatus 1.279 +DH_GenParam(int primeLen, DHParams ** params) 1.280 +{ 1.281 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.282 + return SECFailure; 1.283 + return (vector->p_DH_GenParam)(primeLen, params); 1.284 +} 1.285 + 1.286 +SECStatus 1.287 +DH_NewKey(DHParams * params, DHPrivateKey ** privKey) 1.288 +{ 1.289 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.290 + return SECFailure; 1.291 + return (vector->p_DH_NewKey)( params, privKey); 1.292 +} 1.293 + 1.294 +SECStatus 1.295 +DH_Derive(SECItem * publicValue, SECItem * prime, SECItem * privateValue, 1.296 + SECItem * derivedSecret, unsigned int maxOutBytes) 1.297 +{ 1.298 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.299 + return SECFailure; 1.300 + return (vector->p_DH_Derive)( publicValue, prime, privateValue, 1.301 + derivedSecret, maxOutBytes); 1.302 +} 1.303 + 1.304 +SECStatus 1.305 +KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, 1.306 + SECItem *private1, SECItem *private2, SECItem *derivedSecret) 1.307 +{ 1.308 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.309 + return SECFailure; 1.310 + return (vector->p_KEA_Derive)(prime, public1, public2, 1.311 + private1, private2, derivedSecret); 1.312 +} 1.313 + 1.314 +PRBool 1.315 +KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) 1.316 +{ 1.317 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.318 + return PR_FALSE; 1.319 + return (vector->p_KEA_Verify)(Y, prime, subPrime); 1.320 +} 1.321 + 1.322 +RC4Context * 1.323 +RC4_CreateContext(const unsigned char *key, int len) 1.324 +{ 1.325 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.326 + return NULL; 1.327 + return (vector->p_RC4_CreateContext)(key, len); 1.328 +} 1.329 + 1.330 +void 1.331 +RC4_DestroyContext(RC4Context *cx, PRBool freeit) 1.332 +{ 1.333 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.334 + return; 1.335 + (vector->p_RC4_DestroyContext)(cx, freeit); 1.336 +} 1.337 + 1.338 +SECStatus 1.339 +RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, 1.340 + unsigned int maxOutputLen, const unsigned char *input, 1.341 + unsigned int inputLen) 1.342 +{ 1.343 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.344 + return SECFailure; 1.345 + return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input, 1.346 + inputLen); 1.347 +} 1.348 + 1.349 +SECStatus 1.350 +RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, 1.351 + unsigned int maxOutputLen, const unsigned char *input, 1.352 + unsigned int inputLen) 1.353 +{ 1.354 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.355 + return SECFailure; 1.356 + return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input, 1.357 + inputLen); 1.358 +} 1.359 + 1.360 +RC2Context * 1.361 +RC2_CreateContext(const unsigned char *key, unsigned int len, 1.362 + const unsigned char *iv, int mode, unsigned effectiveKeyLen) 1.363 +{ 1.364 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.365 + return NULL; 1.366 + return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); 1.367 +} 1.368 + 1.369 +void 1.370 +RC2_DestroyContext(RC2Context *cx, PRBool freeit) 1.371 +{ 1.372 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.373 + return; 1.374 + (vector->p_RC2_DestroyContext)(cx, freeit); 1.375 +} 1.376 + 1.377 +SECStatus 1.378 +RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, 1.379 + unsigned int maxOutputLen, const unsigned char *input, 1.380 + unsigned int inputLen) 1.381 +{ 1.382 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.383 + return SECFailure; 1.384 + return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input, 1.385 + inputLen); 1.386 +} 1.387 + 1.388 +SECStatus 1.389 +RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, 1.390 + unsigned int maxOutputLen, const unsigned char *input, 1.391 + unsigned int inputLen) 1.392 +{ 1.393 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.394 + return SECFailure; 1.395 + return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input, 1.396 + inputLen); 1.397 +} 1.398 + 1.399 +RC5Context * 1.400 +RC5_CreateContext(const SECItem *key, unsigned int rounds, 1.401 + unsigned int wordSize, const unsigned char *iv, int mode) 1.402 +{ 1.403 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.404 + return NULL; 1.405 + return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); 1.406 +} 1.407 + 1.408 +void 1.409 +RC5_DestroyContext(RC5Context *cx, PRBool freeit) 1.410 +{ 1.411 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.412 + return; 1.413 + (vector->p_RC5_DestroyContext)(cx, freeit); 1.414 +} 1.415 + 1.416 +SECStatus 1.417 +RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, 1.418 + unsigned int maxOutputLen, const unsigned char *input, 1.419 + unsigned int inputLen) 1.420 +{ 1.421 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.422 + return SECFailure; 1.423 + return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input, 1.424 + inputLen); 1.425 +} 1.426 + 1.427 +SECStatus 1.428 +RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, 1.429 + unsigned int maxOutputLen, const unsigned char *input, 1.430 + unsigned int inputLen) 1.431 +{ 1.432 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.433 + return SECFailure; 1.434 + return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input, 1.435 + inputLen); 1.436 +} 1.437 + 1.438 +DESContext * 1.439 +DES_CreateContext(const unsigned char *key, const unsigned char *iv, 1.440 + int mode, PRBool encrypt) 1.441 +{ 1.442 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.443 + return NULL; 1.444 + return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); 1.445 +} 1.446 + 1.447 +void 1.448 +DES_DestroyContext(DESContext *cx, PRBool freeit) 1.449 +{ 1.450 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.451 + return; 1.452 + (vector->p_DES_DestroyContext)(cx, freeit); 1.453 +} 1.454 + 1.455 +SECStatus 1.456 +DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, 1.457 + unsigned int maxOutputLen, const unsigned char *input, 1.458 + unsigned int inputLen) 1.459 +{ 1.460 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.461 + return SECFailure; 1.462 + return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input, 1.463 + inputLen); 1.464 +} 1.465 + 1.466 +SECStatus 1.467 +DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, 1.468 + unsigned int maxOutputLen, const unsigned char *input, 1.469 + unsigned int inputLen) 1.470 +{ 1.471 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.472 + return SECFailure; 1.473 + return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input, 1.474 + inputLen); 1.475 +} 1.476 +SEEDContext * 1.477 +SEED_CreateContext(const unsigned char *key, const unsigned char *iv, 1.478 + int mode, PRBool encrypt) 1.479 +{ 1.480 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.481 + return NULL; 1.482 + return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); 1.483 +} 1.484 + 1.485 +void 1.486 +SEED_DestroyContext(SEEDContext *cx, PRBool freeit) 1.487 +{ 1.488 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.489 + return; 1.490 + (vector->p_SEED_DestroyContext)(cx, freeit); 1.491 +} 1.492 + 1.493 +SECStatus 1.494 +SEED_Encrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, 1.495 + unsigned int maxOutputLen, const unsigned char *input, 1.496 + unsigned int inputLen) 1.497 +{ 1.498 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.499 + return SECFailure; 1.500 + return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input, 1.501 + inputLen); 1.502 +} 1.503 + 1.504 +SECStatus 1.505 +SEED_Decrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, 1.506 + unsigned int maxOutputLen, const unsigned char *input, 1.507 + unsigned int inputLen) 1.508 +{ 1.509 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.510 + return SECFailure; 1.511 + return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input, 1.512 + inputLen); 1.513 +} 1.514 + 1.515 +AESContext * 1.516 +AES_CreateContext(const unsigned char *key, const unsigned char *iv, 1.517 + int mode, int encrypt, 1.518 + unsigned int keylen, unsigned int blocklen) 1.519 +{ 1.520 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.521 + return NULL; 1.522 + return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, 1.523 + blocklen); 1.524 +} 1.525 + 1.526 +void 1.527 +AES_DestroyContext(AESContext *cx, PRBool freeit) 1.528 +{ 1.529 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.530 + return ; 1.531 + (vector->p_AES_DestroyContext)(cx, freeit); 1.532 +} 1.533 + 1.534 +SECStatus 1.535 +AES_Encrypt(AESContext *cx, unsigned char *output, 1.536 + unsigned int *outputLen, unsigned int maxOutputLen, 1.537 + const unsigned char *input, unsigned int inputLen) 1.538 +{ 1.539 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.540 + return SECFailure; 1.541 + return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, 1.542 + input, inputLen); 1.543 +} 1.544 + 1.545 +SECStatus 1.546 +AES_Decrypt(AESContext *cx, unsigned char *output, 1.547 + unsigned int *outputLen, unsigned int maxOutputLen, 1.548 + const unsigned char *input, unsigned int inputLen) 1.549 +{ 1.550 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.551 + return SECFailure; 1.552 + return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, 1.553 + input, inputLen); 1.554 +} 1.555 + 1.556 +SECStatus 1.557 +MD5_Hash(unsigned char *dest, const char *src) 1.558 +{ 1.559 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.560 + return SECFailure; 1.561 + return (vector->p_MD5_Hash)(dest, src); 1.562 +} 1.563 + 1.564 +SECStatus 1.565 +MD5_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.566 +{ 1.567 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.568 + return SECFailure; 1.569 + return (vector->p_MD5_HashBuf)(dest, src, src_length); 1.570 +} 1.571 + 1.572 +MD5Context * 1.573 +MD5_NewContext(void) 1.574 +{ 1.575 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.576 + return NULL; 1.577 + return (vector->p_MD5_NewContext)(); 1.578 +} 1.579 + 1.580 +void 1.581 +MD5_DestroyContext(MD5Context *cx, PRBool freeit) 1.582 +{ 1.583 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.584 + return; 1.585 + (vector->p_MD5_DestroyContext)(cx, freeit); 1.586 +} 1.587 + 1.588 +void 1.589 +MD5_Begin(MD5Context *cx) 1.590 +{ 1.591 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.592 + return; 1.593 + (vector->p_MD5_Begin)(cx); 1.594 +} 1.595 + 1.596 +void 1.597 +MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen) 1.598 +{ 1.599 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.600 + return; 1.601 + (vector->p_MD5_Update)(cx, input, inputLen); 1.602 +} 1.603 + 1.604 +void 1.605 +MD5_End(MD5Context *cx, unsigned char *digest, 1.606 + unsigned int *digestLen, unsigned int maxDigestLen) 1.607 +{ 1.608 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.609 + return; 1.610 + (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); 1.611 +} 1.612 + 1.613 +unsigned int 1.614 +MD5_FlattenSize(MD5Context *cx) 1.615 +{ 1.616 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.617 + return 0; 1.618 + return (vector->p_MD5_FlattenSize)(cx); 1.619 +} 1.620 + 1.621 +SECStatus 1.622 +MD5_Flatten(MD5Context *cx,unsigned char *space) 1.623 +{ 1.624 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.625 + return SECFailure; 1.626 + return (vector->p_MD5_Flatten)(cx, space); 1.627 +} 1.628 + 1.629 +MD5Context * 1.630 +MD5_Resurrect(unsigned char *space, void *arg) 1.631 +{ 1.632 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.633 + return NULL; 1.634 + return (vector->p_MD5_Resurrect)(space, arg); 1.635 +} 1.636 + 1.637 +void 1.638 +MD5_TraceState(MD5Context *cx) 1.639 +{ 1.640 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.641 + return ; 1.642 + (vector->p_MD5_TraceState)(cx); 1.643 +} 1.644 + 1.645 +SECStatus 1.646 +MD2_Hash(unsigned char *dest, const char *src) 1.647 +{ 1.648 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.649 + return SECFailure; 1.650 + return (vector->p_MD2_Hash)(dest, src); 1.651 +} 1.652 + 1.653 +MD2Context * 1.654 +MD2_NewContext(void) 1.655 +{ 1.656 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.657 + return NULL; 1.658 + return (vector->p_MD2_NewContext)(); 1.659 +} 1.660 + 1.661 +void 1.662 +MD2_DestroyContext(MD2Context *cx, PRBool freeit) 1.663 +{ 1.664 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.665 + return ; 1.666 + (vector->p_MD2_DestroyContext)(cx, freeit); 1.667 +} 1.668 + 1.669 +void 1.670 +MD2_Begin(MD2Context *cx) 1.671 +{ 1.672 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.673 + return ; 1.674 + (vector->p_MD2_Begin)(cx); 1.675 +} 1.676 + 1.677 +void 1.678 +MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen) 1.679 +{ 1.680 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.681 + return ; 1.682 + (vector->p_MD2_Update)(cx, input, inputLen); 1.683 +} 1.684 + 1.685 +void 1.686 +MD2_End(MD2Context *cx, unsigned char *digest, 1.687 + unsigned int *digestLen, unsigned int maxDigestLen) 1.688 +{ 1.689 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.690 + return ; 1.691 + (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); 1.692 +} 1.693 + 1.694 +unsigned int 1.695 +MD2_FlattenSize(MD2Context *cx) 1.696 +{ 1.697 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.698 + return 0; 1.699 + return (vector->p_MD2_FlattenSize)(cx); 1.700 +} 1.701 + 1.702 +SECStatus 1.703 +MD2_Flatten(MD2Context *cx,unsigned char *space) 1.704 +{ 1.705 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.706 + return SECFailure; 1.707 + return (vector->p_MD2_Flatten)(cx, space); 1.708 +} 1.709 + 1.710 +MD2Context * 1.711 +MD2_Resurrect(unsigned char *space, void *arg) 1.712 +{ 1.713 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.714 + return NULL; 1.715 + return (vector->p_MD2_Resurrect)(space, arg); 1.716 +} 1.717 + 1.718 + 1.719 +SECStatus 1.720 +SHA1_Hash(unsigned char *dest, const char *src) 1.721 +{ 1.722 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.723 + return SECFailure; 1.724 + return (vector->p_SHA1_Hash)(dest, src); 1.725 +} 1.726 + 1.727 +SECStatus 1.728 +SHA1_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.729 +{ 1.730 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.731 + return SECFailure; 1.732 + return (vector->p_SHA1_HashBuf)(dest, src, src_length); 1.733 +} 1.734 + 1.735 +SHA1Context * 1.736 +SHA1_NewContext(void) 1.737 +{ 1.738 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.739 + return NULL; 1.740 + return (vector->p_SHA1_NewContext)(); 1.741 +} 1.742 + 1.743 +void 1.744 +SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) 1.745 +{ 1.746 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.747 + return ; 1.748 + (vector->p_SHA1_DestroyContext)(cx, freeit); 1.749 +} 1.750 + 1.751 +void 1.752 +SHA1_Begin(SHA1Context *cx) 1.753 +{ 1.754 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.755 + return ; 1.756 + (vector->p_SHA1_Begin)(cx); 1.757 +} 1.758 + 1.759 +void 1.760 +SHA1_Update(SHA1Context *cx, const unsigned char *input, 1.761 + unsigned int inputLen) 1.762 +{ 1.763 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.764 + return ; 1.765 + (vector->p_SHA1_Update)(cx, input, inputLen); 1.766 +} 1.767 + 1.768 +void 1.769 +SHA1_End(SHA1Context *cx, unsigned char *digest, 1.770 + unsigned int *digestLen, unsigned int maxDigestLen) 1.771 +{ 1.772 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.773 + return ; 1.774 + (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); 1.775 +} 1.776 + 1.777 +void 1.778 +SHA1_TraceState(SHA1Context *cx) 1.779 +{ 1.780 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.781 + return ; 1.782 + (vector->p_SHA1_TraceState)(cx); 1.783 +} 1.784 + 1.785 +unsigned int 1.786 +SHA1_FlattenSize(SHA1Context *cx) 1.787 +{ 1.788 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.789 + return 0; 1.790 + return (vector->p_SHA1_FlattenSize)(cx); 1.791 +} 1.792 + 1.793 +SECStatus 1.794 +SHA1_Flatten(SHA1Context *cx,unsigned char *space) 1.795 +{ 1.796 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.797 + return SECFailure; 1.798 + return (vector->p_SHA1_Flatten)(cx, space); 1.799 +} 1.800 + 1.801 +SHA1Context * 1.802 +SHA1_Resurrect(unsigned char *space, void *arg) 1.803 +{ 1.804 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.805 + return NULL; 1.806 + return (vector->p_SHA1_Resurrect)(space, arg); 1.807 +} 1.808 + 1.809 +SECStatus 1.810 +RNG_RNGInit(void) 1.811 +{ 1.812 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.813 + return SECFailure; 1.814 + return (vector->p_RNG_RNGInit)(); 1.815 +} 1.816 + 1.817 +SECStatus 1.818 +RNG_RandomUpdate(const void *data, size_t bytes) 1.819 +{ 1.820 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.821 + return SECFailure; 1.822 + return (vector->p_RNG_RandomUpdate)(data, bytes); 1.823 +} 1.824 + 1.825 +SECStatus 1.826 +RNG_GenerateGlobalRandomBytes(void *dest, size_t len) 1.827 +{ 1.828 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.829 + return SECFailure; 1.830 + return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); 1.831 +} 1.832 + 1.833 +void 1.834 +RNG_RNGShutdown(void) 1.835 +{ 1.836 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.837 + return ; 1.838 + (vector->p_RNG_RNGShutdown)(); 1.839 +} 1.840 + 1.841 +SECStatus 1.842 +PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) 1.843 +{ 1.844 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.845 + return SECFailure; 1.846 + return (vector->p_PQG_ParamGen)(j, pParams, pVfy); 1.847 +} 1.848 + 1.849 +SECStatus 1.850 +PQG_ParamGenSeedLen( unsigned int j, unsigned int seedBytes, 1.851 + PQGParams **pParams, PQGVerify **pVfy) 1.852 +{ 1.853 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.854 + return SECFailure; 1.855 + return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); 1.856 +} 1.857 + 1.858 + 1.859 +SECStatus 1.860 +PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, 1.861 + SECStatus *result) 1.862 +{ 1.863 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.864 + return SECFailure; 1.865 + return (vector->p_PQG_VerifyParams)(params, vfy, result); 1.866 +} 1.867 + 1.868 +void 1.869 +PQG_DestroyParams(PQGParams *params) 1.870 +{ 1.871 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.872 + return; 1.873 + (vector->p_PQG_DestroyParams)(params); 1.874 +} 1.875 + 1.876 +void 1.877 +PQG_DestroyVerify(PQGVerify *vfy) 1.878 +{ 1.879 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.880 + return; 1.881 + (vector->p_PQG_DestroyVerify)(vfy); 1.882 +} 1.883 + 1.884 +void 1.885 +BL_Cleanup(void) 1.886 +{ 1.887 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.888 + return; 1.889 + (vector->p_BL_Cleanup)(); 1.890 +} 1.891 + 1.892 +void 1.893 +BL_Unload(void) 1.894 +{ 1.895 + /* This function is not thread-safe, but doesn't need to be, because it is 1.896 + * only called from functions that are also defined as not thread-safe, 1.897 + * namely C_Finalize in softoken, and the SSL bypass shutdown callback called 1.898 + * from NSS_Shutdown. */ 1.899 + char *disableUnload = NULL; 1.900 + vector = NULL; 1.901 + /* If an SSL socket is configured with SSL_BYPASS_PKCS11, but the application 1.902 + * never does a handshake on it, BL_Unload will be called even though freebl 1.903 + * was never loaded. So, don't assert blLib. */ 1.904 + if (blLib) { 1.905 + disableUnload = PR_GetEnv("NSS_DISABLE_UNLOAD"); 1.906 + if (!disableUnload) { 1.907 + PRStatus status = PR_UnloadLibrary(blLib); 1.908 + PORT_Assert(PR_SUCCESS == status); 1.909 + } 1.910 + blLib = NULL; 1.911 + } 1.912 + loadFreeBLOnce = pristineCallOnce; 1.913 +} 1.914 + 1.915 +/* ============== New for 3.003 =============================== */ 1.916 + 1.917 +SECStatus 1.918 +SHA256_Hash(unsigned char *dest, const char *src) 1.919 +{ 1.920 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.921 + return SECFailure; 1.922 + return (vector->p_SHA256_Hash)(dest, src); 1.923 +} 1.924 + 1.925 +SECStatus 1.926 +SHA256_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.927 +{ 1.928 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.929 + return SECFailure; 1.930 + return (vector->p_SHA256_HashBuf)(dest, src, src_length); 1.931 +} 1.932 + 1.933 +SHA256Context * 1.934 +SHA256_NewContext(void) 1.935 +{ 1.936 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.937 + return NULL; 1.938 + return (vector->p_SHA256_NewContext)(); 1.939 +} 1.940 + 1.941 +void 1.942 +SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) 1.943 +{ 1.944 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.945 + return ; 1.946 + (vector->p_SHA256_DestroyContext)(cx, freeit); 1.947 +} 1.948 + 1.949 +void 1.950 +SHA256_Begin(SHA256Context *cx) 1.951 +{ 1.952 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.953 + return ; 1.954 + (vector->p_SHA256_Begin)(cx); 1.955 +} 1.956 + 1.957 +void 1.958 +SHA256_Update(SHA256Context *cx, const unsigned char *input, 1.959 + unsigned int inputLen) 1.960 +{ 1.961 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.962 + return ; 1.963 + (vector->p_SHA256_Update)(cx, input, inputLen); 1.964 +} 1.965 + 1.966 +void 1.967 +SHA256_End(SHA256Context *cx, unsigned char *digest, 1.968 + unsigned int *digestLen, unsigned int maxDigestLen) 1.969 +{ 1.970 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.971 + return ; 1.972 + (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); 1.973 +} 1.974 + 1.975 +void 1.976 +SHA256_TraceState(SHA256Context *cx) 1.977 +{ 1.978 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.979 + return ; 1.980 + (vector->p_SHA256_TraceState)(cx); 1.981 +} 1.982 + 1.983 +unsigned int 1.984 +SHA256_FlattenSize(SHA256Context *cx) 1.985 +{ 1.986 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.987 + return 0; 1.988 + return (vector->p_SHA256_FlattenSize)(cx); 1.989 +} 1.990 + 1.991 +SECStatus 1.992 +SHA256_Flatten(SHA256Context *cx,unsigned char *space) 1.993 +{ 1.994 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.995 + return SECFailure; 1.996 + return (vector->p_SHA256_Flatten)(cx, space); 1.997 +} 1.998 + 1.999 +SHA256Context * 1.1000 +SHA256_Resurrect(unsigned char *space, void *arg) 1.1001 +{ 1.1002 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1003 + return NULL; 1.1004 + return (vector->p_SHA256_Resurrect)(space, arg); 1.1005 +} 1.1006 + 1.1007 +SECStatus 1.1008 +SHA512_Hash(unsigned char *dest, const char *src) 1.1009 +{ 1.1010 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1011 + return SECFailure; 1.1012 + return (vector->p_SHA512_Hash)(dest, src); 1.1013 +} 1.1014 + 1.1015 +SECStatus 1.1016 +SHA512_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.1017 +{ 1.1018 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1019 + return SECFailure; 1.1020 + return (vector->p_SHA512_HashBuf)(dest, src, src_length); 1.1021 +} 1.1022 + 1.1023 +SHA512Context * 1.1024 +SHA512_NewContext(void) 1.1025 +{ 1.1026 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1027 + return NULL; 1.1028 + return (vector->p_SHA512_NewContext)(); 1.1029 +} 1.1030 + 1.1031 +void 1.1032 +SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) 1.1033 +{ 1.1034 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1035 + return ; 1.1036 + (vector->p_SHA512_DestroyContext)(cx, freeit); 1.1037 +} 1.1038 + 1.1039 +void 1.1040 +SHA512_Begin(SHA512Context *cx) 1.1041 +{ 1.1042 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1043 + return ; 1.1044 + (vector->p_SHA512_Begin)(cx); 1.1045 +} 1.1046 + 1.1047 +void 1.1048 +SHA512_Update(SHA512Context *cx, const unsigned char *input, 1.1049 + unsigned int inputLen) 1.1050 +{ 1.1051 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1052 + return ; 1.1053 + (vector->p_SHA512_Update)(cx, input, inputLen); 1.1054 +} 1.1055 + 1.1056 +void 1.1057 +SHA512_End(SHA512Context *cx, unsigned char *digest, 1.1058 + unsigned int *digestLen, unsigned int maxDigestLen) 1.1059 +{ 1.1060 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1061 + return ; 1.1062 + (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); 1.1063 +} 1.1064 + 1.1065 +void 1.1066 +SHA512_TraceState(SHA512Context *cx) 1.1067 +{ 1.1068 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1069 + return ; 1.1070 + (vector->p_SHA512_TraceState)(cx); 1.1071 +} 1.1072 + 1.1073 +unsigned int 1.1074 +SHA512_FlattenSize(SHA512Context *cx) 1.1075 +{ 1.1076 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1077 + return 0; 1.1078 + return (vector->p_SHA512_FlattenSize)(cx); 1.1079 +} 1.1080 + 1.1081 +SECStatus 1.1082 +SHA512_Flatten(SHA512Context *cx,unsigned char *space) 1.1083 +{ 1.1084 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1085 + return SECFailure; 1.1086 + return (vector->p_SHA512_Flatten)(cx, space); 1.1087 +} 1.1088 + 1.1089 +SHA512Context * 1.1090 +SHA512_Resurrect(unsigned char *space, void *arg) 1.1091 +{ 1.1092 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1093 + return NULL; 1.1094 + return (vector->p_SHA512_Resurrect)(space, arg); 1.1095 +} 1.1096 + 1.1097 + 1.1098 +SECStatus 1.1099 +SHA384_Hash(unsigned char *dest, const char *src) 1.1100 +{ 1.1101 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1102 + return SECFailure; 1.1103 + return (vector->p_SHA384_Hash)(dest, src); 1.1104 +} 1.1105 + 1.1106 +SECStatus 1.1107 +SHA384_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.1108 +{ 1.1109 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1110 + return SECFailure; 1.1111 + return (vector->p_SHA384_HashBuf)(dest, src, src_length); 1.1112 +} 1.1113 + 1.1114 +SHA384Context * 1.1115 +SHA384_NewContext(void) 1.1116 +{ 1.1117 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1118 + return NULL; 1.1119 + return (vector->p_SHA384_NewContext)(); 1.1120 +} 1.1121 + 1.1122 +void 1.1123 +SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) 1.1124 +{ 1.1125 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1126 + return ; 1.1127 + (vector->p_SHA384_DestroyContext)(cx, freeit); 1.1128 +} 1.1129 + 1.1130 +void 1.1131 +SHA384_Begin(SHA384Context *cx) 1.1132 +{ 1.1133 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1134 + return ; 1.1135 + (vector->p_SHA384_Begin)(cx); 1.1136 +} 1.1137 + 1.1138 +void 1.1139 +SHA384_Update(SHA384Context *cx, const unsigned char *input, 1.1140 + unsigned int inputLen) 1.1141 +{ 1.1142 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1143 + return ; 1.1144 + (vector->p_SHA384_Update)(cx, input, inputLen); 1.1145 +} 1.1146 + 1.1147 +void 1.1148 +SHA384_End(SHA384Context *cx, unsigned char *digest, 1.1149 + unsigned int *digestLen, unsigned int maxDigestLen) 1.1150 +{ 1.1151 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1152 + return ; 1.1153 + (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); 1.1154 +} 1.1155 + 1.1156 +void 1.1157 +SHA384_TraceState(SHA384Context *cx) 1.1158 +{ 1.1159 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1160 + return ; 1.1161 + (vector->p_SHA384_TraceState)(cx); 1.1162 +} 1.1163 + 1.1164 +unsigned int 1.1165 +SHA384_FlattenSize(SHA384Context *cx) 1.1166 +{ 1.1167 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1168 + return 0; 1.1169 + return (vector->p_SHA384_FlattenSize)(cx); 1.1170 +} 1.1171 + 1.1172 +SECStatus 1.1173 +SHA384_Flatten(SHA384Context *cx,unsigned char *space) 1.1174 +{ 1.1175 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1176 + return SECFailure; 1.1177 + return (vector->p_SHA384_Flatten)(cx, space); 1.1178 +} 1.1179 + 1.1180 +SHA384Context * 1.1181 +SHA384_Resurrect(unsigned char *space, void *arg) 1.1182 +{ 1.1183 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1184 + return NULL; 1.1185 + return (vector->p_SHA384_Resurrect)(space, arg); 1.1186 +} 1.1187 + 1.1188 + 1.1189 +AESKeyWrapContext * 1.1190 +AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv, 1.1191 + int encrypt, unsigned int keylen) 1.1192 +{ 1.1193 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1194 + return NULL; 1.1195 + return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); 1.1196 +} 1.1197 + 1.1198 +void 1.1199 +AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) 1.1200 +{ 1.1201 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1202 + return; 1.1203 + vector->p_AESKeyWrap_DestroyContext(cx, freeit); 1.1204 +} 1.1205 + 1.1206 +SECStatus 1.1207 +AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, 1.1208 + unsigned int *outputLen, unsigned int maxOutputLen, 1.1209 + const unsigned char *input, unsigned int inputLen) 1.1210 +{ 1.1211 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1212 + return SECFailure; 1.1213 + return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, 1.1214 + input, inputLen); 1.1215 +} 1.1216 +SECStatus 1.1217 +AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, 1.1218 + unsigned int *outputLen, unsigned int maxOutputLen, 1.1219 + const unsigned char *input, unsigned int inputLen) 1.1220 +{ 1.1221 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1222 + return SECFailure; 1.1223 + return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, 1.1224 + input, inputLen); 1.1225 +} 1.1226 + 1.1227 +PRBool 1.1228 +BLAPI_SHVerify(const char *name, PRFuncPtr addr) 1.1229 +{ 1.1230 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1231 + return PR_FALSE; 1.1232 + return vector->p_BLAPI_SHVerify(name, addr); 1.1233 +} 1.1234 + 1.1235 +/* 1.1236 + * The Caller is expected to pass NULL as the name, which will 1.1237 + * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. Pass the real 1.1238 + * name of the shared library we loaded (the static libraryName set 1.1239 + * in freebl_LoadDSO) to p_BLAPI_VerifySelf. 1.1240 + */ 1.1241 +PRBool 1.1242 +BLAPI_VerifySelf(const char *name) 1.1243 +{ 1.1244 + PORT_Assert(!name); 1.1245 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1246 + return PR_FALSE; 1.1247 + return vector->p_BLAPI_VerifySelf(libraryName); 1.1248 +} 1.1249 + 1.1250 +/* ============== New for 3.006 =============================== */ 1.1251 + 1.1252 +SECStatus 1.1253 +EC_NewKey(ECParams * params, ECPrivateKey ** privKey) 1.1254 +{ 1.1255 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1256 + return SECFailure; 1.1257 + return (vector->p_EC_NewKey)( params, privKey ); 1.1258 +} 1.1259 + 1.1260 +SECStatus 1.1261 +EC_NewKeyFromSeed(ECParams * params, ECPrivateKey ** privKey, 1.1262 + const unsigned char *seed, int seedlen) 1.1263 +{ 1.1264 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1265 + return SECFailure; 1.1266 + return (vector->p_EC_NewKeyFromSeed)( params, privKey, seed, seedlen ); 1.1267 +} 1.1268 + 1.1269 +SECStatus 1.1270 +EC_ValidatePublicKey(ECParams * params, SECItem * publicValue) 1.1271 +{ 1.1272 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1273 + return SECFailure; 1.1274 + return (vector->p_EC_ValidatePublicKey)( params, publicValue ); 1.1275 +} 1.1276 + 1.1277 +SECStatus 1.1278 +ECDH_Derive(SECItem * publicValue, ECParams * params, SECItem * privateValue, 1.1279 + PRBool withCofactor, SECItem * derivedSecret) 1.1280 +{ 1.1281 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1282 + return SECFailure; 1.1283 + return (vector->p_ECDH_Derive)( publicValue, params, privateValue, 1.1284 + withCofactor, derivedSecret ); 1.1285 +} 1.1286 + 1.1287 +SECStatus 1.1288 +ECDSA_SignDigest(ECPrivateKey * key, SECItem * signature, 1.1289 + const SECItem * digest) 1.1290 +{ 1.1291 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1292 + return SECFailure; 1.1293 + return (vector->p_ECDSA_SignDigest)( key, signature, digest ); 1.1294 +} 1.1295 + 1.1296 +SECStatus 1.1297 +ECDSA_VerifyDigest(ECPublicKey * key, const SECItem * signature, 1.1298 + const SECItem * digest) 1.1299 +{ 1.1300 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1301 + return SECFailure; 1.1302 + return (vector->p_ECDSA_VerifyDigest)( key, signature, digest ); 1.1303 +} 1.1304 + 1.1305 +SECStatus 1.1306 +ECDSA_SignDigestWithSeed(ECPrivateKey * key, SECItem * signature, 1.1307 + const SECItem * digest, const unsigned char *seed, const int seedlen) 1.1308 +{ 1.1309 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1310 + return SECFailure; 1.1311 + return (vector->p_ECDSA_SignDigestWithSeed)( key, signature, digest, 1.1312 + seed, seedlen ); 1.1313 +} 1.1314 + 1.1315 +/* ============== New for 3.008 =============================== */ 1.1316 + 1.1317 +AESContext * 1.1318 +AES_AllocateContext(void) 1.1319 +{ 1.1320 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1321 + return NULL; 1.1322 + return (vector->p_AES_AllocateContext)(); 1.1323 +} 1.1324 + 1.1325 +AESKeyWrapContext * 1.1326 +AESKeyWrap_AllocateContext(void) 1.1327 +{ 1.1328 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1329 + return NULL; 1.1330 + return (vector->p_AESKeyWrap_AllocateContext)(); 1.1331 +} 1.1332 + 1.1333 +DESContext * 1.1334 +DES_AllocateContext(void) 1.1335 +{ 1.1336 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1337 + return NULL; 1.1338 + return (vector->p_DES_AllocateContext)(); 1.1339 +} 1.1340 + 1.1341 +RC2Context * 1.1342 +RC2_AllocateContext(void) 1.1343 +{ 1.1344 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1345 + return NULL; 1.1346 + return (vector->p_RC2_AllocateContext)(); 1.1347 +} 1.1348 + 1.1349 +RC4Context * 1.1350 +RC4_AllocateContext(void) 1.1351 +{ 1.1352 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1353 + return NULL; 1.1354 + return (vector->p_RC4_AllocateContext)(); 1.1355 +} 1.1356 + 1.1357 +SECStatus 1.1358 +AES_InitContext(AESContext *cx, const unsigned char *key, 1.1359 + unsigned int keylen, const unsigned char *iv, int mode, 1.1360 + unsigned int encrypt, unsigned int blocklen) 1.1361 +{ 1.1362 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1363 + return SECFailure; 1.1364 + return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, 1.1365 + blocklen); 1.1366 +} 1.1367 + 1.1368 +SECStatus 1.1369 +AESKeyWrap_InitContext(AESKeyWrapContext *cx, const unsigned char *key, 1.1370 + unsigned int keylen, const unsigned char *iv, int mode, 1.1371 + unsigned int encrypt, unsigned int blocklen) 1.1372 +{ 1.1373 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1374 + return SECFailure; 1.1375 + return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, 1.1376 + encrypt, blocklen); 1.1377 +} 1.1378 + 1.1379 +SECStatus 1.1380 +DES_InitContext(DESContext *cx, const unsigned char *key, 1.1381 + unsigned int keylen, const unsigned char *iv, int mode, 1.1382 + unsigned int encrypt, unsigned int xtra) 1.1383 +{ 1.1384 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1385 + return SECFailure; 1.1386 + return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); 1.1387 +} 1.1388 + 1.1389 +SECStatus 1.1390 +SEED_InitContext(SEEDContext *cx, const unsigned char *key, 1.1391 + unsigned int keylen, const unsigned char *iv, int mode, 1.1392 + unsigned int encrypt, unsigned int xtra) 1.1393 +{ 1.1394 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1395 + return SECFailure; 1.1396 + return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); 1.1397 +} 1.1398 + 1.1399 +SECStatus 1.1400 +RC2_InitContext(RC2Context *cx, const unsigned char *key, 1.1401 + unsigned int keylen, const unsigned char *iv, int mode, 1.1402 + unsigned int effectiveKeyLen, unsigned int xtra) 1.1403 +{ 1.1404 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1405 + return SECFailure; 1.1406 + return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, 1.1407 + effectiveKeyLen, xtra); 1.1408 +} 1.1409 + 1.1410 +SECStatus 1.1411 +RC4_InitContext(RC4Context *cx, const unsigned char *key, 1.1412 + unsigned int keylen, const unsigned char *x1, int x2, 1.1413 + unsigned int x3, unsigned int x4) 1.1414 +{ 1.1415 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1416 + return SECFailure; 1.1417 + return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); 1.1418 +} 1.1419 + 1.1420 +void 1.1421 +MD2_Clone(MD2Context *dest, MD2Context *src) 1.1422 +{ 1.1423 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1424 + return; 1.1425 + (vector->p_MD2_Clone)(dest, src); 1.1426 +} 1.1427 + 1.1428 +void 1.1429 +MD5_Clone(MD5Context *dest, MD5Context *src) 1.1430 +{ 1.1431 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1432 + return; 1.1433 + (vector->p_MD5_Clone)(dest, src); 1.1434 +} 1.1435 + 1.1436 +void 1.1437 +SHA1_Clone(SHA1Context *dest, SHA1Context *src) 1.1438 +{ 1.1439 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1440 + return; 1.1441 + (vector->p_SHA1_Clone)(dest, src); 1.1442 +} 1.1443 + 1.1444 +void 1.1445 +SHA256_Clone(SHA256Context *dest, SHA256Context *src) 1.1446 +{ 1.1447 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1448 + return; 1.1449 + (vector->p_SHA256_Clone)(dest, src); 1.1450 +} 1.1451 + 1.1452 +void 1.1453 +SHA384_Clone(SHA384Context *dest, SHA384Context *src) 1.1454 +{ 1.1455 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1456 + return; 1.1457 + (vector->p_SHA384_Clone)(dest, src); 1.1458 +} 1.1459 + 1.1460 +void 1.1461 +SHA512_Clone(SHA512Context *dest, SHA512Context *src) 1.1462 +{ 1.1463 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1464 + return; 1.1465 + (vector->p_SHA512_Clone)(dest, src); 1.1466 +} 1.1467 + 1.1468 +SECStatus 1.1469 +TLS_PRF(const SECItem *secret, const char *label, 1.1470 + SECItem *seed, SECItem *result, PRBool isFIPS) 1.1471 +{ 1.1472 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1473 + return SECFailure; 1.1474 + return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); 1.1475 +} 1.1476 + 1.1477 +const SECHashObject * 1.1478 +HASH_GetRawHashObject(HASH_HashType hashType) 1.1479 +{ 1.1480 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1481 + return NULL; 1.1482 + return (vector->p_HASH_GetRawHashObject)(hashType); 1.1483 +} 1.1484 + 1.1485 + 1.1486 +void 1.1487 +HMAC_Destroy(HMACContext *cx, PRBool freeit) 1.1488 +{ 1.1489 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1490 + return; 1.1491 + (vector->p_HMAC_Destroy)(cx, freeit); 1.1492 +} 1.1493 + 1.1494 +HMACContext * 1.1495 +HMAC_Create(const SECHashObject *hashObj, const unsigned char *secret, 1.1496 + unsigned int secret_len, PRBool isFIPS) 1.1497 +{ 1.1498 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1499 + return NULL; 1.1500 + return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); 1.1501 +} 1.1502 + 1.1503 +SECStatus 1.1504 +HMAC_Init(HMACContext *cx, const SECHashObject *hashObj, 1.1505 + const unsigned char *secret, unsigned int secret_len, PRBool isFIPS) 1.1506 +{ 1.1507 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1508 + return SECFailure; 1.1509 + return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); 1.1510 +} 1.1511 + 1.1512 +void 1.1513 +HMAC_Begin(HMACContext *cx) 1.1514 +{ 1.1515 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1516 + return; 1.1517 + (vector->p_HMAC_Begin)(cx); 1.1518 +} 1.1519 + 1.1520 +void 1.1521 +HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) 1.1522 +{ 1.1523 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1524 + return; 1.1525 + (vector->p_HMAC_Update)(cx, data, data_len); 1.1526 +} 1.1527 + 1.1528 +SECStatus 1.1529 +HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, 1.1530 + unsigned int max_result_len) 1.1531 +{ 1.1532 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1533 + return SECFailure; 1.1534 + return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); 1.1535 +} 1.1536 + 1.1537 +HMACContext * 1.1538 +HMAC_Clone(HMACContext *cx) 1.1539 +{ 1.1540 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1541 + return NULL; 1.1542 + return (vector->p_HMAC_Clone)(cx); 1.1543 +} 1.1544 + 1.1545 +void 1.1546 +RNG_SystemInfoForRNG(void) 1.1547 +{ 1.1548 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1549 + return ; 1.1550 + (vector->p_RNG_SystemInfoForRNG)(); 1.1551 + 1.1552 +} 1.1553 + 1.1554 +SECStatus 1.1555 +FIPS186Change_GenerateX(unsigned char *XKEY, const unsigned char *XSEEDj, 1.1556 + unsigned char *x_j) 1.1557 +{ 1.1558 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1559 + return SECFailure; 1.1560 + return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); 1.1561 +} 1.1562 + 1.1563 +SECStatus 1.1564 +FIPS186Change_ReduceModQForDSA(const unsigned char *w, 1.1565 + const unsigned char *q, 1.1566 + unsigned char *xj) 1.1567 +{ 1.1568 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1569 + return SECFailure; 1.1570 + return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); 1.1571 +} 1.1572 + 1.1573 +/* === new for Camellia === */ 1.1574 +SECStatus 1.1575 +Camellia_InitContext(CamelliaContext *cx, const unsigned char *key, 1.1576 + unsigned int keylen, const unsigned char *iv, int mode, 1.1577 + unsigned int encrypt, unsigned int unused) 1.1578 +{ 1.1579 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1580 + return SECFailure; 1.1581 + return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, 1.1582 + unused); 1.1583 +} 1.1584 + 1.1585 +CamelliaContext * 1.1586 +Camellia_AllocateContext(void) 1.1587 +{ 1.1588 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1589 + return NULL; 1.1590 + return (vector->p_Camellia_AllocateContext)(); 1.1591 +} 1.1592 + 1.1593 + 1.1594 +CamelliaContext * 1.1595 +Camellia_CreateContext(const unsigned char *key, const unsigned char *iv, 1.1596 + int mode, int encrypt, 1.1597 + unsigned int keylen) 1.1598 +{ 1.1599 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1600 + return NULL; 1.1601 + return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); 1.1602 +} 1.1603 + 1.1604 +void 1.1605 +Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) 1.1606 +{ 1.1607 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1608 + return ; 1.1609 + (vector->p_Camellia_DestroyContext)(cx, freeit); 1.1610 +} 1.1611 + 1.1612 +SECStatus 1.1613 +Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, 1.1614 + unsigned int *outputLen, unsigned int maxOutputLen, 1.1615 + const unsigned char *input, unsigned int inputLen) 1.1616 +{ 1.1617 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1618 + return SECFailure; 1.1619 + return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen, 1.1620 + input, inputLen); 1.1621 +} 1.1622 + 1.1623 +SECStatus 1.1624 +Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, 1.1625 + unsigned int *outputLen, unsigned int maxOutputLen, 1.1626 + const unsigned char *input, unsigned int inputLen) 1.1627 +{ 1.1628 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1629 + return SECFailure; 1.1630 + return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen, 1.1631 + input, inputLen); 1.1632 +} 1.1633 + 1.1634 +void BL_SetForkState(PRBool forked) 1.1635 +{ 1.1636 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1637 + return; 1.1638 + (vector->p_BL_SetForkState)(forked); 1.1639 +} 1.1640 + 1.1641 +SECStatus 1.1642 +PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, 1.1643 + const PRUint8 *nonce, unsigned int nonce_len, 1.1644 + const PRUint8 *personal_string, unsigned int ps_len) 1.1645 +{ 1.1646 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1647 + return SECFailure; 1.1648 + return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, 1.1649 + nonce, nonce_len, 1.1650 + personal_string, ps_len); 1.1651 +} 1.1652 + 1.1653 +SECStatus 1.1654 +PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, 1.1655 + const PRUint8 *additional, unsigned int additional_len) 1.1656 +{ 1.1657 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1658 + return SECFailure; 1.1659 + return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, 1.1660 + additional, additional_len); 1.1661 +} 1.1662 + 1.1663 +SECStatus 1.1664 +PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, 1.1665 + const PRUint8 *additional, unsigned int additional_len) 1.1666 +{ 1.1667 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1668 + return SECFailure; 1.1669 + return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, 1.1670 + additional, additional_len); 1.1671 +} 1.1672 + 1.1673 +SECStatus 1.1674 +PRNGTEST_Uninstantiate() 1.1675 +{ 1.1676 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1677 + return SECFailure; 1.1678 + return (vector->p_PRNGTEST_Uninstantiate)(); 1.1679 +} 1.1680 + 1.1681 +SECStatus 1.1682 +RSA_PopulatePrivateKey(RSAPrivateKey *key) 1.1683 +{ 1.1684 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1685 + return SECFailure; 1.1686 + return (vector->p_RSA_PopulatePrivateKey)(key); 1.1687 +} 1.1688 + 1.1689 + 1.1690 +SECStatus 1.1691 +JPAKE_Sign(PLArenaPool * arena, const PQGParams * pqg, HASH_HashType hashType, 1.1692 + const SECItem * signerID, const SECItem * x, 1.1693 + const SECItem * testRandom, const SECItem * gxIn, SECItem * gxOut, 1.1694 + SECItem * gv, SECItem * r) 1.1695 +{ 1.1696 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1697 + return SECFailure; 1.1698 + return (vector->p_JPAKE_Sign)(arena, pqg, hashType, signerID, x, 1.1699 + testRandom, gxIn, gxOut, gv, r); 1.1700 +} 1.1701 + 1.1702 +SECStatus 1.1703 +JPAKE_Verify(PLArenaPool * arena, const PQGParams * pqg, 1.1704 + HASH_HashType hashType, const SECItem * signerID, 1.1705 + const SECItem * peerID, const SECItem * gx, 1.1706 + const SECItem * gv, const SECItem * r) 1.1707 +{ 1.1708 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1709 + return SECFailure; 1.1710 + return (vector->p_JPAKE_Verify)(arena, pqg, hashType, signerID, peerID, 1.1711 + gx, gv, r); 1.1712 +} 1.1713 + 1.1714 +SECStatus 1.1715 +JPAKE_Round2(PLArenaPool * arena, const SECItem * p, const SECItem *q, 1.1716 + const SECItem * gx1, const SECItem * gx3, const SECItem * gx4, 1.1717 + SECItem * base, const SECItem * x2, const SECItem * s, SECItem * x2s) 1.1718 +{ 1.1719 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1720 + return SECFailure; 1.1721 + return (vector->p_JPAKE_Round2)(arena, p, q, gx1, gx3, gx4, base, x2, s, x2s); 1.1722 +} 1.1723 + 1.1724 +SECStatus 1.1725 +JPAKE_Final(PLArenaPool * arena, const SECItem * p, const SECItem *q, 1.1726 + const SECItem * x2, const SECItem * gx4, const SECItem * x2s, 1.1727 + const SECItem * B, SECItem * K) 1.1728 +{ 1.1729 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1730 + return SECFailure; 1.1731 + return (vector->p_JPAKE_Final)(arena, p, q, x2, gx4, x2s, B, K); 1.1732 +} 1.1733 + 1.1734 +SECStatus 1.1735 +TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, const char *label, 1.1736 + SECItem *seed, SECItem *result, PRBool isFIPS) 1.1737 +{ 1.1738 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1739 + return SECFailure; 1.1740 + return (vector->p_TLS_P_hash)(hashAlg, secret, label, seed, result, isFIPS); 1.1741 +} 1.1742 + 1.1743 +SECStatus 1.1744 +SHA224_Hash(unsigned char *dest, const char *src) 1.1745 +{ 1.1746 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1747 + return SECFailure; 1.1748 + return (vector->p_SHA224_Hash)(dest, src); 1.1749 +} 1.1750 + 1.1751 +SECStatus 1.1752 +SHA224_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1.1753 +{ 1.1754 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1755 + return SECFailure; 1.1756 + return (vector->p_SHA224_HashBuf)(dest, src, src_length); 1.1757 +} 1.1758 + 1.1759 +SHA224Context * 1.1760 +SHA224_NewContext(void) 1.1761 +{ 1.1762 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1763 + return NULL; 1.1764 + return (vector->p_SHA224_NewContext)(); 1.1765 +} 1.1766 + 1.1767 +void 1.1768 +SHA224_DestroyContext(SHA224Context *cx, PRBool freeit) 1.1769 +{ 1.1770 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1771 + return; 1.1772 + (vector->p_SHA224_DestroyContext)(cx, freeit); 1.1773 +} 1.1774 + 1.1775 +void 1.1776 +SHA224_Begin(SHA256Context *cx) 1.1777 +{ 1.1778 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1779 + return; 1.1780 + (vector->p_SHA224_Begin)(cx); 1.1781 +} 1.1782 + 1.1783 +void 1.1784 +SHA224_Update(SHA224Context *cx, const unsigned char *input, 1.1785 + unsigned int inputLen) 1.1786 +{ 1.1787 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1788 + return; 1.1789 + (vector->p_SHA224_Update)(cx, input, inputLen); 1.1790 +} 1.1791 + 1.1792 +void 1.1793 +SHA224_End(SHA224Context *cx, unsigned char *digest, 1.1794 + unsigned int *digestLen, unsigned int maxDigestLen) 1.1795 +{ 1.1796 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1797 + return; 1.1798 + (vector->p_SHA224_End)(cx, digest, digestLen, maxDigestLen); 1.1799 +} 1.1800 + 1.1801 +void 1.1802 +SHA224_TraceState(SHA224Context *cx) 1.1803 +{ 1.1804 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1805 + return; 1.1806 + (vector->p_SHA224_TraceState)(cx); 1.1807 +} 1.1808 + 1.1809 +unsigned int 1.1810 +SHA224_FlattenSize(SHA224Context *cx) 1.1811 +{ 1.1812 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1813 + return 0; 1.1814 + return (vector->p_SHA224_FlattenSize)(cx); 1.1815 +} 1.1816 + 1.1817 +SECStatus 1.1818 +SHA224_Flatten(SHA224Context *cx,unsigned char *space) 1.1819 +{ 1.1820 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1821 + return SECFailure; 1.1822 + return (vector->p_SHA224_Flatten)(cx, space); 1.1823 +} 1.1824 + 1.1825 +SHA224Context * 1.1826 +SHA224_Resurrect(unsigned char *space, void *arg) 1.1827 +{ 1.1828 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1829 + return NULL; 1.1830 + return (vector->p_SHA224_Resurrect)(space, arg); 1.1831 +} 1.1832 + 1.1833 +void 1.1834 +SHA224_Clone(SHA224Context *dest, SHA224Context *src) 1.1835 +{ 1.1836 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1837 + return; 1.1838 + (vector->p_SHA224_Clone)(dest, src); 1.1839 +} 1.1840 + 1.1841 +PRBool 1.1842 +BLAPI_SHVerifyFile(const char *name) 1.1843 +{ 1.1844 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1845 + return PR_FALSE; 1.1846 + return vector->p_BLAPI_SHVerifyFile(name); 1.1847 +} 1.1848 + 1.1849 +/* === new for DSA-2 === */ 1.1850 +SECStatus 1.1851 +PQG_ParamGenV2( unsigned int L, unsigned int N, unsigned int seedBytes, 1.1852 + PQGParams **pParams, PQGVerify **pVfy) 1.1853 +{ 1.1854 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1855 + return SECFailure; 1.1856 + return (vector->p_PQG_ParamGenV2)(L, N, seedBytes, pParams, pVfy); 1.1857 +} 1.1858 + 1.1859 +SECStatus 1.1860 +PRNGTEST_RunHealthTests(void) 1.1861 +{ 1.1862 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1863 + return SECFailure; 1.1864 + return vector->p_PRNGTEST_RunHealthTests(); 1.1865 +} 1.1866 + 1.1867 +SECStatus 1.1868 +SSLv3_MAC_ConstantTime( 1.1869 + unsigned char *result, 1.1870 + unsigned int *resultLen, 1.1871 + unsigned int maxResultLen, 1.1872 + const SECHashObject *hashObj, 1.1873 + const unsigned char *secret, 1.1874 + unsigned int secretLen, 1.1875 + const unsigned char *header, 1.1876 + unsigned int headerLen, 1.1877 + const unsigned char *body, 1.1878 + unsigned int bodyLen, 1.1879 + unsigned int bodyTotalLen) 1.1880 +{ 1.1881 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1882 + return SECFailure; 1.1883 + return (vector->p_SSLv3_MAC_ConstantTime)( 1.1884 + result, resultLen, maxResultLen, 1.1885 + hashObj, 1.1886 + secret, secretLen, 1.1887 + header, headerLen, 1.1888 + body, bodyLen, bodyTotalLen); 1.1889 +} 1.1890 + 1.1891 +SECStatus 1.1892 +HMAC_ConstantTime( 1.1893 + unsigned char *result, 1.1894 + unsigned int *resultLen, 1.1895 + unsigned int maxResultLen, 1.1896 + const SECHashObject *hashObj, 1.1897 + const unsigned char *secret, 1.1898 + unsigned int secretLen, 1.1899 + const unsigned char *header, 1.1900 + unsigned int headerLen, 1.1901 + const unsigned char *body, 1.1902 + unsigned int bodyLen, 1.1903 + unsigned int bodyTotalLen) 1.1904 +{ 1.1905 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1906 + return SECFailure; 1.1907 + return (vector->p_HMAC_ConstantTime)( 1.1908 + result, resultLen, maxResultLen, 1.1909 + hashObj, 1.1910 + secret, secretLen, 1.1911 + header, headerLen, 1.1912 + body, bodyLen, bodyTotalLen); 1.1913 +} 1.1914 + 1.1915 +SECStatus RSA_SignRaw(RSAPrivateKey *key, 1.1916 + unsigned char *output, 1.1917 + unsigned int *outputLen, 1.1918 + unsigned int maxOutputLen, 1.1919 + const unsigned char *input, 1.1920 + unsigned int inputLen) { 1.1921 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1922 + return SECFailure; 1.1923 + return (vector->p_RSA_SignRaw)(key, output, outputLen, maxOutputLen, input, 1.1924 + inputLen); 1.1925 +} 1.1926 + 1.1927 +SECStatus RSA_CheckSignRaw(RSAPublicKey *key, 1.1928 + const unsigned char *sig, 1.1929 + unsigned int sigLen, 1.1930 + const unsigned char *hash, 1.1931 + unsigned int hashLen) { 1.1932 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1933 + return SECFailure; 1.1934 + return (vector->p_RSA_CheckSignRaw)(key, sig, sigLen, hash, hashLen); 1.1935 +} 1.1936 + 1.1937 +SECStatus RSA_CheckSignRecoverRaw(RSAPublicKey *key, 1.1938 + unsigned char *data, 1.1939 + unsigned int *dataLen, 1.1940 + unsigned int maxDataLen, 1.1941 + const unsigned char *sig, 1.1942 + unsigned int sigLen) { 1.1943 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1944 + return SECFailure; 1.1945 + return (vector->p_RSA_CheckSignRecoverRaw)(key, data, dataLen, maxDataLen, 1.1946 + sig, sigLen); 1.1947 +} 1.1948 + 1.1949 +SECStatus RSA_EncryptRaw(RSAPublicKey *key, 1.1950 + unsigned char *output, 1.1951 + unsigned int *outputLen, 1.1952 + unsigned int maxOutputLen, 1.1953 + const unsigned char *input, 1.1954 + unsigned int inputLen) { 1.1955 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1956 + return SECFailure; 1.1957 + return (vector->p_RSA_EncryptRaw)(key, output, outputLen, maxOutputLen, 1.1958 + input, inputLen); 1.1959 +} 1.1960 + 1.1961 +SECStatus RSA_DecryptRaw(RSAPrivateKey *key, 1.1962 + unsigned char *output, 1.1963 + unsigned int *outputLen, 1.1964 + unsigned int maxOutputLen, 1.1965 + const unsigned char *input, 1.1966 + unsigned int inputLen) { 1.1967 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1968 + return SECFailure; 1.1969 + return (vector->p_RSA_DecryptRaw)(key, output, outputLen, maxOutputLen, 1.1970 + input, inputLen); 1.1971 + 1.1972 +} 1.1973 + 1.1974 +SECStatus RSA_EncryptOAEP(RSAPublicKey *key, 1.1975 + HASH_HashType hashAlg, 1.1976 + HASH_HashType maskHashAlg, 1.1977 + const unsigned char *label, 1.1978 + unsigned int labelLen, 1.1979 + const unsigned char *seed, 1.1980 + unsigned int seedLen, 1.1981 + unsigned char *output, 1.1982 + unsigned int *outputLen, 1.1983 + unsigned int maxOutputLen, 1.1984 + const unsigned char *input, 1.1985 + unsigned int inputLen) { 1.1986 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.1987 + return SECFailure; 1.1988 + return (vector->p_RSA_EncryptOAEP)(key, hashAlg, maskHashAlg, label, 1.1989 + labelLen, seed, seedLen, output, 1.1990 + outputLen, maxOutputLen, input, inputLen); 1.1991 +} 1.1992 + 1.1993 +SECStatus RSA_DecryptOAEP(RSAPrivateKey *key, 1.1994 + HASH_HashType hashAlg, 1.1995 + HASH_HashType maskHashAlg, 1.1996 + const unsigned char *label, 1.1997 + unsigned int labelLen, 1.1998 + unsigned char *output, 1.1999 + unsigned int *outputLen, 1.2000 + unsigned int maxOutputLen, 1.2001 + const unsigned char *input, 1.2002 + unsigned int inputLen) { 1.2003 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2004 + return SECFailure; 1.2005 + return (vector->p_RSA_DecryptOAEP)(key, hashAlg, maskHashAlg, label, 1.2006 + labelLen, output, outputLen, 1.2007 + maxOutputLen, input, inputLen); 1.2008 +} 1.2009 + 1.2010 +SECStatus RSA_EncryptBlock(RSAPublicKey *key, 1.2011 + unsigned char *output, 1.2012 + unsigned int *outputLen, 1.2013 + unsigned int maxOutputLen, 1.2014 + const unsigned char *input, 1.2015 + unsigned int inputLen) { 1.2016 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2017 + return SECFailure; 1.2018 + return (vector->p_RSA_EncryptBlock)(key, output, outputLen, maxOutputLen, 1.2019 + input, inputLen); 1.2020 +} 1.2021 + 1.2022 +SECStatus RSA_DecryptBlock(RSAPrivateKey *key, 1.2023 + unsigned char *output, 1.2024 + unsigned int *outputLen, 1.2025 + unsigned int maxOutputLen, 1.2026 + const unsigned char *input, 1.2027 + unsigned int inputLen) { 1.2028 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2029 + return SECFailure; 1.2030 + return (vector->p_RSA_DecryptBlock)(key, output, outputLen, maxOutputLen, 1.2031 + input, inputLen); 1.2032 +} 1.2033 + 1.2034 +SECStatus RSA_SignPSS(RSAPrivateKey *key, 1.2035 + HASH_HashType hashAlg, 1.2036 + HASH_HashType maskHashAlg, 1.2037 + const unsigned char *salt, 1.2038 + unsigned int saltLen, 1.2039 + unsigned char *output, 1.2040 + unsigned int *outputLen, 1.2041 + unsigned int maxOutputLen, 1.2042 + const unsigned char *input, 1.2043 + unsigned int inputLen) { 1.2044 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2045 + return SECFailure; 1.2046 + return (vector->p_RSA_SignPSS)(key, hashAlg, maskHashAlg, salt, saltLen, 1.2047 + output, outputLen, maxOutputLen, input, 1.2048 + inputLen); 1.2049 +} 1.2050 + 1.2051 +SECStatus RSA_CheckSignPSS(RSAPublicKey *key, 1.2052 + HASH_HashType hashAlg, 1.2053 + HASH_HashType maskHashAlg, 1.2054 + unsigned int saltLen, 1.2055 + const unsigned char *sig, 1.2056 + unsigned int sigLen, 1.2057 + const unsigned char *hash, 1.2058 + unsigned int hashLen) { 1.2059 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2060 + return SECFailure; 1.2061 + return (vector->p_RSA_CheckSignPSS)(key, hashAlg, maskHashAlg, saltLen, 1.2062 + sig, sigLen, hash, hashLen); 1.2063 +} 1.2064 + 1.2065 +SECStatus RSA_Sign(RSAPrivateKey *key, 1.2066 + unsigned char *output, 1.2067 + unsigned int *outputLen, 1.2068 + unsigned int maxOutputLen, 1.2069 + const unsigned char *input, 1.2070 + unsigned int inputLen) { 1.2071 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2072 + return SECFailure; 1.2073 + return (vector->p_RSA_Sign)(key, output, outputLen, maxOutputLen, input, 1.2074 + inputLen); 1.2075 +} 1.2076 + 1.2077 +SECStatus RSA_CheckSign(RSAPublicKey *key, 1.2078 + const unsigned char *sig, 1.2079 + unsigned int sigLen, 1.2080 + const unsigned char *data, 1.2081 + unsigned int dataLen) { 1.2082 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2083 + return SECFailure; 1.2084 + return (vector->p_RSA_CheckSign)(key, sig, sigLen, data, dataLen); 1.2085 + 1.2086 +} 1.2087 + 1.2088 +SECStatus RSA_CheckSignRecover(RSAPublicKey *key, 1.2089 + unsigned char *output, 1.2090 + unsigned int *outputLen, 1.2091 + unsigned int maxOutputLen, 1.2092 + const unsigned char *sig, 1.2093 + unsigned int sigLen) { 1.2094 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2095 + return SECFailure; 1.2096 + return (vector->p_RSA_CheckSignRecover)(key, output, outputLen, maxOutputLen, 1.2097 + sig, sigLen); 1.2098 +} 1.2099 + 1.2100 +SECStatus EC_FillParams(PLArenaPool *arena, 1.2101 + const SECItem *encodedParams, 1.2102 + ECParams *params) 1.2103 +{ 1.2104 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2105 + return SECFailure; 1.2106 + return (vector->p_EC_FillParams)(arena, encodedParams, params); 1.2107 +} 1.2108 + 1.2109 +SECStatus EC_DecodeParams(const SECItem *encodedParams, 1.2110 + ECParams **ecparams) 1.2111 +{ 1.2112 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2113 + return SECFailure; 1.2114 + return (vector->p_EC_DecodeParams)(encodedParams, ecparams); 1.2115 +} 1.2116 + 1.2117 +SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, 1.2118 + const ECParams *srcParams) 1.2119 +{ 1.2120 + if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1.2121 + return SECFailure; 1.2122 + return (vector->p_EC_CopyParams)(arena, dstParams, srcParams); 1.2123 +} 1.2124 +