Skip to content

Instantly share code, notes, and snippets.

@LiranCohen
Created March 27, 2024 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiranCohen/9c93d27ae218f60042932eba271af75b to your computer and use it in GitHub Desktop.
Save LiranCohen/9c93d27ae218f60042932eba271af75b to your computer and use it in GitHub Desktop.
AES-KW Rejection with `OperationError` in `electron`
const { app } = require('electron');
app.whenReady().then(() => {
(async () => {
const cek = crypto.getRandomValues(new Uint8Array(16));
const cryptoKeyCek = await crypto.subtle.importKey(
"raw",
cek,
{ name: "HMAC", hash: "SHA-256" },
true,
["sign"],
);
const cryptoKey = await crypto.subtle.generateKey(
{ name: "AES-KW", length: 128 },
true,
["wrapKey", "unwrapKey"]
);
await crypto.subtle.wrapKey("raw", cryptoKeyCek, cryptoKey, "AES-KW");
})();
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
{
"name": "my-electron-app",
"version": "1.0.0",
"main": "main.js",
"author": "example.com",
"description": "Example Electron",
"license": "MIT",
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^29.1.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment