hpke 0.5.0 → 1.0.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/LICENSE.md +21 -0
- package/README.md +123 -58
- package/index.d.ts +1824 -0
- package/index.d.ts.map +1 -0
- package/index.js +4170 -0
- package/index.ts +4170 -0
- package/package.json +68 -38
- package/LICENSE +0 -375
- package/pkg/node/.gitignore +0 -1
- package/pkg/node/LICENSE +0 -375
- package/pkg/node/README.md +0 -83
- package/pkg/node/hpke_dispatch.d.ts +0 -241
- package/pkg/node/hpke_dispatch.js +0 -812
- package/pkg/node/hpke_dispatch_bg.wasm +0 -0
- package/pkg/node/hpke_dispatch_bg.wasm.d.ts +0 -32
- package/pkg/node/index.spec.ts +0 -82
- package/pkg/node/package.json +0 -21
- package/pkg/web/.gitignore +0 -1
- package/pkg/web/LICENSE +0 -375
- package/pkg/web/README.md +0 -83
- package/pkg/web/hpke_dispatch.d.ts +0 -297
- package/pkg/web/hpke_dispatch.js +0 -852
- package/pkg/web/hpke_dispatch_bg.wasm +0 -0
- package/pkg/web/hpke_dispatch_bg.wasm.d.ts +0 -32
- package/pkg/web/index.mjs +0 -2
- package/pkg/web/index.mjs.map +0 -7
- package/pkg/web/index.ts +0 -5
- package/pkg/web/package.json +0 -22
|
@@ -1,297 +0,0 @@
|
|
|
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} recipient_public_key
|
|
23
|
-
* @param {Uint8Array} info
|
|
24
|
-
* @param {Uint8Array} plaintext
|
|
25
|
-
* @param {Uint8Array} aad
|
|
26
|
-
* @returns {EncappedKeyAndCiphertext}
|
|
27
|
-
*/
|
|
28
|
-
export function base_mode_seal(config: Config, recipient_public_key: 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} info
|
|
50
|
-
* @param {Uint8Array} ciphertext
|
|
51
|
-
* @param {Uint8Array} aad
|
|
52
|
-
* @returns {Uint8Array}
|
|
53
|
-
*/
|
|
54
|
-
export function base_mode_open(config: Config, private_key: Uint8Array, encapped_key: Uint8Array, info: Uint8Array, ciphertext: 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][section-7.1]. Currently only two of options listed in
|
|
97
|
-
*the hpke draft are available.
|
|
98
|
-
*
|
|
99
|
-
*[section-7.1]: https://www.rfc-editor.org/rfc/rfc9180.html#section-7.1
|
|
100
|
-
*/
|
|
101
|
-
export enum Kem {
|
|
102
|
-
/**
|
|
103
|
-
* DHKEM(P-256, HKDF-SHA256) [NISTCurves](https://doi.org/10.6028/nist.fips.186-4)
|
|
104
|
-
*/
|
|
105
|
-
DhP256HkdfSha256,
|
|
106
|
-
/**
|
|
107
|
-
* DHKEM(X25519, HKDF-SHA256) [RFC7748](https://www.rfc-editor.org/info/rfc7748)
|
|
108
|
-
*/
|
|
109
|
-
X25519HkdfSha256,
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*Config is an open struct that contains an ([`Aead`], [`Kdf`], [`Kem`])
|
|
114
|
-
*algorithmic triple. This can be used with [`Config::base_mode_seal`],
|
|
115
|
-
*[`Config::base_mode_open`], [`base_mode_seal`], or [`base_mode_open`].
|
|
116
|
-
*/
|
|
117
|
-
export class Config {
|
|
118
|
-
free(): void;
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
* base_mode_seal provides an interface to [`hpke::single_shot_seal`] that does
|
|
122
|
-
* not require compile time selection of an algorithm. Instead, the
|
|
123
|
-
* selected algorithm is provided through the [`Config`] that this
|
|
124
|
-
* method is called on.
|
|
125
|
-
*
|
|
126
|
-
* Requires the `base-mode-seal` crate feature to be enabled.
|
|
127
|
-
*
|
|
128
|
-
* # Errors
|
|
129
|
-
*
|
|
130
|
-
* This will return an `Result::Err` variant if:
|
|
131
|
-
*
|
|
132
|
-
* * we are unable to deserialize the recipient public key
|
|
133
|
-
* * there is an error in key encapsultion
|
|
134
|
-
* * there is an error in encryption
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @param {Uint8Array} recipient_public_key
|
|
138
|
-
* @param {Uint8Array} info
|
|
139
|
-
* @param {Uint8Array} plaintext
|
|
140
|
-
* @param {Uint8Array} aad
|
|
141
|
-
* @returns {EncappedKeyAndCiphertext}
|
|
142
|
-
*/
|
|
143
|
-
base_mode_seal(recipient_public_key: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): EncappedKeyAndCiphertext;
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
146
|
-
* base_mode_open provides an interface to [`hpke::single_shot_open`]
|
|
147
|
-
* that does not require compile time selection of an
|
|
148
|
-
* algorithm. Instead, the selected algorithm is provided through the
|
|
149
|
-
* [`Config`] that this method is called on.
|
|
150
|
-
*
|
|
151
|
-
* Requires the `base-mode-open` crate feature to be enabled.
|
|
152
|
-
*
|
|
153
|
-
* # Errors
|
|
154
|
-
*
|
|
155
|
-
* This will return an `Result::Err` variant if:
|
|
156
|
-
*
|
|
157
|
-
* * we are unable to deserialize the private key or encapsulated key
|
|
158
|
-
* * there is an error in key decapsulation
|
|
159
|
-
* * there is an error in decryption
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* @param {Uint8Array} private_key
|
|
163
|
-
* @param {Uint8Array} encapped_key
|
|
164
|
-
* @param {Uint8Array} info
|
|
165
|
-
* @param {Uint8Array} ciphertext
|
|
166
|
-
* @param {Uint8Array} aad
|
|
167
|
-
* @returns {Uint8Array}
|
|
168
|
-
*/
|
|
169
|
-
base_mode_open(private_key: Uint8Array, encapped_key: Uint8Array, info: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
170
|
-
/**
|
|
171
|
-
* Attempt to convert three u16 ids into a valid config. The id mappings are defined in the draft.
|
|
172
|
-
* @param {number} aead_id
|
|
173
|
-
* @param {number} kdf_id
|
|
174
|
-
* @param {number} kem_id
|
|
175
|
-
* @returns {Config}
|
|
176
|
-
*/
|
|
177
|
-
static try_from_ids(aead_id: number, kdf_id: number, kem_id: number): Config;
|
|
178
|
-
/**
|
|
179
|
-
* the [authenticated encryption with additional data encryption function](crate::Aead) to be used
|
|
180
|
-
*/
|
|
181
|
-
aead: number;
|
|
182
|
-
/**
|
|
183
|
-
* the [key derivation function](crate::Kdf) to be used
|
|
184
|
-
*/
|
|
185
|
-
kdf: number;
|
|
186
|
-
/**
|
|
187
|
-
* the [asymmetric key encapsulation mechanism](crate::Kem) to be used
|
|
188
|
-
*/
|
|
189
|
-
kem: number;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
*a simple struct to return the combined encapsulated key
|
|
194
|
-
*and ciphertext from seal
|
|
195
|
-
*/
|
|
196
|
-
export class EncappedKeyAndCiphertext {
|
|
197
|
-
free(): void;
|
|
198
|
-
/**
|
|
199
|
-
* the ciphertext, encrypted with the key
|
|
200
|
-
*/
|
|
201
|
-
ciphertext: Uint8Array;
|
|
202
|
-
/**
|
|
203
|
-
* the encapsulated encryption key
|
|
204
|
-
*/
|
|
205
|
-
encapped_key: Uint8Array;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
*r"
|
|
209
|
-
* a newtype wrapper for HpkeError so we can use it in wasm_bindgen
|
|
210
|
-
*
|
|
211
|
-
*/
|
|
212
|
-
export class HpkeError {
|
|
213
|
-
free(): void;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
*
|
|
217
|
-
*A simple error type for failed id lookups
|
|
218
|
-
*
|
|
219
|
-
*/
|
|
220
|
-
export class IdLookupError {
|
|
221
|
-
free(): void;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* An encoded keypair
|
|
225
|
-
*/
|
|
226
|
-
export class Keypair {
|
|
227
|
-
free(): void;
|
|
228
|
-
/**
|
|
229
|
-
* generate a keypair from a [`Kem`]
|
|
230
|
-
* @param {number} kem
|
|
231
|
-
*/
|
|
232
|
-
constructor(kem: number);
|
|
233
|
-
/**
|
|
234
|
-
* the private key for this keypair,
|
|
235
|
-
*/
|
|
236
|
-
private_key: Uint8Array;
|
|
237
|
-
/**
|
|
238
|
-
* the public key for this keypair
|
|
239
|
-
*/
|
|
240
|
-
public_key: Uint8Array;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
244
|
-
|
|
245
|
-
export interface InitOutput {
|
|
246
|
-
readonly memory: WebAssembly.Memory;
|
|
247
|
-
readonly __wbg_keypair_free: (a: number) => void;
|
|
248
|
-
readonly __wbg_get_keypair_public_key: (a: number, b: number) => void;
|
|
249
|
-
readonly __wbg_set_keypair_public_key: (a: number, b: number, c: number) => void;
|
|
250
|
-
readonly __wbg_get_keypair_private_key: (a: number, b: number) => void;
|
|
251
|
-
readonly __wbg_set_keypair_private_key: (a: number, b: number, c: number) => void;
|
|
252
|
-
readonly keypair_new: (a: number) => number;
|
|
253
|
-
readonly __wbg_encappedkeyandciphertext_free: (a: number) => void;
|
|
254
|
-
readonly __wbg_get_encappedkeyandciphertext_encapped_key: (a: number, b: number) => void;
|
|
255
|
-
readonly __wbg_set_encappedkeyandciphertext_encapped_key: (a: number, b: number, c: number) => void;
|
|
256
|
-
readonly __wbg_get_encappedkeyandciphertext_ciphertext: (a: number, b: number) => void;
|
|
257
|
-
readonly __wbg_set_encappedkeyandciphertext_ciphertext: (a: number, b: number, c: number) => void;
|
|
258
|
-
readonly __wbg_idlookuperror_free: (a: number) => void;
|
|
259
|
-
readonly __wbg_hpkeerror_free: (a: number) => void;
|
|
260
|
-
readonly base_mode_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
261
|
-
readonly base_mode_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
262
|
-
readonly __wbg_config_free: (a: number) => void;
|
|
263
|
-
readonly __wbg_get_config_aead: (a: number) => number;
|
|
264
|
-
readonly __wbg_set_config_aead: (a: number, b: number) => void;
|
|
265
|
-
readonly __wbg_get_config_kdf: (a: number) => number;
|
|
266
|
-
readonly __wbg_set_config_kdf: (a: number, b: number) => void;
|
|
267
|
-
readonly __wbg_get_config_kem: (a: number) => number;
|
|
268
|
-
readonly __wbg_set_config_kem: (a: number, b: number) => void;
|
|
269
|
-
readonly config_base_mode_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
270
|
-
readonly config_base_mode_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
271
|
-
readonly config_try_from_ids: (a: number, b: number, c: number, d: number) => void;
|
|
272
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
273
|
-
readonly __wbindgen_free: (a: number, b: number) => void;
|
|
274
|
-
readonly __wbindgen_malloc: (a: number) => number;
|
|
275
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
279
|
-
/**
|
|
280
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
281
|
-
* a precompiled `WebAssembly.Module`.
|
|
282
|
-
*
|
|
283
|
-
* @param {SyncInitInput} module
|
|
284
|
-
*
|
|
285
|
-
* @returns {InitOutput}
|
|
286
|
-
*/
|
|
287
|
-
export function initSync(module: SyncInitInput): InitOutput;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
291
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
292
|
-
*
|
|
293
|
-
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
294
|
-
*
|
|
295
|
-
* @returns {Promise<InitOutput>}
|
|
296
|
-
*/
|
|
297
|
-
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|