-
Notifications
You must be signed in to change notification settings - Fork 41
feat: implement SubtleCrypto.prototype.digest method #372
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
Conversation
6c474f9 to
73bdfb6
Compare
23fdbf5 to
25c1078
Compare
elliottt
left a comment
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.
Looking good! Just a few comments about avoiding copies when possible.
tests/wpt-harness/expectations/WebCryptoAPI/idlharness.https.any.js.json
Show resolved
Hide resolved
c07ebc9 to
0a3d5dc
Compare
0a3d5dc to
8eee88f
Compare
elliottt
left a comment
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.
Looks great! I just had one suggestion for removing an unused vector.
| builtins::CryptoAlgorithmIdentifier::AES_KW, builtins::CryptoAlgorithmIdentifier::HMAC, | ||
| builtins::CryptoAlgorithmIdentifier::HKDF, builtins::CryptoAlgorithmIdentifier::PBKDF2}; | ||
| } // namespace | ||
| namespace builtins { |
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 need to change this, but it's totally fine to nest anonymous namespaces within another -- it would have been fine to leave the definition of the builtins namespace on line 25.
This commit is the start towards full SubtleCrypto support in the runtime. I've implemented the `SubtleCrypto` class but with only one method so far, `SubtleCrypto.prototype.digest`. I've made `globalThis.crypto` become an instance of `Crypto` and have added an instance of `SubtleCrypto` as a getter on `Crypto.prototype.subtle` as per the [WebIDL specification](https://w3c.github.io/webcrypto/#webidl-1120328020): ```webidl partial interface mixin WindowOrWorkerGlobalScope { [SameObject] readonly attribute Crypto crypto; }; [Exposed] interface Crypto { [SecureContext] readonly attribute SubtleCrypto subtle; ArrayBufferView getRandomValues(ArrayBufferView array); [SecureContext] DOMString randomUUID(); }; ``` Currently 76 out of 80 of the Web Platform Tests pass for `SubtleCrypto.prototype.digest`, the ones which fail are to do with providing a large `data` parameter and altering the `data` parameter's buffer after calling `SubtleCrypto.prototype.digest`. I'm not sure yet as to why these tests are failing, it is confusing for me as the same test but with a smaller `data` parameter does pass as expected.
416e575 to
f86b3d8
Compare
Co-authored-by: Trevor Elliott <[email protected]>
f86b3d8 to
bfbadb3
Compare
This pull-request is the start towards full SubtleCrypto support in the runtime.
I've implemented the
SubtleCryptoclass but with only one method so far,SubtleCrypto.prototype.digest.I've made
globalThis.cryptobecome an instance ofCryptoand have added an instance ofSubtleCryptoas a getter onCrypto.prototype.subtleas per the WebIDL specification:Remaining parts to add in this pull-request:
subtleproperty.SubtleCryptoSubtleCrypto.prototype.digest