Botan  1.11.15
Public Member Functions | Protected Member Functions | Protected Attributes
Botan::EAC_Signed_Object Class Reference

#include <signed_obj.h>

Inheritance diagram for Botan::EAC_Signed_Object:
Botan::EAC1_1_obj< Derived > Botan::EAC1_1_obj< EAC1_1_ADO > Botan::EAC1_1_obj< EAC1_1_CVC > Botan::EAC1_1_obj< EAC1_1_Req > Botan::EAC1_1_gen_CVC< Derived > Botan::EAC1_1_ADO Botan::EAC1_1_gen_CVC< EAC1_1_CVC > Botan::EAC1_1_gen_CVC< EAC1_1_Req > Botan::EAC1_1_CVC Botan::EAC1_1_Req

List of all members.

Public Member Functions

std::vector< byteBER_encode () const
bool check_signature (class Public_Key &key, const std::vector< byte > &sig) const
virtual void encode (Pipe &pipe, X509_Encoding encoding=PEM) const =0
virtual std::vector< byteget_concat_sig () const =0
std::string PEM_encode () const
AlgorithmIdentifier signature_algorithm () const
virtual std::vector< bytetbs_data () const =0
virtual ~EAC_Signed_Object ()

Protected Member Functions

void do_decode ()
 EAC_Signed_Object ()

Protected Attributes

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

Detailed Description

This class represents abstract signed EAC object

Definition at line 23 of file signed_obj.h.


Constructor & Destructor Documentation

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

Definition at line 81 of file signed_obj.h.

{}

Definition at line 84 of file signed_obj.h.

{}

Member Function Documentation

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

BER encode this object.

Returns:
result containing the BER representation of this object.

Definition at line 18 of file signed_obj.cpp.

References 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::EAC_Signed_Object::check_signature ( class Public_Key key,
const std::vector< byte > &  sig 
) const

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, sig_algo, Botan::split_on(), 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;
      }
   }

Definition at line 78 of file signed_obj.cpp.

References e, and PEM_label_pref.

Referenced by Botan::EAC1_1_ADO::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 + ")");
      }
   }
virtual void Botan::EAC_Signed_Object::encode ( Pipe pipe,
X509_Encoding  encoding = PEM 
) const [pure virtual]

Write this object DER encoded into a specified pipe.

Parameters:
pipethe pipe to write the encoded object to
encodingthe encoding type to use

Implemented in Botan::EAC1_1_ADO, Botan::EAC1_1_gen_CVC< Derived >, Botan::EAC1_1_gen_CVC< EAC1_1_CVC >, and Botan::EAC1_1_gen_CVC< EAC1_1_Req >.

Referenced by BER_encode(), and PEM_encode().

virtual std::vector<byte> Botan::EAC_Signed_Object::get_concat_sig ( ) const [pure virtual]

Get the signature of this object as a concatenation, i.e. if the signature consists of multiple parts (like in the case of ECDSA) these will be concatenated.

Returns:
signature as a concatenation of its parts

Implemented in Botan::EAC1_1_obj< Derived >, Botan::EAC1_1_obj< EAC1_1_ADO >, Botan::EAC1_1_obj< EAC1_1_CVC >, and Botan::EAC1_1_obj< EAC1_1_Req >.

std::string Botan::EAC_Signed_Object::PEM_encode ( ) const

PEM encode this object.

Returns:
result containing the PEM representation of this object.

Definition at line 30 of file signed_obj.cpp.

References 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 sig_algo.

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

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

Get the TBS (to-be-signed) data in this object.

Returns:
DER encoded TBS data of this object

Implemented in Botan::EAC1_1_ADO, Botan::EAC1_1_gen_CVC< Derived >, Botan::EAC1_1_gen_CVC< EAC1_1_CVC >, and Botan::EAC1_1_gen_CVC< EAC1_1_Req >.

Referenced by check_signature().


Member Data Documentation

Definition at line 88 of file signed_obj.h.

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

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

Definition at line 89 of file signed_obj.h.

Definition at line 86 of file signed_obj.h.

Referenced by check_signature(), and signature_algorithm().

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

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