1%%% -*- erlang-indent-level: 2 -*- 2%%%------------------------------------------------------------------- 3%%% File : bs_des.erl 4%%% Author : Per Gustafsson <pergu@it.uu.se> 5%%% Purpose : An implementation of the DES Encryption/Descryption 6%%% algorithm using Erlang binaries. 7%%% 8%%% Created : 14 Apr 2004 9%%%------------------------------------------------------------------- 10-module(bs_des). 11 12-export([encode/2, decode/2, test/0]). 13 14-define(ITERATIONS, 42). %% for benchmarking use a higher number 15 16test() -> 17 Bin = <<1:64>>, 18 Size= byte_size(Bin), 19 Key = <<4704650607608769871263876:64>>, 20 Jumbled = run_encode(?ITERATIONS, Bin, Key), 21 Unjumbled = run_decode(?ITERATIONS, Jumbled, Key), 22 <<Bin:Size/binary,_/binary>> = Unjumbled, 23 ok. 24 25run_encode(1, Bin, Key) -> 26 encode(Bin, Key); 27run_encode(N, Bin, Key) -> 28 encode(Bin, Key), 29 run_encode(N-1, Bin, Key). 30 31run_decode(1, Bin, Key) -> 32 decode(Bin, Key); 33run_decode(N, Bin, Key) -> 34 decode(Bin, Key), 35 run_decode(N-1, Bin, Key). 36 37encode(Data, Key) -> 38 Keys = schedule(Key), 39 list_to_binary(encode_data(Data, Keys)). 40 41decode(Data, Key) -> 42 Keys = lists:reverse(schedule(Key)), 43 list_to_binary(decode_data(Data, Keys)). 44 45encode_data(<<Data:8/binary, Rest/binary>>, Keys) -> 46 [ipinv(des_core(ip(Data), Keys))|encode_data(Rest, Keys)]; 47encode_data(<<Rest/binary>>, Keys) -> 48 case byte_size(Rest) of 49 0 -> []; 50 X -> 51 Y = 8 - X, 52 Data = <<Rest/binary, 0:Y/integer-unit:8>>, 53 [ipinv(des_core(ip(Data), Keys))] 54 end. 55 56decode_data(<<Data:8/binary, Rest/binary>>, Keys) -> 57 [ipinv(dechiper(ip(Data), Keys))|decode_data(Rest, Keys)]; 58decode_data(_, _Keys) -> 59 []. 60 61schedule(Key) -> 62 NewKey = pc1(Key), 63 subkeys(NewKey, 1). 64 65subkeys(_Key, 17) -> 66 []; 67subkeys(Key, N) -> 68 TmpKey = 69 case rotate(N) of 70 1 -> 71 <<X1:1, L:27, X2:1, R:27>> = Key, 72 <<L:27, X1:1, R:27, X2:1>>; 73 2 -> 74 <<X1:2, L:26, X2:2, R:26>> = Key, 75 <<L:26, X1:2, R:26, X2:2>> 76 end, 77 [pc2(TmpKey)|subkeys(TmpKey, N+1)]. 78 79pc2(<<I1:1, I2:1, I3:1, I4:1, I5:1, I6:1, I7:1, I8:1, 80 _I9:1, I10:1, I11:1, I12:1, I13:1, I14:1, I15:1, I16:1, 81 I17:1, _I18:1, I19:1, I20:1, I21:1, _I22:1, I23:1, I24:1, 82 _I25:1, I26:1, I27:1, I28:1, I29:1, I30:1, I31:1, I32:1, 83 I33:1, I34:1, _I35:1, I36:1, I37:1, _I38:1, I39:1, I40:1, 84 I41:1, I42:1, _I43:1, I44:1, I45:1, I46:1, I47:1, I48:1, 85 I49:1, I50:1, I51:1, I52:1, I53:1, _I54:1, I55:1, I56:1>>) -> 86 <<I14:1, I17:1, I11:1, I24:1, I1:1, I5:1, I3:1, I28:1, 87 I15:1, I6:1, I21:1, I10:1, I23:1, I19:1, I12:1, I4:1, 88 I26:1, I8:1, I16:1, I7:1, I27:1, I20:1, I13:1, I2:1, 89 I41:1, I52:1, I31:1, I37:1, I47:1, I55:1, I30:1, I40:1, 90 I51:1, I45:1, I33:1, I48:1, I44:1, I49:1, I39:1, I56:1, 91 I34:1, I53:1, I46:1, I42:1, I50:1, I36:1, I29:1, I32:1>>. 92 93pc1(<<I1:1, I2:1, I3:1, I4:1, I5:1, I6:1, I7:1, _:1, 94 I9:1, I10:1, I11:1, I12:1, I13:1, I14:1, I15:1, _:1, 95 I17:1, I18:1, I19:1, I20:1, I21:1, I22:1, I23:1, _:1, 96 I25:1, I26:1, I27:1, I28:1, I29:1, I30:1, I31:1, _:1, 97 I33:1, I34:1, I35:1, I36:1, I37:1, I38:1, I39:1, _:1, 98 I41:1, I42:1, I43:1, I44:1, I45:1, I46:1, I47:1, _:1, 99 I49:1, I50:1, I51:1, I52:1, I53:1, I54:1, I55:1, _:1, 100 I57:1, I58:1, I59:1, I60:1, I61:1, I62:1, I63:1, _:1>>) -> 101 <<I57:1, I49:1, I41:1, I33:1, I25:1, I17:1, I9:1, I1:1, 102 I58:1, I50:1, I42:1, I34:1, I26:1, I18:1, I10:1, I2:1, 103 I59:1, I51:1, I43:1, I35:1, I27:1, I19:1, I11:1, I3:1, 104 I60:1, I52:1, I44:1, I36:1, I63:1, I55:1, I47:1, I39:1, 105 I31:1, I23:1, I15:1, I7:1, I62:1, I54:1, I46:1, I38:1, 106 I30:1, I22:1, I14:1, I6:1, I61:1, I53:1, I45:1, I37:1, 107 I29:1, I21:1, I13:1, I5:1, I28:1, I20:1, I12:1, I4:1>>. 108 109ip(<<I1:1, I2:1, I3:1, I4:1, I5:1, I6:1, I7:1, I8:1, 110 I9:1, I10:1, I11:1, I12:1, I13:1, I14:1, I15:1, I16:1, 111 I17:1, I18:1, I19:1, I20:1, I21:1, I22:1, I23:1, I24:1, 112 I25:1, I26:1, I27:1, I28:1, I29:1, I30:1, I31:1, I32:1, 113 I33:1, I34:1, I35:1, I36:1, I37:1, I38:1, I39:1, I40:1, 114 I41:1, I42:1, I43:1, I44:1, I45:1, I46:1, I47:1, I48:1, 115 I49:1, I50:1, I51:1, I52:1, I53:1, I54:1, I55:1, I56:1, 116 I57:1, I58:1, I59:1, I60:1, I61:1, I62:1, I63:1, I64:1>>) -> 117 <<I58:1, I50:1, I42:1, I34:1, I26:1, I18:1, I10:1, I2:1, 118 I60:1, I52:1, I44:1, I36:1, I28:1, I20:1, I12:1, I4:1, 119 I62:1, I54:1, I46:1, I38:1, I30:1, I22:1, I14:1, I6:1, 120 I64:1, I56:1, I48:1, I40:1, I32:1, I24:1, I16:1, I8:1, 121 I57:1, I49:1, I41:1, I33:1, I25:1, I17:1, I9:1, I1:1, 122 I59:1, I51:1, I43:1, I35:1, I27:1, I19:1, I11:1, I3:1, 123 I61:1, I53:1, I45:1, I37:1, I29:1, I21:1, I13:1, I5:1, 124 I63:1, I55:1, I47:1, I39:1, I31:1, I23:1, I15:1, I7:1>>. 125 126ipinv(<<I58:1, I50:1, I42:1, I34:1, I26:1, I18:1, I10:1, I2:1, 127 I60:1, I52:1, I44:1, I36:1, I28:1, I20:1, I12:1, I4:1, 128 I62:1, I54:1, I46:1, I38:1, I30:1, I22:1, I14:1, I6:1, 129 I64:1, I56:1, I48:1, I40:1, I32:1, I24:1, I16:1, I8:1, 130 I57:1, I49:1, I41:1, I33:1, I25:1, I17:1, I9:1, I1:1, 131 I59:1, I51:1, I43:1, I35:1, I27:1, I19:1, I11:1, I3:1, 132 I61:1, I53:1, I45:1, I37:1, I29:1, I21:1, I13:1, I5:1, 133 I63:1, I55:1, I47:1, I39:1, I31:1, I23:1, I15:1, I7:1>>) -> 134 <<I1:1, I2:1, I3:1, I4:1, I5:1, I6:1, I7:1, I8:1, 135 I9:1, I10:1, I11:1, I12:1, I13:1, I14:1, I15:1, I16:1, 136 I17:1, I18:1, I19:1, I20:1, I21:1, I22:1, I23:1, I24:1, 137 I25:1, I26:1, I27:1, I28:1, I29:1, I30:1, I31:1, I32:1, 138 I33:1, I34:1, I35:1, I36:1, I37:1, I38:1, I39:1, I40:1, 139 I41:1, I42:1, I43:1, I44:1, I45:1, I46:1, I47:1, I48:1, 140 I49:1, I50:1, I51:1, I52:1, I53:1, I54:1, I55:1, I56:1, 141 I57:1, I58:1, I59:1, I60:1, I61:1, I62:1, I63:1, I64:1>>. 142 143dechiper(<<L:4/binary, R:4/binary>>, Keys) -> 144 dechiper(L, R, Keys, 16). 145 146dechiper(L, R, [], 0) -> 147 <<L:4/binary, R:4/binary>>; 148dechiper(L, R, [Key|Rest], I) -> 149 NewL = ebit(L), 150 XorL = xor48(NewL, Key), 151 Sboxed = sboxing(XorL), 152 Ped = p(Sboxed), 153 EndL = xor32(Ped, R), 154 dechiper(EndL, L, Rest, I-1). 155 156des_core(<<L:4/binary, R:4/binary>>, Keys) -> 157 des_core(L, R, Keys, 0). 158 159des_core(L, R, [], 16) -> 160 <<L:4/binary, R:4/binary>>; 161des_core(L, R, [Key|Rest], I) when I<16 -> 162 NewR = ebit(R), 163 XorR = xor48(NewR, Key), 164 Sboxed = sboxing(XorR), 165 Ped = p(Sboxed), 166 EndR = xor32(Ped, L), 167 des_core(R, EndR, Rest, I+1). 168 169ebit(<<I1:1, I2:2, I3:2,I4:2,I5:2,I6:2, 170 I7:2,I8:2,I9:2,I10:2,I11:2,I12:2, 171 I13:2,I14:2,I15:2,I16:2,I17:1>>) -> 172 <<I17:1, I1:1, I2:2, I3:2, I3:2, 173 I4:2, I5:2, I5:2, I6:2, 174 I7:2, I7:2, I8:2, I9:2, 175 I9:2, I10:2, I11:2, I11:2, 176 I12:2, I13:2, I13:2, I14:2, 177 I15:2, I15:2, I16:2, I17:1, I1:1>>. 178 179p(<<I1:1, I2:1, I3:1, I4:1, I5:1, I6:1, I7:1, I8:1, 180 I9:1, I10:1, I11:1, I12:1, I13:1, I14:1, I15:1, I16:1, 181 I17:1, I18:1, I19:1, I20:1, I21:1, I22:1, I23:1, I24:1, 182 I25:1, I26:1, I27:1, I28:1, I29:1, I30:1, I31:1, I32:1>>) -> 183 <<I16:1, I7:1, I20:1, I21:1, I29:1, I12:1, I28:1, I17:1, 184 I1:1, I15:1, I23:1, I26:1, I5:1, I18:1, I31:1, I10:1, 185 I2:1, I8:1, I24:1, I14:1, I32:1, I27:1, I3:1, I9:1, 186 I19:1, I13:1, I30:1, I6:1, I22:1, I11:1, I4:1, I25:1>>. 187 188rotate(1) -> 1; 189rotate(2) -> 1; 190rotate(9) -> 1; 191rotate(16) -> 1; 192rotate(N) when N>0, N<17 -> 2. 193 194%% xor64(<<I1:16, I2:16, I3:16, I4:16>>,<<J1:16, J2:16, J3:16, J4:16>>) -> 195%% K1 = I1 bxor J1, 196%% K2 = I2 bxor J2, 197%% K3 = I3 bxor J3, 198%% K4 = I4 bxor J4, 199%% <<K1:16, K2:16, K3:16, K4:16>>. 200 201xor48(<<I1:16, I2:16, I3:16>>,<<J1:16, J2:16, J3:16>>) -> 202 K1 = I1 bxor J1, 203 K2 = I2 bxor J2, 204 K3 = I3 bxor J3, 205 <<K1:16, K2:16, K3:16>>. 206 207xor32(<<I1:16, I2:16>>,<<J1:16, J2:16>>) -> 208 K1 = I1 bxor J1, 209 K2 = I2 bxor J2, 210 <<K1:16, K2:16>>. 211 212sboxing(<<A1:6, A2:6, A3:6, A4:6, A5:6, A6:6, A7:6, A8:6>>) -> 213 S1 = sbox(A1, 1), 214 S2 = sbox(A2, 2), 215 S3 = sbox(A3, 3), 216 S4 = sbox(A4, 4), 217 S5 = sbox(A5, 5), 218 S6 = sbox(A6, 6), 219 S7 = sbox(A7, 7), 220 S8 = sbox(A8, 8), 221 <<S1:4,S2:4,S3:4,S4:4,S5:4,S6:4,S7:4,S8:4>>. 222 223sbox(0,1) -> 14; 224sbox(1,1) -> 0; 225sbox(2,1) -> 4; 226sbox(3,1) -> 15; 227sbox(4,1) -> 13; 228sbox(5,1) -> 7; 229sbox(6,1) -> 1; 230sbox(7,1) -> 4; 231sbox(8,1) -> 2; 232sbox(9,1) -> 14; 233sbox(10,1) -> 15; 234sbox(11,1) -> 2; 235sbox(12,1) -> 11; 236sbox(13,1) -> 13; 237sbox(14,1) -> 8; 238sbox(15,1) -> 1; 239sbox(16,1) -> 3; 240sbox(17,1) -> 10; 241sbox(18,1) -> 10; 242sbox(19,1) -> 6; 243sbox(20,1) -> 6; 244sbox(21,1) -> 12; 245sbox(22,1) -> 12; 246sbox(23,1) -> 11; 247sbox(24,1) -> 5; 248sbox(25,1) -> 9; 249sbox(26,1) -> 9; 250sbox(27,1) -> 5; 251sbox(28,1) -> 0; 252sbox(29,1) -> 3; 253sbox(30,1) -> 7; 254sbox(31,1) -> 8; 255sbox(32,1) -> 4; 256sbox(33,1) -> 15; 257sbox(34,1) -> 1; 258sbox(35,1) -> 12; 259sbox(36,1) -> 14; 260sbox(37,1) -> 8; 261sbox(38,1) -> 8; 262sbox(39,1) -> 2; 263sbox(40,1) -> 13; 264sbox(41,1) -> 4; 265sbox(42,1) -> 6; 266sbox(43,1) -> 9; 267sbox(44,1) -> 2; 268sbox(45,1) -> 1; 269sbox(46,1) -> 11; 270sbox(47,1) -> 7; 271sbox(48,1) -> 15; 272sbox(49,1) -> 5; 273sbox(50,1) -> 12; 274sbox(51,1) -> 11; 275sbox(52,1) -> 9; 276sbox(53,1) -> 3; 277sbox(54,1) -> 7; 278sbox(55,1) -> 14; 279sbox(56,1) -> 3; 280sbox(57,1) -> 10; 281sbox(58,1) -> 10; 282sbox(59,1) -> 0; 283sbox(60,1) -> 5; 284sbox(61,1) -> 6; 285sbox(62,1) -> 0; 286sbox(63,1) -> 13; 287sbox(0,2) -> 15; 288sbox(1,2) -> 3; 289sbox(2,2) -> 1; 290sbox(3,2) -> 13; 291sbox(4,2) -> 8; 292sbox(5,2) -> 4; 293sbox(6,2) -> 14; 294sbox(7,2) -> 7; 295sbox(8,2) -> 6; 296sbox(9,2) -> 15; 297sbox(10,2) -> 11; 298sbox(11,2) -> 2; 299sbox(12,2) -> 3; 300sbox(13,2) -> 8; 301sbox(14,2) -> 4; 302sbox(15,2) -> 14; 303sbox(16,2) -> 9; 304sbox(17,2) -> 12; 305sbox(18,2) -> 7; 306sbox(19,2) -> 0; 307sbox(20,2) -> 2; 308sbox(21,2) -> 1; 309sbox(22,2) -> 13; 310sbox(23,2) -> 10; 311sbox(24,2) -> 12; 312sbox(25,2) -> 6; 313sbox(26,2) -> 0; 314sbox(27,2) -> 9; 315sbox(28,2) -> 5; 316sbox(29,2) -> 11; 317sbox(30,2) -> 10; 318sbox(31,2) -> 5; 319sbox(32,2) -> 0; 320sbox(33,2) -> 13; 321sbox(34,2) -> 14; 322sbox(35,2) -> 8; 323sbox(36,2) -> 7; 324sbox(37,2) -> 10; 325sbox(38,2) -> 11; 326sbox(39,2) -> 1; 327sbox(40,2) -> 10; 328sbox(41,2) -> 3; 329sbox(42,2) -> 4; 330sbox(43,2) -> 15; 331sbox(44,2) -> 13; 332sbox(45,2) -> 4; 333sbox(46,2) -> 1; 334sbox(47,2) -> 2; 335sbox(48,2) -> 5; 336sbox(49,2) -> 11; 337sbox(50,2) -> 8; 338sbox(51,2) -> 6; 339sbox(52,2) -> 12; 340sbox(53,2) -> 7; 341sbox(54,2) -> 6; 342sbox(55,2) -> 12; 343sbox(56,2) -> 9; 344sbox(57,2) -> 0; 345sbox(58,2) -> 3; 346sbox(59,2) -> 5; 347sbox(60,2) -> 2; 348sbox(61,2) -> 14; 349sbox(62,2) -> 15; 350sbox(63,2) -> 9; 351sbox(0,3) -> 10; 352sbox(1,3) -> 13; 353sbox(2,3) -> 0; 354sbox(3,3) -> 7; 355sbox(4,3) -> 9; 356sbox(5,3) -> 0; 357sbox(6,3) -> 14; 358sbox(7,3) -> 9; 359sbox(8,3) -> 6; 360sbox(9,3) -> 3; 361sbox(10,3) -> 3; 362sbox(11,3) -> 4; 363sbox(12,3) -> 15; 364sbox(13,3) -> 6; 365sbox(14,3) -> 5; 366sbox(15,3) -> 10; 367sbox(16,3) -> 1; 368sbox(17,3) -> 2; 369sbox(18,3) -> 13; 370sbox(19,3) -> 8; 371sbox(20,3) -> 12; 372sbox(21,3) -> 5; 373sbox(22,3) -> 7; 374sbox(23,3) -> 14; 375sbox(24,3) -> 11; 376sbox(25,3) -> 12; 377sbox(26,3) -> 4; 378sbox(27,3) -> 11; 379sbox(28,3) -> 2; 380sbox(29,3) -> 15; 381sbox(30,3) -> 8; 382sbox(31,3) -> 1; 383sbox(32,3) -> 13; 384sbox(33,3) -> 1; 385sbox(34,3) -> 6; 386sbox(35,3) -> 10; 387sbox(36,3) -> 4; 388sbox(37,3) -> 13; 389sbox(38,3) -> 9; 390sbox(39,3) -> 0; 391sbox(40,3) -> 8; 392sbox(41,3) -> 6; 393sbox(42,3) -> 15; 394sbox(43,3) -> 9; 395sbox(44,3) -> 3; 396sbox(45,3) -> 8; 397sbox(46,3) -> 0; 398sbox(47,3) -> 7; 399sbox(48,3) -> 11; 400sbox(49,3) -> 4; 401sbox(50,3) -> 1; 402sbox(51,3) -> 15; 403sbox(52,3) -> 2; 404sbox(53,3) -> 14; 405sbox(54,3) -> 12; 406sbox(55,3) -> 3; 407sbox(56,3) -> 5; 408sbox(57,3) -> 11; 409sbox(58,3) -> 10; 410sbox(59,3) -> 5; 411sbox(60,3) -> 14; 412sbox(61,3) -> 2; 413sbox(62,3) -> 7; 414sbox(63,3) -> 12; 415sbox(0,4) -> 7; 416sbox(1,4) -> 13; 417sbox(2,4) -> 13; 418sbox(3,4) -> 8; 419sbox(4,4) -> 14; 420sbox(5,4) -> 11; 421sbox(6,4) -> 3; 422sbox(7,4) -> 5; 423sbox(8,4) -> 0; 424sbox(9,4) -> 6; 425sbox(10,4) -> 6; 426sbox(11,4) -> 15; 427sbox(12,4) -> 9; 428sbox(13,4) -> 0; 429sbox(14,4) -> 10; 430sbox(15,4) -> 3; 431sbox(16,4) -> 1; 432sbox(17,4) -> 4; 433sbox(18,4) -> 2; 434sbox(19,4) -> 7; 435sbox(20,4) -> 8; 436sbox(21,4) -> 2; 437sbox(22,4) -> 5; 438sbox(23,4) -> 12; 439sbox(24,4) -> 11; 440sbox(25,4) -> 1; 441sbox(26,4) -> 12; 442sbox(27,4) -> 10; 443sbox(28,4) -> 4; 444sbox(29,4) -> 14; 445sbox(30,4) -> 15; 446sbox(31,4) -> 9; 447sbox(32,4) -> 10; 448sbox(33,4) -> 3; 449sbox(34,4) -> 6; 450sbox(35,4) -> 15; 451sbox(36,4) -> 9; 452sbox(37,4) -> 0; 453sbox(38,4) -> 0; 454sbox(39,4) -> 6; 455sbox(40,4) -> 12; 456sbox(41,4) -> 10; 457sbox(42,4) -> 11; 458sbox(43,4) -> 1; 459sbox(44,4) -> 7; 460sbox(45,4) -> 13; 461sbox(46,4) -> 13; 462sbox(47,4) -> 8; 463sbox(48,4) -> 15; 464sbox(49,4) -> 9; 465sbox(50,4) -> 1; 466sbox(51,4) -> 4; 467sbox(52,4) -> 3; 468sbox(53,4) -> 5; 469sbox(54,4) -> 14; 470sbox(55,4) -> 11; 471sbox(56,4) -> 5; 472sbox(57,4) -> 12; 473sbox(58,4) -> 2; 474sbox(59,4) -> 7; 475sbox(60,4) -> 8; 476sbox(61,4) -> 2; 477sbox(62,4) -> 4; 478sbox(63,4) -> 14; 479sbox(0,5) -> 2; 480sbox(1,5) -> 14; 481sbox(2,5) -> 12; 482sbox(3,5) -> 11; 483sbox(4,5) -> 4; 484sbox(5,5) -> 2; 485sbox(6,5) -> 1; 486sbox(7,5) -> 12; 487sbox(8,5) -> 7; 488sbox(9,5) -> 4; 489sbox(10,5) -> 10; 490sbox(11,5) -> 7; 491sbox(12,5) -> 11; 492sbox(13,5) -> 13; 493sbox(14,5) -> 6; 494sbox(15,5) -> 1; 495sbox(16,5) -> 8; 496sbox(17,5) -> 5; 497sbox(18,5) -> 5; 498sbox(19,5) -> 0; 499sbox(20,5) -> 3; 500sbox(21,5) -> 15; 501sbox(22,5) -> 15; 502sbox(23,5) -> 10; 503sbox(24,5) -> 13; 504sbox(25,5) -> 3; 505sbox(26,5) -> 0; 506sbox(27,5) -> 9; 507sbox(28,5) -> 14; 508sbox(29,5) -> 8; 509sbox(30,5) -> 9; 510sbox(31,5) -> 6; 511sbox(32,5) -> 4; 512sbox(33,5) -> 11; 513sbox(34,5) -> 2; 514sbox(35,5) -> 8; 515sbox(36,5) -> 1; 516sbox(37,5) -> 12; 517sbox(38,5) -> 11; 518sbox(39,5) -> 7; 519sbox(40,5) -> 10; 520sbox(41,5) -> 1; 521sbox(42,5) -> 13; 522sbox(43,5) -> 14; 523sbox(44,5) -> 7; 524sbox(45,5) -> 2; 525sbox(46,5) -> 8; 526sbox(47,5) -> 13; 527sbox(48,5) -> 15; 528sbox(49,5) -> 6; 529sbox(50,5) -> 9; 530sbox(51,5) -> 15; 531sbox(52,5) -> 12; 532sbox(53,5) -> 0; 533sbox(54,5) -> 5; 534sbox(55,5) -> 9; 535sbox(56,5) -> 6; 536sbox(57,5) -> 10; 537sbox(58,5) -> 3; 538sbox(59,5) -> 4; 539sbox(60,5) -> 0; 540sbox(61,5) -> 5; 541sbox(62,5) -> 14; 542sbox(63,5) -> 3; 543sbox(0,6) -> 12; 544sbox(1,6) -> 10; 545sbox(2,6) -> 1; 546sbox(3,6) -> 15; 547sbox(4,6) -> 10; 548sbox(5,6) -> 4; 549sbox(6,6) -> 15; 550sbox(7,6) -> 2; 551sbox(8,6) -> 9; 552sbox(9,6) -> 7; 553sbox(10,6) -> 2; 554sbox(11,6) -> 12; 555sbox(12,6) -> 6; 556sbox(13,6) -> 9; 557sbox(14,6) -> 8; 558sbox(15,6) -> 5; 559sbox(16,6) -> 0; 560sbox(17,6) -> 6; 561sbox(18,6) -> 13; 562sbox(19,6) -> 1; 563sbox(20,6) -> 3; 564sbox(21,6) -> 13; 565sbox(22,6) -> 4; 566sbox(23,6) -> 14; 567sbox(24,6) -> 14; 568sbox(25,6) -> 0; 569sbox(26,6) -> 7; 570sbox(27,6) -> 11; 571sbox(28,6) -> 5; 572sbox(29,6) -> 3; 573sbox(30,6) -> 11; 574sbox(31,6) -> 8; 575sbox(32,6) -> 9; 576sbox(33,6) -> 4; 577sbox(34,6) -> 14; 578sbox(35,6) -> 3; 579sbox(36,6) -> 15; 580sbox(37,6) -> 2; 581sbox(38,6) -> 5; 582sbox(39,6) -> 12; 583sbox(40,6) -> 2; 584sbox(41,6) -> 9; 585sbox(42,6) -> 8; 586sbox(43,6) -> 5; 587sbox(44,6) -> 12; 588sbox(45,6) -> 15; 589sbox(46,6) -> 3; 590sbox(47,6) -> 10; 591sbox(48,6) -> 7; 592sbox(49,6) -> 11; 593sbox(50,6) -> 0; 594sbox(51,6) -> 14; 595sbox(52,6) -> 4; 596sbox(53,6) -> 1; 597sbox(54,6) -> 10; 598sbox(55,6) -> 7; 599sbox(56,6) -> 1; 600sbox(57,6) -> 6; 601sbox(58,6) -> 13; 602sbox(59,6) -> 0; 603sbox(60,6) -> 11; 604sbox(61,6) -> 8; 605sbox(62,6) -> 6; 606sbox(63,6) -> 13; 607sbox(0,7) -> 4; 608sbox(1,7) -> 13; 609sbox(2,7) -> 11; 610sbox(3,7) -> 0; 611sbox(4,7) -> 2; 612sbox(5,7) -> 11; 613sbox(6,7) -> 14; 614sbox(7,7) -> 7; 615sbox(8,7) -> 15; 616sbox(9,7) -> 4; 617sbox(10,7) -> 0; 618sbox(11,7) -> 9; 619sbox(12,7) -> 8; 620sbox(13,7) -> 1; 621sbox(14,7) -> 13; 622sbox(15,7) -> 10; 623sbox(16,7) -> 3; 624sbox(17,7) -> 14; 625sbox(18,7) -> 12; 626sbox(19,7) -> 3; 627sbox(20,7) -> 9; 628sbox(21,7) -> 5; 629sbox(22,7) -> 7; 630sbox(23,7) -> 12; 631sbox(24,7) -> 5; 632sbox(25,7) -> 2; 633sbox(26,7) -> 10; 634sbox(27,7) -> 15; 635sbox(28,7) -> 6; 636sbox(29,7) -> 8; 637sbox(30,7) -> 1; 638sbox(31,7) -> 6; 639sbox(32,7) -> 1; 640sbox(33,7) -> 6; 641sbox(34,7) -> 4; 642sbox(35,7) -> 11; 643sbox(36,7) -> 11; 644sbox(37,7) -> 13; 645sbox(38,7) -> 13; 646sbox(39,7) -> 8; 647sbox(40,7) -> 12; 648sbox(41,7) -> 1; 649sbox(42,7) -> 3; 650sbox(43,7) -> 4; 651sbox(44,7) -> 7; 652sbox(45,7) -> 10; 653sbox(46,7) -> 14; 654sbox(47,7) -> 7; 655sbox(48,7) -> 10; 656sbox(49,7) -> 9; 657sbox(50,7) -> 15; 658sbox(51,7) -> 5; 659sbox(52,7) -> 6; 660sbox(53,7) -> 0; 661sbox(54,7) -> 8; 662sbox(55,7) -> 15; 663sbox(56,7) -> 0; 664sbox(57,7) -> 14; 665sbox(58,7) -> 5; 666sbox(59,7) -> 2; 667sbox(60,7) -> 9; 668sbox(61,7) -> 3; 669sbox(62,7) -> 2; 670sbox(63,7) -> 12; 671sbox(0,8) -> 13; 672sbox(1,8) -> 1; 673sbox(2,8) -> 2; 674sbox(3,8) -> 15; 675sbox(4,8) -> 8; 676sbox(5,8) -> 13; 677sbox(6,8) -> 4; 678sbox(7,8) -> 8; 679sbox(8,8) -> 6; 680sbox(9,8) -> 10; 681sbox(10,8) -> 15; 682sbox(11,8) -> 3; 683sbox(12,8) -> 11; 684sbox(13,8) -> 7; 685sbox(14,8) -> 1; 686sbox(15,8) -> 4; 687sbox(16,8) -> 10; 688sbox(17,8) -> 12; 689sbox(18,8) -> 9; 690sbox(19,8) -> 5; 691sbox(20,8) -> 3; 692sbox(21,8) -> 6; 693sbox(22,8) -> 14; 694sbox(23,8) -> 11; 695sbox(24,8) -> 5; 696sbox(25,8) -> 0; 697sbox(26,8) -> 0; 698sbox(27,8) -> 14; 699sbox(28,8) -> 12; 700sbox(29,8) -> 9; 701sbox(30,8) -> 7; 702sbox(31,8) -> 2; 703sbox(32,8) -> 7; 704sbox(33,8) -> 2; 705sbox(34,8) -> 11; 706sbox(35,8) -> 1; 707sbox(36,8) -> 4; 708sbox(37,8) -> 14; 709sbox(38,8) -> 1; 710sbox(39,8) -> 7; 711sbox(40,8) -> 9; 712sbox(41,8) -> 4; 713sbox(42,8) -> 12; 714sbox(43,8) -> 10; 715sbox(44,8) -> 14; 716sbox(45,8) -> 8; 717sbox(46,8) -> 2; 718sbox(47,8) -> 13; 719sbox(48,8) -> 0; 720sbox(49,8) -> 15; 721sbox(50,8) -> 6; 722sbox(51,8) -> 12; 723sbox(52,8) -> 10; 724sbox(53,8) -> 9; 725sbox(54,8) -> 13; 726sbox(55,8) -> 0; 727sbox(56,8) -> 15; 728sbox(57,8) -> 3; 729sbox(58,8) -> 3; 730sbox(59,8) -> 5; 731sbox(60,8) -> 5; 732sbox(61,8) -> 6; 733sbox(62,8) -> 8; 734sbox(63,8) -> 11. 735