ASN1.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. #include <LibCore/DateTime.h>
  9. #include <LibCrypto/BigInt/UnsignedBigInteger.h>
  10. namespace Crypto::ASN1 {
  11. enum class Kind : u8 {
  12. Eol,
  13. Boolean = 0x01,
  14. Integer = 0x02,
  15. BitString = 0x03,
  16. OctetString = 0x04,
  17. Null = 0x05,
  18. ObjectIdentifier = 0x06,
  19. IA5String = 0x16,
  20. PrintableString = 0x13,
  21. Utf8String = 0x0c,
  22. UTCTime = 0x017,
  23. GeneralizedTime = 0x018,
  24. Sequence = 0x10,
  25. Set = 0x11,
  26. // Choice = ??,
  27. };
  28. enum class Class : u8 {
  29. Universal = 0,
  30. Application = 0x40,
  31. Context = 0x80,
  32. Private = 0xc0,
  33. };
  34. enum class Type : u8 {
  35. Primitive = 0,
  36. Constructed = 0x20,
  37. };
  38. struct Tag {
  39. Kind kind;
  40. Class class_;
  41. Type type;
  42. };
  43. String kind_name(Kind);
  44. String class_name(Class);
  45. String type_name(Type);
  46. Optional<Core::DateTime> parse_utc_time(const StringView&);
  47. Optional<Core::DateTime> parse_generalized_time(const StringView&);
  48. }