@etherna/sdk-js
Version:
Etherna SDKs for operations on the network
1,461 lines (1,458 loc) • 385 kB
JavaScript
var ot = Object.defineProperty;
var dt = (n, e, t) => e in n ? ot(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var D = (n, e, t) => (dt(n, typeof e != "symbol" ? e + "" : e, t), t);
import { AxiosError } from "axios";
import { produce } from "immer";
function checkReference(n) {
if (!(n instanceof Uint8Array))
throw new Error("Given referennce is not an Uint8Array instance.");
if (n.length !== 32 && n.length !== 64)
throw new Error("Wrong reference length. Entry only can be 32 or 64 length in bytes");
}
function checkBytes(n, e) {
if (!(n instanceof Uint8Array))
throw Error("Cannot set given bytes, because is not an Uint8Array type");
if (n.length !== 32)
throw Error(
`Cannot set given bytes, because it does not have ${e} length. Got ${n.length}`
);
}
function findIndexOfArray(n, e) {
for (let t = 0; t <= n.length - e.length; t++) {
let s = 0;
for (; s < e.length && n[t + s] === e[s++]; )
;
if (s === e.length)
return t;
}
return -1;
}
function overwriteBytes(n, e, t = 0) {
if (n.length < e.length + t)
throw Error(
`Cannot copy bytes because the base byte array length is lesser (${n.length}) than the others (${e.length})`
);
for (let s = 0; s < e.length; s++)
n[s + t] = e[s];
}
function flattenBytesArray(n) {
if (n.length === 0)
return new Uint8Array(0);
const e = n.map((Q) => Q.length).reduce((Q, B) => Q += B), t = new Uint8Array(e);
let s = 0;
for (const Q of n)
overwriteBytes(t, Q, s), s += Q.length;
return t;
}
function equalBytes(n, e) {
return n.length !== e.length ? !1 : n.every((t, s) => e[s] === t);
}
function encryptDecrypt(n, e, t = 0, s) {
if (!equalBytes(n, new Uint8Array(32))) {
s || (s = e.length);
for (let Q = t; Q < s; Q += n.length) {
const B = Q + n.length, F = B <= e.length ? B : e.length, U = e.slice(Q, F);
for (let o = 0; o < U.length; o++)
U[o] = Number(U[o]) ^ Number(n[o % n.length]);
e.set(U, Q);
}
}
}
function fromBigEndian(n) {
if (n.length === 0)
throw Error("fromBigEndian got 0 length bytes");
const e = [], t = n.length - 1;
for (let s = 0; s < n.length; s++)
e.push(n[t - s] << 8 * s);
return e.reduce((s, Q) => s |= Q) >>> 0;
}
function toBigEndianFromUint16(n) {
if (n < 0)
throw Error(`toBigEndianFromUint16 got lesser than 0 value: ${n}`);
const e = 65535;
if (n > e)
throw Error(`toBigEndianFromUint16 got greater value then ${e}: ${n} `);
const t = new ArrayBuffer(2);
return new DataView(t).setUint16(0, n, !1), new Uint8Array(t);
}
function toBigEndianFromBigInt64(n) {
if (n < 0)
throw Error(`toBigEndianFromBigInt64 got lesser than 0 value: ${n}`);
const e = new ArrayBuffer(8);
return new DataView(e).setBigUint64(0, n, !1), new Uint8Array(e);
}
function common(n, e) {
let t = new Uint8Array(0);
for (let s = 0; s < n.length && s < e.length && n[s] === e[s]; s++)
t = new Uint8Array([...t, n[s]]);
return t;
}
class IndexBytes {
constructor() {
D(this, "bytes");
this.bytes = new Uint8Array(32);
}
get getBytes() {
return new Uint8Array([...this.bytes]);
}
set setBytes(e) {
checkBytes(e, 32), this.bytes = new Uint8Array([...e]);
}
/**
*
* @param byte is number max 255
*/
setByte(e) {
if (e > 255)
throw Error(`IndexBytes setByte error: ${e} is greater than 255`);
this.bytes[Math.floor(e / 8)] |= 1 << e % 8;
}
/**
* checks the given byte is mapped in the Bytes<32> index
*
* @param byte is number max 255
*/
checkBytePresent(e) {
return (this.bytes[Math.floor(e / 8)] >> e % 8 & 1) > 0;
}
/** Iterates through on the indexed byte values */
forEach(e) {
for (let t = 0; t <= 255; t++)
this.checkBytePresent(t) && e(t);
}
}
const SPAN_SIZE = 8, MAX_CHUNK_PAYLOAD_SIZE = 4096, IDENTIFIER_SIZE = 32, SIGNATURE_SIZE = 65, SOC_IDENTIFIER_OFFSET = 0, SOC_SIGNATURE_OFFSET = SOC_IDENTIFIER_OFFSET + IDENTIFIER_SIZE, SOC_SPAN_OFFSET = SOC_SIGNATURE_OFFSET + SIGNATURE_SIZE, SOC_PAYLOAD_OFFSET = SOC_SPAN_OFFSET + SPAN_SIZE, BUCKET_DEPTH = 16, STAMPS_DEPTH_MIN = 17, buffersEquals = (n, e) => n.length === e.length && n.every((t, s) => t === e[s]);
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var extendStatics = function(n, e) {
return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, s) {
t.__proto__ = s;
} || function(t, s) {
for (var Q in s)
s.hasOwnProperty(Q) && (t[Q] = s[Q]);
}, extendStatics(n, e);
};
function __extends(n, e) {
extendStatics(n, e);
function t() {
this.constructor = n;
}
n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
}
/**
* @license crypto-ts
* MIT license
*/
var Hex = (
/** @class */
function() {
function n() {
}
return n.stringify = /**
* Converts a word array to a hex string.
*
* \@example
*
* let hexString = Hex.stringify(wordArray);
* @param {?} wordArray The word array.
*
* @return {?} The hex string.
*
*/
function(e) {
for (var t = [], s = 0; s < e.sigBytes; s++) {
var Q = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255;
t.push((Q >>> 4).toString(16)), t.push((Q & 15).toString(16));
}
return t.join("");
}, n.parse = /**
* Converts a hex string to a word array.
*
* \@example
*
* let wordArray = Hex.parse(hexString);
* @param {?} hexStr The hex string.
*
* @return {?} The word array.
*
*/
function(e) {
for (var t = e.length, s = [], Q = 0; Q < t; Q += 2)
s[Q >>> 3] |= parseInt(e.substr(Q, 2), 16) << 24 - Q % 8 * 4;
return new WordArray(s, t / 2);
}, n;
}()
), WordArray = (
/** @class */
function() {
function n(e, t) {
this.words = e || [], t !== void 0 ? this.sigBytes = t : this.sigBytes = this.words.length * 4;
}
return n.random = /**
* Creates a word array filled with random bytes.
*
* \@example
*
* let wordArray = WordArray.random(16);
* @param {?} nBytes The number of random bytes to generate.
*
* @return {?} The random word array.
*
*/
function(e) {
for (var t = [], s = function(U) {
var o = 987654321, a = 4294967295;
return function() {
o = 36969 * (o & 65535) + (o >> 16) & a, U = 18e3 * (U & 65535) + (U >> 16) & a;
var d = (o << 16) + U & a;
return d /= 4294967296, d += 0.5, d * (Math.random() > 0.5 ? 1 : -1);
};
}, Q = 0, B = void 0; Q < e; Q += 4) {
var F = s((B || Math.random()) * 4294967296);
B = F() * 987654071, t.push(F() * 4294967296 | 0);
}
return new n(t, e);
}, n.prototype.toString = /**
* Converts this word array to a string.
*
* \@example
*
* let string = wordArray + '';
* let string = wordArray.toString();
* let string = wordArray.toString(CryptoJS.enc.Utf8);
* @param {?=} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
*
* @return {?} The stringified word array.
*
*/
function(e) {
return (e || Hex).stringify(this);
}, n.prototype.concat = /**
* Concatenates a word array to this word array.
*
* \@example
*
* wordArray1.concat(wordArray2);
* @param {?} wordArray The word array to append.
*
* @return {?} This word array.
*
*/
function(e) {
if (this.clamp(), this.sigBytes % 4)
for (var t = 0; t < e.sigBytes; t++) {
var s = e.words[t >>> 2] >>> 24 - t % 4 * 8 & 255;
this.words[this.sigBytes + t >>> 2] |= s << 24 - (this.sigBytes + t) % 4 * 8;
}
else
for (var t = 0; t < e.sigBytes; t += 4)
this.words[this.sigBytes + t >>> 2] = e.words[t >>> 2];
return this.sigBytes += e.sigBytes, this;
}, n.prototype.clamp = /**
* Removes insignificant bits.
*
* \@example
*
* wordArray.clamp();
* @return {?}
*/
function() {
this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8, this.words.length = Math.ceil(this.sigBytes / 4);
}, n.prototype.clone = /**
* Creates a copy of this word array.
*
* \@example
*
* let clone = wordArray.clone();
* @return {?} The clone.
*
*/
function() {
return new n(this.words.slice(0), this.sigBytes);
}, n;
}()
), Latin1 = (
/** @class */
function() {
function n() {
}
return n.stringify = /**
* Converts a word array to a Latin1 string.
*
* \@example
*
* let latin1String = Latin1.stringify(wordArray);
* @param {?} wordArray The word array.
*
* @return {?} The Latin1 string.
*
*/
function(e) {
for (var t = [], s = 0; s < e.sigBytes; s++) {
var Q = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255;
t.push(String.fromCharCode(Q));
}
return t.join("");
}, n.parse = /**
* Converts a Latin1 string to a word array.
*
* \@example
*
* let wordArray = Latin1.parse(latin1String);
* @param {?} latin1Str The Latin1 string.
*
* @return {?} The word array.
*
*/
function(e) {
for (var t = e.length, s = [], Q = 0; Q < t; Q++)
s[Q >>> 2] |= (e.charCodeAt(Q) & 255) << 24 - Q % 4 * 8;
return new WordArray(s, t);
}, n;
}()
), Utf8 = (
/** @class */
function() {
function n() {
}
return n.stringify = /**
* Converts a word array to a UTF-8 string.
*
* \@example
*
* let utf8String = Utf8.stringify(wordArray);
* @param {?} wordArray The word array.
*
* @return {?} The UTF-8 string.
*
*/
function(e) {
try {
return decodeURIComponent(escape(Latin1.stringify(e)));
} catch {
throw new Error("Malformed UTF-8 data");
}
}, n.parse = /**
* Converts a UTF-8 string to a word array.
*
* \@example
*
* let wordArray = Utf8.parse(utf8String);
* @param {?} utf8Str The UTF-8 string.
*
* @return {?} The word array.
*
*/
function(e) {
return Latin1.parse(unescape(encodeURIComponent(e)));
}, n;
}()
), BufferedBlockAlgorithm = (
/** @class */
function() {
function n(e) {
this._minBufferSize = 0, this.cfg = Object.assign({
blockSize: 1
}, e), this._data = new WordArray(), this._nDataBytes = 0;
}
return n.prototype.reset = /**
* Resets this block algorithm's data buffer to its initial state.
*
* \@example
*
* bufferedBlockAlgorithm.reset();
* @return {?}
*/
function() {
this._data = new WordArray(), this._nDataBytes = 0;
}, n.prototype._append = /**
* Adds new data to this block algorithm's buffer.
*
* \@example
*
* bufferedBlockAlgorithm._append('data');
* bufferedBlockAlgorithm._append(wordArray);
* @param {?} data The data to append. Strings are converted to a WordArray using UTF-8.
*
* @return {?}
*/
function(e) {
typeof e == "string" && (e = Utf8.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes;
}, n.prototype._process = /**
* Processes available data blocks.
*
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
*
* \@example
*
* let processedData = bufferedBlockAlgorithm._process();
* let processedData = bufferedBlockAlgorithm._process(!!'flush');
* @param {?=} doFlush Whether all blocks and partial blocks should be processed.
*
* @return {?} The processed data.
*
*/
function(e) {
if (!this.cfg.blockSize)
throw new Error("missing blockSize in config");
var t = this.cfg.blockSize * 4, s = this._data.sigBytes / t;
e ? s = Math.ceil(s) : s = Math.max((s | 0) - this._minBufferSize, 0);
var Q = s * this.cfg.blockSize, B = Math.min(Q * 4, this._data.sigBytes), F;
if (Q) {
for (var U = 0; U < Q; U += this.cfg.blockSize)
this._doProcessBlock(this._data.words, U);
F = this._data.words.splice(0, Q), this._data.sigBytes -= B;
}
return new WordArray(F, B);
}, n.prototype.clone = /**
* Creates a copy of this object.
*
* \@example
*
* let clone = bufferedBlockAlgorithm.clone();
* @return {?} The clone.
*
*/
function() {
var e = this.constructor();
for (var t in this)
this.hasOwnProperty(t) && (e[t] = this[t]);
return e._data = this._data.clone(), e;
}, n;
}()
), Base = (
/** @class */
/* @__PURE__ */ function() {
function n() {
}
return n;
}()
), CipherParams = (
/** @class */
function(n) {
__extends(e, n);
function e(t) {
var s = n.call(this) || this;
return s.ciphertext = t.ciphertext, s.key = t.key, s.iv = t.iv, s.salt = t.salt, s.algorithm = t.algorithm, s.mode = t.mode, s.padding = t.padding, s.blockSize = t.blockSize, s.formatter = t.formatter, s;
}
return e.prototype.extend = /**
* @param {?} additionalParams
* @return {?}
*/
function(t) {
return t.ciphertext !== void 0 && (this.ciphertext = t.ciphertext), t.key !== void 0 && (this.key = t.key), t.iv !== void 0 && (this.iv = t.iv), t.salt !== void 0 && (this.salt = t.salt), t.algorithm !== void 0 && (this.algorithm = t.algorithm), t.mode !== void 0 && (this.mode = t.mode), t.padding !== void 0 && (this.padding = t.padding), t.blockSize !== void 0 && (this.blockSize = t.blockSize), t.formatter !== void 0 && (this.formatter = t.formatter), this;
}, e.prototype.toString = /**
* Converts this cipher params object to a string.
*
* @throws Error If neither the formatter nor the default formatter is set.
*
* \@example
*
* let string = cipherParams + '';
* let string = cipherParams.toString();
* let string = cipherParams.toString(CryptoJS.format.OpenSSL);
* @param {?=} formatter (Optional) The formatting strategy to use.
*
* @return {?} The stringified cipher params.
*
*/
function(t) {
if (t)
return t.stringify(this);
if (this.formatter)
return this.formatter.stringify(this);
throw new Error("cipher needs a formatter to be able to convert the result into a string");
}, e;
}(Base)
), Base64 = (
/** @class */
function() {
function n() {
}
return n.stringify = /**
* Converts a word array to a Base64 string.
*
* \@example
*
* let base64String = Base64.stringify(wordArray);
* @param {?} wordArray The word array.
*
* @return {?} The Base64 string.
*
*/
function(e) {
e.clamp();
for (var t = [], s = 0; s < e.sigBytes; s += 3)
for (var Q = e.words[s >>> 2] >>> 24 - s % 4 * 8 & 255, B = e.words[s + 1 >>> 2] >>> 24 - (s + 1) % 4 * 8 & 255, F = e.words[s + 2 >>> 2] >>> 24 - (s + 2) % 4 * 8 & 255, U = Q << 16 | B << 8 | F, o = 0; o < 4 && s + o * 0.75 < e.sigBytes; o++)
t.push(this._map.charAt(U >>> 6 * (3 - o) & 63));
var a = this._map.charAt(64);
if (a)
for (; t.length % 4; )
t.push(a);
return t.join("");
}, n.parse = /**
* Converts a Base64 string to a word array.
*
* \@example
*
* let wordArray = Base64.parse(base64String);
* @param {?} base64Str The Base64 string.
*
* @return {?} The word array.
*
*/
function(e) {
var t = e.length;
if (this._reverseMap === void 0) {
this._reverseMap = [];
for (var s = 0; s < this._map.length; s++)
this._reverseMap[this._map.charCodeAt(s)] = s;
}
var Q = this._map.charAt(64);
if (Q) {
var B = e.indexOf(Q);
B !== -1 && (t = B);
}
return this.parseLoop(e, t, this._reverseMap);
}, n.parseLoop = /**
* @param {?} base64Str
* @param {?} base64StrLength
* @param {?} reverseMap
* @return {?}
*/
function(e, t, s) {
for (var Q = [], B = 0, F = 0; F < t; F++)
if (F % 4) {
var U = s[e.charCodeAt(F - 1)] << F % 4 * 2, o = s[e.charCodeAt(F)] >>> 6 - F % 4 * 2;
Q[B >>> 2] |= (U | o) << 24 - B % 4 * 8, B++;
}
return new WordArray(Q, B);
}, n._map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", n._reverseMap = void 0, n;
}()
), OpenSSL = (
/** @class */
function() {
function n() {
}
return n.stringify = /**
* Converts a cipher params object to an OpenSSL-compatible string.
*
* \@example
*
* let openSSLString = OpenSSLFormatter.stringify(cipherParams);
* @param {?} cipherParams The cipher params object.
*
* @return {?} The OpenSSL-compatible string.
*
*/
function(e) {
if (!e.ciphertext)
throw new Error("missing ciphertext in params");
var t = e.ciphertext, s = e.salt, Q;
if (s) {
if (typeof s == "string")
throw new Error("salt is expected to be a WordArray");
Q = new WordArray([1398893684, 1701076831]).concat(s).concat(t);
} else
Q = t;
return Q.toString(Base64);
}, n.parse = /**
* Converts an OpenSSL-compatible string to a cipher params object.
*
* \@example
*
* let cipherParams = OpenSSLFormatter.parse(openSSLString);
* @param {?} openSSLStr The OpenSSL-compatible string.
*
* @return {?} The cipher params object.
*
*/
function(e) {
var t = Base64.parse(e), s;
return t.words[0] === 1398893684 && t.words[1] === 1701076831 && (s = new WordArray(t.words.slice(2, 4)), t.words.splice(0, 4), t.sigBytes -= 16), new CipherParams({ ciphertext: t, salt: s });
}, n;
}()
), SerializableCipher = (
/** @class */
function() {
function n() {
}
return n.encrypt = /**
* Encrypts a message.
*
* \@example
*
* let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
* let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
* let ciphertextParams = SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, {
* iv: iv,
* format: CryptoJS.format.OpenSSL
* });
* @param {?} cipher The cipher algorithm to use.
* @param {?} message The message to encrypt.
* @param {?} key The key.
* @param {?=} cfg (Optional) The configuration options to use for this operation.
*
* @return {?} A cipher params object.
*
*/
function(e, t, s, Q) {
var B = Object.assign({}, this.cfg, Q), F = e.createEncryptor(s, B), U = F.finalize(t);
return new CipherParams({
ciphertext: U,
key: s,
iv: F.cfg.iv,
algorithm: e,
mode: (
/** @type {?} */
F.cfg.mode
),
padding: (
/** @type {?} */
F.cfg.padding
),
blockSize: F.cfg.blockSize,
formatter: B.format
});
}, n.decrypt = /**
* Decrypts serialized ciphertext.
*
* \@example
*
* let plaintext = SerializableCipher.decrypt(
* AESAlgorithm,
* formattedCiphertext,
* key, {
* iv: iv,
* format: CryptoJS.format.OpenSSL
* }
* );
*
* let plaintext = SerializableCipher.decrypt(
* AESAlgorithm,
* ciphertextParams,
* key, {
* iv: iv,
* format: CryptoJS.format.OpenSSL
* }
* );
* @param {?} cipher The cipher algorithm to use.
* @param {?} ciphertext The ciphertext to decrypt.
* @param {?} key The key.
* @param {?=} optionalCfg
* @return {?} The plaintext.
*
*/
function(e, t, s, Q) {
var B = Object.assign({}, this.cfg, Q);
if (!B.format)
throw new Error("could not determine format");
if (t = this._parse(t, B.format), !t.ciphertext)
throw new Error("could not determine ciphertext");
var F = e.createDecryptor(s, B).finalize(t.ciphertext);
return F;
}, n._parse = /**
* Converts serialized ciphertext to CipherParams,
* else assumed CipherParams already and returns ciphertext unchanged.
*
* \@example
*
* var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
* @param {?} ciphertext The ciphertext.
* @param {?} format The formatting strategy to use to parse serialized ciphertext.
*
* @return {?} The unserialized ciphertext.
*
*/
function(e, t) {
return typeof e == "string" ? t.parse(e) : e;
}, n.cfg = {
blockSize: 4,
iv: new WordArray([]),
format: OpenSSL
}, n;
}()
), Hasher = (
/** @class */
function(n) {
__extends(e, n);
function e(t) {
var s = (
// Apply config defaults
n.call(this, Object.assign({
blockSize: 16
}, t)) || this
);
return s.reset(), s;
}
return e._createHelper = /**
* Creates a shortcut function to a hasher's object interface.
*
* \@example
*
* let SHA256 = Hasher._createHelper(SHA256);
* @param {?} hasher The hasher to create a helper for.
*
* @return {?} The shortcut function.
*
*/
function(t) {
function s(Q, B) {
var F = t, U = new F(B);
return U.finalize(Q);
}
return s;
}, e.prototype.update = /**
* Updates this hasher with a message.
*
* \@example
*
* hasher.update('message');
* hasher.update(wordArray);
* @param {?} messageUpdate The message to append.
*
* @return {?} This hasher.
*
*/
function(t) {
return this._append(t), this._process(), this;
}, e.prototype.finalize = /**
* Finalizes the hash computation.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* \@example
*
* let hash = hasher.finalize();
* let hash = hasher.finalize('message');
* let hash = hasher.finalize(wordArray);
* @param {?} messageUpdate (Optional) A final message update.
*
* @return {?} The hash.
*
*/
function(t) {
t && this._append(t);
var s = this._doFinalize();
return s;
}, e;
}(BufferedBlockAlgorithm)
), T = [];
for (var i = 0; i < 64; i++)
T[i] = Math.abs(Math.sin(i + 1)) * 4294967296 | 0;
var MD5 = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.FF = /**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} x
* @param {?} s
* @param {?} t
* @return {?}
*/
function(t, s, Q, B, F, U, o) {
var a = t + (s & Q | ~s & B) + F + o;
return (a << U | a >>> 32 - U) + s;
}, e.GG = /**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} x
* @param {?} s
* @param {?} t
* @return {?}
*/
function(t, s, Q, B, F, U, o) {
var a = t + (s & B | Q & ~B) + F + o;
return (a << U | a >>> 32 - U) + s;
}, e.HH = /**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} x
* @param {?} s
* @param {?} t
* @return {?}
*/
function(t, s, Q, B, F, U, o) {
var a = t + (s ^ Q ^ B) + F + o;
return (a << U | a >>> 32 - U) + s;
}, e.II = /**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} x
* @param {?} s
* @param {?} t
* @return {?}
*/
function(t, s, Q, B, F, U, o) {
var a = t + (Q ^ (s | ~B)) + F + o;
return (a << U | a >>> 32 - U) + s;
}, e.prototype.reset = /**
* @return {?}
*/
function() {
n.prototype.reset.call(this), this._hash = new WordArray([
1732584193,
4023233417,
2562383102,
271733878
]);
}, e.prototype._doProcessBlock = /**
* @param {?} M
* @param {?} offset
* @return {?}
*/
function(t, s) {
for (var Q = 0; Q < 16; Q++) {
var B = s + Q, F = t[B];
t[B] = (F << 8 | F >>> 24) & 16711935 | (F << 24 | F >>> 8) & 4278255360;
}
var U = this._hash.words, o = t[s + 0], a = t[s + 1], d = t[s + 2], E = t[s + 3], N = t[s + 4], C = t[s + 5], V = t[s + 6], y = t[s + 7], b = t[s + 8], R = t[s + 9], L = t[s + 10], G = t[s + 11], Y = t[s + 12], _ = t[s + 13], J = t[s + 14], w = t[s + 15], I = U[0], u = U[1], g = U[2], x = U[3];
I = e.FF(I, u, g, x, o, 7, T[0]), x = e.FF(x, I, u, g, a, 12, T[1]), g = e.FF(g, x, I, u, d, 17, T[2]), u = e.FF(u, g, x, I, E, 22, T[3]), I = e.FF(I, u, g, x, N, 7, T[4]), x = e.FF(x, I, u, g, C, 12, T[5]), g = e.FF(g, x, I, u, V, 17, T[6]), u = e.FF(u, g, x, I, y, 22, T[7]), I = e.FF(I, u, g, x, b, 7, T[8]), x = e.FF(x, I, u, g, R, 12, T[9]), g = e.FF(g, x, I, u, L, 17, T[10]), u = e.FF(u, g, x, I, G, 22, T[11]), I = e.FF(I, u, g, x, Y, 7, T[12]), x = e.FF(x, I, u, g, _, 12, T[13]), g = e.FF(g, x, I, u, J, 17, T[14]), u = e.FF(u, g, x, I, w, 22, T[15]), I = e.GG(I, u, g, x, a, 5, T[16]), x = e.GG(x, I, u, g, V, 9, T[17]), g = e.GG(g, x, I, u, G, 14, T[18]), u = e.GG(u, g, x, I, o, 20, T[19]), I = e.GG(I, u, g, x, C, 5, T[20]), x = e.GG(x, I, u, g, L, 9, T[21]), g = e.GG(g, x, I, u, w, 14, T[22]), u = e.GG(u, g, x, I, N, 20, T[23]), I = e.GG(I, u, g, x, R, 5, T[24]), x = e.GG(x, I, u, g, J, 9, T[25]), g = e.GG(g, x, I, u, E, 14, T[26]), u = e.GG(u, g, x, I, b, 20, T[27]), I = e.GG(I, u, g, x, _, 5, T[28]), x = e.GG(x, I, u, g, d, 9, T[29]), g = e.GG(g, x, I, u, y, 14, T[30]), u = e.GG(u, g, x, I, Y, 20, T[31]), I = e.HH(I, u, g, x, C, 4, T[32]), x = e.HH(x, I, u, g, b, 11, T[33]), g = e.HH(g, x, I, u, G, 16, T[34]), u = e.HH(u, g, x, I, J, 23, T[35]), I = e.HH(I, u, g, x, a, 4, T[36]), x = e.HH(x, I, u, g, N, 11, T[37]), g = e.HH(g, x, I, u, y, 16, T[38]), u = e.HH(u, g, x, I, L, 23, T[39]), I = e.HH(I, u, g, x, _, 4, T[40]), x = e.HH(x, I, u, g, o, 11, T[41]), g = e.HH(g, x, I, u, E, 16, T[42]), u = e.HH(u, g, x, I, V, 23, T[43]), I = e.HH(I, u, g, x, R, 4, T[44]), x = e.HH(x, I, u, g, Y, 11, T[45]), g = e.HH(g, x, I, u, w, 16, T[46]), u = e.HH(u, g, x, I, d, 23, T[47]), I = e.II(I, u, g, x, o, 6, T[48]), x = e.II(x, I, u, g, y, 10, T[49]), g = e.II(g, x, I, u, J, 15, T[50]), u = e.II(u, g, x, I, C, 21, T[51]), I = e.II(I, u, g, x, Y, 6, T[52]), x = e.II(x, I, u, g, E, 10, T[53]), g = e.II(g, x, I, u, L, 15, T[54]), u = e.II(u, g, x, I, a, 21, T[55]), I = e.II(I, u, g, x, b, 6, T[56]), x = e.II(x, I, u, g, w, 10, T[57]), g = e.II(g, x, I, u, V, 15, T[58]), u = e.II(u, g, x, I, _, 21, T[59]), I = e.II(I, u, g, x, N, 6, T[60]), x = e.II(x, I, u, g, G, 10, T[61]), g = e.II(g, x, I, u, d, 15, T[62]), u = e.II(u, g, x, I, R, 21, T[63]), U[0] = U[0] + I | 0, U[1] = U[1] + u | 0, U[2] = U[2] + g | 0, U[3] = U[3] + x | 0;
}, e.prototype._doFinalize = /**
* @return {?}
*/
function() {
var t = this._data, s = t.words, Q = this._nDataBytes * 8, B = t.sigBytes * 8;
s[B >>> 5] |= 128 << 24 - B % 32;
var F = Math.floor(Q / 4294967296), U = Q;
s[(B + 64 >>> 9 << 4) + 15] = (F << 8 | F >>> 24) & 16711935 | (F << 24 | F >>> 8) & 4278255360, s[(B + 64 >>> 9 << 4) + 14] = (U << 8 | U >>> 24) & 16711935 | (U << 24 | U >>> 8) & 4278255360, t.sigBytes = (s.length + 1) * 4, this._process();
for (var o = this._hash, a = o.words, d = 0; d < 4; d++) {
var E = a[d];
a[d] = (E << 8 | E >>> 24) & 16711935 | (E << 24 | E >>> 8) & 4278255360;
}
return o;
}, e;
}(Hasher)
), EvpKDF = (
/** @class */
function() {
function n(e) {
this.cfg = Object.assign({
keySize: 128 / 32,
hasher: MD5,
iterations: 1
}, e);
}
return n.prototype.compute = /**
* Derives a key from a password.
*
* \@example
*
* let key = kdf.compute(password, salt);
* @param {?} password The password.
* @param {?} salt A salt.
*
* @return {?} The derived key.
*
*/
function(e, t) {
for (var s = new /** @type {?} */
this.cfg.hasher(), Q = new WordArray(), B; Q.words.length < this.cfg.keySize; ) {
B && s.update(B), B = s.update(e).finalize(t), s.reset();
for (var F = 1; F < this.cfg.iterations; F++)
B = s.finalize(B), s.reset();
Q.concat(B);
}
return Q.sigBytes = this.cfg.keySize * 4, Q;
}, n;
}()
), OpenSSLKdf = (
/** @class */
function() {
function n() {
}
return n.execute = /**
* Derives a key and IV from a password.
*
* \@example
*
* let derivedParams = OpenSSL.execute('Password', 256/32, 128/32);
* let derivedParams = OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
* @param {?} password The password to derive from.
* @param {?} keySize The size in words of the key to generate.
* @param {?} ivSize The size in words of the IV to generate.
* @param {?=} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
*
* @return {?} A cipher params object with the key, IV, and salt.
*
*/
function(e, t, s, Q) {
Q || (Q = WordArray.random(64 / 8));
var B = new EvpKDF({ keySize: t + s }).compute(e, Q), F = new WordArray(B.words.slice(t), s * 4);
return B.sigBytes = t * 4, new CipherParams({ key: B, iv: F, salt: Q });
}, n;
}()
), PasswordBasedCipher = (
/** @class */
function() {
function n() {
}
return n.encrypt = /**
* Encrypts a message using a password.
*
* \@example
*
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(AES, message, 'password');
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(AES, message, 'password', { format: OpenSSL });
* @param {?} cipher The cipher algorithm to use.
* @param {?} message The message to encrypt.
* @param {?} password The password.
* @param {?=} cfg (Optional) The configuration options to use for this operation.
*
* @return {?} A cipher params object.
*
*/
function(e, t, s, Q) {
var B = Object.assign({}, this.cfg, Q);
if (B.kdf === void 0)
throw new Error("missing kdf in config");
var F = B.kdf.execute(s, e.keySize, e.ivSize);
F.iv !== void 0 && (B.iv = F.iv);
var U = SerializableCipher.encrypt.call(this, e, t, F.key, B);
return U.extend(F);
}, n.decrypt = /**
* Decrypts serialized ciphertext using a password.
*
* \@example
*
* var plaintext = PasswordBasedCipher.decrypt(AES, formattedCiphertext, 'password', { format: OpenSSL });
* var plaintext = PasswordBasedCipher.decrypt(AES, ciphertextParams, 'password', { format: OpenSSL });
* @param {?} cipher The cipher algorithm to use.
* @param {?} ciphertext The ciphertext to decrypt.
* @param {?} password The password.
* @param {?=} cfg (Optional) The configuration options to use for this operation.
*
* @return {?} The plaintext.
*
*/
function(e, t, s, Q) {
var B = Object.assign({}, this.cfg, Q);
if (B.format === void 0)
throw new Error("missing format in config");
if (t = this._parse(t, B.format), B.kdf === void 0)
throw new Error("the key derivation function must be set");
var F = B.kdf.execute(s, e.keySize, e.ivSize, t.salt);
F.iv !== void 0 && (B.iv = F.iv);
var U = SerializableCipher.decrypt.call(this, e, t, F.key, B);
return U;
}, n._parse = /**
* Converts serialized ciphertext to CipherParams,
* else assumed CipherParams already and returns ciphertext unchanged.
*
* \@example
*
* var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
* @param {?} ciphertext The ciphertext.
* @param {?} format The formatting strategy to use to parse serialized ciphertext.
*
* @return {?} The unserialized ciphertext.
*
*/
function(e, t) {
return typeof e == "string" ? t.parse(e) : e;
}, n.cfg = {
blockSize: 4,
iv: new WordArray([]),
format: OpenSSL,
kdf: OpenSSLKdf
}, n;
}()
), Cipher = (
/** @class */
function(n) {
__extends(e, n);
function e(t, s, Q) {
var B = (
// Apply config defaults
n.call(this, Object.assign({
blockSize: 1
}, Q)) || this
);
return B._xformMode = t, B._key = s, B.reset(), B;
}
return e.createEncryptor = /**
* Creates this cipher in encryption mode.
*
* \@example
*
* let cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray });
* @param {?} key The key.
* @param {?=} cfg (Optional) The configuration options to use for this operation.
*
* @return {?} A cipher instance.
*
*/
function(t, s) {
var Q = this;
return new Q(this._ENC_XFORM_MODE, t, s);
}, e.createDecryptor = /**
* Creates this cipher in decryption mode.
*
* \@example
*
* let cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray });
* @param {?} key The key.
* @param {?=} cfg (Optional) The configuration options to use for this operation.
*
* @return {?} A cipher instance.
*
*/
function(t, s) {
var Q = this;
return new Q(this._DEC_XFORM_MODE, t, s);
}, e._createHelper = /**
* Creates shortcut functions to a cipher's object interface.
*
* \@example
*
* let AES = Cipher._createHelper(AESAlgorithm);
* @param {?} cipher The cipher to create a helper for.
*
* @return {?} An object with encrypt and decrypt shortcut functions.
*
*/
function(t) {
function s(B, F, U) {
return typeof F == "string" ? PasswordBasedCipher.encrypt(t, B, F, U) : SerializableCipher.encrypt(t, B, F, U);
}
function Q(B, F, U) {
return typeof F == "string" ? PasswordBasedCipher.decrypt(t, B, F, U) : SerializableCipher.decrypt(t, B, F, U);
}
return {
encrypt: s,
decrypt: Q
};
}, e.prototype.process = /**
* Adds data to be encrypted or decrypted.
*
* \@example
*
* let encrypted = cipher.process('data');
* let encrypted = cipher.process(wordArray);
* @param {?} dataUpdate The data to encrypt or decrypt.
*
* @return {?} The data after processing.
*
*/
function(t) {
return this._append(t), this._process();
}, e.prototype.finalize = /**
* Finalizes the encryption or decryption process.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* \@example
*
* var encrypted = cipher.finalize();
* var encrypted = cipher.finalize('data');
* var encrypted = cipher.finalize(wordArray);
* @param {?=} dataUpdate The final data to encrypt or decrypt.
*
* @return {?} The data after final processing.
*
*/
function(t) {
t && this._append(t);
var s = this._doFinalize();
return s;
}, e._ENC_XFORM_MODE = 1, e._DEC_XFORM_MODE = 2, e.keySize = 4, e.ivSize = 4, e;
}(BufferedBlockAlgorithm)
), BlockCipherModeAlgorithm = (
/** @class */
function() {
function n(e, t) {
this.init(e, t);
}
return n.prototype.init = /**
* Initializes a newly created mode.
*
* \@example
*
* var mode = CBC.Encryptor.create(cipher, iv.words);
* @param {?} cipher A block cipher instance.
* @param {?=} iv The IV words.
*
* @return {?}
*/
function(e, t) {
this._cipher = e, this._iv = t;
}, n;
}()
), BlockCipherMode = (
/** @class */
function() {
function n() {
}
return n.createEncryptor = /**
* Creates this mode for encryption.
*
* \@example
*
* var mode = CBC.createEncryptor(cipher, iv.words);
* @param {?} cipher A block cipher instance.
* @param {?} iv The IV words.
*
* @return {?}
*/
function(e, t) {
var s = this.Encryptor;
return new s(e, t);
}, n.createDecryptor = /**
* Creates this mode for decryption.
*
* \@example
*
* var mode = CBC.createDecryptor(cipher, iv.words);
* @param {?} cipher A block cipher instance.
* @param {?} iv The IV words.
*
* @return {?}
*/
function(e, t) {
var s = this.Decryptor;
return new s(e, t);
}, n.Encryptor = BlockCipherModeAlgorithm, n.Decryptor = BlockCipherModeAlgorithm, n;
}()
), CBCEncryptor = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.prototype.processBlock = /**
* Processes the data block at offset.
*
* \@example
*
* mode.processBlock(data.words, offset);
* @param {?} words The data words to operate on.
* @param {?} offset The offset where the block starts.
*
* @return {?}
*/
function(t, s) {
if (this._cipher.cfg.blockSize === void 0)
throw new Error("missing blockSize in cipher config");
this.xorBlock(t, s, this._cipher.cfg.blockSize), this._cipher.encryptBlock(t, s), this._prevBlock = t.slice(s, s + this._cipher.cfg.blockSize);
}, e.prototype.xorBlock = /**
* @param {?} words
* @param {?} offset
* @param {?} blockSize
* @return {?}
*/
function(t, s, Q) {
var B;
if (this._iv ? (B = this._iv, this._iv = void 0) : B = this._prevBlock, B !== void 0)
for (var F = 0; F < Q; F++)
t[s + F] ^= B[F];
}, e;
}(BlockCipherModeAlgorithm)
), CBCDecryptor = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.prototype.processBlock = /**
* Processes the data block at offset.
*
* \@example
*
* mode.processBlock(data.words, offset);
* @param {?} words The data words to operate on.
* @param {?} offset The offset where the block starts.
*
* @return {?}
*/
function(t, s) {
if (this._cipher.cfg.blockSize === void 0)
throw new Error("missing blockSize in cipher config");
var Q = t.slice(s, s + this._cipher.cfg.blockSize);
this._cipher.decryptBlock(t, s), this.xorBlock(t, s, this._cipher.cfg.blockSize), this._prevBlock = Q;
}, e.prototype.xorBlock = /**
* @param {?} words
* @param {?} offset
* @param {?} blockSize
* @return {?}
*/
function(t, s, Q) {
var B;
if (this._iv ? (B = this._iv, this._iv = void 0) : B = this._prevBlock, B !== void 0)
for (var F = 0; F < Q; F++)
t[s + F] ^= B[F];
}, e;
}(BlockCipherModeAlgorithm)
), CBC = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.Encryptor = CBCEncryptor, e.Decryptor = CBCDecryptor, e;
}(BlockCipherMode)
), PKCS7 = (
/** @class */
function() {
function n() {
}
return n.pad = /**
* Pads data using the algorithm defined in PKCS #5/7.
*
* \@example
*
* PKCS7.pad(wordArray, 4);
* @param {?} data The data to pad.
* @param {?} blockSize The multiple that the data should be padded to.
*
* @return {?}
*/
function(e, t) {
for (var s = t * 4, Q = s - e.sigBytes % s, B = Q << 24 | Q << 16 | Q << 8 | Q, F = [], U = 0; U < Q; U += 4)
F.push(B);
var o = new WordArray(F, Q);
e.concat(o);
}, n.unpad = /**
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
*
* \@example
*
* PKCS7.unpad(wordArray);
* @param {?} data The data to unpad.
*
* @return {?}
*/
function(e) {
var t = e.words[e.sigBytes - 1 >>> 2] & 255;
e.sigBytes -= t;
}, n;
}()
), BlockCipher = (
/** @class */
function(n) {
__extends(e, n);
function e(t, s, Q) {
return n.call(this, t, s, Object.assign({
// default: 128 / 32
blockSize: 4,
mode: CBC,
padding: PKCS7
}, Q)) || this;
}
return e.prototype.reset = /**
* @return {?}
*/
function() {
if (n.prototype.reset.call(this), this.cfg.mode === void 0)
throw new Error("missing mode in config");
var t;
this._xformMode === /** @type {?} */
this.constructor._ENC_XFORM_MODE ? t = this.cfg.mode.createEncryptor : (t = this.cfg.mode.createDecryptor, this._minBufferSize = 1), this._mode && this._mode.__creator === t ? this._mode.init(this, this.cfg.iv && this.cfg.iv.words) : (this._mode = t.call(this.cfg.mode, this, this.cfg.iv && this.cfg.iv.words), this._mode.__creator = t);
}, e.prototype._doProcessBlock = /**
* @param {?} words
* @param {?} offset
* @return {?}
*/
function(t, s) {
this._mode.processBlock(t, s);
}, e.prototype._doFinalize = /**
* @return {?}
*/
function() {
if (this.cfg.padding === void 0)
throw new Error("missing padding in config");
var t;
if (this._xformMode === /** @type {?} */
this.constructor._ENC_XFORM_MODE) {
if (this.cfg.blockSize === void 0)
throw new Error("missing blockSize in config");
this.cfg.padding.pad(this._data, this.cfg.blockSize), t = this._process(!0);
} else
t = this._process(!0), this.cfg.padding.unpad(t);
return t;
}, e;
}(Cipher)
), SBOX = [], INV_SBOX = [], SUB_MIX_0 = [], SUB_MIX_1 = [], SUB_MIX_2 = [], SUB_MIX_3 = [], INV_SUB_MIX_0 = [], INV_SUB_MIX_1 = [], INV_SUB_MIX_2 = [], INV_SUB_MIX_3 = [];
(function() {
for (var n = [], e = 0; e < 256; e++)
e < 128 ? n[e] = e << 1 : n[e] = e << 1 ^ 283;
for (var t = 0, s = 0, e = 0; e < 256; e++) {
var Q = s ^ s << 1 ^ s << 2 ^ s << 3 ^ s << 4;
Q = Q >>> 8 ^ Q & 255 ^ 99, SBOX[t] = Q, INV_SBOX[Q] = t;
var B = n[t], F = n[B], U = n[F], o = n[Q] * 257 ^ Q * 16843008;
SUB_MIX_0[t] = o << 24 | o >>> 8, SUB_MIX_1[t] = o << 16 | o >>> 16, SUB_MIX_2[t] = o << 8 | o >>> 24, SUB_MIX_3[t] = o, o = U * 16843009 ^ F * 65537 ^ B * 257 ^ t * 16843008, INV_SUB_MIX_0[Q] = o << 24 | o >>> 8, INV_SUB_MIX_1[Q] = o << 16 | o >>> 16, INV_SUB_MIX_2[Q] = o << 8 | o >>> 24, INV_SUB_MIX_3[Q] = o, t ? (t = B ^ n[n[n[U ^ B]]], s ^= n[n[s]]) : t = s = 1;
}
})();
var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], AES = (
/** @class */
function(n) {
__extends(e, n);
function e(t, s, Q) {
return n.call(this, t, s, Q) || this;
}
return e.prototype.reset = /**
* @return {?}
*/
function() {
if (n.prototype.reset.call(this), !(this._nRounds && this._keyPriorReset === this._key)) {
for (var t = this._keyPriorReset = this._key, s = t.words, Q = t.sigBytes / 4, B = this._nRounds = Q + 6, F = (B + 1) * 4, U = this._keySchedule = [], o = 0; o < F; o++)
if (o < Q)
U[o] = s[o];
else {
var a = U[o - 1];
o % Q ? Q > 6 && o % Q === 4 && (a = SBOX[a >>> 24] << 24 | SBOX[a >>> 16 & 255] << 16 | SBOX[a >>> 8 & 255] << 8 | SBOX[a & 255]) : (a = a << 8 | a >>> 24, a = SBOX[a >>> 24] << 24 | SBOX[a >>> 16 & 255] << 16 | SBOX[a >>> 8 & 255] << 8 | SBOX[a & 255], a ^= RCON[o / Q | 0] << 24), U[o] = U[o - Q] ^ a;
}
for (var d = this._invKeySchedule = [], E = 0; E < F; E++) {
var o = F - E, a = void 0;
E % 4 ? a = U[o] : a = U[o - 4], E < 4 || o <= 4 ? d[E] = a : d[E] = INV_SUB_MIX_0[SBOX[a >>> 24]] ^ INV_SUB_MIX_1[SBOX[a >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[a >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[a & 255]];
}
}
}, e.prototype.encryptBlock = /**
* @param {?} M
* @param {?} offset
* @return {?}
*/
function(t, s) {
this._doCryptBlock(t, s, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
}, e.prototype.decryptBlock = /**
* @param {?} M
* @param {?} offset
* @return {?}
*/
function(t, s) {
var Q = t[s + 1];
t[s + 1] = t[s + 3], t[s + 3] = Q, this._doCryptBlock(t, s, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX), Q = t[s + 1], t[s + 1] = t[s + 3], t[s + 3] = Q;
}, e.prototype._doCryptBlock = /**
* @param {?} M
* @param {?} offset
* @param {?} keySchedule
* @param {?} sub_mix_0
* @param {?} sub_mix_1
* @param {?} sub_mix_2
* @param {?} sub_mix_3
* @param {?} sbox
* @return {?}
*/
function(t, s, Q, B, F, U, o, a) {
for (var d = t[s] ^ Q[0], E = t[s + 1] ^ Q[1], N = t[s + 2] ^ Q[2], C = t[s + 3] ^ Q[3], V = 4, y = 1; y < this._nRounds; y++) {
var b = B[d >>> 24] ^ F[E >>> 16 & 255] ^ U[N >>> 8 & 255] ^ o[C & 255] ^ Q[V++], R = B[E >>> 24] ^ F[N >>> 16 & 255] ^ U[C >>> 8 & 255] ^ o[d & 255] ^ Q[V++], L = B[N >>> 24] ^ F[C >>> 16 & 255] ^ U[d >>> 8 & 255] ^ o[E & 255] ^ Q[V++], G = B[C >>> 24] ^ F[d >>> 16 & 255] ^ U[E >>> 8 & 255] ^ o[N & 255] ^ Q[V++];
d = b, E = R, N = L, C = G;
}
var Y = (a[d >>> 24] << 24 | a[E >>> 16 & 255] << 16 | a[N >>> 8 & 255] << 8 | a[C & 255]) ^ Q[V++], _ = (a[E >>> 24] << 24 | a[N >>> 16 & 255] << 16 | a[C >>> 8 & 255] << 8 | a[d & 255]) ^ Q[V++], J = (a[N >>> 24] << 24 | a[C >>> 16 & 255] << 16 | a[d >>> 8 & 255] << 8 | a[E & 255]) ^ Q[V++], w = (a[C >>> 24] << 24 | a[d >>> 16 & 255] << 16 | a[E >>> 8 & 255] << 8 | a[N & 255]) ^ Q[V++];
t[s] = Y, t[s + 1] = _, t[s + 2] = J, t[s + 3] = w;
}, e.keySize = 8, e;
}(BlockCipher)
), H = [], K = [], W = [], SHA256 = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.prototype.reset = /**
* @return {?}
*/
function() {
n.prototype.reset.call(this), this._hash = new WordArray(H.slice(0));
}, e.prototype._doProcessBlock = /**
* @param {?} M
* @param {?} offset
* @return {?}
*/
function(t, s) {
for (var Q = this._hash.words, B = Q[0], F = Q[1], U = Q[2], o = Q[3], a = Q[4], d = Q[5], E = Q[6], N = Q[7], C = 0; C < 64; C++) {
if (C < 16)
W[C] = t[s + C] | 0;
else {
var V = W[C - 15], y = (V << 25 | V >>> 7) ^ (V << 14 | V >>> 18) ^ V >>> 3, b = W[C - 2], R = (b << 15 | b >>> 17) ^ (b << 13 | b >>> 19) ^ b >>> 10;
W[C] = y + W[C - 7] + R + W[C - 16];
}
var L = a & d ^ ~a & E, G = B & F ^ B & U ^ F & U, Y = (B << 30 | B >>> 2) ^ (B << 19 | B >>> 13) ^ (B << 10 | B >>> 22), _ = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), J = N + _ + L + K[C] + W[C], w = Y + G;
N = E, E = d, d = a, a = o + J | 0, o = U, U = F, F = B, B = J + w | 0;
}
Q[0] = Q[0] + B | 0, Q[1] = Q[1] + F | 0, Q[2] = Q[2] + U | 0, Q[3] = Q[3] + o | 0, Q[4] = Q[4] + a | 0, Q[5] = Q[5] + d | 0, Q[6] = Q[6] + E | 0, Q[7] = Q[7] + N | 0;
}, e.prototype._doFinalize = /**
* @return {?}
*/
function() {
var t = this._nDataBytes * 8, s = this._data.sigBytes * 8;
return this._data.words[s >>> 5] |= 128 << 24 - s % 32, this._data.words[(s + 64 >>> 9 << 4) + 14] = Math.floor(t / 4294967296), this._data.words[(s + 64 >>> 9 << 4) + 15] = t, this._data.sigBytes = this._data.words.length * 4, this._process(), this._hash;
}, e;
}(Hasher)
), ECBEncryptor = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.prototype.processBlock = /**
* Processes the data block at offset.
*
* \@example
*
* mode.processBlock(data.words, offset);
* @param {?} words The data words to operate on.
* @param {?} offset The offset where the block starts.
*
* @return {?}
*/
function(t, s) {
this._cipher.encryptBlock(t, s);
}, e;
}(BlockCipherModeAlgorithm)
), ECBDecryptor = (
/** @class */
function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.prototype.processBlock = /**
* Processes the data block at offset.
*
* \@example
*
* mode.processBlock(data.words, offset);
* @param {?} words The data words to operate on.
* @param {?} offset The offset where the block starts.
*
* @return {?}
*/
function(t, s) {
this._cipher.decryptBlock(t, s);
}, e;
}(BlockCipherModeAlgorithm)
);
(function(n) {
__extends(e, n);
function e() {
return n !== null && n.apply(this, arguments) || this;
}
return e.Encryptor = ECBEncryptor, e.Decryptor = ECBDecryptor, e;
})(BlockCipherMode);
var lib = {
BlockCipher,