mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibCrypto: Use BitmapView instead of Bitmap::wrap()
This commit is contained in:
parent
a1d1a3b50b
commit
ed9ab38b3b
3 changed files with 5 additions and 6 deletions
|
@ -190,14 +190,13 @@ Result<StringView, DecodeError> Decoder::decode_printable_string(ReadonlyBytes d
|
||||||
return StringView { data };
|
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)
|
if (data.size() < 1)
|
||||||
return DecodeError::InvalidInputFormat;
|
return DecodeError::InvalidInputFormat;
|
||||||
|
|
||||||
auto unused_bits = data[0];
|
auto unused_bits = data[0];
|
||||||
// FIXME: It's rather annoying that `Bitmap` is always mutable.
|
return BitmapView { const_cast<u8*>(data.offset_pointer(1)), data.size() * 8 - unused_bits };
|
||||||
return Bitmap::wrap(const_cast<u8*>(data.offset_pointer(1)), data.size() * 8 - unused_bits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<Tag, DecodeError> Decoder::peek()
|
Result<Tag, DecodeError> Decoder::peek()
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Bitmap.h>
|
#include <AK/BitmapView.h>
|
||||||
#include <AK/Result.h>
|
#include <AK/Result.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibCrypto/ASN1/ASN1.h>
|
#include <LibCrypto/ASN1/ASN1.h>
|
||||||
|
@ -176,7 +176,7 @@ private:
|
||||||
static Result<std::nullptr_t, DecodeError> decode_null(ReadonlyBytes);
|
static Result<std::nullptr_t, DecodeError> decode_null(ReadonlyBytes);
|
||||||
static Result<Vector<int>, DecodeError> decode_object_identifier(ReadonlyBytes);
|
static Result<Vector<int>, DecodeError> decode_object_identifier(ReadonlyBytes);
|
||||||
static Result<StringView, DecodeError> decode_printable_string(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;
|
Vector<ReadonlyBytes> m_stack;
|
||||||
Optional<Tag> m_current_tag;
|
Optional<Tag> m_current_tag;
|
||||||
|
|
|
@ -209,7 +209,7 @@ RSA::KeyPairType RSA::parse_rsa_key(ReadonlyBytes der)
|
||||||
return keypair;
|
return keypair;
|
||||||
|
|
||||||
// Now we have a bit string, which contains the PKCS#1 encoded public key.
|
// 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()) {
|
if (data_result.is_error()) {
|
||||||
dbgln_if(RSA_PARSE_DEBUG, "RSA PKCS#8 public key parse failed: {}", data_result.error());
|
dbgln_if(RSA_PARSE_DEBUG, "RSA PKCS#8 public key parse failed: {}", data_result.error());
|
||||||
return keypair;
|
return keypair;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue