summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCrypto
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibCrypto')
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/PEM.cpp2
-rw-r--r--Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp2
-rw-r--r--Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp10
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/AES.cpp10
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Cipher.h6
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h12
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h8
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h2
-rw-r--r--Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h2
-rw-r--r--Userland/Libraries/LibCrypto/Hash/HashManager.h8
-rw-r--r--Userland/Libraries/LibCrypto/Hash/MD5.cpp2
-rw-r--r--Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp12
-rw-r--r--Userland/Libraries/LibCrypto/PK/RSA.cpp6
13 files changed, 41 insertions, 41 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
index 96c9e1a65e..c7fae1b6fb 100644
--- a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
+++ b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp
@@ -62,7 +62,7 @@ ByteBuffer decode_pem(ReadonlyBytes data)
lexer.consume_all();
break;
default:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
}
diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
index c0699018e6..5d548c23a5 100644
--- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
+++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
@@ -40,7 +40,7 @@ size_t SignedBigInteger::export_data(Bytes data, bool remove_leading_zeros) cons
{
// FIXME: Support this:
// m <0XX> -> m <XX> (if remove_leading_zeros)
- ASSERT(!remove_leading_zeros);
+ VERIFY(!remove_leading_zeros);
data[0] = m_sign;
auto bytes_view = data.slice(1, data.size() - 1);
diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp
index 63021614bb..ec622847c8 100644
--- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp
+++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp
@@ -106,7 +106,7 @@ String UnsignedBigInteger::to_base10() const
while (temp != UnsignedBigInteger { 0 }) {
divide_u16_without_allocation(temp, 10, quotient, remainder);
- ASSERT(remainder.words()[0] < 10);
+ VERIFY(remainder.words()[0] < 10);
builder.append(static_cast<char>(remainder.words()[0] + '0'));
temp.set_to(quotient);
}
@@ -389,7 +389,7 @@ void UnsignedBigInteger::subtract_without_allocation(
}
// This assertion should not fail, because we verified that *this>=other at the beginning of the function
- ASSERT(borrow == 0);
+ VERIFY(borrow == 0);
}
/**
@@ -672,7 +672,7 @@ FLATTEN void UnsignedBigInteger::divide_u16_without_allocation(
UnsignedBigInteger& quotient,
UnsignedBigInteger& remainder)
{
- ASSERT(denominator < (1 << 16));
+ VERIFY(denominator < (1 << 16));
u32 remainder_word = 0;
auto numerator_length = numerator.trimmed_length();
quotient.set_to_0();
@@ -717,8 +717,8 @@ ALWAYS_INLINE u32 UnsignedBigInteger::shift_left_get_one_word(
{
// "<= length()" (rather than length() - 1) is intentional,
// The result inedx of length() is used when calculating the carry word
- ASSERT(result_word_index <= number.length());
- ASSERT(num_bits <= UnsignedBigInteger::BITS_IN_WORD);
+ VERIFY(result_word_index <= number.length());
+ VERIFY(num_bits <= UnsignedBigInteger::BITS_IN_WORD);
u32 result = 0;
// we need to check for "num_bits != 0" since shifting right by 32 is apparently undefined behaviour!
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;
}
}
diff --git a/Userland/Libraries/LibCrypto/Hash/HashManager.h b/Userland/Libraries/LibCrypto/Hash/HashManager.h
index 9b47149602..9da7c24526 100644
--- a/Userland/Libraries/LibCrypto/Hash/HashManager.h
+++ b/Userland/Libraries/LibCrypto/Hash/HashManager.h
@@ -85,7 +85,7 @@ struct MultiHashDigestVariant {
return sha512.value().immutable_data();
default:
case HashKind::None:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
break;
}
}
@@ -103,7 +103,7 @@ struct MultiHashDigestVariant {
return sha512.value().data_length();
default:
case HashKind::None:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
break;
}
}
@@ -179,7 +179,7 @@ public:
inline void initialize(HashKind kind)
{
if (m_kind != HashKind::None) {
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
m_kind = kind;
@@ -248,7 +248,7 @@ public:
return { m_sha512->peek() };
default:
case HashKind::None:
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
break;
}
}
diff --git a/Userland/Libraries/LibCrypto/Hash/MD5.cpp b/Userland/Libraries/LibCrypto/Hash/MD5.cpp
index 1b2a71d30a..5cf717134f 100644
--- a/Userland/Libraries/LibCrypto/Hash/MD5.cpp
+++ b/Userland/Libraries/LibCrypto/Hash/MD5.cpp
@@ -88,7 +88,7 @@ void MD5::update(const u8* input, size_t length)
index = 0;
}
- ASSERT(length < part_length || length - offset <= 64);
+ VERIFY(length < part_length || length - offset <= 64);
m_buffer.overwrite(index, &input[offset], length - offset);
}
MD5::DigestType MD5::digest()
diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
index ecccd2c60e..fd54602ae4 100644
--- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
+++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp
@@ -240,7 +240,7 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
{
// Written using Wikipedia:
// https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test
- ASSERT(!(n < 4));
+ VERIFY(!(n < 4));
auto predecessor = n.minus({ 1 });
auto d = predecessor;
size_t r = 0;
@@ -259,8 +259,8 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
}
for (auto& a : tests) {
- // Technically: ASSERT(2 <= a && a <= n - 2)
- ASSERT(a < n);
+ // Technically: VERIFY(2 <= a && a <= n - 2)
+ VERIFY(a < n);
auto x = ModularPower(a, d, n);
if (x == 1 || x == predecessor)
continue;
@@ -283,13 +283,13 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBigInteger& max_excluded)
{
- ASSERT(min < max_excluded);
+ VERIFY(min < max_excluded);
auto range = max_excluded.minus(min);
UnsignedBigInteger base;
auto size = range.trimmed_length() * sizeof(u32) + 2;
// "+2" is intentional (see below).
// Also, if we're about to crash anyway, at least produce a nice error:
- ASSERT(size < 8 * MiB);
+ VERIFY(size < 8 * MiB);
u8 buf[size];
AK::fill_with_random(buf, size);
UnsignedBigInteger random { buf, size };
@@ -340,7 +340,7 @@ bool is_probably_prime(const UnsignedBigInteger& p)
UnsignedBigInteger random_big_prime(size_t bits)
{
- ASSERT(bits >= 33);
+ VERIFY(bits >= 33);
UnsignedBigInteger min = UnsignedBigInteger::from_base10("6074001000").shift_left(bits - 33);
UnsignedBigInteger max = UnsignedBigInteger { 1 }.shift_left(bits).minus(1);
for (;;) {
diff --git a/Userland/Libraries/LibCrypto/PK/RSA.cpp b/Userland/Libraries/LibCrypto/PK/RSA.cpp
index dc6a042b83..b4b90c187b 100644
--- a/Userland/Libraries/LibCrypto/PK/RSA.cpp
+++ b/Userland/Libraries/LibCrypto/PK/RSA.cpp
@@ -286,7 +286,7 @@ void RSA::import_private_key(ReadonlyBytes bytes, bool pem)
auto key = parse_rsa_key(bytes);
if (!key.private_key.length()) {
dbgln("We expected to see a private key, but we found none");
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
m_private_key = key.private_key;
}
@@ -302,7 +302,7 @@ void RSA::import_public_key(ReadonlyBytes bytes, bool pem)
auto key = parse_rsa_key(bytes);
if (!key.public_key.length()) {
dbgln("We expected to see a public key, but we found none");
- ASSERT_NOT_REACHED();
+ VERIFY_NOT_REACHED();
}
m_public_key = key.public_key;
}
@@ -356,7 +356,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
u8 ps[ps_length];
// FIXME: Without this assertion, GCC refuses to compile due to a memcpy overflow(!?)
- ASSERT(ps_length < 16384);
+ VERIFY(ps_length < 16384);
AK::fill_with_random(ps, ps_length);
// since arc4random can create zeros (shocking!)