mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibCrypto: Add missing ASN1 tag kinds
This commit is contained in:
parent
6163f607c0
commit
8273fc230c
3 changed files with 90 additions and 17 deletions
|
@ -26,20 +26,66 @@ DeprecatedString kind_name(Kind kind)
|
||||||
return "Null";
|
return "Null";
|
||||||
case Kind::ObjectIdentifier:
|
case Kind::ObjectIdentifier:
|
||||||
return "ObjectIdentifier";
|
return "ObjectIdentifier";
|
||||||
case Kind::IA5String:
|
case Kind::ObjectDescriptor:
|
||||||
return "IA5String";
|
return "ObjectDescriptor";
|
||||||
case Kind::PrintableString:
|
case Kind::External:
|
||||||
return "PrintableString";
|
return "External";
|
||||||
|
case Kind::Real:
|
||||||
|
return "Real";
|
||||||
|
case Kind::Enumerated:
|
||||||
|
return "Enumerated";
|
||||||
|
case Kind::EmbeddedPdv:
|
||||||
|
return "EmbeddedPdv";
|
||||||
case Kind::Utf8String:
|
case Kind::Utf8String:
|
||||||
return "UTF8String";
|
return "Utf8String";
|
||||||
case Kind::UTCTime:
|
case Kind::RelativeOid:
|
||||||
return "UTCTime";
|
return "RelativeOid";
|
||||||
case Kind::GeneralizedTime:
|
case Kind::Time:
|
||||||
return "GeneralizedTime";
|
return "Time";
|
||||||
|
case Kind::Reserved:
|
||||||
|
return "Reserved";
|
||||||
case Kind::Sequence:
|
case Kind::Sequence:
|
||||||
return "Sequence";
|
return "Sequence";
|
||||||
case Kind::Set:
|
case Kind::Set:
|
||||||
return "Set";
|
return "Set";
|
||||||
|
case Kind::NumericString:
|
||||||
|
return "NumericString";
|
||||||
|
case Kind::PrintableString:
|
||||||
|
return "PrintableString";
|
||||||
|
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::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";
|
return "InvalidKind";
|
||||||
|
@ -190,5 +236,4 @@ done_parsing:;
|
||||||
// Unceremoniously drop the milliseconds on the floor.
|
// 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));
|
return Core::DateTime::create(year.value(), month.value(), day.value(), hour.value(), minute.value_or(0), seconds.value_or(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,22 +12,45 @@
|
||||||
|
|
||||||
namespace Crypto::ASN1 {
|
namespace Crypto::ASN1 {
|
||||||
|
|
||||||
|
// ITU-T X.680, section 8, table 1
|
||||||
enum class Kind : u8 {
|
enum class Kind : u8 {
|
||||||
Eol,
|
Eol = 0x00,
|
||||||
Boolean = 0x01,
|
Boolean = 0x01,
|
||||||
Integer = 0x02,
|
Integer = 0x02,
|
||||||
BitString = 0x03,
|
BitString = 0x03,
|
||||||
OctetString = 0x04,
|
OctetString = 0x04,
|
||||||
Null = 0x05,
|
Null = 0x05,
|
||||||
ObjectIdentifier = 0x06,
|
ObjectIdentifier = 0x06,
|
||||||
IA5String = 0x16,
|
ObjectDescriptor = 0x07,
|
||||||
PrintableString = 0x13,
|
External = 0x08,
|
||||||
Utf8String = 0x0c,
|
Real = 0x09,
|
||||||
UTCTime = 0x017,
|
Enumerated = 0x0A,
|
||||||
GeneralizedTime = 0x018,
|
EmbeddedPdv = 0x0B,
|
||||||
|
Utf8String = 0x0C,
|
||||||
|
RelativeOid = 0x0D,
|
||||||
|
Time = 0x0E,
|
||||||
|
Reserved = 0x0F,
|
||||||
Sequence = 0x10,
|
Sequence = 0x10,
|
||||||
Set = 0x11,
|
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 {
|
enum class Class : u8 {
|
||||||
|
|
|
@ -294,6 +294,8 @@ ErrorOr<void> pretty_print(Decoder& decoder, Stream& stream, int indent)
|
||||||
case Kind::UTCTime:
|
case Kind::UTCTime:
|
||||||
case Kind::GeneralizedTime:
|
case Kind::GeneralizedTime:
|
||||||
case Kind::IA5String:
|
case Kind::IA5String:
|
||||||
|
case Kind::VisibleString:
|
||||||
|
case Kind::BMPString:
|
||||||
case Kind::PrintableString: {
|
case Kind::PrintableString: {
|
||||||
auto value = TRY(decoder.read<StringView>());
|
auto value = TRY(decoder.read<StringView>());
|
||||||
builder.append(' ');
|
builder.append(' ');
|
||||||
|
@ -310,6 +312,9 @@ ErrorOr<void> pretty_print(Decoder& decoder, Stream& stream, int indent)
|
||||||
case Kind::Sequence:
|
case Kind::Sequence:
|
||||||
case Kind::Set:
|
case Kind::Set:
|
||||||
return Error::from_string_literal("ASN1::Decoder: Unexpected Primitive");
|
return Error::from_string_literal("ASN1::Decoder: Unexpected Primitive");
|
||||||
|
default: {
|
||||||
|
dbgln("PrettyPrint error: Unhandled kind {}", static_cast<u8>(tag.kind));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue