init
This commit is contained in:
10
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts
generated
vendored
Normal file
10
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Derive AES and HMAC keys from a master key.
|
||||
*
|
||||
* This is used for deriving secret storage keys: see https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2 (step 1).
|
||||
*
|
||||
* @param key
|
||||
* @param name
|
||||
*/
|
||||
export declare function deriveKeys(key: Uint8Array<ArrayBuffer>, name: string): Promise<[CryptoKey, CryptoKey]>;
|
||||
//# sourceMappingURL=deriveKeys.d.ts.map
|
||||
1
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deriveKeys.d.ts","sourceRoot":"","sources":["../../../src/utils/internal/deriveKeys.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAkC5G"}
|
||||
52
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js
generated
vendored
Normal file
52
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2024 The Matrix.org Foundation C.I.C.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// salt for HKDF, with 8 bytes of zeros
|
||||
const zeroSalt = new Uint8Array(8);
|
||||
|
||||
/**
|
||||
* Derive AES and HMAC keys from a master key.
|
||||
*
|
||||
* This is used for deriving secret storage keys: see https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2 (step 1).
|
||||
*
|
||||
* @param key
|
||||
* @param name
|
||||
*/
|
||||
export async function deriveKeys(key, name) {
|
||||
const hkdfkey = await globalThis.crypto.subtle.importKey("raw", key, {
|
||||
name: "HKDF"
|
||||
}, false, ["deriveBits"]);
|
||||
const keybits = await globalThis.crypto.subtle.deriveBits({
|
||||
name: "HKDF",
|
||||
salt: zeroSalt,
|
||||
// @ts-ignore: https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/879
|
||||
info: new TextEncoder().encode(name),
|
||||
hash: "SHA-256"
|
||||
}, hkdfkey, 512);
|
||||
const aesKey = keybits.slice(0, 32);
|
||||
const hmacKey = keybits.slice(32);
|
||||
const aesProm = globalThis.crypto.subtle.importKey("raw", aesKey, {
|
||||
name: "AES-CTR"
|
||||
}, false, ["encrypt", "decrypt"]);
|
||||
const hmacProm = globalThis.crypto.subtle.importKey("raw", hmacKey, {
|
||||
name: "HMAC",
|
||||
hash: {
|
||||
name: "SHA-256"
|
||||
}
|
||||
}, false, ["sign", "verify"]);
|
||||
return Promise.all([aesProm, hmacProm]);
|
||||
}
|
||||
//# sourceMappingURL=deriveKeys.js.map
|
||||
1
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map
generated
vendored
Normal file
1
node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deriveKeys.js","names":[],"sources":["../../../src/utils/internal/deriveKeys.ts"],"sourcesContent":["/*\n * Copyright 2024 The Matrix.org Foundation C.I.C.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// salt for HKDF, with 8 bytes of zeros\nconst zeroSalt = new Uint8Array(8);\n\n/**\n * Derive AES and HMAC keys from a master key.\n *\n * This is used for deriving secret storage keys: see https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2 (step 1).\n *\n * @param key\n * @param name\n */\nexport async function deriveKeys(key: Uint8Array<ArrayBuffer>, name: string): Promise<[CryptoKey, CryptoKey]> {\n const hkdfkey = await globalThis.crypto.subtle.importKey(\"raw\", key, { name: \"HKDF\" }, false, [\"deriveBits\"]);\n const keybits = await globalThis.crypto.subtle.deriveBits(\n {\n name: \"HKDF\",\n salt: zeroSalt,\n // @ts-ignore: https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/879\n info: new TextEncoder().encode(name),\n hash: \"SHA-256\",\n },\n hkdfkey,\n 512,\n );\n\n const aesKey = keybits.slice(0, 32);\n const hmacKey = keybits.slice(32);\n\n const aesProm = globalThis.crypto.subtle.importKey(\"raw\", aesKey, { name: \"AES-CTR\" }, false, [\n \"encrypt\",\n \"decrypt\",\n ]);\n\n const hmacProm = globalThis.crypto.subtle.importKey(\n \"raw\",\n hmacKey,\n {\n name: \"HMAC\",\n hash: { name: \"SHA-256\" },\n },\n false,\n [\"sign\", \"verify\"],\n );\n\n return Promise.all([aesProm, hmacProm]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAM,QAAQ,GAAG,IAAI,UAA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