@hpke/jose 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +111 -2
- package/esm/mod.d.ts +17 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +11 -0
- package/esm/package.json +4 -0
- package/esm/src/alg.d.ts +58 -0
- package/esm/src/alg.d.ts.map +1 -0
- package/esm/src/alg.js +96 -0
- package/esm/src/encrypt.d.ts +83 -0
- package/esm/src/encrypt.d.ts.map +1 -0
- package/esm/src/encrypt.js +228 -0
- package/esm/src/encrypt0.d.ts +64 -0
- package/esm/src/encrypt0.d.ts.map +1 -0
- package/esm/src/encrypt0.js +128 -0
- package/esm/src/errors.d.ts +7 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +18 -0
- package/esm/src/hpke0.d.ts +16 -0
- package/esm/src/hpke0.d.ts.map +1 -0
- package/esm/src/hpke0.js +30 -0
- package/esm/src/hpke1.d.ts +16 -0
- package/esm/src/hpke1.d.ts.map +1 -0
- package/esm/src/hpke1.js +30 -0
- package/esm/src/hpke2.d.ts +16 -0
- package/esm/src/hpke2.d.ts.map +1 -0
- package/esm/src/hpke2.js +30 -0
- package/esm/src/hpke3.d.ts +16 -0
- package/esm/src/hpke3.d.ts.map +1 -0
- package/esm/src/hpke3.js +30 -0
- package/esm/src/hpke4.d.ts +4 -0
- package/esm/src/hpke4.d.ts.map +1 -0
- package/esm/src/hpke4.js +13 -0
- package/esm/src/hpke5.d.ts +16 -0
- package/esm/src/hpke5.d.ts.map +1 -0
- package/esm/src/hpke5.js +31 -0
- package/esm/src/hpke6.d.ts +4 -0
- package/esm/src/hpke6.d.ts.map +1 -0
- package/esm/src/hpke6.js +14 -0
- package/esm/src/hpke7.d.ts +16 -0
- package/esm/src/hpke7.d.ts.map +1 -0
- package/esm/src/hpke7.js +30 -0
- package/esm/src/jwk.d.ts +18 -0
- package/esm/src/jwk.d.ts.map +1 -0
- package/esm/src/jwk.js +77 -0
- package/esm/src/serialization.d.ts +61 -0
- package/esm/src/serialization.d.ts.map +1 -0
- package/esm/src/serialization.js +107 -0
- package/esm/src/structures.d.ts +14 -0
- package/esm/src/structures.d.ts.map +1 -0
- package/esm/src/structures.js +31 -0
- package/esm/src/utils.d.ts +5 -0
- package/esm/src/utils.d.ts.map +1 -0
- package/esm/src/utils.js +26 -0
- package/package.json +45 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CipherSuite } from "@hpke/core";
|
|
2
|
+
import { type JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { type JweFlattenedJson, type JweGeneralJson } from "./serialization.js";
|
|
4
|
+
/** Options for JoseEncrypt0 seal/open operations. */
|
|
5
|
+
export interface JoseEncrypt0Options {
|
|
6
|
+
/** HPKE info parameter. Defaults to empty. */
|
|
7
|
+
info?: Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Pre-shared key for PSK mode. `id` is the HPKE psk_id; it is carried in the
|
|
10
|
+
* "psk_id" header parameter as BASE64URL(id).
|
|
11
|
+
*/
|
|
12
|
+
psk?: {
|
|
13
|
+
id: Uint8Array;
|
|
14
|
+
key: Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
/** Key identifier to include in the protected header. */
|
|
17
|
+
kid?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* JWE Integrated Encryption using HPKE.
|
|
21
|
+
*
|
|
22
|
+
* Implements draft-ietf-jose-hpke-encrypt-22 Section 5. seal() produces the
|
|
23
|
+
* Compact Serialization; open() accepts all JWE serializations.
|
|
24
|
+
*/
|
|
25
|
+
export interface JoseEncrypt0 {
|
|
26
|
+
/** The underlying HPKE CipherSuite. */
|
|
27
|
+
readonly suite: CipherSuite;
|
|
28
|
+
/** Generate a KEM key pair. */
|
|
29
|
+
generateKemKeyPair(): Promise<CryptoKeyPair>;
|
|
30
|
+
/**
|
|
31
|
+
* Encrypt a plaintext into a JWE Compact Serialization string.
|
|
32
|
+
*
|
|
33
|
+
* Format: BASE64URL(header).BASE64URL(enc)..BASE64URL(ct).
|
|
34
|
+
*/
|
|
35
|
+
seal(recipientPublicKey: CryptoKey, plaintext: Uint8Array, options?: JoseEncrypt0Options): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Decrypt a JWE in the Compact, Flattened JSON or General JSON Serialization.
|
|
38
|
+
* The JWE AAD, if any, is taken from the "aad" member.
|
|
39
|
+
*/
|
|
40
|
+
open(recipientKey: CryptoKeyPair | CryptoKey, jwe: string | JweFlattenedJson | JweGeneralJson, options?: JoseEncrypt0Options): Promise<Uint8Array>;
|
|
41
|
+
/**
|
|
42
|
+
* Import a public key from a JWK.
|
|
43
|
+
* Validates kty and crv against the algorithm.
|
|
44
|
+
*/
|
|
45
|
+
importPublicJwk(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
46
|
+
/**
|
|
47
|
+
* Import a private key from a JWK.
|
|
48
|
+
* Validates kty and crv against the algorithm.
|
|
49
|
+
*/
|
|
50
|
+
importPrivateJwk(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
export declare class JoseEncrypt0Impl implements JoseEncrypt0 {
|
|
54
|
+
private _alg;
|
|
55
|
+
private _suite;
|
|
56
|
+
constructor(suite: CipherSuite, alg: JoseHpkeAlg);
|
|
57
|
+
get suite(): CipherSuite;
|
|
58
|
+
generateKemKeyPair(): Promise<CryptoKeyPair>;
|
|
59
|
+
seal(recipientPublicKey: CryptoKey, plaintext: Uint8Array, options?: JoseEncrypt0Options): Promise<string>;
|
|
60
|
+
open(recipientKey: CryptoKeyPair | CryptoKey, jwe: string | JweFlattenedJson | JweGeneralJson, options?: JoseEncrypt0Options): Promise<Uint8Array>;
|
|
61
|
+
importPublicJwk(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
62
|
+
importPrivateJwk(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=encrypt0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encrypt0.d.ts","sourceRoot":"","sources":["../../src/src/encrypt0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAGpE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAEpB,MAAM,oBAAoB,CAAC;AAS5B,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,GAAG,EAAE,UAAU,CAAA;KAAE,CAAC;IAC1C,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAE5B,+BAA+B;IAC/B,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7C;;;;OAIG;IACH,IAAI,CACF,kBAAkB,EAAE,SAAS,EAC7B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;OAGG;IACH,IAAI,CACF,YAAY,EAAE,aAAa,GAAG,SAAS,EACvC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,cAAc,EAC/C,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAErD;;;OAGG;IACH,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CACvD;AAED,gBAAgB;AAChB,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAAc;gBAEhB,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW;IAUhD,IAAI,KAAK,IAAI,WAAW,CAEvB;IAEK,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC;IAI5C,IAAI,CACR,kBAAkB,EAAE,SAAS,EAC7B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,CAAC;IAqCZ,IAAI,CACR,YAAY,EAAE,aAAa,GAAG,SAAS,EACvC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,cAAc,EAC/C,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,UAAU,CAAC;IAqFhB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IASpD,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;CAQ5D"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { isIntegratedEncryption } from "./alg.js";
|
|
2
|
+
import { decodeBase64Url, encodeBase64Url } from "./utils.js";
|
|
3
|
+
import { JoseError } from "./errors.js";
|
|
4
|
+
import { parseJwe, } from "./serialization.js";
|
|
5
|
+
import { extractPrivateKeyBytesFromJwk, extractPublicKeyBytesFromJwk, } from "./jwk.js";
|
|
6
|
+
const EMPTY = new Uint8Array(0);
|
|
7
|
+
const te = new TextEncoder();
|
|
8
|
+
/** @internal */
|
|
9
|
+
export class JoseEncrypt0Impl {
|
|
10
|
+
constructor(suite, alg) {
|
|
11
|
+
Object.defineProperty(this, "_alg", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "_suite", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
if (!isIntegratedEncryption(alg)) {
|
|
24
|
+
throw new JoseError("JoseEncrypt0 requires an Integrated Encryption algorithm");
|
|
25
|
+
}
|
|
26
|
+
this._alg = alg;
|
|
27
|
+
this._suite = suite;
|
|
28
|
+
}
|
|
29
|
+
get suite() {
|
|
30
|
+
return this._suite;
|
|
31
|
+
}
|
|
32
|
+
async generateKemKeyPair() {
|
|
33
|
+
return await this._suite.kem.generateKeyPair();
|
|
34
|
+
}
|
|
35
|
+
async seal(recipientPublicKey, plaintext, options) {
|
|
36
|
+
const info = options?.info ?? EMPTY;
|
|
37
|
+
const senderParams = {
|
|
38
|
+
recipientPublicKey,
|
|
39
|
+
info,
|
|
40
|
+
};
|
|
41
|
+
if (options?.psk) {
|
|
42
|
+
senderParams.psk = options.psk;
|
|
43
|
+
}
|
|
44
|
+
const ctx = await this._suite.createSenderContext(senderParams);
|
|
45
|
+
const encBytes = new Uint8Array(ctx.enc);
|
|
46
|
+
// Build protected header
|
|
47
|
+
const header = { alg: this._alg };
|
|
48
|
+
if (options?.kid) {
|
|
49
|
+
header.kid = options.kid;
|
|
50
|
+
}
|
|
51
|
+
if (options?.psk) {
|
|
52
|
+
header.psk_id = encodeBase64Url(options.psk.id);
|
|
53
|
+
}
|
|
54
|
+
const encodedProtectedHeader = encodeBase64Url(te.encode(JSON.stringify(header)));
|
|
55
|
+
// AAD = ASCII(Encoded Protected Header)
|
|
56
|
+
const aad = te.encode(encodedProtectedHeader);
|
|
57
|
+
const ciphertext = new Uint8Array(await ctx.seal(plaintext, aad));
|
|
58
|
+
// Compact JWE: header.enc..ct.
|
|
59
|
+
// IV and tag are empty for Integrated Encryption
|
|
60
|
+
return `${encodedProtectedHeader}.${encodeBase64Url(encBytes)}..${encodeBase64Url(ciphertext)}.`;
|
|
61
|
+
}
|
|
62
|
+
async open(recipientKey, jwe, options) {
|
|
63
|
+
const info = options?.info ?? EMPTY;
|
|
64
|
+
const parsed = parseJwe(jwe);
|
|
65
|
+
if (parsed.recipients.length !== 1) {
|
|
66
|
+
throw new JoseError("Integrated Encryption requires exactly one recipient");
|
|
67
|
+
}
|
|
68
|
+
const { joseHeader: header, encryptedKey } = parsed.recipients[0];
|
|
69
|
+
// "alg" MUST be in the protected header for Integrated Encryption
|
|
70
|
+
const algValue = parsed.protectedHeader.alg;
|
|
71
|
+
if (algValue !== this._alg) {
|
|
72
|
+
throw new JoseError(`Algorithm mismatch: expected ${this._alg}, got ${algValue}`);
|
|
73
|
+
}
|
|
74
|
+
// "enc" MUST NOT be present for Integrated Encryption
|
|
75
|
+
if ("enc" in header) {
|
|
76
|
+
throw new JoseError("enc parameter must not be present for Integrated Encryption");
|
|
77
|
+
}
|
|
78
|
+
// "ek" MUST NOT be present for Integrated Encryption
|
|
79
|
+
if ("ek" in header) {
|
|
80
|
+
throw new JoseError("ek parameter must not be present for Integrated Encryption");
|
|
81
|
+
}
|
|
82
|
+
// The JWE IV and Authentication Tag MUST be empty
|
|
83
|
+
if (parsed.iv || parsed.tag) {
|
|
84
|
+
throw new JoseError("iv and tag must be empty for Integrated Encryption");
|
|
85
|
+
}
|
|
86
|
+
if (!encryptedKey || !parsed.ciphertext) {
|
|
87
|
+
throw new JoseError("Missing encrypted key or ciphertext");
|
|
88
|
+
}
|
|
89
|
+
// PSK consistency validation
|
|
90
|
+
if (options?.psk) {
|
|
91
|
+
const storedPskId = parsed.protectedHeader.psk_id;
|
|
92
|
+
if (storedPskId === undefined) {
|
|
93
|
+
throw new JoseError("Missing psk_id in protected header for PSK mode");
|
|
94
|
+
}
|
|
95
|
+
if (storedPskId !== encodeBase64Url(options.psk.id)) {
|
|
96
|
+
throw new JoseError("psk_id mismatch");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if ("psk_id" in header) {
|
|
101
|
+
throw new JoseError("psk_id present but PSK mode was not selected");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const encBytes = decodeBase64Url(encryptedKey);
|
|
105
|
+
const ciphertext = decodeBase64Url(parsed.ciphertext);
|
|
106
|
+
const privateKey = "privateKey" in recipientKey
|
|
107
|
+
? recipientKey.privateKey
|
|
108
|
+
: recipientKey;
|
|
109
|
+
const recipientParams = {
|
|
110
|
+
recipientKey: privateKey,
|
|
111
|
+
enc: encBytes,
|
|
112
|
+
info,
|
|
113
|
+
};
|
|
114
|
+
if (options?.psk) {
|
|
115
|
+
recipientParams.psk = options.psk;
|
|
116
|
+
}
|
|
117
|
+
const ctx = await this._suite.createRecipientContext(recipientParams);
|
|
118
|
+
return new Uint8Array(await ctx.open(ciphertext, parsed.additionalData));
|
|
119
|
+
}
|
|
120
|
+
async importPublicJwk(jwk) {
|
|
121
|
+
const rawBytes = extractPublicKeyBytesFromJwk(jwk, this._alg);
|
|
122
|
+
return await this._suite.kem.importKey("raw", rawBytes.buffer, true);
|
|
123
|
+
}
|
|
124
|
+
async importPrivateJwk(jwk) {
|
|
125
|
+
const rawBytes = extractPrivateKeyBytesFromJwk(jwk, this._alg);
|
|
126
|
+
return await this._suite.kem.importKey("raw", rawBytes.buffer, false);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Base error for @hpke/jose operations. */
|
|
2
|
+
export declare class JoseError extends Error {
|
|
3
|
+
constructor(message: string, options?: ErrorOptions);
|
|
4
|
+
}
|
|
5
|
+
/** Wrap a failed crypto operation, retaining its original error as cause. */
|
|
6
|
+
export declare function withJoseError<T>(message: string, fn: () => Promise<T>): Promise<T>;
|
|
7
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/src/errors.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,qBAAa,SAAU,SAAQ,KAAK;gBACf,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAI3D;AAED,6EAA6E;AAC7E,wBAAsB,aAAa,CAAC,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Base error for @hpke/jose operations. */
|
|
2
|
+
export class JoseError extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = "JoseError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Wrap a failed crypto operation, retaining its original error as cause. */
|
|
9
|
+
export async function withJoseError(message, fn) {
|
|
10
|
+
try {
|
|
11
|
+
return await fn();
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
if (e instanceof JoseError)
|
|
15
|
+
throw e;
|
|
16
|
+
throw new JoseError(message, { cause: e });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(P-256), HKDF-SHA256, AES-128-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke0(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(P-256), HKDF-SHA256, AES-128-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke0Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke0.d.ts","sourceRoot":"","sources":["../../src/src/hpke0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,sEAAsE;AACtE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke0.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Aes128Gcm, CipherSuite, DhkemP256HkdfSha256, HkdfSha256, } from "@hpke/core";
|
|
2
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
4
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
5
|
+
/** DHKEM(P-256), HKDF-SHA256, AES-128-GCM — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke0() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemP256HkdfSha256(),
|
|
9
|
+
kdf: new HkdfSha256(),
|
|
10
|
+
aead: new Aes128Gcm(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DHKEM(P-256), HKDF-SHA256, AES-128-GCM — Key Encryption.
|
|
16
|
+
*
|
|
17
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
18
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
19
|
+
* The JWE content algorithm is derived from it.
|
|
20
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
21
|
+
* equivalent.
|
|
22
|
+
*/
|
|
23
|
+
export function createJoseHpke0Ke(contentAead) {
|
|
24
|
+
const suite = new CipherSuite({
|
|
25
|
+
kem: new DhkemP256HkdfSha256(),
|
|
26
|
+
kdf: new HkdfSha256(),
|
|
27
|
+
aead: new Aes128Gcm(),
|
|
28
|
+
});
|
|
29
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_0_KE, contentAead);
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(P-384), HKDF-SHA384, AES-256-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke1(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(P-384), HKDF-SHA384, AES-256-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke1Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke1.d.ts","sourceRoot":"","sources":["../../src/src/hpke1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,sEAAsE;AACtE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke1.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Aes256Gcm, CipherSuite, DhkemP384HkdfSha384, HkdfSha384, } from "@hpke/core";
|
|
2
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
4
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
5
|
+
/** DHKEM(P-384), HKDF-SHA384, AES-256-GCM — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke1() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemP384HkdfSha384(),
|
|
9
|
+
kdf: new HkdfSha384(),
|
|
10
|
+
aead: new Aes256Gcm(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_1);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DHKEM(P-384), HKDF-SHA384, AES-256-GCM — Key Encryption.
|
|
16
|
+
*
|
|
17
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
18
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
19
|
+
* The JWE content algorithm is derived from it.
|
|
20
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
21
|
+
* equivalent.
|
|
22
|
+
*/
|
|
23
|
+
export function createJoseHpke1Ke(contentAead) {
|
|
24
|
+
const suite = new CipherSuite({
|
|
25
|
+
kem: new DhkemP384HkdfSha384(),
|
|
26
|
+
kdf: new HkdfSha384(),
|
|
27
|
+
aead: new Aes256Gcm(),
|
|
28
|
+
});
|
|
29
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_1_KE, contentAead);
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(P-521), HKDF-SHA512, AES-256-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke2(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(P-521), HKDF-SHA512, AES-256-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke2Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke2.d.ts","sourceRoot":"","sources":["../../src/src/hpke2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,sEAAsE;AACtE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke2.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Aes256Gcm, CipherSuite, DhkemP521HkdfSha512, HkdfSha512, } from "@hpke/core";
|
|
2
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
4
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
5
|
+
/** DHKEM(P-521), HKDF-SHA512, AES-256-GCM — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke2() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemP521HkdfSha512(),
|
|
9
|
+
kdf: new HkdfSha512(),
|
|
10
|
+
aead: new Aes256Gcm(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_2);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DHKEM(P-521), HKDF-SHA512, AES-256-GCM — Key Encryption.
|
|
16
|
+
*
|
|
17
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
18
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
19
|
+
* The JWE content algorithm is derived from it.
|
|
20
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
21
|
+
* equivalent.
|
|
22
|
+
*/
|
|
23
|
+
export function createJoseHpke2Ke(contentAead) {
|
|
24
|
+
const suite = new CipherSuite({
|
|
25
|
+
kem: new DhkemP521HkdfSha512(),
|
|
26
|
+
kdf: new HkdfSha512(),
|
|
27
|
+
aead: new Aes256Gcm(),
|
|
28
|
+
});
|
|
29
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_2_KE, contentAead);
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(X25519), HKDF-SHA256, AES-128-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke3(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(X25519), HKDF-SHA256, AES-128-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke3Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke3.d.ts","sourceRoot":"","sources":["../../src/src/hpke3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke3.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Aes128Gcm, CipherSuite, DhkemX25519HkdfSha256, HkdfSha256, } from "@hpke/core";
|
|
2
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
4
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
5
|
+
/** DHKEM(X25519), HKDF-SHA256, AES-128-GCM — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke3() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemX25519HkdfSha256(),
|
|
9
|
+
kdf: new HkdfSha256(),
|
|
10
|
+
aead: new Aes128Gcm(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_3);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DHKEM(X25519), HKDF-SHA256, AES-128-GCM — Key Encryption.
|
|
16
|
+
*
|
|
17
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
18
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
19
|
+
* The JWE content algorithm is derived from it.
|
|
20
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
21
|
+
* equivalent.
|
|
22
|
+
*/
|
|
23
|
+
export function createJoseHpke3Ke(contentAead) {
|
|
24
|
+
const suite = new CipherSuite({
|
|
25
|
+
kem: new DhkemX25519HkdfSha256(),
|
|
26
|
+
kdf: new HkdfSha256(),
|
|
27
|
+
aead: new Aes128Gcm(),
|
|
28
|
+
});
|
|
29
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_3_KE, contentAead);
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke4.d.ts","sourceRoot":"","sources":["../../src/src/hpke4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,4EAA4E;AAC5E,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
|
package/esm/src/hpke4.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CipherSuite, DhkemX25519HkdfSha256, HkdfSha256 } from "@hpke/core";
|
|
2
|
+
import { Chacha20Poly1305 } from "@hpke/chacha20poly1305";
|
|
3
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
4
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
5
|
+
/** DHKEM(X25519), HKDF-SHA256, ChaCha20Poly1305 — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke4() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemX25519HkdfSha256(),
|
|
9
|
+
kdf: new HkdfSha256(),
|
|
10
|
+
aead: new Chacha20Poly1305(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_4);
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(X448), HKDF-SHA512, AES-256-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke5(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(X448), HKDF-SHA512, AES-256-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke5Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke5.d.ts","sourceRoot":"","sources":["../../src/src/hpke5.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,qEAAqE;AACrE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke5.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Aes256Gcm, CipherSuite, HkdfSha512, } from "@hpke/core";
|
|
2
|
+
import { DhkemX448HkdfSha512 } from "@hpke/dhkem-x448";
|
|
3
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
4
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
5
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
6
|
+
/** DHKEM(X448), HKDF-SHA512, AES-256-GCM — Integrated Encryption. */
|
|
7
|
+
export function createJoseHpke5() {
|
|
8
|
+
const suite = new CipherSuite({
|
|
9
|
+
kem: new DhkemX448HkdfSha512(),
|
|
10
|
+
kdf: new HkdfSha512(),
|
|
11
|
+
aead: new Aes256Gcm(),
|
|
12
|
+
});
|
|
13
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_5);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* DHKEM(X448), HKDF-SHA512, AES-256-GCM — Key Encryption.
|
|
17
|
+
*
|
|
18
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
19
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
20
|
+
* The JWE content algorithm is derived from it.
|
|
21
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
22
|
+
* equivalent.
|
|
23
|
+
*/
|
|
24
|
+
export function createJoseHpke5Ke(contentAead) {
|
|
25
|
+
const suite = new CipherSuite({
|
|
26
|
+
kem: new DhkemX448HkdfSha512(),
|
|
27
|
+
kdf: new HkdfSha512(),
|
|
28
|
+
aead: new Aes256Gcm(),
|
|
29
|
+
});
|
|
30
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_5_KE, contentAead);
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke6.d.ts","sourceRoot":"","sources":["../../src/src/hpke6.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,0EAA0E;AAC1E,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
|
package/esm/src/hpke6.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CipherSuite, HkdfSha512 } from "@hpke/core";
|
|
2
|
+
import { DhkemX448HkdfSha512 } from "@hpke/dhkem-x448";
|
|
3
|
+
import { Chacha20Poly1305 } from "@hpke/chacha20poly1305";
|
|
4
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
5
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
6
|
+
/** DHKEM(X448), HKDF-SHA512, ChaCha20Poly1305 — Integrated Encryption. */
|
|
7
|
+
export function createJoseHpke6() {
|
|
8
|
+
const suite = new CipherSuite({
|
|
9
|
+
kem: new DhkemX448HkdfSha512(),
|
|
10
|
+
kdf: new HkdfSha512(),
|
|
11
|
+
aead: new Chacha20Poly1305(),
|
|
12
|
+
});
|
|
13
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_6);
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AeadInterface } from "@hpke/core";
|
|
2
|
+
import type { JoseEncrypt0 } from "./encrypt0.js";
|
|
3
|
+
import type { JoseEncrypt } from "./encrypt.js";
|
|
4
|
+
/** DHKEM(P-256), HKDF-SHA256, AES-256-GCM — Integrated Encryption. */
|
|
5
|
+
export declare function createJoseHpke7(): JoseEncrypt0;
|
|
6
|
+
/**
|
|
7
|
+
* DHKEM(P-256), HKDF-SHA256, AES-256-GCM — Key Encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
10
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
11
|
+
* The JWE content algorithm is derived from it.
|
|
12
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
13
|
+
* equivalent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createJoseHpke7Ke(contentAead: AeadInterface): JoseEncrypt;
|
|
16
|
+
//# sourceMappingURL=hpke7.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hpke7.d.ts","sourceRoot":"","sources":["../../src/src/hpke7.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,sEAAsE;AACtE,wBAAgB,eAAe,IAAI,YAAY,CAO9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAWzE"}
|
package/esm/src/hpke7.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Aes256Gcm, CipherSuite, DhkemP256HkdfSha256, HkdfSha256, } from "@hpke/core";
|
|
2
|
+
import { JoseHpkeAlg } from "./alg.js";
|
|
3
|
+
import { JoseEncrypt0Impl } from "./encrypt0.js";
|
|
4
|
+
import { JoseEncryptImpl } from "./encrypt.js";
|
|
5
|
+
/** DHKEM(P-256), HKDF-SHA256, AES-256-GCM — Integrated Encryption. */
|
|
6
|
+
export function createJoseHpke7() {
|
|
7
|
+
const suite = new CipherSuite({
|
|
8
|
+
kem: new DhkemP256HkdfSha256(),
|
|
9
|
+
kdf: new HkdfSha256(),
|
|
10
|
+
aead: new Aes256Gcm(),
|
|
11
|
+
});
|
|
12
|
+
return new JoseEncrypt0Impl(suite, JoseHpkeAlg.HPKE_7);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DHKEM(P-256), HKDF-SHA256, AES-256-GCM — Key Encryption.
|
|
16
|
+
*
|
|
17
|
+
* @param contentAead The AEAD for content encryption (Layer 0), e.g.
|
|
18
|
+
* `new Aes128Gcm()` or `new Aes256Gcm()`.
|
|
19
|
+
* The JWE content algorithm is derived from it.
|
|
20
|
+
* @throws {JoseError} if contentAead has no supported JWE content-encryption
|
|
21
|
+
* equivalent.
|
|
22
|
+
*/
|
|
23
|
+
export function createJoseHpke7Ke(contentAead) {
|
|
24
|
+
const suite = new CipherSuite({
|
|
25
|
+
kem: new DhkemP256HkdfSha256(),
|
|
26
|
+
kdf: new HkdfSha256(),
|
|
27
|
+
aead: new Aes256Gcm(),
|
|
28
|
+
});
|
|
29
|
+
return new JoseEncryptImpl(suite, JoseHpkeAlg.HPKE_7_KE, contentAead);
|
|
30
|
+
}
|
package/esm/src/jwk.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JoseHpkeAlg } from "./alg.js";
|
|
2
|
+
/** Expected JWK key type and curve for a given JOSE HPKE algorithm. */
|
|
3
|
+
export declare function getExpectedJwkParams(alg: JoseHpkeAlg): {
|
|
4
|
+
kty: string;
|
|
5
|
+
crv: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Extract raw public key bytes from a JWK.
|
|
9
|
+
* For EC keys: uncompressed point (0x04 || x || y).
|
|
10
|
+
* For OKP keys: raw x coordinate bytes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractPublicKeyBytesFromJwk(jwk: JsonWebKey, alg: JoseHpkeAlg): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Extract raw private key bytes from a JWK.
|
|
15
|
+
* Returns the d parameter bytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractPrivateKeyBytesFromJwk(jwk: JsonWebKey, alg: JoseHpkeAlg): Uint8Array;
|
|
18
|
+
//# sourceMappingURL=jwk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwk.d.ts","sourceRoot":"","sources":["../../src/src/jwk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,uEAAuE;AACvE,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,WAAW,GACf;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAwB9B;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,WAAW,GACf,UAAU,CAiCZ;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,WAAW,GACf,UAAU,CAkBZ"}
|