1 line
159 KiB
Plaintext
1 line
159 KiB
Plaintext
|
{"version":3,"file":"cryptico.iife.js","sources":["../src/aes.ts","../src/random.ts","../src/jsbn.ts","../src/hash/native.ts","../src/hash/index.ts","../src/hash/node.ts","../src/rsa.ts","../src/api.ts"],"sourcesContent":["/*\n * jsaes version 0.1 - Copyright 2006 B. Poettering\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License as\n * published by the Free Software Foundation; either version 2 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\n * 02111-1307 USA\n */\n\n// later modifications by wwwtyro@github\n\nimport { ByteArray } from './type'\n\nexport type AESKey = ByteArray\n\nexport const aes = <const>{\n // eslint-disable-next-line prettier/prettier\n Sbox: [\n 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,\n 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114,\n 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49,\n 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9,\n 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209,\n 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170,\n 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143,\n 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236,\n 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34,\n 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6,\n 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213,\n 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166,\n 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3,\n 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217,\n 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230,\n 66, 104, 65, 153, 45, 15, 176, 84, 187, 22,\n ] as ByteArray,\n\n ShiftRowTab: [\n 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11,\n ] as ByteArray,\n\n Sbox_Inv: new Array<number>(256),\n ShiftRowTab_Inv: new Array<number>(16),\n xtime: new Array<number>(256),\n\n Init() {\n for (let i = 0; i < 256; i++) this.Sbox_Inv[this.Sbox[i]] = i\n\n for (let i = 0; i < 16; i++) this.ShiftRowTab_Inv[this.ShiftRowTab[i]] = i\n\n for (let i = 0; i < 128; i++) {\n this.xtime[i] = i << 1\n this.xtime[128 + i] = (i << 1) ^ 0x1b\n }\n },\n\n Done() {\n this.Sbox_Inv.length = 0\n this.Sbox_Inv.length = 256\n this.ShiftRowTab_Inv.length = 0\n this.ShiftRowTab_Inv.length = 16\n this.xtime.length = 0\n this.xtime.length = 256\n },\n\n ExpandKey(key: AESKey) {\n const kl = key.length\n let ks,\n Rcon = 1\n switch (kl) {\n case 16:\n ks = 16 * (10 + 1)\n break\n case 24:\n ks = 16 * (12 + 1)\n break\n case 32:\n ks = 16 * (14 + 1)\n break\n default:\n throw 'my.ExpandKey: Only key lengths of 16, 24 or 32 bytes allowed!'\n }\n for (let i = kl; i < ks; i += 4) {\n let temp = key.slice(i - 4, i)\n if (i % kl === 0) {\n temp = [\n aes.Sbox[temp[1]] ^ Rcon,\n aes.Sbox[temp[2]],\n aes.Sbox[temp[3]],\n aes.Sbox[temp[0]],\n ]\n if ((Rcon <<= 1) >= 256) Rcon ^= 0x11b\n } else if (kl > 24 && i % kl === 16)\n temp = [\n aes.Sbox[temp[0]],\n aes.Sbox[temp[1]],\n aes.Sbox[temp[2]],\n aes.Sbox[temp[3
|