summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-26 23:46:17 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-26 23:46:17 +0200
commitb0eca4023f2c7461aaa391eab5bb5617914b8165 (patch)
treea99e8c41a64278886c4ba7cb9f3d55450bcefc1a
parent4ec8b9f6ee8275782ff425d1815f6b3e7bba0fb8 (diff)
downloadserenity-b0eca4023f2c7461aaa391eab5bb5617914b8165.zip
LibCrypto: Put some debug spam behind CRYPTO_DEBUG
-rw-r--r--Libraries/LibCrypto/PK/RSA.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp
index 9fae5047bd..7e257b1715 100644
--- a/Libraries/LibCrypto/PK/RSA.cpp
+++ b/Libraries/LibCrypto/PK/RSA.cpp
@@ -114,7 +114,9 @@ RSA::KeyPairType RSA::parse_rsa_key(const ByteBuffer& in)
void RSA::encrypt(const ByteBuffer& in, ByteBuffer& out)
{
+#ifdef CRYPTO_DEBUG
dbg() << "in size: " << in.size();
+#endif
auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size());
if (!(in_integer < m_public_key.modulus())) {
dbg() << "value too large for key";
@@ -218,7 +220,9 @@ VerificationConsistency RSA_EMSA_PSS<HashFunction>::verify(const ByteBuffer& in)
void RSA_PKCS1_EME::encrypt(const ByteBuffer& in, ByteBuffer& out)
{
auto mod_len = (m_public_key.modulus().trimmed_length() * sizeof(u32) * 8 + 7) / 8;
+#ifdef CRYPTO_DEBUG
dbg() << "key size: " << mod_len;
+#endif
if (in.size() > mod_len - 11) {
dbg() << "message too long :(";
out.trim(0);
@@ -247,7 +251,9 @@ void RSA_PKCS1_EME::encrypt(const ByteBuffer& in, ByteBuffer& out)
out.overwrite(3 + ps_length, in.data(), in.size());
out.trim(3 + ps_length + in.size()); // should be a single block
+#ifdef CRYPTO_DEBUG
dbg() << "padded output size: " << 3 + ps_length + in.size() << " buffer size: " << out.size();
+#endif
RSA::encrypt(out, out);
}