aes_test.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. // Copyright 2012 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.crypt.AesTest');
  15. goog.setTestOnly('goog.crypt.AesTest');
  16. goog.require('goog.crypt');
  17. goog.require('goog.crypt.Aes');
  18. goog.require('goog.testing.jsunit');
  19. goog.crypt.Aes.ENABLE_TEST_MODE = true;
  20. /*
  21. * Unit test for goog.crypt.Aes using the test vectors from the spec:
  22. * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
  23. */
  24. var testData = null;
  25. function test128() {
  26. doTest(
  27. '000102030405060708090a0b0c0d0e0f', '00112233445566778899aabbccddeeff',
  28. v128, true /* encrypt */);
  29. }
  30. function test192() {
  31. doTest(
  32. '000102030405060708090a0b0c0d0e0f1011121314151617',
  33. '00112233445566778899aabbccddeeff', v192, true /* encrypt */);
  34. }
  35. function test256() {
  36. doTest(
  37. '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
  38. '00112233445566778899aabbccddeeff', v256, true /* encrypt */);
  39. }
  40. function test128d() {
  41. doTest(
  42. '000102030405060708090a0b0c0d0e0f', '69c4e0d86a7b0430d8cdb78070b4c55a',
  43. v128d, false /* decrypt */);
  44. }
  45. function test192d() {
  46. doTest(
  47. '000102030405060708090a0b0c0d0e0f1011121314151617',
  48. 'dda97ca4864cdfe06eaf70a0ec0d7191', v192d, false /* decrypt */);
  49. }
  50. function test256d() {
  51. doTest(
  52. '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
  53. '8ea2b7ca516745bfeafc49904b496089', v256d, false /* decrypt */);
  54. }
  55. function doTest(key, input, values, dir) {
  56. testData = values;
  57. var keyArray = goog.crypt.hexToByteArray(key);
  58. var aes = new goog.crypt.Aes(keyArray);
  59. aes.testKeySchedule_ = onTestKeySchedule;
  60. aes.testStartRound_ = onTestStartRound;
  61. aes.testAfterSubBytes_ = onTestAfterSubBytes;
  62. aes.testAfterShiftRows_ = onTestAfterShiftRows;
  63. aes.testAfterMixColumns_ = onTestAfterMixColumns;
  64. aes.testAfterAddRoundKey_ = onTestAfterAddRoundKey;
  65. var inputArr = goog.crypt.hexToByteArray(input);
  66. var keyArr = goog.crypt.hexToByteArray(key);
  67. var outputArr = [];
  68. var outputArr;
  69. if (dir) {
  70. outputArr = aes.encrypt(inputArr);
  71. } else {
  72. outputArr = aes.decrypt(inputArr);
  73. }
  74. assertEquals(
  75. 'Incorrect output for test ' + testData.name,
  76. testData[testData.length - 1].output, encodeHex(outputArr));
  77. }
  78. function onTestKeySchedule(roundNum, keySchedule, keyScheduleIndex) {
  79. assertNotNull(keySchedule);
  80. assertEquals(
  81. 'Incorrect key for round ' + roundNum, testData[roundNum].k_sch,
  82. encodeKey(keySchedule, keyScheduleIndex));
  83. }
  84. function onTestStartRound(roundNum, state) {
  85. assertEquals(
  86. 'Incorrect state for test ' + testData.name + ' at start round ' +
  87. roundNum,
  88. testData[roundNum].start, encodeState(state));
  89. }
  90. function onTestAfterSubBytes(roundNum, state) {
  91. assertEquals(
  92. 'Incorrect state for test ' + testData.name +
  93. ' after sub bytes in round ' + roundNum,
  94. testData[roundNum].s_box, encodeState(state));
  95. }
  96. function onTestAfterShiftRows(roundNum, state) {
  97. assertEquals(
  98. 'Incorrect state for test ' + testData.name +
  99. ' after shift rows in round ' + roundNum,
  100. testData[roundNum].s_row, encodeState(state));
  101. }
  102. function onTestAfterMixColumns(roundNum, state) {
  103. assertEquals(
  104. 'Incorrect state for test ' + testData.name +
  105. ' after mix columns in round ' + roundNum,
  106. testData[roundNum].m_col, encodeState(state));
  107. }
  108. function onTestAfterAddRoundKey(roundNum, state) {
  109. assertEquals(
  110. 'Incorrect state for test ' + testData.name +
  111. ' after adding round key in round ' + roundNum,
  112. testData[roundNum].k_add, encodeState(state));
  113. }
  114. function encodeHex(arr) {
  115. var str = [];
  116. for (var i = 0; i < arr.length; i++) {
  117. str.push(encodeByte(arr[i]));
  118. }
  119. return str.join('');
  120. }
  121. function encodeState(state) {
  122. var s = [];
  123. for (var c = 0; c < 4; c++) {
  124. for (var r = 0; r < 4; r++) {
  125. s.push(encodeByte(state[r][c]));
  126. }
  127. }
  128. return s.join('');
  129. }
  130. function encodeKey(key, round) {
  131. var s = [];
  132. for (var r = round * 4; r < (round * 4 + 4); r++) {
  133. for (var c = 0; c < 4; c++) {
  134. s.push(encodeByte(key[r][c]));
  135. }
  136. }
  137. return s.join('');
  138. }
  139. function encodeByte(val) {
  140. val = Number(val).toString(16);
  141. if (val.length == 1) {
  142. val = '0' + val;
  143. }
  144. return val;
  145. }
  146. var v128 = [];
  147. (function v128_init() {
  148. for (var i = 0; i <= 10; i++) v128[i] = {};
  149. v128.name = '128';
  150. v128[0].input = '00112233445566778899aabbccddeeff';
  151. v128[0].k_sch = '000102030405060708090a0b0c0d0e0f';
  152. v128[1].start = '00102030405060708090a0b0c0d0e0f0';
  153. v128[1].s_box = '63cab7040953d051cd60e0e7ba70e18c';
  154. v128[1].s_row = '6353e08c0960e104cd70b751bacad0e7';
  155. v128[1].m_col = '5f72641557f5bc92f7be3b291db9f91a';
  156. v128[1].k_sch = 'd6aa74fdd2af72fadaa678f1d6ab76fe';
  157. v128[2].start = '89d810e8855ace682d1843d8cb128fe4';
  158. v128[2].s_box = 'a761ca9b97be8b45d8ad1a611fc97369';
  159. v128[2].s_row = 'a7be1a6997ad739bd8c9ca451f618b61';
  160. v128[2].m_col = 'ff87968431d86a51645151fa773ad009';
  161. v128[2].k_sch = 'b692cf0b643dbdf1be9bc5006830b3fe';
  162. v128[3].start = '4915598f55e5d7a0daca94fa1f0a63f7';
  163. v128[3].s_box = '3b59cb73fcd90ee05774222dc067fb68';
  164. v128[3].s_row = '3bd92268fc74fb735767cbe0c0590e2d';
  165. v128[3].m_col = '4c9c1e66f771f0762c3f868e534df256';
  166. v128[3].k_sch = 'b6ff744ed2c2c9bf6c590cbf0469bf41';
  167. v128[4].start = 'fa636a2825b339c940668a3157244d17';
  168. v128[4].s_box = '2dfb02343f6d12dd09337ec75b36e3f0';
  169. v128[4].s_row = '2d6d7ef03f33e334093602dd5bfb12c7';
  170. v128[4].m_col = '6385b79ffc538df997be478e7547d691';
  171. v128[4].k_sch = '47f7f7bc95353e03f96c32bcfd058dfd';
  172. v128[5].start = '247240236966b3fa6ed2753288425b6c';
  173. v128[5].s_box = '36400926f9336d2d9fb59d23c42c3950';
  174. v128[5].s_row = '36339d50f9b539269f2c092dc4406d23';
  175. v128[5].m_col = 'f4bcd45432e554d075f1d6c51dd03b3c';
  176. v128[5].k_sch = '3caaa3e8a99f9deb50f3af57adf622aa';
  177. v128[6].start = 'c81677bc9b7ac93b25027992b0261996';
  178. v128[6].s_box = 'e847f56514dadde23f77b64fe7f7d490';
  179. v128[6].s_row = 'e8dab6901477d4653ff7f5e2e747dd4f';
  180. v128[6].m_col = '9816ee7400f87f556b2c049c8e5ad036';
  181. v128[6].k_sch = '5e390f7df7a69296a7553dc10aa31f6b';
  182. v128[7].start = 'c62fe109f75eedc3cc79395d84f9cf5d';
  183. v128[7].s_box = 'b415f8016858552e4bb6124c5f998a4c';
  184. v128[7].s_row = 'b458124c68b68a014b99f82e5f15554c';
  185. v128[7].m_col = 'c57e1c159a9bd286f05f4be098c63439';
  186. v128[7].k_sch = '14f9701ae35fe28c440adf4d4ea9c026';
  187. v128[8].start = 'd1876c0f79c4300ab45594add66ff41f';
  188. v128[8].s_box = '3e175076b61c04678dfc2295f6a8bfc0';
  189. v128[8].s_row = '3e1c22c0b6fcbf768da85067f6170495';
  190. v128[8].m_col = 'baa03de7a1f9b56ed5512cba5f414d23';
  191. v128[8].k_sch = '47438735a41c65b9e016baf4aebf7ad2';
  192. v128[9].start = 'fde3bad205e5d0d73547964ef1fe37f1';
  193. v128[9].s_box = '5411f4b56bd9700e96a0902fa1bb9aa1';
  194. v128[9].s_row = '54d990a16ba09ab596bbf40ea111702f';
  195. v128[9].m_col = 'e9f74eec023020f61bf2ccf2353c21c7';
  196. v128[9].k_sch = '549932d1f08557681093ed9cbe2c974e';
  197. v128[10].start = 'bd6e7c3df2b5779e0b61216e8b10b689';
  198. v128[10].s_box = '7a9f102789d5f50b2beffd9f3dca4ea7';
  199. v128[10].s_row = '7ad5fda789ef4e272bca100b3d9ff59f';
  200. v128[10].k_sch = '13111d7fe3944a17f307a78b4d2b30c5';
  201. v128[10].output = '69c4e0d86a7b0430d8cdb78070b4c55a';
  202. })();
  203. var v128d = [];
  204. (function v128d_init() {
  205. for (var i = 0; i <= 10; i++) v128d[i] = {};
  206. v128d.name = '128d';
  207. v128d[0].input = '69c4e0d86a7b0430d8cdb78070b4c55a';
  208. v128d[0].k_sch = '13111d7fe3944a17f307a78b4d2b30c5';
  209. v128d[1].start = '7ad5fda789ef4e272bca100b3d9ff59f';
  210. v128d[1].s_row = '7a9f102789d5f50b2beffd9f3dca4ea7';
  211. v128d[1].s_box = 'bd6e7c3df2b5779e0b61216e8b10b689';
  212. v128d[1].k_sch = '549932d1f08557681093ed9cbe2c974e';
  213. v128d[1].k_add = 'e9f74eec023020f61bf2ccf2353c21c7';
  214. v128d[2].start = '54d990a16ba09ab596bbf40ea111702f';
  215. v128d[2].s_row = '5411f4b56bd9700e96a0902fa1bb9aa1';
  216. v128d[2].s_box = 'fde3bad205e5d0d73547964ef1fe37f1';
  217. v128d[2].k_sch = '47438735a41c65b9e016baf4aebf7ad2';
  218. v128d[2].k_add = 'baa03de7a1f9b56ed5512cba5f414d23';
  219. v128d[3].start = '3e1c22c0b6fcbf768da85067f6170495';
  220. v128d[3].s_row = '3e175076b61c04678dfc2295f6a8bfc0';
  221. v128d[3].s_box = 'd1876c0f79c4300ab45594add66ff41f';
  222. v128d[3].k_sch = '14f9701ae35fe28c440adf4d4ea9c026';
  223. v128d[3].k_add = 'c57e1c159a9bd286f05f4be098c63439';
  224. v128d[4].start = 'b458124c68b68a014b99f82e5f15554c';
  225. v128d[4].s_row = 'b415f8016858552e4bb6124c5f998a4c';
  226. v128d[4].s_box = 'c62fe109f75eedc3cc79395d84f9cf5d';
  227. v128d[4].k_sch = '5e390f7df7a69296a7553dc10aa31f6b';
  228. v128d[4].k_add = '9816ee7400f87f556b2c049c8e5ad036';
  229. v128d[5].start = 'e8dab6901477d4653ff7f5e2e747dd4f';
  230. v128d[5].s_row = 'e847f56514dadde23f77b64fe7f7d490';
  231. v128d[5].s_box = 'c81677bc9b7ac93b25027992b0261996';
  232. v128d[5].k_sch = '3caaa3e8a99f9deb50f3af57adf622aa';
  233. v128d[5].k_add = 'f4bcd45432e554d075f1d6c51dd03b3c';
  234. v128d[6].start = '36339d50f9b539269f2c092dc4406d23';
  235. v128d[6].s_row = '36400926f9336d2d9fb59d23c42c3950';
  236. v128d[6].s_box = '247240236966b3fa6ed2753288425b6c';
  237. v128d[6].k_sch = '47f7f7bc95353e03f96c32bcfd058dfd';
  238. v128d[6].k_add = '6385b79ffc538df997be478e7547d691';
  239. v128d[7].start = '2d6d7ef03f33e334093602dd5bfb12c7';
  240. v128d[7].s_row = '2dfb02343f6d12dd09337ec75b36e3f0';
  241. v128d[7].s_box = 'fa636a2825b339c940668a3157244d17';
  242. v128d[7].k_sch = 'b6ff744ed2c2c9bf6c590cbf0469bf41';
  243. v128d[7].k_add = '4c9c1e66f771f0762c3f868e534df256';
  244. v128d[8].start = '3bd92268fc74fb735767cbe0c0590e2d';
  245. v128d[8].s_row = '3b59cb73fcd90ee05774222dc067fb68';
  246. v128d[8].s_box = '4915598f55e5d7a0daca94fa1f0a63f7';
  247. v128d[8].k_sch = 'b692cf0b643dbdf1be9bc5006830b3fe';
  248. v128d[8].k_add = 'ff87968431d86a51645151fa773ad009';
  249. v128d[9].start = 'a7be1a6997ad739bd8c9ca451f618b61';
  250. v128d[9].s_row = 'a761ca9b97be8b45d8ad1a611fc97369';
  251. v128d[9].s_box = '89d810e8855ace682d1843d8cb128fe4';
  252. v128d[9].k_sch = 'd6aa74fdd2af72fadaa678f1d6ab76fe';
  253. v128d[9].k_add = '5f72641557f5bc92f7be3b291db9f91a';
  254. v128d[10].start = '6353e08c0960e104cd70b751bacad0e7';
  255. v128d[10].s_row = '63cab7040953d051cd60e0e7ba70e18c';
  256. v128d[10].s_box = '00102030405060708090a0b0c0d0e0f0';
  257. v128d[10].k_sch = '000102030405060708090a0b0c0d0e0f';
  258. v128d[10].output = '00112233445566778899aabbccddeeff';
  259. })();
  260. var v192 = [];
  261. (function v192_init() {
  262. for (var i = 0; i <= 12; i++) v192[i] = {};
  263. v192.name = '192';
  264. v192[0].input = '00112233445566778899aabbccddeeff';
  265. v192[0].k_sch = '000102030405060708090a0b0c0d0e0f';
  266. v192[1].start = '00102030405060708090a0b0c0d0e0f0';
  267. v192[1].s_box = '63cab7040953d051cd60e0e7ba70e18c';
  268. v192[1].s_row = '6353e08c0960e104cd70b751bacad0e7';
  269. v192[1].m_col = '5f72641557f5bc92f7be3b291db9f91a';
  270. v192[1].k_sch = '10111213141516175846f2f95c43f4fe';
  271. v192[2].start = '4f63760643e0aa85aff8c9d041fa0de4';
  272. v192[2].s_box = '84fb386f1ae1ac977941dd70832dd769';
  273. v192[2].s_row = '84e1dd691a41d76f792d389783fbac70';
  274. v192[2].m_col = '9f487f794f955f662afc86abd7f1ab29';
  275. v192[2].k_sch = '544afef55847f0fa4856e2e95c43f4fe';
  276. v192[3].start = 'cb02818c17d2af9c62aa64428bb25fd7';
  277. v192[3].s_box = '1f770c64f0b579deaaac432c3d37cf0e';
  278. v192[3].s_row = '1fb5430ef0accf64aa370cde3d77792c';
  279. v192[3].m_col = 'b7a53ecbbf9d75a0c40efc79b674cc11';
  280. v192[3].k_sch = '40f949b31cbabd4d48f043b810b7b342';
  281. v192[4].start = 'f75c7778a327c8ed8cfebfc1a6c37f53';
  282. v192[4].s_box = '684af5bc0acce85564bb0878242ed2ed';
  283. v192[4].s_row = '68cc08ed0abbd2bc642ef555244ae878';
  284. v192[4].m_col = '7a1e98bdacb6d1141a6944dd06eb2d3e';
  285. v192[4].k_sch = '58e151ab04a2a5557effb5416245080c';
  286. v192[5].start = '22ffc916a81474416496f19c64ae2532';
  287. v192[5].s_box = '9316dd47c2fa92834390a1de43e43f23';
  288. v192[5].s_row = '93faa123c2903f4743e4dd83431692de';
  289. v192[5].m_col = 'aaa755b34cffe57cef6f98e1f01c13e6';
  290. v192[5].k_sch = '2ab54bb43a02f8f662e3a95d66410c08';
  291. v192[6].start = '80121e0776fd1d8a8d8c31bc965d1fee';
  292. v192[6].s_box = 'cdc972c53854a47e5d64c765904cc028';
  293. v192[6].s_row = 'cd54c7283864c0c55d4c727e90c9a465';
  294. v192[6].m_col = '921f748fd96e937d622d7725ba8ba50c';
  295. v192[6].k_sch = 'f501857297448d7ebdf1c6ca87f33e3c';
  296. v192[7].start = '671ef1fd4e2a1e03dfdcb1ef3d789b30';
  297. v192[7].s_box = '8572a1542fe5727b9e86c8df27bc1404';
  298. v192[7].s_row = '85e5c8042f8614549ebca17b277272df';
  299. v192[7].m_col = 'e913e7b18f507d4b227ef652758acbcc';
  300. v192[7].k_sch = 'e510976183519b6934157c9ea351f1e0';
  301. v192[8].start = '0c0370d00c01e622166b8accd6db3a2c';
  302. v192[8].s_box = 'fe7b5170fe7c8e93477f7e4bf6b98071';
  303. v192[8].s_row = 'fe7c7e71fe7f807047b95193f67b8e4b';
  304. v192[8].m_col = '6cf5edf996eb0a069c4ef21cbfc25762';
  305. v192[8].k_sch = '1ea0372a995309167c439e77ff12051e';
  306. v192[9].start = '7255dad30fb80310e00d6c6b40d0527c';
  307. v192[9].s_box = '40fc5766766c7bcae1d7507f09700010';
  308. v192[9].s_row = '406c501076d70066e17057ca09fc7b7f';
  309. v192[9].m_col = '7478bcdce8a50b81d4327a9009188262';
  310. v192[9].k_sch = 'dd7e0e887e2fff68608fc842f9dcc154';
  311. v192[10].start = 'a906b254968af4e9b4bdb2d2f0c44336';
  312. v192[10].s_box = 'd36f3720907ebf1e8d7a37b58c1c1a05';
  313. v192[10].s_row = 'd37e3705907a1a208d1c371e8c6fbfb5';
  314. v192[10].m_col = '0d73cc2d8f6abe8b0cf2dd9bb83d422e';
  315. v192[10].k_sch = '859f5f237a8d5a3dc0c02952beefd63a';
  316. v192[11].start = '88ec930ef5e7e4b6cc32f4c906d29414';
  317. v192[11].s_box = 'c4cedcabe694694e4b23bfdd6fb522fa';
  318. v192[11].s_row = 'c494bffae62322ab4bb5dc4e6fce69dd';
  319. v192[11].m_col = '71d720933b6d677dc00b8f28238e0fb7';
  320. v192[11].k_sch = 'de601e7827bcdf2ca223800fd8aeda32';
  321. v192[12].start = 'afb73eeb1cd1b85162280f27fb20d585';
  322. v192[12].s_box = '79a9b2e99c3e6cd1aa3476cc0fb70397';
  323. v192[12].s_row = '793e76979c3403e9aab7b2d10fa96ccc';
  324. v192[12].k_sch = 'a4970a331a78dc09c418c271e3a41d5d';
  325. v192[12].output = 'dda97ca4864cdfe06eaf70a0ec0d7191';
  326. })();
  327. var v192d = [];
  328. (function v192d_init() {
  329. for (var i = 0; i <= 12; i++) v192d[i] = {};
  330. v192d.name = '192d';
  331. v192d[0].input = 'dda97ca4864cdfe06eaf70a0ec0d7191';
  332. v192d[0].k_sch = 'a4970a331a78dc09c418c271e3a41d5d';
  333. v192d[1].start = '793e76979c3403e9aab7b2d10fa96ccc';
  334. v192d[1].s_row = '79a9b2e99c3e6cd1aa3476cc0fb70397';
  335. v192d[1].s_box = 'afb73eeb1cd1b85162280f27fb20d585';
  336. v192d[1].k_sch = 'de601e7827bcdf2ca223800fd8aeda32';
  337. v192d[1].k_add = '71d720933b6d677dc00b8f28238e0fb7';
  338. v192d[2].start = 'c494bffae62322ab4bb5dc4e6fce69dd';
  339. v192d[2].s_row = 'c4cedcabe694694e4b23bfdd6fb522fa';
  340. v192d[2].s_box = '88ec930ef5e7e4b6cc32f4c906d29414';
  341. v192d[2].k_sch = '859f5f237a8d5a3dc0c02952beefd63a';
  342. v192d[2].k_add = '0d73cc2d8f6abe8b0cf2dd9bb83d422e';
  343. v192d[3].start = 'd37e3705907a1a208d1c371e8c6fbfb5';
  344. v192d[3].s_row = 'd36f3720907ebf1e8d7a37b58c1c1a05';
  345. v192d[3].s_box = 'a906b254968af4e9b4bdb2d2f0c44336';
  346. v192d[3].k_sch = 'dd7e0e887e2fff68608fc842f9dcc154';
  347. v192d[3].k_add = '7478bcdce8a50b81d4327a9009188262';
  348. v192d[4].start = '406c501076d70066e17057ca09fc7b7f';
  349. v192d[4].s_row = '40fc5766766c7bcae1d7507f09700010';
  350. v192d[4].s_box = '7255dad30fb80310e00d6c6b40d0527c';
  351. v192d[4].k_sch = '1ea0372a995309167c439e77ff12051e';
  352. v192d[4].k_add = '6cf5edf996eb0a069c4ef21cbfc25762';
  353. v192d[5].start = 'fe7c7e71fe7f807047b95193f67b8e4b';
  354. v192d[5].s_row = 'fe7b5170fe7c8e93477f7e4bf6b98071';
  355. v192d[5].s_box = '0c0370d00c01e622166b8accd6db3a2c';
  356. v192d[5].k_sch = 'e510976183519b6934157c9ea351f1e0';
  357. v192d[5].k_add = 'e913e7b18f507d4b227ef652758acbcc';
  358. v192d[6].start = '85e5c8042f8614549ebca17b277272df';
  359. v192d[6].s_row = '8572a1542fe5727b9e86c8df27bc1404';
  360. v192d[6].s_box = '671ef1fd4e2a1e03dfdcb1ef3d789b30';
  361. v192d[6].k_sch = 'f501857297448d7ebdf1c6ca87f33e3c';
  362. v192d[6].k_add = '921f748fd96e937d622d7725ba8ba50c';
  363. v192d[7].start = 'cd54c7283864c0c55d4c727e90c9a465';
  364. v192d[7].s_row = 'cdc972c53854a47e5d64c765904cc028';
  365. v192d[7].s_box = '80121e0776fd1d8a8d8c31bc965d1fee';
  366. v192d[7].k_sch = '2ab54bb43a02f8f662e3a95d66410c08';
  367. v192d[7].k_add = 'aaa755b34cffe57cef6f98e1f01c13e6';
  368. v192d[8].start = '93faa123c2903f4743e4dd83431692de';
  369. v192d[8].s_row = '9316dd47c2fa92834390a1de43e43f23';
  370. v192d[8].s_box = '22ffc916a81474416496f19c64ae2532';
  371. v192d[8].k_sch = '58e151ab04a2a5557effb5416245080c';
  372. v192d[8].k_add = '7a1e98bdacb6d1141a6944dd06eb2d3e';
  373. v192d[9].start = '68cc08ed0abbd2bc642ef555244ae878';
  374. v192d[9].s_row = '684af5bc0acce85564bb0878242ed2ed';
  375. v192d[9].s_box = 'f75c7778a327c8ed8cfebfc1a6c37f53';
  376. v192d[9].k_sch = '40f949b31cbabd4d48f043b810b7b342';
  377. v192d[9].k_add = 'b7a53ecbbf9d75a0c40efc79b674cc11';
  378. v192d[10].start = '1fb5430ef0accf64aa370cde3d77792c';
  379. v192d[10].s_row = '1f770c64f0b579deaaac432c3d37cf0e';
  380. v192d[10].s_box = 'cb02818c17d2af9c62aa64428bb25fd7';
  381. v192d[10].k_sch = '544afef55847f0fa4856e2e95c43f4fe';
  382. v192d[10].k_add = '9f487f794f955f662afc86abd7f1ab29';
  383. v192d[11].start = '84e1dd691a41d76f792d389783fbac70';
  384. v192d[11].s_row = '84fb386f1ae1ac977941dd70832dd769';
  385. v192d[11].s_box = '4f63760643e0aa85aff8c9d041fa0de4';
  386. v192d[11].k_sch = '10111213141516175846f2f95c43f4fe';
  387. v192d[11].k_add = '5f72641557f5bc92f7be3b291db9f91a';
  388. v192d[12].start = '6353e08c0960e104cd70b751bacad0e7';
  389. v192d[12].s_row = '63cab7040953d051cd60e0e7ba70e18c';
  390. v192d[12].s_box = '00102030405060708090a0b0c0d0e0f0';
  391. v192d[12].k_sch = '000102030405060708090a0b0c0d0e0f';
  392. v192d[12].output = '00112233445566778899aabbccddeeff';
  393. })();
  394. var v256 = [];
  395. (function v256_init() {
  396. for (var i = 0; i <= 14; i++) v256[i] = {};
  397. v256.name = '256';
  398. v256[0].input = '00112233445566778899aabbccddeeff';
  399. v256[0].k_sch = '000102030405060708090a0b0c0d0e0f';
  400. v256[1].start = '00102030405060708090a0b0c0d0e0f0';
  401. v256[1].s_box = '63cab7040953d051cd60e0e7ba70e18c';
  402. v256[1].s_row = '6353e08c0960e104cd70b751bacad0e7';
  403. v256[1].m_col = '5f72641557f5bc92f7be3b291db9f91a';
  404. v256[1].k_sch = '101112131415161718191a1b1c1d1e1f';
  405. v256[2].start = '4f63760643e0aa85efa7213201a4e705';
  406. v256[2].s_box = '84fb386f1ae1ac97df5cfd237c49946b';
  407. v256[2].s_row = '84e1fd6b1a5c946fdf4938977cfbac23';
  408. v256[2].m_col = 'bd2a395d2b6ac438d192443e615da195';
  409. v256[2].k_sch = 'a573c29fa176c498a97fce93a572c09c';
  410. v256[3].start = '1859fbc28a1c00a078ed8aadc42f6109';
  411. v256[3].s_box = 'adcb0f257e9c63e0bc557e951c15ef01';
  412. v256[3].s_row = 'ad9c7e017e55ef25bc150fe01ccb6395';
  413. v256[3].m_col = '810dce0cc9db8172b3678c1e88a1b5bd';
  414. v256[3].k_sch = '1651a8cd0244beda1a5da4c10640bade';
  415. v256[4].start = '975c66c1cb9f3fa8a93a28df8ee10f63';
  416. v256[4].s_box = '884a33781fdb75c2d380349e19f876fb';
  417. v256[4].s_row = '88db34fb1f807678d3f833c2194a759e';
  418. v256[4].m_col = 'b2822d81abe6fb275faf103a078c0033';
  419. v256[4].k_sch = 'ae87dff00ff11b68a68ed5fb03fc1567';
  420. v256[5].start = '1c05f271a417e04ff921c5c104701554';
  421. v256[5].s_box = '9c6b89a349f0e18499fda678f2515920';
  422. v256[5].s_row = '9cf0a62049fd59a399518984f26be178';
  423. v256[5].m_col = 'aeb65ba974e0f822d73f567bdb64c877';
  424. v256[5].k_sch = '6de1f1486fa54f9275f8eb5373b8518d';
  425. v256[6].start = 'c357aae11b45b7b0a2c7bd28a8dc99fa';
  426. v256[6].s_box = '2e5bacf8af6ea9e73ac67a34c286ee2d';
  427. v256[6].s_row = '2e6e7a2dafc6eef83a86ace7c25ba934';
  428. v256[6].m_col = 'b951c33c02e9bd29ae25cdb1efa08cc7';
  429. v256[6].k_sch = 'c656827fc9a799176f294cec6cd5598b';
  430. v256[7].start = '7f074143cb4e243ec10c815d8375d54c';
  431. v256[7].s_box = 'd2c5831a1f2f36b278fe0c4cec9d0329';
  432. v256[7].s_row = 'd22f0c291ffe031a789d83b2ecc5364c';
  433. v256[7].m_col = 'ebb19e1c3ee7c9e87d7535e9ed6b9144';
  434. v256[7].k_sch = '3de23a75524775e727bf9eb45407cf39';
  435. v256[8].start = 'd653a4696ca0bc0f5acaab5db96c5e7d';
  436. v256[8].s_box = 'f6ed49f950e06576be74624c565058ff';
  437. v256[8].s_row = 'f6e062ff507458f9be50497656ed654c';
  438. v256[8].m_col = '5174c8669da98435a8b3e62ca974a5ea';
  439. v256[8].k_sch = '0bdc905fc27b0948ad5245a4c1871c2f';
  440. v256[9].start = '5aa858395fd28d7d05e1a38868f3b9c5';
  441. v256[9].s_box = 'bec26a12cfb55dff6bf80ac4450d56a6';
  442. v256[9].s_row = 'beb50aa6cff856126b0d6aff45c25dc4';
  443. v256[9].m_col = '0f77ee31d2ccadc05430a83f4ef96ac3';
  444. v256[9].k_sch = '45f5a66017b2d387300d4d33640a820a';
  445. v256[10].start = '4a824851c57e7e47643de50c2af3e8c9';
  446. v256[10].s_box = 'd61352d1a6f3f3a04327d9fee50d9bdd';
  447. v256[10].s_row = 'd6f3d9dda6279bd1430d52a0e513f3fe';
  448. v256[10].m_col = 'bd86f0ea748fc4f4630f11c1e9331233';
  449. v256[10].k_sch = '7ccff71cbeb4fe5413e6bbf0d261a7df';
  450. v256[11].start = 'c14907f6ca3b3aa070e9aa313b52b5ec';
  451. v256[11].s_box = '783bc54274e280e0511eacc7e200d5ce';
  452. v256[11].s_row = '78e2acce741ed5425100c5e0e23b80c7';
  453. v256[11].m_col = 'af8690415d6e1dd387e5fbedd5c89013';
  454. v256[11].k_sch = 'f01afafee7a82979d7a5644ab3afe640';
  455. v256[12].start = '5f9c6abfbac634aa50409fa766677653';
  456. v256[12].s_box = 'cfde0208f4b418ac5309db5c338538ed';
  457. v256[12].s_row = 'cfb4dbedf4093808538502ac33de185c';
  458. v256[12].m_col = '7427fae4d8a695269ce83d315be0392b';
  459. v256[12].k_sch = '2541fe719bf500258813bbd55a721c0a';
  460. v256[13].start = '516604954353950314fb86e401922521';
  461. v256[13].s_box = 'd133f22a1aed2a7bfa0f44697c4f3ffd';
  462. v256[13].s_row = 'd1ed44fd1a0f3f2afa4ff27b7c332a69';
  463. v256[13].m_col = '2c21a820306f154ab712c75eee0da04f';
  464. v256[13].k_sch = '4e5a6699a9f24fe07e572baacdf8cdea';
  465. v256[14].start = '627bceb9999d5aaac945ecf423f56da5';
  466. v256[14].s_box = 'aa218b56ee5ebeacdd6ecebf26e63c06';
  467. v256[14].s_row = 'aa5ece06ee6e3c56dde68bac2621bebf';
  468. v256[14].k_sch = '24fc79ccbf0979e9371ac23c6d68de36';
  469. v256[14].output = '8ea2b7ca516745bfeafc49904b496089';
  470. })();
  471. var v256d = [];
  472. (function v256d_init() {
  473. for (var i = 0; i <= 14; i++) v256d[i] = {};
  474. v256d.name = '256d';
  475. v256d[0].input = '8ea2b7ca516745bfeafc49904b496089';
  476. v256d[0].k_sch = '24fc79ccbf0979e9371ac23c6d68de36';
  477. v256d[1].start = 'aa5ece06ee6e3c56dde68bac2621bebf';
  478. v256d[1].s_row = 'aa218b56ee5ebeacdd6ecebf26e63c06';
  479. v256d[1].s_box = '627bceb9999d5aaac945ecf423f56da5';
  480. v256d[1].k_sch = '4e5a6699a9f24fe07e572baacdf8cdea';
  481. v256d[1].k_add = '2c21a820306f154ab712c75eee0da04f';
  482. v256d[2].start = 'd1ed44fd1a0f3f2afa4ff27b7c332a69';
  483. v256d[2].s_row = 'd133f22a1aed2a7bfa0f44697c4f3ffd';
  484. v256d[2].s_box = '516604954353950314fb86e401922521';
  485. v256d[2].k_sch = '2541fe719bf500258813bbd55a721c0a';
  486. v256d[2].k_add = '7427fae4d8a695269ce83d315be0392b';
  487. v256d[3].start = 'cfb4dbedf4093808538502ac33de185c';
  488. v256d[3].s_row = 'cfde0208f4b418ac5309db5c338538ed';
  489. v256d[3].s_box = '5f9c6abfbac634aa50409fa766677653';
  490. v256d[3].k_sch = 'f01afafee7a82979d7a5644ab3afe640';
  491. v256d[3].k_add = 'af8690415d6e1dd387e5fbedd5c89013';
  492. v256d[4].start = '78e2acce741ed5425100c5e0e23b80c7';
  493. v256d[4].s_row = '783bc54274e280e0511eacc7e200d5ce';
  494. v256d[4].s_box = 'c14907f6ca3b3aa070e9aa313b52b5ec';
  495. v256d[4].k_sch = '7ccff71cbeb4fe5413e6bbf0d261a7df';
  496. v256d[4].k_add = 'bd86f0ea748fc4f4630f11c1e9331233';
  497. v256d[5].start = 'd6f3d9dda6279bd1430d52a0e513f3fe';
  498. v256d[5].s_row = 'd61352d1a6f3f3a04327d9fee50d9bdd';
  499. v256d[5].s_box = '4a824851c57e7e47643de50c2af3e8c9';
  500. v256d[5].k_sch = '45f5a66017b2d387300d4d33640a820a';
  501. v256d[5].k_add = '0f77ee31d2ccadc05430a83f4ef96ac3';
  502. v256d[6].start = 'beb50aa6cff856126b0d6aff45c25dc4';
  503. v256d[6].s_row = 'bec26a12cfb55dff6bf80ac4450d56a6';
  504. v256d[6].s_box = '5aa858395fd28d7d05e1a38868f3b9c5';
  505. v256d[6].k_sch = '0bdc905fc27b0948ad5245a4c1871c2f';
  506. v256d[6].k_add = '5174c8669da98435a8b3e62ca974a5ea';
  507. v256d[7].start = 'f6e062ff507458f9be50497656ed654c';
  508. v256d[7].s_row = 'f6ed49f950e06576be74624c565058ff';
  509. v256d[7].s_box = 'd653a4696ca0bc0f5acaab5db96c5e7d';
  510. v256d[7].k_sch = '3de23a75524775e727bf9eb45407cf39';
  511. v256d[7].k_add = 'ebb19e1c3ee7c9e87d7535e9ed6b9144';
  512. v256d[8].start = 'd22f0c291ffe031a789d83b2ecc5364c';
  513. v256d[8].s_row = 'd2c5831a1f2f36b278fe0c4cec9d0329';
  514. v256d[8].s_box = '7f074143cb4e243ec10c815d8375d54c';
  515. v256d[8].k_sch = 'c656827fc9a799176f294cec6cd5598b';
  516. v256d[8].k_add = 'b951c33c02e9bd29ae25cdb1efa08cc7';
  517. v256d[9].start = '2e6e7a2dafc6eef83a86ace7c25ba934';
  518. v256d[9].s_row = '2e5bacf8af6ea9e73ac67a34c286ee2d';
  519. v256d[9].s_box = 'c357aae11b45b7b0a2c7bd28a8dc99fa';
  520. v256d[9].k_sch = '6de1f1486fa54f9275f8eb5373b8518d';
  521. v256d[9].k_add = 'aeb65ba974e0f822d73f567bdb64c877';
  522. v256d[10].start = '9cf0a62049fd59a399518984f26be178';
  523. v256d[10].s_row = '9c6b89a349f0e18499fda678f2515920';
  524. v256d[10].s_box = '1c05f271a417e04ff921c5c104701554';
  525. v256d[10].k_sch = 'ae87dff00ff11b68a68ed5fb03fc1567';
  526. v256d[10].k_add = 'b2822d81abe6fb275faf103a078c0033';
  527. v256d[11].start = '88db34fb1f807678d3f833c2194a759e';
  528. v256d[11].s_row = '884a33781fdb75c2d380349e19f876fb';
  529. v256d[11].s_box = '975c66c1cb9f3fa8a93a28df8ee10f63';
  530. v256d[11].k_sch = '1651a8cd0244beda1a5da4c10640bade';
  531. v256d[11].k_add = '810dce0cc9db8172b3678c1e88a1b5bd';
  532. v256d[12].start = 'ad9c7e017e55ef25bc150fe01ccb6395';
  533. v256d[12].s_row = 'adcb0f257e9c63e0bc557e951c15ef01';
  534. v256d[12].s_box = '1859fbc28a1c00a078ed8aadc42f6109';
  535. v256d[12].k_sch = 'a573c29fa176c498a97fce93a572c09c';
  536. v256d[12].k_add = 'bd2a395d2b6ac438d192443e615da195';
  537. v256d[13].start = '84e1fd6b1a5c946fdf4938977cfbac23';
  538. v256d[13].s_row = '84fb386f1ae1ac97df5cfd237c49946b';
  539. v256d[13].s_box = '4f63760643e0aa85efa7213201a4e705';
  540. v256d[13].k_sch = '101112131415161718191a1b1c1d1e1f';
  541. v256d[13].k_add = '5f72641557f5bc92f7be3b291db9f91a';
  542. v256d[14].start = '6353e08c0960e104cd70b751bacad0e7';
  543. v256d[14].s_row = '63cab7040953d051cd60e0e7ba70e18c';
  544. v256d[14].s_box = '00102030405060708090a0b0c0d0e0f0';
  545. v256d[14].k_sch = '000102030405060708090a0b0c0d0e0f';
  546. v256d[14].output = '00112233445566778899aabbccddeeff';
  547. })();