Botan  1.11.15
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
Botan::EAC1_1_ADO Class Reference

#include <cvc_ado.h>

Inheritance diagram for Botan::EAC1_1_ADO:
Botan::EAC1_1_obj< EAC1_1_ADO > Botan::EAC_Signed_Object

List of all members.

Public Member Functions

std::vector< byteBER_encode () const
bool check_signature (class Public_Key &key) const
bool check_signature (class Public_Key &key, const std::vector< byte > &sig) const
 EAC1_1_ADO (const std::string &str)
 EAC1_1_ADO (DataSource &source)
void encode (Pipe &out, X509_Encoding encoding) const
ASN1_Car get_car () const
std::vector< byteget_concat_sig () const
EAC1_1_Req get_request () const
bool operator== (EAC1_1_ADO const &rhs) const
std::string PEM_encode () const
AlgorithmIdentifier signature_algorithm () const
std::vector< bytetbs_data () const
virtual ~EAC1_1_ADO ()

Static Public Member Functions

static std::vector< bytemake_signed (PK_Signer &signer, const std::vector< byte > &tbs_bits, RandomNumberGenerator &rng)

Protected Member Functions

void do_decode ()
void init (DataSource &in)

Protected Attributes

ECDSA_Signature m_sig
std::string PEM_label_pref
std::vector< std::string > PEM_labels_allowed
AlgorithmIdentifier sig_algo
std::vector< bytetbs_bits

Friends

class EAC1_1_obj< EAC1_1_ADO >

Detailed Description

This class represents a TR03110 (EAC) v1.1 CVC ADO request

Definition at line 23 of file cvc_ado.h.


Constructor & Destructor Documentation

Botan::EAC1_1_ADO::EAC1_1_ADO ( const std::string &  str)

Construct a CVC ADO request from a DER encoded CVC ADO request file.

Parameters:
strthe path to the DER encoded file

Definition at line 20 of file cvc_ado.cpp.

References Botan::EAC_Signed_Object::do_decode(), and Botan::EAC1_1_obj< EAC1_1_ADO >::init().

   {
   DataSource_Stream stream(in, true);
   init(stream);
   do_decode();
   }

Construct a CVC ADO request from a data source

Parameters:
sourcethe data source

Definition at line 14 of file cvc_ado.cpp.

References Botan::EAC_Signed_Object::do_decode(), and Botan::EAC1_1_obj< EAC1_1_ADO >::init().

   {
   init(in);
   do_decode();
   }
virtual Botan::EAC1_1_ADO::~EAC1_1_ADO ( ) [inline, virtual]

Definition at line 78 of file cvc_ado.h.

{}

Member Function Documentation

std::vector< byte > Botan::EAC_Signed_Object::BER_encode ( ) const [inherited]

BER encode this object.

Returns:
result containing the BER representation of this object.

Definition at line 18 of file signed_obj.cpp.

References Botan::EAC_Signed_Object::encode(), Botan::Pipe::end_msg(), Botan::RAW_BER, Botan::Pipe::read_all(), Botan::Pipe::start_msg(), and Botan::unlock().

Referenced by Botan::CVC_EAC::create_ado_req().

   {
   Pipe ber;
   ber.start_msg();
   encode(ber, RAW_BER);
   ber.end_msg();
   return unlock(ber.read_all());
   }
bool Botan::EAC1_1_obj< EAC1_1_ADO >::check_signature ( class Public_Key key) const [inline, inherited]

Definition at line 30 of file eac_obj.h.

         {
         return EAC_Signed_Object::check_signature(key, m_sig.DER_encode());
         }
bool Botan::EAC_Signed_Object::check_signature ( class Public_Key key,
const std::vector< byte > &  sig 
) const [inherited]

Check the signature of this object.

Parameters:
keythe public key associated with this signed object
sigthe signature we are checking
Returns:
true if the signature was created by the private key associated with this public key

Definition at line 47 of file signed_obj.cpp.

References Botan::Public_Key::algo_name(), Botan::DER_SEQUENCE, Botan::IEEE_1363, Botan::OIDS::lookup(), Botan::Public_Key::message_parts(), Botan::AlgorithmIdentifier::oid, Botan::EAC_Signed_Object::sig_algo, Botan::split_on(), Botan::EAC_Signed_Object::tbs_data(), and Botan::PK_Verifier::verify_message().

   {
   try
      {
      std::vector<std::string> sig_info =
         split_on(OIDS::lookup(sig_algo.oid), '/');

      if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
         {
         return false;
         }

      std::string padding = sig_info[1];
      Signature_Format format =
         (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;

      std::vector<byte> to_sign = tbs_data();

      PK_Verifier verifier(pub_key, padding, format);
      return verifier.verify_message(to_sign, sig);
      }
   catch(...)
      {
      return false;
      }
   }
void Botan::EAC_Signed_Object::do_decode ( ) [protected, inherited]

Definition at line 78 of file signed_obj.cpp.

References e, and Botan::EAC_Signed_Object::PEM_label_pref.

Referenced by EAC1_1_ADO(), Botan::EAC1_1_CVC::EAC1_1_CVC(), and Botan::EAC1_1_Req::EAC1_1_Req().

   {
   try {
      force_decode();
   }
   catch(Decoding_Error& e)
      {
      const std::string what = e.what();
      throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
      }
   catch(Invalid_Argument& e)
      {
      const std::string what = e.what();
      throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
      }
   }
void Botan::EAC1_1_ADO::encode ( Pipe out,
X509_Encoding  encoding 
) const [virtual]

Encode this object into a pipe. Only DER is supported.

Parameters:
outthe pipe to encode this object into
encodingthe encoding type to use, must be DER

Implements Botan::EAC_Signed_Object.

Definition at line 95 of file cvc_ado.cpp.

References Botan::APPLICATION, Botan::OCTET_STRING, Botan::PEM, Botan::EAC_Signed_Object::tbs_bits, and Botan::Pipe::write().

   {
   if(encoding == PEM)
      throw Invalid_Argument("EAC1_1_ADO::encode() cannot PEM encode an EAC object");

   auto concat_sig = EAC1_1_obj<EAC1_1_ADO>::m_sig.get_concatenation();

   out.write(DER_Encoder()
             .start_cons(ASN1_Tag(7), APPLICATION)
                 .raw_bytes(tbs_bits)
                 .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
             .end_cons()
             .get_contents());
   }

Get the CAR of this CVC ADO request

Returns:
the CAR of this CVC ADO request

Definition at line 62 of file cvc_ado.cpp.

Referenced by operator==().

   {
   return m_car;
   }
std::vector<byte> Botan::EAC1_1_obj< EAC1_1_ADO >::get_concat_sig ( ) const [inline, virtual, inherited]

Return the signature as a concatenation of the encoded parts.

Returns:
the concatenated signature

Implements Botan::EAC_Signed_Object.

Definition at line 27 of file eac_obj.h.

Referenced by operator==().

         { return m_sig.get_concatenation(); }

Get the CVC request contained in this object.

Returns:
the CVC request inside this CVC ADO request

Definition at line 122 of file cvc_ado.cpp.

   {
   return m_req;
   }
void Botan::EAC1_1_obj< EAC1_1_ADO >::init ( DataSource in) [inline, protected, inherited]

Definition at line 38 of file eac_obj.h.

Referenced by EAC1_1_ADO().

         {
         try
            {
            Derived::decode_info(in, tbs_bits, m_sig);
            }
         catch(Decoding_Error)
            {
            throw Decoding_Error(PEM_label_pref + " decoding failed");
            }
         }
std::vector< byte > Botan::EAC1_1_ADO::make_signed ( PK_Signer signer,
const std::vector< byte > &  tbs_bits,
RandomNumberGenerator rng 
) [static]

Create a signed CVC ADO request from to be signed (TBS) data

Parameters:
signerthe signer used to sign the CVC ADO request
tbs_bitsthe TBS data to sign
rnga random number generator

Definition at line 48 of file cvc_ado.cpp.

References Botan::APPLICATION, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::OCTET_STRING, Botan::DER_Encoder::raw_bytes(), Botan::PK_Signer::sign_message(), and Botan::DER_Encoder::start_cons().

Referenced by Botan::CVC_EAC::create_ado_req().

   {
   const std::vector<byte> concat_sig = signer.sign_message(tbs_bits, rng);

   return DER_Encoder()
      .start_cons(ASN1_Tag(7), APPLICATION)
      .raw_bytes(tbs_bits)
      .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
      .end_cons()
      .get_contents_unlocked();
   }
bool Botan::EAC1_1_ADO::operator== ( EAC1_1_ADO const &  rhs) const

Definition at line 115 of file cvc_ado.cpp.

References get_car(), Botan::EAC1_1_obj< Derived >::get_concat_sig(), Botan::EAC1_1_obj< EAC1_1_ADO >::get_concat_sig(), and tbs_data().

   {
   return (this->get_concat_sig() == rhs.get_concat_sig()
           && this->tbs_data() == rhs.tbs_data()
           && this->get_car() ==  rhs.get_car());
   }
std::string Botan::EAC_Signed_Object::PEM_encode ( ) const [inherited]

PEM encode this object.

Returns:
result containing the PEM representation of this object.

Definition at line 30 of file signed_obj.cpp.

References Botan::EAC_Signed_Object::encode(), Botan::Pipe::end_msg(), Botan::PEM, Botan::Pipe::read_all_as_string(), and Botan::Pipe::start_msg().

   {
   Pipe pem;
   pem.start_msg();
   encode(pem, PEM);
   pem.end_msg();
   return pem.read_all_as_string();
   }

Get the signature algorithm identifier used to sign this object.

Returns:
the signature algorithm identifier

Definition at line 42 of file signed_obj.cpp.

References Botan::EAC_Signed_Object::sig_algo.

Referenced by Botan::CVC_EAC::create_ado_req(), Botan::DE_EAC::link_cvca(), and Botan::DE_EAC::sign_request().

   {
   return sig_algo;
   }
std::vector< byte > Botan::EAC1_1_ADO::tbs_data ( ) const [virtual]

Get the TBS data of this CVC ADO request.

Returns:
the TBS data

Implements Botan::EAC_Signed_Object.

Definition at line 110 of file cvc_ado.cpp.

References Botan::EAC_Signed_Object::tbs_bits.

Referenced by operator==().

   {
   return tbs_bits;
   }

Friends And Related Function Documentation

friend class EAC1_1_obj< EAC1_1_ADO > [friend]

Definition at line 26 of file cvc_ado.h.


Member Data Documentation

ECDSA_Signature Botan::EAC1_1_obj< EAC1_1_ADO >::m_sig [protected, inherited]

Definition at line 36 of file eac_obj.h.

std::string Botan::EAC_Signed_Object::PEM_label_pref [protected, inherited]
std::vector<std::string> Botan::EAC_Signed_Object::PEM_labels_allowed [protected, inherited]

Definition at line 89 of file signed_obj.h.

std::vector<byte> Botan::EAC_Signed_Object::tbs_bits [protected, inherited]

Definition at line 87 of file signed_obj.h.

Referenced by encode(), Botan::EAC1_1_obj< EAC1_1_Req >::init(), and tbs_data().


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