From ed9ab38b3b074f188ac739c132335dac2f0f6cb8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 4 Mar 2021 10:59:00 +0100 Subject: [PATCH] LibCrypto: Use BitmapView instead of Bitmap::wrap() --- Userland/Libraries/LibCrypto/ASN1/DER.cpp | 5 ++--- Userland/Libraries/LibCrypto/ASN1/DER.h | 4 ++-- 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 Decoder::decode_printable_string(ReadonlyBytes d return StringView { data }; } -Result Decoder::decode_bit_string(ReadonlyBytes data) +Result 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(data.offset_pointer(1)), data.size() * 8 - unused_bits); + return BitmapView { const_cast(data.offset_pointer(1)), data.size() * 8 - unused_bits }; } Result 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 +#include #include #include #include @@ -176,7 +176,7 @@ private: static Result decode_null(ReadonlyBytes); static Result, DecodeError> decode_object_identifier(ReadonlyBytes); static Result decode_printable_string(ReadonlyBytes); - static Result decode_bit_string(ReadonlyBytes); + static Result decode_bit_string(ReadonlyBytes); Vector m_stack; Optional 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(); + auto data_result = decoder.read(); if (data_result.is_error()) { dbgln_if(RSA_PARSE_DEBUG, "RSA PKCS#8 public key parse failed: {}", data_result.error()); return keypair;