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