summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstelar7 <dudedbz@gmail.com>2023-04-03 18:50:57 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2023-04-06 09:57:31 +0330
commit8273fc230ce16d3244b99b749ae1a16cd82ea55d (patch)
tree99c4f67414b1597a9505ceb32a95ece06209893f
parent6163f607c0fc1e417e42461c1bdd8a807338fccf (diff)
downloadserenity-8273fc230ce16d3244b99b749ae1a16cd82ea55d.zip
LibCrypto: Add missing ASN1 tag kinds
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/ASN1.cpp63
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/ASN1.h37
-rw-r--r--Userland/Libraries/LibCrypto/ASN1/DER.cpp5
3 files changed, 89 insertions, 16 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp
index df431365ed..25c66441eb 100644
--- a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp
+++ b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp
@@ -26,20 +26,66 @@ DeprecatedString kind_name(Kind kind)
return "Null";
case Kind::ObjectIdentifier:
return "ObjectIdentifier";
- case Kind::IA5String:
- return "IA5String";
+ case Kind::ObjectDescriptor:
+ return "ObjectDescriptor";
+ case Kind::External:
+ return "External";
+ case Kind::Real:
+ return "Real";
+ case Kind::Enumerated:
+ return "Enumerated";
+ case Kind::EmbeddedPdv:
+ return "EmbeddedPdv";
+ case Kind::Utf8String:
+ return "Utf8String";
+ case Kind::RelativeOid:
+ return "RelativeOid";
+ case Kind::Time:
+ return "Time";
+ case Kind::Reserved:
+ return "Reserved";
+ case Kind::Sequence:
+ return "Sequence";
+ case Kind::Set:
+ return "Set";
+ case Kind::NumericString:
+ return "NumericString";
case Kind::PrintableString:
return "PrintableString";
- case Kind::Utf8String:
- return "UTF8String";
+ case Kind::T61String:
+ return "T61String";
+ case Kind::VideotexString:
+ return "VideotexString";
+ case Kind::IA5String:
+ return "IA5String";
case Kind::UTCTime:
return "UTCTime";
case Kind::GeneralizedTime:
return "GeneralizedTime";
- case Kind::Sequence:
- return "Sequence";
- case Kind::Set:
- return "Set";
+ case Kind::GraphicString:
+ return "GraphicString";
+ case Kind::VisibleString:
+ return "VisibleString";
+ case Kind::GeneralString:
+ return "GeneralString";
+ case Kind::UniversalString:
+ return "UniversalString";
+ case Kind::CharacterString:
+ return "CharacterString";
+ case Kind::BMPString:
+ return "BMPString";
+ case Kind::Date:
+ return "Date";
+ case Kind::TimeOfDay:
+ return "TimeOfDay";
+ case Kind::DateTime:
+ return "DateTime";
+ case Kind::Duration:
+ return "Duration";
+ case Kind::OidIri:
+ return "OidIri";
+ case Kind::RelativeOidIri:
+ return "RelativeOidIri";
}
return "InvalidKind";
@@ -190,5 +236,4 @@ done_parsing:;
// Unceremoniously drop the milliseconds on the floor.
return Core::DateTime::create(year.value(), month.value(), day.value(), hour.value(), minute.value_or(0), seconds.value_or(0));
}
-
}
diff --git a/Userland/Libraries/LibCrypto/ASN1/ASN1.h b/Userland/Libraries/LibCrypto/ASN1/ASN1.h
index b0e6e6c030..5553b7d81b 100644
--- a/Userland/Libraries/LibCrypto/ASN1/ASN1.h
+++ b/Userland/Libraries/LibCrypto/ASN1/ASN1.h
@@ -12,22 +12,45 @@
namespace Crypto::ASN1 {
+// ITU-T X.680, section 8, table 1
enum class Kind : u8 {
- Eol,
+ Eol = 0x00,
Boolean = 0x01,
Integer = 0x02,
BitString = 0x03,
OctetString = 0x04,
Null = 0x05,
ObjectIdentifier = 0x06,
- IA5String = 0x16,
- PrintableString = 0x13,
- Utf8String = 0x0c,
- UTCTime = 0x017,
- GeneralizedTime = 0x018,
+ ObjectDescriptor = 0x07,
+ External = 0x08,
+ Real = 0x09,
+ Enumerated = 0x0A,
+ EmbeddedPdv = 0x0B,
+ Utf8String = 0x0C,
+ RelativeOid = 0x0D,
+ Time = 0x0E,
+ Reserved = 0x0F,
Sequence = 0x10,
Set = 0x11,
- // Choice = ??,
+ NumericString = 0x12,
+ PrintableString = 0x13,
+ T61String = 0x14,
+ VideotexString = 0x15,
+ IA5String = 0x16,
+ UTCTime = 0x017,
+ GeneralizedTime = 0x18,
+ GraphicString = 0x19,
+ VisibleString = 0x1A,
+ GeneralString = 0x1B,
+ UniversalString = 0x1C,
+ CharacterString = 0x1D,
+ BMPString = 0x1E,
+ Date = 0x1F,
+ TimeOfDay = 0x20,
+ DateTime = 0x21,
+ Duration = 0x22,
+ OidIri = 0x23,
+ RelativeOidIri = 0x24,
};
enum class Class : u8 {
diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp
index c68d3b524f..cbd7167921 100644
--- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp
+++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp
@@ -294,6 +294,8 @@ ErrorOr<void> pretty_print(Decoder& decoder, Stream& stream, int indent)
case Kind::UTCTime:
case Kind::GeneralizedTime:
case Kind::IA5String:
+ case Kind::VisibleString:
+ case Kind::BMPString:
case Kind::PrintableString: {
auto value = TRY(decoder.read<StringView>());
builder.append(' ');
@@ -310,6 +312,9 @@ ErrorOr<void> pretty_print(Decoder& decoder, Stream& stream, int indent)
case Kind::Sequence:
case Kind::Set:
return Error::from_string_literal("ASN1::Decoder: Unexpected Primitive");
+ default: {
+ dbgln("PrettyPrint error: Unhandled kind {}", static_cast<u8>(tag.kind));
+ }
}
}