Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/crypto/blowfish * Const poison, ANSI'ify, like newer Ope...
details: https://anonhg.NetBSD.org/src/rev/3e495079c058
branches: trunk
changeset: 550994:3e495079c058
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Aug 26 23:51:12 2003 +0000
description:
* Const poison, ANSI'ify, like newer OpenSSL Blowfish code.
* Add a BF_ecb_encrypt(), which makes for a prettier interface than
using BF_encrypt()/BF_decrypt() directly.
diffstat:
sys/crypto/blowfish/bf_cbc.c | 4 +-
sys/crypto/blowfish/bf_ecb.c | 89 ++++++++++++++++++++++++++++++++++++++
sys/crypto/blowfish/bf_enc.c | 10 +--
sys/crypto/blowfish/bf_skey.c | 13 ++---
sys/crypto/blowfish/blowfish.h | 10 ++-
sys/crypto/blowfish/files.blowfish | 3 +-
6 files changed, 108 insertions(+), 21 deletions(-)
diffs (222 lines):
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/bf_cbc.c
--- a/sys/crypto/blowfish/bf_cbc.c Tue Aug 26 23:14:18 2003 +0000
+++ b/sys/crypto/blowfish/bf_cbc.c Tue Aug 26 23:51:12 2003 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: bf_cbc.c,v 1.9 2003/08/26 23:51:12 thorpej Exp $ */
+
/* crypto/bf/bf_cbc.c */
/* Copyright (C) 1995-1998 Eric Young (eay%cryptsoft.com@localhost)
* All rights reserved.
@@ -57,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bf_cbc.c,v 1.8 2002/09/08 07:52:41 elric Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bf_cbc.c,v 1.9 2003/08/26 23:51:12 thorpej Exp $");
#include <sys/types.h>
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/bf_ecb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/crypto/blowfish/bf_ecb.c Tue Aug 26 23:51:12 2003 +0000
@@ -0,0 +1,89 @@
+/* $NetBSD: bf_ecb.c,v 1.1 2003/08/26 23:51:13 thorpej Exp $ */
+
+/* crypto/bf/bf_ecb.c */
+/* Copyright (C) 1995-1998 Eric Young (eay%cryptsoft.com@localhost)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay%cryptsoft.com@localhost).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh%cryptsoft.com@localhost).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 cryptographic software written by
+ * Eric Young (eay%cryptsoft.com@localhost)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh%cryptsoft.com@localhost)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bf_ecb.c,v 1.1 2003/08/26 23:51:13 thorpej Exp $");
+
+#include <sys/types.h>
+
+#include <crypto/blowfish/blowfish.h>
+#include "bf_locl.h"
+
+/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
+ * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
+ * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
+ */
+
+void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
+ const BF_KEY *key, int encrypt)
+ {
+ BF_LONG l,d[2];
+
+ n2l(in,l); d[0]=l;
+ n2l(in,l); d[1]=l;
+ if (encrypt)
+ BF_encrypt(d,key);
+ else
+ BF_decrypt(d,key);
+ l=d[0]; l2n(l,out);
+ l=d[1]; l2n(l,out);
+ l=d[0]=d[1]=0;
+ }
+
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/bf_enc.c
--- a/sys/crypto/blowfish/bf_enc.c Tue Aug 26 23:14:18 2003 +0000
+++ b/sys/crypto/blowfish/bf_enc.c Tue Aug 26 23:51:12 2003 +0000
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bf_enc.c,v 1.6 2002/02/27 01:32:17 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bf_enc.c,v 1.7 2003/08/26 23:51:13 thorpej Exp $");
#include <sys/types.h>
#include <crypto/blowfish/blowfish.h>
@@ -75,9 +75,7 @@
/* XXX "data" is host endian */
void
-BF_encrypt(data, key)
- BF_LONG *data;
- BF_KEY *key;
+BF_encrypt(BF_LONG *data, const BF_KEY *key)
{
register BF_LONG l, r, *p, *s;
@@ -117,9 +115,7 @@
/* XXX "data" is host endian */
void
-BF_decrypt(data, key)
- BF_LONG *data;
- BF_KEY *key;
+BF_decrypt(BF_LONG *data, const BF_KEY *key)
{
register BF_LONG l, r, *p, *s;
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/bf_skey.c
--- a/sys/crypto/blowfish/bf_skey.c Tue Aug 26 23:14:18 2003 +0000
+++ b/sys/crypto/blowfish/bf_skey.c Tue Aug 26 23:51:12 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bf_skey.c,v 1.4 2002/02/27 01:32:17 itojun Exp $ */
+/* $NetBSD: bf_skey.c,v 1.5 2003/08/26 23:51:13 thorpej Exp $ */
/* $KAME: bf_skey.c,v 1.5 2000/11/06 13:58:08 itojun Exp $ */
/* crypto/bf/bf_skey.c */
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bf_skey.c,v 1.4 2002/02/27 01:32:17 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bf_skey.c,v 1.5 2003/08/26 23:51:13 thorpej Exp $");
#include <sys/types.h>
#include <sys/time.h>
@@ -74,16 +74,13 @@
#include <crypto/blowfish/bf_pi.h>
void
-BF_set_key(key, len, data)
- BF_KEY *key;
- int len;
- unsigned char *data;
+BF_set_key(BF_KEY *key, int len, const unsigned char *data)
{
int i;
BF_LONG *p, ri, in[2];
- unsigned char *d, *end;
+ const unsigned char *d, *end;
- memcpy((char *)key, (char *)&bf_init, sizeof(BF_KEY));
+ memcpy(key, &bf_init, sizeof(BF_KEY));
p = key->P;
if (len > ((BF_ROUNDS + 2) * 4))
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/blowfish.h
--- a/sys/crypto/blowfish/blowfish.h Tue Aug 26 23:14:18 2003 +0000
+++ b/sys/crypto/blowfish/blowfish.h Tue Aug 26 23:51:12 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: blowfish.h,v 1.5 2002/02/27 01:32:17 itojun Exp $ */
+/* $NetBSD: blowfish.h,v 1.6 2003/08/26 23:51:14 thorpej Exp $ */
/* $KAME: blowfish.h,v 1.10 2000/09/18 21:21:20 itojun Exp $ */
/* crypto/bf/blowfish.h */
@@ -80,11 +80,13 @@
BF_LONG S[4*256];
} BF_KEY;
-void BF_set_key __P((BF_KEY *, int, unsigned char *));
-void BF_encrypt __P((BF_LONG *, BF_KEY *));
-void BF_decrypt __P((BF_LONG *, BF_KEY *));
+void BF_set_key __P((BF_KEY *, int, const unsigned char *));
+void BF_encrypt __P((BF_LONG *, const BF_KEY *));
+void BF_decrypt __P((BF_LONG *, const BF_KEY *));
void BF_cbc_encrypt(const unsigned char *, unsigned char *, long,
const BF_KEY *, unsigned char *, int);
+void BF_ecb_encrypt(const unsigned char *, unsigned char *,
+ const BF_KEY *, int);
#ifdef __cplusplus
}
diff -r 9b64f417206d -r 3e495079c058 sys/crypto/blowfish/files.blowfish
--- a/sys/crypto/blowfish/files.blowfish Tue Aug 26 23:14:18 2003 +0000
+++ b/sys/crypto/blowfish/files.blowfish Tue Aug 26 23:51:12 2003 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: files.blowfish,v 1.1 2002/10/11 01:52:08 thorpej Exp $
+# $NetBSD: files.blowfish,v 1.2 2003/08/26 23:51:14 thorpej Exp $
define blowfish
+file crypto/blowfish/bf_ecb.c blowfish
file crypto/blowfish/bf_enc.c blowfish
file crypto/blowfish/bf_cbc.c blowfish
file crypto/blowfish/bf_skey.c blowfish
Home |
Main Index |
Thread Index |
Old Index