diff options
author | lloyd <[email protected]> | 2010-11-29 22:52:17 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-11-29 22:52:17 +0000 |
commit | 0e41e0e8d441ff907f092c718db650cda06e2e1a (patch) | |
tree | 8c0df20500bdf601d4378a6000923501a48ad1f3 /src/asn1/x509_dn.cpp | |
parent | 5d4621b745ac529c7df6c4d91e4d2b68bd0325e4 (diff) | |
parent | 65ab36776317f73ddf0f2d3bd6c1c7e35608962f (diff) |
propagate from branch 'net.randombit.botan' (head fc8daa606ab7954eab48778d7236986747b719e4)
to branch 'net.randombit.botan.c++0x' (head 2bf71b0a2e0e468d7eb3631e4ca284234f554729)
Diffstat (limited to 'src/asn1/x509_dn.cpp')
-rw-r--r-- | src/asn1/x509_dn.cpp | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/src/asn1/x509_dn.cpp b/src/asn1/x509_dn.cpp index 0deed1a70..984645cfe 100644 --- a/src/asn1/x509_dn.cpp +++ b/src/asn1/x509_dn.cpp @@ -104,35 +104,6 @@ std::vector<std::string> X509_DN::get_attribute(const std::string& attr) const } /* -* Handle the decoding operation of a DN -*/ -void X509_DN::do_decode(const MemoryRegion<byte>& bits) - { - BER_Decoder sequence(bits); - - while(sequence.more_items()) - { - BER_Decoder rdn = sequence.start_cons(SET); - - while(rdn.more_items()) - { - OID oid; - ASN1_String str; - - rdn.start_cons(SEQUENCE) - .decode(oid) - .decode(str) - .verify_end() - .end_cons(); - - add_attribute(oid, str.value()); - } - } - - dn_bits = bits; - } - -/* * Return the BER encoded data, if any */ MemoryVector<byte> X509_DN::get_bits() const @@ -259,12 +230,12 @@ void X509_DN::encode_into(DER_Encoder& der) const der.raw_bytes(dn_bits); else { - do_ava(der, dn_info, PRINTABLE_STRING, "X520.Country", true); + do_ava(der, dn_info, PRINTABLE_STRING, "X520.Country"); do_ava(der, dn_info, DIRECTORY_STRING, "X520.State"); do_ava(der, dn_info, DIRECTORY_STRING, "X520.Locality"); do_ava(der, dn_info, DIRECTORY_STRING, "X520.Organization"); do_ava(der, dn_info, DIRECTORY_STRING, "X520.OrganizationalUnit"); - do_ava(der, dn_info, DIRECTORY_STRING, "X520.CommonName", true); + do_ava(der, dn_info, DIRECTORY_STRING, "X520.CommonName"); do_ava(der, dn_info, PRINTABLE_STRING, "X520.SerialNumber"); } @@ -276,13 +247,34 @@ void X509_DN::encode_into(DER_Encoder& der) const */ void X509_DN::decode_from(BER_Decoder& source) { - dn_info.clear(); + MemoryVector<byte> bits; source.start_cons(SEQUENCE) - .raw_bytes(dn_bits) + .raw_bytes(bits) .end_cons(); - do_decode(dn_bits); + BER_Decoder sequence(bits); + + while(sequence.more_items()) + { + BER_Decoder rdn = sequence.start_cons(SET); + + while(rdn.more_items()) + { + OID oid; + ASN1_String str; + + rdn.start_cons(SEQUENCE) + .decode(oid) + .decode(str) + .verify_end() + .end_cons(); + + add_attribute(oid, str.value()); + } + } + + dn_bits = bits; } } |