loader.c (84955B)
1 /* 2 * loader.c - load platform dependent DSO containing freebl implementation. 3 * 4 * This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #include "loader.h" 9 #include "prmem.h" 10 #include "prerror.h" 11 #include "prinit.h" 12 #include "prenv.h" 13 #include "blname.c" 14 15 #include "prio.h" 16 #include "prprf.h" 17 #include <stdio.h> 18 #include "prsystem.h" 19 20 static const char *NameOfThisSharedLib = 21 SHLIB_PREFIX "softokn" SOFTOKEN_SHLIB_VERSION "." SHLIB_SUFFIX; 22 23 static PRLibrary *blLib = NULL; 24 25 #define LSB(x) ((x)&0xff) 26 #define MSB(x) ((x) >> 8) 27 28 static const FREEBLVector *vector; 29 static const char *libraryName = NULL; 30 31 #include "genload.c" 32 33 /* This function must be run only once. */ 34 /* determine if hybrid platform, then actually load the DSO. */ 35 static PRStatus 36 freebl_LoadDSO(void) 37 { 38 PRLibrary *handle; 39 const char *name = getLibName(); 40 41 if (!name) { 42 PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); 43 return PR_FAILURE; 44 } 45 46 handle = loader_LoadLibrary(name); 47 if (handle) { 48 PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); 49 if (address) { 50 FREEBLGetVectorFn *getVector = (FREEBLGetVectorFn *)address; 51 const FREEBLVector *dsoVector = getVector(); 52 if (dsoVector) { 53 unsigned short dsoVersion = dsoVector->version; 54 unsigned short myVersion = FREEBL_VERSION; 55 if (MSB(dsoVersion) == MSB(myVersion) && 56 LSB(dsoVersion) >= LSB(myVersion) && 57 dsoVector->length >= sizeof(FREEBLVector)) { 58 vector = dsoVector; 59 libraryName = name; 60 blLib = handle; 61 return PR_SUCCESS; 62 } 63 } 64 } 65 #ifdef DEBUG 66 if (blLib) { 67 PRStatus status = PR_UnloadLibrary(blLib); 68 PORT_Assert(PR_SUCCESS == status); 69 } 70 #else 71 if (blLib) 72 PR_UnloadLibrary(blLib); 73 #endif 74 } 75 return PR_FAILURE; 76 } 77 78 static const PRCallOnceType pristineCallOnce; 79 static PRCallOnceType loadFreeBLOnce; 80 81 static PRStatus 82 freebl_RunLoaderOnce(void) 83 { 84 PRStatus status; 85 86 status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); 87 return status; 88 } 89 90 SECStatus 91 BL_Init(void) 92 { 93 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 94 return SECFailure; 95 return (vector->p_BL_Init)(); 96 } 97 98 RSAPrivateKey * 99 RSA_NewKey(int keySizeInBits, SECItem *publicExponent) 100 { 101 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 102 return NULL; 103 return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); 104 } 105 106 SECStatus 107 RSA_PublicKeyOp(RSAPublicKey *key, 108 unsigned char *output, 109 const unsigned char *input) 110 { 111 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 112 return SECFailure; 113 return (vector->p_RSA_PublicKeyOp)(key, output, input); 114 } 115 116 SECStatus 117 RSA_PrivateKeyOp(RSAPrivateKey *key, 118 unsigned char *output, 119 const unsigned char *input) 120 { 121 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 122 return SECFailure; 123 return (vector->p_RSA_PrivateKeyOp)(key, output, input); 124 } 125 126 SECStatus 127 RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, 128 unsigned char *output, 129 const unsigned char *input) 130 { 131 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 132 return SECFailure; 133 return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); 134 } 135 136 SECStatus 137 RSA_PrivateKeyCheck(const RSAPrivateKey *key) 138 { 139 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 140 return SECFailure; 141 return (vector->p_RSA_PrivateKeyCheck)(key); 142 } 143 144 SECStatus 145 DSA_NewKey(const PQGParams *params, DSAPrivateKey **privKey) 146 { 147 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 148 return SECFailure; 149 return (vector->p_DSA_NewKey)(params, privKey); 150 } 151 152 SECStatus 153 DSA_SignDigest(DSAPrivateKey *key, SECItem *signature, const SECItem *digest) 154 { 155 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 156 return SECFailure; 157 return (vector->p_DSA_SignDigest)(key, signature, digest); 158 } 159 160 SECStatus 161 DSA_VerifyDigest(DSAPublicKey *key, const SECItem *signature, 162 const SECItem *digest) 163 { 164 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 165 return SECFailure; 166 return (vector->p_DSA_VerifyDigest)(key, signature, digest); 167 } 168 169 SECStatus 170 DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char *seed, 171 DSAPrivateKey **privKey) 172 { 173 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 174 return SECFailure; 175 return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); 176 } 177 178 SECStatus 179 DSA_SignDigestWithSeed(DSAPrivateKey *key, SECItem *signature, 180 const SECItem *digest, const unsigned char *seed) 181 { 182 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 183 return SECFailure; 184 return (vector->p_DSA_SignDigestWithSeed)(key, signature, digest, seed); 185 } 186 187 SECStatus 188 DSA_NewRandom(PLArenaPool *arena, const SECItem *q, SECItem *seed) 189 { 190 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 191 return SECFailure; 192 return (vector->p_DSA_NewRandom)(arena, q, seed); 193 } 194 195 SECStatus 196 DH_GenParam(int primeLen, DHParams **params) 197 { 198 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 199 return SECFailure; 200 return (vector->p_DH_GenParam)(primeLen, params); 201 } 202 203 SECStatus 204 DH_NewKey(DHParams *params, DHPrivateKey **privKey) 205 { 206 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 207 return SECFailure; 208 return (vector->p_DH_NewKey)(params, privKey); 209 } 210 211 SECStatus 212 DH_Derive(SECItem *publicValue, SECItem *prime, SECItem *privateValue, 213 SECItem *derivedSecret, unsigned int maxOutBytes) 214 { 215 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 216 return SECFailure; 217 return (vector->p_DH_Derive)(publicValue, prime, privateValue, 218 derivedSecret, maxOutBytes); 219 } 220 221 SECStatus 222 KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, 223 SECItem *private1, SECItem *private2, SECItem *derivedSecret) 224 { 225 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 226 return SECFailure; 227 return (vector->p_KEA_Derive)(prime, public1, public2, 228 private1, private2, derivedSecret); 229 } 230 231 PRBool 232 KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) 233 { 234 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 235 return PR_FALSE; 236 return (vector->p_KEA_Verify)(Y, prime, subPrime); 237 } 238 239 PRBool 240 KEA_PrimeCheck(SECItem *prime) 241 { 242 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 243 return PR_FALSE; 244 return (vector->p_KEA_PrimeCheck)(prime); 245 } 246 247 RC4Context * 248 RC4_CreateContext(const unsigned char *key, int len) 249 { 250 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 251 return NULL; 252 return (vector->p_RC4_CreateContext)(key, len); 253 } 254 255 void 256 RC4_DestroyContext(RC4Context *cx, PRBool freeit) 257 { 258 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 259 return; 260 (vector->p_RC4_DestroyContext)(cx, freeit); 261 } 262 263 SECStatus 264 RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, 265 unsigned int maxOutputLen, const unsigned char *input, 266 unsigned int inputLen) 267 { 268 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 269 return SECFailure; 270 return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input, 271 inputLen); 272 } 273 274 SECStatus 275 RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, 276 unsigned int maxOutputLen, const unsigned char *input, 277 unsigned int inputLen) 278 { 279 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 280 return SECFailure; 281 return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input, 282 inputLen); 283 } 284 285 RC2Context * 286 RC2_CreateContext(const unsigned char *key, unsigned int len, 287 const unsigned char *iv, int mode, unsigned effectiveKeyLen) 288 { 289 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 290 return NULL; 291 #ifndef NSS_DISABLE_DEPRECATED_RC2 292 return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); 293 #else 294 return NULL; 295 #endif 296 } 297 298 void 299 RC2_DestroyContext(RC2Context *cx, PRBool freeit) 300 { 301 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 302 return; 303 #ifndef NSS_DISABLE_DEPRECATED_RC2 304 (vector->p_RC2_DestroyContext)(cx, freeit); 305 #else 306 return; 307 #endif 308 } 309 310 SECStatus 311 RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, 312 unsigned int maxOutputLen, const unsigned char *input, 313 unsigned int inputLen) 314 { 315 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 316 return SECFailure; 317 #ifndef NSS_DISABLE_DEPRECATED_RC2 318 return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input, 319 inputLen); 320 #else 321 return SECFailure; 322 #endif 323 } 324 325 SECStatus 326 RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, 327 unsigned int maxOutputLen, const unsigned char *input, 328 unsigned int inputLen) 329 { 330 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 331 return SECFailure; 332 #ifndef NSS_DISABLE_DEPRECATED_RC2 333 return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input, 334 inputLen); 335 #else 336 return SECFailure; 337 #endif 338 } 339 340 RC5Context * 341 RC5_CreateContext(const SECItem *key, unsigned int rounds, 342 unsigned int wordSize, const unsigned char *iv, int mode) 343 { 344 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 345 return NULL; 346 return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); 347 } 348 349 void 350 RC5_DestroyContext(RC5Context *cx, PRBool freeit) 351 { 352 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 353 return; 354 (vector->p_RC5_DestroyContext)(cx, freeit); 355 } 356 357 SECStatus 358 RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, 359 unsigned int maxOutputLen, const unsigned char *input, 360 unsigned int inputLen) 361 { 362 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 363 return SECFailure; 364 return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input, 365 inputLen); 366 } 367 368 SECStatus 369 RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, 370 unsigned int maxOutputLen, const unsigned char *input, 371 unsigned int inputLen) 372 { 373 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 374 return SECFailure; 375 return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input, 376 inputLen); 377 } 378 379 DESContext * 380 DES_CreateContext(const unsigned char *key, const unsigned char *iv, 381 int mode, PRBool encrypt) 382 { 383 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 384 return NULL; 385 return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); 386 } 387 388 void 389 DES_DestroyContext(DESContext *cx, PRBool freeit) 390 { 391 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 392 return; 393 (vector->p_DES_DestroyContext)(cx, freeit); 394 } 395 396 SECStatus 397 DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, 398 unsigned int maxOutputLen, const unsigned char *input, 399 unsigned int inputLen) 400 { 401 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 402 return SECFailure; 403 return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input, 404 inputLen); 405 } 406 407 SECStatus 408 DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, 409 unsigned int maxOutputLen, const unsigned char *input, 410 unsigned int inputLen) 411 { 412 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 413 return SECFailure; 414 return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input, 415 inputLen); 416 } 417 SEEDContext * 418 SEED_CreateContext(const unsigned char *key, const unsigned char *iv, 419 int mode, PRBool encrypt) 420 { 421 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 422 return NULL; 423 #ifndef NSS_DISABLE_DEPRECATED_SEED 424 return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); 425 #else 426 return NULL; 427 #endif 428 } 429 430 void 431 SEED_DestroyContext(SEEDContext *cx, PRBool freeit) 432 { 433 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 434 return; 435 #ifndef NSS_DISABLE_DEPRECATED_SEED 436 (vector->p_SEED_DestroyContext)(cx, freeit); 437 #else 438 return; 439 #endif 440 } 441 442 SECStatus 443 SEED_Encrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, 444 unsigned int maxOutputLen, const unsigned char *input, 445 unsigned int inputLen) 446 { 447 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 448 return SECFailure; 449 #ifndef NSS_DISABLE_DEPRECATED_SEED 450 return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input, 451 inputLen); 452 #else 453 return SECFailure; 454 #endif 455 } 456 457 SECStatus 458 SEED_Decrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, 459 unsigned int maxOutputLen, const unsigned char *input, 460 unsigned int inputLen) 461 { 462 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 463 return SECFailure; 464 #ifndef NSS_DISABLE_DEPRECATED_SEED 465 return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input, 466 inputLen); 467 #else 468 return SECFailure; 469 #endif 470 } 471 472 AESContext * 473 AES_CreateContext(const unsigned char *key, const unsigned char *iv, 474 int mode, int encrypt, 475 unsigned int keylen, unsigned int blocklen) 476 { 477 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 478 return NULL; 479 return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, 480 blocklen); 481 } 482 483 void 484 AES_DestroyContext(AESContext *cx, PRBool freeit) 485 { 486 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 487 return; 488 (vector->p_AES_DestroyContext)(cx, freeit); 489 } 490 491 SECStatus 492 AES_Encrypt(AESContext *cx, unsigned char *output, 493 unsigned int *outputLen, unsigned int maxOutputLen, 494 const unsigned char *input, unsigned int inputLen) 495 { 496 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 497 return SECFailure; 498 return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, 499 input, inputLen); 500 } 501 502 SECStatus 503 AES_Decrypt(AESContext *cx, unsigned char *output, 504 unsigned int *outputLen, unsigned int maxOutputLen, 505 const unsigned char *input, unsigned int inputLen) 506 { 507 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 508 return SECFailure; 509 return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, 510 input, inputLen); 511 } 512 513 SECStatus 514 AES_AEAD(AESContext *cx, unsigned char *output, 515 unsigned int *outputLen, unsigned int maxOutputLen, 516 const unsigned char *input, unsigned int inputLen, 517 void *params, unsigned int paramsLen, 518 const unsigned char *aad, unsigned int aadLen) 519 { 520 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 521 return SECFailure; 522 return (vector->p_AES_AEAD)(cx, output, outputLen, maxOutputLen, input, 523 inputLen, params, paramsLen, aad, aadLen); 524 } 525 526 SECStatus 527 MD5_Hash(unsigned char *dest, const char *src) 528 { 529 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 530 return SECFailure; 531 return (vector->p_MD5_Hash)(dest, src); 532 } 533 534 SECStatus 535 MD5_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 536 { 537 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 538 return SECFailure; 539 return (vector->p_MD5_HashBuf)(dest, src, src_length); 540 } 541 542 MD5Context * 543 MD5_NewContext(void) 544 { 545 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 546 return NULL; 547 return (vector->p_MD5_NewContext)(); 548 } 549 550 void 551 MD5_DestroyContext(MD5Context *cx, PRBool freeit) 552 { 553 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 554 return; 555 (vector->p_MD5_DestroyContext)(cx, freeit); 556 } 557 558 void 559 MD5_Begin(MD5Context *cx) 560 { 561 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 562 return; 563 (vector->p_MD5_Begin)(cx); 564 } 565 566 void 567 MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen) 568 { 569 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 570 return; 571 (vector->p_MD5_Update)(cx, input, inputLen); 572 } 573 574 void 575 MD5_End(MD5Context *cx, unsigned char *digest, 576 unsigned int *digestLen, unsigned int maxDigestLen) 577 { 578 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 579 return; 580 (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); 581 } 582 583 unsigned int 584 MD5_FlattenSize(MD5Context *cx) 585 { 586 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 587 return 0; 588 return (vector->p_MD5_FlattenSize)(cx); 589 } 590 591 SECStatus 592 MD5_Flatten(MD5Context *cx, unsigned char *space) 593 { 594 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 595 return SECFailure; 596 return (vector->p_MD5_Flatten)(cx, space); 597 } 598 599 MD5Context * 600 MD5_Resurrect(unsigned char *space, void *arg) 601 { 602 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 603 return NULL; 604 return (vector->p_MD5_Resurrect)(space, arg); 605 } 606 607 void 608 MD5_TraceState(MD5Context *cx) 609 { 610 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 611 return; 612 (vector->p_MD5_TraceState)(cx); 613 } 614 615 SECStatus 616 MD2_Hash(unsigned char *dest, const char *src) 617 { 618 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 619 return SECFailure; 620 return (vector->p_MD2_Hash)(dest, src); 621 } 622 623 MD2Context * 624 MD2_NewContext(void) 625 { 626 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 627 return NULL; 628 return (vector->p_MD2_NewContext)(); 629 } 630 631 void 632 MD2_DestroyContext(MD2Context *cx, PRBool freeit) 633 { 634 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 635 return; 636 (vector->p_MD2_DestroyContext)(cx, freeit); 637 } 638 639 void 640 MD2_Begin(MD2Context *cx) 641 { 642 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 643 return; 644 (vector->p_MD2_Begin)(cx); 645 } 646 647 void 648 MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen) 649 { 650 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 651 return; 652 (vector->p_MD2_Update)(cx, input, inputLen); 653 } 654 655 void 656 MD2_End(MD2Context *cx, unsigned char *digest, 657 unsigned int *digestLen, unsigned int maxDigestLen) 658 { 659 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 660 return; 661 (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); 662 } 663 664 unsigned int 665 MD2_FlattenSize(MD2Context *cx) 666 { 667 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 668 return 0; 669 return (vector->p_MD2_FlattenSize)(cx); 670 } 671 672 SECStatus 673 MD2_Flatten(MD2Context *cx, unsigned char *space) 674 { 675 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 676 return SECFailure; 677 return (vector->p_MD2_Flatten)(cx, space); 678 } 679 680 MD2Context * 681 MD2_Resurrect(unsigned char *space, void *arg) 682 { 683 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 684 return NULL; 685 return (vector->p_MD2_Resurrect)(space, arg); 686 } 687 688 SECStatus 689 SHA1_Hash(unsigned char *dest, const char *src) 690 { 691 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 692 return SECFailure; 693 return (vector->p_SHA1_Hash)(dest, src); 694 } 695 696 SECStatus 697 SHA1_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 698 { 699 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 700 return SECFailure; 701 return (vector->p_SHA1_HashBuf)(dest, src, src_length); 702 } 703 704 SHA1Context * 705 SHA1_NewContext(void) 706 { 707 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 708 return NULL; 709 return (vector->p_SHA1_NewContext)(); 710 } 711 712 void 713 SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) 714 { 715 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 716 return; 717 (vector->p_SHA1_DestroyContext)(cx, freeit); 718 } 719 720 void 721 SHA1_Begin(SHA1Context *cx) 722 { 723 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 724 return; 725 (vector->p_SHA1_Begin)(cx); 726 } 727 728 void 729 SHA1_Update(SHA1Context *cx, const unsigned char *input, 730 unsigned int inputLen) 731 { 732 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 733 return; 734 (vector->p_SHA1_Update)(cx, input, inputLen); 735 } 736 737 void 738 SHA1_End(SHA1Context *cx, unsigned char *digest, 739 unsigned int *digestLen, unsigned int maxDigestLen) 740 { 741 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 742 return; 743 (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); 744 } 745 746 void 747 SHA1_TraceState(SHA1Context *cx) 748 { 749 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 750 return; 751 (vector->p_SHA1_TraceState)(cx); 752 } 753 754 unsigned int 755 SHA1_FlattenSize(SHA1Context *cx) 756 { 757 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 758 return 0; 759 return (vector->p_SHA1_FlattenSize)(cx); 760 } 761 762 SECStatus 763 SHA1_Flatten(SHA1Context *cx, unsigned char *space) 764 { 765 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 766 return SECFailure; 767 return (vector->p_SHA1_Flatten)(cx, space); 768 } 769 770 SHA1Context * 771 SHA1_Resurrect(unsigned char *space, void *arg) 772 { 773 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 774 return NULL; 775 return (vector->p_SHA1_Resurrect)(space, arg); 776 } 777 778 SECStatus 779 RNG_RNGInit(void) 780 { 781 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 782 return SECFailure; 783 return (vector->p_RNG_RNGInit)(); 784 } 785 786 SECStatus 787 RNG_RandomUpdate(const void *data, size_t bytes) 788 { 789 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 790 return SECFailure; 791 return (vector->p_RNG_RandomUpdate)(data, bytes); 792 } 793 794 SECStatus 795 RNG_GenerateGlobalRandomBytes(void *dest, size_t len) 796 { 797 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 798 return SECFailure; 799 return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); 800 } 801 802 void 803 RNG_RNGShutdown(void) 804 { 805 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 806 return; 807 (vector->p_RNG_RNGShutdown)(); 808 } 809 810 SECStatus 811 PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) 812 { 813 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 814 return SECFailure; 815 return (vector->p_PQG_ParamGen)(j, pParams, pVfy); 816 } 817 818 SECStatus 819 PQG_ParamGenSeedLen(unsigned int j, unsigned int seedBytes, 820 PQGParams **pParams, PQGVerify **pVfy) 821 { 822 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 823 return SECFailure; 824 return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); 825 } 826 827 SECStatus 828 PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, 829 SECStatus *result) 830 { 831 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 832 return SECFailure; 833 return (vector->p_PQG_VerifyParams)(params, vfy, result); 834 } 835 836 void 837 PQG_DestroyParams(PQGParams *params) 838 { 839 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 840 return; 841 (vector->p_PQG_DestroyParams)(params); 842 } 843 844 void 845 PQG_DestroyVerify(PQGVerify *vfy) 846 { 847 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 848 return; 849 (vector->p_PQG_DestroyVerify)(vfy); 850 } 851 852 void 853 BL_Cleanup(void) 854 { 855 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 856 return; 857 (vector->p_BL_Cleanup)(); 858 } 859 860 void 861 BL_Unload(void) 862 { 863 /* This function is not thread-safe, but doesn't need to be, because it is 864 * only called from functions that are also defined as not thread-safe, 865 * namely C_Finalize in softoken, and the SSL bypass shutdown callback called 866 * from NSS_Shutdown. */ 867 char *disableUnload = NULL; 868 vector = NULL; 869 disableUnload = PR_GetEnvSecure("NSS_DISABLE_UNLOAD"); 870 if (blLib && !disableUnload) { 871 #ifdef DEBUG 872 PRStatus status = PR_UnloadLibrary(blLib); 873 PORT_Assert(PR_SUCCESS == status); 874 #else 875 PR_UnloadLibrary(blLib); 876 #endif 877 } 878 blLib = NULL; 879 loadFreeBLOnce = pristineCallOnce; 880 } 881 882 /* ============== New for 3.003 =============================== */ 883 884 SECStatus 885 SHA256_Hash(unsigned char *dest, const char *src) 886 { 887 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 888 return SECFailure; 889 return (vector->p_SHA256_Hash)(dest, src); 890 } 891 892 SECStatus 893 SHA256_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 894 { 895 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 896 return SECFailure; 897 return (vector->p_SHA256_HashBuf)(dest, src, src_length); 898 } 899 900 SHA256Context * 901 SHA256_NewContext(void) 902 { 903 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 904 return NULL; 905 return (vector->p_SHA256_NewContext)(); 906 } 907 908 void 909 SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) 910 { 911 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 912 return; 913 (vector->p_SHA256_DestroyContext)(cx, freeit); 914 } 915 916 void 917 SHA256_Begin(SHA256Context *cx) 918 { 919 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 920 return; 921 (vector->p_SHA256_Begin)(cx); 922 } 923 924 void 925 SHA256_Update(SHA256Context *cx, const unsigned char *input, 926 unsigned int inputLen) 927 { 928 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 929 return; 930 (vector->p_SHA256_Update)(cx, input, inputLen); 931 } 932 933 void 934 SHA256_End(SHA256Context *cx, unsigned char *digest, 935 unsigned int *digestLen, unsigned int maxDigestLen) 936 { 937 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 938 return; 939 (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); 940 } 941 942 void 943 SHA256_TraceState(SHA256Context *cx) 944 { 945 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 946 return; 947 (vector->p_SHA256_TraceState)(cx); 948 } 949 950 unsigned int 951 SHA256_FlattenSize(SHA256Context *cx) 952 { 953 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 954 return 0; 955 return (vector->p_SHA256_FlattenSize)(cx); 956 } 957 958 SECStatus 959 SHA256_Flatten(SHA256Context *cx, unsigned char *space) 960 { 961 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 962 return SECFailure; 963 return (vector->p_SHA256_Flatten)(cx, space); 964 } 965 966 SHA256Context * 967 SHA256_Resurrect(unsigned char *space, void *arg) 968 { 969 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 970 return NULL; 971 return (vector->p_SHA256_Resurrect)(space, arg); 972 } 973 974 SECStatus 975 SHA512_Hash(unsigned char *dest, const char *src) 976 { 977 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 978 return SECFailure; 979 return (vector->p_SHA512_Hash)(dest, src); 980 } 981 982 SECStatus 983 SHA512_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 984 { 985 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 986 return SECFailure; 987 return (vector->p_SHA512_HashBuf)(dest, src, src_length); 988 } 989 990 SHA512Context * 991 SHA512_NewContext(void) 992 { 993 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 994 return NULL; 995 return (vector->p_SHA512_NewContext)(); 996 } 997 998 void 999 SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) 1000 { 1001 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1002 return; 1003 (vector->p_SHA512_DestroyContext)(cx, freeit); 1004 } 1005 1006 void 1007 SHA512_Begin(SHA512Context *cx) 1008 { 1009 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1010 return; 1011 (vector->p_SHA512_Begin)(cx); 1012 } 1013 1014 void 1015 SHA512_Update(SHA512Context *cx, const unsigned char *input, 1016 unsigned int inputLen) 1017 { 1018 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1019 return; 1020 (vector->p_SHA512_Update)(cx, input, inputLen); 1021 } 1022 1023 void 1024 SHA512_End(SHA512Context *cx, unsigned char *digest, 1025 unsigned int *digestLen, unsigned int maxDigestLen) 1026 { 1027 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1028 return; 1029 (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); 1030 } 1031 1032 void 1033 SHA512_TraceState(SHA512Context *cx) 1034 { 1035 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1036 return; 1037 (vector->p_SHA512_TraceState)(cx); 1038 } 1039 1040 unsigned int 1041 SHA512_FlattenSize(SHA512Context *cx) 1042 { 1043 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1044 return 0; 1045 return (vector->p_SHA512_FlattenSize)(cx); 1046 } 1047 1048 SECStatus 1049 SHA512_Flatten(SHA512Context *cx, unsigned char *space) 1050 { 1051 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1052 return SECFailure; 1053 return (vector->p_SHA512_Flatten)(cx, space); 1054 } 1055 1056 SHA512Context * 1057 SHA512_Resurrect(unsigned char *space, void *arg) 1058 { 1059 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1060 return NULL; 1061 return (vector->p_SHA512_Resurrect)(space, arg); 1062 } 1063 1064 SECStatus 1065 SHA384_Hash(unsigned char *dest, const char *src) 1066 { 1067 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1068 return SECFailure; 1069 return (vector->p_SHA384_Hash)(dest, src); 1070 } 1071 1072 SECStatus 1073 SHA384_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1074 { 1075 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1076 return SECFailure; 1077 return (vector->p_SHA384_HashBuf)(dest, src, src_length); 1078 } 1079 1080 SHA384Context * 1081 SHA384_NewContext(void) 1082 { 1083 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1084 return NULL; 1085 return (vector->p_SHA384_NewContext)(); 1086 } 1087 1088 void 1089 SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) 1090 { 1091 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1092 return; 1093 (vector->p_SHA384_DestroyContext)(cx, freeit); 1094 } 1095 1096 void 1097 SHA384_Begin(SHA384Context *cx) 1098 { 1099 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1100 return; 1101 (vector->p_SHA384_Begin)(cx); 1102 } 1103 1104 void 1105 SHA384_Update(SHA384Context *cx, const unsigned char *input, 1106 unsigned int inputLen) 1107 { 1108 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1109 return; 1110 (vector->p_SHA384_Update)(cx, input, inputLen); 1111 } 1112 1113 void 1114 SHA384_End(SHA384Context *cx, unsigned char *digest, 1115 unsigned int *digestLen, unsigned int maxDigestLen) 1116 { 1117 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1118 return; 1119 (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); 1120 } 1121 1122 void 1123 SHA384_TraceState(SHA384Context *cx) 1124 { 1125 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1126 return; 1127 (vector->p_SHA384_TraceState)(cx); 1128 } 1129 1130 unsigned int 1131 SHA384_FlattenSize(SHA384Context *cx) 1132 { 1133 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1134 return 0; 1135 return (vector->p_SHA384_FlattenSize)(cx); 1136 } 1137 1138 SECStatus 1139 SHA384_Flatten(SHA384Context *cx, unsigned char *space) 1140 { 1141 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1142 return SECFailure; 1143 return (vector->p_SHA384_Flatten)(cx, space); 1144 } 1145 1146 SHA384Context * 1147 SHA384_Resurrect(unsigned char *space, void *arg) 1148 { 1149 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1150 return NULL; 1151 return (vector->p_SHA384_Resurrect)(space, arg); 1152 } 1153 1154 AESKeyWrapContext * 1155 AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv, 1156 int encrypt, unsigned int keylen) 1157 { 1158 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1159 return NULL; 1160 return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); 1161 } 1162 1163 void 1164 AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) 1165 { 1166 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1167 return; 1168 vector->p_AESKeyWrap_DestroyContext(cx, freeit); 1169 } 1170 1171 SECStatus 1172 AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, 1173 unsigned int *outputLen, unsigned int maxOutputLen, 1174 const unsigned char *input, unsigned int inputLen) 1175 { 1176 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1177 return SECFailure; 1178 return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, 1179 input, inputLen); 1180 } 1181 1182 SECStatus 1183 AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, 1184 unsigned int *outputLen, unsigned int maxOutputLen, 1185 const unsigned char *input, unsigned int inputLen) 1186 { 1187 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1188 return SECFailure; 1189 return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, 1190 input, inputLen); 1191 } 1192 1193 SECStatus 1194 AESKeyWrap_EncryptKWP(AESKeyWrapContext *cx, unsigned char *output, 1195 unsigned int *outputLen, unsigned int maxOutputLen, 1196 const unsigned char *input, unsigned int inputLen) 1197 { 1198 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1199 return SECFailure; 1200 return vector->p_AESKeyWrap_EncryptKWP(cx, output, outputLen, maxOutputLen, 1201 input, inputLen); 1202 } 1203 1204 SECStatus 1205 AESKeyWrap_DecryptKWP(AESKeyWrapContext *cx, unsigned char *output, 1206 unsigned int *outputLen, unsigned int maxOutputLen, 1207 const unsigned char *input, unsigned int inputLen) 1208 { 1209 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1210 return SECFailure; 1211 return vector->p_AESKeyWrap_DecryptKWP(cx, output, outputLen, maxOutputLen, 1212 input, inputLen); 1213 } 1214 1215 PRBool 1216 BLAPI_SHVerify(const char *name, PRFuncPtr addr) 1217 { 1218 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1219 return PR_FALSE; 1220 return vector->p_BLAPI_SHVerify(name, addr); 1221 } 1222 1223 /* 1224 * The Caller is expected to pass NULL as the name, which will 1225 * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. Pass the real 1226 * name of the shared library we loaded (the static libraryName set 1227 * in freebl_LoadDSO) to p_BLAPI_VerifySelf. 1228 */ 1229 PRBool 1230 BLAPI_VerifySelf(const char *name) 1231 { 1232 PORT_Assert(!name); 1233 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1234 return PR_FALSE; 1235 return vector->p_BLAPI_VerifySelf(libraryName); 1236 } 1237 1238 /* ============== New for 3.006 =============================== */ 1239 1240 SECStatus 1241 EC_NewKey(ECParams *params, ECPrivateKey **privKey) 1242 { 1243 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1244 return SECFailure; 1245 return (vector->p_EC_NewKey)(params, privKey); 1246 } 1247 1248 SECStatus 1249 EC_NewKeyFromSeed(ECParams *params, ECPrivateKey **privKey, 1250 const unsigned char *seed, int seedlen) 1251 { 1252 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1253 return SECFailure; 1254 return (vector->p_EC_NewKeyFromSeed)(params, privKey, seed, seedlen); 1255 } 1256 1257 SECStatus 1258 EC_ValidatePublicKey(ECParams *params, SECItem *publicValue) 1259 { 1260 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1261 return SECFailure; 1262 return (vector->p_EC_ValidatePublicKey)(params, publicValue); 1263 } 1264 1265 SECStatus 1266 ECDH_Derive(SECItem *publicValue, ECParams *params, SECItem *privateValue, 1267 PRBool withCofactor, SECItem *derivedSecret) 1268 { 1269 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1270 return SECFailure; 1271 return (vector->p_ECDH_Derive)(publicValue, params, privateValue, 1272 withCofactor, derivedSecret); 1273 } 1274 1275 SECStatus 1276 ECDSA_SignDigest(ECPrivateKey *key, SECItem *signature, 1277 const SECItem *digest) 1278 { 1279 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1280 return SECFailure; 1281 return (vector->p_ECDSA_SignDigest)(key, signature, digest); 1282 } 1283 1284 SECStatus 1285 ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, 1286 const SECItem *digest) 1287 { 1288 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1289 return SECFailure; 1290 return (vector->p_ECDSA_VerifyDigest)(key, signature, digest); 1291 } 1292 1293 SECStatus 1294 ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, 1295 const SECItem *digest, const unsigned char *seed, const int seedlen) 1296 { 1297 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1298 return SECFailure; 1299 return (vector->p_ECDSA_SignDigestWithSeed)(key, signature, digest, 1300 seed, seedlen); 1301 } 1302 1303 /* ============== New for 3.008 =============================== */ 1304 1305 AESContext * 1306 AES_AllocateContext(void) 1307 { 1308 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1309 return NULL; 1310 return (vector->p_AES_AllocateContext)(); 1311 } 1312 1313 AESKeyWrapContext * 1314 AESKeyWrap_AllocateContext(void) 1315 { 1316 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1317 return NULL; 1318 return (vector->p_AESKeyWrap_AllocateContext)(); 1319 } 1320 1321 DESContext * 1322 DES_AllocateContext(void) 1323 { 1324 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1325 return NULL; 1326 return (vector->p_DES_AllocateContext)(); 1327 } 1328 1329 RC2Context * 1330 RC2_AllocateContext(void) 1331 { 1332 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1333 return NULL; 1334 #ifndef NSS_DISABLE_DEPRECATED_RC2 1335 return (vector->p_RC2_AllocateContext)(); 1336 #else 1337 return NULL; 1338 #endif 1339 } 1340 1341 RC4Context * 1342 RC4_AllocateContext(void) 1343 { 1344 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1345 return NULL; 1346 return (vector->p_RC4_AllocateContext)(); 1347 } 1348 1349 SECStatus 1350 AES_InitContext(AESContext *cx, const unsigned char *key, 1351 unsigned int keylen, const unsigned char *iv, int mode, 1352 unsigned int encrypt, unsigned int blocklen) 1353 { 1354 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1355 return SECFailure; 1356 return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, 1357 blocklen); 1358 } 1359 1360 SECStatus 1361 AESKeyWrap_InitContext(AESKeyWrapContext *cx, const unsigned char *key, 1362 unsigned int keylen, const unsigned char *iv, int mode, 1363 unsigned int encrypt, unsigned int blocklen) 1364 { 1365 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1366 return SECFailure; 1367 return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, 1368 encrypt, blocklen); 1369 } 1370 1371 SECStatus 1372 DES_InitContext(DESContext *cx, const unsigned char *key, 1373 unsigned int keylen, const unsigned char *iv, int mode, 1374 unsigned int encrypt, unsigned int xtra) 1375 { 1376 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1377 return SECFailure; 1378 return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); 1379 } 1380 1381 SECStatus 1382 SEED_InitContext(SEEDContext *cx, const unsigned char *key, 1383 unsigned int keylen, const unsigned char *iv, int mode, 1384 unsigned int encrypt, unsigned int xtra) 1385 { 1386 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1387 return SECFailure; 1388 #ifndef NSS_DISABLE_DEPRECATED_SEED 1389 return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); 1390 #else 1391 return SECFailure; 1392 #endif 1393 } 1394 1395 SECStatus 1396 RC2_InitContext(RC2Context *cx, const unsigned char *key, 1397 unsigned int keylen, const unsigned char *iv, int mode, 1398 unsigned int effectiveKeyLen, unsigned int xtra) 1399 { 1400 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1401 return SECFailure; 1402 #ifndef NSS_DISABLE_DEPRECATED_RC2 1403 return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, 1404 effectiveKeyLen, xtra); 1405 #else 1406 return SECFailure; 1407 #endif 1408 } 1409 1410 SECStatus 1411 RC4_InitContext(RC4Context *cx, const unsigned char *key, 1412 unsigned int keylen, const unsigned char *x1, int x2, 1413 unsigned int x3, unsigned int x4) 1414 { 1415 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1416 return SECFailure; 1417 return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); 1418 } 1419 1420 void 1421 MD2_Clone(MD2Context *dest, MD2Context *src) 1422 { 1423 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1424 return; 1425 (vector->p_MD2_Clone)(dest, src); 1426 } 1427 1428 void 1429 MD5_Clone(MD5Context *dest, MD5Context *src) 1430 { 1431 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1432 return; 1433 (vector->p_MD5_Clone)(dest, src); 1434 } 1435 1436 void 1437 SHA1_Clone(SHA1Context *dest, SHA1Context *src) 1438 { 1439 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1440 return; 1441 (vector->p_SHA1_Clone)(dest, src); 1442 } 1443 1444 void 1445 SHA256_Clone(SHA256Context *dest, SHA256Context *src) 1446 { 1447 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1448 return; 1449 (vector->p_SHA256_Clone)(dest, src); 1450 } 1451 1452 void 1453 SHA384_Clone(SHA384Context *dest, SHA384Context *src) 1454 { 1455 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1456 return; 1457 (vector->p_SHA384_Clone)(dest, src); 1458 } 1459 1460 void 1461 SHA512_Clone(SHA512Context *dest, SHA512Context *src) 1462 { 1463 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1464 return; 1465 (vector->p_SHA512_Clone)(dest, src); 1466 } 1467 1468 SECStatus 1469 TLS_PRF(const SECItem *secret, const char *label, 1470 SECItem *seed, SECItem *result, PRBool isFIPS) 1471 { 1472 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1473 return SECFailure; 1474 return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); 1475 } 1476 1477 const SECHashObject * 1478 HASH_GetRawHashObject(HASH_HashType hashType) 1479 { 1480 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1481 return NULL; 1482 return (vector->p_HASH_GetRawHashObject)(hashType); 1483 } 1484 1485 void 1486 HMAC_Destroy(HMACContext *cx, PRBool freeit) 1487 { 1488 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1489 return; 1490 (vector->p_HMAC_Destroy)(cx, freeit); 1491 } 1492 1493 HMACContext * 1494 HMAC_Create(const SECHashObject *hashObj, const unsigned char *secret, 1495 unsigned int secret_len, PRBool isFIPS) 1496 { 1497 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1498 return NULL; 1499 return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); 1500 } 1501 1502 SECStatus 1503 HMAC_Init(HMACContext *cx, const SECHashObject *hashObj, 1504 const unsigned char *secret, unsigned int secret_len, PRBool isFIPS) 1505 { 1506 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1507 return SECFailure; 1508 return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); 1509 } 1510 1511 void 1512 HMAC_Begin(HMACContext *cx) 1513 { 1514 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1515 return; 1516 (vector->p_HMAC_Begin)(cx); 1517 } 1518 1519 void 1520 HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) 1521 { 1522 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1523 return; 1524 (vector->p_HMAC_Update)(cx, data, data_len); 1525 } 1526 1527 SECStatus 1528 HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, 1529 unsigned int max_result_len) 1530 { 1531 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1532 return SECFailure; 1533 return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); 1534 } 1535 1536 HMACContext * 1537 HMAC_Clone(HMACContext *cx) 1538 { 1539 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1540 return NULL; 1541 return (vector->p_HMAC_Clone)(cx); 1542 } 1543 1544 void 1545 RNG_SystemInfoForRNG(void) 1546 { 1547 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1548 return; 1549 (vector->p_RNG_SystemInfoForRNG)(); 1550 } 1551 1552 SECStatus 1553 FIPS186Change_GenerateX(unsigned char *XKEY, const unsigned char *XSEEDj, 1554 unsigned char *x_j) 1555 { 1556 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1557 return SECFailure; 1558 return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); 1559 } 1560 1561 SECStatus 1562 FIPS186Change_ReduceModQForDSA(const unsigned char *w, 1563 const unsigned char *q, 1564 unsigned char *xj) 1565 { 1566 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1567 return SECFailure; 1568 return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); 1569 } 1570 1571 /* === new for Camellia === */ 1572 SECStatus 1573 Camellia_InitContext(CamelliaContext *cx, const unsigned char *key, 1574 unsigned int keylen, const unsigned char *iv, int mode, 1575 unsigned int encrypt, unsigned int unused) 1576 { 1577 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1578 return SECFailure; 1579 return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, 1580 unused); 1581 } 1582 1583 CamelliaContext * 1584 Camellia_AllocateContext(void) 1585 { 1586 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1587 return NULL; 1588 return (vector->p_Camellia_AllocateContext)(); 1589 } 1590 1591 CamelliaContext * 1592 Camellia_CreateContext(const unsigned char *key, const unsigned char *iv, 1593 int mode, int encrypt, 1594 unsigned int keylen) 1595 { 1596 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1597 return NULL; 1598 return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); 1599 } 1600 1601 void 1602 Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) 1603 { 1604 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1605 return; 1606 (vector->p_Camellia_DestroyContext)(cx, freeit); 1607 } 1608 1609 SECStatus 1610 Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, 1611 unsigned int *outputLen, unsigned int maxOutputLen, 1612 const unsigned char *input, unsigned int inputLen) 1613 { 1614 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1615 return SECFailure; 1616 return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen, 1617 input, inputLen); 1618 } 1619 1620 SECStatus 1621 Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, 1622 unsigned int *outputLen, unsigned int maxOutputLen, 1623 const unsigned char *input, unsigned int inputLen) 1624 { 1625 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1626 return SECFailure; 1627 return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen, 1628 input, inputLen); 1629 } 1630 1631 void 1632 BL_SetForkState(PRBool forked) 1633 { 1634 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1635 return; 1636 (vector->p_BL_SetForkState)(forked); 1637 } 1638 1639 SECStatus 1640 PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, 1641 const PRUint8 *nonce, unsigned int nonce_len, 1642 const PRUint8 *personal_string, unsigned int ps_len) 1643 { 1644 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1645 return SECFailure; 1646 return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, 1647 nonce, nonce_len, 1648 personal_string, ps_len); 1649 } 1650 1651 SECStatus 1652 PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, 1653 const PRUint8 *additional, unsigned int additional_len) 1654 { 1655 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1656 return SECFailure; 1657 return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, 1658 additional, additional_len); 1659 } 1660 1661 SECStatus 1662 PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, 1663 const PRUint8 *additional, unsigned int additional_len) 1664 { 1665 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1666 return SECFailure; 1667 return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, 1668 additional, additional_len); 1669 } 1670 1671 SECStatus 1672 PRNGTEST_Uninstantiate() 1673 { 1674 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1675 return SECFailure; 1676 return (vector->p_PRNGTEST_Uninstantiate)(); 1677 } 1678 1679 SECStatus 1680 RSA_PopulatePrivateKey(RSAPrivateKey *key) 1681 { 1682 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1683 return SECFailure; 1684 return (vector->p_RSA_PopulatePrivateKey)(key); 1685 } 1686 1687 SECStatus 1688 JPAKE_Sign(PLArenaPool *arena, const PQGParams *pqg, HASH_HashType hashType, 1689 const SECItem *signerID, const SECItem *x, 1690 const SECItem *testRandom, const SECItem *gxIn, SECItem *gxOut, 1691 SECItem *gv, SECItem *r) 1692 { 1693 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1694 return SECFailure; 1695 return (vector->p_JPAKE_Sign)(arena, pqg, hashType, signerID, x, 1696 testRandom, gxIn, gxOut, gv, r); 1697 } 1698 1699 SECStatus 1700 JPAKE_Verify(PLArenaPool *arena, const PQGParams *pqg, 1701 HASH_HashType hashType, const SECItem *signerID, 1702 const SECItem *peerID, const SECItem *gx, 1703 const SECItem *gv, const SECItem *r) 1704 { 1705 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1706 return SECFailure; 1707 return (vector->p_JPAKE_Verify)(arena, pqg, hashType, signerID, peerID, 1708 gx, gv, r); 1709 } 1710 1711 SECStatus 1712 JPAKE_Round2(PLArenaPool *arena, const SECItem *p, const SECItem *q, 1713 const SECItem *gx1, const SECItem *gx3, const SECItem *gx4, 1714 SECItem *base, const SECItem *x2, const SECItem *s, SECItem *x2s) 1715 { 1716 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1717 return SECFailure; 1718 return (vector->p_JPAKE_Round2)(arena, p, q, gx1, gx3, gx4, base, x2, s, x2s); 1719 } 1720 1721 SECStatus 1722 JPAKE_Final(PLArenaPool *arena, const SECItem *p, const SECItem *q, 1723 const SECItem *x2, const SECItem *gx4, const SECItem *x2s, 1724 const SECItem *B, SECItem *K) 1725 { 1726 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1727 return SECFailure; 1728 return (vector->p_JPAKE_Final)(arena, p, q, x2, gx4, x2s, B, K); 1729 } 1730 1731 SECStatus 1732 TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, const char *label, 1733 SECItem *seed, SECItem *result, PRBool isFIPS) 1734 { 1735 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1736 return SECFailure; 1737 return (vector->p_TLS_P_hash)(hashAlg, secret, label, seed, result, isFIPS); 1738 } 1739 1740 SECStatus 1741 SHA224_Hash(unsigned char *dest, const char *src) 1742 { 1743 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1744 return SECFailure; 1745 return (vector->p_SHA224_Hash)(dest, src); 1746 } 1747 1748 SECStatus 1749 SHA224_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 1750 { 1751 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1752 return SECFailure; 1753 return (vector->p_SHA224_HashBuf)(dest, src, src_length); 1754 } 1755 1756 SHA224Context * 1757 SHA224_NewContext(void) 1758 { 1759 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1760 return NULL; 1761 return (vector->p_SHA224_NewContext)(); 1762 } 1763 1764 void 1765 SHA224_DestroyContext(SHA224Context *cx, PRBool freeit) 1766 { 1767 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1768 return; 1769 (vector->p_SHA224_DestroyContext)(cx, freeit); 1770 } 1771 1772 void 1773 SHA224_Begin(SHA256Context *cx) 1774 { 1775 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1776 return; 1777 (vector->p_SHA224_Begin)(cx); 1778 } 1779 1780 void 1781 SHA224_Update(SHA224Context *cx, const unsigned char *input, 1782 unsigned int inputLen) 1783 { 1784 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1785 return; 1786 (vector->p_SHA224_Update)(cx, input, inputLen); 1787 } 1788 1789 void 1790 SHA224_End(SHA224Context *cx, unsigned char *digest, 1791 unsigned int *digestLen, unsigned int maxDigestLen) 1792 { 1793 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1794 return; 1795 (vector->p_SHA224_End)(cx, digest, digestLen, maxDigestLen); 1796 } 1797 1798 void 1799 SHA224_TraceState(SHA224Context *cx) 1800 { 1801 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1802 return; 1803 (vector->p_SHA224_TraceState)(cx); 1804 } 1805 1806 unsigned int 1807 SHA224_FlattenSize(SHA224Context *cx) 1808 { 1809 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1810 return 0; 1811 return (vector->p_SHA224_FlattenSize)(cx); 1812 } 1813 1814 SECStatus 1815 SHA224_Flatten(SHA224Context *cx, unsigned char *space) 1816 { 1817 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1818 return SECFailure; 1819 return (vector->p_SHA224_Flatten)(cx, space); 1820 } 1821 1822 SHA224Context * 1823 SHA224_Resurrect(unsigned char *space, void *arg) 1824 { 1825 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1826 return NULL; 1827 return (vector->p_SHA224_Resurrect)(space, arg); 1828 } 1829 1830 void 1831 SHA224_Clone(SHA224Context *dest, SHA224Context *src) 1832 { 1833 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1834 return; 1835 (vector->p_SHA224_Clone)(dest, src); 1836 } 1837 1838 PRBool 1839 BLAPI_SHVerifyFile(const char *name) 1840 { 1841 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1842 return PR_FALSE; 1843 return vector->p_BLAPI_SHVerifyFile(name); 1844 } 1845 1846 /* === new for DSA-2 === */ 1847 SECStatus 1848 PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes, 1849 PQGParams **pParams, PQGVerify **pVfy) 1850 { 1851 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1852 return SECFailure; 1853 return (vector->p_PQG_ParamGenV2)(L, N, seedBytes, pParams, pVfy); 1854 } 1855 1856 SECStatus 1857 PRNGTEST_RunHealthTests(void) 1858 { 1859 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1860 return SECFailure; 1861 return vector->p_PRNGTEST_RunHealthTests(); 1862 } 1863 1864 SECStatus 1865 SSLv3_MAC_ConstantTime( 1866 unsigned char *result, 1867 unsigned int *resultLen, 1868 unsigned int maxResultLen, 1869 const SECHashObject *hashObj, 1870 const unsigned char *secret, 1871 unsigned int secretLen, 1872 const unsigned char *header, 1873 unsigned int headerLen, 1874 const unsigned char *body, 1875 unsigned int bodyLen, 1876 unsigned int bodyTotalLen) 1877 { 1878 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1879 return SECFailure; 1880 return (vector->p_SSLv3_MAC_ConstantTime)( 1881 result, resultLen, maxResultLen, 1882 hashObj, 1883 secret, secretLen, 1884 header, headerLen, 1885 body, bodyLen, bodyTotalLen); 1886 } 1887 1888 SECStatus 1889 HMAC_ConstantTime( 1890 unsigned char *result, 1891 unsigned int *resultLen, 1892 unsigned int maxResultLen, 1893 const SECHashObject *hashObj, 1894 const unsigned char *secret, 1895 unsigned int secretLen, 1896 const unsigned char *header, 1897 unsigned int headerLen, 1898 const unsigned char *body, 1899 unsigned int bodyLen, 1900 unsigned int bodyTotalLen) 1901 { 1902 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1903 return SECFailure; 1904 return (vector->p_HMAC_ConstantTime)( 1905 result, resultLen, maxResultLen, 1906 hashObj, 1907 secret, secretLen, 1908 header, headerLen, 1909 body, bodyLen, bodyTotalLen); 1910 } 1911 1912 SECStatus 1913 RSA_SignRaw(RSAPrivateKey *key, 1914 unsigned char *output, 1915 unsigned int *outputLen, 1916 unsigned int maxOutputLen, 1917 const unsigned char *input, 1918 unsigned int inputLen) 1919 { 1920 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1921 return SECFailure; 1922 return (vector->p_RSA_SignRaw)(key, output, outputLen, maxOutputLen, input, 1923 inputLen); 1924 } 1925 1926 SECStatus 1927 RSA_CheckSignRaw(RSAPublicKey *key, 1928 const unsigned char *sig, 1929 unsigned int sigLen, 1930 const unsigned char *hash, 1931 unsigned int hashLen) 1932 { 1933 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1934 return SECFailure; 1935 return (vector->p_RSA_CheckSignRaw)(key, sig, sigLen, hash, hashLen); 1936 } 1937 1938 SECStatus 1939 RSA_CheckSignRecoverRaw(RSAPublicKey *key, 1940 unsigned char *data, 1941 unsigned int *dataLen, 1942 unsigned int maxDataLen, 1943 const unsigned char *sig, 1944 unsigned int sigLen) 1945 { 1946 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1947 return SECFailure; 1948 return (vector->p_RSA_CheckSignRecoverRaw)(key, data, dataLen, maxDataLen, 1949 sig, sigLen); 1950 } 1951 1952 SECStatus 1953 RSA_EncryptRaw(RSAPublicKey *key, 1954 unsigned char *output, 1955 unsigned int *outputLen, 1956 unsigned int maxOutputLen, 1957 const unsigned char *input, 1958 unsigned int inputLen) 1959 { 1960 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1961 return SECFailure; 1962 return (vector->p_RSA_EncryptRaw)(key, output, outputLen, maxOutputLen, 1963 input, inputLen); 1964 } 1965 1966 SECStatus 1967 RSA_DecryptRaw(RSAPrivateKey *key, 1968 unsigned char *output, 1969 unsigned int *outputLen, 1970 unsigned int maxOutputLen, 1971 const unsigned char *input, 1972 unsigned int inputLen) 1973 { 1974 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1975 return SECFailure; 1976 return (vector->p_RSA_DecryptRaw)(key, output, outputLen, maxOutputLen, 1977 input, inputLen); 1978 } 1979 1980 SECStatus 1981 RSA_EncryptOAEP(RSAPublicKey *key, 1982 HASH_HashType hashAlg, 1983 HASH_HashType maskHashAlg, 1984 const unsigned char *label, 1985 unsigned int labelLen, 1986 const unsigned char *seed, 1987 unsigned int seedLen, 1988 unsigned char *output, 1989 unsigned int *outputLen, 1990 unsigned int maxOutputLen, 1991 const unsigned char *input, 1992 unsigned int inputLen) 1993 { 1994 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 1995 return SECFailure; 1996 return (vector->p_RSA_EncryptOAEP)(key, hashAlg, maskHashAlg, label, 1997 labelLen, seed, seedLen, output, 1998 outputLen, maxOutputLen, input, inputLen); 1999 } 2000 2001 SECStatus 2002 RSA_DecryptOAEP(RSAPrivateKey *key, 2003 HASH_HashType hashAlg, 2004 HASH_HashType maskHashAlg, 2005 const unsigned char *label, 2006 unsigned int labelLen, 2007 unsigned char *output, 2008 unsigned int *outputLen, 2009 unsigned int maxOutputLen, 2010 const unsigned char *input, 2011 unsigned int inputLen) 2012 { 2013 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2014 return SECFailure; 2015 return (vector->p_RSA_DecryptOAEP)(key, hashAlg, maskHashAlg, label, 2016 labelLen, output, outputLen, 2017 maxOutputLen, input, inputLen); 2018 } 2019 2020 SECStatus 2021 RSA_EncryptBlock(RSAPublicKey *key, 2022 unsigned char *output, 2023 unsigned int *outputLen, 2024 unsigned int maxOutputLen, 2025 const unsigned char *input, 2026 unsigned int inputLen) 2027 { 2028 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2029 return SECFailure; 2030 return (vector->p_RSA_EncryptBlock)(key, output, outputLen, maxOutputLen, 2031 input, inputLen); 2032 } 2033 2034 SECStatus 2035 RSA_DecryptBlock(RSAPrivateKey *key, 2036 unsigned char *output, 2037 unsigned int *outputLen, 2038 unsigned int maxOutputLen, 2039 const unsigned char *input, 2040 unsigned int inputLen) 2041 { 2042 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2043 return SECFailure; 2044 return (vector->p_RSA_DecryptBlock)(key, output, outputLen, maxOutputLen, 2045 input, inputLen); 2046 } 2047 2048 SECStatus 2049 RSA_SignPSS(RSAPrivateKey *key, 2050 HASH_HashType hashAlg, 2051 HASH_HashType maskHashAlg, 2052 const unsigned char *salt, 2053 unsigned int saltLen, 2054 unsigned char *output, 2055 unsigned int *outputLen, 2056 unsigned int maxOutputLen, 2057 const unsigned char *input, 2058 unsigned int inputLen) 2059 { 2060 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2061 return SECFailure; 2062 return (vector->p_RSA_SignPSS)(key, hashAlg, maskHashAlg, salt, saltLen, 2063 output, outputLen, maxOutputLen, input, 2064 inputLen); 2065 } 2066 2067 SECStatus 2068 RSA_CheckSignPSS(RSAPublicKey *key, 2069 HASH_HashType hashAlg, 2070 HASH_HashType maskHashAlg, 2071 unsigned int saltLen, 2072 const unsigned char *sig, 2073 unsigned int sigLen, 2074 const unsigned char *hash, 2075 unsigned int hashLen) 2076 { 2077 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2078 return SECFailure; 2079 return (vector->p_RSA_CheckSignPSS)(key, hashAlg, maskHashAlg, saltLen, 2080 sig, sigLen, hash, hashLen); 2081 } 2082 2083 SECStatus 2084 RSA_Sign(RSAPrivateKey *key, 2085 unsigned char *output, 2086 unsigned int *outputLen, 2087 unsigned int maxOutputLen, 2088 const unsigned char *input, 2089 unsigned int inputLen) 2090 { 2091 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2092 return SECFailure; 2093 return (vector->p_RSA_Sign)(key, output, outputLen, maxOutputLen, input, 2094 inputLen); 2095 } 2096 2097 SECStatus 2098 RSA_CheckSign(RSAPublicKey *key, 2099 const unsigned char *sig, 2100 unsigned int sigLen, 2101 const unsigned char *data, 2102 unsigned int dataLen) 2103 { 2104 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2105 return SECFailure; 2106 return (vector->p_RSA_CheckSign)(key, sig, sigLen, data, dataLen); 2107 } 2108 2109 SECStatus 2110 RSA_CheckSignRecover(RSAPublicKey *key, 2111 unsigned char *output, 2112 unsigned int *outputLen, 2113 unsigned int maxOutputLen, 2114 const unsigned char *sig, 2115 unsigned int sigLen) 2116 { 2117 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2118 return SECFailure; 2119 return (vector->p_RSA_CheckSignRecover)(key, output, outputLen, maxOutputLen, 2120 sig, sigLen); 2121 } 2122 2123 SECStatus 2124 EC_FillParams(PLArenaPool *arena, 2125 const SECItem *encodedParams, 2126 ECParams *params) 2127 { 2128 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2129 return SECFailure; 2130 return (vector->p_EC_FillParams)(arena, encodedParams, params); 2131 } 2132 2133 SECStatus 2134 EC_DecodeParams(const SECItem *encodedParams, 2135 ECParams **ecparams) 2136 { 2137 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2138 return SECFailure; 2139 return (vector->p_EC_DecodeParams)(encodedParams, ecparams); 2140 } 2141 2142 SECStatus 2143 EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, 2144 const ECParams *srcParams) 2145 { 2146 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2147 return SECFailure; 2148 return (vector->p_EC_CopyParams)(arena, dstParams, srcParams); 2149 } 2150 2151 SECStatus 2152 ChaCha20_Xor(unsigned char *output, const unsigned char *block, unsigned int len, 2153 const unsigned char *k, const unsigned char *nonce, PRUint32 ctr) 2154 { 2155 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2156 return SECFailure; 2157 } 2158 return (vector->p_ChaCha20_Xor)(output, block, len, k, nonce, ctr); 2159 } 2160 2161 SECStatus 2162 ChaCha20_InitContext(ChaCha20Context *ctx, const unsigned char *key, 2163 unsigned int keyLen, 2164 const unsigned char *nonce, 2165 unsigned int nonceLen, 2166 PRUint32 ctr) 2167 { 2168 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2169 return SECFailure; 2170 return (vector->p_ChaCha20_InitContext)(ctx, key, keyLen, nonce, nonceLen, ctr); 2171 } 2172 2173 ChaCha20Context * 2174 ChaCha20_CreateContext(const unsigned char *key, unsigned int keyLen, 2175 const unsigned char *nonce, unsigned int nonceLen, 2176 PRUint32 ctr) 2177 { 2178 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2179 return NULL; 2180 return (vector->p_ChaCha20_CreateContext)(key, keyLen, nonce, nonceLen, ctr); 2181 } 2182 2183 void 2184 ChaCha20_DestroyContext(ChaCha20Context *ctx, PRBool freeit) 2185 { 2186 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2187 return; 2188 (vector->p_ChaCha20_DestroyContext)(ctx, freeit); 2189 } 2190 2191 SECStatus 2192 ChaCha20Poly1305_InitContext(ChaCha20Poly1305Context *ctx, 2193 const unsigned char *key, unsigned int keyLen, 2194 unsigned int tagLen) 2195 { 2196 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2197 return SECFailure; 2198 return (vector->p_ChaCha20Poly1305_InitContext)(ctx, key, keyLen, tagLen); 2199 } 2200 2201 ChaCha20Poly1305Context * 2202 ChaCha20Poly1305_CreateContext(const unsigned char *key, unsigned int keyLen, 2203 unsigned int tagLen) 2204 { 2205 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2206 return NULL; 2207 return (vector->p_ChaCha20Poly1305_CreateContext)(key, keyLen, tagLen); 2208 } 2209 2210 void 2211 ChaCha20Poly1305_DestroyContext(ChaCha20Poly1305Context *ctx, PRBool freeit) 2212 { 2213 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2214 return; 2215 (vector->p_ChaCha20Poly1305_DestroyContext)(ctx, freeit); 2216 } 2217 2218 SECStatus 2219 ChaCha20Poly1305_Seal(const ChaCha20Poly1305Context *ctx, 2220 unsigned char *output, unsigned int *outputLen, 2221 unsigned int maxOutputLen, 2222 const unsigned char *input, unsigned int inputLen, 2223 const unsigned char *nonce, unsigned int nonceLen, 2224 const unsigned char *ad, unsigned int adLen) 2225 { 2226 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2227 return SECFailure; 2228 return (vector->p_ChaCha20Poly1305_Seal)( 2229 ctx, output, outputLen, maxOutputLen, input, inputLen, 2230 nonce, nonceLen, ad, adLen); 2231 } 2232 2233 SECStatus 2234 ChaCha20Poly1305_Open(const ChaCha20Poly1305Context *ctx, 2235 unsigned char *output, unsigned int *outputLen, 2236 unsigned int maxOutputLen, 2237 const unsigned char *input, unsigned int inputLen, 2238 const unsigned char *nonce, unsigned int nonceLen, 2239 const unsigned char *ad, unsigned int adLen) 2240 { 2241 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2242 return SECFailure; 2243 return (vector->p_ChaCha20Poly1305_Open)( 2244 ctx, output, outputLen, maxOutputLen, input, inputLen, 2245 nonce, nonceLen, ad, adLen); 2246 } 2247 2248 SECStatus 2249 ChaCha20Poly1305_Encrypt(const ChaCha20Poly1305Context *ctx, 2250 unsigned char *output, unsigned int *outputLen, 2251 unsigned int maxOutputLen, 2252 const unsigned char *input, unsigned int inputLen, 2253 const unsigned char *nonce, unsigned int nonceLen, 2254 const unsigned char *ad, unsigned int adLen, 2255 unsigned char *tagOut) 2256 { 2257 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2258 return SECFailure; 2259 return (vector->p_ChaCha20Poly1305_Encrypt)( 2260 ctx, output, outputLen, maxOutputLen, input, inputLen, 2261 nonce, nonceLen, ad, adLen, tagOut); 2262 } 2263 2264 SECStatus 2265 ChaCha20Poly1305_Decrypt(const ChaCha20Poly1305Context *ctx, 2266 unsigned char *output, unsigned int *outputLen, 2267 unsigned int maxOutputLen, 2268 const unsigned char *input, unsigned int inputLen, 2269 const unsigned char *nonce, unsigned int nonceLen, 2270 const unsigned char *ad, unsigned int adLen, 2271 unsigned char *tagIn) 2272 { 2273 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2274 return SECFailure; 2275 return (vector->p_ChaCha20Poly1305_Decrypt)( 2276 ctx, output, outputLen, maxOutputLen, input, inputLen, 2277 nonce, nonceLen, ad, adLen, tagIn); 2278 } 2279 2280 int 2281 EC_GetPointSize(const ECParams *params) 2282 { 2283 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2284 return SECFailure; 2285 return (vector->p_EC_GetPointSize)(params); 2286 } 2287 2288 SECStatus 2289 BLAKE2B_Hash(unsigned char *dest, const char *src) 2290 { 2291 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2292 return SECFailure; 2293 } 2294 return (vector->p_BLAKE2B_Hash)(dest, src); 2295 } 2296 2297 SECStatus 2298 BLAKE2B_HashBuf(unsigned char *output, const unsigned char *input, PRUint32 inlen) 2299 { 2300 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2301 return SECFailure; 2302 } 2303 return (vector->p_BLAKE2B_HashBuf)(output, input, inlen); 2304 } 2305 2306 SECStatus 2307 BLAKE2B_MAC_HashBuf(unsigned char *output, const unsigned char *input, 2308 unsigned int inlen, const unsigned char *key, 2309 unsigned int keylen) 2310 { 2311 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2312 return SECFailure; 2313 } 2314 return (vector->p_BLAKE2B_MAC_HashBuf)(output, input, inlen, key, keylen); 2315 } 2316 2317 BLAKE2BContext * 2318 BLAKE2B_NewContext(void) 2319 { 2320 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2321 return NULL; 2322 } 2323 return (vector->p_BLAKE2B_NewContext)(); 2324 } 2325 2326 void 2327 BLAKE2B_DestroyContext(BLAKE2BContext *ctx, PRBool freeit) 2328 { 2329 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2330 return; 2331 } 2332 (vector->p_BLAKE2B_DestroyContext)(ctx, freeit); 2333 } 2334 2335 SECStatus 2336 BLAKE2B_Begin(BLAKE2BContext *ctx) 2337 { 2338 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2339 return SECFailure; 2340 } 2341 return (vector->p_BLAKE2B_Begin)(ctx); 2342 } 2343 2344 SECStatus 2345 BLAKE2B_MAC_Begin(BLAKE2BContext *ctx, const PRUint8 *key, const size_t keylen) 2346 { 2347 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2348 return SECFailure; 2349 } 2350 return (vector->p_BLAKE2B_MAC_Begin)(ctx, key, keylen); 2351 } 2352 2353 SECStatus 2354 BLAKE2B_Update(BLAKE2BContext *ctx, const unsigned char *in, unsigned int inlen) 2355 { 2356 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2357 return SECFailure; 2358 } 2359 return (vector->p_BLAKE2B_Update)(ctx, in, inlen); 2360 } 2361 2362 SECStatus 2363 BLAKE2B_End(BLAKE2BContext *ctx, unsigned char *out, 2364 unsigned int *digestLen, size_t maxDigestLen) 2365 { 2366 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2367 return SECFailure; 2368 } 2369 return (vector->p_BLAKE2B_End)(ctx, out, digestLen, maxDigestLen); 2370 } 2371 2372 unsigned int 2373 BLAKE2B_FlattenSize(BLAKE2BContext *ctx) 2374 { 2375 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2376 return 0; 2377 } 2378 return (vector->p_BLAKE2B_FlattenSize)(ctx); 2379 } 2380 2381 SECStatus 2382 BLAKE2B_Flatten(BLAKE2BContext *ctx, unsigned char *space) 2383 { 2384 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2385 return SECFailure; 2386 } 2387 return (vector->p_BLAKE2B_Flatten)(ctx, space); 2388 } 2389 2390 BLAKE2BContext * 2391 BLAKE2B_Resurrect(unsigned char *space, void *arg) 2392 { 2393 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) { 2394 return NULL; 2395 } 2396 return (vector->p_BLAKE2B_Resurrect)(space, arg); 2397 } 2398 2399 /* == New for CMAC == */ 2400 SECStatus 2401 CMAC_Init(CMACContext *ctx, CMACCipher type, const unsigned char *key, 2402 unsigned int key_len) 2403 { 2404 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2405 return SECFailure; 2406 return (vector->p_CMAC_Init)(ctx, type, key, key_len); 2407 } 2408 2409 CMACContext * 2410 CMAC_Create(CMACCipher type, const unsigned char *key, unsigned int key_len) 2411 { 2412 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2413 return NULL; 2414 return (vector->p_CMAC_Create)(type, key, key_len); 2415 } 2416 2417 SECStatus 2418 CMAC_Begin(CMACContext *ctx) 2419 { 2420 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2421 return SECFailure; 2422 return (vector->p_CMAC_Begin)(ctx); 2423 } 2424 2425 SECStatus 2426 CMAC_Update(CMACContext *ctx, const unsigned char *data, unsigned int data_len) 2427 { 2428 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2429 return SECFailure; 2430 return (vector->p_CMAC_Update)(ctx, data, data_len); 2431 } 2432 2433 SECStatus 2434 CMAC_Finish(CMACContext *ctx, unsigned char *result, unsigned int *result_len, 2435 unsigned int max_result_len) 2436 { 2437 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2438 return SECFailure; 2439 return (vector->p_CMAC_Finish)(ctx, result, result_len, max_result_len); 2440 } 2441 2442 void 2443 CMAC_Destroy(CMACContext *ctx, PRBool free_it) 2444 { 2445 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2446 return; 2447 (vector->p_CMAC_Destroy)(ctx, free_it); 2448 } 2449 2450 /* ============== New for 3.0026 =============================== */ 2451 2452 SHA3_224Context * 2453 SHA3_224_NewContext(void) 2454 { 2455 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2456 return NULL; 2457 return (vector->p_SHA3_224_NewContext)(); 2458 } 2459 2460 void 2461 SHA3_224_DestroyContext(SHA3_224Context *cx, PRBool freeit) 2462 { 2463 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2464 return; 2465 (vector->p_SHA3_224_DestroyContext)(cx, freeit); 2466 } 2467 2468 unsigned int 2469 SHA3_224_FlattenSize(SHA3_224Context *cx) 2470 { 2471 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2472 return 0; 2473 return (vector->p_SHA3_224_FlattenSize)(cx); 2474 } 2475 2476 void 2477 SHA3_224_Begin(SHA3_224Context *cx) 2478 { 2479 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2480 return; 2481 (vector->p_SHA3_224_Begin)(cx); 2482 } 2483 2484 void 2485 SHA3_224_Update(SHA3_224Context *cx, const unsigned char *input, 2486 unsigned int inputLen) 2487 { 2488 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2489 return; 2490 (vector->p_SHA3_224_Update)(cx, input, inputLen); 2491 } 2492 2493 void 2494 SHA3_224_End(SHA3_224Context *cx, unsigned char *digest, 2495 unsigned int *digestLen, unsigned int maxDigestLen) 2496 { 2497 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2498 return; 2499 (vector->p_SHA3_224_End)(cx, digest, digestLen, maxDigestLen); 2500 } 2501 2502 SECStatus 2503 SHA3_224_Hash(unsigned char *dest, const char *src) 2504 { 2505 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2506 return SECFailure; 2507 return (vector->p_SHA3_224_Hash)(dest, src); 2508 } 2509 2510 SECStatus 2511 SHA3_224_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 2512 { 2513 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2514 return SECFailure; 2515 return (vector->p_SHA3_224_HashBuf)(dest, src, src_length); 2516 } 2517 2518 SHA3_256Context * 2519 SHA3_256_NewContext(void) 2520 { 2521 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2522 return NULL; 2523 return (vector->p_SHA3_256_NewContext)(); 2524 } 2525 2526 void 2527 SHA3_256_DestroyContext(SHA3_256Context *cx, PRBool freeit) 2528 { 2529 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2530 return; 2531 (vector->p_SHA3_256_DestroyContext)(cx, freeit); 2532 } 2533 2534 unsigned int 2535 SHA3_256_FlattenSize(SHA3_256Context *cx) 2536 { 2537 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2538 return 0; 2539 return (vector->p_SHA3_256_FlattenSize)(cx); 2540 } 2541 2542 void 2543 SHA3_256_Begin(SHA3_256Context *cx) 2544 { 2545 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2546 return; 2547 (vector->p_SHA3_256_Begin)(cx); 2548 } 2549 2550 void 2551 SHA3_256_Update(SHA3_256Context *cx, const unsigned char *input, 2552 unsigned int inputLen) 2553 { 2554 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2555 return; 2556 (vector->p_SHA3_256_Update)(cx, input, inputLen); 2557 } 2558 2559 void 2560 SHA3_256_End(SHA3_256Context *cx, unsigned char *digest, 2561 unsigned int *digestLen, unsigned int maxDigestLen) 2562 { 2563 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2564 return; 2565 (vector->p_SHA3_256_End)(cx, digest, digestLen, maxDigestLen); 2566 } 2567 2568 SECStatus 2569 SHA3_256_Hash(unsigned char *dest, const char *src) 2570 { 2571 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2572 return SECFailure; 2573 return (vector->p_SHA3_256_Hash)(dest, src); 2574 } 2575 2576 SECStatus 2577 SHA3_256_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 2578 { 2579 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2580 return SECFailure; 2581 return (vector->p_SHA3_256_HashBuf)(dest, src, src_length); 2582 } 2583 2584 SHA3_384Context * 2585 SHA3_384_NewContext(void) 2586 { 2587 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2588 return NULL; 2589 return (vector->p_SHA3_384_NewContext)(); 2590 } 2591 2592 void 2593 SHA3_384_DestroyContext(SHA3_384Context *cx, PRBool freeit) 2594 { 2595 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2596 return; 2597 (vector->p_SHA3_384_DestroyContext)(cx, freeit); 2598 } 2599 2600 unsigned int 2601 SHA3_384_FlattenSize(SHA3_384Context *cx) 2602 { 2603 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2604 return 0; 2605 return (vector->p_SHA3_384_FlattenSize)(cx); 2606 } 2607 2608 void 2609 SHA3_384_Begin(SHA3_384Context *cx) 2610 { 2611 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2612 return; 2613 (vector->p_SHA3_384_Begin)(cx); 2614 } 2615 2616 void 2617 SHA3_384_Update(SHA3_384Context *cx, const unsigned char *input, 2618 unsigned int inputLen) 2619 { 2620 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2621 return; 2622 (vector->p_SHA3_384_Update)(cx, input, inputLen); 2623 } 2624 2625 void 2626 SHA3_384_End(SHA3_384Context *cx, unsigned char *digest, 2627 unsigned int *digestLen, unsigned int maxDigestLen) 2628 { 2629 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2630 return; 2631 (vector->p_SHA3_384_End)(cx, digest, digestLen, maxDigestLen); 2632 } 2633 2634 SECStatus 2635 SHA3_384_Hash(unsigned char *dest, const char *src) 2636 { 2637 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2638 return SECFailure; 2639 return (vector->p_SHA3_384_Hash)(dest, src); 2640 } 2641 2642 SECStatus 2643 SHA3_384_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 2644 { 2645 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2646 return SECFailure; 2647 return (vector->p_SHA3_384_HashBuf)(dest, src, src_length); 2648 } 2649 2650 SHA3_512Context * 2651 SHA3_512_NewContext(void) 2652 { 2653 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2654 return NULL; 2655 return (vector->p_SHA3_512_NewContext)(); 2656 } 2657 2658 void 2659 SHA3_512_DestroyContext(SHA3_512Context *cx, PRBool freeit) 2660 { 2661 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2662 return; 2663 (vector->p_SHA3_512_DestroyContext)(cx, freeit); 2664 } 2665 2666 unsigned int 2667 SHA3_512_FlattenSize(SHA3_512Context *cx) 2668 { 2669 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2670 return 0; 2671 return (vector->p_SHA3_512_FlattenSize)(cx); 2672 } 2673 2674 void 2675 SHA3_512_Begin(SHA3_512Context *cx) 2676 { 2677 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2678 return; 2679 (vector->p_SHA3_512_Begin)(cx); 2680 } 2681 2682 void 2683 SHA3_512_Update(SHA3_512Context *cx, const unsigned char *input, 2684 unsigned int inputLen) 2685 { 2686 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2687 return; 2688 (vector->p_SHA3_512_Update)(cx, input, inputLen); 2689 } 2690 2691 void 2692 SHA3_512_End(SHA3_512Context *cx, unsigned char *digest, 2693 unsigned int *digestLen, unsigned int maxDigestLen) 2694 { 2695 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2696 return; 2697 (vector->p_SHA3_512_End)(cx, digest, digestLen, maxDigestLen); 2698 } 2699 2700 SECStatus 2701 SHA3_512_Hash(unsigned char *dest, const char *src) 2702 { 2703 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2704 return SECFailure; 2705 return (vector->p_SHA3_512_Hash)(dest, src); 2706 } 2707 2708 SECStatus 2709 SHA3_512_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) 2710 { 2711 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2712 return SECFailure; 2713 return (vector->p_SHA3_512_HashBuf)(dest, src, src_length); 2714 } 2715 2716 SHAKE_128Context * 2717 SHAKE_128_NewContext(void) 2718 { 2719 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2720 return NULL; 2721 return (vector->p_SHAKE_128_NewContext)(); 2722 } 2723 2724 void 2725 SHAKE_128_DestroyContext(SHAKE_128Context *cx, PRBool freeit) 2726 { 2727 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2728 return; 2729 (vector->p_SHAKE_128_DestroyContext)(cx, freeit); 2730 } 2731 2732 void 2733 SHAKE_128_Begin(SHAKE_128Context *cx) 2734 { 2735 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2736 return; 2737 (vector->p_SHAKE_128_Begin)(cx); 2738 } 2739 2740 void 2741 SHAKE_128_Absorb(SHAKE_128Context *cx, const unsigned char *input, 2742 unsigned int inputLen) 2743 { 2744 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2745 return; 2746 (vector->p_SHAKE_128_Absorb)(cx, input, inputLen); 2747 } 2748 2749 void 2750 SHAKE_128_SqueezeEnd(SHAKE_128Context *cx, unsigned char *digest, 2751 unsigned int digestLen) 2752 { 2753 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2754 return; 2755 (vector->p_SHAKE_128_SqueezeEnd)(cx, digest, digestLen); 2756 } 2757 2758 SECStatus 2759 SHAKE_128_HashBuf(unsigned char *dest, PRUint32 dest_length, const unsigned char *src, PRUint32 src_length) 2760 { 2761 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2762 return SECFailure; 2763 return (vector->p_SHAKE_128_HashBuf)(dest, dest_length, src, src_length); 2764 } 2765 2766 SECStatus 2767 SHAKE_128_Hash(unsigned char *dest, PRUint32 dest_length, const char *src) 2768 { 2769 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2770 return SECFailure; 2771 return (vector->p_SHAKE_128_Hash)(dest, dest_length, src); 2772 } 2773 2774 SHAKE_256Context * 2775 SHAKE_256_NewContext(void) 2776 { 2777 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2778 return NULL; 2779 return (vector->p_SHAKE_256_NewContext)(); 2780 } 2781 2782 void 2783 SHAKE_256_DestroyContext(SHAKE_256Context *cx, PRBool freeit) 2784 { 2785 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2786 return; 2787 (vector->p_SHAKE_256_DestroyContext)(cx, freeit); 2788 } 2789 2790 void 2791 SHAKE_256_Begin(SHAKE_256Context *cx) 2792 { 2793 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2794 return; 2795 (vector->p_SHAKE_256_Begin)(cx); 2796 } 2797 2798 void 2799 SHAKE_256_Absorb(SHAKE_256Context *cx, const unsigned char *input, 2800 unsigned int inputLen) 2801 { 2802 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2803 return; 2804 (vector->p_SHAKE_256_Absorb)(cx, input, inputLen); 2805 } 2806 2807 void 2808 SHAKE_256_SqueezeEnd(SHAKE_256Context *cx, unsigned char *digest, 2809 unsigned int digestLen) 2810 { 2811 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2812 return; 2813 (vector->p_SHAKE_256_SqueezeEnd)(cx, digest, digestLen); 2814 } 2815 2816 SECStatus 2817 SHAKE_256_HashBuf(unsigned char *dest, PRUint32 dest_length, const unsigned char *src, PRUint32 src_length) 2818 { 2819 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2820 return SECFailure; 2821 return (vector->p_SHAKE_256_HashBuf)(dest, dest_length, src, src_length); 2822 } 2823 2824 SECStatus 2825 SHAKE_256_Hash(unsigned char *dest, PRUint32 dest_length, const char *src) 2826 { 2827 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2828 return SECFailure; 2829 return (vector->p_SHAKE_256_Hash)(dest, dest_length, src); 2830 } 2831 2832 /* ============== New for 3.0027 =============================== */ 2833 2834 SECStatus 2835 Kyber_NewKey(KyberParams params, const SECItem *seed, SECItem *privKey, SECItem *pubKey) 2836 { 2837 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2838 return SECFailure; 2839 return (vector->p_Kyber_NewKey)(params, seed, privKey, pubKey); 2840 } 2841 2842 SECStatus 2843 Kyber_Encapsulate(KyberParams params, const SECItem *seed, const SECItem *pubKey, SECItem *ciphertext, SECItem *secret) 2844 { 2845 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2846 return SECFailure; 2847 return (vector->p_Kyber_Encapsulate)(params, seed, pubKey, ciphertext, secret); 2848 } 2849 2850 SECStatus 2851 Kyber_Decapsulate(KyberParams params, const SECItem *privKey, const SECItem *ciphertext, SECItem *secret) 2852 { 2853 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2854 return SECFailure; 2855 return (vector->p_Kyber_Decapsulate)(params, privKey, ciphertext, secret); 2856 } 2857 2858 /* ============== New for 3.0028 =============================== */ 2859 2860 SECStatus 2861 ED_SignMessage(ECPrivateKey *key, SECItem *signature, 2862 const SECItem *msg) 2863 { 2864 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2865 return SECFailure; 2866 return (vector->p_ED_SignMessage)(key, signature, msg); 2867 } 2868 2869 SECStatus 2870 ED_VerifyMessage(ECPublicKey *key, const SECItem *signature, 2871 const SECItem *msg) 2872 { 2873 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2874 return SECFailure; 2875 return (vector->p_ED_VerifyMessage)(key, signature, msg); 2876 } 2877 2878 SECStatus 2879 ED_DerivePublicKey(const SECItem *privateKey, SECItem *publicKey) 2880 { 2881 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2882 return SECFailure; 2883 return (vector->p_ED_DerivePublicKey)(privateKey, publicKey); 2884 } 2885 2886 /* ============== New for 3.0029 =============================== */ 2887 2888 SECStatus 2889 X25519_DerivePublicKey(const SECItem *privateKey, SECItem *publicKey) 2890 { 2891 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2892 return SECFailure; 2893 return (vector->p_X25519_DerivePublicKey)(privateKey, publicKey); 2894 } 2895 2896 /* ============== New for 3.0030 =============================== */ 2897 2898 SECStatus 2899 EC_DerivePublicKey(const SECItem *privateKey, const ECParams *ecParams, SECItem *publicKey) 2900 { 2901 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2902 return SECFailure; 2903 return (vector->p_EC_DerivePublicKey)(privateKey, ecParams, publicKey); 2904 } 2905 2906 /* ============== New for 3.0031 =============================== */ 2907 2908 SECStatus 2909 MLDSA_NewKey(CK_ML_DSA_PARAMETER_SET_TYPE paramSet, SECItem *seed, 2910 MLDSAPrivateKey *privKey, MLDSAPublicKey *pubKey) 2911 { 2912 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2913 return SECFailure; 2914 return (vector->p_MLDSA_NewKey)(paramSet, seed, privKey, pubKey); 2915 } 2916 SECStatus 2917 MLDSA_SignInit(MLDSAPrivateKey *key, CK_HEDGE_TYPE hedgeType, 2918 const SECItem *sgnCtx, MLDSAContext **ctx) 2919 { 2920 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2921 return SECFailure; 2922 return (vector->p_MLDSA_SignInit)(key, hedgeType, sgnCtx, ctx); 2923 } 2924 SECStatus 2925 MLDSA_SignUpdate(MLDSAContext *ctx, const SECItem *data) 2926 { 2927 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2928 return SECFailure; 2929 return (vector->p_MLDSA_SignUpdate)(ctx, data); 2930 } 2931 SECStatus 2932 MLDSA_SignFinal(MLDSAContext *ctx, SECItem *signature) 2933 { 2934 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2935 return SECFailure; 2936 return (vector->p_MLDSA_SignFinal)(ctx, signature); 2937 } 2938 2939 SECStatus 2940 MLDSA_VerifyInit(MLDSAPublicKey *key, const SECItem *sgnCtx, 2941 MLDSAContext **ctx) 2942 { 2943 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2944 return SECFailure; 2945 return (vector->p_MLDSA_VerifyInit)(key, sgnCtx, ctx); 2946 } 2947 SECStatus 2948 MLDSA_VerifyUpdate(MLDSAContext *ctx, const SECItem *data) 2949 { 2950 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2951 return SECFailure; 2952 return (vector->p_MLDSA_VerifyUpdate)(ctx, data); 2953 } 2954 SECStatus 2955 MLDSA_VerifyFinal(MLDSAContext *ctx, const SECItem *signature) 2956 { 2957 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2958 return SECFailure; 2959 return (vector->p_MLDSA_VerifyFinal)(ctx, signature); 2960 } 2961 2962 /* ============== New for 3.0032 =============================== */ 2963 SECStatus 2964 EC_DecompressPublicKey(const SECItem *publicCompressed, const ECParams *params, SECItem *publicUncompressed) 2965 { 2966 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) 2967 return SECFailure; 2968 return (vector->p_EC_DecompressPublicKey)(publicCompressed, params, publicUncompressed); 2969 }