aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1/ber_dec.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-09 16:24:14 +0000
committerlloyd <[email protected]>2012-07-09 16:24:14 +0000
commit4e43080954be57e362feb1cc8202bfd42117e286 (patch)
treeffcefbd2b2b78ddee4285e8dd4d2d90e112acb93 /src/asn1/ber_dec.h
parent38f7ed8efb6621d55a705bb7af4ba5a21495113a (diff)
Fix for bug 209. Required some reworking of the ASN.1 bytestring
decoding code but seems an improvement.
Diffstat (limited to 'src/asn1/ber_dec.h')
-rw-r--r--src/asn1/ber_dec.h34
1 files changed, 29 insertions, 5 deletions
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;