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