aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1/asn1_att.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 22:14:54 +0000
committerlloyd <[email protected]>2008-09-28 22:14:54 +0000
commit31204986023619c385d378e79a6511bb81ef7b78 (patch)
treece272a6585dc070f750f6875b0450d53145b935d /src/asn1/asn1_att.cpp
parent42c0fe76ab6d9625d0e51c68b8dd187322c991bd (diff)
Move almost all of the ASN.1, BER, and DER codec related code into new
module asn1 Move hex and base64 codecs into new codecs directory. Also move zlib and bzip2 to codecs from compress.
Diffstat (limited to 'src/asn1/asn1_att.cpp')
-rw-r--r--src/asn1/asn1_att.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/asn1/asn1_att.cpp b/src/asn1/asn1_att.cpp
new file mode 100644
index 000000000..7c16ff3a5
--- /dev/null
+++ b/src/asn1/asn1_att.cpp
@@ -0,0 +1,58 @@
+/*************************************************
+* Attribute Source File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/asn1_obj.h>
+#include <botan/der_enc.h>
+#include <botan/ber_dec.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& codec) const
+ {
+ codec.start_cons(SEQUENCE)
+ .encode(oid)
+ .start_cons(SET)
+ .raw_bytes(parameters)
+ .end_cons()
+ .end_cons();
+ }
+
+/*************************************************
+* Decode a BER encoded Attribute *
+*************************************************/
+void Attribute::decode_from(BER_Decoder& codec)
+ {
+ codec.start_cons(SEQUENCE)
+ .decode(oid)
+ .start_cons(SET)
+ .raw_bytes(parameters)
+ .end_cons()
+ .end_cons();
+ }
+
+}