@reallyme/crypto 0.2.0 → 0.3.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 +107 -17
- package/dist/aead.js +15 -8
- package/dist/aesKw.d.ts +7 -4
- package/dist/aesKw.js +69 -22
- package/dist/algorithms.d.ts +12 -4
- package/dist/algorithms.js +8 -2
- package/dist/argon2id.d.ts +1 -0
- package/dist/argon2id.js +13 -4
- package/dist/cryptoFacade.d.ts +33 -8
- package/dist/cryptoFacade.js +42 -29
- package/dist/hkdf.d.ts +1 -0
- package/dist/hkdf.js +5 -1
- package/dist/hmac.d.ts +3 -0
- package/dist/hmac.js +24 -3
- package/dist/hpke.d.ts +1 -2
- package/dist/hpke.js +33 -22
- package/dist/index.d.ts +9 -7
- package/dist/index.js +8 -6
- package/dist/jwk.d.ts +2 -1
- package/dist/jwk.js +104 -63
- package/dist/kmac.d.ts +11 -0
- package/dist/kmac.js +49 -0
- package/dist/mlDsa.js +22 -11
- package/dist/mlKem.d.ts +0 -3
- package/dist/mlKem.js +19 -37
- package/dist/operationResponse.d.ts +16 -0
- package/dist/operationResponse.js +46 -0
- package/dist/pbkdf2.d.ts +6 -8
- package/dist/pbkdf2.js +12 -12
- package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.d.ts +1741 -328
- package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.js +731 -344
- package/dist/proto.d.ts +6 -22
- package/dist/proto.js +124 -102
- package/dist/rsa.d.ts +2 -1
- package/dist/rsa.js +5 -1
- package/dist/slhDsa.js +21 -11
- package/dist/validateBytes.d.ts +6 -1
- package/dist/validateBytes.js +57 -3
- package/dist/wasm/reallyme_crypto_wasm.js +91 -134
- package/dist/wasm/reallyme_crypto_wasm_bg.wasm +0 -0
- package/dist/wasmModuleTypes.d.ts +7 -10
- package/dist/wasmProvider.d.ts +11 -13
- package/dist/wasmProvider.js +16 -19
- package/dist/xWing.d.ts +0 -5
- package/dist/xWing.js +20 -52
- package/package.json +15 -2
package/dist/cryptoFacade.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { ReallyMeAead } from "./aead.js";
|
|
5
5
|
import { ReallyMeAesKw } from "./aesKw.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ReallyMeArgon2id } from "./argon2id.js";
|
|
7
7
|
import { ReallyMeBip340Schnorr } from "./bip340Schnorr.js";
|
|
8
8
|
import { ReallyMeDigest } from "./digest.js";
|
|
9
9
|
import { ReallyMeEd25519 } from "./ed25519.js";
|
|
@@ -12,6 +12,7 @@ import { ReallyMeHkdf } from "./hkdf.js";
|
|
|
12
12
|
import { ReallyMeHmac } from "./hmac.js";
|
|
13
13
|
import { ReallyMeHpke } from "./hpke.js";
|
|
14
14
|
import { ReallyMeJwaConcatKdf } from "./jwaConcatKdf.js";
|
|
15
|
+
import { ReallyMeKmac } from "./kmac.js";
|
|
15
16
|
import { ReallyMeMlDsa } from "./mlDsa.js";
|
|
16
17
|
import { ReallyMeMlKem } from "./mlKem.js";
|
|
17
18
|
import { ReallyMeP256Ecdsa } from "./p256Ecdsa.js";
|
|
@@ -25,6 +26,8 @@ import { ReallyMeRsa } from "./rsa.js";
|
|
|
25
26
|
import { ReallyMeSecp256k1 } from "./secp256k1.js";
|
|
26
27
|
import { ReallyMeSlhDsa } from "./slhDsa.js";
|
|
27
28
|
import { requireReallyMeWasmProvider } from "./wasmProvider.js";
|
|
29
|
+
import { processOperationResponseJsonWithProvider, processOperationResponseWithProvider, } from "./operationResponse.js";
|
|
30
|
+
import { ensureByteArray } from "./validateBytes.js";
|
|
28
31
|
import { ReallyMeX25519 } from "./x25519.js";
|
|
29
32
|
import { ReallyMeXWing } from "./xWing.js";
|
|
30
33
|
const SECP256K1_ECDSA = "ECDSA-secp256k1-SHA256";
|
|
@@ -36,9 +39,27 @@ const ED25519 = "Ed25519";
|
|
|
36
39
|
/**
|
|
37
40
|
* Generic package facade. Algorithm-specific objects remain available for
|
|
38
41
|
* callers that want direct provider access; this facade gives consumers a
|
|
39
|
-
* stable typed route
|
|
42
|
+
* stable typed route and rejects algorithm/operation combinations that the
|
|
43
|
+
* selected method does not define.
|
|
40
44
|
*/
|
|
41
45
|
const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
46
|
+
/**
|
|
47
|
+
* Executes a generated binary request and returns a binary
|
|
48
|
+
* `CryptoOperationResponse`.
|
|
49
|
+
*/
|
|
50
|
+
processOperationResponse(request) {
|
|
51
|
+
ensureByteArray(request);
|
|
52
|
+
return processOperationResponseWithProvider(resolveWasmProvider(), request);
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Executes a permitted non-secret generated ProtoJSON request and returns
|
|
56
|
+
* the same binary `CryptoOperationResponse`. Secret-bearing selectors fail
|
|
57
|
+
* before JSON value deserialization.
|
|
58
|
+
*/
|
|
59
|
+
processOperationResponseJson(requestJson) {
|
|
60
|
+
ensureByteArray(requestJson);
|
|
61
|
+
return processOperationResponseJsonWithProvider(resolveWasmProvider(), requestJson);
|
|
62
|
+
},
|
|
42
63
|
hash(algorithm, bytes) {
|
|
43
64
|
switch (algorithm) {
|
|
44
65
|
case "SHA2-256":
|
|
@@ -89,6 +110,8 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
89
110
|
switch (algorithm) {
|
|
90
111
|
case "HMAC-SHA-256":
|
|
91
112
|
return ReallyMeHmac.authenticateSha256(key, message);
|
|
113
|
+
case "HMAC-SHA-384":
|
|
114
|
+
return ReallyMeHmac.authenticateSha384(key, message);
|
|
92
115
|
case "HMAC-SHA-512":
|
|
93
116
|
return ReallyMeHmac.authenticateSha512(key, message);
|
|
94
117
|
default:
|
|
@@ -99,6 +122,8 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
99
122
|
switch (algorithm) {
|
|
100
123
|
case "HMAC-SHA-256":
|
|
101
124
|
return ReallyMeHmac.verifySha256(tag, key, message);
|
|
125
|
+
case "HMAC-SHA-384":
|
|
126
|
+
return ReallyMeHmac.verifySha384(tag, key, message);
|
|
102
127
|
case "HMAC-SHA-512":
|
|
103
128
|
return ReallyMeHmac.verifySha512(tag, key, message);
|
|
104
129
|
default:
|
|
@@ -110,22 +135,10 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
110
135
|
},
|
|
111
136
|
deriveKey(algorithm, password, salt, iterations, outputLength) {
|
|
112
137
|
switch (algorithm) {
|
|
113
|
-
case "Argon2id":
|
|
114
|
-
if (outputLength !== ARGON2ID_DERIVED_KEY_LENGTH) {
|
|
115
|
-
throw new ReallyMeCryptoError("invalid-input");
|
|
116
|
-
}
|
|
117
|
-
// Argon2id is governed by fixed ReallyMe profile versions, not by
|
|
118
|
-
// caller-selected iteration counts. This legacy generic KDF shape
|
|
119
|
-
// preserves the existing facade contract; new code should call
|
|
120
|
-
// deriveArgon2id(kdfVersion, secret, salt) so the profile selector is
|
|
121
|
-
// explicit at the API boundary.
|
|
122
|
-
return ReallyMeArgon2id.deriveKeyWithProvider(resolveWasmProvider(), iterations, password, salt);
|
|
123
138
|
case "PBKDF2-HMAC-SHA-256":
|
|
124
139
|
return ReallyMePbkdf2.deriveHmacSha256(password, salt, iterations, outputLength);
|
|
125
140
|
case "PBKDF2-HMAC-SHA-512":
|
|
126
141
|
return ReallyMePbkdf2.deriveHmacSha512(password, salt, iterations, outputLength);
|
|
127
|
-
case "HKDF-SHA256":
|
|
128
|
-
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
129
142
|
default:
|
|
130
143
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
131
144
|
}
|
|
@@ -134,11 +147,8 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
134
147
|
switch (algorithm) {
|
|
135
148
|
case "HKDF-SHA256":
|
|
136
149
|
return ReallyMeHkdf.deriveSha256(inputKeyMaterial, salt, info, outputLength);
|
|
137
|
-
case "
|
|
138
|
-
|
|
139
|
-
case "PBKDF2-HMAC-SHA-512":
|
|
140
|
-
case "JWA-CONCAT-KDF-SHA256":
|
|
141
|
-
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
150
|
+
case "HKDF-SHA384":
|
|
151
|
+
return ReallyMeHkdf.deriveSha384(inputKeyMaterial, salt, info, outputLength);
|
|
142
152
|
default:
|
|
143
153
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
144
154
|
}
|
|
@@ -147,27 +157,34 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
147
157
|
switch (algorithm) {
|
|
148
158
|
case "JWA-CONCAT-KDF-SHA256":
|
|
149
159
|
return ReallyMeJwaConcatKdf.deriveSha256(sharedSecret, algorithmId, partyUInfo, partyVInfo, outputLength);
|
|
150
|
-
|
|
151
|
-
case "HKDF-SHA256":
|
|
152
|
-
case "PBKDF2-HMAC-SHA-256":
|
|
153
|
-
case "PBKDF2-HMAC-SHA-512":
|
|
160
|
+
default:
|
|
154
161
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
deriveKmac256(algorithm, key, context, customization, outputLength) {
|
|
165
|
+
switch (algorithm) {
|
|
166
|
+
case "KMAC256":
|
|
167
|
+
return ReallyMeKmac.deriveKmac256WithProvider(resolveWasmProvider(), key, context, customization, outputLength);
|
|
155
168
|
default:
|
|
156
169
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
157
170
|
}
|
|
158
171
|
},
|
|
159
172
|
wrapKey(algorithm, wrappingKey, keyToWrap) {
|
|
160
173
|
switch (algorithm) {
|
|
174
|
+
case "AES-128-KW":
|
|
175
|
+
case "AES-192-KW":
|
|
161
176
|
case "AES-256-KW":
|
|
162
|
-
return ReallyMeAesKw.wrapKeyWithProvider(resolveWasmProvider(), wrappingKey, keyToWrap);
|
|
177
|
+
return ReallyMeAesKw.wrapKeyWithProvider(algorithm, resolveWasmProvider(), wrappingKey, keyToWrap);
|
|
163
178
|
default:
|
|
164
179
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
165
180
|
}
|
|
166
181
|
},
|
|
167
182
|
unwrapKey(algorithm, wrappingKey, wrappedKey) {
|
|
168
183
|
switch (algorithm) {
|
|
184
|
+
case "AES-128-KW":
|
|
185
|
+
case "AES-192-KW":
|
|
169
186
|
case "AES-256-KW":
|
|
170
|
-
return ReallyMeAesKw.unwrapKeyWithProvider(resolveWasmProvider(), wrappingKey, wrappedKey);
|
|
187
|
+
return ReallyMeAesKw.unwrapKeyWithProvider(algorithm, resolveWasmProvider(), wrappingKey, wrappedKey);
|
|
171
188
|
default:
|
|
172
189
|
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
173
190
|
}
|
|
@@ -333,7 +350,6 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
333
350
|
generateKemKeyPair(algorithm) {
|
|
334
351
|
switch (algorithm) {
|
|
335
352
|
case "X-Wing-768":
|
|
336
|
-
case "X-Wing-1024":
|
|
337
353
|
return ReallyMeXWing.generateKeyPairWithProvider(resolveWasmProvider(), algorithm);
|
|
338
354
|
case "ML-KEM-512":
|
|
339
355
|
case "ML-KEM-768":
|
|
@@ -346,7 +362,6 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
346
362
|
deriveKemKeyPair(algorithm, secretKey) {
|
|
347
363
|
switch (algorithm) {
|
|
348
364
|
case "X-Wing-768":
|
|
349
|
-
case "X-Wing-1024":
|
|
350
365
|
return ReallyMeXWing.deriveKeyPairWithProvider(resolveWasmProvider(), algorithm, secretKey);
|
|
351
366
|
case "ML-KEM-512":
|
|
352
367
|
case "ML-KEM-768":
|
|
@@ -359,7 +374,6 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
359
374
|
encapsulate(algorithm, publicKey) {
|
|
360
375
|
switch (algorithm) {
|
|
361
376
|
case "X-Wing-768":
|
|
362
|
-
case "X-Wing-1024":
|
|
363
377
|
return ReallyMeXWing.encapsulateWithProvider(resolveWasmProvider(), algorithm, publicKey);
|
|
364
378
|
case "ML-KEM-512":
|
|
365
379
|
case "ML-KEM-768":
|
|
@@ -372,7 +386,6 @@ const createReallyMeCryptoFacade = (resolveWasmProvider) => ({
|
|
|
372
386
|
decapsulate(algorithm, ciphertext, secretKey) {
|
|
373
387
|
switch (algorithm) {
|
|
374
388
|
case "X-Wing-768":
|
|
375
|
-
case "X-Wing-1024":
|
|
376
389
|
return ReallyMeXWing.decapsulateWithProvider(resolveWasmProvider(), algorithm, ciphertext, secretKey);
|
|
377
390
|
case "ML-KEM-512":
|
|
378
391
|
case "ML-KEM-768":
|
package/dist/hkdf.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare const HKDF_MIN_OUTPUT_LENGTH = 1;
|
|
|
4
4
|
export declare const HKDF_MAX_OUTPUT_LENGTH = 4096;
|
|
5
5
|
export declare const ReallyMeHkdf: {
|
|
6
6
|
readonly deriveSha256: (inputKeyMaterial: Uint8Array, salt: Uint8Array, info: Uint8Array, outputLength: number) => Uint8Array;
|
|
7
|
+
readonly deriveSha384: (inputKeyMaterial: Uint8Array, salt: Uint8Array, info: Uint8Array, outputLength: number) => Uint8Array;
|
|
7
8
|
};
|
package/dist/hkdf.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
5
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
5
|
+
import { sha256, sha384 } from "@noble/hashes/sha2.js";
|
|
6
6
|
import { ReallyMeCryptoError } from "./errors.js";
|
|
7
7
|
export const HKDF_MIN_INPUT_KEY_MATERIAL_LENGTH = 1;
|
|
8
8
|
export const HKDF_MAX_INPUT_LENGTH = 4096;
|
|
@@ -13,6 +13,10 @@ export const ReallyMeHkdf = {
|
|
|
13
13
|
validate(inputKeyMaterial, salt, info, outputLength);
|
|
14
14
|
return hkdf(sha256, inputKeyMaterial, salt, info, outputLength);
|
|
15
15
|
},
|
|
16
|
+
deriveSha384(inputKeyMaterial, salt, info, outputLength) {
|
|
17
|
+
validate(inputKeyMaterial, salt, info, outputLength);
|
|
18
|
+
return hkdf(sha384, inputKeyMaterial, salt, info, outputLength);
|
|
19
|
+
},
|
|
16
20
|
};
|
|
17
21
|
function validate(inputKeyMaterial, salt, info, outputLength) {
|
|
18
22
|
if (inputKeyMaterial.length < HKDF_MIN_INPUT_KEY_MATERIAL_LENGTH ||
|
package/dist/hmac.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export declare const HMAC_MAX_KEY_LENGTH = 4096;
|
|
2
2
|
export declare const HMAC_SHA256_TAG_LENGTH = 32;
|
|
3
|
+
export declare const HMAC_SHA384_TAG_LENGTH = 48;
|
|
3
4
|
export declare const HMAC_SHA512_TAG_LENGTH = 64;
|
|
4
5
|
export declare const ReallyMeHmac: {
|
|
5
6
|
readonly authenticateSha256: (key: Uint8Array, message: Uint8Array) => Uint8Array;
|
|
7
|
+
readonly authenticateSha384: (key: Uint8Array, message: Uint8Array) => Uint8Array;
|
|
6
8
|
readonly authenticateSha512: (key: Uint8Array, message: Uint8Array) => Uint8Array;
|
|
7
9
|
readonly verifySha256: (tag: Uint8Array, key: Uint8Array, message: Uint8Array) => boolean;
|
|
10
|
+
readonly verifySha384: (tag: Uint8Array, key: Uint8Array, message: Uint8Array) => boolean;
|
|
8
11
|
readonly verifySha512: (tag: Uint8Array, key: Uint8Array, message: Uint8Array) => boolean;
|
|
9
12
|
};
|
package/dist/hmac.js
CHANGED
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { hmac } from "@noble/hashes/hmac.js";
|
|
5
|
-
import { sha256, sha512 } from "@noble/hashes/sha2.js";
|
|
5
|
+
import { sha256, sha384, sha512 } from "@noble/hashes/sha2.js";
|
|
6
6
|
import { ReallyMeCryptoError } from "./errors.js";
|
|
7
7
|
export const HMAC_MAX_KEY_LENGTH = 4096;
|
|
8
8
|
export const HMAC_SHA256_TAG_LENGTH = 32;
|
|
9
|
+
export const HMAC_SHA384_TAG_LENGTH = 48;
|
|
9
10
|
export const HMAC_SHA512_TAG_LENGTH = 64;
|
|
10
11
|
export const ReallyMeHmac = {
|
|
11
12
|
authenticateSha256(key, message) {
|
|
12
13
|
validateKey(key);
|
|
13
14
|
return hmac(sha256, key, message);
|
|
14
15
|
},
|
|
16
|
+
authenticateSha384(key, message) {
|
|
17
|
+
validateKey(key);
|
|
18
|
+
return hmac(sha384, key, message);
|
|
19
|
+
},
|
|
15
20
|
authenticateSha512(key, message) {
|
|
16
21
|
validateKey(key);
|
|
17
22
|
return hmac(sha512, key, message);
|
|
@@ -20,13 +25,19 @@ export const ReallyMeHmac = {
|
|
|
20
25
|
if (tag.length !== HMAC_SHA256_TAG_LENGTH) {
|
|
21
26
|
throw new ReallyMeCryptoError("invalid-input");
|
|
22
27
|
}
|
|
23
|
-
return
|
|
28
|
+
return verifyAndClearExpectedTag(tag, ReallyMeHmac.authenticateSha256(key, message));
|
|
29
|
+
},
|
|
30
|
+
verifySha384(tag, key, message) {
|
|
31
|
+
if (tag.length !== HMAC_SHA384_TAG_LENGTH) {
|
|
32
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
33
|
+
}
|
|
34
|
+
return verifyAndClearExpectedTag(tag, ReallyMeHmac.authenticateSha384(key, message));
|
|
24
35
|
},
|
|
25
36
|
verifySha512(tag, key, message) {
|
|
26
37
|
if (tag.length !== HMAC_SHA512_TAG_LENGTH) {
|
|
27
38
|
throw new ReallyMeCryptoError("invalid-input");
|
|
28
39
|
}
|
|
29
|
-
return
|
|
40
|
+
return verifyAndClearExpectedTag(tag, ReallyMeHmac.authenticateSha512(key, message));
|
|
30
41
|
},
|
|
31
42
|
};
|
|
32
43
|
function validateKey(key) {
|
|
@@ -48,3 +59,13 @@ function constantTimeEquals(left, right) {
|
|
|
48
59
|
}
|
|
49
60
|
return difference === 0;
|
|
50
61
|
}
|
|
62
|
+
function verifyAndClearExpectedTag(tag, expectedTag) {
|
|
63
|
+
try {
|
|
64
|
+
return constantTimeEquals(tag, expectedTag);
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
// Noble returns a new typed array. Clear it immediately so verification
|
|
68
|
+
// does not retain key-derived authentication material until a GC cycle.
|
|
69
|
+
expectedTag.fill(0);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/hpke.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const HPKE_P256_PUBLIC_KEY_LENGTH = 65;
|
|
|
5
5
|
export declare const HPKE_X25519_PRIVATE_KEY_LENGTH = 32;
|
|
6
6
|
export declare const HPKE_X25519_PUBLIC_KEY_LENGTH = 32;
|
|
7
7
|
export declare const HPKE_AEAD_TAG_LENGTH = 16;
|
|
8
|
+
export declare const HPKE_INFO_MAX_LENGTH = 65530;
|
|
8
9
|
export type ReallyMeHpkeSealedMessage = Readonly<{
|
|
9
10
|
encapsulatedKey: Uint8Array;
|
|
10
11
|
ciphertext: Uint8Array;
|
|
@@ -15,5 +16,3 @@ export declare const ReallyMeHpke: {
|
|
|
15
16
|
readonly openBase: (suite: ReallyMeHpkeSuite, recipientSecretKey: Uint8Array, encapsulatedKey: Uint8Array, info: Uint8Array, aad: Uint8Array, ciphertext: Uint8Array) => Uint8Array;
|
|
16
17
|
readonly openBaseWithProvider: (provider: ReallyMeWasmProvider, suite: ReallyMeHpkeSuite, recipientSecretKey: Uint8Array, encapsulatedKey: Uint8Array, info: Uint8Array, aad: Uint8Array, ciphertext: Uint8Array) => Uint8Array;
|
|
17
18
|
};
|
|
18
|
-
export declare const sealHpkeBaseDeterministicallyForTest: (suite: ReallyMeHpkeSuite, recipientPublicKey: Uint8Array, encapsulationRandomness: Uint8Array, info: Uint8Array, aad: Uint8Array, plaintext: Uint8Array) => ReallyMeHpkeSealedMessage;
|
|
19
|
-
export declare const sealHpkeBaseDeterministicallyWithProviderForTest: (provider: ReallyMeWasmProvider, suite: ReallyMeHpkeSuite, recipientPublicKey: Uint8Array, encapsulationRandomness: Uint8Array, info: Uint8Array, aad: Uint8Array, plaintext: Uint8Array) => ReallyMeHpkeSealedMessage;
|
package/dist/hpke.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { ReallyMeCryptoError } from "./errors.js";
|
|
5
|
-
import { ensureBytes,
|
|
5
|
+
import { ensureByteArrayAtMost, ensureBytes, ensureIndependentByteArray, MAX_CRYPTO_INPUT_LENGTH, readIndependentByteArrayProperty, } from "./validateBytes.js";
|
|
6
6
|
import { requireReallyMeWasmProvider } from "./wasmProvider.js";
|
|
7
7
|
export const HPKE_P256_PRIVATE_KEY_LENGTH = 32;
|
|
8
8
|
export const HPKE_P256_PUBLIC_KEY_LENGTH = 65;
|
|
9
9
|
export const HPKE_X25519_PRIVATE_KEY_LENGTH = 32;
|
|
10
10
|
export const HPKE_X25519_PUBLIC_KEY_LENGTH = 32;
|
|
11
11
|
export const HPKE_AEAD_TAG_LENGTH = 16;
|
|
12
|
+
export const HPKE_INFO_MAX_LENGTH = 65_530;
|
|
12
13
|
const hpkeSuite = (suite) => {
|
|
13
14
|
switch (suite) {
|
|
14
15
|
case "DHKEM-P256-HKDF-SHA256-HKDF-SHA256-AES-256-GCM":
|
|
@@ -23,57 +24,67 @@ const hpkeSuite = (suite) => {
|
|
|
23
24
|
publicKeyLength: HPKE_X25519_PUBLIC_KEY_LENGTH,
|
|
24
25
|
privateKeyLength: HPKE_X25519_PRIVATE_KEY_LENGTH,
|
|
25
26
|
};
|
|
27
|
+
default:
|
|
28
|
+
// JavaScript callers can bypass TypeScript's string union at runtime.
|
|
29
|
+
// Reject before a numeric selector can reach wasm-bindgen and truncate.
|
|
30
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
26
31
|
}
|
|
27
32
|
};
|
|
28
|
-
const readSealedMessage = (value, suite, plaintextLength) =>
|
|
29
|
-
encapsulatedKey
|
|
30
|
-
ciphertext
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
+
const readSealedMessage = (value, suite, plaintextLength, inputs) => {
|
|
34
|
+
const encapsulatedKey = readIndependentByteArrayProperty(value, "encapsulatedKey", suite.publicKeyLength, inputs);
|
|
35
|
+
const ciphertext = readIndependentByteArrayProperty(value, "ciphertext", plaintextLength + HPKE_AEAD_TAG_LENGTH, [...inputs, encapsulatedKey]);
|
|
36
|
+
return { encapsulatedKey, ciphertext };
|
|
37
|
+
};
|
|
38
|
+
const requirePlaintext = (value, expectedLength, inputs) => {
|
|
33
39
|
if (!(value instanceof Uint8Array)) {
|
|
34
40
|
throw new ReallyMeCryptoError("provider-failure");
|
|
35
41
|
}
|
|
42
|
+
ensureIndependentByteArray(value, inputs);
|
|
43
|
+
if (value.length !== expectedLength) {
|
|
44
|
+
value.fill(0);
|
|
45
|
+
throw new ReallyMeCryptoError("provider-failure");
|
|
46
|
+
}
|
|
36
47
|
return value;
|
|
37
48
|
};
|
|
38
49
|
export const ReallyMeHpke = {
|
|
39
50
|
sealBase(suite, recipientPublicKey, info, aad, plaintext) {
|
|
40
51
|
const config = hpkeSuite(suite);
|
|
41
52
|
ensureBytes(recipientPublicKey, config.publicKeyLength);
|
|
42
|
-
|
|
53
|
+
ensureByteArrayAtMost(info, HPKE_INFO_MAX_LENGTH);
|
|
54
|
+
ensureByteArrayAtMost(aad, MAX_CRYPTO_INPUT_LENGTH);
|
|
55
|
+
ensureByteArrayAtMost(plaintext, MAX_CRYPTO_INPUT_LENGTH);
|
|
56
|
+
return readSealedMessage(requireReallyMeWasmProvider().hpkeSealBase(config.id, recipientPublicKey, info, aad, plaintext), config, plaintext.length, [recipientPublicKey, info, aad, plaintext]);
|
|
43
57
|
},
|
|
44
58
|
sealBaseWithProvider(provider, suite, recipientPublicKey, info, aad, plaintext) {
|
|
45
59
|
const config = hpkeSuite(suite);
|
|
46
60
|
ensureBytes(recipientPublicKey, config.publicKeyLength);
|
|
47
|
-
|
|
61
|
+
ensureByteArrayAtMost(info, HPKE_INFO_MAX_LENGTH);
|
|
62
|
+
ensureByteArrayAtMost(aad, MAX_CRYPTO_INPUT_LENGTH);
|
|
63
|
+
ensureByteArrayAtMost(plaintext, MAX_CRYPTO_INPUT_LENGTH);
|
|
64
|
+
return readSealedMessage(provider.hpkeSealBase(config.id, recipientPublicKey, info, aad, plaintext), config, plaintext.length, [recipientPublicKey, info, aad, plaintext]);
|
|
48
65
|
},
|
|
49
66
|
openBase(suite, recipientSecretKey, encapsulatedKey, info, aad, ciphertext) {
|
|
50
67
|
const config = hpkeSuite(suite);
|
|
51
68
|
ensureBytes(recipientSecretKey, config.privateKeyLength);
|
|
52
69
|
ensureBytes(encapsulatedKey, config.publicKeyLength);
|
|
70
|
+
ensureByteArrayAtMost(info, HPKE_INFO_MAX_LENGTH);
|
|
71
|
+
ensureByteArrayAtMost(aad, MAX_CRYPTO_INPUT_LENGTH);
|
|
72
|
+
ensureByteArrayAtMost(ciphertext, MAX_CRYPTO_INPUT_LENGTH + HPKE_AEAD_TAG_LENGTH);
|
|
53
73
|
if (ciphertext.length < HPKE_AEAD_TAG_LENGTH) {
|
|
54
74
|
throw new ReallyMeCryptoError("invalid-input");
|
|
55
75
|
}
|
|
56
|
-
return requirePlaintext(requireReallyMeWasmProvider().hpkeOpenBase(config.id, recipientSecretKey, encapsulatedKey, info, aad, ciphertext));
|
|
76
|
+
return requirePlaintext(requireReallyMeWasmProvider().hpkeOpenBase(config.id, recipientSecretKey, encapsulatedKey, info, aad, ciphertext), ciphertext.length - HPKE_AEAD_TAG_LENGTH, [recipientSecretKey, encapsulatedKey, info, aad, ciphertext]);
|
|
57
77
|
},
|
|
58
78
|
openBaseWithProvider(provider, suite, recipientSecretKey, encapsulatedKey, info, aad, ciphertext) {
|
|
59
79
|
const config = hpkeSuite(suite);
|
|
60
80
|
ensureBytes(recipientSecretKey, config.privateKeyLength);
|
|
61
81
|
ensureBytes(encapsulatedKey, config.publicKeyLength);
|
|
82
|
+
ensureByteArrayAtMost(info, HPKE_INFO_MAX_LENGTH);
|
|
83
|
+
ensureByteArrayAtMost(aad, MAX_CRYPTO_INPUT_LENGTH);
|
|
84
|
+
ensureByteArrayAtMost(ciphertext, MAX_CRYPTO_INPUT_LENGTH + HPKE_AEAD_TAG_LENGTH);
|
|
62
85
|
if (ciphertext.length < HPKE_AEAD_TAG_LENGTH) {
|
|
63
86
|
throw new ReallyMeCryptoError("invalid-input");
|
|
64
87
|
}
|
|
65
|
-
return requirePlaintext(provider.hpkeOpenBase(config.id, recipientSecretKey, encapsulatedKey, info, aad, ciphertext));
|
|
88
|
+
return requirePlaintext(provider.hpkeOpenBase(config.id, recipientSecretKey, encapsulatedKey, info, aad, ciphertext), ciphertext.length - HPKE_AEAD_TAG_LENGTH, [recipientSecretKey, encapsulatedKey, info, aad, ciphertext]);
|
|
66
89
|
},
|
|
67
90
|
};
|
|
68
|
-
export const sealHpkeBaseDeterministicallyForTest = (suite, recipientPublicKey, encapsulationRandomness, info, aad, plaintext) => {
|
|
69
|
-
const config = hpkeSuite(suite);
|
|
70
|
-
ensureBytes(recipientPublicKey, config.publicKeyLength);
|
|
71
|
-
ensureBytes(encapsulationRandomness, config.privateKeyLength);
|
|
72
|
-
return readSealedMessage(requireReallyMeWasmProvider().hpkeSealBaseDerand(config.id, recipientPublicKey, encapsulationRandomness, info, aad, plaintext), config, plaintext.length);
|
|
73
|
-
};
|
|
74
|
-
export const sealHpkeBaseDeterministicallyWithProviderForTest = (provider, suite, recipientPublicKey, encapsulationRandomness, info, aad, plaintext) => {
|
|
75
|
-
const config = hpkeSuite(suite);
|
|
76
|
-
ensureBytes(recipientPublicKey, config.publicKeyLength);
|
|
77
|
-
ensureBytes(encapsulationRandomness, config.privateKeyLength);
|
|
78
|
-
return readSealedMessage(provider.hpkeSealBaseDerand(config.id, recipientPublicKey, encapsulationRandomness, info, aad, plaintext), config, plaintext.length);
|
|
79
|
-
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { ReallyMeCryptoError } from "./errors.js";
|
|
2
2
|
export type { ReallyMeCryptoErrorCode } from "./errors.js";
|
|
3
3
|
export { REALLYME_AEAD_ALGORITHMS, REALLYME_HASH_ALGORITHMS, REALLYME_HPKE_SUITES, REALLYME_KDF_ALGORITHMS, REALLYME_KEM_ALGORITHMS, REALLYME_KEY_AGREEMENT_ALGORITHMS, REALLYME_KEY_WRAP_ALGORITHMS, REALLYME_MAC_ALGORITHMS, REALLYME_SIGNATURE_ALGORITHMS, } from "./algorithms.js";
|
|
4
|
-
export type { ReallyMeAeadAlgorithm, ReallyMeHashAlgorithm, ReallyMeHpkeSuite, ReallyMeKdfAlgorithm, ReallyMeKemAlgorithm, ReallyMeKeyAgreementAlgorithm, ReallyMeKeyWrapAlgorithm, ReallyMeMacAlgorithm, ReallyMeSignatureAlgorithm, } from "./algorithms.js";
|
|
4
|
+
export type { ReallyMeAeadAlgorithm, ReallyMeHashAlgorithm, ReallyMeHkdfAlgorithm, ReallyMeHpkeSuite, ReallyMeJwaConcatKdfAlgorithm, ReallyMeKdfAlgorithm, ReallyMeKemAlgorithm, ReallyMeKeyAgreementAlgorithm, ReallyMeKeyWrapAlgorithm, ReallyMeKmacKdfAlgorithm, ReallyMeMacAlgorithm, ReallyMePbkdf2Algorithm, ReallyMeSignatureAlgorithm, } from "./algorithms.js";
|
|
5
5
|
export { AEAD_KEY_LENGTH, AEAD_NONCE_LENGTH, AEAD_TAG_LENGTH, AES_128_GCM_KEY_LENGTH, AES_192_GCM_KEY_LENGTH, AES_256_GCM_KEY_LENGTH, CHACHA20_POLY1305_KEY_LENGTH, ReallyMeAead, XCHACHA20_POLY1305_NONCE_LENGTH, } from "./aead.js";
|
|
6
6
|
export { AES_256_KW_KEK_LENGTH, AES_KW_BLOCK_LENGTH, AES_KW_INTEGRITY_CHECK_LENGTH, AES_KW_MAX_KEY_DATA_LENGTH, AES_KW_MIN_KEY_DATA_LENGTH, AES_KW_MIN_WRAPPED_KEY_LENGTH, ReallyMeAesKw, } from "./aesKw.js";
|
|
7
|
-
export { ARGON2ID_DERIVED_KEY_LENGTH, ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_V1, ARGON2ID_V2, ReallyMeArgon2id, } from "./argon2id.js";
|
|
7
|
+
export { ARGON2ID_DERIVED_KEY_LENGTH, ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_SECRET_MAX_LENGTH, ARGON2ID_V1, ARGON2ID_V2, ReallyMeArgon2id, } from "./argon2id.js";
|
|
8
8
|
export { BIP340_SCHNORR_AUX_RAND_LENGTH, BIP340_SCHNORR_MESSAGE_LENGTH, BIP340_SCHNORR_PUBLIC_KEY_LENGTH, BIP340_SCHNORR_SECRET_KEY_LENGTH, BIP340_SCHNORR_SIGNATURE_LENGTH, ReallyMeBip340Schnorr, } from "./bip340Schnorr.js";
|
|
9
|
-
export { HPKE_AEAD_TAG_LENGTH, HPKE_P256_PRIVATE_KEY_LENGTH, HPKE_P256_PUBLIC_KEY_LENGTH, HPKE_X25519_PRIVATE_KEY_LENGTH, HPKE_X25519_PUBLIC_KEY_LENGTH, ReallyMeHpke, } from "./hpke.js";
|
|
9
|
+
export { HPKE_AEAD_TAG_LENGTH, HPKE_INFO_MAX_LENGTH, HPKE_P256_PRIVATE_KEY_LENGTH, HPKE_P256_PUBLIC_KEY_LENGTH, HPKE_X25519_PRIVATE_KEY_LENGTH, HPKE_X25519_PUBLIC_KEY_LENGTH, ReallyMeHpke, } from "./hpke.js";
|
|
10
10
|
export type { ReallyMeHpkeSealedMessage as ReallyMeHpkeProviderSealedMessage } from "./hpke.js";
|
|
11
11
|
export { ReallyMeJwk } from "./jwk.js";
|
|
12
12
|
export type { ReallyMeAkpJwk, ReallyMeEcJwk, ReallyMeJwk as ReallyMeJsonWebKey, ReallyMeJwkAlgorithm, ReallyMeJwkKey, ReallyMeJwks, ReallyMeJwksKeySet, ReallyMeOkpJwk, } from "./jwk.js";
|
|
13
|
-
export { ML_KEM_1024_CIPHERTEXT_LENGTH, ML_KEM_1024_PUBLIC_KEY_LENGTH, ML_KEM_512_CIPHERTEXT_LENGTH, ML_KEM_512_PUBLIC_KEY_LENGTH, ML_KEM_768_CIPHERTEXT_LENGTH, ML_KEM_768_PUBLIC_KEY_LENGTH,
|
|
13
|
+
export { ML_KEM_1024_CIPHERTEXT_LENGTH, ML_KEM_1024_PUBLIC_KEY_LENGTH, ML_KEM_512_CIPHERTEXT_LENGTH, ML_KEM_512_PUBLIC_KEY_LENGTH, ML_KEM_768_CIPHERTEXT_LENGTH, ML_KEM_768_PUBLIC_KEY_LENGTH, ML_KEM_SECRET_KEY_LENGTH, ML_KEM_SHARED_SECRET_LENGTH, ReallyMeMlKem, } from "./mlKem.js";
|
|
14
14
|
export type { ReallyMeMlKemEncapsulation, ReallyMeMlKemKeyPair } from "./mlKem.js";
|
|
15
15
|
export { ML_DSA_44_PUBLIC_KEY_LENGTH, ML_DSA_44_SIGNATURE_LENGTH, ML_DSA_65_PUBLIC_KEY_LENGTH, ML_DSA_65_SIGNATURE_LENGTH, ML_DSA_87_PUBLIC_KEY_LENGTH, ML_DSA_87_SIGNATURE_LENGTH, ML_DSA_SECRET_KEY_LENGTH, ReallyMeMlDsa, } from "./mlDsa.js";
|
|
16
16
|
export type { ReallyMeMlDsaKeyPair } from "./mlDsa.js";
|
|
@@ -23,21 +23,23 @@ export type { ReallyMeCryptoFacade, ReallyMeCryptoProviders, ReallyMeHpkeSealedM
|
|
|
23
23
|
export { ReallyMeDigest } from "./digest.js";
|
|
24
24
|
export { ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, ReallyMeEd25519, } from "./ed25519.js";
|
|
25
25
|
export { HKDF_MAX_INPUT_LENGTH, HKDF_MAX_OUTPUT_LENGTH, HKDF_MIN_INPUT_KEY_MATERIAL_LENGTH, HKDF_MIN_OUTPUT_LENGTH, ReallyMeHkdf, } from "./hkdf.js";
|
|
26
|
+
export { KMAC256_MAX_CONTEXT_LENGTH, KMAC256_MAX_CUSTOMIZATION_LENGTH, KMAC256_MAX_KEY_LENGTH, KMAC256_MAX_OUTPUT_LENGTH, KMAC256_MIN_KEY_LENGTH, KMAC256_MIN_OUTPUT_LENGTH, ReallyMeKmac, } from "./kmac.js";
|
|
26
27
|
export { JWA_CONCAT_KDF_MAX_INFO_LENGTH, JWA_CONCAT_KDF_MAX_OUTPUT_LENGTH, JWA_CONCAT_KDF_MAX_SHARED_SECRET_LENGTH, JWA_CONCAT_KDF_MIN_OUTPUT_LENGTH, JWA_CONCAT_KDF_SHA256_DIGEST_LENGTH, ReallyMeJwaConcatKdf, } from "./jwaConcatKdf.js";
|
|
27
28
|
export { bestEffortClear } from "./memory.js";
|
|
28
|
-
export {
|
|
29
|
+
export { processOperationResponse, processOperationResponseJson, } from "./operationResponse.js";
|
|
30
|
+
export { HMAC_MAX_KEY_LENGTH, HMAC_SHA256_TAG_LENGTH, HMAC_SHA384_TAG_LENGTH, HMAC_SHA512_TAG_LENGTH, ReallyMeHmac, } from "./hmac.js";
|
|
29
31
|
export { P256_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P256_ECDH_SECRET_KEY_LENGTH, P256_ECDH_SHARED_SECRET_LENGTH, ReallyMeP256Ecdh, } from "./p256Ecdh.js";
|
|
30
32
|
export { P256_ECDSA_COMPACT_SIGNATURE_LENGTH, P256_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P256_ECDSA_DER_SIGNATURE_MAX_LENGTH, P256_ECDSA_SECRET_KEY_LENGTH, ReallyMeP256Ecdsa, } from "./p256Ecdsa.js";
|
|
31
33
|
export { P384_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P384_ECDH_SECRET_KEY_LENGTH, P384_ECDH_SHARED_SECRET_LENGTH, ReallyMeP384Ecdh, } from "./p384Ecdh.js";
|
|
32
34
|
export { P384_ECDSA_COMPACT_SIGNATURE_LENGTH, P384_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P384_ECDSA_DER_SIGNATURE_MAX_LENGTH, P384_ECDSA_SECRET_KEY_LENGTH, ReallyMeP384Ecdsa, } from "./p384Ecdsa.js";
|
|
33
35
|
export { P521_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P521_ECDH_SECRET_KEY_LENGTH, P521_ECDH_SHARED_SECRET_LENGTH, ReallyMeP521Ecdh, } from "./p521Ecdh.js";
|
|
34
36
|
export { P521_ECDSA_COMPACT_SIGNATURE_LENGTH, P521_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P521_ECDSA_DER_SIGNATURE_MAX_LENGTH, P521_ECDSA_SECRET_KEY_LENGTH, ReallyMeP521Ecdsa, } from "./p521Ecdsa.js";
|
|
35
|
-
export { PBKDF2_MAX_INPUT_LENGTH, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MIN_INPUT_LENGTH, PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512, ReallyMePbkdf2, } from "./pbkdf2.js";
|
|
37
|
+
export { PBKDF2_MAX_INPUT_LENGTH, PBKDF2_MAX_ITERATIONS, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MIN_INPUT_LENGTH, PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512, ReallyMePbkdf2, } from "./pbkdf2.js";
|
|
36
38
|
export { ReallyMeSecp256k1, SECP256K1_COMPRESSED_PUBLIC_KEY_LENGTH, SECP256K1_SECRET_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH, } from "./secp256k1.js";
|
|
37
39
|
export { ReallyMeRsa, RSA_PUBLIC_KEY_DER_MAX_LENGTH, RSA_SIGNATURE_MAX_LENGTH, } from "./rsa.js";
|
|
38
40
|
export type { ReallyMeRsaPublicKeyDerEncoding } from "./rsa.js";
|
|
39
41
|
export { ReallyMeX25519, X25519_PUBLIC_KEY_LENGTH, X25519_SECRET_KEY_LENGTH, X25519_SHARED_SECRET_LENGTH, } from "./x25519.js";
|
|
40
42
|
export { createReallyMeWasmProvider, installReallyMeWasmProvider } from "./wasmProvider.js";
|
|
41
43
|
export type { ReallyMeWasmProvider } from "./wasmProvider.js";
|
|
42
|
-
export { ReallyMeXWing,
|
|
44
|
+
export { ReallyMeXWing, X_WING_768_CIPHERTEXT_LENGTH, X_WING_768_PUBLIC_KEY_LENGTH, X_WING_SECRET_KEY_LENGTH, X_WING_SHARED_SECRET_LENGTH, } from "./xWing.js";
|
|
43
45
|
export type { ReallyMeXWingEncapsulation, ReallyMeXWingKeyPair } from "./xWing.js";
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ export { ReallyMeCryptoError } from "./errors.js";
|
|
|
5
5
|
export { REALLYME_AEAD_ALGORITHMS, REALLYME_HASH_ALGORITHMS, REALLYME_HPKE_SUITES, REALLYME_KDF_ALGORITHMS, REALLYME_KEM_ALGORITHMS, REALLYME_KEY_AGREEMENT_ALGORITHMS, REALLYME_KEY_WRAP_ALGORITHMS, REALLYME_MAC_ALGORITHMS, REALLYME_SIGNATURE_ALGORITHMS, } from "./algorithms.js";
|
|
6
6
|
export { AEAD_KEY_LENGTH, AEAD_NONCE_LENGTH, AEAD_TAG_LENGTH, AES_128_GCM_KEY_LENGTH, AES_192_GCM_KEY_LENGTH, AES_256_GCM_KEY_LENGTH, CHACHA20_POLY1305_KEY_LENGTH, ReallyMeAead, XCHACHA20_POLY1305_NONCE_LENGTH, } from "./aead.js";
|
|
7
7
|
export { AES_256_KW_KEK_LENGTH, AES_KW_BLOCK_LENGTH, AES_KW_INTEGRITY_CHECK_LENGTH, AES_KW_MAX_KEY_DATA_LENGTH, AES_KW_MIN_KEY_DATA_LENGTH, AES_KW_MIN_WRAPPED_KEY_LENGTH, ReallyMeAesKw, } from "./aesKw.js";
|
|
8
|
-
export { ARGON2ID_DERIVED_KEY_LENGTH, ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_V1, ARGON2ID_V2, ReallyMeArgon2id, } from "./argon2id.js";
|
|
8
|
+
export { ARGON2ID_DERIVED_KEY_LENGTH, ARGON2ID_SALT_MAX_LENGTH, ARGON2ID_SALT_MIN_LENGTH, ARGON2ID_SECRET_MAX_LENGTH, ARGON2ID_V1, ARGON2ID_V2, ReallyMeArgon2id, } from "./argon2id.js";
|
|
9
9
|
export { BIP340_SCHNORR_AUX_RAND_LENGTH, BIP340_SCHNORR_MESSAGE_LENGTH, BIP340_SCHNORR_PUBLIC_KEY_LENGTH, BIP340_SCHNORR_SECRET_KEY_LENGTH, BIP340_SCHNORR_SIGNATURE_LENGTH, ReallyMeBip340Schnorr, } from "./bip340Schnorr.js";
|
|
10
|
-
export { HPKE_AEAD_TAG_LENGTH, HPKE_P256_PRIVATE_KEY_LENGTH, HPKE_P256_PUBLIC_KEY_LENGTH, HPKE_X25519_PRIVATE_KEY_LENGTH, HPKE_X25519_PUBLIC_KEY_LENGTH, ReallyMeHpke, } from "./hpke.js";
|
|
10
|
+
export { HPKE_AEAD_TAG_LENGTH, HPKE_INFO_MAX_LENGTH, HPKE_P256_PRIVATE_KEY_LENGTH, HPKE_P256_PUBLIC_KEY_LENGTH, HPKE_X25519_PRIVATE_KEY_LENGTH, HPKE_X25519_PUBLIC_KEY_LENGTH, ReallyMeHpke, } from "./hpke.js";
|
|
11
11
|
export { ReallyMeJwk } from "./jwk.js";
|
|
12
|
-
export { ML_KEM_1024_CIPHERTEXT_LENGTH, ML_KEM_1024_PUBLIC_KEY_LENGTH, ML_KEM_512_CIPHERTEXT_LENGTH, ML_KEM_512_PUBLIC_KEY_LENGTH, ML_KEM_768_CIPHERTEXT_LENGTH, ML_KEM_768_PUBLIC_KEY_LENGTH,
|
|
12
|
+
export { ML_KEM_1024_CIPHERTEXT_LENGTH, ML_KEM_1024_PUBLIC_KEY_LENGTH, ML_KEM_512_CIPHERTEXT_LENGTH, ML_KEM_512_PUBLIC_KEY_LENGTH, ML_KEM_768_CIPHERTEXT_LENGTH, ML_KEM_768_PUBLIC_KEY_LENGTH, ML_KEM_SECRET_KEY_LENGTH, ML_KEM_SHARED_SECRET_LENGTH, ReallyMeMlKem, } from "./mlKem.js";
|
|
13
13
|
export { ML_DSA_44_PUBLIC_KEY_LENGTH, ML_DSA_44_SIGNATURE_LENGTH, ML_DSA_65_PUBLIC_KEY_LENGTH, ML_DSA_65_SIGNATURE_LENGTH, ML_DSA_87_PUBLIC_KEY_LENGTH, ML_DSA_87_SIGNATURE_LENGTH, ML_DSA_SECRET_KEY_LENGTH, ReallyMeMlDsa, } from "./mlDsa.js";
|
|
14
14
|
export { ReallyMeSlhDsa, SLH_DSA_SHA2_128S_KEYGEN_SEED_LENGTH, SLH_DSA_SHA2_128S_PUBLIC_KEY_LENGTH, SLH_DSA_SHA2_128S_SECRET_KEY_LENGTH, SLH_DSA_SHA2_128S_SIGNATURE_LENGTH, } from "./slhDsa.js";
|
|
15
15
|
export { compiledProviders, REALLYME_CRYPTO_PROVIDERS } from "./providerCatalog.js";
|
|
@@ -17,18 +17,20 @@ export { createReallyMeCrypto, ReallyMeCrypto } from "./cryptoFacade.js";
|
|
|
17
17
|
export { ReallyMeDigest } from "./digest.js";
|
|
18
18
|
export { ED25519_PUBLIC_KEY_LENGTH, ED25519_SECRET_KEY_LENGTH, ED25519_SIGNATURE_LENGTH, ReallyMeEd25519, } from "./ed25519.js";
|
|
19
19
|
export { HKDF_MAX_INPUT_LENGTH, HKDF_MAX_OUTPUT_LENGTH, HKDF_MIN_INPUT_KEY_MATERIAL_LENGTH, HKDF_MIN_OUTPUT_LENGTH, ReallyMeHkdf, } from "./hkdf.js";
|
|
20
|
+
export { KMAC256_MAX_CONTEXT_LENGTH, KMAC256_MAX_CUSTOMIZATION_LENGTH, KMAC256_MAX_KEY_LENGTH, KMAC256_MAX_OUTPUT_LENGTH, KMAC256_MIN_KEY_LENGTH, KMAC256_MIN_OUTPUT_LENGTH, ReallyMeKmac, } from "./kmac.js";
|
|
20
21
|
export { JWA_CONCAT_KDF_MAX_INFO_LENGTH, JWA_CONCAT_KDF_MAX_OUTPUT_LENGTH, JWA_CONCAT_KDF_MAX_SHARED_SECRET_LENGTH, JWA_CONCAT_KDF_MIN_OUTPUT_LENGTH, JWA_CONCAT_KDF_SHA256_DIGEST_LENGTH, ReallyMeJwaConcatKdf, } from "./jwaConcatKdf.js";
|
|
21
22
|
export { bestEffortClear } from "./memory.js";
|
|
22
|
-
export {
|
|
23
|
+
export { processOperationResponse, processOperationResponseJson, } from "./operationResponse.js";
|
|
24
|
+
export { HMAC_MAX_KEY_LENGTH, HMAC_SHA256_TAG_LENGTH, HMAC_SHA384_TAG_LENGTH, HMAC_SHA512_TAG_LENGTH, ReallyMeHmac, } from "./hmac.js";
|
|
23
25
|
export { P256_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P256_ECDH_SECRET_KEY_LENGTH, P256_ECDH_SHARED_SECRET_LENGTH, ReallyMeP256Ecdh, } from "./p256Ecdh.js";
|
|
24
26
|
export { P256_ECDSA_COMPACT_SIGNATURE_LENGTH, P256_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P256_ECDSA_DER_SIGNATURE_MAX_LENGTH, P256_ECDSA_SECRET_KEY_LENGTH, ReallyMeP256Ecdsa, } from "./p256Ecdsa.js";
|
|
25
27
|
export { P384_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P384_ECDH_SECRET_KEY_LENGTH, P384_ECDH_SHARED_SECRET_LENGTH, ReallyMeP384Ecdh, } from "./p384Ecdh.js";
|
|
26
28
|
export { P384_ECDSA_COMPACT_SIGNATURE_LENGTH, P384_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P384_ECDSA_DER_SIGNATURE_MAX_LENGTH, P384_ECDSA_SECRET_KEY_LENGTH, ReallyMeP384Ecdsa, } from "./p384Ecdsa.js";
|
|
27
29
|
export { P521_ECDH_COMPRESSED_PUBLIC_KEY_LENGTH, P521_ECDH_SECRET_KEY_LENGTH, P521_ECDH_SHARED_SECRET_LENGTH, ReallyMeP521Ecdh, } from "./p521Ecdh.js";
|
|
28
30
|
export { P521_ECDSA_COMPACT_SIGNATURE_LENGTH, P521_ECDSA_COMPRESSED_PUBLIC_KEY_LENGTH, P521_ECDSA_DER_SIGNATURE_MAX_LENGTH, P521_ECDSA_SECRET_KEY_LENGTH, ReallyMeP521Ecdsa, } from "./p521Ecdsa.js";
|
|
29
|
-
export { PBKDF2_MAX_INPUT_LENGTH, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MIN_INPUT_LENGTH, PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512, ReallyMePbkdf2, } from "./pbkdf2.js";
|
|
31
|
+
export { PBKDF2_MAX_INPUT_LENGTH, PBKDF2_MAX_ITERATIONS, PBKDF2_MAX_OUTPUT_LENGTH, PBKDF2_MIN_INPUT_LENGTH, PBKDF2_MIN_ITERATIONS, PBKDF2_MIN_OUTPUT_LENGTH, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256, PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512, ReallyMePbkdf2, } from "./pbkdf2.js";
|
|
30
32
|
export { ReallyMeSecp256k1, SECP256K1_COMPRESSED_PUBLIC_KEY_LENGTH, SECP256K1_SECRET_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH, } from "./secp256k1.js";
|
|
31
33
|
export { ReallyMeRsa, RSA_PUBLIC_KEY_DER_MAX_LENGTH, RSA_SIGNATURE_MAX_LENGTH, } from "./rsa.js";
|
|
32
34
|
export { ReallyMeX25519, X25519_PUBLIC_KEY_LENGTH, X25519_SECRET_KEY_LENGTH, X25519_SHARED_SECRET_LENGTH, } from "./x25519.js";
|
|
33
35
|
export { createReallyMeWasmProvider, installReallyMeWasmProvider } from "./wasmProvider.js";
|
|
34
|
-
export { ReallyMeXWing,
|
|
36
|
+
export { ReallyMeXWing, X_WING_768_CIPHERTEXT_LENGTH, X_WING_768_PUBLIC_KEY_LENGTH, X_WING_SECRET_KEY_LENGTH, X_WING_SHARED_SECRET_LENGTH, } from "./xWing.js";
|
package/dist/jwk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ReallyMeJwkAlgorithm = "Ed25519" | "X25519" | "P-256" | "secp256k1" | "ML-DSA-44" | "ML-DSA-65" | "ML-DSA-87" | "ML-KEM-512" | "ML-KEM-768" | "ML-KEM-1024" | "SLH-DSA-SHA2-128s" | "X-Wing-768"
|
|
1
|
+
export type ReallyMeJwkAlgorithm = "Ed25519" | "X25519" | "P-256" | "secp256k1" | "ML-DSA-44" | "ML-DSA-65" | "ML-DSA-87" | "ML-KEM-512" | "ML-KEM-768" | "ML-KEM-1024" | "SLH-DSA-SHA2-128s" | "X-Wing-768";
|
|
2
2
|
export type ReallyMeOkpJwk = Readonly<{
|
|
3
3
|
alg: string;
|
|
4
4
|
crv: "Ed25519" | "X25519";
|
|
@@ -32,6 +32,7 @@ export type ReallyMeJwks = Readonly<{
|
|
|
32
32
|
export type ReallyMeJwksKeySet = Readonly<{
|
|
33
33
|
keys: ReadonlyArray<ReallyMeJwkKey>;
|
|
34
34
|
}>;
|
|
35
|
+
export declare const MAX_JWKS_KEYS = 1024;
|
|
35
36
|
export declare const ReallyMeJwk: {
|
|
36
37
|
readonly toJwk: (algorithm: ReallyMeJwkAlgorithm, publicKey: Uint8Array) => ReallyMeJwk;
|
|
37
38
|
readonly fromJwk: (value: unknown) => ReallyMeJwkKey;
|