Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: AES-KW through main process crypto.subtle causes OperationError #41720

Closed
3 tasks done
LiranCohen opened this issue Mar 27, 2024 · 2 comments
Closed
3 tasks done
Labels
bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/

Comments

@LiranCohen
Copy link

Preflight Checklist

Electron Version

29.1.5

What operating system are you using?

macOS

Operating System Version

Sonoma 14.4.1

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

Support of crypto.subtle.wrapKey for AES-KW given the native support in underlying NodeJS

Actual Behavior

$ electron . --trace-warnings
(node:72602) UnhandledPromiseRejectionWarning: OperationError: The operation failed for an operation-specific reason
    at new DOMException (node:internal/per_context/domexception:53:5)
    at __node_internal_ (node:internal/util:695:10)
    at onDone (node:internal/crypto/util:420:19)
    at node:internal/crypto/util:434:7
    at new Promise (<anonymous>)
    at jobPromise (node:internal/crypto/util:428:10)
    at asyncAesKwCipher (node:internal/crypto/aes:145:10)
    at Object.aesCipher (node:internal/crypto/aes:212:27)
    at cipherOrWrap (node:internal/crypto/webcrypto:918:12)
    at SubtleCrypto.wrapKey (node:internal/crypto/webcrypto:715:10)
    at emitUnhandledRejectionWarning (node:internal/process/promises:201:15)
    at processPromiseRejections (node:internal/process/promises:297:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
(node:72602) OperationError: The operation failed for an operation-specific reason
    at new DOMException (node:internal/per_context/domexception:53:5)
    at __node_internal_ (node:internal/util:695:10)
    at onDone (node:internal/crypto/util:420:19)
    at node:internal/crypto/util:434:7
    at new Promise (<anonymous>)
    at jobPromise (node:internal/crypto/util:428:10)
    at asyncAesKwCipher (node:internal/crypto/aes:145:10)
    at Object.aesCipher (node:internal/crypto/aes:212:27)
    at cipherOrWrap (node:internal/crypto/webcrypto:918:12)
    at SubtleCrypto.wrapKey (node:internal/crypto/webcrypto:715:10)

Testcase Gist URL

https://gist.github.com/LiranCohen/9c93d27ae218f60042932eba271af75b

Additional Information

Reviving this auto-closed issue:
#36256

@electron-issue-triage electron-issue-triage bot added the has-repro-gist Issue can be reproduced with code at https://gist.github.com/ label Mar 27, 2024
@codebytere
Copy link
Member

@LiranCohen this is unfortunately by design and not something we're currently likely to change. Node.js proper uses OpenSSL to underpin crypto, whereas Electron uses BoringSSL: a fork of OpenSSL from Chromium pared down significantly compared to Node.js. The actual error here is that the cipher is unsupported, which is a choice made intentionally by BoringSSL. It's implemented in WebCrypto, however, so you're able to use it in the renderer process if you so choose.

@codebytere codebytere closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@shamilovtim
Copy link

shamilovtim commented Apr 9, 2024

@LiranCohen this is unfortunately by design and not something we're currently likely to change. Node.js proper uses OpenSSL to underpin crypto, whereas Electron uses BoringSSL: a fork of OpenSSL from Chromium pared down significantly compared to Node.js. The actual error here is that the cipher is unsupported, which is a choice made intentionally by BoringSSL. It's implemented in WebCrypto, however, so you're able to use it in the renderer process if you so choose.

@codebytere If it's supported in the renderer process (via webcrypto) what is the distinction and and reasoning for keeping it unsupported in the Node.js process? Node also has crypto.webcrypto so this isn't making sense.

As a consequence of this Electron has made a conscious choice to be the only platform that doesn't support keywrap by pointing responsibility back to BoringSSL, even though BoringSSL does support keywrap on browser: https://commondatastorage.googleapis.com/chromium-boringssl-docs/aes.h.html#AES_wrap_key. Logically this isn't adding up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/
Projects
None yet
Development

No branches or pull requests

3 participants