From f4568a9015f99c40e69c3ced829833155316cf04 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 11 Aug 2013 18:47:47 +0200 Subject: Forgot isPrime implementation. --- src/BigInt.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/BigInt.cc') diff --git a/src/BigInt.cc b/src/BigInt.cc index 0c1b1a5..3f4b275 100644 --- a/src/BigInt.cc +++ b/src/BigInt.cc @@ -487,6 +487,13 @@ Balau::BigInt & Balau::BigInt::do_modpow(const BigInt & a, const BigInt & m) thr return *this; } +bool Balau::BigInt::isPrime() const throw (GeneralException) { + int r = 0; + if (mp_prime_is_prime(m_bi, NULL, &r) != CRYPT_OK) + throw GeneralException("Error while calling mp_prime_is_prime"); + return r == LTC_MP_YES; +} + Balau::String Balau::BigInt::toString(int radix) const { char * out = (char *) alloca(mp_count_bits(m_bi) / (radix >= 10 ? 3 : 1) + 3); mp_toradix(m_bi, out, radix); -- cgit v1.2.3