diff options
author | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
commit | a2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch) | |
tree | ad3d6c4fcc8dd0f403f8105598943616246fe172 /src/asn1_att.cpp |
Initial checkin1.5.6
Diffstat (limited to 'src/asn1_att.cpp')
-rw-r--r-- | src/asn1_att.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/asn1_att.cpp b/src/asn1_att.cpp new file mode 100644 index 000000000..58ed761b4 --- /dev/null +++ b/src/asn1_att.cpp @@ -0,0 +1,62 @@ +/************************************************* +* Attribute Source File * +* (C) 1999-2006 The Botan Project * +*************************************************/ + +#include <botan/asn1_obj.h> +#include <botan/oids.h> + +namespace Botan { + +/************************************************* +* Create an Attribute * +*************************************************/ +Attribute::Attribute(const OID& attr_oid, const MemoryRegion<byte>& attr_value) + { + oid = attr_oid; + parameters = attr_value; + } + +/************************************************* +* Create an Attribute * +*************************************************/ +Attribute::Attribute(const std::string& attr_oid, + const MemoryRegion<byte>& attr_value) + { + oid = OIDS::lookup(attr_oid); + parameters = attr_value; + } + +/************************************************* +* DER encode a Attribute * +*************************************************/ +void Attribute::encode_into(DER_Encoder& der) const + { + der.start_sequence() + .encode(oid) + .start_set() + .add_raw_octets(parameters) + .end_set() + .end_sequence(); + } + +namespace BER { + +/************************************************* +* Decode a BER encoded Attribute * +*************************************************/ +void decode(BER_Decoder& source, Attribute& attr) + { + BER_Decoder decoder = BER::get_subsequence(source); + BER::decode(decoder, attr.oid); + + BER_Decoder attributes = BER::get_subset(decoder); + attr.parameters = attributes.get_remaining(); + attributes.verify_end(); + + decoder.verify_end(); + } + +} + +} |