/* testd2001.c 20 Dec. 1981 4:37 pm PST (Sunday) */ extern char IRESET, I9513, I8237; extern int encrypt(), decrypt(), encend(), chav(); extern char getchar(); char key[8], plain[160], cypher[160], res[160]; struct ecb { char *kp, *srcp, *dstp; int count; }; struct ecb cbe, cbd; /* Test DMA encryption */ main() { char c; int i; putstring("\rDMA 2001 test, ? for help.\r"); portstr(&IRESET); audoff(); portstr(&I9513); portstr(&I8237); audon(); for (i=0; i<8; i++) key[i] = 0x01; for (i=0; i<160; i++) plain[i] = i; cbe.kp = key; cbe.srcp = plain; cbe.dstp = cypher; cbe.count = 160; cbd.kp = key; cbd.srcp = cypher; cbd.dstp = res; cbd.count = 160; for (;;) { c = getchar() & 0177; switch (c) { case 'q': { putstring("\rQuit!\r"); return; }; case '?': { help(); break; }; case 'f': { putstring("\rfast\r"); while (!chav()) once(&cbe, &cbd); getchar(); break; }; case ' ': { once(&cbe, &cbd); putchar('.'); break; }; default: putstring("\r unknown command\r"); }; }; /* end of forever loop */ }; help() { putstring("\rq: quit, (sp): once, ?: help\r"); putstring("f: fast"); }; once(a, b) struct ecb *a, *b; { int i; pioaon(1); if (encrypt(a)) { putchar('k'); return; }; while (!encend()); if (decrypt(b)) { putchar('k'); return; }; while (!encend()); pioaoff(1); for (i=0; i<160; i++) { if (plain[i] != res[i]) { putchar('#'); break; }; }; };