Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::ASN1_String Class Referencefinal

`#include <asn1_str.h>`

Inheritance diagram for Botan::ASN1_String:

## Public Member Functions
| ASN1_String (const std::string &="")
| ASN1_String (const std::string &, ASN1_Tag)
void | decode_from (class BER_Decoder &) override
void | encode_into (class DER_Encoder &) const override
std::string | iso_8859 () const
ASN1_Tag | tagging () const
std::string | value () const

## Detailed Description

Simple String

Definition at line 18 of file asn1_str.h.

## Constructor & Destructor Documentation

Botan::ASN1_String::ASN1_String | ( | const std::string & | str = `""` | ) |
| explicit

Definition at line 85 of file asn1_str.cpp.

Referenced by decode_from().

85 : m_iso_8859_str(Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET)), m_tag(choose_encoding(m_iso_8859_str, "latin1"))
86 {}
Botan::Charset::transcode
std::string transcode(const std::string &str, Character_Set to, Character_Set from)
Definition: charset.cpp:103
Botan::LATIN1_CHARSET
Definition: charset.h:23
Botan::LOCAL_CHARSET
Definition: charset.h:20

Botan::ASN1_String::ASN1_String | ( | const std::string & | str,
|  | ASN1_Tag | t
| ) |  |

Definition at line 65 of file asn1_str.cpp.

References Botan::BMP_STRING, Botan::DIRECTORY_STRING, Botan::IA5_STRING, Botan::NUMERIC_STRING, Botan::PRINTABLE_STRING, Botan::T61_STRING, Botan::ASN1::to_string(), Botan::UTF8_STRING, and Botan::VISIBLE_STRING.

65 : m_iso_8859_str(Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET)), m_tag(t)
66 {
67
68 if(m_tag == DIRECTORY_STRING)
69 m_tag = choose_encoding(m_iso_8859_str, "latin1");
70
71 if(m_tag != NUMERIC_STRING &&
72 m_tag != PRINTABLE_STRING &&
73 m_tag != VISIBLE_STRING &&
74 m_tag != T61_STRING &&
75 m_tag != IA5_STRING &&
76 m_tag != UTF8_STRING &&
77 m_tag != BMP_STRING)
78 throw Invalid_Argument("ASN1_String: Unknown string type " +
79 std::to_string(m_tag));
80 }
Botan::BMP_STRING
Definition: asn1_obj.h:48
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::PRINTABLE_STRING
Definition: asn1_obj.h:44
Botan::Charset::transcode
std::string transcode(const std::string &str, Character_Set to, Character_Set from)
Definition: charset.cpp:103
Botan::T61_STRING
Definition: asn1_obj.h:45
Botan::LATIN1_CHARSET
Definition: charset.h:23
Botan::DIRECTORY_STRING
Definition: asn1_obj.h:55
Botan::VISIBLE_STRING
Definition: asn1_obj.h:47
Botan::LOCAL_CHARSET
Definition: charset.h:20
Botan::NUMERIC_STRING
Definition: asn1_obj.h:43
Botan::UTF8_STRING
Definition: asn1_obj.h:42
Botan::IA5_STRING
Definition: asn1_obj.h:46

## Member Function Documentation

void Botan::ASN1_String::decode_from | ( | class BER_Decoder & | from | ) |
| override virtual

Decode whatever this object is from from

Parameters

  from | the BER_Decoder that will be read from

Implements Botan::ASN1_Object.

Definition at line 126 of file asn1_str.cpp.

References ASN1_String(), Botan::BMP_STRING, Botan::BER_Decoder::get_next_object(), Botan::LATIN1_CHARSET, Botan::LOCAL_CHARSET, Botan::ASN1::to_string(), Botan::Charset::transcode(), Botan::BER_Object::type_tag, Botan::UCS2_CHARSET, Botan::UTF8_CHARSET, and Botan::UTF8_STRING.

127 {
128 BER_Object obj = source.get_next_object();
129
130 Character_Set charset_is;
131
132 if(obj.type_tag == BMP_STRING)
133 charset_is = UCS2_CHARSET;
134 else if(obj.type_tag == UTF8_STRING)
135 charset_is = UTF8_CHARSET;
136 else
137 charset_is = LATIN1_CHARSET;
138
139 *this = ASN1_String(
140 Charset::transcode(ASN1::to_string(obj), LOCAL_CHARSET, charset_is),
141 obj.type_tag);
142 }
Botan::BMP_STRING
Definition: asn1_obj.h:48
Botan::UTF8_CHARSET
Definition: charset.h:22
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::Character_Set
Character_Set
Definition: charset.h:19
Botan::Charset::transcode
std::string transcode(const std::string &str, Character_Set to, Character_Set from)
Definition: charset.cpp:103
Botan::ASN1_String::ASN1_String
ASN1_String(const std::string &="")
Definition: asn1_str.cpp:85
Botan::LATIN1_CHARSET
Definition: charset.h:23
Botan::LOCAL_CHARSET
Definition: charset.h:20
Botan::UTF8_STRING
Definition: asn1_obj.h:42
Botan::UCS2_CHARSET
Definition: charset.h:21

void Botan::ASN1_String::encode_into | ( | class DER_Encoder & | to | ) | const
| override virtual

Encode whatever this object is into to

Parameters

  to | the DER_Encoder that will be written to

Implements Botan::ASN1_Object.

Definition at line 115 of file asn1_str.cpp.

References Botan::DER_Encoder::add_object(), iso_8859(), Botan::LATIN1_CHARSET, tagging(), Botan::Charset::transcode(), Botan::UNIVERSAL, Botan::UTF8_CHARSET, Botan::UTF8_STRING, and value().

116 {
117 std::string value = iso_8859();
118 if(tagging() == UTF8_STRING)
119 value = Charset::transcode(value, LATIN1_CHARSET, UTF8_CHARSET);
120 encoder.add_object(tagging(), UNIVERSAL, value);
121 }
Botan::ASN1_String::tagging
ASN1_Tag tagging() const
Definition: asn1_str.cpp:107
Botan::ASN1_String::value
std::string value() const
Definition: asn1_str.cpp:99
Botan::UTF8_CHARSET
Definition: charset.h:22
Botan::UNIVERSAL
Definition: asn1_obj.h:23
Botan::Charset::transcode
std::string transcode(const std::string &str, Character_Set to, Character_Set from)
Definition: charset.cpp:103
Botan::LATIN1_CHARSET
Definition: charset.h:23
Botan::ASN1_String::iso_8859
std::string iso_8859() const
Definition: asn1_str.cpp:91
Botan::UTF8_STRING
Definition: asn1_obj.h:42

std::string Botan::ASN1_String::iso_8859 | ( |  | ) | const

Definition at line 91 of file asn1_str.cpp.

Referenced by encode_into().

92 {
93 return m_iso_8859_str;
94 }

ASN1_Tag Botan::ASN1_String::tagging | ( |  | ) | const

Definition at line 107 of file asn1_str.cpp.

Referenced by encode_into().

108 {
109 return m_tag;
110 }

std::string Botan::ASN1_String::value | ( |  | ) | const

Definition at line 99 of file asn1_str.cpp.

References Botan::LATIN1_CHARSET, Botan::LOCAL_CHARSET, and Botan::Charset::transcode().

Referenced by Botan::X509_DN::decode_from(), encode_into(), and Botan::TLS::Session::Session().

100 {
101 return Charset::transcode(m_iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
102 }
Botan::Charset::transcode
std::string transcode(const std::string &str, Character_Set to, Character_Set from)
Definition: charset.cpp:103
Botan::LATIN1_CHARSET
Definition: charset.h:23
Botan::LOCAL_CHARSET
Definition: charset.h:20

The documentation for this class was generated from the following files:

- src/lib/asn1/asn1_str.h
- src/lib/asn1/asn1_str.cpp