Make WebPageProxy::wrapCryptoKey take CryptoKey instead of serialized key data#37761
Conversation
|
EWS run on previous version of this PR (hash 3529f7a) Details |
3529f7a to
1e4a1f7
Compare
|
EWS run on previous version of this PR (hash 1e4a1f7) Details |
1e4a1f7 to
677309d
Compare
|
EWS run on previous version of this PR (hash 677309d) Details |
677309d to
fc71371
Compare
|
EWS run on previous version of this PR (hash fc71371) Details |
fc71371 to
7f92321
Compare
|
EWS run on previous version of this PR (hash 7f92321) Details |
7f92321 to
aa7c37d
Compare
|
EWS run on previous version of this PR (hash aa7c37d) Details |
aa7c37d to
d61c322
Compare
|
EWS run on previous version of this PR (hash d61c322) Details |
d61c322 to
08c79f8
Compare
|
EWS run on previous version of this PR (hash 08c79f8) Details |
There was a problem hiding this comment.
Why do you need both jwk and Vector together.. wouldn't jwk work everywhere ?
and if it's either then std::variant<jwk,Vector> seems like a natural choice.
There was a problem hiding this comment.
The algorithm Identifier should probably also not really need optional ? it should always be there.
There was a problem hiding this comment.
Or is it something to do with IPC serialization that all items are optional ?
There was a problem hiding this comment.
Why do you need both jwk and Vector together.. wouldn't jwk work everywhere ?
CryptoKeyRaw cannot export jwk
The algorithm Identifier should probably also not really need optional ? it should always be there.
Algorithm identifier is not optional, hash algorithm identifier is; see members of CryptoKeyData starting at line 73 of this file.
CryptoKeyType also.
CryptoKeyType is optional because some importJwk functions do not require that.
When a parameter is not required for all functions, I make it optional.
Or is it something to do with IPC serialization that all items are optional ?
The logic is we extract CryptoKeyData from CryptoKey (with exportJwk and other property accessor function) on the web process side, send CryptoKeyData to UI process, and recreate CryptoKey from CryptoKeyData (with CryptoKey::create(CryptoKeyData&&))on the UI process side.
Source/WebCore/dom/Document.cpp
Outdated
There was a problem hiding this comment.
This looks like a new API. Who is calling it ?
There was a problem hiding this comment.
auto wrappedKey = serializeAndWrapCryptoKey(m_lexicalGlobalObject, key->data()); in Source/WebCore/bindings/js/SerializedScriptValue.cpp
|
This seems like an additive change and the title of the PR says wrapCryptoKey is changing but the commit diff does not show that it's changing. Am I missing something ? |
There was a problem hiding this comment.
Today I learnt that this is valid. thanks!
Because I directly replace the usage of |
Looks good to me. |
and yea the build needs to be green! |
e57f567 to
7d9bbe5
Compare
|
EWS run on previous version of this PR (hash 7d9bbe5) Details |
sysrqb
left a comment
There was a problem hiding this comment.
Mostly rubberstamped based on Nitin's review
There was a problem hiding this comment.
I assume this is because the key size is in bytes, and we need bits? Please make that more explicit.
There was a problem hiding this comment.
This looks like it can be a forward declaration instead of including a header from another header.
There was a problem hiding this comment.
I'm not sure if it would be better to have this return std::optional and have CryptoKey::create return nullptr if it's not one of the two supported string, or if this actually is unreachable.
There was a problem hiding this comment.
Yes, might be better to return std::optional here.
There was a problem hiding this comment.
Will update with CHAR_BIT.
There was a problem hiding this comment.
Can this call a JsonWebKey constructor with members rather than calling the empty constructor then populating?
There was a problem hiding this comment.
I think it can, but JsonWebKey currently doesn't have constructors and I tried to use what's available to keep change size small.
May it do as followup.
7d9bbe5 to
52ae166
Compare
|
EWS run on current version of this PR (hash 52ae166) Details |
… key data https://bugs.webkit.org/show_bug.cgi?id=284444 rdar://141265745 Reviewed by Pascoe and Matthew Finkel. In current implementation of wrapping crypto key, web process serializes key into bytes and sends the bytes to UI process for encryption. On receiving the bytes, UI process is not able to validate that the bytes actually represent crypto key, as it does not know the serialization format. To ensure UI process can do validation, now we make web process send structured crypto key data to UI process, by introducing WebCore::CryptoKeyData and adding IPC serialization for it. If UI process cannot recreate crypto key from the data, it will reject the request; otherwise it will do both serialization and encryption. There should be no user-visible behavior change after this patch. * Source/WebCore/Headers.cmake: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::serializeAndWrapCryptoKey): (WebCore::CloneSerializer::serializeCryptoKey): (WebCore::CloneSerializer::dumpIfTerminal): (WebCore::SerializedScriptValue::serializeCryptoKey): (WebCore::wrapCryptoKey): Deleted. * Source/WebCore/bindings/js/SerializedScriptValue.h: * Source/WebCore/crypto/CryptoKey.cpp: (WebCore::CryptoKey::create): * Source/WebCore/crypto/CryptoKey.h: (WebCore::CryptoKey::isValid const): * Source/WebCore/crypto/CryptoKeyData.h: Added. (WebCore::CryptoKeyData::CryptoKeyData): (WebCore::CryptoKeyData::isolatedCopy): * Source/WebCore/crypto/JsonWebKey.h: (WebCore::JsonWebKey::isolatedCopy): * Source/WebCore/crypto/RsaOtherPrimesInfo.h: (WebCore::RsaOtherPrimesInfo::isolatedCopy): * Source/WebCore/crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::exportJwk const): (WebCore::CryptoKeyAES::data const): * Source/WebCore/crypto/keys/CryptoKeyAES.h: * Source/WebCore/crypto/keys/CryptoKeyEC.cpp: (WebCore::CryptoKeyEC::exportJwk const): (WebCore::CryptoKeyEC::data const): * Source/WebCore/crypto/keys/CryptoKeyEC.h: * Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp: (WebCore::CryptoKeyHMAC::exportJwk const): (WebCore::CryptoKeyHMAC::data const): * Source/WebCore/crypto/keys/CryptoKeyHMAC.h: * Source/WebCore/crypto/keys/CryptoKeyOKP.cpp: (WebCore::CryptoKeyOKP::exportJwk const): (WebCore::CryptoKeyOKP::namedCurveFromString): (WebCore::CryptoKeyOKP::data const): * Source/WebCore/crypto/keys/CryptoKeyOKP.h: * Source/WebCore/crypto/keys/CryptoKeyRSA.cpp: (WebCore::CryptoKeyRSA::exportJwk const): (WebCore::CryptoKeyRSA::data const): * Source/WebCore/crypto/keys/CryptoKeyRSA.h: * Source/WebCore/crypto/keys/CryptoKeyRaw.cpp: (WebCore::CryptoKeyRaw::data const): * Source/WebCore/crypto/keys/CryptoKeyRaw.h: * Source/WebCore/dom/Document.cpp: (WebCore::Document::serializeAndWrapCryptoKey): * Source/WebCore/dom/Document.h: * Source/WebCore/dom/EmptyScriptExecutionContext.h: * Source/WebCore/dom/ScriptExecutionContext.h: * Source/WebCore/page/CryptoClient.h: (WebCore::CryptoClient::serializeAndWrapCryptoKey const): * Source/WebCore/workers/WorkerGlobalScope.cpp: (WebCore::WorkerGlobalScope::serializeAndWrapCryptoKey): * Source/WebCore/workers/WorkerGlobalScope.h: * Source/WebCore/worklets/WorkletGlobalScope.h: * Source/WebKit/Scripts/webkit/messages.py: (headers_for_type): * Source/WebKit/Shared/API/APISerializedScriptValue.cpp: (API::SerializedScriptValue::serializeCryptoKey): * Source/WebKit/Shared/API/APISerializedScriptValue.h: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp: * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::serializeAndWrapCryptoKey): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/WebPageProxy.messages.in: * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::serializeAndWrapCryptoKey): * Source/WebKit/UIProcess/WebProcessProxy.h: * Source/WebKit/UIProcess/WebProcessProxy.messages.in: * Source/WebKit/WebProcess/WebCoreSupport/WebCryptoClient.cpp: (WebKit::WebCryptoClient::serializeAndWrapCryptoKey const): * Source/WebKit/WebProcess/WebCoreSupport/WebCryptoClient.h: * Source/WebKitLegacy/WebCoreSupport/WebCryptoClient.h: * Source/WebKitLegacy/WebCoreSupport/WebCryptoClient.mm: (WebCryptoClient::serializeAndWrapCryptoKey const): Canonical link: https://commits.webkit.org/287927@main
52ae166 to
22614e8
Compare
|
Committed 287927@main (22614e8): https://commits.webkit.org/287927@main Reviewed commits have been landed. Closing PR #37761 and removing active labels. |
22614e8
52ae166
🧪 win-tests🧪 api-ios🧪 mac-AS-debug-wk2🛠 mac-safer-cpp