2 * Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
13 #include <mit-cpyright.h>
20 Key_schedule KEYSCHED;
21 C_Block key = {0,1,2,3,4,5,6,7};
23 char inbuf[512+8]; /* leave room for cksum and len */
30 #include "AFS_component_version_number.c"
37 register afs_int32 length;
41 fprintf (stderr, "%s: Usage: %s infile outfile mode.\n",
45 if (!strcmp(argv[3], "e"))
47 else if (!strcmp(argv[3], "d"))
50 fprintf (stderr, "%s: Mode must be e (encrypt) or d (decrypt).\n",
54 if ((ind = open(argv[1], O_RDONLY, 0666)) < 0) {
55 fprintf (stderr, "%s: Cannot open %s for input.\n",
59 if (!strcmp(argv[2], "-"))
61 else if ((oud = open(argv[2], O_CREAT|O_WRONLY, 0666)) < 0) {
62 fprintf (stderr, "%s: Cannot open %s for output.\n",
67 (void) freopen ("/dev/tty", "r", stdin);
68 (void) freopen ("/dev/tty", "w", stdout);
70 read_password (key, "\n\07\07Enter Key> ", 1);
71 if (key_sched (key, KEYSCHED) < 0) {
72 fprintf (stderr, "%s: Key parity error\n", argv[0]);
77 bcopy(key,sum,sizeof(C_Block));
79 if ((length = read (ind, inbuf, 512)) < 0) {
80 fprintf (stderr, "%s: Error reading from input.\n",
83 } else if (length == 0) {
84 fprintf (stderr, "\n");
89 sum = quad_cksum(inbuf,NULL,length,1,sum);
91 quad_cksum(inbuf,sum,length,1,sum);
94 "\nlength = %d tot length = %d quad_sum = %X %X",
95 length, orig_size, *(afs_uint32 *) sum,
96 *((afs_uint32 *) sum+1));
99 pcbc_encrypt (inbuf, oubuf, (afs_int32) length, KEYSCHED, ivec,
103 sum = quad_cksum(oubuf,NULL,length,1,sum);
105 quad_cksum(oubuf,sum,length,1,sum);
108 "\nlength = %d tot length = %d quad_sum = %X ",
109 length, orig_size, *(afs_uint32 *) sum,
110 *((afs_uint32 *) sum+1));
112 length = (length+7)& ~07;
113 write (oud, oubuf, length);
115 p = (int *)&oubuf[length-8];
117 p = (int *)&inbuf[length-8];
122 fprintf(stderr,"\ntot length = %d quad_sum = %X\n",
124 /* if encrypting, now put the original length and checksum in */