summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c')
-rw-r--r--source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c b/source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c
new file mode 100644
index 0000000000..0458744fc7
--- /dev/null
+++ b/source4/heimdal/lib/hcrypto/libtommath/bn_mp_find_prime.c
@@ -0,0 +1,26 @@
+/* TomsFastMath, a fast ISO C bignum library.
+ *
+ * This project is public domain and free for all purposes.
+ *
+ * Love Hornquist Astrand <lha@h5l.org>
+ */
+#include <tommath.h>
+
+int mp_find_prime(mp_int *a)
+{
+ int res;
+
+ if (mp_iseven(a))
+ mp_add_d(a, 1, a);
+
+ do {
+
+ if ((res = mp_isprime(a)) == MP_NO) {
+ mp_add_d(a, 2, a);
+ continue;
+ }
+
+ } while (res != MP_YES);
+
+ return res;
+}