Change SubtleCrypto.generateKey return type [chromium/src : main]

0 views
Skip to first unread message

Hubert Chao (Gerrit)

unread,
Apr 15, 2026, 4:17:57 PM (12 days ago) Apr 15
to Daniel Cheng, android-bu...@system.gserviceaccount.com, chromiu...@luci-project-accounts.iam.gserviceaccount.com, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, kinuko...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org
Attention needed from Daniel Cheng

Hubert Chao added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Hubert Chao . unresolved

Questions:

1. Is this the right way to do this? this seems like a lot of boilerplate but maybe that's due to WebCrypto's structure?

2. I couldn't get rid of the casts to Any in crypto_result_impl.cc because a bunch of tests in V8ScriptValueSerializerForModulesTest failed; I tried fixing them but I didn't follow the templated stuff well enough (starting with SubtleCryptoSync) to figure out what a possible fix might be. Any ideas?

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7011668d19f7361e9746df07e7d601093192a734
Gerrit-Change-Number: 7754862
Gerrit-PatchSet: 6
Gerrit-Owner: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Hubert Chao <hc...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Wed, 15 Apr 2026 20:17:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Cheng (Gerrit)

unread,
Apr 22, 2026, 4:35:41 PM (5 days ago) Apr 22
to Hubert Chao, Nate Chapin, Daniel Cheng, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, kinuko...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org
Attention needed from Hubert Chao and Nate Chapin

Daniel Cheng added 1 comment

Patchset-level comments
Hubert Chao . unresolved

Questions:

1. Is this the right way to do this? this seems like a lot of boilerplate but maybe that's due to WebCrypto's structure?

2. I couldn't get rid of the casts to Any in crypto_result_impl.cc because a bunch of tests in V8ScriptValueSerializerForModulesTest failed; I tried fixing them but I didn't follow the templated stuff well enough (starting with SubtleCryptoSync) to figure out what a possible fix might be. Any ideas?

Daniel Cheng

@jap...@chromium.org can you help answer these questions? I'm not familiar enough with the bindings anymore.

Open in Gerrit

Related details

Attention is currently required from:
  • Hubert Chao
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7011668d19f7361e9746df07e7d601093192a734
Gerrit-Change-Number: 7754862
Gerrit-PatchSet: 6
Gerrit-Owner: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Hubert Chao <hc...@chromium.org>
Gerrit-Comment-Date: Wed, 22 Apr 2026 20:35:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hubert Chao <hc...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Apr 22, 2026, 5:13:43 PM (5 days ago) Apr 22
to Hubert Chao, Daniel Cheng, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, kinuko...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org
Attention needed from Hubert Chao

Nate Chapin added 1 comment

Patchset-level comments
Hubert Chao . unresolved

Questions:

1. Is this the right way to do this? this seems like a lot of boilerplate but maybe that's due to WebCrypto's structure?

2. I couldn't get rid of the casts to Any in crypto_result_impl.cc because a bunch of tests in V8ScriptValueSerializerForModulesTest failed; I tried fixing them but I didn't follow the templated stuff well enough (starting with SubtleCryptoSync) to figure out what a possible fix might be. Any ideas?

Daniel Cheng

@jap...@chromium.org can you help answer these questions? I'm not familiar enough with the bindings anymore.

Nate Chapin

1. Yeah, sorry. When I went through and typed all the promises, to ensure that spec-defined promises always resolve with an IDL-compatible type, there were only a couple of places where the boilerplate got bad. WebCrypo was just about the worst in the entire codebase.

2. Can you give me an example error? I might be able to spot something :/

Open in Gerrit

Related details

Attention is currently required from:
  • Hubert Chao
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7011668d19f7361e9746df07e7d601093192a734
Gerrit-Change-Number: 7754862
Gerrit-PatchSet: 6
Gerrit-Owner: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Hubert Chao <hc...@chromium.org>
Gerrit-Comment-Date: Wed, 22 Apr 2026 21:13:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hubert Chao <hc...@chromium.org>
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Hubert Chao (Gerrit)

unread,
Apr 24, 2026, 2:51:08 PM (3 days ago) Apr 24
to David Benjamin, Nate Chapin, Daniel Cheng, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, kinuko...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org
Attention needed from Daniel Cheng, David Benjamin and Nate Chapin

Hubert Chao added 1 comment

Patchset-level comments
Hubert Chao . unresolved

Questions:

1. Is this the right way to do this? this seems like a lot of boilerplate but maybe that's due to WebCrypto's structure?

2. I couldn't get rid of the casts to Any in crypto_result_impl.cc because a bunch of tests in V8ScriptValueSerializerForModulesTest failed; I tried fixing them but I didn't follow the templated stuff well enough (starting with SubtleCryptoSync) to figure out what a possible fix might be. Any ideas?

Daniel Cheng

@jap...@chromium.org can you help answer these questions? I'm not familiar enough with the bindings anymore.

Nate Chapin

1. Yeah, sorry. When I went through and typed all the promises, to ensure that spec-defined promises always resolve with an IDL-compatible type, there were only a couple of places where the boilerplate got bad. WebCrypo was just about the worst in the entire codebase.

2. Can you give me an example error? I might be able to spot something :/

Hubert Chao

1. Yeah, sorry. When I went through and typed all the promises, to ensure that spec-defined promises always resolve with an IDL-compatible type, there were only a couple of places where the boilerplate got bad. WebCrypo was just about the worst in the entire codebase.

Yeah there are way too many layers of abstraction; @davi...@chromium.org and I keep complaining about them. Maybe someday one of us will get annoyed enough and have the cycles to do something about it.

2. Can you give me an example error? I might be able to spot something :/

You can see the errors from the checks in patchset 3. Example:

https://ci.chromium.org/ui/p/chromium/builders/try/linux-rel/b8684606857278391073/test-results?q=ExactID%3A%3A%2F%2Fthird_party%2Fblink%2Frenderer%2Fcontroller%5C%3Ablink_unittests%21gtest%3A%3AV8ScriptValueSerializerForModulesTest%23RoundTripCryptoKeyX25519+VHash%3A5a6b49b59946f24e&clean=

```
31892:431892:FATAL:third_party/blink/renderer/modules/crypto/crypto_result_impl.cc:216] Check failed: type_ == ResolverType::kTyped (0 vs. 1).
#0 0x5db842d866f2 base::debug::CollectStackTrace()
#1 0x5db842d6ccb1 base::debug::StackTrace::StackTrace()
#2 0x5db842c481cc logging::LogMessage::Flush()
#3 0x5db842c4809c logging::LogMessage::~LogMessage()
#4 0x5db842c30a42 logging::(anonymous namespace)::CheckLogMessage::~CheckLogMessage()
#5 0x5db842c305bb logging::CheckNoreturnError::~CheckNoreturnError()
#6 0x5db84940ae00 blink::CryptoResultImpl::CompleteWithKeyPair()
#7 0x5db846f4f2f1 blink::WebCryptoResult::CompleteWithKeyPair()
#8 0x5db84a5680b3 webcrypto::GenerateKeyResult::Complete()
#9 0x5db84a55c19d webcrypto::WebCryptoImpl::GenerateKey()
#10 0x5db8380b72a6 blink::(anonymous namespace)::SyncGenerateKeyPair()
#11 0x5db8380bcdbf blink::(anonymous namespace)::V8ScriptValueSerializerForModulesTest_RoundTripCryptoKeyX25519_Test::TestBody()
```

Specifically there's something off in the template code that starts with `SyncGenerateKeyPair`/`SyncGenerateKey`[1] in
third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc that i wasn't able to figure out

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc;drc=5057ee5f97babbb66b52a7d875439585d18cc70a;l=395?q=RoundTripCryptoKeyX25519

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
  • David Benjamin
  • Nate Chapin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7011668d19f7361e9746df07e7d601093192a734
Gerrit-Change-Number: 7754862
Gerrit-PatchSet: 6
Gerrit-Owner: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: David Benjamin <davi...@chromium.org>
Gerrit-Attention: David Benjamin <davi...@chromium.org>
Gerrit-Attention: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Fri, 24 Apr 2026 18:50:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nate Chapin (Gerrit)

unread,
Apr 24, 2026, 6:29:29 PM (2 days ago) Apr 24
to Hubert Chao, David Benjamin, Daniel Cheng, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, kinuko...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org
Attention needed from Daniel Cheng, David Benjamin and Hubert Chao

Nate Chapin added 1 comment

Patchset-level comments
Nate Chapin

Yeah, it's ugly. I think these diffs will get it working on PS6.

```
diff --git a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc
index 947e3b296e138..8c575643cf5ef 100644
--- a/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc
+++ b/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc
@@ -31,12 +31,14 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_browser_capture_media_stream_track.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_crop_target.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_crypto_key.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_crypto_key_pair.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_dom_file_system.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_stream_track.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_restriction_target.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_certificate.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_data_channel.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_rtc_data_channel_state.h"
+#include "third_party/blink/renderer/bindings/modules/v8/v8_union_cryptokey_cryptokeypair.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
@@ -276,25 +278,9 @@ TEST(V8ScriptValueSerializerForModulesTest, DecodeInvalidRTCCertificate) {
// A bunch of voodoo which allows the asynchronous WebCrypto operations to be
// called synchronously, with the resulting JavaScript values extracted.

-using CryptoKeyPair = std::pair<CryptoKey*, CryptoKey*>;
-
template <typename T>
T ConvertCryptoResult(v8::Isolate*, const ScriptValue&);
-template <>
-CryptoKey* ConvertCryptoResult<CryptoKey*>(v8::Isolate* isolate,
- const ScriptValue& value) {
- return V8CryptoKey::ToWrappable(isolate, value.V8Value());
-}
-template <>
-CryptoKeyPair ConvertCryptoResult<CryptoKeyPair>(v8::Isolate* isolate,
- const ScriptValue& value) {
- Dictionary dictionary(isolate, value.V8Value(), ASSERT_NO_EXCEPTION);
- v8::Local<v8::Value> private_key, public_key;
- EXPECT_TRUE(dictionary.Get("publicKey", public_key));
- EXPECT_TRUE(dictionary.Get("privateKey", private_key));
- return std::make_pair(V8CryptoKey::ToWrappable(isolate, public_key),
- V8CryptoKey::ToWrappable(isolate, private_key));
-}
+
template <>
DOMException* ConvertCryptoResult<DOMException*>(v8::Isolate* isolate,
const ScriptValue& value) {
@@ -333,6 +319,11 @@ class WebCryptoResultAdapter
void React(ScriptState* script_state, CryptoKey* crypto_key) {
function_.Run(crypto_key);
}
+ template <typename I = IDLType>
+ requires(std::is_same_v<I, V8UnionCryptoKeyOrCryptoKeyPair>)
+ void React(ScriptState* script_state, V8UnionCryptoKeyOrCryptoKeyPair* crypto_union) {
+ function_.Run(crypto_union);
+ }
template <typename I = IDLType>
requires(std::is_same_v<I, DOMArrayBuffer>)
void React(ScriptState* script_state, DOMArrayBuffer* buffer) {
@@ -384,22 +375,14 @@ T SubtleCryptoSync(V8TestingScope& scope, PMF func, Args&&... args) {
return result;
}

-CryptoKey* SyncGenerateKey(V8TestingScope& scope,
+V8UnionCryptoKeyOrCryptoKeyPair* SyncGenerateKey(V8TestingScope& scope,
const WebCryptoAlgorithm& algorithm,
bool extractable,
WebCryptoKeyUsageMask usages) {
- return SubtleCryptoSync<CryptoKey*, IDLAny>(scope, &WebCrypto::GenerateKey,
+ return SubtleCryptoSync<V8UnionCryptoKeyOrCryptoKeyPair*, V8UnionCryptoKeyOrCryptoKeyPair>(scope, &WebCrypto::GenerateKey,
algorithm, extractable, usages);
}

-CryptoKeyPair SyncGenerateKeyPair(V8TestingScope& scope,
- const WebCryptoAlgorithm& algorithm,
- bool extractable,
- WebCryptoKeyUsageMask usages) {
- return SubtleCryptoSync<CryptoKeyPair, IDLAny>(
- scope, &WebCrypto::GenerateKey, algorithm, extractable, usages);
-}
-
CryptoKey* SyncImportKey(V8TestingScope& scope,
WebCryptoKeyFormat format,
std::vector<unsigned char> data,
@@ -470,7 +453,7 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyAES) {
WebCryptoAlgorithm algorithm(kWebCryptoAlgorithmIdAesCbc, std::move(params));
CryptoKey* key =
SyncGenerateKey(scope, algorithm, true,
- kWebCryptoKeyUsageEncrypt | kWebCryptoKeyUsageDecrypt);
+ kWebCryptoKeyUsageEncrypt | kWebCryptoKeyUsageDecrypt)->GetAsCryptoKey();

// Round trip it and check the visible attributes.
v8::Local<v8::Value> wrapper =
@@ -545,7 +528,7 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyHMAC) {
std::move(generate_key_params));
CryptoKey* key =
SyncGenerateKey(scope, generate_key_algorithm, true,
- kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify);
+ kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify)->GetAsCryptoKey();

// Round trip it and check the visible attributes.
v8::Local<v8::Value> wrapper =
@@ -618,11 +601,11 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyRSAHashed) {
new WebCryptoRsaHashedKeyGenParams(hash, 1024, {1, 0, 1}));
WebCryptoAlgorithm generate_key_algorithm(kWebCryptoAlgorithmIdRsaPss,
std::move(generate_key_params));
- CryptoKey* public_key;
- CryptoKey* private_key;
- std::tie(public_key, private_key) =
- SyncGenerateKeyPair(scope, generate_key_algorithm, true,
- kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify);
+ CryptoKeyPair* key_pair =
+ SyncGenerateKey(scope, generate_key_algorithm, true,
+ kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify)->GetAsCryptoKeyPair();
+ CryptoKey* public_key = key_pair->publicKey();
+ CryptoKey* private_key = key_pair->privateKey();

// Round trip the private key and check the visible attributes.
v8::Local<v8::Value> wrapper =
@@ -713,11 +696,11 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyEC) {
new WebCryptoEcKeyGenParams(kWebCryptoNamedCurveP256));
WebCryptoAlgorithm generate_key_algorithm(kWebCryptoAlgorithmIdEcdsa,
std::move(generate_key_params));
- CryptoKey* public_key;
- CryptoKey* private_key;
- std::tie(public_key, private_key) =
- SyncGenerateKeyPair(scope, generate_key_algorithm, true,
- kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify);
+ CryptoKeyPair* key_pair =
+ SyncGenerateKey(scope, generate_key_algorithm, true,
+ kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify)->GetAsCryptoKeyPair();
+ CryptoKey* public_key = key_pair->publicKey();
+ CryptoKey* private_key = key_pair->privateKey();

// Round trip the private key and check the visible attributes.
v8::Local<v8::Value> wrapper =
@@ -798,11 +781,11 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyEd25519) {
// Generate an Ed25519 key pair.
WebCryptoAlgorithm generate_key_algorithm(kWebCryptoAlgorithmIdEd25519,
nullptr);
- CryptoKey* public_key;
- CryptoKey* private_key;
- std::tie(public_key, private_key) =
- SyncGenerateKeyPair(scope, generate_key_algorithm, true,
- kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify);
+ CryptoKeyPair* key_pair =
+ SyncGenerateKey(scope, generate_key_algorithm, true,
+ kWebCryptoKeyUsageSign | kWebCryptoKeyUsageVerify)->GetAsCryptoKeyPair();
+ CryptoKey* public_key = key_pair->publicKey();
+ CryptoKey* private_key = key_pair->privateKey();

// Round trip the private key and check the visible attributes.
v8::Local<v8::Value> wrapper =
@@ -878,9 +861,11 @@ TEST(V8ScriptValueSerializerForModulesTest, RoundTripCryptoKeyX25519) {
// Generate an X25519 key pair.
WebCryptoAlgorithm generate_key_algorithm(kWebCryptoAlgorithmIdX25519,
nullptr);
- auto [public_key, private_key] = SyncGenerateKeyPair(
- scope, generate_key_algorithm, true,
- kWebCryptoKeyUsageDeriveKey | kWebCryptoKeyUsageDeriveBits);
+ CryptoKeyPair* key_pair =
+ SyncGenerateKey(scope, generate_key_algorithm, true,
+ kWebCryptoKeyUsageDeriveKey | kWebCryptoKeyUsageDeriveBits)->GetAsCryptoKeyPair();
+ CryptoKey* public_key = key_pair->publicKey();
+ CryptoKey* private_key = key_pair->privateKey();

// Round trip the private key and check the visible attributes.
v8::Local<v8::Value> wrapper =
diff --git a/third_party/blink/renderer/modules/crypto/crypto_result_impl.cc b/third_party/blink/renderer/modules/crypto/crypto_result_impl.cc
index 4fa99722728f1..97e9a26553fe0 100644
--- a/third_party/blink/renderer/modules/crypto/crypto_result_impl.cc
+++ b/third_party/blink/renderer/modules/crypto/crypto_result_impl.cc
@@ -198,13 +198,8 @@ void CryptoResultImpl::CompleteWithKeyForGenerateKey(const WebCryptoKey& key) {
}

auto* result = MakeGarbageCollected<CryptoKey>(key);
- if (type_ == ResolverType::kTyped) {
- resolver_->DowncastTo<V8UnionCryptoKeyOrCryptoKeyPair>()->Resolve(result);
- } else {
- ScriptState* script_state = resolver_->GetScriptState();
- ScriptState::Scope scope(script_state);
- resolver_->DowncastTo<IDLAny>()->Resolve(result->ToV8(script_state));
- }
+ CHECK_EQ(type_, ResolverType::kTyped);
+ resolver_->DowncastTo<V8UnionCryptoKeyOrCryptoKeyPair>()->Resolve(result);
ClearResolver();
}

@@ -219,13 +214,8 @@ void CryptoResultImpl::CompleteWithKeyPairForGenerateKey(
result->setPublicKey(MakeGarbageCollected<CryptoKey>(public_key));
result->setPrivateKey(MakeGarbageCollected<CryptoKey>(private_key));

- if (type_ == ResolverType::kTyped) {
- resolver_->DowncastTo<V8UnionCryptoKeyOrCryptoKeyPair>()->Resolve(result);
- } else {
- ScriptState* script_state = resolver_->GetScriptState();
- ScriptState::Scope scope(script_state);
- resolver_->DowncastTo<IDLAny>()->Resolve(result->ToV8(script_state));
- }
+ CHECK_EQ(type_, ResolverType::kTyped);
+ resolver_->DowncastTo<V8UnionCryptoKeyOrCryptoKeyPair>()->Resolve(result);
ClearResolver();
}
```
Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
  • David Benjamin
  • Hubert Chao
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7011668d19f7361e9746df07e7d601093192a734
Gerrit-Change-Number: 7754862
Gerrit-PatchSet: 6
Gerrit-Owner: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Hubert Chao <hc...@chromium.org>
Gerrit-Reviewer: Nate Chapin <jap...@chromium.org>
Gerrit-CC: David Benjamin <davi...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Hubert Chao <hc...@chromium.org>
Gerrit-Attention: David Benjamin <davi...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Fri, 24 Apr 2026 22:29:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Hubert Chao <hc...@chromium.org>
Comment-In-Reply-To: Nate Chapin <jap...@chromium.org>
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages