@sebastienrousseau/crypto-lib 0.0.3 → 0.0.8
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 +304 -314
- package/dist/accel/index.d.ts +11 -0
- package/dist/accel/index.d.ts.map +1 -0
- package/dist/accel/index.js +31 -0
- package/dist/accel/native-pqc-bridge.d.ts +18 -0
- package/dist/accel/native-pqc-bridge.d.ts.map +1 -0
- package/dist/accel/native-pqc-bridge.js +100 -0
- package/dist/accel/wasm-bridge.d.ts +35 -0
- package/dist/accel/wasm-bridge.d.ts.map +1 -0
- package/dist/accel/wasm-bridge.js +161 -0
- package/dist/accel/webcrypto-bridge.d.ts +32 -0
- package/dist/accel/webcrypto-bridge.d.ts.map +1 -0
- package/dist/accel/webcrypto-bridge.js +179 -0
- package/dist/accel/webcrypto-modern.d.ts +40 -0
- package/dist/accel/webcrypto-modern.d.ts.map +1 -0
- package/dist/accel/webcrypto-modern.js +213 -0
- package/dist/accel/worker-pool.d.ts +23 -0
- package/dist/accel/worker-pool.d.ts.map +1 -0
- package/dist/accel/worker-pool.js +119 -0
- package/dist/bin/cryptolib.d.ts +9 -7
- package/dist/bin/cryptolib.d.ts.map +1 -1
- package/dist/bin/cryptolib.js +25 -16
- package/dist/config/config.d.ts.map +1 -1
- package/dist/crypto.d.ts +43 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +107 -0
- package/dist/enums.d.ts +29 -29
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +54 -54
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/high-level/index.d.ts +11 -0
- package/dist/high-level/index.d.ts.map +1 -0
- package/dist/high-level/index.js +53 -0
- package/dist/high-level/key-wrap.d.ts +16 -0
- package/dist/high-level/key-wrap.d.ts.map +1 -0
- package/dist/high-level/key-wrap.js +93 -0
- package/dist/high-level/multi-recipient.d.ts +25 -0
- package/dist/high-level/multi-recipient.d.ts.map +1 -0
- package/dist/high-level/multi-recipient.js +122 -0
- package/dist/high-level/password-encrypt.d.ts +14 -0
- package/dist/high-level/password-encrypt.d.ts.map +1 -0
- package/dist/high-level/password-encrypt.js +93 -0
- package/dist/high-level/sealedbox.d.ts +13 -0
- package/dist/high-level/sealedbox.d.ts.map +1 -0
- package/dist/high-level/sealedbox.js +119 -0
- package/dist/high-level/secretbox.d.ts +7 -0
- package/dist/high-level/secretbox.d.ts.map +1 -0
- package/dist/high-level/secretbox.js +54 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -0
- package/dist/key/key.d.ts +6 -13
- package/dist/key/key.d.ts.map +1 -1
- package/dist/key/key.js +20 -14
- package/dist/key/keystore.d.ts +11 -0
- package/dist/key/keystore.d.ts.map +1 -0
- package/dist/key/keystore.js +87 -0
- package/dist/keys/index.d.ts +7 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +22 -0
- package/dist/keys/keygen.d.ts +16 -0
- package/dist/keys/keygen.d.ts.map +1 -0
- package/dist/keys/keygen.js +128 -0
- package/dist/keys/keyring.d.ts +35 -0
- package/dist/keys/keyring.d.ts.map +1 -0
- package/dist/keys/keyring.js +136 -0
- package/dist/keys/serialize.d.ts +30 -0
- package/dist/keys/serialize.d.ts.map +1 -0
- package/dist/keys/serialize.js +120 -0
- package/dist/lib/decrypt.d.ts +4 -1
- package/dist/lib/decrypt.d.ts.map +1 -1
- package/dist/lib/decrypt.js +43 -51
- package/dist/lib/encrypt.d.ts +1 -1
- package/dist/lib/encrypt.d.ts.map +1 -1
- package/dist/lib/encrypt.js +29 -45
- package/dist/lib/generate.d.ts.map +1 -1
- package/dist/lib/generate.js +56 -63
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +17 -7
- package/dist/lib/key-output.d.ts +7 -0
- package/dist/lib/key-output.d.ts.map +1 -0
- package/dist/lib/key-output.js +50 -0
- package/dist/lib/reformat.d.ts +6 -1
- package/dist/lib/reformat.d.ts.map +1 -1
- package/dist/lib/reformat.js +37 -61
- package/dist/lib/revoke.d.ts +2 -2
- package/dist/lib/revoke.d.ts.map +1 -1
- package/dist/lib/revoke.js +33 -50
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/session.js +21 -36
- package/dist/lib/sign.d.ts.map +1 -1
- package/dist/lib/sign.js +36 -43
- package/dist/lib/verify.d.ts +1 -3
- package/dist/lib/verify.d.ts.map +1 -1
- package/dist/lib/verify.js +25 -30
- package/dist/modern/aead.d.ts +17 -0
- package/dist/modern/aead.d.ts.map +1 -0
- package/dist/modern/aead.js +51 -0
- package/dist/modern/aes.d.ts +35 -0
- package/dist/modern/aes.d.ts.map +1 -0
- package/dist/modern/aes.js +82 -0
- package/dist/modern/cost-limits.d.ts +11 -0
- package/dist/modern/cost-limits.d.ts.map +1 -0
- package/dist/modern/cost-limits.js +35 -0
- package/dist/modern/curves.d.ts +86 -0
- package/dist/modern/curves.d.ts.map +1 -0
- package/dist/modern/curves.js +171 -0
- package/dist/modern/ecdh.d.ts +11 -0
- package/dist/modern/ecdh.d.ts.map +1 -0
- package/dist/modern/ecdh.js +28 -0
- package/dist/modern/fn-dsa.d.ts +19 -0
- package/dist/modern/fn-dsa.d.ts.map +1 -0
- package/dist/modern/fn-dsa.js +57 -0
- package/dist/modern/hash.d.ts +13 -0
- package/dist/modern/hash.d.ts.map +1 -0
- package/dist/modern/hash.js +45 -0
- package/dist/modern/hpke.d.ts +47 -0
- package/dist/modern/hpke.d.ts.map +1 -0
- package/dist/modern/hpke.js +207 -0
- package/dist/modern/index.d.ts +40 -0
- package/dist/modern/index.d.ts.map +1 -0
- package/dist/modern/index.js +194 -0
- package/dist/modern/kdf.d.ts +23 -0
- package/dist/modern/kdf.d.ts.map +1 -0
- package/dist/modern/kdf.js +67 -0
- package/dist/modern/mac.d.ts +51 -0
- package/dist/modern/mac.d.ts.map +1 -0
- package/dist/modern/mac.js +119 -0
- package/dist/modern/password.d.ts +40 -0
- package/dist/modern/password.d.ts.map +1 -0
- package/dist/modern/password.js +123 -0
- package/dist/modern/pq-hash-sign.d.ts +18 -0
- package/dist/modern/pq-hash-sign.d.ts.map +1 -0
- package/dist/modern/pq-hash-sign.js +73 -0
- package/dist/modern/pq-kem.d.ts +88 -0
- package/dist/modern/pq-kem.d.ts.map +1 -0
- package/dist/modern/pq-kem.js +270 -0
- package/dist/modern/pq-sign.d.ts +30 -0
- package/dist/modern/pq-sign.d.ts.map +1 -0
- package/dist/modern/pq-sign.js +94 -0
- package/dist/modern/pq.d.ts +38 -0
- package/dist/modern/pq.d.ts.map +1 -0
- package/dist/modern/pq.js +80 -0
- package/dist/modern/signing.d.ts +16 -0
- package/dist/modern/signing.d.ts.map +1 -0
- package/dist/modern/signing.js +34 -0
- package/dist/protocols/index.d.ts +7 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js +46 -0
- package/dist/protocols/iso20022.d.ts +51 -0
- package/dist/protocols/iso20022.d.ts.map +1 -0
- package/dist/protocols/iso20022.js +145 -0
- package/dist/protocols/opaque/ake.d.ts +51 -0
- package/dist/protocols/opaque/ake.d.ts.map +1 -0
- package/dist/protocols/opaque/ake.js +102 -0
- package/dist/protocols/opaque/client.d.ts +45 -0
- package/dist/protocols/opaque/client.d.ts.map +1 -0
- package/dist/protocols/opaque/client.js +63 -0
- package/dist/protocols/opaque/config.d.ts +14 -0
- package/dist/protocols/opaque/config.d.ts.map +1 -0
- package/dist/protocols/opaque/config.js +18 -0
- package/dist/protocols/opaque/credentials.d.ts +29 -0
- package/dist/protocols/opaque/credentials.d.ts.map +1 -0
- package/dist/protocols/opaque/credentials.js +61 -0
- package/dist/protocols/opaque/envelope.d.ts +36 -0
- package/dist/protocols/opaque/envelope.d.ts.map +1 -0
- package/dist/protocols/opaque/envelope.js +77 -0
- package/dist/protocols/opaque/ksf.d.ts +15 -0
- package/dist/protocols/opaque/ksf.d.ts.map +1 -0
- package/dist/protocols/opaque/ksf.js +27 -0
- package/dist/protocols/opaque/messages.d.ts +61 -0
- package/dist/protocols/opaque/messages.d.ts.map +1 -0
- package/dist/protocols/opaque/messages.js +94 -0
- package/dist/protocols/opaque/server.d.ts +33 -0
- package/dist/protocols/opaque/server.d.ts.map +1 -0
- package/dist/protocols/opaque/server.js +74 -0
- package/dist/protocols/opaque/suite.d.ts +58 -0
- package/dist/protocols/opaque/suite.d.ts.map +1 -0
- package/dist/protocols/opaque/suite.js +115 -0
- package/dist/protocols/pake.d.ts +14 -0
- package/dist/protocols/pake.d.ts.map +1 -0
- package/dist/protocols/pake.js +33 -0
- package/dist/protocols/pqxdh.d.ts +53 -0
- package/dist/protocols/pqxdh.d.ts.map +1 -0
- package/dist/protocols/pqxdh.js +143 -0
- package/dist/protocols/ratchet.d.ts +52 -0
- package/dist/protocols/ratchet.d.ts.map +1 -0
- package/dist/protocols/ratchet.js +187 -0
- package/dist/protocols/threshold.d.ts +23 -0
- package/dist/protocols/threshold.d.ts.map +1 -0
- package/dist/protocols/threshold.js +191 -0
- package/dist/registry.d.ts +20 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +399 -0
- package/dist/streaming/index.d.ts +7 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +15 -0
- package/dist/streaming/stream-aead.d.ts +17 -0
- package/dist/streaming/stream-aead.d.ts.map +1 -0
- package/dist/streaming/stream-aead.js +125 -0
- package/dist/streaming/stream-hash.d.ts +9 -0
- package/dist/streaming/stream-hash.d.ts.map +1 -0
- package/dist/streaming/stream-hash.js +52 -0
- package/dist/streaming/web-streams.d.ts +17 -0
- package/dist/streaming/web-streams.d.ts.map +1 -0
- package/dist/streaming/web-streams.js +114 -0
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +15 -0
- package/dist/tokens/key-rotation.d.ts +20 -0
- package/dist/tokens/key-rotation.d.ts.map +1 -0
- package/dist/tokens/key-rotation.js +76 -0
- package/dist/tokens/paseto.d.ts +46 -0
- package/dist/tokens/paseto.d.ts.map +1 -0
- package/dist/tokens/paseto.js +200 -0
- package/dist/types/types.d.ts +24 -16
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +56 -0
- package/package.json +77 -142
- package/dist/COPYRIGHT +0 -15
- package/dist/Report.txt +0 -160
- package/dist/bin/cryptolib.js.map +0 -1
- package/dist/config/config.js.map +0 -1
- package/dist/data/decrypted.txt +0 -1
- package/dist/data/detached.sig +0 -1
- package/dist/data/encrypted.txt +0 -1
- package/dist/data/signed.sig +0 -1
- package/dist/enums.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/key/key.js.map +0 -1
- package/dist/key/rsa-reformat.cert +0 -1
- package/dist/key/rsa-reformat.key +0 -1
- package/dist/key/rsa-reformat.pub +0 -1
- package/dist/key/rsa-revoke.key +0 -1
- package/dist/key/rsa-revoke.pub +0 -1
- package/dist/key/rsa.cert +0 -1
- package/dist/key/rsa.key +0 -1
- package/dist/key/rsa.pub +0 -1
- package/dist/lib/decrypt.js.map +0 -1
- package/dist/lib/encrypt.js.map +0 -1
- package/dist/lib/generate.js.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/reformat.js.map +0 -1
- package/dist/lib/revoke.js.map +0 -1
- package/dist/lib/session.js.map +0 -1
- package/dist/lib/sign.js.map +0 -1
- package/dist/lib/verify.js.map +0 -1
- package/dist/package.json +0 -143
- package/dist/types/types.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRegistrationRequestWith = createRegistrationRequestWith;
|
|
4
|
+
exports.createRegistrationRequest = createRegistrationRequest;
|
|
5
|
+
exports.finalizeRegistrationRequestWith = finalizeRegistrationRequestWith;
|
|
6
|
+
exports.finalizeRegistrationRequest = finalizeRegistrationRequest;
|
|
7
|
+
exports.generateKE1With = generateKE1With;
|
|
8
|
+
exports.generateKE1 = generateKE1;
|
|
9
|
+
exports.generateKE3 = generateKE3;
|
|
10
|
+
const utils_js_1 = require("@noble/hashes/utils.js");
|
|
11
|
+
const ake_1 = require("./ake");
|
|
12
|
+
const config_1 = require("./config");
|
|
13
|
+
const credentials_1 = require("./credentials");
|
|
14
|
+
const envelope_1 = require("./envelope");
|
|
15
|
+
const messages_1 = require("./messages");
|
|
16
|
+
const suite_1 = require("./suite");
|
|
17
|
+
function createRegistrationRequestWith(password, config, blind) {
|
|
18
|
+
const { s } = (0, config_1.resolveConfig)(config);
|
|
19
|
+
const r = (0, credentials_1.blindPassword)(s, (0, suite_1.toBytes)(password), blind);
|
|
20
|
+
return { request: { blindedMessage: r.blindedMessage }, blind: r.blind };
|
|
21
|
+
}
|
|
22
|
+
function createRegistrationRequest(password, config = {}) {
|
|
23
|
+
return createRegistrationRequestWith(password, config);
|
|
24
|
+
}
|
|
25
|
+
function finalizeRegistrationRequestWith(password, blind, response, identities, config, envelopeNonce = (0, utils_js_1.randomBytes)(suite_1.Nn)) {
|
|
26
|
+
const { s, ksf } = (0, config_1.resolveConfig)(config);
|
|
27
|
+
const res = (0, messages_1.deserializeRegistrationResponse)((0, messages_1.serializeRegistrationResponse)(response), s.id);
|
|
28
|
+
const { randomizedPassword } = (0, credentials_1.finalizeOprf)(s, ksf, (0, suite_1.toBytes)(password), blind, res.evaluatedMessage);
|
|
29
|
+
const stored = (0, envelope_1.store)(s, randomizedPassword, res.serverPublicKey, identities, envelopeNonce);
|
|
30
|
+
const { clientPublicKey, maskingKey, envelope } = stored;
|
|
31
|
+
return {
|
|
32
|
+
record: { clientPublicKey, maskingKey, envelope },
|
|
33
|
+
exportKey: stored.exportKey,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function finalizeRegistrationRequest(password, blind, response, identities = {}, config = {}) {
|
|
37
|
+
return finalizeRegistrationRequestWith(password, blind, response, identities, config);
|
|
38
|
+
}
|
|
39
|
+
function generateKE1With(password, config, r) {
|
|
40
|
+
const { s } = (0, config_1.resolveConfig)(config);
|
|
41
|
+
const pw = (0, suite_1.toBytes)(password);
|
|
42
|
+
const blinded = (0, credentials_1.blindPassword)(s, pw, r.blind);
|
|
43
|
+
const ake = (0, ake_1.authClientStart)(s, { blindedMessage: blinded.blindedMessage }, r.clientNonce ?? (0, utils_js_1.randomBytes)(suite_1.Nn), r.clientKeyshareSeed ?? (0, utils_js_1.randomBytes)(suite_1.Nseed));
|
|
44
|
+
const state = {
|
|
45
|
+
config,
|
|
46
|
+
password: pw,
|
|
47
|
+
blind: blinded.blind,
|
|
48
|
+
clientSecret: ake.clientSecret,
|
|
49
|
+
ke1: ake.ke1,
|
|
50
|
+
};
|
|
51
|
+
return { ke1: ake.ke1, state };
|
|
52
|
+
}
|
|
53
|
+
function generateKE1(password, config = {}) {
|
|
54
|
+
return generateKE1With(password, config, {});
|
|
55
|
+
}
|
|
56
|
+
function generateKE3(state, ke2, identities = {}) {
|
|
57
|
+
const { s, ksf, context } = (0, config_1.resolveConfig)(state.config);
|
|
58
|
+
const k = (0, messages_1.deserializeKE2)((0, messages_1.serializeKE2)(ke2), s.id);
|
|
59
|
+
const recovered = (0, credentials_1.recoverCredentials)(s, ksf, state.password, state.blind, k.credentialResponse, identities);
|
|
60
|
+
const { ke3, sessionKey } = (0, ake_1.authClientFinalize)(s, context, recovered.cleartextCredentials, recovered.clientPrivateKey, state, k);
|
|
61
|
+
return { ke3, sessionKey, exportKey: recovered.exportKey };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Ksf } from "./ksf";
|
|
2
|
+
import type { Suite, SuiteId } from "./suite";
|
|
3
|
+
export interface OpaqueConfig {
|
|
4
|
+
suite?: SuiteId;
|
|
5
|
+
ksf?: Ksf;
|
|
6
|
+
context?: Uint8Array | string;
|
|
7
|
+
}
|
|
8
|
+
export interface ResolvedConfig {
|
|
9
|
+
s: Suite;
|
|
10
|
+
ksf: Ksf;
|
|
11
|
+
context: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveConfig(config: OpaqueConfig): ResolvedConfig;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG9C,MAAM,WAAW,YAAY;IAE3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAKhB,GAAG,CAAC,EAAE,GAAG,CAAC;IAMV,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAC/B;AAGD,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,KAAK,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,UAAU,CAAC;CACrB;AAGD,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAalE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfig = resolveConfig;
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
|
+
const ksf_1 = require("./ksf");
|
|
6
|
+
const suite_1 = require("./suite");
|
|
7
|
+
function resolveConfig(config) {
|
|
8
|
+
const context = (0, suite_1.toBytes)(config.context ?? new Uint8Array(0));
|
|
9
|
+
if (context.length > 0xffff) {
|
|
10
|
+
throw new errors_1.CryptoError("OPAQUE context must be at most 65535 bytes", suite_1.OpaqueErrorCode.INVALID_INPUT);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
s: (0, suite_1.getSuite)(config.suite ?? "P256-SHA256"),
|
|
14
|
+
ksf: config.ksf ?? ksf_1.DEFAULT_KSF,
|
|
15
|
+
context,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Ksf } from "./ksf";
|
|
2
|
+
import type { Identities } from "./envelope";
|
|
3
|
+
import type { CredentialRequest, CredentialResponse, RegistrationRecord } from "./messages";
|
|
4
|
+
import type { Suite } from "./suite";
|
|
5
|
+
export declare function deriveOprfKey(s: Suite, oprfSeed: Uint8Array, credentialIdentifier: Uint8Array | string): Uint8Array;
|
|
6
|
+
export declare function blindPassword(s: Suite, password: Uint8Array, blind?: Uint8Array): {
|
|
7
|
+
blind: Uint8Array;
|
|
8
|
+
blindedMessage: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export declare function evaluateOprf(s: Suite, oprfSeed: Uint8Array, credentialIdentifier: Uint8Array | string, blindedMessage: Uint8Array): Uint8Array;
|
|
11
|
+
export declare function finalizeOprf(s: Suite, ksf: Ksf, password: Uint8Array, blind: Uint8Array, evaluatedMessage: Uint8Array): {
|
|
12
|
+
oprfOutput: import("@noble/curves/abstract/oprf").Bytes & Uint8Array<ArrayBuffer>;
|
|
13
|
+
randomizedPassword: Uint8Array<ArrayBufferLike>;
|
|
14
|
+
};
|
|
15
|
+
export interface CredentialResponseInput {
|
|
16
|
+
request: CredentialRequest;
|
|
17
|
+
serverPublicKey: Uint8Array;
|
|
18
|
+
record: RegistrationRecord;
|
|
19
|
+
credentialIdentifier: Uint8Array | string;
|
|
20
|
+
oprfSeed: Uint8Array;
|
|
21
|
+
maskingNonce: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export declare function createCredentialResponse(s: Suite, input: CredentialResponseInput): CredentialResponse;
|
|
24
|
+
export declare function recoverCredentials(s: Suite, ksf: Ksf, password: Uint8Array, blind: Uint8Array, response: CredentialResponse, ids: Identities): {
|
|
25
|
+
clientPrivateKey: import("@noble/curves/abstract/oprf").ScalarBytes & Uint8Array<ArrayBuffer>;
|
|
26
|
+
cleartextCredentials: import("./envelope").CleartextCredentials;
|
|
27
|
+
exportKey: Uint8Array<ArrayBufferLike>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/credentials.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAOrC,wBAAgB,aAAa,CAC3B,CAAC,EAAE,KAAK,EACR,QAAQ,EAAE,UAAU,EACpB,oBAAoB,EAAE,UAAU,GAAG,MAAM,GACxC,UAAU,CAIZ;AAOD,wBAAgB,aAAa,CAC3B,CAAC,EAAE,KAAK,EACR,QAAQ,EAAE,UAAU,EACpB,KAAK,CAAC,EAAE,UAAU,GACjB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,cAAc,EAAE,UAAU,CAAA;CAAE,CAMnD;AAOD,wBAAgB,YAAY,CAC1B,CAAC,EAAE,KAAK,EACR,QAAQ,EAAE,UAAU,EACpB,oBAAoB,EAAE,UAAU,GAAG,MAAM,EACzC,cAAc,EAAE,UAAU,GACzB,UAAU,CAGZ;AAGD,wBAAgB,YAAY,CAC1B,CAAC,EAAE,KAAK,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,UAAU,EACjB,gBAAgB,EAAE,UAAU;;;EAO7B;AASD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,eAAe,EAAE,UAAU,CAAC;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,oBAAoB,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1C,QAAQ,EAAE,UAAU,CAAC;IACrB,YAAY,EAAE,UAAU,CAAC;CAC1B;AAOD,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,KAAK,EACR,KAAK,EAAE,uBAAuB,GAC7B,kBAAkB,CAiBpB;AAGD,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,KAAK,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,EAAE,UAAU;;;;EAkBhB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveOprfKey = deriveOprfKey;
|
|
4
|
+
exports.blindPassword = blindPassword;
|
|
5
|
+
exports.evaluateOprf = evaluateOprf;
|
|
6
|
+
exports.finalizeOprf = finalizeOprf;
|
|
7
|
+
exports.createCredentialResponse = createCredentialResponse;
|
|
8
|
+
exports.recoverCredentials = recoverCredentials;
|
|
9
|
+
const envelope_1 = require("./envelope");
|
|
10
|
+
const messages_1 = require("./messages");
|
|
11
|
+
const suite_1 = require("./suite");
|
|
12
|
+
function deriveOprfKey(s, oprfSeed, credentialIdentifier) {
|
|
13
|
+
const info = (0, suite_1.concat)((0, suite_1.toBytes)(credentialIdentifier), (0, suite_1.utf8)("OprfKey"));
|
|
14
|
+
const seed = (0, suite_1.kdfExpand)(s, oprfSeed, info, s.Nok);
|
|
15
|
+
return s.oprf.deriveKeyPair(seed, (0, suite_1.utf8)("OPAQUE-DeriveKeyPair")).secretKey;
|
|
16
|
+
}
|
|
17
|
+
function blindPassword(s, password, blind) {
|
|
18
|
+
if (blind !== undefined) {
|
|
19
|
+
return { blind, blindedMessage: (0, suite_1.blindWith)(s, password, blind) };
|
|
20
|
+
}
|
|
21
|
+
const r = s.oprf.blind(password);
|
|
22
|
+
return { blind: r.blind, blindedMessage: r.blinded };
|
|
23
|
+
}
|
|
24
|
+
function evaluateOprf(s, oprfSeed, credentialIdentifier, blindedMessage) {
|
|
25
|
+
const key = deriveOprfKey(s, oprfSeed, credentialIdentifier);
|
|
26
|
+
return s.oprf.blindEvaluate(key, blindedMessage);
|
|
27
|
+
}
|
|
28
|
+
function finalizeOprf(s, ksf, password, blind, evaluatedMessage) {
|
|
29
|
+
const oprfOutput = s.oprf.finalize(password, blind, evaluatedMessage);
|
|
30
|
+
return {
|
|
31
|
+
oprfOutput,
|
|
32
|
+
randomizedPassword: (0, envelope_1.randomizePassword)(s, ksf, oprfOutput),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function responsePad(s, maskingKey, nonce) {
|
|
36
|
+
const info = (0, suite_1.concat)(nonce, (0, suite_1.utf8)("CredentialResponsePad"));
|
|
37
|
+
return (0, suite_1.kdfExpand)(s, maskingKey, info, (0, messages_1.maskedResponseLength)(s));
|
|
38
|
+
}
|
|
39
|
+
function createCredentialResponse(s, input) {
|
|
40
|
+
const evaluatedMessage = evaluateOprf(s, input.oprfSeed, input.credentialIdentifier, input.request.blindedMessage);
|
|
41
|
+
const pad = responsePad(s, input.record.maskingKey, input.maskingNonce);
|
|
42
|
+
const plain = (0, suite_1.concat)(input.serverPublicKey, (0, messages_1.serializeEnvelope)(input.record.envelope));
|
|
43
|
+
return {
|
|
44
|
+
evaluatedMessage,
|
|
45
|
+
maskingNonce: input.maskingNonce.slice(),
|
|
46
|
+
maskedResponse: (0, suite_1.xor)(pad, plain),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function recoverCredentials(s, ksf, password, blind, response, ids) {
|
|
50
|
+
const { randomizedPassword } = finalizeOprf(s, ksf, password, blind, response.evaluatedMessage);
|
|
51
|
+
const maskingKey = (0, envelope_1.maskingKeyFor)(s, randomizedPassword);
|
|
52
|
+
const pad = responsePad(s, maskingKey, response.maskingNonce);
|
|
53
|
+
const plain = (0, suite_1.xor)(pad, response.maskedResponse);
|
|
54
|
+
const serverPublicKey = plain.slice(0, s.Npk);
|
|
55
|
+
const envelope = {
|
|
56
|
+
nonce: plain.slice(s.Npk, s.Npk + suite_1.Nn),
|
|
57
|
+
authTag: plain.slice(s.Npk + suite_1.Nn),
|
|
58
|
+
};
|
|
59
|
+
return (0, envelope_1.recover)(s, randomizedPassword, serverPublicKey, envelope, ids);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Ksf } from "./ksf";
|
|
2
|
+
import type { Envelope } from "./messages";
|
|
3
|
+
import type { Suite } from "./suite";
|
|
4
|
+
export interface Identities {
|
|
5
|
+
clientIdentity?: Uint8Array | string;
|
|
6
|
+
serverIdentity?: Uint8Array | string;
|
|
7
|
+
}
|
|
8
|
+
export interface CleartextCredentials {
|
|
9
|
+
serverPublicKey: Uint8Array;
|
|
10
|
+
serverIdentity: Uint8Array;
|
|
11
|
+
clientIdentity: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
export declare function createCleartextCredentials(serverPublicKey: Uint8Array, clientPublicKey: Uint8Array, ids: Identities): CleartextCredentials;
|
|
14
|
+
export declare function serializeCleartextCredentials(cc: CleartextCredentials): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
|
|
15
|
+
export declare function randomizePassword(s: Suite, ksf: Ksf, oprfOutput: Uint8Array): Uint8Array;
|
|
16
|
+
export declare function maskingKeyFor(s: Suite, randomizedPassword: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
17
|
+
export declare function envelopeKeys(s: Suite, randomizedPassword: Uint8Array, nonce: Uint8Array): {
|
|
18
|
+
authKey: Uint8Array<ArrayBufferLike>;
|
|
19
|
+
exportKey: Uint8Array<ArrayBufferLike>;
|
|
20
|
+
keyPair: {
|
|
21
|
+
privateKey: import("@noble/curves/abstract/oprf").ScalarBytes & Uint8Array<ArrayBuffer>;
|
|
22
|
+
publicKey: import("@noble/curves/abstract/oprf").PointBytes & Uint8Array<ArrayBuffer>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function store(s: Suite, randomizedPassword: Uint8Array, serverPublicKey: Uint8Array, ids: Identities, nonce: Uint8Array): {
|
|
26
|
+
envelope: Envelope;
|
|
27
|
+
clientPublicKey: import("@noble/curves/abstract/oprf").PointBytes & Uint8Array<ArrayBuffer>;
|
|
28
|
+
maskingKey: Uint8Array<ArrayBufferLike>;
|
|
29
|
+
exportKey: Uint8Array<ArrayBufferLike>;
|
|
30
|
+
};
|
|
31
|
+
export declare function recover(s: Suite, randomizedPassword: Uint8Array, serverPublicKey: Uint8Array, envelope: Envelope, ids: Identities): {
|
|
32
|
+
clientPrivateKey: import("@noble/curves/abstract/oprf").ScalarBytes & Uint8Array<ArrayBuffer>;
|
|
33
|
+
cleartextCredentials: CleartextCredentials;
|
|
34
|
+
exportKey: Uint8Array<ArrayBufferLike>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/envelope.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,WAAW,UAAU;IAEzB,cAAc,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAErC,cAAc,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC;AAGD,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,UAAU,CAAC;IAC5B,cAAc,EAAE,UAAU,CAAC;IAC3B,cAAc,EAAE,UAAU,CAAC;CAC5B;AAmBD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,UAAU,EAC3B,eAAe,EAAE,UAAU,EAC3B,GAAG,EAAE,UAAU,GACd,oBAAoB,CAMtB;AAGD,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,oBAAoB,yDAQrE;AAOD,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE,KAAK,EACR,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,GACrB,UAAU,CAGZ;AAGD,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,+BAErE;AAGD,wBAAgB,YAAY,CAC1B,CAAC,EAAE,KAAK,EACR,kBAAkB,EAAE,UAAU,EAC9B,KAAK,EAAE,UAAU;;;;;;;EASlB;AAaD,wBAAgB,KAAK,CACnB,CAAC,EAAE,KAAK,EACR,kBAAkB,EAAE,UAAU,EAC9B,eAAe,EAAE,UAAU,EAC3B,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,UAAU;;;;;EAsBlB;AAOD,wBAAgB,OAAO,CACrB,CAAC,EAAE,KAAK,EACR,kBAAkB,EAAE,UAAU,EAC9B,eAAe,EAAE,UAAU,EAC3B,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,UAAU;;;;EAwBhB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCleartextCredentials = createCleartextCredentials;
|
|
4
|
+
exports.serializeCleartextCredentials = serializeCleartextCredentials;
|
|
5
|
+
exports.randomizePassword = randomizePassword;
|
|
6
|
+
exports.maskingKeyFor = maskingKeyFor;
|
|
7
|
+
exports.envelopeKeys = envelopeKeys;
|
|
8
|
+
exports.store = store;
|
|
9
|
+
exports.recover = recover;
|
|
10
|
+
const errors_1 = require("../../errors");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const suite_1 = require("./suite");
|
|
13
|
+
function identityOr(value, fallback) {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
return fallback;
|
|
16
|
+
const bytes = (0, suite_1.toBytes)(value);
|
|
17
|
+
if (bytes.length < 1 || bytes.length > 0xffff) {
|
|
18
|
+
throw new errors_1.CryptoError("OPAQUE identities must be 1 to 65535 bytes", suite_1.OpaqueErrorCode.INVALID_INPUT);
|
|
19
|
+
}
|
|
20
|
+
return bytes;
|
|
21
|
+
}
|
|
22
|
+
function createCleartextCredentials(serverPublicKey, clientPublicKey, ids) {
|
|
23
|
+
return {
|
|
24
|
+
serverPublicKey,
|
|
25
|
+
serverIdentity: identityOr(ids.serverIdentity, serverPublicKey),
|
|
26
|
+
clientIdentity: identityOr(ids.clientIdentity, clientPublicKey),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function serializeCleartextCredentials(cc) {
|
|
30
|
+
return (0, suite_1.concat)(cc.serverPublicKey, (0, suite_1.i2osp)(cc.serverIdentity.length, 2), cc.serverIdentity, (0, suite_1.i2osp)(cc.clientIdentity.length, 2), cc.clientIdentity);
|
|
31
|
+
}
|
|
32
|
+
function randomizePassword(s, ksf, oprfOutput) {
|
|
33
|
+
const stretched = ksf.stretch(oprfOutput);
|
|
34
|
+
return (0, suite_1.kdfExtract)(s, new Uint8Array(0), (0, suite_1.concat)(oprfOutput, stretched));
|
|
35
|
+
}
|
|
36
|
+
function maskingKeyFor(s, randomizedPassword) {
|
|
37
|
+
return (0, suite_1.kdfExpand)(s, randomizedPassword, (0, suite_1.utf8)("MaskingKey"), s.Nh);
|
|
38
|
+
}
|
|
39
|
+
function envelopeKeys(s, randomizedPassword, nonce) {
|
|
40
|
+
const derive = (label, length) => (0, suite_1.kdfExpand)(s, randomizedPassword, (0, suite_1.concat)(nonce, (0, suite_1.utf8)(label)), length);
|
|
41
|
+
return {
|
|
42
|
+
authKey: derive("AuthKey", s.Nh),
|
|
43
|
+
exportKey: derive("ExportKey", s.Nh),
|
|
44
|
+
keyPair: (0, suite_1.deriveDiffieHellmanKeyPair)(s, derive("PrivateKey", suite_1.Nseed)),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function authTag(s, authKey, nonce, cc) {
|
|
48
|
+
return (0, suite_1.mac)(s, authKey, (0, suite_1.concat)(nonce, serializeCleartextCredentials(cc)));
|
|
49
|
+
}
|
|
50
|
+
function store(s, randomizedPassword, serverPublicKey, ids, nonce) {
|
|
51
|
+
const { authKey, exportKey, keyPair } = envelopeKeys(s, randomizedPassword, nonce);
|
|
52
|
+
const cc = createCleartextCredentials(serverPublicKey, keyPair.publicKey, ids);
|
|
53
|
+
const envelope = {
|
|
54
|
+
nonce: nonce.slice(),
|
|
55
|
+
authTag: authTag(s, authKey, nonce, cc),
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
envelope,
|
|
59
|
+
clientPublicKey: keyPair.publicKey,
|
|
60
|
+
maskingKey: maskingKeyFor(s, randomizedPassword),
|
|
61
|
+
exportKey,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function recover(s, randomizedPassword, serverPublicKey, envelope, ids) {
|
|
65
|
+
const { authKey, exportKey, keyPair } = envelopeKeys(s, randomizedPassword, envelope.nonce);
|
|
66
|
+
const cc = createCleartextCredentials(serverPublicKey, keyPair.publicKey, ids);
|
|
67
|
+
const expected = authTag(s, authKey, envelope.nonce, cc);
|
|
68
|
+
if (!(0, utils_1.timingSafeEqual)(envelope.authTag, expected)) {
|
|
69
|
+
throw new errors_1.CryptoError("OPAQUE envelope recovery failed: wrong password or invalid response", suite_1.OpaqueErrorCode.ENVELOPE_RECOVERY);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
clientPrivateKey: keyPair.privateKey,
|
|
73
|
+
cleartextCredentials: cc,
|
|
74
|
+
exportKey,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Ksf {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
stretch(msg: Uint8Array): Uint8Array;
|
|
4
|
+
}
|
|
5
|
+
export interface ScryptKsfParams {
|
|
6
|
+
N: number;
|
|
7
|
+
r: number;
|
|
8
|
+
p: number;
|
|
9
|
+
dkLen: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const RFC9807_SCRYPT_PARAMS: Readonly<ScryptKsfParams>;
|
|
12
|
+
export declare function scryptKsf(params?: Partial<ScryptKsfParams>): Ksf;
|
|
13
|
+
export declare const identityKsf: Ksf;
|
|
14
|
+
export declare const DEFAULT_KSF: Ksf;
|
|
15
|
+
//# sourceMappingURL=ksf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ksf.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/ksf.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,GAAG;IAElB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AAGD,MAAM,WAAW,eAAe;IAE9B,CAAC,EAAE,MAAM,CAAC;IAEV,CAAC,EAAE,MAAM,CAAC;IAEV,CAAC,EAAE,MAAM,CAAC;IAEV,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,eAAe,CAK1D,CAAC;AASH,wBAAgB,SAAS,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,GAAG,CAQpE;AAQD,eAAO,MAAM,WAAW,EAAE,GAGxB,CAAC;AAGH,eAAO,MAAM,WAAW,EAAE,GAAiB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_KSF = exports.identityKsf = exports.RFC9807_SCRYPT_PARAMS = void 0;
|
|
4
|
+
exports.scryptKsf = scryptKsf;
|
|
5
|
+
const scrypt_js_1 = require("@noble/hashes/scrypt.js");
|
|
6
|
+
const cost_limits_1 = require("../../modern/cost-limits");
|
|
7
|
+
exports.RFC9807_SCRYPT_PARAMS = Object.freeze({
|
|
8
|
+
N: 32768,
|
|
9
|
+
r: 8,
|
|
10
|
+
p: 1,
|
|
11
|
+
dkLen: 32,
|
|
12
|
+
});
|
|
13
|
+
function scryptKsf(params = {}) {
|
|
14
|
+
const { N, r, p, dkLen } = { ...exports.RFC9807_SCRYPT_PARAMS, ...params };
|
|
15
|
+
(0, cost_limits_1.checkScryptCosts)(N, r, p);
|
|
16
|
+
const salt = new Uint8Array(16);
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
name: `scrypt(N=${N},r=${r},p=${p},dkLen=${dkLen})`,
|
|
19
|
+
stretch: (msg) => (0, scrypt_js_1.scrypt)(msg, salt, { N, r, p, dkLen }),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.identityKsf = Object.freeze({
|
|
23
|
+
name: "Identity",
|
|
24
|
+
stretch: (msg) => msg.slice(),
|
|
25
|
+
});
|
|
26
|
+
exports.DEFAULT_KSF = scryptKsf();
|
|
27
|
+
//# sourceMappingURL=ksf.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Suite, SuiteId } from "./suite";
|
|
2
|
+
export interface RegistrationRequest {
|
|
3
|
+
blindedMessage: Uint8Array;
|
|
4
|
+
}
|
|
5
|
+
export interface RegistrationResponse {
|
|
6
|
+
evaluatedMessage: Uint8Array;
|
|
7
|
+
serverPublicKey: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
export interface Envelope {
|
|
10
|
+
nonce: Uint8Array;
|
|
11
|
+
authTag: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
export interface RegistrationRecord {
|
|
14
|
+
clientPublicKey: Uint8Array;
|
|
15
|
+
maskingKey: Uint8Array;
|
|
16
|
+
envelope: Envelope;
|
|
17
|
+
}
|
|
18
|
+
export interface CredentialRequest {
|
|
19
|
+
blindedMessage: Uint8Array;
|
|
20
|
+
}
|
|
21
|
+
export interface CredentialResponse {
|
|
22
|
+
evaluatedMessage: Uint8Array;
|
|
23
|
+
maskingNonce: Uint8Array;
|
|
24
|
+
maskedResponse: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
export interface AuthRequest {
|
|
27
|
+
clientNonce: Uint8Array;
|
|
28
|
+
clientPublicKeyshare: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
export interface KE1 {
|
|
31
|
+
credentialRequest: CredentialRequest;
|
|
32
|
+
authRequest: AuthRequest;
|
|
33
|
+
}
|
|
34
|
+
export interface AuthResponse {
|
|
35
|
+
serverNonce: Uint8Array;
|
|
36
|
+
serverPublicKeyshare: Uint8Array;
|
|
37
|
+
serverMac: Uint8Array;
|
|
38
|
+
}
|
|
39
|
+
export interface KE2 {
|
|
40
|
+
credentialResponse: CredentialResponse;
|
|
41
|
+
authResponse: AuthResponse;
|
|
42
|
+
}
|
|
43
|
+
export interface KE3 {
|
|
44
|
+
clientMac: Uint8Array;
|
|
45
|
+
}
|
|
46
|
+
export declare function maskedResponseLength(s: Suite): number;
|
|
47
|
+
export declare function serializeEnvelope(e: Envelope): Uint8Array;
|
|
48
|
+
export declare function serializeCredentialResponse(r: CredentialResponse): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
|
|
49
|
+
export declare function serializeRegistrationRequest(m: RegistrationRequest): Uint8Array<ArrayBuffer>;
|
|
50
|
+
export declare function deserializeRegistrationRequest(bytes: Uint8Array, suite?: SuiteId): RegistrationRequest;
|
|
51
|
+
export declare function serializeRegistrationResponse(m: RegistrationResponse): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
|
|
52
|
+
export declare function deserializeRegistrationResponse(bytes: Uint8Array, suite?: SuiteId): RegistrationResponse;
|
|
53
|
+
export declare function serializeRegistrationRecord(m: RegistrationRecord): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
|
|
54
|
+
export declare function deserializeRegistrationRecord(bytes: Uint8Array, suite?: SuiteId): RegistrationRecord;
|
|
55
|
+
export declare function serializeKE1(m: KE1): Uint8Array;
|
|
56
|
+
export declare function deserializeKE1(bytes: Uint8Array, suite?: SuiteId): KE1;
|
|
57
|
+
export declare function serializeKE2(m: KE2): Uint8Array;
|
|
58
|
+
export declare function deserializeKE2(bytes: Uint8Array, suite?: SuiteId): KE2;
|
|
59
|
+
export declare function serializeKE3(m: KE3): Uint8Array;
|
|
60
|
+
export declare function deserializeKE3(bytes: Uint8Array, suite?: SuiteId): KE3;
|
|
61
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/messages.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG9C,MAAM,WAAW,mBAAmB;IAElC,cAAc,EAAE,UAAU,CAAC;CAC5B;AAGD,MAAM,WAAW,oBAAoB;IAEnC,gBAAgB,EAAE,UAAU,CAAC;IAE7B,eAAe,EAAE,UAAU,CAAC;CAC7B;AAGD,MAAM,WAAW,QAAQ;IAEvB,KAAK,EAAE,UAAU,CAAC;IAElB,OAAO,EAAE,UAAU,CAAC;CACrB;AAQD,MAAM,WAAW,kBAAkB;IAEjC,eAAe,EAAE,UAAU,CAAC;IAE5B,UAAU,EAAE,UAAU,CAAC;IAEvB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAGD,MAAM,WAAW,iBAAiB;IAEhC,cAAc,EAAE,UAAU,CAAC;CAC5B;AAGD,MAAM,WAAW,kBAAkB;IAEjC,gBAAgB,EAAE,UAAU,CAAC;IAE7B,YAAY,EAAE,UAAU,CAAC;IAEzB,cAAc,EAAE,UAAU,CAAC;CAC5B;AAGD,MAAM,WAAW,WAAW;IAE1B,WAAW,EAAE,UAAU,CAAC;IAExB,oBAAoB,EAAE,UAAU,CAAC;CAClC;AAGD,MAAM,WAAW,GAAG;IAElB,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAGD,MAAM,WAAW,YAAY;IAE3B,WAAW,EAAE,UAAU,CAAC;IAExB,oBAAoB,EAAE,UAAU,CAAC;IAEjC,SAAS,EAAE,UAAU,CAAC;CACvB;AAGD,MAAM,WAAW,GAAG;IAElB,kBAAkB,EAAE,kBAAkB,CAAC;IAEvC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAGD,MAAM,WAAW,GAAG;IAElB,SAAS,EAAE,UAAU,CAAC;CACvB;AAgBD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,CAErD;AAGD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,GAAG,UAAU,CAEzD;AAGD,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,kBAAkB,yDAEhE;AAGD,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,mBAAmB,2BAElE;AAGD,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,mBAAmB,CAOrB;AAGD,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,oBAAoB,yDAEpE;AAMD,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,oBAAoB,CAStB;AAGD,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,kBAAkB,yDAEhE;AAMD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,kBAAkB,CASpB;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,UAAU,CAM/C;AAGD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,GAAG,CAWL;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,UAAU,CAQ/C;AAGD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,GAAG,CAiBL;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,GAAG,UAAU,CAE/C;AAGD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,KAAK,GAAE,OAAuB,GAC7B,GAAG,CAGL"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maskedResponseLength = maskedResponseLength;
|
|
4
|
+
exports.serializeEnvelope = serializeEnvelope;
|
|
5
|
+
exports.serializeCredentialResponse = serializeCredentialResponse;
|
|
6
|
+
exports.serializeRegistrationRequest = serializeRegistrationRequest;
|
|
7
|
+
exports.deserializeRegistrationRequest = deserializeRegistrationRequest;
|
|
8
|
+
exports.serializeRegistrationResponse = serializeRegistrationResponse;
|
|
9
|
+
exports.deserializeRegistrationResponse = deserializeRegistrationResponse;
|
|
10
|
+
exports.serializeRegistrationRecord = serializeRegistrationRecord;
|
|
11
|
+
exports.deserializeRegistrationRecord = deserializeRegistrationRecord;
|
|
12
|
+
exports.serializeKE1 = serializeKE1;
|
|
13
|
+
exports.deserializeKE1 = deserializeKE1;
|
|
14
|
+
exports.serializeKE2 = serializeKE2;
|
|
15
|
+
exports.deserializeKE2 = deserializeKE2;
|
|
16
|
+
exports.serializeKE3 = serializeKE3;
|
|
17
|
+
exports.deserializeKE3 = deserializeKE3;
|
|
18
|
+
const errors_1 = require("../../errors");
|
|
19
|
+
const suite_1 = require("./suite");
|
|
20
|
+
function split(bytes, lengths, label) {
|
|
21
|
+
const total = lengths.reduce((a, b) => a + b, 0);
|
|
22
|
+
if (!(bytes instanceof Uint8Array) || bytes.length !== total) {
|
|
23
|
+
throw new errors_1.CryptoError(`Invalid ${label}: expected ${total} bytes`, suite_1.OpaqueErrorCode.DESERIALIZE);
|
|
24
|
+
}
|
|
25
|
+
let offset = 0;
|
|
26
|
+
return lengths.map((len) => bytes.slice(offset, (offset += len)));
|
|
27
|
+
}
|
|
28
|
+
function maskedResponseLength(s) {
|
|
29
|
+
return s.Npk + suite_1.Nn + s.Nh;
|
|
30
|
+
}
|
|
31
|
+
function serializeEnvelope(e) {
|
|
32
|
+
return (0, suite_1.concat)(e.nonce, e.authTag);
|
|
33
|
+
}
|
|
34
|
+
function serializeCredentialResponse(r) {
|
|
35
|
+
return (0, suite_1.concat)(r.evaluatedMessage, r.maskingNonce, r.maskedResponse);
|
|
36
|
+
}
|
|
37
|
+
function serializeRegistrationRequest(m) {
|
|
38
|
+
return m.blindedMessage.slice();
|
|
39
|
+
}
|
|
40
|
+
function deserializeRegistrationRequest(bytes, suite = "P256-SHA256") {
|
|
41
|
+
const [blindedMessage] = split(bytes, [(0, suite_1.getSuite)(suite).Noe], "RegistrationRequest");
|
|
42
|
+
return { blindedMessage };
|
|
43
|
+
}
|
|
44
|
+
function serializeRegistrationResponse(m) {
|
|
45
|
+
return (0, suite_1.concat)(m.evaluatedMessage, m.serverPublicKey);
|
|
46
|
+
}
|
|
47
|
+
function deserializeRegistrationResponse(bytes, suite = "P256-SHA256") {
|
|
48
|
+
const s = (0, suite_1.getSuite)(suite);
|
|
49
|
+
const [evaluatedMessage, serverPublicKey] = split(bytes, [s.Noe, s.Npk], "RegistrationResponse");
|
|
50
|
+
(0, suite_1.decodeElement)(s, serverPublicKey, "server public key");
|
|
51
|
+
return { evaluatedMessage, serverPublicKey };
|
|
52
|
+
}
|
|
53
|
+
function serializeRegistrationRecord(m) {
|
|
54
|
+
return (0, suite_1.concat)(m.clientPublicKey, m.maskingKey, serializeEnvelope(m.envelope));
|
|
55
|
+
}
|
|
56
|
+
function deserializeRegistrationRecord(bytes, suite = "P256-SHA256") {
|
|
57
|
+
const s = (0, suite_1.getSuite)(suite);
|
|
58
|
+
const [clientPublicKey, maskingKey, nonce, authTag] = split(bytes, [s.Npk, s.Nh, suite_1.Nn, s.Nh], "RegistrationRecord");
|
|
59
|
+
(0, suite_1.decodeElement)(s, clientPublicKey, "client public key");
|
|
60
|
+
return { clientPublicKey, maskingKey, envelope: { nonce, authTag } };
|
|
61
|
+
}
|
|
62
|
+
function serializeKE1(m) {
|
|
63
|
+
return (0, suite_1.concat)(m.credentialRequest.blindedMessage, m.authRequest.clientNonce, m.authRequest.clientPublicKeyshare);
|
|
64
|
+
}
|
|
65
|
+
function deserializeKE1(bytes, suite = "P256-SHA256") {
|
|
66
|
+
const s = (0, suite_1.getSuite)(suite);
|
|
67
|
+
const [blindedMessage, clientNonce, clientPublicKeyshare] = split(bytes, [s.Noe, suite_1.Nn, s.Npk], "KE1");
|
|
68
|
+
return {
|
|
69
|
+
credentialRequest: { blindedMessage },
|
|
70
|
+
authRequest: { clientNonce, clientPublicKeyshare },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function serializeKE2(m) {
|
|
74
|
+
const a = m.authResponse;
|
|
75
|
+
return (0, suite_1.concat)(serializeCredentialResponse(m.credentialResponse), a.serverNonce, a.serverPublicKeyshare, a.serverMac);
|
|
76
|
+
}
|
|
77
|
+
function deserializeKE2(bytes, suite = "P256-SHA256") {
|
|
78
|
+
const s = (0, suite_1.getSuite)(suite);
|
|
79
|
+
const lengths = [s.Noe, suite_1.Nn, maskedResponseLength(s), suite_1.Nn, s.Npk, s.Nh];
|
|
80
|
+
const [evaluatedMessage, maskingNonce, maskedResponse, ...auth] = split(bytes, lengths, "KE2");
|
|
81
|
+
const [serverNonce, serverPublicKeyshare, serverMac] = auth;
|
|
82
|
+
return {
|
|
83
|
+
credentialResponse: { evaluatedMessage, maskingNonce, maskedResponse },
|
|
84
|
+
authResponse: { serverNonce, serverPublicKeyshare, serverMac },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function serializeKE3(m) {
|
|
88
|
+
return m.clientMac.slice();
|
|
89
|
+
}
|
|
90
|
+
function deserializeKE3(bytes, suite = "P256-SHA256") {
|
|
91
|
+
const [clientMac] = split(bytes, [(0, suite_1.getSuite)(suite).Nh], "KE3");
|
|
92
|
+
return { clientMac };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DerivedKeys, ServerLoginState } from "./ake";
|
|
2
|
+
import type { OpaqueConfig } from "./config";
|
|
3
|
+
import type { Identities } from "./envelope";
|
|
4
|
+
import type { KE1, KE2, KE3, RegistrationRecord, RegistrationRequest, RegistrationResponse } from "./messages";
|
|
5
|
+
export interface ServerSetup {
|
|
6
|
+
serverPrivateKey: Uint8Array;
|
|
7
|
+
serverPublicKey: Uint8Array;
|
|
8
|
+
oprfSeed: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export interface GenerateKE2Input extends ServerSetup, Identities {
|
|
11
|
+
record: RegistrationRecord;
|
|
12
|
+
credentialIdentifier: Uint8Array | string;
|
|
13
|
+
ke1: KE1;
|
|
14
|
+
}
|
|
15
|
+
export interface KE2Randomness {
|
|
16
|
+
maskingNonce?: Uint8Array;
|
|
17
|
+
serverNonce?: Uint8Array;
|
|
18
|
+
serverKeyshareSeed?: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
export declare function createServerSetup(config?: OpaqueConfig): ServerSetup;
|
|
21
|
+
export declare function createFakeRecord(config?: OpaqueConfig): RegistrationRecord;
|
|
22
|
+
export declare function createRegistrationResponse(request: RegistrationRequest, serverPublicKey: Uint8Array, credentialIdentifier: Uint8Array | string, oprfSeed: Uint8Array, config?: OpaqueConfig): RegistrationResponse;
|
|
23
|
+
export declare function generateKE2With(input: GenerateKE2Input, config: OpaqueConfig, r: KE2Randomness): {
|
|
24
|
+
ke2: KE2;
|
|
25
|
+
state: ServerLoginState;
|
|
26
|
+
keys: DerivedKeys;
|
|
27
|
+
};
|
|
28
|
+
export declare function generateKE2(input: GenerateKE2Input, config?: OpaqueConfig): {
|
|
29
|
+
ke2: KE2;
|
|
30
|
+
state: ServerLoginState;
|
|
31
|
+
};
|
|
32
|
+
export declare function serverFinish(state: ServerLoginState, ke3: KE3): Uint8Array;
|
|
33
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/protocols/opaque/server.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C,OAAO,KAAK,EACV,GAAG,EACH,GAAG,EACH,GAAG,EACH,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,WAAW;IAE1B,gBAAgB,EAAE,UAAU,CAAC;IAE7B,eAAe,EAAE,UAAU,CAAC;IAE5B,QAAQ,EAAE,UAAU,CAAC;CACtB;AAGD,MAAM,WAAW,gBAAiB,SAAQ,WAAW,EAAE,UAAU;IAE/D,MAAM,EAAE,kBAAkB,CAAC;IAE3B,oBAAoB,EAAE,UAAU,GAAG,MAAM,CAAC;IAE1C,GAAG,EAAE,GAAG,CAAC;CACV;AAGD,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,kBAAkB,CAAC,EAAE,UAAU,CAAC;CACjC;AASD,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,YAAiB,GAAG,WAAW,CAQxE;AAYD,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE,YAAiB,GACxB,kBAAkB,CAQpB;AAaD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,EAC5B,eAAe,EAAE,UAAU,EAC3B,oBAAoB,EAAE,UAAU,GAAG,MAAM,EACzC,QAAQ,EAAE,UAAU,EACpB,MAAM,GAAE,YAAiB,GACxB,oBAAoB,CAetB;AAGD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,YAAY,EACpB,CAAC,EAAE,aAAa,GACf;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CA+B1D;AAYD,wBAAgB,WAAW,CACzB,KAAK,EAAE,gBAAgB,EACvB,MAAM,GAAE,YAAiB,GACxB;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAGvC;AAaD,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,GAAG,UAAU,CAE1E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createServerSetup = createServerSetup;
|
|
4
|
+
exports.createFakeRecord = createFakeRecord;
|
|
5
|
+
exports.createRegistrationResponse = createRegistrationResponse;
|
|
6
|
+
exports.generateKE2With = generateKE2With;
|
|
7
|
+
exports.generateKE2 = generateKE2;
|
|
8
|
+
exports.serverFinish = serverFinish;
|
|
9
|
+
const utils_js_1 = require("@noble/hashes/utils.js");
|
|
10
|
+
const ake_1 = require("./ake");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const credentials_1 = require("./credentials");
|
|
13
|
+
const envelope_1 = require("./envelope");
|
|
14
|
+
const messages_1 = require("./messages");
|
|
15
|
+
const suite_1 = require("./suite");
|
|
16
|
+
function createServerSetup(config = {}) {
|
|
17
|
+
const { s } = (0, config_1.resolveConfig)(config);
|
|
18
|
+
const kp = (0, suite_1.deriveDiffieHellmanKeyPair)(s, (0, utils_js_1.randomBytes)(suite_1.Nseed));
|
|
19
|
+
return {
|
|
20
|
+
serverPrivateKey: kp.privateKey,
|
|
21
|
+
serverPublicKey: kp.publicKey,
|
|
22
|
+
oprfSeed: (0, utils_js_1.randomBytes)(s.Nh),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createFakeRecord(config = {}) {
|
|
26
|
+
const { s } = (0, config_1.resolveConfig)(config);
|
|
27
|
+
return {
|
|
28
|
+
clientPublicKey: (0, suite_1.deriveDiffieHellmanKeyPair)(s, (0, utils_js_1.randomBytes)(suite_1.Nseed))
|
|
29
|
+
.publicKey,
|
|
30
|
+
maskingKey: (0, utils_js_1.randomBytes)(s.Nh),
|
|
31
|
+
envelope: { nonce: new Uint8Array(suite_1.Nn), authTag: new Uint8Array(s.Nh) },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function createRegistrationResponse(request, serverPublicKey, credentialIdentifier, oprfSeed, config = {}) {
|
|
35
|
+
const { s } = (0, config_1.resolveConfig)(config);
|
|
36
|
+
const req = (0, messages_1.deserializeRegistrationRequest)((0, messages_1.serializeRegistrationRequest)(request), s.id);
|
|
37
|
+
return {
|
|
38
|
+
evaluatedMessage: (0, credentials_1.evaluateOprf)(s, oprfSeed, credentialIdentifier, req.blindedMessage),
|
|
39
|
+
serverPublicKey: serverPublicKey.slice(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function generateKE2With(input, config, r) {
|
|
43
|
+
const { s, context } = (0, config_1.resolveConfig)(config);
|
|
44
|
+
const ke1 = (0, messages_1.deserializeKE1)((0, messages_1.serializeKE1)(input.ke1), s.id);
|
|
45
|
+
const record = (0, messages_1.deserializeRegistrationRecord)((0, messages_1.serializeRegistrationRecord)(input.record), s.id);
|
|
46
|
+
const credentialResponse = (0, credentials_1.createCredentialResponse)(s, {
|
|
47
|
+
request: ke1.credentialRequest,
|
|
48
|
+
serverPublicKey: input.serverPublicKey,
|
|
49
|
+
record,
|
|
50
|
+
credentialIdentifier: input.credentialIdentifier,
|
|
51
|
+
oprfSeed: input.oprfSeed,
|
|
52
|
+
maskingNonce: r.maskingNonce ?? (0, utils_js_1.randomBytes)(suite_1.Nn),
|
|
53
|
+
});
|
|
54
|
+
const auth = (0, ake_1.authServerRespond)(s, {
|
|
55
|
+
context,
|
|
56
|
+
cleartextCredentials: (0, envelope_1.createCleartextCredentials)(input.serverPublicKey, record.clientPublicKey, input),
|
|
57
|
+
serverPrivateKey: input.serverPrivateKey,
|
|
58
|
+
clientPublicKey: record.clientPublicKey,
|
|
59
|
+
ke1,
|
|
60
|
+
credentialResponse,
|
|
61
|
+
serverNonce: r.serverNonce ?? (0, utils_js_1.randomBytes)(suite_1.Nn),
|
|
62
|
+
serverKeyshareSeed: r.serverKeyshareSeed ?? (0, utils_js_1.randomBytes)(suite_1.Nseed),
|
|
63
|
+
});
|
|
64
|
+
const ke2 = { credentialResponse, authResponse: auth.authResponse };
|
|
65
|
+
return { ke2, state: auth.state, keys: auth.keys };
|
|
66
|
+
}
|
|
67
|
+
function generateKE2(input, config = {}) {
|
|
68
|
+
const { ke2, state } = generateKE2With(input, config, {});
|
|
69
|
+
return { ke2, state };
|
|
70
|
+
}
|
|
71
|
+
function serverFinish(state, ke3) {
|
|
72
|
+
return (0, ake_1.authServerFinalize)(state, ke3);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=server.js.map
|