Skip to content

Commit

Permalink
Deployed using Blazing fast GitHub Pages deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
nin-jin committed Jan 8, 2024
1 parent f00bda7 commit 9631dfe
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 54 deletions.
5 changes: 4 additions & 1 deletion node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5403,13 +5403,16 @@ declare namespace $ {
}
}

declare namespace $ {
function $mol_crypto_hash(data: Uint8Array): Uint8Array;
}

declare namespace $ {
class $mol_crypto_secret extends Object {
readonly native: CryptoKey & {
type: 'secret';
};
static size: number;
static extra: number;
constructor(native: CryptoKey & {
type: 'secret';
});
Expand Down
2 changes: 1 addition & 1 deletion node.deps.json

Large diffs are not rendered by default.

87 changes: 79 additions & 8 deletions node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20100,7 +20100,7 @@ var $;
return this.$.$mol_locale.text('$hyoo_meta_safe_bid_pass_long');
}
key_size() {
return 133;
return 144;
}
attr() {
return {
Expand Down Expand Up @@ -20311,16 +20311,87 @@ var $;
;
"use strict";
var $;
(function ($) {
let sponge = new Uint32Array(80);
function $mol_crypto_hash(data) {
const bits = data.byteLength << 3;
const kbits = bits >> 5;
const kword = 0x80 << (24 - bits & 0b11111);
const bytes = 16 + (bits + 64 >>> 9 << 4);
const klens = bytes - 1;
const words = new Int32Array(data.buffer, data.byteOffset, data.byteLength >> 2);
let tail = 0;
for (let i = words.length * 4; i < data.length; ++i) {
tail |= data[i] << (i << 3 & 0b11000);
}
const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]);
for (let i = 0; i < bytes; i += 16) {
let h0 = hash[0];
let h1 = hash[1];
let h2 = hash[2];
let h3 = hash[3];
let h4 = hash[4];
for (let j = 0; j < 80; ++j) {
let turn;
if (j < 16) {
const k = i + j;
if (k === klens) {
sponge[j] = bits;
}
else {
let word = k === words.length ? tail :
k > words.length ? 0 :
words[k];
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
if (k === kbits)
word |= kword;
sponge[j] = word;
}
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
}
else {
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
sponge[j] = shuffle << 1 | shuffle >>> 31;
turn =
j < 20 ? (h1 & h2 | ~h1 & h3) + 1518500249 :
j < 40 ? (h1 ^ h2 ^ h3) + 1859775393 :
j < 60 ? (h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 :
(h1 ^ h2 ^ h3) - 899497514;
}
const next = turn + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27));
h4 = h3;
h3 = h2;
h2 = (h1 << 30) | (h1 >>> 2);
h1 = h0;
h0 = next;
}
hash[0] += h0;
hash[1] += h1;
hash[2] += h2;
hash[3] += h3;
hash[4] += h4;
}
for (let i = 0; i < 20; ++i) {
const word = hash[i];
hash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
}
return new Uint8Array(hash.buffer);
}
$.$mol_crypto_hash = $mol_crypto_hash;
})($ || ($ = {}));
//mol/crypto/hash/hash.ts
;
"use strict";
var $;
(function ($) {
const algorithm = {
name: 'AES-GCM',
name: 'AES-CBC',
length: 128,
tagLength: 32,
};
class $mol_crypto_secret extends Object {
native;
static size = 16;
static extra = 4;
constructor(native) {
super();
this.native = native;
Expand Down Expand Up @@ -20462,7 +20533,7 @@ var $;
try {
const pack = $mol_base64_decode(serial);
const closed = pack.slice(0, this.key_size());
const salt = pack.slice(this.key_size());
const salt = $mol_crypto_hash(pack.slice(this.key_size())).slice(0, 16);
const pass = this.password();
const secret = $mol_wire_sync(this.$.$mol_crypto_secret).from(pass);
const opened = $mol_wire_sync(secret).decrypt(closed, salt);
Expand All @@ -20482,14 +20553,14 @@ var $;
}
key_export() {
const pass = this.password();
const recall = this.recall() || '...';
const recall = $mol_charset_encode(this.recall());
const secret = $mol_wire_sync(this.$.$mol_crypto_secret).from(pass);
const salt = $mol_charset_encode(recall);
const salt = $mol_crypto_hash(recall).slice(0, 16);
const open = this.$.$mol_charset_encode(this.yard().peer().key_private_serial);
const closed = new Uint8Array($mol_wire_sync(secret).encrypt(open, salt));
const pack = new Uint8Array(this.key_size() + salt.byteLength);
const pack = new Uint8Array(this.key_size() + recall.byteLength);
pack.set(closed, 0);
pack.set(salt, this.key_size());
pack.set(recall, this.key_size());
return this.$.$mol_base64_encode(pack);
}
export_rows() {
Expand Down
2 changes: 1 addition & 1 deletion node.js.map

Large diffs are not rendered by default.

87 changes: 79 additions & 8 deletions node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20100,7 +20100,7 @@ var $;
return this.$.$mol_locale.text('$hyoo_meta_safe_bid_pass_long');
}
key_size() {
return 133;
return 144;
}
attr() {
return {
Expand Down Expand Up @@ -20311,16 +20311,87 @@ var $;
;
"use strict";
var $;
(function ($) {
let sponge = new Uint32Array(80);
function $mol_crypto_hash(data) {
const bits = data.byteLength << 3;
const kbits = bits >> 5;
const kword = 0x80 << (24 - bits & 0b11111);
const bytes = 16 + (bits + 64 >>> 9 << 4);
const klens = bytes - 1;
const words = new Int32Array(data.buffer, data.byteOffset, data.byteLength >> 2);
let tail = 0;
for (let i = words.length * 4; i < data.length; ++i) {
tail |= data[i] << (i << 3 & 0b11000);
}
const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]);
for (let i = 0; i < bytes; i += 16) {
let h0 = hash[0];
let h1 = hash[1];
let h2 = hash[2];
let h3 = hash[3];
let h4 = hash[4];
for (let j = 0; j < 80; ++j) {
let turn;
if (j < 16) {
const k = i + j;
if (k === klens) {
sponge[j] = bits;
}
else {
let word = k === words.length ? tail :
k > words.length ? 0 :
words[k];
word = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
if (k === kbits)
word |= kword;
sponge[j] = word;
}
turn = (h1 & h2 | ~h1 & h3) + 1518500249;
}
else {
const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16];
sponge[j] = shuffle << 1 | shuffle >>> 31;
turn =
j < 20 ? (h1 & h2 | ~h1 & h3) + 1518500249 :
j < 40 ? (h1 ^ h2 ^ h3) + 1859775393 :
j < 60 ? (h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 :
(h1 ^ h2 ^ h3) - 899497514;
}
const next = turn + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27));
h4 = h3;
h3 = h2;
h2 = (h1 << 30) | (h1 >>> 2);
h1 = h0;
h0 = next;
}
hash[0] += h0;
hash[1] += h1;
hash[2] += h2;
hash[3] += h3;
hash[4] += h4;
}
for (let i = 0; i < 20; ++i) {
const word = hash[i];
hash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF;
}
return new Uint8Array(hash.buffer);
}
$.$mol_crypto_hash = $mol_crypto_hash;
})($ || ($ = {}));
//mol/crypto/hash/hash.ts
;
"use strict";
var $;
(function ($) {
const algorithm = {
name: 'AES-GCM',
name: 'AES-CBC',
length: 128,
tagLength: 32,
};
class $mol_crypto_secret extends Object {
native;
static size = 16;
static extra = 4;
constructor(native) {
super();
this.native = native;
Expand Down Expand Up @@ -20462,7 +20533,7 @@ var $;
try {
const pack = $mol_base64_decode(serial);
const closed = pack.slice(0, this.key_size());
const salt = pack.slice(this.key_size());
const salt = $mol_crypto_hash(pack.slice(this.key_size())).slice(0, 16);
const pass = this.password();
const secret = $mol_wire_sync(this.$.$mol_crypto_secret).from(pass);
const opened = $mol_wire_sync(secret).decrypt(closed, salt);
Expand All @@ -20482,14 +20553,14 @@ var $;
}
key_export() {
const pass = this.password();
const recall = this.recall() || '...';
const recall = $mol_charset_encode(this.recall());
const secret = $mol_wire_sync(this.$.$mol_crypto_secret).from(pass);
const salt = $mol_charset_encode(recall);
const salt = $mol_crypto_hash(recall).slice(0, 16);
const open = this.$.$mol_charset_encode(this.yard().peer().key_private_serial);
const closed = new Uint8Array($mol_wire_sync(secret).encrypt(open, salt));
const pack = new Uint8Array(this.key_size() + salt.byteLength);
const pack = new Uint8Array(this.key_size() + recall.byteLength);
pack.set(closed, 0);
pack.set(salt, this.key_size());
pack.set(recall, this.key_size());
return this.$.$mol_base64_encode(pack);
}
export_rows() {
Expand Down
Loading

0 comments on commit 9631dfe

Please sign in to comment.