diff options
| -rw-r--r-- | includes/BigInt.h | 2 | ||||
| -rw-r--r-- | src/BigInt.cc | 7 | 
2 files changed, 8 insertions, 1 deletions
diff --git a/includes/BigInt.h b/includes/BigInt.h index 29a2740..55a5c75 100644 --- a/includes/BigInt.h +++ b/includes/BigInt.h @@ -91,7 +91,7 @@ class BigInt {      BigInt & do_modinv(const BigInt & m) throw (GeneralException);      BigInt & do_modpow(const BigInt & a, const BigInt & m) throw (GeneralException); -    bool isPrime() const; +    bool isPrime() const throw (GeneralException);      String toString(int radix = 10) const;      char * makeString(int radix = 10) const; 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);  | 
