summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCrypto/Authentication/GHash.cpp1
-rw-r--r--Userland/Libraries/LibCrypto/Authentication/GHash.h13
-rw-r--r--Userland/Libraries/LibCrypto/Authentication/HMAC.h7
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/AES.h7
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Cipher.h2
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h12
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h12
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h12
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h8
-rw-r--r--Userland/Libraries/LibCrypto/Hash/HashFunction.h2
-rw-r--r--Userland/Libraries/LibCrypto/Hash/HashManager.h2
-rw-r--r--Userland/Libraries/LibCrypto/Hash/MD5.h12
-rw-r--r--Userland/Libraries/LibCrypto/Hash/SHA1.h8
-rw-r--r--Userland/Libraries/LibCrypto/Hash/SHA2.h11
-rw-r--r--Userland/Libraries/LibCrypto/PK/PK.h7
-rw-r--r--Userland/Libraries/LibCrypto/PK/RSA.h24
16 files changed, 119 insertions, 21 deletions
diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp
index 737f46868e..de06e63087 100644
--- a/Userland/Libraries/LibCrypto/Authentication/GHash.cpp
+++ b/Userland/Libraries/LibCrypto/Authentication/GHash.cpp
@@ -9,7 +9,6 @@
#include <AK/MemoryStream.h>
#include <AK/Types.h>
#include <LibCrypto/Authentication/GHash.h>
-#include <LibCrypto/BigInt/UnsignedBigInteger.h>
namespace {
diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.h b/Userland/Libraries/LibCrypto/Authentication/GHash.h
index 5225d906d9..0bfc8274cd 100644
--- a/Userland/Libraries/LibCrypto/Authentication/GHash.h
+++ b/Userland/Libraries/LibCrypto/Authentication/GHash.h
@@ -7,10 +7,14 @@
#pragma once
#include <AK/ByteReader.h>
-#include <AK/String.h>
+#include <AK/Endian.h>
#include <AK/Types.h>
#include <LibCrypto/Hash/HashFunction.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Authentication {
@@ -44,7 +48,12 @@ public:
constexpr static size_t digest_size() { return TagType::Size; }
- String class_name() const { return "GHash"; }
+#ifndef KERNEL
+ String class_name() const
+ {
+ return "GHash";
+ }
+#endif
TagType process(ReadonlyBytes aad, ReadonlyBytes cipher);
diff --git a/Userland/Libraries/LibCrypto/Authentication/HMAC.h b/Userland/Libraries/LibCrypto/Authentication/HMAC.h
index c1abba3956..8c80602dbe 100644
--- a/Userland/Libraries/LibCrypto/Authentication/HMAC.h
+++ b/Userland/Libraries/LibCrypto/Authentication/HMAC.h
@@ -7,12 +7,15 @@
#pragma once
#include <AK/ByteBuffer.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <AK/Vector.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
constexpr static auto IPAD = 0x36;
constexpr static auto OPAD = 0x5c;
@@ -70,6 +73,7 @@ public:
m_outer_hasher.update(m_key_data + m_inner_hasher.block_size(), m_outer_hasher.block_size());
}
+#ifndef KERNEL
String class_name() const
{
StringBuilder builder;
@@ -77,6 +81,7 @@ public:
builder.append(m_inner_hasher.class_name());
return builder.build();
}
+#endif
private:
void derive_key(const u8* key, size_t length)
diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.h b/Userland/Libraries/LibCrypto/Cipher/AES.h
index 796c653167..654475f61d 100644
--- a/Userland/Libraries/LibCrypto/Cipher/AES.h
+++ b/Userland/Libraries/LibCrypto/Cipher/AES.h
@@ -119,7 +119,12 @@ public:
virtual void encrypt_block(const BlockType& in, BlockType& out) override;
virtual void decrypt_block(const BlockType& in, BlockType& out) override;
- virtual String class_name() const override { return "AES"; }
+#ifndef KERNEL
+ virtual String class_name() const override
+ {
+ return "AES";
+ }
+#endif
protected:
AESCipherKey m_key;
diff --git a/Userland/Libraries/LibCrypto/Cipher/Cipher.h b/Userland/Libraries/LibCrypto/Cipher/Cipher.h
index 436ff6e2f2..d8ab4d1aac 100644
--- a/Userland/Libraries/LibCrypto/Cipher/Cipher.h
+++ b/Userland/Libraries/LibCrypto/Cipher/Cipher.h
@@ -111,7 +111,9 @@ public:
virtual void encrypt_block(const BlockType& in, BlockType& out) = 0;
virtual void decrypt_block(const BlockType& in, BlockType& out) = 0;
+#ifndef KERNEL
virtual String class_name() const = 0;
+#endif
protected:
virtual ~Cipher() = default;
diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h
index a32a0874e3..9cc3210a7e 100644
--- a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h
+++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h
@@ -6,11 +6,14 @@
#pragma once
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <LibCrypto/Cipher/Mode/Mode.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Cipher {
@@ -26,6 +29,7 @@ public:
{
}
+#ifndef KERNEL
virtual String class_name() const override
{
StringBuilder builder;
@@ -33,8 +37,12 @@ public:
builder.append("_CBC");
return builder.build();
}
+#endif
- virtual size_t IV_length() const override { return IVSizeInBits / 8; }
+ virtual size_t IV_length() const override
+ {
+ return IVSizeInBits / 8;
+ }
virtual void encrypt(ReadonlyBytes in, Bytes& out, ReadonlyBytes ivec = {}, Bytes* ivec_out = nullptr) override
{
diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h
index 8a0d557083..979ca281ed 100644
--- a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h
+++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h
@@ -6,11 +6,14 @@
#pragma once
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <LibCrypto/Cipher/Mode/Mode.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Cipher {
@@ -101,6 +104,7 @@ public:
{
}
+#ifndef KERNEL
virtual String class_name() const override
{
StringBuilder builder;
@@ -108,8 +112,12 @@ public:
builder.append("_CTR");
return builder.build();
}
+#endif
- virtual size_t IV_length() const override { return IVSizeInBits / 8; }
+ virtual size_t IV_length() const override
+ {
+ return IVSizeInBits / 8;
+ }
virtual void encrypt(ReadonlyBytes in, Bytes& out, ReadonlyBytes ivec = {}, Bytes* ivec_out = nullptr) override
{
diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h
index d5cb048ba9..b50713bd69 100644
--- a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h
+++ b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h
@@ -7,13 +7,16 @@
#pragma once
#include <AK/OwnPtr.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <LibCrypto/Authentication/GHash.h>
#include <LibCrypto/Cipher/Mode/CTR.h>
#include <LibCrypto/Verification.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Cipher {
@@ -40,6 +43,7 @@ public:
m_ghash = Authentication::GHash(m_auth_key);
}
+#ifndef KERNEL
virtual String class_name() const override
{
StringBuilder builder;
@@ -47,8 +51,12 @@ public:
builder.append("_GCM");
return builder.build();
}
+#endif
- virtual size_t IV_length() const override { return IVSizeInBits / 8; }
+ virtual size_t IV_length() const override
+ {
+ return IVSizeInBits / 8;
+ }
// FIXME: This overload throws away the auth stuff, think up a better way to return more than a single bytebuffer.
virtual void encrypt(ReadonlyBytes in, Bytes& out, ReadonlyBytes ivec = {}, Bytes* = nullptr) override
diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h
index 0daf56eac6..6546c5a9c8 100644
--- a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h
+++ b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h
@@ -35,8 +35,14 @@ public:
return ByteBuffer::create_uninitialized(input_size + T::block_size() - remainder);
}
+#ifndef KERNEL
virtual String class_name() const = 0;
- T& cipher() { return m_cipher; }
+#endif
+
+ T& cipher()
+ {
+ return m_cipher;
+ }
protected:
virtual void prune_padding(Bytes& data)
diff --git a/Userland/Libraries/LibCrypto/Hash/HashFunction.h b/Userland/Libraries/LibCrypto/Hash/HashFunction.h
index a803b1650b..ff73aa6e61 100644
--- a/Userland/Libraries/LibCrypto/Hash/HashFunction.h
+++ b/Userland/Libraries/LibCrypto/Hash/HashFunction.h
@@ -51,7 +51,9 @@ public:
virtual void reset() = 0;
+#ifndef KERNEL
virtual String class_name() const = 0;
+#endif
protected:
virtual ~HashFunction() = default;
diff --git a/Userland/Libraries/LibCrypto/Hash/HashManager.h b/Userland/Libraries/LibCrypto/Hash/HashManager.h
index 4c31ecdf4a..28a9bf4e9e 100644
--- a/Userland/Libraries/LibCrypto/Hash/HashManager.h
+++ b/Userland/Libraries/LibCrypto/Hash/HashManager.h
@@ -191,12 +191,14 @@ public:
[&](auto& hash) { hash.reset(); });
}
+#ifndef KERNEL
virtual String class_name() const override
{
return m_algorithm.visit(
[&](const Empty&) -> String { return "UninitializedHashManager"; },
[&](const auto& hash) { return hash.class_name(); });
}
+#endif
inline bool is(HashKind kind) const
{
diff --git a/Userland/Libraries/LibCrypto/Hash/MD5.h b/Userland/Libraries/LibCrypto/Hash/MD5.h
index 6e91276953..9c55b38b86 100644
--- a/Userland/Libraries/LibCrypto/Hash/MD5.h
+++ b/Userland/Libraries/LibCrypto/Hash/MD5.h
@@ -6,10 +6,13 @@
#pragma once
-#include <AK/String.h>
#include <AK/Types.h>
#include <LibCrypto/Hash/HashFunction.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Hash {
@@ -53,7 +56,12 @@ public:
virtual DigestType digest() override;
virtual DigestType peek() override;
- virtual String class_name() const override { return "MD5"; }
+#ifndef KERNEL
+ virtual String class_name() const override
+ {
+ return "MD5";
+ }
+#endif
inline static DigestType hash(const u8* data, size_t length)
{
diff --git a/Userland/Libraries/LibCrypto/Hash/SHA1.h b/Userland/Libraries/LibCrypto/Hash/SHA1.h
index 8b3f574390..8fcbfc7f56 100644
--- a/Userland/Libraries/LibCrypto/Hash/SHA1.h
+++ b/Userland/Libraries/LibCrypto/Hash/SHA1.h
@@ -6,9 +6,12 @@
#pragma once
-#include <AK/String.h>
#include <LibCrypto/Hash/HashFunction.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Hash {
@@ -49,10 +52,13 @@ public:
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
+#ifndef KERNEL
virtual String class_name() const override
{
return "SHA1";
}
+#endif
+
inline virtual void reset() override
{
m_data_length = 0;
diff --git a/Userland/Libraries/LibCrypto/Hash/SHA2.h b/Userland/Libraries/LibCrypto/Hash/SHA2.h
index 5421b2bdf0..584e229845 100644
--- a/Userland/Libraries/LibCrypto/Hash/SHA2.h
+++ b/Userland/Libraries/LibCrypto/Hash/SHA2.h
@@ -6,10 +6,13 @@
#pragma once
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCrypto/Hash/HashFunction.h>
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
+
namespace Crypto {
namespace Hash {
@@ -97,10 +100,12 @@ public:
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
+#ifndef KERNEL
virtual String class_name() const override
{
return String::formatted("SHA{}", DigestSize * 8);
}
+#endif
inline virtual void reset() override
{
@@ -147,10 +152,12 @@ public:
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
+#ifndef KERNEL
virtual String class_name() const override
{
return String::formatted("SHA{}", DigestSize * 8);
}
+#endif
inline virtual void reset() override
{
@@ -197,10 +204,12 @@ public:
inline static DigestType hash(const ByteBuffer& buffer) { return hash(buffer.data(), buffer.size()); }
inline static DigestType hash(StringView buffer) { return hash((const u8*)buffer.characters_without_null_termination(), buffer.length()); }
+#ifndef KERNEL
virtual String class_name() const override
{
return String::formatted("SHA{}", DigestSize * 8);
}
+#endif
inline virtual void reset() override
{
diff --git a/Userland/Libraries/LibCrypto/PK/PK.h b/Userland/Libraries/LibCrypto/PK/PK.h
index 75159db4c0..4483339b36 100644
--- a/Userland/Libraries/LibCrypto/PK/PK.h
+++ b/Userland/Libraries/LibCrypto/PK/PK.h
@@ -7,7 +7,10 @@
#pragma once
#include <AK/ByteBuffer.h>
-#include <AK/String.h>
+
+#ifndef KERNEL
+# include <AK/String.h>
+#endif
namespace Crypto {
namespace PK {
@@ -33,7 +36,9 @@ public:
virtual void sign(ReadonlyBytes in, Bytes& out) = 0;
virtual void verify(ReadonlyBytes in, Bytes& out) = 0;
+#ifndef KERNEL
virtual String class_name() const = 0;
+#endif
virtual size_t output_size() const = 0;
diff --git a/Userland/Libraries/LibCrypto/PK/RSA.h b/Userland/Libraries/LibCrypto/PK/RSA.h
index 48a0cae3bf..23dc1b3bd5 100644
--- a/Userland/Libraries/LibCrypto/PK/RSA.h
+++ b/Userland/Libraries/LibCrypto/PK/RSA.h
@@ -160,9 +160,17 @@ public:
virtual void sign(ReadonlyBytes in, Bytes& out) override;
virtual void verify(ReadonlyBytes in, Bytes& out) override;
- virtual String class_name() const override { return "RSA"; }
+#ifndef KERNEL
+ virtual String class_name() const override
+ {
+ return "RSA";
+ }
+#endif
- virtual size_t output_size() const override { return m_public_key.length(); }
+ virtual size_t output_size() const override
+ {
+ return m_public_key.length();
+ }
void import_public_key(ReadonlyBytes, bool pem = true);
void import_private_key(ReadonlyBytes, bool pem = true);
@@ -204,8 +212,16 @@ public:
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(); }
+#ifndef KERNEL
+ virtual String class_name() const override
+ {
+ return "RSA_PKCS1-EME";
+ }
+#endif
+ virtual size_t output_size() const override
+ {
+ return m_public_key.length();
+ }
};
}
}