|
Botan
1.11.15
|
#include <asn1_str.h>
Public Member Functions | |
| ASN1_String (const std::string &="") | |
| ASN1_String (const std::string &, ASN1_Tag) | |
| void | decode_from (class BER_Decoder &) |
| void | encode_into (class DER_Encoder &) const |
| std::string | iso_8859 () const |
| ASN1_Tag | tagging () const |
| std::string | value () const |
Simple String
Definition at line 18 of file asn1_str.h.
| Botan::ASN1_String::ASN1_String | ( | const std::string & | str = "" | ) |
Definition at line 86 of file asn1_str.cpp.
References Botan::LATIN1_CHARSET, Botan::LOCAL_CHARSET, and Botan::Charset::transcode().
Referenced by decode_from().
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
tag = choose_encoding(iso_8859_str, "latin1");
}
| 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::LATIN1_CHARSET, Botan::LOCAL_CHARSET, Botan::NUMERIC_STRING, Botan::PRINTABLE_STRING, Botan::T61_STRING, Botan::ASN1::to_string(), Botan::Charset::transcode(), Botan::UTF8_STRING, and Botan::VISIBLE_STRING.
: tag(t)
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
if(tag == DIRECTORY_STRING)
tag = choose_encoding(iso_8859_str, "latin1");
if(tag != NUMERIC_STRING &&
tag != PRINTABLE_STRING &&
tag != VISIBLE_STRING &&
tag != T61_STRING &&
tag != IA5_STRING &&
tag != UTF8_STRING &&
tag != BMP_STRING)
throw Invalid_Argument("ASN1_String: Unknown string type " +
std::to_string(tag));
}
| void Botan::ASN1_String::decode_from | ( | class BER_Decoder & | from | ) | [virtual] |
Decode whatever this object is from from
| from | the BER_Decoder that will be read from |
Implements Botan::ASN1_Object.
Definition at line 130 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.
{
BER_Object obj = source.get_next_object();
Character_Set charset_is;
if(obj.type_tag == BMP_STRING)
charset_is = UCS2_CHARSET;
else if(obj.type_tag == UTF8_STRING)
charset_is = UTF8_CHARSET;
else
charset_is = LATIN1_CHARSET;
*this = ASN1_String(
Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
obj.type_tag);
}
| void Botan::ASN1_String::encode_into | ( | class DER_Encoder & | to | ) | const [virtual] |
Encode whatever this object is into to
| to | the DER_Encoder that will be written to |
Implements Botan::ASN1_Object.
Definition at line 119 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().
{
std::string value = iso_8859();
if(tagging() == UTF8_STRING)
value = Charset::transcode(value, LATIN1_CHARSET, UTF8_CHARSET);
encoder.add_object(tagging(), UNIVERSAL, value);
}
| std::string Botan::ASN1_String::iso_8859 | ( | ) | const |
| ASN1_Tag Botan::ASN1_String::tagging | ( | ) | const |
| std::string Botan::ASN1_String::value | ( | ) | const |
Definition at line 103 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().
{
return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
}
1.7.6.1