Botan: src/asn1/asn1_att.cpp Source File

Botan 1.10.17

asn1_att.cpp
Go to the documentation of this file.
1 /*
2 * Attribute
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #include <botan/asn1_obj.h>
9 #include <botan/der_enc.h>
10 #include <botan/ber_dec.h>
11 #include <botan/oids.h>
12
13 namespace Botan {
14
15 /*
16 * Create an Attribute
17 */
18 Attribute::Attribute(const OID& attr_oid, const MemoryRegion<byte>& attr_value)
19 {
20 oid = attr_oid;
21 parameters = attr_value;
22 }
23
24 /*
25 * Create an Attribute
26 */
27 Attribute::Attribute(const std::string& attr_oid,
28 const MemoryRegion<byte>& attr_value)
29 {
30 oid = OIDS::lookup(attr_oid);
31 parameters = attr_value;
32 }
33
34 /*
35 * DER encode a Attribute
36 */
37 void Attribute::encode_into(DER_Encoder& codec) const
38 {
39 codec.start_cons(SEQUENCE)
40 .encode(oid)
41 .start_cons(SET)
42 .raw_bytes(parameters)
43 .end_cons()
44 .end_cons();
45 }
46
47 /*
48 * Decode a BER encoded Attribute
49 */
50 void Attribute::decode_from(BER_Decoder& codec)
51 {
52 codec.start_cons(SEQUENCE)
53 .decode(oid)
54 .start_cons(SET)
55 .raw_bytes(parameters)
56 .end_cons()
57 .end_cons();
58 }
59
60 }
Botan::Attribute::parameters
MemoryVector< byte > parameters
Definition: asn1_obj.h:31
Botan::DER_Encoder::raw_bytes
DER_Encoder & raw_bytes(const byte val[], size_t len)
Definition: der_enc.cpp:188
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &)
Definition: ber_dec.cpp:344
Botan::DER_Encoder::end_cons
DER_Encoder & end_cons()
Definition: der_enc.cpp:145
Botan::BER_Decoder::start_cons
BER_Decoder start_cons(ASN1_Tag, ASN1_Tag=UNIVERSAL)
Definition: ber_dec.cpp:238
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:209
Botan::DER_Encoder
Definition: der_enc.h:22
Botan::Attribute::oid
OID oid
Definition: asn1_obj.h:30
Botan::BER_Decoder::end_cons
BER_Decoder & end_cons()
Definition: ber_dec.cpp:252
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:31
Botan::Attribute::encode_into
void encode_into(class DER_Encoder &to) const
Definition: asn1_att.cpp:37
Botan::SEQUENCE
Definition: asn1_int.h:35
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::SET
Definition: asn1_int.h:36
Botan::BER_Decoder::raw_bytes
BER_Decoder & raw_bytes(MemoryRegion< byte > &)
Definition: ber_dec.cpp:173
Botan::DER_Encoder::start_cons
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition: der_enc.cpp:135
Botan::Attribute::decode_from
void decode_from(class BER_Decoder &from)
Definition: asn1_att.cpp:50
Botan::OID
Definition: asn1_oid.h:20
Botan::BER_Decoder
Definition: ber_dec.h:19
Botan::Attribute::Attribute
Attribute()
Definition: asn1_obj.h:33