diff options
author | lloyd <[email protected]> | 2008-05-08 15:16:22 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-05-08 15:16:22 +0000 |
commit | 7f0ab13ebd0342dbcffbeb726ac50dac95e35c88 (patch) | |
tree | f66f884ec6bcb2e4d7425bc35c0e5e69ca47ca0c | |
parent | 64fc7744bea527beab8c0eebcde68831c896bfdc (diff) |
The BER decoder assumed that all constructed types would be tagged as
universal: this prevented it from decoding application, context-specific,
or private-class constructions.
Add a new parameter to BER_Decoder::start_cons which specifies the expected
class type (default universal). The decoder still verifies that the
constructed bit is set in the class tag. This provides parity with the
interface to the DER encoder.
Problem was found and reported by Falko Strenzke
-rw-r--r-- | include/ber_dec.h | 4 | ||||
-rw-r--r-- | src/ber_dec.cpp | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/include/ber_dec.h b/include/ber_dec.h index 1ea880595..9fec75832 100644 --- a/include/ber_dec.h +++ b/include/ber_dec.h @@ -1,6 +1,6 @@ /************************************************* * BER Decoder Header File * -* (C) 1999-2007 Jack Lloyd * +* (C) 1999-2008 Jack Lloyd * *************************************************/ #ifndef BOTAN_BER_DECODER_H__ @@ -25,7 +25,7 @@ class BOTAN_DLL BER_Decoder BER_Decoder& verify_end(); BER_Decoder& discard_remaining(); - BER_Decoder start_cons(ASN1_Tag); + BER_Decoder start_cons(ASN1_Tag, ASN1_Tag = UNIVERSAL); BER_Decoder& end_cons(); BER_Decoder& raw_bytes(MemoryRegion<byte>&); diff --git a/src/ber_dec.cpp b/src/ber_dec.cpp index 83414ea01..c725a5af9 100644 --- a/src/ber_dec.cpp +++ b/src/ber_dec.cpp @@ -1,6 +1,6 @@ /************************************************* * BER Decoder Source File * -* (C) 1999-2007 Jack Lloyd * +* (C) 1999-2008 Jack Lloyd * *************************************************/ #include <botan/ber_dec.h> @@ -226,10 +226,12 @@ void BER_Decoder::push_back(const BER_Object& obj) /************************************************* * Begin decoding a CONSTRUCTED type * *************************************************/ -BER_Decoder BER_Decoder::start_cons(ASN1_Tag type_tag) +BER_Decoder BER_Decoder::start_cons(ASN1_Tag type_tag, + ASN1_Tag class_tag) { BER_Object obj = get_next_object(); - obj.assert_is_a(type_tag, CONSTRUCTED); + obj.assert_is_a(type_tag, ASN1_Tag(class_tag | CONSTRUCTED)); + BER_Decoder result(obj.value, obj.value.size()); result.parent = this; return result; |