bitwarden/remove-argon2-browser.patch
2024-11-25 06:23:45 +00:00

66 lines
2.4 KiB
Diff

Remove dependency on argon-browser2 which should be dead code after https://github.com/bitwarden/clients/commit/996823169a5134da56c0e08f6e83a01e64164774
We used to path this to use node_modules/argon2 but cannot anymore due to sandbox now being enabled; fortunately, upstream at the same time moved the crypto to main process.
Therefore the WASM implementation in web-crypto-function should be dead code now and can be removed because we do not want to compile WASM.
--- clients/apps/desktop/webpack.renderer.js.orig 2024-10-17 19:47:51.805420136 +0200
+++ clients/apps/desktop/webpack.renderer.js 2024-10-17 21:00:08.105664818 +0200
@@ -41,11 +41,6 @@ const common = {
},
type: "asset/resource",
},
- {
- test: /argon2(-simd)?\.wasm$/,
- loader: "base64-loader",
- type: "javascript/auto",
- },
],
},
plugins: [],
@@ -142,11 +137,6 @@ const renderer = {
test: /[\/\\]@angular[\/\\].+\.js$/,
parser: { system: true },
},
- {
- test: /argon2(-simd)?\.wasm$/,
- loader: "base64-loader",
- type: "javascript/auto",
- },
],
noParse: /argon2(-simd)?\.wasm$/,
},
--- a/libs/common/src/platform/services/web-crypto-function.service.ts
+++ b/libs/common/src/platform/services/web-crypto-function.service.ts
@@ -1,4 +1,3 @@
-import * as argon2 from "argon2-browser";
import * as forge from "node-forge";
import { Utils } from "../../platform/misc/utils";
@@ -54,24 +53,9 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
memory: number,
parallelism: number,
): Promise<Uint8Array> {
- if (!this.wasmSupported) {
- throw "Webassembly support is required for the Argon2 KDF feature.";
- }
-
- const passwordArr = new Uint8Array(this.toBuf(password));
- const saltArr = new Uint8Array(this.toBuf(salt));
-
- const result = await argon2.hash({
- pass: passwordArr,
- salt: saltArr,
- time: iterations,
- mem: memory,
- parallelism: parallelism,
- hashLen: 32,
- type: argon2.ArgonType.Argon2id,
- });
- argon2.unloadRuntime();
- return result.hash;
+ const err="This should be unreachable dead code. If you're seeing this message, please report a bug to openSUSE maintainers because we must have made a mistake when patching."
+ alert(err)
+ throw err
}
async hkdf(