1 /* 2 * loader.h - 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 #ifndef _LOADER_H_ 9 #define _LOADER_H_ 1 10 11 #include "blapi.h" 12 13 #define FREEBL_VERSION 0x0325 14 15 struct FREEBLVectorStr { 16 17 unsigned short length; /* of this struct in bytes */ 18 unsigned short version; /* of this struct. */ 19 20 RSAPrivateKey *(*p_RSA_NewKey)(int keySizeInBits, 21 SECItem *publicExponent); 22 23 SECStatus (*p_RSA_PublicKeyOp)(RSAPublicKey *key, 24 unsigned char *output, 25 const unsigned char *input); 26 27 SECStatus (*p_RSA_PrivateKeyOp)(RSAPrivateKey *key, 28 unsigned char *output, 29 const unsigned char *input); 30 31 SECStatus (*p_DSA_NewKey)(const PQGParams *params, 32 DSAPrivateKey **privKey); 33 34 SECStatus (*p_DSA_SignDigest)(DSAPrivateKey *key, 35 SECItem *signature, 36 const SECItem *digest); 37 38 SECStatus (*p_DSA_VerifyDigest)(DSAPublicKey *key, 39 const SECItem *signature, 40 const SECItem *digest); 41 42 SECStatus (*p_DSA_NewKeyFromSeed)(const PQGParams *params, 43 const unsigned char *seed, 44 DSAPrivateKey **privKey); 45 46 SECStatus (*p_DSA_SignDigestWithSeed)(DSAPrivateKey *key, 47 SECItem *signature, 48 const SECItem *digest, 49 const unsigned char *seed); 50 51 SECStatus (*p_DH_GenParam)(int primeLen, DHParams **params); 52 53 SECStatus (*p_DH_NewKey)(DHParams *params, 54 DHPrivateKey **privKey); 55 56 SECStatus (*p_DH_Derive)(SECItem *publicValue, 57 SECItem *prime, 58 SECItem *privateValue, 59 SECItem *derivedSecret, 60 unsigned int maxOutBytes); 61 62 SECStatus (*p_KEA_Derive)(SECItem *prime, 63 SECItem *public1, 64 SECItem *public2, 65 SECItem *private1, 66 SECItem *private2, 67 SECItem *derivedSecret); 68 69 PRBool (*p_KEA_Verify)(SECItem *Y, SECItem *prime, SECItem *subPrime); 70 71 RC4Context *(*p_RC4_CreateContext)(const unsigned char *key, int len); 72 73 void (*p_RC4_DestroyContext)(RC4Context *cx, PRBool freeit); 74 75 SECStatus (*p_RC4_Encrypt)(RC4Context *cx, unsigned char *output, 76 unsigned int *outputLen, unsigned int maxOutputLen, 77 const unsigned char *input, unsigned int inputLen); 78 79 SECStatus (*p_RC4_Decrypt)(RC4Context *cx, unsigned char *output, 80 unsigned int *outputLen, unsigned int maxOutputLen, 81 const unsigned char *input, unsigned int inputLen); 82 83 RC2Context *(*p_RC2_CreateContext)(const unsigned char *key, 84 unsigned int len, const unsigned char *iv, 85 int mode, unsigned effectiveKeyLen); 86 87 void (*p_RC2_DestroyContext)(RC2Context *cx, PRBool freeit); 88 89 SECStatus (*p_RC2_Encrypt)(RC2Context *cx, unsigned char *output, 90 unsigned int *outputLen, unsigned int maxOutputLen, 91 const unsigned char *input, unsigned int inputLen); 92 93 SECStatus (*p_RC2_Decrypt)(RC2Context *cx, unsigned char *output, 94 unsigned int *outputLen, unsigned int maxOutputLen, 95 const unsigned char *input, unsigned int inputLen); 96 97 RC5Context *(*p_RC5_CreateContext)(const SECItem *key, unsigned int rounds, 98 unsigned int wordSize, const unsigned char *iv, int mode); 99 100 void (*p_RC5_DestroyContext)(RC5Context *cx, PRBool freeit); 101 102 SECStatus (*p_RC5_Encrypt)(RC5Context *cx, unsigned char *output, 103 unsigned int *outputLen, unsigned int maxOutputLen, 104 const unsigned char *input, unsigned int inputLen); 105 106 SECStatus (*p_RC5_Decrypt)(RC5Context *cx, unsigned char *output, 107 unsigned int *outputLen, unsigned int maxOutputLen, 108 const unsigned char *input, unsigned int inputLen); 109 110 DESContext *(*p_DES_CreateContext)(const unsigned char *key, 111 const unsigned char *iv, 112 int mode, PRBool encrypt); 113 114 void (*p_DES_DestroyContext)(DESContext *cx, PRBool freeit); 115 116 SECStatus (*p_DES_Encrypt)(DESContext *cx, unsigned char *output, 117 unsigned int *outputLen, unsigned int maxOutputLen, 118 const unsigned char *input, unsigned int inputLen); 119 120 SECStatus (*p_DES_Decrypt)(DESContext *cx, unsigned char *output, 121 unsigned int *outputLen, unsigned int maxOutputLen, 122 const unsigned char *input, unsigned int inputLen); 123 124 AESContext *(*p_AES_CreateContext)(const unsigned char *key, 125 const unsigned char *iv, 126 int mode, int encrypt, unsigned int keylen, 127 unsigned int blocklen); 128 129 void (*p_AES_DestroyContext)(AESContext *cx, PRBool freeit); 130 131 SECStatus (*p_AES_Encrypt)(AESContext *cx, unsigned char *output, 132 unsigned int *outputLen, unsigned int maxOutputLen, 133 const unsigned char *input, unsigned int inputLen); 134 135 SECStatus (*p_AES_Decrypt)(AESContext *cx, unsigned char *output, 136 unsigned int *outputLen, unsigned int maxOutputLen, 137 const unsigned char *input, unsigned int inputLen); 138 139 SECStatus (*p_MD5_Hash)(unsigned char *dest, const char *src); 140 141 SECStatus (*p_MD5_HashBuf)(unsigned char *dest, const unsigned char *src, 142 PRUint32 src_length); 143 144 MD5Context *(*p_MD5_NewContext)(void); 145 146 void (*p_MD5_DestroyContext)(MD5Context *cx, PRBool freeit); 147 148 void (*p_MD5_Begin)(MD5Context *cx); 149 150 void (*p_MD5_Update)(MD5Context *cx, 151 const unsigned char *input, unsigned int inputLen); 152 153 void (*p_MD5_End)(MD5Context *cx, unsigned char *digest, 154 unsigned int *digestLen, unsigned int maxDigestLen); 155 156 unsigned int (*p_MD5_FlattenSize)(MD5Context *cx); 157 158 SECStatus (*p_MD5_Flatten)(MD5Context *cx, unsigned char *space); 159 160 MD5Context *(*p_MD5_Resurrect)(unsigned char *space, void *arg); 161 162 void (*p_MD5_TraceState)(MD5Context *cx); 163 164 SECStatus (*p_MD2_Hash)(unsigned char *dest, const char *src); 165 166 MD2Context *(*p_MD2_NewContext)(void); 167 168 void (*p_MD2_DestroyContext)(MD2Context *cx, PRBool freeit); 169 170 void (*p_MD2_Begin)(MD2Context *cx); 171 172 void (*p_MD2_Update)(MD2Context *cx, 173 const unsigned char *input, unsigned int inputLen); 174 175 void (*p_MD2_End)(MD2Context *cx, unsigned char *digest, 176 unsigned int *digestLen, unsigned int maxDigestLen); 177 178 unsigned int (*p_MD2_FlattenSize)(MD2Context *cx); 179 180 SECStatus (*p_MD2_Flatten)(MD2Context *cx, unsigned char *space); 181 182 MD2Context *(*p_MD2_Resurrect)(unsigned char *space, void *arg); 183 184 SECStatus (*p_SHA1_Hash)(unsigned char *dest, const char *src); 185 186 SECStatus (*p_SHA1_HashBuf)(unsigned char *dest, const unsigned char *src, 187 PRUint32 src_length); 188 189 SHA1Context *(*p_SHA1_NewContext)(void); 190 191 void (*p_SHA1_DestroyContext)(SHA1Context *cx, PRBool freeit); 192 193 void (*p_SHA1_Begin)(SHA1Context *cx); 194 195 void (*p_SHA1_Update)(SHA1Context *cx, const unsigned char *input, 196 unsigned int inputLen); 197 198 void (*p_SHA1_End)(SHA1Context *cx, unsigned char *digest, 199 unsigned int *digestLen, unsigned int maxDigestLen); 200 201 void (*p_SHA1_TraceState)(SHA1Context *cx); 202 203 unsigned int (*p_SHA1_FlattenSize)(SHA1Context *cx); 204 205 SECStatus (*p_SHA1_Flatten)(SHA1Context *cx, unsigned char *space); 206 207 SHA1Context *(*p_SHA1_Resurrect)(unsigned char *space, void *arg); 208 209 SECStatus (*p_RNG_RNGInit)(void); 210 211 SECStatus (*p_RNG_RandomUpdate)(const void *data, size_t bytes); 212 213 SECStatus (*p_RNG_GenerateGlobalRandomBytes)(void *dest, size_t len); 214 215 void (*p_RNG_RNGShutdown)(void); 216 217 SECStatus (*p_PQG_ParamGen)(unsigned int j, PQGParams **pParams, 218 PQGVerify **pVfy); 219 220 SECStatus (*p_PQG_ParamGenSeedLen)(unsigned int j, unsigned int seedBytes, 221 PQGParams **pParams, PQGVerify **pVfy); 222 223 SECStatus (*p_PQG_VerifyParams)(const PQGParams *params, 224 const PQGVerify *vfy, SECStatus *result); 225 226 /* Version 3.001 came to here */ 227 228 SECStatus (*p_RSA_PrivateKeyOpDoubleChecked)(RSAPrivateKey *key, 229 unsigned char *output, 230 const unsigned char *input); 231 232 SECStatus (*p_RSA_PrivateKeyCheck)(const RSAPrivateKey *key); 233 234 void (*p_BL_Cleanup)(void); 235 236 /* Version 3.002 came to here */ 237 238 SHA256Context *(*p_SHA256_NewContext)(void); 239 void (*p_SHA256_DestroyContext)(SHA256Context *cx, PRBool freeit); 240 void (*p_SHA256_Begin)(SHA256Context *cx); 241 void (*p_SHA256_Update)(SHA256Context *cx, const unsigned char *input, 242 unsigned int inputLen); 243 void (*p_SHA256_End)(SHA256Context *cx, unsigned char *digest, 244 unsigned int *digestLen, unsigned int maxDigestLen); 245 SECStatus (*p_SHA256_HashBuf)(unsigned char *dest, const unsigned char *src, 246 PRUint32 src_length); 247 SECStatus (*p_SHA256_Hash)(unsigned char *dest, const char *src); 248 void (*p_SHA256_TraceState)(SHA256Context *cx); 249 unsigned int (*p_SHA256_FlattenSize)(SHA256Context *cx); 250 SECStatus (*p_SHA256_Flatten)(SHA256Context *cx, unsigned char *space); 251 SHA256Context *(*p_SHA256_Resurrect)(unsigned char *space, void *arg); 252 253 SHA512Context *(*p_SHA512_NewContext)(void); 254 void (*p_SHA512_DestroyContext)(SHA512Context *cx, PRBool freeit); 255 void (*p_SHA512_Begin)(SHA512Context *cx); 256 void (*p_SHA512_Update)(SHA512Context *cx, const unsigned char *input, 257 unsigned int inputLen); 258 void (*p_SHA512_End)(SHA512Context *cx, unsigned char *digest, 259 unsigned int *digestLen, unsigned int maxDigestLen); 260 SECStatus (*p_SHA512_HashBuf)(unsigned char *dest, const unsigned char *src, 261 PRUint32 src_length); 262 SECStatus (*p_SHA512_Hash)(unsigned char *dest, const char *src); 263 void (*p_SHA512_TraceState)(SHA512Context *cx); 264 unsigned int (*p_SHA512_FlattenSize)(SHA512Context *cx); 265 SECStatus (*p_SHA512_Flatten)(SHA512Context *cx, unsigned char *space); 266 SHA512Context *(*p_SHA512_Resurrect)(unsigned char *space, void *arg); 267 268 SHA384Context *(*p_SHA384_NewContext)(void); 269 void (*p_SHA384_DestroyContext)(SHA384Context *cx, PRBool freeit); 270 void (*p_SHA384_Begin)(SHA384Context *cx); 271 void (*p_SHA384_Update)(SHA384Context *cx, const unsigned char *input, 272 unsigned int inputLen); 273 void (*p_SHA384_End)(SHA384Context *cx, unsigned char *digest, 274 unsigned int *digestLen, unsigned int maxDigestLen); 275 SECStatus (*p_SHA384_HashBuf)(unsigned char *dest, const unsigned char *src, 276 PRUint32 src_length); 277 SECStatus (*p_SHA384_Hash)(unsigned char *dest, const char *src); 278 void (*p_SHA384_TraceState)(SHA384Context *cx); 279 unsigned int (*p_SHA384_FlattenSize)(SHA384Context *cx); 280 SECStatus (*p_SHA384_Flatten)(SHA384Context *cx, unsigned char *space); 281 SHA384Context *(*p_SHA384_Resurrect)(unsigned char *space, void *arg); 282 283 /* Version 3.003 came to here */ 284 285 AESKeyWrapContext *(*p_AESKeyWrap_CreateContext)(const unsigned char *key, 286 const unsigned char *iv, int encrypt, unsigned int keylen); 287 288 void (*p_AESKeyWrap_DestroyContext)(AESKeyWrapContext *cx, PRBool freeit); 289 290 SECStatus (*p_AESKeyWrap_Encrypt)(AESKeyWrapContext *cx, 291 unsigned char *output, 292 unsigned int *outputLen, unsigned int maxOutputLen, 293 const unsigned char *input, unsigned int inputLen); 294 295 SECStatus (*p_AESKeyWrap_Decrypt)(AESKeyWrapContext *cx, 296 unsigned char *output, 297 unsigned int *outputLen, unsigned int maxOutputLen, 298 const unsigned char *input, unsigned int inputLen); 299 300 /* Version 3.004 came to here */ 301 302 PRBool (*p_BLAPI_SHVerify)(const char *name, PRFuncPtr addr); 303 PRBool (*p_BLAPI_VerifySelf)(const char *name); 304 305 /* Version 3.005 came to here */ 306 307 SECStatus (*p_EC_NewKey)(ECParams *params, 308 ECPrivateKey **privKey); 309 310 SECStatus (*p_EC_NewKeyFromSeed)(ECParams *params, 311 ECPrivateKey **privKey, 312 const unsigned char *seed, 313 int seedlen); 314 315 SECStatus (*p_EC_ValidatePublicKey)(ECParams *params, 316 SECItem *publicValue); 317 318 SECStatus (*p_ECDH_Derive)(SECItem *publicValue, 319 ECParams *params, 320 SECItem *privateValue, 321 PRBool withCofactor, 322 SECItem *derivedSecret); 323 324 SECStatus (*p_ECDSA_SignDigest)(ECPrivateKey *key, 325 SECItem *signature, 326 const SECItem *digest); 327 328 SECStatus (*p_ECDSA_VerifyDigest)(ECPublicKey *key, 329 const SECItem *signature, 330 const SECItem *digest); 331 332 SECStatus (*p_ECDSA_SignDigestWithSeed)(ECPrivateKey *key, 333 SECItem *signature, 334 const SECItem *digest, 335 const unsigned char *seed, 336 const int seedlen); 337 338 /* Version 3.006 came to here */ 339 340 /* no modification to FREEBLVectorStr itself 341 * but ECParamStr was modified 342 */ 343 344 /* Version 3.007 came to here */ 345 346 SECStatus (*p_AES_InitContext)(AESContext *cx, 347 const unsigned char *key, 348 unsigned int keylen, 349 const unsigned char *iv, 350 int mode, 351 unsigned int encrypt, 352 unsigned int blocklen); 353 SECStatus (*p_AESKeyWrap_InitContext)(AESKeyWrapContext *cx, 354 const unsigned char *key, 355 unsigned int keylen, 356 const unsigned char *iv, 357 int mode, 358 unsigned int encrypt, 359 unsigned int blocklen); 360 SECStatus (*p_DES_InitContext)(DESContext *cx, 361 const unsigned char *key, 362 unsigned int keylen, 363 const unsigned char *iv, 364 int mode, 365 unsigned int encrypt, 366 unsigned int); 367 SECStatus (*p_RC2_InitContext)(RC2Context *cx, 368 const unsigned char *key, 369 unsigned int keylen, 370 const unsigned char *iv, 371 int mode, 372 unsigned int effectiveKeyLen, 373 unsigned int); 374 SECStatus (*p_RC4_InitContext)(RC4Context *cx, 375 const unsigned char *key, 376 unsigned int keylen, 377 const unsigned char *, 378 int, 379 unsigned int, 380 unsigned int); 381 382 AESContext *(*p_AES_AllocateContext)(void); 383 AESKeyWrapContext *(*p_AESKeyWrap_AllocateContext)(void); 384 DESContext *(*p_DES_AllocateContext)(void); 385 RC2Context *(*p_RC2_AllocateContext)(void); 386 RC4Context *(*p_RC4_AllocateContext)(void); 387 388 void (*p_MD2_Clone)(MD2Context *dest, MD2Context *src); 389 void (*p_MD5_Clone)(MD5Context *dest, MD5Context *src); 390 void (*p_SHA1_Clone)(SHA1Context *dest, SHA1Context *src); 391 void (*p_SHA256_Clone)(SHA256Context *dest, SHA256Context *src); 392 void (*p_SHA384_Clone)(SHA384Context *dest, SHA384Context *src); 393 void (*p_SHA512_Clone)(SHA512Context *dest, SHA512Context *src); 394 395 SECStatus (*p_TLS_PRF)(const SECItem *secret, const char *label, 396 SECItem *seed, SECItem *result, PRBool isFIPS); 397 398 const SECHashObject *(*p_HASH_GetRawHashObject)(HASH_HashType hashType); 399 400 HMACContext *(*p_HMAC_Create)(const SECHashObject *hashObj, 401 const unsigned char *secret, 402 unsigned int secret_len, PRBool isFIPS); 403 SECStatus (*p_HMAC_Init)(HMACContext *cx, const SECHashObject *hash_obj, 404 const unsigned char *secret, 405 unsigned int secret_len, PRBool isFIPS); 406 void (*p_HMAC_Begin)(HMACContext *cx); 407 void (*p_HMAC_Update)(HMACContext *cx, const unsigned char *data, 408 unsigned int data_len); 409 HMACContext *(*p_HMAC_Clone)(HMACContext *cx); 410 SECStatus (*p_HMAC_Finish)(HMACContext *cx, unsigned char *result, 411 unsigned int *result_len, 412 unsigned int max_result_len); 413 void (*p_HMAC_Destroy)(HMACContext *cx, PRBool freeit); 414 415 void (*p_RNG_SystemInfoForRNG)(void); 416 417 /* Version 3.008 came to here */ 418 419 SECStatus (*p_FIPS186Change_GenerateX)(unsigned char *XKEY, 420 const unsigned char *XSEEDj, 421 unsigned char *x_j); 422 SECStatus (*p_FIPS186Change_ReduceModQForDSA)(const unsigned char *w, 423 const unsigned char *q, 424 unsigned char *xj); 425 426 /* Version 3.009 came to here */ 427 428 SECStatus (*p_Camellia_InitContext)(CamelliaContext *cx, 429 const unsigned char *key, 430 unsigned int keylen, 431 const unsigned char *iv, 432 int mode, 433 unsigned int encrypt, 434 unsigned int unused); 435 436 CamelliaContext *(*p_Camellia_AllocateContext)(void); 437 CamelliaContext *(*p_Camellia_CreateContext)(const unsigned char *key, 438 const unsigned char *iv, 439 int mode, int encrypt, 440 unsigned int keylen); 441 void (*p_Camellia_DestroyContext)(CamelliaContext *cx, PRBool freeit); 442 443 SECStatus (*p_Camellia_Encrypt)(CamelliaContext *cx, unsigned char *output, 444 unsigned int *outputLen, 445 unsigned int maxOutputLen, 446 const unsigned char *input, 447 unsigned int inputLen); 448 449 SECStatus (*p_Camellia_Decrypt)(CamelliaContext *cx, unsigned char *output, 450 unsigned int *outputLen, 451 unsigned int maxOutputLen, 452 const unsigned char *input, 453 unsigned int inputLen); 454 455 void (*p_PQG_DestroyParams)(PQGParams *params); 456 457 void (*p_PQG_DestroyVerify)(PQGVerify *vfy); 458 459 /* Version 3.010 came to here */ 460 461 SECStatus (*p_SEED_InitContext)(SEEDContext *cx, 462 const unsigned char *key, 463 unsigned int keylen, 464 const unsigned char *iv, 465 int mode, 466 unsigned int encrypt, 467 unsigned int); 468 469 SEEDContext *(*p_SEED_AllocateContext)(void); 470 471 SEEDContext *(*p_SEED_CreateContext)(const unsigned char *key, 472 const unsigned char *iv, 473 int mode, PRBool encrypt); 474 475 void (*p_SEED_DestroyContext)(SEEDContext *cx, PRBool freeit); 476 477 SECStatus (*p_SEED_Encrypt)(SEEDContext *cx, unsigned char *output, 478 unsigned int *outputLen, unsigned int maxOutputLen, 479 const unsigned char *input, unsigned int inputLen); 480 481 SECStatus (*p_SEED_Decrypt)(SEEDContext *cx, unsigned char *output, 482 unsigned int *outputLen, unsigned int maxOutputLen, 483 const unsigned char *input, unsigned int inputLen); 484 485 SECStatus (*p_BL_Init)(void); 486 void (*p_BL_SetForkState)(PRBool); 487 488 SECStatus (*p_PRNGTEST_Instantiate)(const PRUint8 *entropy, 489 unsigned int entropy_len, 490 const PRUint8 *nonce, 491 unsigned int nonce_len, 492 const PRUint8 *personal_string, 493 unsigned int ps_len); 494 495 SECStatus (*p_PRNGTEST_Reseed)(const PRUint8 *entropy, 496 unsigned int entropy_len, 497 const PRUint8 *additional, 498 unsigned int additional_len); 499 500 SECStatus (*p_PRNGTEST_Generate)(PRUint8 *bytes, 501 unsigned int bytes_len, 502 const PRUint8 *additional, 503 unsigned int additional_len); 504 505 SECStatus (*p_PRNGTEST_Uninstantiate)(void); 506 /* Version 3.011 came to here */ 507 508 SECStatus (*p_RSA_PopulatePrivateKey)(RSAPrivateKey *key); 509 510 SECStatus (*p_DSA_NewRandom)(PLArenaPool *arena, const SECItem *q, 511 SECItem *seed); 512 513 SECStatus (*p_JPAKE_Sign)(PLArenaPool *arena, const PQGParams *pqg, 514 HASH_HashType hashType, const SECItem *signerID, 515 const SECItem *x, const SECItem *testRandom, 516 const SECItem *gxIn, SECItem *gxOut, 517 SECItem *gv, SECItem *r); 518 519 SECStatus (*p_JPAKE_Verify)(PLArenaPool *arena, const PQGParams *pqg, 520 HASH_HashType hashType, const SECItem *signerID, 521 const SECItem *peerID, const SECItem *gx, 522 const SECItem *gv, const SECItem *r); 523 524 SECStatus (*p_JPAKE_Round2)(PLArenaPool *arena, const SECItem *p, 525 const SECItem *q, const SECItem *gx1, 526 const SECItem *gx3, const SECItem *gx4, 527 SECItem *base, const SECItem *x2, 528 const SECItem *s, SECItem *x2s); 529 530 SECStatus (*p_JPAKE_Final)(PLArenaPool *arena, const SECItem *p, 531 const SECItem *q, const SECItem *x2, 532 const SECItem *gx4, const SECItem *x2s, 533 const SECItem *B, SECItem *K); 534 535 /* Version 3.012 came to here */ 536 537 SECStatus (*p_TLS_P_hash)(HASH_HashType hashAlg, 538 const SECItem *secret, 539 const char *label, 540 SECItem *seed, 541 SECItem *result, 542 PRBool isFIPS); 543 544 SHA224Context *(*p_SHA224_NewContext)(void); 545 void (*p_SHA224_DestroyContext)(SHA224Context *cx, PRBool freeit); 546 void (*p_SHA224_Begin)(SHA224Context *cx); 547 void (*p_SHA224_Update)(SHA224Context *cx, const unsigned char *input, 548 unsigned int inputLen); 549 void (*p_SHA224_End)(SHA224Context *cx, unsigned char *digest, 550 unsigned int *digestLen, unsigned int maxDigestLen); 551 SECStatus (*p_SHA224_HashBuf)(unsigned char *dest, const unsigned char *src, 552 PRUint32 src_length); 553 SECStatus (*p_SHA224_Hash)(unsigned char *dest, const char *src); 554 void (*p_SHA224_TraceState)(SHA224Context *cx); 555 unsigned int (*p_SHA224_FlattenSize)(SHA224Context *cx); 556 SECStatus (*p_SHA224_Flatten)(SHA224Context *cx, unsigned char *space); 557 SHA224Context *(*p_SHA224_Resurrect)(unsigned char *space, void *arg); 558 void (*p_SHA224_Clone)(SHA224Context *dest, SHA224Context *src); 559 PRBool (*p_BLAPI_SHVerifyFile)(const char *name); 560 561 /* Version 3.013 came to here */ 562 563 SECStatus (*p_PQG_ParamGenV2)(unsigned int L, unsigned int N, 564 unsigned int seedBytes, 565 PQGParams **pParams, PQGVerify **pVfy); 566 SECStatus (*p_PRNGTEST_RunHealthTests)(void); 567 568 /* Version 3.014 came to here */ 569 570 SECStatus (*p_HMAC_ConstantTime)( 571 unsigned char *result, 572 unsigned int *resultLen, 573 unsigned int maxResultLen, 574 const SECHashObject *hashObj, 575 const unsigned char *secret, 576 unsigned int secretLen, 577 const unsigned char *header, 578 unsigned int headerLen, 579 const unsigned char *body, 580 unsigned int bodyLen, 581 unsigned int bodyTotalLen); 582 583 SECStatus (*p_SSLv3_MAC_ConstantTime)( 584 unsigned char *result, 585 unsigned int *resultLen, 586 unsigned int maxResultLen, 587 const SECHashObject *hashObj, 588 const unsigned char *secret, 589 unsigned int secretLen, 590 const unsigned char *header, 591 unsigned int headerLen, 592 const unsigned char *body, 593 unsigned int bodyLen, 594 unsigned int bodyTotalLen); 595 596 /* Version 3.015 came to here */ 597 598 SECStatus (*p_RSA_SignRaw)(RSAPrivateKey *key, 599 unsigned char *output, 600 unsigned int *outputLen, 601 unsigned int maxOutputLen, 602 const unsigned char *input, 603 unsigned int inputLen); 604 SECStatus (*p_RSA_CheckSignRaw)(RSAPublicKey *key, 605 const unsigned char *sig, 606 unsigned int sigLen, 607 const unsigned char *hash, 608 unsigned int hashLen); 609 SECStatus (*p_RSA_CheckSignRecoverRaw)(RSAPublicKey *key, 610 unsigned char *data, 611 unsigned int *dataLen, 612 unsigned int maxDataLen, 613 const unsigned char *sig, 614 unsigned int sigLen); 615 SECStatus (*p_RSA_EncryptRaw)(RSAPublicKey *key, 616 unsigned char *output, 617 unsigned int *outputLen, 618 unsigned int maxOutputLen, 619 const unsigned char *input, 620 unsigned int inputLen); 621 SECStatus (*p_RSA_DecryptRaw)(RSAPrivateKey *key, 622 unsigned char *output, 623 unsigned int *outputLen, 624 unsigned int maxOutputLen, 625 const unsigned char *input, 626 unsigned int inputLen); 627 SECStatus (*p_RSA_EncryptOAEP)(RSAPublicKey *key, 628 HASH_HashType hashAlg, 629 HASH_HashType maskHashAlg, 630 const unsigned char *label, 631 unsigned int labelLen, 632 const unsigned char *seed, 633 unsigned int seedLen, 634 unsigned char *output, 635 unsigned int *outputLen, 636 unsigned int maxOutputLen, 637 const unsigned char *input, 638 unsigned int inputLen); 639 SECStatus (*p_RSA_DecryptOAEP)(RSAPrivateKey *key, 640 HASH_HashType hashAlg, 641 HASH_HashType maskHashAlg, 642 const unsigned char *label, 643 unsigned int labelLen, 644 unsigned char *output, 645 unsigned int *outputLen, 646 unsigned int maxOutputLen, 647 const unsigned char *input, 648 unsigned int inputLen); 649 SECStatus (*p_RSA_EncryptBlock)(RSAPublicKey *key, 650 unsigned char *output, 651 unsigned int *outputLen, 652 unsigned int maxOutputLen, 653 const unsigned char *input, 654 unsigned int inputLen); 655 SECStatus (*p_RSA_DecryptBlock)(RSAPrivateKey *key, 656 unsigned char *output, 657 unsigned int *outputLen, 658 unsigned int maxOutputLen, 659 const unsigned char *input, 660 unsigned int inputLen); 661 SECStatus (*p_RSA_SignPSS)(RSAPrivateKey *key, 662 HASH_HashType hashAlg, 663 HASH_HashType maskHashAlg, 664 const unsigned char *salt, 665 unsigned int saltLen, 666 unsigned char *output, 667 unsigned int *outputLen, 668 unsigned int maxOutputLen, 669 const unsigned char *input, 670 unsigned int inputLen); 671 SECStatus (*p_RSA_CheckSignPSS)(RSAPublicKey *key, 672 HASH_HashType hashAlg, 673 HASH_HashType maskHashAlg, 674 unsigned int saltLen, 675 const unsigned char *sig, 676 unsigned int sigLen, 677 const unsigned char *hash, 678 unsigned int hashLen); 679 SECStatus (*p_RSA_Sign)(RSAPrivateKey *key, 680 unsigned char *output, 681 unsigned int *outputLen, 682 unsigned int maxOutputLen, 683 const unsigned char *input, 684 unsigned int inputLen); 685 SECStatus (*p_RSA_CheckSign)(RSAPublicKey *key, 686 const unsigned char *sig, 687 unsigned int sigLen, 688 const unsigned char *data, 689 unsigned int dataLen); 690 SECStatus (*p_RSA_CheckSignRecover)(RSAPublicKey *key, 691 unsigned char *output, 692 unsigned int *outputLen, 693 unsigned int maxOutputLen, 694 const unsigned char *sig, 695 unsigned int sigLen); 696 697 /* Version 3.016 came to here */ 698 699 SECStatus (*p_EC_FillParams)(PLArenaPool *arena, 700 const SECItem *encodedParams, ECParams *params); 701 SECStatus (*p_EC_DecodeParams)(const SECItem *encodedParams, 702 ECParams **ecparams); 703 SECStatus (*p_EC_CopyParams)(PLArenaPool *arena, ECParams *dstParams, 704 const ECParams *srcParams); 705 706 /* Version 3.017 came to here */ 707 708 SECStatus (*p_ChaCha20Poly1305_InitContext)(ChaCha20Poly1305Context *ctx, 709 const unsigned char *key, 710 unsigned int keyLen, 711 unsigned int tagLen); 712 713 ChaCha20Poly1305Context *(*p_ChaCha20Poly1305_CreateContext)( 714 const unsigned char *key, unsigned int keyLen, unsigned int tagLen); 715 716 void (*p_ChaCha20Poly1305_DestroyContext)(ChaCha20Poly1305Context *ctx, 717 PRBool freeit); 718 719 SECStatus (*p_ChaCha20Poly1305_Seal)( 720 const ChaCha20Poly1305Context *ctx, unsigned char *output, 721 unsigned int *outputLen, unsigned int maxOutputLen, 722 const unsigned char *input, unsigned int inputLen, 723 const unsigned char *nonce, unsigned int nonceLen, 724 const unsigned char *ad, unsigned int adLen); 725 726 SECStatus (*p_ChaCha20Poly1305_Open)( 727 const ChaCha20Poly1305Context *ctx, unsigned char *output, 728 unsigned int *outputLen, unsigned int maxOutputLen, 729 const unsigned char *input, unsigned int inputLen, 730 const unsigned char *nonce, unsigned int nonceLen, 731 const unsigned char *ad, unsigned int adLen); 732 733 /* Version 3.018 came to here */ 734 735 int (*p_EC_GetPointSize)(const ECParams *); 736 737 /* Version 3.019 came to here */ 738 739 SECStatus (*p_BLAKE2B_Hash)(unsigned char *dest, const char *src); 740 SECStatus (*p_BLAKE2B_HashBuf)(unsigned char *output, 741 const unsigned char *input, PRUint32 inlen); 742 SECStatus (*p_BLAKE2B_MAC_HashBuf)(unsigned char *output, 743 const unsigned char *input, 744 unsigned int inlen, 745 const unsigned char *key, 746 unsigned int keylen); 747 BLAKE2BContext *(*p_BLAKE2B_NewContext)(); 748 void (*p_BLAKE2B_DestroyContext)(BLAKE2BContext *ctx, PRBool freeit); 749 SECStatus (*p_BLAKE2B_Begin)(BLAKE2BContext *ctx); 750 SECStatus (*p_BLAKE2B_MAC_Begin)(BLAKE2BContext *ctx, const PRUint8 *key, 751 const size_t keylen); 752 SECStatus (*p_BLAKE2B_Update)(BLAKE2BContext *ctx, const unsigned char *in, 753 unsigned int inlen); 754 SECStatus (*p_BLAKE2B_End)(BLAKE2BContext *ctx, unsigned char *out, 755 unsigned int *digestLen, size_t maxDigestLen); 756 unsigned int (*p_BLAKE2B_FlattenSize)(BLAKE2BContext *ctx); 757 SECStatus (*p_BLAKE2B_Flatten)(BLAKE2BContext *ctx, unsigned char *space); 758 BLAKE2BContext *(*p_BLAKE2B_Resurrect)(unsigned char *space, void *arg); 759 760 /* Version 3.020 came to here */ 761 762 SECStatus (*p_ChaCha20_Xor)(unsigned char *output, const unsigned char *block, 763 unsigned int len, const unsigned char *k, 764 const unsigned char *nonce, PRUint32 ctr); 765 766 /* Version 3.021 came to here */ 767 768 SECStatus (*p_CMAC_Init)(CMACContext *ctx, CMACCipher type, 769 const unsigned char *key, unsigned int key_len); 770 CMACContext *(*p_CMAC_Create)(CMACCipher type, const unsigned char *key, 771 unsigned int key_len); 772 SECStatus (*p_CMAC_Begin)(CMACContext *ctx); 773 SECStatus (*p_CMAC_Update)(CMACContext *ctx, const unsigned char *data, 774 unsigned int data_len); 775 SECStatus (*p_CMAC_Finish)(CMACContext *ctx, unsigned char *result, 776 unsigned int *result_len, 777 unsigned int max_result_len); 778 void (*p_CMAC_Destroy)(CMACContext *ctx, PRBool free_it); 779 780 /* Version 3.022 came to here */ 781 SECStatus (*p_ChaCha20Poly1305_Encrypt)( 782 const ChaCha20Poly1305Context *ctx, unsigned char *output, 783 unsigned int *outputLen, unsigned int maxOutputLen, 784 const unsigned char *input, unsigned int inputLen, 785 const unsigned char *nonce, unsigned int nonceLen, 786 const unsigned char *ad, unsigned int adLen, unsigned char *tagOut); 787 788 SECStatus (*p_ChaCha20Poly1305_Decrypt)( 789 const ChaCha20Poly1305Context *ctx, unsigned char *output, 790 unsigned int *outputLen, unsigned int maxOutputLen, 791 const unsigned char *input, unsigned int inputLen, 792 const unsigned char *nonce, unsigned int nonceLen, 793 const unsigned char *ad, unsigned int adLen, unsigned char *tagIn); 794 SECStatus (*p_AES_AEAD)(AESContext *cx, unsigned char *output, 795 unsigned int *outputLen, unsigned int maxOutputLen, 796 const unsigned char *input, unsigned int inputLen, 797 void *params, unsigned int paramsLen, 798 const unsigned char *aad, unsigned int aadLen); 799 SECStatus (*p_AESKeyWrap_EncryptKWP)(AESKeyWrapContext *cx, 800 unsigned char *output, 801 unsigned int *outputLen, 802 unsigned int maxOutputLen, 803 const unsigned char *input, 804 unsigned int inputLen); 805 806 SECStatus (*p_AESKeyWrap_DecryptKWP)(AESKeyWrapContext *cx, 807 unsigned char *output, 808 unsigned int *outputLen, 809 unsigned int maxOutputLen, 810 const unsigned char *input, 811 unsigned int inputLen); 812 813 /* Version 3.023 came to here */ 814 815 PRBool (*p_KEA_PrimeCheck)(SECItem *prime); 816 /* Version 3.024 came to here */ 817 818 SECStatus (*p_ChaCha20_InitContext)(ChaCha20Context *ctx, 819 const unsigned char *key, 820 unsigned int keyLen, 821 const unsigned char *nonce, 822 unsigned int nonceLen, 823 PRUint32 ctr); 824 825 ChaCha20Context *(*p_ChaCha20_CreateContext)(const unsigned char *key, 826 unsigned int keyLen, 827 const unsigned char *nonce, 828 unsigned int nonceLen, 829 PRUint32 ctr); 830 831 void (*p_ChaCha20_DestroyContext)(ChaCha20Context *ctx, PRBool freeit); 832 833 /* Version 3.025 came to here */ 834 835 /* Add new function pointers at the end of this struct and bump 836 * FREEBL_VERSION at the beginning of this file. */ 837 }; 838 839 typedef struct FREEBLVectorStr FREEBLVector; 840 841 #ifdef FREEBL_LOWHASH 842 #include "nsslowhash.h" 843 844 #define NSSLOW_VERSION 0x0300 845 846 struct NSSLOWVectorStr { 847 unsigned short length; /* of this struct in bytes */ 848 unsigned short version; /* of this struct. */ 849 const FREEBLVector *(*p_FREEBL_GetVector)(void); 850 NSSLOWInitContext *(*p_NSSLOW_Init)(void); 851 void (*p_NSSLOW_Shutdown)(NSSLOWInitContext *context); 852 void (*p_NSSLOW_Reset)(NSSLOWInitContext *context); 853 NSSLOWHASHContext *(*p_NSSLOWHASH_NewContext)( 854 NSSLOWInitContext *initContext, 855 HASH_HashType hashType); 856 void (*p_NSSLOWHASH_Begin)(NSSLOWHASHContext *context); 857 void (*p_NSSLOWHASH_Update)(NSSLOWHASHContext *context, 858 const unsigned char *buf, 859 unsigned int len); 860 void (*p_NSSLOWHASH_End)(NSSLOWHASHContext *context, 861 unsigned char *buf, 862 unsigned int *ret, unsigned int len); 863 void (*p_NSSLOWHASH_Destroy)(NSSLOWHASHContext *context); 864 unsigned int (*p_NSSLOWHASH_Length)(NSSLOWHASHContext *context); 865 }; 866 867 typedef struct NSSLOWVectorStr NSSLOWVector; 868 #endif 869 870 SEC_BEGIN_PROTOS 871 872 #ifdef FREEBL_LOWHASH 873 typedef const NSSLOWVector *NSSLOWGetVectorFn(void); 874 875 extern NSSLOWGetVectorFn NSSLOW_GetVector; 876 #endif 877 878 typedef const FREEBLVector *FREEBLGetVectorFn(void); 879 880 extern FREEBLGetVectorFn FREEBL_GetVector; 881 882 SEC_END_PROTOS 883 884 #endif 885 886 #ifdef NSS_DISABLE_DEPRECATED_SEED 887 typedef SECStatus (*F_SEED_InitContext)(SEEDContext *cx, 888 const unsigned char *key, 889 unsigned int keylen, 890 const unsigned char *iv, 891 int mode, 892 unsigned int encrypt, 893 unsigned int); 894 895 typedef SEEDContext *(*F_SEED_AllocateContext)(void); 896 897 typedef SEEDContext *(*F_SEED_CreateContext)(const unsigned char *key, 898 const unsigned char *iv, 899 int mode, PRBool encrypt); 900 901 typedef void (*F_SEED_DestroyContext)(SEEDContext *cx, PRBool freeit); 902 903 typedef SECStatus (*F_SEED_Encrypt)(SEEDContext *cx, unsigned char *output, 904 unsigned int *outputLen, unsigned int maxOutputLen, 905 const unsigned char *input, unsigned int inputLen); 906 907 typedef SECStatus (*F_SEED_Decrypt)(SEEDContext *cx, unsigned char *output, 908 unsigned int *outputLen, unsigned int maxOutputLen, 909 const unsigned char *input, unsigned int inputLen); 910 #endif 911 912 #ifdef NSS_DISABLE_DEPRECATED_RC2 913 typedef RC2Context *(*F_RC2_CreateContext)(const unsigned char *key, 914 unsigned int len, const unsigned char *iv, 915 int mode, unsigned effectiveKeyLen); 916 917 typedef void (*F_RC2_DestroyContext)(RC2Context *cx, PRBool freeit); 918 919 typedef SECStatus (*F_RC2_Encrypt)(RC2Context *cx, unsigned char *output, 920 unsigned int *outputLen, unsigned int maxOutputLen, 921 const unsigned char *input, unsigned int inputLen); 922 923 typedef SECStatus (*F_RC2_Decrypt)(RC2Context *cx, unsigned char *output, 924 unsigned int *outputLen, unsigned int maxOutputLen, 925 const unsigned char *input, unsigned int inputLen); 926 927 typedef SECStatus (*F_RC2_InitContext)(RC2Context *cx, 928 const unsigned char *key, 929 unsigned int keylen, 930 const unsigned char *iv, 931 int mode, 932 unsigned int effectiveKeyLen, 933 unsigned int); 934 935 typedef RC2Context *(*F_RC2_AllocateContext)(void); 936 #endif 937