source: trunk/Packages/synapse/source/lib/synacrypt.pas

Last change on this file was 2, checked in by chronos, 12 years ago
  • Přidáno: Základní kostra projektu.
  • Přidáno: Knihovna synapse.
File size: 124.5 KB
Line 
1{==============================================================================|
2| Project : Ararat Synapse | 001.001.000 |
3|==============================================================================|
4| Content: Encryption support |
5|==============================================================================|
6| Copyright (c)2007-2011, Lukas Gebauer |
7| All rights reserved. |
8| |
9| Redistribution and use in source and binary forms, with or without |
10| modification, are permitted provided that the following conditions are met: |
11| |
12| Redistributions of source code must retain the above copyright notice, this |
13| list of conditions and the following disclaimer. |
14| |
15| Redistributions in binary form must reproduce the above copyright notice, |
16| this list of conditions and the following disclaimer in the documentation |
17| and/or other materials provided with the distribution. |
18| |
19| Neither the name of Lukas Gebauer nor the names of its contributors may |
20| be used to endorse or promote products derived from this software without |
21| specific prior written permission. |
22| |
23| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
24| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
25| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
26| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
27| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
29| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
30| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
33| DAMAGE. |
34|==============================================================================|
35| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
36| Portions created by Lukas Gebauer are Copyright (c)2007-2011. |
37| All Rights Reserved. |
38| Based on work of David Barton and Eric Young |
39|==============================================================================|
40| Contributor(s): |
41|==============================================================================|
42| History: see HISTORY.HTM from distribution package |
43| (Found at URL: http://www.ararat.cz/synapse/) |
44|==============================================================================}
45
46{:@abstract(Encryption support)
47
48Implemented are DES and 3DES encryption/decryption by ECB, CBC, CFB-8bit,
49 CFB-block, OFB and CTR methods.
50}
51
52{$IFDEF FPC}
53 {$MODE DELPHI}
54{$ENDIF}
55{$Q-}
56{$R-}
57{$H+}
58
59{$IFDEF UNICODE}
60 {$WARN IMPLICIT_STRING_CAST OFF}
61 {$WARN IMPLICIT_STRING_CAST_LOSS OFF}
62{$ENDIF}
63
64unit synacrypt;
65
66interface
67
68uses
69 SysUtils, Classes, synautil, synafpc;
70
71type
72 {:@abstract(Implementation of common routines block ciphers (dafault size is 64-bits))
73
74 Do not use this class directly, use descendants only!}
75 TSynaBlockCipher= class(TObject)
76 protected
77 procedure InitKey(Key: AnsiString); virtual;
78 function GetSize: byte; virtual;
79 private
80 IV, CV: AnsiString;
81 procedure IncCounter;
82 public
83 {:Sets the IV to Value and performs a reset}
84 procedure SetIV(const Value: AnsiString); virtual;
85 {:Returns the current chaining information, not the actual IV}
86 function GetIV: AnsiString; virtual;
87 {:Reset any stored chaining information}
88 procedure Reset; virtual;
89 {:Encrypt a 64-bit block of data using the ECB method of encryption}
90 function EncryptECB(const InData: AnsiString): AnsiString; virtual;
91 {:Decrypt a 64-bit block of data using the ECB method of decryption}
92 function DecryptECB(const InData: AnsiString): AnsiString; virtual;
93 {:Encrypt data using the CBC method of encryption}
94 function EncryptCBC(const Indata: AnsiString): AnsiString; virtual;
95 {:Decrypt data using the CBC method of decryption}
96 function DecryptCBC(const Indata: AnsiString): AnsiString; virtual;
97 {:Encrypt data using the CFB (8 bit) method of encryption}
98 function EncryptCFB8bit(const Indata: AnsiString): AnsiString; virtual;
99 {:Decrypt data using the CFB (8 bit) method of decryption}
100 function DecryptCFB8bit(const Indata: AnsiString): AnsiString; virtual;
101 {:Encrypt data using the CFB (block) method of encryption}
102 function EncryptCFBblock(const Indata: AnsiString): AnsiString; virtual;
103 {:Decrypt data using the CFB (block) method of decryption}
104 function DecryptCFBblock(const Indata: AnsiString): AnsiString; virtual;
105 {:Encrypt data using the OFB method of encryption}
106 function EncryptOFB(const Indata: AnsiString): AnsiString; virtual;
107 {:Decrypt data using the OFB method of decryption}
108 function DecryptOFB(const Indata: AnsiString): AnsiString; virtual;
109 {:Encrypt data using the CTR method of encryption}
110 function EncryptCTR(const Indata: AnsiString): AnsiString; virtual;
111 {:Decrypt data using the CTR method of decryption}
112 function DecryptCTR(const Indata: AnsiString): AnsiString; virtual;
113 {:Create a encryptor/decryptor instance and initialize it by the Key.}
114 constructor Create(Key: AnsiString);
115 end;
116
117 {:@abstract(Datatype for holding one DES key data)
118
119 This data type is used internally.}
120 TDesKeyData = array[0..31] of integer;
121
122 {:@abstract(Implementation of common routines for DES encryption)
123
124 Do not use this class directly, use descendants only!}
125 TSynaCustomDes = class(TSynaBlockcipher)
126 protected
127 procedure DoInit(KeyB: AnsiString; var KeyData: TDesKeyData);
128 function EncryptBlock(const InData: AnsiString; var KeyData: TDesKeyData): AnsiString;
129 function DecryptBlock(const InData: AnsiString; var KeyData: TDesKeyData): AnsiString;
130 end;
131
132 {:@abstract(Implementation of DES encryption)}
133 TSynaDes= class(TSynaCustomDes)
134 protected
135 KeyData: TDesKeyData;
136 procedure InitKey(Key: AnsiString); override;
137 public
138 {:Encrypt a 64-bit block of data using the ECB method of encryption}
139 function EncryptECB(const InData: AnsiString): AnsiString; override;
140 {:Decrypt a 64-bit block of data using the ECB method of decryption}
141 function DecryptECB(const InData: AnsiString): AnsiString; override;
142 end;
143
144 {:@abstract(Implementation of 3DES encryption)}
145 TSyna3Des= class(TSynaCustomDes)
146 protected
147 KeyData: array[0..2] of TDesKeyData;
148 procedure InitKey(Key: AnsiString); override;
149 public
150 {:Encrypt a 64-bit block of data using the ECB method of encryption}
151 function EncryptECB(const InData: AnsiString): AnsiString; override;
152 {:Decrypt a 64-bit block of data using the ECB method of decryption}
153 function DecryptECB(const InData: AnsiString): AnsiString; override;
154 end;
155
156const
157 BC = 4;
158 MAXROUNDS = 14;
159type
160 {:@abstract(Implementation of AES encryption)}
161 TSynaAes= class(TSynaBlockcipher)
162 protected
163 numrounds: longword;
164 rk, drk: array[0..MAXROUNDS,0..7] of longword;
165 procedure InitKey(Key: AnsiString); override;
166 function GetSize: byte; override;
167 public
168 {:Encrypt a 128-bit block of data using the ECB method of encryption}
169 function EncryptECB(const InData: AnsiString): AnsiString; override;
170 {:Decrypt a 128-bit block of data using the ECB method of decryption}
171 function DecryptECB(const InData: AnsiString): AnsiString; override;
172 end;
173
174{:Call internal test of all DES encryptions. Returns @true if all is OK.}
175function TestDes: boolean;
176{:Call internal test of all 3DES encryptions. Returns @true if all is OK.}
177function Test3Des: boolean;
178{:Call internal test of all AES encryptions. Returns @true if all is OK.}
179function TestAes: boolean;
180
181{==============================================================================}
182implementation
183
184//DES consts
185const
186 shifts2: array[0..15]of byte=
187 (0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
188
189 des_skb: array[0..7,0..63]of integer=(
190 (
191 (* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 *)
192 integer($00000000),integer($00000010),integer($20000000),integer($20000010),
193 integer($00010000),integer($00010010),integer($20010000),integer($20010010),
194 integer($00000800),integer($00000810),integer($20000800),integer($20000810),
195 integer($00010800),integer($00010810),integer($20010800),integer($20010810),
196 integer($00000020),integer($00000030),integer($20000020),integer($20000030),
197 integer($00010020),integer($00010030),integer($20010020),integer($20010030),
198 integer($00000820),integer($00000830),integer($20000820),integer($20000830),
199 integer($00010820),integer($00010830),integer($20010820),integer($20010830),
200 integer($00080000),integer($00080010),integer($20080000),integer($20080010),
201 integer($00090000),integer($00090010),integer($20090000),integer($20090010),
202 integer($00080800),integer($00080810),integer($20080800),integer($20080810),
203 integer($00090800),integer($00090810),integer($20090800),integer($20090810),
204 integer($00080020),integer($00080030),integer($20080020),integer($20080030),
205 integer($00090020),integer($00090030),integer($20090020),integer($20090030),
206 integer($00080820),integer($00080830),integer($20080820),integer($20080830),
207 integer($00090820),integer($00090830),integer($20090820),integer($20090830)
208 ),(
209 (* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 *)
210 integer($00000000),integer($02000000),integer($00002000),integer($02002000),
211 integer($00200000),integer($02200000),integer($00202000),integer($02202000),
212 integer($00000004),integer($02000004),integer($00002004),integer($02002004),
213 integer($00200004),integer($02200004),integer($00202004),integer($02202004),
214 integer($00000400),integer($02000400),integer($00002400),integer($02002400),
215 integer($00200400),integer($02200400),integer($00202400),integer($02202400),
216 integer($00000404),integer($02000404),integer($00002404),integer($02002404),
217 integer($00200404),integer($02200404),integer($00202404),integer($02202404),
218 integer($10000000),integer($12000000),integer($10002000),integer($12002000),
219 integer($10200000),integer($12200000),integer($10202000),integer($12202000),
220 integer($10000004),integer($12000004),integer($10002004),integer($12002004),
221 integer($10200004),integer($12200004),integer($10202004),integer($12202004),
222 integer($10000400),integer($12000400),integer($10002400),integer($12002400),
223 integer($10200400),integer($12200400),integer($10202400),integer($12202400),
224 integer($10000404),integer($12000404),integer($10002404),integer($12002404),
225 integer($10200404),integer($12200404),integer($10202404),integer($12202404)
226 ),(
227 (* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 *)
228 integer($00000000),integer($00000001),integer($00040000),integer($00040001),
229 integer($01000000),integer($01000001),integer($01040000),integer($01040001),
230 integer($00000002),integer($00000003),integer($00040002),integer($00040003),
231 integer($01000002),integer($01000003),integer($01040002),integer($01040003),
232 integer($00000200),integer($00000201),integer($00040200),integer($00040201),
233 integer($01000200),integer($01000201),integer($01040200),integer($01040201),
234 integer($00000202),integer($00000203),integer($00040202),integer($00040203),
235 integer($01000202),integer($01000203),integer($01040202),integer($01040203),
236 integer($08000000),integer($08000001),integer($08040000),integer($08040001),
237 integer($09000000),integer($09000001),integer($09040000),integer($09040001),
238 integer($08000002),integer($08000003),integer($08040002),integer($08040003),
239 integer($09000002),integer($09000003),integer($09040002),integer($09040003),
240 integer($08000200),integer($08000201),integer($08040200),integer($08040201),
241 integer($09000200),integer($09000201),integer($09040200),integer($09040201),
242 integer($08000202),integer($08000203),integer($08040202),integer($08040203),
243 integer($09000202),integer($09000203),integer($09040202),integer($09040203)
244 ),(
245 (* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 *)
246 integer($00000000),integer($00100000),integer($00000100),integer($00100100),
247 integer($00000008),integer($00100008),integer($00000108),integer($00100108),
248 integer($00001000),integer($00101000),integer($00001100),integer($00101100),
249 integer($00001008),integer($00101008),integer($00001108),integer($00101108),
250 integer($04000000),integer($04100000),integer($04000100),integer($04100100),
251 integer($04000008),integer($04100008),integer($04000108),integer($04100108),
252 integer($04001000),integer($04101000),integer($04001100),integer($04101100),
253 integer($04001008),integer($04101008),integer($04001108),integer($04101108),
254 integer($00020000),integer($00120000),integer($00020100),integer($00120100),
255 integer($00020008),integer($00120008),integer($00020108),integer($00120108),
256 integer($00021000),integer($00121000),integer($00021100),integer($00121100),
257 integer($00021008),integer($00121008),integer($00021108),integer($00121108),
258 integer($04020000),integer($04120000),integer($04020100),integer($04120100),
259 integer($04020008),integer($04120008),integer($04020108),integer($04120108),
260 integer($04021000),integer($04121000),integer($04021100),integer($04121100),
261 integer($04021008),integer($04121008),integer($04021108),integer($04121108)
262 ),(
263 (* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 *)
264 integer($00000000),integer($10000000),integer($00010000),integer($10010000),
265 integer($00000004),integer($10000004),integer($00010004),integer($10010004),
266 integer($20000000),integer($30000000),integer($20010000),integer($30010000),
267 integer($20000004),integer($30000004),integer($20010004),integer($30010004),
268 integer($00100000),integer($10100000),integer($00110000),integer($10110000),
269 integer($00100004),integer($10100004),integer($00110004),integer($10110004),
270 integer($20100000),integer($30100000),integer($20110000),integer($30110000),
271 integer($20100004),integer($30100004),integer($20110004),integer($30110004),
272 integer($00001000),integer($10001000),integer($00011000),integer($10011000),
273 integer($00001004),integer($10001004),integer($00011004),integer($10011004),
274 integer($20001000),integer($30001000),integer($20011000),integer($30011000),
275 integer($20001004),integer($30001004),integer($20011004),integer($30011004),
276 integer($00101000),integer($10101000),integer($00111000),integer($10111000),
277 integer($00101004),integer($10101004),integer($00111004),integer($10111004),
278 integer($20101000),integer($30101000),integer($20111000),integer($30111000),
279 integer($20101004),integer($30101004),integer($20111004),integer($30111004)
280 ),(
281 (* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 *)
282 integer($00000000),integer($08000000),integer($00000008),integer($08000008),
283 integer($00000400),integer($08000400),integer($00000408),integer($08000408),
284 integer($00020000),integer($08020000),integer($00020008),integer($08020008),
285 integer($00020400),integer($08020400),integer($00020408),integer($08020408),
286 integer($00000001),integer($08000001),integer($00000009),integer($08000009),
287 integer($00000401),integer($08000401),integer($00000409),integer($08000409),
288 integer($00020001),integer($08020001),integer($00020009),integer($08020009),
289 integer($00020401),integer($08020401),integer($00020409),integer($08020409),
290 integer($02000000),integer($0A000000),integer($02000008),integer($0A000008),
291 integer($02000400),integer($0A000400),integer($02000408),integer($0A000408),
292 integer($02020000),integer($0A020000),integer($02020008),integer($0A020008),
293 integer($02020400),integer($0A020400),integer($02020408),integer($0A020408),
294 integer($02000001),integer($0A000001),integer($02000009),integer($0A000009),
295 integer($02000401),integer($0A000401),integer($02000409),integer($0A000409),
296 integer($02020001),integer($0A020001),integer($02020009),integer($0A020009),
297 integer($02020401),integer($0A020401),integer($02020409),integer($0A020409)
298 ),(
299 (* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 *)
300 integer($00000000),integer($00000100),integer($00080000),integer($00080100),
301 integer($01000000),integer($01000100),integer($01080000),integer($01080100),
302 integer($00000010),integer($00000110),integer($00080010),integer($00080110),
303 integer($01000010),integer($01000110),integer($01080010),integer($01080110),
304 integer($00200000),integer($00200100),integer($00280000),integer($00280100),
305 integer($01200000),integer($01200100),integer($01280000),integer($01280100),
306 integer($00200010),integer($00200110),integer($00280010),integer($00280110),
307 integer($01200010),integer($01200110),integer($01280010),integer($01280110),
308 integer($00000200),integer($00000300),integer($00080200),integer($00080300),
309 integer($01000200),integer($01000300),integer($01080200),integer($01080300),
310 integer($00000210),integer($00000310),integer($00080210),integer($00080310),
311 integer($01000210),integer($01000310),integer($01080210),integer($01080310),
312 integer($00200200),integer($00200300),integer($00280200),integer($00280300),
313 integer($01200200),integer($01200300),integer($01280200),integer($01280300),
314 integer($00200210),integer($00200310),integer($00280210),integer($00280310),
315 integer($01200210),integer($01200310),integer($01280210),integer($01280310)
316 ),(
317 (* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 *)
318 integer($00000000),integer($04000000),integer($00040000),integer($04040000),
319 integer($00000002),integer($04000002),integer($00040002),integer($04040002),
320 integer($00002000),integer($04002000),integer($00042000),integer($04042000),
321 integer($00002002),integer($04002002),integer($00042002),integer($04042002),
322 integer($00000020),integer($04000020),integer($00040020),integer($04040020),
323 integer($00000022),integer($04000022),integer($00040022),integer($04040022),
324 integer($00002020),integer($04002020),integer($00042020),integer($04042020),
325 integer($00002022),integer($04002022),integer($00042022),integer($04042022),
326 integer($00000800),integer($04000800),integer($00040800),integer($04040800),
327 integer($00000802),integer($04000802),integer($00040802),integer($04040802),
328 integer($00002800),integer($04002800),integer($00042800),integer($04042800),
329 integer($00002802),integer($04002802),integer($00042802),integer($04042802),
330 integer($00000820),integer($04000820),integer($00040820),integer($04040820),
331 integer($00000822),integer($04000822),integer($00040822),integer($04040822),
332 integer($00002820),integer($04002820),integer($00042820),integer($04042820),
333 integer($00002822),integer($04002822),integer($00042822),integer($04042822)
334 ));
335
336 des_sptrans: array[0..7,0..63] of integer=(
337 (
338 (* nibble 0 *)
339 integer($02080800), integer($00080000), integer($02000002), integer($02080802),
340 integer($02000000), integer($00080802), integer($00080002), integer($02000002),
341 integer($00080802), integer($02080800), integer($02080000), integer($00000802),
342 integer($02000802), integer($02000000), integer($00000000), integer($00080002),
343 integer($00080000), integer($00000002), integer($02000800), integer($00080800),
344 integer($02080802), integer($02080000), integer($00000802), integer($02000800),
345 integer($00000002), integer($00000800), integer($00080800), integer($02080002),
346 integer($00000800), integer($02000802), integer($02080002), integer($00000000),
347 integer($00000000), integer($02080802), integer($02000800), integer($00080002),
348 integer($02080800), integer($00080000), integer($00000802), integer($02000800),
349 integer($02080002), integer($00000800), integer($00080800), integer($02000002),
350 integer($00080802), integer($00000002), integer($02000002), integer($02080000),
351 integer($02080802), integer($00080800), integer($02080000), integer($02000802),
352 integer($02000000), integer($00000802), integer($00080002), integer($00000000),
353 integer($00080000), integer($02000000), integer($02000802), integer($02080800),
354 integer($00000002), integer($02080002), integer($00000800), integer($00080802)
355 ),(
356 (* nibble 1 *)
357 integer($40108010), integer($00000000), integer($00108000), integer($40100000),
358 integer($40000010), integer($00008010), integer($40008000), integer($00108000),
359 integer($00008000), integer($40100010), integer($00000010), integer($40008000),
360 integer($00100010), integer($40108000), integer($40100000), integer($00000010),
361 integer($00100000), integer($40008010), integer($40100010), integer($00008000),
362 integer($00108010), integer($40000000), integer($00000000), integer($00100010),
363 integer($40008010), integer($00108010), integer($40108000), integer($40000010),
364 integer($40000000), integer($00100000), integer($00008010), integer($40108010),
365 integer($00100010), integer($40108000), integer($40008000), integer($00108010),
366 integer($40108010), integer($00100010), integer($40000010), integer($00000000),
367 integer($40000000), integer($00008010), integer($00100000), integer($40100010),
368 integer($00008000), integer($40000000), integer($00108010), integer($40008010),
369 integer($40108000), integer($00008000), integer($00000000), integer($40000010),
370 integer($00000010), integer($40108010), integer($00108000), integer($40100000),
371 integer($40100010), integer($00100000), integer($00008010), integer($40008000),
372 integer($40008010), integer($00000010), integer($40100000), integer($00108000)
373 ),(
374 (* nibble 2 *)
375 integer($04000001), integer($04040100), integer($00000100), integer($04000101),
376 integer($00040001), integer($04000000), integer($04000101), integer($00040100),
377 integer($04000100), integer($00040000), integer($04040000), integer($00000001),
378 integer($04040101), integer($00000101), integer($00000001), integer($04040001),
379 integer($00000000), integer($00040001), integer($04040100), integer($00000100),
380 integer($00000101), integer($04040101), integer($00040000), integer($04000001),
381 integer($04040001), integer($04000100), integer($00040101), integer($04040000),
382 integer($00040100), integer($00000000), integer($04000000), integer($00040101),
383 integer($04040100), integer($00000100), integer($00000001), integer($00040000),
384 integer($00000101), integer($00040001), integer($04040000), integer($04000101),
385 integer($00000000), integer($04040100), integer($00040100), integer($04040001),
386 integer($00040001), integer($04000000), integer($04040101), integer($00000001),
387 integer($00040101), integer($04000001), integer($04000000), integer($04040101),
388 integer($00040000), integer($04000100), integer($04000101), integer($00040100),
389 integer($04000100), integer($00000000), integer($04040001), integer($00000101),
390 integer($04000001), integer($00040101), integer($00000100), integer($04040000)
391 ),(
392 (* nibble 3 *)
393 integer($00401008), integer($10001000), integer($00000008), integer($10401008),
394 integer($00000000), integer($10400000), integer($10001008), integer($00400008),
395 integer($10401000), integer($10000008), integer($10000000), integer($00001008),
396 integer($10000008), integer($00401008), integer($00400000), integer($10000000),
397 integer($10400008), integer($00401000), integer($00001000), integer($00000008),
398 integer($00401000), integer($10001008), integer($10400000), integer($00001000),
399 integer($00001008), integer($00000000), integer($00400008), integer($10401000),
400 integer($10001000), integer($10400008), integer($10401008), integer($00400000),
401 integer($10400008), integer($00001008), integer($00400000), integer($10000008),
402 integer($00401000), integer($10001000), integer($00000008), integer($10400000),
403 integer($10001008), integer($00000000), integer($00001000), integer($00400008),
404 integer($00000000), integer($10400008), integer($10401000), integer($00001000),
405 integer($10000000), integer($10401008), integer($00401008), integer($00400000),
406 integer($10401008), integer($00000008), integer($10001000), integer($00401008),
407 integer($00400008), integer($00401000), integer($10400000), integer($10001008),
408 integer($00001008), integer($10000000), integer($10000008), integer($10401000)
409 ),(
410 (* nibble 4 *)
411 integer($08000000), integer($00010000), integer($00000400), integer($08010420),
412 integer($08010020), integer($08000400), integer($00010420), integer($08010000),
413 integer($00010000), integer($00000020), integer($08000020), integer($00010400),
414 integer($08000420), integer($08010020), integer($08010400), integer($00000000),
415 integer($00010400), integer($08000000), integer($00010020), integer($00000420),
416 integer($08000400), integer($00010420), integer($00000000), integer($08000020),
417 integer($00000020), integer($08000420), integer($08010420), integer($00010020),
418 integer($08010000), integer($00000400), integer($00000420), integer($08010400),
419 integer($08010400), integer($08000420), integer($00010020), integer($08010000),
420 integer($00010000), integer($00000020), integer($08000020), integer($08000400),
421 integer($08000000), integer($00010400), integer($08010420), integer($00000000),
422 integer($00010420), integer($08000000), integer($00000400), integer($00010020),
423 integer($08000420), integer($00000400), integer($00000000), integer($08010420),
424 integer($08010020), integer($08010400), integer($00000420), integer($00010000),
425 integer($00010400), integer($08010020), integer($08000400), integer($00000420),
426 integer($00000020), integer($00010420), integer($08010000), integer($08000020)
427 ),(
428 (* nibble 5 *)
429 integer($80000040), integer($00200040), integer($00000000), integer($80202000),
430 integer($00200040), integer($00002000), integer($80002040), integer($00200000),
431 integer($00002040), integer($80202040), integer($00202000), integer($80000000),
432 integer($80002000), integer($80000040), integer($80200000), integer($00202040),
433 integer($00200000), integer($80002040), integer($80200040), integer($00000000),
434 integer($00002000), integer($00000040), integer($80202000), integer($80200040),
435 integer($80202040), integer($80200000), integer($80000000), integer($00002040),
436 integer($00000040), integer($00202000), integer($00202040), integer($80002000),
437 integer($00002040), integer($80000000), integer($80002000), integer($00202040),
438 integer($80202000), integer($00200040), integer($00000000), integer($80002000),
439 integer($80000000), integer($00002000), integer($80200040), integer($00200000),
440 integer($00200040), integer($80202040), integer($00202000), integer($00000040),
441 integer($80202040), integer($00202000), integer($00200000), integer($80002040),
442 integer($80000040), integer($80200000), integer($00202040), integer($00000000),
443 integer($00002000), integer($80000040), integer($80002040), integer($80202000),
444 integer($80200000), integer($00002040), integer($00000040), integer($80200040)
445 ),(
446 (* nibble 6 *)
447 integer($00004000), integer($00000200), integer($01000200), integer($01000004),
448 integer($01004204), integer($00004004), integer($00004200), integer($00000000),
449 integer($01000000), integer($01000204), integer($00000204), integer($01004000),
450 integer($00000004), integer($01004200), integer($01004000), integer($00000204),
451 integer($01000204), integer($00004000), integer($00004004), integer($01004204),
452 integer($00000000), integer($01000200), integer($01000004), integer($00004200),
453 integer($01004004), integer($00004204), integer($01004200), integer($00000004),
454 integer($00004204), integer($01004004), integer($00000200), integer($01000000),
455 integer($00004204), integer($01004000), integer($01004004), integer($00000204),
456 integer($00004000), integer($00000200), integer($01000000), integer($01004004),
457 integer($01000204), integer($00004204), integer($00004200), integer($00000000),
458 integer($00000200), integer($01000004), integer($00000004), integer($01000200),
459 integer($00000000), integer($01000204), integer($01000200), integer($00004200),
460 integer($00000204), integer($00004000), integer($01004204), integer($01000000),
461 integer($01004200), integer($00000004), integer($00004004), integer($01004204),
462 integer($01000004), integer($01004200), integer($01004000), integer($00004004)
463 ),(
464 (* nibble 7 *)
465 integer($20800080), integer($20820000), integer($00020080), integer($00000000),
466 integer($20020000), integer($00800080), integer($20800000), integer($20820080),
467 integer($00000080), integer($20000000), integer($00820000), integer($00020080),
468 integer($00820080), integer($20020080), integer($20000080), integer($20800000),
469 integer($00020000), integer($00820080), integer($00800080), integer($20020000),
470 integer($20820080), integer($20000080), integer($00000000), integer($00820000),
471 integer($20000000), integer($00800000), integer($20020080), integer($20800080),
472 integer($00800000), integer($00020000), integer($20820000), integer($00000080),
473 integer($00800000), integer($00020000), integer($20000080), integer($20820080),
474 integer($00020080), integer($20000000), integer($00000000), integer($00820000),
475 integer($20800080), integer($20020080), integer($20020000), integer($00800080),
476 integer($20820000), integer($00000080), integer($00800080), integer($20020000),
477 integer($20820080), integer($00800000), integer($20800000), integer($20000080),
478 integer($00820000), integer($00020080), integer($20020080), integer($20800000),
479 integer($00000080), integer($20820000), integer($00820080), integer($00000000),
480 integer($20000000), integer($20800080), integer($00020000), integer($00820080)
481 ));
482
483//AES consts
484const
485 MAXBC= 8;
486 MAXKC= 8;
487
488 S: array[0..255] of byte= (
489 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,
490 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192,
491 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21,
492 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117,
493 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132,
494 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207,
495 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168,
496 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210,
497 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115,
498 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219,
499 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121,
500 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8,
501 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138,
502 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158,
503 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223,
504 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22);
505 T1: array[0..255,0..3] of byte= (
506 ($c6,$63,$63,$a5), ($f8,$7c,$7c,$84), ($ee,$77,$77,$99), ($f6,$7b,$7b,$8d),
507 ($ff,$f2,$f2,$0d), ($d6,$6b,$6b,$bd), ($de,$6f,$6f,$b1), ($91,$c5,$c5,$54),
508 ($60,$30,$30,$50), ($02,$01,$01,$03), ($ce,$67,$67,$a9), ($56,$2b,$2b,$7d),
509 ($e7,$fe,$fe,$19), ($b5,$d7,$d7,$62), ($4d,$ab,$ab,$e6), ($ec,$76,$76,$9a),
510 ($8f,$ca,$ca,$45), ($1f,$82,$82,$9d), ($89,$c9,$c9,$40), ($fa,$7d,$7d,$87),
511 ($ef,$fa,$fa,$15), ($b2,$59,$59,$eb), ($8e,$47,$47,$c9), ($fb,$f0,$f0,$0b),
512 ($41,$ad,$ad,$ec), ($b3,$d4,$d4,$67), ($5f,$a2,$a2,$fd), ($45,$af,$af,$ea),
513 ($23,$9c,$9c,$bf), ($53,$a4,$a4,$f7), ($e4,$72,$72,$96), ($9b,$c0,$c0,$5b),
514 ($75,$b7,$b7,$c2), ($e1,$fd,$fd,$1c), ($3d,$93,$93,$ae), ($4c,$26,$26,$6a),
515 ($6c,$36,$36,$5a), ($7e,$3f,$3f,$41), ($f5,$f7,$f7,$02), ($83,$cc,$cc,$4f),
516 ($68,$34,$34,$5c), ($51,$a5,$a5,$f4), ($d1,$e5,$e5,$34), ($f9,$f1,$f1,$08),
517 ($e2,$71,$71,$93), ($ab,$d8,$d8,$73), ($62,$31,$31,$53), ($2a,$15,$15,$3f),
518 ($08,$04,$04,$0c), ($95,$c7,$c7,$52), ($46,$23,$23,$65), ($9d,$c3,$c3,$5e),
519 ($30,$18,$18,$28), ($37,$96,$96,$a1), ($0a,$05,$05,$0f), ($2f,$9a,$9a,$b5),
520 ($0e,$07,$07,$09), ($24,$12,$12,$36), ($1b,$80,$80,$9b), ($df,$e2,$e2,$3d),
521 ($cd,$eb,$eb,$26), ($4e,$27,$27,$69), ($7f,$b2,$b2,$cd), ($ea,$75,$75,$9f),
522 ($12,$09,$09,$1b), ($1d,$83,$83,$9e), ($58,$2c,$2c,$74), ($34,$1a,$1a,$2e),
523 ($36,$1b,$1b,$2d), ($dc,$6e,$6e,$b2), ($b4,$5a,$5a,$ee), ($5b,$a0,$a0,$fb),
524 ($a4,$52,$52,$f6), ($76,$3b,$3b,$4d), ($b7,$d6,$d6,$61), ($7d,$b3,$b3,$ce),
525 ($52,$29,$29,$7b), ($dd,$e3,$e3,$3e), ($5e,$2f,$2f,$71), ($13,$84,$84,$97),
526 ($a6,$53,$53,$f5), ($b9,$d1,$d1,$68), ($00,$00,$00,$00), ($c1,$ed,$ed,$2c),
527 ($40,$20,$20,$60), ($e3,$fc,$fc,$1f), ($79,$b1,$b1,$c8), ($b6,$5b,$5b,$ed),
528 ($d4,$6a,$6a,$be), ($8d,$cb,$cb,$46), ($67,$be,$be,$d9), ($72,$39,$39,$4b),
529 ($94,$4a,$4a,$de), ($98,$4c,$4c,$d4), ($b0,$58,$58,$e8), ($85,$cf,$cf,$4a),
530 ($bb,$d0,$d0,$6b), ($c5,$ef,$ef,$2a), ($4f,$aa,$aa,$e5), ($ed,$fb,$fb,$16),
531 ($86,$43,$43,$c5), ($9a,$4d,$4d,$d7), ($66,$33,$33,$55), ($11,$85,$85,$94),
532 ($8a,$45,$45,$cf), ($e9,$f9,$f9,$10), ($04,$02,$02,$06), ($fe,$7f,$7f,$81),
533 ($a0,$50,$50,$f0), ($78,$3c,$3c,$44), ($25,$9f,$9f,$ba), ($4b,$a8,$a8,$e3),
534 ($a2,$51,$51,$f3), ($5d,$a3,$a3,$fe), ($80,$40,$40,$c0), ($05,$8f,$8f,$8a),
535 ($3f,$92,$92,$ad), ($21,$9d,$9d,$bc), ($70,$38,$38,$48), ($f1,$f5,$f5,$04),
536 ($63,$bc,$bc,$df), ($77,$b6,$b6,$c1), ($af,$da,$da,$75), ($42,$21,$21,$63),
537 ($20,$10,$10,$30), ($e5,$ff,$ff,$1a), ($fd,$f3,$f3,$0e), ($bf,$d2,$d2,$6d),
538 ($81,$cd,$cd,$4c), ($18,$0c,$0c,$14), ($26,$13,$13,$35), ($c3,$ec,$ec,$2f),
539 ($be,$5f,$5f,$e1), ($35,$97,$97,$a2), ($88,$44,$44,$cc), ($2e,$17,$17,$39),
540 ($93,$c4,$c4,$57), ($55,$a7,$a7,$f2), ($fc,$7e,$7e,$82), ($7a,$3d,$3d,$47),
541 ($c8,$64,$64,$ac), ($ba,$5d,$5d,$e7), ($32,$19,$19,$2b), ($e6,$73,$73,$95),
542 ($c0,$60,$60,$a0), ($19,$81,$81,$98), ($9e,$4f,$4f,$d1), ($a3,$dc,$dc,$7f),
543 ($44,$22,$22,$66), ($54,$2a,$2a,$7e), ($3b,$90,$90,$ab), ($0b,$88,$88,$83),
544 ($8c,$46,$46,$ca), ($c7,$ee,$ee,$29), ($6b,$b8,$b8,$d3), ($28,$14,$14,$3c),
545 ($a7,$de,$de,$79), ($bc,$5e,$5e,$e2), ($16,$0b,$0b,$1d), ($ad,$db,$db,$76),
546 ($db,$e0,$e0,$3b), ($64,$32,$32,$56), ($74,$3a,$3a,$4e), ($14,$0a,$0a,$1e),
547 ($92,$49,$49,$db), ($0c,$06,$06,$0a), ($48,$24,$24,$6c), ($b8,$5c,$5c,$e4),
548 ($9f,$c2,$c2,$5d), ($bd,$d3,$d3,$6e), ($43,$ac,$ac,$ef), ($c4,$62,$62,$a6),
549 ($39,$91,$91,$a8), ($31,$95,$95,$a4), ($d3,$e4,$e4,$37), ($f2,$79,$79,$8b),
550 ($d5,$e7,$e7,$32), ($8b,$c8,$c8,$43), ($6e,$37,$37,$59), ($da,$6d,$6d,$b7),
551 ($01,$8d,$8d,$8c), ($b1,$d5,$d5,$64), ($9c,$4e,$4e,$d2), ($49,$a9,$a9,$e0),
552 ($d8,$6c,$6c,$b4), ($ac,$56,$56,$fa), ($f3,$f4,$f4,$07), ($cf,$ea,$ea,$25),
553 ($ca,$65,$65,$af), ($f4,$7a,$7a,$8e), ($47,$ae,$ae,$e9), ($10,$08,$08,$18),
554 ($6f,$ba,$ba,$d5), ($f0,$78,$78,$88), ($4a,$25,$25,$6f), ($5c,$2e,$2e,$72),
555 ($38,$1c,$1c,$24), ($57,$a6,$a6,$f1), ($73,$b4,$b4,$c7), ($97,$c6,$c6,$51),
556 ($cb,$e8,$e8,$23), ($a1,$dd,$dd,$7c), ($e8,$74,$74,$9c), ($3e,$1f,$1f,$21),
557 ($96,$4b,$4b,$dd), ($61,$bd,$bd,$dc), ($0d,$8b,$8b,$86), ($0f,$8a,$8a,$85),
558 ($e0,$70,$70,$90), ($7c,$3e,$3e,$42), ($71,$b5,$b5,$c4), ($cc,$66,$66,$aa),
559 ($90,$48,$48,$d8), ($06,$03,$03,$05), ($f7,$f6,$f6,$01), ($1c,$0e,$0e,$12),
560 ($c2,$61,$61,$a3), ($6a,$35,$35,$5f), ($ae,$57,$57,$f9), ($69,$b9,$b9,$d0),
561 ($17,$86,$86,$91), ($99,$c1,$c1,$58), ($3a,$1d,$1d,$27), ($27,$9e,$9e,$b9),
562 ($d9,$e1,$e1,$38), ($eb,$f8,$f8,$13), ($2b,$98,$98,$b3), ($22,$11,$11,$33),
563 ($d2,$69,$69,$bb), ($a9,$d9,$d9,$70), ($07,$8e,$8e,$89), ($33,$94,$94,$a7),
564 ($2d,$9b,$9b,$b6), ($3c,$1e,$1e,$22), ($15,$87,$87,$92), ($c9,$e9,$e9,$20),
565 ($87,$ce,$ce,$49), ($aa,$55,$55,$ff), ($50,$28,$28,$78), ($a5,$df,$df,$7a),
566 ($03,$8c,$8c,$8f), ($59,$a1,$a1,$f8), ($09,$89,$89,$80), ($1a,$0d,$0d,$17),
567 ($65,$bf,$bf,$da), ($d7,$e6,$e6,$31), ($84,$42,$42,$c6), ($d0,$68,$68,$b8),
568 ($82,$41,$41,$c3), ($29,$99,$99,$b0), ($5a,$2d,$2d,$77), ($1e,$0f,$0f,$11),
569 ($7b,$b0,$b0,$cb), ($a8,$54,$54,$fc), ($6d,$bb,$bb,$d6), ($2c,$16,$16,$3a));
570 T2: array[0..255,0..3] of byte= (
571 ($a5,$c6,$63,$63), ($84,$f8,$7c,$7c), ($99,$ee,$77,$77), ($8d,$f6,$7b,$7b),
572 ($0d,$ff,$f2,$f2), ($bd,$d6,$6b,$6b), ($b1,$de,$6f,$6f), ($54,$91,$c5,$c5),
573 ($50,$60,$30,$30), ($03,$02,$01,$01), ($a9,$ce,$67,$67), ($7d,$56,$2b,$2b),
574 ($19,$e7,$fe,$fe), ($62,$b5,$d7,$d7), ($e6,$4d,$ab,$ab), ($9a,$ec,$76,$76),
575 ($45,$8f,$ca,$ca), ($9d,$1f,$82,$82), ($40,$89,$c9,$c9), ($87,$fa,$7d,$7d),
576 ($15,$ef,$fa,$fa), ($eb,$b2,$59,$59), ($c9,$8e,$47,$47), ($0b,$fb,$f0,$f0),
577 ($ec,$41,$ad,$ad), ($67,$b3,$d4,$d4), ($fd,$5f,$a2,$a2), ($ea,$45,$af,$af),
578 ($bf,$23,$9c,$9c), ($f7,$53,$a4,$a4), ($96,$e4,$72,$72), ($5b,$9b,$c0,$c0),
579 ($c2,$75,$b7,$b7), ($1c,$e1,$fd,$fd), ($ae,$3d,$93,$93), ($6a,$4c,$26,$26),
580 ($5a,$6c,$36,$36), ($41,$7e,$3f,$3f), ($02,$f5,$f7,$f7), ($4f,$83,$cc,$cc),
581 ($5c,$68,$34,$34), ($f4,$51,$a5,$a5), ($34,$d1,$e5,$e5), ($08,$f9,$f1,$f1),
582 ($93,$e2,$71,$71), ($73,$ab,$d8,$d8), ($53,$62,$31,$31), ($3f,$2a,$15,$15),
583 ($0c,$08,$04,$04), ($52,$95,$c7,$c7), ($65,$46,$23,$23), ($5e,$9d,$c3,$c3),
584 ($28,$30,$18,$18), ($a1,$37,$96,$96), ($0f,$0a,$05,$05), ($b5,$2f,$9a,$9a),
585 ($09,$0e,$07,$07), ($36,$24,$12,$12), ($9b,$1b,$80,$80), ($3d,$df,$e2,$e2),
586 ($26,$cd,$eb,$eb), ($69,$4e,$27,$27), ($cd,$7f,$b2,$b2), ($9f,$ea,$75,$75),
587 ($1b,$12,$09,$09), ($9e,$1d,$83,$83), ($74,$58,$2c,$2c), ($2e,$34,$1a,$1a),
588 ($2d,$36,$1b,$1b), ($b2,$dc,$6e,$6e), ($ee,$b4,$5a,$5a), ($fb,$5b,$a0,$a0),
589 ($f6,$a4,$52,$52), ($4d,$76,$3b,$3b), ($61,$b7,$d6,$d6), ($ce,$7d,$b3,$b3),
590 ($7b,$52,$29,$29), ($3e,$dd,$e3,$e3), ($71,$5e,$2f,$2f), ($97,$13,$84,$84),
591 ($f5,$a6,$53,$53), ($68,$b9,$d1,$d1), ($00,$00,$00,$00), ($2c,$c1,$ed,$ed),
592 ($60,$40,$20,$20), ($1f,$e3,$fc,$fc), ($c8,$79,$b1,$b1), ($ed,$b6,$5b,$5b),
593 ($be,$d4,$6a,$6a), ($46,$8d,$cb,$cb), ($d9,$67,$be,$be), ($4b,$72,$39,$39),
594 ($de,$94,$4a,$4a), ($d4,$98,$4c,$4c), ($e8,$b0,$58,$58), ($4a,$85,$cf,$cf),
595 ($6b,$bb,$d0,$d0), ($2a,$c5,$ef,$ef), ($e5,$4f,$aa,$aa), ($16,$ed,$fb,$fb),
596 ($c5,$86,$43,$43), ($d7,$9a,$4d,$4d), ($55,$66,$33,$33), ($94,$11,$85,$85),
597 ($cf,$8a,$45,$45), ($10,$e9,$f9,$f9), ($06,$04,$02,$02), ($81,$fe,$7f,$7f),
598 ($f0,$a0,$50,$50), ($44,$78,$3c,$3c), ($ba,$25,$9f,$9f), ($e3,$4b,$a8,$a8),
599 ($f3,$a2,$51,$51), ($fe,$5d,$a3,$a3), ($c0,$80,$40,$40), ($8a,$05,$8f,$8f),
600 ($ad,$3f,$92,$92), ($bc,$21,$9d,$9d), ($48,$70,$38,$38), ($04,$f1,$f5,$f5),
601 ($df,$63,$bc,$bc), ($c1,$77,$b6,$b6), ($75,$af,$da,$da), ($63,$42,$21,$21),
602 ($30,$20,$10,$10), ($1a,$e5,$ff,$ff), ($0e,$fd,$f3,$f3), ($6d,$bf,$d2,$d2),
603 ($4c,$81,$cd,$cd), ($14,$18,$0c,$0c), ($35,$26,$13,$13), ($2f,$c3,$ec,$ec),
604 ($e1,$be,$5f,$5f), ($a2,$35,$97,$97), ($cc,$88,$44,$44), ($39,$2e,$17,$17),
605 ($57,$93,$c4,$c4), ($f2,$55,$a7,$a7), ($82,$fc,$7e,$7e), ($47,$7a,$3d,$3d),
606 ($ac,$c8,$64,$64), ($e7,$ba,$5d,$5d), ($2b,$32,$19,$19), ($95,$e6,$73,$73),
607 ($a0,$c0,$60,$60), ($98,$19,$81,$81), ($d1,$9e,$4f,$4f), ($7f,$a3,$dc,$dc),
608 ($66,$44,$22,$22), ($7e,$54,$2a,$2a), ($ab,$3b,$90,$90), ($83,$0b,$88,$88),
609 ($ca,$8c,$46,$46), ($29,$c7,$ee,$ee), ($d3,$6b,$b8,$b8), ($3c,$28,$14,$14),
610 ($79,$a7,$de,$de), ($e2,$bc,$5e,$5e), ($1d,$16,$0b,$0b), ($76,$ad,$db,$db),
611 ($3b,$db,$e0,$e0), ($56,$64,$32,$32), ($4e,$74,$3a,$3a), ($1e,$14,$0a,$0a),
612 ($db,$92,$49,$49), ($0a,$0c,$06,$06), ($6c,$48,$24,$24), ($e4,$b8,$5c,$5c),
613 ($5d,$9f,$c2,$c2), ($6e,$bd,$d3,$d3), ($ef,$43,$ac,$ac), ($a6,$c4,$62,$62),
614 ($a8,$39,$91,$91), ($a4,$31,$95,$95), ($37,$d3,$e4,$e4), ($8b,$f2,$79,$79),
615 ($32,$d5,$e7,$e7), ($43,$8b,$c8,$c8), ($59,$6e,$37,$37), ($b7,$da,$6d,$6d),
616 ($8c,$01,$8d,$8d), ($64,$b1,$d5,$d5), ($d2,$9c,$4e,$4e), ($e0,$49,$a9,$a9),
617 ($b4,$d8,$6c,$6c), ($fa,$ac,$56,$56), ($07,$f3,$f4,$f4), ($25,$cf,$ea,$ea),
618 ($af,$ca,$65,$65), ($8e,$f4,$7a,$7a), ($e9,$47,$ae,$ae), ($18,$10,$08,$08),
619 ($d5,$6f,$ba,$ba), ($88,$f0,$78,$78), ($6f,$4a,$25,$25), ($72,$5c,$2e,$2e),
620 ($24,$38,$1c,$1c), ($f1,$57,$a6,$a6), ($c7,$73,$b4,$b4), ($51,$97,$c6,$c6),
621 ($23,$cb,$e8,$e8), ($7c,$a1,$dd,$dd), ($9c,$e8,$74,$74), ($21,$3e,$1f,$1f),
622 ($dd,$96,$4b,$4b), ($dc,$61,$bd,$bd), ($86,$0d,$8b,$8b), ($85,$0f,$8a,$8a),
623 ($90,$e0,$70,$70), ($42,$7c,$3e,$3e), ($c4,$71,$b5,$b5), ($aa,$cc,$66,$66),
624 ($d8,$90,$48,$48), ($05,$06,$03,$03), ($01,$f7,$f6,$f6), ($12,$1c,$0e,$0e),
625 ($a3,$c2,$61,$61), ($5f,$6a,$35,$35), ($f9,$ae,$57,$57), ($d0,$69,$b9,$b9),
626 ($91,$17,$86,$86), ($58,$99,$c1,$c1), ($27,$3a,$1d,$1d), ($b9,$27,$9e,$9e),
627 ($38,$d9,$e1,$e1), ($13,$eb,$f8,$f8), ($b3,$2b,$98,$98), ($33,$22,$11,$11),
628 ($bb,$d2,$69,$69), ($70,$a9,$d9,$d9), ($89,$07,$8e,$8e), ($a7,$33,$94,$94),
629 ($b6,$2d,$9b,$9b), ($22,$3c,$1e,$1e), ($92,$15,$87,$87), ($20,$c9,$e9,$e9),
630 ($49,$87,$ce,$ce), ($ff,$aa,$55,$55), ($78,$50,$28,$28), ($7a,$a5,$df,$df),
631 ($8f,$03,$8c,$8c), ($f8,$59,$a1,$a1), ($80,$09,$89,$89), ($17,$1a,$0d,$0d),
632 ($da,$65,$bf,$bf), ($31,$d7,$e6,$e6), ($c6,$84,$42,$42), ($b8,$d0,$68,$68),
633 ($c3,$82,$41,$41), ($b0,$29,$99,$99), ($77,$5a,$2d,$2d), ($11,$1e,$0f,$0f),
634 ($cb,$7b,$b0,$b0), ($fc,$a8,$54,$54), ($d6,$6d,$bb,$bb), ($3a,$2c,$16,$16));
635 T3: array[0..255,0..3] of byte= (
636 ($63,$a5,$c6,$63), ($7c,$84,$f8,$7c), ($77,$99,$ee,$77), ($7b,$8d,$f6,$7b),
637 ($f2,$0d,$ff,$f2), ($6b,$bd,$d6,$6b), ($6f,$b1,$de,$6f), ($c5,$54,$91,$c5),
638 ($30,$50,$60,$30), ($01,$03,$02,$01), ($67,$a9,$ce,$67), ($2b,$7d,$56,$2b),
639 ($fe,$19,$e7,$fe), ($d7,$62,$b5,$d7), ($ab,$e6,$4d,$ab), ($76,$9a,$ec,$76),
640 ($ca,$45,$8f,$ca), ($82,$9d,$1f,$82), ($c9,$40,$89,$c9), ($7d,$87,$fa,$7d),
641 ($fa,$15,$ef,$fa), ($59,$eb,$b2,$59), ($47,$c9,$8e,$47), ($f0,$0b,$fb,$f0),
642 ($ad,$ec,$41,$ad), ($d4,$67,$b3,$d4), ($a2,$fd,$5f,$a2), ($af,$ea,$45,$af),
643 ($9c,$bf,$23,$9c), ($a4,$f7,$53,$a4), ($72,$96,$e4,$72), ($c0,$5b,$9b,$c0),
644 ($b7,$c2,$75,$b7), ($fd,$1c,$e1,$fd), ($93,$ae,$3d,$93), ($26,$6a,$4c,$26),
645 ($36,$5a,$6c,$36), ($3f,$41,$7e,$3f), ($f7,$02,$f5,$f7), ($cc,$4f,$83,$cc),
646 ($34,$5c,$68,$34), ($a5,$f4,$51,$a5), ($e5,$34,$d1,$e5), ($f1,$08,$f9,$f1),
647 ($71,$93,$e2,$71), ($d8,$73,$ab,$d8), ($31,$53,$62,$31), ($15,$3f,$2a,$15),
648 ($04,$0c,$08,$04), ($c7,$52,$95,$c7), ($23,$65,$46,$23), ($c3,$5e,$9d,$c3),
649 ($18,$28,$30,$18), ($96,$a1,$37,$96), ($05,$0f,$0a,$05), ($9a,$b5,$2f,$9a),
650 ($07,$09,$0e,$07), ($12,$36,$24,$12), ($80,$9b,$1b,$80), ($e2,$3d,$df,$e2),
651 ($eb,$26,$cd,$eb), ($27,$69,$4e,$27), ($b2,$cd,$7f,$b2), ($75,$9f,$ea,$75),
652 ($09,$1b,$12,$09), ($83,$9e,$1d,$83), ($2c,$74,$58,$2c), ($1a,$2e,$34,$1a),
653 ($1b,$2d,$36,$1b), ($6e,$b2,$dc,$6e), ($5a,$ee,$b4,$5a), ($a0,$fb,$5b,$a0),
654 ($52,$f6,$a4,$52), ($3b,$4d,$76,$3b), ($d6,$61,$b7,$d6), ($b3,$ce,$7d,$b3),
655 ($29,$7b,$52,$29), ($e3,$3e,$dd,$e3), ($2f,$71,$5e,$2f), ($84,$97,$13,$84),
656 ($53,$f5,$a6,$53), ($d1,$68,$b9,$d1), ($00,$00,$00,$00), ($ed,$2c,$c1,$ed),
657 ($20,$60,$40,$20), ($fc,$1f,$e3,$fc), ($b1,$c8,$79,$b1), ($5b,$ed,$b6,$5b),
658 ($6a,$be,$d4,$6a), ($cb,$46,$8d,$cb), ($be,$d9,$67,$be), ($39,$4b,$72,$39),
659 ($4a,$de,$94,$4a), ($4c,$d4,$98,$4c), ($58,$e8,$b0,$58), ($cf,$4a,$85,$cf),
660 ($d0,$6b,$bb,$d0), ($ef,$2a,$c5,$ef), ($aa,$e5,$4f,$aa), ($fb,$16,$ed,$fb),
661 ($43,$c5,$86,$43), ($4d,$d7,$9a,$4d), ($33,$55,$66,$33), ($85,$94,$11,$85),
662 ($45,$cf,$8a,$45), ($f9,$10,$e9,$f9), ($02,$06,$04,$02), ($7f,$81,$fe,$7f),
663 ($50,$f0,$a0,$50), ($3c,$44,$78,$3c), ($9f,$ba,$25,$9f), ($a8,$e3,$4b,$a8),
664 ($51,$f3,$a2,$51), ($a3,$fe,$5d,$a3), ($40,$c0,$80,$40), ($8f,$8a,$05,$8f),
665 ($92,$ad,$3f,$92), ($9d,$bc,$21,$9d), ($38,$48,$70,$38), ($f5,$04,$f1,$f5),
666 ($bc,$df,$63,$bc), ($b6,$c1,$77,$b6), ($da,$75,$af,$da), ($21,$63,$42,$21),
667 ($10,$30,$20,$10), ($ff,$1a,$e5,$ff), ($f3,$0e,$fd,$f3), ($d2,$6d,$bf,$d2),
668 ($cd,$4c,$81,$cd), ($0c,$14,$18,$0c), ($13,$35,$26,$13), ($ec,$2f,$c3,$ec),
669 ($5f,$e1,$be,$5f), ($97,$a2,$35,$97), ($44,$cc,$88,$44), ($17,$39,$2e,$17),
670 ($c4,$57,$93,$c4), ($a7,$f2,$55,$a7), ($7e,$82,$fc,$7e), ($3d,$47,$7a,$3d),
671 ($64,$ac,$c8,$64), ($5d,$e7,$ba,$5d), ($19,$2b,$32,$19), ($73,$95,$e6,$73),
672 ($60,$a0,$c0,$60), ($81,$98,$19,$81), ($4f,$d1,$9e,$4f), ($dc,$7f,$a3,$dc),
673 ($22,$66,$44,$22), ($2a,$7e,$54,$2a), ($90,$ab,$3b,$90), ($88,$83,$0b,$88),
674 ($46,$ca,$8c,$46), ($ee,$29,$c7,$ee), ($b8,$d3,$6b,$b8), ($14,$3c,$28,$14),
675 ($de,$79,$a7,$de), ($5e,$e2,$bc,$5e), ($0b,$1d,$16,$0b), ($db,$76,$ad,$db),
676 ($e0,$3b,$db,$e0), ($32,$56,$64,$32), ($3a,$4e,$74,$3a), ($0a,$1e,$14,$0a),
677 ($49,$db,$92,$49), ($06,$0a,$0c,$06), ($24,$6c,$48,$24), ($5c,$e4,$b8,$5c),
678 ($c2,$5d,$9f,$c2), ($d3,$6e,$bd,$d3), ($ac,$ef,$43,$ac), ($62,$a6,$c4,$62),
679 ($91,$a8,$39,$91), ($95,$a4,$31,$95), ($e4,$37,$d3,$e4), ($79,$8b,$f2,$79),
680 ($e7,$32,$d5,$e7), ($c8,$43,$8b,$c8), ($37,$59,$6e,$37), ($6d,$b7,$da,$6d),
681 ($8d,$8c,$01,$8d), ($d5,$64,$b1,$d5), ($4e,$d2,$9c,$4e), ($a9,$e0,$49,$a9),
682 ($6c,$b4,$d8,$6c), ($56,$fa,$ac,$56), ($f4,$07,$f3,$f4), ($ea,$25,$cf,$ea),
683 ($65,$af,$ca,$65), ($7a,$8e,$f4,$7a), ($ae,$e9,$47,$ae), ($08,$18,$10,$08),
684 ($ba,$d5,$6f,$ba), ($78,$88,$f0,$78), ($25,$6f,$4a,$25), ($2e,$72,$5c,$2e),
685 ($1c,$24,$38,$1c), ($a6,$f1,$57,$a6), ($b4,$c7,$73,$b4), ($c6,$51,$97,$c6),
686 ($e8,$23,$cb,$e8), ($dd,$7c,$a1,$dd), ($74,$9c,$e8,$74), ($1f,$21,$3e,$1f),
687 ($4b,$dd,$96,$4b), ($bd,$dc,$61,$bd), ($8b,$86,$0d,$8b), ($8a,$85,$0f,$8a),
688 ($70,$90,$e0,$70), ($3e,$42,$7c,$3e), ($b5,$c4,$71,$b5), ($66,$aa,$cc,$66),
689 ($48,$d8,$90,$48), ($03,$05,$06,$03), ($f6,$01,$f7,$f6), ($0e,$12,$1c,$0e),
690 ($61,$a3,$c2,$61), ($35,$5f,$6a,$35), ($57,$f9,$ae,$57), ($b9,$d0,$69,$b9),
691 ($86,$91,$17,$86), ($c1,$58,$99,$c1), ($1d,$27,$3a,$1d), ($9e,$b9,$27,$9e),
692 ($e1,$38,$d9,$e1), ($f8,$13,$eb,$f8), ($98,$b3,$2b,$98), ($11,$33,$22,$11),
693 ($69,$bb,$d2,$69), ($d9,$70,$a9,$d9), ($8e,$89,$07,$8e), ($94,$a7,$33,$94),
694 ($9b,$b6,$2d,$9b), ($1e,$22,$3c,$1e), ($87,$92,$15,$87), ($e9,$20,$c9,$e9),
695 ($ce,$49,$87,$ce), ($55,$ff,$aa,$55), ($28,$78,$50,$28), ($df,$7a,$a5,$df),
696 ($8c,$8f,$03,$8c), ($a1,$f8,$59,$a1), ($89,$80,$09,$89), ($0d,$17,$1a,$0d),
697 ($bf,$da,$65,$bf), ($e6,$31,$d7,$e6), ($42,$c6,$84,$42), ($68,$b8,$d0,$68),
698 ($41,$c3,$82,$41), ($99,$b0,$29,$99), ($2d,$77,$5a,$2d), ($0f,$11,$1e,$0f),
699 ($b0,$cb,$7b,$b0), ($54,$fc,$a8,$54), ($bb,$d6,$6d,$bb), ($16,$3a,$2c,$16));
700 T4: array[0..255,0..3] of byte= (
701 ($63,$63,$a5,$c6), ($7c,$7c,$84,$f8), ($77,$77,$99,$ee), ($7b,$7b,$8d,$f6),
702 ($f2,$f2,$0d,$ff), ($6b,$6b,$bd,$d6), ($6f,$6f,$b1,$de), ($c5,$c5,$54,$91),
703 ($30,$30,$50,$60), ($01,$01,$03,$02), ($67,$67,$a9,$ce), ($2b,$2b,$7d,$56),
704 ($fe,$fe,$19,$e7), ($d7,$d7,$62,$b5), ($ab,$ab,$e6,$4d), ($76,$76,$9a,$ec),
705 ($ca,$ca,$45,$8f), ($82,$82,$9d,$1f), ($c9,$c9,$40,$89), ($7d,$7d,$87,$fa),
706 ($fa,$fa,$15,$ef), ($59,$59,$eb,$b2), ($47,$47,$c9,$8e), ($f0,$f0,$0b,$fb),
707 ($ad,$ad,$ec,$41), ($d4,$d4,$67,$b3), ($a2,$a2,$fd,$5f), ($af,$af,$ea,$45),
708 ($9c,$9c,$bf,$23), ($a4,$a4,$f7,$53), ($72,$72,$96,$e4), ($c0,$c0,$5b,$9b),
709 ($b7,$b7,$c2,$75), ($fd,$fd,$1c,$e1), ($93,$93,$ae,$3d), ($26,$26,$6a,$4c),
710 ($36,$36,$5a,$6c), ($3f,$3f,$41,$7e), ($f7,$f7,$02,$f5), ($cc,$cc,$4f,$83),
711 ($34,$34,$5c,$68), ($a5,$a5,$f4,$51), ($e5,$e5,$34,$d1), ($f1,$f1,$08,$f9),
712 ($71,$71,$93,$e2), ($d8,$d8,$73,$ab), ($31,$31,$53,$62), ($15,$15,$3f,$2a),
713 ($04,$04,$0c,$08), ($c7,$c7,$52,$95), ($23,$23,$65,$46), ($c3,$c3,$5e,$9d),
714 ($18,$18,$28,$30), ($96,$96,$a1,$37), ($05,$05,$0f,$0a), ($9a,$9a,$b5,$2f),
715 ($07,$07,$09,$0e), ($12,$12,$36,$24), ($80,$80,$9b,$1b), ($e2,$e2,$3d,$df),
716 ($eb,$eb,$26,$cd), ($27,$27,$69,$4e), ($b2,$b2,$cd,$7f), ($75,$75,$9f,$ea),
717 ($09,$09,$1b,$12), ($83,$83,$9e,$1d), ($2c,$2c,$74,$58), ($1a,$1a,$2e,$34),
718 ($1b,$1b,$2d,$36), ($6e,$6e,$b2,$dc), ($5a,$5a,$ee,$b4), ($a0,$a0,$fb,$5b),
719 ($52,$52,$f6,$a4), ($3b,$3b,$4d,$76), ($d6,$d6,$61,$b7), ($b3,$b3,$ce,$7d),
720 ($29,$29,$7b,$52), ($e3,$e3,$3e,$dd), ($2f,$2f,$71,$5e), ($84,$84,$97,$13),
721 ($53,$53,$f5,$a6), ($d1,$d1,$68,$b9), ($00,$00,$00,$00), ($ed,$ed,$2c,$c1),
722 ($20,$20,$60,$40), ($fc,$fc,$1f,$e3), ($b1,$b1,$c8,$79), ($5b,$5b,$ed,$b6),
723 ($6a,$6a,$be,$d4), ($cb,$cb,$46,$8d), ($be,$be,$d9,$67), ($39,$39,$4b,$72),
724 ($4a,$4a,$de,$94), ($4c,$4c,$d4,$98), ($58,$58,$e8,$b0), ($cf,$cf,$4a,$85),
725 ($d0,$d0,$6b,$bb), ($ef,$ef,$2a,$c5), ($aa,$aa,$e5,$4f), ($fb,$fb,$16,$ed),
726 ($43,$43,$c5,$86), ($4d,$4d,$d7,$9a), ($33,$33,$55,$66), ($85,$85,$94,$11),
727 ($45,$45,$cf,$8a), ($f9,$f9,$10,$e9), ($02,$02,$06,$04), ($7f,$7f,$81,$fe),
728 ($50,$50,$f0,$a0), ($3c,$3c,$44,$78), ($9f,$9f,$ba,$25), ($a8,$a8,$e3,$4b),
729 ($51,$51,$f3,$a2), ($a3,$a3,$fe,$5d), ($40,$40,$c0,$80), ($8f,$8f,$8a,$05),
730 ($92,$92,$ad,$3f), ($9d,$9d,$bc,$21), ($38,$38,$48,$70), ($f5,$f5,$04,$f1),
731 ($bc,$bc,$df,$63), ($b6,$b6,$c1,$77), ($da,$da,$75,$af), ($21,$21,$63,$42),
732 ($10,$10,$30,$20), ($ff,$ff,$1a,$e5), ($f3,$f3,$0e,$fd), ($d2,$d2,$6d,$bf),
733 ($cd,$cd,$4c,$81), ($0c,$0c,$14,$18), ($13,$13,$35,$26), ($ec,$ec,$2f,$c3),
734 ($5f,$5f,$e1,$be), ($97,$97,$a2,$35), ($44,$44,$cc,$88), ($17,$17,$39,$2e),
735 ($c4,$c4,$57,$93), ($a7,$a7,$f2,$55), ($7e,$7e,$82,$fc), ($3d,$3d,$47,$7a),
736 ($64,$64,$ac,$c8), ($5d,$5d,$e7,$ba), ($19,$19,$2b,$32), ($73,$73,$95,$e6),
737 ($60,$60,$a0,$c0), ($81,$81,$98,$19), ($4f,$4f,$d1,$9e), ($dc,$dc,$7f,$a3),
738 ($22,$22,$66,$44), ($2a,$2a,$7e,$54), ($90,$90,$ab,$3b), ($88,$88,$83,$0b),
739 ($46,$46,$ca,$8c), ($ee,$ee,$29,$c7), ($b8,$b8,$d3,$6b), ($14,$14,$3c,$28),
740 ($de,$de,$79,$a7), ($5e,$5e,$e2,$bc), ($0b,$0b,$1d,$16), ($db,$db,$76,$ad),
741 ($e0,$e0,$3b,$db), ($32,$32,$56,$64), ($3a,$3a,$4e,$74), ($0a,$0a,$1e,$14),
742 ($49,$49,$db,$92), ($06,$06,$0a,$0c), ($24,$24,$6c,$48), ($5c,$5c,$e4,$b8),
743 ($c2,$c2,$5d,$9f), ($d3,$d3,$6e,$bd), ($ac,$ac,$ef,$43), ($62,$62,$a6,$c4),
744 ($91,$91,$a8,$39), ($95,$95,$a4,$31), ($e4,$e4,$37,$d3), ($79,$79,$8b,$f2),
745 ($e7,$e7,$32,$d5), ($c8,$c8,$43,$8b), ($37,$37,$59,$6e), ($6d,$6d,$b7,$da),
746 ($8d,$8d,$8c,$01), ($d5,$d5,$64,$b1), ($4e,$4e,$d2,$9c), ($a9,$a9,$e0,$49),
747 ($6c,$6c,$b4,$d8), ($56,$56,$fa,$ac), ($f4,$f4,$07,$f3), ($ea,$ea,$25,$cf),
748 ($65,$65,$af,$ca), ($7a,$7a,$8e,$f4), ($ae,$ae,$e9,$47), ($08,$08,$18,$10),
749 ($ba,$ba,$d5,$6f), ($78,$78,$88,$f0), ($25,$25,$6f,$4a), ($2e,$2e,$72,$5c),
750 ($1c,$1c,$24,$38), ($a6,$a6,$f1,$57), ($b4,$b4,$c7,$73), ($c6,$c6,$51,$97),
751 ($e8,$e8,$23,$cb), ($dd,$dd,$7c,$a1), ($74,$74,$9c,$e8), ($1f,$1f,$21,$3e),
752 ($4b,$4b,$dd,$96), ($bd,$bd,$dc,$61), ($8b,$8b,$86,$0d), ($8a,$8a,$85,$0f),
753 ($70,$70,$90,$e0), ($3e,$3e,$42,$7c), ($b5,$b5,$c4,$71), ($66,$66,$aa,$cc),
754 ($48,$48,$d8,$90), ($03,$03,$05,$06), ($f6,$f6,$01,$f7), ($0e,$0e,$12,$1c),
755 ($61,$61,$a3,$c2), ($35,$35,$5f,$6a), ($57,$57,$f9,$ae), ($b9,$b9,$d0,$69),
756 ($86,$86,$91,$17), ($c1,$c1,$58,$99), ($1d,$1d,$27,$3a), ($9e,$9e,$b9,$27),
757 ($e1,$e1,$38,$d9), ($f8,$f8,$13,$eb), ($98,$98,$b3,$2b), ($11,$11,$33,$22),
758 ($69,$69,$bb,$d2), ($d9,$d9,$70,$a9), ($8e,$8e,$89,$07), ($94,$94,$a7,$33),
759 ($9b,$9b,$b6,$2d), ($1e,$1e,$22,$3c), ($87,$87,$92,$15), ($e9,$e9,$20,$c9),
760 ($ce,$ce,$49,$87), ($55,$55,$ff,$aa), ($28,$28,$78,$50), ($df,$df,$7a,$a5),
761 ($8c,$8c,$8f,$03), ($a1,$a1,$f8,$59), ($89,$89,$80,$09), ($0d,$0d,$17,$1a),
762 ($bf,$bf,$da,$65), ($e6,$e6,$31,$d7), ($42,$42,$c6,$84), ($68,$68,$b8,$d0),
763 ($41,$41,$c3,$82), ($99,$99,$b0,$29), ($2d,$2d,$77,$5a), ($0f,$0f,$11,$1e),
764 ($b0,$b0,$cb,$7b), ($54,$54,$fc,$a8), ($bb,$bb,$d6,$6d), ($16,$16,$3a,$2c));
765 T5: array[0..255,0..3] of byte= (
766 ($51,$f4,$a7,$50), ($7e,$41,$65,$53), ($1a,$17,$a4,$c3), ($3a,$27,$5e,$96),
767 ($3b,$ab,$6b,$cb), ($1f,$9d,$45,$f1), ($ac,$fa,$58,$ab), ($4b,$e3,$03,$93),
768 ($20,$30,$fa,$55), ($ad,$76,$6d,$f6), ($88,$cc,$76,$91), ($f5,$02,$4c,$25),
769 ($4f,$e5,$d7,$fc), ($c5,$2a,$cb,$d7), ($26,$35,$44,$80), ($b5,$62,$a3,$8f),
770 ($de,$b1,$5a,$49), ($25,$ba,$1b,$67), ($45,$ea,$0e,$98), ($5d,$fe,$c0,$e1),
771 ($c3,$2f,$75,$02), ($81,$4c,$f0,$12), ($8d,$46,$97,$a3), ($6b,$d3,$f9,$c6),
772 ($03,$8f,$5f,$e7), ($15,$92,$9c,$95), ($bf,$6d,$7a,$eb), ($95,$52,$59,$da),
773 ($d4,$be,$83,$2d), ($58,$74,$21,$d3), ($49,$e0,$69,$29), ($8e,$c9,$c8,$44),
774 ($75,$c2,$89,$6a), ($f4,$8e,$79,$78), ($99,$58,$3e,$6b), ($27,$b9,$71,$dd),
775 ($be,$e1,$4f,$b6), ($f0,$88,$ad,$17), ($c9,$20,$ac,$66), ($7d,$ce,$3a,$b4),
776 ($63,$df,$4a,$18), ($e5,$1a,$31,$82), ($97,$51,$33,$60), ($62,$53,$7f,$45),
777 ($b1,$64,$77,$e0), ($bb,$6b,$ae,$84), ($fe,$81,$a0,$1c), ($f9,$08,$2b,$94),
778 ($70,$48,$68,$58), ($8f,$45,$fd,$19), ($94,$de,$6c,$87), ($52,$7b,$f8,$b7),
779 ($ab,$73,$d3,$23), ($72,$4b,$02,$e2), ($e3,$1f,$8f,$57), ($66,$55,$ab,$2a),
780 ($b2,$eb,$28,$07), ($2f,$b5,$c2,$03), ($86,$c5,$7b,$9a), ($d3,$37,$08,$a5),
781 ($30,$28,$87,$f2), ($23,$bf,$a5,$b2), ($02,$03,$6a,$ba), ($ed,$16,$82,$5c),
782 ($8a,$cf,$1c,$2b), ($a7,$79,$b4,$92), ($f3,$07,$f2,$f0), ($4e,$69,$e2,$a1),
783 ($65,$da,$f4,$cd), ($06,$05,$be,$d5), ($d1,$34,$62,$1f), ($c4,$a6,$fe,$8a),
784 ($34,$2e,$53,$9d), ($a2,$f3,$55,$a0), ($05,$8a,$e1,$32), ($a4,$f6,$eb,$75),
785 ($0b,$83,$ec,$39), ($40,$60,$ef,$aa), ($5e,$71,$9f,$06), ($bd,$6e,$10,$51),
786 ($3e,$21,$8a,$f9), ($96,$dd,$06,$3d), ($dd,$3e,$05,$ae), ($4d,$e6,$bd,$46),
787 ($91,$54,$8d,$b5), ($71,$c4,$5d,$05), ($04,$06,$d4,$6f), ($60,$50,$15,$ff),
788 ($19,$98,$fb,$24), ($d6,$bd,$e9,$97), ($89,$40,$43,$cc), ($67,$d9,$9e,$77),
789 ($b0,$e8,$42,$bd), ($07,$89,$8b,$88), ($e7,$19,$5b,$38), ($79,$c8,$ee,$db),
790 ($a1,$7c,$0a,$47), ($7c,$42,$0f,$e9), ($f8,$84,$1e,$c9), ($00,$00,$00,$00),
791 ($09,$80,$86,$83), ($32,$2b,$ed,$48), ($1e,$11,$70,$ac), ($6c,$5a,$72,$4e),
792 ($fd,$0e,$ff,$fb), ($0f,$85,$38,$56), ($3d,$ae,$d5,$1e), ($36,$2d,$39,$27),
793 ($0a,$0f,$d9,$64), ($68,$5c,$a6,$21), ($9b,$5b,$54,$d1), ($24,$36,$2e,$3a),
794 ($0c,$0a,$67,$b1), ($93,$57,$e7,$0f), ($b4,$ee,$96,$d2), ($1b,$9b,$91,$9e),
795 ($80,$c0,$c5,$4f), ($61,$dc,$20,$a2), ($5a,$77,$4b,$69), ($1c,$12,$1a,$16),
796 ($e2,$93,$ba,$0a), ($c0,$a0,$2a,$e5), ($3c,$22,$e0,$43), ($12,$1b,$17,$1d),
797 ($0e,$09,$0d,$0b), ($f2,$8b,$c7,$ad), ($2d,$b6,$a8,$b9), ($14,$1e,$a9,$c8),
798 ($57,$f1,$19,$85), ($af,$75,$07,$4c), ($ee,$99,$dd,$bb), ($a3,$7f,$60,$fd),
799 ($f7,$01,$26,$9f), ($5c,$72,$f5,$bc), ($44,$66,$3b,$c5), ($5b,$fb,$7e,$34),
800 ($8b,$43,$29,$76), ($cb,$23,$c6,$dc), ($b6,$ed,$fc,$68), ($b8,$e4,$f1,$63),
801 ($d7,$31,$dc,$ca), ($42,$63,$85,$10), ($13,$97,$22,$40), ($84,$c6,$11,$20),
802 ($85,$4a,$24,$7d), ($d2,$bb,$3d,$f8), ($ae,$f9,$32,$11), ($c7,$29,$a1,$6d),
803 ($1d,$9e,$2f,$4b), ($dc,$b2,$30,$f3), ($0d,$86,$52,$ec), ($77,$c1,$e3,$d0),
804 ($2b,$b3,$16,$6c), ($a9,$70,$b9,$99), ($11,$94,$48,$fa), ($47,$e9,$64,$22),
805 ($a8,$fc,$8c,$c4), ($a0,$f0,$3f,$1a), ($56,$7d,$2c,$d8), ($22,$33,$90,$ef),
806 ($87,$49,$4e,$c7), ($d9,$38,$d1,$c1), ($8c,$ca,$a2,$fe), ($98,$d4,$0b,$36),
807 ($a6,$f5,$81,$cf), ($a5,$7a,$de,$28), ($da,$b7,$8e,$26), ($3f,$ad,$bf,$a4),
808 ($2c,$3a,$9d,$e4), ($50,$78,$92,$0d), ($6a,$5f,$cc,$9b), ($54,$7e,$46,$62),
809 ($f6,$8d,$13,$c2), ($90,$d8,$b8,$e8), ($2e,$39,$f7,$5e), ($82,$c3,$af,$f5),
810 ($9f,$5d,$80,$be), ($69,$d0,$93,$7c), ($6f,$d5,$2d,$a9), ($cf,$25,$12,$b3),
811 ($c8,$ac,$99,$3b), ($10,$18,$7d,$a7), ($e8,$9c,$63,$6e), ($db,$3b,$bb,$7b),
812 ($cd,$26,$78,$09), ($6e,$59,$18,$f4), ($ec,$9a,$b7,$01), ($83,$4f,$9a,$a8),
813 ($e6,$95,$6e,$65), ($aa,$ff,$e6,$7e), ($21,$bc,$cf,$08), ($ef,$15,$e8,$e6),
814 ($ba,$e7,$9b,$d9), ($4a,$6f,$36,$ce), ($ea,$9f,$09,$d4), ($29,$b0,$7c,$d6),
815 ($31,$a4,$b2,$af), ($2a,$3f,$23,$31), ($c6,$a5,$94,$30), ($35,$a2,$66,$c0),
816 ($74,$4e,$bc,$37), ($fc,$82,$ca,$a6), ($e0,$90,$d0,$b0), ($33,$a7,$d8,$15),
817 ($f1,$04,$98,$4a), ($41,$ec,$da,$f7), ($7f,$cd,$50,$0e), ($17,$91,$f6,$2f),
818 ($76,$4d,$d6,$8d), ($43,$ef,$b0,$4d), ($cc,$aa,$4d,$54), ($e4,$96,$04,$df),
819 ($9e,$d1,$b5,$e3), ($4c,$6a,$88,$1b), ($c1,$2c,$1f,$b8), ($46,$65,$51,$7f),
820 ($9d,$5e,$ea,$04), ($01,$8c,$35,$5d), ($fa,$87,$74,$73), ($fb,$0b,$41,$2e),
821 ($b3,$67,$1d,$5a), ($92,$db,$d2,$52), ($e9,$10,$56,$33), ($6d,$d6,$47,$13),
822 ($9a,$d7,$61,$8c), ($37,$a1,$0c,$7a), ($59,$f8,$14,$8e), ($eb,$13,$3c,$89),
823 ($ce,$a9,$27,$ee), ($b7,$61,$c9,$35), ($e1,$1c,$e5,$ed), ($7a,$47,$b1,$3c),
824 ($9c,$d2,$df,$59), ($55,$f2,$73,$3f), ($18,$14,$ce,$79), ($73,$c7,$37,$bf),
825 ($53,$f7,$cd,$ea), ($5f,$fd,$aa,$5b), ($df,$3d,$6f,$14), ($78,$44,$db,$86),
826 ($ca,$af,$f3,$81), ($b9,$68,$c4,$3e), ($38,$24,$34,$2c), ($c2,$a3,$40,$5f),
827 ($16,$1d,$c3,$72), ($bc,$e2,$25,$0c), ($28,$3c,$49,$8b), ($ff,$0d,$95,$41),
828 ($39,$a8,$01,$71), ($08,$0c,$b3,$de), ($d8,$b4,$e4,$9c), ($64,$56,$c1,$90),
829 ($7b,$cb,$84,$61), ($d5,$32,$b6,$70), ($48,$6c,$5c,$74), ($d0,$b8,$57,$42));
830 T6: array[0..255,0..3] of byte= (
831 ($50,$51,$f4,$a7), ($53,$7e,$41,$65), ($c3,$1a,$17,$a4), ($96,$3a,$27,$5e),
832 ($cb,$3b,$ab,$6b), ($f1,$1f,$9d,$45), ($ab,$ac,$fa,$58), ($93,$4b,$e3,$03),
833 ($55,$20,$30,$fa), ($f6,$ad,$76,$6d), ($91,$88,$cc,$76), ($25,$f5,$02,$4c),
834 ($fc,$4f,$e5,$d7), ($d7,$c5,$2a,$cb), ($80,$26,$35,$44), ($8f,$b5,$62,$a3),
835 ($49,$de,$b1,$5a), ($67,$25,$ba,$1b), ($98,$45,$ea,$0e), ($e1,$5d,$fe,$c0),
836 ($02,$c3,$2f,$75), ($12,$81,$4c,$f0), ($a3,$8d,$46,$97), ($c6,$6b,$d3,$f9),
837 ($e7,$03,$8f,$5f), ($95,$15,$92,$9c), ($eb,$bf,$6d,$7a), ($da,$95,$52,$59),
838 ($2d,$d4,$be,$83), ($d3,$58,$74,$21), ($29,$49,$e0,$69), ($44,$8e,$c9,$c8),
839 ($6a,$75,$c2,$89), ($78,$f4,$8e,$79), ($6b,$99,$58,$3e), ($dd,$27,$b9,$71),
840 ($b6,$be,$e1,$4f), ($17,$f0,$88,$ad), ($66,$c9,$20,$ac), ($b4,$7d,$ce,$3a),
841 ($18,$63,$df,$4a), ($82,$e5,$1a,$31), ($60,$97,$51,$33), ($45,$62,$53,$7f),
842 ($e0,$b1,$64,$77), ($84,$bb,$6b,$ae), ($1c,$fe,$81,$a0), ($94,$f9,$08,$2b),
843 ($58,$70,$48,$68), ($19,$8f,$45,$fd), ($87,$94,$de,$6c), ($b7,$52,$7b,$f8),
844 ($23,$ab,$73,$d3), ($e2,$72,$4b,$02), ($57,$e3,$1f,$8f), ($2a,$66,$55,$ab),
845 ($07,$b2,$eb,$28), ($03,$2f,$b5,$c2), ($9a,$86,$c5,$7b), ($a5,$d3,$37,$08),
846 ($f2,$30,$28,$87), ($b2,$23,$bf,$a5), ($ba,$02,$03,$6a), ($5c,$ed,$16,$82),
847 ($2b,$8a,$cf,$1c), ($92,$a7,$79,$b4), ($f0,$f3,$07,$f2), ($a1,$4e,$69,$e2),
848 ($cd,$65,$da,$f4), ($d5,$06,$05,$be), ($1f,$d1,$34,$62), ($8a,$c4,$a6,$fe),
849 ($9d,$34,$2e,$53), ($a0,$a2,$f3,$55), ($32,$05,$8a,$e1), ($75,$a4,$f6,$eb),
850 ($39,$0b,$83,$ec), ($aa,$40,$60,$ef), ($06,$5e,$71,$9f), ($51,$bd,$6e,$10),
851 ($f9,$3e,$21,$8a), ($3d,$96,$dd,$06), ($ae,$dd,$3e,$05), ($46,$4d,$e6,$bd),
852 ($b5,$91,$54,$8d), ($05,$71,$c4,$5d), ($6f,$04,$06,$d4), ($ff,$60,$50,$15),
853 ($24,$19,$98,$fb), ($97,$d6,$bd,$e9), ($cc,$89,$40,$43), ($77,$67,$d9,$9e),
854 ($bd,$b0,$e8,$42), ($88,$07,$89,$8b), ($38,$e7,$19,$5b), ($db,$79,$c8,$ee),
855 ($47,$a1,$7c,$0a), ($e9,$7c,$42,$0f), ($c9,$f8,$84,$1e), ($00,$00,$00,$00),
856 ($83,$09,$80,$86), ($48,$32,$2b,$ed), ($ac,$1e,$11,$70), ($4e,$6c,$5a,$72),
857 ($fb,$fd,$0e,$ff), ($56,$0f,$85,$38), ($1e,$3d,$ae,$d5), ($27,$36,$2d,$39),
858 ($64,$0a,$0f,$d9), ($21,$68,$5c,$a6), ($d1,$9b,$5b,$54), ($3a,$24,$36,$2e),
859 ($b1,$0c,$0a,$67), ($0f,$93,$57,$e7), ($d2,$b4,$ee,$96), ($9e,$1b,$9b,$91),
860 ($4f,$80,$c0,$c5), ($a2,$61,$dc,$20), ($69,$5a,$77,$4b), ($16,$1c,$12,$1a),
861 ($0a,$e2,$93,$ba), ($e5,$c0,$a0,$2a), ($43,$3c,$22,$e0), ($1d,$12,$1b,$17),
862 ($0b,$0e,$09,$0d), ($ad,$f2,$8b,$c7), ($b9,$2d,$b6,$a8), ($c8,$14,$1e,$a9),
863 ($85,$57,$f1,$19), ($4c,$af,$75,$07), ($bb,$ee,$99,$dd), ($fd,$a3,$7f,$60),
864 ($9f,$f7,$01,$26), ($bc,$5c,$72,$f5), ($c5,$44,$66,$3b), ($34,$5b,$fb,$7e),
865 ($76,$8b,$43,$29), ($dc,$cb,$23,$c6), ($68,$b6,$ed,$fc), ($63,$b8,$e4,$f1),
866 ($ca,$d7,$31,$dc), ($10,$42,$63,$85), ($40,$13,$97,$22), ($20,$84,$c6,$11),
867 ($7d,$85,$4a,$24), ($f8,$d2,$bb,$3d), ($11,$ae,$f9,$32), ($6d,$c7,$29,$a1),
868 ($4b,$1d,$9e,$2f), ($f3,$dc,$b2,$30), ($ec,$0d,$86,$52), ($d0,$77,$c1,$e3),
869 ($6c,$2b,$b3,$16), ($99,$a9,$70,$b9), ($fa,$11,$94,$48), ($22,$47,$e9,$64),
870 ($c4,$a8,$fc,$8c), ($1a,$a0,$f0,$3f), ($d8,$56,$7d,$2c), ($ef,$22,$33,$90),
871 ($c7,$87,$49,$4e), ($c1,$d9,$38,$d1), ($fe,$8c,$ca,$a2), ($36,$98,$d4,$0b),
872 ($cf,$a6,$f5,$81), ($28,$a5,$7a,$de), ($26,$da,$b7,$8e), ($a4,$3f,$ad,$bf),
873 ($e4,$2c,$3a,$9d), ($0d,$50,$78,$92), ($9b,$6a,$5f,$cc), ($62,$54,$7e,$46),
874 ($c2,$f6,$8d,$13), ($e8,$90,$d8,$b8), ($5e,$2e,$39,$f7), ($f5,$82,$c3,$af),
875 ($be,$9f,$5d,$80), ($7c,$69,$d0,$93), ($a9,$6f,$d5,$2d), ($b3,$cf,$25,$12),
876 ($3b,$c8,$ac,$99), ($a7,$10,$18,$7d), ($6e,$e8,$9c,$63), ($7b,$db,$3b,$bb),
877 ($09,$cd,$26,$78), ($f4,$6e,$59,$18), ($01,$ec,$9a,$b7), ($a8,$83,$4f,$9a),
878 ($65,$e6,$95,$6e), ($7e,$aa,$ff,$e6), ($08,$21,$bc,$cf), ($e6,$ef,$15,$e8),
879 ($d9,$ba,$e7,$9b), ($ce,$4a,$6f,$36), ($d4,$ea,$9f,$09), ($d6,$29,$b0,$7c),
880 ($af,$31,$a4,$b2), ($31,$2a,$3f,$23), ($30,$c6,$a5,$94), ($c0,$35,$a2,$66),
881 ($37,$74,$4e,$bc), ($a6,$fc,$82,$ca), ($b0,$e0,$90,$d0), ($15,$33,$a7,$d8),
882 ($4a,$f1,$04,$98), ($f7,$41,$ec,$da), ($0e,$7f,$cd,$50), ($2f,$17,$91,$f6),
883 ($8d,$76,$4d,$d6), ($4d,$43,$ef,$b0), ($54,$cc,$aa,$4d), ($df,$e4,$96,$04),
884 ($e3,$9e,$d1,$b5), ($1b,$4c,$6a,$88), ($b8,$c1,$2c,$1f), ($7f,$46,$65,$51),
885 ($04,$9d,$5e,$ea), ($5d,$01,$8c,$35), ($73,$fa,$87,$74), ($2e,$fb,$0b,$41),
886 ($5a,$b3,$67,$1d), ($52,$92,$db,$d2), ($33,$e9,$10,$56), ($13,$6d,$d6,$47),
887 ($8c,$9a,$d7,$61), ($7a,$37,$a1,$0c), ($8e,$59,$f8,$14), ($89,$eb,$13,$3c),
888 ($ee,$ce,$a9,$27), ($35,$b7,$61,$c9), ($ed,$e1,$1c,$e5), ($3c,$7a,$47,$b1),
889 ($59,$9c,$d2,$df), ($3f,$55,$f2,$73), ($79,$18,$14,$ce), ($bf,$73,$c7,$37),
890 ($ea,$53,$f7,$cd), ($5b,$5f,$fd,$aa), ($14,$df,$3d,$6f), ($86,$78,$44,$db),
891 ($81,$ca,$af,$f3), ($3e,$b9,$68,$c4), ($2c,$38,$24,$34), ($5f,$c2,$a3,$40),
892 ($72,$16,$1d,$c3), ($0c,$bc,$e2,$25), ($8b,$28,$3c,$49), ($41,$ff,$0d,$95),
893 ($71,$39,$a8,$01), ($de,$08,$0c,$b3), ($9c,$d8,$b4,$e4), ($90,$64,$56,$c1),
894 ($61,$7b,$cb,$84), ($70,$d5,$32,$b6), ($74,$48,$6c,$5c), ($42,$d0,$b8,$57));
895 T7: array[0..255,0..3] of byte= (
896 ($a7,$50,$51,$f4), ($65,$53,$7e,$41), ($a4,$c3,$1a,$17), ($5e,$96,$3a,$27),
897 ($6b,$cb,$3b,$ab), ($45,$f1,$1f,$9d), ($58,$ab,$ac,$fa), ($03,$93,$4b,$e3),
898 ($fa,$55,$20,$30), ($6d,$f6,$ad,$76), ($76,$91,$88,$cc), ($4c,$25,$f5,$02),
899 ($d7,$fc,$4f,$e5), ($cb,$d7,$c5,$2a), ($44,$80,$26,$35), ($a3,$8f,$b5,$62),
900 ($5a,$49,$de,$b1), ($1b,$67,$25,$ba), ($0e,$98,$45,$ea), ($c0,$e1,$5d,$fe),
901 ($75,$02,$c3,$2f), ($f0,$12,$81,$4c), ($97,$a3,$8d,$46), ($f9,$c6,$6b,$d3),
902 ($5f,$e7,$03,$8f), ($9c,$95,$15,$92), ($7a,$eb,$bf,$6d), ($59,$da,$95,$52),
903 ($83,$2d,$d4,$be), ($21,$d3,$58,$74), ($69,$29,$49,$e0), ($c8,$44,$8e,$c9),
904 ($89,$6a,$75,$c2), ($79,$78,$f4,$8e), ($3e,$6b,$99,$58), ($71,$dd,$27,$b9),
905 ($4f,$b6,$be,$e1), ($ad,$17,$f0,$88), ($ac,$66,$c9,$20), ($3a,$b4,$7d,$ce),
906 ($4a,$18,$63,$df), ($31,$82,$e5,$1a), ($33,$60,$97,$51), ($7f,$45,$62,$53),
907 ($77,$e0,$b1,$64), ($ae,$84,$bb,$6b), ($a0,$1c,$fe,$81), ($2b,$94,$f9,$08),
908 ($68,$58,$70,$48), ($fd,$19,$8f,$45), ($6c,$87,$94,$de), ($f8,$b7,$52,$7b),
909 ($d3,$23,$ab,$73), ($02,$e2,$72,$4b), ($8f,$57,$e3,$1f), ($ab,$2a,$66,$55),
910 ($28,$07,$b2,$eb), ($c2,$03,$2f,$b5), ($7b,$9a,$86,$c5), ($08,$a5,$d3,$37),
911 ($87,$f2,$30,$28), ($a5,$b2,$23,$bf), ($6a,$ba,$02,$03), ($82,$5c,$ed,$16),
912 ($1c,$2b,$8a,$cf), ($b4,$92,$a7,$79), ($f2,$f0,$f3,$07), ($e2,$a1,$4e,$69),
913 ($f4,$cd,$65,$da), ($be,$d5,$06,$05), ($62,$1f,$d1,$34), ($fe,$8a,$c4,$a6),
914 ($53,$9d,$34,$2e), ($55,$a0,$a2,$f3), ($e1,$32,$05,$8a), ($eb,$75,$a4,$f6),
915 ($ec,$39,$0b,$83), ($ef,$aa,$40,$60), ($9f,$06,$5e,$71), ($10,$51,$bd,$6e),
916 ($8a,$f9,$3e,$21), ($06,$3d,$96,$dd), ($05,$ae,$dd,$3e), ($bd,$46,$4d,$e6),
917 ($8d,$b5,$91,$54), ($5d,$05,$71,$c4), ($d4,$6f,$04,$06), ($15,$ff,$60,$50),
918 ($fb,$24,$19,$98), ($e9,$97,$d6,$bd), ($43,$cc,$89,$40), ($9e,$77,$67,$d9),
919 ($42,$bd,$b0,$e8), ($8b,$88,$07,$89), ($5b,$38,$e7,$19), ($ee,$db,$79,$c8),
920 ($0a,$47,$a1,$7c), ($0f,$e9,$7c,$42), ($1e,$c9,$f8,$84), ($00,$00,$00,$00),
921 ($86,$83,$09,$80), ($ed,$48,$32,$2b), ($70,$ac,$1e,$11), ($72,$4e,$6c,$5a),
922 ($ff,$fb,$fd,$0e), ($38,$56,$0f,$85), ($d5,$1e,$3d,$ae), ($39,$27,$36,$2d),
923 ($d9,$64,$0a,$0f), ($a6,$21,$68,$5c), ($54,$d1,$9b,$5b), ($2e,$3a,$24,$36),
924 ($67,$b1,$0c,$0a), ($e7,$0f,$93,$57), ($96,$d2,$b4,$ee), ($91,$9e,$1b,$9b),
925 ($c5,$4f,$80,$c0), ($20,$a2,$61,$dc), ($4b,$69,$5a,$77), ($1a,$16,$1c,$12),
926 ($ba,$0a,$e2,$93), ($2a,$e5,$c0,$a0), ($e0,$43,$3c,$22), ($17,$1d,$12,$1b),
927 ($0d,$0b,$0e,$09), ($c7,$ad,$f2,$8b), ($a8,$b9,$2d,$b6), ($a9,$c8,$14,$1e),
928 ($19,$85,$57,$f1), ($07,$4c,$af,$75), ($dd,$bb,$ee,$99), ($60,$fd,$a3,$7f),
929 ($26,$9f,$f7,$01), ($f5,$bc,$5c,$72), ($3b,$c5,$44,$66), ($7e,$34,$5b,$fb),
930 ($29,$76,$8b,$43), ($c6,$dc,$cb,$23), ($fc,$68,$b6,$ed), ($f1,$63,$b8,$e4),
931 ($dc,$ca,$d7,$31), ($85,$10,$42,$63), ($22,$40,$13,$97), ($11,$20,$84,$c6),
932 ($24,$7d,$85,$4a), ($3d,$f8,$d2,$bb), ($32,$11,$ae,$f9), ($a1,$6d,$c7,$29),
933 ($2f,$4b,$1d,$9e), ($30,$f3,$dc,$b2), ($52,$ec,$0d,$86), ($e3,$d0,$77,$c1),
934 ($16,$6c,$2b,$b3), ($b9,$99,$a9,$70), ($48,$fa,$11,$94), ($64,$22,$47,$e9),
935 ($8c,$c4,$a8,$fc), ($3f,$1a,$a0,$f0), ($2c,$d8,$56,$7d), ($90,$ef,$22,$33),
936 ($4e,$c7,$87,$49), ($d1,$c1,$d9,$38), ($a2,$fe,$8c,$ca), ($0b,$36,$98,$d4),
937 ($81,$cf,$a6,$f5), ($de,$28,$a5,$7a), ($8e,$26,$da,$b7), ($bf,$a4,$3f,$ad),
938 ($9d,$e4,$2c,$3a), ($92,$0d,$50,$78), ($cc,$9b,$6a,$5f), ($46,$62,$54,$7e),
939 ($13,$c2,$f6,$8d), ($b8,$e8,$90,$d8), ($f7,$5e,$2e,$39), ($af,$f5,$82,$c3),
940 ($80,$be,$9f,$5d), ($93,$7c,$69,$d0), ($2d,$a9,$6f,$d5), ($12,$b3,$cf,$25),
941 ($99,$3b,$c8,$ac), ($7d,$a7,$10,$18), ($63,$6e,$e8,$9c), ($bb,$7b,$db,$3b),
942 ($78,$09,$cd,$26), ($18,$f4,$6e,$59), ($b7,$01,$ec,$9a), ($9a,$a8,$83,$4f),
943 ($6e,$65,$e6,$95), ($e6,$7e,$aa,$ff), ($cf,$08,$21,$bc), ($e8,$e6,$ef,$15),
944 ($9b,$d9,$ba,$e7), ($36,$ce,$4a,$6f), ($09,$d4,$ea,$9f), ($7c,$d6,$29,$b0),
945 ($b2,$af,$31,$a4), ($23,$31,$2a,$3f), ($94,$30,$c6,$a5), ($66,$c0,$35,$a2),
946 ($bc,$37,$74,$4e), ($ca,$a6,$fc,$82), ($d0,$b0,$e0,$90), ($d8,$15,$33,$a7),
947 ($98,$4a,$f1,$04), ($da,$f7,$41,$ec), ($50,$0e,$7f,$cd), ($f6,$2f,$17,$91),
948 ($d6,$8d,$76,$4d), ($b0,$4d,$43,$ef), ($4d,$54,$cc,$aa), ($04,$df,$e4,$96),
949 ($b5,$e3,$9e,$d1), ($88,$1b,$4c,$6a), ($1f,$b8,$c1,$2c), ($51,$7f,$46,$65),
950 ($ea,$04,$9d,$5e), ($35,$5d,$01,$8c), ($74,$73,$fa,$87), ($41,$2e,$fb,$0b),
951 ($1d,$5a,$b3,$67), ($d2,$52,$92,$db), ($56,$33,$e9,$10), ($47,$13,$6d,$d6),
952 ($61,$8c,$9a,$d7), ($0c,$7a,$37,$a1), ($14,$8e,$59,$f8), ($3c,$89,$eb,$13),
953 ($27,$ee,$ce,$a9), ($c9,$35,$b7,$61), ($e5,$ed,$e1,$1c), ($b1,$3c,$7a,$47),
954 ($df,$59,$9c,$d2), ($73,$3f,$55,$f2), ($ce,$79,$18,$14), ($37,$bf,$73,$c7),
955 ($cd,$ea,$53,$f7), ($aa,$5b,$5f,$fd), ($6f,$14,$df,$3d), ($db,$86,$78,$44),
956 ($f3,$81,$ca,$af), ($c4,$3e,$b9,$68), ($34,$2c,$38,$24), ($40,$5f,$c2,$a3),
957 ($c3,$72,$16,$1d), ($25,$0c,$bc,$e2), ($49,$8b,$28,$3c), ($95,$41,$ff,$0d),
958 ($01,$71,$39,$a8), ($b3,$de,$08,$0c), ($e4,$9c,$d8,$b4), ($c1,$90,$64,$56),
959 ($84,$61,$7b,$cb), ($b6,$70,$d5,$32), ($5c,$74,$48,$6c), ($57,$42,$d0,$b8));
960 T8: array[0..255,0..3] of byte= (
961 ($f4,$a7,$50,$51), ($41,$65,$53,$7e), ($17,$a4,$c3,$1a), ($27,$5e,$96,$3a),
962 ($ab,$6b,$cb,$3b), ($9d,$45,$f1,$1f), ($fa,$58,$ab,$ac), ($e3,$03,$93,$4b),
963 ($30,$fa,$55,$20), ($76,$6d,$f6,$ad), ($cc,$76,$91,$88), ($02,$4c,$25,$f5),
964 ($e5,$d7,$fc,$4f), ($2a,$cb,$d7,$c5), ($35,$44,$80,$26), ($62,$a3,$8f,$b5),
965 ($b1,$5a,$49,$de), ($ba,$1b,$67,$25), ($ea,$0e,$98,$45), ($fe,$c0,$e1,$5d),
966 ($2f,$75,$02,$c3), ($4c,$f0,$12,$81), ($46,$97,$a3,$8d), ($d3,$f9,$c6,$6b),
967 ($8f,$5f,$e7,$03), ($92,$9c,$95,$15), ($6d,$7a,$eb,$bf), ($52,$59,$da,$95),
968 ($be,$83,$2d,$d4), ($74,$21,$d3,$58), ($e0,$69,$29,$49), ($c9,$c8,$44,$8e),
969 ($c2,$89,$6a,$75), ($8e,$79,$78,$f4), ($58,$3e,$6b,$99), ($b9,$71,$dd,$27),
970 ($e1,$4f,$b6,$be), ($88,$ad,$17,$f0), ($20,$ac,$66,$c9), ($ce,$3a,$b4,$7d),
971 ($df,$4a,$18,$63), ($1a,$31,$82,$e5), ($51,$33,$60,$97), ($53,$7f,$45,$62),
972 ($64,$77,$e0,$b1), ($6b,$ae,$84,$bb), ($81,$a0,$1c,$fe), ($08,$2b,$94,$f9),
973 ($48,$68,$58,$70), ($45,$fd,$19,$8f), ($de,$6c,$87,$94), ($7b,$f8,$b7,$52),
974 ($73,$d3,$23,$ab), ($4b,$02,$e2,$72), ($1f,$8f,$57,$e3), ($55,$ab,$2a,$66),
975 ($eb,$28,$07,$b2), ($b5,$c2,$03,$2f), ($c5,$7b,$9a,$86), ($37,$08,$a5,$d3),
976 ($28,$87,$f2,$30), ($bf,$a5,$b2,$23), ($03,$6a,$ba,$02), ($16,$82,$5c,$ed),
977 ($cf,$1c,$2b,$8a), ($79,$b4,$92,$a7), ($07,$f2,$f0,$f3), ($69,$e2,$a1,$4e),
978 ($da,$f4,$cd,$65), ($05,$be,$d5,$06), ($34,$62,$1f,$d1), ($a6,$fe,$8a,$c4),
979 ($2e,$53,$9d,$34), ($f3,$55,$a0,$a2), ($8a,$e1,$32,$05), ($f6,$eb,$75,$a4),
980 ($83,$ec,$39,$0b), ($60,$ef,$aa,$40), ($71,$9f,$06,$5e), ($6e,$10,$51,$bd),
981 ($21,$8a,$f9,$3e), ($dd,$06,$3d,$96), ($3e,$05,$ae,$dd), ($e6,$bd,$46,$4d),
982 ($54,$8d,$b5,$91), ($c4,$5d,$05,$71), ($06,$d4,$6f,$04), ($50,$15,$ff,$60),
983 ($98,$fb,$24,$19), ($bd,$e9,$97,$d6), ($40,$43,$cc,$89), ($d9,$9e,$77,$67),
984 ($e8,$42,$bd,$b0), ($89,$8b,$88,$07), ($19,$5b,$38,$e7), ($c8,$ee,$db,$79),
985 ($7c,$0a,$47,$a1), ($42,$0f,$e9,$7c), ($84,$1e,$c9,$f8), ($00,$00,$00,$00),
986 ($80,$86,$83,$09), ($2b,$ed,$48,$32), ($11,$70,$ac,$1e), ($5a,$72,$4e,$6c),
987 ($0e,$ff,$fb,$fd), ($85,$38,$56,$0f), ($ae,$d5,$1e,$3d), ($2d,$39,$27,$36),
988 ($0f,$d9,$64,$0a), ($5c,$a6,$21,$68), ($5b,$54,$d1,$9b), ($36,$2e,$3a,$24),
989 ($0a,$67,$b1,$0c), ($57,$e7,$0f,$93), ($ee,$96,$d2,$b4), ($9b,$91,$9e,$1b),
990 ($c0,$c5,$4f,$80), ($dc,$20,$a2,$61), ($77,$4b,$69,$5a), ($12,$1a,$16,$1c),
991 ($93,$ba,$0a,$e2), ($a0,$2a,$e5,$c0), ($22,$e0,$43,$3c), ($1b,$17,$1d,$12),
992 ($09,$0d,$0b,$0e), ($8b,$c7,$ad,$f2), ($b6,$a8,$b9,$2d), ($1e,$a9,$c8,$14),
993 ($f1,$19,$85,$57), ($75,$07,$4c,$af), ($99,$dd,$bb,$ee), ($7f,$60,$fd,$a3),
994 ($01,$26,$9f,$f7), ($72,$f5,$bc,$5c), ($66,$3b,$c5,$44), ($fb,$7e,$34,$5b),
995 ($43,$29,$76,$8b), ($23,$c6,$dc,$cb), ($ed,$fc,$68,$b6), ($e4,$f1,$63,$b8),
996 ($31,$dc,$ca,$d7), ($63,$85,$10,$42), ($97,$22,$40,$13), ($c6,$11,$20,$84),
997 ($4a,$24,$7d,$85), ($bb,$3d,$f8,$d2), ($f9,$32,$11,$ae), ($29,$a1,$6d,$c7),
998 ($9e,$2f,$4b,$1d), ($b2,$30,$f3,$dc), ($86,$52,$ec,$0d), ($c1,$e3,$d0,$77),
999 ($b3,$16,$6c,$2b), ($70,$b9,$99,$a9), ($94,$48,$fa,$11), ($e9,$64,$22,$47),
1000 ($fc,$8c,$c4,$a8), ($f0,$3f,$1a,$a0), ($7d,$2c,$d8,$56), ($33,$90,$ef,$22),
1001 ($49,$4e,$c7,$87), ($38,$d1,$c1,$d9), ($ca,$a2,$fe,$8c), ($d4,$0b,$36,$98),
1002 ($f5,$81,$cf,$a6), ($7a,$de,$28,$a5), ($b7,$8e,$26,$da), ($ad,$bf,$a4,$3f),
1003 ($3a,$9d,$e4,$2c), ($78,$92,$0d,$50), ($5f,$cc,$9b,$6a), ($7e,$46,$62,$54),
1004 ($8d,$13,$c2,$f6), ($d8,$b8,$e8,$90), ($39,$f7,$5e,$2e), ($c3,$af,$f5,$82),
1005 ($5d,$80,$be,$9f), ($d0,$93,$7c,$69), ($d5,$2d,$a9,$6f), ($25,$12,$b3,$cf),
1006 ($ac,$99,$3b,$c8), ($18,$7d,$a7,$10), ($9c,$63,$6e,$e8), ($3b,$bb,$7b,$db),
1007 ($26,$78,$09,$cd), ($59,$18,$f4,$6e), ($9a,$b7,$01,$ec), ($4f,$9a,$a8,$83),
1008 ($95,$6e,$65,$e6), ($ff,$e6,$7e,$aa), ($bc,$cf,$08,$21), ($15,$e8,$e6,$ef),
1009 ($e7,$9b,$d9,$ba), ($6f,$36,$ce,$4a), ($9f,$09,$d4,$ea), ($b0,$7c,$d6,$29),
1010 ($a4,$b2,$af,$31), ($3f,$23,$31,$2a), ($a5,$94,$30,$c6), ($a2,$66,$c0,$35),
1011 ($4e,$bc,$37,$74), ($82,$ca,$a6,$fc), ($90,$d0,$b0,$e0), ($a7,$d8,$15,$33),
1012 ($04,$98,$4a,$f1), ($ec,$da,$f7,$41), ($cd,$50,$0e,$7f), ($91,$f6,$2f,$17),
1013 ($4d,$d6,$8d,$76), ($ef,$b0,$4d,$43), ($aa,$4d,$54,$cc), ($96,$04,$df,$e4),
1014 ($d1,$b5,$e3,$9e), ($6a,$88,$1b,$4c), ($2c,$1f,$b8,$c1), ($65,$51,$7f,$46),
1015 ($5e,$ea,$04,$9d), ($8c,$35,$5d,$01), ($87,$74,$73,$fa), ($0b,$41,$2e,$fb),
1016 ($67,$1d,$5a,$b3), ($db,$d2,$52,$92), ($10,$56,$33,$e9), ($d6,$47,$13,$6d),
1017 ($d7,$61,$8c,$9a), ($a1,$0c,$7a,$37), ($f8,$14,$8e,$59), ($13,$3c,$89,$eb),
1018 ($a9,$27,$ee,$ce), ($61,$c9,$35,$b7), ($1c,$e5,$ed,$e1), ($47,$b1,$3c,$7a),
1019 ($d2,$df,$59,$9c), ($f2,$73,$3f,$55), ($14,$ce,$79,$18), ($c7,$37,$bf,$73),
1020 ($f7,$cd,$ea,$53), ($fd,$aa,$5b,$5f), ($3d,$6f,$14,$df), ($44,$db,$86,$78),
1021 ($af,$f3,$81,$ca), ($68,$c4,$3e,$b9), ($24,$34,$2c,$38), ($a3,$40,$5f,$c2),
1022 ($1d,$c3,$72,$16), ($e2,$25,$0c,$bc), ($3c,$49,$8b,$28), ($0d,$95,$41,$ff),
1023 ($a8,$01,$71,$39), ($0c,$b3,$de,$08), ($b4,$e4,$9c,$d8), ($56,$c1,$90,$64),
1024 ($cb,$84,$61,$7b), ($32,$b6,$70,$d5), ($6c,$5c,$74,$48), ($b8,$57,$42,$d0));
1025 S5: array[0..255] of byte= (
1026 $52,$09,$6a,$d5,
1027 $30,$36,$a5,$38,
1028 $bf,$40,$a3,$9e,
1029 $81,$f3,$d7,$fb,
1030 $7c,$e3,$39,$82,
1031 $9b,$2f,$ff,$87,
1032 $34,$8e,$43,$44,
1033 $c4,$de,$e9,$cb,
1034 $54,$7b,$94,$32,
1035 $a6,$c2,$23,$3d,
1036 $ee,$4c,$95,$0b,
1037 $42,$fa,$c3,$4e,
1038 $08,$2e,$a1,$66,
1039 $28,$d9,$24,$b2,
1040 $76,$5b,$a2,$49,
1041 $6d,$8b,$d1,$25,
1042 $72,$f8,$f6,$64,
1043 $86,$68,$98,$16,
1044 $d4,$a4,$5c,$cc,
1045 $5d,$65,$b6,$92,
1046 $6c,$70,$48,$50,
1047 $fd,$ed,$b9,$da,
1048 $5e,$15,$46,$57,
1049 $a7,$8d,$9d,$84,
1050 $90,$d8,$ab,$00,
1051 $8c,$bc,$d3,$0a,
1052 $f7,$e4,$58,$05,
1053 $b8,$b3,$45,$06,
1054 $d0,$2c,$1e,$8f,
1055 $ca,$3f,$0f,$02,
1056 $c1,$af,$bd,$03,
1057 $01,$13,$8a,$6b,
1058 $3a,$91,$11,$41,
1059 $4f,$67,$dc,$ea,
1060 $97,$f2,$cf,$ce,
1061 $f0,$b4,$e6,$73,
1062 $96,$ac,$74,$22,
1063 $e7,$ad,$35,$85,
1064 $e2,$f9,$37,$e8,
1065 $1c,$75,$df,$6e,
1066 $47,$f1,$1a,$71,
1067 $1d,$29,$c5,$89,
1068 $6f,$b7,$62,$0e,
1069 $aa,$18,$be,$1b,
1070 $fc,$56,$3e,$4b,
1071 $c6,$d2,$79,$20,
1072 $9a,$db,$c0,$fe,
1073 $78,$cd,$5a,$f4,
1074 $1f,$dd,$a8,$33,
1075 $88,$07,$c7,$31,
1076 $b1,$12,$10,$59,
1077 $27,$80,$ec,$5f,
1078 $60,$51,$7f,$a9,
1079 $19,$b5,$4a,$0d,
1080 $2d,$e5,$7a,$9f,
1081 $93,$c9,$9c,$ef,
1082 $a0,$e0,$3b,$4d,
1083 $ae,$2a,$f5,$b0,
1084 $c8,$eb,$bb,$3c,
1085 $83,$53,$99,$61,
1086 $17,$2b,$04,$7e,
1087 $ba,$77,$d6,$26,
1088 $e1,$69,$14,$63,
1089 $55,$21,$0c,$7d);
1090 U1: array[0..255,0..3] of byte= (
1091 ($00,$00,$00,$00), ($0e,$09,$0d,$0b), ($1c,$12,$1a,$16), ($12,$1b,$17,$1d),
1092 ($38,$24,$34,$2c), ($36,$2d,$39,$27), ($24,$36,$2e,$3a), ($2a,$3f,$23,$31),
1093 ($70,$48,$68,$58), ($7e,$41,$65,$53), ($6c,$5a,$72,$4e), ($62,$53,$7f,$45),
1094 ($48,$6c,$5c,$74), ($46,$65,$51,$7f), ($54,$7e,$46,$62), ($5a,$77,$4b,$69),
1095 ($e0,$90,$d0,$b0), ($ee,$99,$dd,$bb), ($fc,$82,$ca,$a6), ($f2,$8b,$c7,$ad),
1096 ($d8,$b4,$e4,$9c), ($d6,$bd,$e9,$97), ($c4,$a6,$fe,$8a), ($ca,$af,$f3,$81),
1097 ($90,$d8,$b8,$e8), ($9e,$d1,$b5,$e3), ($8c,$ca,$a2,$fe), ($82,$c3,$af,$f5),
1098 ($a8,$fc,$8c,$c4), ($a6,$f5,$81,$cf), ($b4,$ee,$96,$d2), ($ba,$e7,$9b,$d9),
1099 ($db,$3b,$bb,$7b), ($d5,$32,$b6,$70), ($c7,$29,$a1,$6d), ($c9,$20,$ac,$66),
1100 ($e3,$1f,$8f,$57), ($ed,$16,$82,$5c), ($ff,$0d,$95,$41), ($f1,$04,$98,$4a),
1101 ($ab,$73,$d3,$23), ($a5,$7a,$de,$28), ($b7,$61,$c9,$35), ($b9,$68,$c4,$3e),
1102 ($93,$57,$e7,$0f), ($9d,$5e,$ea,$04), ($8f,$45,$fd,$19), ($81,$4c,$f0,$12),
1103 ($3b,$ab,$6b,$cb), ($35,$a2,$66,$c0), ($27,$b9,$71,$dd), ($29,$b0,$7c,$d6),
1104 ($03,$8f,$5f,$e7), ($0d,$86,$52,$ec), ($1f,$9d,$45,$f1), ($11,$94,$48,$fa),
1105 ($4b,$e3,$03,$93), ($45,$ea,$0e,$98), ($57,$f1,$19,$85), ($59,$f8,$14,$8e),
1106 ($73,$c7,$37,$bf), ($7d,$ce,$3a,$b4), ($6f,$d5,$2d,$a9), ($61,$dc,$20,$a2),
1107 ($ad,$76,$6d,$f6), ($a3,$7f,$60,$fd), ($b1,$64,$77,$e0), ($bf,$6d,$7a,$eb),
1108 ($95,$52,$59,$da), ($9b,$5b,$54,$d1), ($89,$40,$43,$cc), ($87,$49,$4e,$c7),
1109 ($dd,$3e,$05,$ae), ($d3,$37,$08,$a5), ($c1,$2c,$1f,$b8), ($cf,$25,$12,$b3),
1110 ($e5,$1a,$31,$82), ($eb,$13,$3c,$89), ($f9,$08,$2b,$94), ($f7,$01,$26,$9f),
1111 ($4d,$e6,$bd,$46), ($43,$ef,$b0,$4d), ($51,$f4,$a7,$50), ($5f,$fd,$aa,$5b),
1112 ($75,$c2,$89,$6a), ($7b,$cb,$84,$61), ($69,$d0,$93,$7c), ($67,$d9,$9e,$77),
1113 ($3d,$ae,$d5,$1e), ($33,$a7,$d8,$15), ($21,$bc,$cf,$08), ($2f,$b5,$c2,$03),
1114 ($05,$8a,$e1,$32), ($0b,$83,$ec,$39), ($19,$98,$fb,$24), ($17,$91,$f6,$2f),
1115 ($76,$4d,$d6,$8d), ($78,$44,$db,$86), ($6a,$5f,$cc,$9b), ($64,$56,$c1,$90),
1116 ($4e,$69,$e2,$a1), ($40,$60,$ef,$aa), ($52,$7b,$f8,$b7), ($5c,$72,$f5,$bc),
1117 ($06,$05,$be,$d5), ($08,$0c,$b3,$de), ($1a,$17,$a4,$c3), ($14,$1e,$a9,$c8),
1118 ($3e,$21,$8a,$f9), ($30,$28,$87,$f2), ($22,$33,$90,$ef), ($2c,$3a,$9d,$e4),
1119 ($96,$dd,$06,$3d), ($98,$d4,$0b,$36), ($8a,$cf,$1c,$2b), ($84,$c6,$11,$20),
1120 ($ae,$f9,$32,$11), ($a0,$f0,$3f,$1a), ($b2,$eb,$28,$07), ($bc,$e2,$25,$0c),
1121 ($e6,$95,$6e,$65), ($e8,$9c,$63,$6e), ($fa,$87,$74,$73), ($f4,$8e,$79,$78),
1122 ($de,$b1,$5a,$49), ($d0,$b8,$57,$42), ($c2,$a3,$40,$5f), ($cc,$aa,$4d,$54),
1123 ($41,$ec,$da,$f7), ($4f,$e5,$d7,$fc), ($5d,$fe,$c0,$e1), ($53,$f7,$cd,$ea),
1124 ($79,$c8,$ee,$db), ($77,$c1,$e3,$d0), ($65,$da,$f4,$cd), ($6b,$d3,$f9,$c6),
1125 ($31,$a4,$b2,$af), ($3f,$ad,$bf,$a4), ($2d,$b6,$a8,$b9), ($23,$bf,$a5,$b2),
1126 ($09,$80,$86,$83), ($07,$89,$8b,$88), ($15,$92,$9c,$95), ($1b,$9b,$91,$9e),
1127 ($a1,$7c,$0a,$47), ($af,$75,$07,$4c), ($bd,$6e,$10,$51), ($b3,$67,$1d,$5a),
1128 ($99,$58,$3e,$6b), ($97,$51,$33,$60), ($85,$4a,$24,$7d), ($8b,$43,$29,$76),
1129 ($d1,$34,$62,$1f), ($df,$3d,$6f,$14), ($cd,$26,$78,$09), ($c3,$2f,$75,$02),
1130 ($e9,$10,$56,$33), ($e7,$19,$5b,$38), ($f5,$02,$4c,$25), ($fb,$0b,$41,$2e),
1131 ($9a,$d7,$61,$8c), ($94,$de,$6c,$87), ($86,$c5,$7b,$9a), ($88,$cc,$76,$91),
1132 ($a2,$f3,$55,$a0), ($ac,$fa,$58,$ab), ($be,$e1,$4f,$b6), ($b0,$e8,$42,$bd),
1133 ($ea,$9f,$09,$d4), ($e4,$96,$04,$df), ($f6,$8d,$13,$c2), ($f8,$84,$1e,$c9),
1134 ($d2,$bb,$3d,$f8), ($dc,$b2,$30,$f3), ($ce,$a9,$27,$ee), ($c0,$a0,$2a,$e5),
1135 ($7a,$47,$b1,$3c), ($74,$4e,$bc,$37), ($66,$55,$ab,$2a), ($68,$5c,$a6,$21),
1136 ($42,$63,$85,$10), ($4c,$6a,$88,$1b), ($5e,$71,$9f,$06), ($50,$78,$92,$0d),
1137 ($0a,$0f,$d9,$64), ($04,$06,$d4,$6f), ($16,$1d,$c3,$72), ($18,$14,$ce,$79),
1138 ($32,$2b,$ed,$48), ($3c,$22,$e0,$43), ($2e,$39,$f7,$5e), ($20,$30,$fa,$55),
1139 ($ec,$9a,$b7,$01), ($e2,$93,$ba,$0a), ($f0,$88,$ad,$17), ($fe,$81,$a0,$1c),
1140 ($d4,$be,$83,$2d), ($da,$b7,$8e,$26), ($c8,$ac,$99,$3b), ($c6,$a5,$94,$30),
1141 ($9c,$d2,$df,$59), ($92,$db,$d2,$52), ($80,$c0,$c5,$4f), ($8e,$c9,$c8,$44),
1142 ($a4,$f6,$eb,$75), ($aa,$ff,$e6,$7e), ($b8,$e4,$f1,$63), ($b6,$ed,$fc,$68),
1143 ($0c,$0a,$67,$b1), ($02,$03,$6a,$ba), ($10,$18,$7d,$a7), ($1e,$11,$70,$ac),
1144 ($34,$2e,$53,$9d), ($3a,$27,$5e,$96), ($28,$3c,$49,$8b), ($26,$35,$44,$80),
1145 ($7c,$42,$0f,$e9), ($72,$4b,$02,$e2), ($60,$50,$15,$ff), ($6e,$59,$18,$f4),
1146 ($44,$66,$3b,$c5), ($4a,$6f,$36,$ce), ($58,$74,$21,$d3), ($56,$7d,$2c,$d8),
1147 ($37,$a1,$0c,$7a), ($39,$a8,$01,$71), ($2b,$b3,$16,$6c), ($25,$ba,$1b,$67),
1148 ($0f,$85,$38,$56), ($01,$8c,$35,$5d), ($13,$97,$22,$40), ($1d,$9e,$2f,$4b),
1149 ($47,$e9,$64,$22), ($49,$e0,$69,$29), ($5b,$fb,$7e,$34), ($55,$f2,$73,$3f),
1150 ($7f,$cd,$50,$0e), ($71,$c4,$5d,$05), ($63,$df,$4a,$18), ($6d,$d6,$47,$13),
1151 ($d7,$31,$dc,$ca), ($d9,$38,$d1,$c1), ($cb,$23,$c6,$dc), ($c5,$2a,$cb,$d7),
1152 ($ef,$15,$e8,$e6), ($e1,$1c,$e5,$ed), ($f3,$07,$f2,$f0), ($fd,$0e,$ff,$fb),
1153 ($a7,$79,$b4,$92), ($a9,$70,$b9,$99), ($bb,$6b,$ae,$84), ($b5,$62,$a3,$8f),
1154 ($9f,$5d,$80,$be), ($91,$54,$8d,$b5), ($83,$4f,$9a,$a8), ($8d,$46,$97,$a3));
1155 U2: array[0..255,0..3] of byte= (
1156 ($00,$00,$00,$00), ($0b,$0e,$09,$0d), ($16,$1c,$12,$1a), ($1d,$12,$1b,$17),
1157 ($2c,$38,$24,$34), ($27,$36,$2d,$39), ($3a,$24,$36,$2e), ($31,$2a,$3f,$23),
1158 ($58,$70,$48,$68), ($53,$7e,$41,$65), ($4e,$6c,$5a,$72), ($45,$62,$53,$7f),
1159 ($74,$48,$6c,$5c), ($7f,$46,$65,$51), ($62,$54,$7e,$46), ($69,$5a,$77,$4b),
1160 ($b0,$e0,$90,$d0), ($bb,$ee,$99,$dd), ($a6,$fc,$82,$ca), ($ad,$f2,$8b,$c7),
1161 ($9c,$d8,$b4,$e4), ($97,$d6,$bd,$e9), ($8a,$c4,$a6,$fe), ($81,$ca,$af,$f3),
1162 ($e8,$90,$d8,$b8), ($e3,$9e,$d1,$b5), ($fe,$8c,$ca,$a2), ($f5,$82,$c3,$af),
1163 ($c4,$a8,$fc,$8c), ($cf,$a6,$f5,$81), ($d2,$b4,$ee,$96), ($d9,$ba,$e7,$9b),
1164 ($7b,$db,$3b,$bb), ($70,$d5,$32,$b6), ($6d,$c7,$29,$a1), ($66,$c9,$20,$ac),
1165 ($57,$e3,$1f,$8f), ($5c,$ed,$16,$82), ($41,$ff,$0d,$95), ($4a,$f1,$04,$98),
1166 ($23,$ab,$73,$d3), ($28,$a5,$7a,$de), ($35,$b7,$61,$c9), ($3e,$b9,$68,$c4),
1167 ($0f,$93,$57,$e7), ($04,$9d,$5e,$ea), ($19,$8f,$45,$fd), ($12,$81,$4c,$f0),
1168 ($cb,$3b,$ab,$6b), ($c0,$35,$a2,$66), ($dd,$27,$b9,$71), ($d6,$29,$b0,$7c),
1169 ($e7,$03,$8f,$5f), ($ec,$0d,$86,$52), ($f1,$1f,$9d,$45), ($fa,$11,$94,$48),
1170 ($93,$4b,$e3,$03), ($98,$45,$ea,$0e), ($85,$57,$f1,$19), ($8e,$59,$f8,$14),
1171 ($bf,$73,$c7,$37), ($b4,$7d,$ce,$3a), ($a9,$6f,$d5,$2d), ($a2,$61,$dc,$20),
1172 ($f6,$ad,$76,$6d), ($fd,$a3,$7f,$60), ($e0,$b1,$64,$77), ($eb,$bf,$6d,$7a),
1173 ($da,$95,$52,$59), ($d1,$9b,$5b,$54), ($cc,$89,$40,$43), ($c7,$87,$49,$4e),
1174 ($ae,$dd,$3e,$05), ($a5,$d3,$37,$08), ($b8,$c1,$2c,$1f), ($b3,$cf,$25,$12),
1175 ($82,$e5,$1a,$31), ($89,$eb,$13,$3c), ($94,$f9,$08,$2b), ($9f,$f7,$01,$26),
1176 ($46,$4d,$e6,$bd), ($4d,$43,$ef,$b0), ($50,$51,$f4,$a7), ($5b,$5f,$fd,$aa),
1177 ($6a,$75,$c2,$89), ($61,$7b,$cb,$84), ($7c,$69,$d0,$93), ($77,$67,$d9,$9e),
1178 ($1e,$3d,$ae,$d5), ($15,$33,$a7,$d8), ($08,$21,$bc,$cf), ($03,$2f,$b5,$c2),
1179 ($32,$05,$8a,$e1), ($39,$0b,$83,$ec), ($24,$19,$98,$fb), ($2f,$17,$91,$f6),
1180 ($8d,$76,$4d,$d6), ($86,$78,$44,$db), ($9b,$6a,$5f,$cc), ($90,$64,$56,$c1),
1181 ($a1,$4e,$69,$e2), ($aa,$40,$60,$ef), ($b7,$52,$7b,$f8), ($bc,$5c,$72,$f5),
1182 ($d5,$06,$05,$be), ($de,$08,$0c,$b3), ($c3,$1a,$17,$a4), ($c8,$14,$1e,$a9),
1183 ($f9,$3e,$21,$8a), ($f2,$30,$28,$87), ($ef,$22,$33,$90), ($e4,$2c,$3a,$9d),
1184 ($3d,$96,$dd,$06), ($36,$98,$d4,$0b), ($2b,$8a,$cf,$1c), ($20,$84,$c6,$11),
1185 ($11,$ae,$f9,$32), ($1a,$a0,$f0,$3f), ($07,$b2,$eb,$28), ($0c,$bc,$e2,$25),
1186 ($65,$e6,$95,$6e), ($6e,$e8,$9c,$63), ($73,$fa,$87,$74), ($78,$f4,$8e,$79),
1187 ($49,$de,$b1,$5a), ($42,$d0,$b8,$57), ($5f,$c2,$a3,$40), ($54,$cc,$aa,$4d),
1188 ($f7,$41,$ec,$da), ($fc,$4f,$e5,$d7), ($e1,$5d,$fe,$c0), ($ea,$53,$f7,$cd),
1189 ($db,$79,$c8,$ee), ($d0,$77,$c1,$e3), ($cd,$65,$da,$f4), ($c6,$6b,$d3,$f9),
1190 ($af,$31,$a4,$b2), ($a4,$3f,$ad,$bf), ($b9,$2d,$b6,$a8), ($b2,$23,$bf,$a5),
1191 ($83,$09,$80,$86), ($88,$07,$89,$8b), ($95,$15,$92,$9c), ($9e,$1b,$9b,$91),
1192 ($47,$a1,$7c,$0a), ($4c,$af,$75,$07), ($51,$bd,$6e,$10), ($5a,$b3,$67,$1d),
1193 ($6b,$99,$58,$3e), ($60,$97,$51,$33), ($7d,$85,$4a,$24), ($76,$8b,$43,$29),
1194 ($1f,$d1,$34,$62), ($14,$df,$3d,$6f), ($09,$cd,$26,$78), ($02,$c3,$2f,$75),
1195 ($33,$e9,$10,$56), ($38,$e7,$19,$5b), ($25,$f5,$02,$4c), ($2e,$fb,$0b,$41),
1196 ($8c,$9a,$d7,$61), ($87,$94,$de,$6c), ($9a,$86,$c5,$7b), ($91,$88,$cc,$76),
1197 ($a0,$a2,$f3,$55), ($ab,$ac,$fa,$58), ($b6,$be,$e1,$4f), ($bd,$b0,$e8,$42),
1198 ($d4,$ea,$9f,$09), ($df,$e4,$96,$04), ($c2,$f6,$8d,$13), ($c9,$f8,$84,$1e),
1199 ($f8,$d2,$bb,$3d), ($f3,$dc,$b2,$30), ($ee,$ce,$a9,$27), ($e5,$c0,$a0,$2a),
1200 ($3c,$7a,$47,$b1), ($37,$74,$4e,$bc), ($2a,$66,$55,$ab), ($21,$68,$5c,$a6),
1201 ($10,$42,$63,$85), ($1b,$4c,$6a,$88), ($06,$5e,$71,$9f), ($0d,$50,$78,$92),
1202 ($64,$0a,$0f,$d9), ($6f,$04,$06,$d4), ($72,$16,$1d,$c3), ($79,$18,$14,$ce),
1203 ($48,$32,$2b,$ed), ($43,$3c,$22,$e0), ($5e,$2e,$39,$f7), ($55,$20,$30,$fa),
1204 ($01,$ec,$9a,$b7), ($0a,$e2,$93,$ba), ($17,$f0,$88,$ad), ($1c,$fe,$81,$a0),
1205 ($2d,$d4,$be,$83), ($26,$da,$b7,$8e), ($3b,$c8,$ac,$99), ($30,$c6,$a5,$94),
1206 ($59,$9c,$d2,$df), ($52,$92,$db,$d2), ($4f,$80,$c0,$c5), ($44,$8e,$c9,$c8),
1207 ($75,$a4,$f6,$eb), ($7e,$aa,$ff,$e6), ($63,$b8,$e4,$f1), ($68,$b6,$ed,$fc),
1208 ($b1,$0c,$0a,$67), ($ba,$02,$03,$6a), ($a7,$10,$18,$7d), ($ac,$1e,$11,$70),
1209 ($9d,$34,$2e,$53), ($96,$3a,$27,$5e), ($8b,$28,$3c,$49), ($80,$26,$35,$44),
1210 ($e9,$7c,$42,$0f), ($e2,$72,$4b,$02), ($ff,$60,$50,$15), ($f4,$6e,$59,$18),
1211 ($c5,$44,$66,$3b), ($ce,$4a,$6f,$36), ($d3,$58,$74,$21), ($d8,$56,$7d,$2c),
1212 ($7a,$37,$a1,$0c), ($71,$39,$a8,$01), ($6c,$2b,$b3,$16), ($67,$25,$ba,$1b),
1213 ($56,$0f,$85,$38), ($5d,$01,$8c,$35), ($40,$13,$97,$22), ($4b,$1d,$9e,$2f),
1214 ($22,$47,$e9,$64), ($29,$49,$e0,$69), ($34,$5b,$fb,$7e), ($3f,$55,$f2,$73),
1215 ($0e,$7f,$cd,$50), ($05,$71,$c4,$5d), ($18,$63,$df,$4a), ($13,$6d,$d6,$47),
1216 ($ca,$d7,$31,$dc), ($c1,$d9,$38,$d1), ($dc,$cb,$23,$c6), ($d7,$c5,$2a,$cb),
1217 ($e6,$ef,$15,$e8), ($ed,$e1,$1c,$e5), ($f0,$f3,$07,$f2), ($fb,$fd,$0e,$ff),
1218 ($92,$a7,$79,$b4), ($99,$a9,$70,$b9), ($84,$bb,$6b,$ae), ($8f,$b5,$62,$a3),
1219 ($be,$9f,$5d,$80), ($b5,$91,$54,$8d), ($a8,$83,$4f,$9a), ($a3,$8d,$46,$97));
1220 U3: array[0..255,0..3] of byte= (
1221 ($00,$00,$00,$00), ($0d,$0b,$0e,$09), ($1a,$16,$1c,$12), ($17,$1d,$12,$1b),
1222 ($34,$2c,$38,$24), ($39,$27,$36,$2d), ($2e,$3a,$24,$36), ($23,$31,$2a,$3f),
1223 ($68,$58,$70,$48), ($65,$53,$7e,$41), ($72,$4e,$6c,$5a), ($7f,$45,$62,$53),
1224 ($5c,$74,$48,$6c), ($51,$7f,$46,$65), ($46,$62,$54,$7e), ($4b,$69,$5a,$77),
1225 ($d0,$b0,$e0,$90), ($dd,$bb,$ee,$99), ($ca,$a6,$fc,$82), ($c7,$ad,$f2,$8b),
1226 ($e4,$9c,$d8,$b4), ($e9,$97,$d6,$bd), ($fe,$8a,$c4,$a6), ($f3,$81,$ca,$af),
1227 ($b8,$e8,$90,$d8), ($b5,$e3,$9e,$d1), ($a2,$fe,$8c,$ca), ($af,$f5,$82,$c3),
1228 ($8c,$c4,$a8,$fc), ($81,$cf,$a6,$f5), ($96,$d2,$b4,$ee), ($9b,$d9,$ba,$e7),
1229 ($bb,$7b,$db,$3b), ($b6,$70,$d5,$32), ($a1,$6d,$c7,$29), ($ac,$66,$c9,$20),
1230 ($8f,$57,$e3,$1f), ($82,$5c,$ed,$16), ($95,$41,$ff,$0d), ($98,$4a,$f1,$04),
1231 ($d3,$23,$ab,$73), ($de,$28,$a5,$7a), ($c9,$35,$b7,$61), ($c4,$3e,$b9,$68),
1232 ($e7,$0f,$93,$57), ($ea,$04,$9d,$5e), ($fd,$19,$8f,$45), ($f0,$12,$81,$4c),
1233 ($6b,$cb,$3b,$ab), ($66,$c0,$35,$a2), ($71,$dd,$27,$b9), ($7c,$d6,$29,$b0),
1234 ($5f,$e7,$03,$8f), ($52,$ec,$0d,$86), ($45,$f1,$1f,$9d), ($48,$fa,$11,$94),
1235 ($03,$93,$4b,$e3), ($0e,$98,$45,$ea), ($19,$85,$57,$f1), ($14,$8e,$59,$f8),
1236 ($37,$bf,$73,$c7), ($3a,$b4,$7d,$ce), ($2d,$a9,$6f,$d5), ($20,$a2,$61,$dc),
1237 ($6d,$f6,$ad,$76), ($60,$fd,$a3,$7f), ($77,$e0,$b1,$64), ($7a,$eb,$bf,$6d),
1238 ($59,$da,$95,$52), ($54,$d1,$9b,$5b), ($43,$cc,$89,$40), ($4e,$c7,$87,$49),
1239 ($05,$ae,$dd,$3e), ($08,$a5,$d3,$37), ($1f,$b8,$c1,$2c), ($12,$b3,$cf,$25),
1240 ($31,$82,$e5,$1a), ($3c,$89,$eb,$13), ($2b,$94,$f9,$08), ($26,$9f,$f7,$01),
1241 ($bd,$46,$4d,$e6), ($b0,$4d,$43,$ef), ($a7,$50,$51,$f4), ($aa,$5b,$5f,$fd),
1242 ($89,$6a,$75,$c2), ($84,$61,$7b,$cb), ($93,$7c,$69,$d0), ($9e,$77,$67,$d9),
1243 ($d5,$1e,$3d,$ae), ($d8,$15,$33,$a7), ($cf,$08,$21,$bc), ($c2,$03,$2f,$b5),
1244 ($e1,$32,$05,$8a), ($ec,$39,$0b,$83), ($fb,$24,$19,$98), ($f6,$2f,$17,$91),
1245 ($d6,$8d,$76,$4d), ($db,$86,$78,$44), ($cc,$9b,$6a,$5f), ($c1,$90,$64,$56),
1246 ($e2,$a1,$4e,$69), ($ef,$aa,$40,$60), ($f8,$b7,$52,$7b), ($f5,$bc,$5c,$72),
1247 ($be,$d5,$06,$05), ($b3,$de,$08,$0c), ($a4,$c3,$1a,$17), ($a9,$c8,$14,$1e),
1248 ($8a,$f9,$3e,$21), ($87,$f2,$30,$28), ($90,$ef,$22,$33), ($9d,$e4,$2c,$3a),
1249 ($06,$3d,$96,$dd), ($0b,$36,$98,$d4), ($1c,$2b,$8a,$cf), ($11,$20,$84,$c6),
1250 ($32,$11,$ae,$f9), ($3f,$1a,$a0,$f0), ($28,$07,$b2,$eb), ($25,$0c,$bc,$e2),
1251 ($6e,$65,$e6,$95), ($63,$6e,$e8,$9c), ($74,$73,$fa,$87), ($79,$78,$f4,$8e),
1252 ($5a,$49,$de,$b1), ($57,$42,$d0,$b8), ($40,$5f,$c2,$a3), ($4d,$54,$cc,$aa),
1253 ($da,$f7,$41,$ec), ($d7,$fc,$4f,$e5), ($c0,$e1,$5d,$fe), ($cd,$ea,$53,$f7),
1254 ($ee,$db,$79,$c8), ($e3,$d0,$77,$c1), ($f4,$cd,$65,$da), ($f9,$c6,$6b,$d3),
1255 ($b2,$af,$31,$a4), ($bf,$a4,$3f,$ad), ($a8,$b9,$2d,$b6), ($a5,$b2,$23,$bf),
1256 ($86,$83,$09,$80), ($8b,$88,$07,$89), ($9c,$95,$15,$92), ($91,$9e,$1b,$9b),
1257 ($0a,$47,$a1,$7c), ($07,$4c,$af,$75), ($10,$51,$bd,$6e), ($1d,$5a,$b3,$67),
1258 ($3e,$6b,$99,$58), ($33,$60,$97,$51), ($24,$7d,$85,$4a), ($29,$76,$8b,$43),
1259 ($62,$1f,$d1,$34), ($6f,$14,$df,$3d), ($78,$09,$cd,$26), ($75,$02,$c3,$2f),
1260 ($56,$33,$e9,$10), ($5b,$38,$e7,$19), ($4c,$25,$f5,$02), ($41,$2e,$fb,$0b),
1261 ($61,$8c,$9a,$d7), ($6c,$87,$94,$de), ($7b,$9a,$86,$c5), ($76,$91,$88,$cc),
1262 ($55,$a0,$a2,$f3), ($58,$ab,$ac,$fa), ($4f,$b6,$be,$e1), ($42,$bd,$b0,$e8),
1263 ($09,$d4,$ea,$9f), ($04,$df,$e4,$96), ($13,$c2,$f6,$8d), ($1e,$c9,$f8,$84),
1264 ($3d,$f8,$d2,$bb), ($30,$f3,$dc,$b2), ($27,$ee,$ce,$a9), ($2a,$e5,$c0,$a0),
1265 ($b1,$3c,$7a,$47), ($bc,$37,$74,$4e), ($ab,$2a,$66,$55), ($a6,$21,$68,$5c),
1266 ($85,$10,$42,$63), ($88,$1b,$4c,$6a), ($9f,$06,$5e,$71), ($92,$0d,$50,$78),
1267 ($d9,$64,$0a,$0f), ($d4,$6f,$04,$06), ($c3,$72,$16,$1d), ($ce,$79,$18,$14),
1268 ($ed,$48,$32,$2b), ($e0,$43,$3c,$22), ($f7,$5e,$2e,$39), ($fa,$55,$20,$30),
1269 ($b7,$01,$ec,$9a), ($ba,$0a,$e2,$93), ($ad,$17,$f0,$88), ($a0,$1c,$fe,$81),
1270 ($83,$2d,$d4,$be), ($8e,$26,$da,$b7), ($99,$3b,$c8,$ac), ($94,$30,$c6,$a5),
1271 ($df,$59,$9c,$d2), ($d2,$52,$92,$db), ($c5,$4f,$80,$c0), ($c8,$44,$8e,$c9),
1272 ($eb,$75,$a4,$f6), ($e6,$7e,$aa,$ff), ($f1,$63,$b8,$e4), ($fc,$68,$b6,$ed),
1273 ($67,$b1,$0c,$0a), ($6a,$ba,$02,$03), ($7d,$a7,$10,$18), ($70,$ac,$1e,$11),
1274 ($53,$9d,$34,$2e), ($5e,$96,$3a,$27), ($49,$8b,$28,$3c), ($44,$80,$26,$35),
1275 ($0f,$e9,$7c,$42), ($02,$e2,$72,$4b), ($15,$ff,$60,$50), ($18,$f4,$6e,$59),
1276 ($3b,$c5,$44,$66), ($36,$ce,$4a,$6f), ($21,$d3,$58,$74), ($2c,$d8,$56,$7d),
1277 ($0c,$7a,$37,$a1), ($01,$71,$39,$a8), ($16,$6c,$2b,$b3), ($1b,$67,$25,$ba),
1278 ($38,$56,$0f,$85), ($35,$5d,$01,$8c), ($22,$40,$13,$97), ($2f,$4b,$1d,$9e),
1279 ($64,$22,$47,$e9), ($69,$29,$49,$e0), ($7e,$34,$5b,$fb), ($73,$3f,$55,$f2),
1280 ($50,$0e,$7f,$cd), ($5d,$05,$71,$c4), ($4a,$18,$63,$df), ($47,$13,$6d,$d6),
1281 ($dc,$ca,$d7,$31), ($d1,$c1,$d9,$38), ($c6,$dc,$cb,$23), ($cb,$d7,$c5,$2a),
1282 ($e8,$e6,$ef,$15), ($e5,$ed,$e1,$1c), ($f2,$f0,$f3,$07), ($ff,$fb,$fd,$0e),
1283 ($b4,$92,$a7,$79), ($b9,$99,$a9,$70), ($ae,$84,$bb,$6b), ($a3,$8f,$b5,$62),
1284 ($80,$be,$9f,$5d), ($8d,$b5,$91,$54), ($9a,$a8,$83,$4f), ($97,$a3,$8d,$46));
1285 U4: array[0..255,0..3] of byte= (
1286 ($00,$00,$00,$00), ($09,$0d,$0b,$0e), ($12,$1a,$16,$1c), ($1b,$17,$1d,$12),
1287 ($24,$34,$2c,$38), ($2d,$39,$27,$36), ($36,$2e,$3a,$24), ($3f,$23,$31,$2a),
1288 ($48,$68,$58,$70), ($41,$65,$53,$7e), ($5a,$72,$4e,$6c), ($53,$7f,$45,$62),
1289 ($6c,$5c,$74,$48), ($65,$51,$7f,$46), ($7e,$46,$62,$54), ($77,$4b,$69,$5a),
1290 ($90,$d0,$b0,$e0), ($99,$dd,$bb,$ee), ($82,$ca,$a6,$fc), ($8b,$c7,$ad,$f2),
1291 ($b4,$e4,$9c,$d8), ($bd,$e9,$97,$d6), ($a6,$fe,$8a,$c4), ($af,$f3,$81,$ca),
1292 ($d8,$b8,$e8,$90), ($d1,$b5,$e3,$9e), ($ca,$a2,$fe,$8c), ($c3,$af,$f5,$82),
1293 ($fc,$8c,$c4,$a8), ($f5,$81,$cf,$a6), ($ee,$96,$d2,$b4), ($e7,$9b,$d9,$ba),
1294 ($3b,$bb,$7b,$db), ($32,$b6,$70,$d5), ($29,$a1,$6d,$c7), ($20,$ac,$66,$c9),
1295 ($1f,$8f,$57,$e3), ($16,$82,$5c,$ed), ($0d,$95,$41,$ff), ($04,$98,$4a,$f1),
1296 ($73,$d3,$23,$ab), ($7a,$de,$28,$a5), ($61,$c9,$35,$b7), ($68,$c4,$3e,$b9),
1297 ($57,$e7,$0f,$93), ($5e,$ea,$04,$9d), ($45,$fd,$19,$8f), ($4c,$f0,$12,$81),
1298 ($ab,$6b,$cb,$3b), ($a2,$66,$c0,$35), ($b9,$71,$dd,$27), ($b0,$7c,$d6,$29),
1299 ($8f,$5f,$e7,$03), ($86,$52,$ec,$0d), ($9d,$45,$f1,$1f), ($94,$48,$fa,$11),
1300 ($e3,$03,$93,$4b), ($ea,$0e,$98,$45), ($f1,$19,$85,$57), ($f8,$14,$8e,$59),
1301 ($c7,$37,$bf,$73), ($ce,$3a,$b4,$7d), ($d5,$2d,$a9,$6f), ($dc,$20,$a2,$61),
1302 ($76,$6d,$f6,$ad), ($7f,$60,$fd,$a3), ($64,$77,$e0,$b1), ($6d,$7a,$eb,$bf),
1303 ($52,$59,$da,$95), ($5b,$54,$d1,$9b), ($40,$43,$cc,$89), ($49,$4e,$c7,$87),
1304 ($3e,$05,$ae,$dd), ($37,$08,$a5,$d3), ($2c,$1f,$b8,$c1), ($25,$12,$b3,$cf),
1305 ($1a,$31,$82,$e5), ($13,$3c,$89,$eb), ($08,$2b,$94,$f9), ($01,$26,$9f,$f7),
1306 ($e6,$bd,$46,$4d), ($ef,$b0,$4d,$43), ($f4,$a7,$50,$51), ($fd,$aa,$5b,$5f),
1307 ($c2,$89,$6a,$75), ($cb,$84,$61,$7b), ($d0,$93,$7c,$69), ($d9,$9e,$77,$67),
1308 ($ae,$d5,$1e,$3d), ($a7,$d8,$15,$33), ($bc,$cf,$08,$21), ($b5,$c2,$03,$2f),
1309 ($8a,$e1,$32,$05), ($83,$ec,$39,$0b), ($98,$fb,$24,$19), ($91,$f6,$2f,$17),
1310 ($4d,$d6,$8d,$76), ($44,$db,$86,$78), ($5f,$cc,$9b,$6a), ($56,$c1,$90,$64),
1311 ($69,$e2,$a1,$4e), ($60,$ef,$aa,$40), ($7b,$f8,$b7,$52), ($72,$f5,$bc,$5c),
1312 ($05,$be,$d5,$06), ($0c,$b3,$de,$08), ($17,$a4,$c3,$1a), ($1e,$a9,$c8,$14),
1313 ($21,$8a,$f9,$3e), ($28,$87,$f2,$30), ($33,$90,$ef,$22), ($3a,$9d,$e4,$2c),
1314 ($dd,$06,$3d,$96), ($d4,$0b,$36,$98), ($cf,$1c,$2b,$8a), ($c6,$11,$20,$84),
1315 ($f9,$32,$11,$ae), ($f0,$3f,$1a,$a0), ($eb,$28,$07,$b2), ($e2,$25,$0c,$bc),
1316 ($95,$6e,$65,$e6), ($9c,$63,$6e,$e8), ($87,$74,$73,$fa), ($8e,$79,$78,$f4),
1317 ($b1,$5a,$49,$de), ($b8,$57,$42,$d0), ($a3,$40,$5f,$c2), ($aa,$4d,$54,$cc),
1318 ($ec,$da,$f7,$41), ($e5,$d7,$fc,$4f), ($fe,$c0,$e1,$5d), ($f7,$cd,$ea,$53),
1319 ($c8,$ee,$db,$79), ($c1,$e3,$d0,$77), ($da,$f4,$cd,$65), ($d3,$f9,$c6,$6b),
1320 ($a4,$b2,$af,$31), ($ad,$bf,$a4,$3f), ($b6,$a8,$b9,$2d), ($bf,$a5,$b2,$23),
1321 ($80,$86,$83,$09), ($89,$8b,$88,$07), ($92,$9c,$95,$15), ($9b,$91,$9e,$1b),
1322 ($7c,$0a,$47,$a1), ($75,$07,$4c,$af), ($6e,$10,$51,$bd), ($67,$1d,$5a,$b3),
1323 ($58,$3e,$6b,$99), ($51,$33,$60,$97), ($4a,$24,$7d,$85), ($43,$29,$76,$8b),
1324 ($34,$62,$1f,$d1), ($3d,$6f,$14,$df), ($26,$78,$09,$cd), ($2f,$75,$02,$c3),
1325 ($10,$56,$33,$e9), ($19,$5b,$38,$e7), ($02,$4c,$25,$f5), ($0b,$41,$2e,$fb),
1326 ($d7,$61,$8c,$9a), ($de,$6c,$87,$94), ($c5,$7b,$9a,$86), ($cc,$76,$91,$88),
1327 ($f3,$55,$a0,$a2), ($fa,$58,$ab,$ac), ($e1,$4f,$b6,$be), ($e8,$42,$bd,$b0),
1328 ($9f,$09,$d4,$ea), ($96,$04,$df,$e4), ($8d,$13,$c2,$f6), ($84,$1e,$c9,$f8),
1329 ($bb,$3d,$f8,$d2), ($b2,$30,$f3,$dc), ($a9,$27,$ee,$ce), ($a0,$2a,$e5,$c0),
1330 ($47,$b1,$3c,$7a), ($4e,$bc,$37,$74), ($55,$ab,$2a,$66), ($5c,$a6,$21,$68),
1331 ($63,$85,$10,$42), ($6a,$88,$1b,$4c), ($71,$9f,$06,$5e), ($78,$92,$0d,$50),
1332 ($0f,$d9,$64,$0a), ($06,$d4,$6f,$04), ($1d,$c3,$72,$16), ($14,$ce,$79,$18),
1333 ($2b,$ed,$48,$32), ($22,$e0,$43,$3c), ($39,$f7,$5e,$2e), ($30,$fa,$55,$20),
1334 ($9a,$b7,$01,$ec), ($93,$ba,$0a,$e2), ($88,$ad,$17,$f0), ($81,$a0,$1c,$fe),
1335 ($be,$83,$2d,$d4), ($b7,$8e,$26,$da), ($ac,$99,$3b,$c8), ($a5,$94,$30,$c6),
1336 ($d2,$df,$59,$9c), ($db,$d2,$52,$92), ($c0,$c5,$4f,$80), ($c9,$c8,$44,$8e),
1337 ($f6,$eb,$75,$a4), ($ff,$e6,$7e,$aa), ($e4,$f1,$63,$b8), ($ed,$fc,$68,$b6),
1338 ($0a,$67,$b1,$0c), ($03,$6a,$ba,$02), ($18,$7d,$a7,$10), ($11,$70,$ac,$1e),
1339 ($2e,$53,$9d,$34), ($27,$5e,$96,$3a), ($3c,$49,$8b,$28), ($35,$44,$80,$26),
1340 ($42,$0f,$e9,$7c), ($4b,$02,$e2,$72), ($50,$15,$ff,$60), ($59,$18,$f4,$6e),
1341 ($66,$3b,$c5,$44), ($6f,$36,$ce,$4a), ($74,$21,$d3,$58), ($7d,$2c,$d8,$56),
1342 ($a1,$0c,$7a,$37), ($a8,$01,$71,$39), ($b3,$16,$6c,$2b), ($ba,$1b,$67,$25),
1343 ($85,$38,$56,$0f), ($8c,$35,$5d,$01), ($97,$22,$40,$13), ($9e,$2f,$4b,$1d),
1344 ($e9,$64,$22,$47), ($e0,$69,$29,$49), ($fb,$7e,$34,$5b), ($f2,$73,$3f,$55),
1345 ($cd,$50,$0e,$7f), ($c4,$5d,$05,$71), ($df,$4a,$18,$63), ($d6,$47,$13,$6d),
1346 ($31,$dc,$ca,$d7), ($38,$d1,$c1,$d9), ($23,$c6,$dc,$cb), ($2a,$cb,$d7,$c5),
1347 ($15,$e8,$e6,$ef), ($1c,$e5,$ed,$e1), ($07,$f2,$f0,$f3), ($0e,$ff,$fb,$fd),
1348 ($79,$b4,$92,$a7), ($70,$b9,$99,$a9), ($6b,$ae,$84,$bb), ($62,$a3,$8f,$b5),
1349 ($5d,$80,$be,$9f), ($54,$8d,$b5,$91), ($4f,$9a,$a8,$83), ($46,$97,$a3,$8d));
1350
1351 rcon: array[0..29] of cardinal= (
1352 $01, $02, $04, $08, $10, $20, $40, $80, $1b, $36, $6c, $d8, $ab, $4d, $9a,
1353 $2f, $5e, $bc, $63, $c6, $97, $35, $6a, $d4, $b3, $7d, $fa, $ef, $c5, $91);
1354
1355{==============================================================================}
1356type
1357 PDWord = ^LongWord;
1358
1359procedure hperm_op(var a, t: integer; n, m: integer);
1360begin
1361 t:= ((a shl (16 - n)) xor a) and m;
1362 a:= a xor t xor (t shr (16 - n));
1363end;
1364
1365procedure perm_op(var a, b, t: integer; n, m: integer);
1366begin
1367 t:= ((a shr n) xor b) and m;
1368 b:= b xor t;
1369 a:= a xor (t shl n);
1370end;
1371
1372{==============================================================================}
1373function TSynaBlockCipher.GetSize: byte;
1374begin
1375 Result := 8;
1376end;
1377
1378procedure TSynaBlockCipher.IncCounter;
1379var
1380 i: integer;
1381begin
1382 Inc(CV[GetSize]);
1383 i:= GetSize -1;
1384 while (i> 0) and (CV[i + 1] = #0) do
1385 begin
1386 Inc(CV[i]);
1387 Dec(i);
1388 end;
1389end;
1390
1391procedure TSynaBlockCipher.Reset;
1392begin
1393 CV := IV;
1394end;
1395
1396procedure TSynaBlockCipher.InitKey(Key: AnsiString);
1397begin
1398end;
1399
1400procedure TSynaBlockCipher.SetIV(const Value: AnsiString);
1401begin
1402 IV := PadString(Value, GetSize, #0);
1403 Reset;
1404end;
1405
1406function TSynaBlockCipher.GetIV: AnsiString;
1407begin
1408 Result := CV;
1409end;
1410
1411function TSynaBlockCipher.EncryptECB(const InData: AnsiString): AnsiString;
1412begin
1413 Result := InData;
1414end;
1415
1416function TSynaBlockCipher.DecryptECB(const InData: AnsiString): AnsiString;
1417begin
1418 Result := InData;
1419end;
1420
1421function TSynaBlockCipher.EncryptCBC(const Indata: AnsiString): AnsiString;
1422var
1423 i: integer;
1424 s: ansistring;
1425 l: integer;
1426 bs: byte;
1427begin
1428 Result := '';
1429 l := Length(InData);
1430 bs := GetSize;
1431 for i:= 1 to (l div bs) do
1432 begin
1433 s := copy(Indata, (i - 1) * bs + 1, bs);
1434 s := XorString(s, CV);
1435 s := EncryptECB(s);
1436 CV := s;
1437 Result := Result + s;
1438 end;
1439 if (l mod bs)<> 0 then
1440 begin
1441 CV := EncryptECB(CV);
1442 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1443 s := XorString(s, CV);
1444 Result := Result + s;
1445 end;
1446end;
1447
1448function TSynaBlockCipher.DecryptCBC(const Indata: AnsiString): AnsiString;
1449var
1450 i: integer;
1451 s, temp: ansistring;
1452 l: integer;
1453 bs: byte;
1454begin
1455 Result := '';
1456 l := Length(InData);
1457 bs := GetSize;
1458 for i:= 1 to (l div bs) do
1459 begin
1460 s := copy(Indata, (i - 1) * bs + 1, bs);
1461 temp := s;
1462 s := DecryptECB(s);
1463 s := XorString(s, CV);
1464 Result := Result + s;
1465 CV := Temp;
1466 end;
1467 if (l mod bs)<> 0 then
1468 begin
1469 CV := EncryptECB(CV);
1470 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1471 s := XorString(s, CV);
1472 Result := Result + s;
1473 end;
1474end;
1475
1476function TSynaBlockCipher.EncryptCFB8bit(const Indata: AnsiString): AnsiString;
1477var
1478 i: integer;
1479 Temp: AnsiString;
1480 c: AnsiChar;
1481begin
1482 Result := '';
1483 for i:= 1 to Length(Indata) do
1484 begin
1485 Temp := EncryptECB(CV);
1486 c := AnsiChar(ord(InData[i]) xor ord(temp[1]));
1487 Result := Result + c;
1488 Delete(CV, 1, 1);
1489 CV := CV + c;
1490 end;
1491end;
1492
1493function TSynaBlockCipher.DecryptCFB8bit(const Indata: AnsiString): AnsiString;
1494var
1495 i: integer;
1496 Temp: AnsiString;
1497 c: AnsiChar;
1498begin
1499 Result := '';
1500 for i:= 1 to length(Indata) do
1501 begin
1502 c:= Indata[i];
1503 Temp := EncryptECB(CV);
1504 Result := Result + AnsiChar(ord(InData[i]) xor ord(temp[1]));
1505 Delete(CV, 1, 1);
1506 CV := CV + c;
1507 end;
1508end;
1509
1510function TSynaBlockCipher.EncryptCFBblock(const Indata: AnsiString): AnsiString;
1511var
1512 i: integer;
1513 s: AnsiString;
1514 l: integer;
1515 bs: byte;
1516begin
1517 Result := '';
1518 l := Length(InData);
1519 bs := GetSize;
1520 for i:= 1 to (l div bs) do
1521 begin
1522 CV := EncryptECB(CV);
1523 s := copy(Indata, (i - 1) * bs + 1, bs);
1524 s := XorString(s, CV);
1525 Result := Result + s;
1526 CV := s;
1527 end;
1528 if (l mod bs)<> 0 then
1529 begin
1530 CV := EncryptECB(CV);
1531 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1532 s := XorString(s, CV);
1533 Result := Result + s;
1534 end;
1535end;
1536
1537function TSynaBlockCipher.DecryptCFBblock(const Indata: AnsiString): AnsiString;
1538var
1539 i: integer;
1540 S, Temp: AnsiString;
1541 l: integer;
1542 bs: byte;
1543begin
1544 Result := '';
1545 l := Length(InData);
1546 bs := GetSize;
1547 for i:= 1 to (l div bs) do
1548 begin
1549 s := copy(Indata, (i - 1) * bs + 1, bs);
1550 Temp := s;
1551 CV := EncryptECB(CV);
1552 s := XorString(s, CV);
1553 Result := result + s;
1554 CV := temp;
1555 end;
1556 if (l mod bs)<> 0 then
1557 begin
1558 CV := EncryptECB(CV);
1559 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1560 s := XorString(s, CV);
1561 Result := Result + s;
1562 end;
1563end;
1564
1565function TSynaBlockCipher.EncryptOFB(const Indata: AnsiString): AnsiString;
1566var
1567 i: integer;
1568 s: AnsiString;
1569 l: integer;
1570 bs: byte;
1571begin
1572 Result := '';
1573 l := Length(InData);
1574 bs := GetSize;
1575 for i:= 1 to (l div bs) do
1576 begin
1577 CV := EncryptECB(CV);
1578 s := copy(Indata, (i - 1) * bs + 1, bs);
1579 s := XorString(s, CV);
1580 Result := Result + s;
1581 end;
1582 if (l mod bs)<> 0 then
1583 begin
1584 CV := EncryptECB(CV);
1585 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1586 s := XorString(s, CV);
1587 Result := Result + s;
1588 end;
1589end;
1590
1591function TSynaBlockCipher.DecryptOFB(const Indata: AnsiString): AnsiString;
1592var
1593 i: integer;
1594 s: AnsiString;
1595 l: integer;
1596 bs: byte;
1597begin
1598 Result := '';
1599 l := Length(InData);
1600 bs := GetSize;
1601 for i:= 1 to (l div bs) do
1602 begin
1603 Cv := EncryptECB(CV);
1604 s := copy(Indata, (i - 1) * bs + 1, bs);
1605 s := XorString(s, CV);
1606 Result := Result + s;
1607 end;
1608 if (l mod bs)<> 0 then
1609 begin
1610 CV := EncryptECB(CV);
1611 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1612 s := XorString(s, CV);
1613 Result := Result + s;
1614 end;
1615end;
1616
1617function TSynaBlockCipher.EncryptCTR(const Indata: AnsiString): AnsiString;
1618var
1619 temp: AnsiString;
1620 i: integer;
1621 s: AnsiString;
1622 l: integer;
1623 bs: byte;
1624begin
1625 Result := '';
1626 l := Length(InData);
1627 bs := GetSize;
1628 for i:= 1 to (l div bs) do
1629 begin
1630 temp := EncryptECB(CV);
1631 IncCounter;
1632 s := copy(Indata, (i - 1) * bs + 1, bs);
1633 s := XorString(s, temp);
1634 Result := Result + s;
1635 end;
1636 if (l mod bs)<> 0 then
1637 begin
1638 temp := EncryptECB(CV);
1639 IncCounter;
1640 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1641 s := XorString(s, temp);
1642 Result := Result + s;
1643 end;
1644end;
1645
1646function TSynaBlockCipher.DecryptCTR(const Indata: AnsiString): AnsiString;
1647var
1648 temp: AnsiString;
1649 s: AnsiString;
1650 i: integer;
1651 l: integer;
1652 bs: byte;
1653begin
1654 Result := '';
1655 l := Length(InData);
1656 bs := GetSize;
1657 for i:= 1 to (l div bs) do
1658 begin
1659 temp := EncryptECB(CV);
1660 IncCounter;
1661 s := copy(Indata, (i - 1) * bs + 1, bs);
1662 s := XorString(s, temp);
1663 Result := Result + s;
1664 end;
1665 if (l mod bs)<> 0 then
1666 begin
1667 temp := EncryptECB(CV);
1668 IncCounter;
1669 s := copy(Indata, (l div bs) * bs + 1, l mod bs);
1670 s := XorString(s, temp);
1671 Result := Result + s;
1672 end;
1673end;
1674
1675constructor TSynaBlockCipher.Create(Key: AnsiString);
1676begin
1677 inherited Create;
1678 InitKey(Key);
1679 IV := StringOfChar(#0, GetSize);
1680 IV := EncryptECB(IV);
1681 Reset;
1682end;
1683
1684{==============================================================================}
1685
1686procedure TSynaCustomDes.DoInit(KeyB: AnsiString; var KeyData: TDesKeyData);
1687var
1688 c, d, t, s, t2, i: integer;
1689begin
1690 KeyB := PadString(KeyB, 8, #0);
1691 c:= ord(KeyB[1]) or (ord(KeyB[2]) shl 8) or (ord(KeyB[3]) shl 16) or (ord(KeyB[4]) shl 24);
1692 d:= ord(KeyB[5]) or (ord(KeyB[6]) shl 8) or (ord(KeyB[7]) shl 16) or (ord(KeyB[8]) shl 24);
1693 perm_op(d,c,t,4,integer($0f0f0f0f));
1694 hperm_op(c,t,integer(-2),integer($cccc0000));
1695 hperm_op(d,t,integer(-2),integer($cccc0000));
1696 perm_op(d,c,t,1,integer($55555555));
1697 perm_op(c,d,t,8,integer($00ff00ff));
1698 perm_op(d,c,t,1,integer($55555555));
1699 d:= ((d and $ff) shl 16) or (d and $ff00) or ((d and $ff0000) shr 16) or
1700 ((c and integer($f0000000)) shr 4);
1701 c:= c and $fffffff;
1702 for i:= 0 to 15 do
1703 begin
1704 if shifts2[i]<> 0 then
1705 begin
1706 c:= ((c shr 2) or (c shl 26));
1707 d:= ((d shr 2) or (d shl 26));
1708 end
1709 else
1710 begin
1711 c:= ((c shr 1) or (c shl 27));
1712 d:= ((d shr 1) or (d shl 27));
1713 end;
1714 c:= c and $fffffff;
1715 d:= d and $fffffff;
1716 s:= des_skb[0,c and $3f] or
1717 des_skb[1,((c shr 6) and $03) or ((c shr 7) and $3c)] or
1718 des_skb[2,((c shr 13) and $0f) or ((c shr 14) and $30)] or
1719 des_skb[3,((c shr 20) and $01) or ((c shr 21) and $06) or ((c shr 22) and $38)];
1720 t:= des_skb[4,d and $3f] or
1721 des_skb[5,((d shr 7) and $03) or ((d shr 8) and $3c)] or
1722 des_skb[6, (d shr 15) and $3f ] or
1723 des_skb[7,((d shr 21) and $0f) or ((d shr 22) and $30)];
1724 t2:= ((t shl 16) or (s and $ffff));
1725 KeyData[(i shl 1)]:= ((t2 shl 2) or (t2 shr 30));
1726 t2:= ((s shr 16) or (t and integer($ffff0000)));
1727 KeyData[(i shl 1)+1]:= ((t2 shl 6) or (t2 shr 26));
1728 end;
1729end;
1730
1731function TSynaCustomDes.EncryptBlock(const InData: AnsiString; var KeyData: TDesKeyData): AnsiString;
1732var
1733 l, r, t, u: integer;
1734 i: longint;
1735begin
1736 r := Swapbytes(DecodeLongint(Indata, 1));
1737 l := swapbytes(DecodeLongint(Indata, 5));
1738 t:= ((l shr 4) xor r) and $0f0f0f0f;
1739 r:= r xor t;
1740 l:= l xor (t shl 4);
1741 t:= ((r shr 16) xor l) and $0000ffff;
1742 l:= l xor t;
1743 r:= r xor (t shl 16);
1744 t:= ((l shr 2) xor r) and $33333333;
1745 r:= r xor t;
1746 l:= l xor (t shl 2);
1747 t:= ((r shr 8) xor l) and $00ff00ff;
1748 l:= l xor t;
1749 r:= r xor (t shl 8);
1750 t:= ((l shr 1) xor r) and $55555555;
1751 r:= r xor t;
1752 l:= l xor (t shl 1);
1753 r:= (r shr 29) or (r shl 3);
1754 l:= (l shr 29) or (l shl 3);
1755 i:= 0;
1756 while i< 32 do
1757 begin
1758 u:= r xor KeyData[i ];
1759 t:= r xor KeyData[i+1];
1760 t:= (t shr 4) or (t shl 28);
1761 l:= l xor des_SPtrans[0,(u shr 2) and $3f] xor
1762 des_SPtrans[2,(u shr 10) and $3f] xor
1763 des_SPtrans[4,(u shr 18) and $3f] xor
1764 des_SPtrans[6,(u shr 26) and $3f] xor
1765 des_SPtrans[1,(t shr 2) and $3f] xor
1766 des_SPtrans[3,(t shr 10) and $3f] xor
1767 des_SPtrans[5,(t shr 18) and $3f] xor
1768 des_SPtrans[7,(t shr 26) and $3f];
1769 u:= l xor KeyData[i+2];
1770 t:= l xor KeyData[i+3];
1771 t:= (t shr 4) or (t shl 28);
1772 r:= r xor des_SPtrans[0,(u shr 2) and $3f] xor
1773 des_SPtrans[2,(u shr 10) and $3f] xor
1774 des_SPtrans[4,(u shr 18) and $3f] xor
1775 des_SPtrans[6,(u shr 26) and $3f] xor
1776 des_SPtrans[1,(t shr 2) and $3f] xor
1777 des_SPtrans[3,(t shr 10) and $3f] xor
1778 des_SPtrans[5,(t shr 18) and $3f] xor
1779 des_SPtrans[7,(t shr 26) and $3f];
1780 u:= r xor KeyData[i+4];
1781 t:= r xor KeyData[i+5];
1782 t:= (t shr 4) or (t shl 28);
1783 l:= l xor des_SPtrans[0,(u shr 2) and $3f] xor
1784 des_SPtrans[2,(u shr 10) and $3f] xor
1785 des_SPtrans[4,(u shr 18) and $3f] xor
1786 des_SPtrans[6,(u shr 26) and $3f] xor
1787 des_SPtrans[1,(t shr 2) and $3f] xor
1788 des_SPtrans[3,(t shr 10) and $3f] xor
1789 des_SPtrans[5,(t shr 18) and $3f] xor
1790 des_SPtrans[7,(t shr 26) and $3f];
1791 u:= l xor KeyData[i+6];
1792 t:= l xor KeyData[i+7];
1793 t:= (t shr 4) or (t shl 28);
1794 r:= r xor des_SPtrans[0,(u shr 2) and $3f] xor
1795 des_SPtrans[2,(u shr 10) and $3f] xor
1796 des_SPtrans[4,(u shr 18) and $3f] xor
1797 des_SPtrans[6,(u shr 26) and $3f] xor
1798 des_SPtrans[1,(t shr 2) and $3f] xor
1799 des_SPtrans[3,(t shr 10) and $3f] xor
1800 des_SPtrans[5,(t shr 18) and $3f] xor
1801 des_SPtrans[7,(t shr 26) and $3f];
1802 Inc(i,8);
1803 end;
1804 r:= (r shr 3) or (r shl 29);
1805 l:= (l shr 3) or (l shl 29);
1806 t:= ((r shr 1) xor l) and $55555555;
1807 l:= l xor t;
1808 r:= r xor (t shl 1);
1809 t:= ((l shr 8) xor r) and $00ff00ff;
1810 r:= r xor t;
1811 l:= l xor (t shl 8);
1812 t:= ((r shr 2) xor l) and $33333333;
1813 l:= l xor t;
1814 r:= r xor (t shl 2);
1815 t:= ((l shr 16) xor r) and $0000ffff;
1816 r:= r xor t;
1817 l:= l xor (t shl 16);
1818 t:= ((r shr 4) xor l) and $0f0f0f0f;
1819 l:= l xor t;
1820 r:= r xor (t shl 4);
1821 Result := CodeLongInt(Swapbytes(l)) + CodeLongInt(Swapbytes(r));
1822end;
1823
1824function TSynaCustomDes.DecryptBlock(const InData: AnsiString; var KeyData: TDesKeyData): AnsiString;
1825var
1826 l, r, t, u: integer;
1827 i: longint;
1828begin
1829 r := Swapbytes(DecodeLongint(Indata, 1));
1830 l := Swapbytes(DecodeLongint(Indata, 5));
1831 t:= ((l shr 4) xor r) and $0f0f0f0f;
1832 r:= r xor t;
1833 l:= l xor (t shl 4);
1834 t:= ((r shr 16) xor l) and $0000ffff;
1835 l:= l xor t;
1836 r:= r xor (t shl 16);
1837 t:= ((l shr 2) xor r) and $33333333;
1838 r:= r xor t;
1839 l:= l xor (t shl 2);
1840 t:= ((r shr 8) xor l) and $00ff00ff;
1841 l:= l xor t;
1842 r:= r xor (t shl 8);
1843 t:= ((l shr 1) xor r) and $55555555;
1844 r:= r xor t;
1845 l:= l xor (t shl 1);
1846 r:= (r shr 29) or (r shl 3);
1847 l:= (l shr 29) or (l shl 3);
1848 i:= 30;
1849 while i> 0 do
1850 begin
1851 u:= r xor KeyData[i ];
1852 t:= r xor KeyData[i+1];
1853 t:= (t shr 4) or (t shl 28);
1854 l:= l xor des_SPtrans[0,(u shr 2) and $3f] xor
1855 des_SPtrans[2,(u shr 10) and $3f] xor
1856 des_SPtrans[4,(u shr 18) and $3f] xor
1857 des_SPtrans[6,(u shr 26) and $3f] xor
1858 des_SPtrans[1,(t shr 2) and $3f] xor
1859 des_SPtrans[3,(t shr 10) and $3f] xor
1860 des_SPtrans[5,(t shr 18) and $3f] xor
1861 des_SPtrans[7,(t shr 26) and $3f];
1862 u:= l xor KeyData[i-2];
1863 t:= l xor KeyData[i-1];
1864 t:= (t shr 4) or (t shl 28);
1865 r:= r xor des_SPtrans[0,(u shr 2) and $3f] xor
1866 des_SPtrans[2,(u shr 10) and $3f] xor
1867 des_SPtrans[4,(u shr 18) and $3f] xor
1868 des_SPtrans[6,(u shr 26) and $3f] xor
1869 des_SPtrans[1,(t shr 2) and $3f] xor
1870 des_SPtrans[3,(t shr 10) and $3f] xor
1871 des_SPtrans[5,(t shr 18) and $3f] xor
1872 des_SPtrans[7,(t shr 26) and $3f];
1873 u:= r xor KeyData[i-4];
1874 t:= r xor KeyData[i-3];
1875 t:= (t shr 4) or (t shl 28);
1876 l:= l xor des_SPtrans[0,(u shr 2) and $3f] xor
1877 des_SPtrans[2,(u shr 10) and $3f] xor
1878 des_SPtrans[4,(u shr 18) and $3f] xor
1879 des_SPtrans[6,(u shr 26) and $3f] xor
1880 des_SPtrans[1,(t shr 2) and $3f] xor
1881 des_SPtrans[3,(t shr 10) and $3f] xor
1882 des_SPtrans[5,(t shr 18) and $3f] xor
1883 des_SPtrans[7,(t shr 26) and $3f];
1884 u:= l xor KeyData[i-6];
1885 t:= l xor KeyData[i-5];
1886 t:= (t shr 4) or (t shl 28);
1887 r:= r xor des_SPtrans[0,(u shr 2) and $3f] xor
1888 des_SPtrans[2,(u shr 10) and $3f] xor
1889 des_SPtrans[4,(u shr 18) and $3f] xor
1890 des_SPtrans[6,(u shr 26) and $3f] xor
1891 des_SPtrans[1,(t shr 2) and $3f] xor
1892 des_SPtrans[3,(t shr 10) and $3f] xor
1893 des_SPtrans[5,(t shr 18) and $3f] xor
1894 des_SPtrans[7,(t shr 26) and $3f];
1895 Dec(i,8);
1896 end;
1897 r:= (r shr 3) or (r shl 29);
1898 l:= (l shr 3) or (l shl 29);
1899 t:= ((r shr 1) xor l) and $55555555;
1900 l:= l xor t;
1901 r:= r xor (t shl 1);
1902 t:= ((l shr 8) xor r) and $00ff00ff;
1903 r:= r xor t;
1904 l:= l xor (t shl 8);
1905 t:= ((r shr 2) xor l) and $33333333;
1906 l:= l xor t;
1907 r:= r xor (t shl 2);
1908 t:= ((l shr 16) xor r) and $0000ffff;
1909 r:= r xor t;
1910 l:= l xor (t shl 16);
1911 t:= ((r shr 4) xor l) and $0f0f0f0f;
1912 l:= l xor t;
1913 r:= r xor (t shl 4);
1914 Result := CodeLongInt(Swapbytes(l)) + CodeLongInt(Swapbytes(r));
1915end;
1916
1917{==============================================================================}
1918
1919procedure TSynaDes.InitKey(Key: AnsiString);
1920begin
1921 Key := PadString(Key, 8, #0);
1922 DoInit(Key,KeyData);
1923end;
1924
1925function TSynaDes.EncryptECB(const InData: AnsiString): AnsiString;
1926begin
1927 Result := EncryptBlock(InData,KeyData);
1928end;
1929
1930function TSynaDes.DecryptECB(const InData: AnsiString): AnsiString;
1931begin
1932 Result := DecryptBlock(Indata,KeyData);
1933end;
1934
1935{==============================================================================}
1936
1937procedure TSyna3Des.InitKey(Key: AnsiString);
1938var
1939 Size: integer;
1940 n: integer;
1941begin
1942 Size := length(Key);
1943 key := PadString(key, 3 * 8, #0);
1944 DoInit(Copy(key, 1, 8),KeyData[0]);
1945 DoInit(Copy(key, 9, 8),KeyData[1]);
1946 if Size > 16 then
1947 DoInit(Copy(key, 17, 8),KeyData[2])
1948 else
1949 for n := 0 to high(KeyData[0]) do
1950 KeyData[2][n] := Keydata[0][n];
1951end;
1952
1953function TSyna3Des.EncryptECB(const InData: AnsiString): AnsiString;
1954begin
1955 Result := EncryptBlock(Indata,KeyData[0]);
1956 Result := DecryptBlock(Result,KeyData[1]);
1957 Result := EncryptBlock(Result,KeyData[2]);
1958end;
1959
1960function TSyna3Des.DecryptECB(const InData: AnsiString): AnsiString;
1961begin
1962 Result := DecryptBlock(InData,KeyData[2]);
1963 Result := EncryptBlock(Result,KeyData[1]);
1964 Result := DecryptBlock(Result,KeyData[0]);
1965end;
1966
1967{==============================================================================}
1968
1969procedure InvMixColumn(a: PByteArray; BC: byte);
1970var
1971 j: longword;
1972begin
1973 for j:= 0 to (BC-1) do
1974 PDWord(@(a^[j*4]))^:= PDWord(@U1[a^[j*4+0]])^
1975 xor PDWord(@U2[a^[j*4+1]])^
1976 xor PDWord(@U3[a^[j*4+2]])^
1977 xor PDWord(@U4[a^[j*4+3]])^;
1978end;
1979
1980{==============================================================================}
1981
1982function TSynaAes.GetSize: byte;
1983begin
1984 Result := 16;
1985end;
1986
1987procedure TSynaAes.InitKey(Key: AnsiString);
1988var
1989 Size: integer;
1990 KC, ROUNDS, j, r, t, rconpointer: longword;
1991 tk: array[0..MAXKC-1,0..3] of byte;
1992 n: integer;
1993begin
1994 FillChar(tk,Sizeof(tk),0);
1995 //key must have at least 128 bits and max 256 bits
1996 if length(key) < 16 then
1997 key := PadString(key, 16, #0);
1998 if length(key) > 32 then
1999 delete(key, 33, maxint);
2000 Size := length(Key);
2001 Move(PAnsiChar(Key)^, tk, Size);
2002 if Size<= 16 then
2003 begin
2004 KC:= 4;
2005 Rounds:= 10;
2006 end
2007 else if Size<= 24 then
2008 begin
2009 KC:= 6;
2010 Rounds:= 12;
2011 end
2012 else
2013 begin
2014 KC:= 8;
2015 Rounds:= 14;
2016 end;
2017 numrounds:= rounds;
2018 r:= 0;
2019 t:= 0;
2020 j:= 0;
2021 while (j< KC) and (r< (rounds+1)) do
2022 begin
2023 while (j< KC) and (t< BC) do
2024 begin
2025 rk[r,t]:= PDWord(@tk[j])^;
2026 Inc(j);
2027 Inc(t);
2028 end;
2029 if t= BC then
2030 begin
2031 t:= 0;
2032 Inc(r);
2033 end;
2034 end;
2035 rconpointer:= 0;
2036 while (r< (rounds+1)) do
2037 begin
2038 tk[0,0]:= tk[0,0] xor S[tk[KC-1,1]];
2039 tk[0,1]:= tk[0,1] xor S[tk[KC-1,2]];
2040 tk[0,2]:= tk[0,2] xor S[tk[KC-1,3]];
2041 tk[0,3]:= tk[0,3] xor S[tk[KC-1,0]];
2042 tk[0,0]:= tk[0,0] xor rcon[rconpointer];
2043 Inc(rconpointer);
2044 if KC<> 8 then
2045 begin
2046 for j:= 1 to (KC-1) do
2047 PDWord(@tk[j])^:= PDWord(@tk[j])^ xor PDWord(@tk[j-1])^;
2048 end
2049 else
2050 begin
2051 for j:= 1 to ((KC div 2)-1) do
2052 PDWord(@tk[j])^:= PDWord(@tk[j])^ xor PDWord(@tk[j-1])^;
2053 tk[KC div 2,0]:= tk[KC div 2,0] xor S[tk[KC div 2 - 1,0]];
2054 tk[KC div 2,1]:= tk[KC div 2,1] xor S[tk[KC div 2 - 1,1]];
2055 tk[KC div 2,2]:= tk[KC div 2,2] xor S[tk[KC div 2 - 1,2]];
2056 tk[KC div 2,3]:= tk[KC div 2,3] xor S[tk[KC div 2 - 1,3]];
2057 for j:= ((KC div 2) + 1) to (KC-1) do
2058 PDWord(@tk[j])^:= PDWord(@tk[j])^ xor PDWord(@tk[j-1])^;
2059 end;
2060 j:= 0;
2061 while (j< KC) and (r< (rounds+1)) do
2062 begin
2063 while (j< KC) and (t< BC) do
2064 begin
2065 rk[r,t]:= PDWord(@tk[j])^;
2066 Inc(j);
2067 Inc(t);
2068 end;
2069 if t= BC then
2070 begin
2071 Inc(r);
2072 t:= 0;
2073 end;
2074 end;
2075 end;
2076 Move(rk,drk,Sizeof(rk));
2077 for r:= 1 to (numrounds-1) do
2078 InvMixColumn(@drk[r],BC);
2079end;
2080
2081function TSynaAes.EncryptECB(const InData: AnsiString): AnsiString;
2082var
2083 r: longword;
2084 tempb: array[0..MAXBC-1,0..3] of byte;
2085 a: array[0..MAXBC,0..3] of byte;
2086 p: pointer;
2087begin
2088 p := @a[0,0];
2089 move(pointer(InData)^, p^, 16);
2090 for r:= 0 to (numrounds-2) do
2091 begin
2092 PDWord(@tempb[0])^:= PDWord(@a[0])^ xor rk[r,0];
2093 PDWord(@tempb[1])^:= PDWord(@a[1])^ xor rk[r,1];
2094 PDWord(@tempb[2])^:= PDWord(@a[2])^ xor rk[r,2];
2095 PDWord(@tempb[3])^:= PDWord(@a[3])^ xor rk[r,3];
2096 PDWord(@a[0])^:= PDWord(@T1[tempb[0,0]])^ xor
2097 PDWord(@T2[tempb[1,1]])^ xor
2098 PDWord(@T3[tempb[2,2]])^ xor
2099 PDWord(@T4[tempb[3,3]])^;
2100 PDWord(@a[1])^:= PDWord(@T1[tempb[1,0]])^ xor
2101 PDWord(@T2[tempb[2,1]])^ xor
2102 PDWord(@T3[tempb[3,2]])^ xor
2103 PDWord(@T4[tempb[0,3]])^;
2104 PDWord(@a[2])^:= PDWord(@T1[tempb[2,0]])^ xor
2105 PDWord(@T2[tempb[3,1]])^ xor
2106 PDWord(@T3[tempb[0,2]])^ xor
2107 PDWord(@T4[tempb[1,3]])^;
2108 PDWord(@a[3])^:= PDWord(@T1[tempb[3,0]])^ xor
2109 PDWord(@T2[tempb[0,1]])^ xor
2110 PDWord(@T3[tempb[1,2]])^ xor
2111 PDWord(@T4[tempb[2,3]])^;
2112 end;
2113 PDWord(@tempb[0])^:= PDWord(@a[0])^ xor rk[numrounds-1,0];
2114 PDWord(@tempb[1])^:= PDWord(@a[1])^ xor rk[numrounds-1,1];
2115 PDWord(@tempb[2])^:= PDWord(@a[2])^ xor rk[numrounds-1,2];
2116 PDWord(@tempb[3])^:= PDWord(@a[3])^ xor rk[numrounds-1,3];
2117 a[0,0]:= T1[tempb[0,0],1];
2118 a[0,1]:= T1[tempb[1,1],1];
2119 a[0,2]:= T1[tempb[2,2],1];
2120 a[0,3]:= T1[tempb[3,3],1];
2121 a[1,0]:= T1[tempb[1,0],1];
2122 a[1,1]:= T1[tempb[2,1],1];
2123 a[1,2]:= T1[tempb[3,2],1];
2124 a[1,3]:= T1[tempb[0,3],1];
2125 a[2,0]:= T1[tempb[2,0],1];
2126 a[2,1]:= T1[tempb[3,1],1];
2127 a[2,2]:= T1[tempb[0,2],1];
2128 a[2,3]:= T1[tempb[1,3],1];
2129 a[3,0]:= T1[tempb[3,0],1];
2130 a[3,1]:= T1[tempb[0,1],1];
2131 a[3,2]:= T1[tempb[1,2],1];
2132 a[3,3]:= T1[tempb[2,3],1];
2133 PDWord(@a[0])^:= PDWord(@a[0])^ xor rk[numrounds,0];
2134 PDWord(@a[1])^:= PDWord(@a[1])^ xor rk[numrounds,1];
2135 PDWord(@a[2])^:= PDWord(@a[2])^ xor rk[numrounds,2];
2136 PDWord(@a[3])^:= PDWord(@a[3])^ xor rk[numrounds,3];
2137
2138 Result := StringOfChar(#0, 16);
2139 move(p^, pointer(Result)^, 16);
2140end;
2141
2142function TSynaAes.DecryptECB(const InData: AnsiString): AnsiString;
2143var
2144 r: longword;
2145 tempb: array[0..MAXBC-1,0..3] of byte;
2146 a: array[0..MAXBC,0..3] of byte;
2147 p: pointer;
2148begin
2149 p := @a[0,0];
2150 move(pointer(InData)^, p^, 16);
2151 for r:= NumRounds downto 2 do
2152 begin
2153 PDWord(@tempb[0])^:= PDWord(@a[0])^ xor drk[r,0];
2154 PDWord(@tempb[1])^:= PDWord(@a[1])^ xor drk[r,1];
2155 PDWord(@tempb[2])^:= PDWord(@a[2])^ xor drk[r,2];
2156 PDWord(@tempb[3])^:= PDWord(@a[3])^ xor drk[r,3];
2157 PDWord(@a[0])^:= PDWord(@T5[tempb[0,0]])^ xor
2158 PDWord(@T6[tempb[3,1]])^ xor
2159 PDWord(@T7[tempb[2,2]])^ xor
2160 PDWord(@T8[tempb[1,3]])^;
2161 PDWord(@a[1])^:= PDWord(@T5[tempb[1,0]])^ xor
2162 PDWord(@T6[tempb[0,1]])^ xor
2163 PDWord(@T7[tempb[3,2]])^ xor
2164 PDWord(@T8[tempb[2,3]])^;
2165 PDWord(@a[2])^:= PDWord(@T5[tempb[2,0]])^ xor
2166 PDWord(@T6[tempb[1,1]])^ xor
2167 PDWord(@T7[tempb[0,2]])^ xor
2168 PDWord(@T8[tempb[3,3]])^;
2169 PDWord(@a[3])^:= PDWord(@T5[tempb[3,0]])^ xor
2170 PDWord(@T6[tempb[2,1]])^ xor
2171 PDWord(@T7[tempb[1,2]])^ xor
2172 PDWord(@T8[tempb[0,3]])^;
2173 end;
2174 PDWord(@tempb[0])^:= PDWord(@a[0])^ xor drk[1,0];
2175 PDWord(@tempb[1])^:= PDWord(@a[1])^ xor drk[1,1];
2176 PDWord(@tempb[2])^:= PDWord(@a[2])^ xor drk[1,2];
2177 PDWord(@tempb[3])^:= PDWord(@a[3])^ xor drk[1,3];
2178 a[0,0]:= S5[tempb[0,0]];
2179 a[0,1]:= S5[tempb[3,1]];
2180 a[0,2]:= S5[tempb[2,2]];
2181 a[0,3]:= S5[tempb[1,3]];
2182 a[1,0]:= S5[tempb[1,0]];
2183 a[1,1]:= S5[tempb[0,1]];
2184 a[1,2]:= S5[tempb[3,2]];
2185 a[1,3]:= S5[tempb[2,3]];
2186 a[2,0]:= S5[tempb[2,0]];
2187 a[2,1]:= S5[tempb[1,1]];
2188 a[2,2]:= S5[tempb[0,2]];
2189 a[2,3]:= S5[tempb[3,3]];
2190 a[3,0]:= S5[tempb[3,0]];
2191 a[3,1]:= S5[tempb[2,1]];
2192 a[3,2]:= S5[tempb[1,2]];
2193 a[3,3]:= S5[tempb[0,3]];
2194 PDWord(@a[0])^:= PDWord(@a[0])^ xor drk[0,0];
2195 PDWord(@a[1])^:= PDWord(@a[1])^ xor drk[0,1];
2196 PDWord(@a[2])^:= PDWord(@a[2])^ xor drk[0,2];
2197 PDWord(@a[3])^:= PDWord(@a[3])^ xor drk[0,3];
2198 Result := StringOfChar(#0, 16);
2199 move(p^, pointer(Result)^, 16);
2200end;
2201
2202{==============================================================================}
2203
2204function TestDes: boolean;
2205var
2206 des: TSynaDes;
2207 s, t: string;
2208const
2209 key = '01234567';
2210 data1= '01234567';
2211 data2= '0123456789abcdefghij';
2212begin
2213 //ECB
2214 des := TSynaDes.Create(key);
2215 try
2216 s := des.EncryptECB(data1);
2217 t := strtohex(s);
2218 result := t = 'c50ad028c6da9800';
2219 s := des.DecryptECB(s);
2220 result := result and (data1 = s);
2221 finally
2222 des.free;
2223 end;
2224 //CBC
2225 des := TSynaDes.Create(key);
2226 try
2227 s := des.EncryptCBC(data2);
2228 t := strtohex(s);
2229 result := result and (t = 'eec50f6353115ad6dee90a22ed1b6a88a0926e35');
2230 des.Reset;
2231 s := des.DecryptCBC(s);
2232 result := result and (data2 = s);
2233 finally
2234 des.free;
2235 end;
2236 //CFB-8bit
2237 des := TSynaDes.Create(key);
2238 try
2239 s := des.EncryptCFB8bit(data2);
2240 t := strtohex(s);
2241 result := result and (t = 'eb6aa12c2f0ff634b4dfb6da6cb2af8f9c5c1452');
2242 des.Reset;
2243 s := des.DecryptCFB8bit(s);
2244 result := result and (data2 = s);
2245 finally
2246 des.free;
2247 end;
2248 //CFB-block
2249 des := TSynaDes.Create(key);
2250 try
2251 s := des.EncryptCFBblock(data2);
2252 t := strtohex(s);
2253 result := result and (t = 'ebdbbaa7f9286cdec28605e07f9b7f3be1053257');
2254 des.Reset;
2255 s := des.DecryptCFBblock(s);
2256 result := result and (data2 = s);
2257 finally
2258 des.free;
2259 end;
2260 //OFB
2261 des := TSynaDes.Create(key);
2262 try
2263 s := des.EncryptOFB(data2);
2264 t := strtohex(s);
2265 result := result and (t = 'ebdbbaa7f9286cdee0b8b3798c4c34baac87dbdc');
2266 des.Reset;
2267 s := des.DecryptOFB(s);
2268 result := result and (data2 = s);
2269 finally
2270 des.free;
2271 end;
2272 //CTR
2273 des := TSynaDes.Create(key);
2274 try
2275 s := des.EncryptCTR(data2);
2276 t := strtohex(s);
2277 result := result and (t = 'ebdbbaa7f9286cde0dd20b45f3afd9aa1b91b87e');
2278 des.Reset;
2279 s := des.DecryptCTR(s);
2280 result := result and (data2 = s);
2281 finally
2282 des.free;
2283 end;
2284end;
2285
2286function Test3Des: boolean;
2287var
2288 des: TSyna3Des;
2289 s, t: string;
2290const
2291 key = '0123456789abcdefghijklmn';
2292 data1= '01234567';
2293 data2= '0123456789abcdefghij';
2294begin
2295 //ECB
2296 des := TSyna3Des.Create(key);
2297 try
2298 s := des.EncryptECB(data1);
2299 t := strtohex(s);
2300 result := t = 'e0dee91008dc460c';
2301 s := des.DecryptECB(s);
2302 result := result and (data1 = s);
2303 finally
2304 des.free;
2305 end;
2306 //CBC
2307 des := TSyna3Des.Create(key);
2308 try
2309 s := des.EncryptCBC(data2);
2310 t := strtohex(s);
2311 result := result and (t = 'ee844a2a4f49c01b91a1599b8eba29128c1ad87a');
2312 des.Reset;
2313 s := des.DecryptCBC(s);
2314 result := result and (data2 = s);
2315 finally
2316 des.free;
2317 end;
2318 //CFB-8bit
2319 des := TSyna3Des.Create(key);
2320 try
2321 s := des.EncryptCFB8bit(data2);
2322 t := strtohex(s);
2323 result := result and (t = '935bbf5210c32cfa1faf61f91e8dc02dfa0ff1e8');
2324 des.Reset;
2325 s := des.DecryptCFB8bit(s);
2326 result := result and (data2 = s);
2327 finally
2328 des.free;
2329 end;
2330 //CFB-block
2331 des := TSyna3Des.Create(key);
2332 try
2333 s := des.EncryptCFBblock(data2);
2334 t := strtohex(s);
2335 result := result and (t = '93754e3d54828fbf4bd81f1739419e8d2cfe1671');
2336 des.Reset;
2337 s := des.DecryptCFBblock(s);
2338 result := result and (data2 = s);
2339 finally
2340 des.free;
2341 end;
2342 //OFB
2343 des := TSyna3Des.Create(key);
2344 try
2345 s := des.EncryptOFB(data2);
2346 t := strtohex(s);
2347 result := result and (t = '93754e3d54828fbf04ef0a5efc926ebdf2d95f20');
2348 des.Reset;
2349 s := des.DecryptOFB(s);
2350 result := result and (data2 = s);
2351 finally
2352 des.free;
2353 end;
2354 //CTR
2355 des := TSyna3Des.Create(key);
2356 try
2357 s := des.EncryptCTR(data2);
2358 t := strtohex(s);
2359 result := result and (t = '93754e3d54828fbf1c51a121d2c93f989e70b3ad');
2360 des.Reset;
2361 s := des.DecryptCTR(s);
2362 result := result and (data2 = s);
2363 finally
2364 des.free;
2365 end;
2366end;
2367
2368function TestAes: boolean;
2369var
2370 aes: TSynaAes;
2371 s, t: string;
2372const
2373 key1 = #$00#$01#$02#$03#$05#$06#$07#$08#$0A#$0B#$0C#$0D#$0F#$10#$11#$12;
2374 data1= #$50#$68#$12#$A4#$5F#$08#$C8#$89#$B9#$7F#$59#$80#$03#$8B#$83#$59;
2375 key2 = #$A0#$A1#$A2#$A3#$A5#$A6#$A7#$A8#$AA#$AB#$AC#$AD#$AF#$B0#$B1#$B2#$B4#$B5#$B6#$B7#$B9#$BA#$BB#$BC;
2376 data2= #$4F#$1C#$76#$9D#$1E#$5B#$05#$52#$C7#$EC#$A8#$4D#$EA#$26#$A5#$49;
2377 key3 = #$00#$01#$02#$03#$05#$06#$07#$08#$0A#$0B#$0C#$0D#$0F#$10#$11#$12#$14#$15#$16#$17#$19#$1A#$1B#$1C#$1E#$1F#$20#$21#$23#$24#$25#$26;
2378 data3= #$5E#$25#$CA#$78#$F0#$DE#$55#$80#$25#$24#$D3#$8D#$A3#$FE#$44#$56;
2379begin
2380 //ECB
2381 aes := TSynaAes.Create(key1);
2382 try
2383 t := aes.EncryptECB(data1);
2384 result := t = #$D8#$F5#$32#$53#$82#$89#$EF#$7D#$06#$B5#$06#$A4#$FD#$5B#$E9#$C9;
2385 s := aes.DecryptECB(t);
2386 result := result and (data1 = s);
2387 finally
2388 aes.free;
2389 end;
2390 aes := TSynaAes.Create(key2);
2391 try
2392 t := aes.EncryptECB(data2);
2393 result := result and (t = #$F3#$84#$72#$10#$D5#$39#$1E#$23#$60#$60#$8E#$5A#$CB#$56#$05#$81);
2394 s := aes.DecryptECB(t);
2395 result := result and (data2 = s);
2396 finally
2397 aes.free;
2398 end;
2399 aes := TSynaAes.Create(key3);
2400 try
2401 t := aes.EncryptECB(data3);
2402 result := result and (t = #$E8#$B7#$2B#$4E#$8B#$E2#$43#$43#$8C#$9F#$FF#$1F#$0E#$20#$58#$72);
2403 s := aes.DecryptECB(t);
2404 result := result and (data3 = s);
2405 finally
2406 aes.free;
2407 end;
2408end;
2409
2410{==============================================================================}
2411
2412end.
Note: See TracBrowser for help on using the repository browser.