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
13namespace Botan {
14
15/*
16* Create an Attribute
17*/
18Attribute::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*/
27Attribute::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*/
38 {
39 codec.start_cons(SEQUENCE)
40 .encode(oid)
43 .end_cons()
44 .end_cons();
45 }
46
47/*
48* Decode a BER encoded Attribute
49*/
59
60}
void decode_from(class BER_Decoder &from)
Definition asn1_att.cpp:50
MemoryVector< byte > parameters
Definition asn1_obj.h:31
void encode_into(class DER_Encoder &to) const
Definition asn1_att.cpp:37
BER_Decoder start_cons(ASN1_Tag, ASN1_Tag=UNIVERSAL)
Definition ber_dec.cpp:238
BER_Decoder & raw_bytes(MemoryRegion< byte > &)
Definition ber_dec.cpp:173
BER_Decoder & decode(bool &)
Definition ber_dec.cpp:344
BER_Decoder & end_cons()
Definition ber_dec.cpp:252
DER_Encoder & start_cons(ASN1_Tag type_tag, ASN1_Tag class_tag=UNIVERSAL)
Definition der_enc.cpp:135
DER_Encoder & raw_bytes(const byte val[], size_t len)
Definition der_enc.cpp:188
DER_Encoder & end_cons()
Definition der_enc.cpp:145
DER_Encoder & encode(bool b)
Definition der_enc.cpp:209
std::string lookup(const OID &oid)
Definition oids.cpp:31
@ SEQUENCE
Definition asn1_int.h:35
@ SET
Definition asn1_int.h:36