Botan: Botan::ASN1_EAC_String Class Reference

Botan 1.10.17

Public Member Functions | Protected Member Functions | List of all members
Botan::ASN1_EAC_String Class Reference

`#include <eac_asn_obj.h>`

Inheritance diagram for Botan::ASN1_EAC_String:

## Public Member Functions
| ASN1_EAC_String (const std::string &str, ASN1_Tag the_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
virtual | ~ASN1_EAC_String ()

## Protected Member Functions
bool | sanity_check () const

## Detailed Description

Base class for car/chr of cv certificates.

Definition at line 169 of file eac_asn_obj.h.

## Constructor & Destructor Documentation

## ◆ ASN1_EAC_String()

Botan::ASN1_EAC_String::ASN1_EAC_String | ( | const std::string & | str,
|  | ASN1_Tag | the_tag
| ) |  |

Definition at line 22 of file asn1_eac_str.cpp.

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

Referenced by decode_from().

22 : tag(t)
23 {
24 iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
25
26 if(!sanity_check())
27 throw Invalid_Argument("ASN1_EAC_String contains illegal characters");
28 }
Botan::ASN1_EAC_String::sanity_check
bool sanity_check() const
Definition: asn1_eac_str.cpp:100
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
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

## ◆ ~ASN1_EAC_String()

virtual Botan::ASN1_EAC_String::~ASN1_EAC_String | ( |  | ) |
| inlinevirtual

Definition at line 190 of file eac_asn_obj.h.

190 {}

## Member Function Documentation

## ◆ decode_from()

void Botan::ASN1_EAC_String::decode_from | ( | class BER_Decoder & | from | ) |
| 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 66 of file asn1_eac_str.cpp.

References ASN1_EAC_String(), Botan::BER_Decoder::get_next_object(), Botan::LATIN1_CHARSET, Botan::LOCAL_CHARSET, Botan::ASN1::to_string(), Botan::Charset::transcode(), and Botan::BER_Object::type_tag.

67 {
68 BER_Object obj = source.get_next_object();
69
70 if(obj.type_tag != this->tag)
71 {
72 std::stringstream ss;
73
74 ss << "ASN1_EAC_String tag mismatch, tag was "
75 << std::hex << obj.type_tag
76 << " expected "
77 << std::hex << this->tag;
78
79 throw Decoding_Error(ss.str());
80 }
81
82 Character_Set charset_is;
83 charset_is = LATIN1_CHARSET;
84
85 try
86 {
87 *this = ASN1_EAC_String(
88 Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
89 obj.type_tag);
90 }
91 catch(Invalid_Argument inv_arg)
92 {
93 throw Decoding_Error(std::string("ASN1_EAC_String decoding failed: ") +
94 inv_arg.what());
95 }
96 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_int.cpp:46
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::LATIN1_CHARSET
Definition: charset.h:23
Botan::LOCAL_CHARSET
Definition: charset.h:20
Botan::ASN1_EAC_String::ASN1_EAC_String
ASN1_EAC_String(const std::string &str, ASN1_Tag the_tag)
Definition: asn1_eac_str.cpp:22

## ◆ encode_into()

void Botan::ASN1_EAC_String::encode_into | ( | class DER_Encoder & | to | ) | const
| 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 57 of file asn1_eac_str.cpp.

References Botan::DER_Encoder::add_object(), Botan::APPLICATION, iso_8859(), tagging(), and value().

58 {
59 std::string value = iso_8859();
60 encoder.add_object(tagging(), APPLICATION, value);
61 }
Botan::ASN1_EAC_String::value
std::string value() const
Definition: asn1_eac_str.cpp:41
Botan::ASN1_EAC_String::iso_8859
std::string iso_8859() const
Definition: asn1_eac_str.cpp:33
Botan::ASN1_EAC_String::tagging
ASN1_Tag tagging() const
Definition: asn1_eac_str.cpp:49
Botan::APPLICATION
Definition: asn1_int.h:21

## ◆ iso_8859()

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

Get this objects string value.

Returns
  string value in iso8859 encoding

Definition at line 33 of file asn1_eac_str.cpp.

Referenced by encode_into(), and Botan::operator==().

34 {
35 return iso_8859_str;
36 }

## ◆ sanity_check()

bool Botan::ASN1_EAC_String::sanity_check | ( |  | ) | const
| protected

Definition at line 100 of file asn1_eac_str.cpp.

Referenced by ASN1_EAC_String().

101 {
102 const byte* rep = reinterpret_cast<const byte*>(iso_8859_str.data());
103 const size_t rep_len = iso_8859_str.size();
104
105 for(size_t i = 0; i != rep_len; ++i)
106 {
107 if((rep[i] < 0x20) || ((rep[i] >= 0x7F) && (rep[i] < 0xA0)))
108 return false;
109 }
110
111 return true;
112 }
Botan::byte
unsigned char byte
Definition: types.h:22

## ◆ tagging()

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

Definition at line 49 of file asn1_eac_str.cpp.

Referenced by encode_into().

50 {
51 return tag;
52 }

## ◆ value()

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

Get this objects string value.

Returns
  string value

Definition at line 41 of file asn1_eac_str.cpp.

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

Referenced by encode_into().

42 {
43 return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
44 }
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/cert/cvc/eac_asn_obj.h
- src/cert/cvc/asn1_eac_str.cpp