mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-10 19:46:03 +00:00
Tests: Remove use of VLAs from TestRSA.cpp
This commit removes the use of variable length arrays from the tests for RSA. This is the last remaining place using VLAs.
This commit is contained in:
parent
edd3b14ddf
commit
74309ce8c2
Notes:
github-actions[bot]
2024-12-20 08:38:57 +00:00
Author: https://github.com/R-Goc
Commit: 74309ce8c2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2945
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/shlyakpavel
1 changed files with 20 additions and 12 deletions
|
@ -25,8 +25,9 @@ TEST_CASE(test_RSA_raw_encrypt)
|
||||||
"8126832723025844890518845777858816391166654950553329127845898924164623511718747856014227624997335860970996746552094406240834082304784428582653994490504519"_bigint,
|
"8126832723025844890518845777858816391166654950553329127845898924164623511718747856014227624997335860970996746552094406240834082304784428582653994490504519"_bigint,
|
||||||
"65537"_bigint,
|
"65537"_bigint,
|
||||||
});
|
});
|
||||||
u8 buffer[rsa.output_size()];
|
ByteBuffer buffer = {};
|
||||||
auto buf = Bytes { buffer, sizeof(buffer) };
|
buffer.resize(rsa.output_size());
|
||||||
|
auto buf = buffer.bytes();
|
||||||
rsa.encrypt(data, buf);
|
rsa.encrypt(data, buf);
|
||||||
EXPECT(memcmp(result, buf.data(), buf.size()) == 0);
|
EXPECT(memcmp(result, buf.data(), buf.size()) == 0);
|
||||||
}
|
}
|
||||||
|
@ -36,8 +37,9 @@ TEST_CASE(test_RSA_PKCS_1_encrypt)
|
||||||
{
|
{
|
||||||
ByteBuffer data { "hellohellohellohellohellohellohellohellohello123-"_b };
|
ByteBuffer data { "hellohellohellohellohellohellohellohellohello123-"_b };
|
||||||
Crypto::PK::RSA_PKCS1_EME rsa(Crypto::PK::RSA::generate_key_pair(1024));
|
Crypto::PK::RSA_PKCS1_EME rsa(Crypto::PK::RSA::generate_key_pair(1024));
|
||||||
u8 buffer[rsa.output_size()];
|
ByteBuffer buffer = {};
|
||||||
auto buf = Bytes { buffer, sizeof(buffer) };
|
buffer.resize(rsa.output_size());
|
||||||
|
auto buf = buffer.bytes();
|
||||||
rsa.encrypt(data, buf);
|
rsa.encrypt(data, buf);
|
||||||
rsa.decrypt(buf, buf);
|
rsa.decrypt(buf, buf);
|
||||||
|
|
||||||
|
@ -134,11 +136,14 @@ c8yGzl89pYST
|
||||||
|
|
||||||
EXPECT_EQ(keypem, StringView(priv_pem));
|
EXPECT_EQ(keypem, StringView(priv_pem));
|
||||||
|
|
||||||
u8 enc_buffer[rsa_from_pair.output_size()];
|
ByteBuffer enc_buffer = {};
|
||||||
u8 dec_buffer[rsa_from_pair.output_size()];
|
enc_buffer.resize(rsa_from_pair.output_size());
|
||||||
|
|
||||||
auto enc = Bytes { enc_buffer, rsa_from_pair.output_size() };
|
ByteBuffer dec_buffer = {};
|
||||||
auto dec = Bytes { dec_buffer, rsa_from_pair.output_size() };
|
dec_buffer.resize(rsa_from_pair.output_size());
|
||||||
|
|
||||||
|
auto enc = enc_buffer.bytes();
|
||||||
|
auto dec = dec_buffer.bytes();
|
||||||
|
|
||||||
dec.overwrite(0, "WellHelloFriends", 16);
|
dec.overwrite(0, "WellHelloFriends", 16);
|
||||||
|
|
||||||
|
@ -152,11 +157,14 @@ TEST_CASE(test_RSA_encrypt_decrypt)
|
||||||
{
|
{
|
||||||
Crypto::PK::RSA rsa(Crypto::PK::RSA::generate_key_pair(1024));
|
Crypto::PK::RSA rsa(Crypto::PK::RSA::generate_key_pair(1024));
|
||||||
|
|
||||||
u8 enc_buffer[rsa.output_size()];
|
ByteBuffer enc_buffer = {};
|
||||||
u8 dec_buffer[rsa.output_size()];
|
enc_buffer.resize(rsa.output_size());
|
||||||
|
|
||||||
auto enc = Bytes { enc_buffer, rsa.output_size() };
|
ByteBuffer dec_buffer = {};
|
||||||
auto dec = Bytes { dec_buffer, rsa.output_size() };
|
dec_buffer.resize(rsa.output_size());
|
||||||
|
|
||||||
|
auto enc = enc_buffer.bytes();
|
||||||
|
auto dec = dec_buffer.bytes();
|
||||||
|
|
||||||
enc.overwrite(0, "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64);
|
enc.overwrite(0, "WellHelloFriendsWellHelloFriendsWellHelloFriendsWellHelloFriends", 64);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue