Botan::ASN1_EAC_String Class Reference

#include <eac_asn_obj.h>

Inheritance diagram for Botan::ASN1_EAC_String:

Botan::ASN1_Object Botan::ASN1_Car Botan::ASN1_Chr

List of all members.

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

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

Definition at line 21 of file asn1_eac_str.cpp.

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

Referenced by decode_from().

00021                                                                  : tag(t)
00022    {
00023    iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
00024    if (!sanity_check())
00025       {
00026       throw Invalid_Argument("attempted to construct ASN1_EAC_String with illegal characters");
00027       }
00028    }

virtual Botan::ASN1_EAC_String::~ASN1_EAC_String (  )  [inline, virtual]

Definition at line 190 of file eac_asn_obj.h.

00190 {}


Member Function Documentation

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.

00067    {
00068    BER_Object obj = source.get_next_object();
00069    if (obj.type_tag != this->tag)
00070       {
00071 
00072       std::string message("decoding type mismatch for ASN1_EAC_String, tag is ");
00073       std::stringstream ss;
00074       std::string str_is;
00075       ss << std::hex << obj.type_tag;
00076       ss >> str_is;
00077       message.append(str_is);
00078       message.append(", while it should be ");
00079       std::stringstream ss2;
00080       std::string str_should;
00081       ss2 << std::hex << this->tag;
00082       ss2 >> str_should;
00083       message.append(str_should);
00084       throw Decoding_Error(message);
00085       }
00086    Character_Set charset_is;
00087    charset_is = LATIN1_CHARSET;
00088 
00089    try
00090       {
00091       *this = ASN1_EAC_String(
00092          Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
00093          obj.type_tag);
00094       }
00095    catch (Invalid_Argument inv_arg)
00096       {
00097       throw Decoding_Error(std::string("error while decoding ASN1_EAC_String: ") + std::string(inv_arg.what()));
00098       }
00099    }

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().

00058    {
00059    std::string value = iso_8859();
00060    encoder.add_object(tagging(), APPLICATION, value);
00061    }

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(), Botan::operator==(), and Botan::DE_EAC::sign_request().

00034    {
00035    return iso_8859_str;
00036    }

bool Botan::ASN1_EAC_String::sanity_check (  )  const [protected]

Definition at line 103 of file asn1_eac_str.cpp.

Referenced by ASN1_EAC_String().

00104    {
00105    const byte* rep = reinterpret_cast<const byte*>(iso_8859_str.data());
00106    const u32bit rep_len = iso_8859_str.size();
00107    for (u32bit i=0; i<rep_len; i++)
00108       {
00109       if ((rep[i] < 0x20) || ((rep[i] >= 0x7F) && (rep[i] < 0xA0)))
00110          {
00111          return false;
00112          }
00113       }
00114    return true;
00115    }

ASN1_Tag Botan::ASN1_EAC_String::tagging (  )  const

Definition at line 49 of file asn1_eac_str.cpp.

Referenced by encode_into().

00050    {
00051    return tag;
00052    }

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 Botan::CVC_EAC::create_self_signed_cert(), encode_into(), and Botan::DE_EAC::sign_request().

00042    {
00043    return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
00044    }


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

Generated on Tue Jun 29 08:56:41 2010 for Botan by  doxygen 1.5.8