mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:17:44 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -19,7 +19,7 @@ struct Digest {
|
|||
constexpr static size_t Size = DigestS / 8;
|
||||
u8 data[Size];
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE const u8* immutable_data() const { return data; }
|
||||
[[nodiscard]] ALWAYS_INLINE u8 const* immutable_data() const { return data; }
|
||||
[[nodiscard]] ALWAYS_INLINE size_t data_length() const { return Size; }
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE ReadonlyBytes bytes() const { return { immutable_data(), data_length() }; }
|
||||
|
@ -39,12 +39,12 @@ public:
|
|||
constexpr static size_t block_size() { return BlockSize; }
|
||||
constexpr static size_t digest_size() { return DigestSize; }
|
||||
|
||||
virtual void update(const u8*, size_t) = 0;
|
||||
virtual void update(u8 const*, size_t) = 0;
|
||||
|
||||
void update(Bytes buffer) { update(buffer.data(), buffer.size()); }
|
||||
void update(ReadonlyBytes buffer) { update(buffer.data(), buffer.size()); }
|
||||
void update(const ByteBuffer& buffer) { update(buffer.data(), buffer.size()); }
|
||||
void update(StringView string) { update((const u8*)string.characters_without_null_termination(), string.length()); }
|
||||
void update(ByteBuffer const& buffer) { update(buffer.data(), buffer.size()); }
|
||||
void update(StringView string) { update((u8 const*)string.characters_without_null_termination(), string.length()); }
|
||||
|
||||
virtual DigestType peek() = 0;
|
||||
virtual DigestType digest() = 0;
|
||||
|
|
|
@ -59,25 +59,25 @@ struct MultiHashDigestVariant {
|
|||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] const u8* immutable_data() const
|
||||
[[nodiscard]] u8 const* immutable_data() const
|
||||
{
|
||||
return m_digest.visit(
|
||||
[&](const Empty&) -> const u8* { VERIFY_NOT_REACHED(); },
|
||||
[&](const auto& value) { return value.immutable_data(); });
|
||||
[&](Empty const&) -> u8 const* { VERIFY_NOT_REACHED(); },
|
||||
[&](auto const& value) { return value.immutable_data(); });
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t data_length() const
|
||||
{
|
||||
return m_digest.visit(
|
||||
[&](const Empty&) -> size_t { VERIFY_NOT_REACHED(); },
|
||||
[&](const auto& value) { return value.data_length(); });
|
||||
[&](Empty const&) -> size_t { VERIFY_NOT_REACHED(); },
|
||||
[&](auto const& value) { return value.data_length(); });
|
||||
}
|
||||
|
||||
[[nodiscard]] ReadonlyBytes bytes() const
|
||||
{
|
||||
return m_digest.visit(
|
||||
[&](const Empty&) -> ReadonlyBytes { VERIFY_NOT_REACHED(); },
|
||||
[&](const auto& value) { return value.bytes(); });
|
||||
[&](Empty const&) -> ReadonlyBytes { VERIFY_NOT_REACHED(); },
|
||||
[&](auto const& value) { return value.bytes(); });
|
||||
}
|
||||
|
||||
using DigestVariant = Variant<Empty, MD5::DigestType, SHA1::DigestType, SHA256::DigestType, SHA384::DigestType, SHA512::DigestType>;
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
m_pre_init_buffer = ByteBuffer();
|
||||
}
|
||||
|
||||
Manager(const Manager& other) // NOT a copy constructor!
|
||||
Manager(Manager const& other) // NOT a copy constructor!
|
||||
{
|
||||
m_pre_init_buffer = ByteBuffer(); // will not be used
|
||||
initialize(other.m_kind);
|
||||
|
@ -113,15 +113,15 @@ public:
|
|||
inline size_t digest_size() const
|
||||
{
|
||||
return m_algorithm.visit(
|
||||
[&](const Empty&) -> size_t { return 0; },
|
||||
[&](const auto& hash) { return hash.digest_size(); });
|
||||
[&](Empty const&) -> size_t { return 0; },
|
||||
[&](auto const& hash) { return hash.digest_size(); });
|
||||
}
|
||||
|
||||
inline size_t block_size() const
|
||||
{
|
||||
return m_algorithm.visit(
|
||||
[&](const Empty&) -> size_t { return 0; },
|
||||
[&](const auto& hash) { return hash.block_size(); });
|
||||
[&](Empty const&) -> size_t { return 0; },
|
||||
[&](auto const& hash) { return hash.block_size(); });
|
||||
}
|
||||
|
||||
inline void initialize(HashKind kind)
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void update(const u8* data, size_t length) override
|
||||
virtual void update(u8 const* data, size_t length) override
|
||||
{
|
||||
auto size = m_pre_init_buffer.size();
|
||||
if (size) {
|
||||
|
@ -195,8 +195,8 @@ public:
|
|||
virtual String class_name() const override
|
||||
{
|
||||
return m_algorithm.visit(
|
||||
[&](const Empty&) -> String { return "UninitializedHashManager"; },
|
||||
[&](const auto& hash) { return hash.class_name(); });
|
||||
[&](Empty const&) -> String { return "UninitializedHashManager"; },
|
||||
[&](auto const& hash) { return hash.class_name(); });
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static constexpr void round_4(u32& a, u32 b, u32 c, u32 d, u32 x, u32 s, u32 ac)
|
|||
namespace Crypto {
|
||||
namespace Hash {
|
||||
|
||||
void MD5::update(const u8* input, size_t length)
|
||||
void MD5::update(u8 const* input, size_t length)
|
||||
{
|
||||
auto index = (u32)(m_count[0] >> 3) & 0x3f;
|
||||
size_t offset { 0 };
|
||||
|
@ -101,7 +101,7 @@ MD5::DigestType MD5::peek()
|
|||
return digest;
|
||||
}
|
||||
|
||||
void MD5::encode(const u32* from, u8* to, size_t length)
|
||||
void MD5::encode(u32 const* from, u8* to, size_t length)
|
||||
{
|
||||
for (size_t i = 0, j = 0; j < length; ++i, j += 4) {
|
||||
to[j] = (u8)(from[i] & 0xff);
|
||||
|
@ -111,13 +111,13 @@ void MD5::encode(const u32* from, u8* to, size_t length)
|
|||
}
|
||||
}
|
||||
|
||||
void MD5::decode(const u8* from, u32* to, size_t length)
|
||||
void MD5::decode(u8 const* from, u32* to, size_t length)
|
||||
{
|
||||
for (size_t i = 0, j = 0; j < length; ++i, j += 4)
|
||||
to[i] = (((u32)from[j]) | (((u32)from[j + 1]) << 8) | (((u32)from[j + 2]) << 16) | (((u32)from[j + 3]) << 24));
|
||||
}
|
||||
|
||||
void MD5::transform(const u8* block)
|
||||
void MD5::transform(u8 const* block)
|
||||
{
|
||||
auto a = m_A;
|
||||
auto b = m_B;
|
||||
|
|
|
@ -52,7 +52,7 @@ class MD5 final : public HashFunction<512, 128> {
|
|||
public:
|
||||
using HashFunction::update;
|
||||
|
||||
virtual void update(const u8*, size_t) override;
|
||||
virtual void update(u8 const*, size_t) override;
|
||||
virtual DigestType digest() override;
|
||||
virtual DigestType peek() override;
|
||||
|
||||
|
@ -63,15 +63,15 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
inline static DigestType hash(const u8* data, size_t length)
|
||||
inline static DigestType hash(u8 const* data, size_t length)
|
||||
{
|
||||
MD5 md5;
|
||||
md5.update(data, length);
|
||||
return md5.digest();
|
||||
}
|
||||
|
||||
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()); }
|
||||
inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); }
|
||||
inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); }
|
||||
inline virtual void reset() override
|
||||
{
|
||||
m_A = MD5Constants::init_A;
|
||||
|
@ -86,10 +86,10 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline void transform(const u8*);
|
||||
inline void transform(u8 const*);
|
||||
|
||||
static void encode(const u32* from, u8* to, size_t length);
|
||||
static void decode(const u8* from, u32* to, size_t length);
|
||||
static void encode(u32 const* from, u8* to, size_t length);
|
||||
static void decode(u8 const* from, u32* to, size_t length);
|
||||
|
||||
u32 m_A { MD5Constants::init_A }, m_B { MD5Constants::init_B }, m_C { MD5Constants::init_C }, m_D { MD5Constants::init_D };
|
||||
u32 m_count[2] { 0, 0 };
|
||||
|
|
|
@ -17,11 +17,11 @@ static constexpr auto ROTATE_LEFT(u32 value, size_t bits)
|
|||
return (value << bits) | (value >> (32 - bits));
|
||||
}
|
||||
|
||||
inline void SHA1::transform(const u8* data)
|
||||
inline void SHA1::transform(u8 const* data)
|
||||
{
|
||||
u32 blocks[80];
|
||||
for (size_t i = 0; i < 16; ++i)
|
||||
blocks[i] = AK::convert_between_host_and_network_endian(((const u32*)data)[i]);
|
||||
blocks[i] = AK::convert_between_host_and_network_endian(((u32 const*)data)[i]);
|
||||
|
||||
// w[i] = (w[i-3] xor w[i-8] xor w[i-14] xor w[i-16]) leftrotate 1
|
||||
for (size_t i = 16; i < Rounds; ++i)
|
||||
|
@ -67,7 +67,7 @@ inline void SHA1::transform(const u8* data)
|
|||
secure_zero(blocks, 16 * sizeof(u32));
|
||||
}
|
||||
|
||||
void SHA1::update(const u8* message, size_t length)
|
||||
void SHA1::update(u8 const* message, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (m_data_length == BlockSize) {
|
||||
|
|
|
@ -37,20 +37,20 @@ public:
|
|||
reset();
|
||||
}
|
||||
|
||||
virtual void update(const u8*, size_t) override;
|
||||
virtual void update(u8 const*, size_t) override;
|
||||
|
||||
virtual DigestType digest() override;
|
||||
virtual DigestType peek() override;
|
||||
|
||||
inline static DigestType hash(const u8* data, size_t length)
|
||||
inline static DigestType hash(u8 const* data, size_t length)
|
||||
{
|
||||
SHA1 sha;
|
||||
sha.update(data, length);
|
||||
return sha.digest();
|
||||
}
|
||||
|
||||
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()); }
|
||||
inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); }
|
||||
inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); }
|
||||
|
||||
#ifndef KERNEL
|
||||
virtual String class_name() const override
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline void transform(const u8*);
|
||||
inline void transform(u8 const*);
|
||||
|
||||
u8 m_data_buffer[BlockSize] {};
|
||||
size_t m_data_length { 0 };
|
||||
|
|
|
@ -25,7 +25,7 @@ constexpr static auto EP1(u64 x) { return ROTRIGHT(x, 14) ^ ROTRIGHT(x, 18) ^ RO
|
|||
constexpr static auto SIGN0(u64 x) { return ROTRIGHT(x, 1) ^ ROTRIGHT(x, 8) ^ (x >> 7); }
|
||||
constexpr static auto SIGN1(u64 x) { return ROTRIGHT(x, 19) ^ ROTRIGHT(x, 61) ^ (x >> 6); }
|
||||
|
||||
inline void SHA256::transform(const u8* data)
|
||||
inline void SHA256::transform(u8 const* data)
|
||||
{
|
||||
u32 m[64];
|
||||
|
||||
|
@ -66,7 +66,7 @@ inline void SHA256::transform(const u8* data)
|
|||
m_state[7] += h;
|
||||
}
|
||||
|
||||
void SHA256::update(const u8* message, size_t length)
|
||||
void SHA256::update(u8 const* message, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (m_data_length == BlockSize) {
|
||||
|
@ -142,7 +142,7 @@ SHA256::DigestType SHA256::peek()
|
|||
return digest;
|
||||
}
|
||||
|
||||
inline void SHA384::transform(const u8* data)
|
||||
inline void SHA384::transform(u8 const* data)
|
||||
{
|
||||
u64 m[80];
|
||||
|
||||
|
@ -184,7 +184,7 @@ inline void SHA384::transform(const u8* data)
|
|||
m_state[7] += h;
|
||||
}
|
||||
|
||||
void SHA384::update(const u8* message, size_t length)
|
||||
void SHA384::update(u8 const* message, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (m_data_length == BlockSize) {
|
||||
|
@ -267,7 +267,7 @@ SHA384::DigestType SHA384::peek()
|
|||
return digest;
|
||||
}
|
||||
|
||||
inline void SHA512::transform(const u8* data)
|
||||
inline void SHA512::transform(u8 const* data)
|
||||
{
|
||||
u64 m[80];
|
||||
|
||||
|
@ -308,7 +308,7 @@ inline void SHA512::transform(const u8* data)
|
|||
m_state[7] += h;
|
||||
}
|
||||
|
||||
void SHA512::update(const u8* message, size_t length)
|
||||
void SHA512::update(u8 const* message, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (m_data_length == BlockSize) {
|
||||
|
|
|
@ -85,20 +85,20 @@ public:
|
|||
reset();
|
||||
}
|
||||
|
||||
virtual void update(const u8*, size_t) override;
|
||||
virtual void update(u8 const*, size_t) override;
|
||||
|
||||
virtual DigestType digest() override;
|
||||
virtual DigestType peek() override;
|
||||
|
||||
inline static DigestType hash(const u8* data, size_t length)
|
||||
inline static DigestType hash(u8 const* data, size_t length)
|
||||
{
|
||||
SHA256 sha;
|
||||
sha.update(data, length);
|
||||
return sha.digest();
|
||||
}
|
||||
|
||||
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()); }
|
||||
inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); }
|
||||
inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); }
|
||||
|
||||
#ifndef KERNEL
|
||||
virtual String class_name() const override
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline void transform(const u8*);
|
||||
inline void transform(u8 const*);
|
||||
|
||||
u8 m_data_buffer[BlockSize] {};
|
||||
size_t m_data_length { 0 };
|
||||
|
@ -137,20 +137,20 @@ public:
|
|||
reset();
|
||||
}
|
||||
|
||||
virtual void update(const u8*, size_t) override;
|
||||
virtual void update(u8 const*, size_t) override;
|
||||
|
||||
virtual DigestType digest() override;
|
||||
virtual DigestType peek() override;
|
||||
|
||||
inline static DigestType hash(const u8* data, size_t length)
|
||||
inline static DigestType hash(u8 const* data, size_t length)
|
||||
{
|
||||
SHA384 sha;
|
||||
sha.update(data, length);
|
||||
return sha.digest();
|
||||
}
|
||||
|
||||
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()); }
|
||||
inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); }
|
||||
inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); }
|
||||
|
||||
#ifndef KERNEL
|
||||
virtual String class_name() const override
|
||||
|
@ -168,7 +168,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline void transform(const u8*);
|
||||
inline void transform(u8 const*);
|
||||
|
||||
u8 m_data_buffer[BlockSize] {};
|
||||
size_t m_data_length { 0 };
|
||||
|
@ -189,20 +189,20 @@ public:
|
|||
reset();
|
||||
}
|
||||
|
||||
virtual void update(const u8*, size_t) override;
|
||||
virtual void update(u8 const*, size_t) override;
|
||||
|
||||
virtual DigestType digest() override;
|
||||
virtual DigestType peek() override;
|
||||
|
||||
inline static DigestType hash(const u8* data, size_t length)
|
||||
inline static DigestType hash(u8 const* data, size_t length)
|
||||
{
|
||||
SHA512 sha;
|
||||
sha.update(data, length);
|
||||
return sha.digest();
|
||||
}
|
||||
|
||||
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()); }
|
||||
inline static DigestType hash(ByteBuffer const& buffer) { return hash(buffer.data(), buffer.size()); }
|
||||
inline static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); }
|
||||
|
||||
#ifndef KERNEL
|
||||
virtual String class_name() const override
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline void transform(const u8*);
|
||||
inline void transform(u8 const*);
|
||||
|
||||
u8 m_data_buffer[BlockSize] {};
|
||||
size_t m_data_length { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue