/* Author: Pate Williams (c) 1997 Exercise 9.7 "Suppose that Alice is using the Quisquater Scheme with n = 199543, b = 523, and v = 146152. Suppose that Olga has discovered that v ^ 465 101360 ^ b = v ^ 257 36056 ^ b mod n. Show how Olga can compute u." -Douglas R. Stinson- See "Cryptograhy: Theory and Practice" by Douglas R. Stinson page 304. */ #include #include "lip.h" int main(void) { long b = 523, n = 199543l, v = 146152l; long r1 = 456, r2 = 257, y1 = 101360l; long y2 = 36056l; verylong za = 0, zb = 0, zc = 0, zd = 0, zl = 0; verylong zn = 0, zt = 0, zu = 0, zv = 0; verylong zr1 = 0, zr2 = 0, zy1 = 0, zy2 = 0; zintoz(b, &zb); zintoz(n, &zn); zintoz(v, &zv); zintoz(r1, &zr1); zintoz(r2, &zr2); zintoz(y1, &zy1); zintoz(y2, &zy2); zsubmod(zr1, zr2, zb, &za); zinvmod(za, zb, &zt); zmul(za, zt, &zc); zsadd(zc, - 1l, &zd); zdiv(zd, zb, &zl, &zc); zdiv(zy1, zy2, &za, &zc); zexpmod(za, zt, zn, &zc); zexpmod(zv, zl, zn, &za); zmulmod(za, zc, zn, &zu); printf("b = %ld\n", b); printf("n = %ld\n", n); printf("v = %ld\n", v); printf("r_1 = %ld\n", r1); printf("r_2 = %ld\n", r2); printf("y_1 = %ld\n", y1); printf("y_2 = %ld\n", y2); printf("t = "); zwriteln(zt); printf("l = "); zwriteln(zl); printf("u = "); zwriteln(zu); zfree(&za); zfree(&zb); zfree(&zc); zfree(&zd); zfree(&zl); zfree(&zn); zfree(&zt); zfree(&zu); zfree(&zv); zfree(&zr1); zfree(&zr2); zfree(&zy1); zfree(&zy2); return 0; }