@sebastienrousseau/crypto-mcp 0.0.35 → 0.0.37
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 +4 -2
- package/dist/tools/kem.d.ts.map +1 -1
- package/dist/tools/kem.js +5 -2
- package/dist/tools/keys.js +1 -1
- package/dist/tools/stream-definitions.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
`@sebastienrousseau/crypto-mcp` implements the **Model Context Protocol (MCP)** specification, turning the Crypto Service Suite into a secure, tool-enabled cryptographic runtime for AI agents and LLM-driven environments (including Cursor, Antigravity, Claude Desktop, VS Code, and Zed).
|
|
16
16
|
|
|
17
|
-
Instead of relying on fragile shell scripts or unverified LLM math, agents invoke cryptographically verified tools backed by `@sebastienrousseau/crypto-lib
|
|
17
|
+
Instead of relying on fragile shell scripts or unverified LLM math, agents invoke cryptographically verified tools backed by `@sebastienrousseau/crypto-lib` and `@sebastienrousseau/crypto-kms`.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
23
|
- **Standard MCP Protocol**: JSON-RPC 2.0 over stdio, with tools, resources and prompts.
|
|
24
|
-
- **Key handles, not key material**: keys are generated, unwrapped or derived inside the server process. Tools return an opaque `keyHandle` (`kh_` followed by 32 hex characters) plus public metadata; no tool returns a private key, a symmetric key or a DEK, and no tool
|
|
24
|
+
- **Key handles, not key material**: keys are generated, unwrapped or derived inside the server process. Tools return an opaque `keyHandle` (`kh_` followed by 32 hex characters) plus public metadata; no tool returns a private key, a symmetric key or a DEK, no tool accepts one, and no tool wraps an existing key to public keys the client chooses unless the operator allows it (`MCP_ALLOW_KEY_EXPORT=1`).
|
|
25
25
|
- **Post-Quantum Cryptography (PQC)**: ML-KEM-768 (NIST FIPS 203) key generation, encapsulation and decapsulation.
|
|
26
26
|
- **Classical Primitives**: RSA-2048/3072/4096 (RSASSA-PSS), ECDSA on P-256, P-384 and secp256k1, Ed25519, HMAC-SHA256, and AES-256-GCM / ChaCha20-Poly1305.
|
|
27
27
|
- **Envelope Encryption**: wrap and unwrap DEKs under a key-encryption key. Only the `local` provider (random, in-process keys that do not survive a restart) is configured; `aws`, `gcp`, `azure` and `vault` return an error.
|
|
@@ -87,6 +87,8 @@ Signature algorithms by key type: `ed25519` signs Ed25519, `rsa` signs RSASSA-PS
|
|
|
87
87
|
|
|
88
88
|
A key handle is a capability: whoever can call the server with it can use the key, but cannot read it. Handles live only as long as the server process. The store holds at most 64 keys; adding one more destroys the least recently used key, so a client that needs a key for long should keep using it or expect to generate a new one. `crypto_key_destroy` removes a key at once.
|
|
89
89
|
|
|
90
|
+
`crypto_hybrid_kem_multi_encapsulate` wraps a fresh 256-bit DEK for the recipients it is given. It refuses an existing `keyHandle` unless the server runs with `MCP_ALLOW_KEY_EXPORT=1`: wrapping an existing key to public keys the client names would let a prompt-injected client send that key to keys it controls.
|
|
91
|
+
|
|
90
92
|
A typical session:
|
|
91
93
|
|
|
92
94
|
1. `crypto_generate_key` with `type: "ed25519"` returns `keyHandle` and `publicKey`.
|
package/dist/tools/kem.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kem.d.ts","sourceRoot":"","sources":["../../src/tools/kem.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;AA2BnD,eAAO,MAAM,cAAc,EAAE,WAa5B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,WAoB5B,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAoBzC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAuBzC,CAAC;AAmBF,eAAO,MAAM,gCAAgC,EAAE,
|
|
1
|
+
{"version":3,"file":"kem.d.ts","sourceRoot":"","sources":["../../src/tools/kem.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;AA2BnD,eAAO,MAAM,cAAc,EAAE,WAa5B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,WAoB5B,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAoBzC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAuBzC,CAAC;AAmBF,eAAO,MAAM,gCAAgC,EAAE,WA2C9C,CAAC;AAgEF,eAAO,MAAM,gCAAgC,EAAE,WAqB9C,CAAC"}
|
package/dist/tools/kem.js
CHANGED
|
@@ -24,7 +24,7 @@ function inferLevelFromKey(keyKind) {
|
|
|
24
24
|
}
|
|
25
25
|
const kemEncapsulate = async (args) => {
|
|
26
26
|
const level = resolveKemLevel(args.level, 768);
|
|
27
|
-
const { ciphertext, sharedSecret, algorithm } = (0, crypto_lib_1.
|
|
27
|
+
const { ciphertext, sharedSecret, algorithm } = (0, crypto_lib_1.mlKemEncapsulate)(level, String(args.publicKey));
|
|
28
28
|
const keyHandle = keystore_1.keyStore.add((0, keystore_1.symmetricKey)(Buffer.from(sharedSecret, "hex"), `${algorithm} encapsulation`));
|
|
29
29
|
return (0, result_1.jsonResult)({ algorithm, ciphertext, keyHandle });
|
|
30
30
|
};
|
|
@@ -37,7 +37,7 @@ const kemDecapsulate = async (args) => {
|
|
|
37
37
|
]);
|
|
38
38
|
const defaultLevel = inferLevelFromKey(key.kind);
|
|
39
39
|
const level = resolveKemLevel(args.level, defaultLevel);
|
|
40
|
-
const { sharedSecret, algorithm } = (0, crypto_lib_1.
|
|
40
|
+
const { sharedSecret, algorithm } = (0, crypto_lib_1.mlKemDecapsulate)(level, key.secret.toString("hex"), String(args.ciphertext));
|
|
41
41
|
const keyHandle = keystore_1.keyStore.add((0, keystore_1.symmetricKey)(Buffer.from(sharedSecret, "hex"), `${algorithm} decapsulation`));
|
|
42
42
|
return (0, result_1.jsonResult)({ algorithm, keyHandle });
|
|
43
43
|
};
|
|
@@ -80,6 +80,9 @@ const hybridKemMultiEncapsulateHandler = async (args) => {
|
|
|
80
80
|
let dek;
|
|
81
81
|
let keyHandle;
|
|
82
82
|
if (args.keyHandle !== undefined && args.keyHandle !== null) {
|
|
83
|
+
if (process.env["MCP_ALLOW_KEY_EXPORT"] !== "1") {
|
|
84
|
+
throw new Error("Wrapping an existing keyHandle exports the key; omit keyHandle to wrap a fresh key, or set MCP_ALLOW_KEY_EXPORT=1 on the server to allow it");
|
|
85
|
+
}
|
|
83
86
|
keyHandle = String(args.keyHandle);
|
|
84
87
|
const stored = keystore_1.keyStore.use(keyHandle, ["symmetric-256"]);
|
|
85
88
|
dek = Buffer.from(stored.secret);
|
package/dist/tools/keys.js
CHANGED
|
@@ -75,7 +75,7 @@ function generateSymmetric() {
|
|
|
75
75
|
return (0, keystore_1.symmetricKey)(node_crypto_1.default.randomBytes(32), "generated");
|
|
76
76
|
}
|
|
77
77
|
function generateX25519() {
|
|
78
|
-
const pair = (0, crypto_lib_1.
|
|
78
|
+
const pair = (0, crypto_lib_1.x25519Keygen)();
|
|
79
79
|
return {
|
|
80
80
|
kind: "x25519",
|
|
81
81
|
secret: Buffer.from(pair.privateKey, "hex"),
|
|
@@ -89,7 +89,7 @@ exports.STREAM_TOOLS = [
|
|
|
89
89
|
additionalProperties: false,
|
|
90
90
|
properties: {
|
|
91
91
|
recipients: (0, schema_helpers_1.text)("JSON-serialized array of recipient public key objects: [{ id?, x25519PublicKey, mlKemPublicKey }]."),
|
|
92
|
-
keyHandle: (0, schema_helpers_1.keyHandle)("Optional handle of an existing symmetric-256 key to encapsulate. If omitted, a fresh 256-bit DEK is generated."),
|
|
92
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Optional handle of an existing symmetric-256 key to encapsulate. Refused unless the server sets MCP_ALLOW_KEY_EXPORT=1, since it sends the key to the recipients. If omitted, a fresh 256-bit DEK is generated."),
|
|
93
93
|
},
|
|
94
94
|
required: ["recipients"],
|
|
95
95
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebastienrousseau/crypto-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server that gives AI assistants and agents cryptography tools: key generation, encryption, ML-KEM, ML-DSA signing, hashing, streaming encryption, KMS and CBOM.",
|
|
5
5
|
"author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
"dist/**/*.d.ts.map"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sebastienrousseau/crypto-lib": "0.0.
|
|
32
|
-
"@sebastienrousseau/crypto-kms": "0.0.
|
|
33
|
-
"@sebastienrousseau/crypto-wasm": "0.0.35"
|
|
31
|
+
"@sebastienrousseau/crypto-lib": "0.0.37",
|
|
32
|
+
"@sebastienrousseau/crypto-kms": "0.0.37"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/chai": "^5.2.3",
|
|
@@ -74,6 +73,7 @@
|
|
|
74
73
|
"build": "tsc --build tsconfig.json",
|
|
75
74
|
"clean": "rimraf ./coverage ./dist ./docs",
|
|
76
75
|
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --reporter=lcov --reporter=text mocha --config=.mocharc.cjs",
|
|
76
|
+
"test:run": "mocha --config=.mocharc.cjs",
|
|
77
77
|
"docs": "typedoc",
|
|
78
78
|
"lint": "eslint src __tests__",
|
|
79
79
|
"lint:fix": "eslint --cache --fix src __tests__",
|