tor-browser

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

blapii.h (3505B)


      1 /*
      2 * blapii.h - private data structures and prototypes for the freebl library
      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 _BLAPII_H_
      9 #define _BLAPII_H_
     10 
     11 #include "blapit.h"
     12 #include "mpi.h"
     13 #include "hasht.h"
     14 
     15 /* max block size of supported block ciphers */
     16 #define MAX_BLOCK_SIZE 16
     17 
     18 typedef SECStatus (*freeblCipherFunc)(void *cx, unsigned char *output,
     19                                      unsigned int *outputLen, unsigned int maxOutputLen,
     20                                      const unsigned char *input, unsigned int inputLen,
     21                                      unsigned int blocksize);
     22 typedef SECStatus (*freeblAeadFunc)(void *cx, unsigned char *output,
     23                                    unsigned int *outputLen, unsigned int maxOutputLen,
     24                                    const unsigned char *input, unsigned int inputLen,
     25                                    void *params, unsigned int paramsLen,
     26                                    const unsigned char *aad, unsigned int aadLen,
     27                                    unsigned int blocksize);
     28 typedef void (*freeblDestroyFunc)(void *cx, PRBool freeit);
     29 
     30 SEC_BEGIN_PROTOS
     31 
     32 #ifndef NSS_FIPS_DISABLED
     33 SECStatus BL_FIPSEntryOK(PRBool freeblOnly, PRBool rerun);
     34 PRBool BL_POSTRan(PRBool freeblOnly);
     35 #endif
     36 
     37 #if defined(XP_UNIX) && !defined(NO_FORK_CHECK)
     38 
     39 extern PRBool bl_parentForkedAfterC_Initialize;
     40 
     41 #define SKIP_AFTER_FORK(x)                 \
     42    if (!bl_parentForkedAfterC_Initialize) \
     43    x
     44 
     45 #else
     46 
     47 #define SKIP_AFTER_FORK(x) x
     48 
     49 #endif
     50 
     51 SEC_END_PROTOS
     52 
     53 #if defined(NSS_X86_OR_X64)
     54 #define HAVE_UNALIGNED_ACCESS 1
     55 #endif
     56 
     57 #if defined(__clang__)
     58 #define HAVE_NO_SANITIZE_ATTR __has_attribute(no_sanitize)
     59 #else
     60 #define HAVE_NO_SANITIZE_ATTR 0
     61 #endif
     62 
     63 /* Alignment helpers. */
     64 #if defined(_MSC_VER)
     65 #define pre_align __declspec(align(16))
     66 #define post_align
     67 #elif defined(__GNUC__)
     68 #define pre_align
     69 #define post_align __attribute__((aligned(16)))
     70 #else
     71 #define pre_align
     72 #define post_align
     73 #endif
     74 
     75 #if defined(HAVE_UNALIGNED_ACCESS) && HAVE_NO_SANITIZE_ATTR
     76 #define NO_SANITIZE_ALIGNMENT __attribute__((no_sanitize("alignment")))
     77 #else
     78 #define NO_SANITIZE_ALIGNMENT
     79 #endif
     80 
     81 #undef HAVE_NO_SANITIZE_ATTR
     82 
     83 SECStatus RSA_Init();
     84 SECStatus generate_prime(mp_int *prime, int primeLen);
     85 
     86 SECStatus
     87 RSA_EMSAEncodePSS(unsigned char *em,
     88                  unsigned int emLen,
     89                  unsigned int emBits,
     90                  const unsigned char *mHash,
     91                  HASH_HashType hashAlg,
     92                  HASH_HashType maskHashAlg,
     93                  const unsigned char *salt,
     94                  unsigned int saltLen);
     95 
     96 /* Freebl state. */
     97 PRBool aesni_support();
     98 PRBool clmul_support();
     99 PRBool sha_support();
    100 PRBool avx_support();
    101 PRBool avx2_support();
    102 PRBool adx_support();
    103 PRBool ssse3_support();
    104 PRBool sse4_1_support();
    105 PRBool sse4_2_support();
    106 PRBool arm_neon_support();
    107 PRBool arm_aes_support();
    108 PRBool arm_pmull_support();
    109 PRBool arm_sha1_support();
    110 PRBool arm_sha2_support();
    111 PRBool ppc_crypto_support();
    112 
    113 #ifdef NSS_FIPS_DISABLED
    114 #define BLAPI_CLEAR_STACK(stack_size)
    115 #else
    116 #define BLAPI_CLEAR_STACK(stack_size)                   \
    117    {                                                   \
    118        volatile char _stkclr[stack_size];              \
    119        PORT_SafeZero((void *)&_stkclr[0], stack_size); \
    120    }
    121 #endif
    122 
    123 #endif /* _BLAPII_H_ */