aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'src/asn1')
-rw-r--r--src/asn1/asn1_int.h2
-rw-r--r--src/asn1/asn1_oid.h2
-rw-r--r--src/asn1/ber_dec.cpp37
-rw-r--r--src/asn1/ber_dec.h34
4 files changed, 32 insertions, 43 deletions
diff --git a/src/asn1/asn1_int.h b/src/asn1/asn1_int.h
index 6d254e4db..564f4ecdb 100644
--- a/src/asn1/asn1_int.h
+++ b/src/asn1/asn1_int.h
@@ -23,6 +23,8 @@ enum ASN1_Tag {
CONSTRUCTED = 0x20,
+ PRIVATE = CONSTRUCTED | CONTEXT_SPECIFIC,
+
EOC = 0x00,
BOOLEAN = 0x01,
INTEGER = 0x02,
diff --git a/src/asn1/asn1_oid.h b/src/asn1/asn1_oid.h
index 85e863907..9d712b256 100644
--- a/src/asn1/asn1_oid.h
+++ b/src/asn1/asn1_oid.h
@@ -27,7 +27,7 @@ class BOTAN_DLL OID : public ASN1_Object
* Find out whether this OID is empty
* @return true is no OID value is set
*/
- bool is_empty() const { return id.size() == 0; }
+ bool empty() const { return id.size() == 0; }
/**
* Get this OID as list (vector) of its components.
diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp
index 25c412600..81b2e34f6 100644
--- a/src/asn1/ber_dec.cpp
+++ b/src/asn1/ber_dec.cpp
@@ -558,41 +558,4 @@ BER_Decoder& BER_Decoder::decode(std::vector<byte>& buffer,
return (*this);
}
-/*
-* Decode an OPTIONAL string type
-*/
-BER_Decoder& BER_Decoder::decode_optional_string(secure_vector<byte>& out,
- ASN1_Tag real_type,
- u16bit type_no)
- {
- BER_Object obj = get_next_object();
-
- ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
-
- out.clear();
- push_back(obj);
-
- if(obj.type_tag == type_tag && obj.class_tag == CONTEXT_SPECIFIC)
- decode(out, real_type, type_tag, CONTEXT_SPECIFIC);
-
- return (*this);
- }
-
-BER_Decoder& BER_Decoder::decode_optional_string(std::vector<byte>& out,
- ASN1_Tag real_type,
- u16bit type_no)
- {
- BER_Object obj = get_next_object();
-
- ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
-
- out.clear();
- push_back(obj);
-
- if(obj.type_tag == type_tag && obj.class_tag == CONTEXT_SPECIFIC)
- decode(out, real_type, type_tag, CONTEXT_SPECIFIC);
-
- return (*this);
- }
-
}
diff --git a/src/asn1/ber_dec.h b/src/asn1/ber_dec.h
index 0d0d0ec72..ebfa91c85 100644
--- a/src/asn1/ber_dec.h
+++ b/src/asn1/ber_dec.h
@@ -123,13 +123,37 @@ class BOTAN_DLL BER_Decoder
return (*this);
}
- BER_Decoder& decode_optional_string(std::vector<byte>& out,
+ /*
+ * Decode an OPTIONAL string type
+ */
+ template<typename Alloc>
+ BER_Decoder& decode_optional_string(std::vector<byte, Alloc>& out,
ASN1_Tag real_type,
- u16bit type_no);
+ u16bit type_no,
+ ASN1_Tag class_tag = CONTEXT_SPECIFIC)
+ {
+ BER_Object obj = get_next_object();
+
+ ASN1_Tag type_tag = static_cast<ASN1_Tag>(type_no);
+
+ if(obj.type_tag == type_tag && obj.class_tag == class_tag)
+ {
+ if((class_tag & CONSTRUCTED) && (class_tag & CONTEXT_SPECIFIC))
+ BER_Decoder(obj.value).decode(out, real_type).verify_end();
+ else
+ {
+ push_back(obj);
+ decode(out, real_type, type_tag, class_tag);
+ }
+ }
+ else
+ {
+ out.clear();
+ push_back(obj);
+ }
- BER_Decoder& decode_optional_string(secure_vector<byte>& out,
- ASN1_Tag real_type,
- u16bit type_no);
+ return (*this);
+ }
BER_Decoder& operator=(const BER_Decoder&) = delete;