Deleted Added
full compact
enigma.c (227237) enigma.c (231994)
1/*-
2 * "enigma.c" is in file cbw.tar from
3 * anonymous FTP host watmsg.waterloo.edu: pub/crypt/cbw.tar.Z
4 *
5 * A one-rotor machine designed along the lines of Enigma
6 * but considerably trivialized.
7 *
8 * A public-domain replacement for the UNIX "crypt" command.
9 *
10 * Upgraded to function properly on 64-bit machines.
11 */
12
13#include <sys/cdefs.h>
1/*-
2 * "enigma.c" is in file cbw.tar from
3 * anonymous FTP host watmsg.waterloo.edu: pub/crypt/cbw.tar.Z
4 *
5 * A one-rotor machine designed along the lines of Enigma
6 * but considerably trivialized.
7 *
8 * A public-domain replacement for the UNIX "crypt" command.
9 *
10 * Upgraded to function properly on 64-bit machines.
11 */
12
13#include <sys/cdefs.h>
14__FBSDID("$FreeBSD: head/usr.bin/enigma/enigma.c 227237 2011-11-06 18:49:23Z ed $");
14__FBSDID("$FreeBSD: head/usr.bin/enigma/enigma.c 231994 2012-02-22 06:27:20Z kevlo $");
15
16#include <sys/types.h>
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <unistd.h>
22

--- 13 unchanged lines hidden (view full) ---

36
37static void
38setup(char *pw)
39{
40 int ic, i, k, temp;
41 char salt[3];
42 unsigned rnd;
43 int32_t seed;
15
16#include <sys/types.h>
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <unistd.h>
22

--- 13 unchanged lines hidden (view full) ---

36
37static void
38setup(char *pw)
39{
40 int ic, i, k, temp;
41 char salt[3];
42 unsigned rnd;
43 int32_t seed;
44 char *cryptpw;
44
45 strlcpy(salt, pw, sizeof(salt));
45
46 strlcpy(salt, pw, sizeof(salt));
46 memcpy(buf, crypt(pw, salt), sizeof(buf));
47 cryptpw = crypt(pw, salt);
48 if (cryptpw == NULL) {
49 fprintf(stderr, "crypt(3) failure\n");
50 exit(1);
51 }
52 memcpy(buf, cryptpw, sizeof(buf));
47 seed = 123;
48 for (i=0; i<13; i++)
49 seed = seed*buf[i] + i;
50 for(i=0;i<ROTORSZ;i++) {
51 t1[i] = i;
52 deck[i] = i;
53 }
54 for(i=0;i<ROTORSZ;i++) {

--- 93 unchanged lines hidden ---
53 seed = 123;
54 for (i=0; i<13; i++)
55 seed = seed*buf[i] + i;
56 for(i=0;i<ROTORSZ;i++) {
57 t1[i] = i;
58 deck[i] = i;
59 }
60 for(i=0;i<ROTORSZ;i++) {

--- 93 unchanged lines hidden ---