aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asn1/ber_dec.cpp9
-rw-r--r--src/asn1/ber_dec.h15
-rw-r--r--src/cert/x509/x509_ext.cpp10
3 files changed, 22 insertions, 12 deletions
diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp
index dbd59988b..51b952e71 100644
--- a/src/asn1/ber_dec.cpp
+++ b/src/asn1/ber_dec.cpp
@@ -232,6 +232,12 @@ BER_Object BER_Decoder::get_next_object()
return next;
}
+BER_Decoder& BER_Decoder::get_next(BER_Object& ber)
+ {
+ ber = get_next_object();
+ return (*this);
+ }
+
/*
* Push a object back into the stream
*/
@@ -341,7 +347,8 @@ BER_Decoder::~BER_Decoder()
/*
* Request for an object to decode itself
*/
-BER_Decoder& BER_Decoder::decode(ASN1_Object& obj)
+BER_Decoder& BER_Decoder::decode(ASN1_Object& obj,
+ ASN1_Tag, ASN1_Tag)
{
obj.decode_from(*this);
return (*this);
diff --git a/src/asn1/ber_dec.h b/src/asn1/ber_dec.h
index 6b010fcc4..6ca9aa777 100644
--- a/src/asn1/ber_dec.h
+++ b/src/asn1/ber_dec.h
@@ -29,6 +29,8 @@ class BOTAN_DLL BER_Decoder
BER_Decoder start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag = UNIVERSAL);
BER_Decoder& end_cons();
+ BER_Decoder& get_next(BER_Object& ber);
+
BER_Decoder& raw_bytes(secure_vector<byte>& v);
BER_Decoder& raw_bytes(std::vector<byte>& v);
@@ -61,7 +63,9 @@ class BOTAN_DLL BER_Decoder
ASN1_Tag type_tag,
ASN1_Tag class_tag = CONTEXT_SPECIFIC);
- BER_Decoder& decode(class ASN1_Object& obj);
+ BER_Decoder& decode(class ASN1_Object& obj,
+ ASN1_Tag type_tag = NO_OBJECT,
+ ASN1_Tag class_tag = NO_OBJECT);
BER_Decoder& decode_octet_string_bigint(class BigInt& b);
@@ -172,12 +176,17 @@ BER_Decoder& BER_Decoder::decode_list(std::vector<T>& vec, bool clear_it)
if(clear_it)
vec.clear();
- while(more_items())
+ BER_Decoder list = start_cons(SEQUENCE);
+
+ while(list.more_items())
{
T value;
- decode(value);
+ list.decode(value);
vec.push_back(value);
}
+
+ list.end_cons();
+
return (*this);
}
diff --git a/src/cert/x509/x509_ext.cpp b/src/cert/x509/x509_ext.cpp
index 751d20266..7daa58f20 100644
--- a/src/cert/x509/x509_ext.cpp
+++ b/src/cert/x509/x509_ext.cpp
@@ -418,10 +418,7 @@ std::vector<byte> Extended_Key_Usage::encode_inner() const
*/
void Extended_Key_Usage::decode_inner(const std::vector<byte>& in)
{
- BER_Decoder(in)
- .start_cons(SEQUENCE)
- .decode_list(oids)
- .end_cons();
+ BER_Decoder(in).decode_list(oids);
}
/*
@@ -488,10 +485,7 @@ void Certificate_Policies::decode_inner(const std::vector<byte>& in)
{
std::vector<Policy_Information> policies;
- BER_Decoder(in)
- .start_cons(SEQUENCE)
- .decode_list(policies)
- .end_cons();
+ BER_Decoder(in).decode_list(policies);
oids.clear();
for(size_t i = 0; i != policies.size(); ++i)