~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-updates

« back to all changes in this revision

Viewing changes to cipher/tiger.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* tiger.c  -  The TIGER hash function
2
 
 *      Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3
 
 *
4
 
 * This file is part of GnuPG.
5
 
 *
6
 
 * GnuPG is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * GnuPG is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
#include <stdio.h>
23
 
#include <stdlib.h>
24
 
#include <string.h>
25
 
#include <assert.h>
26
 
#include "util.h"
27
 
#include "memory.h"
28
 
#include "algorithms.h"
29
 
 
30
 
#ifdef HAVE_U64_TYPEDEF
31
 
 
32
 
/* we really need it here, but as this is only experiment we
33
 
 * can live without Tiger */
34
 
 
35
 
typedef struct {
36
 
    u64  a, b, c;
37
 
    byte buf[64];
38
 
    int  count;
39
 
    u32  nblocks;
40
 
} TIGER_CONTEXT;
41
 
 
42
 
 
43
 
/*********************************
44
 
 * Okay, okay, this is not the fastest code - improvements are welcome.
45
 
 *
46
 
 */
47
 
 
48
 
/* Some test vectors:
49
 
 * ""                   24F0130C63AC9332 16166E76B1BB925F F373DE2D49584E7A
50
 
 * "abc"                F258C1E88414AB2A 527AB541FFC5B8BF 935F7B951C132951
51
 
 * "Tiger"              9F00F599072300DD 276ABB38C8EB6DEC 37790C116F9D2BDF
52
 
 * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
53
 
 *                      87FB2A9083851CF7 470D2CF810E6DF9E B586445034A5A386
54
 
 * "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789"
55
 
 *                      467DB80863EBCE48 8DF1CD1261655DE9 57896565975F9197
56
 
 * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"
57
 
 *                      0C410A042968868A 1671DA5A3FD29A72 5EC1E457D3CDB303
58
 
 * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
59
 
 * "eedings of Fast Software Encryption 3, Cambridge."
60
 
 *                      EBF591D5AFA655CE 7F22894FF87F54AC 89C811B6B0DA3193
61
 
 * "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proc"
62
 
 * "eedings of Fast Software Encryption 3, Cambridge, 1996."
63
 
 *                      3D9AEB03D1BD1A63 57B2774DFD6D5B24 DD68151D503974FC
64
 
 * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEF"
65
 
 * "GHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"
66
 
 *                      00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4
67
 
 */
68
 
 
69
 
 
70
 
static u64 sbox1[256] = {
71
 
    0x02aab17cf7e90c5eLL /*    0 */,    0xac424b03e243a8ecLL /*    1 */,
72
 
    0x72cd5be30dd5fcd3LL /*    2 */,    0x6d019b93f6f97f3aLL /*    3 */,
73
 
    0xcd9978ffd21f9193LL /*    4 */,    0x7573a1c9708029e2LL /*    5 */,
74
 
    0xb164326b922a83c3LL /*    6 */,    0x46883eee04915870LL /*    7 */,
75
 
    0xeaace3057103ece6LL /*    8 */,    0xc54169b808a3535cLL /*    9 */,
76
 
    0x4ce754918ddec47cLL /*   10 */,    0x0aa2f4dfdc0df40cLL /*   11 */,
77
 
    0x10b76f18a74dbefaLL /*   12 */,    0xc6ccb6235ad1ab6aLL /*   13 */,
78
 
    0x13726121572fe2ffLL /*   14 */,    0x1a488c6f199d921eLL /*   15 */,
79
 
    0x4bc9f9f4da0007caLL /*   16 */,    0x26f5e6f6e85241c7LL /*   17 */,
80
 
    0x859079dbea5947b6LL /*   18 */,    0x4f1885c5c99e8c92LL /*   19 */,
81
 
    0xd78e761ea96f864bLL /*   20 */,    0x8e36428c52b5c17dLL /*   21 */,
82
 
    0x69cf6827373063c1LL /*   22 */,    0xb607c93d9bb4c56eLL /*   23 */,
83
 
    0x7d820e760e76b5eaLL /*   24 */,    0x645c9cc6f07fdc42LL /*   25 */,
84
 
    0xbf38a078243342e0LL /*   26 */,    0x5f6b343c9d2e7d04LL /*   27 */,
85
 
    0xf2c28aeb600b0ec6LL /*   28 */,    0x6c0ed85f7254bcacLL /*   29 */,
86
 
    0x71592281a4db4fe5LL /*   30 */,    0x1967fa69ce0fed9fLL /*   31 */,
87
 
    0xfd5293f8b96545dbLL /*   32 */,    0xc879e9d7f2a7600bLL /*   33 */,
88
 
    0x860248920193194eLL /*   34 */,    0xa4f9533b2d9cc0b3LL /*   35 */,
89
 
    0x9053836c15957613LL /*   36 */,    0xdb6dcf8afc357bf1LL /*   37 */,
90
 
    0x18beea7a7a370f57LL /*   38 */,    0x037117ca50b99066LL /*   39 */,
91
 
    0x6ab30a9774424a35LL /*   40 */,    0xf4e92f02e325249bLL /*   41 */,
92
 
    0x7739db07061ccae1LL /*   42 */,    0xd8f3b49ceca42a05LL /*   43 */,
93
 
    0xbd56be3f51382f73LL /*   44 */,    0x45faed5843b0bb28LL /*   45 */,
94
 
    0x1c813d5c11bf1f83LL /*   46 */,    0x8af0e4b6d75fa169LL /*   47 */,
95
 
    0x33ee18a487ad9999LL /*   48 */,    0x3c26e8eab1c94410LL /*   49 */,
96
 
    0xb510102bc0a822f9LL /*   50 */,    0x141eef310ce6123bLL /*   51 */,
97
 
    0xfc65b90059ddb154LL /*   52 */,    0xe0158640c5e0e607LL /*   53 */,
98
 
    0x884e079826c3a3cfLL /*   54 */,    0x930d0d9523c535fdLL /*   55 */,
99
 
    0x35638d754e9a2b00LL /*   56 */,    0x4085fccf40469dd5LL /*   57 */,
100
 
    0xc4b17ad28be23a4cLL /*   58 */,    0xcab2f0fc6a3e6a2eLL /*   59 */,
101
 
    0x2860971a6b943fcdLL /*   60 */,    0x3dde6ee212e30446LL /*   61 */,
102
 
    0x6222f32ae01765aeLL /*   62 */,    0x5d550bb5478308feLL /*   63 */,
103
 
    0xa9efa98da0eda22aLL /*   64 */,    0xc351a71686c40da7LL /*   65 */,
104
 
    0x1105586d9c867c84LL /*   66 */,    0xdcffee85fda22853LL /*   67 */,
105
 
    0xccfbd0262c5eef76LL /*   68 */,    0xbaf294cb8990d201LL /*   69 */,
106
 
    0xe69464f52afad975LL /*   70 */,    0x94b013afdf133e14LL /*   71 */,
107
 
    0x06a7d1a32823c958LL /*   72 */,    0x6f95fe5130f61119LL /*   73 */,
108
 
    0xd92ab34e462c06c0LL /*   74 */,    0xed7bde33887c71d2LL /*   75 */,
109
 
    0x79746d6e6518393eLL /*   76 */,    0x5ba419385d713329LL /*   77 */,
110
 
    0x7c1ba6b948a97564LL /*   78 */,    0x31987c197bfdac67LL /*   79 */,
111
 
    0xde6c23c44b053d02LL /*   80 */,    0x581c49fed002d64dLL /*   81 */,
112
 
    0xdd474d6338261571LL /*   82 */,    0xaa4546c3e473d062LL /*   83 */,
113
 
    0x928fce349455f860LL /*   84 */,    0x48161bbacaab94d9LL /*   85 */,
114
 
    0x63912430770e6f68LL /*   86 */,    0x6ec8a5e602c6641cLL /*   87 */,
115
 
    0x87282515337ddd2bLL /*   88 */,    0x2cda6b42034b701bLL /*   89 */,
116
 
    0xb03d37c181cb096dLL /*   90 */,    0xe108438266c71c6fLL /*   91 */,
117
 
    0x2b3180c7eb51b255LL /*   92 */,    0xdf92b82f96c08bbcLL /*   93 */,
118
 
    0x5c68c8c0a632f3baLL /*   94 */,    0x5504cc861c3d0556LL /*   95 */,
119
 
    0xabbfa4e55fb26b8fLL /*   96 */,    0x41848b0ab3baceb4LL /*   97 */,
120
 
    0xb334a273aa445d32LL /*   98 */,    0xbca696f0a85ad881LL /*   99 */,
121
 
    0x24f6ec65b528d56cLL /*  100 */,    0x0ce1512e90f4524aLL /*  101 */,
122
 
    0x4e9dd79d5506d35aLL /*  102 */,    0x258905fac6ce9779LL /*  103 */,
123
 
    0x2019295b3e109b33LL /*  104 */,    0xf8a9478b73a054ccLL /*  105 */,
124
 
    0x2924f2f934417eb0LL /*  106 */,    0x3993357d536d1bc4LL /*  107 */,
125
 
    0x38a81ac21db6ff8bLL /*  108 */,    0x47c4fbf17d6016bfLL /*  109 */,
126
 
    0x1e0faadd7667e3f5LL /*  110 */,    0x7abcff62938beb96LL /*  111 */,
127
 
    0xa78dad948fc179c9LL /*  112 */,    0x8f1f98b72911e50dLL /*  113 */,
128
 
    0x61e48eae27121a91LL /*  114 */,    0x4d62f7ad31859808LL /*  115 */,
129
 
    0xeceba345ef5ceaebLL /*  116 */,    0xf5ceb25ebc9684ceLL /*  117 */,
130
 
    0xf633e20cb7f76221LL /*  118 */,    0xa32cdf06ab8293e4LL /*  119 */,
131
 
    0x985a202ca5ee2ca4LL /*  120 */,    0xcf0b8447cc8a8fb1LL /*  121 */,
132
 
    0x9f765244979859a3LL /*  122 */,    0xa8d516b1a1240017LL /*  123 */,
133
 
    0x0bd7ba3ebb5dc726LL /*  124 */,    0xe54bca55b86adb39LL /*  125 */,
134
 
    0x1d7a3afd6c478063LL /*  126 */,    0x519ec608e7669eddLL /*  127 */,
135
 
    0x0e5715a2d149aa23LL /*  128 */,    0x177d4571848ff194LL /*  129 */,
136
 
    0xeeb55f3241014c22LL /*  130 */,    0x0f5e5ca13a6e2ec2LL /*  131 */,
137
 
    0x8029927b75f5c361LL /*  132 */,    0xad139fabc3d6e436LL /*  133 */,
138
 
    0x0d5df1a94ccf402fLL /*  134 */,    0x3e8bd948bea5dfc8LL /*  135 */,
139
 
    0xa5a0d357bd3ff77eLL /*  136 */,    0xa2d12e251f74f645LL /*  137 */,
140
 
    0x66fd9e525e81a082LL /*  138 */,    0x2e0c90ce7f687a49LL /*  139 */,
141
 
    0xc2e8bcbeba973bc5LL /*  140 */,    0x000001bce509745fLL /*  141 */,
142
 
    0x423777bbe6dab3d6LL /*  142 */,    0xd1661c7eaef06eb5LL /*  143 */,
143
 
    0xa1781f354daacfd8LL /*  144 */,    0x2d11284a2b16affcLL /*  145 */,
144
 
    0xf1fc4f67fa891d1fLL /*  146 */,    0x73ecc25dcb920adaLL /*  147 */,
145
 
    0xae610c22c2a12651LL /*  148 */,    0x96e0a810d356b78aLL /*  149 */,
146
 
    0x5a9a381f2fe7870fLL /*  150 */,    0xd5ad62ede94e5530LL /*  151 */,
147
 
    0xd225e5e8368d1427LL /*  152 */,    0x65977b70c7af4631LL /*  153 */,
148
 
    0x99f889b2de39d74fLL /*  154 */,    0x233f30bf54e1d143LL /*  155 */,
149
 
    0x9a9675d3d9a63c97LL /*  156 */,    0x5470554ff334f9a8LL /*  157 */,
150
 
    0x166acb744a4f5688LL /*  158 */,    0x70c74caab2e4aeadLL /*  159 */,
151
 
    0xf0d091646f294d12LL /*  160 */,    0x57b82a89684031d1LL /*  161 */,
152
 
    0xefd95a5a61be0b6bLL /*  162 */,    0x2fbd12e969f2f29aLL /*  163 */,
153
 
    0x9bd37013feff9fe8LL /*  164 */,    0x3f9b0404d6085a06LL /*  165 */,
154
 
    0x4940c1f3166cfe15LL /*  166 */,    0x09542c4dcdf3defbLL /*  167 */,
155
 
    0xb4c5218385cd5ce3LL /*  168 */,    0xc935b7dc4462a641LL /*  169 */,
156
 
    0x3417f8a68ed3b63fLL /*  170 */,    0xb80959295b215b40LL /*  171 */,
157
 
    0xf99cdaef3b8c8572LL /*  172 */,    0x018c0614f8fcb95dLL /*  173 */,
158
 
    0x1b14accd1a3acdf3LL /*  174 */,    0x84d471f200bb732dLL /*  175 */,
159
 
    0xc1a3110e95e8da16LL /*  176 */,    0x430a7220bf1a82b8LL /*  177 */,
160
 
    0xb77e090d39df210eLL /*  178 */,    0x5ef4bd9f3cd05e9dLL /*  179 */,
161
 
    0x9d4ff6da7e57a444LL /*  180 */,    0xda1d60e183d4a5f8LL /*  181 */,
162
 
    0xb287c38417998e47LL /*  182 */,    0xfe3edc121bb31886LL /*  183 */,
163
 
    0xc7fe3ccc980ccbefLL /*  184 */,    0xe46fb590189bfd03LL /*  185 */,
164
 
    0x3732fd469a4c57dcLL /*  186 */,    0x7ef700a07cf1ad65LL /*  187 */,
165
 
    0x59c64468a31d8859LL /*  188 */,    0x762fb0b4d45b61f6LL /*  189 */,
166
 
    0x155baed099047718LL /*  190 */,    0x68755e4c3d50baa6LL /*  191 */,
167
 
    0xe9214e7f22d8b4dfLL /*  192 */,    0x2addbf532eac95f4LL /*  193 */,
168
 
    0x32ae3909b4bd0109LL /*  194 */,    0x834df537b08e3450LL /*  195 */,
169
 
    0xfa209da84220728dLL /*  196 */,    0x9e691d9b9efe23f7LL /*  197 */,
170
 
    0x0446d288c4ae8d7fLL /*  198 */,    0x7b4cc524e169785bLL /*  199 */,
171
 
    0x21d87f0135ca1385LL /*  200 */,    0xcebb400f137b8aa5LL /*  201 */,
172
 
    0x272e2b66580796beLL /*  202 */,    0x3612264125c2b0deLL /*  203 */,
173
 
    0x057702bdad1efbb2LL /*  204 */,    0xd4babb8eacf84be9LL /*  205 */,
174
 
    0x91583139641bc67bLL /*  206 */,    0x8bdc2de08036e024LL /*  207 */,
175
 
    0x603c8156f49f68edLL /*  208 */,    0xf7d236f7dbef5111LL /*  209 */,
176
 
    0x9727c4598ad21e80LL /*  210 */,    0xa08a0896670a5fd7LL /*  211 */,
177
 
    0xcb4a8f4309eba9cbLL /*  212 */,    0x81af564b0f7036a1LL /*  213 */,
178
 
    0xc0b99aa778199abdLL /*  214 */,    0x959f1ec83fc8e952LL /*  215 */,
179
 
    0x8c505077794a81b9LL /*  216 */,    0x3acaaf8f056338f0LL /*  217 */,
180
 
    0x07b43f50627a6778LL /*  218 */,    0x4a44ab49f5eccc77LL /*  219 */,
181
 
    0x3bc3d6e4b679ee98LL /*  220 */,    0x9cc0d4d1cf14108cLL /*  221 */,
182
 
    0x4406c00b206bc8a0LL /*  222 */,    0x82a18854c8d72d89LL /*  223 */,
183
 
    0x67e366b35c3c432cLL /*  224 */,    0xb923dd61102b37f2LL /*  225 */,
184
 
    0x56ab2779d884271dLL /*  226 */,    0xbe83e1b0ff1525afLL /*  227 */,
185
 
    0xfb7c65d4217e49a9LL /*  228 */,    0x6bdbe0e76d48e7d4LL /*  229 */,
186
 
    0x08df828745d9179eLL /*  230 */,    0x22ea6a9add53bd34LL /*  231 */,
187
 
    0xe36e141c5622200aLL /*  232 */,    0x7f805d1b8cb750eeLL /*  233 */,
188
 
    0xafe5c7a59f58e837LL /*  234 */,    0xe27f996a4fb1c23cLL /*  235 */,
189
 
    0xd3867dfb0775f0d0LL /*  236 */,    0xd0e673de6e88891aLL /*  237 */,
190
 
    0x123aeb9eafb86c25LL /*  238 */,    0x30f1d5d5c145b895LL /*  239 */,
191
 
    0xbb434a2dee7269e7LL /*  240 */,    0x78cb67ecf931fa38LL /*  241 */,
192
 
    0xf33b0372323bbf9cLL /*  242 */,    0x52d66336fb279c74LL /*  243 */,
193
 
    0x505f33ac0afb4eaaLL /*  244 */,    0xe8a5cd99a2cce187LL /*  245 */,
194
 
    0x534974801e2d30bbLL /*  246 */,    0x8d2d5711d5876d90LL /*  247 */,
195
 
    0x1f1a412891bc038eLL /*  248 */,    0xd6e2e71d82e56648LL /*  249 */,
196
 
    0x74036c3a497732b7LL /*  250 */,    0x89b67ed96361f5abLL /*  251 */,
197
 
    0xffed95d8f1ea02a2LL /*  252 */,    0xe72b3bd61464d43dLL /*  253 */,
198
 
    0xa6300f170bdc4820LL /*  254 */,    0xebc18760ed78a77aLL /*  255 */
199
 
};
200
 
static u64 sbox2[256] = {
201
 
    0xe6a6be5a05a12138LL /*  256 */,    0xb5a122a5b4f87c98LL /*  257 */,
202
 
    0x563c6089140b6990LL /*  258 */,    0x4c46cb2e391f5dd5LL /*  259 */,
203
 
    0xd932addbc9b79434LL /*  260 */,    0x08ea70e42015aff5LL /*  261 */,
204
 
    0xd765a6673e478cf1LL /*  262 */,    0xc4fb757eab278d99LL /*  263 */,
205
 
    0xdf11c6862d6e0692LL /*  264 */,    0xddeb84f10d7f3b16LL /*  265 */,
206
 
    0x6f2ef604a665ea04LL /*  266 */,    0x4a8e0f0ff0e0dfb3LL /*  267 */,
207
 
    0xa5edeef83dbcba51LL /*  268 */,    0xfc4f0a2a0ea4371eLL /*  269 */,
208
 
    0xe83e1da85cb38429LL /*  270 */,    0xdc8ff882ba1b1ce2LL /*  271 */,
209
 
    0xcd45505e8353e80dLL /*  272 */,    0x18d19a00d4db0717LL /*  273 */,
210
 
    0x34a0cfeda5f38101LL /*  274 */,    0x0be77e518887caf2LL /*  275 */,
211
 
    0x1e341438b3c45136LL /*  276 */,    0xe05797f49089ccf9LL /*  277 */,
212
 
    0xffd23f9df2591d14LL /*  278 */,    0x543dda228595c5cdLL /*  279 */,
213
 
    0x661f81fd99052a33LL /*  280 */,    0x8736e641db0f7b76LL /*  281 */,
214
 
    0x15227725418e5307LL /*  282 */,    0xe25f7f46162eb2faLL /*  283 */,
215
 
    0x48a8b2126c13d9feLL /*  284 */,    0xafdc541792e76eeaLL /*  285 */,
216
 
    0x03d912bfc6d1898fLL /*  286 */,    0x31b1aafa1b83f51bLL /*  287 */,
217
 
    0xf1ac2796e42ab7d9LL /*  288 */,    0x40a3a7d7fcd2ebacLL /*  289 */,
218
 
    0x1056136d0afbbcc5LL /*  290 */,    0x7889e1dd9a6d0c85LL /*  291 */,
219
 
    0xd33525782a7974aaLL /*  292 */,    0xa7e25d09078ac09bLL /*  293 */,
220
 
    0xbd4138b3eac6edd0LL /*  294 */,    0x920abfbe71eb9e70LL /*  295 */,
221
 
    0xa2a5d0f54fc2625cLL /*  296 */,    0xc054e36b0b1290a3LL /*  297 */,
222
 
    0xf6dd59ff62fe932bLL /*  298 */,    0x3537354511a8ac7dLL /*  299 */,
223
 
    0xca845e9172fadcd4LL /*  300 */,    0x84f82b60329d20dcLL /*  301 */,
224
 
    0x79c62ce1cd672f18LL /*  302 */,    0x8b09a2add124642cLL /*  303 */,
225
 
    0xd0c1e96a19d9e726LL /*  304 */,    0x5a786a9b4ba9500cLL /*  305 */,
226
 
    0x0e020336634c43f3LL /*  306 */,    0xc17b474aeb66d822LL /*  307 */,
227
 
    0x6a731ae3ec9baac2LL /*  308 */,    0x8226667ae0840258LL /*  309 */,
228
 
    0x67d4567691caeca5LL /*  310 */,    0x1d94155c4875adb5LL /*  311 */,
229
 
    0x6d00fd985b813fdfLL /*  312 */,    0x51286efcb774cd06LL /*  313 */,
230
 
    0x5e8834471fa744afLL /*  314 */,    0xf72ca0aee761ae2eLL /*  315 */,
231
 
    0xbe40e4cdaee8e09aLL /*  316 */,    0xe9970bbb5118f665LL /*  317 */,
232
 
    0x726e4beb33df1964LL /*  318 */,    0x703b000729199762LL /*  319 */,
233
 
    0x4631d816f5ef30a7LL /*  320 */,    0xb880b5b51504a6beLL /*  321 */,
234
 
    0x641793c37ed84b6cLL /*  322 */,    0x7b21ed77f6e97d96LL /*  323 */,
235
 
    0x776306312ef96b73LL /*  324 */,    0xae528948e86ff3f4LL /*  325 */,
236
 
    0x53dbd7f286a3f8f8LL /*  326 */,    0x16cadce74cfc1063LL /*  327 */,
237
 
    0x005c19bdfa52c6ddLL /*  328 */,    0x68868f5d64d46ad3LL /*  329 */,
238
 
    0x3a9d512ccf1e186aLL /*  330 */,    0x367e62c2385660aeLL /*  331 */,
239
 
    0xe359e7ea77dcb1d7LL /*  332 */,    0x526c0773749abe6eLL /*  333 */,
240
 
    0x735ae5f9d09f734bLL /*  334 */,    0x493fc7cc8a558ba8LL /*  335 */,
241
 
    0xb0b9c1533041ab45LL /*  336 */,    0x321958ba470a59bdLL /*  337 */,
242
 
    0x852db00b5f46c393LL /*  338 */,    0x91209b2bd336b0e5LL /*  339 */,
243
 
    0x6e604f7d659ef19fLL /*  340 */,    0xb99a8ae2782ccb24LL /*  341 */,
244
 
    0xccf52ab6c814c4c7LL /*  342 */,    0x4727d9afbe11727bLL /*  343 */,
245
 
    0x7e950d0c0121b34dLL /*  344 */,    0x756f435670ad471fLL /*  345 */,
246
 
    0xf5add442615a6849LL /*  346 */,    0x4e87e09980b9957aLL /*  347 */,
247
 
    0x2acfa1df50aee355LL /*  348 */,    0xd898263afd2fd556LL /*  349 */,
248
 
    0xc8f4924dd80c8fd6LL /*  350 */,    0xcf99ca3d754a173aLL /*  351 */,
249
 
    0xfe477bacaf91bf3cLL /*  352 */,    0xed5371f6d690c12dLL /*  353 */,
250
 
    0x831a5c285e687094LL /*  354 */,    0xc5d3c90a3708a0a4LL /*  355 */,
251
 
    0x0f7f903717d06580LL /*  356 */,    0x19f9bb13b8fdf27fLL /*  357 */,
252
 
    0xb1bd6f1b4d502843LL /*  358 */,    0x1c761ba38fff4012LL /*  359 */,
253
 
    0x0d1530c4e2e21f3bLL /*  360 */,    0x8943ce69a7372c8aLL /*  361 */,
254
 
    0xe5184e11feb5ce66LL /*  362 */,    0x618bdb80bd736621LL /*  363 */,
255
 
    0x7d29bad68b574d0bLL /*  364 */,    0x81bb613e25e6fe5bLL /*  365 */,
256
 
    0x071c9c10bc07913fLL /*  366 */,    0xc7beeb7909ac2d97LL /*  367 */,
257
 
    0xc3e58d353bc5d757LL /*  368 */,    0xeb017892f38f61e8LL /*  369 */,
258
 
    0xd4effb9c9b1cc21aLL /*  370 */,    0x99727d26f494f7abLL /*  371 */,
259
 
    0xa3e063a2956b3e03LL /*  372 */,    0x9d4a8b9a4aa09c30LL /*  373 */,
260
 
    0x3f6ab7d500090fb4LL /*  374 */,    0x9cc0f2a057268ac0LL /*  375 */,
261
 
    0x3dee9d2dedbf42d1LL /*  376 */,    0x330f49c87960a972LL /*  377 */,
262
 
    0xc6b2720287421b41LL /*  378 */,    0x0ac59ec07c00369cLL /*  379 */,
263
 
    0xef4eac49cb353425LL /*  380 */,    0xf450244eef0129d8LL /*  381 */,
264
 
    0x8acc46e5caf4deb6LL /*  382 */,    0x2ffeab63989263f7LL /*  383 */,
265
 
    0x8f7cb9fe5d7a4578LL /*  384 */,    0x5bd8f7644e634635LL /*  385 */,
266
 
    0x427a7315bf2dc900LL /*  386 */,    0x17d0c4aa2125261cLL /*  387 */,
267
 
    0x3992486c93518e50LL /*  388 */,    0xb4cbfee0a2d7d4c3LL /*  389 */,
268
 
    0x7c75d6202c5ddd8dLL /*  390 */,    0xdbc295d8e35b6c61LL /*  391 */,
269
 
    0x60b369d302032b19LL /*  392 */,    0xce42685fdce44132LL /*  393 */,
270
 
    0x06f3ddb9ddf65610LL /*  394 */,    0x8ea4d21db5e148f0LL /*  395 */,
271
 
    0x20b0fce62fcd496fLL /*  396 */,    0x2c1b912358b0ee31LL /*  397 */,
272
 
    0xb28317b818f5a308LL /*  398 */,    0xa89c1e189ca6d2cfLL /*  399 */,
273
 
    0x0c6b18576aaadbc8LL /*  400 */,    0xb65deaa91299fae3LL /*  401 */,
274
 
    0xfb2b794b7f1027e7LL /*  402 */,    0x04e4317f443b5bebLL /*  403 */,
275
 
    0x4b852d325939d0a6LL /*  404 */,    0xd5ae6beefb207ffcLL /*  405 */,
276
 
    0x309682b281c7d374LL /*  406 */,    0xbae309a194c3b475LL /*  407 */,
277
 
    0x8cc3f97b13b49f05LL /*  408 */,    0x98a9422ff8293967LL /*  409 */,
278
 
    0x244b16b01076ff7cLL /*  410 */,    0xf8bf571c663d67eeLL /*  411 */,
279
 
    0x1f0d6758eee30da1LL /*  412 */,    0xc9b611d97adeb9b7LL /*  413 */,
280
 
    0xb7afd5887b6c57a2LL /*  414 */,    0x6290ae846b984fe1LL /*  415 */,
281
 
    0x94df4cdeacc1a5fdLL /*  416 */,    0x058a5bd1c5483affLL /*  417 */,
282
 
    0x63166cc142ba3c37LL /*  418 */,    0x8db8526eb2f76f40LL /*  419 */,
283
 
    0xe10880036f0d6d4eLL /*  420 */,    0x9e0523c9971d311dLL /*  421 */,
284
 
    0x45ec2824cc7cd691LL /*  422 */,    0x575b8359e62382c9LL /*  423 */,
285
 
    0xfa9e400dc4889995LL /*  424 */,    0xd1823ecb45721568LL /*  425 */,
286
 
    0xdafd983b8206082fLL /*  426 */,    0xaa7d29082386a8cbLL /*  427 */,
287
 
    0x269fcd4403b87588LL /*  428 */,    0x1b91f5f728bdd1e0LL /*  429 */,
288
 
    0xe4669f39040201f6LL /*  430 */,    0x7a1d7c218cf04adeLL /*  431 */,
289
 
    0x65623c29d79ce5ceLL /*  432 */,    0x2368449096c00bb1LL /*  433 */,
290
 
    0xab9bf1879da503baLL /*  434 */,    0xbc23ecb1a458058eLL /*  435 */,
291
 
    0x9a58df01bb401eccLL /*  436 */,    0xa070e868a85f143dLL /*  437 */,
292
 
    0x4ff188307df2239eLL /*  438 */,    0x14d565b41a641183LL /*  439 */,
293
 
    0xee13337452701602LL /*  440 */,    0x950e3dcf3f285e09LL /*  441 */,
294
 
    0x59930254b9c80953LL /*  442 */,    0x3bf299408930da6dLL /*  443 */,
295
 
    0xa955943f53691387LL /*  444 */,    0xa15edecaa9cb8784LL /*  445 */,
296
 
    0x29142127352be9a0LL /*  446 */,    0x76f0371fff4e7afbLL /*  447 */,
297
 
    0x0239f450274f2228LL /*  448 */,    0xbb073af01d5e868bLL /*  449 */,
298
 
    0xbfc80571c10e96c1LL /*  450 */,    0xd267088568222e23LL /*  451 */,
299
 
    0x9671a3d48e80b5b0LL /*  452 */,    0x55b5d38ae193bb81LL /*  453 */,
300
 
    0x693ae2d0a18b04b8LL /*  454 */,    0x5c48b4ecadd5335fLL /*  455 */,
301
 
    0xfd743b194916a1caLL /*  456 */,    0x2577018134be98c4LL /*  457 */,
302
 
    0xe77987e83c54a4adLL /*  458 */,    0x28e11014da33e1b9LL /*  459 */,
303
 
    0x270cc59e226aa213LL /*  460 */,    0x71495f756d1a5f60LL /*  461 */,
304
 
    0x9be853fb60afef77LL /*  462 */,    0xadc786a7f7443dbfLL /*  463 */,
305
 
    0x0904456173b29a82LL /*  464 */,    0x58bc7a66c232bd5eLL /*  465 */,
306
 
    0xf306558c673ac8b2LL /*  466 */,    0x41f639c6b6c9772aLL /*  467 */,
307
 
    0x216defe99fda35daLL /*  468 */,    0x11640cc71c7be615LL /*  469 */,
308
 
    0x93c43694565c5527LL /*  470 */,    0xea038e6246777839LL /*  471 */,
309
 
    0xf9abf3ce5a3e2469LL /*  472 */,    0x741e768d0fd312d2LL /*  473 */,
310
 
    0x0144b883ced652c6LL /*  474 */,    0xc20b5a5ba33f8552LL /*  475 */,
311
 
    0x1ae69633c3435a9dLL /*  476 */,    0x97a28ca4088cfdecLL /*  477 */,
312
 
    0x8824a43c1e96f420LL /*  478 */,    0x37612fa66eeea746LL /*  479 */,
313
 
    0x6b4cb165f9cf0e5aLL /*  480 */,    0x43aa1c06a0abfb4aLL /*  481 */,
314
 
    0x7f4dc26ff162796bLL /*  482 */,    0x6cbacc8e54ed9b0fLL /*  483 */,
315
 
    0xa6b7ffefd2bb253eLL /*  484 */,    0x2e25bc95b0a29d4fLL /*  485 */,
316
 
    0x86d6a58bdef1388cLL /*  486 */,    0xded74ac576b6f054LL /*  487 */,
317
 
    0x8030bdbc2b45805dLL /*  488 */,    0x3c81af70e94d9289LL /*  489 */,
318
 
    0x3eff6dda9e3100dbLL /*  490 */,    0xb38dc39fdfcc8847LL /*  491 */,
319
 
    0x123885528d17b87eLL /*  492 */,    0xf2da0ed240b1b642LL /*  493 */,
320
 
    0x44cefadcd54bf9a9LL /*  494 */,    0x1312200e433c7ee6LL /*  495 */,
321
 
    0x9ffcc84f3a78c748LL /*  496 */,    0xf0cd1f72248576bbLL /*  497 */,
322
 
    0xec6974053638cfe4LL /*  498 */,    0x2ba7b67c0cec4e4cLL /*  499 */,
323
 
    0xac2f4df3e5ce32edLL /*  500 */,    0xcb33d14326ea4c11LL /*  501 */,
324
 
    0xa4e9044cc77e58bcLL /*  502 */,    0x5f513293d934fcefLL /*  503 */,
325
 
    0x5dc9645506e55444LL /*  504 */,    0x50de418f317de40aLL /*  505 */,
326
 
    0x388cb31a69dde259LL /*  506 */,    0x2db4a83455820a86LL /*  507 */,
327
 
    0x9010a91e84711ae9LL /*  508 */,    0x4df7f0b7b1498371LL /*  509 */,
328
 
    0xd62a2eabc0977179LL /*  510 */,    0x22fac097aa8d5c0eLL /*  511 */
329
 
};
330
 
static u64 sbox3[256] = {
331
 
    0xf49fcc2ff1daf39bLL /*  512 */,    0x487fd5c66ff29281LL /*  513 */,
332
 
    0xe8a30667fcdca83fLL /*  514 */,    0x2c9b4be3d2fcce63LL /*  515 */,
333
 
    0xda3ff74b93fbbbc2LL /*  516 */,    0x2fa165d2fe70ba66LL /*  517 */,
334
 
    0xa103e279970e93d4LL /*  518 */,    0xbecdec77b0e45e71LL /*  519 */,
335
 
    0xcfb41e723985e497LL /*  520 */,    0xb70aaa025ef75017LL /*  521 */,
336
 
    0xd42309f03840b8e0LL /*  522 */,    0x8efc1ad035898579LL /*  523 */,
337
 
    0x96c6920be2b2abc5LL /*  524 */,    0x66af4163375a9172LL /*  525 */,
338
 
    0x2174abdcca7127fbLL /*  526 */,    0xb33ccea64a72ff41LL /*  527 */,
339
 
    0xf04a4933083066a5LL /*  528 */,    0x8d970acdd7289af5LL /*  529 */,
340
 
    0x8f96e8e031c8c25eLL /*  530 */,    0xf3fec02276875d47LL /*  531 */,
341
 
    0xec7bf310056190ddLL /*  532 */,    0xf5adb0aebb0f1491LL /*  533 */,
342
 
    0x9b50f8850fd58892LL /*  534 */,    0x4975488358b74de8LL /*  535 */,
343
 
    0xa3354ff691531c61LL /*  536 */,    0x0702bbe481d2c6eeLL /*  537 */,
344
 
    0x89fb24057deded98LL /*  538 */,    0xac3075138596e902LL /*  539 */,
345
 
    0x1d2d3580172772edLL /*  540 */,    0xeb738fc28e6bc30dLL /*  541 */,
346
 
    0x5854ef8f63044326LL /*  542 */,    0x9e5c52325add3bbeLL /*  543 */,
347
 
    0x90aa53cf325c4623LL /*  544 */,    0xc1d24d51349dd067LL /*  545 */,
348
 
    0x2051cfeea69ea624LL /*  546 */,    0x13220f0a862e7e4fLL /*  547 */,
349
 
    0xce39399404e04864LL /*  548 */,    0xd9c42ca47086fcb7LL /*  549 */,
350
 
    0x685ad2238a03e7ccLL /*  550 */,    0x066484b2ab2ff1dbLL /*  551 */,
351
 
    0xfe9d5d70efbf79ecLL /*  552 */,    0x5b13b9dd9c481854LL /*  553 */,
352
 
    0x15f0d475ed1509adLL /*  554 */,    0x0bebcd060ec79851LL /*  555 */,
353
 
    0xd58c6791183ab7f8LL /*  556 */,    0xd1187c5052f3eee4LL /*  557 */,
354
 
    0xc95d1192e54e82ffLL /*  558 */,    0x86eea14cb9ac6ca2LL /*  559 */,
355
 
    0x3485beb153677d5dLL /*  560 */,    0xdd191d781f8c492aLL /*  561 */,
356
 
    0xf60866baa784ebf9LL /*  562 */,    0x518f643ba2d08c74LL /*  563 */,
357
 
    0x8852e956e1087c22LL /*  564 */,    0xa768cb8dc410ae8dLL /*  565 */,
358
 
    0x38047726bfec8e1aLL /*  566 */,    0xa67738b4cd3b45aaLL /*  567 */,
359
 
    0xad16691cec0dde19LL /*  568 */,    0xc6d4319380462e07LL /*  569 */,
360
 
    0xc5a5876d0ba61938LL /*  570 */,    0x16b9fa1fa58fd840LL /*  571 */,
361
 
    0x188ab1173ca74f18LL /*  572 */,    0xabda2f98c99c021fLL /*  573 */,
362
 
    0x3e0580ab134ae816LL /*  574 */,    0x5f3b05b773645abbLL /*  575 */,
363
 
    0x2501a2be5575f2f6LL /*  576 */,    0x1b2f74004e7e8ba9LL /*  577 */,
364
 
    0x1cd7580371e8d953LL /*  578 */,    0x7f6ed89562764e30LL /*  579 */,
365
 
    0xb15926ff596f003dLL /*  580 */,    0x9f65293da8c5d6b9LL /*  581 */,
366
 
    0x6ecef04dd690f84cLL /*  582 */,    0x4782275fff33af88LL /*  583 */,
367
 
    0xe41433083f820801LL /*  584 */,    0xfd0dfe409a1af9b5LL /*  585 */,
368
 
    0x4325a3342cdb396bLL /*  586 */,    0x8ae77e62b301b252LL /*  587 */,
369
 
    0xc36f9e9f6655615aLL /*  588 */,    0x85455a2d92d32c09LL /*  589 */,
370
 
    0xf2c7dea949477485LL /*  590 */,    0x63cfb4c133a39ebaLL /*  591 */,
371
 
    0x83b040cc6ebc5462LL /*  592 */,    0x3b9454c8fdb326b0LL /*  593 */,
372
 
    0x56f56a9e87ffd78cLL /*  594 */,    0x2dc2940d99f42bc6LL /*  595 */,
373
 
    0x98f7df096b096e2dLL /*  596 */,    0x19a6e01e3ad852bfLL /*  597 */,
374
 
    0x42a99ccbdbd4b40bLL /*  598 */,    0xa59998af45e9c559LL /*  599 */,
375
 
    0x366295e807d93186LL /*  600 */,    0x6b48181bfaa1f773LL /*  601 */,
376
 
    0x1fec57e2157a0a1dLL /*  602 */,    0x4667446af6201ad5LL /*  603 */,
377
 
    0xe615ebcacfb0f075LL /*  604 */,    0xb8f31f4f68290778LL /*  605 */,
378
 
    0x22713ed6ce22d11eLL /*  606 */,    0x3057c1a72ec3c93bLL /*  607 */,
379
 
    0xcb46acc37c3f1f2fLL /*  608 */,    0xdbb893fd02aaf50eLL /*  609 */,
380
 
    0x331fd92e600b9fcfLL /*  610 */,    0xa498f96148ea3ad6LL /*  611 */,
381
 
    0xa8d8426e8b6a83eaLL /*  612 */,    0xa089b274b7735cdcLL /*  613 */,
382
 
    0x87f6b3731e524a11LL /*  614 */,    0x118808e5cbc96749LL /*  615 */,
383
 
    0x9906e4c7b19bd394LL /*  616 */,    0xafed7f7e9b24a20cLL /*  617 */,
384
 
    0x6509eadeeb3644a7LL /*  618 */,    0x6c1ef1d3e8ef0edeLL /*  619 */,
385
 
    0xb9c97d43e9798fb4LL /*  620 */,    0xa2f2d784740c28a3LL /*  621 */,
386
 
    0x7b8496476197566fLL /*  622 */,    0x7a5be3e6b65f069dLL /*  623 */,
387
 
    0xf96330ed78be6f10LL /*  624 */,    0xeee60de77a076a15LL /*  625 */,
388
 
    0x2b4bee4aa08b9bd0LL /*  626 */,    0x6a56a63ec7b8894eLL /*  627 */,
389
 
    0x02121359ba34fef4LL /*  628 */,    0x4cbf99f8283703fcLL /*  629 */,
390
 
    0x398071350caf30c8LL /*  630 */,    0xd0a77a89f017687aLL /*  631 */,
391
 
    0xf1c1a9eb9e423569LL /*  632 */,    0x8c7976282dee8199LL /*  633 */,
392
 
    0x5d1737a5dd1f7abdLL /*  634 */,    0x4f53433c09a9fa80LL /*  635 */,
393
 
    0xfa8b0c53df7ca1d9LL /*  636 */,    0x3fd9dcbc886ccb77LL /*  637 */,
394
 
    0xc040917ca91b4720LL /*  638 */,    0x7dd00142f9d1dcdfLL /*  639 */,
395
 
    0x8476fc1d4f387b58LL /*  640 */,    0x23f8e7c5f3316503LL /*  641 */,
396
 
    0x032a2244e7e37339LL /*  642 */,    0x5c87a5d750f5a74bLL /*  643 */,
397
 
    0x082b4cc43698992eLL /*  644 */,    0xdf917becb858f63cLL /*  645 */,
398
 
    0x3270b8fc5bf86ddaLL /*  646 */,    0x10ae72bb29b5dd76LL /*  647 */,
399
 
    0x576ac94e7700362bLL /*  648 */,    0x1ad112dac61efb8fLL /*  649 */,
400
 
    0x691bc30ec5faa427LL /*  650 */,    0xff246311cc327143LL /*  651 */,
401
 
    0x3142368e30e53206LL /*  652 */,    0x71380e31e02ca396LL /*  653 */,
402
 
    0x958d5c960aad76f1LL /*  654 */,    0xf8d6f430c16da536LL /*  655 */,
403
 
    0xc8ffd13f1be7e1d2LL /*  656 */,    0x7578ae66004ddbe1LL /*  657 */,
404
 
    0x05833f01067be646LL /*  658 */,    0xbb34b5ad3bfe586dLL /*  659 */,
405
 
    0x095f34c9a12b97f0LL /*  660 */,    0x247ab64525d60ca8LL /*  661 */,
406
 
    0xdcdbc6f3017477d1LL /*  662 */,    0x4a2e14d4decad24dLL /*  663 */,
407
 
    0xbdb5e6d9be0a1eebLL /*  664 */,    0x2a7e70f7794301abLL /*  665 */,
408
 
    0xdef42d8a270540fdLL /*  666 */,    0x01078ec0a34c22c1LL /*  667 */,
409
 
    0xe5de511af4c16387LL /*  668 */,    0x7ebb3a52bd9a330aLL /*  669 */,
410
 
    0x77697857aa7d6435LL /*  670 */,    0x004e831603ae4c32LL /*  671 */,
411
 
    0xe7a21020ad78e312LL /*  672 */,    0x9d41a70c6ab420f2LL /*  673 */,
412
 
    0x28e06c18ea1141e6LL /*  674 */,    0xd2b28cbd984f6b28LL /*  675 */,
413
 
    0x26b75f6c446e9d83LL /*  676 */,    0xba47568c4d418d7fLL /*  677 */,
414
 
    0xd80badbfe6183d8eLL /*  678 */,    0x0e206d7f5f166044LL /*  679 */,
415
 
    0xe258a43911cbca3eLL /*  680 */,    0x723a1746b21dc0bcLL /*  681 */,
416
 
    0xc7caa854f5d7cdd3LL /*  682 */,    0x7cac32883d261d9cLL /*  683 */,
417
 
    0x7690c26423ba942cLL /*  684 */,    0x17e55524478042b8LL /*  685 */,
418
 
    0xe0be477656a2389fLL /*  686 */,    0x4d289b5e67ab2da0LL /*  687 */,
419
 
    0x44862b9c8fbbfd31LL /*  688 */,    0xb47cc8049d141365LL /*  689 */,
420
 
    0x822c1b362b91c793LL /*  690 */,    0x4eb14655fb13dfd8LL /*  691 */,
421
 
    0x1ecbba0714e2a97bLL /*  692 */,    0x6143459d5cde5f14LL /*  693 */,
422
 
    0x53a8fbf1d5f0ac89LL /*  694 */,    0x97ea04d81c5e5b00LL /*  695 */,
423
 
    0x622181a8d4fdb3f3LL /*  696 */,    0xe9bcd341572a1208LL /*  697 */,
424
 
    0x1411258643cce58aLL /*  698 */,    0x9144c5fea4c6e0a4LL /*  699 */,
425
 
    0x0d33d06565cf620fLL /*  700 */,    0x54a48d489f219ca1LL /*  701 */,
426
 
    0xc43e5eac6d63c821LL /*  702 */,    0xa9728b3a72770dafLL /*  703 */,
427
 
    0xd7934e7b20df87efLL /*  704 */,    0xe35503b61a3e86e5LL /*  705 */,
428
 
    0xcae321fbc819d504LL /*  706 */,    0x129a50b3ac60bfa6LL /*  707 */,
429
 
    0xcd5e68ea7e9fb6c3LL /*  708 */,    0xb01c90199483b1c7LL /*  709 */,
430
 
    0x3de93cd5c295376cLL /*  710 */,    0xaed52edf2ab9ad13LL /*  711 */,
431
 
    0x2e60f512c0a07884LL /*  712 */,    0xbc3d86a3e36210c9LL /*  713 */,
432
 
    0x35269d9b163951ceLL /*  714 */,    0x0c7d6e2ad0cdb5faLL /*  715 */,
433
 
    0x59e86297d87f5733LL /*  716 */,    0x298ef221898db0e7LL /*  717 */,
434
 
    0x55000029d1a5aa7eLL /*  718 */,    0x8bc08ae1b5061b45LL /*  719 */,
435
 
    0xc2c31c2b6c92703aLL /*  720 */,    0x94cc596baf25ef42LL /*  721 */,
436
 
    0x0a1d73db22540456LL /*  722 */,    0x04b6a0f9d9c4179aLL /*  723 */,
437
 
    0xeffdafa2ae3d3c60LL /*  724 */,    0xf7c8075bb49496c4LL /*  725 */,
438
 
    0x9cc5c7141d1cd4e3LL /*  726 */,    0x78bd1638218e5534LL /*  727 */,
439
 
    0xb2f11568f850246aLL /*  728 */,    0xedfabcfa9502bc29LL /*  729 */,
440
 
    0x796ce5f2da23051bLL /*  730 */,    0xaae128b0dc93537cLL /*  731 */,
441
 
    0x3a493da0ee4b29aeLL /*  732 */,    0xb5df6b2c416895d7LL /*  733 */,
442
 
    0xfcabbd25122d7f37LL /*  734 */,    0x70810b58105dc4b1LL /*  735 */,
443
 
    0xe10fdd37f7882a90LL /*  736 */,    0x524dcab5518a3f5cLL /*  737 */,
444
 
    0x3c9e85878451255bLL /*  738 */,    0x4029828119bd34e2LL /*  739 */,
445
 
    0x74a05b6f5d3ceccbLL /*  740 */,    0xb610021542e13ecaLL /*  741 */,
446
 
    0x0ff979d12f59e2acLL /*  742 */,    0x6037da27e4f9cc50LL /*  743 */,
447
 
    0x5e92975a0df1847dLL /*  744 */,    0xd66de190d3e623feLL /*  745 */,
448
 
    0x5032d6b87b568048LL /*  746 */,    0x9a36b7ce8235216eLL /*  747 */,
449
 
    0x80272a7a24f64b4aLL /*  748 */,    0x93efed8b8c6916f7LL /*  749 */,
450
 
    0x37ddbff44cce1555LL /*  750 */,    0x4b95db5d4b99bd25LL /*  751 */,
451
 
    0x92d3fda169812fc0LL /*  752 */,    0xfb1a4a9a90660bb6LL /*  753 */,
452
 
    0x730c196946a4b9b2LL /*  754 */,    0x81e289aa7f49da68LL /*  755 */,
453
 
    0x64669a0f83b1a05fLL /*  756 */,    0x27b3ff7d9644f48bLL /*  757 */,
454
 
    0xcc6b615c8db675b3LL /*  758 */,    0x674f20b9bcebbe95LL /*  759 */,
455
 
    0x6f31238275655982LL /*  760 */,    0x5ae488713e45cf05LL /*  761 */,
456
 
    0xbf619f9954c21157LL /*  762 */,    0xeabac46040a8eae9LL /*  763 */,
457
 
    0x454c6fe9f2c0c1cdLL /*  764 */,    0x419cf6496412691cLL /*  765 */,
458
 
    0xd3dc3bef265b0f70LL /*  766 */,    0x6d0e60f5c3578a9eLL /*  767 */
459
 
};
460
 
static u64 sbox4[256] = {
461
 
    0x5b0e608526323c55LL /*  768 */,    0x1a46c1a9fa1b59f5LL /*  769 */,
462
 
    0xa9e245a17c4c8ffaLL /*  770 */,    0x65ca5159db2955d7LL /*  771 */,
463
 
    0x05db0a76ce35afc2LL /*  772 */,    0x81eac77ea9113d45LL /*  773 */,
464
 
    0x528ef88ab6ac0a0dLL /*  774 */,    0xa09ea253597be3ffLL /*  775 */,
465
 
    0x430ddfb3ac48cd56LL /*  776 */,    0xc4b3a67af45ce46fLL /*  777 */,
466
 
    0x4ececfd8fbe2d05eLL /*  778 */,    0x3ef56f10b39935f0LL /*  779 */,
467
 
    0x0b22d6829cd619c6LL /*  780 */,    0x17fd460a74df2069LL /*  781 */,
468
 
    0x6cf8cc8e8510ed40LL /*  782 */,    0xd6c824bf3a6ecaa7LL /*  783 */,
469
 
    0x61243d581a817049LL /*  784 */,    0x048bacb6bbc163a2LL /*  785 */,
470
 
    0xd9a38ac27d44cc32LL /*  786 */,    0x7fddff5baaf410abLL /*  787 */,
471
 
    0xad6d495aa804824bLL /*  788 */,    0xe1a6a74f2d8c9f94LL /*  789 */,
472
 
    0xd4f7851235dee8e3LL /*  790 */,    0xfd4b7f886540d893LL /*  791 */,
473
 
    0x247c20042aa4bfdaLL /*  792 */,    0x096ea1c517d1327cLL /*  793 */,
474
 
    0xd56966b4361a6685LL /*  794 */,    0x277da5c31221057dLL /*  795 */,
475
 
    0x94d59893a43acff7LL /*  796 */,    0x64f0c51ccdc02281LL /*  797 */,
476
 
    0x3d33bcc4ff6189dbLL /*  798 */,    0xe005cb184ce66af1LL /*  799 */,
477
 
    0xff5ccd1d1db99beaLL /*  800 */,    0xb0b854a7fe42980fLL /*  801 */,
478
 
    0x7bd46a6a718d4b9fLL /*  802 */,    0xd10fa8cc22a5fd8cLL /*  803 */,
479
 
    0xd31484952be4bd31LL /*  804 */,    0xc7fa975fcb243847LL /*  805 */,
480
 
    0x4886ed1e5846c407LL /*  806 */,    0x28cddb791eb70b04LL /*  807 */,
481
 
    0xc2b00be2f573417fLL /*  808 */,    0x5c9590452180f877LL /*  809 */,
482
 
    0x7a6bddfff370eb00LL /*  810 */,    0xce509e38d6d9d6a4LL /*  811 */,
483
 
    0xebeb0f00647fa702LL /*  812 */,    0x1dcc06cf76606f06LL /*  813 */,
484
 
    0xe4d9f28ba286ff0aLL /*  814 */,    0xd85a305dc918c262LL /*  815 */,
485
 
    0x475b1d8732225f54LL /*  816 */,    0x2d4fb51668ccb5feLL /*  817 */,
486
 
    0xa679b9d9d72bba20LL /*  818 */,    0x53841c0d912d43a5LL /*  819 */,
487
 
    0x3b7eaa48bf12a4e8LL /*  820 */,    0x781e0e47f22f1ddfLL /*  821 */,
488
 
    0xeff20ce60ab50973LL /*  822 */,    0x20d261d19dffb742LL /*  823 */,
489
 
    0x16a12b03062a2e39LL /*  824 */,    0x1960eb2239650495LL /*  825 */,
490
 
    0x251c16fed50eb8b8LL /*  826 */,    0x9ac0c330f826016eLL /*  827 */,
491
 
    0xed152665953e7671LL /*  828 */,    0x02d63194a6369570LL /*  829 */,
492
 
    0x5074f08394b1c987LL /*  830 */,    0x70ba598c90b25ce1LL /*  831 */,
493
 
    0x794a15810b9742f6LL /*  832 */,    0x0d5925e9fcaf8c6cLL /*  833 */,
494
 
    0x3067716cd868744eLL /*  834 */,    0x910ab077e8d7731bLL /*  835 */,
495
 
    0x6a61bbdb5ac42f61LL /*  836 */,    0x93513efbf0851567LL /*  837 */,
496
 
    0xf494724b9e83e9d5LL /*  838 */,    0xe887e1985c09648dLL /*  839 */,
497
 
    0x34b1d3c675370cfdLL /*  840 */,    0xdc35e433bc0d255dLL /*  841 */,
498
 
    0xd0aab84234131be0LL /*  842 */,    0x08042a50b48b7eafLL /*  843 */,
499
 
    0x9997c4ee44a3ab35LL /*  844 */,    0x829a7b49201799d0LL /*  845 */,
500
 
    0x263b8307b7c54441LL /*  846 */,    0x752f95f4fd6a6ca6LL /*  847 */,
501
 
    0x927217402c08c6e5LL /*  848 */,    0x2a8ab754a795d9eeLL /*  849 */,
502
 
    0xa442f7552f72943dLL /*  850 */,    0x2c31334e19781208LL /*  851 */,
503
 
    0x4fa98d7ceaee6291LL /*  852 */,    0x55c3862f665db309LL /*  853 */,
504
 
    0xbd0610175d53b1f3LL /*  854 */,    0x46fe6cb840413f27LL /*  855 */,
505
 
    0x3fe03792df0cfa59LL /*  856 */,    0xcfe700372eb85e8fLL /*  857 */,
506
 
    0xa7be29e7adbce118LL /*  858 */,    0xe544ee5cde8431ddLL /*  859 */,
507
 
    0x8a781b1b41f1873eLL /*  860 */,    0xa5c94c78a0d2f0e7LL /*  861 */,
508
 
    0x39412e2877b60728LL /*  862 */,    0xa1265ef3afc9a62cLL /*  863 */,
509
 
    0xbcc2770c6a2506c5LL /*  864 */,    0x3ab66dd5dce1ce12LL /*  865 */,
510
 
    0xe65499d04a675b37LL /*  866 */,    0x7d8f523481bfd216LL /*  867 */,
511
 
    0x0f6f64fcec15f389LL /*  868 */,    0x74efbe618b5b13c8LL /*  869 */,
512
 
    0xacdc82b714273e1dLL /*  870 */,    0xdd40bfe003199d17LL /*  871 */,
513
 
    0x37e99257e7e061f8LL /*  872 */,    0xfa52626904775aaaLL /*  873 */,
514
 
    0x8bbbf63a463d56f9LL /*  874 */,    0xf0013f1543a26e64LL /*  875 */,
515
 
    0xa8307e9f879ec898LL /*  876 */,    0xcc4c27a4150177ccLL /*  877 */,
516
 
    0x1b432f2cca1d3348LL /*  878 */,    0xde1d1f8f9f6fa013LL /*  879 */,
517
 
    0x606602a047a7ddd6LL /*  880 */,    0xd237ab64cc1cb2c7LL /*  881 */,
518
 
    0x9b938e7225fcd1d3LL /*  882 */,    0xec4e03708e0ff476LL /*  883 */,
519
 
    0xfeb2fbda3d03c12dLL /*  884 */,    0xae0bced2ee43889aLL /*  885 */,
520
 
    0x22cb8923ebfb4f43LL /*  886 */,    0x69360d013cf7396dLL /*  887 */,
521
 
    0x855e3602d2d4e022LL /*  888 */,    0x073805bad01f784cLL /*  889 */,
522
 
    0x33e17a133852f546LL /*  890 */,    0xdf4874058ac7b638LL /*  891 */,
523
 
    0xba92b29c678aa14aLL /*  892 */,    0x0ce89fc76cfaadcdLL /*  893 */,
524
 
    0x5f9d4e0908339e34LL /*  894 */,    0xf1afe9291f5923b9LL /*  895 */,
525
 
    0x6e3480f60f4a265fLL /*  896 */,    0xeebf3a2ab29b841cLL /*  897 */,
526
 
    0xe21938a88f91b4adLL /*  898 */,    0x57dfeff845c6d3c3LL /*  899 */,
527
 
    0x2f006b0bf62caaf2LL /*  900 */,    0x62f479ef6f75ee78LL /*  901 */,
528
 
    0x11a55ad41c8916a9LL /*  902 */,    0xf229d29084fed453LL /*  903 */,
529
 
    0x42f1c27b16b000e6LL /*  904 */,    0x2b1f76749823c074LL /*  905 */,
530
 
    0x4b76eca3c2745360LL /*  906 */,    0x8c98f463b91691bdLL /*  907 */,
531
 
    0x14bcc93cf1ade66aLL /*  908 */,    0x8885213e6d458397LL /*  909 */,
532
 
    0x8e177df0274d4711LL /*  910 */,    0xb49b73b5503f2951LL /*  911 */,
533
 
    0x10168168c3f96b6bLL /*  912 */,    0x0e3d963b63cab0aeLL /*  913 */,
534
 
    0x8dfc4b5655a1db14LL /*  914 */,    0xf789f1356e14de5cLL /*  915 */,
535
 
    0x683e68af4e51dac1LL /*  916 */,    0xc9a84f9d8d4b0fd9LL /*  917 */,
536
 
    0x3691e03f52a0f9d1LL /*  918 */,    0x5ed86e46e1878e80LL /*  919 */,
537
 
    0x3c711a0e99d07150LL /*  920 */,    0x5a0865b20c4e9310LL /*  921 */,
538
 
    0x56fbfc1fe4f0682eLL /*  922 */,    0xea8d5de3105edf9bLL /*  923 */,
539
 
    0x71abfdb12379187aLL /*  924 */,    0x2eb99de1bee77b9cLL /*  925 */,
540
 
    0x21ecc0ea33cf4523LL /*  926 */,    0x59a4d7521805c7a1LL /*  927 */,
541
 
    0x3896f5eb56ae7c72LL /*  928 */,    0xaa638f3db18f75dcLL /*  929 */,
542
 
    0x9f39358dabe9808eLL /*  930 */,    0xb7defa91c00b72acLL /*  931 */,
543
 
    0x6b5541fd62492d92LL /*  932 */,    0x6dc6dee8f92e4d5bLL /*  933 */,
544
 
    0x353f57abc4beea7eLL /*  934 */,    0x735769d6da5690ceLL /*  935 */,
545
 
    0x0a234aa642391484LL /*  936 */,    0xf6f9508028f80d9dLL /*  937 */,
546
 
    0xb8e319a27ab3f215LL /*  938 */,    0x31ad9c1151341a4dLL /*  939 */,
547
 
    0x773c22a57bef5805LL /*  940 */,    0x45c7561a07968633LL /*  941 */,
548
 
    0xf913da9e249dbe36LL /*  942 */,    0xda652d9b78a64c68LL /*  943 */,
549
 
    0x4c27a97f3bc334efLL /*  944 */,    0x76621220e66b17f4LL /*  945 */,
550
 
    0x967743899acd7d0bLL /*  946 */,    0xf3ee5bcae0ed6782LL /*  947 */,
551
 
    0x409f753600c879fcLL /*  948 */,    0x06d09a39b5926db6LL /*  949 */,
552
 
    0x6f83aeb0317ac588LL /*  950 */,    0x01e6ca4a86381f21LL /*  951 */,
553
 
    0x66ff3462d19f3025LL /*  952 */,    0x72207c24ddfd3bfbLL /*  953 */,
554
 
    0x4af6b6d3e2ece2ebLL /*  954 */,    0x9c994dbec7ea08deLL /*  955 */,
555
 
    0x49ace597b09a8bc4LL /*  956 */,    0xb38c4766cf0797baLL /*  957 */,
556
 
    0x131b9373c57c2a75LL /*  958 */,    0xb1822cce61931e58LL /*  959 */,
557
 
    0x9d7555b909ba1c0cLL /*  960 */,    0x127fafdd937d11d2LL /*  961 */,
558
 
    0x29da3badc66d92e4LL /*  962 */,    0xa2c1d57154c2ecbcLL /*  963 */,
559
 
    0x58c5134d82f6fe24LL /*  964 */,    0x1c3ae3515b62274fLL /*  965 */,
560
 
    0xe907c82e01cb8126LL /*  966 */,    0xf8ed091913e37fcbLL /*  967 */,
561
 
    0x3249d8f9c80046c9LL /*  968 */,    0x80cf9bede388fb63LL /*  969 */,
562
 
    0x1881539a116cf19eLL /*  970 */,    0x5103f3f76bd52457LL /*  971 */,
563
 
    0x15b7e6f5ae47f7a8LL /*  972 */,    0xdbd7c6ded47e9ccfLL /*  973 */,
564
 
    0x44e55c410228bb1aLL /*  974 */,    0xb647d4255edb4e99LL /*  975 */,
565
 
    0x5d11882bb8aafc30LL /*  976 */,    0xf5098bbb29d3212aLL /*  977 */,
566
 
    0x8fb5ea14e90296b3LL /*  978 */,    0x677b942157dd025aLL /*  979 */,
567
 
    0xfb58e7c0a390acb5LL /*  980 */,    0x89d3674c83bd4a01LL /*  981 */,
568
 
    0x9e2da4df4bf3b93bLL /*  982 */,    0xfcc41e328cab4829LL /*  983 */,
569
 
    0x03f38c96ba582c52LL /*  984 */,    0xcad1bdbd7fd85db2LL /*  985 */,
570
 
    0xbbb442c16082ae83LL /*  986 */,    0xb95fe86ba5da9ab0LL /*  987 */,
571
 
    0xb22e04673771a93fLL /*  988 */,    0x845358c9493152d8LL /*  989 */,
572
 
    0xbe2a488697b4541eLL /*  990 */,    0x95a2dc2dd38e6966LL /*  991 */,
573
 
    0xc02c11ac923c852bLL /*  992 */,    0x2388b1990df2a87bLL /*  993 */,
574
 
    0x7c8008fa1b4f37beLL /*  994 */,    0x1f70d0c84d54e503LL /*  995 */,
575
 
    0x5490adec7ece57d4LL /*  996 */,    0x002b3c27d9063a3aLL /*  997 */,
576
 
    0x7eaea3848030a2bfLL /*  998 */,    0xc602326ded2003c0LL /*  999 */,
577
 
    0x83a7287d69a94086LL /* 1000 */,    0xc57a5fcb30f57a8aLL /* 1001 */,
578
 
    0xb56844e479ebe779LL /* 1002 */,    0xa373b40f05dcbce9LL /* 1003 */,
579
 
    0xd71a786e88570ee2LL /* 1004 */,    0x879cbacdbde8f6a0LL /* 1005 */,
580
 
    0x976ad1bcc164a32fLL /* 1006 */,    0xab21e25e9666d78bLL /* 1007 */,
581
 
    0x901063aae5e5c33cLL /* 1008 */,    0x9818b34448698d90LL /* 1009 */,
582
 
    0xe36487ae3e1e8abbLL /* 1010 */,    0xafbdf931893bdcb4LL /* 1011 */,
583
 
    0x6345a0dc5fbbd519LL /* 1012 */,    0x8628fe269b9465caLL /* 1013 */,
584
 
    0x1e5d01603f9c51ecLL /* 1014 */,    0x4de44006a15049b7LL /* 1015 */,
585
 
    0xbf6c70e5f776cbb1LL /* 1016 */,    0x411218f2ef552bedLL /* 1017 */,
586
 
    0xcb0c0708705a36a3LL /* 1018 */,    0xe74d14754f986044LL /* 1019 */,
587
 
    0xcd56d9430ea8280eLL /* 1020 */,    0xc12591d7535f5065LL /* 1021 */,
588
 
    0xc83223f1720aef96LL /* 1022 */,    0xc3a0396f7363a51fLL /* 1023 */
589
 
};
590
 
 
591
 
 
592
 
static void
593
 
print_abc( const char *text, u64 a, u64 b, u64 c )
594
 
{
595
 
/*printf("%s: %08X%08X %08X%08X %08X%08X\n",
596
 
         text,
597
 
         (u32)(a>>32),
598
 
         (u32)(a),
599
 
         (u32)(b>>32),
600
 
         (u32)(b),
601
 
         (u32)(c>>32),
602
 
         (u32)(c) );*/
603
 
}
604
 
 
605
 
static void
606
 
print_data( const char *text, u64 a, u64 b, u64 c,
607
 
                              u64 d, u64 e, u64 f,
608
 
                              u64 g, u64 h )
609
 
{
610
 
/*printf("%s: %08X%08X %08X%08X %08X%08X %08X%08X\n"
611
 
         "%s  %08X%08X %08X%08X %08X%08X %08X%08X\n",
612
 
         text,
613
 
         (u32)(a>>32),
614
 
         (u32)(a),
615
 
         (u32)(b>>32),
616
 
         (u32)(b),
617
 
         (u32)(c>>32),
618
 
         (u32)(c),
619
 
         (u32)(d>>32),
620
 
         (u32)(d),
621
 
         text,
622
 
         (u32)(e>>32),
623
 
         (u32)(e),
624
 
         (u32)(f>>32),
625
 
         (u32)(f),
626
 
         (u32)(g>>32),
627
 
         (u32)(g),
628
 
         (u32)(h>>32),
629
 
         (u32)(h) );*/
630
 
}
631
 
 
632
 
 
633
 
static void
634
 
burn_stack (int bytes)
635
 
{
636
 
    char buf[256];
637
 
    
638
 
    memset (buf, 0, sizeof buf);
639
 
    bytes -= sizeof buf;
640
 
    if (bytes > 0)
641
 
        burn_stack (bytes);
642
 
}
643
 
 
644
 
 
645
 
 
646
 
static void
647
 
tiger_init( TIGER_CONTEXT *hd )
648
 
{
649
 
    hd->a = 0x0123456789abcdefLL;
650
 
    hd->b = 0xfedcba9876543210LL;
651
 
    hd->c = 0xf096a5b4c3b2e187LL;
652
 
    hd->nblocks = 0;
653
 
    hd->count = 0;
654
 
}
655
 
 
656
 
static void
657
 
round( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul )
658
 
{
659
 
    u64 a = *ra;
660
 
    u64 b = *rb;
661
 
    u64 c = *rc;
662
 
 
663
 
    c ^= x;
664
 
    a -=   sbox1[  c        & 0xff ] ^ sbox2[ (c >> 16) & 0xff ]
665
 
         ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ];
666
 
    b +=   sbox4[ (c >>  8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ]
667
 
         ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ];
668
 
    b *= mul;
669
 
 
670
 
    *ra = a;
671
 
    *rb = b;
672
 
    *rc = c;
673
 
}
674
 
 
675
 
 
676
 
static void
677
 
pass( u64 *ra, u64 *rb, u64 *rc, u64 *x, int mul )
678
 
{
679
 
    u64 a = *ra;
680
 
    u64 b = *rb;
681
 
    u64 c = *rc;
682
 
 
683
 
    round( &a, &b, &c, x[0], mul );
684
 
    round( &b, &c, &a, x[1], mul );
685
 
    round( &c, &a, &b, x[2], mul );
686
 
    round( &a, &b, &c, x[3], mul );
687
 
    round( &b, &c, &a, x[4], mul );
688
 
    round( &c, &a, &b, x[5], mul );
689
 
    round( &a, &b, &c, x[6], mul );
690
 
    round( &b, &c, &a, x[7], mul );
691
 
 
692
 
    *ra = a;
693
 
    *rb = b;
694
 
    *rc = c;
695
 
}
696
 
 
697
 
 
698
 
static void
699
 
key_schedule( u64 *x )
700
 
{
701
 
    x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL;
702
 
    x[1] ^= x[0];
703
 
    x[2] += x[1];
704
 
    x[3] -= x[2] ^ ((~x[1]) << 19 );
705
 
    x[4] ^= x[3];
706
 
    x[5] += x[4];
707
 
    x[6] -= x[5] ^ ((~x[4]) >> 23 );
708
 
    x[7] ^= x[6];
709
 
    x[0] += x[7];
710
 
    x[1] -= x[0] ^ ((~x[7]) << 19 );
711
 
    x[2] ^= x[1];
712
 
    x[3] += x[2];
713
 
    x[4] -= x[3] ^ ((~x[2]) >> 23 );
714
 
    x[5] ^= x[4];
715
 
    x[6] += x[5];
716
 
    x[7] -= x[6] ^ 0x0123456789abcdefLL;
717
 
}
718
 
 
719
 
 
720
 
/****************
721
 
 * Transform the message DATA which consists of 512 bytes (8 words)
722
 
 */
723
 
static void
724
 
transform( TIGER_CONTEXT *hd, byte *data )
725
 
{
726
 
    u64 a,b,c,aa,bb,cc;
727
 
    u64 x[8];
728
 
  #ifdef BIG_ENDIAN_HOST
729
 
    #define MKWORD(d,n) \
730
 
                (  ((u64)(d)[8*(n)+7]) << 56 | ((u64)(d)[8*(n)+6]) << 48  \
731
 
                 | ((u64)(d)[8*(n)+5]) << 40 | ((u64)(d)[8*(n)+4]) << 32  \
732
 
                 | ((u64)(d)[8*(n)+3]) << 24 | ((u64)(d)[8*(n)+2]) << 16  \
733
 
                 | ((u64)(d)[8*(n)+1]) << 8  | ((u64)(d)[8*(n)  ])       )
734
 
    x[0] = MKWORD(data, 0);
735
 
    x[1] = MKWORD(data, 1);
736
 
    x[2] = MKWORD(data, 2);
737
 
    x[3] = MKWORD(data, 3);
738
 
    x[4] = MKWORD(data, 4);
739
 
    x[5] = MKWORD(data, 5);
740
 
    x[6] = MKWORD(data, 6);
741
 
    x[7] = MKWORD(data, 7);
742
 
    #undef MKWORD
743
 
  #else
744
 
    memcpy( &x[0], data, 64 );
745
 
  #endif
746
 
 
747
 
    /* save */
748
 
    a = aa = hd->a;
749
 
    b = bb = hd->b;
750
 
    c = cc = hd->c;
751
 
 
752
 
    print_data(" key0", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] );
753
 
    print_abc(" init", a, b, c );
754
 
    pass( &a, &b, &c, x, 5);
755
 
    print_abc("pass1", a, b, c );
756
 
    key_schedule( x );
757
 
    pass( &c, &a, &b, x, 7);
758
 
    print_abc("pass2", a, b, c );
759
 
    key_schedule( x );
760
 
    pass( &b, &c, &a, x, 9);
761
 
    print_abc("pass3", a, b, c );
762
 
 
763
 
 
764
 
    /* feedforward */
765
 
    a ^= aa;
766
 
    b -= bb;
767
 
    c += cc;
768
 
    /* store */
769
 
    hd->a = a;
770
 
    hd->b = b;
771
 
    hd->c = c;
772
 
}
773
 
 
774
 
 
775
 
 
776
 
/* Update the message digest with the contents
777
 
 * of INBUF with length INLEN.
778
 
 */
779
 
static void
780
 
tiger_write( TIGER_CONTEXT *hd, byte *inbuf, size_t inlen)
781
 
{
782
 
    if( hd->count == 64 ) { /* flush the buffer */
783
 
        transform( hd, hd->buf );
784
 
        burn_stack (21*8+11*sizeof(void*));
785
 
        hd->count = 0;
786
 
        hd->nblocks++;
787
 
    }
788
 
    if( !inbuf )
789
 
        return;
790
 
    if( hd->count ) {
791
 
        for( ; inlen && hd->count < 64; inlen-- )
792
 
            hd->buf[hd->count++] = *inbuf++;
793
 
        tiger_write( hd, NULL, 0 );
794
 
        if( !inlen )
795
 
            return;
796
 
    }
797
 
 
798
 
    while( inlen >= 64 ) {
799
 
        transform( hd, inbuf );
800
 
        hd->count = 0;
801
 
        hd->nblocks++;
802
 
        inlen -= 64;
803
 
        inbuf += 64;
804
 
    }
805
 
    burn_stack (21*8+11*sizeof(void*));
806
 
    for( ; inlen && hd->count < 64; inlen-- )
807
 
        hd->buf[hd->count++] = *inbuf++;
808
 
}
809
 
 
810
 
 
811
 
 
812
 
/* The routine terminates the computation
813
 
 */
814
 
 
815
 
static void
816
 
tiger_final( TIGER_CONTEXT *hd )
817
 
{
818
 
    u32 t, msb, lsb;
819
 
    byte *p;
820
 
 
821
 
    tiger_write(hd, NULL, 0); /* flush */;
822
 
 
823
 
    t = hd->nblocks;
824
 
    /* multiply by 64 to make a byte count */
825
 
    lsb = t << 6;
826
 
    msb = t >> 26;
827
 
    /* add the count */
828
 
    t = lsb;
829
 
    if( (lsb += hd->count) < t )
830
 
        msb++;
831
 
    /* multiply by 8 to make a bit count */
832
 
    t = lsb;
833
 
    lsb <<= 3;
834
 
    msb <<= 3;
835
 
    msb |= t >> 29;
836
 
 
837
 
    if( hd->count < 56 ) { /* enough room */
838
 
        hd->buf[hd->count++] = 0x01; /* pad */
839
 
        while( hd->count < 56 )
840
 
            hd->buf[hd->count++] = 0;  /* pad */
841
 
    }
842
 
    else { /* need one extra block */
843
 
        hd->buf[hd->count++] = 0x01; /* pad character */
844
 
        while( hd->count < 64 )
845
 
            hd->buf[hd->count++] = 0;
846
 
        tiger_write(hd, NULL, 0);  /* flush */;
847
 
        memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
848
 
    }
849
 
    /* append the 64 bit count */
850
 
    hd->buf[56] = lsb      ;
851
 
    hd->buf[57] = lsb >>  8;
852
 
    hd->buf[58] = lsb >> 16;
853
 
    hd->buf[59] = lsb >> 24;
854
 
    hd->buf[60] = msb      ;
855
 
    hd->buf[61] = msb >>  8;
856
 
    hd->buf[62] = msb >> 16;
857
 
    hd->buf[63] = msb >> 24;
858
 
    transform( hd, hd->buf );
859
 
    burn_stack (21*8+11*sizeof(void*));
860
 
 
861
 
    p = hd->buf;
862
 
  #ifdef BIG_ENDIAN_HOST
863
 
    #define X(a) do { *(u64*)p = hd-> a ; p += 8; } while(0)
864
 
  #else /* little endian */
865
 
    #define X(a) do { *p++ = hd-> a >> 56; *p++ = hd-> a >> 48; \
866
 
                      *p++ = hd-> a >> 40; *p++ = hd-> a >> 32; \
867
 
                      *p++ = hd-> a >> 24; *p++ = hd-> a >> 16; \
868
 
                      *p++ = hd-> a >>  8; *p++ = hd-> a; } while(0)
869
 
  #endif
870
 
    X(a);
871
 
    X(b);
872
 
    X(c);
873
 
  #undef X
874
 
}
875
 
 
876
 
static byte *
877
 
tiger_read( TIGER_CONTEXT *hd )
878
 
{
879
 
    return hd->buf;
880
 
}
881
 
 
882
 
#endif /*HAVE_U64_TYPEDEF*/
883
 
 
884
 
/****************
885
 
 * Return some information about the algorithm.  We need algo here to
886
 
 * distinguish different flavors of the algorithm.
887
 
 * Returns: A pointer to string describing the algorithm or NULL if
888
 
 *          the ALGO is invalid.
889
 
 */
890
 
const char *
891
 
tiger_get_info( int algo, size_t *contextsize,
892
 
               byte **r_asnoid, int *r_asnlen, int *r_mdlen,
893
 
               void (**r_init)( void *c ),
894
 
               void (**r_write)( void *c, byte *buf, size_t nbytes ),
895
 
               void (**r_final)( void *c ),
896
 
               byte *(**r_read)( void *c )
897
 
             )
898
 
{
899
 
#ifdef HAVE_U64_TYPEDEF
900
 
 
901
 
#ifdef USE_OLD_TIGER
902
 
    /* This is the old fake OID */
903
 
    static byte asn[18] =
904
 
      { 0x30, 0x28, 0x30, 0x0c, 0x04, 0x08, 0x54, 0x49, 0x47,
905
 
        0x45, 0x52, 0x31, 0x39, 0x32, 0x05, 0x00, 0x04, 0x18 };
906
 
#else /* !USE_OLD_TIGER */
907
 
    /* This is the new correct OID */
908
 
    static byte asn[19] = /* Object ID is 1.3.6.1.4.1.11591.12.2 */
909
 
                         { 0x30, 0x29, 0x30, 0x0d, 0x06, 0x09, 0x2b, 0x06,
910
 
                           0x01, 0x04, 0x01, 0xda, 0x47, 0x0c, 0x02,
911
 
                           0x05, 0x00, 0x04, 0x18 };
912
 
#endif
913
 
 
914
 
    if( algo != 6 )
915
 
        return NULL;
916
 
 
917
 
    *contextsize = sizeof(TIGER_CONTEXT);
918
 
    *r_asnoid = asn;
919
 
    *r_asnlen = DIM(asn);
920
 
    *r_mdlen = 24;
921
 
    *(void  (**)(TIGER_CONTEXT *))r_init                 = tiger_init;
922
 
    *(void  (**)(TIGER_CONTEXT *, byte*, size_t))r_write = tiger_write;
923
 
    *(void  (**)(TIGER_CONTEXT *))r_final                = tiger_final;
924
 
    *(byte *(**)(TIGER_CONTEXT *))r_read                 = tiger_read;
925
 
 
926
 
    return "TIGER192";
927
 
#else /*!HAVE_U64_TYPEDEF*/
928
 
    return NULL; /* Alorithm not available. */
929
 
#endif
930
 
}