From 8bb52c7b67b85b37e65b876f46230dea535d1f4d Mon Sep 17 00:00:00 2001 From: Tete17 Date: Sat, 22 Nov 2025 21:43:10 +0100 Subject: [PATCH] LibCrypto: Remove no longer needed output_size in Public Key class It is a remnant of serenityos and doesn't make sense in non RSA algorithms. --- Libraries/LibCrypto/PK/PK.h | 2 -- Libraries/LibCrypto/PK/RSA.h | 5 ----- Tests/LibCrypto/TestRSA.cpp | 6 +++--- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Libraries/LibCrypto/PK/PK.h b/Libraries/LibCrypto/PK/PK.h index d3ab0156cd..8640829cd8 100644 --- a/Libraries/LibCrypto/PK/PK.h +++ b/Libraries/LibCrypto/PK/PK.h @@ -239,8 +239,6 @@ public: virtual ByteString class_name() const = 0; - virtual size_t output_size() const = 0; - protected: virtual ~PKSystem() = default; diff --git a/Libraries/LibCrypto/PK/RSA.h b/Libraries/LibCrypto/PK/RSA.h index 10c7bb67ee..e001148c20 100644 --- a/Libraries/LibCrypto/PK/RSA.h +++ b/Libraries/LibCrypto/PK/RSA.h @@ -184,11 +184,6 @@ public: return "RSA"; } - virtual size_t output_size() const override - { - return m_public_key.length(); - } - void import_public_key(ReadonlyBytes, bool pem = true); void import_private_key(ReadonlyBytes, bool pem = true); diff --git a/Tests/LibCrypto/TestRSA.cpp b/Tests/LibCrypto/TestRSA.cpp index 0d2b1c36b9..1373636fd8 100644 --- a/Tests/LibCrypto/TestRSA.cpp +++ b/Tests/LibCrypto/TestRSA.cpp @@ -134,7 +134,7 @@ c8yGzl89pYST EXPECT_EQ(keypem, StringView(priv_pem)); ByteBuffer msg_buffer = {}; - msg_buffer.resize(rsa_from_pair.output_size()); + msg_buffer.resize(rsa_from_pair.public_key().length()); auto msg = msg_buffer.bytes(); msg.overwrite(0, "WellHelloFriends", 16); @@ -151,7 +151,7 @@ TEST_CASE(test_RSA_encrypt_decrypt) Crypto::PK::RSA rsa(keypair); ByteBuffer msg_buffer = {}; - msg_buffer.resize(rsa.output_size()); + msg_buffer.resize(rsa.public_key().length()); auto msg = msg_buffer.bytes(); msg.overwrite(0, "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64); @@ -168,7 +168,7 @@ TEST_CASE(test_RSA_sign_verify) Crypto::PK::RSA rsa(keypair); ByteBuffer msg_buffer = {}; - msg_buffer.resize(rsa.output_size()); + msg_buffer.resize(rsa.public_key().length()); auto msg = msg_buffer.bytes(); msg.overwrite(0, "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64);