Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

asn1_attribute.cpp
Go to the documentation of this file.
1 /*
2 * Attribute
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #include <botan/asn1_attribute.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 std::vector<uint8_t>& attr_value) : oid(attr_oid), parameters(attr_value)
19 {}
20
21 /*
22 * Create an Attribute
23 */
24 Attribute::Attribute(const std::string& attr_oid,
25 const std::vector<uint8_t>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value)
26 {}
27
28 /*
29 * DER encode a Attribute
30 */
31 void Attribute::encode_into(DER_Encoder& codec) const
32 {
33 codec.start_cons(SEQUENCE)
34 .encode(oid)
35 .start_cons(SET)
36 .raw_bytes(parameters)
37 .end_cons()
38 .end_cons();
39 }
40
41 /*
42 * Decode a BER encoded Attribute
43 */
44 void Attribute::decode_from(BER_Decoder& codec)
45 {
46 codec.start_cons(SEQUENCE)
47 .decode(oid)
48 .start_cons(SET)
49 .raw_bytes(parameters)
50 .end_cons()
51 .end_cons();
52 }
53
54 }
Botan::BER_Decoder::decode
BER_Decoder & decode(bool &v)
Definition: ber_dec.cpp:376
Botan::DER_Encoder::end_cons
DER_Encoder & end_cons()
Definition: der_enc.cpp:147
Botan::DER_Encoder::raw_bytes
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
Definition: der_enc.cpp:195
Botan::DER_Encoder::encode
DER_Encoder & encode(bool b)
Definition: der_enc.cpp:216
Botan::DER_Encoder
Definition: der_enc.h:22
Botan::Attribute::oid
OID oid
Definition: asn1_attribute.h:27
Botan::BER_Decoder::end_cons
BER_Decoder & end_cons()
Definition: ber_dec.cpp:272
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18
Botan::Attribute::parameters
std::vector< uint8_t > parameters
Definition: asn1_attribute.h:30
Botan::Attribute::Attribute
Attribute()=default
Botan::SEQUENCE
Definition: asn1_obj.h:39
Botan::BER_Decoder::start_cons
BER_Decoder start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition: ber_dec.cpp:258
Botan::Attribute::encode_into
void encode_into(class DER_Encoder &to) const override
Definition: asn1_attribute.cpp:31
Botan
Definition: alg_id.cpp:13
Botan::SET
Definition: asn1_obj.h:40
Botan::DER_Encoder::start_cons
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition: der_enc.cpp:137
Botan::OID
Definition: asn1_oid.h:20
Botan::BER_Decoder::raw_bytes
BER_Decoder & raw_bytes(secure_vector< uint8_t > &v)
Definition: ber_dec.cpp:178
Botan::BER_Decoder
Definition: ber_dec.h:19
Botan::Attribute::decode_from
void decode_from(class BER_Decoder &from) override
Definition: asn1_attribute.cpp:44