summaryrefslogtreecommitdiff
path: root/Tests/LibCrypto
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 17:32:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch)
tree152c7a187c98184d58bf91a326357e0af435edcf /Tests/LibCrypto
parente5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff)
downloadserenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
Diffstat (limited to 'Tests/LibCrypto')
-rw-r--r--Tests/LibCrypto/TestBigInteger.cpp4
-rw-r--r--Tests/LibCrypto/TestHMAC.cpp52
-rw-r--r--Tests/LibCrypto/TestHash.cpp80
-rw-r--r--Tests/LibCrypto/TestRSA.cpp4
4 files changed, 70 insertions, 70 deletions
diff --git a/Tests/LibCrypto/TestBigInteger.cpp b/Tests/LibCrypto/TestBigInteger.cpp
index 94beca9553..b13e8aafed 100644
--- a/Tests/LibCrypto/TestBigInteger.cpp
+++ b/Tests/LibCrypto/TestBigInteger.cpp
@@ -234,7 +234,7 @@ TEST_CASE(test_unsigned_bigint_division_combined_test)
TEST_CASE(test_unsigned_bigint_base10_from_string)
{
- auto result = Crypto::UnsignedBigInteger::from_base(10, "57195071295721390579057195715793");
+ auto result = Crypto::UnsignedBigInteger::from_base(10, "57195071295721390579057195715793"sv);
Vector<u32> expected_result { 3806301393, 954919431, 3879607298, 721 };
EXPECT_EQ(result.words(), expected_result);
}
@@ -414,7 +414,7 @@ TEST_CASE(test_bigint_import_big_endian_encode_decode_roundtrip)
TEST_CASE(test_bigint_big_endian_import)
{
- auto number = Crypto::UnsignedBigInteger::import_data("hello");
+ auto number = Crypto::UnsignedBigInteger::import_data("hello"sv);
EXPECT_EQ(number, "448378203247"_bigint);
}
diff --git a/Tests/LibCrypto/TestHMAC.cpp b/Tests/LibCrypto/TestHMAC.cpp
index c07d371c8b..ec65553867 100644
--- a/Tests/LibCrypto/TestHMAC.cpp
+++ b/Tests/LibCrypto/TestHMAC.cpp
@@ -13,34 +13,34 @@
TEST_CASE(test_hmac_md5_name)
{
- Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends");
- EXPECT_EQ(hmac.class_name(), "HMAC-MD5");
+ Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends"sv);
+ EXPECT_EQ(hmac.class_name(), "HMAC-MD5"sv);
}
TEST_CASE(test_hmac_md5_process)
{
- Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends"sv);
u8 result[] {
0x3b, 0x5b, 0xde, 0x30, 0x3a, 0x54, 0x7b, 0xbb, 0x09, 0xfe, 0x78, 0x89, 0xbc, 0x9f, 0x22, 0xa3
};
- auto mac = hmac.process("Some bogus data");
+ auto mac = hmac.process("Some bogus data"sv);
EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_md5_process_reuse)
{
- Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends"sv);
- auto mac_0 = hmac.process("Some bogus data");
- auto mac_1 = hmac.process("Some bogus data");
+ auto mac_0 = hmac.process("Some bogus data"sv);
+ auto mac_1 = hmac.process("Some bogus data"sv);
EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha1_name)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA1> hmac("Well Hello Friends");
- EXPECT_EQ(hmac.class_name(), "HMAC-SHA1");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA1> hmac("Well Hello Friends"sv);
+ EXPECT_EQ(hmac.class_name(), "HMAC-SHA1"sv);
}
TEST_CASE(test_hmac_sha1_process)
@@ -76,72 +76,72 @@ TEST_CASE(test_hmac_sha1_process_reuse)
TEST_CASE(test_hmac_sha256_name)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
- EXPECT_EQ(hmac.class_name(), "HMAC-SHA256");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends"sv);
+ EXPECT_EQ(hmac.class_name(), "HMAC-SHA256"sv);
}
TEST_CASE(test_hmac_sha256_process)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends"sv);
u8 result[] {
0x1a, 0xf2, 0x20, 0x62, 0xde, 0x3b, 0x84, 0x65, 0xc1, 0x25, 0x23, 0x99, 0x76, 0x15, 0x1b, 0xec, 0x15, 0x21, 0x82, 0x1f, 0x23, 0xca, 0x11, 0x66, 0xdd, 0x8c, 0x6e, 0xf1, 0x81, 0x3b, 0x7f, 0x1b
};
- auto mac = hmac.process("Some bogus data");
+ auto mac = hmac.process("Some bogus data"sv);
EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha256_reuse)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends"sv);
- auto mac_0 = hmac.process("Some bogus data");
- auto mac_1 = hmac.process("Some bogus data");
+ auto mac_0 = hmac.process("Some bogus data"sv);
+ auto mac_1 = hmac.process("Some bogus data"sv);
EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha256_data_is_same_size_as_block)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends"sv);
u8 result[] = {
0x1d, 0x90, 0xce, 0x68, 0x45, 0x0b, 0xba, 0xd6, 0xbe, 0x1c, 0xb2, 0x3a, 0xea, 0x7f, 0xac, 0x4b, 0x68, 0x08, 0xa4, 0x77, 0x81, 0x2a, 0xad, 0x5d, 0x05, 0xe2, 0x15, 0xe8, 0xf4, 0xcb, 0x06, 0xaf
};
- auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv);
EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha256_data_is_bigger_size_as_block)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends"sv);
u8 result[] = {
0x9b, 0xa3, 0x9e, 0xf3, 0xb4, 0x30, 0x5f, 0x6f, 0x67, 0xd0, 0xa8, 0xb0, 0xf0, 0xcb, 0x12, 0xf5, 0x85, 0xe2, 0x19, 0xba, 0x0c, 0x8b, 0xe5, 0x43, 0xf0, 0x93, 0x39, 0xa8, 0xa3, 0x07, 0xf1, 0x95
};
- auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv);
EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha512_name)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends"sv);
EXPECT_EQ(hmac.class_name(), "HMAC-SHA512");
}
TEST_CASE(test_hmac_sha512_process)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends"sv);
u8 result[] {
0xeb, 0xa8, 0x34, 0x11, 0xfd, 0x5b, 0x46, 0x5b, 0xef, 0xbb, 0x67, 0x5e, 0x7d, 0xc2, 0x7c, 0x2c, 0x6b, 0xe1, 0xcf, 0xe6, 0xc7, 0xe4, 0x7d, 0xeb, 0xca, 0x97, 0xb7, 0x4c, 0xd3, 0x4d, 0x6f, 0x08, 0x9f, 0x0d, 0x3a, 0xf1, 0xcb, 0x00, 0x79, 0x78, 0x2f, 0x05, 0x8e, 0xeb, 0x94, 0x48, 0x0d, 0x50, 0x64, 0x3b, 0xca, 0x70, 0xe2, 0x69, 0x38, 0x4f, 0xe4, 0xb0, 0x49, 0x0f, 0xc5, 0x4c, 0x7a, 0xa7
};
- auto mac = hmac.process("Some bogus data");
+ auto mac = hmac.process("Some bogus data"sv);
EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0);
}
TEST_CASE(test_hmac_sha512_reuse)
{
- Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends");
+ Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends"sv);
- auto mac_0 = hmac.process("Some bogus data");
- auto mac_1 = hmac.process("Some bogus data");
+ auto mac_0 = hmac.process("Some bogus data"sv);
+ auto mac_1 = hmac.process("Some bogus data"sv);
EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0);
}
diff --git a/Tests/LibCrypto/TestHash.cpp b/Tests/LibCrypto/TestHash.cpp
index 29fd33f88c..d59ba7defd 100644
--- a/Tests/LibCrypto/TestHash.cpp
+++ b/Tests/LibCrypto/TestHash.cpp
@@ -23,7 +23,7 @@ TEST_CASE(test_MD5_hash_string)
u8 result[] {
0xaf, 0x04, 0x3a, 0x08, 0x94, 0x38, 0x6e, 0x7f, 0xbf, 0x73, 0xe4, 0xaa, 0xf0, 0x8e, 0xee, 0x4c
};
- auto digest = Crypto::Hash::MD5::hash("Well hello friends");
+ auto digest = Crypto::Hash::MD5::hash("Well hello friends"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
}
@@ -32,7 +32,7 @@ TEST_CASE(test_MD5_hash_empty_string)
u8 result[] {
0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e
};
- auto digest = Crypto::Hash::MD5::hash("");
+ auto digest = Crypto::Hash::MD5::hash(""sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
}
@@ -41,7 +41,7 @@ TEST_CASE(test_MD5_hash_single_character)
u8 result[] {
0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61
};
- auto digest = Crypto::Hash::MD5::hash("a");
+ auto digest = Crypto::Hash::MD5::hash("a"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
}
@@ -50,7 +50,7 @@ TEST_CASE(test_MD5_hash_alphabet)
u8 result[] {
0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b
};
- auto digest = Crypto::Hash::MD5::hash("abcdefghijklmnopqrstuvwxyz");
+ auto digest = Crypto::Hash::MD5::hash("abcdefghijklmnopqrstuvwxyz"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
}
@@ -59,7 +59,7 @@ TEST_CASE(test_MD5_hash_long_sequence)
u8 result[] {
0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a
};
- auto digest = Crypto::Hash::MD5::hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
+ auto digest = Crypto::Hash::MD5::hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
}
@@ -70,9 +70,9 @@ TEST_CASE(test_MD5_consecutive_multiple_updates)
};
Crypto::Hash::MD5 md5;
- md5.update("Well");
- md5.update(" hello ");
- md5.update("friends");
+ md5.update("Well"sv);
+ md5.update(" hello "sv);
+ md5.update("friends"sv);
auto digest = md5.digest();
EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0);
@@ -82,14 +82,14 @@ TEST_CASE(test_MD5_consecutive_updates_reuse)
{
Crypto::Hash::MD5 md5;
- md5.update("Well");
- md5.update(" hello ");
- md5.update("friends");
+ md5.update("Well"sv);
+ md5.update(" hello "sv);
+ md5.update("friends"sv);
auto digest0 = md5.digest();
- md5.update("Well");
- md5.update(" hello ");
- md5.update("friends");
+ md5.update("Well"sv);
+ md5.update(" hello "sv);
+ md5.update("friends"sv);
auto digest1 = md5.digest();
EXPECT(memcmp(digest0.data, digest1.data, Crypto::Hash::MD5::digest_size()) == 0);
@@ -98,7 +98,7 @@ TEST_CASE(test_MD5_consecutive_updates_reuse)
TEST_CASE(test_SHA1_name)
{
Crypto::Hash::SHA1 sha;
- EXPECT(sha.class_name() == "SHA1");
+ EXPECT(sha.class_name() == "SHA1"sv);
}
TEST_CASE(test_SHA1_hash_empty_string)
@@ -106,7 +106,7 @@ TEST_CASE(test_SHA1_hash_empty_string)
u8 result[] {
0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09
};
- auto digest = Crypto::Hash::SHA1::hash("");
+ auto digest = Crypto::Hash::SHA1::hash(""sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0);
}
@@ -115,7 +115,7 @@ TEST_CASE(test_SHA1_hash_long_string)
u8 result[] {
0x12, 0x15, 0x1f, 0xb1, 0x04, 0x44, 0x93, 0xcc, 0xed, 0x54, 0xa6, 0xb8, 0x7e, 0x93, 0x37, 0x7b, 0xb2, 0x13, 0x39, 0xdb
};
- auto digest = Crypto::Hash::SHA1::hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+ auto digest = Crypto::Hash::SHA1::hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0);
}
@@ -125,19 +125,19 @@ TEST_CASE(test_SHA1_hash_successive_updates)
0xd6, 0x6e, 0xce, 0xd1, 0xf4, 0x08, 0xc6, 0xd8, 0x35, 0xab, 0xf0, 0xc9, 0x05, 0x26, 0xa4, 0xb2, 0xb8, 0xa3, 0x7c, 0xd3
};
auto hasher = Crypto::Hash::SHA1 {};
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaaaaaaaa");
- hasher.update("aaaaaaaaa");
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaaaaaaaa"sv);
+ hasher.update("aaaaaaaaa"sv);
auto digest = hasher.digest();
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0);
}
@@ -145,7 +145,7 @@ TEST_CASE(test_SHA1_hash_successive_updates)
TEST_CASE(test_SHA256_name)
{
Crypto::Hash::SHA256 sha;
- EXPECT_EQ(sha.class_name(), "SHA256");
+ EXPECT_EQ(sha.class_name(), "SHA256"sv);
}
TEST_CASE(test_SHA256_hash_string)
@@ -153,7 +153,7 @@ TEST_CASE(test_SHA256_hash_string)
u8 result[] {
0x9a, 0xcd, 0x50, 0xf9, 0xa2, 0xaf, 0x37, 0xe4, 0x71, 0xf7, 0x61, 0xc3, 0xfe, 0x7b, 0x8d, 0xea, 0x56, 0x17, 0xe5, 0x1d, 0xac, 0x80, 0x2f, 0xe6, 0xc1, 0x77, 0xb7, 0x4a, 0xbf, 0x0a, 0xbb, 0x5a
};
- auto digest = Crypto::Hash::SHA256::hash("Well hello friends");
+ auto digest = Crypto::Hash::SHA256::hash("Well hello friends"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0);
}
@@ -162,14 +162,14 @@ TEST_CASE(test_SHA256_hash_empty_string)
u8 result[] {
0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55
};
- auto digest = Crypto::Hash::SHA256::hash("");
+ auto digest = Crypto::Hash::SHA256::hash(""sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0);
}
TEST_CASE(test_SHA384_name)
{
Crypto::Hash::SHA384 sha;
- EXPECT_EQ(sha.class_name(), "SHA384");
+ EXPECT_EQ(sha.class_name(), "SHA384"sv);
}
TEST_CASE(test_SHA384_hash_string)
@@ -177,7 +177,7 @@ TEST_CASE(test_SHA384_hash_string)
u8 result[] {
0x2f, 0x01, 0x8e, 0x9a, 0x4f, 0xd1, 0x36, 0xb9, 0x0f, 0xcc, 0x21, 0xde, 0x1a, 0xd4, 0x49, 0x51, 0x57, 0x82, 0x86, 0x84, 0x54, 0x09, 0x82, 0x7b, 0x54, 0x56, 0x93, 0xac, 0x2c, 0x46, 0x0c, 0x1f, 0x5e, 0xec, 0xe0, 0xf7, 0x8b, 0x0b, 0x84, 0x27, 0xc8, 0xb8, 0xbe, 0x49, 0xce, 0x8f, 0x1c, 0xff
};
- auto digest = Crypto::Hash::SHA384::hash("Well hello friends");
+ auto digest = Crypto::Hash::SHA384::hash("Well hello friends"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA384::digest_size()) == 0);
}
@@ -187,14 +187,14 @@ TEST_CASE(test_SHA384_hash_bug)
0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39
};
ReadonlyBytes result_bytes { result, 48 };
- auto digest = Crypto::Hash::SHA384::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu");
+ auto digest = Crypto::Hash::SHA384::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"sv);
EXPECT_EQ(result_bytes, digest.bytes());
}
TEST_CASE(test_SHA512_name)
{
Crypto::Hash::SHA512 sha;
- EXPECT_EQ(sha.class_name(), "SHA512");
+ EXPECT_EQ(sha.class_name(), "SHA512"sv);
}
TEST_CASE(test_SHA512_hash_string)
@@ -202,7 +202,7 @@ TEST_CASE(test_SHA512_hash_string)
u8 result[] {
0x00, 0xfe, 0x68, 0x09, 0x71, 0x0e, 0xcb, 0x2b, 0xe9, 0x58, 0x00, 0x13, 0x69, 0x6a, 0x9e, 0x9e, 0xbd, 0x09, 0x1b, 0xfe, 0x14, 0xc9, 0x13, 0x82, 0xc7, 0x40, 0x34, 0xfe, 0xca, 0xe6, 0x87, 0xcb, 0x26, 0x36, 0x92, 0xe6, 0x34, 0x94, 0x3a, 0x11, 0xe5, 0xbb, 0xb5, 0xeb, 0x8e, 0x70, 0xef, 0x64, 0xca, 0xf7, 0x21, 0xb1, 0xde, 0xf2, 0x34, 0x85, 0x6f, 0xa8, 0x56, 0xd8, 0x23, 0xa1, 0x3b, 0x29
};
- auto digest = Crypto::Hash::SHA512::hash("Well hello friends");
+ auto digest = Crypto::Hash::SHA512::hash("Well hello friends"sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA512::digest_size()) == 0);
}
@@ -212,7 +212,7 @@ TEST_CASE(test_SHA512_hash_bug)
0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09
};
ReadonlyBytes result_bytes { result, 64 };
- auto digest = Crypto::Hash::SHA512::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu");
+ auto digest = Crypto::Hash::SHA512::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"sv);
EXPECT_EQ(result_bytes, digest.bytes());
}
@@ -221,7 +221,7 @@ TEST_CASE(test_SHA512_hash_empty_string)
u8 result[] {
0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd, 0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07, 0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc, 0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce, 0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0, 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e
};
- auto digest = Crypto::Hash::SHA512::hash("");
+ auto digest = Crypto::Hash::SHA512::hash(""sv);
EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA512::digest_size()) == 0);
}
diff --git a/Tests/LibCrypto/TestRSA.cpp b/Tests/LibCrypto/TestRSA.cpp
index 04c72f8f42..56dd495063 100644
--- a/Tests/LibCrypto/TestRSA.cpp
+++ b/Tests/LibCrypto/TestRSA.cpp
@@ -55,7 +55,7 @@ joNOYoR5R9z5oX2cpcyykQ58FC2vKKg+x8N6xczG7qO95tw5UQIhAN354CP/FA+uTeJ6KJ+i
zCBCl58CjNCzO0s5HTc56el5AiEAsvPKXo5/9gS/S4UzDRP6abq7GreixTfjR8LXidk3FL8C
IQCTjYI861Y+hjMnlORkGSdvWlTHUj6gjEOh4TlWeJzQoQIgAxMZOQKtxCZUuxFwzRq4xLRG
nrDlBQpuxz7bwSyQO7UCIHrYMnDohgNbwtA5ZpW3H1cKKQQvueWm6sxW9P5sUrZ3
------END RSA PRIVATE KEY-----)";
+-----END RSA PRIVATE KEY-----)"sv;
Crypto::PK::RSA rsa(privkey);
if (rsa.public_key().public_exponent() != 65537) {
@@ -96,7 +96,7 @@ o+7RC7iOkO+rnzTXwxBSBpXMiUTAIx/hrdfPVxQT+wKBgCh7N3OLIOH6EWcW1fif
UoENh8rkt/kzm89G1JLwBhuBIBPXUEZt2dS/xSUempqVqFGONpP87gvqxkMTtgCA
73KXn/cxHWM2kmXyHA3kQlOYw6WHjpldQAxLE+TRHXO2JUtZ09Mu4rVXX7lmwbTm
l3vmuDEF3/Bo1C1HTg0xRV/l
------END PRIVATE KEY-----)";
+-----END PRIVATE KEY-----)"sv;
Crypto::PK::RSA rsa(privkey);
if (rsa.public_key().public_exponent() != 65537) {