/* Author: Pate Williams (c) 1997 Exercise 9.6 "Suppose that Alice is using the Quisquater Scheme with p = 503, q = 379, and b = 509. (a) Suppose that Alice's secret u = 155863. Compute v. (b) Suppose that k = 123845. Compute gamma. (c) Suppose that Bob issues the challenge r = 487. Compute Alice's response y. (d) Perform Bob's calculation to verify y." -Douglas R. Stinson- See "Cryptography: Theory and Practice" by Douglas R. Stinson page 304. */ #include #include "lip.h" int main(void) { long b = 509, k = 123845, p = 503, q = 379; long n = p * q, r = 487, u = 155863; verylong za = 0, zb = 0, zc = 0, zd = 0, zk = 0; verylong zn = 0, zr = 0, zu = 0, zv = 0, zy = 0; verylong zgamma = 0; zintoz(b, &zb); zintoz(k, &zk); zintoz(n, &zn); zintoz(r, &zr); zintoz(u, &zu); zexpmod(zk, zb, zn, &zgamma); zexpmod(zu, zr, zn, &za); zmulmod(za, zk, zn, &zy); zinvmod(zu, zn, &za); zexpmod(za, zb, zn, &zv); zexpmod(zv, zr, zn, &za); zexpmod(zy, zb, zn, &zc); zmulmod(za, zc, zn, &zd); printf("p = %ld\n", p); printf("q = %ld\n", q); printf("b = %ld\n", b); printf("n = %ld\n", n); printf("k = %ld\n", k); printf("r = %ld\n", r); printf("u = %ld\n", u); printf("v = "); zwriteln(zv); printf("gamma = "); zwriteln(zgamma); printf("y = "); zwriteln(zy); if (zcompare(zd, zgamma) == 0) printf("Bob has verified y\n"); else printf("Bob did no verify y\n"); zfree(&za); zfree(&zb); zfree(&zc); zfree(&zd); zfree(&zk); zfree(&zn); zfree(&zr); zfree(&zu); zfree(&zv); zfree(&zy); zfree(&zgamma); return 0; }