diff options
author | lloyd <[email protected]> | 2012-11-06 14:59:48 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-11-06 14:59:48 +0000 |
commit | 2458460b4478b7464dede87dc3beff8ea2838789 (patch) | |
tree | f399cb8e116b48d03909ae75b3e66a29c59ad0aa /src/asn1 | |
parent | 6b075b7655d818a29ce5c8168cd22e3bc30f219c (diff) |
Split asn1_obj.h into asn1_alt_name.h, asn1_attribute.h, and
asn1_time.h
Diffstat (limited to 'src/asn1')
-rw-r--r-- | src/asn1/asn1_alt_name.cpp (renamed from src/asn1/asn1_alt.cpp) | 2 | ||||
-rw-r--r-- | src/asn1/asn1_alt_name.h | 47 | ||||
-rw-r--r-- | src/asn1/asn1_att.cpp | 2 | ||||
-rw-r--r-- | src/asn1/asn1_attribute.h | 36 | ||||
-rw-r--r-- | src/asn1/asn1_obj.h | 104 | ||||
-rw-r--r-- | src/asn1/asn1_time.h | 55 | ||||
-rw-r--r-- | src/asn1/asn1_tm.cpp | 2 | ||||
-rw-r--r-- | src/asn1/info.txt | 24 |
8 files changed, 141 insertions, 131 deletions
diff --git a/src/asn1/asn1_alt.cpp b/src/asn1/asn1_alt_name.cpp index 1a5c699cd..2e7116bac 100644 --- a/src/asn1/asn1_alt.cpp +++ b/src/asn1/asn1_alt_name.cpp @@ -6,7 +6,7 @@ * Distributed under the terms of the Botan license */ -#include <botan/asn1_obj.h> +#include <botan/asn1_alt_name.h> #include <botan/der_enc.h> #include <botan/ber_dec.h> #include <botan/oids.h> diff --git a/src/asn1/asn1_alt_name.h b/src/asn1/asn1_alt_name.h new file mode 100644 index 000000000..b71be1ff7 --- /dev/null +++ b/src/asn1/asn1_alt_name.h @@ -0,0 +1,47 @@ +/* +* Common ASN.1 Objects +* (C) 1999-2007 Jack Lloyd +* 2007 Yves Jerschow +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_ALT_NAME_H__ +#define BOTAN_ASN1_ALT_NAME_H__ + +#include <botan/asn1_int.h> +#include <botan/asn1_str.h> +#include <botan/asn1_oid.h> +#include <map> + +namespace Botan { + +/** +* Alternative Name +*/ +class BOTAN_DLL AlternativeName : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::multimap<std::string, std::string> contents() const; + + void add_attribute(const std::string&, const std::string&); + std::multimap<std::string, std::string> get_attributes() const; + + void add_othername(const OID&, const std::string&, ASN1_Tag); + std::multimap<OID, ASN1_String> get_othernames() const; + + bool has_items() const; + + AlternativeName(const std::string& = "", const std::string& = "", + const std::string& = "", const std::string& = ""); + private: + std::multimap<std::string, std::string> alt_info; + std::multimap<OID, ASN1_String> othernames; + }; + +} + +#endif diff --git a/src/asn1/asn1_att.cpp b/src/asn1/asn1_att.cpp index c0adae643..dff52bef9 100644 --- a/src/asn1/asn1_att.cpp +++ b/src/asn1/asn1_att.cpp @@ -5,7 +5,7 @@ * Distributed under the terms of the Botan license */ -#include <botan/asn1_obj.h> +#include <botan/asn1_attribute.h> #include <botan/der_enc.h> #include <botan/ber_dec.h> #include <botan/oids.h> diff --git a/src/asn1/asn1_attribute.h b/src/asn1/asn1_attribute.h new file mode 100644 index 000000000..b51811015 --- /dev/null +++ b/src/asn1/asn1_attribute.h @@ -0,0 +1,36 @@ +/* +* ASN.1 Attribute +* (C) 1999-2007,2012 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_ATTRIBUTE_H__ +#define BOTAN_ASN1_ATTRIBUTE_H__ + +#include <botan/asn1_int.h> +#include <botan/asn1_oid.h> +#include <vector> + +namespace Botan { + +/** +* Attribute +*/ +class BOTAN_DLL Attribute : public ASN1_Object + { + public: + void encode_into(class DER_Encoder& to) const; + void decode_from(class BER_Decoder& from); + + OID oid; + std::vector<byte> parameters; + + Attribute() {} + Attribute(const OID&, const std::vector<byte>&); + Attribute(const std::string&, const std::vector<byte>&); + }; + +} + +#endif diff --git a/src/asn1/asn1_obj.h b/src/asn1/asn1_obj.h deleted file mode 100644 index cee5a18ed..000000000 --- a/src/asn1/asn1_obj.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -* Common ASN.1 Objects -* (C) 1999-2007 Jack Lloyd -* 2007 Yves Jerschow -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_ASN1_OBJ_H__ -#define BOTAN_ASN1_OBJ_H__ - -#include <botan/asn1_int.h> -#include <botan/asn1_oid.h> -#include <botan/asn1_str.h> -#include <botan/alg_id.h> -#include <vector> -#include <map> -#include <chrono> - -namespace Botan { - -/** -* Attribute -*/ -class BOTAN_DLL Attribute : public ASN1_Object - { - public: - void encode_into(class DER_Encoder& to) const; - void decode_from(class BER_Decoder& from); - - OID oid; - std::vector<byte> parameters; - - Attribute() {} - Attribute(const OID&, const std::vector<byte>&); - Attribute(const std::string&, const std::vector<byte>&); - }; - -/** -* X.509 Time -*/ -class BOTAN_DLL X509_Time : public ASN1_Object - { - public: - void encode_into(class DER_Encoder&) const; - void decode_from(class BER_Decoder&); - - std::string as_string() const; - std::string readable_string() const; - bool time_is_set() const; - - s32bit cmp(const X509_Time&) const; - - void set_to(const std::string&); - void set_to(const std::string&, ASN1_Tag); - - X509_Time(const std::chrono::system_clock::time_point& time); - X509_Time(const std::string& = ""); - X509_Time(const std::string&, ASN1_Tag); - private: - bool passes_sanity_check() const; - u32bit year, month, day, hour, minute, second; - ASN1_Tag tag; - }; - -/** -* Alternative Name -*/ -class BOTAN_DLL AlternativeName : public ASN1_Object - { - public: - void encode_into(class DER_Encoder&) const; - void decode_from(class BER_Decoder&); - - std::multimap<std::string, std::string> contents() const; - - void add_attribute(const std::string&, const std::string&); - std::multimap<std::string, std::string> get_attributes() const; - - void add_othername(const OID&, const std::string&, ASN1_Tag); - std::multimap<OID, ASN1_String> get_othernames() const; - - bool has_items() const; - - AlternativeName(const std::string& = "", const std::string& = "", - const std::string& = "", const std::string& = ""); - private: - std::multimap<std::string, std::string> alt_info; - std::multimap<OID, ASN1_String> othernames; - }; - -/* -* Comparison Operations -*/ -bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&); -bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&); -bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&); -bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&); -bool BOTAN_DLL operator<(const X509_Time&, const X509_Time&); -bool BOTAN_DLL operator>(const X509_Time&, const X509_Time&); - -} - -#endif diff --git a/src/asn1/asn1_time.h b/src/asn1/asn1_time.h new file mode 100644 index 000000000..ca8449178 --- /dev/null +++ b/src/asn1/asn1_time.h @@ -0,0 +1,55 @@ +/* +* ASN.1 Time Representation +* (C) 1999-2007,2012 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_ASN1_TIME_H__ +#define BOTAN_ASN1_TIME_H__ + +#include <botan/asn1_int.h> +#include <chrono> + +namespace Botan { + +/** +* X.509 Time +*/ +class BOTAN_DLL X509_Time : public ASN1_Object + { + public: + void encode_into(class DER_Encoder&) const; + void decode_from(class BER_Decoder&); + + std::string as_string() const; + std::string readable_string() const; + bool time_is_set() const; + + s32bit cmp(const X509_Time&) const; + + void set_to(const std::string&); + void set_to(const std::string&, ASN1_Tag); + + X509_Time(const std::chrono::system_clock::time_point& time); + X509_Time(const std::string& = ""); + X509_Time(const std::string&, ASN1_Tag); + private: + bool passes_sanity_check() const; + u32bit year, month, day, hour, minute, second; + ASN1_Tag tag; + }; + +/* +* Comparison Operations +*/ +bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator<(const X509_Time&, const X509_Time&); +bool BOTAN_DLL operator>(const X509_Time&, const X509_Time&); + +} + +#endif diff --git a/src/asn1/asn1_tm.cpp b/src/asn1/asn1_tm.cpp index b8095a41c..b1093158c 100644 --- a/src/asn1/asn1_tm.cpp +++ b/src/asn1/asn1_tm.cpp @@ -5,7 +5,7 @@ * Distributed under the terms of the Botan license */ -#include <botan/asn1_obj.h> +#include <botan/asn1_time.h> #include <botan/der_enc.h> #include <botan/ber_dec.h> #include <botan/charset.h> diff --git a/src/asn1/info.txt b/src/asn1/info.txt index e190ad9ea..4bf31732f 100644 --- a/src/asn1/info.txt +++ b/src/asn1/info.txt @@ -2,30 +2,6 @@ define ASN1 load_on auto -<source> -alg_id.cpp -asn1_alt.cpp -asn1_att.cpp -asn1_int.cpp -asn1_oid.cpp -asn1_str.cpp -asn1_tm.cpp -ber_dec.cpp -der_enc.cpp -x509_dn.cpp -</source> - -<header:public> -alg_id.h -asn1_int.h -asn1_obj.h -asn1_oid.h -asn1_str.h -ber_dec.h -der_enc.h -x509_dn.h -</header:public> - <requires> alloc bigint |