diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-23 20:42:32 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-23 20:56:54 +0100 |
commit | 5d180d1f996ead27f9c5cb3db7f91e293de34d9d (patch) | |
tree | e881854dac5d749518562970d6194a0ef65736ec /Userland/Libraries/LibCrypto/Cipher | |
parent | b33a6a443e700cd80325d312f21c985b0687bb97 (diff) | |
download | serenity-5d180d1f996ead27f9c5cb3db7f91e293de34d9d.zip |
Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
Diffstat (limited to 'Userland/Libraries/LibCrypto/Cipher')
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/AES.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/Cipher.h | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h | 2 |
6 files changed, 20 insertions, 20 deletions
diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.cpp b/Userland/Libraries/LibCrypto/Cipher/AES.cpp index 1ce0e12240..21107fbdc0 100644 --- a/Userland/Libraries/LibCrypto/Cipher/AES.cpp +++ b/Userland/Libraries/LibCrypto/Cipher/AES.cpp @@ -65,9 +65,9 @@ void AESCipherKey::expand_encrypt_key(ReadonlyBytes user_key, size_t bits) u32 temp; size_t i { 0 }; - ASSERT(!user_key.is_null()); - ASSERT(is_valid_key_size(bits)); - ASSERT(user_key.size() == bits / 8); + VERIFY(!user_key.is_null()); + VERIFY(is_valid_key_size(bits)); + VERIFY(user_key.size() == bits / 8); round_key = round_keys(); @@ -401,7 +401,7 @@ void AESCipherBlock::overwrite(ReadonlyBytes bytes) auto data = bytes.data(); auto length = bytes.size(); - ASSERT(length <= this->data_size()); + VERIFY(length <= this->data_size()); this->bytes().overwrite(0, data, length); if (length < this->data_size()) { switch (padding_mode()) { @@ -419,7 +419,7 @@ void AESCipherBlock::overwrite(ReadonlyBytes bytes) break; default: // FIXME: We should handle the rest of the common padding modes - ASSERT_NOT_REACHED(); + VERIFY_NOT_REACHED(); break; } } diff --git a/Userland/Libraries/LibCrypto/Cipher/Cipher.h b/Userland/Libraries/LibCrypto/Cipher/Cipher.h index 3b16c61cd9..a17db5a8c0 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Cipher.h +++ b/Userland/Libraries/LibCrypto/Cipher/Cipher.h @@ -59,7 +59,7 @@ public: { } - static size_t block_size() { ASSERT_NOT_REACHED(); } + static size_t block_size() { VERIFY_NOT_REACHED(); } virtual ReadonlyBytes bytes() const = 0; @@ -74,11 +74,11 @@ public: template<typename T> void put(size_t offset, T value) { - ASSERT(offset + sizeof(T) <= bytes().size()); + VERIFY(offset + sizeof(T) <= bytes().size()); auto* ptr = bytes().offset_pointer(offset); auto index { 0 }; - ASSERT(sizeof(T) <= 4); + VERIFY(sizeof(T) <= 4); if constexpr (sizeof(T) > 3) ptr[index++] = (u8)(value >> 24); diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h index 68358a05ca..deec336f2f 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h @@ -66,7 +66,7 @@ public: // FIXME: We should have two of these encrypt/decrypt functions that // we SFINAE out based on whether the Cipher mode needs an ivec - ASSERT(!ivec.is_empty()); + VERIFY(!ivec.is_empty()); const auto* iv = ivec.data(); m_cipher_block.set_padding_mode(cipher.padding_mode()); @@ -77,7 +77,7 @@ public: m_cipher_block.overwrite(in.slice(offset, block_size)); m_cipher_block.apply_initialization_vector(iv); cipher.encrypt_block(m_cipher_block, m_cipher_block); - ASSERT(offset + block_size <= out.size()); + VERIFY(offset + block_size <= out.size()); __builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size); iv = out.offset(offset); length -= block_size; @@ -88,7 +88,7 @@ public: m_cipher_block.overwrite(in.slice(offset, length)); m_cipher_block.apply_initialization_vector(iv); cipher.encrypt_block(m_cipher_block, m_cipher_block); - ASSERT(offset + block_size <= out.size()); + VERIFY(offset + block_size <= out.size()); __builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size); iv = out.offset(offset); } @@ -105,14 +105,14 @@ public: auto& cipher = this->cipher(); - ASSERT(!ivec.is_empty()); + VERIFY(!ivec.is_empty()); const auto* iv = ivec.data(); auto block_size = cipher.block_size(); // if the data is not aligned, it's not correct encrypted data // FIXME (ponder): Should we simply decrypt as much as we can? - ASSERT(length % block_size == 0); + VERIFY(length % block_size == 0); m_cipher_block.set_padding_mode(cipher.padding_mode()); size_t offset { 0 }; @@ -123,7 +123,7 @@ public: cipher.decrypt_block(m_cipher_block, m_cipher_block); m_cipher_block.apply_initialization_vector(iv); auto decrypted = m_cipher_block.bytes(); - ASSERT(offset + decrypted.size() <= out.size()); + VERIFY(offset + decrypted.size() <= out.size()); __builtin_memcpy(out.offset(offset), decrypted.data(), decrypted.size()); iv = slice; length -= block_size; diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h index 26895a8fca..a2601956c4 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h @@ -160,7 +160,7 @@ protected: { size_t length; if (in) { - ASSERT(in->size() <= out.size()); + VERIFY(in->size() <= out.size()); length = in->size(); if (length == 0) return; @@ -172,8 +172,8 @@ protected: // FIXME: We should have two of these encrypt/decrypt functions that // we SFINAE out based on whether the Cipher mode needs an ivec - ASSERT(!ivec.is_empty()); - ASSERT(ivec.size() >= IV_length()); + VERIFY(!ivec.is_empty()); + VERIFY(ivec.size() >= IV_length()); m_cipher_block.set_padding_mode(cipher.padding_mode()); @@ -192,7 +192,7 @@ protected: } auto write_size = min(block_size, length); - ASSERT(offset + write_size <= out.size()); + VERIFY(offset + write_size <= out.size()); __builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), write_size); increment(iv); diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h index 4d034f5bac..3a1d17b1d5 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h @@ -73,7 +73,7 @@ public: // 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 { - ASSERT(!ivec.is_empty()); + VERIFY(!ivec.is_empty()); static ByteBuffer dummy; diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h index a34f6a4b98..c7daba471b 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h @@ -98,7 +98,7 @@ protected: } default: // FIXME: support other padding modes - ASSERT_NOT_REACHED(); + VERIFY_NOT_REACHED(); break; } } |