diff options
author | stelar7 <dudedbz@gmail.com> | 2023-04-03 18:53:29 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2023-04-06 09:57:31 +0330 |
commit | b1d80b35af1d05e0fff8ce3da76f58dd5b5a4fd0 (patch) | |
tree | a1b96ce3904603e9d65a67f01f5488e9a5efd586 /Userland | |
parent | 8273fc230ce16d3244b99b749ae1a16cd82ea55d (diff) | |
download | serenity-b1d80b35af1d05e0fff8ce3da76f58dd5b5a4fd0.zip |
LibCrypto: Add ability to rewrite current tag kind
This is used for IMPLICIT tags where the expected kind is overriden
by the encoding instructions.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCrypto/ASN1/DER.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index d4333e5b94..63829c95b2 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -58,6 +58,25 @@ public: ValueType value; }; + ErrorOr<void> rewrite_tag(Kind kind) + { + if (m_stack.is_empty()) + return Error::from_string_view("Nothing on stack to rewrite"sv); + + if (eof()) + return Error::from_string_view("Stream is empty"sv); + + if (m_current_tag.has_value()) { + m_current_tag->kind = kind; + return {}; + } + + auto tag = TRY(read_tag()); + m_current_tag = tag; + m_current_tag->kind = kind; + return {}; + } + ErrorOr<void> drop() { if (m_stack.is_empty()) |