Browse Source

Merge branch 'feature/wiener'

Conflicts:
	src/questions/tests/test_wiener.c
	src/questions/wiener.c
Michele Orrù 11 years ago
parent
commit
4fd29e7f36
2 changed files with 4 additions and 2 deletions
  1. 1 1
      src/questions/tests/test_wiener.c
  2. 3 1
      src/questions/wiener.c

+ 1 - 1
src/questions/tests/test_wiener.c

@@ -162,7 +162,7 @@ void test_BN_sqrtmod(void)
 void test_wiener(void)
 {
   X509 *crt;
-  FILE *fp = fopen("questions/tests/wiener_test.crt", "r");
+  FILE *fp = fopen("tests/wiener_test.crt", "r");
 
   if (!fp) exit(EXIT_FAILURE);
   crt = PEM_read_X509(fp, NULL, 0, NULL);

+ 3 - 1
src/questions/wiener.c

@@ -204,6 +204,7 @@ int wiener_question_ask(X509* cert)
   /* equation coefficients */
   BIGNUM *b2, *delta;
   BN_CTX *ctx;
+  int bits;
 
   rsa = X509_get_pubkey(cert)->pkey.rsa;
   phi = BN_new();
@@ -217,11 +218,12 @@ int wiener_question_ask(X509* cert)
   /*
    * Generate the continued fractions approximating e/N
    */
+  bits = BN_num_bits(n);
   cf = cf_init(NULL, e, n);
   ctx = cf->ctx;
   for (i=0, it = cf_next(cf);
        // XXX. how many keys shall I test?
-       i!=100 && it;
+       i!=bits && it;
        i++, it = cf_next(cf)) {
     t = it->h;
     d = it->k;