tor-browser

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

secmpi.c (594B)


      1 #include "blapi.h"
      2 
      3 #include "mpi.h"
      4 #include "mpprime.h"
      5 
      6 mp_err
      7 mpp_random_secure(mp_int *a)
      8 {
      9    SECStatus rv;
     10    rv = RNG_GenerateGlobalRandomBytes((unsigned char *)MP_DIGITS(a), MP_USED(a) * sizeof(mp_digit));
     11    if (rv != SECSuccess) {
     12        return MP_UNDEF;
     13    }
     14    MP_SIGN(a) = MP_ZPOS;
     15    return MP_OKAY;
     16 }
     17 
     18 mp_err
     19 mpp_pprime_secure(mp_int *a, int nt)
     20 {
     21    return mpp_pprime_ext_random(a, nt, &mpp_random_secure);
     22 }
     23 
     24 mp_err
     25 mpp_make_prime_secure(mp_int *start, mp_size nBits, mp_size strong)
     26 {
     27    return mpp_make_prime_ext_random(start, nBits, strong, &mpp_random_secure);
     28 }