summaryrefslogtreecommitdiffstats
path: root/sys/crypto/cast128
diff options
context:
space:
mode:
authoritojun <itojun@FreeBSD.org>2000-07-04 16:35:15 +0000
committeritojun <itojun@FreeBSD.org>2000-07-04 16:35:15 +0000
commit5f4e854de19331a53788d6100bbcd42845056bc1 (patch)
tree3ff8c876a5868b103fb8713055d83e29a3fa38d5 /sys/crypto/cast128
parentbdc16885232d771a99d7dfc247cd27a44cd061f9 (diff)
downloadFreeBSD-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/cast128')
-rw-r--r--sys/crypto/cast128/cast128.c5
-rw-r--r--sys/crypto/cast128/cast128.h9
-rw-r--r--sys/crypto/cast128/cast128_cbc.c19
-rw-r--r--sys/crypto/cast128/cast128_subkey.h97
4 files changed, 68 insertions, 62 deletions
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 <suzuki@grelot.elec.ryukoku.ac.jp>
*/
@@ -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 <sys/param.h>
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 <suzuki@grelot.elec.ryukoku.ac.jp>
*/
@@ -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 <sys/param.h>
#include <sys/mbuf.h>
@@ -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 <sys/mbuf.h>
#include <crypto/cast128/cast128.h>
+#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 <suzuki@grelot.elec.ryukoku.ac.jp>
*/
@@ -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
OpenPOWER on IntegriCloud