Botan  1.11.12
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Botan::EAC1_1_Req Class Reference

#include <cvc_req.h>

Inheritance diagram for Botan::EAC1_1_Req:
Botan::EAC1_1_gen_CVC< EAC1_1_Req > Botan::EAC1_1_obj< EAC1_1_Req > Botan::EAC_Signed_Object

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_Req (DataSource &source)
 
 EAC1_1_Req (const std::string &str)
 
void encode (Pipe &out, X509_Encoding encoding) const
 
ASN1_Chr get_chr () const
 
std::vector< byteget_concat_sig () const
 
bool is_self_signed () const
 
bool operator== (const EAC1_1_Req &other) const
 
std::string PEM_encode () const
 
AlgorithmIdentifier signature_algorithm () const
 
Public_Keysubject_public_key () const
 
std::vector< bytetbs_data () const
 
virtual ~EAC1_1_Req ()
 

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_ADO
 
class EAC1_1_obj< EAC1_1_Req >
 

Detailed Description

This class represents TR03110 v1.1 EAC CV Certificate Requests.

Definition at line 19 of file cvc_req.h.

Constructor & Destructor Documentation

Botan::EAC1_1_Req::EAC1_1_Req ( DataSource source)

Construct a CVC request from a data source.

Parameters
sourcethe data source

Definition at line 38 of file cvc_req.cpp.

References Botan::EAC_Signed_Object::do_decode(), Botan::EAC1_1_obj< EAC1_1_Req >::init(), and Botan::EAC1_1_gen_CVC< EAC1_1_Req >::self_signed.

39  {
40  init(in);
41  self_signed = true;
42  do_decode();
43  }
void init(DataSource &in)
Definition: eac_obj.h:38
Botan::EAC1_1_Req::EAC1_1_Req ( const std::string &  str)

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

Parameters
strthe path to the DER encoded file

Definition at line 45 of file cvc_req.cpp.

References Botan::EAC_Signed_Object::do_decode(), Botan::EAC1_1_obj< EAC1_1_Req >::init(), and Botan::EAC1_1_gen_CVC< EAC1_1_Req >::self_signed.

46  {
47  DataSource_Stream stream(in, true);
48  init(stream);
49  self_signed = true;
50  do_decode();
51  }
void init(DataSource &in)
Definition: eac_obj.h:38
virtual Botan::EAC1_1_Req::~EAC1_1_Req ( )
inlinevirtual

Definition at line 43 of file cvc_req.h.

43 {}

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

19  {
20  Pipe ber;
21  ber.start_msg();
22  encode(ber, RAW_BER);
23  ber.end_msg();
24  return unlock(ber.read_all());
25  }
virtual void encode(Pipe &pipe, X509_Encoding encoding=PEM) const =0
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:95
static std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_Req >::build_cert_body ( const std::vector< byte > &  tbs)
staticinherited

Build the DER encoded certifcate body of an object

Parameters
tbsthe data to be signed
Returns
the correctly encoded body of the object
bool Botan::EAC1_1_obj< EAC1_1_Req >::check_signature ( class Public_Key key) const
inlineinherited

Definition at line 30 of file eac_obj.h.

References Botan::EAC_Signed_Object::check_signature(), Botan::ECDSA_Signature::DER_encode(), and Botan::EAC1_1_obj< Derived >::m_sig.

31  {
32  return EAC_Signed_Object::check_signature(key, m_sig.DER_encode());
33  }
std::vector< byte > DER_encode() const
Definition: ecdsa_sig.cpp:23
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().

Referenced by Botan::EAC1_1_obj< EAC1_1_Req >::check_signature().

49  {
50  try
51  {
52  std::vector<std::string> sig_info =
54 
55  if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
56  {
57  return false;
58  }
59 
60  std::string padding = sig_info[1];
61  Signature_Format format =
62  (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
63 
64  std::vector<byte> to_sign = tbs_data();
65 
66  PK_Verifier verifier(pub_key, padding, format);
67  return verifier.verify_message(to_sign, sig);
68  }
69  catch(...)
70  {
71  return false;
72  }
73  }
virtual std::vector< byte > tbs_data() const =0
AlgorithmIdentifier sig_algo
Definition: signed_obj.h:86
Signature_Format
Definition: pubkey.h:24
std::vector< std::string > split_on(const std::string &str, char delim)
Definition: parsing.cpp:108
std::string lookup(const OID &oid)
Definition: oids.cpp:111
static void Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info ( DataSource source,
std::vector< byte > &  res_tbs_bits,
ECDSA_Signature res_sig 
)
staticprotectedinherited
void Botan::EAC_Signed_Object::do_decode ( )
protectedinherited

Definition at line 78 of file signed_obj.cpp.

References Botan::EAC_Signed_Object::PEM_label_pref.

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

79  {
80  try {
81  force_decode();
82  }
83  catch(Decoding_Error& e)
84  {
85  const std::string what = e.what();
86  throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
87  }
88  catch(Invalid_Argument& e)
89  {
90  const std::string what = e.what();
91  throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
92  }
93  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
std::string PEM_label_pref
Definition: signed_obj.h:88
void Botan::EAC1_1_gen_CVC< EAC1_1_Req >::encode ( Pipe out,
X509_Encoding  encoding 
) const
virtualinherited

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.

ASN1_Chr Botan::EAC1_1_gen_CVC< EAC1_1_Req >::get_chr ( ) const
inherited

Get the CHR of the certificate.

Returns
the CHR of the certificate
std::vector<byte> Botan::EAC1_1_obj< EAC1_1_Req >::get_concat_sig ( ) const
inlinevirtualinherited

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.

References Botan::ECDSA_Signature::get_concatenation(), and Botan::EAC1_1_obj< Derived >::m_sig.

Referenced by operator==().

28  { return m_sig.get_concatenation(); }
std::vector< byte > get_concatenation() const
Definition: ecdsa_sig.cpp:33
void Botan::EAC1_1_obj< EAC1_1_Req >::init ( DataSource in)
inlineprotectedinherited

Definition at line 38 of file eac_obj.h.

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

Referenced by EAC1_1_Req().

39  {
40  try
41  {
42  Derived::decode_info(in, tbs_bits, m_sig);
43  }
44  catch(Decoding_Error)
45  {
46  throw Decoding_Error(PEM_label_pref + " decoding failed");
47  }
48  }
std::string PEM_label_pref
Definition: signed_obj.h:88
std::vector< byte > tbs_bits
Definition: signed_obj.h:87
bool Botan::EAC1_1_gen_CVC< EAC1_1_Req >::is_self_signed ( ) const
inherited

Find out whether this object is self signed.

Returns
true if this object is self signed
static std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_Req >::make_signed ( PK_Signer signer,
const std::vector< byte > &  tbs_bits,
RandomNumberGenerator rng 
)
staticinherited

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
bool Botan::EAC1_1_Req::operator== ( const EAC1_1_Req other) const

Compare for equality with other

Parameters
othercompare for equality with this object

Definition at line 14 of file cvc_req.cpp.

References Botan::EAC1_1_obj< EAC1_1_Req >::get_concat_sig(), Botan::EAC1_1_obj< Derived >::get_concat_sig(), Botan::EAC1_1_gen_CVC< EAC1_1_Req >::tbs_data(), and Botan::EAC1_1_gen_CVC< Derived >::tbs_data().

15  {
16  return (this->tbs_data() == rhs.tbs_data() &&
17  this->get_concat_sig() == rhs.get_concat_sig());
18  }
std::vector< byte > tbs_data() const
std::vector< byte > get_concat_sig() const
Definition: eac_obj.h:27
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().

31  {
32  Pipe pem;
33  pem.start_msg();
34  encode(pem, PEM);
35  pem.end_msg();
36  return pem.read_all_as_string();
37  }
virtual void encode(Pipe &pipe, X509_Encoding encoding=PEM) const =0
AlgorithmIdentifier Botan::EAC_Signed_Object::signature_algorithm ( ) const
inherited

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

43  {
44  return sig_algo;
45  }
AlgorithmIdentifier sig_algo
Definition: signed_obj.h:86
Public_Key* Botan::EAC1_1_gen_CVC< EAC1_1_Req >::subject_public_key ( ) const
inherited

Get this certificates public key.

Returns
this certificates public key
std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_Req >::tbs_data ( ) const
virtualinherited

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

Returns
the TBS data of this object

Implements Botan::EAC_Signed_Object.

Referenced by operator==().

Friends And Related Function Documentation

friend class EAC1_1_ADO
friend

Definition at line 22 of file cvc_req.h.

friend class EAC1_1_obj< EAC1_1_Req >
friend

Definition at line 23 of file cvc_req.h.

Member Data Documentation

ASN1_Chr Botan::EAC1_1_gen_CVC< EAC1_1_Req >::m_chr
protectedinherited

Definition at line 87 of file cvc_gen_cert.h.

ECDSA_PublicKey* Botan::EAC1_1_gen_CVC< EAC1_1_Req >::m_pk
protectedinherited

Definition at line 86 of file cvc_gen_cert.h.

ECDSA_Signature Botan::EAC1_1_obj< EAC1_1_Req >::m_sig
protectedinherited

Definition at line 36 of file eac_obj.h.

std::string Botan::EAC_Signed_Object::PEM_label_pref
protectedinherited
std::vector<std::string> Botan::EAC_Signed_Object::PEM_labels_allowed
protectedinherited

Definition at line 89 of file signed_obj.h.

bool Botan::EAC1_1_gen_CVC< EAC1_1_Req >::self_signed
protectedinherited

Definition at line 88 of file cvc_gen_cert.h.

Referenced by EAC1_1_Req().

AlgorithmIdentifier Botan::EAC_Signed_Object::sig_algo
protectedinherited
std::vector<byte> Botan::EAC_Signed_Object::tbs_bits
protectedinherited

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