Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/opencrypto It's bad form to use the <opencrypto/rmd160.h...



details:   https://anonhg.NetBSD.org/src/rev/861c01ba2a58
branches:  trunk
changeset: 550909:861c01ba2a58
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Aug 25 04:09:57 2003 +0000

description:
It's bad form to use the <opencrypto/rmd160.h> header file while
using the crypto/ripemd160/rmd160.c implementation.  Remove the
opencrypto-local copies of these files entirely.

diffstat:

 sys/opencrypto/cryptodev.c  |    7 +-
 sys/opencrypto/cryptosoft.c |    7 +-
 sys/opencrypto/rmd160.c     |  368 --------------------------------------------
 sys/opencrypto/rmd160.h     |   41 ----
 sys/opencrypto/xform.c      |    6 +-
 sys/opencrypto/xform.h      |    4 +-
 6 files changed, 13 insertions(+), 420 deletions(-)

diffs (truncated from 519 to 300 lines):

diff -r b06f9e24ec0e -r 861c01ba2a58 sys/opencrypto/cryptodev.c
--- a/sys/opencrypto/cryptodev.c        Mon Aug 25 04:09:05 2003 +0000
+++ b/sys/opencrypto/cryptodev.c        Mon Aug 25 04:09:57 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptodev.c,v 1.5 2003/08/22 05:07:26 itojun Exp $ */
+/*     $NetBSD: cryptodev.c,v 1.6 2003/08/25 04:09:57 thorpej Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $        */
 /*     $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $   */
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.5 2003/08/22 05:07:26 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.6 2003/08/25 04:09:57 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,7 +50,8 @@
 #include <sys/conf.h>
 #include <sys/device.h>
 
-#include <opencrypto/rmd160.h>
+#include <crypto/ripemd160/rmd160.h>
+
 #include <opencrypto/cast.h>
 #include <opencrypto/skipjack.h>
 #include <opencrypto/blf.h>
diff -r b06f9e24ec0e -r 861c01ba2a58 sys/opencrypto/cryptosoft.c
--- a/sys/opencrypto/cryptosoft.c       Mon Aug 25 04:09:05 2003 +0000
+++ b/sys/opencrypto/cryptosoft.c       Mon Aug 25 04:09:57 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptosoft.c,v 1.5 2003/07/30 18:20:16 jonathan Exp $ */
+/*     $NetBSD: cryptosoft.c,v 1.6 2003/08/25 04:09:57 thorpej Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $       */
 /*     $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */
 
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.5 2003/07/30 18:20:16 jonathan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.6 2003/08/25 04:09:57 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -35,7 +35,8 @@
 #include <sys/md5.h>
 #include <sys/sha1.h>
 
-#include <opencrypto/rmd160.h>
+#include <crypto/ripemd160/rmd160.h>
+
 #include <opencrypto/cast.h>
 #include <opencrypto/skipjack.h>
 #include <opencrypto/blf.h>
diff -r b06f9e24ec0e -r 861c01ba2a58 sys/opencrypto/rmd160.c
--- a/sys/opencrypto/rmd160.c   Mon Aug 25 04:09:05 2003 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,368 +0,0 @@
-/*     $NetBSD: rmd160.c,v 1.1 2003/07/25 21:12:47 jonathan Exp $ */
-/*     $OpenBSD: rmd160.c,v 1.3 2001/09/26 21:40:13 markus Exp $       */
-
-/*
- * Copyright (c) 2001 Markus Friedl.  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.
- *
- * 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.
- */
-/*
- * Preneel, Bosselaers, Dobbertin, "The Cryptographic Hash Function RIPEMD-160",
- * RSA Laboratories, CryptoBytes, Volume 3, Number 2, Autumn 1997,
- * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rmd160.c,v 1.1 2003/07/25 21:12:47 jonathan Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/endian.h>
-#include <opencrypto/rmd160.h>
-
-#define PUT_64BIT_LE(cp, value) do { \
-       (cp)[7] = (value) >> 56; \
-       (cp)[6] = (value) >> 48; \
-       (cp)[5] = (value) >> 40; \
-       (cp)[4] = (value) >> 32; \
-       (cp)[3] = (value) >> 24; \
-       (cp)[2] = (value) >> 16; \
-       (cp)[1] = (value) >> 8; \
-       (cp)[0] = (value); } while (0)
-
-#define PUT_32BIT_LE(cp, value) do { \
-       (cp)[3] = (value) >> 24; \
-       (cp)[2] = (value) >> 16; \
-       (cp)[1] = (value) >> 8; \
-       (cp)[0] = (value); } while (0)
-
-#define        H0      0x67452301U
-#define        H1      0xEFCDAB89U
-#define        H2      0x98BADCFEU
-#define        H3      0x10325476U
-#define        H4      0xC3D2E1F0U
-
-#define        K0      0x00000000U
-#define        K1      0x5A827999U
-#define        K2      0x6ED9EBA1U
-#define        K3      0x8F1BBCDCU
-#define        K4      0xA953FD4EU
-
-#define        KK0     0x50A28BE6U
-#define        KK1     0x5C4DD124U
-#define        KK2     0x6D703EF3U
-#define        KK3     0x7A6D76E9U
-#define        KK4     0x00000000U
-
-/* rotate x left n bits.  */
-#define ROL(n, x) (((x) << (n)) | ((x) >> (32-(n))))
-
-#define F0(x, y, z) ((x) ^ (y) ^ (z))
-#define F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define F2(x, y, z) (((x) | (~y)) ^ (z))
-#define F3(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define F4(x, y, z) ((x) ^ ((y) | (~z)))
-
-#define R(a, b, c, d, e, Fj, Kj, sj, rj) \
-       do { \
-               a = ROL(sj, a + Fj(b,c,d) + X(rj) + Kj) + e; \
-               c = ROL(10, c); \
-       } while(0)
-
-#define X(i)   x[i]
-
-static u_char PADDING[64] = {
-       0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-void
-RMD160Init(RMD160_CTX *ctx)
-{
-       ctx->count = 0;
-       ctx->state[0] = H0;
-       ctx->state[1] = H1;
-       ctx->state[2] = H2;
-       ctx->state[3] = H3;
-       ctx->state[4] = H4;
-}
-
-void
-RMD160Update(RMD160_CTX *ctx, const u_char *input, u_int32_t len)
-{
-       u_int32_t have, off, need;
-
-       have = (ctx->count/8) % 64;
-       need = 64 - have;
-       ctx->count += 8 * len;
-       off = 0;
-
-       if (len >= need) {
-               if (have) {
-                       memcpy(ctx->buffer + have, input, need);
-                       RMD160Transform(ctx->state, ctx->buffer);
-                       off = need;
-                       have = 0;
-               }
-               /* now the buffer is empty */
-               while (off + 64 <= len) {
-                       RMD160Transform(ctx->state, input+off);
-                       off += 64;
-               }
-       }
-       if (off < len)
-               memcpy(ctx->buffer + have, input+off, len-off);
-}
-
-void
-RMD160Final(u_char digest[20], RMD160_CTX *ctx)
-{
-       int i;
-       u_char size[8];
-       u_int32_t padlen;
-
-       PUT_64BIT_LE(size, ctx->count);
-
-       /*
-        * pad to 64 byte blocks, at least one byte from PADDING plus 8 bytes
-        * for the size
-        */
-       padlen = 64 - ((ctx->count/8) % 64);
-       if (padlen < 1 + 8)
-               padlen += 64;
-       RMD160Update(ctx, PADDING, padlen - 8);         /* padlen - 8 <= 64 */
-       RMD160Update(ctx, size, 8);
-
-       if (digest != NULL)
-               for (i = 0; i < 5; i++)
-                       PUT_32BIT_LE(digest + i*4, ctx->state[i]);
-
-       memset(ctx, 0, sizeof (*ctx));
-}
-
-void
-RMD160Transform(u_int32_t state[5], const u_char block[64])
-{
-       u_int32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16];
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-       memcpy(x, block, 64);
-#else
-       int i;
-
-       for (i = 0; i < 16; i++)
-               x[i] = swap32(*(u_int32_t*)(block+i*4));
-#endif
-
-       a = state[0];
-       b = state[1];
-       c = state[2];
-       d = state[3];
-       e = state[4];
-
-       /* Round 1 */
-       R(a, b, c, d, e, F0, K0, 11,  0);
-       R(e, a, b, c, d, F0, K0, 14,  1);
-       R(d, e, a, b, c, F0, K0, 15,  2);
-       R(c, d, e, a, b, F0, K0, 12,  3);
-       R(b, c, d, e, a, F0, K0,  5,  4);
-       R(a, b, c, d, e, F0, K0,  8,  5);
-       R(e, a, b, c, d, F0, K0,  7,  6);
-       R(d, e, a, b, c, F0, K0,  9,  7);
-       R(c, d, e, a, b, F0, K0, 11,  8);
-       R(b, c, d, e, a, F0, K0, 13,  9);
-       R(a, b, c, d, e, F0, K0, 14, 10);
-       R(e, a, b, c, d, F0, K0, 15, 11);
-       R(d, e, a, b, c, F0, K0,  6, 12);
-       R(c, d, e, a, b, F0, K0,  7, 13);
-       R(b, c, d, e, a, F0, K0,  9, 14);
-       R(a, b, c, d, e, F0, K0,  8, 15); /* #15 */
-       /* Round 2 */
-       R(e, a, b, c, d, F1, K1,  7,  7);
-       R(d, e, a, b, c, F1, K1,  6,  4);
-       R(c, d, e, a, b, F1, K1,  8, 13);
-       R(b, c, d, e, a, F1, K1, 13,  1);
-       R(a, b, c, d, e, F1, K1, 11, 10);
-       R(e, a, b, c, d, F1, K1,  9,  6);
-       R(d, e, a, b, c, F1, K1,  7, 15);
-       R(c, d, e, a, b, F1, K1, 15,  3);
-       R(b, c, d, e, a, F1, K1,  7, 12);
-       R(a, b, c, d, e, F1, K1, 12,  0);
-       R(e, a, b, c, d, F1, K1, 15,  9);
-       R(d, e, a, b, c, F1, K1,  9,  5);
-       R(c, d, e, a, b, F1, K1, 11,  2);
-       R(b, c, d, e, a, F1, K1,  7, 14);
-       R(a, b, c, d, e, F1, K1, 13, 11);
-       R(e, a, b, c, d, F1, K1, 12,  8); /* #31 */
-       /* Round 3 */
-       R(d, e, a, b, c, F2, K2, 11,  3);
-       R(c, d, e, a, b, F2, K2, 13, 10);
-       R(b, c, d, e, a, F2, K2,  6, 14);
-       R(a, b, c, d, e, F2, K2,  7,  4);
-       R(e, a, b, c, d, F2, K2, 14,  9);
-       R(d, e, a, b, c, F2, K2,  9, 15);
-       R(c, d, e, a, b, F2, K2, 13,  8);
-       R(b, c, d, e, a, F2, K2, 15,  1);
-       R(a, b, c, d, e, F2, K2, 14,  2);
-       R(e, a, b, c, d, F2, K2,  8,  7);
-       R(d, e, a, b, c, F2, K2, 13,  0);
-       R(c, d, e, a, b, F2, K2,  6,  6);
-       R(b, c, d, e, a, F2, K2,  5, 13);
-       R(a, b, c, d, e, F2, K2, 12, 11);
-       R(e, a, b, c, d, F2, K2,  7,  5);
-       R(d, e, a, b, c, F2, K2,  5, 12); /* #47 */
-       /* Round 4 */
-       R(c, d, e, a, b, F3, K3, 11,  1);
-       R(b, c, d, e, a, F3, K3, 12,  9);
-       R(a, b, c, d, e, F3, K3, 14, 11);
-       R(e, a, b, c, d, F3, K3, 15, 10);
-       R(d, e, a, b, c, F3, K3, 14,  0);
-       R(c, d, e, a, b, F3, K3, 15,  8);
-       R(b, c, d, e, a, F3, K3,  9, 12);



Home | Main Index | Thread Index | Old Index