diff options
author | itojun <itojun@FreeBSD.org> | 2000-07-04 16:35:15 +0000 |
---|---|---|
committer | itojun <itojun@FreeBSD.org> | 2000-07-04 16:35:15 +0000 |
commit | 5f4e854de19331a53788d6100bbcd42845056bc1 (patch) | |
tree | 3ff8c876a5868b103fb8713055d83e29a3fa38d5 /sys/crypto/rc5 | |
parent | bdc16885232d771a99d7dfc247cd27a44cd061f9 (diff) | |
download | FreeBSD-src-5f4e854de19331a53788d6100bbcd42845056bc1.zip FreeBSD-src-5f4e854de19331a53788d6100bbcd42845056bc1.tar.gz |
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)
Diffstat (limited to 'sys/crypto/rc5')
-rw-r--r-- | sys/crypto/rc5/rc5.c | 5 | ||||
-rw-r--r-- | sys/crypto/rc5/rc5.h | 57 | ||||
-rw-r--r-- | sys/crypto/rc5/rc5_cbc.c | 18 |
3 files changed, 43 insertions, 37 deletions
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 <crypto/rc5/rc5.h> 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 <sys/param.h> #include <sys/systm.h> @@ -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 <crypto/rc5/rc5.h> +#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; } |