Repository: randombit/botan
Pull request #2441 (2020-10-31 10:55:34)

Merge some of the ASN.1 headers
Deprecate asn1_str.h asn1_time.h asn1_oid.h and alg_id.h with all contents moved to existing asn1_obj.h

The deprecated headers are still there but just forward the include


Patch:
diff --git a/doc/deprecated.rst b/doc/deprecated.rst
index 8dce1c980..f2e4f0a01 100644
--- a/doc/deprecated.rst
+++ b/doc/deprecated.rst
@@ -257,6 +257,9 @@ Deprecated Headers
   ``stl_compatibility.h``,
   ``uuid.h``,
 
+  Merged into other headers:
+  ``alg_id.h``, ``asn1_oid.h``, ``asn1_str.h``, and ``asn1_time.h`` - use ``asn1_obj.h``
+
 Other API deprecations
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
diff --git a/src/lib/asn1/alg_id.cpp b/src/lib/asn1/alg_id.cpp
index b564bf1fa..1e82f2995 100644
--- a/src/lib/asn1/alg_id.cpp
+++ b/src/lib/asn1/alg_id.cpp
@@ -5,7 +5,7 @@
 * Botan is released under the Simplified BSD License (see license.txt)
 */
 
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/oids.h>
diff --git a/src/lib/asn1/alg_id.h b/src/lib/asn1/alg_id.h
index 55e533d66..88e54466d 100644
--- a/src/lib/asn1/alg_id.h
+++ b/src/lib/asn1/alg_id.h
@@ -9,59 +9,6 @@
 #define BOTAN_ALGORITHM_IDENTIFIER_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/asn1_oid.h>
-#include <string>
-#include <vector>
-
-namespace Botan {
-
-/**
-* Algorithm Identifier
-*/
-class BOTAN_PUBLIC_API(2,0) AlgorithmIdentifier final : public ASN1_Object
-   {
-   public:
-      enum Encoding_Option { USE_NULL_PARAM, USE_EMPTY_PARAM };
-
-      void encode_into(class DER_Encoder&) const override;
-      void decode_from(class BER_Decoder&) override;
-
-      AlgorithmIdentifier() = default;
-
-      AlgorithmIdentifier(const OID& oid, Encoding_Option enc);
-      AlgorithmIdentifier(const std::string& oid_name, Encoding_Option enc);
-
-      AlgorithmIdentifier(const OID& oid, const std::vector<uint8_t>& params);
-      AlgorithmIdentifier(const std::string& oid_name, const std::vector<uint8_t>& params);
-
-      const OID& get_oid() const { return oid; }
-      const std::vector<uint8_t>& get_parameters() const { return parameters; }
-
-      bool parameters_are_null() const;
-      bool parameters_are_empty() const { return parameters.empty(); }
-
-      bool parameters_are_null_or_empty() const
-         {
-         return parameters_are_empty() || parameters_are_null();
-         }
-
-   BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES:
-      /*
-      * These values are public for historical reasons, but in a future release
-      * they will be made private. Do not access them.
-      */
-      OID oid;
-      std::vector<uint8_t> parameters;
-   };
-
-/*
-* Comparison Operations
-*/
-bool BOTAN_PUBLIC_API(2,0) operator==(const AlgorithmIdentifier&,
-                                      const AlgorithmIdentifier&);
-bool BOTAN_PUBLIC_API(2,0) operator!=(const AlgorithmIdentifier&,
-                                      const AlgorithmIdentifier&);
-
-}
+BOTAN_DEPRECATED_HEADER(alg_id.h)
 
 #endif
diff --git a/src/lib/asn1/asn1_attribute.h b/src/lib/asn1/asn1_attribute.h
index c9f69eb77..11670e110 100644
--- a/src/lib/asn1/asn1_attribute.h
+++ b/src/lib/asn1/asn1_attribute.h
@@ -9,7 +9,6 @@
 #define BOTAN_ASN1_ATTRIBUTE_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/asn1_oid.h>
 #include <vector>
 
 namespace Botan {
diff --git a/src/lib/asn1/asn1_obj.h b/src/lib/asn1/asn1_obj.h
index 41228a2d8..0ce443771 100644
--- a/src/lib/asn1/asn1_obj.h
+++ b/src/lib/asn1/asn1_obj.h
@@ -1,15 +1,17 @@
 /*
-* ASN.1 Internals
-* (C) 1999-2007,2018 Jack Lloyd
+* (C) 1999-2007,2018,2020 Jack Lloyd
 *
 * Botan is released under the Simplified BSD License (see license.txt)
 */
 
-#ifndef BOTAN_ASN1_H_
-#define BOTAN_ASN1_H_
+#ifndef BOTAN_ASN1_OBJECT_TYPES_H_
+#define BOTAN_ASN1_OBJECT_TYPES_H_
 
 #include <botan/secmem.h>
 #include <botan/exceptn.h>
+#include <vector>
+#include <string>
+#include <chrono>
 
 namespace Botan {
 
@@ -185,6 +187,289 @@ class BOTAN_PUBLIC_API(2,0) BER_Bad_Tag final : public BER_Decoding_Error
       BER_Bad_Tag(const std::string& msg, ASN1_Tag tag1, ASN1_Tag tag2);
    };
 
+/**
+* This class represents ASN.1 object identifiers.
+*/
+class BOTAN_PUBLIC_API(2,0) OID final : public ASN1_Object
+   {
+   public:
+
+      /**
+      * Create an uninitialied OID object
+      */
+      explicit OID() {}
+
+      /**
+      * Construct an OID from a string.
+      * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
+      */
+      explicit OID(const std::string& str);
+
+      /**
+      * Initialize an OID from a sequence of integer values
+      */
+      explicit OID(std::initializer_list<uint32_t> init) : m_id(init) {}
+
+      /**
+      * Initialize an OID from a vector of integer values
+      */
+      explicit OID(std::vector<uint32_t>&& init) : m_id(init) {}
+
+      /**
+      * Construct an OID from a string.
+      * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
+      *        or any known OID name (for example "RSA" or "X509v3.SubjectKeyIdentifier")
+      */
+      static OID from_string(const std::string& str);
+
+      void encode_into(class DER_Encoder&) const override;
+      void decode_from(class BER_Decoder&) override;
+
+      /**
+      * Find out whether this OID is empty
+      * @return true is no OID value is set
+      */
+      bool empty() const { return m_id.empty(); }
+
+      /**
+      * Find out whether this OID has a value
+      * @return true is this OID has a value
+      */
+      bool has_value() const { return (m_id.empty() == false); }
+
+      /**
+      * Get this OID as list (vector) of its components.
+      * @return vector representing this OID
+      */
+      const std::vector<uint32_t>& get_components() const { return m_id; }
+
+      const std::vector<uint32_t>& get_id() const { return get_components(); }
+
+      /**
+      * Get this OID as a string
+      * @return string representing this OID
+      */
+      std::string BOTAN_DEPRECATED("Use OID::to_string") as_string() const
+         {
+         return this->to_string();
+         }
+
+      /**
+      * Get this OID as a dotted-decimal string
+      * @return string representing this OID
+      */
+      std::string to_string() const;
+
+      /**
+      * If there is a known name associated with this OID, return that.
+      * Otherwise return the result of to_string
+      */
+      std::string to_formatted_string() const;
+
+      /**
+      * Compare two OIDs.
+      * @return true if they are equal, false otherwise
+      */
+      bool operator==(const OID& other) const
+         {
+         return m_id == other.m_id;
+         }
+
+      /**
+      * Reset this instance to an empty OID.
+      */
+      void BOTAN_DEPRECATED("Avoid mutation of OIDs") clear() { m_id.clear(); }
+
+      /**
+      * Add a component to this OID.
+      * @param new_comp the new component to add to the end of this OID
+      * @return reference to *this
+      */
+      BOTAN_DEPRECATED("Avoid mutation of OIDs") OID& operator+=(uint32_t new_comp)
+         {
+         m_id.push_back(new_comp);
+         return (*this);
+         }
+
+   private:
+      std::vector<uint32_t> m_id;
+   };
+
+/**
+* Append another component onto the OID.
+* @param oid the OID to add the new component to
+* @param new_comp the new component to add
+*/
+OID BOTAN_PUBLIC_API(2,0) operator+(const OID& oid, uint32_t new_comp);
+
+/**
+* Compare two OIDs.
+* @param a the first OID
+* @param b the second OID
+* @return true if a is not equal to b
+*/
+inline bool operator!=(const OID& a, const OID& b)
+   {
+   return !(a == b);
+   }
+
+/**
+* Compare two OIDs.
+* @param a the first OID
+* @param b the second OID
+* @return true if a is lexicographically smaller than b
+*/
+bool BOTAN_PUBLIC_API(2,0) operator<(const OID& a, const OID& b);
+
+/**
+* Time (GeneralizedTime/UniversalTime)
+*/
+class BOTAN_PUBLIC_API(2,0) ASN1_Time final : public ASN1_Object
+   {
+   public:
+      /// DER encode a ASN1_Time
+      void encode_into(DER_Encoder&) const override;
+
+      // Decode a BER encoded ASN1_Time
+      void decode_from(BER_Decoder&) override;
+
+      /// Return an internal string representation of the time
+      std::string to_string() const;
+
+      /// Returns a human friendly string replesentation of no particular formatting
+      std::string readable_string() const;
+
+      /// Return if the time has been set somehow
+      bool time_is_set() const;
+
+      ///  Compare this time against another
+      int32_t cmp(const ASN1_Time& other) const;
+
+      /// Create an invalid ASN1_Time
+      ASN1_Time() = default;
+
+      /// Create a ASN1_Time from a time point
+      explicit ASN1_Time(const std::chrono::system_clock::time_point& time);
+
+      /// Create an ASN1_Time from string
+      ASN1_Time(const std::string& t_spec, ASN1_Tag tag);
+
+      /// Returns a STL timepoint object
+      std::chrono::system_clock::time_point to_std_timepoint() const;
+
+      /// Return time since epoch
+      uint64_t time_since_epoch() const;
+
+   private:
+      void set_to(const std::string& t_spec, ASN1_Tag);
+      bool passes_sanity_check() const;
+
+      uint32_t m_year = 0;
+      uint32_t m_month = 0;
+      uint32_t m_day = 0;
+      uint32_t m_hour = 0;
+      uint32_t m_minute = 0;
+      uint32_t m_second = 0;
+      ASN1_Tag m_tag = NO_OBJECT;
+   };
+
+/*
+* Comparison Operations
+*/
+bool BOTAN_PUBLIC_API(2,0) operator==(const ASN1_Time&, const ASN1_Time&);
+bool BOTAN_PUBLIC_API(2,0) operator!=(const ASN1_Time&, const ASN1_Time&);
+bool BOTAN_PUBLIC_API(2,0) operator<=(const ASN1_Time&, const ASN1_Time&);
+bool BOTAN_PUBLIC_API(2,0) operator>=(const ASN1_Time&, const ASN1_Time&);
+bool BOTAN_PUBLIC_API(2,0) operator<(const ASN1_Time&, const ASN1_Time&);
+bool BOTAN_PUBLIC_API(2,0) operator>(const ASN1_Time&, const ASN1_Time&);
+
+typedef ASN1_Time X509_Time;
+
+/**
+* ASN.1 string type
+* This class normalizes all inputs to a UTF-8 std::string
+*/
+class BOTAN_PUBLIC_API(2,0) ASN1_String final : public ASN1_Object
+   {
+   public:
+      void encode_into(class DER_Encoder&) const override;
+      void decode_from(class BER_Decoder&) override;
+
+      ASN1_Tag tagging() const { return m_tag; }
+
+      const std::string& value() const { return m_utf8_str; }
+
+      size_t size() const { return value().size(); }
+
+      bool empty() const { return m_utf8_str.empty(); }
+
+      std::string BOTAN_DEPRECATED("Use value() to get UTF-8 string instead")
+         iso_8859() const;
+
+      /**
+      * Return true iff this is a tag for a known string type we can handle.
+      * This ignores string types that are not supported, eg teletexString
+      */
+      static bool is_string_type(ASN1_Tag tag);
+
+      bool operator==(const ASN1_String& other) const
+         { return value() == other.value(); }
+
+      explicit ASN1_String(const std::string& utf8 = "");
+      ASN1_String(const std::string& utf8, ASN1_Tag tag);
+   private:
+      std::vector<uint8_t> m_data;
+      std::string m_utf8_str;
+      ASN1_Tag m_tag;
+   };
+
+/**
+* Algorithm Identifier
+*/
+class BOTAN_PUBLIC_API(2,0) AlgorithmIdentifier final : public ASN1_Object
+   {
+   public:
+      enum Encoding_Option { USE_NULL_PARAM, USE_EMPTY_PARAM };
+
+      void encode_into(class DER_Encoder&) const override;
+      void decode_from(class BER_Decoder&) override;
+
+      AlgorithmIdentifier() = default;
+
+      AlgorithmIdentifier(const OID& oid, Encoding_Option enc);
+      AlgorithmIdentifier(const std::string& oid_name, Encoding_Option enc);
+
+      AlgorithmIdentifier(const OID& oid, const std::vector<uint8_t>& params);
+      AlgorithmIdentifier(const std::string& oid_name, const std::vector<uint8_t>& params);
+
+      const OID& get_oid() const { return oid; }
+      const std::vector<uint8_t>& get_parameters() const { return parameters; }
+
+      bool parameters_are_null() const;
+      bool parameters_are_empty() const { return parameters.empty(); }
+
+      bool parameters_are_null_or_empty() const
+         {
+         return parameters_are_empty() || parameters_are_null();
+         }
+
+   BOTAN_DEPRECATED_PUBLIC_MEMBER_VARIABLES:
+      /*
+      * These values are public for historical reasons, but in a future release
+      * they will be made private. Do not access them.
+      */
+      OID oid;
+      std::vector<uint8_t> parameters;
+   };
+
+/*
+* Comparison Operations
+*/
+bool BOTAN_PUBLIC_API(2,0) operator==(const AlgorithmIdentifier&,
+                                      const AlgorithmIdentifier&);
+bool BOTAN_PUBLIC_API(2,0) operator!=(const AlgorithmIdentifier&,
+                                      const AlgorithmIdentifier&);
+
 }
 
 #endif
diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp
index cdf9e7c81..7338886f6 100644
--- a/src/lib/asn1/asn1_oid.cpp
+++ b/src/lib/asn1/asn1_oid.cpp
@@ -5,7 +5,7 @@
 * Botan is released under the Simplified BSD License (see license.txt)
 */
 
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/internal/bit_ops.h>
diff --git a/src/lib/asn1/asn1_oid.h b/src/lib/asn1/asn1_oid.h
index 0ee3690e3..91c5da9d8 100644
--- a/src/lib/asn1/asn1_oid.h
+++ b/src/lib/asn1/asn1_oid.h
@@ -9,145 +9,6 @@
 #define BOTAN_ASN1_OID_H_
 
 #include <botan/asn1_obj.h>
-#include <string>
-#include <vector>
-
-namespace Botan {
-
-/**
-* This class represents ASN.1 object identifiers.
-*/
-class BOTAN_PUBLIC_API(2,0) OID final : public ASN1_Object
-   {
-   public:
-
-      /**
-      * Create an uninitialied OID object
-      */
-      explicit OID() {}
-
-      /**
-      * Construct an OID from a string.
-      * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
-      */
-      explicit OID(const std::string& str);
-
-      /**
-      * Initialize an OID from a sequence of integer values
-      */
-      explicit OID(std::initializer_list<uint32_t> init) : m_id(init) {}
-
-      /**
-      * Initialize an OID from a vector of integer values
-      */
-      explicit OID(std::vector<uint32_t>&& init) : m_id(init) {}
-
-      /**
-      * Construct an OID from a string.
-      * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
-      *        or any known OID name (for example "RSA" or "X509v3.SubjectKeyIdentifier")
-      */
-      static OID from_string(const std::string& str);
-
-      void encode_into(class DER_Encoder&) const override;
-      void decode_from(class BER_Decoder&) override;
-
-      /**
-      * Find out whether this OID is empty
-      * @return true is no OID value is set
-      */
-      bool empty() const { return m_id.empty(); }
-
-      /**
-      * Find out whether this OID has a value
-      * @return true is this OID has a value
-      */
-      bool has_value() const { return (m_id.empty() == false); }
-
-      /**
-      * Get this OID as list (vector) of its components.
-      * @return vector representing this OID
-      */
-      const std::vector<uint32_t>& get_components() const { return m_id; }
-
-      const std::vector<uint32_t>& get_id() const { return get_components(); }
-
-      /**
-      * Get this OID as a string
-      * @return string representing this OID
-      */
-      std::string BOTAN_DEPRECATED("Use OID::to_string") as_string() const
-         {
-         return this->to_string();
-         }
-
-      /**
-      * Get this OID as a dotted-decimal string
-      * @return string representing this OID
-      */
-      std::string to_string() const;
-
-      /**
-      * If there is a known name associated with this OID, return that.
-      * Otherwise return the result of to_string
-      */
-      std::string to_formatted_string() const;
-
-      /**
-      * Compare two OIDs.
-      * @return true if they are equal, false otherwise
-      */
-      bool operator==(const OID& other) const
-         {
-         return m_id == other.m_id;
-         }
-
-      /**
-      * Reset this instance to an empty OID.
-      */
-      void BOTAN_DEPRECATED("Avoid mutation of OIDs") clear() { m_id.clear(); }
-
-      /**
-      * Add a component to this OID.
-      * @param new_comp the new component to add to the end of this OID
-      * @return reference to *this
-      */
-      BOTAN_DEPRECATED("Avoid mutation of OIDs") OID& operator+=(uint32_t new_comp)
-         {
-         m_id.push_back(new_comp);
-         return (*this);
-         }
-
-   private:
-      std::vector<uint32_t> m_id;
-   };
-
-/**
-* Append another component onto the OID.
-* @param oid the OID to add the new component to
-* @param new_comp the new component to add
-*/
-OID BOTAN_PUBLIC_API(2,0) operator+(const OID& oid, uint32_t new_comp);
-
-/**
-* Compare two OIDs.
-* @param a the first OID
-* @param b the second OID
-* @return true if a is not equal to b
-*/
-inline bool operator!=(const OID& a, const OID& b)
-   {
-   return !(a == b);
-   }
-
-/**
-* Compare two OIDs.
-* @param a the first OID
-* @param b the second OID
-* @return true if a is lexicographically smaller than b
-*/
-bool BOTAN_PUBLIC_API(2,0) operator<(const OID& a, const OID& b);
-
-}
+BOTAN_DEPRECATED_HEADER(asn1_oid.h)
 
 #endif
diff --git a/src/lib/asn1/asn1_print.cpp b/src/lib/asn1/asn1_print.cpp
index 5b22c1d3a..faadad02b 100644
--- a/src/lib/asn1/asn1_print.cpp
+++ b/src/lib/asn1/asn1_print.cpp
@@ -9,8 +9,6 @@
 #include <botan/hex.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
-#include <botan/asn1_time.h>
-#include <botan/asn1_str.h>
 #include <botan/oids.h>
 #include <iomanip>
 #include <sstream>
@@ -228,7 +226,7 @@ void ASN1_Formatter::decode(std::ostream& output,
          }
       else if(type_tag == UTC_TIME || type_tag == GENERALIZED_TIME)
          {
-         X509_Time time;
+         ASN1_Time time;
          data.decode(time);
          output << format(type_tag, class_tag, level, length, time.readable_string());
          }
diff --git a/src/lib/asn1/asn1_str.cpp b/src/lib/asn1/asn1_str.cpp
index 416e4f0ac..6a31c5bb2 100644
--- a/src/lib/asn1/asn1_str.cpp
+++ b/src/lib/asn1/asn1_str.cpp
@@ -5,7 +5,7 @@
 * Botan is released under the Simplified BSD License (see license.txt)
 */
 
-#include <botan/asn1_str.h>
+#include <botan/asn1_obj.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/charset.h>
diff --git a/src/lib/asn1/asn1_str.h b/src/lib/asn1/asn1_str.h
index 41dbd005c..fed4950cc 100644
--- a/src/lib/asn1/asn1_str.h
+++ b/src/lib/asn1/asn1_str.h
@@ -9,47 +9,6 @@
 #define BOTAN_ASN1_STRING_H_
 
 #include <botan/asn1_obj.h>
-
-namespace Botan {
-
-/**
-* ASN.1 string type
-* This class normalizes all inputs to a UTF-8 std::string
-*/
-class BOTAN_PUBLIC_API(2,0) ASN1_String final : public ASN1_Object
-   {
-   public:
-      void encode_into(class DER_Encoder&) const override;
-      void decode_from(class BER_Decoder&) override;
-
-      ASN1_Tag tagging() const { return m_tag; }
-
-      const std::string& value() const { return m_utf8_str; }
-
-      size_t size() const { return value().size(); }
-
-      bool empty() const { return m_utf8_str.empty(); }
-
-      std::string BOTAN_DEPRECATED("Use value() to get UTF-8 string instead")
-         iso_8859() const;
-
-      /**
-      * Return true iff this is a tag for a known string type we can handle.
-      * This ignores string types that are not supported, eg teletexString
-      */
-      static bool is_string_type(ASN1_Tag tag);
-
-      bool operator==(const ASN1_String& other) const
-         { return value() == other.value(); }
-
-      explicit ASN1_String(const std::string& utf8 = "");
-      ASN1_String(const std::string& utf8, ASN1_Tag tag);
-   private:
-      std::vector<uint8_t> m_data;
-      std::string m_utf8_str;
-      ASN1_Tag m_tag;
-   };
-
-}
+BOTAN_DEPRECATED_HEADER(asn1_str.h)
 
 #endif
diff --git a/src/lib/asn1/asn1_time.cpp b/src/lib/asn1/asn1_time.cpp
index 77e2f822f..004be27b9 100644
--- a/src/lib/asn1/asn1_time.cpp
+++ b/src/lib/asn1/asn1_time.cpp
@@ -5,7 +5,7 @@
 * Botan is released under the Simplified BSD License (see license.txt)
 */
 
-#include <botan/asn1_time.h>
+#include <botan/asn1_obj.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/exceptn.h>
@@ -16,7 +16,7 @@
 
 namespace Botan {
 
-X509_Time::X509_Time(const std::chrono::system_clock::time_point& time)
+ASN1_Time::ASN1_Time(const std::chrono::system_clock::time_point& time)
    {
    calendar_point cal = calendar_value(time);
 
@@ -30,37 +30,37 @@ X509_Time::X509_Time(const std::chrono::system_clock::time_point& time)
    m_tag = (m_year >= 2050) ? GENERALIZED_TIME : UTC_TIME;
    }
 
-X509_Time::X509_Time(const std::string& t_spec, ASN1_Tag tag)
+ASN1_Time::ASN1_Time(const std::string& t_spec, ASN1_Tag tag)
    {
    set_to(t_spec, tag);
    }
 
-void X509_Time::encode_into(DER_Encoder& der) const
+void ASN1_Time::encode_into(DER_Encoder& der) const
    {
    BOTAN_ARG_CHECK(m_tag == UTC_TIME || m_tag == GENERALIZED_TIME,
-                   "X509_Time: Bad encoding tag");
+                   "ASN1_Time: Bad encoding tag");
 
    der.add_object(m_tag, UNIVERSAL, to_string());
    }
 
-void X509_Time::decode_from(BER_Decoder& source)
+void ASN1_Time::decode_from(BER_Decoder& source)
    {
    BER_Object ber_time = source.get_next_object();
 
    set_to(ASN1::to_string(ber_time), ber_time.type());
    }
 
-std::string X509_Time::to_string() const
+std::string ASN1_Time::to_string() const
    {
    if(time_is_set() == false)
-      throw Invalid_State("X509_Time::to_string: No time set");
+      throw Invalid_State("ASN1_Time::to_string: No time set");
 
    uint32_t full_year = m_year;
 
    if(m_tag == UTC_TIME)
       {
       if(m_year < 1950 || m_year >= 2050)
-         throw Encoding_Error("X509_Time: The time " + readable_string() +
+         throw Encoding_Error("ASN1_Time: The time " + readable_string() +
                               " cannot be encoded as a UTCTime");
 
       full_year = (m_year >= 2000) ? (m_year - 2000) : (m_year - 1900);
@@ -90,10 +90,10 @@ std::string X509_Time::to_string() const
    return repr;
    }
 
-std::string X509_Time::readable_string() const
+std::string ASN1_Time::readable_string() const
    {
    if(time_is_set() == false)
-      throw Invalid_State("X509_Time::readable_string: No time set");
+      throw Invalid_State("ASN1_Time::readable_string: No time set");
 
    // desired format: "%04d/%02d/%02d %02d:%02d:%02d UTC"
    std::stringstream output;
@@ -110,15 +110,15 @@ std::string X509_Time::readable_string() const
    return output.str();
    }
 
-bool X509_Time::time_is_set() const
+bool ASN1_Time::time_is_set() const
    {
    return (m_year != 0);
    }
 
-int32_t X509_Time::cmp(const X509_Time& other) const
+int32_t ASN1_Time::cmp(const ASN1_Time& other) const
    {
    if(time_is_set() == false)
-      throw Invalid_State("X509_Time::cmp: No time set");
+      throw Invalid_State("ASN1_Time::cmp: No time set");
 
    const int32_t EARLIER = -1, LATER = 1, SAME_TIME = 0;
 
@@ -138,7 +138,7 @@ int32_t X509_Time::cmp(const X509_Time& other) const
    return SAME_TIME;
    }
 
-void X509_Time::set_to(const std::string& t_spec, ASN1_Tag spec_tag)
+void ASN1_Time::set_to(const std::string& t_spec, ASN1_Tag spec_tag)
    {
    if(spec_tag == UTC_OR_GENERALIZED_TIME)
       {
@@ -215,7 +215,7 @@ void X509_Time::set_to(const std::string& t_spec, ASN1_Tag spec_tag)
 /*
 * Do a general sanity check on the time
 */
-bool X509_Time::passes_sanity_check() const
+bool ASN1_Time::passes_sanity_check() const
    {
    // AppVeyor's trust store includes a cert with expiration date in 3016 ...
    if(m_year < 1950 || m_year > 3100)
@@ -258,33 +258,33 @@ bool X509_Time::passes_sanity_check() const
    return true;
    }
 
-std::chrono::system_clock::time_point X509_Time::to_std_timepoint() const
+std::chrono::system_clock::time_point ASN1_Time::to_std_timepoint() const
    {
    return calendar_point(m_year, m_month, m_day, m_hour, m_minute, m_second).to_std_timepoint();
    }
 
-uint64_t X509_Time::time_since_epoch() const
+uint64_t ASN1_Time::time_since_epoch() const
    {
    auto tp = this->to_std_timepoint();
    return std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch()).count();
    }
 
 /*
-* Compare two X509_Times for in various ways
+* Compare two ASN1_Times for in various ways
 */
-bool operator==(const X509_Time& t1, const X509_Time& t2)
+bool operator==(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) == 0); }
-bool operator!=(const X509_Time& t1, const X509_Time& t2)
+bool operator!=(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) != 0); }
 
-bool operator<=(const X509_Time& t1, const X509_Time& t2)
+bool operator<=(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) <= 0); }
-bool operator>=(const X509_Time& t1, const X509_Time& t2)
+bool operator>=(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) >= 0); }
 
-bool operator<(const X509_Time& t1, const X509_Time& t2)
+bool operator<(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) < 0); }
-bool operator>(const X509_Time& t1, const X509_Time& t2)
+bool operator>(const ASN1_Time& t1, const ASN1_Time& t2)
    { return (t1.cmp(t2) > 0); }
 
 }
diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h
index 83567e780..55ef82e05 100644
--- a/src/lib/asn1/asn1_time.h
+++ b/src/lib/asn1/asn1_time.h
@@ -9,74 +9,6 @@
 #define BOTAN_ASN1_TIME_H_
 
 #include <botan/asn1_obj.h>
-#include <chrono>
-
-namespace Botan {
-
-/**
-* X.509 Time
-*/
-class BOTAN_PUBLIC_API(2,0) X509_Time final : public ASN1_Object
-   {
-   public:
-      /// DER encode a X509_Time
-      void encode_into(DER_Encoder&) const override;
-
-      // Decode a BER encoded X509_Time
-      void decode_from(BER_Decoder&) override;
-
-      /// Return an internal string representation of the time
-      std::string to_string() const;
-
-      /// Returns a human friendly string replesentation of no particular formatting
-      std::string readable_string() const;
-
-      /// Return if the time has been set somehow
-      bool time_is_set() const;
-
-      ///  Compare this time against another
-      int32_t cmp(const X509_Time& other) const;
-
-      /// Create an invalid X509_Time
-      X509_Time() = default;
-
-      /// Create a X509_Time from a time point
-      explicit X509_Time(const std::chrono::system_clock::time_point& time);
-
-      /// Create an X509_Time from string
-      X509_Time(const std::string& t_spec, ASN1_Tag tag);
-
-      /// Returns a STL timepoint object
-      std::chrono::system_clock::time_point to_std_timepoint() const;
-
-      /// Return time since epoch
-      uint64_t time_since_epoch() const;
-
-   private:
-      void set_to(const std::string& t_spec, ASN1_Tag);
-      bool passes_sanity_check() const;
-
-      uint32_t m_year = 0;
-      uint32_t m_month = 0;
-      uint32_t m_day = 0;
-      uint32_t m_hour = 0;
-      uint32_t m_minute = 0;
-      uint32_t m_second = 0;
-      ASN1_Tag m_tag = NO_OBJECT;
-   };
-
-/*
-* Comparison Operations
-*/
-bool BOTAN_PUBLIC_API(2,0) operator==(const X509_Time&, const X509_Time&);
-bool BOTAN_PUBLIC_API(2,0) operator!=(const X509_Time&, const X509_Time&);
-bool BOTAN_PUBLIC_API(2,0) operator<=(const X509_Time&, const X509_Time&);
-bool BOTAN_PUBLIC_API(2,0) operator>=(const X509_Time&, const X509_Time&);
-bool BOTAN_PUBLIC_API(2,0) operator<(const X509_Time&, const X509_Time&);
-bool BOTAN_PUBLIC_API(2,0) operator>(const X509_Time&, const X509_Time&);
-
-typedef X509_Time ASN1_Time;
-
-}
+BOTAN_DEPRECATED_HEADER(asn1_time.h)
 
 #endif
diff --git a/src/lib/asn1/der_enc.h b/src/lib/asn1/der_enc.h
index fac11ebf2..93d53f4b9 100644
--- a/src/lib/asn1/der_enc.h
+++ b/src/lib/asn1/der_enc.h
@@ -15,7 +15,6 @@
 namespace Botan {
 
 class BigInt;
-class ASN1_Object;
 
 /**
 * General DER Encoding Object
diff --git a/src/lib/asn1/oids.h b/src/lib/asn1/oids.h
index 1f8f88905..9af451fe4 100644
--- a/src/lib/asn1/oids.h
+++ b/src/lib/asn1/oids.h
@@ -8,7 +8,7 @@
 #ifndef BOTAN_OIDS_H_
 #define BOTAN_OIDS_H_
 
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <unordered_map>
 
 namespace Botan {
diff --git a/src/lib/kdf/prf_x942/prf_x942.h b/src/lib/kdf/prf_x942/prf_x942.h
index 1987b9bc3..98af7e069 100644
--- a/src/lib/kdf/prf_x942/prf_x942.h
+++ b/src/lib/kdf/prf_x942/prf_x942.h
@@ -9,7 +9,7 @@
 #define BOTAN_ANSI_X942_PRF_H_
 
 #include <botan/kdf.h>
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 
 BOTAN_FUTURE_INTERNAL_HEADER(prf_x942.h)
 
diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h
index 06c18a488..7178eae23 100644
--- a/src/lib/pk_pad/emsa.h
+++ b/src/lib/pk_pad/emsa.h
@@ -9,7 +9,7 @@
 #define BOTAN_PUBKEY_EMSA_H_
 
 #include <botan/secmem.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <string>
 
 BOTAN_FUTURE_INTERNAL_HEADER(emsa.h)
diff --git a/src/lib/prov/pkcs11/p11_ecc_key.h b/src/lib/prov/pkcs11/p11_ecc_key.h
index 9b6fe9240..e2fd35b1a 100644
--- a/src/lib/prov/pkcs11/p11_ecc_key.h
+++ b/src/lib/prov/pkcs11/p11_ecc_key.h
@@ -15,7 +15,7 @@
 #if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
 #include <botan/ecc_key.h>
 #include <botan/ec_group.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <vector>
 
 namespace Botan {
diff --git a/src/lib/pubkey/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h
index ec06624e2..8f583a309 100644
--- a/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/lib/pubkey/ec_group/ec_group.h
@@ -11,7 +11,7 @@
 #define BOTAN_ECC_DOMAIN_PARAMETERS_H_
 
 #include <botan/point_gfp.h>
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <memory>
 #include <set>
 
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index 66c621644..1360de67c 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -13,7 +13,7 @@
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/parsing.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/oids.h>
 #include <botan/rng.h>
 
diff --git a/src/lib/pubkey/pbes2/pbes2.h b/src/lib/pubkey/pbes2/pbes2.h
index daa9ac580..a5051a8fd 100644
--- a/src/lib/pubkey/pbes2/pbes2.h
+++ b/src/lib/pubkey/pbes2/pbes2.h
@@ -8,7 +8,7 @@
 #ifndef BOTAN_PBE_PKCS_v20_H_
 #define BOTAN_PBE_PKCS_v20_H_
 
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <chrono>
 
 BOTAN_FUTURE_INTERNAL_HEADER(pbes2.h)
diff --git a/src/lib/pubkey/pk_algs.h b/src/lib/pubkey/pk_algs.h
index e3c717428..12514908e 100644
--- a/src/lib/pubkey/pk_algs.h
+++ b/src/lib/pubkey/pk_algs.h
@@ -9,7 +9,7 @@
 #define BOTAN_PK_KEY_FACTORY_H_
 
 #include <botan/pk_keys.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <memory>
 
 namespace Botan {
diff --git a/src/lib/pubkey/pk_keys.h b/src/lib/pubkey/pk_keys.h
index 6f2b7ab60..bf2be6bbd 100644
--- a/src/lib/pubkey/pk_keys.h
+++ b/src/lib/pubkey/pk_keys.h
@@ -9,8 +9,7 @@
 #define BOTAN_PK_KEYS_H_
 
 #include <botan/secmem.h>
-#include <botan/asn1_oid.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/pk_ops_fwd.h>
 #include <string>
 
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp
index abb5d9c9a..2989e20aa 100644
--- a/src/lib/pubkey/pkcs8.cpp
+++ b/src/lib/pubkey/pkcs8.cpp
@@ -9,7 +9,7 @@
 #include <botan/rng.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/oids.h>
 #include <botan/pem.h>
 #include <botan/scan_name.h>
diff --git a/src/lib/pubkey/x509_key.cpp b/src/lib/pubkey/x509_key.cpp
index fff75ec44..716cb1ba4 100644
--- a/src/lib/pubkey/x509_key.cpp
+++ b/src/lib/pubkey/x509_key.cpp
@@ -9,7 +9,7 @@
 #include <botan/data_src.h>
 #include <botan/ber_dec.h>
 #include <botan/pem.h>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/pk_algs.h>
 
 namespace Botan {
diff --git a/src/lib/pubkey/xmss/xmss_privatekey.h b/src/lib/pubkey/xmss/xmss_privatekey.h
index 7d219f8ba..97e431dd6 100644
--- a/src/lib/pubkey/xmss/xmss_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_privatekey.h
@@ -11,7 +11,7 @@
 #include <cstddef>
 #include <iterator>
 #include <memory>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/exceptn.h>
 #include <botan/pk_keys.h>
 #include <botan/types.h>
diff --git a/src/lib/pubkey/xmss/xmss_publickey.h b/src/lib/pubkey/xmss/xmss_publickey.h
index faea04d15..bd7187d4c 100644
--- a/src/lib/pubkey/xmss/xmss_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_publickey.h
@@ -13,8 +13,7 @@
 #include <iterator>
 #include <memory>
 #include <string>
-#include <botan/alg_id.h>
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <botan/der_enc.h>
 #include <botan/exceptn.h>
 #include <botan/rng.h>
diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
index 550bfb86b..e6dea133d 100644
--- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h
@@ -10,7 +10,7 @@
 
 #include <cstddef>
 #include <memory>
-#include <botan/alg_id.h>
+#include <botan/asn1_obj.h>
 #include <botan/exceptn.h>
 #include <botan/pk_keys.h>
 #include <botan/rng.h>
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h
index f9d5d62c7..324764be2 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.h
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h
@@ -11,12 +11,10 @@
 #include <cstddef>
 #include <string>
 #include <vector>
-#include <botan/alg_id.h>
 #include <botan/rng.h>
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <botan/exceptn.h>
 #include <botan/pk_keys.h>
-#include <botan/types.h>
 #include <botan/xmss_wots_parameters.h>
 #include <botan/xmss_address.h>
 #include <botan/xmss_hash.h>
diff --git a/src/lib/tls/tls_session.cpp b/src/lib/tls/tls_session.cpp
index 7d1bd7200..0fd73c9fc 100644
--- a/src/lib/tls/tls_session.cpp
+++ b/src/lib/tls/tls_session.cpp
@@ -9,7 +9,7 @@
 #include <botan/loadstor.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
-#include <botan/asn1_str.h>
+#include <botan/asn1_obj.h>
 #include <botan/pem.h>
 #include <botan/aead.h>
 #include <botan/mac.h>
diff --git a/src/lib/utils/parsing.cpp b/src/lib/utils/parsing.cpp
index f3e74d386..8004dbdd0 100644
--- a/src/lib/utils/parsing.cpp
+++ b/src/lib/utils/parsing.cpp
@@ -17,7 +17,7 @@
 #include <set>
 
 #if defined(BOTAN_HAS_ASN1)
-  #include <botan/asn1_oid.h>
+  #include <botan/asn1_obj.h>
 #endif
 
 namespace Botan {
diff --git a/src/lib/x509/asn1_alt_name.h b/src/lib/x509/asn1_alt_name.h
index d35383815..ac9053be7 100644
--- a/src/lib/x509/asn1_alt_name.h
+++ b/src/lib/x509/asn1_alt_name.h
@@ -9,8 +9,6 @@
 #define BOTAN_X509_ALT_NAME_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/asn1_str.h>
-#include <botan/asn1_oid.h>
 #include <botan/x509_dn.h>
 #include <map>
 
diff --git a/src/lib/x509/crl_ent.h b/src/lib/x509/crl_ent.h
index ea64ee21a..4fa562994 100644
--- a/src/lib/x509/crl_ent.h
+++ b/src/lib/x509/crl_ent.h
@@ -8,7 +8,7 @@
 #ifndef BOTAN_CRL_ENTRY_H_
 #define BOTAN_CRL_ENTRY_H_
 
-#include <botan/asn1_time.h>
+#include <botan/asn1_obj.h>
 
 namespace Botan {
 
diff --git a/src/lib/x509/ocsp_types.h b/src/lib/x509/ocsp_types.h
index 8131addb1..ea93f3613 100644
--- a/src/lib/x509/ocsp_types.h
+++ b/src/lib/x509/ocsp_types.h
@@ -9,7 +9,7 @@
 #define BOTAN_OCSP_TYPES_H_
 
 #include <botan/x509cert.h>
-#include <botan/asn1_time.h>
+#include <botan/asn1_obj.h>
 #include <botan/bigint.h>
 
 namespace Botan {
diff --git a/src/lib/x509/x509_dn.h b/src/lib/x509/x509_dn.h
index db608ff26..4f9f8041e 100644
--- a/src/lib/x509/x509_dn.h
+++ b/src/lib/x509/x509_dn.h
@@ -10,8 +10,6 @@
 #define BOTAN_X509_DN_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/asn1_oid.h>
-#include <botan/asn1_str.h>
 #include <vector>
 #include <map>
 #include <iosfwd>
diff --git a/src/lib/x509/x509_dn_ub.cpp b/src/lib/x509/x509_dn_ub.cpp
index d41168b95..0da17f6c0 100644
--- a/src/lib/x509/x509_dn_ub.cpp
+++ b/src/lib/x509/x509_dn_ub.cpp
@@ -10,7 +10,7 @@
 */
 
 #include <botan/x509_dn.h>
-#include <botan/asn1_oid.h>
+#include <botan/asn1_obj.h>
 #include <map>
 
 namespace {
diff --git a/src/lib/x509/x509_ext.h b/src/lib/x509/x509_ext.h
index 59ece4c22..a0a4a84f1 100644
--- a/src/lib/x509/x509_ext.h
+++ b/src/lib/x509/x509_ext.h
@@ -9,7 +9,6 @@
 #define BOTAN_X509_EXTENSIONS_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/asn1_oid.h>
 #include <botan/asn1_alt_name.h>
 #include <botan/cert_status.h>
 #include <botan/name_constraint.h>
diff --git a/src/lib/x509/x509_obj.h b/src/lib/x509/x509_obj.h
index a0c8e5b39..ff1a01739 100644
--- a/src/lib/x509/x509_obj.h
+++ b/src/lib/x509/x509_obj.h
@@ -9,7 +9,6 @@
 #define BOTAN_X509_OBJECT_H_
 
 #include <botan/asn1_obj.h>
-#include <botan/alg_id.h>
 #include <botan/cert_status.h>
 #include <vector>
 
diff --git a/src/lib/x509/x509cert.h b/src/lib/x509/x509cert.h
index f65d76d23..982d6b845 100644
--- a/src/lib/x509/x509cert.h
+++ b/src/lib/x509/x509cert.h
@@ -10,7 +10,7 @@
 
 #include <botan/x509_obj.h>
 #include <botan/x509_key.h>
-#include <botan/asn1_time.h>
+#include <botan/asn1_obj.h>
 #include <botan/key_constraint.h>
 #include <botan/name_constraint.h>
 #include <memory>
diff --git a/src/lib/x509/x509self.h b/src/lib/x509/x509self.h
index 8d8ca5820..c105c8457 100644
--- a/src/lib/x509/x509self.h
+++ b/src/lib/x509/x509self.h
@@ -11,7 +11,7 @@
 #include <botan/x509cert.h>
 #include <botan/x509_ext.h>
 #include <botan/pkcs10.h>
-#include <botan/asn1_time.h>
+#include <botan/asn1_obj.h>
 
 namespace Botan {
 


Test patch:
diff --git a/src/tests/test_asn1.cpp b/src/tests/test_asn1.cpp
index 5cf39b7a4..ab276cc8a 100644
--- a/src/tests/test_asn1.cpp
+++ b/src/tests/test_asn1.cpp
@@ -9,9 +9,7 @@
 #if defined(BOTAN_HAS_ASN1)
    #include <botan/der_enc.h>
    #include <botan/ber_dec.h>
-   #include <botan/asn1_str.h>
    #include <botan/asn1_print.h>
-   #include <botan/asn1_time.h>
 #endif
 
 namespace Botan_Tests {
diff --git a/src/tests/test_hash_id.cpp b/src/tests/test_hash_id.cpp
index 2813efe6e..1d75955f3 100644
--- a/src/tests/test_hash_id.cpp
+++ b/src/tests/test_hash_id.cpp
@@ -9,7 +9,7 @@
 #if defined(BOTAN_HAS_HASH_ID) && defined(BOTAN_HAS_ASN1)
   #include <botan/hash_id.h>
   #include <botan/der_enc.h>
-  #include <botan/alg_id.h>
+  #include <botan/asn1_obj.h>
 #endif
 
 namespace Botan_Tests {