From ed7666b445666a57f938e7e55c08975fbea3246e Mon Sep 17 00:00:00 2001 From: Claudio DeSouza Date: Sat, 12 Jul 2025 05:46:38 +0100 Subject: [PATCH] [cr140] `SignatureCreator` deleted This change removes the only use in Brave for `SignatureCreator`, and replaces it with `crypto::sign::Sign`. Chromium changes: https://chromium.googlesource.com/chromium/src/+/cb74f0799e82a75b96c414272adbeddf48db0a6b https://chromium.googlesource.com/chromium/src/+/7e517f85c0974949ee096e089e65dcdd8173f587 commit cb74f0799e82a75b96c414272adbeddf48db0a6b Author: Elly Date: Tue Jul 8 20:24:53 2025 -0700 crypto: get rid of SignatureCreator All the remaining deps on it are gone now. Bug: 406190025 Change-Id: I10b9f37007c5308b98b64c02756d9d382eb1d838 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6711257 Reviewed-by: David Benjamin Reviewed-by: Xiyuan Xia Commit-Queue: Elly FJ Reviewed-by: Sergey Poromov Cr-Commit-Position: refs/heads/main@{#1484137} commit 7e517f85c0974949ee096e089e65dcdd8173f587 Author: Elly Date: Thu Jul 3 08:33:14 2025 -0700 components/policy: stop using SignatureCreator Instead, use crypto::sign::Sign(), which is functionally identical but not deprecated. Bug: 428657808 Change-Id: I50ffd6a84d31bd34221302c38c177ac7948954a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6692471 Commit-Queue: Elly FJ Reviewed-by: Sylvain Defresne Cr-Commit-Position: refs/heads/main@{#1482292} --- components/web_discovery/browser/rsa.cc | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/components/web_discovery/browser/rsa.cc b/components/web_discovery/browser/rsa.cc index 9b9dbaffa2e..ebf5c485f5e 100644 --- a/components/web_discovery/browser/rsa.cc +++ b/components/web_discovery/browser/rsa.cc @@ -11,8 +11,9 @@ #include "base/base64.h" #include "base/check.h" #include "base/threading/thread_restrictions.h" +#include "crypto/keypair.h" #include "crypto/rsa_private_key.h" -#include "crypto/signature_creator.h" +#include "crypto/sign.h" namespace web_discovery { @@ -81,20 +82,11 @@ std::optional RSASign(crypto::RSAPrivateKey* key, base::AssertLongCPUWorkAllowed(); CHECK(key); - std::vector signature; - auto signature_creator = crypto::SignatureCreator::Create( - key, crypto::SignatureCreator::HashAlgorithm::SHA256); - if (!signature_creator) { - return std::nullopt; - } - if (!signature_creator->Update(message.data(), message.size())) { - return std::nullopt; - } - if (!signature_creator->Final(&signature)) { - return std::nullopt; - } - - return base::Base64Encode(signature); + auto wrapped_key = + crypto::keypair::PrivateKey::FromDeprecatedRSAPrivateKey(key); + std::vector signature_bytes = crypto::sign::Sign( + crypto::sign::SignatureKind::RSA_PKCS1_SHA256, wrapped_key, message); + return base::Base64Encode(signature_bytes); } } // namespace web_discovery