tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ldvector.c (10125B)


      1 /*
      2 * ldvector.c - 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 #ifdef FREEBL_NO_DEPEND
      9 #include "stubs.h"
     10 extern int FREEBL_InitStubs(void);
     11 #endif
     12 
     13 #include "loader.h"
     14 #include "cmac.h"
     15 #include "alghmac.h"
     16 #include "hmacct.h"
     17 #include "blapii.h"
     18 #include "secerr.h"
     19 
     20 SECStatus
     21 FREEBL_Deprecated(void)
     22 {
     23 
     24    PORT_SetError(SEC_ERROR_UNSUPPORTED_KEYALG);
     25    return SECFailure;
     26 }
     27 
     28 static const struct FREEBLVectorStr vector = {
     29 
     30    sizeof vector,
     31    FREEBL_VERSION,
     32 
     33    RSA_NewKey,
     34    RSA_PublicKeyOp,
     35    RSA_PrivateKeyOp,
     36    DSA_NewKey,
     37    DSA_SignDigest,
     38    DSA_VerifyDigest,
     39    DSA_NewKeyFromSeed,
     40    DSA_SignDigestWithSeed,
     41    DH_GenParam,
     42    DH_NewKey,
     43    DH_Derive,
     44    KEA_Derive,
     45    KEA_Verify,
     46    RC4_CreateContext,
     47    RC4_DestroyContext,
     48    RC4_Encrypt,
     49    RC4_Decrypt,
     50 #ifndef NSS_DISABLE_DEPRECATED_RC2
     51    RC2_CreateContext,
     52    RC2_DestroyContext,
     53    RC2_Encrypt,
     54    RC2_Decrypt,
     55 #else
     56    (F_RC2_CreateContext)FREEBL_Deprecated,
     57    (F_RC2_DestroyContext)FREEBL_Deprecated,
     58    (F_RC2_Encrypt)FREEBL_Deprecated,
     59    (F_RC2_Decrypt)FREEBL_Deprecated,
     60 #endif
     61    RC5_CreateContext,
     62    RC5_DestroyContext,
     63    RC5_Encrypt,
     64    RC5_Decrypt,
     65    DES_CreateContext,
     66    DES_DestroyContext,
     67    DES_Encrypt,
     68    DES_Decrypt,
     69    AES_CreateContext,
     70    AES_DestroyContext,
     71    AES_Encrypt,
     72    AES_Decrypt,
     73    MD5_Hash,
     74    MD5_HashBuf,
     75    MD5_NewContext,
     76    MD5_DestroyContext,
     77    MD5_Begin,
     78    MD5_Update,
     79    MD5_End,
     80    MD5_FlattenSize,
     81    MD5_Flatten,
     82    MD5_Resurrect,
     83    MD5_TraceState,
     84    MD2_Hash,
     85    MD2_NewContext,
     86    MD2_DestroyContext,
     87    MD2_Begin,
     88    MD2_Update,
     89    MD2_End,
     90    MD2_FlattenSize,
     91    MD2_Flatten,
     92    MD2_Resurrect,
     93    SHA1_Hash,
     94    SHA1_HashBuf,
     95    SHA1_NewContext,
     96    SHA1_DestroyContext,
     97    SHA1_Begin,
     98    SHA1_Update,
     99    SHA1_End,
    100    SHA1_TraceState,
    101    SHA1_FlattenSize,
    102    SHA1_Flatten,
    103    SHA1_Resurrect,
    104    RNG_RNGInit,
    105    RNG_RandomUpdate,
    106    RNG_GenerateGlobalRandomBytes,
    107    RNG_RNGShutdown,
    108    PQG_ParamGen,
    109    PQG_ParamGenSeedLen,
    110    PQG_VerifyParams,
    111 
    112    /* End of Version 3.001. */
    113 
    114    RSA_PrivateKeyOpDoubleChecked,
    115    RSA_PrivateKeyCheck,
    116    BL_Cleanup,
    117 
    118    /* End of Version 3.002. */
    119 
    120    SHA256_NewContext,
    121    SHA256_DestroyContext,
    122    SHA256_Begin,
    123    SHA256_Update,
    124    SHA256_End,
    125    SHA256_HashBuf,
    126    SHA256_Hash,
    127    SHA256_TraceState,
    128    SHA256_FlattenSize,
    129    SHA256_Flatten,
    130    SHA256_Resurrect,
    131 
    132    SHA512_NewContext,
    133    SHA512_DestroyContext,
    134    SHA512_Begin,
    135    SHA512_Update,
    136    SHA512_End,
    137    SHA512_HashBuf,
    138    SHA512_Hash,
    139    SHA512_TraceState,
    140    SHA512_FlattenSize,
    141    SHA512_Flatten,
    142    SHA512_Resurrect,
    143 
    144    SHA384_NewContext,
    145    SHA384_DestroyContext,
    146    SHA384_Begin,
    147    SHA384_Update,
    148    SHA384_End,
    149    SHA384_HashBuf,
    150    SHA384_Hash,
    151    SHA384_TraceState,
    152    SHA384_FlattenSize,
    153    SHA384_Flatten,
    154    SHA384_Resurrect,
    155 
    156    /* End of Version 3.003. */
    157 
    158    AESKeyWrap_CreateContext,
    159    AESKeyWrap_DestroyContext,
    160    AESKeyWrap_Encrypt,
    161    AESKeyWrap_Decrypt,
    162 
    163    /* End of Version 3.004. */
    164 
    165    BLAPI_SHVerify,
    166    BLAPI_VerifySelf,
    167 
    168    /* End of Version 3.005. */
    169 
    170    EC_NewKey,
    171    EC_NewKeyFromSeed,
    172    EC_ValidatePublicKey,
    173    ECDH_Derive,
    174    ECDSA_SignDigest,
    175    ECDSA_VerifyDigest,
    176    ECDSA_SignDigestWithSeed,
    177 
    178    /* End of Version 3.006. */
    179    /* End of Version 3.007. */
    180 
    181    AES_InitContext,
    182    AESKeyWrap_InitContext,
    183    DES_InitContext,
    184 #ifndef NSS_DISABLE_DEPRECATED_RC2
    185    RC2_InitContext,
    186 #else
    187    (F_RC2_InitContext)FREEBL_Deprecated,
    188 #endif
    189    RC4_InitContext,
    190 
    191    AES_AllocateContext,
    192    AESKeyWrap_AllocateContext,
    193    DES_AllocateContext,
    194 #ifndef NSS_DISABLE_DEPRECATED_RC2
    195    RC2_AllocateContext,
    196 #else
    197    (F_RC2_AllocateContext)FREEBL_Deprecated,
    198 #endif
    199    RC4_AllocateContext,
    200 
    201    MD2_Clone,
    202    MD5_Clone,
    203    SHA1_Clone,
    204    SHA256_Clone,
    205    SHA384_Clone,
    206    SHA512_Clone,
    207 
    208    TLS_PRF,
    209    HASH_GetRawHashObject,
    210 
    211    HMAC_Create,
    212    HMAC_Init,
    213    HMAC_Begin,
    214    HMAC_Update,
    215    HMAC_Clone,
    216    HMAC_Finish,
    217    HMAC_Destroy,
    218 
    219    RNG_SystemInfoForRNG,
    220 
    221    /* End of Version 3.008. */
    222 
    223    FIPS186Change_GenerateX,
    224    FIPS186Change_ReduceModQForDSA,
    225 
    226    /* End of Version 3.009. */
    227    Camellia_InitContext,
    228    Camellia_AllocateContext,
    229    Camellia_CreateContext,
    230    Camellia_DestroyContext,
    231    Camellia_Encrypt,
    232    Camellia_Decrypt,
    233 
    234    PQG_DestroyParams,
    235    PQG_DestroyVerify,
    236 
    237 /* End of Version 3.010. */
    238 
    239 #ifndef NSS_DISABLE_DEPRECATED_SEED
    240    SEED_InitContext,
    241    SEED_AllocateContext,
    242    SEED_CreateContext,
    243    SEED_DestroyContext,
    244    SEED_Encrypt,
    245    SEED_Decrypt,
    246 #else
    247    (F_SEED_InitContext)FREEBL_Deprecated,
    248    (F_SEED_AllocateContext)FREEBL_Deprecated,
    249    (F_SEED_CreateContext)FREEBL_Deprecated,
    250    (F_SEED_DestroyContext)FREEBL_Deprecated,
    251    (F_SEED_Encrypt)FREEBL_Deprecated,
    252    (F_SEED_Decrypt)FREEBL_Deprecated,
    253 #endif /* NSS_DISABLE_DEPRECATED_SEED */
    254 
    255    BL_Init,
    256    BL_SetForkState,
    257 
    258    PRNGTEST_Instantiate,
    259    PRNGTEST_Reseed,
    260    PRNGTEST_Generate,
    261 
    262    PRNGTEST_Uninstantiate,
    263 
    264    /* End of Version 3.011. */
    265 
    266    RSA_PopulatePrivateKey,
    267 
    268    DSA_NewRandom,
    269 
    270    JPAKE_Sign,
    271    JPAKE_Verify,
    272    JPAKE_Round2,
    273    JPAKE_Final,
    274 
    275    /* End of Version 3.012 */
    276 
    277    TLS_P_hash,
    278    SHA224_NewContext,
    279    SHA224_DestroyContext,
    280    SHA224_Begin,
    281    SHA224_Update,
    282    SHA224_End,
    283    SHA224_HashBuf,
    284    SHA224_Hash,
    285    SHA224_TraceState,
    286    SHA224_FlattenSize,
    287    SHA224_Flatten,
    288    SHA224_Resurrect,
    289    SHA224_Clone,
    290    BLAPI_SHVerifyFile,
    291 
    292    /* End of Version 3.013 */
    293 
    294    PQG_ParamGenV2,
    295    PRNGTEST_RunHealthTests,
    296 
    297    /* End of Version 3.014 */
    298 
    299    HMAC_ConstantTime,
    300    SSLv3_MAC_ConstantTime,
    301 
    302    /* End of Version 3.015 */
    303 
    304    RSA_SignRaw,
    305    RSA_CheckSignRaw,
    306    RSA_CheckSignRecoverRaw,
    307    RSA_EncryptRaw,
    308    RSA_DecryptRaw,
    309    RSA_EncryptOAEP,
    310    RSA_DecryptOAEP,
    311    RSA_EncryptBlock,
    312    RSA_DecryptBlock,
    313    RSA_SignPSS,
    314    RSA_CheckSignPSS,
    315    RSA_Sign,
    316    RSA_CheckSign,
    317    RSA_CheckSignRecover,
    318 
    319    /* End of Version 3.016 */
    320 
    321    EC_FillParams,
    322    EC_DecodeParams,
    323    EC_CopyParams,
    324 
    325    /* End of Version 3.017 */
    326 
    327    ChaCha20Poly1305_InitContext,
    328    ChaCha20Poly1305_CreateContext,
    329    ChaCha20Poly1305_DestroyContext,
    330    ChaCha20Poly1305_Seal,
    331    ChaCha20Poly1305_Open,
    332 
    333    /* End of Version 3.018 */
    334 
    335    EC_GetPointSize,
    336 
    337    /* End of Version 3.019 */
    338 
    339    BLAKE2B_Hash,
    340    BLAKE2B_HashBuf,
    341    BLAKE2B_MAC_HashBuf,
    342    BLAKE2B_NewContext,
    343    BLAKE2B_DestroyContext,
    344    BLAKE2B_Begin,
    345    BLAKE2B_MAC_Begin,
    346    BLAKE2B_Update,
    347    BLAKE2B_End,
    348    BLAKE2B_FlattenSize,
    349    BLAKE2B_Flatten,
    350    BLAKE2B_Resurrect,
    351 
    352    /* End of Version 3.020 */
    353 
    354    ChaCha20_Xor,
    355 
    356    /* End of version 3.021 */
    357 
    358    CMAC_Init,
    359    CMAC_Create,
    360    CMAC_Begin,
    361    CMAC_Update,
    362    CMAC_Finish,
    363    CMAC_Destroy,
    364 
    365    /* End of version 3.022 */
    366    ChaCha20Poly1305_Encrypt,
    367    ChaCha20Poly1305_Decrypt,
    368    AES_AEAD,
    369    AESKeyWrap_EncryptKWP,
    370    AESKeyWrap_DecryptKWP,
    371 
    372    /* End of version 3.023 */
    373    KEA_PrimeCheck,
    374 
    375    /* End of version 3.024 */
    376    ChaCha20_InitContext,
    377    ChaCha20_CreateContext,
    378    ChaCha20_DestroyContext,
    379 
    380    /* End of version 3.025 */
    381 
    382    SHA3_224_NewContext,
    383    SHA3_224_DestroyContext,
    384    SHA3_224_FlattenSize,
    385    SHA3_224_Begin,
    386    SHA3_224_Update,
    387    SHA3_224_End,
    388    SHA3_224_HashBuf,
    389    SHA3_224_Hash,
    390 
    391    SHA3_256_NewContext,
    392    SHA3_256_DestroyContext,
    393    SHA3_256_FlattenSize,
    394    SHA3_256_Begin,
    395    SHA3_256_Update,
    396    SHA3_256_End,
    397    SHA3_256_HashBuf,
    398    SHA3_256_Hash,
    399 
    400    SHA3_384_NewContext,
    401    SHA3_384_DestroyContext,
    402    SHA3_384_FlattenSize,
    403    SHA3_384_Begin,
    404    SHA3_384_Update,
    405    SHA3_384_End,
    406    SHA3_384_HashBuf,
    407    SHA3_384_Hash,
    408 
    409    SHA3_512_NewContext,
    410    SHA3_512_DestroyContext,
    411    SHA3_512_FlattenSize,
    412    SHA3_512_Begin,
    413    SHA3_512_Update,
    414    SHA3_512_End,
    415    SHA3_512_HashBuf,
    416    SHA3_512_Hash,
    417 
    418    SHAKE_128_NewContext,
    419    SHAKE_128_DestroyContext,
    420    SHAKE_128_Begin,
    421    SHAKE_128_Absorb,
    422    SHAKE_128_SqueezeEnd,
    423    SHAKE_128_HashBuf,
    424    SHAKE_128_Hash,
    425 
    426    SHAKE_256_NewContext,
    427    SHAKE_256_DestroyContext,
    428    SHAKE_256_Begin,
    429    SHAKE_256_Absorb,
    430    SHAKE_256_SqueezeEnd,
    431    SHAKE_256_HashBuf,
    432    SHAKE_256_Hash,
    433 
    434    /* End of version 3.026 */
    435 
    436    Kyber_NewKey,
    437    Kyber_Encapsulate,
    438    Kyber_Decapsulate,
    439 
    440    /* End of version 3.027 */
    441 
    442    ED_SignMessage,
    443    ED_VerifyMessage,
    444    ED_DerivePublicKey,
    445    /* End of version 3.028 */
    446 
    447    X25519_DerivePublicKey,
    448    /* End of version 3.029 */
    449 
    450    EC_DerivePublicKey,
    451    /* End of version 3.030 */
    452 
    453    MLDSA_NewKey,
    454    MLDSA_SignInit,
    455    MLDSA_SignUpdate,
    456    MLDSA_SignFinal,
    457    MLDSA_VerifyInit,
    458    MLDSA_VerifyUpdate,
    459    MLDSA_VerifyFinal,
    460    /* End of version 3.031 */
    461 
    462    EC_DecompressPublicKey,
    463    /* End of version 3.032 */
    464 
    465 };
    466 
    467 const FREEBLVector*
    468 FREEBL_GetVector(void)
    469 {
    470 #ifdef FREEBL_NO_DEPEND
    471    SECStatus rv;
    472 #endif
    473 
    474 #define NSS_VERSION_VARIABLE __nss_freebl_version
    475 #include "verref.h"
    476 
    477 #ifdef FREEBL_NO_DEPEND
    478    /* this entry point is only valid if nspr and nss-util has been loaded */
    479    rv = FREEBL_InitStubs();
    480    if (rv != SECSuccess) {
    481        return NULL;
    482    }
    483 #endif
    484 
    485 #ifndef NSS_FIPS_DISABLED
    486    /* In FIPS mode make sure the Full self tests have been run before
    487     * continuing. */
    488    BL_POSTRan(PR_FALSE);
    489 #endif
    490 
    491    return &vector;
    492 }
    493 
    494 #ifdef FREEBL_LOWHASH
    495 static const struct NSSLOWVectorStr nssvector = {
    496    sizeof nssvector,
    497    NSSLOW_VERSION,
    498    FREEBL_GetVector,
    499    NSSLOW_Init,
    500    NSSLOW_Shutdown,
    501    NSSLOW_Reset,
    502    NSSLOWHASH_NewContext,
    503    NSSLOWHASH_Begin,
    504    NSSLOWHASH_Update,
    505    NSSLOWHASH_End,
    506    NSSLOWHASH_Destroy,
    507    NSSLOWHASH_Length
    508 };
    509 
    510 const NSSLOWVector*
    511 NSSLOW_GetVector(void)
    512 {
    513    /* POST check and  stub init happens in FREEBL_GetVector() and
    514     * NSSLOW_Init() respectively */
    515    return &nssvector;
    516 }
    517 #endif