| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "./cipher"], function (require, exports, cipher_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _AdvancedEncryption128Cipher = (function (_super) { __extends(_AdvancedEncryption128Cipher, _super); function _AdvancedEncryption128Cipher(key) { var _this = _super.call(this) || this; _this._cyclesOfRepetition = 10; _this._keySize = 160; _this._key = new Uint8Array([ 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x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5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d ]); _this._key = _this._expandKey(key); return _this; } _AdvancedEncryption128Cipher.prototype._expandKey = function (cipherKey) { var count = 176; var s = this._s; var rcon = this._key; var result = new Uint8Array(count); result.set(cipherKey); for (var j = 16, i = 1; j < count; ++i) { var t1 = result[j - 3]; var t2 = result[j - 2]; var t3 = result[j - 1]; var t4 = result[j - 4]; t1 = s[t1]; t2 = s[t2]; t3 = s[t3]; t4 = s[t4]; t1 ^= rcon[i]; for (var n = 0; n < 4; ++n) { result[j] = t1 ^= result[j - 16]; result[j + 1] = t2 ^= result[j - 15]; result[j + 2] = t3 ^= result[j - 14]; result[j + 3] = t4 ^= result[j - 13]; j += 4; } } return result; }; return _AdvancedEncryption128Cipher; }(cipher_1._AdvancedEncryptionBaseCipher)); exports._AdvancedEncryption128Cipher = _AdvancedEncryption128Cipher; var _AdvancedEncryption256Cipher = (function (_super) { __extends(_AdvancedEncryption256Cipher, _super); function _AdvancedEncryption256Cipher(key) { var _this = _super.call(this) || this; _this._cyclesOfRepetition = 14; _this._keySize = 224; _this._key = _this._expandKey(key); return _this; } _AdvancedEncryption256Cipher.prototype._expandKey = function (cipherKey) { var count = 240; var s = this._s; var result = new Uint8Array(count); result.set(cipherKey); var r = 1; var t1; var t2; var t3; var t4; for (var j = 32, i = 1; j < count; ++i) { if (j % 32 === 16) { t1 = s[t1]; t2 = s[t2]; t3 = s[t3]; t4 = s[t4]; } else if (j % 32 === 0) { t1 = result[j - 3]; t2 = result[j - 2]; t3 = result[j - 1]; t4 = result[j - 4]; t1 = s[t1]; t2 = s[t2]; t3 = s[t3]; t4 = s[t4]; t1 ^= r; r = r << 1; if (r >= 256) { r = (r ^ 0x1b) & 0xff; } } for (var n = 0; n < 4; ++n) { result[j] = t1 ^= result[j - 32]; result[j + 1] = t2 ^= result[j - 31]; result[j + 2] = t3 ^= result[j - 30]; result[j + 3] = t4 ^= result[j - 29]; j += 4; } } return result; }; return _AdvancedEncryption256Cipher; }(cipher_1._AdvancedEncryptionBaseCipher)); exports._AdvancedEncryption256Cipher = _AdvancedEncryption256Cipher; }); |