|
|
1.1 root 1: /*
2: * Process Arguments to Command and Set Up Key and Permutation
3: * D.P.Mitchell 83/07/01.
4: */
5:
6: #include <stdio.h>
7: #include "crypt.h"
8:
9: Block random;
10: int pflag;
11:
12: Block
13: setup(argc, argv)
14: int argc;
15: char *argv[];
16: {
17: char tempkey[128];
18: Block key;
19: char *keystring;
20: int i;
21: extern Block key_crunch(), recrunch(), rand_block();
22: extern char *getpass(), *strcpy();
23:
24: if (--argc > 0 && argv[1][0] == '-' && argv[1][1] == 'p')
25: pflag = 1;
26: else
27: argc++;
28: if (argc > 2) {
29: fprintf(stderr, "Usage: en/decrypt [-p] [key]\n");
30: exit(1);
31: }
32: if (argc == 2)
33: keystring = argv[1 + pflag];
34: else {
35: keystring = getpass("Enter Key: ");
36: (void) strcpy(tempkey, keystring);
37: keystring = getpass("Enter Key Again: ");
38: if (strcmp(keystring, tempkey)) {
39: fprintf(stderr, "Key Mistyped\n");
40: exit(1);
41: }
42: }
43: random = rand_block();
44: key = key_crunch(keystring);
45: while (*keystring)
46: *keystring++ = '\0';
47: /*
48: * Repeating shuffle and recrunch prevents the recovery of
49: * the key if the permutation becomes known.
50: */
51: for (i = 0; i < 7; i++) {
52: shuffle_permutation();
53: key = recrunch();
54: }
55: return key;
56: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.