summaryrefslogtreecommitdiff
path: root/src/BigInt.cc
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 18:47:47 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 18:47:47 +0200
commitf4568a9015f99c40e69c3ced829833155316cf04 (patch)
treea1ea037d11ec448613fd013a0314a702699569d3 /src/BigInt.cc
parentd5a38318b3876bbedffe52ca3b378b03ad4d995a (diff)
Forgot isPrime implementation.
Diffstat (limited to 'src/BigInt.cc')
-rw-r--r--src/BigInt.cc7
1 files changed, 7 insertions, 0 deletions
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);