hpke 0.2.0 → 0.2.1
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/hpke_dispatch.js +803 -2
- package/hpke_dispatch_bg.wasm +0 -0
- package/package.json +2 -4
- package/hpke_dispatch_bg.js +0 -789
package/hpke_dispatch_bg.js
DELETED
|
@@ -1,789 +0,0 @@
|
|
|
1
|
-
import * as wasm from './hpke_dispatch_bg.wasm';
|
|
2
|
-
|
|
3
|
-
const heap = new Array(32).fill(undefined);
|
|
4
|
-
|
|
5
|
-
heap.push(undefined, null, true, false);
|
|
6
|
-
|
|
7
|
-
function getObject(idx) { return heap[idx]; }
|
|
8
|
-
|
|
9
|
-
let heap_next = heap.length;
|
|
10
|
-
|
|
11
|
-
function dropObject(idx) {
|
|
12
|
-
if (idx < 36) return;
|
|
13
|
-
heap[idx] = heap_next;
|
|
14
|
-
heap_next = idx;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function takeObject(idx) {
|
|
18
|
-
const ret = getObject(idx);
|
|
19
|
-
dropObject(idx);
|
|
20
|
-
return ret;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function addHeapObject(obj) {
|
|
24
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
25
|
-
const idx = heap_next;
|
|
26
|
-
heap_next = heap[idx];
|
|
27
|
-
|
|
28
|
-
heap[idx] = obj;
|
|
29
|
-
return idx;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
33
|
-
|
|
34
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
35
|
-
|
|
36
|
-
cachedTextDecoder.decode();
|
|
37
|
-
|
|
38
|
-
let cachegetUint8Memory0 = null;
|
|
39
|
-
function getUint8Memory0() {
|
|
40
|
-
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
41
|
-
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
42
|
-
}
|
|
43
|
-
return cachegetUint8Memory0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getStringFromWasm0(ptr, len) {
|
|
47
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let cachegetInt32Memory0 = null;
|
|
51
|
-
function getInt32Memory0() {
|
|
52
|
-
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
53
|
-
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
54
|
-
}
|
|
55
|
-
return cachegetInt32Memory0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
59
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let WASM_VECTOR_LEN = 0;
|
|
63
|
-
|
|
64
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
65
|
-
const ptr = malloc(arg.length * 1);
|
|
66
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
67
|
-
WASM_VECTOR_LEN = arg.length;
|
|
68
|
-
return ptr;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function _assertClass(instance, klass) {
|
|
72
|
-
if (!(instance instanceof klass)) {
|
|
73
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
74
|
-
}
|
|
75
|
-
return instance.ptr;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
*`base_mode_seal` provides an interface to [`hpke::single_shot_seal`]
|
|
80
|
-
*that does not require compile time selection of an
|
|
81
|
-
*algorithm. Instead, the selected algorithm is provided through the
|
|
82
|
-
*[`Config`] passed as the first argument.
|
|
83
|
-
*
|
|
84
|
-
*Requires the `base-mode-seal` crate feature to be enabled.
|
|
85
|
-
*
|
|
86
|
-
*# Errors
|
|
87
|
-
*
|
|
88
|
-
*This will return an `Result::Err` variant if:
|
|
89
|
-
*
|
|
90
|
-
** we are unable to deserialize the recipient public key
|
|
91
|
-
** there is an error in key encapsultion
|
|
92
|
-
** there is an error in encryption
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @param {Config} config
|
|
96
|
-
* @param {Uint8Array} recipient_public_key
|
|
97
|
-
* @param {Uint8Array} info
|
|
98
|
-
* @param {Uint8Array} plaintext
|
|
99
|
-
* @param {Uint8Array} aad
|
|
100
|
-
* @returns {EncappedKeyAndCiphertext}
|
|
101
|
-
*/
|
|
102
|
-
export function base_mode_seal(config, recipient_public_key, info, plaintext, aad) {
|
|
103
|
-
try {
|
|
104
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
105
|
-
_assertClass(config, Config);
|
|
106
|
-
const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
|
|
107
|
-
const len0 = WASM_VECTOR_LEN;
|
|
108
|
-
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
109
|
-
const len1 = WASM_VECTOR_LEN;
|
|
110
|
-
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
111
|
-
const len2 = WASM_VECTOR_LEN;
|
|
112
|
-
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
113
|
-
const len3 = WASM_VECTOR_LEN;
|
|
114
|
-
wasm.base_mode_seal(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
115
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
116
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
117
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
118
|
-
if (r2) {
|
|
119
|
-
throw takeObject(r1);
|
|
120
|
-
}
|
|
121
|
-
return EncappedKeyAndCiphertext.__wrap(r0);
|
|
122
|
-
} finally {
|
|
123
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
*`base_mode_open` provides an interface to [`hpke::single_shot_open`]
|
|
130
|
-
*that does not require compile time selection of an algorithm. Instead,
|
|
131
|
-
*the selected algorithm is provided through the [`Config`] passed as
|
|
132
|
-
*the first argument.
|
|
133
|
-
*
|
|
134
|
-
*Requires the `base-mode-open` crate feature to be enabled.
|
|
135
|
-
*
|
|
136
|
-
*# Errors
|
|
137
|
-
*
|
|
138
|
-
*This will return an `Result::Err` variant if:
|
|
139
|
-
*
|
|
140
|
-
** we are unable to deserialize the private key or encapsulated key
|
|
141
|
-
** there is an error in key decapsulation
|
|
142
|
-
** there is an error in decryption
|
|
143
|
-
*
|
|
144
|
-
* @param {Config} config
|
|
145
|
-
* @param {Uint8Array} private_key
|
|
146
|
-
* @param {Uint8Array} encapped_key
|
|
147
|
-
* @param {Uint8Array} info
|
|
148
|
-
* @param {Uint8Array} ciphertext
|
|
149
|
-
* @param {Uint8Array} aad
|
|
150
|
-
* @returns {Uint8Array}
|
|
151
|
-
*/
|
|
152
|
-
export function base_mode_open(config, private_key, encapped_key, info, ciphertext, aad) {
|
|
153
|
-
try {
|
|
154
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
155
|
-
_assertClass(config, Config);
|
|
156
|
-
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
157
|
-
const len0 = WASM_VECTOR_LEN;
|
|
158
|
-
const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
159
|
-
const len1 = WASM_VECTOR_LEN;
|
|
160
|
-
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
161
|
-
const len2 = WASM_VECTOR_LEN;
|
|
162
|
-
const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
163
|
-
const len3 = WASM_VECTOR_LEN;
|
|
164
|
-
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
165
|
-
const len4 = WASM_VECTOR_LEN;
|
|
166
|
-
wasm.base_mode_open(retptr, config.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
167
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
168
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
169
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
170
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
171
|
-
if (r3) {
|
|
172
|
-
throw takeObject(r2);
|
|
173
|
-
}
|
|
174
|
-
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
175
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
176
|
-
return v5;
|
|
177
|
-
} finally {
|
|
178
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function handleError(f, args) {
|
|
183
|
-
try {
|
|
184
|
-
return f.apply(this, args);
|
|
185
|
-
} catch (e) {
|
|
186
|
-
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
*
|
|
191
|
-
*Aead represents an authenticated encryption with additional data
|
|
192
|
-
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
193
|
-
*/
|
|
194
|
-
export const Aead = Object.freeze({
|
|
195
|
-
/**
|
|
196
|
-
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
197
|
-
*/
|
|
198
|
-
AesGcm128:1,"1":"AesGcm128",
|
|
199
|
-
/**
|
|
200
|
-
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
201
|
-
*/
|
|
202
|
-
AesGcm256:2,"2":"AesGcm256",
|
|
203
|
-
/**
|
|
204
|
-
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
205
|
-
*/
|
|
206
|
-
ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
|
|
207
|
-
/**
|
|
208
|
-
*
|
|
209
|
-
*Kdf represents an key derivation function, as per
|
|
210
|
-
*[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
|
|
211
|
-
*/
|
|
212
|
-
export const Kdf = Object.freeze({
|
|
213
|
-
/**
|
|
214
|
-
* Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
215
|
-
*/
|
|
216
|
-
Sha256:1,"1":"Sha256",
|
|
217
|
-
/**
|
|
218
|
-
* Sha384 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
219
|
-
*/
|
|
220
|
-
Sha384:2,"2":"Sha384",
|
|
221
|
-
/**
|
|
222
|
-
* Sha512 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
223
|
-
*/
|
|
224
|
-
Sha512:3,"3":"Sha512", });
|
|
225
|
-
/**
|
|
226
|
-
*
|
|
227
|
-
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
228
|
-
*[RFC9180§7.1][section-7.1]. Currently only two of options listed in
|
|
229
|
-
*the hpke draft are available.
|
|
230
|
-
*
|
|
231
|
-
*[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
|
|
232
|
-
*/
|
|
233
|
-
export const Kem = Object.freeze({
|
|
234
|
-
/**
|
|
235
|
-
* DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
|
|
236
|
-
*/
|
|
237
|
-
DhP256HkdfSha256:16,"16":"DhP256HkdfSha256",
|
|
238
|
-
/**
|
|
239
|
-
* DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748)
|
|
240
|
-
*/
|
|
241
|
-
X25519HkdfSha256:32,"32":"X25519HkdfSha256", });
|
|
242
|
-
/**
|
|
243
|
-
*
|
|
244
|
-
*Config is an open struct that contains an ([`Aead`], [`Kdf`], [`Kem`])
|
|
245
|
-
*algorithmic triple. This can be used with [`Config::base_mode_seal`],
|
|
246
|
-
*[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
|
|
247
|
-
*/
|
|
248
|
-
export class Config {
|
|
249
|
-
|
|
250
|
-
static __wrap(ptr) {
|
|
251
|
-
const obj = Object.create(Config.prototype);
|
|
252
|
-
obj.ptr = ptr;
|
|
253
|
-
|
|
254
|
-
return obj;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
__destroy_into_raw() {
|
|
258
|
-
const ptr = this.ptr;
|
|
259
|
-
this.ptr = 0;
|
|
260
|
-
|
|
261
|
-
return ptr;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
free() {
|
|
265
|
-
const ptr = this.__destroy_into_raw();
|
|
266
|
-
wasm.__wbg_config_free(ptr);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
270
|
-
*/
|
|
271
|
-
get aead() {
|
|
272
|
-
const ret = wasm.__wbg_get_config_aead(this.ptr);
|
|
273
|
-
return ret >>> 0;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
277
|
-
* @param {number} arg0
|
|
278
|
-
*/
|
|
279
|
-
set aead(arg0) {
|
|
280
|
-
wasm.__wbg_set_config_aead(this.ptr, arg0);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* the [key derivation function](crate::Kdf) to be used
|
|
284
|
-
*/
|
|
285
|
-
get kdf() {
|
|
286
|
-
const ret = wasm.__wbg_get_config_kdf(this.ptr);
|
|
287
|
-
return ret >>> 0;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* the [key derivation function](crate::Kdf) to be used
|
|
291
|
-
* @param {number} arg0
|
|
292
|
-
*/
|
|
293
|
-
set kdf(arg0) {
|
|
294
|
-
wasm.__wbg_set_config_kdf(this.ptr, arg0);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
298
|
-
*/
|
|
299
|
-
get kem() {
|
|
300
|
-
const ret = wasm.__wbg_get_config_kem(this.ptr);
|
|
301
|
-
return ret >>> 0;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
305
|
-
* @param {number} arg0
|
|
306
|
-
*/
|
|
307
|
-
set kem(arg0) {
|
|
308
|
-
wasm.__wbg_set_config_kem(this.ptr, arg0);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
*
|
|
312
|
-
* base_mode_seal provides an interface to [`hpke::single_shot_seal`] that does
|
|
313
|
-
* not require compile time selection of an algorithm. Instead, the
|
|
314
|
-
* selected algorithm is provided through the [`Config`] that this
|
|
315
|
-
* method is called on.
|
|
316
|
-
*
|
|
317
|
-
* Requires the `base-mode-seal` crate feature to be enabled.
|
|
318
|
-
*
|
|
319
|
-
* # Errors
|
|
320
|
-
*
|
|
321
|
-
* This will return an `Result::Err` variant if:
|
|
322
|
-
*
|
|
323
|
-
* * we are unable to deserialize the recipient public key
|
|
324
|
-
* * there is an error in key encapsultion
|
|
325
|
-
* * there is an error in encryption
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param {Uint8Array} recipient_public_key
|
|
329
|
-
* @param {Uint8Array} info
|
|
330
|
-
* @param {Uint8Array} plaintext
|
|
331
|
-
* @param {Uint8Array} aad
|
|
332
|
-
* @returns {EncappedKeyAndCiphertext}
|
|
333
|
-
*/
|
|
334
|
-
base_mode_seal(recipient_public_key, info, plaintext, aad) {
|
|
335
|
-
try {
|
|
336
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
337
|
-
const ptr0 = passArray8ToWasm0(recipient_public_key, wasm.__wbindgen_malloc);
|
|
338
|
-
const len0 = WASM_VECTOR_LEN;
|
|
339
|
-
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
340
|
-
const len1 = WASM_VECTOR_LEN;
|
|
341
|
-
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
342
|
-
const len2 = WASM_VECTOR_LEN;
|
|
343
|
-
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
344
|
-
const len3 = WASM_VECTOR_LEN;
|
|
345
|
-
wasm.config_base_mode_seal(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
346
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
347
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
348
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
349
|
-
if (r2) {
|
|
350
|
-
throw takeObject(r1);
|
|
351
|
-
}
|
|
352
|
-
return EncappedKeyAndCiphertext.__wrap(r0);
|
|
353
|
-
} finally {
|
|
354
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
*
|
|
359
|
-
* base_mode_open provides an interface to [`hpke::single_shot_open`]
|
|
360
|
-
* that does not require compile time selection of an
|
|
361
|
-
* algorithm. Instead, the selected algorithm is provided through the
|
|
362
|
-
* [`Config`] that this method is called on.
|
|
363
|
-
*
|
|
364
|
-
* Requires the `base-mode-open` crate feature to be enabled.
|
|
365
|
-
*
|
|
366
|
-
* # Errors
|
|
367
|
-
*
|
|
368
|
-
* This will return an `Result::Err` variant if:
|
|
369
|
-
*
|
|
370
|
-
* * we are unable to deserialize the private key or encapsulated key
|
|
371
|
-
* * there is an error in key decapsulation
|
|
372
|
-
* * there is an error in decryption
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
* @param {Uint8Array} private_key
|
|
376
|
-
* @param {Uint8Array} encapped_key
|
|
377
|
-
* @param {Uint8Array} info
|
|
378
|
-
* @param {Uint8Array} ciphertext
|
|
379
|
-
* @param {Uint8Array} aad
|
|
380
|
-
* @returns {Uint8Array}
|
|
381
|
-
*/
|
|
382
|
-
base_mode_open(private_key, encapped_key, info, ciphertext, aad) {
|
|
383
|
-
try {
|
|
384
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
385
|
-
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
386
|
-
const len0 = WASM_VECTOR_LEN;
|
|
387
|
-
const ptr1 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
388
|
-
const len1 = WASM_VECTOR_LEN;
|
|
389
|
-
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
390
|
-
const len2 = WASM_VECTOR_LEN;
|
|
391
|
-
const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
392
|
-
const len3 = WASM_VECTOR_LEN;
|
|
393
|
-
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
394
|
-
const len4 = WASM_VECTOR_LEN;
|
|
395
|
-
wasm.config_base_mode_open(retptr, this.ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
396
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
397
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
398
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
399
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
400
|
-
if (r3) {
|
|
401
|
-
throw takeObject(r2);
|
|
402
|
-
}
|
|
403
|
-
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
404
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
405
|
-
return v5;
|
|
406
|
-
} finally {
|
|
407
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
|
|
412
|
-
* @param {number} aead_id
|
|
413
|
-
* @param {number} kdf_id
|
|
414
|
-
* @param {number} kem_id
|
|
415
|
-
* @returns {Config}
|
|
416
|
-
*/
|
|
417
|
-
static try_from_ids(aead_id, kdf_id, kem_id) {
|
|
418
|
-
try {
|
|
419
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
420
|
-
wasm.config_try_from_ids(retptr, aead_id, kdf_id, kem_id);
|
|
421
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
422
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
423
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
424
|
-
if (r2) {
|
|
425
|
-
throw takeObject(r1);
|
|
426
|
-
}
|
|
427
|
-
return Config.__wrap(r0);
|
|
428
|
-
} finally {
|
|
429
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
*
|
|
435
|
-
*a simple struct to return the combined encapsulated key
|
|
436
|
-
*and ciphertext from seal
|
|
437
|
-
*/
|
|
438
|
-
export class EncappedKeyAndCiphertext {
|
|
439
|
-
|
|
440
|
-
static __wrap(ptr) {
|
|
441
|
-
const obj = Object.create(EncappedKeyAndCiphertext.prototype);
|
|
442
|
-
obj.ptr = ptr;
|
|
443
|
-
|
|
444
|
-
return obj;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
__destroy_into_raw() {
|
|
448
|
-
const ptr = this.ptr;
|
|
449
|
-
this.ptr = 0;
|
|
450
|
-
|
|
451
|
-
return ptr;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
free() {
|
|
455
|
-
const ptr = this.__destroy_into_raw();
|
|
456
|
-
wasm.__wbg_encappedkeyandciphertext_free(ptr);
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* the encapsulated encryption key
|
|
460
|
-
*/
|
|
461
|
-
get encapped_key() {
|
|
462
|
-
try {
|
|
463
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
464
|
-
wasm.__wbg_get_encappedkeyandciphertext_encapped_key(retptr, this.ptr);
|
|
465
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
466
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
467
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
468
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
469
|
-
return v0;
|
|
470
|
-
} finally {
|
|
471
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* the encapsulated encryption key
|
|
476
|
-
* @param {Uint8Array} arg0
|
|
477
|
-
*/
|
|
478
|
-
set encapped_key(arg0) {
|
|
479
|
-
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
480
|
-
const len0 = WASM_VECTOR_LEN;
|
|
481
|
-
wasm.__wbg_set_encappedkeyandciphertext_encapped_key(this.ptr, ptr0, len0);
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* the ciphertext, encrypted with the key
|
|
485
|
-
*/
|
|
486
|
-
get ciphertext() {
|
|
487
|
-
try {
|
|
488
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
489
|
-
wasm.__wbg_get_encappedkeyandciphertext_ciphertext(retptr, this.ptr);
|
|
490
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
491
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
492
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
493
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
494
|
-
return v0;
|
|
495
|
-
} finally {
|
|
496
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* the ciphertext, encrypted with the key
|
|
501
|
-
* @param {Uint8Array} arg0
|
|
502
|
-
*/
|
|
503
|
-
set ciphertext(arg0) {
|
|
504
|
-
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
505
|
-
const len0 = WASM_VECTOR_LEN;
|
|
506
|
-
wasm.__wbg_set_encappedkeyandciphertext_ciphertext(this.ptr, ptr0, len0);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
*r"
|
|
511
|
-
* a newtype wrapper for HpkeError so we can use it in wasm_bindgen
|
|
512
|
-
*
|
|
513
|
-
*/
|
|
514
|
-
export class HpkeError {
|
|
515
|
-
|
|
516
|
-
static __wrap(ptr) {
|
|
517
|
-
const obj = Object.create(HpkeError.prototype);
|
|
518
|
-
obj.ptr = ptr;
|
|
519
|
-
|
|
520
|
-
return obj;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
__destroy_into_raw() {
|
|
524
|
-
const ptr = this.ptr;
|
|
525
|
-
this.ptr = 0;
|
|
526
|
-
|
|
527
|
-
return ptr;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
free() {
|
|
531
|
-
const ptr = this.__destroy_into_raw();
|
|
532
|
-
wasm.__wbg_hpkeerror_free(ptr);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
*
|
|
537
|
-
*A simple error type for failed id lookups
|
|
538
|
-
*
|
|
539
|
-
*/
|
|
540
|
-
export class IdLookupError {
|
|
541
|
-
|
|
542
|
-
static __wrap(ptr) {
|
|
543
|
-
const obj = Object.create(IdLookupError.prototype);
|
|
544
|
-
obj.ptr = ptr;
|
|
545
|
-
|
|
546
|
-
return obj;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
__destroy_into_raw() {
|
|
550
|
-
const ptr = this.ptr;
|
|
551
|
-
this.ptr = 0;
|
|
552
|
-
|
|
553
|
-
return ptr;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
free() {
|
|
557
|
-
const ptr = this.__destroy_into_raw();
|
|
558
|
-
wasm.__wbg_idlookuperror_free(ptr);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* An encoded keypair
|
|
563
|
-
*/
|
|
564
|
-
export class Keypair {
|
|
565
|
-
|
|
566
|
-
static __wrap(ptr) {
|
|
567
|
-
const obj = Object.create(Keypair.prototype);
|
|
568
|
-
obj.ptr = ptr;
|
|
569
|
-
|
|
570
|
-
return obj;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
__destroy_into_raw() {
|
|
574
|
-
const ptr = this.ptr;
|
|
575
|
-
this.ptr = 0;
|
|
576
|
-
|
|
577
|
-
return ptr;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
free() {
|
|
581
|
-
const ptr = this.__destroy_into_raw();
|
|
582
|
-
wasm.__wbg_keypair_free(ptr);
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* the public key for this keypair
|
|
586
|
-
*/
|
|
587
|
-
get public_key() {
|
|
588
|
-
try {
|
|
589
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
590
|
-
wasm.__wbg_get_keypair_public_key(retptr, this.ptr);
|
|
591
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
592
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
593
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
594
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
595
|
-
return v0;
|
|
596
|
-
} finally {
|
|
597
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* the public key for this keypair
|
|
602
|
-
* @param {Uint8Array} arg0
|
|
603
|
-
*/
|
|
604
|
-
set public_key(arg0) {
|
|
605
|
-
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
606
|
-
const len0 = WASM_VECTOR_LEN;
|
|
607
|
-
wasm.__wbg_set_keypair_public_key(this.ptr, ptr0, len0);
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* the private key for this keypair,
|
|
611
|
-
*/
|
|
612
|
-
get private_key() {
|
|
613
|
-
try {
|
|
614
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
615
|
-
wasm.__wbg_get_keypair_private_key(retptr, this.ptr);
|
|
616
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
617
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
618
|
-
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
619
|
-
wasm.__wbindgen_free(r0, r1 * 1);
|
|
620
|
-
return v0;
|
|
621
|
-
} finally {
|
|
622
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* the private key for this keypair,
|
|
627
|
-
* @param {Uint8Array} arg0
|
|
628
|
-
*/
|
|
629
|
-
set private_key(arg0) {
|
|
630
|
-
const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
|
|
631
|
-
const len0 = WASM_VECTOR_LEN;
|
|
632
|
-
wasm.__wbg_set_keypair_private_key(this.ptr, ptr0, len0);
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* generate a keypair from a [`Kem`]
|
|
636
|
-
* @param {number} kem
|
|
637
|
-
*/
|
|
638
|
-
constructor(kem) {
|
|
639
|
-
const ret = wasm.keypair_new(kem);
|
|
640
|
-
return Keypair.__wrap(ret);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
export function __wbg_idlookuperror_new(arg0) {
|
|
645
|
-
const ret = IdLookupError.__wrap(arg0);
|
|
646
|
-
return addHeapObject(ret);
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
export function __wbg_hpkeerror_new(arg0) {
|
|
650
|
-
const ret = HpkeError.__wrap(arg0);
|
|
651
|
-
return addHeapObject(ret);
|
|
652
|
-
};
|
|
653
|
-
|
|
654
|
-
export function __wbg_randomFillSync_654a7797990fb8db() { return handleError(function (arg0, arg1, arg2) {
|
|
655
|
-
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
|
656
|
-
}, arguments) };
|
|
657
|
-
|
|
658
|
-
export function __wbindgen_object_drop_ref(arg0) {
|
|
659
|
-
takeObject(arg0);
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
export function __wbg_getRandomValues_fb6b088efb6bead2() { return handleError(function (arg0, arg1) {
|
|
663
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
664
|
-
}, arguments) };
|
|
665
|
-
|
|
666
|
-
export function __wbg_process_70251ed1291754d5(arg0) {
|
|
667
|
-
const ret = getObject(arg0).process;
|
|
668
|
-
return addHeapObject(ret);
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
export function __wbindgen_is_object(arg0) {
|
|
672
|
-
const val = getObject(arg0);
|
|
673
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
674
|
-
return ret;
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
export function __wbg_versions_b23f2588cdb2ddbb(arg0) {
|
|
678
|
-
const ret = getObject(arg0).versions;
|
|
679
|
-
return addHeapObject(ret);
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
export function __wbg_node_61b8c9a82499895d(arg0) {
|
|
683
|
-
const ret = getObject(arg0).node;
|
|
684
|
-
return addHeapObject(ret);
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
export function __wbindgen_is_string(arg0) {
|
|
688
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
689
|
-
return ret;
|
|
690
|
-
};
|
|
691
|
-
|
|
692
|
-
export function __wbg_static_accessor_NODE_MODULE_33b45247c55045b0() {
|
|
693
|
-
const ret = module;
|
|
694
|
-
return addHeapObject(ret);
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
export function __wbg_require_2a93bc09fee45aca() { return handleError(function (arg0, arg1, arg2) {
|
|
698
|
-
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
|
699
|
-
return addHeapObject(ret);
|
|
700
|
-
}, arguments) };
|
|
701
|
-
|
|
702
|
-
export function __wbg_crypto_2f56257a38275dbd(arg0) {
|
|
703
|
-
const ret = getObject(arg0).crypto;
|
|
704
|
-
return addHeapObject(ret);
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
export function __wbg_msCrypto_d07655bf62361f21(arg0) {
|
|
708
|
-
const ret = getObject(arg0).msCrypto;
|
|
709
|
-
return addHeapObject(ret);
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
export function __wbg_newnoargs_e23b458e372830de(arg0, arg1) {
|
|
713
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
714
|
-
return addHeapObject(ret);
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) {
|
|
718
|
-
const ret = getObject(arg0).call(getObject(arg1));
|
|
719
|
-
return addHeapObject(ret);
|
|
720
|
-
}, arguments) };
|
|
721
|
-
|
|
722
|
-
export function __wbindgen_object_clone_ref(arg0) {
|
|
723
|
-
const ret = getObject(arg0);
|
|
724
|
-
return addHeapObject(ret);
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
export function __wbg_self_99737b4dcdf6f0d8() { return handleError(function () {
|
|
728
|
-
const ret = self.self;
|
|
729
|
-
return addHeapObject(ret);
|
|
730
|
-
}, arguments) };
|
|
731
|
-
|
|
732
|
-
export function __wbg_window_9b61fbbf3564c4fb() { return handleError(function () {
|
|
733
|
-
const ret = window.window;
|
|
734
|
-
return addHeapObject(ret);
|
|
735
|
-
}, arguments) };
|
|
736
|
-
|
|
737
|
-
export function __wbg_globalThis_8e275ef40caea3a3() { return handleError(function () {
|
|
738
|
-
const ret = globalThis.globalThis;
|
|
739
|
-
return addHeapObject(ret);
|
|
740
|
-
}, arguments) };
|
|
741
|
-
|
|
742
|
-
export function __wbg_global_5de1e0f82bddcd27() { return handleError(function () {
|
|
743
|
-
const ret = global.global;
|
|
744
|
-
return addHeapObject(ret);
|
|
745
|
-
}, arguments) };
|
|
746
|
-
|
|
747
|
-
export function __wbindgen_is_undefined(arg0) {
|
|
748
|
-
const ret = getObject(arg0) === undefined;
|
|
749
|
-
return ret;
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
export function __wbg_buffer_7af23f65f6c64548(arg0) {
|
|
753
|
-
const ret = getObject(arg0).buffer;
|
|
754
|
-
return addHeapObject(ret);
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
export function __wbg_new_cc9018bd6f283b6f(arg0) {
|
|
758
|
-
const ret = new Uint8Array(getObject(arg0));
|
|
759
|
-
return addHeapObject(ret);
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) {
|
|
763
|
-
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
export function __wbg_length_0acb1cf9bbaf8519(arg0) {
|
|
767
|
-
const ret = getObject(arg0).length;
|
|
768
|
-
return ret;
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
export function __wbg_newwithlength_8f0657faca9f1422(arg0) {
|
|
772
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
773
|
-
return addHeapObject(ret);
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
export function __wbg_subarray_da527dbd24eafb6b(arg0, arg1, arg2) {
|
|
777
|
-
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
778
|
-
return addHeapObject(ret);
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
782
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
export function __wbindgen_memory() {
|
|
786
|
-
const ret = wasm.memory;
|
|
787
|
-
return addHeapObject(ret);
|
|
788
|
-
};
|
|
789
|
-
|