Repository navigation
X25519 CryptoKeys stored in IndexedDB are read back as null - #77415
Open
calamity5677 wants to merge 1 commit into
Open
calamity5677 wants to merge 1 commit into
calamity5677 wants to merge 1 commit into
Conversation
https://bugs.webkit.org/show_bug.cgi?id=312279 rdar://175258859 Reviewed by NOBODY (OOPS!). X25519 keys could not be round-tripped through structured cloning (and so IndexedDB) at all. CryptoKeyOKP::isValidOKPAlgorithm() only accepted Ed25519, so deserializing any X25519 key failed and IndexedDB returned null. Fixing that exposed a second problem: the serialized OKP key does not record the key type, and deserialization inferred it with CryptoKeyOKP::importRaw(), which treats a key as private only if its usages contain "sign". This works for Ed25519, but an X25519 private key (usages "deriveBits"/"deriveKey") would come back as a public key holding the private key material. Accept X25519 in isValidOKPAlgorithm(), and infer the key type per curve when deserializing an OKP key: Ed25519 keys are private if they can sign, and X25519 keys are private if they can derive. Private keys can never have empty usages and X25519 public keys always have empty usages, so this is unambiguous and keeps the serialization format unchanged, including for X25519 keys that were already written to IndexedDB. Also reject serialized OKP keys whose algorithm and curve do not match, and fail deserialization instead of crashing on a null key if the OKP key cannot be created. Tests: crypto/subtle/ed25519-indexeddb.html crypto/subtle/x25519-indexeddb.html * LayoutTests/crypto/subtle/ed25519-indexeddb-expected.txt: Added. * LayoutTests/crypto/subtle/ed25519-indexeddb.html: Added. * LayoutTests/crypto/subtle/x25519-indexeddb-expected.txt: Added. * LayoutTests/crypto/subtle/x25519-indexeddb.html: Added. * LayoutTests/platform/win/TestExpectations: * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readOKPKey): * Source/WebCore/crypto/keys/CryptoKeyOKP.cpp: (WebCore::CryptoKeyOKP::isValidOKPAlgorithm):
Collaborator
|
EWS run on current version of this PR (hash 1a3c1ce) Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧪 api-ios
1a3c1ce
1a3c1ce
🛠 playstation