From 0b7031437905d5e7dac228d2af05cd8a507c7a04 Mon Sep 17 00:00:00 2001 From: stelar7 Date: Wed, 12 Apr 2023 15:05:08 +0200 Subject: LibCrypto: Store the TBS ASN.1 data on the certificate This way we dont need to guess the offsets in LibTLS when using it. --- Userland/Libraries/LibCrypto/ASN1/DER.cpp | 10 ++++++++++ Userland/Libraries/LibCrypto/ASN1/DER.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'Userland/Libraries/LibCrypto') diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index cbd7167921..262a12454b 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -67,6 +67,16 @@ ErrorOr Decoder::read_byte() return byte; } +ErrorOr Decoder::peek_entry_bytes() +{ + if (m_stack.is_empty()) + return Error::from_string_literal("ASN1::Decoder: Reading bytes from an empty stack"); + + auto entry = m_stack.last(); + + return entry; +} + ErrorOr Decoder::read_bytes(size_t length) { if (m_stack.is_empty()) diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index 63829c95b2..8138461e38 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -151,6 +151,8 @@ public: ErrorOr enter(); ErrorOr leave(); + ErrorOr peek_entry_bytes(); + private: template ErrorOr with_type_check(DecodedType&& value) -- cgit v1.2.3