@cathaysia/crown-wasm 0.26.6 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/crown_wasm.d.ts +100 -8
- package/crown_wasm_bg.js +1008 -51
- package/crown_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/crown_wasm.d.ts
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export function ed25519_keygen(): Uint8Array;
|
|
4
|
+
export function ed25519_sign(secret: Uint8Array, msg: Uint8Array): Uint8Array;
|
|
5
|
+
export function ed25519_verify(_public: Uint8Array, msg: Uint8Array, sig: Uint8Array): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Returns `public || private`.
|
|
8
|
+
*/
|
|
9
|
+
export function ml_dsa_keygen(variant: number, seed: Uint8Array): Uint8Array;
|
|
10
|
+
export function ml_dsa_sign(variant: number, _private: Uint8Array, msg: Uint8Array, ctx: Uint8Array): Uint8Array;
|
|
11
|
+
export function ml_dsa_verify(variant: number, _public: Uint8Array, msg: Uint8Array, ctx: Uint8Array, sig: Uint8Array): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Returns `public || private`.
|
|
14
|
+
*/
|
|
15
|
+
export function slh_dsa_keygen(name: string, seed: Uint8Array): Uint8Array;
|
|
16
|
+
export function slh_dsa_sign(name: string, _private: Uint8Array, msg: Uint8Array, ctx: Uint8Array): Uint8Array;
|
|
17
|
+
export function slh_dsa_verify(name: string, _public: Uint8Array, msg: Uint8Array, ctx: Uint8Array, sig: Uint8Array): boolean;
|
|
18
|
+
export function aes_key_wrap(key: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
19
|
+
export function aes_key_unwrap(key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
20
|
+
export function aes_key_wrap_padded(key: Uint8Array, plaintext: Uint8Array): Uint8Array;
|
|
21
|
+
export function aes_key_unwrap_padded(key: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
22
|
+
export function ff1_encrypt_decimal(key: Uint8Array, tweak: Uint8Array, input: string): string;
|
|
23
|
+
export function ff1_decrypt_decimal(key: Uint8Array, tweak: Uint8Array, input: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* PBKDF2-HMAC-SHA256.
|
|
26
|
+
*/
|
|
27
|
+
export function pbkdf2(password: Uint8Array, salt: Uint8Array, iterations: number, length: number): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* HKDF-Extract + Expand with SHA-256. `info` may be empty.
|
|
30
|
+
*/
|
|
31
|
+
export function hkdf(ikm: Uint8Array, salt: Uint8Array, info: Uint8Array, length: number): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* TLS 1.2 PRF with SHA-256. `seed` is the label+seed material.
|
|
34
|
+
*/
|
|
35
|
+
export function tls1_prf(secret: Uint8Array, seed: Uint8Array, length: number): Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* SSKDF (hash-based) with SHA-256.
|
|
38
|
+
*/
|
|
39
|
+
export function sskdf(secret: Uint8Array, info: Uint8Array, length: number): Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* X963KDF with SHA-256.
|
|
42
|
+
*/
|
|
43
|
+
export function x963_kdf(secret: Uint8Array, info: Uint8Array, length: number): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* HOTP (RFC 4226).
|
|
46
|
+
*/
|
|
47
|
+
export function hotp(key: Uint8Array, counter: number, digits: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* TOTP (RFC 6238).
|
|
50
|
+
*/
|
|
51
|
+
export function totp(key: Uint8Array, time: number, step: number, digits: number, t0: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns `public || private`.
|
|
54
|
+
*/
|
|
55
|
+
export function ml_kem_keygen(variant: number, seed: Uint8Array): Uint8Array;
|
|
56
|
+
/**
|
|
57
|
+
* Returns `ciphertext || shared_secret`.
|
|
58
|
+
*/
|
|
59
|
+
export function ml_kem_encapsulate(variant: number, _public: Uint8Array, message: Uint8Array): Uint8Array;
|
|
60
|
+
export function ml_kem_decapsulate(variant: number, _private: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
3
61
|
export class AeadCipher {
|
|
4
62
|
private constructor();
|
|
5
63
|
free(): void;
|
|
@@ -20,6 +78,9 @@ export class AeadCipher {
|
|
|
20
78
|
static new_multi2_eax(key: Uint8Array, tag_size: number, nonce_size: number, rounds?: number | null): AeadCipher;
|
|
21
79
|
static new_chacha20_poly1305(key: Uint8Array): AeadCipher;
|
|
22
80
|
static new_xchacha20_poly1305(key: Uint8Array): AeadCipher;
|
|
81
|
+
static new_aes_gcm_siv(key: Uint8Array): AeadCipher;
|
|
82
|
+
static new_ascon_aead128(key: Uint8Array): AeadCipher;
|
|
83
|
+
static new_aes_siv(key: Uint8Array): AeadCipher;
|
|
23
84
|
nonce_size(): number;
|
|
24
85
|
open_in_place_separate_tag(data: Uint8Array, tag: Uint8Array, nonce: Uint8Array, aad: Uint8Array): void;
|
|
25
86
|
seal_in_place_separate_tag(data: Uint8Array, nonce: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
@@ -103,6 +164,7 @@ export class BlockCipher {
|
|
|
103
164
|
private constructor();
|
|
104
165
|
free(): void;
|
|
105
166
|
[Symbol.dispose](): void;
|
|
167
|
+
static new_camellia_cbc(key: Uint8Array, iv: Uint8Array, rounds?: number | null): BlockCipher;
|
|
106
168
|
static new_multi2_cbc(key: Uint8Array, iv: Uint8Array, rounds?: number | null): BlockCipher;
|
|
107
169
|
decrypt(data: Uint8Array): number;
|
|
108
170
|
encrypt(data: Uint8Array, pos: number): number;
|
|
@@ -125,14 +187,22 @@ export class BlockCipher {
|
|
|
125
187
|
static new_noekeon_cbc(key: Uint8Array, iv: Uint8Array): BlockCipher;
|
|
126
188
|
static new_khazad_cbc(key: Uint8Array, iv: Uint8Array): BlockCipher;
|
|
127
189
|
static new_serpent_cbc(key: Uint8Array, iv: Uint8Array): BlockCipher;
|
|
190
|
+
static new_desx_cbc(key: Uint8Array, iv: Uint8Array): BlockCipher;
|
|
128
191
|
static new_rc2_cbc(key: Uint8Array, iv: Uint8Array, rounds?: number | null): BlockCipher;
|
|
129
192
|
static new_rc5_cbc(key: Uint8Array, iv: Uint8Array, rounds?: number | null): BlockCipher;
|
|
130
|
-
static new_camellia_cbc(key: Uint8Array, iv: Uint8Array, rounds?: number | null): BlockCipher;
|
|
131
193
|
}
|
|
132
194
|
export class Hash {
|
|
133
195
|
private constructor();
|
|
134
196
|
free(): void;
|
|
135
197
|
[Symbol.dispose](): void;
|
|
198
|
+
static new_blake2b(key: Uint8Array | null | undefined, output_len: number): Hash;
|
|
199
|
+
block_size(): number;
|
|
200
|
+
sum(): Uint8Array;
|
|
201
|
+
read(buf: Uint8Array): number;
|
|
202
|
+
size(): number;
|
|
203
|
+
flush(): void;
|
|
204
|
+
reset(): void;
|
|
205
|
+
write(data: Uint8Array): number;
|
|
136
206
|
static new_md2_hmac(key: Uint8Array): Hash;
|
|
137
207
|
static new_md2(): Hash;
|
|
138
208
|
static new_md4_hmac(key: Uint8Array): Hash;
|
|
@@ -167,15 +237,27 @@ export class Hash {
|
|
|
167
237
|
static new_shake256_hmac(key: Uint8Array): Hash;
|
|
168
238
|
static new_sm3_hmac(key: Uint8Array): Hash;
|
|
169
239
|
static new_sm3(): Hash;
|
|
240
|
+
static new_md5_sha1(): Hash;
|
|
241
|
+
static new_md5_sha1_hmac(key: Uint8Array): Hash;
|
|
242
|
+
static new_ripemd160(): Hash;
|
|
243
|
+
static new_ripemd160_hmac(key: Uint8Array): Hash;
|
|
244
|
+
static new_mdc2_hmac(key: Uint8Array): Hash;
|
|
245
|
+
static new_mdc2(): Hash;
|
|
246
|
+
static new_whirlpool(): Hash;
|
|
247
|
+
static new_whirlpool_hmac(key: Uint8Array): Hash;
|
|
170
248
|
static new_blake2s(key: Uint8Array | null | undefined, output_len: number): Hash;
|
|
171
|
-
|
|
172
|
-
|
|
249
|
+
}
|
|
250
|
+
export class Mac {
|
|
251
|
+
private constructor();
|
|
252
|
+
free(): void;
|
|
253
|
+
[Symbol.dispose](): void;
|
|
254
|
+
static new_kmac128(key: Uint8Array, custom: Uint8Array, output_len: number): Mac;
|
|
255
|
+
static new_kmac256(key: Uint8Array, custom: Uint8Array, output_len: number): Mac;
|
|
256
|
+
static new_siphash(key: Uint8Array, output_len: number): Mac;
|
|
257
|
+
static new_cmac_aes(key: Uint8Array): Mac;
|
|
258
|
+
static new_gmac_aes(key: Uint8Array, iv: Uint8Array): Mac;
|
|
173
259
|
sum(): Uint8Array;
|
|
174
|
-
|
|
175
|
-
size(): number;
|
|
176
|
-
flush(): void;
|
|
177
|
-
reset(): void;
|
|
178
|
-
write(data: Uint8Array): number;
|
|
260
|
+
write(data: Uint8Array): void;
|
|
179
261
|
}
|
|
180
262
|
export class StreamCipher {
|
|
181
263
|
private constructor();
|
|
@@ -259,3 +341,13 @@ export class StreamCipher {
|
|
|
259
341
|
static new_camellia_ctr(key: Uint8Array, iv: Uint8Array, rounds?: number | null): StreamCipher;
|
|
260
342
|
static new_camellia_ofb(key: Uint8Array, iv: Uint8Array, rounds?: number | null): StreamCipher;
|
|
261
343
|
}
|
|
344
|
+
export class Xts {
|
|
345
|
+
private constructor();
|
|
346
|
+
free(): void;
|
|
347
|
+
[Symbol.dispose](): void;
|
|
348
|
+
static new_sm4_gb(key: Uint8Array): Xts;
|
|
349
|
+
decrypt(tweak: Uint8Array, data: Uint8Array): void;
|
|
350
|
+
encrypt(tweak: Uint8Array, data: Uint8Array): void;
|
|
351
|
+
static new_aes(key: Uint8Array): Xts;
|
|
352
|
+
static new_sm4(key: Uint8Array): Xts;
|
|
353
|
+
}
|
package/crown_wasm_bg.js
CHANGED
|
@@ -18,6 +18,21 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
18
18
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function addToExternrefTable0(obj) {
|
|
22
|
+
const idx = wasm.__externref_table_alloc();
|
|
23
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
24
|
+
return idx;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function handleError(f, args) {
|
|
28
|
+
try {
|
|
29
|
+
return f.apply(this, args);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
const idx = addToExternrefTable0(e);
|
|
32
|
+
wasm.__wbindgen_exn_store(idx);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
37
|
|
|
23
38
|
cachedTextDecoder.decode();
|
|
@@ -49,7 +64,7 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
49
64
|
}
|
|
50
65
|
|
|
51
66
|
function takeFromExternrefTable0(idx) {
|
|
52
|
-
const value = wasm.
|
|
67
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
53
68
|
wasm.__externref_table_dealloc(idx);
|
|
54
69
|
return value;
|
|
55
70
|
}
|
|
@@ -57,6 +72,580 @@ function takeFromExternrefTable0(idx) {
|
|
|
57
72
|
function isLikeNone(x) {
|
|
58
73
|
return x === undefined || x === null;
|
|
59
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @returns {Uint8Array}
|
|
77
|
+
*/
|
|
78
|
+
export function ed25519_keygen() {
|
|
79
|
+
const ret = wasm.ed25519_keygen();
|
|
80
|
+
if (ret[3]) {
|
|
81
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
82
|
+
}
|
|
83
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
84
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
85
|
+
return v1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {Uint8Array} secret
|
|
90
|
+
* @param {Uint8Array} msg
|
|
91
|
+
* @returns {Uint8Array}
|
|
92
|
+
*/
|
|
93
|
+
export function ed25519_sign(secret, msg) {
|
|
94
|
+
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
95
|
+
const len0 = WASM_VECTOR_LEN;
|
|
96
|
+
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
97
|
+
const len1 = WASM_VECTOR_LEN;
|
|
98
|
+
const ret = wasm.ed25519_sign(ptr0, len0, ptr1, len1);
|
|
99
|
+
if (ret[3]) {
|
|
100
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
101
|
+
}
|
|
102
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
103
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
104
|
+
return v3;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param {Uint8Array} _public
|
|
109
|
+
* @param {Uint8Array} msg
|
|
110
|
+
* @param {Uint8Array} sig
|
|
111
|
+
* @returns {boolean}
|
|
112
|
+
*/
|
|
113
|
+
export function ed25519_verify(_public, msg, sig) {
|
|
114
|
+
const ptr0 = passArray8ToWasm0(_public, wasm.__wbindgen_malloc);
|
|
115
|
+
const len0 = WASM_VECTOR_LEN;
|
|
116
|
+
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
117
|
+
const len1 = WASM_VECTOR_LEN;
|
|
118
|
+
const ptr2 = passArray8ToWasm0(sig, wasm.__wbindgen_malloc);
|
|
119
|
+
const len2 = WASM_VECTOR_LEN;
|
|
120
|
+
const ret = wasm.ed25519_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
121
|
+
if (ret[2]) {
|
|
122
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
123
|
+
}
|
|
124
|
+
return ret[0] !== 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Returns `public || private`.
|
|
129
|
+
* @param {number} variant
|
|
130
|
+
* @param {Uint8Array} seed
|
|
131
|
+
* @returns {Uint8Array}
|
|
132
|
+
*/
|
|
133
|
+
export function ml_dsa_keygen(variant, seed) {
|
|
134
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
135
|
+
const len0 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.ml_dsa_keygen(variant, ptr0, len0);
|
|
137
|
+
if (ret[3]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
139
|
+
}
|
|
140
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
141
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
142
|
+
return v2;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {number} variant
|
|
147
|
+
* @param {Uint8Array} _private
|
|
148
|
+
* @param {Uint8Array} msg
|
|
149
|
+
* @param {Uint8Array} ctx
|
|
150
|
+
* @returns {Uint8Array}
|
|
151
|
+
*/
|
|
152
|
+
export function ml_dsa_sign(variant, _private, msg, ctx) {
|
|
153
|
+
const ptr0 = passArray8ToWasm0(_private, wasm.__wbindgen_malloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
156
|
+
const len1 = WASM_VECTOR_LEN;
|
|
157
|
+
const ptr2 = passArray8ToWasm0(ctx, wasm.__wbindgen_malloc);
|
|
158
|
+
const len2 = WASM_VECTOR_LEN;
|
|
159
|
+
const ret = wasm.ml_dsa_sign(variant, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
160
|
+
if (ret[3]) {
|
|
161
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
162
|
+
}
|
|
163
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
164
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
165
|
+
return v4;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @param {number} variant
|
|
170
|
+
* @param {Uint8Array} _public
|
|
171
|
+
* @param {Uint8Array} msg
|
|
172
|
+
* @param {Uint8Array} ctx
|
|
173
|
+
* @param {Uint8Array} sig
|
|
174
|
+
* @returns {boolean}
|
|
175
|
+
*/
|
|
176
|
+
export function ml_dsa_verify(variant, _public, msg, ctx, sig) {
|
|
177
|
+
const ptr0 = passArray8ToWasm0(_public, wasm.__wbindgen_malloc);
|
|
178
|
+
const len0 = WASM_VECTOR_LEN;
|
|
179
|
+
const ptr1 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
180
|
+
const len1 = WASM_VECTOR_LEN;
|
|
181
|
+
const ptr2 = passArray8ToWasm0(ctx, wasm.__wbindgen_malloc);
|
|
182
|
+
const len2 = WASM_VECTOR_LEN;
|
|
183
|
+
const ptr3 = passArray8ToWasm0(sig, wasm.__wbindgen_malloc);
|
|
184
|
+
const len3 = WASM_VECTOR_LEN;
|
|
185
|
+
const ret = wasm.ml_dsa_verify(variant, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
186
|
+
if (ret[2]) {
|
|
187
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
188
|
+
}
|
|
189
|
+
return ret[0] !== 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const cachedTextEncoder = new TextEncoder();
|
|
193
|
+
|
|
194
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
195
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
196
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
197
|
+
view.set(buf);
|
|
198
|
+
return {
|
|
199
|
+
read: arg.length,
|
|
200
|
+
written: buf.length
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
206
|
+
|
|
207
|
+
if (realloc === undefined) {
|
|
208
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
209
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
210
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
211
|
+
WASM_VECTOR_LEN = buf.length;
|
|
212
|
+
return ptr;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let len = arg.length;
|
|
216
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
217
|
+
|
|
218
|
+
const mem = getUint8ArrayMemory0();
|
|
219
|
+
|
|
220
|
+
let offset = 0;
|
|
221
|
+
|
|
222
|
+
for (; offset < len; offset++) {
|
|
223
|
+
const code = arg.charCodeAt(offset);
|
|
224
|
+
if (code > 0x7F) break;
|
|
225
|
+
mem[ptr + offset] = code;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (offset !== len) {
|
|
229
|
+
if (offset !== 0) {
|
|
230
|
+
arg = arg.slice(offset);
|
|
231
|
+
}
|
|
232
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
233
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
234
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
235
|
+
|
|
236
|
+
offset += ret.written;
|
|
237
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
WASM_VECTOR_LEN = offset;
|
|
241
|
+
return ptr;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns `public || private`.
|
|
245
|
+
* @param {string} name
|
|
246
|
+
* @param {Uint8Array} seed
|
|
247
|
+
* @returns {Uint8Array}
|
|
248
|
+
*/
|
|
249
|
+
export function slh_dsa_keygen(name, seed) {
|
|
250
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
const ptr1 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
253
|
+
const len1 = WASM_VECTOR_LEN;
|
|
254
|
+
const ret = wasm.slh_dsa_keygen(ptr0, len0, ptr1, len1);
|
|
255
|
+
if (ret[3]) {
|
|
256
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
257
|
+
}
|
|
258
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
259
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
260
|
+
return v3;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @param {string} name
|
|
265
|
+
* @param {Uint8Array} _private
|
|
266
|
+
* @param {Uint8Array} msg
|
|
267
|
+
* @param {Uint8Array} ctx
|
|
268
|
+
* @returns {Uint8Array}
|
|
269
|
+
*/
|
|
270
|
+
export function slh_dsa_sign(name, _private, msg, ctx) {
|
|
271
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
+
const len0 = WASM_VECTOR_LEN;
|
|
273
|
+
const ptr1 = passArray8ToWasm0(_private, wasm.__wbindgen_malloc);
|
|
274
|
+
const len1 = WASM_VECTOR_LEN;
|
|
275
|
+
const ptr2 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
276
|
+
const len2 = WASM_VECTOR_LEN;
|
|
277
|
+
const ptr3 = passArray8ToWasm0(ctx, wasm.__wbindgen_malloc);
|
|
278
|
+
const len3 = WASM_VECTOR_LEN;
|
|
279
|
+
const ret = wasm.slh_dsa_sign(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
280
|
+
if (ret[3]) {
|
|
281
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
282
|
+
}
|
|
283
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
284
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
285
|
+
return v5;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {string} name
|
|
290
|
+
* @param {Uint8Array} _public
|
|
291
|
+
* @param {Uint8Array} msg
|
|
292
|
+
* @param {Uint8Array} ctx
|
|
293
|
+
* @param {Uint8Array} sig
|
|
294
|
+
* @returns {boolean}
|
|
295
|
+
*/
|
|
296
|
+
export function slh_dsa_verify(name, _public, msg, ctx, sig) {
|
|
297
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
298
|
+
const len0 = WASM_VECTOR_LEN;
|
|
299
|
+
const ptr1 = passArray8ToWasm0(_public, wasm.__wbindgen_malloc);
|
|
300
|
+
const len1 = WASM_VECTOR_LEN;
|
|
301
|
+
const ptr2 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
302
|
+
const len2 = WASM_VECTOR_LEN;
|
|
303
|
+
const ptr3 = passArray8ToWasm0(ctx, wasm.__wbindgen_malloc);
|
|
304
|
+
const len3 = WASM_VECTOR_LEN;
|
|
305
|
+
const ptr4 = passArray8ToWasm0(sig, wasm.__wbindgen_malloc);
|
|
306
|
+
const len4 = WASM_VECTOR_LEN;
|
|
307
|
+
const ret = wasm.slh_dsa_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
308
|
+
if (ret[2]) {
|
|
309
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
310
|
+
}
|
|
311
|
+
return ret[0] !== 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @param {Uint8Array} key
|
|
316
|
+
* @param {Uint8Array} plaintext
|
|
317
|
+
* @returns {Uint8Array}
|
|
318
|
+
*/
|
|
319
|
+
export function aes_key_wrap(key, plaintext) {
|
|
320
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
323
|
+
const len1 = WASM_VECTOR_LEN;
|
|
324
|
+
const ret = wasm.aes_key_wrap(ptr0, len0, ptr1, len1);
|
|
325
|
+
if (ret[3]) {
|
|
326
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
327
|
+
}
|
|
328
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
329
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
330
|
+
return v3;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @param {Uint8Array} key
|
|
335
|
+
* @param {Uint8Array} ciphertext
|
|
336
|
+
* @returns {Uint8Array}
|
|
337
|
+
*/
|
|
338
|
+
export function aes_key_unwrap(key, ciphertext) {
|
|
339
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
340
|
+
const len0 = WASM_VECTOR_LEN;
|
|
341
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
342
|
+
const len1 = WASM_VECTOR_LEN;
|
|
343
|
+
const ret = wasm.aes_key_unwrap(ptr0, len0, ptr1, len1);
|
|
344
|
+
if (ret[3]) {
|
|
345
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
346
|
+
}
|
|
347
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
348
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
349
|
+
return v3;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @param {Uint8Array} key
|
|
354
|
+
* @param {Uint8Array} plaintext
|
|
355
|
+
* @returns {Uint8Array}
|
|
356
|
+
*/
|
|
357
|
+
export function aes_key_wrap_padded(key, plaintext) {
|
|
358
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
const ret = wasm.aes_key_wrap_padded(ptr0, len0, ptr1, len1);
|
|
363
|
+
if (ret[3]) {
|
|
364
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
365
|
+
}
|
|
366
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
367
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
368
|
+
return v3;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @param {Uint8Array} key
|
|
373
|
+
* @param {Uint8Array} ciphertext
|
|
374
|
+
* @returns {Uint8Array}
|
|
375
|
+
*/
|
|
376
|
+
export function aes_key_unwrap_padded(key, ciphertext) {
|
|
377
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
380
|
+
const len1 = WASM_VECTOR_LEN;
|
|
381
|
+
const ret = wasm.aes_key_unwrap_padded(ptr0, len0, ptr1, len1);
|
|
382
|
+
if (ret[3]) {
|
|
383
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
384
|
+
}
|
|
385
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
386
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
387
|
+
return v3;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @param {Uint8Array} key
|
|
392
|
+
* @param {Uint8Array} tweak
|
|
393
|
+
* @param {string} input
|
|
394
|
+
* @returns {string}
|
|
395
|
+
*/
|
|
396
|
+
export function ff1_encrypt_decimal(key, tweak, input) {
|
|
397
|
+
let deferred5_0;
|
|
398
|
+
let deferred5_1;
|
|
399
|
+
try {
|
|
400
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
401
|
+
const len0 = WASM_VECTOR_LEN;
|
|
402
|
+
const ptr1 = passArray8ToWasm0(tweak, wasm.__wbindgen_malloc);
|
|
403
|
+
const len1 = WASM_VECTOR_LEN;
|
|
404
|
+
const ptr2 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
405
|
+
const len2 = WASM_VECTOR_LEN;
|
|
406
|
+
const ret = wasm.ff1_encrypt_decimal(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
407
|
+
var ptr4 = ret[0];
|
|
408
|
+
var len4 = ret[1];
|
|
409
|
+
if (ret[3]) {
|
|
410
|
+
ptr4 = 0; len4 = 0;
|
|
411
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
412
|
+
}
|
|
413
|
+
deferred5_0 = ptr4;
|
|
414
|
+
deferred5_1 = len4;
|
|
415
|
+
return getStringFromWasm0(ptr4, len4);
|
|
416
|
+
} finally {
|
|
417
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* @param {Uint8Array} key
|
|
423
|
+
* @param {Uint8Array} tweak
|
|
424
|
+
* @param {string} input
|
|
425
|
+
* @returns {string}
|
|
426
|
+
*/
|
|
427
|
+
export function ff1_decrypt_decimal(key, tweak, input) {
|
|
428
|
+
let deferred5_0;
|
|
429
|
+
let deferred5_1;
|
|
430
|
+
try {
|
|
431
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
432
|
+
const len0 = WASM_VECTOR_LEN;
|
|
433
|
+
const ptr1 = passArray8ToWasm0(tweak, wasm.__wbindgen_malloc);
|
|
434
|
+
const len1 = WASM_VECTOR_LEN;
|
|
435
|
+
const ptr2 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
436
|
+
const len2 = WASM_VECTOR_LEN;
|
|
437
|
+
const ret = wasm.ff1_decrypt_decimal(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
438
|
+
var ptr4 = ret[0];
|
|
439
|
+
var len4 = ret[1];
|
|
440
|
+
if (ret[3]) {
|
|
441
|
+
ptr4 = 0; len4 = 0;
|
|
442
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
443
|
+
}
|
|
444
|
+
deferred5_0 = ptr4;
|
|
445
|
+
deferred5_1 = len4;
|
|
446
|
+
return getStringFromWasm0(ptr4, len4);
|
|
447
|
+
} finally {
|
|
448
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* PBKDF2-HMAC-SHA256.
|
|
454
|
+
* @param {Uint8Array} password
|
|
455
|
+
* @param {Uint8Array} salt
|
|
456
|
+
* @param {number} iterations
|
|
457
|
+
* @param {number} length
|
|
458
|
+
* @returns {Uint8Array}
|
|
459
|
+
*/
|
|
460
|
+
export function pbkdf2(password, salt, iterations, length) {
|
|
461
|
+
const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);
|
|
462
|
+
const len0 = WASM_VECTOR_LEN;
|
|
463
|
+
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
|
|
464
|
+
const len1 = WASM_VECTOR_LEN;
|
|
465
|
+
const ret = wasm.pbkdf2(ptr0, len0, ptr1, len1, iterations, length);
|
|
466
|
+
if (ret[3]) {
|
|
467
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
468
|
+
}
|
|
469
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
470
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
471
|
+
return v3;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* HKDF-Extract + Expand with SHA-256. `info` may be empty.
|
|
476
|
+
* @param {Uint8Array} ikm
|
|
477
|
+
* @param {Uint8Array} salt
|
|
478
|
+
* @param {Uint8Array} info
|
|
479
|
+
* @param {number} length
|
|
480
|
+
* @returns {Uint8Array}
|
|
481
|
+
*/
|
|
482
|
+
export function hkdf(ikm, salt, info, length) {
|
|
483
|
+
const ptr0 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc);
|
|
484
|
+
const len0 = WASM_VECTOR_LEN;
|
|
485
|
+
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
|
|
486
|
+
const len1 = WASM_VECTOR_LEN;
|
|
487
|
+
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
488
|
+
const len2 = WASM_VECTOR_LEN;
|
|
489
|
+
const ret = wasm.hkdf(ptr0, len0, ptr1, len1, ptr2, len2, length);
|
|
490
|
+
if (ret[3]) {
|
|
491
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
492
|
+
}
|
|
493
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
494
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
495
|
+
return v4;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* TLS 1.2 PRF with SHA-256. `seed` is the label+seed material.
|
|
500
|
+
* @param {Uint8Array} secret
|
|
501
|
+
* @param {Uint8Array} seed
|
|
502
|
+
* @param {number} length
|
|
503
|
+
* @returns {Uint8Array}
|
|
504
|
+
*/
|
|
505
|
+
export function tls1_prf(secret, seed, length) {
|
|
506
|
+
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
507
|
+
const len0 = WASM_VECTOR_LEN;
|
|
508
|
+
const ptr1 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
509
|
+
const len1 = WASM_VECTOR_LEN;
|
|
510
|
+
const ret = wasm.tls1_prf(ptr0, len0, ptr1, len1, length);
|
|
511
|
+
if (ret[3]) {
|
|
512
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
513
|
+
}
|
|
514
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
515
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
516
|
+
return v3;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* SSKDF (hash-based) with SHA-256.
|
|
521
|
+
* @param {Uint8Array} secret
|
|
522
|
+
* @param {Uint8Array} info
|
|
523
|
+
* @param {number} length
|
|
524
|
+
* @returns {Uint8Array}
|
|
525
|
+
*/
|
|
526
|
+
export function sskdf(secret, info, length) {
|
|
527
|
+
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
528
|
+
const len0 = WASM_VECTOR_LEN;
|
|
529
|
+
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
530
|
+
const len1 = WASM_VECTOR_LEN;
|
|
531
|
+
const ret = wasm.sskdf(ptr0, len0, ptr1, len1, length);
|
|
532
|
+
if (ret[3]) {
|
|
533
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
534
|
+
}
|
|
535
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
536
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
537
|
+
return v3;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* X963KDF with SHA-256.
|
|
542
|
+
* @param {Uint8Array} secret
|
|
543
|
+
* @param {Uint8Array} info
|
|
544
|
+
* @param {number} length
|
|
545
|
+
* @returns {Uint8Array}
|
|
546
|
+
*/
|
|
547
|
+
export function x963_kdf(secret, info, length) {
|
|
548
|
+
const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
|
|
549
|
+
const len0 = WASM_VECTOR_LEN;
|
|
550
|
+
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
551
|
+
const len1 = WASM_VECTOR_LEN;
|
|
552
|
+
const ret = wasm.x963_kdf(ptr0, len0, ptr1, len1, length);
|
|
553
|
+
if (ret[3]) {
|
|
554
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
555
|
+
}
|
|
556
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
557
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
558
|
+
return v3;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* HOTP (RFC 4226).
|
|
563
|
+
* @param {Uint8Array} key
|
|
564
|
+
* @param {number} counter
|
|
565
|
+
* @param {number} digits
|
|
566
|
+
* @returns {number}
|
|
567
|
+
*/
|
|
568
|
+
export function hotp(key, counter, digits) {
|
|
569
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
570
|
+
const len0 = WASM_VECTOR_LEN;
|
|
571
|
+
const ret = wasm.hotp(ptr0, len0, counter, digits);
|
|
572
|
+
return ret >>> 0;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* TOTP (RFC 6238).
|
|
577
|
+
* @param {Uint8Array} key
|
|
578
|
+
* @param {number} time
|
|
579
|
+
* @param {number} step
|
|
580
|
+
* @param {number} digits
|
|
581
|
+
* @param {number} t0
|
|
582
|
+
* @returns {number}
|
|
583
|
+
*/
|
|
584
|
+
export function totp(key, time, step, digits, t0) {
|
|
585
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
586
|
+
const len0 = WASM_VECTOR_LEN;
|
|
587
|
+
const ret = wasm.totp(ptr0, len0, time, step, digits, t0);
|
|
588
|
+
return ret >>> 0;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Returns `public || private`.
|
|
593
|
+
* @param {number} variant
|
|
594
|
+
* @param {Uint8Array} seed
|
|
595
|
+
* @returns {Uint8Array}
|
|
596
|
+
*/
|
|
597
|
+
export function ml_kem_keygen(variant, seed) {
|
|
598
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
599
|
+
const len0 = WASM_VECTOR_LEN;
|
|
600
|
+
const ret = wasm.ml_kem_keygen(variant, ptr0, len0);
|
|
601
|
+
if (ret[3]) {
|
|
602
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
603
|
+
}
|
|
604
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
605
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
606
|
+
return v2;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Returns `ciphertext || shared_secret`.
|
|
611
|
+
* @param {number} variant
|
|
612
|
+
* @param {Uint8Array} _public
|
|
613
|
+
* @param {Uint8Array} message
|
|
614
|
+
* @returns {Uint8Array}
|
|
615
|
+
*/
|
|
616
|
+
export function ml_kem_encapsulate(variant, _public, message) {
|
|
617
|
+
const ptr0 = passArray8ToWasm0(_public, wasm.__wbindgen_malloc);
|
|
618
|
+
const len0 = WASM_VECTOR_LEN;
|
|
619
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
620
|
+
const len1 = WASM_VECTOR_LEN;
|
|
621
|
+
const ret = wasm.ml_kem_encapsulate(variant, ptr0, len0, ptr1, len1);
|
|
622
|
+
if (ret[3]) {
|
|
623
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
624
|
+
}
|
|
625
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
626
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
627
|
+
return v3;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* @param {number} variant
|
|
632
|
+
* @param {Uint8Array} _private
|
|
633
|
+
* @param {Uint8Array} ciphertext
|
|
634
|
+
* @returns {Uint8Array}
|
|
635
|
+
*/
|
|
636
|
+
export function ml_kem_decapsulate(variant, _private, ciphertext) {
|
|
637
|
+
const ptr0 = passArray8ToWasm0(_private, wasm.__wbindgen_malloc);
|
|
638
|
+
const len0 = WASM_VECTOR_LEN;
|
|
639
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
640
|
+
const len1 = WASM_VECTOR_LEN;
|
|
641
|
+
const ret = wasm.ml_kem_decapsulate(variant, ptr0, len0, ptr1, len1);
|
|
642
|
+
if (ret[3]) {
|
|
643
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
644
|
+
}
|
|
645
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
646
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
647
|
+
return v3;
|
|
648
|
+
}
|
|
60
649
|
|
|
61
650
|
const AeadCipherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
62
651
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -315,6 +904,45 @@ export class AeadCipher {
|
|
|
315
904
|
}
|
|
316
905
|
return AeadCipher.__wrap(ret[0]);
|
|
317
906
|
}
|
|
907
|
+
/**
|
|
908
|
+
* @param {Uint8Array} key
|
|
909
|
+
* @returns {AeadCipher}
|
|
910
|
+
*/
|
|
911
|
+
static new_aes_gcm_siv(key) {
|
|
912
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
913
|
+
const len0 = WASM_VECTOR_LEN;
|
|
914
|
+
const ret = wasm.aeadcipher_new_aes_gcm_siv(ptr0, len0);
|
|
915
|
+
if (ret[2]) {
|
|
916
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
917
|
+
}
|
|
918
|
+
return AeadCipher.__wrap(ret[0]);
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* @param {Uint8Array} key
|
|
922
|
+
* @returns {AeadCipher}
|
|
923
|
+
*/
|
|
924
|
+
static new_ascon_aead128(key) {
|
|
925
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
926
|
+
const len0 = WASM_VECTOR_LEN;
|
|
927
|
+
const ret = wasm.aeadcipher_new_ascon_aead128(ptr0, len0);
|
|
928
|
+
if (ret[2]) {
|
|
929
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
930
|
+
}
|
|
931
|
+
return AeadCipher.__wrap(ret[0]);
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* @param {Uint8Array} key
|
|
935
|
+
* @returns {AeadCipher}
|
|
936
|
+
*/
|
|
937
|
+
static new_aes_siv(key) {
|
|
938
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
939
|
+
const len0 = WASM_VECTOR_LEN;
|
|
940
|
+
const ret = wasm.aeadcipher_new_aes_siv(ptr0, len0);
|
|
941
|
+
if (ret[2]) {
|
|
942
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
943
|
+
}
|
|
944
|
+
return AeadCipher.__wrap(ret[0]);
|
|
945
|
+
}
|
|
318
946
|
/**
|
|
319
947
|
* @returns {number}
|
|
320
948
|
*/
|
|
@@ -1478,6 +2106,23 @@ export class BlockCipher {
|
|
|
1478
2106
|
const ptr = this.__destroy_into_raw();
|
|
1479
2107
|
wasm.__wbg_blockcipher_free(ptr, 0);
|
|
1480
2108
|
}
|
|
2109
|
+
/**
|
|
2110
|
+
* @param {Uint8Array} key
|
|
2111
|
+
* @param {Uint8Array} iv
|
|
2112
|
+
* @param {number | null} [rounds]
|
|
2113
|
+
* @returns {BlockCipher}
|
|
2114
|
+
*/
|
|
2115
|
+
static new_camellia_cbc(key, iv, rounds) {
|
|
2116
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
2117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2118
|
+
const ptr1 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
2119
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2120
|
+
const ret = wasm.blockcipher_new_camellia_cbc(ptr0, len0, ptr1, len1, isLikeNone(rounds) ? 0x100000001 : (rounds) >>> 0);
|
|
2121
|
+
if (ret[2]) {
|
|
2122
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2123
|
+
}
|
|
2124
|
+
return BlockCipher.__wrap(ret[0]);
|
|
2125
|
+
}
|
|
1481
2126
|
/**
|
|
1482
2127
|
* @param {Uint8Array} key
|
|
1483
2128
|
* @param {Uint8Array} iv
|
|
@@ -1829,15 +2474,14 @@ export class BlockCipher {
|
|
|
1829
2474
|
/**
|
|
1830
2475
|
* @param {Uint8Array} key
|
|
1831
2476
|
* @param {Uint8Array} iv
|
|
1832
|
-
* @param {number | null} [rounds]
|
|
1833
2477
|
* @returns {BlockCipher}
|
|
1834
2478
|
*/
|
|
1835
|
-
static
|
|
2479
|
+
static new_desx_cbc(key, iv) {
|
|
1836
2480
|
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
1837
2481
|
const len0 = WASM_VECTOR_LEN;
|
|
1838
2482
|
const ptr1 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
1839
2483
|
const len1 = WASM_VECTOR_LEN;
|
|
1840
|
-
const ret = wasm.
|
|
2484
|
+
const ret = wasm.blockcipher_new_desx_cbc(ptr0, len0, ptr1, len1);
|
|
1841
2485
|
if (ret[2]) {
|
|
1842
2486
|
throw takeFromExternrefTable0(ret[1]);
|
|
1843
2487
|
}
|
|
@@ -1849,12 +2493,12 @@ export class BlockCipher {
|
|
|
1849
2493
|
* @param {number | null} [rounds]
|
|
1850
2494
|
* @returns {BlockCipher}
|
|
1851
2495
|
*/
|
|
1852
|
-
static
|
|
2496
|
+
static new_rc2_cbc(key, iv, rounds) {
|
|
1853
2497
|
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
1854
2498
|
const len0 = WASM_VECTOR_LEN;
|
|
1855
2499
|
const ptr1 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
1856
2500
|
const len1 = WASM_VECTOR_LEN;
|
|
1857
|
-
const ret = wasm.
|
|
2501
|
+
const ret = wasm.blockcipher_new_rc2_cbc(ptr0, len0, ptr1, len1, isLikeNone(rounds) ? 0x100000001 : (rounds) >>> 0);
|
|
1858
2502
|
if (ret[2]) {
|
|
1859
2503
|
throw takeFromExternrefTable0(ret[1]);
|
|
1860
2504
|
}
|
|
@@ -1866,12 +2510,12 @@ export class BlockCipher {
|
|
|
1866
2510
|
* @param {number | null} [rounds]
|
|
1867
2511
|
* @returns {BlockCipher}
|
|
1868
2512
|
*/
|
|
1869
|
-
static
|
|
2513
|
+
static new_rc5_cbc(key, iv, rounds) {
|
|
1870
2514
|
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
1871
2515
|
const len0 = WASM_VECTOR_LEN;
|
|
1872
2516
|
const ptr1 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
1873
2517
|
const len1 = WASM_VECTOR_LEN;
|
|
1874
|
-
const ret = wasm.
|
|
2518
|
+
const ret = wasm.blockcipher_new_rc5_cbc(ptr0, len0, ptr1, len1, isLikeNone(rounds) ? 0x100000001 : (rounds) >>> 0);
|
|
1875
2519
|
if (ret[2]) {
|
|
1876
2520
|
throw takeFromExternrefTable0(ret[1]);
|
|
1877
2521
|
}
|
|
@@ -1905,6 +2549,78 @@ export class Hash {
|
|
|
1905
2549
|
const ptr = this.__destroy_into_raw();
|
|
1906
2550
|
wasm.__wbg_hash_free(ptr, 0);
|
|
1907
2551
|
}
|
|
2552
|
+
/**
|
|
2553
|
+
* @param {Uint8Array | null | undefined} key
|
|
2554
|
+
* @param {number} output_len
|
|
2555
|
+
* @returns {Hash}
|
|
2556
|
+
*/
|
|
2557
|
+
static new_blake2b(key, output_len) {
|
|
2558
|
+
var ptr0 = isLikeNone(key) ? 0 : passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
2559
|
+
var len0 = WASM_VECTOR_LEN;
|
|
2560
|
+
const ret = wasm.hash_new_blake2b(ptr0, len0, output_len);
|
|
2561
|
+
if (ret[2]) {
|
|
2562
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2563
|
+
}
|
|
2564
|
+
return Hash.__wrap(ret[0]);
|
|
2565
|
+
}
|
|
2566
|
+
/**
|
|
2567
|
+
* @returns {number}
|
|
2568
|
+
*/
|
|
2569
|
+
block_size() {
|
|
2570
|
+
const ret = wasm.hash_block_size(this.__wbg_ptr);
|
|
2571
|
+
return ret >>> 0;
|
|
2572
|
+
}
|
|
2573
|
+
/**
|
|
2574
|
+
* @returns {Uint8Array}
|
|
2575
|
+
*/
|
|
2576
|
+
sum() {
|
|
2577
|
+
const ret = wasm.hash_sum(this.__wbg_ptr);
|
|
2578
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2579
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2580
|
+
return v1;
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* @param {Uint8Array} buf
|
|
2584
|
+
* @returns {number}
|
|
2585
|
+
*/
|
|
2586
|
+
read(buf) {
|
|
2587
|
+
var ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc);
|
|
2588
|
+
var len0 = WASM_VECTOR_LEN;
|
|
2589
|
+
const ret = wasm.hash_read(this.__wbg_ptr, ptr0, len0, buf);
|
|
2590
|
+
if (ret[2]) {
|
|
2591
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2592
|
+
}
|
|
2593
|
+
return ret[0] >>> 0;
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* @returns {number}
|
|
2597
|
+
*/
|
|
2598
|
+
size() {
|
|
2599
|
+
const ret = wasm.hash_size(this.__wbg_ptr);
|
|
2600
|
+
return ret >>> 0;
|
|
2601
|
+
}
|
|
2602
|
+
flush() {
|
|
2603
|
+
const ret = wasm.hash_flush(this.__wbg_ptr);
|
|
2604
|
+
if (ret[1]) {
|
|
2605
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
reset() {
|
|
2609
|
+
wasm.hash_reset(this.__wbg_ptr);
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2612
|
+
* @param {Uint8Array} data
|
|
2613
|
+
* @returns {number}
|
|
2614
|
+
*/
|
|
2615
|
+
write(data) {
|
|
2616
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2617
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2618
|
+
const ret = wasm.hash_write(this.__wbg_ptr, ptr0, len0);
|
|
2619
|
+
if (ret[2]) {
|
|
2620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2621
|
+
}
|
|
2622
|
+
return ret[0] >>> 0;
|
|
2623
|
+
}
|
|
1908
2624
|
/**
|
|
1909
2625
|
* @param {Uint8Array} key
|
|
1910
2626
|
* @returns {Hash}
|
|
@@ -2297,14 +3013,92 @@ export class Hash {
|
|
|
2297
3013
|
return Hash.__wrap(ret[0]);
|
|
2298
3014
|
}
|
|
2299
3015
|
/**
|
|
2300
|
-
* @param {Uint8Array | null | undefined} key
|
|
2301
|
-
* @param {number} output_len
|
|
2302
3016
|
* @returns {Hash}
|
|
2303
3017
|
*/
|
|
2304
|
-
static
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
3018
|
+
static new_md5_sha1() {
|
|
3019
|
+
const ret = wasm.hash_new_md5_sha1();
|
|
3020
|
+
if (ret[2]) {
|
|
3021
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3022
|
+
}
|
|
3023
|
+
return Hash.__wrap(ret[0]);
|
|
3024
|
+
}
|
|
3025
|
+
/**
|
|
3026
|
+
* @param {Uint8Array} key
|
|
3027
|
+
* @returns {Hash}
|
|
3028
|
+
*/
|
|
3029
|
+
static new_md5_sha1_hmac(key) {
|
|
3030
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3031
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3032
|
+
const ret = wasm.hash_new_md5_sha1_hmac(ptr0, len0);
|
|
3033
|
+
if (ret[2]) {
|
|
3034
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3035
|
+
}
|
|
3036
|
+
return Hash.__wrap(ret[0]);
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* @returns {Hash}
|
|
3040
|
+
*/
|
|
3041
|
+
static new_ripemd160() {
|
|
3042
|
+
const ret = wasm.hash_new_ripemd160();
|
|
3043
|
+
if (ret[2]) {
|
|
3044
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3045
|
+
}
|
|
3046
|
+
return Hash.__wrap(ret[0]);
|
|
3047
|
+
}
|
|
3048
|
+
/**
|
|
3049
|
+
* @param {Uint8Array} key
|
|
3050
|
+
* @returns {Hash}
|
|
3051
|
+
*/
|
|
3052
|
+
static new_ripemd160_hmac(key) {
|
|
3053
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3054
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3055
|
+
const ret = wasm.hash_new_ripemd160_hmac(ptr0, len0);
|
|
3056
|
+
if (ret[2]) {
|
|
3057
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3058
|
+
}
|
|
3059
|
+
return Hash.__wrap(ret[0]);
|
|
3060
|
+
}
|
|
3061
|
+
/**
|
|
3062
|
+
* @param {Uint8Array} key
|
|
3063
|
+
* @returns {Hash}
|
|
3064
|
+
*/
|
|
3065
|
+
static new_mdc2_hmac(key) {
|
|
3066
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3067
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3068
|
+
const ret = wasm.hash_new_mdc2_hmac(ptr0, len0);
|
|
3069
|
+
if (ret[2]) {
|
|
3070
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3071
|
+
}
|
|
3072
|
+
return Hash.__wrap(ret[0]);
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* @returns {Hash}
|
|
3076
|
+
*/
|
|
3077
|
+
static new_mdc2() {
|
|
3078
|
+
const ret = wasm.hash_new_mdc2();
|
|
3079
|
+
if (ret[2]) {
|
|
3080
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3081
|
+
}
|
|
3082
|
+
return Hash.__wrap(ret[0]);
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3085
|
+
* @returns {Hash}
|
|
3086
|
+
*/
|
|
3087
|
+
static new_whirlpool() {
|
|
3088
|
+
const ret = wasm.hash_new_whirlpool();
|
|
3089
|
+
if (ret[2]) {
|
|
3090
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3091
|
+
}
|
|
3092
|
+
return Hash.__wrap(ret[0]);
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* @param {Uint8Array} key
|
|
3096
|
+
* @returns {Hash}
|
|
3097
|
+
*/
|
|
3098
|
+
static new_whirlpool_hmac(key) {
|
|
3099
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3100
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3101
|
+
const ret = wasm.hash_new_whirlpool_hmac(ptr0, len0);
|
|
2308
3102
|
if (ret[2]) {
|
|
2309
3103
|
throw takeFromExternrefTable0(ret[1]);
|
|
2310
3104
|
}
|
|
@@ -2315,75 +3109,139 @@ export class Hash {
|
|
|
2315
3109
|
* @param {number} output_len
|
|
2316
3110
|
* @returns {Hash}
|
|
2317
3111
|
*/
|
|
2318
|
-
static
|
|
3112
|
+
static new_blake2s(key, output_len) {
|
|
2319
3113
|
var ptr0 = isLikeNone(key) ? 0 : passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
2320
3114
|
var len0 = WASM_VECTOR_LEN;
|
|
2321
|
-
const ret = wasm.
|
|
3115
|
+
const ret = wasm.hash_new_blake2s(ptr0, len0, output_len);
|
|
2322
3116
|
if (ret[2]) {
|
|
2323
3117
|
throw takeFromExternrefTable0(ret[1]);
|
|
2324
3118
|
}
|
|
2325
3119
|
return Hash.__wrap(ret[0]);
|
|
2326
3120
|
}
|
|
3121
|
+
}
|
|
3122
|
+
if (Symbol.dispose) Hash.prototype[Symbol.dispose] = Hash.prototype.free;
|
|
3123
|
+
|
|
3124
|
+
const MacFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3125
|
+
? { register: () => {}, unregister: () => {} }
|
|
3126
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mac_free(ptr >>> 0, 1));
|
|
3127
|
+
|
|
3128
|
+
export class Mac {
|
|
3129
|
+
|
|
3130
|
+
static __wrap(ptr) {
|
|
3131
|
+
ptr = ptr >>> 0;
|
|
3132
|
+
const obj = Object.create(Mac.prototype);
|
|
3133
|
+
obj.__wbg_ptr = ptr;
|
|
3134
|
+
MacFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3135
|
+
return obj;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
__destroy_into_raw() {
|
|
3139
|
+
const ptr = this.__wbg_ptr;
|
|
3140
|
+
this.__wbg_ptr = 0;
|
|
3141
|
+
MacFinalization.unregister(this);
|
|
3142
|
+
return ptr;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
free() {
|
|
3146
|
+
const ptr = this.__destroy_into_raw();
|
|
3147
|
+
wasm.__wbg_mac_free(ptr, 0);
|
|
3148
|
+
}
|
|
2327
3149
|
/**
|
|
2328
|
-
* @
|
|
3150
|
+
* @param {Uint8Array} key
|
|
3151
|
+
* @param {Uint8Array} custom
|
|
3152
|
+
* @param {number} output_len
|
|
3153
|
+
* @returns {Mac}
|
|
2329
3154
|
*/
|
|
2330
|
-
|
|
2331
|
-
const
|
|
2332
|
-
|
|
3155
|
+
static new_kmac128(key, custom, output_len) {
|
|
3156
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3158
|
+
const ptr1 = passArray8ToWasm0(custom, wasm.__wbindgen_malloc);
|
|
3159
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3160
|
+
const ret = wasm.mac_new_kmac128(ptr0, len0, ptr1, len1, output_len);
|
|
3161
|
+
if (ret[2]) {
|
|
3162
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3163
|
+
}
|
|
3164
|
+
return Mac.__wrap(ret[0]);
|
|
2333
3165
|
}
|
|
2334
3166
|
/**
|
|
2335
|
-
* @
|
|
3167
|
+
* @param {Uint8Array} key
|
|
3168
|
+
* @param {Uint8Array} custom
|
|
3169
|
+
* @param {number} output_len
|
|
3170
|
+
* @returns {Mac}
|
|
2336
3171
|
*/
|
|
2337
|
-
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
3172
|
+
static new_kmac256(key, custom, output_len) {
|
|
3173
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3175
|
+
const ptr1 = passArray8ToWasm0(custom, wasm.__wbindgen_malloc);
|
|
3176
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3177
|
+
const ret = wasm.mac_new_kmac256(ptr0, len0, ptr1, len1, output_len);
|
|
3178
|
+
if (ret[2]) {
|
|
3179
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3180
|
+
}
|
|
3181
|
+
return Mac.__wrap(ret[0]);
|
|
2342
3182
|
}
|
|
2343
3183
|
/**
|
|
2344
|
-
* @param {Uint8Array}
|
|
2345
|
-
* @
|
|
3184
|
+
* @param {Uint8Array} key
|
|
3185
|
+
* @param {number} output_len
|
|
3186
|
+
* @returns {Mac}
|
|
2346
3187
|
*/
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
const ret = wasm.
|
|
3188
|
+
static new_siphash(key, output_len) {
|
|
3189
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3191
|
+
const ret = wasm.mac_new_siphash(ptr0, len0, output_len);
|
|
2351
3192
|
if (ret[2]) {
|
|
2352
3193
|
throw takeFromExternrefTable0(ret[1]);
|
|
2353
3194
|
}
|
|
2354
|
-
return ret[0]
|
|
3195
|
+
return Mac.__wrap(ret[0]);
|
|
2355
3196
|
}
|
|
2356
3197
|
/**
|
|
2357
|
-
* @
|
|
3198
|
+
* @param {Uint8Array} key
|
|
3199
|
+
* @returns {Mac}
|
|
2358
3200
|
*/
|
|
2359
|
-
|
|
2360
|
-
const
|
|
2361
|
-
|
|
3201
|
+
static new_cmac_aes(key) {
|
|
3202
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3203
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3204
|
+
const ret = wasm.mac_new_cmac_aes(ptr0, len0);
|
|
3205
|
+
if (ret[2]) {
|
|
3206
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3207
|
+
}
|
|
3208
|
+
return Mac.__wrap(ret[0]);
|
|
2362
3209
|
}
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
3210
|
+
/**
|
|
3211
|
+
* @param {Uint8Array} key
|
|
3212
|
+
* @param {Uint8Array} iv
|
|
3213
|
+
* @returns {Mac}
|
|
3214
|
+
*/
|
|
3215
|
+
static new_gmac_aes(key, iv) {
|
|
3216
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
3217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3218
|
+
const ptr1 = passArray8ToWasm0(iv, wasm.__wbindgen_malloc);
|
|
3219
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3220
|
+
const ret = wasm.mac_new_gmac_aes(ptr0, len0, ptr1, len1);
|
|
3221
|
+
if (ret[2]) {
|
|
3222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2367
3223
|
}
|
|
3224
|
+
return Mac.__wrap(ret[0]);
|
|
2368
3225
|
}
|
|
2369
|
-
|
|
2370
|
-
|
|
3226
|
+
/**
|
|
3227
|
+
* @returns {Uint8Array}
|
|
3228
|
+
*/
|
|
3229
|
+
sum() {
|
|
3230
|
+
const ret = wasm.mac_sum(this.__wbg_ptr);
|
|
3231
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
3232
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
3233
|
+
return v1;
|
|
2371
3234
|
}
|
|
2372
3235
|
/**
|
|
2373
3236
|
* @param {Uint8Array} data
|
|
2374
|
-
* @returns {number}
|
|
2375
3237
|
*/
|
|
2376
3238
|
write(data) {
|
|
2377
3239
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2378
3240
|
const len0 = WASM_VECTOR_LEN;
|
|
2379
|
-
|
|
2380
|
-
if (ret[2]) {
|
|
2381
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
2382
|
-
}
|
|
2383
|
-
return ret[0] >>> 0;
|
|
3241
|
+
wasm.mac_write(this.__wbg_ptr, ptr0, len0);
|
|
2384
3242
|
}
|
|
2385
3243
|
}
|
|
2386
|
-
if (Symbol.dispose)
|
|
3244
|
+
if (Symbol.dispose) Mac.prototype[Symbol.dispose] = Mac.prototype.free;
|
|
2387
3245
|
|
|
2388
3246
|
const StreamCipherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2389
3247
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -3644,6 +4502,105 @@ export class StreamCipher {
|
|
|
3644
4502
|
}
|
|
3645
4503
|
if (Symbol.dispose) StreamCipher.prototype[Symbol.dispose] = StreamCipher.prototype.free;
|
|
3646
4504
|
|
|
4505
|
+
const XtsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4506
|
+
? { register: () => {}, unregister: () => {} }
|
|
4507
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_xts_free(ptr >>> 0, 1));
|
|
4508
|
+
|
|
4509
|
+
export class Xts {
|
|
4510
|
+
|
|
4511
|
+
static __wrap(ptr) {
|
|
4512
|
+
ptr = ptr >>> 0;
|
|
4513
|
+
const obj = Object.create(Xts.prototype);
|
|
4514
|
+
obj.__wbg_ptr = ptr;
|
|
4515
|
+
XtsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4516
|
+
return obj;
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
__destroy_into_raw() {
|
|
4520
|
+
const ptr = this.__wbg_ptr;
|
|
4521
|
+
this.__wbg_ptr = 0;
|
|
4522
|
+
XtsFinalization.unregister(this);
|
|
4523
|
+
return ptr;
|
|
4524
|
+
}
|
|
4525
|
+
|
|
4526
|
+
free() {
|
|
4527
|
+
const ptr = this.__destroy_into_raw();
|
|
4528
|
+
wasm.__wbg_xts_free(ptr, 0);
|
|
4529
|
+
}
|
|
4530
|
+
/**
|
|
4531
|
+
* @param {Uint8Array} key
|
|
4532
|
+
* @returns {Xts}
|
|
4533
|
+
*/
|
|
4534
|
+
static new_sm4_gb(key) {
|
|
4535
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
4536
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4537
|
+
const ret = wasm.xts_new_sm4_gb(ptr0, len0);
|
|
4538
|
+
if (ret[2]) {
|
|
4539
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4540
|
+
}
|
|
4541
|
+
return Xts.__wrap(ret[0]);
|
|
4542
|
+
}
|
|
4543
|
+
/**
|
|
4544
|
+
* @param {Uint8Array} tweak
|
|
4545
|
+
* @param {Uint8Array} data
|
|
4546
|
+
*/
|
|
4547
|
+
decrypt(tweak, data) {
|
|
4548
|
+
const ptr0 = passArray8ToWasm0(tweak, wasm.__wbindgen_malloc);
|
|
4549
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4550
|
+
var ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
4551
|
+
var len1 = WASM_VECTOR_LEN;
|
|
4552
|
+
const ret = wasm.xts_decrypt(this.__wbg_ptr, ptr0, len0, ptr1, len1, data);
|
|
4553
|
+
if (ret[1]) {
|
|
4554
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
/**
|
|
4558
|
+
* @param {Uint8Array} tweak
|
|
4559
|
+
* @param {Uint8Array} data
|
|
4560
|
+
*/
|
|
4561
|
+
encrypt(tweak, data) {
|
|
4562
|
+
const ptr0 = passArray8ToWasm0(tweak, wasm.__wbindgen_malloc);
|
|
4563
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4564
|
+
var ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
4565
|
+
var len1 = WASM_VECTOR_LEN;
|
|
4566
|
+
const ret = wasm.xts_encrypt(this.__wbg_ptr, ptr0, len0, ptr1, len1, data);
|
|
4567
|
+
if (ret[1]) {
|
|
4568
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
/**
|
|
4572
|
+
* @param {Uint8Array} key
|
|
4573
|
+
* @returns {Xts}
|
|
4574
|
+
*/
|
|
4575
|
+
static new_aes(key) {
|
|
4576
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
4577
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4578
|
+
const ret = wasm.xts_new_aes(ptr0, len0);
|
|
4579
|
+
if (ret[2]) {
|
|
4580
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4581
|
+
}
|
|
4582
|
+
return Xts.__wrap(ret[0]);
|
|
4583
|
+
}
|
|
4584
|
+
/**
|
|
4585
|
+
* @param {Uint8Array} key
|
|
4586
|
+
* @returns {Xts}
|
|
4587
|
+
*/
|
|
4588
|
+
static new_sm4(key) {
|
|
4589
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
4590
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4591
|
+
const ret = wasm.xts_new_sm4(ptr0, len0);
|
|
4592
|
+
if (ret[2]) {
|
|
4593
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4594
|
+
}
|
|
4595
|
+
return Xts.__wrap(ret[0]);
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
if (Symbol.dispose) Xts.prototype[Symbol.dispose] = Xts.prototype.free;
|
|
4599
|
+
|
|
4600
|
+
export function __wbg_getRandomValues_3c9c0d586e575a16() { return handleError(function (arg0, arg1) {
|
|
4601
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
4602
|
+
}, arguments) };
|
|
4603
|
+
|
|
3647
4604
|
export function __wbg_wbindgencopytotypedarray_d105febdb9374ca3(arg0, arg1, arg2) {
|
|
3648
4605
|
new Uint8Array(arg2.buffer, arg2.byteOffset, arg2.byteLength).set(getArrayU8FromWasm0(arg0, arg1));
|
|
3649
4606
|
};
|
|
@@ -3659,7 +4616,7 @@ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
|
3659
4616
|
};
|
|
3660
4617
|
|
|
3661
4618
|
export function __wbindgen_init_externref_table() {
|
|
3662
|
-
const table = wasm.
|
|
4619
|
+
const table = wasm.__wbindgen_export_2;
|
|
3663
4620
|
const offset = table.grow(4);
|
|
3664
4621
|
table.set(0, undefined);
|
|
3665
4622
|
table.set(offset + 0, undefined);
|
package/crown_wasm_bg.wasm
CHANGED
|
Binary file
|