aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-11-29 22:52:17 +0000
committerlloyd <[email protected]>2010-11-29 22:52:17 +0000
commit0e41e0e8d441ff907f092c718db650cda06e2e1a (patch)
tree8c0df20500bdf601d4378a6000923501a48ad1f3 /src/asn1
parent5d4621b745ac529c7df6c4d91e4d2b68bd0325e4 (diff)
parent65ab36776317f73ddf0f2d3bd6c1c7e35608962f (diff)
propagate from branch 'net.randombit.botan' (head fc8daa606ab7954eab48778d7236986747b719e4)
to branch 'net.randombit.botan.c++0x' (head 2bf71b0a2e0e468d7eb3631e4ca284234f554729)
Diffstat (limited to 'src/asn1')
-rw-r--r--src/asn1/x509_dn.cpp60
-rw-r--r--src/asn1/x509_dn.h1
2 files changed, 26 insertions, 35 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;
}
}
diff --git a/src/asn1/x509_dn.h b/src/asn1/x509_dn.h
index c4fc2d17b..3f63eb49c 100644
--- a/src/asn1/x509_dn.h
+++ b/src/asn1/x509_dn.h
@@ -34,7 +34,6 @@ class BOTAN_DLL X509_DN : public ASN1_Object
static std::string deref_info_field(const std::string&);
- void do_decode(const MemoryRegion<byte>&);
MemoryVector<byte> get_bits() const;
X509_DN();