BN_primality_test function

  1. @RecordUse.new()
  2. @Native<Int Function(Pointer<Int>, Pointer<BIGNUM>, Int, Pointer<BN_CTX>, Int, Pointer<BN_GENCB>)>(ffi.Pointer<ffi.Int>, ffi.Pointer<BIGNUM>, ffi.Int, ffi.Pointer<BN_CTX>, ffi.Int, ffi.Pointer<BN_GENCB>)>(symbol: 'bssl_dart_BN_primality_test')
int BN_primality_test(
  1. Pointer<Int> is_probably_prime,
  2. Pointer<BIGNUM> candidate,
  3. int checks,
  4. Pointer<BN_CTX> ctx,
  5. int do_trial_division,
  6. Pointer<BN_GENCB> cb,
)

BN_primality_test sets |*is_probably_prime| to one if |candidate| is probably a prime number by the Miller-Rabin test or zero if it's certainly not.

If |do_trial_division| is non-zero then |candidate| will be tested against a list of small primes before Miller-Rabin tests. The probability of this function returning a false positive is at most 2^{2*checks}. See |BN_prime_checks_for_validation| and |BN_prime_checks_for_generation| for recommended values of |checks|.

If |cb| is not NULL then it is called during the checking process. See the comment above |BN_GENCB|.

The function returns one on success and zero on error.

Implementation

@meta.RecordUse()
@ffi.Native<
  ffi.Int Function(
    ffi.Pointer<ffi.Int>,
    ffi.Pointer<BIGNUM>,
    ffi.Int,
    ffi.Pointer<BN_CTX>,
    ffi.Int,
    ffi.Pointer<BN_GENCB>,
  )
>(symbol: 'bssl_dart_BN_primality_test')
external int BN_primality_test(
  ffi.Pointer<ffi.Int> is_probably_prime,
  ffi.Pointer<BIGNUM> candidate,
  int checks,
  ffi.Pointer<BN_CTX> ctx,
  int do_trial_division,
  ffi.Pointer<BN_GENCB> cb,
);