summaryrefslogtreecommitdiff
path: root/secure/lib
diff options
context:
space:
mode:
authorcvs2svn <cvs2svn@FreeBSD.org>2002-10-08 05:39:08 +0000
committercvs2svn <cvs2svn@FreeBSD.org>2002-10-08 05:39:08 +0000
commite1b05e3a6cd90b0bf91b47aeff71da2a9d048a9d (patch)
treed57c49002f2656171c2f00359a26c3e3f414b6ad /secure/lib
parent7d5bc6320988857ad6ae9fe1d002ad6d8a7af0dd (diff)
Diffstat (limited to 'secure/lib')
-rw-r--r--secure/lib/Makefile14
-rw-r--r--secure/lib/Makefile.inc6
-rw-r--r--secure/lib/libcipher/Makefile16
-rw-r--r--secure/lib/libcipher/README98
-rw-r--r--secure/lib/libcipher/README.FreeBSD6
-rw-r--r--secure/lib/libcipher/cipher.3154
-rw-r--r--secure/lib/libcipher/crypt.c623
-rw-r--r--secure/lib/libcipher/test/Makefile56
-rw-r--r--secure/lib/libcipher/test/README10
-rw-r--r--secure/lib/libcipher/test/cert.c344
-rw-r--r--secure/lib/libcipher/test/cert.input179
-rw-r--r--secure/lib/libcipher/test/speedcrypt.c76
-rw-r--r--secure/lib/libcipher/test/speeddes.c61
-rw-r--r--secure/lib/libcrypt/blowfish.c783
-rw-r--r--secure/lib/libcrypt/blowfish.h86
-rw-r--r--secure/lib/libcrypt/crypt-blowfish.c380
-rw-r--r--secure/lib/libcrypt/crypt-des.c695
-rw-r--r--secure/lib/libcrypto/Makefile402
-rw-r--r--secure/lib/libcrypto/Makefile.inc62
-rw-r--r--secure/lib/libcrypto/des_crypt.3509
-rw-r--r--secure/lib/libcrypto/opensslconf-alpha.h175
-rw-r--r--secure/lib/libcrypto/opensslconf-i386.h175
-rw-r--r--secure/lib/libssh/Makefile27
-rw-r--r--secure/lib/libssl/Makefile25
-rw-r--r--secure/lib/libtelnet/Makefile32
25 files changed, 0 insertions, 4994 deletions
diff --git a/secure/lib/Makefile b/secure/lib/Makefile
deleted file mode 100644
index 40731dd3f3ff..000000000000
--- a/secure/lib/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-SUBDIR= libcipher
-.if !defined(NOCRYPT) && !defined(MAKE_KERBEROS4) && !defined(MAKE_KERBEROS5)
-SUBDIR+=libtelnet
-.endif
-.if !defined(NO_OPENSSL)
-SUBDIR+=libcrypto libssl
-.if !defined(NO_OPENSSH)
-SUBDIR+=libssh
-.endif
-.endif
-
-.include <bsd.subdir.mk>
diff --git a/secure/lib/Makefile.inc b/secure/lib/Makefile.inc
deleted file mode 100644
index 1410b215761e..000000000000
--- a/secure/lib/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@
-# $FreeBSD$
-
-.include "${.CURDIR}/../../Makefile.inc"
-.if exists(${.CURDIR}/../../../lib/Makefile.inc)
-.include "${.CURDIR}/../../../lib/Makefile.inc"
-.endif
diff --git a/secure/lib/libcipher/Makefile b/secure/lib/libcipher/Makefile
deleted file mode 100644
index 3074daba5186..000000000000
--- a/secure/lib/libcipher/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# $FreeBSD$
-#
-
-LIB= cipher
-SRCS= crypt.c
-PRECIOUSLIB= yes
-#NOPROFILE= yes
-
-MAN= cipher.3
-MLINKS= cipher.3 encrypt.3 cipher.3 setkey.3
-MLINKS+=cipher.3 des_cipher.3 cipher.3 des_setkey.3
-
-#SUBDIR= test
-
-.include <bsd.lib.mk>
diff --git a/secure/lib/libcipher/README b/secure/lib/libcipher/README
deleted file mode 100644
index ab8af5acbb29..000000000000
--- a/secure/lib/libcipher/README
+++ /dev/null
@@ -1,98 +0,0 @@
-
- FreeSec - NetBSD libcrypt replacement
-
- David Burren <davidb@werj.com.au>
- Release 1.0, March 1994
-
- Document ref: $FreeBSD$
-
-
-Description
-===========
-This library is a drop-in replacement for the libcrypt used in U.S. copies
-of NetBSD, duplicating that library's functionality. A suite of verification
-and benchmark tools is provided.
-
-FreeSec 1.0 is an original implementation of the DES algorithm and the
-crypt(3) interfaces used in Unix-style operating systems. It was produced
-in Australia and as such is not covered by U.S. export restrictions (at
-least for copies that remain outside the U.S.).
-
-
-History
-=======
-An earlier version of the FreeSec library was built using the UFC-crypt
-package that is distributed as part of the GNU library. UFC-crypt did not
-support the des_cipher() or des_setkey() functions, nor the new-style
-crypt with long keys. These were implemented in FreeSec 0.2, but at least
-one bug remained, where encryption would only succeed if either the salt
-or the plaintext was zero. Because of its heritage FreeSec 0.2 was covered
-by the GNU Library Licence.
-
-FreeSec 1.0 is an original implementation by myself, and has been tested
-against the verification suite I'd been using with FreeSec 0.2 (this is not
-encumbered by any licence). FreeSec 1.0 is covered by a Berkeley-style
-licence, which better fits into the *BSD hierarchy than the earlier GNU
-licence.
-
-
-Why should you use FreeSec?
-===========================
-FreeSec is intended as a replacement for the U.S.-only NetBSD libcrypt,
-to act as a baseline for encryption functionality.
-
-Some other packages (such as Eric Young's libdes package) are faster and
-more complete than FreeSec, but typically have different licencing
-arrangements. While some applications will justify the use of these
-packages, the idea here is that everyone should have access to *at least*
-the functionality of FreeSec.
-
-
-Performance of FreeSec 1.0
-==========================
-I compare below the performance of three libcrypt implementations. As can be
-seen, it's between the U.S. library and UFC-crypt. While the performance of
-FreeSec 1.0 is good enough to keep me happy for now, I hope to improve it in
-future versions. I was interested to note that while UFC-crypt is faster on
-a 386, hardware characteristics can have markedly different effects on each
-implementation.
-
-
-386DX40, 128k cache | U.S. BSD | FreeSec 1.0 | FreeSec 0.2
-CFLAGS=-O2 | | |
-========================+===============+===============+==================
-crypt (alternate keys) | 317 | 341 | 395
- crypt/sec | | |
-------------------------+---------------+---------------+------------------
-crypt (constant key) | 317 | 368 | 436
- crypt/sec | | |
-------------------------+---------------+---------------+------------------
-des_cipher( , , , 1) | 6037 | 7459 | 3343
- blocks/sec | | |
-------------------------+---------------+---------------+------------------
-des_cipher( , , , 25) | 8871 | 9627 | 15926
- blocks/sec | | |
-
-Notes: The results tabled here are the average over 10 runs.
- The entry/exit code for FreeSec 0.2's des_cipher() is particularly
- inefficient, thus the anomalous result for single encryptions.
-
-
-As an experiment using a machine with a larger register set and an
-obscenely fast CPU, I obtained the following results:
-
- 60 MHz R4400 | FreeSec 1.0 | FreeSec 0.2
- ========================+=================================
- crypt (alternate keys) | 2545 | 2702
- crypt/sec | |
- ------------------------+---------------------------------
- crypt (constant key) | 2852 | 2981
- crypt/sec | |
- ------------------------+---------------------------------
- des_cipher( , , , 1) | 56443 | 21409
- blocks/sec | |
- ------------------------+---------------------------------
- des_cipher( , , , 25) | 82531 | 18276
- blocks/sec | |
-
-Obviously your mileage will vary with your hardware and your compiler...
diff --git a/secure/lib/libcipher/README.FreeBSD b/secure/lib/libcipher/README.FreeBSD
deleted file mode 100644
index 2379f73015a1..000000000000
--- a/secure/lib/libcipher/README.FreeBSD
+++ /dev/null
@@ -1,6 +0,0 @@
-$FreeBSD$
-
-This is FreeSec package for NetBSD, unchanged for
-FreeBSD, except for the Makefile.
-
-The other stuff in libcrypt will be added in stages!
diff --git a/secure/lib/libcipher/cipher.3 b/secure/lib/libcipher/cipher.3
deleted file mode 100644
index f8b2382a39e0..000000000000
--- a/secure/lib/libcipher/cipher.3
+++ /dev/null
@@ -1,154 +0,0 @@
-.\" FreeSec: libcrypt for NetBSD
-.\"
-.\" Copyright (c) 1994 David Burren
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 4. Neither the name of the author nor the names of other contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.\" Manual page, using -mandoc macros
-.\"
-.Dd March 9, 1994
-.Dt CIPHER 3
-.Os
-.Sh NAME
-.Nm setkey ,
-.Nm encrypt ,
-.Nm des_setkey ,
-.Nm des_cipher
-.Nd DES encryption
-.Sh LIBRARY
-.Lb libcipher
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn setkey "const char *key"
-.Ft int
-.Fn encrypt "char *block" "int flag"
-.Ft int
-.Fn des_setkey "const char *key"
-.Ft int
-.Fn des_cipher "const char *in" "char *out" "long salt" "int count"
-.Sh DESCRIPTION
-The functions,
-.Fn encrypt ,
-.Fn setkey ,
-.Fn des_setkey
-and
-.Fn des_cipher
-provide access to the
-.Tn DES
-algorithm.
-.Fn setkey
-is passed a 64-byte array of binary values (numeric 0 or 1).
-A 56-bit key is extracted from this array by dividing the
-array into groups of 8, and ignoring the last bit in each group.
-That bit is reserved for a byte parity check by DES, but is ignored
-by these functions.
-.Pp
-The
-.Fa block
-argument to
-.Fn encrypt
-is also a 64-byte array of binary values.
-If the value of
-.Fa flag
-is 0,
-.Fa block
-is encrypted otherwise it is decrypted.
-The result is returned in the original array
-.Fa block
-after using the key specified by
-.Fn setkey
-to process it.
-.Pp
-The argument to
-.Fn des_setkey
-is a character array of length 8.
-The least significant bit (the parity bit) in each character is ignored,
-and the remaining bits are concatenated to form a 56-bit key.
-The function
-.Fn des_cipher
-encrypts (or decrypts if
-.Fa count
-is negative) the 64-bits stored in the 8 characters at
-.Fa in
-using
-.Xr abs 3
-of
-.Fa count
-iterations of
-.Tn DES
-and stores the 64-bit result in the 8 characters at
-.Fa out
-(which may be the same as
-.Fa in ) .
-The
-.Fa salt
-introduces disorder in the
-.Tn DES
-algorithm in one of 16777216 or 4096 possible ways
-(ie. with 24 or 12 bits: if bit
-.Em i
-of the
-.Ar salt
-is set, then bits
-.Em i
-and
-.Em i+24
-are swapped in the
-.Tn DES
-E-box output).
-.Pp
-The functions
-.Fn setkey ,
-.Fn encrypt ,
-.Fn des_setkey ,
-and
-.Fn des_cipher
-return 0 on success and 1 on failure.
-.Pp
-The
-.Fn setkey
-and
-.Fn des_setkey
-functions manipulate the same key space.
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr passwd 1 ,
-.Xr crypt 3 ,
-.Xr getpass 3 ,
-.Xr passwd 5
-.Sh HISTORY
-This library (FreeSec 1.0) was developed outside the United States of America
-as an unencumbered replacement for the U.S.-only
-.Nx
-libcrypt encryption
-library.
-Users should be aware that this code (and programs staticly linked with it)
-may not be exported from the U.S., although it apparently can be imported.
-.Sh AUTHORS
-.An David Burren Aq davidb@werj.com.au
diff --git a/secure/lib/libcipher/crypt.c b/secure/lib/libcipher/crypt.c
deleted file mode 100644
index 4798371b251a..000000000000
--- a/secure/lib/libcipher/crypt.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * FreeSec: libcrypt for NetBSD
- *
- * Copyright (c) 1994 David Burren
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the author nor the names of other contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- *
- * This is an original implementation of the DES and the crypt(3) interfaces
- * by David Burren <davidb@werj.com.au>.
- *
- * An excellent reference on the underlying algorithm (and related
- * algorithms) is:
- *
- * B. Schneier, Applied Cryptography: protocols, algorithms,
- * and source code in C, John Wiley & Sons, 1994.
- *
- * Note that in that book's description of DES the lookups for the initial,
- * pbox, and final permutations are inverted (this has been brought to the
- * attention of the author). A list of errata for this book has been
- * posted to the sci.crypt newsgroup by the author and is available for FTP.
- *
- * ARCHITECTURE ASSUMPTIONS:
- * This code assumes that u_longs are 32 bits. It will probably not
- * operate on 64-bit machines without modifications.
- * It is assumed that the 8-byte arrays passed by reference can be
- * addressed as arrays of u_longs (ie. the CPU is not picky about
- * alignment).
- */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <pwd.h>
-
-#ifdef DEBUG
-# include <stdio.h>
-#endif
-
-
-static u_char IP[64] = {
- 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
- 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
- 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
- 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
-};
-
-static u_char inv_key_perm[64];
-static u_char u_key_perm[56];
-static u_char key_perm[56] = {
- 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
- 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
- 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
- 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
-};
-
-static u_char key_shifts[16] = {
- 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
-};
-
-static u_char inv_comp_perm[56];
-static u_char comp_perm[48] = {
- 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
- 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
- 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
- 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
-};
-
-/*
- * No E box is used, as it's replaced by some ANDs, shifts, and ORs.
- */
-
-static u_char u_sbox[8][64];
-static u_char sbox[8][64] = {
- {
- 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
- 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
- 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
- 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
- },
- {
- 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
- 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
- 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
- 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
- },
- {
- 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
- 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
- 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
- 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
- },
- {
- 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
- 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
- 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
- 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
- },
- {
- 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
- 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
- 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
- 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
- },
- {
- 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
- 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
- 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
- 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
- },
- {
- 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
- 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
- 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
- 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
- },
- {
- 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
- 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
- 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
- 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
- }
-};
-
-static u_char un_pbox[32];
-static u_char pbox[32] = {
- 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
- 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
-};
-
-static u_long bits32[32] =
-{
- 0x80000000, 0x40000000, 0x20000000, 0x10000000,
- 0x08000000, 0x04000000, 0x02000000, 0x01000000,
- 0x00800000, 0x00400000, 0x00200000, 0x00100000,
- 0x00080000, 0x00040000, 0x00020000, 0x00010000,
- 0x00008000, 0x00004000, 0x00002000, 0x00001000,
- 0x00000800, 0x00000400, 0x00000200, 0x00000100,
- 0x00000080, 0x00000040, 0x00000020, 0x00000010,
- 0x00000008, 0x00000004, 0x00000002, 0x00000001
-};
-
-static u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
-
-static u_long saltbits;
-static long old_salt;
-static u_long *bits28, *bits24;
-static u_char init_perm[64], final_perm[64];
-static u_long en_keysl[16], en_keysr[16];
-static u_long de_keysl[16], de_keysr[16];
-static int des_initialised = 0;
-static u_char m_sbox[4][4096];
-static u_long psbox[4][256];
-static u_long ip_maskl[8][256], ip_maskr[8][256];
-static u_long fp_maskl[8][256], fp_maskr[8][256];
-static u_long key_perm_maskl[8][128], key_perm_maskr[8][128];
-static u_long comp_maskl[8][128], comp_maskr[8][128];
-static u_long old_rawkey0, old_rawkey1;
-
-static u_char ascii64[] =
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-/* 0000000000111111111122222222223333333333444444444455555555556666 */
-/* 0123456789012345678901234567890123456789012345678901234567890123 */
-
-static inline int
-ascii_to_bin(char ch)
-{
- if (ch > 'z')
- return(0);
- if (ch >= 'a')
- return(ch - 'a' + 38);
- if (ch > 'Z')
- return(0);
- if (ch >= 'A')
- return(ch - 'A' + 12);
- if (ch > '9')
- return(0);
- if (ch >= '.')
- return(ch - '.');
- return(0);
-}
-
-
-static void
-des_init()
-{
- int i, j, b, k, inbit, obit;
- u_long *p, *il, *ir, *fl, *fr;
-
- old_rawkey0 = old_rawkey1 = 0L;
- saltbits = 0L;
- old_salt = 0L;
- bits24 = (bits28 = bits32 + 4) + 4;
-
- /*
- * Invert the S-boxes, reordering the input bits.
- */
- for (i = 0; i < 8; i++)
- for (j = 0; j < 64; j++) {
- b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
- u_sbox[i][j] = sbox[i][b];
- }
-
- /*
- * Convert the inverted S-boxes into 4 arrays of 8 bits.
- * Each will handle 12 bits of the S-box input.
- */
- for (b = 0; b < 4; b++)
- for (i = 0; i < 64; i++)
- for (j = 0; j < 64; j++)
- m_sbox[b][(i << 6) | j] =
- (u_sbox[(b << 1)][i] << 4) |
- u_sbox[(b << 1) + 1][j];
-
- /*
- * Set up the initial & final permutations into a useful form, and
- * initialise the inverted key permutation.
- */
- for (i = 0; i < 64; i++) {
- init_perm[final_perm[i] = IP[i] - 1] = i;
- inv_key_perm[i] = 255;
- }
-
- /*
- * Invert the key permutation and initialise the inverted key
- * compression permutation.
- */
- for (i = 0; i < 56; i++) {
- u_key_perm[i] = key_perm[i] - 1;
- inv_key_perm[key_perm[i] - 1] = i;
- inv_comp_perm[i] = 255;
- }
-
- /*
- * Invert the key compression permutation.
- */
- for (i = 0; i < 48; i++) {
- inv_comp_perm[comp_perm[i] - 1] = i;
- }
-
- /*
- * Set up the OR-mask arrays for the initial and final permutations,
- * and for the key initial and compression permutations.
- */
- for (k = 0; k < 8; k++) {
- for (i = 0; i < 256; i++) {
- *(il = &ip_maskl[k][i]) = 0L;
- *(ir = &ip_maskr[k][i]) = 0L;
- *(fl = &fp_maskl[k][i]) = 0L;
- *(fr = &fp_maskr[k][i]) = 0L;
- for (j = 0; j < 8; j++) {
- inbit = 8 * k + j;
- if (i & bits8[j]) {
- if ((obit = init_perm[inbit]) < 32)
- *il |= bits32[obit];
- else
- *ir |= bits32[obit-32];
- if ((obit = final_perm[inbit]) < 32)
- *fl |= bits32[obit];
- else
- *fr |= bits32[obit - 32];
- }
- }
- }
- for (i = 0; i < 128; i++) {
- *(il = &key_perm_maskl[k][i]) = 0L;
- *(ir = &key_perm_maskr[k][i]) = 0L;
- for (j = 0; j < 7; j++) {
- inbit = 8 * k + j;
- if (i & bits8[j + 1]) {
- if ((obit = inv_key_perm[inbit]) == 255)
- continue;
- if (obit < 28)
- *il |= bits28[obit];
- else
- *ir |= bits28[obit - 28];
- }
- }
- *(il = &comp_maskl[k][i]) = 0L;
- *(ir = &comp_maskr[k][i]) = 0L;
- for (j = 0; j < 7; j++) {
- inbit = 7 * k + j;
- if (i & bits8[j + 1]) {
- if ((obit=inv_comp_perm[inbit]) == 255)
- continue;
- if (obit < 24)
- *il |= bits24[obit];
- else
- *ir |= bits24[obit - 24];
- }
- }
- }
- }
-
- /*
- * Invert the P-box permutation, and convert into OR-masks for
- * handling the output of the S-box arrays setup above.
- */
- for (i = 0; i < 32; i++)
- un_pbox[pbox[i] - 1] = i;
-
- for (b = 0; b < 4; b++)
- for (i = 0; i < 256; i++) {
- *(p = &psbox[b][i]) = 0L;
- for (j = 0; j < 8; j++) {
- if (i & bits8[j])
- *p |= bits32[un_pbox[8 * b + j]];
- }
- }
-
- des_initialised = 1;
-}
-
-
-static void
-setup_salt(long salt)
-{
- u_long obit, saltbit;
- int i;
-
- if (salt == old_salt)
- return;
- old_salt = salt;
-
- saltbits = 0L;
- saltbit = 1;
- obit = 0x800000;
- for (i = 0; i < 24; i++) {
- if (salt & saltbit)
- saltbits |= obit;
- saltbit <<= 1;
- obit >>= 1;
- }
-}
-
-
-int
-des_setkey(const char *key)
-{
- u_long k0, k1, rawkey0, rawkey1;
- int shifts, i, b, round;
-
- if (!des_initialised)
- des_init();
-
- rawkey0 = ntohl(*(u_long *) key);
- rawkey1 = ntohl(*(u_long *) (key + 4));
-
- if ((rawkey0 | rawkey1)
- && rawkey0 == old_rawkey0
- && rawkey1 == old_rawkey1) {
- /*
- * Already setup for this key.
- * This optimisation fails on a zero key (which is weak and
- * has bad parity anyway) in order to simplify the starting
- * conditions.
- */
- return(0);
- }
- old_rawkey0 = rawkey0;
- old_rawkey1 = rawkey1;
-
- /*
- * Do key permutation and split into two 28-bit subkeys.
- */
- k0 = key_perm_maskl[0][rawkey0 >> 25]
- | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
- | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
- | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
- | key_perm_maskl[4][rawkey1 >> 25]
- | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
- | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
- | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
- k1 = key_perm_maskr[0][rawkey0 >> 25]
- | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
- | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
- | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
- | key_perm_maskr[4][rawkey1 >> 25]
- | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
- | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
- | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
- /*
- * Rotate subkeys and do compression permutation.
- */
- shifts = 0;
- for (round = 0; round < 16; round++) {
- u_long t0, t1;
- int bit;
-
- shifts += key_shifts[round];
-
- t0 = (k0 << shifts) | (k0 >> (28 - shifts));
- t1 = (k1 << shifts) | (k1 >> (28 - shifts));
-
- de_keysl[15 - round] =
- en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
- | comp_maskl[1][(t0 >> 14) & 0x7f]
- | comp_maskl[2][(t0 >> 7) & 0x7f]
- | comp_maskl[3][t0 & 0x7f]
- | comp_maskl[4][(t1 >> 21) & 0x7f]
- | comp_maskl[5][(t1 >> 14) & 0x7f]
- | comp_maskl[6][(t1 >> 7) & 0x7f]
- | comp_maskl[7][t1 & 0x7f];
-
- de_keysr[15 - round] =
- en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
- | comp_maskr[1][(t0 >> 14) & 0x7f]
- | comp_maskr[2][(t0 >> 7) & 0x7f]
- | comp_maskr[3][t0 & 0x7f]
- | comp_maskr[4][(t1 >> 21) & 0x7f]
- | comp_maskr[5][(t1 >> 14) & 0x7f]
- | comp_maskr[6][(t1 >> 7) & 0x7f]
- | comp_maskr[7][t1 & 0x7f];
- }
- return(0);
-}
-
-
-static int
-do_des( u_long l_in, u_long r_in, u_long *l_out, u_long *r_out, int count)
-{
- /*
- * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
- */
- u_long mask, rawl, rawr, l, r, *kl, *kr, *kl1, *kr1;
- u_long f, r48l, r48r;
- int i, j, b, round;
-
- if (count == 0) {
- return(1);
- } else if (count > 0) {
- /*
- * Encrypting
- */
- kl1 = en_keysl;
- kr1 = en_keysr;
- } else {
- /*
- * Decrypting
- */
- count = -count;
- kl1 = de_keysl;
- kr1 = de_keysr;
- }
-
- /*
- * Do initial permutation (IP).
- */
- l = ip_maskl[0][l_in >> 24]
- | ip_maskl[1][(l_in >> 16) & 0xff]
- | ip_maskl[2][(l_in >> 8) & 0xff]
- | ip_maskl[3][l_in & 0xff]
- | ip_maskl[4][r_in >> 24]
- | ip_maskl[5][(r_in >> 16) & 0xff]
- | ip_maskl[6][(r_in >> 8) & 0xff]
- | ip_maskl[7][r_in & 0xff];
- r = ip_maskr[0][l_in >> 24]
- | ip_maskr[1][(l_in >> 16) & 0xff]
- | ip_maskr[2][(l_in >> 8) & 0xff]
- | ip_maskr[3][l_in & 0xff]
- | ip_maskr[4][r_in >> 24]
- | ip_maskr[5][(r_in >> 16) & 0xff]
- | ip_maskr[6][(r_in >> 8) & 0xff]
- | ip_maskr[7][r_in & 0xff];
-
- while (count--) {
- /*
- * Do each round.
- */
- kl = kl1;
- kr = kr1;
- round = 16;
- while (round--) {
- /*
- * Expand R to 48 bits (simulate the E-box).
- */
- r48l = ((r & 0x00000001) << 23)
- | ((r & 0xf8000000) >> 9)
- | ((r & 0x1f800000) >> 11)
- | ((r & 0x01f80000) >> 13)
- | ((r & 0x001f8000) >> 15);
-
- r48r = ((r & 0x0001f800) << 7)
- | ((r & 0x00001f80) << 5)
- | ((r & 0x000001f8) << 3)
- | ((r & 0x0000001f) << 1)
- | ((r & 0x80000000) >> 31);
- /*
- * Do salting for crypt() and friends, and
- * XOR with the permuted key.
- */
- f = (r48l ^ r48r) & saltbits;
- r48l ^= f ^ *kl++;
- r48r ^= f ^ *kr++;
- /*
- * Do sbox lookups (which shrink it back to 32 bits)
- * and do the pbox permutation at the same time.
- */
- f = psbox[0][m_sbox[0][r48l >> 12]]
- | psbox[1][m_sbox[1][r48l & 0xfff]]
- | psbox[2][m_sbox[2][r48r >> 12]]
- | psbox[3][m_sbox[3][r48r & 0xfff]];
- /*
- * Now that we've permuted things, complete f().
- */
- f ^= l;
- l = r;
- r = f;
- }
- r = l;
- l = f;
- }
- /*
- * Do final permutation (inverse of IP).
- */
- *l_out = fp_maskl[0][l >> 24]
- | fp_maskl[1][(l >> 16) & 0xff]
- | fp_maskl[2][(l >> 8) & 0xff]
- | fp_maskl[3][l & 0xff]
- | fp_maskl[4][r >> 24]
- | fp_maskl[5][(r >> 16) & 0xff]
- | fp_maskl[6][(r >> 8) & 0xff]
- | fp_maskl[7][r & 0xff];
- *r_out = fp_maskr[0][l >> 24]
- | fp_maskr[1][(l >> 16) & 0xff]
- | fp_maskr[2][(l >> 8) & 0xff]
- | fp_maskr[3][l & 0xff]
- | fp_maskr[4][r >> 24]
- | fp_maskr[5][(r >> 16) & 0xff]
- | fp_maskr[6][(r >> 8) & 0xff]
- | fp_maskr[7][r & 0xff];
- return(0);
-}
-
-
-int
-des_cipher(const char *in, char *out, long salt, int count)
-{
- u_long l_out, r_out, rawl, rawr;
- int retval;
-
- if (!des_initialised)
- des_init();
-
- setup_salt(salt);
-
- rawl = ntohl(*((u_long *) in)++);
- rawr = ntohl(*((u_long *) in));
-
- retval = do_des(rawl, rawr, &l_out, &r_out, count);
-
- *((u_long *) out)++ = htonl(l_out);
- *((u_long *) out) = htonl(r_out);
- return(retval);
-}
-
-
-int
-setkey(char *key)
-{
- int i, j;
- u_long packed_keys[2];
- u_char *p;
-
- p = (u_char *) packed_keys;
-
- for (i = 0; i < 8; i++) {
- p[i] = 0;
- for (j = 0; j < 8; j++)
- if (*key++ & 1)
- p[i] |= bits8[j];
- }
- return(des_setkey(p));
-}
-
-
-int
-encrypt(char *block, int flag)
-{
- u_long io[2];
- u_char *p;
- int i, j, retval;
-
- if (!des_initialised)
- des_init();
-
- setup_salt(0L);
- p = block;
- for (i = 0; i < 2; i++) {
- io[i] = 0L;
- for (j = 0; j < 32; j++)
- if (*p++ & 1)
- io[i] |= bits32[j];
- }
- retval = do_des(io[0], io[1], io, io + 1, flag ? -1 : 1);
- for (i = 0; i < 2; i++)
- for (j = 0; j < 32; j++)
- block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
- return(retval);
-}
-
diff --git a/secure/lib/libcipher/test/Makefile b/secure/lib/libcipher/test/Makefile
deleted file mode 100644
index 50ae57100caf..000000000000
--- a/secure/lib/libcipher/test/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Hacked Makefile to compile and run the DES-certification program,
-# but not install anything.
-#
-# $FreeBSD$
-#
-LIBCRYPT!=cd $(.CURDIR)/..; \
- printf "xxx:\n\techo \$${.OBJDIR}/libcipher.a\n" | make -r -s -f - xxx
-
-#CFLAGS+= -DHAVE_CRYPT16
-LIBCRYPT+= -lcrypt
-
-TARGETS=cert speedcrypt speeddes
-
-all: ${TARGETS}
-
-test: all testcrypt testencrypt testdes testspeed
-
-testcrypt: cert
- @./cert -c
-
-testencrypt: cert
- @./cert -e < ${.CURDIR}/cert.input
-
-testdes: cert
- @./cert -d < ${.CURDIR}/cert.input
-
-testspeed: cryptspeed desspeed
-
-cryptspeed: speedcrypt
- @./speedcrypt 30 1
- @./speedcrypt 30 1
- @./speedcrypt 30 0
- @./speedcrypt 30 0
-
-desspeed: speeddes
- @./speeddes 30 1
- @./speeddes 30 1
- @./speeddes 40 25
- @./speeddes 40 25
-
-cert: cert.c ${LIBCRYPT}
- $(CC) $(CFLAGS) -o cert ${.CURDIR}/cert.c ${LIBCRYPT}
-
-speedcrypt: speedcrypt.c ${LIBCRYPT}
- $(CC) $(CFLAGS) -o speedcrypt ${.CURDIR}/speedcrypt.c ${LIBCRYPT}
-
-speeddes: speeddes.c ${LIBCRYPT}
- $(CC) $(CFLAGS) -o speeddes ${.CURDIR}/speeddes.c ${LIBCRYPT}
-
-clean:
- rm -f ${TARGETS}
-
-install:
-
-.include <bsd.prog.mk>
diff --git a/secure/lib/libcipher/test/README b/secure/lib/libcipher/test/README
deleted file mode 100644
index eb6b0bebbc1d..000000000000
--- a/secure/lib/libcipher/test/README
+++ /dev/null
@@ -1,10 +0,0 @@
-This directory contains test programs to certify DES operation and to
-time the crypt() call (of curiosity value).
-
-Simply type `make test` to run the tests.
-
-The normal `make all` and `make install` that get done during library building
-and installation will build these programs BUT NOT INSTALL THEM. After all,
-they're only for testing...
-
-- David Burren, January 1994
diff --git a/secure/lib/libcipher/test/cert.c b/secure/lib/libcipher/test/cert.c
deleted file mode 100644
index e9907b9a9232..000000000000
--- a/secure/lib/libcipher/test/cert.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * This DES validation program shipped with FreeSec is derived from that
- * shipped with UFC-crypt which is apparently derived from one distributed
- * with Phil Karns PD DES package.
- *
- * $FreeBSD$
- */
-
-#include <stdio.h>
-
-int totfails = 0;
-
-char *crypt();
-#ifdef HAVE_CRYPT16
-char *crypt16();
-#endif /* HAVE_CRYPT16 */
-
-
-static struct crypt_test {
- char *key, *setting, *answer;
-} crypt_tests[] = {
- "foob", "ar", "arlEKn0OzVJn.",
- "holyhooplasbatman!", "_X.......", "_X.......N89y2Z.e4WU",
- "holyhooplasbatman!", "_X...X...", "_X...X...rSUDQ5Na/QM",
- "holyhooplasbatman!", "_XX..X...", "_XX..X...P8vb9xU4JAk",
- "holyhooplasbatman!", "_XX..XX..", "_XX..XX..JDs5IlGLqT2",
- "holyhooplasbatman!", "_XX..XXa.", "_XX..XXa.bFVsOnCNh8Y",
- "holyhooplasbatman!", "_XXa.X...", "_XXa.X...Ghsb3QKNaps",
-#ifdef TAKES_TOO_LONG_ON_SOME_CRYPTS
- "holyhooplasbatman!", "_arararar", "_ararararNGMzvpNjeCc",
-#endif
- NULL, NULL, NULL,
-};
-
-
-static struct crypt_test crypt16_tests[] = {
- "foob", "ar", "arxo23jZDD5AYbHbqoy9Dalg",
- "holyhooplasbatman!", "ar", "arU5FRLJ3kxIoedlmyrOelEw",
- NULL, NULL, NULL
-};
-
-
-void good_bye()
-{
- if(totfails == 0) {
- printf(" Passed validation\n");
- exit(0);
- } else {
- printf(" %d failures during validation!!!\n", totfails);
- exit(1);
- }
-}
-
-
-void put8(cp)
-char *cp;
-{
- int i,j,t;
-
- for(i = 0; i < 8; i++){
- t = 0;
- for(j = 0; j < 8; j++)
- t = t << 1 | *cp++;
- printf("%02x", t);
- }
-}
-
-
-void print_bits(bits)
-unsigned char *bits;
-{
- int i;
-
- for (i = 0; i < 8; i++) {
- printf("%02x", bits[i]);
- }
-}
-
-
-int parse_line(buff, salt, key, plain, answer)
-char *buff;
-long *salt;
-char *key, *plain, *answer;
-{
- char *ptr1, *ptr2;
- int val;
- int i,j,t;
-
- /*
- * Extract salt
- */
- if (sscanf(buff, "%lu", salt) != 1)
- return(-1);
- for (ptr2 = buff; *ptr2 && !isspace(*ptr2); ptr2++)
- ;
-
- /*
- * Extract key
- */
- for (ptr1 = ptr2; *ptr1 && isspace(*ptr1); ptr1++)
- ;
- for (ptr2 = ptr1; *ptr2 && !isspace(*ptr2); ptr2++)
- ;
- if (ptr2 - ptr1 != 16)
- return(-1);
- for (i = 0; i < 8; i++){
- if (sscanf(ptr1 + 2*i, "%2x", &t) != 1)
- return(-2);
- for (j = 0; j < 8; j++)
- *key++ = (t & 1 << (7 - j)) != 0;
- }
-
- /*
- * Extract plain
- */
- for (ptr1 = ptr2; *ptr1 && isspace(*ptr1); ptr1++)
- ;
- for (ptr2 = ptr1; *ptr2 && !isspace(*ptr2); ptr2++)
- ;
- if (ptr2 - ptr1 != 16)
- return(-1);
- for (i = 0; i < 8; i++){
- if (sscanf(ptr1 + 2*i, "%2x", &t) != 1)
- return(-2);
- for (j = 0; j < 8; j++)
- *plain++ = (t & 1 << (7 - j)) != 0;
- }
-
- /*
- * Extract answer
- */
- for (ptr1 = ptr2; *ptr1 && isspace(*ptr1); ptr1++)
- ;
- for (ptr2 = ptr1; *ptr2 && !isspace(*ptr2); ptr2++)
- ;
- if (ptr2 - ptr1 != 16)
- return(-1);
- for (i = 0; i < 8; i++){
- if (sscanf(ptr1 + 2*i, "%2x", &t) != 1)
- return(-2);
- for (j = 0; j < 8; j++)
- *answer++ = (t & 1 << (7 - j)) != 0;
- }
- return(0);
-}
-
-/*
- * Test the setkey and encrypt functions
- */
-void test_encrypt()
-{
- char key[64],plain[64],cipher[64],answer[64];
- char buff[BUFSIZ];
- unsigned long salt;
- int i;
- int test;
- int fail;
-
- printf("Testing setkey/encrypt\n");
-
- for(test=0;fgets(buff, BUFSIZ, stdin);test++){
-
- /*
- * Allow comments.
- */
- if (*buff == '#')
- continue;
-
- if ((fail = parse_line(buff, &salt, key, plain, answer)) < 0){
- printf("test %d garbled (%d)\n", test, fail);
- continue;
- }
-
- if (salt)
- continue; /* encrypt has no salt support */
-
- printf(" K: "); put8(key);
- printf(" P: "); put8(plain);
- printf(" C: "); put8(answer);
-
- setkey(key);
- for(i = 0; i < 64; i++)
- cipher[i] = plain[i];
- encrypt(cipher, 0);
-
- for(i=0;i<64;i++)
- if(cipher[i] != answer[i])
- break;
- fail = 0;
- if(i != 64){
- printf(" Enc FAIL ");
- put8(cipher);
- fail++; totfails++;
- }
-
- encrypt(cipher, 1);
-
- for(i=0;i<64;i++)
- if(cipher[i] != plain[i])
- break;
- if(i != 64){
- printf(" Dec FAIL");
- fail++; totfails++;
- }
-
- if(fail == 0)
- printf(" OK");
- printf("\n");
- }
-}
-
-
-void bytes_to_bits(bytes, bits)
-char *bytes;
-unsigned char *bits;
-{
- int i, j;
-
- for (i = 0; i < 8; i++) {
- bits[i] = 0;
- for (j = 0; j < 8; j++) {
- bits[i] |= (bytes[i*8+j] & 1) << (7 - j);
- }
- }
-}
-
-
-/*
- * Test the des_setkey and des_cipher functions
- */
-void test_des()
-{
- char ckey[64], cplain[64], canswer[64];
- unsigned char key[8], plain[8], cipher[8], answer[8];
- char buff[BUFSIZ];
- unsigned long salt;
- int i;
- int test;
- int fail;
-
- printf("Testing des_setkey/des_cipher\n");
-
- for(test=0;fgets(buff, BUFSIZ, stdin);test++){
-
- /*
- * Allow comments.
- */
- if (*buff == '#')
- continue;
-
- if ((fail = parse_line(buff, &salt, ckey, cplain, canswer)) <0){
- printf("test %d garbled (%d)\n", test, fail);
- continue;
- }
-
- printf(" S: %06x", salt);
- printf(" K: "); put8(ckey);
- printf(" P: "); put8(cplain);
- printf(" C: "); put8(canswer);
-
- bytes_to_bits(ckey, key);
- bytes_to_bits(cplain, plain);
- bytes_to_bits(canswer, answer);
- des_setkey(key);
- des_cipher(plain, cipher, salt, 1);
-
- for(i = 0; i < 8; i++)
- if(cipher[i] != answer[i])
- break;
- fail = 0;
- if(i != 8){
- printf(" Enc FAIL ");
- print_bits(cipher);
- fail++; totfails++;
- }
-
- des_cipher(cipher, cipher, salt, -1);
-
- for(i = 0; i < 8; i++)
- if(cipher[i] != plain[i])
- break;
- if(i != 8){
- printf(" Dec FAIL");
- fail++; totfails++;
- }
-
- if(fail == 0)
- printf(" OK");
- printf("\n");
- }
-}
-
-
-/*
- * Test the old-style crypt(), the new-style crypt(), and crypt16().
- */
-void test_crypt()
-{
- char *result;
- struct crypt_test *p;
-
- printf("Testing crypt() family\n");
-
- for (p = crypt_tests; p->key; p++) {
- printf(" crypt(\"%s\", \"%s\"), \"%s\" expected",
- p->key, p->setting, p->answer);
- fflush(stdout);
- result = crypt(p->key, p->setting);
- if(!strcmp(result, p->answer)) {
- printf(", OK\n");
- } else {
- printf("\n failed (\"%s\")\n", result);
- totfails++;
- }
- }
-
-#ifdef HAVE_CRYPT16
- for (p = crypt16_tests; p->key; p++) {
- printf(" crypt16(\"%s\", \"%s\"), \"%s\" expected",
- p->key, p->setting, p->answer);
- fflush(stdout);
- result = crypt16(p->key, p->setting);
- if(!strcmp(result, p->answer)) {
- printf(", OK\n");
- } else {
- printf("\n failed (\"%s\")\n", result);
- totfails++;
- }
- }
-#endif /* HAVE_CRYPT16 */
-}
-
-main(argc, argv)
-int argc;
-char *argv[];
-{
- if(argc < 1 || !strcmp(argv[1], "-e"))
- test_encrypt();
- else if(!strcmp(argv[1], "-d"))
- test_des();
- else if(!strcmp(argv[1], "-c"))
- test_crypt();
- good_bye();
-}
diff --git a/secure/lib/libcipher/test/cert.input b/secure/lib/libcipher/test/cert.input
deleted file mode 100644
index e7c715c7a9d8..000000000000
--- a/secure/lib/libcipher/test/cert.input
+++ /dev/null
@@ -1,179 +0,0 @@
-# $FreeBSD$
-#
-# Salt, key, plaintext, ciphertext
-#
-0 0101010101010101 95f8a5e5dd31d900 8000000000000000
-0 0101010101010101 dd7f121ca5015619 4000000000000000
-0 0101010101010101 2e8653104f3834ea 2000000000000000
-0 0101010101010101 4bd388ff6cd81d4f 1000000000000000
-0 0101010101010101 20b9e767b2fb1456 0800000000000000
-0 0101010101010101 55579380d77138ef 0400000000000000
-0 0101010101010101 6cc5defaaf04512f 0200000000000000
-0 0101010101010101 0d9f279ba5d87260 0100000000000000
-0 0101010101010101 d9031b0271bd5a0a 0080000000000000
-0 0101010101010101 424250b37c3dd951 0040000000000000
-0 0101010101010101 b8061b7ecd9a21e5 0020000000000000
-0 0101010101010101 f15d0f286b65bd28 0010000000000000
-0 0101010101010101 add0cc8d6e5deba1 0008000000000000
-0 0101010101010101 e6d5f82752ad63d1 0004000000000000
-0 0101010101010101 ecbfe3bd3f591a5e 0002000000000000
-0 0101010101010101 f356834379d165cd 0001000000000000
-0 0101010101010101 2b9f982f20037fa9 0000800000000000
-0 0101010101010101 889de068a16f0be6 0000400000000000
-0 0101010101010101 e19e275d846a1298 0000200000000000
-0 0101010101010101 329a8ed523d71aec 0000100000000000
-0 0101010101010101 e7fce22557d23c97 0000080000000000
-0 0101010101010101 12a9f5817ff2d65d 0000040000000000
-0 0101010101010101 a484c3ad38dc9c19 0000020000000000
-0 0101010101010101 fbe00a8a1ef8ad72 0000010000000000
-0 0101010101010101 750d079407521363 0000008000000000
-0 0101010101010101 64feed9c724c2faf 0000004000000000
-0 0101010101010101 f02b263b328e2b60 0000002000000000
-0 0101010101010101 9d64555a9a10b852 0000001000000000
-0 0101010101010101 d106ff0bed5255d7 0000000800000000
-0 0101010101010101 e1652c6b138c64a5 0000000400000000
-0 0101010101010101 e428581186ec8f46 0000000200000000
-0 0101010101010101 aeb5f5ede22d1a36 0000000100000000
-0 0101010101010101 e943d7568aec0c5c 0000000080000000
-0 0101010101010101 df98c8276f54b04b 0000000040000000
-0 0101010101010101 b160e4680f6c696f 0000000020000000
-0 0101010101010101 fa0752b07d9c4ab8 0000000010000000
-0 0101010101010101 ca3a2b036dbc8502 0000000008000000
-0 0101010101010101 5e0905517bb59bcf 0000000004000000
-0 0101010101010101 814eeb3b91d90726 0000000002000000
-0 0101010101010101 4d49db1532919c9f 0000000001000000
-0 0101010101010101 25eb5fc3f8cf0621 0000000000800000
-0 0101010101010101 ab6a20c0620d1c6f 0000000000400000
-0 0101010101010101 79e90dbc98f92cca 0000000000200000
-0 0101010101010101 866ecedd8072bb0e 0000000000100000
-0 0101010101010101 8b54536f2f3e64a8 0000000000080000
-0 0101010101010101 ea51d3975595b86b 0000000000040000
-0 0101010101010101 caffc6ac4542de31 0000000000020000
-0 0101010101010101 8dd45a2ddf90796c 0000000000010000
-0 0101010101010101 1029d55e880ec2d0 0000000000008000
-0 0101010101010101 5d86cb23639dbea9 0000000000004000
-0 0101010101010101 1d1ca853ae7c0c5f 0000000000002000
-0 0101010101010101 ce332329248f3228 0000000000001000
-0 0101010101010101 8405d1abe24fb942 0000000000000800
-0 0101010101010101 e643d78090ca4207 0000000000000400
-0 0101010101010101 48221b9937748a23 0000000000000200
-0 0101010101010101 dd7c0bbd61fafd54 0000000000000100
-0 0101010101010101 2fbc291a570db5c4 0000000000000080
-0 0101010101010101 e07c30d7e4e26e12 0000000000000040
-0 0101010101010101 0953e2258e8e90a1 0000000000000020
-0 0101010101010101 5b711bc4ceebf2ee 0000000000000010
-0 0101010101010101 cc083f1e6d9e85f6 0000000000000008
-0 0101010101010101 d2fd8867d50d2dfe 0000000000000004
-0 0101010101010101 06e7ea22ce92708f 0000000000000002
-0 0101010101010101 166b40b44aba4bd6 0000000000000001
-0 8001010101010101 0000000000000000 95a8d72813daa94d
-0 4001010101010101 0000000000000000 0eec1487dd8c26d5
-0 2001010101010101 0000000000000000 7ad16ffb79c45926
-0 1001010101010101 0000000000000000 d3746294ca6a6cf3
-0 0801010101010101 0000000000000000 809f5f873c1fd761
-0 0401010101010101 0000000000000000 c02faffec989d1fc
-0 0201010101010101 0000000000000000 4615aa1d33e72f10
-0 0180010101010101 0000000000000000 2055123350c00858
-0 0140010101010101 0000000000000000 df3b99d6577397c8
-0 0120010101010101 0000000000000000 31fe17369b5288c9
-0 0110010101010101 0000000000000000 dfdd3cc64dae1642
-0 0108010101010101 0000000000000000 178c83ce2b399d94
-0 0104010101010101 0000000000000000 50f636324a9b7f80
-0 0102010101010101 0000000000000000 a8468ee3bc18f06d
-0 0101800101010101 0000000000000000 a2dc9e92fd3cde92
-0 0101400101010101 0000000000000000 cac09f797d031287
-0 0101200101010101 0000000000000000 90ba680b22aeb525
-0 0101100101010101 0000000000000000 ce7a24f350e280b6
-0 0101080101010101 0000000000000000 882bff0aa01a0b87
-0 0101040101010101 0000000000000000 25610288924511c2
-0 0101020101010101 0000000000000000 c71516c29c75d170
-0 0101018001010101 0000000000000000 5199c29a52c9f059
-0 0101014001010101 0000000000000000 c22f0a294a71f29f
-0 0101012001010101 0000000000000000 ee371483714c02ea
-0 0101011001010101 0000000000000000 a81fbd448f9e522f
-0 0101010801010101 0000000000000000 4f644c92e192dfed
-0 0101010401010101 0000000000000000 1afa9a66a6df92ae
-0 0101010201010101 0000000000000000 b3c1cc715cb879d8
-0 0101010180010101 0000000000000000 19d032e64ab0bd8b
-0 0101010140010101 0000000000000000 3cfaa7a7dc8720dc
-0 0101010120010101 0000000000000000 b7265f7f447ac6f3
-0 0101010110010101 0000000000000000 9db73b3c0d163f54
-0 0101010108010101 0000000000000000 8181b65babf4a975
-0 0101010104010101 0000000000000000 93c9b64042eaa240
-0 0101010102010101 0000000000000000 5570530829705592
-0 0101010101800101 0000000000000000 8638809e878787a0
-0 0101010101400101 0000000000000000 41b9a79af79ac208
-0 0101010101200101 0000000000000000 7a9be42f2009a892
-0 0101010101100101 0000000000000000 29038d56ba6d2745
-0 0101010101080101 0000000000000000 5495c6abf1e5df51
-0 0101010101040101 0000000000000000 ae13dbd561488933
-0 0101010101020101 0000000000000000 024d1ffa8904e389
-0 0101010101018001 0000000000000000 d1399712f99bf02e
-0 0101010101014001 0000000000000000 14c1d7c1cffec79e
-0 0101010101012001 0000000000000000 1de5279dae3bed6f
-0 0101010101011001 0000000000000000 e941a33f85501303
-0 0101010101010801 0000000000000000 da99dbbc9a03f379
-0 0101010101010401 0000000000000000 b7fc92f91d8e92e9
-0 0101010101010201 0000000000000000 ae8e5caa3ca04e85
-0 0101010101010180 0000000000000000 9cc62df43b6eed74
-0 0101010101010140 0000000000000000 d863dbb5c59a91a0
-0 0101010101010120 0000000000000000 a1ab2190545b91d7
-0 0101010101010110 0000000000000000 0875041e64c570f7
-0 0101010101010108 0000000000000000 5a594528bebef1cc
-0 0101010101010104 0000000000000000 fcdb3291de21f0c0
-0 0101010101010102 0000000000000000 869efd7f9f265a09
-0 1046913489980131 0000000000000000 88d55e54f54c97b4
-0 1007103489988020 0000000000000000 0c0cc00c83ea48fd
-0 10071034c8980120 0000000000000000 83bc8ef3a6570183
-0 1046103489988020 0000000000000000 df725dcad94ea2e9
-0 1086911519190101 0000000000000000 e652b53b550be8b0
-0 1086911519580101 0000000000000000 af527120c485cbb0
-0 5107b01519580101 0000000000000000 0f04ce393db926d5
-0 1007b01519190101 0000000000000000 c9f00ffc74079067
-0 3107915498080101 0000000000000000 7cfd82a593252b4e
-0 3107919498080101 0000000000000000 cb49a2f9e91363e3
-0 10079115b9080140 0000000000000000 00b588be70d23f56
-0 3107911598080140 0000000000000000 406a9a6ab43399ae
-0 1007d01589980101 0000000000000000 6cb773611dca9ada
-0 9107911589980101 0000000000000000 67fd21c17dbb5d70
-0 9107d01589190101 0000000000000000 9592cb4110430787
-0 1007d01598980120 0000000000000000 a6b7ff68a318ddd3
-0 1007940498190101 0000000000000000 4d102196c914ca16
-0 0107910491190401 0000000000000000 2dfa9f4573594965
-0 0107910491190101 0000000000000000 b46604816c0e0774
-0 0107940491190401 0000000000000000 6e7e6221a4f34e87
-0 19079210981a0101 0000000000000000 aa85e74643233199
-0 1007911998190801 0000000000000000 2e5a19db4d1962d6
-0 10079119981a0801 0000000000000000 23a866a809d30894
-0 1007921098190101 0000000000000000 d812d961f017d320
-0 100791159819010b 0000000000000000 055605816e58608f
-0 1004801598190101 0000000000000000 abd88e8b1b7716f1
-0 1004801598190102 0000000000000000 537ac95be69da1e1
-0 1004801598190108 0000000000000000 aed0f6ae3c25cdd8
-0 1002911598100104 0000000000000000 b3e35a5ee53e7b8d
-0 1002911598190104 0000000000000000 61c79c71921a2ef8
-0 1002911598100201 0000000000000000 e2f5728f0995013c
-0 1002911698100101 0000000000000000 1aeac39a61f0a464
-0 7ca110454a1a6e57 01a1d6d039776742 690f5b0d9a26939b
-0 0131d9619dc1376e 5cd54ca83def57da 7a389d10354bd271
-0 07a1133e4a0b2686 0248d43806f67172 868ebb51cab4599a
-0 3849674c2602319e 51454b582ddf440a 7178876e01f19b2a
-0 04b915ba43feb5b6 42fd443059577fa2 af37fb421f8c4095
-0 0113b970fd34f2ce 059b5e0851cf143a 86a560f10ec6d85b
-0 0170f175468fb5e6 0756d8e0774761d2 0cd3da020021dc09
-0 43297fad38e373fe 762514b829bf486a ea676b2cb7db2b7a
-0 07a7137045da2a16 3bdd119049372802 dfd64a815caf1a0f
-0 04689104c2fd3b2f 26955f6835af609a 5c513c9c4886c088
-0 37d06bb516cb7546 164d5e404f275232 0a2aeeae3ff4ab77
-0 1f08260d1ac2465e 6b056e18759f5cca ef1bf03e5dfa575a
-0 584023641aba6176 004bd6ef09176062 88bf0db6d70dee56
-0 025816164629b007 480d39006ee762f2 a1f9915541020b56
-0 49793ebc79b3258f 437540c8698f3cfa 6fbf1cafcffd0556
-0 4fb05e1515ab73a7 072d43a077075292 2f22e49bab7ca1ac
-0 49e95d6d4ca229bf 02fe55778117f12a 5a6b612cc26cce4a
-0 018310dc409b26d6 1d9d5c5018f728c2 5f4c038ed12b2e41
-0 1c587f1c13924fef 305532286d6f295a 63fac0d034d9f793
-1 1c587f1c13924fef 305532286d6f295a 400d307ca24fee60
-57 1c587f1c13924fef 305532286d6f295a 28b568f40e7d43ae
-1 8001010101010101 0000000000000000 f501029f268e45dc
-0 1c587f1c13924fef 305532286d6f295a 63fac0d034d9f793
diff --git a/secure/lib/libcipher/test/speedcrypt.c b/secure/lib/libcipher/test/speedcrypt.c
deleted file mode 100644
index f7507fd789f0..000000000000
--- a/secure/lib/libcipher/test/speedcrypt.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <signal.h>
-#include <stdio.h>
-
-int keep_going, count, alternate, seconds;
-struct rusage prior, now;
-
-void
-finish()
-{
- keep_going = 0;
-}
-
-
-main(int argc, char *argv[])
-{
- struct itimerval itv;
- u_long msecs, key1[8], key2[8];
- char *k1, *k2;
-
- if (argc < 2 || sscanf(argv[1], "%d", &seconds) != 1)
- seconds = 20;
-
- if (argc < 3 || sscanf(argv[2], "%d", &alternate) != 1)
- alternate = 0;
-
- printf ("Running crypt%s for %d seconds of vtime...\n",
- alternate ? " with alternate keys" : "", seconds);
-
- bzero(&itv, sizeof (itv));
- signal (SIGVTALRM, finish);
- itv.it_value.tv_sec = seconds;
- itv.it_value.tv_usec = 0;
- setitimer(ITIMER_VIRTUAL, &itv, NULL);
-
- keep_going = 1;
- if (getrusage(0, &prior) < 0) {
- perror("getrusage");
- exit(1);
- }
-
- k1 = (char *) key1;
- k2 = (char *) key2;
- strcpy(k1, "fredfredfredfredfred");
- strcpy(k2, "joejoejoejoejoejoejo");
-
- if (alternate)
- for (count = 0; keep_going; count++)
- {
-#if defined(LONGCRYPT)
- crypt((count & 1) ? k1 : k2, "_ara.X...");
-#else
- crypt((count & 1) ? k1 : k2, "eek");
-#endif
- }
- else
- for (count = 0; keep_going; count++)
- {
-#if defined(LONGCRYPT)
- crypt(k1, "_ara.X...");
-#else
- crypt(k1, "eek");
-#endif
- }
-
- if (getrusage(0, &now) < 0) {
- perror("getrusage");
- exit(1);
- }
- msecs = (now.ru_utime.tv_sec - prior.ru_utime.tv_sec) * 1000
- + (now.ru_utime.tv_usec - prior.ru_utime.tv_usec) / 1000;
- printf ("\tDid %d crypt()s per second.\n", 1000 * count / msecs);
- exit(0);
-}
diff --git a/secure/lib/libcipher/test/speeddes.c b/secure/lib/libcipher/test/speeddes.c
deleted file mode 100644
index a5822362f107..000000000000
--- a/secure/lib/libcipher/test/speeddes.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <signal.h>
-#include <stdio.h>
-
-int keep_going, count, alternate, seconds, iters;
-struct rusage prior, now;
-u_long block[3];
-char *blk;
-
-void
-finish()
-{
- keep_going = 0;
-}
-
-
-main(int argc, char *argv[])
-{
- struct itimerval itv;
- u_long msecs;
-
- if (argc < 2 || sscanf(argv[1], "%d", &seconds) != 1)
- seconds = 20;
-
- if (argc < 3 || sscanf(argv[2], "%d", &iters) != 1)
- iters = 1;
-
- printf ("Running des_cipher( , , 0L, %d) for %d seconds of vtime...\n",
- iters, seconds);
-
- bzero(&itv, sizeof (itv));
- signal (SIGVTALRM, finish);
- itv.it_value.tv_sec = seconds;
- itv.it_value.tv_usec = 0;
- setitimer(ITIMER_VIRTUAL, &itv, NULL);
-
- keep_going = 1;
- if (getrusage(0, &prior) < 0) {
- perror("getrusage");
- exit(1);
- }
-
- blk = (char *) block;
- (void)des_setkey(blk);
- for (count = 0; keep_going; count++)
- (void) des_cipher(blk, blk, 0, iters);
-
- if (getrusage(0, &now) < 0) {
- perror("getrusage");
- exit(1);
- }
-
- msecs = (now.ru_utime.tv_sec - prior.ru_utime.tv_sec) * 1000
- + (now.ru_utime.tv_usec - prior.ru_utime.tv_usec) / 1000;
- printf ("Did %d encryptions per second, each of %d iteration(s).\n",
- 1000 * count / msecs, iters);
- printf ("\tTotal %d blocks per second.\n", (1000*iters*count)/msecs);
- exit(0);
-}
diff --git a/secure/lib/libcrypt/blowfish.c b/secure/lib/libcrypt/blowfish.c
deleted file mode 100644
index 3d74c05c0f21..000000000000
--- a/secure/lib/libcrypt/blowfish.c
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Blowfish block cipher
- * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
- * All rights reserved.
- *
- * Implementation advice by David Mazieres <dm@lcs.mit.edu>.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Niels Provos.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * This code is derived from section 14.3 and the given source
- * in section V of Applied Cryptography, second edition.
- * Blowfish is an unpatented fast block cipher designed by
- * Bruce Schneier.
- */
-
-/*
- * FreeBSD implementation by Paul Herman <pherman@frenchfries.net>
- */
-
-#if 0
-#include <stdio.h> /* used for debugging */
-#include <string.h>
-#endif
-
-#include <sys/types.h>
-#include "blowfish.h"
-
-#undef inline
-#ifdef __GNUC__
-#define inline __inline
-#else /* !__GNUC__ */
-#define inline
-#endif /* !__GNUC__ */
-
-/* Function for Feistel Networks */
-
-#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \
- + (s)[0x100 + (((x)>>16)&0xFF)]) \
- ^ (s)[0x200 + (((x)>> 8)&0xFF)]) \
- + (s)[0x300 + ( (x) &0xFF)])
-
-#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
-
-void
-Blowfish_encipher(c, xl, xr)
- blf_ctx *c;
- u_int32_t *xl;
- u_int32_t *xr;
-{
- u_int32_t Xl;
- u_int32_t Xr;
- u_int32_t *s = c->S[0];
- u_int32_t *p = c->P;
-
- Xl = *xl;
- Xr = *xr;
-
- Xl ^= p[0];
- BLFRND(s, p, Xr, Xl, 1); BLFRND(s, p, Xl, Xr, 2);
- BLFRND(s, p, Xr, Xl, 3); BLFRND(s, p, Xl, Xr, 4);
- BLFRND(s, p, Xr, Xl, 5); BLFRND(s, p, Xl, Xr, 6);
- BLFRND(s, p, Xr, Xl, 7); BLFRND(s, p, Xl, Xr, 8);
- BLFRND(s, p, Xr, Xl, 9); BLFRND(s, p, Xl, Xr, 10);
- BLFRND(s, p, Xr, Xl, 11); BLFRND(s, p, Xl, Xr, 12);
- BLFRND(s, p, Xr, Xl, 13); BLFRND(s, p, Xl, Xr, 14);
- BLFRND(s, p, Xr, Xl, 15); BLFRND(s, p, Xl, Xr, 16);
-
- *xl = Xr ^ p[17];
- *xr = Xl;
-}
-
-void
-Blowfish_decipher(c, xl, xr)
- blf_ctx *c;
- u_int32_t *xl;
- u_int32_t *xr;
-{
- u_int32_t Xl;
- u_int32_t Xr;
- u_int32_t *s = c->S[0];
- u_int32_t *p = c->P;
-
- Xl = *xl;
- Xr = *xr;
-
- Xl ^= p[17];
- BLFRND(s, p, Xr, Xl, 16); BLFRND(s, p, Xl, Xr, 15);
- BLFRND(s, p, Xr, Xl, 14); BLFRND(s, p, Xl, Xr, 13);
- BLFRND(s, p, Xr, Xl, 12); BLFRND(s, p, Xl, Xr, 11);
- BLFRND(s, p, Xr, Xl, 10); BLFRND(s, p, Xl, Xr, 9);
- BLFRND(s, p, Xr, Xl, 8); BLFRND(s, p, Xl, Xr, 7);
- BLFRND(s, p, Xr, Xl, 6); BLFRND(s, p, Xl, Xr, 5);
- BLFRND(s, p, Xr, Xl, 4); BLFRND(s, p, Xl, Xr, 3);
- BLFRND(s, p, Xr, Xl, 2); BLFRND(s, p, Xl, Xr, 1);
-
- *xl = Xr ^ p[0];
- *xr = Xl;
-}
-
-void
-Blowfish_initstate(c)
- blf_ctx *c;
-{
-
-/* P-box and S-box tables initialized with digits of Pi */
-
- const blf_ctx initstate =
-
- { {
- {
- 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
- 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
- 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
- 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
- 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
- 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
- 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
- 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
- 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
- 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
- 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
- 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
- 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
- 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
- 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
- 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
- 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
- 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
- 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
- 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
- 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
- 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
- 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
- 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
- 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
- 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
- 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
- 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
- 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
- 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
- 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
- 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
- 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
- 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
- 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
- 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
- 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
- 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
- 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
- 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
- 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
- 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
- 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
- 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
- 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
- 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
- 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
- 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
- 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
- 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
- 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
- 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
- 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
- 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a},
- {
- 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
- 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
- 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
- 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
- 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
- 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
- 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
- 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
- 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
- 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
- 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
- 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
- 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
- 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
- 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
- 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
- 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
- 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
- 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
- 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
- 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
- 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
- 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
- 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
- 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
- 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
- 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
- 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
- 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
- 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
- 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
- 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
- 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
- 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
- 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
- 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
- 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
- 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
- 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
- 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
- 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
- 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
- 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
- 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
- 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
- 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
- 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
- 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
- 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
- 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
- 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
- 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
- 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
- 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
- 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
- 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
- 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
- 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
- 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7},
- {
- 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
- 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
- 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
- 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
- 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
- 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
- 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
- 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
- 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
- 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
- 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
- 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
- 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
- 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
- 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
- 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
- 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
- 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
- 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
- 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
- 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
- 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
- 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
- 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
- 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
- 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
- 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
- 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
- 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
- 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
- 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
- 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
- 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
- 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
- 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
- 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
- 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
- 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
- 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
- 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
- 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
- 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
- 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
- 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
- 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
- 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
- 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
- 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
- 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
- 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
- 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
- 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
- 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
- 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
- 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
- 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
- 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
- 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
- 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
- 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0},
- {
- 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
- 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
- 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
- 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
- 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
- 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
- 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
- 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
- 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
- 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
- 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
- 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
- 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
- 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
- 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
- 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
- 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
- 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
- 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
- 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
- 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
- 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
- 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
- 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
- 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
- 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
- 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
- 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
- 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
- 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
- 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
- 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
- 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
- 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
- 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
- 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
- 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
- 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
- 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
- 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
- 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
- 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
- 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
- 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
- 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
- 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
- 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
- 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
- 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
- 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
- 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
- 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
- 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
- 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
- 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}
- },
- {
- 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
- 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
- 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
- 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
- 0x9216d5d9, 0x8979fb1b
- } };
-
- *c = initstate;
-
-}
-
-#ifdef __STDC__
-u_int32_t
-Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current)
-#else
-u_int32_t
-Blowfish_stream2word(data, databytes, current)
- const u_int8_t *data;
- u_int16_t databytes;
- u_int16_t *current;
-#endif
-{
- u_int8_t i;
- u_int16_t j;
- u_int32_t temp;
-
- temp = 0x00000000;
- j = *current;
-
- for (i = 0; i < 4; i++, j++) {
- if (j >= databytes)
- j = 0;
- temp = (temp << 8) | data[j];
- }
-
- *current = j;
- return temp;
-}
-
-#if __STDC__
-void
-Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
-#else
-void
-Blowfish_expand0state(c, key, keybytes)
- blf_ctx *c;
- const u_int8_t *key;
- u_int16_t keybytes;
-#endif
-{
- u_int16_t i;
- u_int16_t j;
- u_int16_t k;
- u_int32_t temp;
- u_int32_t datal;
- u_int32_t datar;
-
- j = 0;
- for (i = 0; i < BLF_N + 2; i++) {
- /* Extract 4 int8 to 1 int32 from keystream */
- temp = Blowfish_stream2word(key, keybytes, &j);
- c->P[i] = c->P[i] ^ temp;
- }
-
- j = 0;
- datal = 0x00000000;
- datar = 0x00000000;
- for (i = 0; i < BLF_N + 2; i += 2) {
- Blowfish_encipher(c, &datal, &datar);
-
- c->P[i] = datal;
- c->P[i + 1] = datar;
- }
-
- for (i = 0; i < 4; i++) {
- for (k = 0; k < 256; k += 2) {
- Blowfish_encipher(c, &datal, &datar);
-
- c->S[i][k] = datal;
- c->S[i][k + 1] = datar;
- }
- }
-}
-
-
-#if __STDC__
-void
-Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
- const u_int8_t *key, u_int16_t keybytes)
-#else
-void
-Blowfish_expandstate(c, data, databytes, key, keybytes)
- blf_ctx *c;
- const u_int8_t *data;
- u_int16_t databytes;
- const u_int8_t *key;
- u_int16_t keybytes;
-#endif
-{
- u_int16_t i;
- u_int16_t j;
- u_int16_t k;
- u_int32_t temp;
- u_int32_t datal;
- u_int32_t datar;
-
- j = 0;
- for (i = 0; i < BLF_N + 2; i++) {
- /* Extract 4 int8 to 1 int32 from keystream */
- temp = Blowfish_stream2word(key, keybytes, &j);
- c->P[i] = c->P[i] ^ temp;
- }
-
- j = 0;
- datal = 0x00000000;
- datar = 0x00000000;
- for (i = 0; i < BLF_N + 2; i += 2) {
- datal ^= Blowfish_stream2word(data, databytes, &j);
- datar ^= Blowfish_stream2word(data, databytes, &j);
- Blowfish_encipher(c, &datal, &datar);
-
- c->P[i] = datal;
- c->P[i + 1] = datar;
- }
-
- for (i = 0; i < 4; i++) {
- for (k = 0; k < 256; k += 2) {
- datal ^= Blowfish_stream2word(data, databytes, &j);
- datar ^= Blowfish_stream2word(data, databytes, &j);
- Blowfish_encipher(c, &datal, &datar);
-
- c->S[i][k] = datal;
- c->S[i][k + 1] = datar;
- }
- }
-
-}
-
-#if __STDC__
-void
-blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
-#else
-void
-blf_key(c, k, len)
- blf_ctx *c;
- const u_int8_t *k;
- u_int16_t len;
-#endif
-{
- /* Initalize S-boxes and subkeys with Pi */
- Blowfish_initstate(c);
-
- /* Transform S-boxes and subkeys with key */
- Blowfish_expand0state(c, k, len);
-}
-
-#if __STDC__
-void
-blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
-#else
-void
-blf_enc(c, data, blocks)
- blf_ctx *c;
- u_int32_t *data;
- u_int16_t blocks;
-#endif
-{
- u_int32_t *d;
- u_int16_t i;
-
- d = data;
- for (i = 0; i < blocks; i++) {
- Blowfish_encipher(c, d, d + 1);
- d += 2;
- }
-}
-
-#if __STDC__
-void
-blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
-#else
-void
-blf_dec(c, data, blocks)
- blf_ctx *c;
- u_int32_t *data;
- u_int16_t blocks;
-#endif
-{
- u_int32_t *d;
- u_int16_t i;
-
- d = data;
- for (i = 0; i < blocks; i++) {
- Blowfish_decipher(c, d, d + 1);
- d += 2;
- }
-}
-
-#if __STDC__
-void
-blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
-#else
-void
-blf_ecb_encrypt(c, data, len)
- blf_ctx *c;
- u_int8_t *data;
- u_int32_t len;
-#endif
-{
- u_int32_t l, r;
- u_int32_t i;
-
- for (i = 0; i < len; i += 8) {
- l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
- r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
- Blowfish_encipher(c, &l, &r);
- data[0] = l >> 24 & 0xff;
- data[1] = l >> 16 & 0xff;
- data[2] = l >> 8 & 0xff;
- data[3] = l & 0xff;
- data[4] = r >> 24 & 0xff;
- data[5] = r >> 16 & 0xff;
- data[6] = r >> 8 & 0xff;
- data[7] = r & 0xff;
- data += 8;
- }
-}
-
-#if __STDC__
-void
-blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
-#else
-void
-blf_ecb_decrypt(c, data, len)
- blf_ctx *c;
- u_int8_t *data;
- u_int32_t len;
-#endif
-{
- u_int32_t l, r;
- u_int32_t i;
-
- for (i = 0; i < len; i += 8) {
- l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
- r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
- Blowfish_decipher(c, &l, &r);
- data[0] = l >> 24 & 0xff;
- data[1] = l >> 16 & 0xff;
- data[2] = l >> 8 & 0xff;
- data[3] = l & 0xff;
- data[4] = r >> 24 & 0xff;
- data[5] = r >> 16 & 0xff;
- data[6] = r >> 8 & 0xff;
- data[7] = r & 0xff;
- data += 8;
- }
-}
-
-#if __STDC__
-void
-blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
-#else
-void
-blf_cbc_encrypt(c, iv, data, len)
- blf_ctx *c;
- u_int8_t *iv;
- u_int8_t *data;
- u_int32_t len;
-#endif
-{
- u_int32_t l, r;
- u_int32_t i, j;
-
- for (i = 0; i < len; i += 8) {
- for (j = 0; j < 8; j++)
- data[j] ^= iv[j];
- l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
- r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
- Blowfish_encipher(c, &l, &r);
- data[0] = l >> 24 & 0xff;
- data[1] = l >> 16 & 0xff;
- data[2] = l >> 8 & 0xff;
- data[3] = l & 0xff;
- data[4] = r >> 24 & 0xff;
- data[5] = r >> 16 & 0xff;
- data[6] = r >> 8 & 0xff;
- data[7] = r & 0xff;
- iv = data;
- data += 8;
- }
-}
-
-#if __STDC__
-void
-blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
-#else
-void
-blf_cbc_decrypt(c, iva, data, len)
- blf_ctx *c;
- u_int8_t *iva;
- u_int8_t *data;
- u_int32_t len;
-#endif
-{
- u_int32_t l, r;
- u_int8_t *iv;
- u_int32_t i, j;
-
- iv = data + len - 16;
- data = data + len - 8;
- for (i = len - 8; i >= 8; i -= 8) {
- l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
- r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
- Blowfish_decipher(c, &l, &r);
- data[0] = l >> 24 & 0xff;
- data[1] = l >> 16 & 0xff;
- data[2] = l >> 8 & 0xff;
- data[3] = l & 0xff;
- data[4] = r >> 24 & 0xff;
- data[5] = r >> 16 & 0xff;
- data[6] = r >> 8 & 0xff;
- data[7] = r & 0xff;
- for (j = 0; j < 8; j++)
- data[j] ^= iv[j];
- iv -= 8;
- data -= 8;
- }
- l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
- r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
- Blowfish_decipher(c, &l, &r);
- data[0] = l >> 24 & 0xff;
- data[1] = l >> 16 & 0xff;
- data[2] = l >> 8 & 0xff;
- data[3] = l & 0xff;
- data[4] = r >> 24 & 0xff;
- data[5] = r >> 16 & 0xff;
- data[6] = r >> 8 & 0xff;
- data[7] = r & 0xff;
- for (j = 0; j < 8; j++)
- data[j] ^= iva[j];
-}
-
-#if 0
-void
-report(u_int32_t data[], u_int16_t len)
-{
- u_int16_t i;
- for (i = 0; i < len; i += 2)
- printf("Block %0hd: %08lx %08lx.\n",
- i / 2, data[i], data[i + 1]);
-}
-void
-main(void)
-{
-
- blf_ctx c;
- char key[] = "AAAAA";
- char key2[] = "abcdefghijklmnopqrstuvwxyz";
-
- u_int32_t data[10];
- u_int32_t data2[] =
- {0x424c4f57l, 0x46495348l};
-
- u_int16_t i;
-
- /* First test */
- for (i = 0; i < 10; i++)
- data[i] = i;
-
- blf_key(&c, (u_int8_t *) key, 5);
- blf_enc(&c, data, 5);
- blf_dec(&c, data, 1);
- blf_dec(&c, data + 2, 4);
- printf("Should read as 0 - 9.\n");
- report(data, 10);
-
- /* Second test */
- blf_key(&c, (u_int8_t *) key2, strlen(key2));
- blf_enc(&c, data2, 1);
- printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
- report(data2, 2);
- blf_dec(&c, data2, 1);
- report(data2, 2);
-}
-#endif
diff --git a/secure/lib/libcrypt/blowfish.h b/secure/lib/libcrypt/blowfish.h
deleted file mode 100644
index 12e60ccf4341..000000000000
--- a/secure/lib/libcrypt/blowfish.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Blowfish - a fast block cipher designed by Bruce Schneier
- *
- * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Niels Provos.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * FreeBSD implementation by Paul Herman <pherman@frenchfries.net>
- */
-
-#ifndef _BLF_H_
-#define _BLF_H_
-
-/* Schneier states the maximum key length to be 56 bytes.
- * The way how the subkeys are initalized by the key up
- * to (N+2)*4 i.e. 72 bytes are utilized.
- * Warning: For normal blowfish encryption only 56 bytes
- * of the key affect all cipherbits.
- */
-
-#define BLF_N 16 /* Number of Subkeys */
-#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
-
-/* Blowfish context */
-typedef struct BlowfishContext {
- u_int32_t S[4][256]; /* S-Boxes */
- u_int32_t P[BLF_N + 2]; /* Subkeys */
-} blf_ctx;
-
-/* Raw access to customized Blowfish
- * blf_key is just:
- * Blowfish_initstate( state )
- * Blowfish_expand0state( state, key, keylen )
- */
-
-void Blowfish_encipher __P((blf_ctx *, u_int32_t *, u_int32_t *));
-void Blowfish_decipher __P((blf_ctx *, u_int32_t *, u_int32_t *));
-void Blowfish_initstate __P((blf_ctx *));
-void Blowfish_expand0state __P((blf_ctx *, const u_int8_t *, u_int16_t));
-void Blowfish_expandstate
- __P((blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t));
-
-/* Standard Blowfish */
-
-void blf_key __P((blf_ctx *, const u_int8_t *, u_int16_t));
-void blf_enc __P((blf_ctx *, u_int32_t *, u_int16_t));
-void blf_dec __P((blf_ctx *, u_int32_t *, u_int16_t));
-
-void blf_ecb_encrypt __P((blf_ctx *, u_int8_t *, u_int32_t));
-void blf_ecb_decrypt __P((blf_ctx *, u_int8_t *, u_int32_t));
-
-void blf_cbc_encrypt __P((blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t));
-void blf_cbc_decrypt __P((blf_ctx *, u_int8_t *, u_int8_t *, u_int32_t));
-
-/* Converts u_int8_t to u_int32_t */
-u_int32_t Blowfish_stream2word __P((const u_int8_t *, u_int16_t , u_int16_t *));
-
-#endif
diff --git a/secure/lib/libcrypt/crypt-blowfish.c b/secure/lib/libcrypt/crypt-blowfish.c
deleted file mode 100644
index 6893da3416de..000000000000
--- a/secure/lib/libcrypt/crypt-blowfish.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Niels Provos.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/* This password hashing algorithm was designed by David Mazieres
- * <dm@lcs.mit.edu> and works as follows:
- *
- * 1. state := InitState ()
- * 2. state := ExpandKey (state, salt, password) 3.
- * REPEAT rounds:
- * state := ExpandKey (state, 0, salt)
- * state := ExpandKey(state, 0, password)
- * 4. ctext := "OrpheanBeholderScryDoubt"
- * 5. REPEAT 64:
- * ctext := Encrypt_ECB (state, ctext);
- * 6. RETURN Concatenate (salt, ctext);
- *
- */
-
-/*
- * FreeBSD implementation by Paul Herman <pherman@frenchfries.net>
- */
-
-#if 0
-#include <stdio.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <string.h>
-#include <pwd.h>
-#include "blowfish.h"
-
-/* This implementation is adaptable to current computing power.
- * You can have up to 2^31 rounds which should be enough for some
- * time to come.
- */
-
-#define BCRYPT_VERSION '2'
-#define BCRYPT_MAXSALT 16 /* Precomputation is just so nice */
-#define BCRYPT_BLOCKS 6 /* Ciphertext blocks */
-#define BCRYPT_MINROUNDS 16 /* we have log2(rounds) in salt */
-
-char *bcrypt_gensalt __P((u_int8_t));
-
-static void encode_salt __P((char *, u_int8_t *, u_int16_t, u_int8_t));
-static void encode_base64 __P((u_int8_t *, u_int8_t *, u_int16_t));
-static void decode_base64 __P((u_int8_t *, u_int16_t, u_int8_t *));
-
-static char encrypted[_PASSWORD_LEN];
-static char gsalt[BCRYPT_MAXSALT * 4 / 3 + 1];
-static char error[] = ":";
-
-const static u_int8_t Base64Code[] =
-"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
-const static u_int8_t index_64[128] =
-{
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 0, 1, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 255, 255,
- 255, 255, 255, 255, 255, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
- 255, 255, 255, 255, 255, 255, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 255, 255, 255, 255, 255
-};
-#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])
-
-#ifdef __STDC__
-static void
-decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data)
-#else
-static void
-decode_base64(buffer, len, data)
- u_int8_t *buffer;
- u_int16_t len;
- u_int8_t *data;
-#endif
-{
- u_int8_t *bp = buffer;
- u_int8_t *p = data;
- u_int8_t c1, c2, c3, c4;
- while (bp < buffer + len) {
- c1 = CHAR64(*p);
- c2 = CHAR64(*(p + 1));
-
- /* Invalid data */
- if (c1 == 255 || c2 == 255)
- break;
-
- *bp++ = (c1 << 2) | ((c2 & 0x30) >> 4);
- if (bp >= buffer + len)
- break;
-
- c3 = CHAR64(*(p + 2));
- if (c3 == 255)
- break;
-
- *bp++ = ((c2 & 0x0f) << 4) | ((c3 & 0x3c) >> 2);
- if (bp >= buffer + len)
- break;
-
- c4 = CHAR64(*(p + 3));
- if (c4 == 255)
- break;
- *bp++ = ((c3 & 0x03) << 6) | c4;
-
- p += 4;
- }
-}
-
-#ifdef __STDC__
-static void
-encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
-#else
-static void
-encode_salt(salt, csalt, clen, logr)
- char *salt;
- u_int8_t *csalt;
- u_int16_t clen;
- u_int8_t logr;
-#endif
-{
- salt[0] = '$';
- salt[1] = BCRYPT_VERSION;
- salt[2] = 'a';
- salt[3] = '$';
-
- snprintf(salt + 4, 4, "%2.2u$", logr);
-
- encode_base64((u_int8_t *) salt + 7, csalt, clen);
-}
-/* Generates a salt for this version of crypt.
- Since versions may change. Keeping this here
- seems sensible.
- */
-
-#ifdef __STDC__
-char *
-bcrypt_gensalt(u_int8_t log_rounds)
-#else
-char *
-bcrypt_gensalt(log_rounds)
- u_int8_t log_rounds;
-#endif
-{
- u_int8_t csalt[BCRYPT_MAXSALT];
- u_int16_t i;
- u_int32_t seed = 0;
-
- for (i = 0; i < BCRYPT_MAXSALT; i++) {
- if (i % 4 == 0)
- seed = arc4random();
- csalt[i] = seed & 0xff;
- seed = seed >> 8;
- }
-
- if (log_rounds < 4)
- log_rounds = 4;
-
- encode_salt(gsalt, csalt, BCRYPT_MAXSALT, log_rounds);
- return gsalt;
-}
-/* We handle $Vers$log2(NumRounds)$salt+passwd$
- i.e. $2$04$iwouldntknowwhattosayetKdJ6iFtacBqJdKe6aW7ou */
-
-char *
-crypt_blowfish(key, salt)
- const char *key;
- const char *salt;
-{
- blf_ctx state;
- u_int32_t rounds, i, k;
- u_int16_t j;
- u_int8_t key_len, salt_len, logr, minor;
- u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
- u_int8_t csalt[BCRYPT_MAXSALT];
- u_int32_t cdata[BCRYPT_BLOCKS];
- static char *magic = "$2a$04$";
-
- /* Defaults */
- minor = 'a';
- logr = 4;
- rounds = 1 << logr;
-
- /* If it starts with the magic string, then skip that */
- if(!strncmp(salt, magic, strlen(magic))) {
- salt += strlen(magic);
- }
- else if (*salt == '$') {
-
- /* Discard "$" identifier */
- salt++;
-
- if (*salt > BCRYPT_VERSION) {
- /* How do I handle errors ? Return ':' */
- return error;
- }
-
- /* Check for minor versions */
- if (salt[1] != '$') {
- switch (salt[1]) {
- case 'a':
- /* 'ab' should not yield the same as 'abab' */
- minor = salt[1];
- salt++;
- break;
- default:
- return error;
- }
- } else
- minor = 0;
-
- /* Discard version + "$" identifier */
- salt += 2;
-
- if (salt[2] != '$')
- /* Out of sync with passwd entry */
- return error;
-
- /* Computer power doesnt increase linear, 2^x should be fine */
- if ((rounds = (u_int32_t) 1 << (logr = atoi(salt))) < BCRYPT_MINROUNDS)
- return error;
-
- /* Discard num rounds + "$" identifier */
- salt += 3;
- }
-
-
- /* We dont want the base64 salt but the raw data */
- decode_base64(csalt, BCRYPT_MAXSALT, (u_int8_t *) salt);
- salt_len = BCRYPT_MAXSALT;
- key_len = strlen(key) + (minor >= 'a' ? 1 : 0);
-
- /* Setting up S-Boxes and Subkeys */
- Blowfish_initstate(&state);
- Blowfish_expandstate(&state, csalt, salt_len,
- (u_int8_t *) key, key_len);
- for (k = 0; k < rounds; k++) {
- Blowfish_expand0state(&state, (u_int8_t *) key, key_len);
- Blowfish_expand0state(&state, csalt, salt_len);
- }
-
- /* This can be precomputed later */
- j = 0;
- for (i = 0; i < BCRYPT_BLOCKS; i++)
- cdata[i] = Blowfish_stream2word(ciphertext, 4 * BCRYPT_BLOCKS, &j);
-
- /* Now do the encryption */
- for (k = 0; k < 64; k++)
- blf_enc(&state, cdata, BCRYPT_BLOCKS / 2);
-
- for (i = 0; i < BCRYPT_BLOCKS; i++) {
- ciphertext[4 * i + 3] = cdata[i] & 0xff;
- cdata[i] = cdata[i] >> 8;
- ciphertext[4 * i + 2] = cdata[i] & 0xff;
- cdata[i] = cdata[i] >> 8;
- ciphertext[4 * i + 1] = cdata[i] & 0xff;
- cdata[i] = cdata[i] >> 8;
- ciphertext[4 * i + 0] = cdata[i] & 0xff;
- }
-
-
- i = 0;
- encrypted[i++] = '$';
- encrypted[i++] = BCRYPT_VERSION;
- if (minor)
- encrypted[i++] = minor;
- encrypted[i++] = '$';
-
- snprintf(encrypted + i, 4, "%2.2u$", logr);
-
- encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT);
- encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext,
- 4 * BCRYPT_BLOCKS - 1);
- return encrypted;
-}
-
-#ifdef __STDC__
-static void
-encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
-#else
-static void
-encode_base64(buffer, data, len)
- u_int8_t *buffer;
- u_int8_t *data;
- u_int16_t len;
-#endif
-{
- u_int8_t *bp = buffer;
- u_int8_t *p = data;
- u_int8_t c1, c2;
- while (p < data + len) {
- c1 = *p++;
- *bp++ = Base64Code[(c1 >> 2)];
- c1 = (c1 & 0x03) << 4;
- if (p >= data + len) {
- *bp++ = Base64Code[c1];
- break;
- }
- c2 = *p++;
- c1 |= (c2 >> 4) & 0x0f;
- *bp++ = Base64Code[c1];
- c1 = (c2 & 0x0f) << 2;
- if (p >= data + len) {
- *bp++ = Base64Code[c1];
- break;
- }
- c2 = *p++;
- c1 |= (c2 >> 6) & 0x03;
- *bp++ = Base64Code[c1];
- *bp++ = Base64Code[c2 & 0x3f];
- }
- *bp = '\0';
-}
-#if 0
-void
-main()
-{
- char blubber[73];
- char salt[100];
- char *p;
- salt[0] = '$';
- salt[1] = BCRYPT_VERSION;
- salt[2] = '$';
-
- snprintf(salt + 3, 4, "%2.2u$", 5);
-
- printf("24 bytes of salt: ");
- fgets(salt + 6, 94, stdin);
- salt[99] = 0;
- printf("72 bytes of password: ");
- fpurge(stdin);
- fgets(blubber, 73, stdin);
- blubber[72] = 0;
-
- p = crypt(blubber, salt);
- printf("Passwd entry: %s\n\n", p);
-
- p = bcrypt_gensalt(5);
- printf("Generated salt: %s\n", p);
- p = crypt(blubber, p);
- printf("Passwd entry: %s\n", p);
-}
-#endif
diff --git a/secure/lib/libcrypt/crypt-des.c b/secure/lib/libcrypt/crypt-des.c
deleted file mode 100644
index 634a1ad9a569..000000000000
--- a/secure/lib/libcrypt/crypt-des.c
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * FreeSec: libcrypt for NetBSD
- *
- * Copyright (c) 1994 David Burren
- * All rights reserved.
- *
- * Adapted for FreeBSD-2.0 by Geoffrey M. Rehmet
- * this file should now *only* export crypt(), in order to make
- * binaries of libcrypt exportable from the USA
- *
- * Adapted for FreeBSD-4.0 by Mark R V Murray
- * this file should now *only* export crypt_des(), in order to make
- * a module that can be optionally included in libcrypt.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of other contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- *
- * This is an original implementation of the DES and the crypt(3) interfaces
- * by David Burren <davidb@werj.com.au>.
- *
- * An excellent reference on the underlying algorithm (and related
- * algorithms) is:
- *
- * B. Schneier, Applied Cryptography: protocols, algorithms,
- * and source code in C, John Wiley & Sons, 1994.
- *
- * Note that in that book's description of DES the lookups for the initial,
- * pbox, and final permutations are inverted (this has been brought to the
- * attention of the author). A list of errata for this book has been
- * posted to the sci.crypt newsgroup by the author and is available for FTP.
- *
- * ARCHITECTURE ASSUMPTIONS:
- * It is assumed that the 8-byte arrays passed by reference can be
- * addressed as arrays of u_int32_t's (ie. the CPU is not picky about
- * alignment).
- */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <pwd.h>
-#include <string.h>
-#include "crypt.h"
-
-/* We can't always assume gcc */
-#ifdef __GNUC__
-#define INLINE inline
-#endif
-
-
-static u_char IP[64] = {
- 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
- 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
- 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
- 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
-};
-
-static u_char inv_key_perm[64];
-static u_char u_key_perm[56];
-static u_char key_perm[56] = {
- 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
- 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
- 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
- 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
-};
-
-static u_char key_shifts[16] = {
- 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
-};
-
-static u_char inv_comp_perm[56];
-static u_char comp_perm[48] = {
- 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
- 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
- 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
- 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
-};
-
-/*
- * No E box is used, as it's replaced by some ANDs, shifts, and ORs.
- */
-
-static u_char u_sbox[8][64];
-static u_char sbox[8][64] = {
- {
- 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
- 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
- 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
- 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
- },
- {
- 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
- 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
- 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
- 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
- },
- {
- 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
- 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
- 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
- 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
- },
- {
- 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
- 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
- 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
- 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
- },
- {
- 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
- 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
- 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
- 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
- },
- {
- 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
- 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
- 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
- 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
- },
- {
- 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
- 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
- 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
- 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
- },
- {
- 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
- 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
- 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
- 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
- }
-};
-
-static u_char un_pbox[32];
-static u_char pbox[32] = {
- 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
- 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
-};
-
-static u_int32_t bits32[32] =
-{
- 0x80000000, 0x40000000, 0x20000000, 0x10000000,
- 0x08000000, 0x04000000, 0x02000000, 0x01000000,
- 0x00800000, 0x00400000, 0x00200000, 0x00100000,
- 0x00080000, 0x00040000, 0x00020000, 0x00010000,
- 0x00008000, 0x00004000, 0x00002000, 0x00001000,
- 0x00000800, 0x00000400, 0x00000200, 0x00000100,
- 0x00000080, 0x00000040, 0x00000020, 0x00000010,
- 0x00000008, 0x00000004, 0x00000002, 0x00000001
-};
-
-static u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
-
-static u_int32_t saltbits;
-static long old_salt;
-static u_int32_t *bits28, *bits24;
-static u_char init_perm[64], final_perm[64];
-static u_int32_t en_keysl[16], en_keysr[16];
-static u_int32_t de_keysl[16], de_keysr[16];
-static int des_initialised = 0;
-static u_char m_sbox[4][4096];
-static u_int32_t psbox[4][256];
-static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
-static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
-static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
-static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
-static u_int32_t old_rawkey0, old_rawkey1;
-
-static u_char ascii64[] =
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-/* 0000000000111111111122222222223333333333444444444455555555556666 */
-/* 0123456789012345678901234567890123456789012345678901234567890123 */
-
-static INLINE int
-ascii_to_bin(char ch)
-{
- if (ch > 'z')
- return(0);
- if (ch >= 'a')
- return(ch - 'a' + 38);
- if (ch > 'Z')
- return(0);
- if (ch >= 'A')
- return(ch - 'A' + 12);
- if (ch > '9')
- return(0);
- if (ch >= '.')
- return(ch - '.');
- return(0);
-}
-
-static void
-des_init()
-{
- int i, j, b, k, inbit, obit;
- u_int32_t *p, *il, *ir, *fl, *fr;
-
- old_rawkey0 = old_rawkey1 = 0L;
- saltbits = 0L;
- old_salt = 0L;
- bits24 = (bits28 = bits32 + 4) + 4;
-
- /*
- * Invert the S-boxes, reordering the input bits.
- */
- for (i = 0; i < 8; i++)
- for (j = 0; j < 64; j++) {
- b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
- u_sbox[i][j] = sbox[i][b];
- }
-
- /*
- * Convert the inverted S-boxes into 4 arrays of 8 bits.
- * Each will handle 12 bits of the S-box input.
- */
- for (b = 0; b < 4; b++)
- for (i = 0; i < 64; i++)
- for (j = 0; j < 64; j++)
- m_sbox[b][(i << 6) | j] =
- (u_sbox[(b << 1)][i] << 4) |
- u_sbox[(b << 1) + 1][j];
-
- /*
- * Set up the initial & final permutations into a useful form, and
- * initialise the inverted key permutation.
- */
- for (i = 0; i < 64; i++) {
- init_perm[final_perm[i] = IP[i] - 1] = i;
- inv_key_perm[i] = 255;
- }
-
- /*
- * Invert the key permutation and initialise the inverted key
- * compression permutation.
- */
- for (i = 0; i < 56; i++) {
- u_key_perm[i] = key_perm[i] - 1;
- inv_key_perm[key_perm[i] - 1] = i;
- inv_comp_perm[i] = 255;
- }
-
- /*
- * Invert the key compression permutation.
- */
- for (i = 0; i < 48; i++) {
- inv_comp_perm[comp_perm[i] - 1] = i;
- }
-
- /*
- * Set up the OR-mask arrays for the initial and final permutations,
- * and for the key initial and compression permutations.
- */
- for (k = 0; k < 8; k++) {
- for (i = 0; i < 256; i++) {
- *(il = &ip_maskl[k][i]) = 0L;
- *(ir = &ip_maskr[k][i]) = 0L;
- *(fl = &fp_maskl[k][i]) = 0L;
- *(fr = &fp_maskr[k][i]) = 0L;
- for (j = 0; j < 8; j++) {
- inbit = 8 * k + j;
- if (i & bits8[j]) {
- if ((obit = init_perm[inbit]) < 32)
- *il |= bits32[obit];
- else
- *ir |= bits32[obit-32];
- if ((obit = final_perm[inbit]) < 32)
- *fl |= bits32[obit];
- else
- *fr |= bits32[obit - 32];
- }
- }
- }
- for (i = 0; i < 128; i++) {
- *(il = &key_perm_maskl[k][i]) = 0L;
- *(ir = &key_perm_maskr[k][i]) = 0L;
- for (j = 0; j < 7; j++) {
- inbit = 8 * k + j;
- if (i & bits8[j + 1]) {
- if ((obit = inv_key_perm[inbit]) == 255)
- continue;
- if (obit < 28)
- *il |= bits28[obit];
- else
- *ir |= bits28[obit - 28];
- }
- }
- *(il = &comp_maskl[k][i]) = 0L;
- *(ir = &comp_maskr[k][i]) = 0L;
- for (j = 0; j < 7; j++) {
- inbit = 7 * k + j;
- if (i & bits8[j + 1]) {
- if ((obit=inv_comp_perm[inbit]) == 255)
- continue;
- if (obit < 24)
- *il |= bits24[obit];
- else
- *ir |= bits24[obit - 24];
- }
- }
- }
- }
-
- /*
- * Invert the P-box permutation, and convert into OR-masks for
- * handling the output of the S-box arrays setup above.
- */
- for (i = 0; i < 32; i++)
- un_pbox[pbox[i] - 1] = i;
-
- for (b = 0; b < 4; b++)
- for (i = 0; i < 256; i++) {
- *(p = &psbox[b][i]) = 0L;
- for (j = 0; j < 8; j++) {
- if (i & bits8[j])
- *p |= bits32[un_pbox[8 * b + j]];
- }
- }
-
- des_initialised = 1;
-}
-
-static void
-setup_salt(long salt)
-{
- u_int32_t obit, saltbit;
- int i;
-
- if (salt == old_salt)
- return;
- old_salt = salt;
-
- saltbits = 0L;
- saltbit = 1;
- obit = 0x800000;
- for (i = 0; i < 24; i++) {
- if (salt & saltbit)
- saltbits |= obit;
- saltbit <<= 1;
- obit >>= 1;
- }
-}
-
-static int
-des_setkey(const char *key)
-{
- u_int32_t k0, k1, rawkey0, rawkey1;
- int shifts, round;
-
- if (!des_initialised)
- des_init();
-
- rawkey0 = ntohl(*(u_int32_t *) key);
- rawkey1 = ntohl(*(u_int32_t *) (key + 4));
-
- if ((rawkey0 | rawkey1)
- && rawkey0 == old_rawkey0
- && rawkey1 == old_rawkey1) {
- /*
- * Already setup for this key.
- * This optimisation fails on a zero key (which is weak and
- * has bad parity anyway) in order to simplify the starting
- * conditions.
- */
- return(0);
- }
- old_rawkey0 = rawkey0;
- old_rawkey1 = rawkey1;
-
- /*
- * Do key permutation and split into two 28-bit subkeys.
- */
- k0 = key_perm_maskl[0][rawkey0 >> 25]
- | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
- | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
- | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
- | key_perm_maskl[4][rawkey1 >> 25]
- | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
- | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
- | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
- k1 = key_perm_maskr[0][rawkey0 >> 25]
- | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
- | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
- | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
- | key_perm_maskr[4][rawkey1 >> 25]
- | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
- | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
- | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
- /*
- * Rotate subkeys and do compression permutation.
- */
- shifts = 0;
- for (round = 0; round < 16; round++) {
- u_int32_t t0, t1;
-
- shifts += key_shifts[round];
-
- t0 = (k0 << shifts) | (k0 >> (28 - shifts));
- t1 = (k1 << shifts) | (k1 >> (28 - shifts));
-
- de_keysl[15 - round] =
- en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
- | comp_maskl[1][(t0 >> 14) & 0x7f]
- | comp_maskl[2][(t0 >> 7) & 0x7f]
- | comp_maskl[3][t0 & 0x7f]
- | comp_maskl[4][(t1 >> 21) & 0x7f]
- | comp_maskl[5][(t1 >> 14) & 0x7f]
- | comp_maskl[6][(t1 >> 7) & 0x7f]
- | comp_maskl[7][t1 & 0x7f];
-
- de_keysr[15 - round] =
- en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
- | comp_maskr[1][(t0 >> 14) & 0x7f]
- | comp_maskr[2][(t0 >> 7) & 0x7f]
- | comp_maskr[3][t0 & 0x7f]
- | comp_maskr[4][(t1 >> 21) & 0x7f]
- | comp_maskr[5][(t1 >> 14) & 0x7f]
- | comp_maskr[6][(t1 >> 7) & 0x7f]
- | comp_maskr[7][t1 & 0x7f];
- }
- return(0);
-}
-
-static int
-do_des( u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, int count)
-{
- /*
- * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
- */
- u_int32_t l, r, *kl, *kr, *kl1, *kr1;
- u_int32_t f, r48l, r48r;
- int round;
-
- if (count == 0) {
- return(1);
- } else if (count > 0) {
- /*
- * Encrypting
- */
- kl1 = en_keysl;
- kr1 = en_keysr;
- } else {
- /*
- * Decrypting
- */
- count = -count;
- kl1 = de_keysl;
- kr1 = de_keysr;
- }
-
- /*
- * Do initial permutation (IP).
- */
- l = ip_maskl[0][l_in >> 24]
- | ip_maskl[1][(l_in >> 16) & 0xff]
- | ip_maskl[2][(l_in >> 8) & 0xff]
- | ip_maskl[3][l_in & 0xff]
- | ip_maskl[4][r_in >> 24]
- | ip_maskl[5][(r_in >> 16) & 0xff]
- | ip_maskl[6][(r_in >> 8) & 0xff]
- | ip_maskl[7][r_in & 0xff];
- r = ip_maskr[0][l_in >> 24]
- | ip_maskr[1][(l_in >> 16) & 0xff]
- | ip_maskr[2][(l_in >> 8) & 0xff]
- | ip_maskr[3][l_in & 0xff]
- | ip_maskr[4][r_in >> 24]
- | ip_maskr[5][(r_in >> 16) & 0xff]
- | ip_maskr[6][(r_in >> 8) & 0xff]
- | ip_maskr[7][r_in & 0xff];
-
- while (count--) {
- /*
- * Do each round.
- */
- kl = kl1;
- kr = kr1;
- round = 16;
- while (round--) {
- /*
- * Expand R to 48 bits (simulate the E-box).
- */
- r48l = ((r & 0x00000001) << 23)
- | ((r & 0xf8000000) >> 9)
- | ((r & 0x1f800000) >> 11)
- | ((r & 0x01f80000) >> 13)
- | ((r & 0x001f8000) >> 15);
-
- r48r = ((r & 0x0001f800) << 7)
- | ((r & 0x00001f80) << 5)
- | ((r & 0x000001f8) << 3)
- | ((r & 0x0000001f) << 1)
- | ((r & 0x80000000) >> 31);
- /*
- * Do salting for crypt() and friends, and
- * XOR with the permuted key.
- */
- f = (r48l ^ r48r) & saltbits;
- r48l ^= f ^ *kl++;
- r48r ^= f ^ *kr++;
- /*
- * Do sbox lookups (which shrink it back to 32 bits)
- * and do the pbox permutation at the same time.
- */
- f = psbox[0][m_sbox[0][r48l >> 12]]
- | psbox[1][m_sbox[1][r48l & 0xfff]]
- | psbox[2][m_sbox[2][r48r >> 12]]
- | psbox[3][m_sbox[3][r48r & 0xfff]];
- /*
- * Now that we've permuted things, complete f().
- */
- f ^= l;
- l = r;
- r = f;
- }
- r = l;
- l = f;
- }
- /*
- * Do final permutation (inverse of IP).
- */
- *l_out = fp_maskl[0][l >> 24]
- | fp_maskl[1][(l >> 16) & 0xff]
- | fp_maskl[2][(l >> 8) & 0xff]
- | fp_maskl[3][l & 0xff]
- | fp_maskl[4][r >> 24]
- | fp_maskl[5][(r >> 16) & 0xff]
- | fp_maskl[6][(r >> 8) & 0xff]
- | fp_maskl[7][r & 0xff];
- *r_out = fp_maskr[0][l >> 24]
- | fp_maskr[1][(l >> 16) & 0xff]
- | fp_maskr[2][(l >> 8) & 0xff]
- | fp_maskr[3][l & 0xff]
- | fp_maskr[4][r >> 24]
- | fp_maskr[5][(r >> 16) & 0xff]
- | fp_maskr[6][(r >> 8) & 0xff]
- | fp_maskr[7][r & 0xff];
- return(0);
-}
-
-static int
-des_cipher(const char *in, char *out, long salt, int count)
-{
- u_int32_t l_out, r_out, rawl, rawr;
- int retval;
-
- if (!des_initialised)
- des_init();
-
- setup_salt(salt);
-
- rawl = ntohl(*((u_int32_t *) in)++);
- rawr = ntohl(*((u_int32_t *) in));
-
- retval = do_des(rawl, rawr, &l_out, &r_out, count);
-
- *((u_int32_t *) out)++ = htonl(l_out);
- *((u_int32_t *) out) = htonl(r_out);
- return(retval);
-}
-
-char *
-crypt_des(const char *key, const char *setting)
-{
- int i;
- u_int32_t count, salt, l, r0, r1, keybuf[2];
- u_char *p, *q;
- static u_char output[21];
-
- if (!des_initialised)
- des_init();
-
-
- /*
- * Copy the key, shifting each character up by one bit
- * and padding with zeros.
- */
- q = (u_char *) keybuf;
- while (q - (u_char *) keybuf - 8) {
- if ((*q++ = *key << 1))
- key++;
- }
- if (des_setkey((u_char *) keybuf))
- return(NULL);
-
- if (*setting == _PASSWORD_EFMT1) {
- /*
- * "new"-style:
- * setting - underscore, 4 bytes of count, 4 bytes of salt
- * key - unlimited characters
- */
- for (i = 1, count = 0L; i < 5; i++)
- count |= ascii_to_bin(setting[i]) << (i - 1) * 6;
-
- for (i = 5, salt = 0L; i < 9; i++)
- salt |= ascii_to_bin(setting[i]) << (i - 5) * 6;
-
- while (*key) {
- /*
- * Encrypt the key with itself.
- */
- if (des_cipher((u_char*)keybuf, (u_char*)keybuf, 0L, 1))
- return(NULL);
- /*
- * And XOR with the next 8 characters of the key.
- */
- q = (u_char *) keybuf;
- while (q - (u_char *) keybuf - 8 && *key)
- *q++ ^= *key++ << 1;
-
- if (des_setkey((u_char *) keybuf))
- return(NULL);
- }
- strncpy(output, setting, 9);
-
- /*
- * Double check that we weren't given a short setting.
- * If we were, the above code will probably have created
- * wierd values for count and salt, but we don't really care.
- * Just make sure the output string doesn't have an extra
- * NUL in it.
- */
- output[9] = '\0';
- p = output + strlen(output);
- } else {
- /*
- * "old"-style:
- * setting - 2 bytes of salt
- * key - up to 8 characters
- */
- count = 25;
-
- salt = (ascii_to_bin(setting[1]) << 6)
- | ascii_to_bin(setting[0]);
-
- output[0] = setting[0];
- /*
- * If the encrypted password that the salt was extracted from
- * is only 1 character long, the salt will be corrupted. We
- * need to ensure that the output string doesn't have an extra
- * NUL in it!
- */
- output[1] = setting[1] ? setting[1] : output[0];
-
- p = output + 2;
- }
- setup_salt(salt);
- /*
- * Do it.
- */
- if (do_des(0L, 0L, &r0, &r1, count))
- return(NULL);
- /*
- * Now encode the result...
- */
- l = (r0 >> 8);
- *p++ = ascii64[(l >> 18) & 0x3f];
- *p++ = ascii64[(l >> 12) & 0x3f];
- *p++ = ascii64[(l >> 6) & 0x3f];
- *p++ = ascii64[l & 0x3f];
-
- l = (r0 << 16) | ((r1 >> 16) & 0xffff);
- *p++ = ascii64[(l >> 18) & 0x3f];
- *p++ = ascii64[(l >> 12) & 0x3f];
- *p++ = ascii64[(l >> 6) & 0x3f];
- *p++ = ascii64[l & 0x3f];
-
- l = r1 << 2;
- *p++ = ascii64[(l >> 12) & 0x3f];
- *p++ = ascii64[(l >> 6) & 0x3f];
- *p++ = ascii64[l & 0x3f];
- *p = 0;
-
- return(output);
-}
diff --git a/secure/lib/libcrypto/Makefile b/secure/lib/libcrypto/Makefile
deleted file mode 100644
index c56c005e9a53..000000000000
--- a/secure/lib/libcrypto/Makefile
+++ /dev/null
@@ -1,402 +0,0 @@
-# $FreeBSD$
-
-.include "Makefile.inc"
-
-.PATH: ${LCRYPTO_SRC} ${LCRYPTO_SRC}/asn1 ${LCRYPTO_SRC}/bf \
- ${LCRYPTO_SRC}/bio ${LCRYPTO_SRC}/bn ${LCRYPTO_SRC}/buffer \
- ${LCRYPTO_SRC}/cast ${LCRYPTO_SRC}/comp ${LCRYPTO_SRC}/conf \
- ${LCRYPTO_SRC}/des ${LCRYPTO_SRC}/dh ${LCRYPTO_SRC}/dsa \
- ${LCRYPTO_SRC}/dso ${LCRYPTO_SRC}/err ${LCRYPTO_SRC}/evp \
- ${LCRYPTO_SRC}/hmac ${LCRYPTO_SRC}/lhash ${LCRYPTO_SRC}/md2 \
- ${LCRYPTO_SRC}/md4 ${LCRYPTO_SRC}/md5 ${LCRYPTO_SRC}/mdc2 \
- ${LCRYPTO_SRC}/objects ${LCRYPTO_SRC}/pem ${LCRYPTO_SRC}/pkcs7 \
- ${LCRYPTO_SRC}/pkcs12 ${LCRYPTO_SRC}/rand ${LCRYPTO_SRC}/rc2 \
- ${LCRYPTO_SRC}/rc4 ${LCRYPTO_SRC}/rc5 ${LCRYPTO_SRC}/ripemd \
- ${LCRYPTO_SRC}/rsa ${LCRYPTO_SRC}/../rsaref ${LCRYPTO_SRC}/sha \
- ${LCRYPTO_SRC}/stack ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}/x509 \
- ${LCRYPTO_SRC}/x509v3
-
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-.PATH: ${LCRYPTO_SRC}/rc4/asm ${LCRYPTO_SRC}/rc5/asm \
- ${LCRYPTO_SRC}/des/asm ${LCRYPTO_SRC}/cast/asm \
- ${LCRYPTO_SRC}/sha/asm ${LCRYPTO_SRC}/bn/asm \
- ${LCRYPTO_SRC}/bf/asm ${LCRYPTO_SRC}/md5/asm \
- ${LCRYPTO_SRC}/ripemd/asm
-PERLPATH= ${LCRYPTO_SRC}/des/asm:${LCRYPTO_SRC}/perlasm
-.endif
-
-.if defined(MAKE_IDEA) && ${MAKE_IDEA} == YES
-.PATH: ${LCRYPTO_SRC}/idea
-.endif
-
-LIB= crypto
-SHLIB_MAJOR= 2
-
-MAINTAINER= kris
-
-# base sources
-SRCS+= cpt_err.c cryptlib.c cversion.c ebcdic.c ex_data.c mem.c mem_dbg.c \
- tmdiff.c uid.c
-
-# asn1
-
-SRCS+= a_bitstr.c a_bmp.c a_bool.c a_bytes.c a_d2i_fp.c a_digest.c \
- a_dup.c a_enum.c a_gentm.c a_hdr.c a_i2d_fp.c a_int.c \
- a_mbstr.c a_meth.c a_null.c a_object.c a_octet.c a_print.c \
- a_set.c a_sign.c a_strex.c a_strnid.c a_time.c a_type.c \
- a_utctm.c a_utf8.c a_verify.c a_vis.c asn1_err.c asn1_lib.c \
- asn1_par.c asn_pack.c d2i_dhp.c d2i_dsap.c d2i_pr.c d2i_pu.c \
- d2i_r_pr.c d2i_r_pu.c d2i_s_pr.c d2i_s_pu.c evp_asn1.c \
- f_enum.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c i2d_pr.c \
- i2d_pu.c i2d_r_pr.c i2d_r_pu.c i2d_s_pr.c i2d_s_pu.c n_pkey.c \
- nsseq.c p5_pbe.c p5_pbev2.c p7_dgst.c p7_enc.c p7_enc_c.c \
- p7_evp.c p7_i_s.c p7_lib.c p7_recip.c p7_s_e.c p7_signd.c \
- p7_signi.c p8_pkey.c t_bitst.c t_crl.c t_pkey.c t_req.c \
- t_spki.c t_x509.c t_x509a.c x_algor.c x_attrib.c x_cinf.c \
- x_crl.c x_exten.c x_info.c x_name.c x_pkey.c x_pubkey.c \
- x_req.c x_sig.c x_spki.c x_val.c x_x509.c x_x509a.c
-
-# blowfish
-SRCS+= bf_cfb64.c bf_ecb.c bf_ofb64.c bf_skey.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-.if ${MACHINE_CPU:Mi686}
-SRCS+= bf-686.pl
-.else
-SRCS+= bf-586.pl
-.endif
-.else
-SRCS+= bf_enc.c
-.endif
-
-# bio
-SRCS+= b_dump.c b_print.c b_sock.c bf_buff.c bf_nbio.c bf_null.c \
- bio_cb.c bio_err.c bio_lib.c bss_acpt.c bss_bio.c bss_conn.c \
- bss_fd.c bss_file.c bss_log.c bss_mem.c bss_null.c bss_sock.c
-
-# bn
-
-SRCS+= bn_add.c bn_blind.c bn_ctx.c bn_div.c bn_err.c \
- bn_exp.c bn_exp2.c bn_gcd.c bn_lib.c bn_mont.c bn_mpi.c \
- bn_mul.c bn_prime.c bn_print.c bn_rand.c bn_recp.c bn_shift.c \
- bn_sqr.c bn_word.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= bn-586.pl co-586.pl
-.else
-SRCS+= bn_asm.c
-.endif
-
-# buffer
-SRCS+= buf_err.c buffer.c
-
-# cast
-SRCS+= c_cfb64.c c_ecb.c c_ofb64.c c_skey.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= cast-586.pl
-.else
-SRCS+= c_enc.c
-.endif
-
-# comp
-SRCS+= c_rle.c c_zlib.c comp_lib.c
-
-# conf
-SRCS+= conf_api.c conf_def.c conf_err.c conf_lib.c
-
-# des
-SRCS+= cbc_cksm.c cbc_enc.c cfb64ede.c cfb64enc.c cfb_enc.c \
- ecb3_enc.c ecb_enc.c ede_cbcm_enc.c enc_read.c enc_writ.c \
- fcrypt.c ofb64ede.c ofb64enc.c ofb_enc.c pcbc_enc.c \
- qud_cksm.c rand_key.c read2pwd.c read_pwd.c rpc_enc.c \
- set_key.c str2key.c xcbc_enc.c rnd_keys.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= des-586.pl crypt586.pl
-.else
-SRCS+= des_enc.c fcrypt_b.c
-.endif
-
-# dh
-SRCS+= dh_check.c dh_err.c dh_gen.c dh_key.c dh_lib.c
-
-# dsa
-SRCS+= dsa_asn1.c dsa_err.c dsa_gen.c dsa_key.c dsa_lib.c dsa_ossl.c \
- dsa_sign.c dsa_vrf.c
-
-# dso
-SRCS+= dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c \
- dso_openssl.c
-
-# err
-SRCS+= err.c err_all.c err_prn.c
-
-# evp
-SRCS+= bio_b64.c bio_enc.c bio_md.c bio_ok.c c_all.c c_allc.c c_alld.c \
- digest.c e_bf.c e_cast.c e_des.c e_des3.c e_idea.c e_null.c \
- e_rc2.c e_rc4.c e_rc5.c e_xcbc_d.c encode.c evp_enc.c \
- evp_err.c evp_key.c evp_lib.c evp_pbe.c evp_pkey.c m_dss.c \
- m_dss1.c m_md2.c m_md4.c m_md5.c m_mdc2.c m_null.c m_ripemd.c \
- m_sha.c m_sha1.c names.c p5_crpt.c p5_crpt2.c p_dec.c p_enc.c \
- p_lib.c p_open.c p_seal.c p_sign.c p_verify.c
-
-# hmac
-SRCS+= hmac.c
-
-# idea
-.if defined(MAKE_IDEA) && ${MAKE_IDEA} == YES
-SRCS+= i_ecb.c i_cbc.c i_cfb64.c i_ofb64.c i_skey.c
-.endif
-
-# lhash
-SRCS+= lh_stats.c lhash.c
-
-# md2
-SRCS+= md2_dgst.c md2_one.c
-
-# md4
-SRCS+= md4_dgst.c md4_one.c
-
-# md5
-SRCS+= md5_dgst.c md5_one.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= md5-586.pl
-.endif
-
-# mdc2
-SRCS+= mdc2dgst.c mdc2_one.c
-
-# objects
-SRCS+= o_names.c obj_dat.c obj_err.c obj_lib.c
-
-# pem
-SRCS+= pem_all.c pem_err.c pem_info.c pem_lib.c pem_seal.c pem_sign.c
-
-# pkcs7
-SRCS+= pk7_attr.c pk7_doit.c pk7_lib.c pk7_mime.c pk7_smime.c pkcs7err.c
-
-# pkcs12
-SRCS+= p12_add.c p12_attr.c p12_bags.c p12_crpt.c p12_crt.c p12_decr.c \
- p12_init.c p12_key.c p12_kiss.c p12_lib.c p12_mac.c p12_mutl.c \
- p12_npas.c p12_sbag.c p12_utl.c pk12err.c
-
-# rand
-SRCS+= md_rand.c rand_egd.c rand_err.c rand_lib.c rand_win.c randfile.c
-
-# rc2
-SRCS+= rc2_cbc.c rc2cfb64.c rc2_ecb.c rc2ofb64.c rc2_skey.c
-
-# rc4
-SRCS+= rc4_skey.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= rc4-586.pl
-.else
-SRCS+= rc4_enc.c
-.endif
-
-# rc5
-SRCS+= rc5cfb64.c rc5_ecb.c rc5ofb64.c rc5_skey.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= rc5-586.pl
-.else
-SRCS+= rc5_enc.c
-.endif
-
-# ripemd
-SRCS+= rmd_dgst.c rmd_one.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= rmd-586.pl
-.endif
-
-# rsa
-.if defined(WITH_RSA) && ${WITH_RSA} == YES
-SRCS+= rsa_chk.c rsa_eay.c rsa_err.c rsa_gen.c rsa_lib.c rsa_none.c \
- rsa_null.c rsa_oaep.c rsa_pk1.c rsa_saos.c rsa_sign.c rsa_ssl.c
-.endif
-
-# sha
-SRCS+= sha_dgst.c sha_one.c sha1_one.c sha1dgst.c
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-SRCS+= sha1-586.pl
-.endif
-
-# stack
-SRCS+= stack.c
-
-# txt_db
-SRCS+= txt_db.c
-
-# x509
-SRCS+= by_dir.c by_file.c x509_att.c x509_cmp.c x509_d2.c x509_def.c \
- x509_err.c x509_ext.c x509_lu.c x509_obj.c x509_r2x.c \
- x509_req.c x509_set.c x509_trs.c x509_txt.c x509_v3.c \
- x509_vfy.c x509name.c x509rset.c x509spki.c x509type.c x_all.c
-# x509v3
-SRCS+= v3_akey.c v3_alt.c v3_bcons.c v3_bitst.c v3_conf.c v3_cpols.c \
- v3_crld.c v3_enum.c v3_extku.c v3_genn.c v3_ia5.c v3_info.c \
- v3_int.c v3_lib.c v3_pku.c v3_prn.c v3_purp.c v3_skey.c \
- v3_sxnet.c v3_utl.c v3err.c
-
-POD1+= apps/CA.pl.pod apps/asn1parse.pod apps/ca.pod \
- apps/ciphers.pod apps/crl.pod \
- apps/crl2pkcs7.pod apps/dgst.pod apps/dhparam.pod apps/dsa.pod \
- apps/dsaparam.pod apps/enc.pod apps/gendsa.pod apps/genrsa.pod \
- apps/nseq.pod apps/openssl.pod apps/passwd.pod apps/pkcs12.pod \
- apps/pkcs7.pod apps/pkcs8.pod apps/rand.pod apps/req.pod \
- apps/rsa.pod apps/rsautl.pod apps/s_client.pod \
- apps/s_server.pod apps/sess_id.pod apps/smime.pod \
- apps/speed.pod apps/spkac.pod apps/verify.pod apps/version.pod \
- apps/x509.pod
-
-POD3+= crypto/BIO_ctrl.pod crypto/BIO_f_base64.pod \
- crypto/BIO_f_buffer.pod crypto/BIO_f_cipher.pod \
- crypto/BIO_f_md.pod crypto/BIO_f_null.pod crypto/BIO_f_ssl.pod \
- crypto/BIO_find_type.pod crypto/BIO_new.pod \
- crypto/BIO_new_bio_pair.pod crypto/BIO_push.pod \
- crypto/BIO_read.pod crypto/BIO_s_accept.pod \
- crypto/BIO_s_bio.pod crypto/BIO_s_connect.pod \
- crypto/BIO_s_fd.pod crypto/BIO_s_file.pod crypto/BIO_s_mem.pod \
- crypto/BIO_s_null.pod crypto/BIO_s_socket.pod \
- crypto/BIO_set_callback.pod crypto/BIO_should_retry.pod \
- crypto/BN_CTX_new.pod crypto/BN_CTX_start.pod \
- crypto/BN_add.pod crypto/BN_add_word.pod crypto/BN_bn2bin.pod \
- crypto/BN_cmp.pod crypto/BN_copy.pod \
- crypto/BN_generate_prime.pod crypto/BN_mod_inverse.pod \
- crypto/BN_mod_mul_montgomery.pod \
- crypto/BN_mod_mul_reciprocal.pod crypto/BN_new.pod \
- crypto/BN_num_bytes.pod crypto/BN_rand.pod \
- crypto/BN_set_bit.pod crypto/BN_zero.pod \
- crypto/CRYPTO_set_ex_data.pod crypto/DH_generate_key.pod \
- crypto/DH_generate_parameters.pod \
- crypto/DH_get_ex_new_index.pod crypto/DH_new.pod \
- crypto/DH_set_method.pod crypto/DH_size.pod \
- crypto/DSA_SIG_new.pod crypto/DSA_do_sign.pod \
- crypto/DSA_dup_DH.pod crypto/DSA_generate_key.pod \
- crypto/DSA_generate_parameters.pod \
- crypto/DSA_get_ex_new_index.pod crypto/DSA_new.pod \
- crypto/DSA_set_method.pod crypto/DSA_sign.pod \
- crypto/DSA_size.pod crypto/ERR_GET_LIB.pod \
- crypto/ERR_clear_error.pod crypto/ERR_error_string.pod \
- crypto/ERR_get_error.pod crypto/ERR_load_crypto_strings.pod \
- crypto/ERR_load_strings.pod crypto/ERR_print_errors.pod \
- crypto/ERR_put_error.pod crypto/ERR_remove_state.pod \
- crypto/EVP_DigestInit.pod crypto/EVP_EncryptInit.pod \
- crypto/EVP_OpenInit.pod crypto/EVP_SealInit.pod \
- crypto/EVP_SignInit.pod crypto/EVP_VerifyInit.pod \
- crypto/OPENSSL_VERSION_NUMBER.pod \
- crypto/OpenSSL_add_all_algorithms.pod crypto/RAND_add.pod \
- crypto/RAND_bytes.pod crypto/RAND_cleanup.pod \
- crypto/RAND_egd.pod crypto/RAND_load_file.pod \
- crypto/RAND_set_rand_method.pod crypto/RSA_blinding_on.pod \
- crypto/RSA_check_key.pod crypto/RSA_generate_key.pod \
- crypto/RSA_get_ex_new_index.pod crypto/RSA_new.pod \
- crypto/RSA_padding_add_PKCS1_type_1.pod crypto/RSA_print.pod \
- crypto/RSA_private_encrypt.pod crypto/RSA_public_encrypt.pod \
- crypto/RSA_set_method.pod crypto/RSA_sign.pod \
- crypto/RSA_sign_ASN1_OCTET_STRING.pod crypto/RSA_size.pod \
- crypto/bio.pod crypto/blowfish.pod crypto/bn.pod \
- crypto/bn_internal.pod crypto/buffer.pod crypto/crypto.pod \
- crypto/d2i_DHparams.pod crypto/d2i_RSAPublicKey.pod \
- crypto/des.pod crypto/des_modes.pod crypto/dh.pod \
- crypto/dsa.pod crypto/err.pod crypto/evp.pod crypto/hmac.pod \
- crypto/lh_stats.pod crypto/lhash.pod crypto/md5.pod \
- crypto/mdc2.pod crypto/rand.pod crypto/rc4.pod \
- crypto/ripemd.pod crypto/rsa.pod crypto/sha.pod \
- crypto/threads.pod
-
-POD3+= ssl/SSL_CIPHER_get_name.pod \
- ssl/SSL_CTX_add_extra_chain_cert.pod \
- ssl/SSL_CTX_add_session.pod ssl/SSL_CTX_flush_sessions.pod \
- ssl/SSL_CTX_free.pod ssl/SSL_CTX_get_ex_new_index.pod \
- ssl/SSL_CTX_get_verify_mode.pod \
- ssl/SSL_CTX_load_verify_locations.pod ssl/SSL_CTX_new.pod \
- ssl/SSL_CTX_sess_set_cache_size.pod ssl/SSL_CTX_sess_set_get_cb.pod \
- ssl/SSL_CTX_sessions.pod ssl/SSL_CTX_set_cipher_list.pod \
- ssl/SSL_CTX_set_client_CA_list.pod \
- ssl/SSL_CTX_set_client_cert_cb.pod \
- ssl/SSL_CTX_set_default_passwd_cb.pod ssl/SSL_CTX_set_options.pod\
- ssl/SSL_CTX_set_session_cache_mode.pod \
- ssl/SSL_CTX_set_session_id_context.pod \
- ssl/SSL_CTX_set_ssl_version.pod \
- ssl/SSL_CTX_set_timeout.pod ssl/SSL_CTX_set_verify.pod \
- ssl/SSL_CTX_use_certificate.pod ssl/SSL_SESSION_free.pod \
- ssl/SSL_SESSION_get_ex_new_index.pod \
- ssl/SSL_SESSION_get_time.pod \
- ssl/SSL_accept.pod ssl/SSL_clear.pod ssl/SSL_connect.pod \
- ssl/SSL_do_handshake.pod \
- ssl/SSL_free.pod ssl/SSL_get_ciphers.pod \
- ssl/SSL_get_client_CA_list.pod ssl/SSL_get_current_cipher.pod \
- ssl/SSL_get_error.pod ssl/SSL_get_ex_data_X509_STORE_CTX_idx.pod \
- ssl/SSL_get_ex_new_index.pod ssl/SSL_get_fd.pod \
- ssl/SSL_get_peer_cert_chain.pod ssl/SSL_get_peer_certificate.pod \
- ssl/SSL_get_rbio.pod ssl/SSL_get_session.pod \
- ssl/SSL_get_verify_result.pod ssl/SSL_library_init.pod \
- ssl/SSL_load_client_CA_file.pod ssl/SSL_new.pod ssl/SSL_pending.pod \
- ssl/SSL_read.pod ssl/SSL_set_bio.pod ssl/SSL_set_fd.pod \
- ssl/SSL_set_session.pod ssl/SSL_set_verify_result.pod \
- ssl/SSL_shutdown.pod ssl/SSL_write.pod ssl/d2i_SSL_SESSION.pod \
- ssl/ssl.pod ssl/SSL_CTX_sess_number.pod ssl/SSL_CTX_set_mode.pod \
- ssl/SSL_get_version.pod ssl/SSL_set_connect_state.pod \
- ssl/SSL_set_shutdown.pod ssl/SSL_alert_type_string.pod \
- ssl/SSL_COMP_add_compression_method.pod ssl/SSL_CTX_ctrl.pod \
- ssl/SSL_CTX_set_cert_store.pod \
- ssl/SSL_CTX_set_cert_verify_callback.pod \
- ssl/SSL_CTX_set_info_callback.pod ssl/SSL_CTX_set_quiet_shutdown.pod \
- ssl/SSL_CTX_set_tmp_dh_callback.pod \
- ssl/SSL_CTX_set_tmp_rsa_callback.pod ssl/SSL_get_default_timeout.pod \
- ssl/SSL_get_SSL_CTX.pod ssl/SSL_rstate_string.pod \
- ssl/SSL_session_reused.pod ssl/SSL_state_string.pod \
- ssl/SSL_want.pod
-
-POD5+= apps/config.pod
-
-.if defined(WANT_OPENSSL_MANPAGES)
-.for section in 1 3 5
-.for pod in ${POD${section}}
-.for target in ${pod:T:S/.pod/.${section}/g}
-MAN+= ${target}
-CLEANFILES+= ${target}
-${target}: ${LCRYPTO_SRC}/../doc/${pod}
- pod2man ${LCRYPTO_SRC}/../doc/${pod} > ${target}
-.endfor
-.endfor
-.endfor
-.endif
-
-MAN+= des_crypt.3
-
-MLINKS= des_crypt.3 des_read_password.3 \
- des_crypt.3 des_read_2password.3 des_crypt.3 des_string_to_key.3 \
- des_crypt.3 des_string_to_2key.3 des_crypt.3 des_read_pw_string.3 \
- des_crypt.3 des_random_key.3 des_crypt.3 des_set_key.3 \
- des_crypt.3 des_key_sched.3 des_crypt.3 des_ecb_encrypt.3 \
- des_crypt.3 des_3ecb_encrypt.3 des_crypt.3 des_cbc_encrypt.3 \
- des_crypt.3 des_3cbc_encrypt.3 des_crypt.3 des_pcbc_encrypt.3 \
- des_crypt.3 des_cfb_encrypt.3 des_crypt.3 des_ofb_encrypt.3 \
- des_crypt.3 des_cbc_cksum.3 des_crypt.3 des_quad_cksum.3 \
- des_crypt.3 des_enc_read.3 des_crypt.3 des_enc_write.3 \
- des_crypt.3 des_set_odd_parity.3 des_crypt.3 des_is_weak_key.3
-
-INCS= ${HDRS} openssl/evp.h openssl/opensslconf.h
-INCSDIR= ${INCLUDEDIR}/openssl
-INCSLINKS= openssl/des.h ${INCLUDEDIR}/des.h
-
-afterinstall:
-.if !defined(NOPIC)
-SYMLINKS+= lib${LIB}.so.${SHLIB_MAJOR} ${LIBDIR}/libdes.so.3
-SYMLINKS+= lib${LIB}.so.${SHLIB_MAJOR} ${LIBDIR}/libdes.so
-.endif
-SYMLINKS+= lib${LIB}.a ${LIBDIR}/libdes.a
-.if !defined(NOPROFILE)
-SYMLINKS+= lib${LIB}_p.a ${LIBDIR}/libdes_p.a
-.endif
-
-.include <bsd.lib.mk>
-
-.if !defined(NOPERL) && ${MACHINE_ARCH} == "i386"
-CLEANFILES+= ${SRCS:M*.pl:S/.pl$/.cmt/} ${SRCS:M*.pl:S/.pl$/.s/}
-.SUFFIXES: .pl .cmt
-.pl.cmt:
- perl -I${PERLPATH} ${.ALLSRC} elf ${CPUTYPE:Mi386:S/i//} > ${.TARGET}
-
-.cmt.s:
- tr -d "'" < ${.ALLSRC} > ${.TARGET}
-.endif
-
diff --git a/secure/lib/libcrypto/Makefile.inc b/secure/lib/libcrypto/Makefile.inc
deleted file mode 100644
index c0a603ee6fdd..000000000000
--- a/secure/lib/libcrypto/Makefile.inc
+++ /dev/null
@@ -1,62 +0,0 @@
-# $FreeBSD$
-
-LCRYPTO_SRC= ${.CURDIR}/../../../crypto/openssl/crypto
-CFLAGS+= -DTERMIOS -DANSI_SOURCE -I${LCRYPTO_SRC} -I${.OBJDIR}
-.if !defined(MAKE_IDEA) || ${MAKE_IDEA} != YES
-CFLAGS+= -DNO_IDEA
-.endif
-
-.if ${MACHINE_ARCH} == "i386"
-CFLAGS+= -DL_ENDIAN
-.if !defined(NOPERL)
-CFLAGS+= -DSHA1_ASM -DBN_ASM -DMD5_ASM -DRMD160_ASM
-.endif
-.elif ${MACHINE_ARCH} == "alpha"
-# no ENDIAN stuff defined for alpha (64-bit)
-.endif
-
-WITH_RSA?= YES
-
-HDRS= asn1/asn1.h asn1/asn1_mac.h bio/bio.h bf/blowfish.h bn/bn.h \
- buffer/buffer.h cast/cast.h comp/comp.h conf/conf.h crypto.h \
- des/des.h dh/dh.h dsa/dsa.h ../e_os.h ../e_os2.h ebcdic.h \
- err/err.h hmac/hmac.h lhash/lhash.h md2/md2.h \
- md5/md5.h mdc2/mdc2.h objects/objects.h opensslv.h pem/pem.h \
- pem/pem2.h pkcs12/pkcs12.h pkcs7/pkcs7.h rand/rand.h rc2/rc2.h \
- rc4/rc4.h rc5/rc5.h ripemd/ripemd.h rsa/rsa.h stack/safestack.h \
- sha/sha.h stack/stack.h tmdiff.h txt_db/txt_db.h x509/x509.h \
- x509/x509_vfy.h x509v3/x509v3.h symhacks.h objects/obj_mac.h \
- md4/md4.h dso/dso.h conf/conf_api.h
-
-.if defined(MAKE_IDEA) && ${MAKE_IDEA} == YES
-HDRS+= idea/idea.h
-.endif
-
-SRCS+= buildinf.h openssl/opensslconf.h openssl/evp.h
-CLEANFILES+= buildinf.h openssl/opensslconf.h openssl/evp.h
-CLEANDIRS+= openssl
-
-buildinf.h:
- ( echo "#ifndef MK1MF_BUILD"; \
- echo " /* auto-generated by crypto/Makefile.ssl for crypto/cversion.c */"; \
- echo " #define CFLAGS \"$(CC)\""; \
- echo " #define PLATFORM \"`uname -s`-`uname -m`\""; \
- echo " #define DATE \"`LC_ALL=C date`\""; \
- echo "#endif" ) > ${.TARGET}
-
-# XXX: The openssl/ dependencies are not correct, in that a change in
-# any of ${HDRS} ${EXTRA_HDRS} will no repopulate openssl/.
-# This deficiency will be fixed in a later commit.
-
-openssl/opensslconf.h: ../libcrypto/opensslconf-${MACHINE_ARCH}.h
- mkdir -p openssl
- cp ${.OODATE} ${.TARGET}
- ${INSTALL} -C -m 444 ${HDRS:S;^;${LCRYPTO_SRC}/;} ${EXTRA_HDRS} openssl
-
-openssl/evp.h: ${LCRYPTO_SRC}/evp/evp.h
- mkdir -p openssl
-.if !defined(MAKE_IDEA) || ${MAKE_IDEA} != YES
- sed '/^#ifndef NO_IDEA$$/,/^#endif$$/d' ${.OODATE} > ${.TARGET}
-.else
- ${INSTALL} -m 444 ${.OODATE} ${.TARGET}
-.endif
diff --git a/secure/lib/libcrypto/des_crypt.3 b/secure/lib/libcrypto/des_crypt.3
deleted file mode 100644
index ed12ff9322e8..000000000000
--- a/secure/lib/libcrypto/des_crypt.3
+++ /dev/null
@@ -1,509 +0,0 @@
-.\" $FreeBSD$
-.TH DES_CRYPT 3
-.SH NAME
-des_read_password, des_read_2password,
-des_string_to_key, des_string_to_2key, des_read_pw_string,
-des_random_key, des_set_key,
-des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
-des_3cbc_encrypt,
-des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
-des_cbc_cksum, des_quad_cksum,
-des_enc_read, des_enc_write, des_set_odd_parity,
-des_is_weak_key, crypt \- (non USA) DES encryption
-.SH SYNOPSIS
-.nf
-.nj
-.ft B
-#include <openssl/des.h>
-.PP
-.B int des_read_password(key,prompt,verify)
-des_cblock *key;
-char *prompt;
-int verify;
-.PP
-.B int des_read_2password(key1,key2,prompt,verify)
-des_cblock *key1,*key2;
-char *prompt;
-int verify;
-.PP
-.B int des_string_to_key(str,key)
-char *str;
-des_cblock *key;
-.PP
-.B int des_string_to_2keys(str,key1,key2)
-char *str;
-des_cblock *key1,*key2;
-.PP
-.B int des_read_pw_string(buf,length,prompt,verify)
-char *buf;
-int length;
-char *prompt;
-int verify;
-.PP
-.B int des_random_key(key)
-des_cblock *key;
-.PP
-.B int des_set_key(key,schedule)
-des_cblock *key;
-des_key_schedule schedule;
-.PP
-.B int des_key_sched(key,schedule)
-des_cblock *key;
-des_key_schedule schedule;
-.PP
-.B int des_ecb_encrypt(input,output,schedule,encrypt)
-des_cblock *input;
-des_cblock *output;
-des_key_schedule schedule;
-int encrypt;
-.PP
-.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
-des_cblock *input;
-des_cblock *output;
-des_key_schedule ks1,ks2;
-int encrypt;
-.PP
-.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
-des_cblock *input;
-des_cblock *output;
-long length;
-des_key_schedule schedule;
-des_cblock *ivec;
-int encrypt;
-.PP
-.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt)
-des_cblock *input;
-des_cblock *output;
-long length;
-des_key_schedule sk1;
-des_key_schedule sk2;
-des_cblock *ivec1;
-des_cblock *ivec2;
-int encrypt;
-.PP
-.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
-des_cblock *input;
-des_cblock *output;
-long length;
-des_key_schedule schedule;
-des_cblock *ivec;
-int encrypt;
-.PP
-.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt)
-unsigned char *input;
-unsigned char *output;
-int numbits;
-long length;
-des_key_schedule schedule;
-des_cblock *ivec;
-int encrypt;
-.PP
-.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec)
-unsigned char *input,*output;
-int numbits;
-long length;
-des_key_schedule schedule;
-des_cblock *ivec;
-.PP
-.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
-des_cblock *input;
-des_cblock *output;
-long length;
-des_key_schedule schedule;
-des_cblock *ivec;
-.PP
-.B unsigned long des_quad_cksum(input,output,length,out_count,seed)
-des_cblock *input;
-des_cblock *output;
-long length;
-int out_count;
-des_cblock *seed;
-.PP
-.B int des_check_key;
-.PP
-.B int des_enc_read(fd,buf,len,sched,iv)
-int fd;
-char *buf;
-int len;
-des_key_schedule sched;
-des_cblock *iv;
-.PP
-.B int des_enc_write(fd,buf,len,sched,iv)
-int fd;
-char *buf;
-int len;
-des_key_schedule sched;
-des_cblock *iv;
-.PP
-.B extern int des_rw_mode;
-.PP
-.B void des_set_odd_parity(key)
-des_cblock *key;
-.PP
-.B int des_is_weak_key(key)
-des_cblock *key;
-.PP
-.B char *crypt(passwd,salt)
-char *passwd;
-char *salt;
-.PP
-.fi
-.SH DESCRIPTION
-This library contains a fast implementation of the DES encryption
-algorithm.
-.PP
-There are two phases to the use of DES encryption.
-The first is the generation of a
-.I des_key_schedule
-from a key,
-the second is the actual encryption.
-A des key is of type
-.I des_cblock.
-This type is made from 8 characters with odd parity.
-The least significant bit in the character is the parity bit.
-The key schedule is an expanded form of the key; it is used to speed the
-encryption process.
-.PP
-.I des_read_password
-writes the string specified by prompt to the standard output,
-turns off echo and reads an input string from standard input
-until terminated with a newline.
-If verify is non-zero, it prompts and reads the input again and verifies
-that both entered passwords are the same.
-The entered string is converted into a des key by using the
-.I des_string_to_key
-routine.
-The new key is placed in the
-.I des_cblock
-that was passed (by reference) to the routine.
-If there were no errors,
-.I des_read_password
-returns 0,
--1 is returned if there was a terminal error and 1 is returned for
-any other error.
-.PP
-.I des_read_2password
-operates in the same way as
-.I des_read_password
-except that it generates 2 keys by using the
-.I des_string_to_2key
-function.
-.PP
-.I des_read_pw_string
-is called by
-.I des_read_password
-to read and verify a string from a terminal device.
-The string is returned in
-.I buf.
-The size of
-.I buf
-is passed to the routine via the
-.I length
-parameter.
-.PP
-.I des_string_to_key
-converts a string into a valid des key.
-.PP
-.I des_string_to_2key
-converts a string into 2 valid des keys.
-This routine is best suited for used to generate keys for use with
-.I des_ecb3_encrypt.
-.PP
-.I des_random_key
-returns a random key that is made of a combination of process id,
-time and an increasing counter.
-.PP
-Before a des key can be used it is converted into a
-.I des_key_schedule
-via the
-.I des_set_key
-routine.
-If the
-.I des_check_key
-flag is non-zero,
-.I des_set_key
-will check that the key passed is of odd parity and is not a week or
-semi-weak key.
-If the parity is wrong,
-then -1 is returned.
-If the key is a weak key,
-then -2 is returned.
-If an error is returned,
-the key schedule is not generated.
-.PP
-.I des_key_sched
-is another name for the
-.I des_set_key
-function.
-.PP
-The following routines mostly operate on an input and output stream of
-.I des_cblock's.
-.PP
-.I des_ecb_encrypt
-is the basic DES encryption routine that encrypts or decrypts a single 8-byte
-.I des_cblock
-in
-.I electronic code book
-mode.
-It always transforms the input data, pointed to by
-.I input,
-into the output data,
-pointed to by the
-.I output
-argument.
-If the
-.I encrypt
-argument is non-zero (DES_ENCRYPT),
-the
-.I input
-(cleartext) is encrypted in to the
-.I output
-(ciphertext) using the key_schedule specified by the
-.I schedule
-argument,
-previously set via
-.I des_set_key.
-If
-.I encrypt
-is zero (DES_DECRYPT),
-the
-.I input
-(now ciphertext)
-is decrypted into the
-.I output
-(now cleartext).
-Input and output may overlap.
-No meaningful value is returned.
-.PP
-.I des_ecb3_encrypt
-encrypts/decrypts the
-.I input
-block by using triple ecb DES encryption.
-This involves encrypting the input with
-.I ks1,
-decryption with the key schedule
-.I ks2,
-and then encryption with the first again.
-This routine greatly reduces the chances of brute force breaking of
-DES and has the advantage of if
-.I ks1
-and
-.I ks2
-are the same, it is equivalent to just encryption using ecb mode and
-.I ks1
-as the key.
-.PP
-.I des_cbc_encrypt
-encrypts/decrypts using the
-.I cipher-block-chaining
-mode of DES.
-If the
-.I encrypt
-argument is non-zero,
-the routine cipher-block-chain encrypts the cleartext data pointed to by the
-.I input
-argument into the ciphertext pointed to by the
-.I output
-argument,
-using the key schedule provided by the
-.I schedule
-argument,
-and initialisation vector provided by the
-.I ivec
-argument.
-If the
-.I length
-argument is not an integral multiple of eight bytes,
-the last block is copied to a temporary area and zero filled.
-The output is always
-an integral multiple of eight bytes.
-To make multiple cbc encrypt calls on a large amount of data appear to
-be one
-.I des_cbc_encrypt
-call, the
-.I ivec
-of subsequent calls should be the last 8 bytes of the output.
-.PP
-.I des_3cbc_encrypt
-encrypts/decrypts the
-.I input
-block by using triple cbc DES encryption.
-This involves encrypting the input with key schedule
-.I ks1,
-decryption with the key schedule
-.I ks2,
-and then encryption with the first again.
-2 initialisation vectors are required,
-.I ivec1
-and
-.I ivec2.
-Unlike
-.I des_cbc_encrypt,
-these initialisation vectors are modified by the subroutine.
-This routine greatly reduces the chances of brute force breaking of
-DES and has the advantage of if
-.I ks1
-and
-.I ks2
-are the same, it is equivalent to just encryption using cbc mode and
-.I ks1
-as the key.
-.PP
-.I des_pcbc_encrypt
-encrypt/decrypts using a modified block chaining mode.
-It provides better error propagation characteristics than cbc
-encryption.
-.PP
-.I des_cfb_encrypt
-encrypt/decrypts using cipher feedback mode. This method takes an
-array of characters as input and outputs and array of characters. It
-does not require any padding to 8 character groups. Note: the ivec
-variable is changed and the new changed value needs to be passed to
-the next call to this function. Since this function runs a complete
-DES ecb encryption per numbits, this function is only suggested for
-use when sending small numbers of characters.
-.PP
-.I des_ofb_encrypt
-encrypt using output feedback mode. This method takes an
-array of characters as input and outputs and array of characters. It
-does not require any padding to 8 character groups. Note: the ivec
-variable is changed and the new changed value needs to be passed to
-the next call to this function. Since this function runs a complete
-DES ecb encryption per numbits, this function is only suggested for
-use when sending small numbers of characters.
-.PP
-.I des_cbc_cksum
-produces an 8 byte checksum based on the input stream (via cbc encryption).
-The last 4 bytes of the checksum is returned and the complete 8 bytes is
-placed in
-.I output.
-.PP
-.I des_quad_cksum
-returns a 4 byte checksum from the input bytes.
-The algorithm can be iterated over the input,
-depending on
-.I out_count,
-1, 2, 3 or 4 times.
-If
-.I output
-is non-NULL,
-the 8 bytes generated by each pass are written into
-.I output.
-.PP
-.I des_enc_write
-is used to write
-.I len
-bytes
-to file descriptor
-.I fd
-from buffer
-.I buf.
-The data is encrypted via
-.I pcbc_encrypt
-(default) using
-.I sched
-for the key and
-.I iv
-as a starting vector.
-The actual data send down
-.I fd
-consists of 4 bytes (in network byte order) containing the length of the
-following encrypted data. The encrypted data then follows, padded with random
-data out to a multiple of 8 bytes.
-.PP
-.I des_enc_read
-is used to read
-.I len
-bytes
-from file descriptor
-.I fd
-into buffer
-.I buf.
-The data being read from
-.I fd
-is assumed to have come from
-.I des_enc_write
-and is decrypted using
-.I sched
-for the key schedule and
-.I iv
-for the initial vector.
-The
-.I des_enc_read/des_enc_write
-pair can be used to read/write to files, pipes and sockets.
-I have used them in implementing a version of rlogin in which all
-data is encrypted.
-.PP
-.I des_rw_mode
-is used to specify the encryption mode to use with
-.I des_enc_read
-and
-.I des_end_write.
-If set to
-.I DES_PCBC_MODE
-(the default), des_pcbc_encrypt is used.
-If set to
-.I DES_CBC_MODE
-des_cbc_encrypt is used.
-These two routines and the variable are not part of the normal MIT library.
-.PP
-.I des_set_odd_parity
-sets the parity of the passed
-.I key
-to odd. This routine is not part of the standard MIT library.
-.PP
-.I des_is_weak_key
-returns 1 is the passed key is a weak key (pick again :-),
-0 if it is ok.
-This routine is not part of the standard MIT library.
-.PP
-.I crypt
-is a replacement for the normal system crypt.
-It is much faster than the system crypt.
-.PP
-.SH FILES
-/usr/include/openssl/des.h
-.br
-/usr/lib/libcrypto.a
-.PP
-The encryption routines have been tested on 16bit, 32bit and 64bit
-machines of various endian and even works under VMS.
-.PP
-.SH BUGS
-.PP
-If you think this manual is sparse,
-read the des_crypt(3) manual from the MIT kerberos (or bones outside
-of the USA) distribution.
-.PP
-.I des_cfb_encrypt
-and
-.I des_ofb_encrypt
-operates on input of 8 bits. What this means is that if you set
-numbits to 12, and length to 2, the first 12 bits will come from the 1st
-input byte and the low half of the second input byte. The second 12
-bits will have the low 8 bits taken from the 3rd input byte and the
-top 4 bits taken from the 4th input byte. The same holds for output.
-This function has been implemented this way because most people will
-be using a multiple of 8 and because once you get into pulling bytes input
-bytes apart things get ugly!
-.PP
-.I des_read_pw_string
-is the most machine/OS dependent function and normally generates the
-most problems when porting this code.
-.PP
-.I des_string_to_key
-is probably different from the MIT version since there are lots
-of fun ways to implement one-way encryption of a text string.
-.PP
-The routines are optimised for 32 bit machines and so are not efficient
-on IBM PCs.
-.PP
-NOTE: extensive work has been done on this library since this document
-was origionally written. Please try to read des.doc from the libdes
-distribution since it is far more upto date and documents more of the
-functions. Libdes is now also being shipped as part of SSLeay, a
-general cryptographic library that amonst other things implements
-netscapes SSL protocoll. The most recent version can be found in
-SSLeay distributions.
-.SH AUTHOR
-Eric Young (eay@cryptsoft.com)
diff --git a/secure/lib/libcrypto/opensslconf-alpha.h b/secure/lib/libcrypto/opensslconf-alpha.h
deleted file mode 100644
index bcbfc08fd0d1..000000000000
--- a/secure/lib/libcrypto/opensslconf-alpha.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* $FreeBSD$ */
-/* opensslconf.h */
-
-/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
-
-/* OpenSSL was configured with the following options: */
-#ifdef OPENSSL_ALGORITHM_DEFINES
- /* no ciphers excluded */
-#endif
-#ifdef OPENSSL_THREAD_DEFINES
-# ifndef THREADS
-# define THREADS
-# endif
-#endif
-#ifdef OPENSSL_OTHER_DEFINES
-# ifndef NO_ASM
-# define NO_ASM
-# endif
-#endif
-
-/* crypto/opensslconf.h.in */
-
-/* Generate 80386 code? */
-#undef I386_ONLY
-
-#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
-#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
-#define OPENSSLDIR "/etc/ssl"
-#endif
-#endif
-
-#define OPENSSL_UNISTD <unistd.h>
-
-#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
-#define IDEA_INT unsigned int
-#endif
-
-#if defined(HEADER_MD2_H) && !defined(MD2_INT)
-#define MD2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC2_H) && !defined(RC2_INT)
-/* I need to put in a mod for the alpha - eay */
-#define RC2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC4_H)
-#if !defined(RC4_INT)
-/* using int types make the structure larger but make the code faster
- * on most boxes I have tested - up to %20 faster. */
-/*
- * I don't know what does "most" mean, but declaring "int" is a must on:
- * - Intel P6 because partial register stalls are very expensive;
- * - elder Alpha because it lacks byte load/store instructions;
- */
-#define RC4_INT unsigned int
-#endif
-#if !defined(RC4_CHUNK)
-/*
- * This enables code handling data aligned at natural CPU word
- * boundary. See crypto/rc4/rc4_enc.c for further details.
- */
-#undef RC4_CHUNK
-#endif
-#endif
-
-#if defined(HEADER_DES_H) && !defined(DES_LONG)
-/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
- * %20 speed up (longs are 8 bytes, int's are 4). */
-#ifndef DES_LONG
-#define DES_LONG unsigned int
-#endif
-#endif
-
-#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
-#define CONFIG_HEADER_BN_H
-#undef BN_LLONG
-
-/* Should we define BN_DIV2W here? */
-
-/* Only one for the following should be defined */
-/* The prime number generation stuff may not work when
- * EIGHT_BIT but I don't care since I've only used this mode
- * for debuging the bignum libraries */
-#define SIXTY_FOUR_BIT_LONG
-#undef SIXTY_FOUR_BIT
-#undef THIRTY_TWO_BIT
-#undef SIXTEEN_BIT
-#undef EIGHT_BIT
-#endif
-
-#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
-#define CONFIG_HEADER_RC4_LOCL_H
-/* if this is defined data[i] is used instead of *data, this is a %20
- * speedup on x86 */
-#undef RC4_INDEX
-#endif
-
-#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
-#define CONFIG_HEADER_BF_LOCL_H
-#undef BF_PTR
-#endif /* HEADER_BF_LOCL_H */
-
-#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
-#define CONFIG_HEADER_DES_LOCL_H
-#ifndef DES_DEFAULT_OPTIONS
-/* the following is tweaked from a config script, that is why it is a
- * protected undef/define */
-#ifndef DES_PTR
-#define DES_PTR
-#endif
-
-/* This helps C compiler generate the correct code for multiple functional
- * units. It reduces register dependancies at the expense of 2 more
- * registers */
-#ifndef DES_RISC1
-#undef DES_RISC1
-#endif
-
-#ifndef DES_RISC2
-#define DES_RISC2
-#endif
-
-#if defined(DES_RISC1) && defined(DES_RISC2)
-YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
-#endif
-
-/* Unroll the inner loop, this sometimes helps, sometimes hinders.
- * Very mucy CPU dependant */
-#ifndef DES_UNROLL
-#undef DES_UNROLL
-#endif
-
-/* These default values were supplied by
- * Peter Gutman <pgut001@cs.auckland.ac.nz>
- * They are only used if nothing else has been defined */
-#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
-/* Special defines which change the way the code is built depending on the
- CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
- even newer MIPS CPU's, but at the moment one size fits all for
- optimization options. Older Sparc's work better with only UNROLL, but
- there's no way to tell at compile time what it is you're running on */
-
-#if defined( sun ) /* Newer Sparc's */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#elif defined( __ultrix ) /* Older MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( __osf1__ ) /* Alpha */
-# define DES_PTR
-# define DES_RISC2
-#elif defined ( _AIX ) /* RS6000 */
- /* Unknown */
-#elif defined( __hpux ) /* HP-PA */
- /* Unknown */
-#elif defined( __aux ) /* 68K */
- /* Unknown */
-#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
-# define DES_UNROLL
-#elif defined( __sgi ) /* Newer MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( i386 ) /* x86 boxes, should be gcc */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#endif /* Systems-specific speed defines */
-#endif
-
-#endif /* DES_DEFAULT_OPTIONS */
-#endif /* HEADER_DES_LOCL_H */
diff --git a/secure/lib/libcrypto/opensslconf-i386.h b/secure/lib/libcrypto/opensslconf-i386.h
deleted file mode 100644
index fc3cf0432479..000000000000
--- a/secure/lib/libcrypto/opensslconf-i386.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* $FreeBSD$ */
-/* opensslconf.h */
-
-/* WARNING: Generated automatically from opensslconf.h.in by Configure. */
-
-/* OpenSSL was configured with the following options: */
-#ifdef OPENSSL_ALGORITHM_DEFINES
- /* no ciphers excluded */
-#endif
-#ifdef OPENSSL_THREAD_DEFINES
-# ifndef THREADS
-# define THREADS
-# endif
-#endif
-#ifdef OPENSSL_OTHER_DEFINES
-# ifndef NO_ASM
-# define NO_ASM
-# endif
-#endif
-
-/* crypto/opensslconf.h.in */
-
-/* Generate 80386 code? */
-#undef I386_ONLY
-
-#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
-#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
-#define OPENSSLDIR "/etc/ssl"
-#endif
-#endif
-
-#define OPENSSL_UNISTD <unistd.h>
-
-#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
-#define IDEA_INT unsigned int
-#endif
-
-#if defined(HEADER_MD2_H) && !defined(MD2_INT)
-#define MD2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC2_H) && !defined(RC2_INT)
-/* I need to put in a mod for the alpha - eay */
-#define RC2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC4_H)
-#if !defined(RC4_INT)
-/* using int types make the structure larger but make the code faster
- * on most boxes I have tested - up to %20 faster. */
-/*
- * I don't know what does "most" mean, but declaring "int" is a must on:
- * - Intel P6 because partial register stalls are very expensive;
- * - elder Alpha because it lacks byte load/store instructions;
- */
-#define RC4_INT unsigned int
-#endif
-#if !defined(RC4_CHUNK)
-/*
- * This enables code handling data aligned at natural CPU word
- * boundary. See crypto/rc4/rc4_enc.c for further details.
- */
-#undef RC4_CHUNK
-#endif
-#endif
-
-#if defined(HEADER_DES_H) && !defined(DES_LONG)
-/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
- * %20 speed up (longs are 8 bytes, int's are 4). */
-#ifndef DES_LONG
-#define DES_LONG unsigned long
-#endif
-#endif
-
-#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
-#define CONFIG_HEADER_BN_H
-#define BN_LLONG
-
-/* Should we define BN_DIV2W here? */
-
-/* Only one for the following should be defined */
-/* The prime number generation stuff may not work when
- * EIGHT_BIT but I don't care since I've only used this mode
- * for debuging the bignum libraries */
-#undef SIXTY_FOUR_BIT_LONG
-#undef SIXTY_FOUR_BIT
-#define THIRTY_TWO_BIT
-#undef SIXTEEN_BIT
-#undef EIGHT_BIT
-#endif
-
-#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
-#define CONFIG_HEADER_RC4_LOCL_H
-/* if this is defined data[i] is used instead of *data, this is a %20
- * speedup on x86 */
-#define RC4_INDEX
-#endif
-
-#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
-#define CONFIG_HEADER_BF_LOCL_H
-#undef BF_PTR
-#endif /* HEADER_BF_LOCL_H */
-
-#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
-#define CONFIG_HEADER_DES_LOCL_H
-#ifndef DES_DEFAULT_OPTIONS
-/* the following is tweaked from a config script, that is why it is a
- * protected undef/define */
-#ifndef DES_PTR
-#define DES_PTR
-#endif
-
-/* This helps C compiler generate the correct code for multiple functional
- * units. It reduces register dependancies at the expense of 2 more
- * registers */
-#ifndef DES_RISC1
-#define DES_RISC1
-#endif
-
-#ifndef DES_RISC2
-#undef DES_RISC2
-#endif
-
-#if defined(DES_RISC1) && defined(DES_RISC2)
-YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
-#endif
-
-/* Unroll the inner loop, this sometimes helps, sometimes hinders.
- * Very mucy CPU dependant */
-#ifndef DES_UNROLL
-#define DES_UNROLL
-#endif
-
-/* These default values were supplied by
- * Peter Gutman <pgut001@cs.auckland.ac.nz>
- * They are only used if nothing else has been defined */
-#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
-/* Special defines which change the way the code is built depending on the
- CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
- even newer MIPS CPU's, but at the moment one size fits all for
- optimization options. Older Sparc's work better with only UNROLL, but
- there's no way to tell at compile time what it is you're running on */
-
-#if defined( sun ) /* Newer Sparc's */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#elif defined( __ultrix ) /* Older MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( __osf1__ ) /* Alpha */
-# define DES_PTR
-# define DES_RISC2
-#elif defined ( _AIX ) /* RS6000 */
- /* Unknown */
-#elif defined( __hpux ) /* HP-PA */
- /* Unknown */
-#elif defined( __aux ) /* 68K */
- /* Unknown */
-#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
-# define DES_UNROLL
-#elif defined( __sgi ) /* Newer MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( i386 ) /* x86 boxes, should be gcc */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#endif /* Systems-specific speed defines */
-#endif
-
-#endif /* DES_DEFAULT_OPTIONS */
-#endif /* HEADER_DES_LOCL_H */
diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile
deleted file mode 100644
index 7bfbdc31789b..000000000000
--- a/secure/lib/libssh/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-#
-
-LIB= ssh
-SRCS= authfd.c authfile.c bufaux.c buffer.c canohost.c channels.c \
- cipher.c compat.c compress.c crc32.c deattack.c fatal.c \
- hostfile.c log.c match.c mpaux.c nchan.c packet.c readpass.c \
- rsa.c tildexpand.c ttymodes.c xmalloc.c atomicio.c \
- key.c dispatch.c kex.c mac.c uuencode.c misc.c \
- rijndael.c ssh-dss.c ssh-rsa.c dh.c kexdh.c kexgex.c \
- scard.c monitor_wrap.c monitor_fdpass.c msg.c
-# Portability layer
-SRCS+= bsd-misc.c entropy.c
-# FreeBSD additions
-SRCS+= version.c
-CFLAGS+=-I${SSHDIR}
-
-.if defined(COMPAT_GETADDRINFO)
-SRCS+= getaddrinfo.c getnameinfo.c name6.c rcmd.c bindresvport.c
-.endif
-
-DPADD= ${LIBCRYPTO} ${LIBZ}
-LDADD= -lcrypto -lz
-
-.include <bsd.lib.mk>
-
-.PATH: ${SSHDIR} ${SSHDIR}/openbsd-compat
diff --git a/secure/lib/libssl/Makefile b/secure/lib/libssl/Makefile
deleted file mode 100644
index 9fbaf339db13..000000000000
--- a/secure/lib/libssl/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# $FreeBSD$
-
-.include "../libcrypto/Makefile.inc"
-
-LCRYPTOSSL_SRC=${LCRYPTO_SRC}/../ssl
-
-.PATH: ${LCRYPTOSSL_SRC}
-
-LIB= ssl
-SHLIB_MAJOR= 2
-
-MAINTAINER= kris
-
-SRCS+= bio_ssl.c s23_clnt.c s23_lib.c s23_meth.c s23_pkt.c s23_srvr.c \
- s2_clnt.c s2_enc.c s2_lib.c s2_meth.c s2_pkt.c s2_srvr.c \
- s3_both.c s3_clnt.c s3_enc.c s3_lib.c s3_meth.c s3_pkt.c \
- s3_srvr.c ssl_algs.c ssl_asn1.c ssl_cert.c ssl_ciph.c \
- ssl_err.c ssl_err2.c ssl_lib.c ssl_rsa.c ssl_sess.c ssl_stat.c \
- ssl_txt.c t1_clnt.c t1_enc.c t1_lib.c t1_meth.c t1_srvr.o \
-
-INCS= ssl.h ssl2.h ssl23.h ssl3.h ssl_locl.h tls1.h
-INCSDIR=${INCLUDEDIR}/openssl
-HDRS+= ${INCS:S;^;../ssl/;}
-
-.include <bsd.lib.mk>
diff --git a/secure/lib/libtelnet/Makefile b/secure/lib/libtelnet/Makefile
deleted file mode 100644
index 102be59108e4..000000000000
--- a/secure/lib/libtelnet/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-# $FreeBSD$
-
-LIB= telnet
-
-INTERNALLIB= yes
-
-SRCS= genget.c getent.c misc.c encrypt.c auth.c \
- enc_des.c sra.c pk.c
-
-CFLAGS+= -DENCRYPTION -DAUTHENTICATION -DSRA \
- -I${TELNETDIR} -I${TELNETDIR}/libtelnet
-
-WARNS?= 2
-
-INCS= ${TELNETDIR}/arpa/telnet.h
-INCSDIR= ${INCLUDEDIR}/arpa
-
-.include <bsd.lib.mk>
-
-.PATH: ${TELNETDIR}/libtelnet
-
-#
-# Remove obsolete shared libraries, if any. We don't bother moving them
-# to /usr/lib/compat, since they were only used by telnet, telnetd and
-# tn3270.
-#
-beforeinstall: __remove-stale-libs
-__remove-stale-libs: .PHONY
-.if exists(${DESTDIR}${SHLIBDIR}/lib${LIB}.so.2.0)
- -chflags noschg ${DESTDIR}${SHLIBDIR}/lib${LIB}.so.2.0
- rm -f ${DESTDIR}${SHLIBDIR}/lib${LIB}.so.2.0
-.endif