BN_is_prime -> BN_is_prime_ex
[novacoin.git] / src / bignum.h
index acba29a..c8ba566 100644 (file)
@@ -78,6 +78,15 @@ public:
         return (*this);
     }
 
+    CBigNum(const BIGNUM *bnp) {
+        BIGNUM *dup = BN_dup(bnp);
+        if (!dup)
+        {
+            throw bignum_error("CBigNum::CBigNum(const BIGNUM*) : BN_dup failed");
+        }
+        bn = dup;
+    }
+
     ~CBigNum()
     {
         BN_clear_free(bn);
@@ -468,12 +477,8 @@ public:
         return ToString(16);
     }
 
-    const BIGNUM* get() const {
-        return bn;
-    }
-
-    BIGNUM* get() {
-        return bn;
+    BIGNUM* get() const {
+        return BN_dup(bn);
     }
 
     unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
@@ -600,7 +605,7 @@ public:
     */
     bool isPrime(const int checks=BN_prime_checks) const {
         CAutoBN_CTX pctx;
-        int ret = BN_is_prime(bn, checks, NULL, pctx, NULL);
+        int ret = BN_is_prime_ex(bn, checks, pctx, NULL);
         if(ret < 0){
             throw bignum_error("CBigNum::isPrime :BN_is_prime");
         }