]> git.saurik.com Git - apple/xnu.git/blob - bsd/crypto/cast128/cast128_subkey.h
xnu-344.tar.gz
[apple/xnu.git] / bsd / crypto / cast128 / cast128_subkey.h
1 /* $FreeBSD: src/sys/crypto/cast128/cast128_subkey.h,v 1.1.2.1 2000/07/15 07:14:21 kris Exp $ */
2 /* $KAME: cast128_subkey.h,v 1.3 2000/03/27 04:36:30 sumikawa Exp $ */
3
4 /*
5 * heavily modified by Tomomi Suzuki <suzuki@grelot.elec.ryukoku.ac.jp>
6 */
7 /*
8 * The CAST-128 Encryption Algorithm (RFC 2144)
9 *
10 * original implementation <Hideo "Sir MaNMOS" Morisita>
11 * 1997/08/21
12 */
13 /*
14 * Copyright (C) 1997 Hideo "Sir MANMOS" Morishita
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY Hideo "Sir MaNMOS" Morishita ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL Hideo "Sir MaNMOS" Morishita BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39 #ifndef RFC2144_CAST_128_SUBKEY_H
40 #define RFC2144_CAST_128_SUBKEY_H
41
42 #define x0x1x2x3 buf[0]
43 #define x4x5x6x7 buf[1]
44 #define x8x9xAxB buf[2]
45 #define xCxDxExF buf[3]
46 #define z0z1z2z3 buf[4]
47 #define z4z5z6z7 buf[5]
48 #define z8z9zAzB buf[6]
49 #define zCzDzEzF buf[7]
50
51 #define byte0(x) (((x) >> 24))
52 #define byte1(x) (((x) >> 16) & 0xff)
53 #define byte2(x) (((x) >> 8) & 0xff)
54 #define byte3(x) (((x)) & 0xff)
55
56 #define x0 byte0(buf[0])
57 #define x1 byte1(buf[0])
58 #define x2 byte2(buf[0])
59 #define x3 byte3(buf[0])
60 #define x4 byte0(buf[1])
61 #define x5 byte1(buf[1])
62 #define x6 byte2(buf[1])
63 #define x7 byte3(buf[1])
64 #define x8 byte0(buf[2])
65 #define x9 byte1(buf[2])
66 #define xA byte2(buf[2])
67 #define xB byte3(buf[2])
68 #define xC byte0(buf[3])
69 #define xD byte1(buf[3])
70 #define xE byte2(buf[3])
71 #define xF byte3(buf[3])
72 #define z0 byte0(buf[4])
73 #define z1 byte1(buf[4])
74 #define z2 byte2(buf[4])
75 #define z3 byte3(buf[4])
76 #define z4 byte0(buf[5])
77 #define z5 byte1(buf[5])
78 #define z6 byte2(buf[5])
79 #define z7 byte3(buf[5])
80 #define z8 byte0(buf[6])
81 #define z9 byte1(buf[6])
82 #define zA byte2(buf[6])
83 #define zB byte3(buf[6])
84 #define zC byte0(buf[7])
85 #define zD byte1(buf[7])
86 #define zE byte2(buf[7])
87 #define zF byte3(buf[7])
88
89 #define circular_leftshift(x, y) ( ((x) << (y)) | ((x) >> (32-(y))) )
90
91 #endif
92