Browse Source

LibCrypto: Skip the check against 2^32 on 32-bit

We can't have a length that large there. This was causing a build error
about shifting a 32-bit value by 32 bits.
Sergey Bugaev 1 year ago
parent
commit
e720eadd9e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Userland/Libraries/LibCrypto/Hash/MGF.h

+ 4 - 2
Userland/Libraries/LibCrypto/Hash/MGF.h

@@ -24,8 +24,10 @@ public:
         size_t h_len = hash.digest_size();
 
         // 1. If length > 2^32(hLen), output "mask too long" and stop.
-        if (length > (h_len << 32))
-            return Error::from_string_view("mask too long"sv);
+        if constexpr (sizeof(size_t) > 32) {
+            if (length > (h_len << 32))
+                return Error::from_string_view("mask too long"sv);
+        }
 
         // 2. Let T be the empty octet string.
         auto t = TRY(ByteBuffer::create_uninitialized(0));