summaryrefslogtreecommitdiff
path: root/usr.bin/enigma
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/enigma')
-rw-r--r--usr.bin/enigma/Makefile8
-rw-r--r--usr.bin/enigma/enigma.1115
-rw-r--r--usr.bin/enigma/enigma.c183
3 files changed, 0 insertions, 306 deletions
diff --git a/usr.bin/enigma/Makefile b/usr.bin/enigma/Makefile
deleted file mode 100644
index 6936b7e7feb1a..0000000000000
--- a/usr.bin/enigma/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-PROG= enigma
-CFLAGS+=-Wall
-MAN1= enigma.1
-
-LINKS= ${BINDIR}/enigma ${BINDIR}/crypt
-MLINKS= enigma.1 crypt.1
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/enigma/enigma.1 b/usr.bin/enigma/enigma.1
deleted file mode 100644
index a8d05f34c1cb1..0000000000000
--- a/usr.bin/enigma/enigma.1
+++ /dev/null
@@ -1,115 +0,0 @@
-.\"
-.\" enigma (aka. crypt) man page written by Joerg Wunsch.
-.\"
-.\" Since enigma itself is distributed in the Public Domain, this file
-.\" is also.
-.\"
-.\" $Id$
-.\" "
-.Dd October 30, 1998
-.Os
-.Dt enigma 1
-.Sh NAME
-.Nm enigma
-.Nd very simple file encryption
-.Sh SYNOPSIS
-.Nm
-.Op Fl s
-.Op Fl k
-.Op Ar password
-.Nm crypt
-.Op Fl s
-.Op Fl k
-.Op Ar password
-.Sh DESCRIPTION
-.Nm Enigma ,
-also known as
-.Nm crypt
-is a
-.Em very
-simple encryption program, working on a
-.Dq secret-key
-basis. It operates as a filter, i. e. it encrypts or decrypts a
-stream of data from standard input, and writes the result to standard
-output. It automatically detects whether the input data stream is
-already encrypted, and switches into decryption mode in this case.
-.Pp
-There are several ways to provide the secret key to the program. By
-default, the program prompts the user on the controlling terminal for
-the key, using
-.Xr getpass 3 .
-This is the only safe way of providing it.
-.Pp
-Alternatively, the key can be provided as the sole command-line
-argument
-.Ar password
-when starting the program. Obviously, this way the key can easily be
-spotted by other users running
-.Xr ps 1 .
-As yet another alternative,
-.Nm
-can be given the option
-.Fl k ,
-and it will take the key from the environment variable
-.Ev CrYpTkEy .
-While this at a first glance seems to be more secure than the previous
-option, it actually isn't since environment variables can also be
-examined with
-.Xr ps 1 .
-Thus this option is mainly provided for compatibility with other
-implementations of
-.Nm enigma .
-.Pp
-When specifying the option
-.Fl s ,
-.Nm
-modifies the encryption engine in a way that is supposed to make it a
-little more secure, but incompatible with other implementations.
-.Pp
-.Ss Warning
-The cryptographic value of
-.Nm
-is rather small. This program is only provided here for compatibility
-with other operating systems that also provide an implementation. For
-real encryption, refer to
-.Xr bdes 1
-(from the DES distribution package), or
-.Xr pgp 1
-(from the ports collection). Hoewever, restrictions for exporting,
-importing or using such tools might exist in some countries, so those
-stronger programs are not being shipped as part of the operating
-system by default.
-.Sh ENVIRONMENT
-.Bl -tag -offset indent -width "XXCrYpTkEy"
-.It Ev CrYpTkEy
-used to obtain the secret key when option
-.Fl k
-has been given
-.El
-.Sh EXAMPLES
-.Bd -literal -offset indent
-man enigma | enigma > encrypted
-Enter key: (XXX \(em key not echoed)
-.Ed
-.Pp
-This will create an encrypted form of this man page, and store it in
-the file
-.Ql encrypted .
-.Bd -literal -offset indent
-enigma XXX < encrypted
-.Ed
-.Pp
-This displays the previously created file on the terminal.
-.Sh SEE ALSO
-.Xr bdes 1 ,
-.Xr pgp 1 ,
-.Xr ps 1 ,
-.Xr getpass 3
-.Sh HISTORY
-Implementations of
-.Nm crypt
-are very common among
-.Ux
-operating systems. This implementation has been taken from the
-.Em Cryptbreakers Workbench
-which is in the public domain.
diff --git a/usr.bin/enigma/enigma.c b/usr.bin/enigma/enigma.c
deleted file mode 100644
index 3b1560c3b5f91..0000000000000
--- a/usr.bin/enigma/enigma.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * "enigma.c" is in file cbw.tar from
- * anonymous FTP host watmsg.waterloo.edu: pub/crypt/cbw.tar.Z
- *
- * A one-rotor machine designed along the lines of Enigma
- * but considerably trivialized.
- *
- * A public-domain replacement for the UNIX "crypt" command.
- *
- * Upgraded to function properly on 64-bit machines.
- */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define MINUSKVAR "CrYpTkEy"
-
-#define ECHO 010
-#define ROTORSZ 256
-#define MASK 0377
-char t1[ROTORSZ];
-char t2[ROTORSZ];
-char t3[ROTORSZ];
-char deck[ROTORSZ];
-char buf[13];
-
-void shuffle(char *);
-
-void
-setup(pw)
- char *pw;
-{
- int ic, i, k, temp, pf[2], pid;
- unsigned random;
- long seed;
-
- strncpy(buf, pw, 8);
- while (*pw)
- *pw++ = '\0';
- buf[8] = buf[0];
- buf[9] = buf[1];
- pipe(pf);
- if ((pid=fork())==0) {
- close(0);
- close(1);
- dup(pf[0]);
- dup(pf[1]);
- execlp("makekey", "-", 0);
- execl("/usr/libexec/makekey", "-", 0); /* BSDI */
- execl("/usr/lib/makekey", "-", 0);
- execl("/usr/bin/makekey", "-", 0); /* IBM */
- execl("/lib/makekey", "-", 0);
- perror("makekey");
- fprintf(stderr, "enigma: cannot execute 'makekey', aborting\n");
- exit(1);
- }
- write(pf[1], buf, 10);
- close(pf[1]);
- i=wait((int *)NULL);
- if (i<0) perror("enigma: wait");
- if (i!=pid) {
- fprintf(stderr, "enigma: expected pid %d, got pid %d\n", pid, i);
- exit(1);
- }
- if ((i=read(pf[0], buf, 13)) != 13) {
- fprintf(stderr, "enigma: cannot generate key, read %d\n",i);
- exit(1);
- }
- seed = 123;
- for (i=0; i<13; i++)
- seed = seed*buf[i] + i;
- for(i=0;i<ROTORSZ;i++) {
- t1[i] = i;
- deck[i] = i;
- }
- for(i=0;i<ROTORSZ;i++) {
- seed = 5*seed + buf[i%13];
- if( sizeof(long) > 4 ) {
- /* Force seed to stay in 32-bit signed math */
- if( seed & 0x80000000 )
- seed = seed | (-1L & ~0xFFFFFFFFL);
- else
- seed &= 0x7FFFFFFF;
- }
- random = seed % 65521;
- k = ROTORSZ-1 - i;
- ic = (random&MASK)%(k+1);
- random >>= 8;
- temp = t1[k];
- t1[k] = t1[ic];
- t1[ic] = temp;
- if(t3[k]!=0) continue;
- ic = (random&MASK) % k;
- while(t3[ic]!=0) ic = (ic+1) % k;
- t3[k] = ic;
- t3[ic] = k;
- }
- for(i=0;i<ROTORSZ;i++)
- t2[t1[i]&MASK] = i;
-}
-
-int
-main(argc, argv)
- char *argv[];
-{
- register int i, n1, n2, nr1, nr2;
- int secureflg = 0, kflag = 0;
- char *cp;
-
- if (argc > 1 && argv[1][0] == '-') {
- if (argv[1][1] == 's') {
- argc--;
- argv++;
- secureflg = 1;
- } else if (argv[1][1] == 'k') {
- argc--;
- argv++;
- kflag = 1;
- }
- }
- if (kflag) {
- if ((cp = getenv(MINUSKVAR)) == NULL) {
- fprintf(stderr, "%s not set\n", MINUSKVAR);
- exit(1);
- }
- setup(cp);
- } else if (argc != 2) {
- setup(getpass("Enter key:"));
- }
- else
- setup(argv[1]);
- n1 = 0;
- n2 = 0;
- nr2 = 0;
-
- while((i=getchar()) != -1) {
- if (secureflg) {
- nr1 = deck[n1]&MASK;
- nr2 = deck[nr1]&MASK;
- } else {
- nr1 = n1;
- }
- i = t2[(t3[(t1[(i+nr1)&MASK]+nr2)&MASK]-nr2)&MASK]-nr1;
- putchar(i);
- n1++;
- if(n1==ROTORSZ) {
- n1 = 0;
- n2++;
- if(n2==ROTORSZ) n2 = 0;
- if (secureflg) {
- shuffle(deck);
- } else {
- nr2 = n2;
- }
- }
- }
-
- return 0;
-}
-
-void
-shuffle(deck)
- char deck[];
-{
- int i, ic, k, temp;
- unsigned random;
- static long seed = 123;
-
- for(i=0;i<ROTORSZ;i++) {
- seed = 5*seed + buf[i%13];
- random = seed % 65521;
- k = ROTORSZ-1 - i;
- ic = (random&MASK)%(k+1);
- temp = deck[k];
- deck[k] = deck[ic];
- deck[ic] = temp;
- }
-}