summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstelar7 <dudedbz@gmail.com>2023-04-03 18:53:29 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2023-04-06 09:57:31 +0330
commitb1d80b35af1d05e0fff8ce3da76f58dd5b5a4fd0 (patch)
treea1b96ce3904603e9d65a67f01f5488e9a5efd586
parent8273fc230ce16d3244b99b749ae1a16cd82ea55d (diff)
downloadserenity-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.
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/DER.h19
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())