Botan  1.11.15
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
Botan::EAC1_1_gen_CVC< Derived > Class Template Reference

#include <cvc_gen_cert.h>

Inheritance diagram for Botan::EAC1_1_gen_CVC< Derived >:
Botan::EAC1_1_obj< Derived > 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_gen_CVC ()
void encode (Pipe &out, X509_Encoding encoding) const
ASN1_Chr get_chr () const
std::vector< byteget_concat_sig () const
bool is_self_signed () const
std::string PEM_encode () const
AlgorithmIdentifier signature_algorithm () const
Public_Keysubject_public_key () const
std::vector< bytetbs_data () const
virtual ~EAC1_1_gen_CVC ()

Static Public Member Functions

static std::vector< bytebuild_cert_body (const std::vector< byte > &tbs)
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)

Static Protected Member Functions

static void decode_info (DataSource &source, std::vector< byte > &res_tbs_bits, ECDSA_Signature &res_sig)

Protected Attributes

ASN1_Chr m_chr
ECDSA_PublicKeym_pk
ECDSA_Signature m_sig
std::string PEM_label_pref
std::vector< std::string > PEM_labels_allowed
bool self_signed
AlgorithmIdentifier sig_algo
std::vector< bytetbs_bits

Friends

class EAC1_1_obj< EAC1_1_gen_CVC >

Detailed Description

template<typename Derived>
class Botan::EAC1_1_gen_CVC< Derived >

This class represents TR03110 (EAC) v1.1 generalized CV Certificates

Definition at line 23 of file cvc_gen_cert.h.


Constructor & Destructor Documentation

template<typename Derived>
Botan::EAC1_1_gen_CVC< Derived >::EAC1_1_gen_CVC ( ) [inline]

Definition at line 80 of file cvc_gen_cert.h.

{ m_pk = 0; }
template<typename Derived>
virtual Botan::EAC1_1_gen_CVC< Derived >::~EAC1_1_gen_CVC ( ) [inline, virtual]

Definition at line 82 of file cvc_gen_cert.h.

         { delete m_pk; }

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());
   }
template<typename Derived >
std::vector< byte > Botan::EAC1_1_gen_CVC< Derived >::build_cert_body ( const std::vector< byte > &  tbs) [static]

Build the DER encoded certifcate body of an object

Parameters:
tbsthe data to be signed
Returns:
the correctly encoded body of the object

Definition at line 128 of file cvc_gen_cert.h.

References Botan::APPLICATION, Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::DER_Encoder::raw_bytes(), and Botan::DER_Encoder::start_cons().

   {
   return DER_Encoder()
      .start_cons(ASN1_Tag(78), APPLICATION)
      .raw_bytes(tbs)
      .end_cons().get_contents_unlocked();
   }
template<typename Derived>
bool Botan::EAC1_1_obj< Derived >::check_signature ( class Public_Key key) const [inline, inherited]
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;
      }
   }
template<typename Derived >
void Botan::EAC1_1_gen_CVC< Derived >::decode_info ( DataSource source,
std::vector< byte > &  res_tbs_bits,
ECDSA_Signature res_sig 
) [static, protected]

Definition at line 160 of file cvc_gen_cert.h.

References Botan::APPLICATION, Botan::BER_Decoder::decode(), Botan::decode_concatenation(), Botan::BER_Decoder::end_cons(), Botan::OCTET_STRING, Botan::BER_Decoder::raw_bytes(), and Botan::BER_Decoder::start_cons().

   {
   std::vector<byte> concat_sig;
   BER_Decoder(source)
      .start_cons(ASN1_Tag(33))
      .start_cons(ASN1_Tag(78))
      .raw_bytes(res_tbs_bits)
      .end_cons()
      .decode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
      .end_cons();
   res_sig = decode_concatenation(concat_sig);
   }
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 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 + ")");
      }
   }
template<typename Derived >
void Botan::EAC1_1_gen_CVC< Derived >::encode ( Pipe out,
X509_Encoding  encoding 
) const [virtual]

Put the DER encoded version of this object into a pipe. PEM is not supported.

Parameters:
outthe pipe to push the DER encoded version into
encodingthe encoding to use. Must be DER.

Implements Botan::EAC_Signed_Object.

Definition at line 141 of file cvc_gen_cert.h.

References Botan::APPLICATION, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::OCTET_STRING, Botan::PEM, Botan::DER_Encoder::raw_bytes(), Botan::DER_Encoder::start_cons(), and Botan::Pipe::write().

   {
   std::vector<byte> concat_sig(EAC1_1_obj<Derived>::m_sig.get_concatenation());
   std::vector<byte> der = DER_Encoder()
      .start_cons(ASN1_Tag(33), APPLICATION)
      .start_cons(ASN1_Tag(78), APPLICATION)
      .raw_bytes(EAC1_1_obj<Derived>::tbs_bits)
      .end_cons()
      .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
      .end_cons()
      .get_contents_unlocked();

   if (encoding == PEM)
      throw Invalid_Argument("EAC1_1_gen_CVC::encode() cannot PEM encode an EAC object");
   else
      out.write(der);
   }
template<typename Derived >
ASN1_Chr Botan::EAC1_1_gen_CVC< Derived >::get_chr ( ) const

Get the CHR of the certificate.

Returns:
the CHR of the certificate

Definition at line 96 of file cvc_gen_cert.h.

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

   {
   return m_chr;
   }
template<typename Derived>
std::vector<byte> Botan::EAC1_1_obj< Derived >::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 Botan::EAC1_1_Req::operator==(), Botan::EAC1_1_CVC::operator==(), and Botan::EAC1_1_ADO::operator==().

         { return m_sig.get_concatenation(); }
template<typename Derived>
void Botan::EAC1_1_obj< Derived >::init ( DataSource in) [inline, protected, inherited]

Definition at line 38 of file eac_obj.h.

         {
         try
            {
            Derived::decode_info(in, tbs_bits, m_sig);
            }
         catch(Decoding_Error)
            {
            throw Decoding_Error(PEM_label_pref + " decoding failed");
            }
         }
template<typename Derived >
bool Botan::EAC1_1_gen_CVC< Derived >::is_self_signed ( ) const

Find out whether this object is self signed.

Returns:
true if this object is self signed

Definition at line 101 of file cvc_gen_cert.h.

   {
   return self_signed;
   }
template<typename Derived >
std::vector< byte > Botan::EAC1_1_gen_CVC< Derived >::make_signed ( PK_Signer signer,
const std::vector< byte > &  tbs_bits,
RandomNumberGenerator rng 
) [static]

Create a signed generalized CVC object.

Parameters:
signerthe signer used to sign this object
tbs_bitsthe body the generalized CVC object to be signed
rnga random number generator
Returns:
the DER encoded signed generalized CVC object

Definition at line 107 of file cvc_gen_cert.h.

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

   {
   const auto concat_sig = signer.sign_message(tbs_bits, rng);

   return DER_Encoder()
      .start_cons(ASN1_Tag(33), APPLICATION)
      .raw_bytes(tbs_bits)
      .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
      .end_cons()
      .get_contents_unlocked();
   }
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;
   }
template<typename Derived >
Public_Key * Botan::EAC1_1_gen_CVC< Derived >::subject_public_key ( ) const

Get this certificates public key.

Returns:
this certificates public key

Definition at line 123 of file cvc_gen_cert.h.

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

   {
   return new ECDSA_PublicKey(*m_pk);
   }
template<typename Derived >
std::vector< byte > Botan::EAC1_1_gen_CVC< Derived >::tbs_data ( ) const [virtual]

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

Returns:
the TBS data of this object

Implements Botan::EAC_Signed_Object.

Definition at line 136 of file cvc_gen_cert.h.

Referenced by Botan::EAC1_1_Req::operator==(), and Botan::EAC1_1_CVC::operator==().

   {
   return build_cert_body(EAC1_1_obj<Derived>::tbs_bits);
   }

Friends And Related Function Documentation

template<typename Derived>
friend class EAC1_1_obj< EAC1_1_gen_CVC > [friend]

Definition at line 25 of file cvc_gen_cert.h.


Member Data Documentation

template<typename Derived>
ASN1_Chr Botan::EAC1_1_gen_CVC< Derived >::m_chr [protected]

Definition at line 87 of file cvc_gen_cert.h.

template<typename Derived>
ECDSA_PublicKey* Botan::EAC1_1_gen_CVC< Derived >::m_pk [protected]
template<typename Derived>
ECDSA_Signature Botan::EAC1_1_obj< Derived >::m_sig [protected, inherited]
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.

template<typename Derived>
bool Botan::EAC1_1_gen_CVC< Derived >::self_signed [protected]

Definition at line 88 of file cvc_gen_cert.h.

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

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