diff libtomcrypt/src/math/rand_prime.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
line wrap: on
line diff
--- a/libtomcrypt/src/math/rand_prime.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/math/rand_prime.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,15 +5,15 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 #include "tomcrypt.h"
 
+#if defined(LTC_MRSA) || (!defined(LTC_NO_MATH) && !defined(LTC_NO_PRNGS))
+
 /**
   @file rand_prime.c
   Generate a random prime, Tom St Denis
-*/  
+*/
 
 #define USE_BBS 1
 
@@ -33,13 +33,13 @@
    }
 
    /* allow sizes between 2 and 512 bytes for a prime size */
-   if (len < 2 || len > 512) { 
+   if (len < 2 || len > 512) {
       return CRYPT_INVALID_PRIME_SIZE;
    }
-   
+
    /* valid PRNG? Better be! */
    if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
-      return err; 
+      return err;
    }
 
    /* allocate buffer to work with */
@@ -58,7 +58,7 @@
       /* munge bits */
       buf[0]     |= 0x80 | 0x40;
       buf[len-1] |= 0x01 | ((type & USE_BBS) ? 0x02 : 0x00);
- 
+
       /* load value */
       if ((err = mp_read_unsigned_bin(N, buf, len)) != CRYPT_OK) {
          XFREE(buf);
@@ -66,7 +66,7 @@
       }
 
       /* test */
-      if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) {
+      if ((err = mp_prime_is_prime(N, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) {
          XFREE(buf);
          return err;
       }
@@ -79,9 +79,10 @@
    XFREE(buf);
    return CRYPT_OK;
 }
-      
+
+#endif /* LTC_NO_MATH */
 
 
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */