hpke 0.1.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/README.md +77 -0
- package/hpke_dispatch.d.ts +222 -0
- package/hpke_dispatch.js +2 -0
- package/hpke_dispatch_bg.js +695 -0
- package/hpke_dispatch_bg.wasm +0 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Hybrid public key encryption with algorithms dispatched at runtime
|
|
2
|
+
|
|
3
|
+
This crate provides a generic-free interface to the [`hpke`][hpke]
|
|
4
|
+
crate, a rust implementation of the draft RFC9180 [hybrid public key
|
|
5
|
+
encryption](https://www.rfc-editor.org/rfc/rfc9180.html)
|
|
6
|
+
scheme. If you know the specific (aead, kdf, kem) triple at compile
|
|
7
|
+
time, you should use the [`hpke`][hpke] crate directly.
|
|
8
|
+
|
|
9
|
+
Currently, this crate only exposes interfaces for the Base mode (0)
|
|
10
|
+
described in the hpke draft, and within base mode, only stateless
|
|
11
|
+
single-shot message encryption/decryption, as defined in [RFC9180§6][section-6]
|
|
12
|
+
|
|
13
|
+
[hpke]: https://github.com/rozbb/rust-hpke
|
|
14
|
+
[section-6]: https://www.rfc-editor.org/rfc/rfc9180.html#section-6
|
|
15
|
+
|
|
16
|
+
## Web-assembly ready
|
|
17
|
+
|
|
18
|
+
This crate will also be published to npm as a typescript/javascript
|
|
19
|
+
package, and can also be custom-built for specific wasm use-cases with
|
|
20
|
+
[`wasm-pack`](https://github.com/rustwasm/wasm-pack)
|
|
21
|
+
|
|
22
|
+
## Nightly-only feature to work around a wasm-bindgen bug: `cfg_eval`
|
|
23
|
+
|
|
24
|
+
In order to opt out of `algo-all` for a wasm build, you must use
|
|
25
|
+
nightly and enable the `cfg_eval` cargo feature. This is due to
|
|
26
|
+
[wasm-bindgen#2058][wasm-bindgen-2058]. This is not necessary for use
|
|
27
|
+
from rust, even when opting out of `algo-all`.
|
|
28
|
+
|
|
29
|
+
[hpke]: https://docs.rs/hpke/latest/hpke/
|
|
30
|
+
[wasm-bindgen-2058]: https://github.com/rustwasm/wasm-bindgen/issues/2058
|
|
31
|
+
|
|
32
|
+
## Available cargo features:
|
|
33
|
+
|
|
34
|
+
* *`cfg_eval`*: allows this crate to be built on nightly rust for wasm
|
|
35
|
+
without `algo-all`. Note that `algo-all` (all
|
|
36
|
+
algorithms) will build for wasm on any channel without this feature.
|
|
37
|
+
disabled by default. Attempting to build for wasm with a subset.
|
|
38
|
+
|
|
39
|
+
* *base-mode-open*: Enables hpke base-mode one-shot open behavior
|
|
40
|
+
(receiver functionality). Enabled by default.
|
|
41
|
+
|
|
42
|
+
* *base-mode-seal*: Enables hpke base-mode one-shot seal behavior
|
|
43
|
+
(sender functionality). Enabled by default.
|
|
44
|
+
|
|
45
|
+
* *algo-all*: enables all aead, kdf, and kem algorithms. enabled by
|
|
46
|
+
default.
|
|
47
|
+
|
|
48
|
+
* *aead-all*: Enables `aead-aes-gcm-128`, `aead-aes-gcm-256`, and
|
|
49
|
+
`aead-chacha-20-poly-1305` algorithm features. Enabled by default.
|
|
50
|
+
|
|
51
|
+
* *kdf-all*: Enables `kdf-sha256`, `kdf-sha384`, `kdf-sha512`
|
|
52
|
+
algorithm features. Enabled by default.
|
|
53
|
+
|
|
54
|
+
* *kem-all*: Enables both `kem-dh-p256-hkdf-sha256` and
|
|
55
|
+
`kem-x25519-hkdf-sha256` algorithm features. Enabled by default.
|
|
56
|
+
|
|
57
|
+
* *serde*: enables derived serde serialization and deserialization for
|
|
58
|
+
all public structs and enums. Disabled by default.
|
|
59
|
+
|
|
60
|
+
## Example feature usage:
|
|
61
|
+
|
|
62
|
+
To depend on this crate from rust with all algorithms,
|
|
63
|
+
`base-mode-open`, and `base-mode-seal`, use default features.
|
|
64
|
+
|
|
65
|
+
To depend on this crate from rust with all algorithms and serde
|
|
66
|
+
enabled, but without `base-mode-seal`: `default-features = false,
|
|
67
|
+
features = ["algo-all", "base-mode-open", "serde"]`
|
|
68
|
+
|
|
69
|
+
To build for wasm without `kem-x25519-hkdf-sha256` or
|
|
70
|
+
`base-mode-open`: `wasm-pack build --no-default-features --features
|
|
71
|
+
aead-all,kdf-all,kem-dh-p256-hkdf-sha256,base-mode-seal,cfg_eval`
|
|
72
|
+
|
|
73
|
+
To build for wasm with all algorithms but without base-mode-open:
|
|
74
|
+
`wasm-pack build --no-default-features --features
|
|
75
|
+
algo-all,base-mode-seal`
|
|
76
|
+
|
|
77
|
+
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*`base_mode_seal` provides an interface to [`hpke::single_shot_seal`]
|
|
6
|
+
*that does not require compile time selection of an
|
|
7
|
+
*algorithm. Instead, the selected algorithm is provided through the
|
|
8
|
+
*[`Config`] passed as the first argument.
|
|
9
|
+
*
|
|
10
|
+
*Requires the `base-mode-seal` crate feature to be enabled.
|
|
11
|
+
*
|
|
12
|
+
*# Errors
|
|
13
|
+
*
|
|
14
|
+
*This will return an `Result::Err` variant if:
|
|
15
|
+
*
|
|
16
|
+
** we are unable to deserialize the recipient public key
|
|
17
|
+
** there is an error in key encapsultion
|
|
18
|
+
** there is an error in encryption
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @param {Config} config
|
|
22
|
+
* @param {Uint8Array} pk_recip
|
|
23
|
+
* @param {Uint8Array} info
|
|
24
|
+
* @param {Uint8Array} plaintext
|
|
25
|
+
* @param {Uint8Array} aad
|
|
26
|
+
* @returns {EncappedKeyAndCiphertext}
|
|
27
|
+
*/
|
|
28
|
+
export function base_mode_seal(config: Config, pk_recip: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
*`base_mode_open` provides an interface to [`hpke::single_shot_open`]
|
|
32
|
+
*that does not require compile time selection of an algorithm. Instead,
|
|
33
|
+
*the selected algorithm is provided through the [`Config`] passed as
|
|
34
|
+
*the first argument.
|
|
35
|
+
*
|
|
36
|
+
*Requires the `base-mode-open` crate feature to be enabled.
|
|
37
|
+
*
|
|
38
|
+
*# Errors
|
|
39
|
+
*
|
|
40
|
+
*This will return an `Result::Err` variant if:
|
|
41
|
+
*
|
|
42
|
+
** we are unable to deserialize the private key or encapsulated key
|
|
43
|
+
** there is an error in key decapsulation
|
|
44
|
+
** there is an error in decryption
|
|
45
|
+
*
|
|
46
|
+
* @param {Config} config
|
|
47
|
+
* @param {Uint8Array} private_key
|
|
48
|
+
* @param {Uint8Array} encapped_key
|
|
49
|
+
* @param {Uint8Array} ciphertext
|
|
50
|
+
* @param {Uint8Array} info
|
|
51
|
+
* @param {Uint8Array} aad
|
|
52
|
+
* @returns {Uint8Array}
|
|
53
|
+
*/
|
|
54
|
+
export function base_mode_open(config: Config, private_key: Uint8Array, encapped_key: Uint8Array, ciphertext: Uint8Array, info: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*Aead represents an authenticated encryption with additional data
|
|
58
|
+
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
59
|
+
*/
|
|
60
|
+
export enum Aead {
|
|
61
|
+
/**
|
|
62
|
+
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
63
|
+
*/
|
|
64
|
+
AesGcm128,
|
|
65
|
+
/**
|
|
66
|
+
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
67
|
+
*/
|
|
68
|
+
AesGcm256,
|
|
69
|
+
/**
|
|
70
|
+
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
71
|
+
*/
|
|
72
|
+
ChaCha20Poly1305,
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
*Kdf represents an key derivation function, as per
|
|
77
|
+
*[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
|
|
78
|
+
*/
|
|
79
|
+
export enum Kdf {
|
|
80
|
+
/**
|
|
81
|
+
* Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
82
|
+
*/
|
|
83
|
+
Sha256,
|
|
84
|
+
/**
|
|
85
|
+
* Sha384 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
86
|
+
*/
|
|
87
|
+
Sha384,
|
|
88
|
+
/**
|
|
89
|
+
* Sha512 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
90
|
+
*/
|
|
91
|
+
Sha512,
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
96
|
+
*[RFC9180§7.1](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1). Currently
|
|
97
|
+
*only two of options listed in the hpke draft are available.
|
|
98
|
+
*/
|
|
99
|
+
export enum Kem {
|
|
100
|
+
/**
|
|
101
|
+
* DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
|
|
102
|
+
*/
|
|
103
|
+
DhP256HkdfSha256,
|
|
104
|
+
/**
|
|
105
|
+
* DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748)
|
|
106
|
+
*/
|
|
107
|
+
X25519HkdfSha256,
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
*Config is an open struct that contains an ([`Aead`], [`Kdf`], [`Kem`])
|
|
112
|
+
*algorithmic triple. This can be used with [`Config::base_mode_seal`],
|
|
113
|
+
*[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
|
|
114
|
+
*/
|
|
115
|
+
export class Config {
|
|
116
|
+
free(): void;
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* base_mode_seal provides an interface to [`hpke::single_shot_seal`] that does
|
|
120
|
+
* not require compile time selection of an algorithm. Instead, the
|
|
121
|
+
* selected algorithm is provided through the [`Config`] that this
|
|
122
|
+
* method is called on.
|
|
123
|
+
*
|
|
124
|
+
* Requires the `base-mode-seal` crate feature to be enabled.
|
|
125
|
+
*
|
|
126
|
+
* # Errors
|
|
127
|
+
*
|
|
128
|
+
* This will return an `Result::Err` variant if:
|
|
129
|
+
*
|
|
130
|
+
* * we are unable to deserialize the recipient public key
|
|
131
|
+
* * there is an error in key encapsultion
|
|
132
|
+
* * there is an error in encryption
|
|
133
|
+
*
|
|
134
|
+
*
|
|
135
|
+
* @param {Uint8Array} pk_recip
|
|
136
|
+
* @param {Uint8Array} info
|
|
137
|
+
* @param {Uint8Array} plaintext
|
|
138
|
+
* @param {Uint8Array} aad
|
|
139
|
+
* @returns {EncappedKeyAndCiphertext}
|
|
140
|
+
*/
|
|
141
|
+
base_mode_seal(pk_recip: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* base_mode_open provides an interface to [`hpke::single_shot_open`]
|
|
145
|
+
* that does not require compile time selection of an
|
|
146
|
+
* algorithm. Instead, the selected algorithm is provided through the
|
|
147
|
+
* [`Config`] that this method is called on.
|
|
148
|
+
*
|
|
149
|
+
* Requires the `base-mode-open` crate feature to be enabled.
|
|
150
|
+
*
|
|
151
|
+
* # Errors
|
|
152
|
+
*
|
|
153
|
+
* This will return an `Result::Err` variant if:
|
|
154
|
+
*
|
|
155
|
+
* * we are unable to deserialize the private key or encapsulated key
|
|
156
|
+
* * there is an error in key decapsulation
|
|
157
|
+
* * there is an error in decryption
|
|
158
|
+
*
|
|
159
|
+
*
|
|
160
|
+
* @param {Uint8Array} private_key
|
|
161
|
+
* @param {Uint8Array} ciphertext
|
|
162
|
+
* @param {Uint8Array} encapped_key
|
|
163
|
+
* @param {Uint8Array} info
|
|
164
|
+
* @param {Uint8Array} aad
|
|
165
|
+
* @returns {Uint8Array}
|
|
166
|
+
*/
|
|
167
|
+
base_mode_open(private_key: Uint8Array, ciphertext: Uint8Array, encapped_key: Uint8Array, info: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
168
|
+
/**
|
|
169
|
+
* Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
|
|
170
|
+
* @param {number} aead_id
|
|
171
|
+
* @param {number} kdf_id
|
|
172
|
+
* @param {number} kem_id
|
|
173
|
+
* @returns {Config}
|
|
174
|
+
*/
|
|
175
|
+
static try_from_ids(aead_id: number, kdf_id: number, kem_id: number): Config;
|
|
176
|
+
/**
|
|
177
|
+
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
178
|
+
*/
|
|
179
|
+
aead: number;
|
|
180
|
+
/**
|
|
181
|
+
* the [key derivation function](crate::Kdf) to be used
|
|
182
|
+
*/
|
|
183
|
+
kdf: number;
|
|
184
|
+
/**
|
|
185
|
+
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
186
|
+
*/
|
|
187
|
+
kem: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
*r"
|
|
191
|
+
* a simple struct to return the combined encapsulated key
|
|
192
|
+
* and ciphertext from seal
|
|
193
|
+
*
|
|
194
|
+
*/
|
|
195
|
+
export class EncappedKeyAndCiphertext {
|
|
196
|
+
free(): void;
|
|
197
|
+
/**
|
|
198
|
+
* getter for ciphertext
|
|
199
|
+
* @returns {Uint8Array}
|
|
200
|
+
*/
|
|
201
|
+
readonly ciphertext: Uint8Array;
|
|
202
|
+
/**
|
|
203
|
+
* getter for encapped_key
|
|
204
|
+
* @returns {Uint8Array}
|
|
205
|
+
*/
|
|
206
|
+
readonly encapped_key: Uint8Array;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
*r"
|
|
210
|
+
* a newtype wrapper for HpkeError so we can use it in wasm_bindgen
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
export class HpkeError {
|
|
214
|
+
free(): void;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
*A simple error type for failed id lookups
|
|
219
|
+
*/
|
|
220
|
+
export class IdLookupError {
|
|
221
|
+
free(): void;
|
|
222
|
+
}
|
package/hpke_dispatch.js
ADDED
|
@@ -0,0 +1,695 @@
|
|
|
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 WASM_VECTOR_LEN = 0;
|
|
51
|
+
|
|
52
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
53
|
+
const ptr = malloc(arg.length * 1);
|
|
54
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
55
|
+
WASM_VECTOR_LEN = arg.length;
|
|
56
|
+
return ptr;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let cachegetInt32Memory0 = null;
|
|
60
|
+
function getInt32Memory0() {
|
|
61
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
62
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
63
|
+
}
|
|
64
|
+
return cachegetInt32Memory0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
68
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
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} pk_recip
|
|
97
|
+
* @param {Uint8Array} info
|
|
98
|
+
* @param {Uint8Array} plaintext
|
|
99
|
+
* @param {Uint8Array} aad
|
|
100
|
+
* @returns {EncappedKeyAndCiphertext}
|
|
101
|
+
*/
|
|
102
|
+
export function base_mode_seal(config, pk_recip, info, plaintext, aad) {
|
|
103
|
+
try {
|
|
104
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
105
|
+
_assertClass(config, Config);
|
|
106
|
+
var ptr0 = config.ptr;
|
|
107
|
+
config.ptr = 0;
|
|
108
|
+
const ptr1 = passArray8ToWasm0(pk_recip, wasm.__wbindgen_malloc);
|
|
109
|
+
const len1 = WASM_VECTOR_LEN;
|
|
110
|
+
const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
111
|
+
const len2 = WASM_VECTOR_LEN;
|
|
112
|
+
const ptr3 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
113
|
+
const len3 = WASM_VECTOR_LEN;
|
|
114
|
+
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
115
|
+
const len4 = WASM_VECTOR_LEN;
|
|
116
|
+
wasm.base_mode_seal(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
117
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
118
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
119
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
120
|
+
if (r2) {
|
|
121
|
+
throw takeObject(r1);
|
|
122
|
+
}
|
|
123
|
+
return EncappedKeyAndCiphertext.__wrap(r0);
|
|
124
|
+
} finally {
|
|
125
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
*`base_mode_open` provides an interface to [`hpke::single_shot_open`]
|
|
132
|
+
*that does not require compile time selection of an algorithm. Instead,
|
|
133
|
+
*the selected algorithm is provided through the [`Config`] passed as
|
|
134
|
+
*the first argument.
|
|
135
|
+
*
|
|
136
|
+
*Requires the `base-mode-open` crate feature to be enabled.
|
|
137
|
+
*
|
|
138
|
+
*# Errors
|
|
139
|
+
*
|
|
140
|
+
*This will return an `Result::Err` variant if:
|
|
141
|
+
*
|
|
142
|
+
** we are unable to deserialize the private key or encapsulated key
|
|
143
|
+
** there is an error in key decapsulation
|
|
144
|
+
** there is an error in decryption
|
|
145
|
+
*
|
|
146
|
+
* @param {Config} config
|
|
147
|
+
* @param {Uint8Array} private_key
|
|
148
|
+
* @param {Uint8Array} encapped_key
|
|
149
|
+
* @param {Uint8Array} ciphertext
|
|
150
|
+
* @param {Uint8Array} info
|
|
151
|
+
* @param {Uint8Array} aad
|
|
152
|
+
* @returns {Uint8Array}
|
|
153
|
+
*/
|
|
154
|
+
export function base_mode_open(config, private_key, encapped_key, ciphertext, info, aad) {
|
|
155
|
+
try {
|
|
156
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
157
|
+
_assertClass(config, Config);
|
|
158
|
+
var ptr0 = config.ptr;
|
|
159
|
+
config.ptr = 0;
|
|
160
|
+
const ptr1 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
161
|
+
const len1 = WASM_VECTOR_LEN;
|
|
162
|
+
const ptr2 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
163
|
+
const len2 = WASM_VECTOR_LEN;
|
|
164
|
+
const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
165
|
+
const len3 = WASM_VECTOR_LEN;
|
|
166
|
+
const ptr4 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
167
|
+
const len4 = WASM_VECTOR_LEN;
|
|
168
|
+
const ptr5 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
169
|
+
const len5 = WASM_VECTOR_LEN;
|
|
170
|
+
wasm.base_mode_open(retptr, ptr0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
|
|
171
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
172
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
173
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
174
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
175
|
+
if (r3) {
|
|
176
|
+
throw takeObject(r2);
|
|
177
|
+
}
|
|
178
|
+
var v6 = getArrayU8FromWasm0(r0, r1).slice();
|
|
179
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
180
|
+
return v6;
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function handleError(f, args) {
|
|
187
|
+
try {
|
|
188
|
+
return f.apply(this, args);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
*
|
|
195
|
+
*Aead represents an authenticated encryption with additional data
|
|
196
|
+
*encryption function, as per [RFC9180§7.3](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3)
|
|
197
|
+
*/
|
|
198
|
+
export const Aead = Object.freeze({
|
|
199
|
+
/**
|
|
200
|
+
* AES-128-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
201
|
+
*/
|
|
202
|
+
AesGcm128:1,"1":"AesGcm128",
|
|
203
|
+
/**
|
|
204
|
+
* AES-256-GCM [GCM](https://doi.org/10.6028/nist.sp.800-38d)
|
|
205
|
+
*/
|
|
206
|
+
AesGcm256:2,"2":"AesGcm256",
|
|
207
|
+
/**
|
|
208
|
+
* ChaCha20Poly1305 [RFC8439](https://www.rfc-editor.org/info/rfc8439)
|
|
209
|
+
*/
|
|
210
|
+
ChaCha20Poly1305:3,"3":"ChaCha20Poly1305", });
|
|
211
|
+
/**
|
|
212
|
+
*
|
|
213
|
+
*Kdf represents an key derivation function, as per
|
|
214
|
+
*[RFC9180§7.2](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.2)
|
|
215
|
+
*/
|
|
216
|
+
export const Kdf = Object.freeze({
|
|
217
|
+
/**
|
|
218
|
+
* Sha256 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
219
|
+
*/
|
|
220
|
+
Sha256:1,"1":"Sha256",
|
|
221
|
+
/**
|
|
222
|
+
* Sha384 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
223
|
+
*/
|
|
224
|
+
Sha384:2,"2":"Sha384",
|
|
225
|
+
/**
|
|
226
|
+
* Sha512 [RFC5869](https://www.rfc-editor.org/info/rfc5869)
|
|
227
|
+
*/
|
|
228
|
+
Sha512:3,"3":"Sha512", });
|
|
229
|
+
/**
|
|
230
|
+
*
|
|
231
|
+
*Kem represents an asymmetric key encapsulation mechanism, as per
|
|
232
|
+
*[RFC9180§7.1](https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1). Currently
|
|
233
|
+
*only two of options listed in the hpke draft are available.
|
|
234
|
+
*/
|
|
235
|
+
export const Kem = Object.freeze({
|
|
236
|
+
/**
|
|
237
|
+
* DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
|
|
238
|
+
*/
|
|
239
|
+
DhP256HkdfSha256:16,"16":"DhP256HkdfSha256",
|
|
240
|
+
/**
|
|
241
|
+
* DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748)
|
|
242
|
+
*/
|
|
243
|
+
X25519HkdfSha256:32,"32":"X25519HkdfSha256", });
|
|
244
|
+
/**
|
|
245
|
+
*
|
|
246
|
+
*Config is an open struct that contains an ([`Aead`], [`Kdf`], [`Kem`])
|
|
247
|
+
*algorithmic triple. This can be used with [`Config::base_mode_seal`],
|
|
248
|
+
*[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
|
|
249
|
+
*/
|
|
250
|
+
export class Config {
|
|
251
|
+
|
|
252
|
+
static __wrap(ptr) {
|
|
253
|
+
const obj = Object.create(Config.prototype);
|
|
254
|
+
obj.ptr = ptr;
|
|
255
|
+
|
|
256
|
+
return obj;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
__destroy_into_raw() {
|
|
260
|
+
const ptr = this.ptr;
|
|
261
|
+
this.ptr = 0;
|
|
262
|
+
|
|
263
|
+
return ptr;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
free() {
|
|
267
|
+
const ptr = this.__destroy_into_raw();
|
|
268
|
+
wasm.__wbg_config_free(ptr);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
272
|
+
*/
|
|
273
|
+
get aead() {
|
|
274
|
+
const ret = wasm.__wbg_get_config_aead(this.ptr);
|
|
275
|
+
return ret >>> 0;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
279
|
+
* @param {number} arg0
|
|
280
|
+
*/
|
|
281
|
+
set aead(arg0) {
|
|
282
|
+
wasm.__wbg_set_config_aead(this.ptr, arg0);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* the [key derivation function](crate::Kdf) to be used
|
|
286
|
+
*/
|
|
287
|
+
get kdf() {
|
|
288
|
+
const ret = wasm.__wbg_get_config_kdf(this.ptr);
|
|
289
|
+
return ret >>> 0;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* the [key derivation function](crate::Kdf) to be used
|
|
293
|
+
* @param {number} arg0
|
|
294
|
+
*/
|
|
295
|
+
set kdf(arg0) {
|
|
296
|
+
wasm.__wbg_set_config_kdf(this.ptr, arg0);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
300
|
+
*/
|
|
301
|
+
get kem() {
|
|
302
|
+
const ret = wasm.__wbg_get_config_kem(this.ptr);
|
|
303
|
+
return ret >>> 0;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
307
|
+
* @param {number} arg0
|
|
308
|
+
*/
|
|
309
|
+
set kem(arg0) {
|
|
310
|
+
wasm.__wbg_set_config_kem(this.ptr, arg0);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
*
|
|
314
|
+
* base_mode_seal provides an interface to [`hpke::single_shot_seal`] that does
|
|
315
|
+
* not require compile time selection of an algorithm. Instead, the
|
|
316
|
+
* selected algorithm is provided through the [`Config`] that this
|
|
317
|
+
* method is called on.
|
|
318
|
+
*
|
|
319
|
+
* Requires the `base-mode-seal` crate feature to be enabled.
|
|
320
|
+
*
|
|
321
|
+
* # Errors
|
|
322
|
+
*
|
|
323
|
+
* This will return an `Result::Err` variant if:
|
|
324
|
+
*
|
|
325
|
+
* * we are unable to deserialize the recipient public key
|
|
326
|
+
* * there is an error in key encapsultion
|
|
327
|
+
* * there is an error in encryption
|
|
328
|
+
*
|
|
329
|
+
*
|
|
330
|
+
* @param {Uint8Array} pk_recip
|
|
331
|
+
* @param {Uint8Array} info
|
|
332
|
+
* @param {Uint8Array} plaintext
|
|
333
|
+
* @param {Uint8Array} aad
|
|
334
|
+
* @returns {EncappedKeyAndCiphertext}
|
|
335
|
+
*/
|
|
336
|
+
base_mode_seal(pk_recip, info, plaintext, aad) {
|
|
337
|
+
try {
|
|
338
|
+
const ptr = this.__destroy_into_raw();
|
|
339
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
340
|
+
const ptr0 = passArray8ToWasm0(pk_recip, wasm.__wbindgen_malloc);
|
|
341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
342
|
+
const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
343
|
+
const len1 = WASM_VECTOR_LEN;
|
|
344
|
+
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
345
|
+
const len2 = WASM_VECTOR_LEN;
|
|
346
|
+
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
347
|
+
const len3 = WASM_VECTOR_LEN;
|
|
348
|
+
wasm.base_mode_seal(retptr, ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
349
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
350
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
351
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
352
|
+
if (r2) {
|
|
353
|
+
throw takeObject(r1);
|
|
354
|
+
}
|
|
355
|
+
return EncappedKeyAndCiphertext.__wrap(r0);
|
|
356
|
+
} finally {
|
|
357
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
*
|
|
362
|
+
* base_mode_open provides an interface to [`hpke::single_shot_open`]
|
|
363
|
+
* that does not require compile time selection of an
|
|
364
|
+
* algorithm. Instead, the selected algorithm is provided through the
|
|
365
|
+
* [`Config`] that this method is called on.
|
|
366
|
+
*
|
|
367
|
+
* Requires the `base-mode-open` crate feature to be enabled.
|
|
368
|
+
*
|
|
369
|
+
* # Errors
|
|
370
|
+
*
|
|
371
|
+
* This will return an `Result::Err` variant if:
|
|
372
|
+
*
|
|
373
|
+
* * we are unable to deserialize the private key or encapsulated key
|
|
374
|
+
* * there is an error in key decapsulation
|
|
375
|
+
* * there is an error in decryption
|
|
376
|
+
*
|
|
377
|
+
*
|
|
378
|
+
* @param {Uint8Array} private_key
|
|
379
|
+
* @param {Uint8Array} ciphertext
|
|
380
|
+
* @param {Uint8Array} encapped_key
|
|
381
|
+
* @param {Uint8Array} info
|
|
382
|
+
* @param {Uint8Array} aad
|
|
383
|
+
* @returns {Uint8Array}
|
|
384
|
+
*/
|
|
385
|
+
base_mode_open(private_key, ciphertext, encapped_key, info, aad) {
|
|
386
|
+
try {
|
|
387
|
+
const ptr = this.__destroy_into_raw();
|
|
388
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
389
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
390
|
+
const len0 = WASM_VECTOR_LEN;
|
|
391
|
+
const ptr1 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
392
|
+
const len1 = WASM_VECTOR_LEN;
|
|
393
|
+
const ptr2 = passArray8ToWasm0(encapped_key, wasm.__wbindgen_malloc);
|
|
394
|
+
const len2 = WASM_VECTOR_LEN;
|
|
395
|
+
const ptr3 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);
|
|
396
|
+
const len3 = WASM_VECTOR_LEN;
|
|
397
|
+
const ptr4 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
398
|
+
const len4 = WASM_VECTOR_LEN;
|
|
399
|
+
wasm.base_mode_open(retptr, ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
400
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
401
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
402
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
403
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
404
|
+
if (r3) {
|
|
405
|
+
throw takeObject(r2);
|
|
406
|
+
}
|
|
407
|
+
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
408
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
409
|
+
return v5;
|
|
410
|
+
} finally {
|
|
411
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
|
|
416
|
+
* @param {number} aead_id
|
|
417
|
+
* @param {number} kdf_id
|
|
418
|
+
* @param {number} kem_id
|
|
419
|
+
* @returns {Config}
|
|
420
|
+
*/
|
|
421
|
+
static try_from_ids(aead_id, kdf_id, kem_id) {
|
|
422
|
+
try {
|
|
423
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
424
|
+
wasm.config_try_from_ids(retptr, aead_id, kdf_id, kem_id);
|
|
425
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
426
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
427
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
428
|
+
if (r2) {
|
|
429
|
+
throw takeObject(r1);
|
|
430
|
+
}
|
|
431
|
+
return Config.__wrap(r0);
|
|
432
|
+
} finally {
|
|
433
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
*r"
|
|
439
|
+
* a simple struct to return the combined encapsulated key
|
|
440
|
+
* and ciphertext from seal
|
|
441
|
+
*
|
|
442
|
+
*/
|
|
443
|
+
export class EncappedKeyAndCiphertext {
|
|
444
|
+
|
|
445
|
+
static __wrap(ptr) {
|
|
446
|
+
const obj = Object.create(EncappedKeyAndCiphertext.prototype);
|
|
447
|
+
obj.ptr = ptr;
|
|
448
|
+
|
|
449
|
+
return obj;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
__destroy_into_raw() {
|
|
453
|
+
const ptr = this.ptr;
|
|
454
|
+
this.ptr = 0;
|
|
455
|
+
|
|
456
|
+
return ptr;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
free() {
|
|
460
|
+
const ptr = this.__destroy_into_raw();
|
|
461
|
+
wasm.__wbg_encappedkeyandciphertext_free(ptr);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* getter for encapped_key
|
|
465
|
+
* @returns {Uint8Array}
|
|
466
|
+
*/
|
|
467
|
+
get encapped_key() {
|
|
468
|
+
try {
|
|
469
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
470
|
+
wasm.encappedkeyandciphertext_encapped_key(retptr, this.ptr);
|
|
471
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
472
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
473
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
474
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
475
|
+
return v0;
|
|
476
|
+
} finally {
|
|
477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* getter for ciphertext
|
|
482
|
+
* @returns {Uint8Array}
|
|
483
|
+
*/
|
|
484
|
+
get ciphertext() {
|
|
485
|
+
try {
|
|
486
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
487
|
+
wasm.encappedkeyandciphertext_ciphertext(retptr, this.ptr);
|
|
488
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
489
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
490
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
491
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
492
|
+
return v0;
|
|
493
|
+
} finally {
|
|
494
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
*r"
|
|
500
|
+
* a newtype wrapper for HpkeError so we can use it in wasm_bindgen
|
|
501
|
+
*
|
|
502
|
+
*/
|
|
503
|
+
export class HpkeError {
|
|
504
|
+
|
|
505
|
+
static __wrap(ptr) {
|
|
506
|
+
const obj = Object.create(HpkeError.prototype);
|
|
507
|
+
obj.ptr = ptr;
|
|
508
|
+
|
|
509
|
+
return obj;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
__destroy_into_raw() {
|
|
513
|
+
const ptr = this.ptr;
|
|
514
|
+
this.ptr = 0;
|
|
515
|
+
|
|
516
|
+
return ptr;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
free() {
|
|
520
|
+
const ptr = this.__destroy_into_raw();
|
|
521
|
+
wasm.__wbg_hpkeerror_free(ptr);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
*
|
|
526
|
+
*A simple error type for failed id lookups
|
|
527
|
+
*/
|
|
528
|
+
export class IdLookupError {
|
|
529
|
+
|
|
530
|
+
static __wrap(ptr) {
|
|
531
|
+
const obj = Object.create(IdLookupError.prototype);
|
|
532
|
+
obj.ptr = ptr;
|
|
533
|
+
|
|
534
|
+
return obj;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
__destroy_into_raw() {
|
|
538
|
+
const ptr = this.ptr;
|
|
539
|
+
this.ptr = 0;
|
|
540
|
+
|
|
541
|
+
return ptr;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
free() {
|
|
545
|
+
const ptr = this.__destroy_into_raw();
|
|
546
|
+
wasm.__wbg_idlookuperror_free(ptr);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export function __wbg_idlookuperror_new(arg0) {
|
|
551
|
+
const ret = IdLookupError.__wrap(arg0);
|
|
552
|
+
return addHeapObject(ret);
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
export function __wbg_hpkeerror_new(arg0) {
|
|
556
|
+
const ret = HpkeError.__wrap(arg0);
|
|
557
|
+
return addHeapObject(ret);
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
export function __wbg_randomFillSync_654a7797990fb8db() { return handleError(function (arg0, arg1, arg2) {
|
|
561
|
+
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
|
|
562
|
+
}, arguments) };
|
|
563
|
+
|
|
564
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
565
|
+
takeObject(arg0);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
export function __wbg_getRandomValues_fb6b088efb6bead2() { return handleError(function (arg0, arg1) {
|
|
569
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
570
|
+
}, arguments) };
|
|
571
|
+
|
|
572
|
+
export function __wbg_process_70251ed1291754d5(arg0) {
|
|
573
|
+
const ret = getObject(arg0).process;
|
|
574
|
+
return addHeapObject(ret);
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
export function __wbindgen_is_object(arg0) {
|
|
578
|
+
const val = getObject(arg0);
|
|
579
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
580
|
+
return ret;
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
export function __wbg_versions_b23f2588cdb2ddbb(arg0) {
|
|
584
|
+
const ret = getObject(arg0).versions;
|
|
585
|
+
return addHeapObject(ret);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
export function __wbg_node_61b8c9a82499895d(arg0) {
|
|
589
|
+
const ret = getObject(arg0).node;
|
|
590
|
+
return addHeapObject(ret);
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
export function __wbindgen_is_string(arg0) {
|
|
594
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
595
|
+
return ret;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
export function __wbg_static_accessor_NODE_MODULE_33b45247c55045b0() {
|
|
599
|
+
const ret = module;
|
|
600
|
+
return addHeapObject(ret);
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
export function __wbg_require_2a93bc09fee45aca() { return handleError(function (arg0, arg1, arg2) {
|
|
604
|
+
const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
|
|
605
|
+
return addHeapObject(ret);
|
|
606
|
+
}, arguments) };
|
|
607
|
+
|
|
608
|
+
export function __wbg_crypto_2f56257a38275dbd(arg0) {
|
|
609
|
+
const ret = getObject(arg0).crypto;
|
|
610
|
+
return addHeapObject(ret);
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
export function __wbg_msCrypto_d07655bf62361f21(arg0) {
|
|
614
|
+
const ret = getObject(arg0).msCrypto;
|
|
615
|
+
return addHeapObject(ret);
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
export function __wbg_newnoargs_e23b458e372830de(arg0, arg1) {
|
|
619
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
620
|
+
return addHeapObject(ret);
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) {
|
|
624
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
625
|
+
return addHeapObject(ret);
|
|
626
|
+
}, arguments) };
|
|
627
|
+
|
|
628
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
629
|
+
const ret = getObject(arg0);
|
|
630
|
+
return addHeapObject(ret);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
export function __wbg_self_99737b4dcdf6f0d8() { return handleError(function () {
|
|
634
|
+
const ret = self.self;
|
|
635
|
+
return addHeapObject(ret);
|
|
636
|
+
}, arguments) };
|
|
637
|
+
|
|
638
|
+
export function __wbg_window_9b61fbbf3564c4fb() { return handleError(function () {
|
|
639
|
+
const ret = window.window;
|
|
640
|
+
return addHeapObject(ret);
|
|
641
|
+
}, arguments) };
|
|
642
|
+
|
|
643
|
+
export function __wbg_globalThis_8e275ef40caea3a3() { return handleError(function () {
|
|
644
|
+
const ret = globalThis.globalThis;
|
|
645
|
+
return addHeapObject(ret);
|
|
646
|
+
}, arguments) };
|
|
647
|
+
|
|
648
|
+
export function __wbg_global_5de1e0f82bddcd27() { return handleError(function () {
|
|
649
|
+
const ret = global.global;
|
|
650
|
+
return addHeapObject(ret);
|
|
651
|
+
}, arguments) };
|
|
652
|
+
|
|
653
|
+
export function __wbindgen_is_undefined(arg0) {
|
|
654
|
+
const ret = getObject(arg0) === undefined;
|
|
655
|
+
return ret;
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
export function __wbg_buffer_7af23f65f6c64548(arg0) {
|
|
659
|
+
const ret = getObject(arg0).buffer;
|
|
660
|
+
return addHeapObject(ret);
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
export function __wbg_new_cc9018bd6f283b6f(arg0) {
|
|
664
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
665
|
+
return addHeapObject(ret);
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) {
|
|
669
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
export function __wbg_length_0acb1cf9bbaf8519(arg0) {
|
|
673
|
+
const ret = getObject(arg0).length;
|
|
674
|
+
return ret;
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
export function __wbg_newwithlength_8f0657faca9f1422(arg0) {
|
|
678
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
679
|
+
return addHeapObject(ret);
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
export function __wbg_subarray_da527dbd24eafb6b(arg0, arg1, arg2) {
|
|
683
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
684
|
+
return addHeapObject(ret);
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
688
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
export function __wbindgen_memory() {
|
|
692
|
+
const ret = wasm.memory;
|
|
693
|
+
return addHeapObject(ret);
|
|
694
|
+
};
|
|
695
|
+
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hpke",
|
|
3
|
+
"description": "runtime algorithmic selection for hybrid public key encryption",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/jbr/hpke-dispatch"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"hpke_dispatch_bg.wasm",
|
|
12
|
+
"hpke_dispatch.js",
|
|
13
|
+
"hpke_dispatch_bg.js",
|
|
14
|
+
"hpke_dispatch.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"module": "hpke_dispatch.js",
|
|
17
|
+
"types": "hpke_dispatch.d.ts",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"keywords": [
|
|
20
|
+
"hpke",
|
|
21
|
+
"encryption"
|
|
22
|
+
]
|
|
23
|
+
}
|