#include int main(int argc, char**argv) { if (argc!=4) { fprintf(stderr, "Usage: calcpq \n"); fprintf(stderr, " numbers can be specified decimal, or 0xHEX\n"); } mpz_t pubexp; parsenum(pubexp, argv[1]); mpz_t privexp; parsenum(privexp, argv[2]); mpz_t pubmod; parsenum(pubmod, argv[3]); // pubexp*privexp + b * (p-1)*(q-1) = 1 // calc pubexp*privexp-1 mpz_t x; mpz_init(x); mpz_set_ui(x, -1); mpz_addmul(x,pubexp,privexp); // todo: factor // // todo: iterate over factor combinations, b, x, y // until (x+1)*(y+1) == pubmod }