monotone

monotone Mtn Source Tree

Root/botan/asn1_att.cpp

1/*************************************************
2* Attribute Source File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#include <botan/asn1_obj.h>
7#include <botan/der_enc.h>
8#include <botan/ber_dec.h>
9#include <botan/oids.h>
10
11namespace Botan {
12
13/*************************************************
14* Create an Attribute *
15*************************************************/
16Attribute::Attribute(const OID& attr_oid, const MemoryRegion<byte>& attr_value)
17 {
18 oid = attr_oid;
19 parameters = attr_value;
20 }
21
22/*************************************************
23* Create an Attribute *
24*************************************************/
25Attribute::Attribute(const std::string& attr_oid,
26 const MemoryRegion<byte>& attr_value)
27 {
28 oid = OIDS::lookup(attr_oid);
29 parameters = attr_value;
30 }
31
32/*************************************************
33* DER encode a Attribute *
34*************************************************/
35void Attribute::encode_into(DER_Encoder& codec) const
36 {
37 codec.start_cons(SEQUENCE)
38 .encode(oid)
39 .start_cons(SET)
40 .raw_bytes(parameters)
41 .end_cons()
42 .end_cons();
43 }
44
45/*************************************************
46* Decode a BER encoded Attribute *
47*************************************************/
48void Attribute::decode_from(BER_Decoder& codec)
49 {
50 codec.start_cons(SEQUENCE)
51 .decode(oid)
52 .start_cons(SET)
53 .raw_bytes(parameters)
54 .end_cons()
55 .end_cons();
56 }
57
58}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status