Botan
1.11.15
|
#include <cvc_cert.h>
Public Member Functions | |
std::vector< byte > | BER_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_CVC (DataSource &source) | |
EAC1_1_CVC (const std::string &str) | |
void | encode (Pipe &out, X509_Encoding encoding) const |
ASN1_Car | get_car () const |
ASN1_Ced | get_ced () const |
ASN1_Cex | get_cex () const |
u32bit | get_chat_value () const |
ASN1_Chr | get_chr () const |
std::vector< byte > | get_concat_sig () const |
bool | is_self_signed () const |
bool | operator== (const EAC1_1_CVC &) const |
std::string | PEM_encode () const |
AlgorithmIdentifier | signature_algorithm () const |
Public_Key * | subject_public_key () const |
std::vector< byte > | tbs_data () const |
virtual | ~EAC1_1_CVC () |
Static Public Member Functions | |
static std::vector< byte > | build_cert_body (const std::vector< byte > &tbs) |
static std::vector< byte > | make_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_PublicKey * | m_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< byte > | tbs_bits |
Friends | |
class | EAC1_1_obj< EAC1_1_CVC > |
This class represents TR03110 (EAC) v1.1 CV Certificates
Definition at line 21 of file cvc_cert.h.
Botan::EAC1_1_CVC::EAC1_1_CVC | ( | DataSource & | source | ) |
Construct a CVC from a data source
source | the data source |
Definition at line 70 of file cvc_cert.cpp.
References Botan::EAC_Signed_Object::do_decode(), Botan::EAC1_1_obj< EAC1_1_CVC >::init(), and Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::self_signed.
{ init(in); self_signed = false; do_decode(); }
Botan::EAC1_1_CVC::EAC1_1_CVC | ( | const std::string & | str | ) |
Construct a CVC from a file
str | the path to the certificate file |
Definition at line 77 of file cvc_cert.cpp.
References Botan::EAC_Signed_Object::do_decode(), Botan::EAC1_1_obj< EAC1_1_CVC >::init(), and Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::self_signed.
{ DataSource_Stream stream(in, true); init(stream); self_signed = false; do_decode(); }
virtual Botan::EAC1_1_CVC::~EAC1_1_CVC | ( | ) | [inline, virtual] |
Definition at line 64 of file cvc_cert.h.
{}
std::vector< byte > Botan::EAC_Signed_Object::BER_encode | ( | ) | const [inherited] |
BER encode 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().
static std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::build_cert_body | ( | const std::vector< byte > & | tbs | ) | [static, inherited] |
Build the DER encoded certifcate body of an object
tbs | the data to be signed |
Referenced by Botan::make_cvc_cert().
bool Botan::EAC1_1_obj< EAC1_1_CVC >::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.
key | the public key associated with this signed object |
sig | the signature we are checking |
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; } }
static void Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::decode_info | ( | DataSource & | source, |
std::vector< byte > & | res_tbs_bits, | ||
ECDSA_Signature & | res_sig | ||
) | [static, protected, inherited] |
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(), 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_gen_CVC< EAC1_1_CVC >::encode | ( | Pipe & | out, |
X509_Encoding | encoding | ||
) | const [virtual, inherited] |
Put the DER encoded version of this object into a pipe. PEM is not supported.
out | the pipe to push the DER encoded version into |
encoding | the encoding to use. Must be DER. |
Implements Botan::EAC_Signed_Object.
ASN1_Car Botan::EAC1_1_CVC::get_car | ( | ) | const |
Get the CAR of the certificate.
Definition at line 13 of file cvc_cert.cpp.
Referenced by Botan::DE_EAC::link_cvca().
{
return m_car;
}
ASN1_Ced Botan::EAC1_1_CVC::get_ced | ( | ) | const |
Get the CED of this certificate.
Definition at line 18 of file cvc_cert.cpp.
{
return m_ced;
}
ASN1_Cex Botan::EAC1_1_CVC::get_cex | ( | ) | const |
Get the CEX of this certificate.
Definition at line 22 of file cvc_cert.cpp.
Referenced by Botan::DE_EAC::link_cvca().
{
return m_cex;
}
u32bit Botan::EAC1_1_CVC::get_chat_value | ( | ) | const |
Get the CHAT value.
Definition at line 26 of file cvc_cert.cpp.
Referenced by Botan::DE_EAC::link_cvca(), and Botan::DE_EAC::sign_request().
{
return m_chat_val;
}
ASN1_Chr Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::get_chr | ( | ) | const [inherited] |
Get the CHR of the certificate.
std::vector<byte> Botan::EAC1_1_obj< EAC1_1_CVC >::get_concat_sig | ( | ) | const [inline, virtual, inherited] |
Return the signature as a concatenation of the encoded parts.
Implements Botan::EAC_Signed_Object.
Definition at line 27 of file eac_obj.h.
Referenced by operator==().
{ return m_sig.get_concatenation(); }
void Botan::EAC1_1_obj< EAC1_1_CVC >::init | ( | DataSource & | in | ) | [inline, protected, inherited] |
Definition at line 38 of file eac_obj.h.
Referenced by EAC1_1_CVC().
{ try { Derived::decode_info(in, tbs_bits, m_sig); } catch(Decoding_Error) { throw Decoding_Error(PEM_label_pref + " decoding failed"); } }
bool Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::is_self_signed | ( | ) | const [inherited] |
Find out whether this object is self signed.
static std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::make_signed | ( | PK_Signer & | signer, |
const std::vector< byte > & | tbs_bits, | ||
RandomNumberGenerator & | rng | ||
) | [static, inherited] |
Create a signed generalized CVC object.
signer | the signer used to sign this object |
tbs_bits | the body the generalized CVC object to be signed |
rng | a random number generator |
Referenced by Botan::make_cvc_cert().
bool Botan::EAC1_1_CVC::operator== | ( | const EAC1_1_CVC & | rhs | ) | const |
Definition at line 85 of file cvc_cert.cpp.
References Botan::EAC1_1_obj< EAC1_1_CVC >::get_concat_sig(), Botan::EAC1_1_obj< Derived >::get_concat_sig(), Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::tbs_data(), and Botan::EAC1_1_gen_CVC< Derived >::tbs_data().
{ return (tbs_data() == rhs.tbs_data() && get_concat_sig() == rhs.get_concat_sig()); }
std::string Botan::EAC_Signed_Object::PEM_encode | ( | ) | const [inherited] |
PEM encode 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().
AlgorithmIdentifier Botan::EAC_Signed_Object::signature_algorithm | ( | ) | const [inherited] |
Get the signature algorithm identifier used to sign this object.
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; }
Public_Key* Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::subject_public_key | ( | ) | const [inherited] |
Get this certificates public key.
std::vector<byte> Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::tbs_data | ( | ) | const [virtual, inherited] |
Get the to-be-signed (TBS) data of this object.
Implements Botan::EAC_Signed_Object.
Referenced by operator==().
friend class EAC1_1_obj< EAC1_1_CVC > [friend] |
Definition at line 24 of file cvc_cert.h.
ASN1_Chr Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::m_chr [protected, inherited] |
Definition at line 87 of file cvc_gen_cert.h.
ECDSA_PublicKey* Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::m_pk [protected, inherited] |
Definition at line 86 of file cvc_gen_cert.h.
ECDSA_Signature Botan::EAC1_1_obj< EAC1_1_CVC >::m_sig [protected, inherited] |
std::string Botan::EAC_Signed_Object::PEM_label_pref [protected, inherited] |
Definition at line 88 of file signed_obj.h.
Referenced by Botan::EAC_Signed_Object::do_decode(), and Botan::EAC1_1_obj< EAC1_1_Req >::init().
std::vector<std::string> Botan::EAC_Signed_Object::PEM_labels_allowed [protected, inherited] |
Definition at line 89 of file signed_obj.h.
bool Botan::EAC1_1_gen_CVC< EAC1_1_CVC >::self_signed [protected, inherited] |
Definition at line 88 of file cvc_gen_cert.h.
Referenced by EAC1_1_CVC().
AlgorithmIdentifier Botan::EAC_Signed_Object::sig_algo [protected, inherited] |
Definition at line 86 of file signed_obj.h.
Referenced by Botan::EAC_Signed_Object::check_signature(), and Botan::EAC_Signed_Object::signature_algorithm().
std::vector<byte> Botan::EAC_Signed_Object::tbs_bits [protected, inherited] |
Definition at line 87 of file signed_obj.h.
Referenced by Botan::EAC1_1_ADO::encode(), Botan::EAC1_1_obj< EAC1_1_Req >::init(), and Botan::EAC1_1_ADO::tbs_data().