1183234Ssimon/*
2296465Sdelphij * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.
3183234Ssimon *
4183234Ssimon * Redistribution and use in source and binary forms, with or without
5183234Ssimon * modification, are permitted provided that the following conditions
6183234Ssimon * are met:
7183234Ssimon * 1. Redistributions of source code must retain the above copyright
8183234Ssimon *    notice, this list of conditions and the following disclaimer.
9183234Ssimon * 2. Neither the name of author nor the names of its contributors may
10183234Ssimon *    be used to endorse or promote products derived from this software
11183234Ssimon *    without specific prior written permission.
12183234Ssimon *
13183234Ssimon * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14183234Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15183234Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16183234Ssimon * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17183234Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18183234Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19183234Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20183234Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21183234Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22183234Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23183234Ssimon * SUCH DAMAGE.
24183234Ssimon *
25183234Ssimon */
26183234Ssimon#ifndef OPENSSL_NO_SEED
27183234Ssimon
28296465Sdelphij# include <stdio.h>
29296465Sdelphij# include <stdlib.h>
30296465Sdelphij# include <string.h>
31296465Sdelphij# ifdef WIN32
32296465Sdelphij#  include <memory.h>
33296465Sdelphij# endif
34183234Ssimon
35296465Sdelphij# include <openssl/seed.h>
36296465Sdelphij# include "seed_locl.h"
37183234Ssimon
38296465Sdelphijstatic seed_word SS[4][256] = { {
39296465Sdelphij                                 0x2989a1a8, 0x05858184, 0x16c6d2d4,
40296465Sdelphij                                 0x13c3d3d0, 0x14445054, 0x1d0d111c,
41296465Sdelphij                                 0x2c8ca0ac, 0x25052124,
42296465Sdelphij                                 0x1d4d515c, 0x03434340, 0x18081018,
43296465Sdelphij                                 0x1e0e121c, 0x11415150, 0x3cccf0fc,
44296465Sdelphij                                 0x0acac2c8, 0x23436360,
45296465Sdelphij                                 0x28082028, 0x04444044, 0x20002020,
46296465Sdelphij                                 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0,
47296465Sdelphij                                 0x08c8c0c8, 0x17071314,
48296465Sdelphij                                 0x2585a1a4, 0x0f8f838c, 0x03030300,
49296465Sdelphij                                 0x3b4b7378, 0x3b8bb3b8, 0x13031310,
50296465Sdelphij                                 0x12c2d2d0, 0x2ecee2ec,
51296465Sdelphij                                 0x30407070, 0x0c8c808c, 0x3f0f333c,
52296465Sdelphij                                 0x2888a0a8, 0x32023230, 0x1dcdd1dc,
53296465Sdelphij                                 0x36c6f2f4, 0x34447074,
54296465Sdelphij                                 0x2ccce0ec, 0x15859194, 0x0b0b0308,
55296465Sdelphij                                 0x17475354, 0x1c4c505c, 0x1b4b5358,
56296465Sdelphij                                 0x3d8db1bc, 0x01010100,
57296465Sdelphij                                 0x24042024, 0x1c0c101c, 0x33437370,
58296465Sdelphij                                 0x18889098, 0x10001010, 0x0cccc0cc,
59296465Sdelphij                                 0x32c2f2f0, 0x19c9d1d8,
60296465Sdelphij                                 0x2c0c202c, 0x27c7e3e4, 0x32427270,
61296465Sdelphij                                 0x03838380, 0x1b8b9398, 0x11c1d1d0,
62296465Sdelphij                                 0x06868284, 0x09c9c1c8,
63296465Sdelphij                                 0x20406060, 0x10405050, 0x2383a3a0,
64296465Sdelphij                                 0x2bcbe3e8, 0x0d0d010c, 0x3686b2b4,
65296465Sdelphij                                 0x1e8e929c, 0x0f4f434c,
66296465Sdelphij                                 0x3787b3b4, 0x1a4a5258, 0x06c6c2c4,
67296465Sdelphij                                 0x38487078, 0x2686a2a4, 0x12021210,
68296465Sdelphij                                 0x2f8fa3ac, 0x15c5d1d4,
69296465Sdelphij                                 0x21416160, 0x03c3c3c0, 0x3484b0b4,
70296465Sdelphij                                 0x01414140, 0x12425250, 0x3d4d717c,
71296465Sdelphij                                 0x0d8d818c, 0x08080008,
72296465Sdelphij                                 0x1f0f131c, 0x19899198, 0x00000000,
73296465Sdelphij                                 0x19091118, 0x04040004, 0x13435350,
74296465Sdelphij                                 0x37c7f3f4, 0x21c1e1e0,
75296465Sdelphij                                 0x3dcdf1fc, 0x36467274, 0x2f0f232c,
76296465Sdelphij                                 0x27072324, 0x3080b0b0, 0x0b8b8388,
77296465Sdelphij                                 0x0e0e020c, 0x2b8ba3a8,
78296465Sdelphij                                 0x2282a2a0, 0x2e4e626c, 0x13839390,
79296465Sdelphij                                 0x0d4d414c, 0x29496168, 0x3c4c707c,
80296465Sdelphij                                 0x09090108, 0x0a0a0208,
81296465Sdelphij                                 0x3f8fb3bc, 0x2fcfe3ec, 0x33c3f3f0,
82296465Sdelphij                                 0x05c5c1c4, 0x07878384, 0x14041014,
83296465Sdelphij                                 0x3ecef2fc, 0x24446064,
84296465Sdelphij                                 0x1eced2dc, 0x2e0e222c, 0x0b4b4348,
85296465Sdelphij                                 0x1a0a1218, 0x06060204, 0x21012120,
86296465Sdelphij                                 0x2b4b6368, 0x26466264,
87296465Sdelphij                                 0x02020200, 0x35c5f1f4, 0x12829290,
88296465Sdelphij                                 0x0a8a8288, 0x0c0c000c, 0x3383b3b0,
89296465Sdelphij                                 0x3e4e727c, 0x10c0d0d0,
90296465Sdelphij                                 0x3a4a7278, 0x07474344, 0x16869294,
91296465Sdelphij                                 0x25c5e1e4, 0x26062224, 0x00808080,
92296465Sdelphij                                 0x2d8da1ac, 0x1fcfd3dc,
93296465Sdelphij                                 0x2181a1a0, 0x30003030, 0x37073334,
94296465Sdelphij                                 0x2e8ea2ac, 0x36063234, 0x15051114,
95296465Sdelphij                                 0x22022220, 0x38083038,
96296465Sdelphij                                 0x34c4f0f4, 0x2787a3a4, 0x05454144,
97296465Sdelphij                                 0x0c4c404c, 0x01818180, 0x29c9e1e8,
98296465Sdelphij                                 0x04848084, 0x17879394,
99296465Sdelphij                                 0x35053134, 0x0bcbc3c8, 0x0ecec2cc,
100296465Sdelphij                                 0x3c0c303c, 0x31417170, 0x11011110,
101296465Sdelphij                                 0x07c7c3c4, 0x09898188,
102296465Sdelphij                                 0x35457174, 0x3bcbf3f8, 0x1acad2d8,
103296465Sdelphij                                 0x38c8f0f8, 0x14849094, 0x19495158,
104296465Sdelphij                                 0x02828280, 0x04c4c0c4,
105296465Sdelphij                                 0x3fcff3fc, 0x09494148, 0x39093138,
106296465Sdelphij                                 0x27476364, 0x00c0c0c0, 0x0fcfc3cc,
107296465Sdelphij                                 0x17c7d3d4, 0x3888b0b8,
108296465Sdelphij                                 0x0f0f030c, 0x0e8e828c, 0x02424240,
109296465Sdelphij                                 0x23032320, 0x11819190, 0x2c4c606c,
110296465Sdelphij                                 0x1bcbd3d8, 0x2484a0a4,
111296465Sdelphij                                 0x34043034, 0x31c1f1f0, 0x08484048,
112296465Sdelphij                                 0x02c2c2c0, 0x2f4f636c, 0x3d0d313c,
113296465Sdelphij                                 0x2d0d212c, 0x00404040,
114296465Sdelphij                                 0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc,
115296465Sdelphij                                 0x01c1c1c0, 0x2a8aa2a8, 0x3a8ab2b8,
116296465Sdelphij                                 0x0e4e424c, 0x15455154,
117296465Sdelphij                                 0x3b0b3338, 0x1cccd0dc, 0x28486068,
118296465Sdelphij                                 0x3f4f737c, 0x1c8c909c, 0x18c8d0d8,
119296465Sdelphij                                 0x0a4a4248, 0x16465254,
120296465Sdelphij                                 0x37477374, 0x2080a0a0, 0x2dcde1ec,
121296465Sdelphij                                 0x06464244, 0x3585b1b4, 0x2b0b2328,
122296465Sdelphij                                 0x25456164, 0x3acaf2f8,
123296465Sdelphij                                 0x23c3e3e0, 0x3989b1b8, 0x3181b1b0,
124296465Sdelphij                                 0x1f8f939c, 0x1e4e525c, 0x39c9f1f8,
125296465Sdelphij                                 0x26c6e2e4, 0x3282b2b0,
126296465Sdelphij                                 0x31013130, 0x2acae2e8, 0x2d4d616c,
127296465Sdelphij                                 0x1f4f535c, 0x24c4e0e4, 0x30c0f0f0,
128296465Sdelphij                                 0x0dcdc1cc, 0x08888088,
129296465Sdelphij                                 0x16061214, 0x3a0a3238, 0x18485058,
130296465Sdelphij                                 0x14c4d0d4, 0x22426260, 0x29092128,
131296465Sdelphij                                 0x07070304, 0x33033330,
132296465Sdelphij                                 0x28c8e0e8, 0x1b0b1318, 0x05050104,
133296465Sdelphij                                 0x39497178, 0x10809090, 0x2a4a6268,
134296465Sdelphij                                 0x2a0a2228, 0x1a8a9298}, {
135296465Sdelphij                                                           0x38380830,
136296465Sdelphij                                                           0xe828c8e0,
137296465Sdelphij                                                           0x2c2d0d21,
138296465Sdelphij                                                           0xa42686a2,
139296465Sdelphij                                                           0xcc0fcfc3,
140296465Sdelphij                                                           0xdc1eced2,
141296465Sdelphij                                                           0xb03383b3,
142296465Sdelphij                                                           0xb83888b0,
143296465Sdelphij                                                           0xac2f8fa3,
144296465Sdelphij                                                           0x60204060,
145296465Sdelphij                                                           0x54154551,
146296465Sdelphij                                                           0xc407c7c3,
147296465Sdelphij                                                           0x44044440,
148296465Sdelphij                                                           0x6c2f4f63,
149296465Sdelphij                                                           0x682b4b63,
150296465Sdelphij                                                           0x581b4b53,
151296465Sdelphij                                                           0xc003c3c3,
152296465Sdelphij                                                           0x60224262,
153296465Sdelphij                                                           0x30330333,
154296465Sdelphij                                                           0xb43585b1,
155296465Sdelphij                                                           0x28290921,
156296465Sdelphij                                                           0xa02080a0,
157296465Sdelphij                                                           0xe022c2e2,
158296465Sdelphij                                                           0xa42787a3,
159296465Sdelphij                                                           0xd013c3d3,
160296465Sdelphij                                                           0x90118191,
161296465Sdelphij                                                           0x10110111,
162296465Sdelphij                                                           0x04060602,
163296465Sdelphij                                                           0x1c1c0c10,
164296465Sdelphij                                                           0xbc3c8cb0,
165296465Sdelphij                                                           0x34360632,
166296465Sdelphij                                                           0x480b4b43,
167296465Sdelphij                                                           0xec2fcfe3,
168296465Sdelphij                                                           0x88088880,
169296465Sdelphij                                                           0x6c2c4c60,
170296465Sdelphij                                                           0xa82888a0,
171296465Sdelphij                                                           0x14170713,
172296465Sdelphij                                                           0xc404c4c0,
173296465Sdelphij                                                           0x14160612,
174296465Sdelphij                                                           0xf434c4f0,
175296465Sdelphij                                                           0xc002c2c2,
176296465Sdelphij                                                           0x44054541,
177296465Sdelphij                                                           0xe021c1e1,
178296465Sdelphij                                                           0xd416c6d2,
179296465Sdelphij                                                           0x3c3f0f33,
180296465Sdelphij                                                           0x3c3d0d31,
181296465Sdelphij                                                           0x8c0e8e82,
182296465Sdelphij                                                           0x98188890,
183296465Sdelphij                                                           0x28280820,
184296465Sdelphij                                                           0x4c0e4e42,
185296465Sdelphij                                                           0xf436c6f2,
186296465Sdelphij                                                           0x3c3e0e32,
187296465Sdelphij                                                           0xa42585a1,
188296465Sdelphij                                                           0xf839c9f1,
189296465Sdelphij                                                           0x0c0d0d01,
190296465Sdelphij                                                           0xdc1fcfd3,
191296465Sdelphij                                                           0xd818c8d0,
192296465Sdelphij                                                           0x282b0b23,
193296465Sdelphij                                                           0x64264662,
194296465Sdelphij                                                           0x783a4a72,
195296465Sdelphij                                                           0x24270723,
196296465Sdelphij                                                           0x2c2f0f23,
197296465Sdelphij                                                           0xf031c1f1,
198296465Sdelphij                                                           0x70324272,
199296465Sdelphij                                                           0x40024242,
200296465Sdelphij                                                           0xd414c4d0,
201296465Sdelphij                                                           0x40014141,
202296465Sdelphij                                                           0xc000c0c0,
203296465Sdelphij                                                           0x70334373,
204296465Sdelphij                                                           0x64274763,
205296465Sdelphij                                                           0xac2c8ca0,
206296465Sdelphij                                                           0x880b8b83,
207296465Sdelphij                                                           0xf437c7f3,
208296465Sdelphij                                                           0xac2d8da1,
209296465Sdelphij                                                           0x80008080,
210296465Sdelphij                                                           0x1c1f0f13,
211296465Sdelphij                                                           0xc80acac2,
212296465Sdelphij                                                           0x2c2c0c20,
213296465Sdelphij                                                           0xa82a8aa2,
214296465Sdelphij                                                           0x34340430,
215296465Sdelphij                                                           0xd012c2d2,
216296465Sdelphij                                                           0x080b0b03,
217296465Sdelphij                                                           0xec2ecee2,
218296465Sdelphij                                                           0xe829c9e1,
219296465Sdelphij                                                           0x5c1d4d51,
220296465Sdelphij                                                           0x94148490,
221296465Sdelphij                                                           0x18180810,
222296465Sdelphij                                                           0xf838c8f0,
223296465Sdelphij                                                           0x54174753,
224296465Sdelphij                                                           0xac2e8ea2,
225296465Sdelphij                                                           0x08080800,
226296465Sdelphij                                                           0xc405c5c1,
227296465Sdelphij                                                           0x10130313,
228296465Sdelphij                                                           0xcc0dcdc1,
229296465Sdelphij                                                           0x84068682,
230296465Sdelphij                                                           0xb83989b1,
231296465Sdelphij                                                           0xfc3fcff3,
232296465Sdelphij                                                           0x7c3d4d71,
233296465Sdelphij                                                           0xc001c1c1,
234296465Sdelphij                                                           0x30310131,
235296465Sdelphij                                                           0xf435c5f1,
236296465Sdelphij                                                           0x880a8a82,
237296465Sdelphij                                                           0x682a4a62,
238296465Sdelphij                                                           0xb03181b1,
239296465Sdelphij                                                           0xd011c1d1,
240296465Sdelphij                                                           0x20200020,
241296465Sdelphij                                                           0xd417c7d3,
242296465Sdelphij                                                           0x00020202,
243296465Sdelphij                                                           0x20220222,
244296465Sdelphij                                                           0x04040400,
245296465Sdelphij                                                           0x68284860,
246296465Sdelphij                                                           0x70314171,
247296465Sdelphij                                                           0x04070703,
248296465Sdelphij                                                           0xd81bcbd3,
249296465Sdelphij                                                           0x9c1d8d91,
250296465Sdelphij                                                           0x98198991,
251296465Sdelphij                                                           0x60214161,
252296465Sdelphij                                                           0xbc3e8eb2,
253296465Sdelphij                                                           0xe426c6e2,
254296465Sdelphij                                                           0x58194951,
255296465Sdelphij                                                           0xdc1dcdd1,
256296465Sdelphij                                                           0x50114151,
257296465Sdelphij                                                           0x90108090,
258296465Sdelphij                                                           0xdc1cccd0,
259296465Sdelphij                                                           0x981a8a92,
260296465Sdelphij                                                           0xa02383a3,
261296465Sdelphij                                                           0xa82b8ba3,
262296465Sdelphij                                                           0xd010c0d0,
263296465Sdelphij                                                           0x80018181,
264296465Sdelphij                                                           0x0c0f0f03,
265296465Sdelphij                                                           0x44074743,
266296465Sdelphij                                                           0x181a0a12,
267296465Sdelphij                                                           0xe023c3e3,
268296465Sdelphij                                                           0xec2ccce0,
269296465Sdelphij                                                           0x8c0d8d81,
270296465Sdelphij                                                           0xbc3f8fb3,
271296465Sdelphij                                                           0x94168692,
272296465Sdelphij                                                           0x783b4b73,
273296465Sdelphij                                                           0x5c1c4c50,
274296465Sdelphij                                                           0xa02282a2,
275296465Sdelphij                                                           0xa02181a1,
276296465Sdelphij                                                           0x60234363,
277296465Sdelphij                                                           0x20230323,
278296465Sdelphij                                                           0x4c0d4d41,
279296465Sdelphij                                                           0xc808c8c0,
280296465Sdelphij                                                           0x9c1e8e92,
281296465Sdelphij                                                           0x9c1c8c90,
282296465Sdelphij                                                           0x383a0a32,
283296465Sdelphij                                                           0x0c0c0c00,
284296465Sdelphij                                                           0x2c2e0e22,
285296465Sdelphij                                                           0xb83a8ab2,
286296465Sdelphij                                                           0x6c2e4e62,
287296465Sdelphij                                                           0x9c1f8f93,
288296465Sdelphij                                                           0x581a4a52,
289296465Sdelphij                                                           0xf032c2f2,
290296465Sdelphij                                                           0x90128292,
291296465Sdelphij                                                           0xf033c3f3,
292296465Sdelphij                                                           0x48094941,
293296465Sdelphij                                                           0x78384870,
294296465Sdelphij                                                           0xcc0cccc0,
295296465Sdelphij                                                           0x14150511,
296296465Sdelphij                                                           0xf83bcbf3,
297296465Sdelphij                                                           0x70304070,
298296465Sdelphij                                                           0x74354571,
299296465Sdelphij                                                           0x7c3f4f73,
300296465Sdelphij                                                           0x34350531,
301296465Sdelphij                                                           0x10100010,
302296465Sdelphij                                                           0x00030303,
303296465Sdelphij                                                           0x64244460,
304296465Sdelphij                                                           0x6c2d4d61,
305296465Sdelphij                                                           0xc406c6c2,
306296465Sdelphij                                                           0x74344470,
307296465Sdelphij                                                           0xd415c5d1,
308296465Sdelphij                                                           0xb43484b0,
309296465Sdelphij                                                           0xe82acae2,
310296465Sdelphij                                                           0x08090901,
311296465Sdelphij                                                           0x74364672,
312296465Sdelphij                                                           0x18190911,
313296465Sdelphij                                                           0xfc3ecef2,
314296465Sdelphij                                                           0x40004040,
315296465Sdelphij                                                           0x10120212,
316296465Sdelphij                                                           0xe020c0e0,
317296465Sdelphij                                                           0xbc3d8db1,
318296465Sdelphij                                                           0x04050501,
319296465Sdelphij                                                           0xf83acaf2,
320296465Sdelphij                                                           0x00010101,
321296465Sdelphij                                                           0xf030c0f0,
322296465Sdelphij                                                           0x282a0a22,
323296465Sdelphij                                                           0x5c1e4e52,
324296465Sdelphij                                                           0xa82989a1,
325296465Sdelphij                                                           0x54164652,
326296465Sdelphij                                                           0x40034343,
327296465Sdelphij                                                           0x84058581,
328296465Sdelphij                                                           0x14140410,
329296465Sdelphij                                                           0x88098981,
330296465Sdelphij                                                           0x981b8b93,
331296465Sdelphij                                                           0xb03080b0,
332296465Sdelphij                                                           0xe425c5e1,
333296465Sdelphij                                                           0x48084840,
334296465Sdelphij                                                           0x78394971,
335296465Sdelphij                                                           0x94178793,
336296465Sdelphij                                                           0xfc3cccf0,
337296465Sdelphij                                                           0x1c1e0e12,
338296465Sdelphij                                                           0x80028282,
339296465Sdelphij                                                           0x20210121,
340296465Sdelphij                                                           0x8c0c8c80,
341296465Sdelphij                                                           0x181b0b13,
342296465Sdelphij                                                           0x5c1f4f53,
343296465Sdelphij                                                           0x74374773,
344296465Sdelphij                                                           0x54144450,
345296465Sdelphij                                                           0xb03282b2,
346296465Sdelphij                                                           0x1c1d0d11,
347296465Sdelphij                                                           0x24250521,
348296465Sdelphij                                                           0x4c0f4f43,
349296465Sdelphij                                                           0x00000000,
350296465Sdelphij                                                           0x44064642,
351296465Sdelphij                                                           0xec2dcde1,
352296465Sdelphij                                                           0x58184850,
353296465Sdelphij                                                           0x50124252,
354296465Sdelphij                                                           0xe82bcbe3,
355296465Sdelphij                                                           0x7c3e4e72,
356296465Sdelphij                                                           0xd81acad2,
357296465Sdelphij                                                           0xc809c9c1,
358296465Sdelphij                                                           0xfc3dcdf1,
359296465Sdelphij                                                           0x30300030,
360296465Sdelphij                                                           0x94158591,
361296465Sdelphij                                                           0x64254561,
362296465Sdelphij                                                           0x3c3c0c30,
363296465Sdelphij                                                           0xb43686b2,
364296465Sdelphij                                                           0xe424c4e0,
365296465Sdelphij                                                           0xb83b8bb3,
366296465Sdelphij                                                           0x7c3c4c70,
367296465Sdelphij                                                           0x0c0e0e02,
368296465Sdelphij                                                           0x50104050,
369296465Sdelphij                                                           0x38390931,
370296465Sdelphij                                                           0x24260622,
371296465Sdelphij                                                           0x30320232,
372296465Sdelphij                                                           0x84048480,
373296465Sdelphij                                                           0x68294961,
374296465Sdelphij                                                           0x90138393,
375296465Sdelphij                                                           0x34370733,
376296465Sdelphij                                                           0xe427c7e3,
377296465Sdelphij                                                           0x24240420,
378296465Sdelphij                                                           0xa42484a0,
379296465Sdelphij                                                           0xc80bcbc3,
380296465Sdelphij                                                           0x50134353,
381296465Sdelphij                                                           0x080a0a02,
382296465Sdelphij                                                           0x84078783,
383296465Sdelphij                                                           0xd819c9d1,
384296465Sdelphij                                                           0x4c0c4c40,
385296465Sdelphij                                                           0x80038383,
386296465Sdelphij                                                           0x8c0f8f83,
387296465Sdelphij                                                           0xcc0ecec2,
388296465Sdelphij                                                           0x383b0b33,
389296465Sdelphij                                                           0x480a4a42,
390296465Sdelphij                                                           0xb43787b3}, {
391296465Sdelphij                                                                         0xa1a82989,
392296465Sdelphij                                                                         0x81840585,
393296465Sdelphij                                                                         0xd2d416c6,
394296465Sdelphij                                                                         0xd3d013c3,
395296465Sdelphij                                                                         0x50541444,
396296465Sdelphij                                                                         0x111c1d0d,
397296465Sdelphij                                                                         0xa0ac2c8c,
398296465Sdelphij                                                                         0x21242505,
399296465Sdelphij                                                                         0x515c1d4d,
400296465Sdelphij                                                                         0x43400343,
401296465Sdelphij                                                                         0x10181808,
402296465Sdelphij                                                                         0x121c1e0e,
403296465Sdelphij                                                                         0x51501141,
404296465Sdelphij                                                                         0xf0fc3ccc,
405296465Sdelphij                                                                         0xc2c80aca,
406296465Sdelphij                                                                         0x63602343,
407296465Sdelphij                                                                         0x20282808,
408296465Sdelphij                                                                         0x40440444,
409296465Sdelphij                                                                         0x20202000,
410296465Sdelphij                                                                         0x919c1d8d,
411296465Sdelphij                                                                         0xe0e020c0,
412296465Sdelphij                                                                         0xe2e022c2,
413296465Sdelphij                                                                         0xc0c808c8,
414296465Sdelphij                                                                         0x13141707,
415296465Sdelphij                                                                         0xa1a42585,
416296465Sdelphij                                                                         0x838c0f8f,
417296465Sdelphij                                                                         0x03000303,
418296465Sdelphij                                                                         0x73783b4b,
419296465Sdelphij                                                                         0xb3b83b8b,
420296465Sdelphij                                                                         0x13101303,
421296465Sdelphij                                                                         0xd2d012c2,
422296465Sdelphij                                                                         0xe2ec2ece,
423296465Sdelphij                                                                         0x70703040,
424296465Sdelphij                                                                         0x808c0c8c,
425296465Sdelphij                                                                         0x333c3f0f,
426296465Sdelphij                                                                         0xa0a82888,
427296465Sdelphij                                                                         0x32303202,
428296465Sdelphij                                                                         0xd1dc1dcd,
429296465Sdelphij                                                                         0xf2f436c6,
430296465Sdelphij                                                                         0x70743444,
431296465Sdelphij                                                                         0xe0ec2ccc,
432296465Sdelphij                                                                         0x91941585,
433296465Sdelphij                                                                         0x03080b0b,
434296465Sdelphij                                                                         0x53541747,
435296465Sdelphij                                                                         0x505c1c4c,
436296465Sdelphij                                                                         0x53581b4b,
437296465Sdelphij                                                                         0xb1bc3d8d,
438296465Sdelphij                                                                         0x01000101,
439296465Sdelphij                                                                         0x20242404,
440296465Sdelphij                                                                         0x101c1c0c,
441296465Sdelphij                                                                         0x73703343,
442296465Sdelphij                                                                         0x90981888,
443296465Sdelphij                                                                         0x10101000,
444296465Sdelphij                                                                         0xc0cc0ccc,
445296465Sdelphij                                                                         0xf2f032c2,
446296465Sdelphij                                                                         0xd1d819c9,
447296465Sdelphij                                                                         0x202c2c0c,
448296465Sdelphij                                                                         0xe3e427c7,
449296465Sdelphij                                                                         0x72703242,
450296465Sdelphij                                                                         0x83800383,
451296465Sdelphij                                                                         0x93981b8b,
452296465Sdelphij                                                                         0xd1d011c1,
453296465Sdelphij                                                                         0x82840686,
454296465Sdelphij                                                                         0xc1c809c9,
455296465Sdelphij                                                                         0x60602040,
456296465Sdelphij                                                                         0x50501040,
457296465Sdelphij                                                                         0xa3a02383,
458296465Sdelphij                                                                         0xe3e82bcb,
459296465Sdelphij                                                                         0x010c0d0d,
460296465Sdelphij                                                                         0xb2b43686,
461296465Sdelphij                                                                         0x929c1e8e,
462296465Sdelphij                                                                         0x434c0f4f,
463296465Sdelphij                                                                         0xb3b43787,
464296465Sdelphij                                                                         0x52581a4a,
465296465Sdelphij                                                                         0xc2c406c6,
466296465Sdelphij                                                                         0x70783848,
467296465Sdelphij                                                                         0xa2a42686,
468296465Sdelphij                                                                         0x12101202,
469296465Sdelphij                                                                         0xa3ac2f8f,
470296465Sdelphij                                                                         0xd1d415c5,
471296465Sdelphij                                                                         0x61602141,
472296465Sdelphij                                                                         0xc3c003c3,
473296465Sdelphij                                                                         0xb0b43484,
474296465Sdelphij                                                                         0x41400141,
475296465Sdelphij                                                                         0x52501242,
476296465Sdelphij                                                                         0x717c3d4d,
477296465Sdelphij                                                                         0x818c0d8d,
478296465Sdelphij                                                                         0x00080808,
479296465Sdelphij                                                                         0x131c1f0f,
480296465Sdelphij                                                                         0x91981989,
481296465Sdelphij                                                                         0x00000000,
482296465Sdelphij                                                                         0x11181909,
483296465Sdelphij                                                                         0x00040404,
484296465Sdelphij                                                                         0x53501343,
485296465Sdelphij                                                                         0xf3f437c7,
486296465Sdelphij                                                                         0xe1e021c1,
487296465Sdelphij                                                                         0xf1fc3dcd,
488296465Sdelphij                                                                         0x72743646,
489296465Sdelphij                                                                         0x232c2f0f,
490296465Sdelphij                                                                         0x23242707,
491296465Sdelphij                                                                         0xb0b03080,
492296465Sdelphij                                                                         0x83880b8b,
493296465Sdelphij                                                                         0x020c0e0e,
494296465Sdelphij                                                                         0xa3a82b8b,
495296465Sdelphij                                                                         0xa2a02282,
496296465Sdelphij                                                                         0x626c2e4e,
497296465Sdelphij                                                                         0x93901383,
498296465Sdelphij                                                                         0x414c0d4d,
499296465Sdelphij                                                                         0x61682949,
500296465Sdelphij                                                                         0x707c3c4c,
501296465Sdelphij                                                                         0x01080909,
502296465Sdelphij                                                                         0x02080a0a,
503296465Sdelphij                                                                         0xb3bc3f8f,
504296465Sdelphij                                                                         0xe3ec2fcf,
505296465Sdelphij                                                                         0xf3f033c3,
506296465Sdelphij                                                                         0xc1c405c5,
507296465Sdelphij                                                                         0x83840787,
508296465Sdelphij                                                                         0x10141404,
509296465Sdelphij                                                                         0xf2fc3ece,
510296465Sdelphij                                                                         0x60642444,
511296465Sdelphij                                                                         0xd2dc1ece,
512296465Sdelphij                                                                         0x222c2e0e,
513296465Sdelphij                                                                         0x43480b4b,
514296465Sdelphij                                                                         0x12181a0a,
515296465Sdelphij                                                                         0x02040606,
516296465Sdelphij                                                                         0x21202101,
517296465Sdelphij                                                                         0x63682b4b,
518296465Sdelphij                                                                         0x62642646,
519296465Sdelphij                                                                         0x02000202,
520296465Sdelphij                                                                         0xf1f435c5,
521296465Sdelphij                                                                         0x92901282,
522296465Sdelphij                                                                         0x82880a8a,
523296465Sdelphij                                                                         0x000c0c0c,
524296465Sdelphij                                                                         0xb3b03383,
525296465Sdelphij                                                                         0x727c3e4e,
526296465Sdelphij                                                                         0xd0d010c0,
527296465Sdelphij                                                                         0x72783a4a,
528296465Sdelphij                                                                         0x43440747,
529296465Sdelphij                                                                         0x92941686,
530296465Sdelphij                                                                         0xe1e425c5,
531296465Sdelphij                                                                         0x22242606,
532296465Sdelphij                                                                         0x80800080,
533296465Sdelphij                                                                         0xa1ac2d8d,
534296465Sdelphij                                                                         0xd3dc1fcf,
535296465Sdelphij                                                                         0xa1a02181,
536296465Sdelphij                                                                         0x30303000,
537296465Sdelphij                                                                         0x33343707,
538296465Sdelphij                                                                         0xa2ac2e8e,
539296465Sdelphij                                                                         0x32343606,
540296465Sdelphij                                                                         0x11141505,
541296465Sdelphij                                                                         0x22202202,
542296465Sdelphij                                                                         0x30383808,
543296465Sdelphij                                                                         0xf0f434c4,
544296465Sdelphij                                                                         0xa3a42787,
545296465Sdelphij                                                                         0x41440545,
546296465Sdelphij                                                                         0x404c0c4c,
547296465Sdelphij                                                                         0x81800181,
548296465Sdelphij                                                                         0xe1e829c9,
549296465Sdelphij                                                                         0x80840484,
550296465Sdelphij                                                                         0x93941787,
551296465Sdelphij                                                                         0x31343505,
552296465Sdelphij                                                                         0xc3c80bcb,
553296465Sdelphij                                                                         0xc2cc0ece,
554296465Sdelphij                                                                         0x303c3c0c,
555296465Sdelphij                                                                         0x71703141,
556296465Sdelphij                                                                         0x11101101,
557296465Sdelphij                                                                         0xc3c407c7,
558296465Sdelphij                                                                         0x81880989,
559296465Sdelphij                                                                         0x71743545,
560296465Sdelphij                                                                         0xf3f83bcb,
561296465Sdelphij                                                                         0xd2d81aca,
562296465Sdelphij                                                                         0xf0f838c8,
563296465Sdelphij                                                                         0x90941484,
564296465Sdelphij                                                                         0x51581949,
565296465Sdelphij                                                                         0x82800282,
566296465Sdelphij                                                                         0xc0c404c4,
567296465Sdelphij                                                                         0xf3fc3fcf,
568296465Sdelphij                                                                         0x41480949,
569296465Sdelphij                                                                         0x31383909,
570296465Sdelphij                                                                         0x63642747,
571296465Sdelphij                                                                         0xc0c000c0,
572296465Sdelphij                                                                         0xc3cc0fcf,
573296465Sdelphij                                                                         0xd3d417c7,
574296465Sdelphij                                                                         0xb0b83888,
575296465Sdelphij                                                                         0x030c0f0f,
576296465Sdelphij                                                                         0x828c0e8e,
577296465Sdelphij                                                                         0x42400242,
578296465Sdelphij                                                                         0x23202303,
579296465Sdelphij                                                                         0x91901181,
580296465Sdelphij                                                                         0x606c2c4c,
581296465Sdelphij                                                                         0xd3d81bcb,
582296465Sdelphij                                                                         0xa0a42484,
583296465Sdelphij                                                                         0x30343404,
584296465Sdelphij                                                                         0xf1f031c1,
585296465Sdelphij                                                                         0x40480848,
586296465Sdelphij                                                                         0xc2c002c2,
587296465Sdelphij                                                                         0x636c2f4f,
588296465Sdelphij                                                                         0x313c3d0d,
589296465Sdelphij                                                                         0x212c2d0d,
590296465Sdelphij                                                                         0x40400040,
591296465Sdelphij                                                                         0xb2bc3e8e,
592296465Sdelphij                                                                         0x323c3e0e,
593296465Sdelphij                                                                         0xb0bc3c8c,
594296465Sdelphij                                                                         0xc1c001c1,
595296465Sdelphij                                                                         0xa2a82a8a,
596296465Sdelphij                                                                         0xb2b83a8a,
597296465Sdelphij                                                                         0x424c0e4e,
598296465Sdelphij                                                                         0x51541545,
599296465Sdelphij                                                                         0x33383b0b,
600296465Sdelphij                                                                         0xd0dc1ccc,
601296465Sdelphij                                                                         0x60682848,
602296465Sdelphij                                                                         0x737c3f4f,
603296465Sdelphij                                                                         0x909c1c8c,
604296465Sdelphij                                                                         0xd0d818c8,
605296465Sdelphij                                                                         0x42480a4a,
606296465Sdelphij                                                                         0x52541646,
607296465Sdelphij                                                                         0x73743747,
608296465Sdelphij                                                                         0xa0a02080,
609296465Sdelphij                                                                         0xe1ec2dcd,
610296465Sdelphij                                                                         0x42440646,
611296465Sdelphij                                                                         0xb1b43585,
612296465Sdelphij                                                                         0x23282b0b,
613296465Sdelphij                                                                         0x61642545,
614296465Sdelphij                                                                         0xf2f83aca,
615296465Sdelphij                                                                         0xe3e023c3,
616296465Sdelphij                                                                         0xb1b83989,
617296465Sdelphij                                                                         0xb1b03181,
618296465Sdelphij                                                                         0x939c1f8f,
619296465Sdelphij                                                                         0x525c1e4e,
620296465Sdelphij                                                                         0xf1f839c9,
621296465Sdelphij                                                                         0xe2e426c6,
622296465Sdelphij                                                                         0xb2b03282,
623296465Sdelphij                                                                         0x31303101,
624296465Sdelphij                                                                         0xe2e82aca,
625296465Sdelphij                                                                         0x616c2d4d,
626296465Sdelphij                                                                         0x535c1f4f,
627296465Sdelphij                                                                         0xe0e424c4,
628296465Sdelphij                                                                         0xf0f030c0,
629296465Sdelphij                                                                         0xc1cc0dcd,
630296465Sdelphij                                                                         0x80880888,
631296465Sdelphij                                                                         0x12141606,
632296465Sdelphij                                                                         0x32383a0a,
633296465Sdelphij                                                                         0x50581848,
634296465Sdelphij                                                                         0xd0d414c4,
635296465Sdelphij                                                                         0x62602242,
636296465Sdelphij                                                                         0x21282909,
637296465Sdelphij                                                                         0x03040707,
638296465Sdelphij                                                                         0x33303303,
639296465Sdelphij                                                                         0xe0e828c8,
640296465Sdelphij                                                                         0x13181b0b,
641296465Sdelphij                                                                         0x01040505,
642296465Sdelphij                                                                         0x71783949,
643296465Sdelphij                                                                         0x90901080,
644296465Sdelphij                                                                         0x62682a4a,
645296465Sdelphij                                                                         0x22282a0a,
646296465Sdelphij                                                                         0x92981a8a},
647296465Sdelphij{
648296465Sdelphij 0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426, 0xcfc3cc0f, 0xced2dc1e,
649296465Sdelphij 0x83b3b033, 0x88b0b838,
650296465Sdelphij 0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407, 0x44404404, 0x4f636c2f,
651296465Sdelphij 0x4b63682b, 0x4b53581b,
652296465Sdelphij 0xc3c3c003, 0x42626022, 0x03333033, 0x85b1b435, 0x09212829, 0x80a0a020,
653296465Sdelphij 0xc2e2e022, 0x87a3a427,
654296465Sdelphij 0xc3d3d013, 0x81919011, 0x01111011, 0x06020406, 0x0c101c1c, 0x8cb0bc3c,
655296465Sdelphij 0x06323436, 0x4b43480b,
656296465Sdelphij 0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828, 0x07131417, 0xc4c0c404,
657296465Sdelphij 0x06121416, 0xc4f0f434,
658296465Sdelphij 0xc2c2c002, 0x45414405, 0xc1e1e021, 0xc6d2d416, 0x0f333c3f, 0x0d313c3d,
659296465Sdelphij 0x8e828c0e, 0x88909818,
660296465Sdelphij 0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e, 0x85a1a425, 0xc9f1f839,
661296465Sdelphij 0x0d010c0d, 0xcfd3dc1f,
662296465Sdelphij 0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a, 0x07232427, 0x0f232c2f,
663296465Sdelphij 0xc1f1f031, 0x42727032,
664296465Sdelphij 0x42424002, 0xc4d0d414, 0x41414001, 0xc0c0c000, 0x43737033, 0x47636427,
665296465Sdelphij 0x8ca0ac2c, 0x8b83880b,
666296465Sdelphij 0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f, 0xcac2c80a, 0x0c202c2c,
667296465Sdelphij 0x8aa2a82a, 0x04303434,
668296465Sdelphij 0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829, 0x4d515c1d, 0x84909414,
669296465Sdelphij 0x08101818, 0xc8f0f838,
670296465Sdelphij 0x47535417, 0x8ea2ac2e, 0x08000808, 0xc5c1c405, 0x03131013, 0xcdc1cc0d,
671296465Sdelphij 0x86828406, 0x89b1b839,
672296465Sdelphij 0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031, 0xc5f1f435, 0x8a82880a,
673296465Sdelphij 0x4a62682a, 0x81b1b031,
674296465Sdelphij 0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002, 0x02222022, 0x04000404,
675296465Sdelphij 0x48606828, 0x41717031,
676296465Sdelphij 0x07030407, 0xcbd3d81b, 0x8d919c1d, 0x89919819, 0x41616021, 0x8eb2bc3e,
677296465Sdelphij 0xc6e2e426, 0x49515819,
678296465Sdelphij 0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c, 0x8a92981a, 0x83a3a023,
679296465Sdelphij 0x8ba3a82b, 0xc0d0d010,
680296465Sdelphij 0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a, 0xc3e3e023, 0xcce0ec2c,
681296465Sdelphij 0x8d818c0d, 0x8fb3bc3f,
682296465Sdelphij 0x86929416, 0x4b73783b, 0x4c505c1c, 0x82a2a022, 0x81a1a021, 0x43636023,
683296465Sdelphij 0x03232023, 0x4d414c0d,
684296465Sdelphij 0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a, 0x0c000c0c, 0x0e222c2e,
685296465Sdelphij 0x8ab2b83a, 0x4e626c2e,
686296465Sdelphij 0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012, 0xc3f3f033, 0x49414809,
687296465Sdelphij 0x48707838, 0xccc0cc0c,
688296465Sdelphij 0x05111415, 0xcbf3f83b, 0x40707030, 0x45717435, 0x4f737c3f, 0x05313435,
689296465Sdelphij 0x00101010, 0x03030003,
690296465Sdelphij 0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434, 0xc5d1d415, 0x84b0b434,
691296465Sdelphij 0xcae2e82a, 0x09010809,
692296465Sdelphij 0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000, 0x02121012, 0xc0e0e020,
693296465Sdelphij 0x8db1bc3d, 0x05010405,
694296465Sdelphij 0xcaf2f83a, 0x01010001, 0xc0f0f030, 0x0a22282a, 0x4e525c1e, 0x89a1a829,
695296465Sdelphij 0x46525416, 0x43434003,
696296465Sdelphij 0x85818405, 0x04101414, 0x89818809, 0x8b93981b, 0x80b0b030, 0xc5e1e425,
697296465Sdelphij 0x48404808, 0x49717839,
698296465Sdelphij 0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002, 0x01212021, 0x8c808c0c,
699296465Sdelphij 0x0b13181b, 0x4f535c1f,
700296465Sdelphij 0x47737437, 0x44505414, 0x82b2b032, 0x0d111c1d, 0x05212425, 0x4f434c0f,
701296465Sdelphij 0x00000000, 0x46424406,
702296465Sdelphij 0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b, 0x4e727c3e, 0xcad2d81a,
703296465Sdelphij 0xc9c1c809, 0xcdf1fc3d,
704296465Sdelphij 0x00303030, 0x85919415, 0x45616425, 0x0c303c3c, 0x86b2b436, 0xc4e0e424,
705296465Sdelphij 0x8bb3b83b, 0x4c707c3c,
706296465Sdelphij 0x0e020c0e, 0x40505010, 0x09313839, 0x06222426, 0x02323032, 0x84808404,
707296465Sdelphij 0x49616829, 0x83939013,
708296465Sdelphij 0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424, 0xcbc3c80b, 0x43535013,
709296465Sdelphij 0x0a02080a, 0x87838407,
710296465Sdelphij 0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f, 0xcec2cc0e, 0x0b33383b,
711296465Sdelphij 0x4a42480a, 0x87b3b437}
712296465Sdelphij};
713183234Ssimon
714183234Ssimon/* key schedule constants - golden ratio */
715296465Sdelphij# define KC0     0x9e3779b9
716296465Sdelphij# define KC1     0x3c6ef373
717296465Sdelphij# define KC2     0x78dde6e6
718296465Sdelphij# define KC3     0xf1bbcdcc
719296465Sdelphij# define KC4     0xe3779b99
720296465Sdelphij# define KC5     0xc6ef3733
721296465Sdelphij# define KC6     0x8dde6e67
722296465Sdelphij# define KC7     0x1bbcdccf
723296465Sdelphij# define KC8     0x3779b99e
724296465Sdelphij# define KC9     0x6ef3733c
725296465Sdelphij# define KC10    0xdde6e678
726296465Sdelphij# define KC11    0xbbcdccf1
727296465Sdelphij# define KC12    0x779b99e3
728296465Sdelphij# define KC13    0xef3733c6
729296465Sdelphij# define KC14    0xde6e678d
730296465Sdelphij# define KC15    0xbcdccf1b
731183234Ssimon
732296465Sdelphijvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],
733296465Sdelphij                  SEED_KEY_SCHEDULE *ks)
734183234Ssimon{
735296465Sdelphij    seed_word x1, x2, x3, x4;
736296465Sdelphij    seed_word t0, t1;
737183234Ssimon
738296465Sdelphij    char2word(rawkey, x1);
739296465Sdelphij    char2word(rawkey + 4, x2);
740296465Sdelphij    char2word(rawkey + 8, x3);
741296465Sdelphij    char2word(rawkey + 12, x4);
742183234Ssimon
743296465Sdelphij    t0 = (x1 + x3 - KC0) & 0xffffffff;
744296465Sdelphij    t1 = (x2 - x4 + KC0) & 0xffffffff;
745296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[0]);
746296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC1);
747296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[2]);
748296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC2);
749296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[4]);
750296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC3);
751296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[6]);
752296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC4);
753296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[8]);
754296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC5);
755296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[10]);
756296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC6);
757296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[12]);
758296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC7);
759296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[14]);
760296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC8);
761296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[16]);
762296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC9);
763296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[18]);
764296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC10);
765296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[20]);
766296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC11);
767296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[22]);
768296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC12);
769296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[24]);
770296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC13);
771296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[26]);
772296465Sdelphij    KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC14);
773296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[28]);
774296465Sdelphij    KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC15);
775296465Sdelphij    KEYUPDATE_TEMP(t0, t1, &ks->data[30]);
776183234Ssimon}
777183234Ssimon
778296465Sdelphijvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],
779296465Sdelphij                  unsigned char d[SEED_BLOCK_SIZE],
780296465Sdelphij                  const SEED_KEY_SCHEDULE *ks)
781183234Ssimon{
782296465Sdelphij    seed_word x1, x2, x3, x4;
783296465Sdelphij    seed_word t0, t1;
784183234Ssimon
785296465Sdelphij    char2word(s, x1);
786296465Sdelphij    char2word(s + 4, x2);
787296465Sdelphij    char2word(s + 8, x3);
788296465Sdelphij    char2word(s + 12, x4);
789183234Ssimon
790296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 0);
791296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 2);
792296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 4);
793296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 6);
794296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 8);
795296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 10);
796296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 12);
797296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 14);
798296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 16);
799296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 18);
800296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 20);
801296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 22);
802296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 24);
803296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 26);
804296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 28);
805296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 30);
806296465Sdelphij
807296465Sdelphij    word2char(x3, d);
808296465Sdelphij    word2char(x4, d + 4);
809296465Sdelphij    word2char(x1, d + 8);
810296465Sdelphij    word2char(x2, d + 12);
811183234Ssimon}
812183234Ssimon
813296465Sdelphijvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],
814296465Sdelphij                  unsigned char d[SEED_BLOCK_SIZE],
815296465Sdelphij                  const SEED_KEY_SCHEDULE *ks)
816183234Ssimon{
817296465Sdelphij    seed_word x1, x2, x3, x4;
818296465Sdelphij    seed_word t0, t1;
819183234Ssimon
820296465Sdelphij    char2word(s, x1);
821296465Sdelphij    char2word(s + 4, x2);
822296465Sdelphij    char2word(s + 8, x3);
823296465Sdelphij    char2word(s + 12, x4);
824183234Ssimon
825296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 30);
826296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 28);
827296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 26);
828296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 24);
829296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 22);
830296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 20);
831296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 18);
832296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 16);
833296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 14);
834296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 12);
835296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 10);
836296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 8);
837296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 6);
838296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 4);
839296465Sdelphij    E_SEED(t0, t1, x1, x2, x3, x4, 2);
840296465Sdelphij    E_SEED(t0, t1, x3, x4, x1, x2, 0);
841296465Sdelphij
842296465Sdelphij    word2char(x3, d);
843296465Sdelphij    word2char(x4, d + 4);
844296465Sdelphij    word2char(x1, d + 8);
845296465Sdelphij    word2char(x2, d + 12);
846183234Ssimon}
847183234Ssimon
848296465Sdelphij#endif                          /* OPENSSL_NO_SEED */
849