From 5f4e854de19331a53788d6100bbcd42845056bc1 Mon Sep 17 00:00:00 2001 From: itojun Date: Tue, 4 Jul 2000 16:35:15 +0000 Subject: sync with kame tree as of july00. tons of bug fixes/improvements. API changes: - additional IPv6 ioctls - IPsec PF_KEY API was changed, it is mandatory to upgrade setkey(8). (also syntax change) --- sys/crypto/blowfish/bf_cbc.c | 5 +- sys/crypto/blowfish/bf_cbc_m.c | 21 ++++---- sys/crypto/blowfish/bf_enc.c | 5 +- sys/crypto/blowfish/bf_locl.h | 37 +++++++------- sys/crypto/blowfish/bf_pi.h | 5 +- sys/crypto/blowfish/bf_skey.c | 5 +- sys/crypto/blowfish/blowfish.h | 20 ++++---- sys/crypto/cast128/cast128.c | 5 +- sys/crypto/cast128/cast128.h | 9 ++-- sys/crypto/cast128/cast128_cbc.c | 19 ++++--- sys/crypto/cast128/cast128_subkey.h | 97 ++++++++++++++++++------------------ sys/crypto/des/des.h | 73 +++++++++++++-------------- sys/crypto/des/des_3cbc.c | 18 ++++--- sys/crypto/des/des_cbc.c | 21 ++++---- sys/crypto/des/des_ecb.c | 7 +-- sys/crypto/des/des_locl.h | 69 +++++++++++++------------- sys/crypto/des/des_setkey.c | 11 +++-- sys/crypto/des/podd.h | 5 +- sys/crypto/des/sk.h | 5 +- sys/crypto/des/spr.h | 5 +- sys/crypto/hmac_md5.c | 98 ------------------------------------- sys/crypto/hmac_md5.h | 37 -------------- sys/crypto/md5.c | 91 +++++++++++++++++----------------- sys/crypto/md5.h | 31 ++++++------ sys/crypto/rc5/rc5.c | 5 +- sys/crypto/rc5/rc5.h | 57 ++++++++++----------- sys/crypto/rc5/rc5_cbc.c | 18 ++++--- sys/crypto/sha1.c | 11 +++-- sys/crypto/sha1.h | 15 +++--- 29 files changed, 355 insertions(+), 450 deletions(-) delete mode 100644 sys/crypto/hmac_md5.c delete mode 100644 sys/crypto/hmac_md5.h (limited to 'sys/crypto') diff --git a/sys/crypto/blowfish/bf_cbc.c b/sys/crypto/blowfish/bf_cbc.c index 47092cb..6eb6d3b 100644 --- a/sys/crypto/blowfish/bf_cbc.c +++ b/sys/crypto/blowfish/bf_cbc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_cbc.c,v 1.3 2000/03/27 04:36:25 sumikawa Exp $ */ + /* crypto/bf/bf_cbc.c */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,8 +57,6 @@ * 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.] - * - * $FreeBSD$ */ #include diff --git a/sys/crypto/blowfish/bf_cbc_m.c b/sys/crypto/blowfish/bf_cbc_m.c index 20df977..088adad 100644 --- a/sys/crypto/blowfish/bf_cbc_m.c +++ b/sys/crypto/blowfish/bf_cbc_m.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_cbc_m.c,v 1.4 2000/06/14 10:41:16 itojun Exp $ */ + /* * heavily modified to accept mbuf, by Jun-ichiro itojun Itoh * , 1997. @@ -58,8 +61,6 @@ * 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.] - * - * $FreeBSD$ */ #include @@ -69,9 +70,9 @@ #include #include -#define panic(x) {printf(x); return;} +#define panic(x) do { printf(x); return EINVAL; } while (0) -void BF_cbc_encrypt_m(m0, skip, length, key, iv, mode) +int BF_cbc_encrypt_m(m0, skip, length, key, iv, mode) struct mbuf *m0; int skip; int length; @@ -89,19 +90,19 @@ void BF_cbc_encrypt_m(m0, skip, length, key, iv, mode) /* sanity checks */ if (m0->m_pkthdr.len < skip) { printf("mbuf length < skip\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < length) { printf("mbuf length < encrypt length\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < skip + length) { printf("mbuf length < skip + encrypt length\n"); - return; + return EINVAL; } if (length % 8) { printf("length is not multiple of 8\n"); - return; + return EINVAL; } m = m0; @@ -155,7 +156,7 @@ void BF_cbc_encrypt_m(m0, skip, length, key, iv, mode) while (in - &inbuf[0] < 8) { if (!p) panic("mbuf chain?\n"); - + *in++ = *p++; noff++; if (noff < n->m_len) @@ -337,4 +338,6 @@ void BF_cbc_encrypt_m(m0, skip, length, key, iv, mode) length -= 8; } } + + return 0; } diff --git a/sys/crypto/blowfish/bf_enc.c b/sys/crypto/blowfish/bf_enc.c index b24e538..6a3bef6 100644 --- a/sys/crypto/blowfish/bf_enc.c +++ b/sys/crypto/blowfish/bf_enc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_enc.c,v 1.3 2000/03/27 04:36:26 sumikawa Exp $ */ + /* crypto/bf/bf_enc.c */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,8 +57,6 @@ * 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.] - * - * $FreeBSD$ */ #include diff --git a/sys/crypto/blowfish/bf_locl.h b/sys/crypto/blowfish/bf_locl.h index e0b62f1..07598d2 100644 --- a/sys/crypto/blowfish/bf_locl.h +++ b/sys/crypto/blowfish/bf_locl.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_locl.h,v 1.3 2000/03/27 04:36:26 sumikawa Exp $ */ + /* crypto/bf/bf_local.h */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,8 +57,6 @@ * 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.] - * - * $FreeBSD$ */ /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * @@ -66,14 +67,14 @@ */ #undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ #undef c2ln -#define c2ln(c,l1,l2,n) { \ +#define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ @@ -89,14 +90,14 @@ } #undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* NOTE - c is not incremented as per l2c */ #undef l2cn -#define l2cn(l1,l2,c,n) { \ +#define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ @@ -111,7 +112,7 @@ } /* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ +#define n2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ @@ -127,7 +128,7 @@ } /* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ +#define l2nn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ @@ -142,13 +143,13 @@ } #undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ l|=((unsigned long)(*((c)++)))<<16L, \ l|=((unsigned long)(*((c)++)))<< 8L, \ l|=((unsigned long)(*((c)++)))) #undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) @@ -164,16 +165,16 @@ #undef BF_PTR #endif -#define BF_M 0x3fc -#define BF_0 22L -#define BF_1 14L -#define BF_2 6L -#define BF_3 2L /* left shift */ +#define BF_M 0x3fc +#define BF_0 22L +#define BF_1 14L +#define BF_2 6L +#define BF_3 2L /* left shift */ #if defined(BF_PTR2) /* This is basically a special pentium verson */ -#define BF_ENC(LL,R,S,P) \ +#define BF_ENC(LL,R,S,P) \ { \ BF_LONG t,u,v; \ u=R>>BF_0; \ @@ -196,7 +197,7 @@ /* This is normally very good */ -#define BF_ENC(LL,R,S,P) \ +#define BF_ENC(LL,R,S,P) \ LL^=P; \ LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \ *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \ @@ -208,7 +209,7 @@ * on the Alpha it is faster than the pointer versions (both 32 and 64 * versions of BF_LONG) */ -#define BF_ENC(LL,R,S,P) \ +#define BF_ENC(LL,R,S,P) \ LL^=P; \ LL^=((( S[ (R>>24L) ] + \ S[0x0100+((R>>16L)&0xff)])^ \ diff --git a/sys/crypto/blowfish/bf_pi.h b/sys/crypto/blowfish/bf_pi.h index 1a397e8..8982aac 100644 --- a/sys/crypto/blowfish/bf_pi.h +++ b/sys/crypto/blowfish/bf_pi.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_pi.h,v 1.3 2000/03/27 04:36:26 sumikawa Exp $ */ + /* crypto/bf/bf_pi.h */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,8 +57,6 @@ * 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.] - * - * $FreeBSD$ */ static BF_KEY bf_init= { diff --git a/sys/crypto/blowfish/bf_skey.c b/sys/crypto/blowfish/bf_skey.c index 04729e1..5717c3f 100644 --- a/sys/crypto/blowfish/bf_skey.c +++ b/sys/crypto/blowfish/bf_skey.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: bf_skey.c,v 1.3 2000/03/27 04:36:27 sumikawa Exp $ */ + /* crypto/bf/bf_skey.c */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,8 +57,6 @@ * 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.] - * - * $FreeBSD$ */ #include diff --git a/sys/crypto/blowfish/blowfish.h b/sys/crypto/blowfish/blowfish.h index d8e6d91..c96b4ec 100644 --- a/sys/crypto/blowfish/blowfish.h +++ b/sys/crypto/blowfish/blowfish.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: blowfish.h,v 1.4 2000/06/14 10:41:16 itojun Exp $ */ + /* crypto/bf/blowfish.h */ /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -54,28 +57,26 @@ * 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.] - * - * $FreeBSD$ */ #ifndef HEADER_BLOWFISH_H -#define HEADER_BLOWFISH_H +#define HEADER_BLOWFISH_H #ifdef __cplusplus extern "C" { #endif -#define BF_ENCRYPT 1 -#define BF_DECRYPT 0 +#define BF_ENCRYPT 1 +#define BF_DECRYPT 0 /* If you make this 'unsigned int' the pointer variants will work on * the Alpha, otherwise they will not. Strangly using the '8 byte' * BF_LONG and the default 'non-pointer' inner loop is the best configuration * for the Alpha */ -#define BF_LONG unsigned long +#define BF_LONG unsigned long -#define BF_ROUNDS 16 -#define BF_BLOCK 8 +#define BF_ROUNDS 16 +#define BF_BLOCK 8 typedef struct bf_key_st { @@ -99,8 +100,7 @@ char *BF_options(void); /* added by itojun */ struct mbuf; -void BF_cbc_encrypt_m(struct mbuf *, int, int, BF_KEY *, - unsigned char *, int); +int BF_cbc_encrypt_m(struct mbuf *, int, int, BF_KEY *, unsigned char *, int); #else diff --git a/sys/crypto/cast128/cast128.c b/sys/crypto/cast128/cast128.c index 72ed733..4df1be9 100644 --- a/sys/crypto/cast128/cast128.c +++ b/sys/crypto/cast128/cast128.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: cast128.c,v 1.3 2000/03/27 04:36:29 sumikawa Exp $ */ + /* * heavily modified by Tomomi Suzuki */ @@ -31,8 +34,6 @@ * 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$ */ #include diff --git a/sys/crypto/cast128/cast128.h b/sys/crypto/cast128/cast128.h index 31c0397..019c2de 100644 --- a/sys/crypto/cast128/cast128.h +++ b/sys/crypto/cast128/cast128.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: cast128.h,v 1.4 2000/06/14 10:41:16 itojun Exp $ */ + /* * heavily modified by Tomomi Suzuki */ @@ -31,12 +34,10 @@ * 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$ */ #ifndef RFC2144_CAST_128_H -#define RFC2144_CAST_128_H +#define RFC2144_CAST_128_H #include #include @@ -55,7 +56,7 @@ extern void cast128_encrypt_round12 __P((u_int8_t *, const u_int8_t *, u_int32_t *)); extern void cast128_decrypt_round12 __P((u_int8_t *, const u_int8_t *, u_int32_t *)); -extern void cast128_cbc_process __P((struct mbuf *, size_t, size_t, +extern int cast128_cbc_process __P((struct mbuf *, size_t, size_t, u_int32_t *, u_int8_t *, size_t, int)); #endif diff --git a/sys/crypto/cast128/cast128_cbc.c b/sys/crypto/cast128/cast128_cbc.c index 1dfe2d8..e4725a9 100644 --- a/sys/crypto/cast128/cast128_cbc.c +++ b/sys/crypto/cast128/cast128_cbc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: cast128_cbc.c,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,8 +28,6 @@ * 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$ */ /* * based on sys/crypto/des/des_cbc.c, rewrote by Tomomi Suzuki @@ -37,8 +38,9 @@ #include #include +#define panic(x) do { printf(x); return EINVAL; } while (0) -void +int cast128_cbc_process(m0, skip, length, subkey, iv, keylen, mode) struct mbuf *m0; size_t skip; @@ -55,20 +57,20 @@ cast128_cbc_process(m0, skip, length, subkey, iv, keylen, mode) /* sanity check */ if (m0->m_pkthdr.len < skip) { printf("cast128_cbc_process: mbuf length < skip\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < length) { printf("cast128_cbc_process: mbuf length < encrypt length\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < skip + length) { printf("cast128_cbc_process: " "mbuf length < skip + encrypt length\n"); - return; + return EINVAL; } if (length % 8) { printf("cast128_cbc_process: length is not multiple of 8\n"); - return; + return EINVAL; } m = m0; @@ -215,5 +217,6 @@ cast128_cbc_process(m0, skip, length, subkey, iv, keylen, mode) length -= 8; } -} + return 0; +} diff --git a/sys/crypto/cast128/cast128_subkey.h b/sys/crypto/cast128/cast128_subkey.h index 3fd0103..fafac45 100644 --- a/sys/crypto/cast128/cast128_subkey.h +++ b/sys/crypto/cast128/cast128_subkey.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: cast128_subkey.h,v 1.3 2000/03/27 04:36:30 sumikawa Exp $ */ + /* * heavily modified by Tomomi Suzuki */ @@ -31,61 +34,59 @@ * 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$ */ #ifndef RFC2144_CAST_128_SUBKEY_H -#define RFC2144_CAST_128_SUBKEY_H +#define RFC2144_CAST_128_SUBKEY_H -#define x0x1x2x3 buf[0] -#define x4x5x6x7 buf[1] -#define x8x9xAxB buf[2] -#define xCxDxExF buf[3] -#define z0z1z2z3 buf[4] -#define z4z5z6z7 buf[5] -#define z8z9zAzB buf[6] -#define zCzDzEzF buf[7] +#define x0x1x2x3 buf[0] +#define x4x5x6x7 buf[1] +#define x8x9xAxB buf[2] +#define xCxDxExF buf[3] +#define z0z1z2z3 buf[4] +#define z4z5z6z7 buf[5] +#define z8z9zAzB buf[6] +#define zCzDzEzF buf[7] -#define byte0(x) (((x) >> 24)) -#define byte1(x) (((x) >> 16) & 0xff) -#define byte2(x) (((x) >> 8) & 0xff) -#define byte3(x) (((x)) & 0xff) +#define byte0(x) (((x) >> 24)) +#define byte1(x) (((x) >> 16) & 0xff) +#define byte2(x) (((x) >> 8) & 0xff) +#define byte3(x) (((x)) & 0xff) -#define x0 byte0(buf[0]) -#define x1 byte1(buf[0]) -#define x2 byte2(buf[0]) -#define x3 byte3(buf[0]) -#define x4 byte0(buf[1]) -#define x5 byte1(buf[1]) -#define x6 byte2(buf[1]) -#define x7 byte3(buf[1]) -#define x8 byte0(buf[2]) -#define x9 byte1(buf[2]) -#define xA byte2(buf[2]) -#define xB byte3(buf[2]) -#define xC byte0(buf[3]) -#define xD byte1(buf[3]) -#define xE byte2(buf[3]) -#define xF byte3(buf[3]) -#define z0 byte0(buf[4]) -#define z1 byte1(buf[4]) -#define z2 byte2(buf[4]) -#define z3 byte3(buf[4]) -#define z4 byte0(buf[5]) -#define z5 byte1(buf[5]) -#define z6 byte2(buf[5]) -#define z7 byte3(buf[5]) -#define z8 byte0(buf[6]) -#define z9 byte1(buf[6]) -#define zA byte2(buf[6]) -#define zB byte3(buf[6]) -#define zC byte0(buf[7]) -#define zD byte1(buf[7]) -#define zE byte2(buf[7]) -#define zF byte3(buf[7]) +#define x0 byte0(buf[0]) +#define x1 byte1(buf[0]) +#define x2 byte2(buf[0]) +#define x3 byte3(buf[0]) +#define x4 byte0(buf[1]) +#define x5 byte1(buf[1]) +#define x6 byte2(buf[1]) +#define x7 byte3(buf[1]) +#define x8 byte0(buf[2]) +#define x9 byte1(buf[2]) +#define xA byte2(buf[2]) +#define xB byte3(buf[2]) +#define xC byte0(buf[3]) +#define xD byte1(buf[3]) +#define xE byte2(buf[3]) +#define xF byte3(buf[3]) +#define z0 byte0(buf[4]) +#define z1 byte1(buf[4]) +#define z2 byte2(buf[4]) +#define z3 byte3(buf[4]) +#define z4 byte0(buf[5]) +#define z5 byte1(buf[5]) +#define z6 byte2(buf[5]) +#define z7 byte3(buf[5]) +#define z8 byte0(buf[6]) +#define z9 byte1(buf[6]) +#define zA byte2(buf[6]) +#define zB byte3(buf[6]) +#define zC byte0(buf[7]) +#define zD byte1(buf[7]) +#define zE byte2(buf[7]) +#define zF byte3(buf[7]) -#define circular_leftshift(x, y) ( ((x) << (y)) | ((x) >> (32-(y))) ) +#define circular_leftshift(x, y) ( ((x) << (y)) | ((x) >> (32-(y))) ) #endif diff --git a/sys/crypto/des/des.h b/sys/crypto/des/des.h index 16a8129..536f0c9 100644 --- a/sys/crypto/des/des.h +++ b/sys/crypto/des/des.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des.h,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* lib/des/des.h */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,12 +46,10 @@ * 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.] - * - * $FreeBSD$ */ #ifndef HEADER_DES_H -#define HEADER_DES_H +#define HEADER_DES_H #ifdef __cplusplus extern "C" { @@ -57,7 +58,7 @@ extern "C" { /* 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 +#define DES_LONG unsigned long #endif typedef unsigned char des_cblock[8]; @@ -70,54 +71,54 @@ typedef struct des_ks_struct DES_LONG pad[2]; } ks; #undef _ -#define _ ks._ +#define _ ks._ } des_key_schedule[16]; -#define DES_KEY_SZ (sizeof(des_cblock)) -#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) +#define DES_KEY_SZ (sizeof(des_cblock)) +#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) -#define DES_ENCRYPT 1 -#define DES_DECRYPT 0 +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 -#define DES_CBC_MODE 0 -#define DES_PCBC_MODE 1 +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 -#define des_ecb2_encrypt(i,o,k1,k2,e) \ +#define des_ecb2_encrypt(i,o,k1,k2,e) \ des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) -#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) -#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) -#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) -#define C_Block des_cblock -#define Key_schedule des_key_schedule +#define C_Block des_cblock +#define Key_schedule des_key_schedule #ifdef KERBEROS -#define ENCRYPT DES_ENCRYPT -#define DECRYPT DES_DECRYPT +#define ENCRYPT DES_ENCRYPT +#define DECRYPT DES_DECRYPT #endif -#define KEY_SZ DES_KEY_SZ -#define string_to_key des_string_to_key -#define read_pw_string des_read_pw_string -#define random_key des_random_key -#define pcbc_encrypt des_pcbc_encrypt -#define set_key des_set_key -#define key_sched des_key_sched -#define ecb_encrypt des_ecb_encrypt -#define cbc_encrypt des_cbc_encrypt -#define ncbc_encrypt des_ncbc_encrypt -#define xcbc_encrypt des_xcbc_encrypt -#define cbc_cksum des_cbc_cksum -#define quad_cksum des_quad_cksum +#define KEY_SZ DES_KEY_SZ +#define string_to_key des_string_to_key +#define read_pw_string des_read_pw_string +#define random_key des_random_key +#define pcbc_encrypt des_pcbc_encrypt +#define set_key des_set_key +#define key_sched des_key_sched +#define ecb_encrypt des_ecb_encrypt +#define cbc_encrypt des_cbc_encrypt +#define ncbc_encrypt des_ncbc_encrypt +#define xcbc_encrypt des_xcbc_encrypt +#define cbc_cksum des_cbc_cksum +#define quad_cksum des_quad_cksum /* For compatibility with the MIT lib - eay 20/05/92 */ typedef des_key_schedule bit_64; -#define des_fixup_key_parity des_set_odd_parity -#define des_check_key_parity check_parity +#define des_fixup_key_parity des_set_odd_parity +#define des_check_key_parity check_parity extern int des_check_key; /* defaults to false */ extern int des_rw_mode; /* defaults to DES_PCBC_MODE */ @@ -139,7 +140,7 @@ DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output, void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, des_key_schedule schedule,des_cblock *ivec,int enc); */ -void des_cbc_encrypt(struct mbuf *, size_t, size_t, +int des_cbc_encrypt(struct mbuf *, size_t, size_t, des_key_schedule schedule,des_cblock *ivec, int enc); void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length, des_key_schedule schedule,des_cblock *ivec,int enc); @@ -149,7 +150,7 @@ void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length, void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, des_key_schedule sk1,des_key_schedule sk2, des_cblock *ivec1,des_cblock *ivec2,int enc); -extern void des_3cbc_process(struct mbuf *, size_t, size_t, +extern int des_3cbc_process(struct mbuf *, size_t, size_t, des_key_schedule *schedule, des_cblock *ivec, int mode); void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, long length,des_key_schedule schedule,des_cblock *ivec,int enc); diff --git a/sys/crypto/des/des_3cbc.c b/sys/crypto/des/des_3cbc.c index 7ddb06c..e675871 100644 --- a/sys/crypto/des/des_3cbc.c +++ b/sys/crypto/des/des_3cbc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des_3cbc.c,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,16 +28,15 @@ * 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$ */ /* * based on sys/crypto/des/des_cbc.c, rewrote by Tomomi Suzuki */ #include +#define panic(x) do { printf(x); return EINVAL; } while (0) -void des_3cbc_process(m0, skip, length, schedule, ivec, mode) +int des_3cbc_process(m0, skip, length, schedule, ivec, mode) struct mbuf *m0; size_t skip; size_t length; @@ -55,21 +57,21 @@ void des_3cbc_process(m0, skip, length, schedule, ivec, mode) /* sanity check */ if (m0->m_pkthdr.len < skip) { printf("des_3cbc_process: mbuf length < skip\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < length) { printf("des_3cbc_process: mbuf length < encrypt length\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < skip + length) { printf("des_3cbc_process: mbuf length < " "skip + encrypt length\n"); - return; + return EINVAL; } if (length % 8) { printf("des_3cbc_process: length(%lu) is not multiple of 8\n", (u_long)length); - return; + return EINVAL; } m = m0; @@ -242,5 +244,7 @@ void des_3cbc_process(m0, skip, length, schedule, ivec, mode) length -= 8; } + + return 0; } diff --git a/sys/crypto/des/des_cbc.c b/sys/crypto/des/des_cbc.c index 665352a..92de8f8 100644 --- a/sys/crypto/des/des_cbc.c +++ b/sys/crypto/des/des_cbc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des_cbc.c,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* * heavily modified by Yoshifumi Nishida . * then, completely rewrote by Jun-ichiro itojun Itoh , @@ -48,15 +51,13 @@ * 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.] - * - * $FreeBSD$ */ #include -#define panic(x) {printf(x); return;} +#define panic(x) do {printf(x); return EINVAL;} while (0) -void des_cbc_encrypt(m0, skip, length, schedule, ivec, mode) +int des_cbc_encrypt(m0, skip, length, schedule, ivec, mode) struct mbuf *m0; size_t skip; size_t length; @@ -75,19 +76,19 @@ void des_cbc_encrypt(m0, skip, length, schedule, ivec, mode) /* sanity checks */ if (m0->m_pkthdr.len < skip) { printf("mbuf length < skip\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < length) { printf("mbuf length < encrypt length\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < skip + length) { printf("mbuf length < skip + encrypt length\n"); - return; + return EINVAL; } if (length % 8) { printf("length is not multiple of 8\n"); - return; + return EINVAL; } m = m0; @@ -142,7 +143,7 @@ void des_cbc_encrypt(m0, skip, length, schedule, ivec, mode) while (in - &inbuf[0] < 8) { if (!p) panic("mbuf chain?\n"); - + *in++ = *p++; noff++; if (noff < n->m_len) @@ -325,4 +326,6 @@ void des_cbc_encrypt(m0, skip, length, schedule, ivec, mode) length -= 8; } } + + return 0; } diff --git a/sys/crypto/des/des_ecb.c b/sys/crypto/des/des_ecb.c index 9e74d6c..d828b91 100644 --- a/sys/crypto/des/des_ecb.c +++ b/sys/crypto/des/des_ecb.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des_ecb.c,v 1.3 2000/03/27 04:36:33 sumikawa Exp $ */ + /* crypto/des/ecb_enc.c */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ #include @@ -67,7 +68,7 @@ char *des_options() return("des(idx,long)"); #endif } - + void des_ecb_encrypt(input, output, ks, encrypt) des_cblock (*input); diff --git a/sys/crypto/des/des_locl.h b/sys/crypto/des/des_locl.h index ff49cc7..ae6e828 100644 --- a/sys/crypto/des/des_locl.h +++ b/sys/crypto/des/des_locl.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des_locl.h,v 1.4 2000/03/27 04:43:46 sumikawa Exp $ */ + /* lib/des/des_locl.h */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * @@ -60,11 +61,11 @@ #include #ifndef HEADER_DES_LOCL_H -#define HEADER_DES_LOCL_H +#define HEADER_DES_LOCL_H #if defined(WIN32) || defined(WIN16) #ifndef MSDOS -#define MSDOS +#define MSDOS #endif #endif @@ -89,7 +90,7 @@ #include #include #ifndef RAND -#define RAND +#define RAND #endif #undef NOPROTO #endif @@ -105,7 +106,7 @@ #endif #ifndef RAND -#define RAND +#define RAND #endif #ifdef linux @@ -113,13 +114,13 @@ #endif #ifdef MSDOS -#define getpid() 2 -#define RAND +#define getpid() 2 +#define RAND #undef NOPROTO #endif #if defined(NOCONST) -#define const +#define const #endif #ifdef __STDC__ @@ -127,24 +128,24 @@ #endif #ifdef RAND -#define srandom(s) srand(s) -#define random rand +#define srandom(s) srand(s) +#define random rand #endif -#define ITERATIONS 16 -#define HALF_ITERATIONS 8 +#define ITERATIONS 16 +#define HALF_ITERATIONS 8 /* used in des_read and des_write */ -#define MAXWRITE (1024*16) -#define BSIZE (MAXWRITE+4) +#define MAXWRITE (1024*16) +#define BSIZE (MAXWRITE+4) -#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ +#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ l|=((DES_LONG)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<<24L) /* NOTE - c is not incremented as per c2l */ -#define c2ln(c,l1,l2,n) { \ +#define c2ln(c,l1,l2,n) { \ c+=n; \ l1=l2=0; \ switch (n) { \ @@ -159,27 +160,27 @@ } \ } -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>>24L)&0xff)) /* replacements for htonl and ntohl since I have no idea what to do * when faced with machines with 8 byte longs. */ -#define HDRSIZE 4 +#define HDRSIZE 4 -#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ +#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ l|=((DES_LONG)(*((c)++)))<<16L, \ l|=((DES_LONG)(*((c)++)))<< 8L, \ l|=((DES_LONG)(*((c)++)))) -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ *((c)++)=(unsigned char)(((l) )&0xff)) /* NOTE - c is not incremented as per l2c */ -#define l2cn(l1,l2,c,n) { \ +#define l2cn(l1,l2,c,n) { \ c+=n; \ switch (n) { \ case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ @@ -207,7 +208,7 @@ * bytes, probably an issue of accessing non-word aligned objects :-( */ #ifdef DES_PTR -#define D_ENCRYPT(L,R,S) { \ +#define D_ENCRYPT(L,R,S) { \ u=((R^s[S ])<<2); \ t= R^s[S+1]; \ t=ROTATE(t,2); \ @@ -222,7 +223,7 @@ *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24)&0xfc))); } #else /* original version */ #ifdef undef -#define D_ENCRYPT(L,R,S) \ +#define D_ENCRYPT(L,R,S) \ U.l=R^s[S+1]; \ T.s[0]=((U.s[0]>>4)|(U.s[1]<<12))&0x3f3f; \ T.s[1]=((U.s[1]>>4)|(U.s[0]<<12))&0x3f3f; \ @@ -236,7 +237,7 @@ des_SPtrans[4][(U.c[2])]| \ des_SPtrans[6][(U.c[3])]; #else -#define D_ENCRYPT(Q,R,S) {\ +#define D_ENCRYPT(Q,R,S) {\ u=(R^s[S ]); \ t=R^s[S+1]; \ t=ROTATE(t,4); \ @@ -288,11 +289,11 @@ I first got ~42 operations without xors. When I remembered how to use xors :-) I got it to its final state. */ -#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ +#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ (b)^=(t),\ (a)^=((t)<<(n))) -#define IP(l,r) \ +#define IP(l,r) \ { \ register DES_LONG tt; \ PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ @@ -302,7 +303,7 @@ PERM_OP(r,l,tt, 1,0x55555555L); \ } -#define FP(l,r) \ +#define FP(l,r) \ { \ register DES_LONG tt; \ PERM_OP(l,r,tt, 1,0x55555555L); \ @@ -315,10 +316,10 @@ /* -#define mbuf2char(i_mbuf, i_index, in) \ +#define mbuf2char(i_mbuf, i_index, in) \ { \ - register int i; \ - struct mbuf *m; \ + register int i; \ + struct mbuf *m; \ char *buf; \ m = i_mbuf; \ for (i = 0; i < 8; i ++){ \ @@ -330,10 +331,10 @@ } -#define char2mbuf(o_mbuf, o_index, out) \ +#define char2mbuf(o_mbuf, o_index, out) \ { \ - register int i; \ - struct mbuf *m; \ + register int i; \ + struct mbuf *m; \ char *buf; \ m = o_mbuf; \ for (i = 0; i < 8; i ++){ \ diff --git a/sys/crypto/des/des_setkey.c b/sys/crypto/des/des_setkey.c index 9747b52..48d13fc 100644 --- a/sys/crypto/des/des_setkey.c +++ b/sys/crypto/des/des_setkey.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: des_setkey.c,v 1.3 2000/03/27 04:36:33 sumikawa Exp $ */ + /* crypto/des/set_key.c */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ /* set_key.c v 1.4 eay 24/9/91 @@ -97,7 +98,7 @@ des_cblock (*key); * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference * (and actual cblock values). */ -#define NUM_WEAK_KEY 16 +#define NUM_WEAK_KEY 16 static des_cblock weak_keys[NUM_WEAK_KEY]={ /* weak keys */ {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, @@ -142,7 +143,7 @@ des_cblock (*key); * (a)=((a)^((t)<<(n)))) */ -#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ +#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n)))) /* return 0 if key parity is odd (correct), @@ -223,7 +224,7 @@ des_key_schedule schedule; /* table contained 0213 4657 */ *(k++)=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; s= ((s>>16L)|(t&0xffff0000L)); - + s=(s<<4L)|(s>>28L); *(k++)=s&0xffffffffL; } diff --git a/sys/crypto/des/podd.h b/sys/crypto/des/podd.h index a0efc55..fb54c39 100644 --- a/sys/crypto/des/podd.h +++ b/sys/crypto/des/podd.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: podd.h,v 1.3 2000/03/27 04:36:34 sumikawa Exp $ */ + /* crypto/des/podd.h */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ static const unsigned char odd_parity[256]={ diff --git a/sys/crypto/des/sk.h b/sys/crypto/des/sk.h index 1a1469c..24bde96 100644 --- a/sys/crypto/des/sk.h +++ b/sys/crypto/des/sk.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: sk.h,v 1.3 2000/03/27 04:36:34 sumikawa Exp $ */ + /* crypto/des/sk.h */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ static const DES_LONG des_skb[8][64]={ diff --git a/sys/crypto/des/spr.h b/sys/crypto/des/spr.h index c340f58..606e12b 100644 --- a/sys/crypto/des/spr.h +++ b/sys/crypto/des/spr.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: spr.h,v 1.3 2000/03/27 04:36:35 sumikawa Exp $ */ + /* crypto/des/spr.h */ /* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au) * All rights reserved. @@ -43,8 +46,6 @@ * 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.] - * - * $FreeBSD$ */ static const DES_LONG des_SPtrans[8][64]={ diff --git a/sys/crypto/hmac_md5.c b/sys/crypto/hmac_md5.c deleted file mode 100644 index 5302dbe..0000000 --- a/sys/crypto/hmac_md5.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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$ - */ - -/* - * Based on sample code appeared on RFC2104. - */ - -#include -#include -#include -#include -#include - -#include - -void -hmac_md5(src0, srclen, key0, keylen, digest) - caddr_t src0; - size_t srclen; - caddr_t key0; - size_t keylen; - caddr_t digest; -{ - u_int8_t *src; - u_int8_t *key; - u_int8_t tk[16]; - u_int8_t ipad[65]; - u_int8_t opad[65]; - size_t i; - - src = (u_int8_t *)src0; - key = (u_int8_t *)key0; - - /* - * compress the key into 16bytes, if key is too long. - */ - if (64 < keylen) { - md5_init(); - md5_loop(key, keylen); - md5_pad(); - md5_result(&tk[0]); - key = &tk[0]; - keylen = 16; - } - - /* - * - */ - bzero(&ipad[0], sizeof ipad); - bzero(&opad[0], sizeof opad); - bcopy(key, &ipad[0], keylen); - bcopy(key, &opad[0], keylen); - - for (i = 0; i < 64; i++) { - ipad[i] ^= 0x36; - opad[i] ^= 0x5c; - } - - md5_init(); - md5_loop(&ipad[0], 64); - md5_loop(src, srclen); - md5_pad(); - md5_result((u_int8_t *)digest); - - md5_init(); - md5_loop(&opad[0], 64); - md5_loop((u_int8_t *)digest, 16); - md5_pad(); - md5_result((u_int8_t *)digest); -} diff --git a/sys/crypto/hmac_md5.h b/sys/crypto/hmac_md5.h deleted file mode 100644 index 86558fc..0000000 --- a/sys/crypto/hmac_md5.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * 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. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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$ - */ - -#ifndef _NETINET6_HMAC_MD5_H_ -#define _NETINET6_HMAC_MD5_H_ - -extern void hmac_md5 __P((caddr_t, size_t, caddr_t, size_t, caddr_t)); - -#endif /* ! _NETINET6_HMAC_MD5_H_*/ diff --git a/sys/crypto/md5.c b/sys/crypto/md5.c index 211c89b..e827700 100644 --- a/sys/crypto/md5.c +++ b/sys/crypto/md5.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: md5.c,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,8 +28,6 @@ * 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$ */ #include @@ -35,61 +36,61 @@ #include #include -#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) +#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) -#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) -#define G(X, Y, Z) (((X) & (Z)) | ((Y) & (~Z))) -#define H(X, Y, Z) ((X) ^ (Y) ^ (Z)) -#define I(X, Y, Z) ((Y) ^ ((X) | (~Z))) +#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) +#define G(X, Y, Z) (((X) & (Z)) | ((Y) & (~Z))) +#define H(X, Y, Z) ((X) ^ (Y) ^ (Z)) +#define I(X, Y, Z) ((Y) ^ ((X) | (~Z))) -#define ROUND1(a, b, c, d, k, s, i) { \ +#define ROUND1(a, b, c, d, k, s, i) { \ (a) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \ (a) = SHIFT((a), (s)); \ (a) = (b) + (a); \ } -#define ROUND2(a, b, c, d, k, s, i) { \ +#define ROUND2(a, b, c, d, k, s, i) { \ (a) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \ (a) = SHIFT((a), (s)); \ (a) = (b) + (a); \ } -#define ROUND3(a, b, c, d, k, s, i) { \ +#define ROUND3(a, b, c, d, k, s, i) { \ (a) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \ (a) = SHIFT((a), (s)); \ (a) = (b) + (a); \ } -#define ROUND4(a, b, c, d, k, s, i) { \ +#define ROUND4(a, b, c, d, k, s, i) { \ (a) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \ (a) = SHIFT((a), (s)); \ (a) = (b) + (a); \ } -#define Sa 7 -#define Sb 12 -#define Sc 17 -#define Sd 22 +#define Sa 7 +#define Sb 12 +#define Sc 17 +#define Sd 22 -#define Se 5 -#define Sf 9 -#define Sg 14 -#define Sh 20 +#define Se 5 +#define Sf 9 +#define Sg 14 +#define Sh 20 -#define Si 4 -#define Sj 11 -#define Sk 16 -#define Sl 23 +#define Si 4 +#define Sj 11 +#define Sk 16 +#define Sl 23 -#define Sm 6 -#define Sn 10 -#define So 15 -#define Sp 21 +#define Sm 6 +#define Sn 10 +#define So 15 +#define Sp 21 -#define MD5_A0 0x67452301 -#define MD5_B0 0xefcdab89 -#define MD5_C0 0x98badcfe -#define MD5_D0 0x10325476 +#define MD5_A0 0x67452301 +#define MD5_B0 0xefcdab89 +#define MD5_C0 0x98badcfe +#define MD5_D0 0x10325476 /* Integer part of 4294967296 times abs(sin(i)), where i is in radians. */ static const u_int32_t T[65] = { @@ -123,7 +124,7 @@ static const u_int8_t md5_paddat[MD5_BUFLEN] = { 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, }; static void md5_calc __P((u_int8_t *, md5_ctxt *)); @@ -158,7 +159,7 @@ void md5_loop(ctxt, input, len) for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) { md5_calc((u_int8_t *)(input + i), ctxt); } - + ctxt->md5_i = len - i; bcopy((void *)(input + i), (void *)ctxt->md5_buf, ctxt->md5_i); } else { @@ -173,7 +174,7 @@ void md5_pad(ctxt) { u_int gap; - /* Don't count up padding. Keep md5_n. */ + /* Don't count up padding. Keep md5_n. */ gap = MD5_BUFLEN - ctxt->md5_i; if (gap > 8) { bcopy((void *)md5_paddat, @@ -189,7 +190,7 @@ void md5_pad(ctxt) MD5_BUFLEN - sizeof(ctxt->md5_n)); } - /* 8 byte word */ + /* 8 byte word */ #if BYTE_ORDER == LITTLE_ENDIAN bcopy(&ctxt->md5_n8[0], &ctxt->md5_buf[56], 8); #endif @@ -241,7 +242,7 @@ static void md5_calc(b64, ctxt) u_int32_t D = ctxt->md5_std; #if BYTE_ORDER == LITTLE_ENDIAN u_int32_t *X = (u_int32_t *)b64; -#endif +#endif #if BYTE_ORDER == BIG_ENDIAN /* 4 byte words */ /* what a brute force but fast! */ @@ -272,7 +273,7 @@ static void md5_calc(b64, ctxt) ROUND1(C, D, A, B, 10, Sc, 11); ROUND1(B, C, D, A, 11, Sd, 12); ROUND1(A, B, C, D, 12, Sa, 13); ROUND1(D, A, B, C, 13, Sb, 14); ROUND1(C, D, A, B, 14, Sc, 15); ROUND1(B, C, D, A, 15, Sd, 16); - + ROUND2(A, B, C, D, 1, Se, 17); ROUND2(D, A, B, C, 6, Sf, 18); ROUND2(C, D, A, B, 11, Sg, 19); ROUND2(B, C, D, A, 0, Sh, 20); ROUND2(A, B, C, D, 5, Se, 21); ROUND2(D, A, B, C, 10, Sf, 22); @@ -290,14 +291,14 @@ static void md5_calc(b64, ctxt) ROUND3(C, D, A, B, 3, Sk, 43); ROUND3(B, C, D, A, 6, Sl, 44); ROUND3(A, B, C, D, 9, Si, 45); ROUND3(D, A, B, C, 12, Sj, 46); ROUND3(C, D, A, B, 15, Sk, 47); ROUND3(B, C, D, A, 2, Sl, 48); - - ROUND4(A, B, C, D, 0, Sm, 49); ROUND4(D, A, B, C, 7, Sn, 50); - ROUND4(C, D, A, B, 14, So, 51); ROUND4(B, C, D, A, 5, Sp, 52); - ROUND4(A, B, C, D, 12, Sm, 53); ROUND4(D, A, B, C, 3, Sn, 54); - ROUND4(C, D, A, B, 10, So, 55); ROUND4(B, C, D, A, 1, Sp, 56); - ROUND4(A, B, C, D, 8, Sm, 57); ROUND4(D, A, B, C, 15, Sn, 58); - ROUND4(C, D, A, B, 6, So, 59); ROUND4(B, C, D, A, 13, Sp, 60); - ROUND4(A, B, C, D, 4, Sm, 61); ROUND4(D, A, B, C, 11, Sn, 62); + + ROUND4(A, B, C, D, 0, Sm, 49); ROUND4(D, A, B, C, 7, Sn, 50); + ROUND4(C, D, A, B, 14, So, 51); ROUND4(B, C, D, A, 5, Sp, 52); + ROUND4(A, B, C, D, 12, Sm, 53); ROUND4(D, A, B, C, 3, Sn, 54); + ROUND4(C, D, A, B, 10, So, 55); ROUND4(B, C, D, A, 1, Sp, 56); + ROUND4(A, B, C, D, 8, Sm, 57); ROUND4(D, A, B, C, 15, Sn, 58); + ROUND4(C, D, A, B, 6, So, 59); ROUND4(B, C, D, A, 13, Sp, 60); + ROUND4(A, B, C, D, 4, Sm, 61); ROUND4(D, A, B, C, 11, Sn, 62); ROUND4(C, D, A, B, 2, So, 63); ROUND4(B, C, D, A, 9, Sp, 64); ctxt->md5_sta += A; diff --git a/sys/crypto/md5.h b/sys/crypto/md5.h index 61eb2ac..2418199 100644 --- a/sys/crypto/md5.h +++ b/sys/crypto/md5.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,14 +28,12 @@ * 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$ */ #ifndef _NETINET6_MD5_H_ -#define _NETINET6_MD5_H_ +#define _NETINET6_MD5_H_ -#define MD5_BUFLEN 64 +#define MD5_BUFLEN 64 typedef struct { union { @@ -40,18 +41,18 @@ typedef struct { u_int8_t md5_state8[16]; } md5_st; -#define md5_sta md5_st.md5_state32[0] -#define md5_stb md5_st.md5_state32[1] -#define md5_stc md5_st.md5_state32[2] -#define md5_std md5_st.md5_state32[3] -#define md5_st8 md5_st.md5_state8 +#define md5_sta md5_st.md5_state32[0] +#define md5_stb md5_st.md5_state32[1] +#define md5_stc md5_st.md5_state32[2] +#define md5_std md5_st.md5_state32[3] +#define md5_st8 md5_st.md5_state8 union { u_int64_t md5_count64; u_int8_t md5_count8[8]; } md5_count; -#define md5_n md5_count.md5_count64 -#define md5_n8 md5_count.md5_count8 +#define md5_n md5_count.md5_count64 +#define md5_n8 md5_count.md5_count8 u_int md5_i; u_int8_t md5_buf[MD5_BUFLEN]; @@ -63,10 +64,10 @@ extern void md5_pad __P((md5_ctxt *)); extern void md5_result __P((u_int8_t *, md5_ctxt *)); /* compatibility */ -#define MD5_CTX md5_ctxt -#define MD5Init(x) md5_init((x)) -#define MD5Update(x, y, z) md5_loop((x), (y), (z)) -#define MD5Final(x, y) \ +#define MD5_CTX md5_ctxt +#define MD5Init(x) md5_init((x)) +#define MD5Update(x, y, z) md5_loop((x), (y), (z)) +#define MD5Final(x, y) \ do { \ md5_pad((y)); \ md5_result((x), (y)); \ diff --git a/sys/crypto/rc5/rc5.c b/sys/crypto/rc5/rc5.c index 52ccdd1..99a8ac6 100644 --- a/sys/crypto/rc5/rc5.c +++ b/sys/crypto/rc5/rc5.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: rc5.c,v 1.3 2000/03/27 04:36:36 sumikawa Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,8 +28,6 @@ * 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$ */ #include diff --git a/sys/crypto/rc5/rc5.h b/sys/crypto/rc5/rc5.h index 20c235b..ae2339b 100644 --- a/sys/crypto/rc5/rc5.h +++ b/sys/crypto/rc5/rc5.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: rc5.h,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,12 +28,10 @@ * 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$ */ #ifndef _RFC2040_RC5_H_ -#define _RFC2040_RC5_H_ +#define _RFC2040_RC5_H_ #include #include @@ -41,46 +42,46 @@ */ typedef u_int32_t RC5_WORD; -#define W (32) -#define WW (W / 8) -#define ROT_MASK (W - 1) -#define BB ((2 * W) / 8) +#define W (32) +#define WW (W / 8) +#define ROT_MASK (W - 1) +#define BB ((2 * W) / 8) -#define SHLL(x, s) ((RC5_WORD)((x) << ((s)&ROT_MASK))) -#define SHLR(x, s, w) ((RC5_WORD)((x) >> ((w)-((s)&ROT_MASK)))) -#define SHRL(x, s, w) ((RC5_WORD)((x) << ((w)-((s)&ROT_MASK)))) -#define SHRR(x, s) ((RC5_WORD)((x) >> ((s)&ROT_MASK))) +#define SHLL(x, s) ((RC5_WORD)((x) << ((s)&ROT_MASK))) +#define SHLR(x, s, w) ((RC5_WORD)((x) >> ((w)-((s)&ROT_MASK)))) +#define SHRL(x, s, w) ((RC5_WORD)((x) << ((w)-((s)&ROT_MASK)))) +#define SHRR(x, s) ((RC5_WORD)((x) >> ((s)&ROT_MASK))) -#define ROTL(x, s, w) ((RC5_WORD)(SHLL((x), (s))|SHLR((x), (s), (w)))) -#define ROTR(x, s, w) ((RC5_WORD)(SHRL((x), (s), (w))|SHRR((x), (s)))) +#define ROTL(x, s, w) ((RC5_WORD)(SHLL((x), (s))|SHLR((x), (s), (w)))) +#define ROTR(x, s, w) ((RC5_WORD)(SHRL((x), (s), (w))|SHRR((x), (s)))) -#define P16 0xb7e1 -#define Q16 0x9e37 -#define P32 0xb7e15163 -#define Q32 0x9e3779b9 -#define P64 0xb7e151628aed2a6b -#define Q64 0x9e3779b97f4a7c15 +#define P16 0xb7e1 +#define Q16 0x9e37 +#define P32 0xb7e15163 +#define Q32 0x9e3779b9 +#define P64 0xb7e151628aed2a6b +#define Q64 0x9e3779b97f4a7c15 #if W == 16 -#define Pw P16 -#define Qw Q16 +#define Pw P16 +#define Qw Q16 #elif W == 32 -#define Pw P32 -#define Qw Q32 +#define Pw P32 +#define Qw Q32 #elif W == 64 -#define Pw P64 -#define Qw Q64 +#define Pw P64 +#define Qw Q64 #endif -#define RC5_ENCRYPT 1 -#define RC5_DECRYPT 0 +#define RC5_ENCRYPT 1 +#define RC5_DECRYPT 0 extern void set_rc5_expandkey __P((RC5_WORD *, u_int8_t *, size_t, int)); extern void rc5_encrypt_round16 __P((u_int8_t *, const u_int8_t *, const RC5_WORD *)); extern void rc5_decrypt_round16 __P((u_int8_t *, const u_int8_t *, const RC5_WORD *)); -extern void rc5_cbc_process __P((struct mbuf *, size_t, size_t, RC5_WORD *, +extern int rc5_cbc_process __P((struct mbuf *, size_t, size_t, RC5_WORD *, u_int8_t *, int)); #endif diff --git a/sys/crypto/rc5/rc5_cbc.c b/sys/crypto/rc5/rc5_cbc.c index c588eda..5972cc6 100644 --- a/sys/crypto/rc5/rc5_cbc.c +++ b/sys/crypto/rc5/rc5_cbc.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: rc5_cbc.c,v 1.4 2000/06/14 10:41:17 itojun Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,16 +28,15 @@ * 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$ */ /* * based on sys/crypto/des/des_cbc.c, rewrote by Tomomi Suzuki */ #include +#define panic(x) do { printf(x); return EINVAL; } while (0) -void +int rc5_cbc_process(m0, skip, length, e_key, iv, mode) struct mbuf *m0; size_t skip; @@ -50,21 +52,21 @@ rc5_cbc_process(m0, skip, length, e_key, iv, mode) /* sanity check */ if (m0->m_pkthdr.len < skip) { printf("rc5_cbc_process: mbuf length < skip\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < length) { printf("rc5_cbc_process: mbuf length < encrypt length\n"); - return; + return EINVAL; } if (m0->m_pkthdr.len < skip + length) { printf("rc5_cbc_process: mbuf length < " "skip + encrypt length\n"); - return; + return EINVAL; } if (length % 8) { printf("rc5_cbc_process: length(%lu)is not multipleof 8\n", (u_long)length); - return; + return EINVAL; } m = m0; @@ -207,5 +209,7 @@ rc5_cbc_process(m0, skip, length, e_key, iv, mode) length -= 8; } + + return 0; } diff --git a/sys/crypto/sha1.c b/sys/crypto/sha1.c index 337f944..815bc5a 100644 --- a/sys/crypto/sha1.c +++ b/sys/crypto/sha1.c @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: sha1.c,v 1.4 2000/03/27 04:36:23 sumikawa Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,8 +28,6 @@ * 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$ */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) @@ -218,16 +219,18 @@ sha1_pad(ctxt) } void -sha1_loop(ctxt, input, len) +sha1_loop(ctxt, input0, len) struct sha1_ctxt *ctxt; - const u_char *input; + const caddr_t input0; size_t len; { + const u_int8_t *input; size_t gaplen; size_t gapstart; size_t off; size_t copysiz; + input = (const u_int8_t *)input0; off = 0; while (off < len) { diff --git a/sys/crypto/sha1.h b/sys/crypto/sha1.h index dc7966c..2e87f05 100644 --- a/sys/crypto/sha1.h +++ b/sys/crypto/sha1.h @@ -1,3 +1,6 @@ +/* $FreeBSD$ */ +/* $KAME: sha1.h,v 1.5 2000/03/27 04:36:23 sumikawa Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -25,8 +28,6 @@ * 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$ */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) @@ -35,7 +36,7 @@ */ #ifndef _NETINET6_SHA1_H_ -#define _NETINET6_SHA1_H_ +#define _NETINET6_SHA1_H_ struct sha1_ctxt { union { @@ -56,14 +57,14 @@ struct sha1_ctxt { #ifdef _KERNEL extern void sha1_init __P((struct sha1_ctxt *)); extern void sha1_pad __P((struct sha1_ctxt *)); -extern void sha1_loop __P((struct sha1_ctxt *, const u_char *, size_t)); +extern void sha1_loop __P((struct sha1_ctxt *, const caddr_t, size_t)); extern void sha1_result __P((struct sha1_ctxt *, caddr_t)); /* compatibilty with other SHA1 source codes */ typedef struct sha1_ctxt SHA1_CTX; -#define SHA1Init(x) sha1_init((x)) -#define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) -#define SHA1Final(x, y) sha1_result((y), (x)) +#define SHA1Init(x) sha1_init((x)) +#define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) +#define SHA1Final(x, y) sha1_result((y), (x)) #endif #define SHA1_RESULTLEN (160/8) -- cgit v1.1