117 lines
3.4 KiB
JavaScript
117 lines
3.4 KiB
JavaScript
// Metro module 8887 (f8888).
|
|
import * as _classCallCheck from "./_classCallCheck";
|
|
import * as __createClass from "./_createClass";
|
|
import * as _possibleConstructorReturn from "./_possibleConstructorReturn";
|
|
import * as _getPrototypeOf from "./_getPrototypeOf";
|
|
import * as __inherits from "./_inherits";
|
|
import { hash, exists, bytes } from "./bytes";
|
|
import { toBytes, Hash } from "./Hash_8883";
|
|
let c5799_6;
|
|
let HMAC;
|
|
let env5799 = {};
|
|
env5799[5] = function _isNativeReflectConstruct() {
|
|
let c16847_0;
|
|
try {
|
|
c16847_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
} catch ($e) {}
|
|
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
|
|
return !!c16847_0;
|
|
};
|
|
env5799[5] = _isNativeReflectConstruct2;
|
|
return _isNativeReflectConstruct2();
|
|
};
|
|
HMAC = function HMAC(a0, a1) {
|
|
_classCallCheck(this, HMAC);
|
|
const r15 = _getPrototypeOf(HMAC);
|
|
const r32 = _possibleConstructorReturn(this, (0, env5799[5])() ? Reflect.construct(r15, [], _getPrototypeOf(this).constructor) : r15.apply(this, void 0));
|
|
r32.finished = false;
|
|
r32.destroyed = false;
|
|
(0, hash)(a0);
|
|
const r42 = (0, toBytes)(a1);
|
|
r32.iHash = a0.create();
|
|
if (typeof r32.iHash.update !== "function") {
|
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
}
|
|
r32.blockLen = r32.iHash.blockLen;
|
|
r32.outputLen = r32.iHash.outputLen;
|
|
const blockLen = r32.blockLen;
|
|
const uint8Array = new Uint8Array(blockLen);
|
|
uint8Array.set(r42.length > blockLen ? a0.create().update(r42).digest() : r42);
|
|
const r67 = 0 < uint8Array.length;
|
|
let r0 = 0;
|
|
if (r67) {
|
|
do {
|
|
uint8Array[r0] = uint8Array[r0] ^ 54;
|
|
r0 = r0 + 1;
|
|
} while (r0 < uint8Array.length);
|
|
}
|
|
r32.iHash.update(uint8Array);
|
|
r32.oHash = a0.create();
|
|
const r76 = 0 < uint8Array.length;
|
|
let r78 = 0;
|
|
if (r76) {
|
|
do {
|
|
uint8Array[r78] = uint8Array[r78] ^ 106;
|
|
r78 = r78 + 1;
|
|
} while (r78 < uint8Array.length);
|
|
}
|
|
r32.oHash.update(uint8Array);
|
|
uint8Array.fill(0);
|
|
return r32;
|
|
};
|
|
__inherits(HMAC, Hash);
|
|
c5799_6 = __createClass(HMAC, [{
|
|
key: "update",
|
|
value: function update(a0) {
|
|
(0, exists)(this);
|
|
this.iHash.update(a0);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "digestInto",
|
|
value: function digestInto(a0) {
|
|
(0, exists)(this);
|
|
(0, bytes)(a0, this.outputLen);
|
|
this.finished = true;
|
|
this.iHash.digestInto(a0);
|
|
this.oHash.update(a0);
|
|
this.oHash.digestInto(a0);
|
|
this.destroy();
|
|
}
|
|
}, {
|
|
key: "digest",
|
|
value: function digest() {
|
|
const uint8Array = new Uint8Array(this.oHash.outputLen);
|
|
this.digestInto(uint8Array);
|
|
return uint8Array;
|
|
}
|
|
}, {
|
|
key: "_cloneInto",
|
|
value: function _cloneInto(a0) {
|
|
const r0 = a0 ? a0 : Object.create(Object.getPrototypeOf(this), {});
|
|
const oHash = this.oHash;
|
|
const iHash = this.iHash;
|
|
const finished = this.finished;
|
|
const destroyed = this.destroyed;
|
|
const blockLen = this.blockLen;
|
|
const outputLen = this.outputLen;
|
|
r0.finished = finished;
|
|
r0.destroyed = destroyed;
|
|
r0.blockLen = blockLen;
|
|
r0.outputLen = outputLen;
|
|
r0.oHash = oHash._cloneInto(r0.oHash);
|
|
r0.iHash = iHash._cloneInto(r0.iHash);
|
|
return r0;
|
|
}
|
|
}, {
|
|
key: "destroy",
|
|
value: function destroy() {
|
|
this.destroyed = true;
|
|
this.oHash.destroy();
|
|
this.iHash.destroy();
|
|
}
|
|
}]);
|
|
export { c5799_6 as HMAC };
|
|
exports.hmac = (a0, a1, a2) => new c5799_6(a0, a1).update(a2).digest();
|
|
exports.hmac.create = (a0, a1) => new c5799_6(a0, a1);
|