cangrepp

Some cryptographic attacks
Log | Files | Refs | README

varmkorv.c (637B)


      1 #include <fmpz.h>
      2 #include <stdint.h>
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 
      6 #include "fmpzio.h"
      7 #include "wiener.h"
      8 #include "context.h"
      9 
     10 int
     11 main(void)
     12 {
     13   fmpz_t e, N, res;
     14   ctx_t ctx;
     15 
     16   fmpz_init(e);
     17   fmpz_init(N);
     18   fmpz_init(res);
     19 
     20   ctx_init(&ctx);
     21   ctx_require(&ctx, 10, 5);
     22 
     23   while (1) {
     24     if (read_next_fmpz(N) != 0) {
     25       break;
     26     }
     27 
     28     if (read_next_fmpz(e) != 0) {
     29       break;
     30     }
     31 
     32     if (wiener_factor_small_d(&ctx, res, e, N)) {
     33       fmpz_print(res);
     34       printf("\n");
     35     } else {
     36       printf("0\n");
     37     }
     38   }
     39 
     40   fmpz_clear(e);
     41   fmpz_clear(N);
     42   fmpz_clear(res);
     43 
     44   ctx_clear(&ctx);
     45 
     46   return 0;
     47 }