diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-04 10:59:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-04 11:25:45 +0100 |
commit | ed9ab38b3b074f188ac739c132335dac2f0f6cb8 (patch) | |
tree | 4591bc477121d29fbbdefb1205411e64379e4c44 /Userland/Libraries | |
parent | a1d1a3b50b3c00effa8ea44dd7c1c080eed8c34b (diff) | |
download | serenity-ed9ab38b3b074f188ac739c132335dac2f0f6cb8.zip |
LibCrypto: Use BitmapView instead of Bitmap::wrap()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCrypto/ASN1/DER.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/ASN1/DER.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibCrypto/PK/RSA.cpp | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index 3beeb221ae..1fcbbc113b 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -190,14 +190,13 @@ Result<StringView, DecodeError> Decoder::decode_printable_string(ReadonlyBytes d return StringView { data }; } -Result<Bitmap, DecodeError> Decoder::decode_bit_string(ReadonlyBytes data) +Result<const BitmapView, DecodeError> Decoder::decode_bit_string(ReadonlyBytes data) { if (data.size() < 1) return DecodeError::InvalidInputFormat; auto unused_bits = data[0]; - // FIXME: It's rather annoying that `Bitmap` is always mutable. - return Bitmap::wrap(const_cast<u8*>(data.offset_pointer(1)), data.size() * 8 - unused_bits); + return BitmapView { const_cast<u8*>(data.offset_pointer(1)), data.size() * 8 - unused_bits }; } Result<Tag, DecodeError> Decoder::peek() diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index e073820be6..42df876554 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -26,7 +26,7 @@ #pragma once -#include <AK/Bitmap.h> +#include <AK/BitmapView.h> #include <AK/Result.h> #include <AK/Types.h> #include <LibCrypto/ASN1/ASN1.h> @@ -176,7 +176,7 @@ private: static Result<std::nullptr_t, DecodeError> decode_null(ReadonlyBytes); static Result<Vector<int>, DecodeError> decode_object_identifier(ReadonlyBytes); static Result<StringView, DecodeError> decode_printable_string(ReadonlyBytes); - static Result<Bitmap, DecodeError> decode_bit_string(ReadonlyBytes); + static Result<const BitmapView, DecodeError> decode_bit_string(ReadonlyBytes); Vector<ReadonlyBytes> m_stack; Optional<Tag> m_current_tag; diff --git a/Userland/Libraries/LibCrypto/PK/RSA.cpp b/Userland/Libraries/LibCrypto/PK/RSA.cpp index 2a5b7960b4..a19ea0ba4c 100644 --- a/Userland/Libraries/LibCrypto/PK/RSA.cpp +++ b/Userland/Libraries/LibCrypto/PK/RSA.cpp @@ -209,7 +209,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes der) return keypair; // Now we have a bit string, which contains the PKCS#1 encoded public key. - auto data_result = decoder.read<Bitmap>(); + auto data_result = decoder.read<BitmapView>(); if (data_result.is_error()) { dbgln_if(RSA_PARSE_DEBUG, "RSA PKCS#8 public key parse failed: {}", data_result.error()); return keypair; |