Botan 3.6.1
Crypto and TLS for C&
x509_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/pkix_types.h>
9
10#include <botan/ber_dec.h>
11#include <botan/der_enc.h>
12
13namespace Botan {
14
15/*
16* Create an Attribute
17*/
18Attribute::Attribute(const OID& attr_oid, const std::vector<uint8_t>& attr_value) :
19 m_oid(attr_oid), m_parameters(attr_value) {}
20
21/*
22* Create an Attribute
23*/
24Attribute::Attribute(std::string_view attr_oid, const std::vector<uint8_t>& attr_value) :
25 m_oid(OID::from_string(attr_oid)), m_parameters(attr_value) {}
26
27/*
28* DER encode a Attribute
29*/
31 codec.start_sequence().encode(m_oid).start_set().raw_bytes(m_parameters).end_cons().end_cons();
32}
33
34/*
35* Decode a BER encoded Attribute
36*/
38 codec.start_sequence().decode(m_oid).start_set().raw_bytes(m_parameters).end_cons().end_cons();
39}
40
41} // namespace Botan
void decode_from(BER_Decoder &from) override
void encode_into(DER_Encoder &to) const override
Attribute()=default
BER_Decoder start_set()
Definition ber_dec.h:125
BER_Decoder & decode(bool &out)
Definition ber_dec.h:186
BER_Decoder & raw_bytes(std::vector< uint8_t, Alloc > &out)
Definition ber_dec.h:172
BER_Decoder & end_cons()
Definition ber_dec.cpp:309
BER_Decoder start_sequence()
Definition ber_dec.h:123
DER_Encoder & start_set()
Definition der_enc.h:66
DER_Encoder & start_sequence()
Definition der_enc.h:64
DER_Encoder & raw_bytes(const uint8_t val[], size_t len)
Definition der_enc.cpp:207
DER_Encoder & end_cons()
Definition der_enc.cpp:171
DER_Encoder & encode(bool b)
Definition der_enc.cpp:250