vite-ssh-plugin
Version:
vite cdn upload plugin
1,424 lines (1,415 loc) • 1.46 MB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw new Error('Dynamic require of "' + x + '" is not supported');
});
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// node_modules/.pnpm/registry.npmmirror.com+tsup@6.7.0_typescript@4.9.5/node_modules/tsup/assets/esm_shims.js
import { fileURLToPath } from "url";
import path from "path";
var getFilename, getDirname, __dirname, __filename;
var init_esm_shims = __esm({
"node_modules/.pnpm/registry.npmmirror.com+tsup@6.7.0_typescript@4.9.5/node_modules/tsup/assets/esm_shims.js"() {
getFilename = () => fileURLToPath(import.meta.url);
getDirname = () => path.dirname(getFilename());
__dirname = /* @__PURE__ */ getDirname();
__filename = /* @__PURE__ */ getFilename();
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/errors.js
var require_errors = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/errors.js"(exports, module) {
init_esm_shims();
module.exports = {
newInvalidAsn1Error: function(msg) {
var e = new Error();
e.name = "InvalidAsn1Error";
e.message = msg || "";
return e;
}
};
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/types.js
var require_types = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/types.js"(exports, module) {
init_esm_shims();
module.exports = {
EOC: 0,
Boolean: 1,
Integer: 2,
BitString: 3,
OctetString: 4,
Null: 5,
OID: 6,
ObjectDescriptor: 7,
External: 8,
Real: 9,
// float
Enumeration: 10,
PDV: 11,
Utf8String: 12,
RelativeOID: 13,
Sequence: 16,
Set: 17,
NumericString: 18,
PrintableString: 19,
T61String: 20,
VideotexString: 21,
IA5String: 22,
UTCTime: 23,
GeneralizedTime: 24,
GraphicString: 25,
VisibleString: 26,
GeneralString: 28,
UniversalString: 29,
CharacterString: 30,
BMPString: 31,
Constructor: 32,
Context: 128
};
}
});
// node_modules/.pnpm/safer-buffer@2.1.2/node_modules/safer-buffer/safer.js
var require_safer = __commonJS({
"node_modules/.pnpm/safer-buffer@2.1.2/node_modules/safer-buffer/safer.js"(exports, module) {
"use strict";
init_esm_shims();
var buffer = __require("buffer");
var Buffer2 = buffer.Buffer;
var safer = {};
var key;
for (key in buffer) {
if (!buffer.hasOwnProperty(key))
continue;
if (key === "SlowBuffer" || key === "Buffer")
continue;
safer[key] = buffer[key];
}
var Safer = safer.Buffer = {};
for (key in Buffer2) {
if (!Buffer2.hasOwnProperty(key))
continue;
if (key === "allocUnsafe" || key === "allocUnsafeSlow")
continue;
Safer[key] = Buffer2[key];
}
safer.Buffer.prototype = Buffer2.prototype;
if (!Safer.from || Safer.from === Uint8Array.from) {
Safer.from = function(value, encodingOrOffset, length) {
if (typeof value === "number") {
throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value);
}
if (value && typeof value.length === "undefined") {
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
}
return Buffer2(value, encodingOrOffset, length);
};
}
if (!Safer.alloc) {
Safer.alloc = function(size, fill, encoding) {
if (typeof size !== "number") {
throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size);
}
if (size < 0 || size >= 2 * (1 << 30)) {
throw new RangeError('The value "' + size + '" is invalid for option "size"');
}
var buf = Buffer2(size);
if (!fill || fill.length === 0) {
buf.fill(0);
} else if (typeof encoding === "string") {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
return buf;
};
}
if (!safer.kStringMaxLength) {
try {
safer.kStringMaxLength = process.binding("buffer").kStringMaxLength;
} catch (e) {
}
}
if (!safer.constants) {
safer.constants = {
MAX_LENGTH: safer.kMaxLength
};
if (safer.kStringMaxLength) {
safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength;
}
}
module.exports = safer;
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/reader.js
var require_reader = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/reader.js"(exports, module) {
init_esm_shims();
var assert = __require("assert");
var Buffer2 = require_safer().Buffer;
var ASN1 = require_types();
var errors = require_errors();
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
function Reader(data) {
if (!data || !Buffer2.isBuffer(data))
throw new TypeError("data must be a node Buffer");
this._buf = data;
this._size = data.length;
this._len = 0;
this._offset = 0;
}
Object.defineProperty(Reader.prototype, "length", {
enumerable: true,
get: function() {
return this._len;
}
});
Object.defineProperty(Reader.prototype, "offset", {
enumerable: true,
get: function() {
return this._offset;
}
});
Object.defineProperty(Reader.prototype, "remain", {
get: function() {
return this._size - this._offset;
}
});
Object.defineProperty(Reader.prototype, "buffer", {
get: function() {
return this._buf.slice(this._offset);
}
});
Reader.prototype.readByte = function(peek) {
if (this._size - this._offset < 1)
return null;
var b = this._buf[this._offset] & 255;
if (!peek)
this._offset += 1;
return b;
};
Reader.prototype.peek = function() {
return this.readByte(true);
};
Reader.prototype.readLength = function(offset) {
if (offset === void 0)
offset = this._offset;
if (offset >= this._size)
return null;
var lenB = this._buf[offset++] & 255;
if (lenB === null)
return null;
if ((lenB & 128) === 128) {
lenB &= 127;
if (lenB === 0)
throw newInvalidAsn1Error("Indefinite length not supported");
if (lenB > 4)
throw newInvalidAsn1Error("encoding too long");
if (this._size - offset < lenB)
return null;
this._len = 0;
for (var i = 0; i < lenB; i++)
this._len = (this._len << 8) + (this._buf[offset++] & 255);
} else {
this._len = lenB;
}
return offset;
};
Reader.prototype.readSequence = function(tag) {
var seq = this.peek();
if (seq === null)
return null;
if (tag !== void 0 && tag !== seq)
throw newInvalidAsn1Error("Expected 0x" + tag.toString(16) + ": got 0x" + seq.toString(16));
var o = this.readLength(this._offset + 1);
if (o === null)
return null;
this._offset = o;
return seq;
};
Reader.prototype.readInt = function() {
return this._readTag(ASN1.Integer);
};
Reader.prototype.readBoolean = function() {
return this._readTag(ASN1.Boolean) === 0 ? false : true;
};
Reader.prototype.readEnumeration = function() {
return this._readTag(ASN1.Enumeration);
};
Reader.prototype.readString = function(tag, retbuf) {
if (!tag)
tag = ASN1.OctetString;
var b = this.peek();
if (b === null)
return null;
if (b !== tag)
throw newInvalidAsn1Error("Expected 0x" + tag.toString(16) + ": got 0x" + b.toString(16));
var o = this.readLength(this._offset + 1);
if (o === null)
return null;
if (this.length > this._size - o)
return null;
this._offset = o;
if (this.length === 0)
return retbuf ? Buffer2.alloc(0) : "";
var str = this._buf.slice(this._offset, this._offset + this.length);
this._offset += this.length;
return retbuf ? str : str.toString("utf8");
};
Reader.prototype.readOID = function(tag) {
if (!tag)
tag = ASN1.OID;
var b = this.readString(tag, true);
if (b === null)
return null;
var values = [];
var value = 0;
for (var i = 0; i < b.length; i++) {
var byte = b[i] & 255;
value <<= 7;
value += byte & 127;
if ((byte & 128) === 0) {
values.push(value);
value = 0;
}
}
value = values.shift();
values.unshift(value % 40);
values.unshift(value / 40 >> 0);
return values.join(".");
};
Reader.prototype._readTag = function(tag) {
assert.ok(tag !== void 0);
var b = this.peek();
if (b === null)
return null;
if (b !== tag)
throw newInvalidAsn1Error("Expected 0x" + tag.toString(16) + ": got 0x" + b.toString(16));
var o = this.readLength(this._offset + 1);
if (o === null)
return null;
if (this.length > 4)
throw newInvalidAsn1Error("Integer too long: " + this.length);
if (this.length > this._size - o)
return null;
this._offset = o;
var fb = this._buf[this._offset];
var value = 0;
for (var i = 0; i < this.length; i++) {
value <<= 8;
value |= this._buf[this._offset++] & 255;
}
if ((fb & 128) === 128 && i !== 4)
value -= 1 << i * 8;
return value >> 0;
};
module.exports = Reader;
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/writer.js
var require_writer = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/writer.js"(exports, module) {
init_esm_shims();
var assert = __require("assert");
var Buffer2 = require_safer().Buffer;
var ASN1 = require_types();
var errors = require_errors();
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
var DEFAULT_OPTS = {
size: 1024,
growthFactor: 8
};
function merge(from, to) {
assert.ok(from);
assert.equal(typeof from, "object");
assert.ok(to);
assert.equal(typeof to, "object");
var keys = Object.getOwnPropertyNames(from);
keys.forEach(function(key) {
if (to[key])
return;
var value = Object.getOwnPropertyDescriptor(from, key);
Object.defineProperty(to, key, value);
});
return to;
}
function Writer(options) {
options = merge(DEFAULT_OPTS, options || {});
this._buf = Buffer2.alloc(options.size || 1024);
this._size = this._buf.length;
this._offset = 0;
this._options = options;
this._seq = [];
}
Object.defineProperty(Writer.prototype, "buffer", {
get: function() {
if (this._seq.length)
throw newInvalidAsn1Error(this._seq.length + " unended sequence(s)");
return this._buf.slice(0, this._offset);
}
});
Writer.prototype.writeByte = function(b) {
if (typeof b !== "number")
throw new TypeError("argument must be a Number");
this._ensure(1);
this._buf[this._offset++] = b;
};
Writer.prototype.writeInt = function(i, tag) {
if (typeof i !== "number")
throw new TypeError("argument must be a Number");
if (typeof tag !== "number")
tag = ASN1.Integer;
var sz = 4;
while (((i & 4286578688) === 0 || (i & 4286578688) === 4286578688 >> 0) && sz > 1) {
sz--;
i <<= 8;
}
if (sz > 4)
throw newInvalidAsn1Error("BER ints cannot be > 0xffffffff");
this._ensure(2 + sz);
this._buf[this._offset++] = tag;
this._buf[this._offset++] = sz;
while (sz-- > 0) {
this._buf[this._offset++] = (i & 4278190080) >>> 24;
i <<= 8;
}
};
Writer.prototype.writeNull = function() {
this.writeByte(ASN1.Null);
this.writeByte(0);
};
Writer.prototype.writeEnumeration = function(i, tag) {
if (typeof i !== "number")
throw new TypeError("argument must be a Number");
if (typeof tag !== "number")
tag = ASN1.Enumeration;
return this.writeInt(i, tag);
};
Writer.prototype.writeBoolean = function(b, tag) {
if (typeof b !== "boolean")
throw new TypeError("argument must be a Boolean");
if (typeof tag !== "number")
tag = ASN1.Boolean;
this._ensure(3);
this._buf[this._offset++] = tag;
this._buf[this._offset++] = 1;
this._buf[this._offset++] = b ? 255 : 0;
};
Writer.prototype.writeString = function(s, tag) {
if (typeof s !== "string")
throw new TypeError("argument must be a string (was: " + typeof s + ")");
if (typeof tag !== "number")
tag = ASN1.OctetString;
var len = Buffer2.byteLength(s);
this.writeByte(tag);
this.writeLength(len);
if (len) {
this._ensure(len);
this._buf.write(s, this._offset);
this._offset += len;
}
};
Writer.prototype.writeBuffer = function(buf, tag) {
if (typeof tag !== "number")
throw new TypeError("tag must be a number");
if (!Buffer2.isBuffer(buf))
throw new TypeError("argument must be a buffer");
this.writeByte(tag);
this.writeLength(buf.length);
this._ensure(buf.length);
buf.copy(this._buf, this._offset, 0, buf.length);
this._offset += buf.length;
};
Writer.prototype.writeStringArray = function(strings) {
if (!strings instanceof Array)
throw new TypeError("argument must be an Array[String]");
var self2 = this;
strings.forEach(function(s) {
self2.writeString(s);
});
};
Writer.prototype.writeOID = function(s, tag) {
if (typeof s !== "string")
throw new TypeError("argument must be a string");
if (typeof tag !== "number")
tag = ASN1.OID;
if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
throw new Error("argument is not a valid OID string");
function encodeOctet(bytes2, octet) {
if (octet < 128) {
bytes2.push(octet);
} else if (octet < 16384) {
bytes2.push(octet >>> 7 | 128);
bytes2.push(octet & 127);
} else if (octet < 2097152) {
bytes2.push(octet >>> 14 | 128);
bytes2.push((octet >>> 7 | 128) & 255);
bytes2.push(octet & 127);
} else if (octet < 268435456) {
bytes2.push(octet >>> 21 | 128);
bytes2.push((octet >>> 14 | 128) & 255);
bytes2.push((octet >>> 7 | 128) & 255);
bytes2.push(octet & 127);
} else {
bytes2.push((octet >>> 28 | 128) & 255);
bytes2.push((octet >>> 21 | 128) & 255);
bytes2.push((octet >>> 14 | 128) & 255);
bytes2.push((octet >>> 7 | 128) & 255);
bytes2.push(octet & 127);
}
}
var tmp = s.split(".");
var bytes = [];
bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
tmp.slice(2).forEach(function(b) {
encodeOctet(bytes, parseInt(b, 10));
});
var self2 = this;
this._ensure(2 + bytes.length);
this.writeByte(tag);
this.writeLength(bytes.length);
bytes.forEach(function(b) {
self2.writeByte(b);
});
};
Writer.prototype.writeLength = function(len) {
if (typeof len !== "number")
throw new TypeError("argument must be a Number");
this._ensure(4);
if (len <= 127) {
this._buf[this._offset++] = len;
} else if (len <= 255) {
this._buf[this._offset++] = 129;
this._buf[this._offset++] = len;
} else if (len <= 65535) {
this._buf[this._offset++] = 130;
this._buf[this._offset++] = len >> 8;
this._buf[this._offset++] = len;
} else if (len <= 16777215) {
this._buf[this._offset++] = 131;
this._buf[this._offset++] = len >> 16;
this._buf[this._offset++] = len >> 8;
this._buf[this._offset++] = len;
} else {
throw newInvalidAsn1Error("Length too long (> 4 bytes)");
}
};
Writer.prototype.startSequence = function(tag) {
if (typeof tag !== "number")
tag = ASN1.Sequence | ASN1.Constructor;
this.writeByte(tag);
this._seq.push(this._offset);
this._ensure(3);
this._offset += 3;
};
Writer.prototype.endSequence = function() {
var seq = this._seq.pop();
var start = seq + 3;
var len = this._offset - start;
if (len <= 127) {
this._shift(start, len, -2);
this._buf[seq] = len;
} else if (len <= 255) {
this._shift(start, len, -1);
this._buf[seq] = 129;
this._buf[seq + 1] = len;
} else if (len <= 65535) {
this._buf[seq] = 130;
this._buf[seq + 1] = len >> 8;
this._buf[seq + 2] = len;
} else if (len <= 16777215) {
this._shift(start, len, 1);
this._buf[seq] = 131;
this._buf[seq + 1] = len >> 16;
this._buf[seq + 2] = len >> 8;
this._buf[seq + 3] = len;
} else {
throw newInvalidAsn1Error("Sequence too long");
}
};
Writer.prototype._shift = function(start, len, shift) {
assert.ok(start !== void 0);
assert.ok(len !== void 0);
assert.ok(shift);
this._buf.copy(this._buf, start + shift, start, start + len);
this._offset += shift;
};
Writer.prototype._ensure = function(len) {
assert.ok(len);
if (this._size - this._offset < len) {
var sz = this._size * this._options.growthFactor;
if (sz - this._offset < len)
sz += len;
var buf = Buffer2.alloc(sz);
this._buf.copy(buf, 0, 0, this._offset);
this._buf = buf;
this._size = sz;
}
};
module.exports = Writer;
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/index.js
var require_ber = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/ber/index.js"(exports, module) {
init_esm_shims();
var errors = require_errors();
var types = require_types();
var Reader = require_reader();
var Writer = require_writer();
module.exports = {
Reader,
Writer
};
for (t in types) {
if (types.hasOwnProperty(t))
module.exports[t] = types[t];
}
var t;
for (e in errors) {
if (errors.hasOwnProperty(e))
module.exports[e] = errors[e];
}
var e;
}
});
// node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/index.js
var require_lib = __commonJS({
"node_modules/.pnpm/asn1@0.2.6/node_modules/asn1/lib/index.js"(exports, module) {
init_esm_shims();
var Ber = require_ber();
module.exports = {
Ber,
BerReader: Ber.Reader,
BerWriter: Ber.Writer
};
}
});
// node_modules/.pnpm/tweetnacl@0.14.5/node_modules/tweetnacl/nacl-fast.js
var require_nacl_fast = __commonJS({
"node_modules/.pnpm/tweetnacl@0.14.5/node_modules/tweetnacl/nacl-fast.js"(exports, module) {
init_esm_shims();
(function(nacl) {
"use strict";
var gf = function(init) {
var i, r = new Float64Array(16);
if (init)
for (i = 0; i < init.length; i++)
r[i] = init[i];
return r;
};
var randombytes = function() {
throw new Error("no PRNG");
};
var _0 = new Uint8Array(16);
var _9 = new Uint8Array(32);
_9[0] = 9;
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([56129, 1]), D = gf([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), D2 = gf([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), X = gf([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), Y = gf([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), I = gf([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]);
function ts64(x, i, h, l) {
x[i] = h >> 24 & 255;
x[i + 1] = h >> 16 & 255;
x[i + 2] = h >> 8 & 255;
x[i + 3] = h & 255;
x[i + 4] = l >> 24 & 255;
x[i + 5] = l >> 16 & 255;
x[i + 6] = l >> 8 & 255;
x[i + 7] = l & 255;
}
function vn(x, xi, y, yi, n) {
var i, d = 0;
for (i = 0; i < n; i++)
d |= x[xi + i] ^ y[yi + i];
return (1 & d - 1 >>> 8) - 1;
}
function crypto_verify_16(x, xi, y, yi) {
return vn(x, xi, y, yi, 16);
}
function crypto_verify_32(x, xi, y, yi) {
return vn(x, xi, y, yi, 32);
}
function core_salsa20(o, p, k, c) {
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
for (var i = 0; i < 20; i += 2) {
u = x0 + x12 | 0;
x4 ^= u << 7 | u >>> 32 - 7;
u = x4 + x0 | 0;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x4 | 0;
x12 ^= u << 13 | u >>> 32 - 13;
u = x12 + x8 | 0;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x1 | 0;
x9 ^= u << 7 | u >>> 32 - 7;
u = x9 + x5 | 0;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x9 | 0;
x1 ^= u << 13 | u >>> 32 - 13;
u = x1 + x13 | 0;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x6 | 0;
x14 ^= u << 7 | u >>> 32 - 7;
u = x14 + x10 | 0;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x14 | 0;
x6 ^= u << 13 | u >>> 32 - 13;
u = x6 + x2 | 0;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x11 | 0;
x3 ^= u << 7 | u >>> 32 - 7;
u = x3 + x15 | 0;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x3 | 0;
x11 ^= u << 13 | u >>> 32 - 13;
u = x11 + x7 | 0;
x15 ^= u << 18 | u >>> 32 - 18;
u = x0 + x3 | 0;
x1 ^= u << 7 | u >>> 32 - 7;
u = x1 + x0 | 0;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x1 | 0;
x3 ^= u << 13 | u >>> 32 - 13;
u = x3 + x2 | 0;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x4 | 0;
x6 ^= u << 7 | u >>> 32 - 7;
u = x6 + x5 | 0;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x6 | 0;
x4 ^= u << 13 | u >>> 32 - 13;
u = x4 + x7 | 0;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x9 | 0;
x11 ^= u << 7 | u >>> 32 - 7;
u = x11 + x10 | 0;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x11 | 0;
x9 ^= u << 13 | u >>> 32 - 13;
u = x9 + x8 | 0;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x14 | 0;
x12 ^= u << 7 | u >>> 32 - 7;
u = x12 + x15 | 0;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x12 | 0;
x14 ^= u << 13 | u >>> 32 - 13;
u = x14 + x13 | 0;
x15 ^= u << 18 | u >>> 32 - 18;
}
x0 = x0 + j0 | 0;
x1 = x1 + j1 | 0;
x2 = x2 + j2 | 0;
x3 = x3 + j3 | 0;
x4 = x4 + j4 | 0;
x5 = x5 + j5 | 0;
x6 = x6 + j6 | 0;
x7 = x7 + j7 | 0;
x8 = x8 + j8 | 0;
x9 = x9 + j9 | 0;
x10 = x10 + j10 | 0;
x11 = x11 + j11 | 0;
x12 = x12 + j12 | 0;
x13 = x13 + j13 | 0;
x14 = x14 + j14 | 0;
x15 = x15 + j15 | 0;
o[0] = x0 >>> 0 & 255;
o[1] = x0 >>> 8 & 255;
o[2] = x0 >>> 16 & 255;
o[3] = x0 >>> 24 & 255;
o[4] = x1 >>> 0 & 255;
o[5] = x1 >>> 8 & 255;
o[6] = x1 >>> 16 & 255;
o[7] = x1 >>> 24 & 255;
o[8] = x2 >>> 0 & 255;
o[9] = x2 >>> 8 & 255;
o[10] = x2 >>> 16 & 255;
o[11] = x2 >>> 24 & 255;
o[12] = x3 >>> 0 & 255;
o[13] = x3 >>> 8 & 255;
o[14] = x3 >>> 16 & 255;
o[15] = x3 >>> 24 & 255;
o[16] = x4 >>> 0 & 255;
o[17] = x4 >>> 8 & 255;
o[18] = x4 >>> 16 & 255;
o[19] = x4 >>> 24 & 255;
o[20] = x5 >>> 0 & 255;
o[21] = x5 >>> 8 & 255;
o[22] = x5 >>> 16 & 255;
o[23] = x5 >>> 24 & 255;
o[24] = x6 >>> 0 & 255;
o[25] = x6 >>> 8 & 255;
o[26] = x6 >>> 16 & 255;
o[27] = x6 >>> 24 & 255;
o[28] = x7 >>> 0 & 255;
o[29] = x7 >>> 8 & 255;
o[30] = x7 >>> 16 & 255;
o[31] = x7 >>> 24 & 255;
o[32] = x8 >>> 0 & 255;
o[33] = x8 >>> 8 & 255;
o[34] = x8 >>> 16 & 255;
o[35] = x8 >>> 24 & 255;
o[36] = x9 >>> 0 & 255;
o[37] = x9 >>> 8 & 255;
o[38] = x9 >>> 16 & 255;
o[39] = x9 >>> 24 & 255;
o[40] = x10 >>> 0 & 255;
o[41] = x10 >>> 8 & 255;
o[42] = x10 >>> 16 & 255;
o[43] = x10 >>> 24 & 255;
o[44] = x11 >>> 0 & 255;
o[45] = x11 >>> 8 & 255;
o[46] = x11 >>> 16 & 255;
o[47] = x11 >>> 24 & 255;
o[48] = x12 >>> 0 & 255;
o[49] = x12 >>> 8 & 255;
o[50] = x12 >>> 16 & 255;
o[51] = x12 >>> 24 & 255;
o[52] = x13 >>> 0 & 255;
o[53] = x13 >>> 8 & 255;
o[54] = x13 >>> 16 & 255;
o[55] = x13 >>> 24 & 255;
o[56] = x14 >>> 0 & 255;
o[57] = x14 >>> 8 & 255;
o[58] = x14 >>> 16 & 255;
o[59] = x14 >>> 24 & 255;
o[60] = x15 >>> 0 & 255;
o[61] = x15 >>> 8 & 255;
o[62] = x15 >>> 16 & 255;
o[63] = x15 >>> 24 & 255;
}
function core_hsalsa20(o, p, k, c) {
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
for (var i = 0; i < 20; i += 2) {
u = x0 + x12 | 0;
x4 ^= u << 7 | u >>> 32 - 7;
u = x4 + x0 | 0;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x4 | 0;
x12 ^= u << 13 | u >>> 32 - 13;
u = x12 + x8 | 0;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x1 | 0;
x9 ^= u << 7 | u >>> 32 - 7;
u = x9 + x5 | 0;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x9 | 0;
x1 ^= u << 13 | u >>> 32 - 13;
u = x1 + x13 | 0;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x6 | 0;
x14 ^= u << 7 | u >>> 32 - 7;
u = x14 + x10 | 0;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x14 | 0;
x6 ^= u << 13 | u >>> 32 - 13;
u = x6 + x2 | 0;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x11 | 0;
x3 ^= u << 7 | u >>> 32 - 7;
u = x3 + x15 | 0;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x3 | 0;
x11 ^= u << 13 | u >>> 32 - 13;
u = x11 + x7 | 0;
x15 ^= u << 18 | u >>> 32 - 18;
u = x0 + x3 | 0;
x1 ^= u << 7 | u >>> 32 - 7;
u = x1 + x0 | 0;
x2 ^= u << 9 | u >>> 32 - 9;
u = x2 + x1 | 0;
x3 ^= u << 13 | u >>> 32 - 13;
u = x3 + x2 | 0;
x0 ^= u << 18 | u >>> 32 - 18;
u = x5 + x4 | 0;
x6 ^= u << 7 | u >>> 32 - 7;
u = x6 + x5 | 0;
x7 ^= u << 9 | u >>> 32 - 9;
u = x7 + x6 | 0;
x4 ^= u << 13 | u >>> 32 - 13;
u = x4 + x7 | 0;
x5 ^= u << 18 | u >>> 32 - 18;
u = x10 + x9 | 0;
x11 ^= u << 7 | u >>> 32 - 7;
u = x11 + x10 | 0;
x8 ^= u << 9 | u >>> 32 - 9;
u = x8 + x11 | 0;
x9 ^= u << 13 | u >>> 32 - 13;
u = x9 + x8 | 0;
x10 ^= u << 18 | u >>> 32 - 18;
u = x15 + x14 | 0;
x12 ^= u << 7 | u >>> 32 - 7;
u = x12 + x15 | 0;
x13 ^= u << 9 | u >>> 32 - 9;
u = x13 + x12 | 0;
x14 ^= u << 13 | u >>> 32 - 13;
u = x14 + x13 | 0;
x15 ^= u << 18 | u >>> 32 - 18;
}
o[0] = x0 >>> 0 & 255;
o[1] = x0 >>> 8 & 255;
o[2] = x0 >>> 16 & 255;
o[3] = x0 >>> 24 & 255;
o[4] = x5 >>> 0 & 255;
o[5] = x5 >>> 8 & 255;
o[6] = x5 >>> 16 & 255;
o[7] = x5 >>> 24 & 255;
o[8] = x10 >>> 0 & 255;
o[9] = x10 >>> 8 & 255;
o[10] = x10 >>> 16 & 255;
o[11] = x10 >>> 24 & 255;
o[12] = x15 >>> 0 & 255;
o[13] = x15 >>> 8 & 255;
o[14] = x15 >>> 16 & 255;
o[15] = x15 >>> 24 & 255;
o[16] = x6 >>> 0 & 255;
o[17] = x6 >>> 8 & 255;
o[18] = x6 >>> 16 & 255;
o[19] = x6 >>> 24 & 255;
o[20] = x7 >>> 0 & 255;
o[21] = x7 >>> 8 & 255;
o[22] = x7 >>> 16 & 255;
o[23] = x7 >>> 24 & 255;
o[24] = x8 >>> 0 & 255;
o[25] = x8 >>> 8 & 255;
o[26] = x8 >>> 16 & 255;
o[27] = x8 >>> 24 & 255;
o[28] = x9 >>> 0 & 255;
o[29] = x9 >>> 8 & 255;
o[30] = x9 >>> 16 & 255;
o[31] = x9 >>> 24 & 255;
}
function crypto_core_salsa20(out, inp, k, c) {
core_salsa20(out, inp, k, c);
}
function crypto_core_hsalsa20(out, inp, k, c) {
core_hsalsa20(out, inp, k, c);
}
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
function crypto_stream_salsa20_xor(c, cpos, m, mpos, b, n, k) {
var z = new Uint8Array(16), x = new Uint8Array(64);
var u, i;
for (i = 0; i < 16; i++)
z[i] = 0;
for (i = 0; i < 8; i++)
z[i] = n[i];
while (b >= 64) {
crypto_core_salsa20(x, z, k, sigma);
for (i = 0; i < 64; i++)
c[cpos + i] = m[mpos + i] ^ x[i];
u = 1;
for (i = 8; i < 16; i++) {
u = u + (z[i] & 255) | 0;
z[i] = u & 255;
u >>>= 8;
}
b -= 64;
cpos += 64;
mpos += 64;
}
if (b > 0) {
crypto_core_salsa20(x, z, k, sigma);
for (i = 0; i < b; i++)
c[cpos + i] = m[mpos + i] ^ x[i];
}
return 0;
}
function crypto_stream_salsa20(c, cpos, b, n, k) {
var z = new Uint8Array(16), x = new Uint8Array(64);
var u, i;
for (i = 0; i < 16; i++)
z[i] = 0;
for (i = 0; i < 8; i++)
z[i] = n[i];
while (b >= 64) {
crypto_core_salsa20(x, z, k, sigma);
for (i = 0; i < 64; i++)
c[cpos + i] = x[i];
u = 1;
for (i = 8; i < 16; i++) {
u = u + (z[i] & 255) | 0;
z[i] = u & 255;
u >>>= 8;
}
b -= 64;
cpos += 64;
}
if (b > 0) {
crypto_core_salsa20(x, z, k, sigma);
for (i = 0; i < b; i++)
c[cpos + i] = x[i];
}
return 0;
}
function crypto_stream(c, cpos, d, n, k) {
var s = new Uint8Array(32);
crypto_core_hsalsa20(s, n, k, sigma);
var sn = new Uint8Array(8);
for (var i = 0; i < 8; i++)
sn[i] = n[i + 16];
return crypto_stream_salsa20(c, cpos, d, sn, s);
}
function crypto_stream_xor(c, cpos, m, mpos, d, n, k) {
var s = new Uint8Array(32);
crypto_core_hsalsa20(s, n, k, sigma);
var sn = new Uint8Array(8);
for (var i = 0; i < 8; i++)
sn[i] = n[i + 16];
return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, sn, s);
}
var poly1305 = function(key) {
this.buffer = new Uint8Array(16);
this.r = new Uint16Array(10);
this.h = new Uint16Array(10);
this.pad = new Uint16Array(8);
this.leftover = 0;
this.fin = 0;
var t0, t1, t2, t3, t4, t5, t6, t7;
t0 = key[0] & 255 | (key[1] & 255) << 8;
this.r[0] = t0 & 8191;
t1 = key[2] & 255 | (key[3] & 255) << 8;
this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
t2 = key[4] & 255 | (key[5] & 255) << 8;
this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
t3 = key[6] & 255 | (key[7] & 255) << 8;
this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
t4 = key[8] & 255 | (key[9] & 255) << 8;
this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
this.r[5] = t4 >>> 1 & 8190;
t5 = key[10] & 255 | (key[11] & 255) << 8;
this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
t6 = key[12] & 255 | (key[13] & 255) << 8;
this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
t7 = key[14] & 255 | (key[15] & 255) << 8;
this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
this.r[9] = t7 >>> 5 & 127;
this.pad[0] = key[16] & 255 | (key[17] & 255) << 8;
this.pad[1] = key[18] & 255 | (key[19] & 255) << 8;
this.pad[2] = key[20] & 255 | (key[21] & 255) << 8;
this.pad[3] = key[22] & 255 | (key[23] & 255) << 8;
this.pad[4] = key[24] & 255 | (key[25] & 255) << 8;
this.pad[5] = key[26] & 255 | (key[27] & 255) << 8;
this.pad[6] = key[28] & 255 | (key[29] & 255) << 8;
this.pad[7] = key[30] & 255 | (key[31] & 255) << 8;
};
poly1305.prototype.blocks = function(m, mpos, bytes) {
var hibit = this.fin ? 0 : 1 << 11;
var t0, t1, t2, t3, t4, t5, t6, t7, c;
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
var h0 = this.h[0], h1 = this.h[1], h2 = this.h[2], h3 = this.h[3], h4 = this.h[4], h5 = this.h[5], h6 = this.h[6], h7 = this.h[7], h8 = this.h[8], h9 = this.h[9];
var r0 = this.r[0], r1 = this.r[1], r2 = this.r[2], r3 = this.r[3], r4 = this.r[4], r5 = this.r[5], r6 = this.r[6], r7 = this.r[7], r8 = this.r[8], r9 = this.r[9];
while (bytes >= 16) {
t0 = m[mpos + 0] & 255 | (m[mpos + 1] & 255) << 8;
h0 += t0 & 8191;
t1 = m[mpos + 2] & 255 | (m[mpos + 3] & 255) << 8;
h1 += (t0 >>> 13 | t1 << 3) & 8191;
t2 = m[mpos + 4] & 255 | (m[mpos + 5] & 255) << 8;
h2 += (t1 >>> 10 | t2 << 6) & 8191;
t3 = m[mpos + 6] & 255 | (m[mpos + 7] & 255) << 8;
h3 += (t2 >>> 7 | t3 << 9) & 8191;
t4 = m[mpos + 8] & 255 | (m[mpos + 9] & 255) << 8;
h4 += (t3 >>> 4 | t4 << 12) & 8191;
h5 += t4 >>> 1 & 8191;
t5 = m[mpos + 10] & 255 | (m[mpos + 11] & 255) << 8;
h6 += (t4 >>> 14 | t5 << 2) & 8191;
t6 = m[mpos + 12] & 255 | (m[mpos + 13] & 255) << 8;
h7 += (t5 >>> 11 | t6 << 5) & 8191;
t7 = m[mpos + 14] & 255 | (m[mpos + 15] & 255) << 8;
h8 += (t6 >>> 8 | t7 << 8) & 8191;
h9 += t7 >>> 5 | hibit;
c = 0;
d0 = c;
d0 += h0 * r0;
d0 += h1 * (5 * r9);
d0 += h2 * (5 * r8);
d0 += h3 * (5 * r7);
d0 += h4 * (5 * r6);
c = d0 >>> 13;
d0 &= 8191;
d0 += h5 * (5 * r5);
d0 += h6 * (5 * r4);
d0 += h7 * (5 * r3);
d0 += h8 * (5 * r2);
d0 += h9 * (5 * r1);
c += d0 >>> 13;
d0 &= 8191;
d1 = c;
d1 += h0 * r1;
d1 += h1 * r0;
d1 += h2 * (5 * r9);
d1 += h3 * (5 * r8);
d1 += h4 * (5 * r7);
c = d1 >>> 13;
d1 &= 8191;
d1 += h5 * (5 * r6);
d1 += h6 * (5 * r5);
d1 += h7 * (5 * r4);
d1 += h8 * (5 * r3);
d1 += h9 * (5 * r2);
c += d1 >>> 13;
d1 &= 8191;
d2 = c;
d2 += h0 * r2;
d2 += h1 * r1;
d2 += h2 * r0;
d2 += h3 * (5 * r9);
d2 += h4 * (5 * r8);
c = d2 >>> 13;
d2 &= 8191;
d2 += h5 * (5 * r7);
d2 += h6 * (5 * r6);
d2 += h7 * (5 * r5);
d2 += h8 * (5 * r4);
d2 += h9 * (5 * r3);
c += d2 >>> 13;
d2 &= 8191;
d3 = c;
d3 += h0 * r3;
d3 += h1 * r2;
d3 += h2 * r1;
d3 += h3 * r0;
d3 += h4 * (5 * r9);
c = d3 >>> 13;
d3 &= 8191;
d3 += h5 * (5 * r8);
d3 += h6 * (5 * r7);
d3 += h7 * (5 * r6);
d3 += h8 * (5 * r5);
d3 += h9 * (5 * r4);
c += d3 >>> 13;
d3 &= 8191;
d4 = c;
d4 += h0 * r4;
d4 += h1 * r3;
d4 += h2 * r2;
d4 += h3 * r1;
d4 += h4 * r0;
c = d4 >>> 13;
d4 &= 8191;
d4 += h5 * (5 * r9);
d4 += h6 * (5 * r8);
d4 += h7 * (5 * r7);
d4 += h8 * (5 * r6);
d4 += h9 * (5 * r5);
c += d4 >>> 13;
d4 &= 8191;
d5 = c;
d5 += h0 * r5;
d5 += h1 * r4;
d5 += h2 * r3;
d5 += h3 * r2;
d5 += h4 * r1;
c = d5 >>> 13;
d5 &= 8191;
d5 += h5 * r0;
d5 += h6 * (5 * r9);
d5 += h7 * (5 * r8);
d5 += h8 * (5 * r7);
d5 += h9 * (5 * r6);
c += d5 >>> 13;
d5 &= 8191;
d6 = c;
d6 += h0 * r6;
d6 += h1 * r5;
d6 += h2 * r4;
d6 += h3 * r3;
d6 += h4 * r2;
c = d6 >>> 13;
d6 &= 8191;
d6 += h5 * r1;
d6 += h6 * r0;
d6 += h7 * (5 * r9);
d6 += h8 * (5 * r8);
d6 += h9 * (5 * r7);
c += d6 >>> 13;
d6 &= 8191;
d7 = c;
d7 += h0 * r7;
d7 += h1 * r6;
d7 += h2 * r5;
d7 += h3 * r4;
d7 += h4 * r3;
c = d7 >>> 13;
d7 &= 8191;
d7 += h5 * r2;
d7 += h6 * r1;
d7 += h7 * r0;
d7 += h8 * (5 * r9);
d7 += h9 * (5 * r8);
c += d7 >>> 13;
d7 &= 8191;
d8 = c;
d8 += h0 * r8;
d8 += h1 * r7;
d8 += h2 * r6;
d8 += h3 * r5;
d8 += h4 * r4;
c = d8 >>> 13;
d8 &= 8191;
d8 += h5 * r3;
d8 += h6 * r2;
d8 += h7 * r1;
d8 += h8 * r0;
d8 += h9 * (5 * r9);
c += d8 >>> 13;
d8 &= 8191;
d9 = c;
d9 += h0 * r9;
d9 += h1 * r8;
d9 += h2 * r7;
d9 += h3 * r6;
d9 += h4 * r5;
c = d9 >>> 13;
d9 &= 8191;
d9 += h5 * r4;
d9 += h6 * r3;
d9 += h7 * r2;
d9 += h8 * r1;
d9 += h9 * r0;
c += d9 >>> 13;
d9 &= 8191;
c = (c << 2) + c | 0;
c = c + d0 | 0;
d0 = c & 8191;
c = c >>> 13;
d1 += c;
h0 = d0;
h1 = d1;
h2 = d2;
h3 = d3;
h4 = d4;
h5 = d5;
h6 = d6;
h7 = d7;
h8 = d8;
h9 = d9;
mpos += 16;
bytes -= 16;
}
this.h[0] = h0;
this.h[1] = h1;
this.h[2] = h2;
this.h[3] = h3;
this.h[4] = h4;
this.h[5] = h5;
this.h[6] = h6;
this.h[7] = h7;
this.h[8] = h8;
this.h[9] = h9;
};
poly1305.prototype.finish = function(mac, macpos) {
var g = new Uint16Array(10);
var c, mask, f, i;
if (this.leftover) {
i = this.leftover;
this.buffer[i++] = 1;
for (; i < 16; i++)
this.buffer[i] = 0;
this.fin = 1;
this.blocks(this.buffer, 0, 16);
}
c = this.h[1] >>> 13;
this.h[1] &= 8191;
for (i = 2; i < 10; i++) {
this.h[i] += c;
c = this.h[i] >>> 13;
this.h[i] &= 8191;
}
this.h[0] += c * 5;
c = this.h[0] >>> 13;
this.h[0] &= 8191;
this.h[1] += c;
c = this.h[1] >>> 13;
this.h[1] &= 8191;
this.h[2] += c;
g[0] = this.h[0] + 5;
c = g[0] >>> 13;
g[0] &= 8191;
for (i = 1; i < 10; i++) {
g[i] = this.h[i] + c;
c = g[i] >>> 13;
g[i] &= 8191;
}
g[9] -= 1 << 13;
mask = (c ^ 1) - 1;
for (i = 0; i < 10; i++)
g[i] &= mask;
mask = ~mask;
for (i = 0; i < 10; i++)
this.h[i] = this.h[i] & mask | g[i];
this.h[0] = (this.h[0] | this.h[1] << 13) & 65535;
this.h[1] = (this.h[1] >>> 3 | this.h[2] << 10) & 65535;
this.h[2] = (this.h[2] >>> 6 | this.h[3] << 7) & 65535;
this.h[3] = (this.h[3] >>> 9 | this.h[4] << 4) & 65535;
this.h[4] = (this.h[4] >>> 12 | this.h[5] << 1 | this.h[6] << 14) & 65535;
this.h[5] = (this.h[6] >>> 2 | this.h[7] << 11) & 65535;
this.h[6] = (this.h[7] >>> 5 | this.h[8] << 8) & 65535;
this.h[7] = (this.h[8] >>> 8 | this.h[9] << 5) & 65535;
f = this.h[0] + this.pad[0];
this.h[0] = f & 65535;
for (i = 1; i < 8; i++) {
f = (this.h[i] + this.pad[i] | 0) + (f >>> 16) | 0;
this.h[i] = f & 65535;
}
mac[macpos + 0] = this.h[0] >>> 0 & 255;
mac[macpos + 1] = this.h[0] >>> 8 & 255;
mac[macpos + 2] = this.h[1] >>> 0 & 255;
mac[macpos + 3] = this.h[1] >>> 8 & 255;
mac[macpos + 4] = this.h[2] >>> 0 & 255;
mac[macpos + 5] = this.h[2] >>> 8 & 255;
mac[macpos + 6] = this.h[3] >>> 0 & 255;
mac[macpos + 7] = this.h[3] >>> 8 & 255;
mac[macpos + 8] = this.h[4] >>> 0 & 255;
mac[macpos + 9] = this.h[4] >>> 8 & 255;
mac[macpos + 10] = this.h[5] >>> 0 & 255;
mac[macpos + 11] = this.h[5] >>> 8 & 255;
mac[macpos + 12] = this.h[6] >>> 0 & 255;
mac[macpos + 13] = this.h[6] >>> 8 & 255;
mac[macpos + 14] = this.h[7] >>> 0 & 255;
mac[macpos + 15] = this.h[7] >>> 8 & 255;
};
poly1305.prototype.update = function(m, mpos, bytes) {
var i, want;
if (this.leftover) {
want = 16 - this.leftover;
if (want > bytes)
want = bytes;
for (i = 0; i < want; i++)
this.buffer[this.leftover + i] = m[mpos + i];
bytes -= want;
mpos += want;
this.leftover += want;
if (this.leftover < 16)
return;
this.blocks(this.buffer, 0, 16);
this.leftover = 0;
}
if (bytes >= 16) {
want = bytes - bytes % 16;
this.blocks(m, mpos, want);
mpos += want;
bytes -= want;
}
if (bytes) {
for (i = 0; i < bytes; i++)
this.buffer[this.leftover + i] = m[mpos + i];
this.leftover += bytes;
}
};
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
var s = new poly1305(k);
s.update(m, mpos, n);
s.finish(out, outpos);
return 0;
}
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
var x = new Uint8Array(16);
crypto_onetimeauth(x, 0, m, mpos, n, k);
return crypto_verify_16(h, hpos, x, 0);
}
function crypto_secretbox(c, m, d, n, k) {
var i;
if (d < 32)
return -1;
crypto_stream_xor(c, 0, m, 0, d, n, k);
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
for (i = 0; i < 16; i++)
c[i] = 0;
return 0;
}
function crypto_secretbox_open(m, c, d, n, k) {
var i;
var x = new Uint8Array(32);
if (d < 32)
return -1;
crypto_stream(x, 0, 32, n, k);
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0)
return -1;
crypto_stream_xor(m, 0, c, 0, d, n, k);
for (i = 0; i < 32; i++)
m[i] = 0;
return 0;
}
function set25519(r, a) {
var i;
for (i = 0; i < 16; i++)
r[i] = a[i] | 0;
}
function car25519(o) {
var i, v, c = 1;
for (i = 0; i < 16; i++) {
v = o[i] + c + 65535;
c = Math.floor(v / 65536);
o[i] = v - c * 65536;
}
o[0] += c - 1 + 37 * (c - 1);
}
function sel25519(p, q, b) {
var t, c = ~(b - 1);
for (var i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]);
p[i] ^= t;
q[i] ^= t;
}
}
function pack25519(o, n) {
var i, j, b;
var m = gf(), t = gf();
for (i = 0; i < 16; i++)
t[i] = n[i];
car25519(t);
car25519(t);
car25519(t);
for (j = 0; j < 2; j++) {
m[0] = t[0] - 65517;
for (i = 1; i < 15; i++) {
m[i] = t[i] - 65535 - (m[i - 1] >> 16 & 1);
m[i - 1] &= 65535;
}
m[15] = t[15] - 32767 - (m[14] >> 16 & 1);
b = m[15] >> 16 & 1;
m[14] &= 65535;
sel25519(t, m, 1 - b);
}
for (i = 0; i < 16; i++) {
o[2 * i] = t[i] & 255;
o[2 * i + 1] = t[i] >> 8;
}
}
function neq25519(a, b) {
var c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a);
pack25519(d, b);
return crypto_verify_32(c, 0, d, 0);
}
functio