summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibCrypto/PK/PK.h4
-rw-r--r--Libraries/LibCrypto/PK/RSA.cpp12
-rw-r--r--Libraries/LibCrypto/PK/RSA.h10
-rw-r--r--Userland/test-crypto.cpp2
4 files changed, 14 insertions, 14 deletions
diff --git a/Libraries/LibCrypto/PK/PK.h b/Libraries/LibCrypto/PK/PK.h
index 4b7fa739f5..580b0336ba 100644
--- a/Libraries/LibCrypto/PK/PK.h
+++ b/Libraries/LibCrypto/PK/PK.h
@@ -52,8 +52,8 @@ public:
virtual void encrypt(ReadonlyBytes in, ByteBuffer& out) = 0;
virtual void decrypt(ReadonlyBytes in, ByteBuffer& out) = 0;
- virtual void sign(ReadonlyBytes in, ByteBuffer& out) = 0;
- virtual void verify(ReadonlyBytes in, ByteBuffer& out) = 0;
+ virtual void sign(ReadonlyBytes in, Bytes& out) = 0;
+ virtual void verify(ReadonlyBytes in, Bytes& out) = 0;
virtual String class_name() const = 0;
diff --git a/Libraries/LibCrypto/PK/RSA.cpp b/Libraries/LibCrypto/PK/RSA.cpp
index 4422e36e6d..f144662c7a 100644
--- a/Libraries/LibCrypto/PK/RSA.cpp
+++ b/Libraries/LibCrypto/PK/RSA.cpp
@@ -149,7 +149,7 @@ void RSA::decrypt(ReadonlyBytes in, ByteBuffer& out)
out = out.slice(out.size() - aligned_size, aligned_size);
}
-void RSA::sign(ReadonlyBytes in, ByteBuffer& out)
+void RSA::sign(ReadonlyBytes in, Bytes& out)
{
auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size());
auto exp = NumberTheory::ModularPower(in_integer, m_private_key.private_exponent(), m_private_key.modulus());
@@ -157,7 +157,7 @@ void RSA::sign(ReadonlyBytes in, ByteBuffer& out)
out = out.slice(out.size() - size, size);
}
-void RSA::verify(ReadonlyBytes in, ByteBuffer& out)
+void RSA::verify(ReadonlyBytes in, Bytes& out)
{
auto in_integer = UnsignedBigInteger::import_data(in.data(), in.size());
auto exp = NumberTheory::ModularPower(in_integer, m_public_key.public_exponent(), m_public_key.modulus());
@@ -198,7 +198,7 @@ void RSA::import_public_key(ReadonlyBytes bytes, bool pem)
}
template<typename HashFunction>
-void RSA_EMSA_PSS<HashFunction>::sign(ReadonlyBytes in, ByteBuffer& out)
+void RSA_EMSA_PSS<HashFunction>::sign(ReadonlyBytes in, Bytes& out)
{
// -- encode via EMSA_PSS
auto mod_bits = m_rsa.private_key().modulus().trimmed_length() * sizeof(u32) * 8;
@@ -219,7 +219,7 @@ VerificationConsistency RSA_EMSA_PSS<HashFunction>::verify(ReadonlyBytes in)
return VerificationConsistency::Inconsistent;
u8 EM[mod_bytes];
- auto EM_buf = ByteBuffer::wrap(EM, mod_bytes);
+ auto EM_buf = Bytes { EM, mod_bytes };
// -- verify via RSA
m_rsa.verify(in, EM_buf);
@@ -317,11 +317,11 @@ void RSA_PKCS1_EME::decrypt(ReadonlyBytes in, ByteBuffer& out)
out = out.slice(offset, out.size() - offset);
}
-void RSA_PKCS1_EME::sign(ReadonlyBytes, ByteBuffer&)
+void RSA_PKCS1_EME::sign(ReadonlyBytes, Bytes&)
{
dbg() << "FIXME: RSA_PKCS_EME::sign";
}
-void RSA_PKCS1_EME::verify(ReadonlyBytes, ByteBuffer&)
+void RSA_PKCS1_EME::verify(ReadonlyBytes, Bytes&)
{
dbg() << "FIXME: RSA_PKCS_EME::verify";
}
diff --git a/Libraries/LibCrypto/PK/RSA.h b/Libraries/LibCrypto/PK/RSA.h
index 329a7b3890..318857d81c 100644
--- a/Libraries/LibCrypto/PK/RSA.h
+++ b/Libraries/LibCrypto/PK/RSA.h
@@ -181,8 +181,8 @@ public:
virtual void encrypt(ReadonlyBytes in, ByteBuffer& out) override;
virtual void decrypt(ReadonlyBytes in, ByteBuffer& out) override;
- virtual void sign(ReadonlyBytes in, ByteBuffer& out) override;
- virtual void verify(ReadonlyBytes in, ByteBuffer& out) override;
+ virtual void sign(ReadonlyBytes in, Bytes& out) override;
+ virtual void verify(ReadonlyBytes in, Bytes& out) override;
virtual String class_name() const override { return "RSA"; }
@@ -203,7 +203,7 @@ public:
{
}
- void sign(ReadonlyBytes in, ByteBuffer& out);
+ void sign(ReadonlyBytes in, Bytes& out);
VerificationConsistency verify(ReadonlyBytes in);
private:
@@ -225,8 +225,8 @@ public:
virtual void encrypt(ReadonlyBytes in, ByteBuffer& out) override;
virtual void decrypt(ReadonlyBytes in, ByteBuffer& out) override;
- virtual void sign(ReadonlyBytes, ByteBuffer&) override;
- virtual void verify(ReadonlyBytes, ByteBuffer&) override;
+ virtual void sign(ReadonlyBytes, Bytes&) override;
+ virtual void verify(ReadonlyBytes, Bytes&) override;
virtual String class_name() const override { return "RSA_PKCS1-EME"; }
virtual size_t output_size() const override { return m_public_key.length(); }
diff --git a/Userland/test-crypto.cpp b/Userland/test-crypto.cpp
index b650f1773d..1163f0967c 100644
--- a/Userland/test-crypto.cpp
+++ b/Userland/test-crypto.cpp
@@ -700,7 +700,7 @@ static void aes_cbc_test_encrypt()
0xd6, 0xa0, 0x46
};
u8 key[] { 0x0a, 0x8c, 0x5b, 0x0d, 0x8a, 0x68, 0x43, 0xf7, 0xaf, 0xc0, 0xe3, 0x4e, 0x4b, 0x43, 0xaa, 0x28, 0x69, 0x9b, 0x6f, 0xe7, 0x24, 0x82, 0x1c, 0x71, 0x86, 0xf6, 0x2b, 0x87, 0xd6, 0x8b, 0x8f, 0xf1 };
- Crypto::Cipher::AESCipher::CBCMode cipher(ByteBuffer::wrap(key, 32), 256, Crypto::Cipher::Intent::Encryption);
+ Crypto::Cipher::AESCipher::CBCMode cipher(ReadonlyBytes { key, sizeof(key) }, 256, Crypto::Cipher::Intent::Encryption);
test_it(cipher, result);
}
// TODO: Test non-CMS padding options