-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(extensions/crypto): implement generateKey() & sign() #9614
feat(extensions/crypto): implement generateKey() & sign() #9614
Conversation
Unfortunately we cannot test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy with this now. Thanks a lot @littledivy, and sorry that this took so long to land.
@bartlomieju could you additionally review?
@bnoordhuis could you review the key generation ops for any egregious security issues?
@@ -18,5 +18,11 @@ deno_core = { version = "0.92.0", path = "../../core" } | |||
deno_web = { version = "0.41.1", path = "../web" } | |||
tokio = { version = "1.7.1", features = ["full"] } | |||
rand = "0.8.3" | |||
ring = "0.16.20" | |||
ring = { version = "0.16.20", features = ["std"] } | |||
rsa = "0.4.0" # TODO: remove "pem" feature when next release is on crates.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO is outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I am waiting for RustCrypto/RSA@366ff6e to land in a release.
extensions/crypto/Cargo.toml
Outdated
ring = "0.16.20" | ||
ring = { version = "0.16.20", features = ["std"] } | ||
rsa = "0.4.0" # TODO: remove "pem" feature when next release is on crates.io | ||
sha-1 = "0.9.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf nit: we could enable the asm
feature of sha-1/sha2. Should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust bits LGTM. Thanks for the PR!
)); | ||
} | ||
|
||
let mut rng = OsRng; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using different PRNGs is kind of regrettable, although I understand you can't really get around that. I trust both rand and ring to get it right but still...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too
Can you reconsider the way non-extractable keys are handled. Existing libraries that implement higher level functions often work with generating single-use keys generated on the fly to use in lower level functions. These use This lack of support will mean existing libraries will not be usable under deno, only because of this one thing. |
@panva We are happy to reconsider, but first we need clarification from the spec authors if "non extractable keys" are meant to be a security primitive or not. Deno has no way to implement non extractable keys securely if they are meant to be a security primitive. I'll do some more research and will reach out to some WebCrypto API authors to figure out the details. |
Thank you, that's fair. I have not encountered a normative language in the spec that would say e.g. that the memory used to hold the non-extractable keying material must be out of reach, it only says the raw keying material may not be exported by the application.
|
I have opened #11481 to figure this out. |
Related #1891
Implements
CryptoKey
related logic along with the following methods:generateKey()
andsign()
Uses
ring
for ECDSA & HMACUses
rsa
for RSA-*