2020-04-09 02:39:48 +04:30
|
|
|
/*
|
2021-04-23 00:43:01 +04:30
|
|
|
* Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
|
2020-04-09 02:39:48 +04:30
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-09 02:39:48 +04:30
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
2021-04-18 13:44:36 +04:30
|
|
|
#include <LibCore/DateTime.h>
|
2020-04-09 02:39:48 +04:30
|
|
|
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
|
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
namespace Crypto::ASN1 {
|
2020-04-09 02:39:48 +04:30
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
enum class Kind : u8 {
|
2020-04-23 03:03:05 +04:30
|
|
|
Eol,
|
2021-02-14 14:50:42 +03:30
|
|
|
Boolean = 0x01,
|
|
|
|
|
Integer = 0x02,
|
|
|
|
|
BitString = 0x03,
|
|
|
|
|
OctetString = 0x04,
|
|
|
|
|
Null = 0x05,
|
|
|
|
|
ObjectIdentifier = 0x06,
|
|
|
|
|
IA5String = 0x16,
|
|
|
|
|
PrintableString = 0x13,
|
|
|
|
|
Utf8String = 0x0c,
|
|
|
|
|
UTCTime = 0x017,
|
2021-04-18 13:39:09 +04:30
|
|
|
GeneralizedTime = 0x018,
|
2021-02-14 14:50:42 +03:30
|
|
|
Sequence = 0x10,
|
|
|
|
|
Set = 0x11,
|
|
|
|
|
// Choice = ??,
|
2020-04-23 03:03:05 +04:30
|
|
|
};
|
2020-04-09 02:39:48 +04:30
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
enum class Class : u8 {
|
|
|
|
|
Universal = 0,
|
|
|
|
|
Application = 0x40,
|
|
|
|
|
Context = 0x80,
|
|
|
|
|
Private = 0xc0,
|
|
|
|
|
};
|
2020-04-09 02:39:48 +04:30
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
enum class Type : u8 {
|
|
|
|
|
Primitive = 0,
|
|
|
|
|
Constructed = 0x20,
|
|
|
|
|
};
|
2020-04-09 02:39:48 +04:30
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
struct Tag {
|
2020-04-23 03:03:05 +04:30
|
|
|
Kind kind;
|
2021-02-14 14:50:42 +03:30
|
|
|
Class class_;
|
|
|
|
|
Type type;
|
2020-04-23 03:03:05 +04:30
|
|
|
};
|
|
|
|
|
|
2021-02-14 14:50:42 +03:30
|
|
|
String kind_name(Kind);
|
|
|
|
|
String class_name(Class);
|
|
|
|
|
String type_name(Type);
|
2020-04-09 02:39:48 +04:30
|
|
|
|
2021-04-18 13:44:36 +04:30
|
|
|
Optional<Core::DateTime> parse_utc_time(const StringView&);
|
|
|
|
|
Optional<Core::DateTime> parse_generalized_time(const StringView&);
|
|
|
|
|
|
2020-04-09 02:39:48 +04:30
|
|
|
}
|