-# $OpenBSD: Makefile.inc,v 1.6 1997/02/13 16:59:53 provos Exp $
+# $OpenBSD: Makefile.inc,v 1.7 1997/02/16 20:58:11 provos Exp $
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/crypt ${.CURDIR}/crypt
SRCS+= crypt.c morecrypt.c md5crypt.c arc4random.c blowfish.c
SRCS+= bcrypt.c
-MAN+= crypt.3
+MAN+= crypt.3 blowfish.3
MLINKS+=crypt.3 encrypt.3 crypt.3 setkey.3 crypt.3 des_cipher.3
-MLINKS+=crypt.3 des_setkey.3
+MLINKS+=crypt.3 des_setkey.3 blowfish.3 blf_key.3 blowfish.3 blf_enc.3
+MLINKS+=blowfish.3 blf_dec.3
-/* $OpenBSD: bcrypt.c,v 1.2 1997/02/14 18:40:14 provos Exp $ */
+/* $OpenBSD: bcrypt.c,v 1.3 1997/02/16 20:58:15 provos Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
* All rights reserved.
* 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 Theo de Raadt.
+ * 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.
*
* REPEAT rounds:
* state := ExpandKey (state, 0, salt)
* state := ExpandKey(state, 0, password)
- * 4. ctext := "OpenBSDbcrypthashfunc"
+ * 4. ctext := "OrpheanBeholderScryDoubt"
* 5. REPEAT 64:
* ctext := Encrypt_ECB (state, ctext);
* 6. RETURN Concatenate (salt, ctext);
u_int32_t rounds, i, k;
u_int16_t j;
u_int8_t key_len, salt_len, logr;
- u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OpenBSDbcrypthashfunc";
+ u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
u_int8_t csalt[BCRYPT_MAXSALT];
u_int32_t cdata[BCRYPT_BLOCKS];
/* Discard "$" identifier */
--- /dev/null
+.\" $OpenBSD: blowfish.3,v 1.1 1997/02/16 20:58:16 provos Exp $
+.\" 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.
+.\"
+.\" Manual page, using -mandoc macros
+.\"
+.Dd February 13, 1997
+.Dt BLOWFISH 3
+.Os "OpenBSD 2.0"
+.Sh NAME
+.Nm blf_key,
+.Nm blf_enc,
+.Nm blf_dec
+.Nd Blowfish encryption
+.Sh SYNOPSIS
+.Fd #include <blf.h>
+.Ft void
+.Fn blf_key "blf_ctx *state" "const u_int8_t *key" "u_int16_t keylen"
+.Ft void
+.Fn blf_enc "blf_ctx *state" "u_int32_t *data" "u_int16_t datalen"
+.Ft void
+.Fn blf_dec "blf_ctx *state" "u_int32_t *data" "u_int16_t datalen"
+.Sh DESCRIPTION
+.Pa Blowfish
+is a fast unpatented block cipher designed by Bruce Schneier.
+It basically consists of a 16 times iterated Feistel network.
+The block size is 64 bit and the key size is maximal 448 bit.
+.Pp
+The
+.Fn blf_key
+function initializes the 4 8bit S-boxes and the 18 Subkeys with
+the hexadecimal digits of Pi. The key is used for further randomization.
+The first argument to
+.Fn blf_enc
+is the initalized state derived from
+.Fn blf_key .
+The stream of data is encrypted in Electronic Cookbook Mode (ECB) and
+.Pa datalen
+must be even.
+.Fn blf_dec
+is used for decrypting Blowfish encrypted blocks.
+.Pp
+The functions
+.Fn Blowfish_initstate ,
+.Fn Blowfish_expand0state ,
+.Fn Blowfish_expandstate ,
+.Fn Blowfish_encipher
+and
+.Fn Blowfish_decipher
+are used for customization of the
+.Pa Blowfish
+cipher, i.e. for the blowfish password hashing function or for
+implementation of Cipher Block Chaining Mode (CBC).
+.Sh SEE ALSO
+.Xr crypt 3 ,
+.Xr passwd 1 ,
+.Xr passwd 5
+.Sh AUTHOR
+Niels Provos <provos@physnet.uni-hamburg.de>
-/* $OpenBSD: blowfish.c,v 1.2 1997/02/14 18:40:18 provos Exp $ */
+/* $OpenBSD: blowfish.c,v 1.3 1997/02/16 20:58:17 provos Exp $ */
/*
* Blowfish block cipher for OpenBSD
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
* 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 Theo de Raadt.
+ * 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.
*
static inline u_int32_t F __P((blf_ctx * bc, u_int32_t x));
-/* Standard Blowfish */
-
-void blf_key __P((blf_ctx * c, u_int8_t * k, u_int16_t len));
-void blf_enc __P((blf_ctx * c, u_int32_t * data, u_int16_t blocks));
-void blf_dec __P((blf_ctx * c, u_int32_t * data, u_int16_t blocks));
-
/* Function for Feistel Networks */
static inline u_int32_t
u_int32_t
Blowfish_stream2word(data, databytes, current)
- u_int8_t *data;
+ const u_int8_t *data;
u_int16_t databytes;
u_int16_t *current;
{
void
Blowfish_expand0state(c, key, keybytes)
blf_ctx *c;
- u_int8_t *key;
+ const u_int8_t *key;
u_int16_t keybytes;
{
u_int16_t i;
void
Blowfish_expandstate(c, data, databytes, key, keybytes)
blf_ctx *c;
- u_int8_t *data;
+ const u_int8_t *data;
u_int16_t databytes;
- u_int8_t *key;
+ const u_int8_t *key;
u_int16_t keybytes;
{
u_int16_t i;
void
blf_key(c, k, len)
blf_ctx *c;
- u_int8_t *k;
+ const u_int8_t *k;
u_int16_t len;
{
/* Initalize S-boxes and subkeys with Pi */