mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibCrypto+LibTLS: Replace RSA_PKCS1-EMSA
implementation
This commit replaces the old implementation of `EMSA_PKCS1_V1_5` with one backed by OpenSSL. In doing so, the `sign` and `verify` methods of RSA have been modified to behave like expected and not just be encryption and decryption. I was not able to split this commit because the changes to `verify` and `sign` break pretty much everything.
This commit is contained in:
parent
4b832b67fb
commit
70bc26e32a
Notes:
github-actions[bot]
2025-01-13 16:01:27 +00:00
Author: https://github.com/devgianlu
Commit: 70bc26e32a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3234
6 changed files with 236 additions and 50 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Peter Bocan <me@pbocan.net>
|
||||
* Copyright (c) 2025, Altomani Gianluca <altomanigianluca@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -160,3 +161,19 @@ TEST_CASE(test_RSA_encrypt_decrypt)
|
|||
|
||||
EXPECT(memcmp(dec.data(), "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE(test_RSA_sign_verify)
|
||||
{
|
||||
auto keypair = TRY_OR_FAIL(Crypto::PK::RSA::generate_key_pair(1024));
|
||||
Crypto::PK::RSA rsa(keypair);
|
||||
|
||||
ByteBuffer msg_buffer = {};
|
||||
msg_buffer.resize(rsa.output_size());
|
||||
|
||||
auto msg = msg_buffer.bytes();
|
||||
msg.overwrite(0, "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64);
|
||||
|
||||
auto sig = TRY_OR_FAIL(rsa.sign(msg));
|
||||
auto ok = TRY_OR_FAIL(rsa.verify(msg, sig));
|
||||
EXPECT_EQ(ok, true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue