1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:07:34 +00:00

LibCrypto: Exclude AESCipher{Block, Key}::to_string() from the Kernel

These use infallible Strings and are not actually used in the Kernel,
so let's just ifdef them out for now.
This commit is contained in:
Idan Horowitz 2022-02-15 21:22:11 +02:00 committed by Andreas Kling
parent 7bd409dbdf
commit 6959e7f778
2 changed files with 12 additions and 1 deletions

View file

@ -24,6 +24,7 @@ constexpr void swap_keys(u32* keys, size_t i, size_t j)
keys[j] = temp; keys[j] = temp;
} }
#ifndef KERNEL
String AESCipherBlock::to_string() const String AESCipherBlock::to_string() const
{ {
StringBuilder builder; StringBuilder builder;
@ -39,6 +40,7 @@ String AESCipherKey::to_string() const
builder.appendff("{:02x}", m_rd_keys[i]); builder.appendff("{:02x}", m_rd_keys[i]);
return builder.build(); return builder.build();
} }
#endif
void AESCipherKey::expand_encrypt_key(ReadonlyBytes user_key, size_t bits) void AESCipherKey::expand_encrypt_key(ReadonlyBytes user_key, size_t bits)
{ {

View file

@ -6,13 +6,16 @@
#pragma once #pragma once
#include <AK/String.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibCrypto/Cipher/Cipher.h> #include <LibCrypto/Cipher/Cipher.h>
#include <LibCrypto/Cipher/Mode/CBC.h> #include <LibCrypto/Cipher/Mode/CBC.h>
#include <LibCrypto/Cipher/Mode/CTR.h> #include <LibCrypto/Cipher/Mode/CTR.h>
#include <LibCrypto/Cipher/Mode/GCM.h> #include <LibCrypto/Cipher/Mode/GCM.h>
#ifndef KERNEL
# include <AK/String.h>
#endif
namespace Crypto { namespace Crypto {
namespace Cipher { namespace Cipher {
@ -44,7 +47,9 @@ public:
m_data[i] ^= ivec[i]; m_data[i] ^= ivec[i];
} }
#ifndef KERNEL
String to_string() const; String to_string() const;
#endif
private: private:
constexpr static size_t data_size() { return sizeof(m_data); } constexpr static size_t data_size() { return sizeof(m_data); }
@ -57,7 +62,11 @@ struct AESCipherKey : public CipherKey {
virtual void expand_encrypt_key(ReadonlyBytes user_key, size_t bits) override; virtual void expand_encrypt_key(ReadonlyBytes user_key, size_t bits) override;
virtual void expand_decrypt_key(ReadonlyBytes user_key, size_t bits) override; virtual void expand_decrypt_key(ReadonlyBytes user_key, size_t bits) override;
static bool is_valid_key_size(size_t bits) { return bits == 128 || bits == 192 || bits == 256; }; static bool is_valid_key_size(size_t bits) { return bits == 128 || bits == 192 || bits == 256; };
#ifndef KERNEL
String to_string() const; String to_string() const;
#endif
const u32* round_keys() const const u32* round_keys() const
{ {
return (const u32*)m_rd_keys; return (const u32*)m_rd_keys;