Botan 1.10.17
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

Public Member Functions

SecureVector< byteBER_encode () const
bool check_signature (class Public_Key &key) const
bool check_signature (class Public_Key &key, const MemoryRegion< 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
SecureVector< 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
SecureVector< bytetbs_data () const
virtual ~EAC1_1_ADO ()

Static Public Member Functions

static MemoryVector< bytemake_signed (PK_Signer &signer, const MemoryRegion< 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
SecureVector< 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

◆ EAC1_1_ADO() [1/2]

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.

21 {
22 DataSource_Stream stream(in, true);
23 init(stream);
24 do_decode();
25 }
void init(DataSource &in)
Definition eac_obj.h:38

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

Referenced by Botan::CVC_EAC::create_ado_req(), EAC1_1_obj< EAC1_1_ADO >, and operator==().

◆ EAC1_1_ADO() [2/2]

Botan::EAC1_1_ADO::EAC1_1_ADO ( DataSource & source)

Construct a CVC ADO request from a data source

Parameters
sourcethe data source

Definition at line 14 of file cvc_ado.cpp.

15 {
16 init(in);
17 do_decode();
18 }

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

◆ ~EAC1_1_ADO()

virtual Botan::EAC1_1_ADO::~EAC1_1_ADO ( )
inlinevirtual

Definition at line 78 of file cvc_ado.h.

78{}

Member Function Documentation

◆ BER_encode()

SecureVector< 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 19 of file signed_obj.cpp.

20 {
21 Pipe ber;
22 ber.start_msg();
23 encode(ber, RAW_BER);
24 ber.end_msg();
25 return ber.read_all();
26 }
virtual void encode(Pipe &pipe, X509_Encoding encoding=PEM) const =0

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

Referenced by Botan::CVC_EAC::create_ado_req(), and encode().

◆ check_signature() [1/2]

bool Botan::EAC1_1_obj< EAC1_1_ADO >::check_signature ( class Public_Key & key) const
inlineinherited

Definition at line 30 of file eac_obj.h.

31 {
32 return EAC_Signed_Object::check_signature(key, m_sig.DER_encode());
33 }
bool check_signature(class Public_Key &key, const MemoryRegion< byte > &sig) const

◆ check_signature() [2/2]

bool Botan::EAC_Signed_Object::check_signature ( class Public_Key & key,
const MemoryRegion< 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 48 of file signed_obj.cpp.

50 {
51 try
52 {
53 std::vector<std::string> sig_info =
55
56 if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
57 {
58 return false;
59 }
60
61 std::string padding = sig_info[1];
62 Signature_Format format =
63 (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
64
65 SecureVector<byte> to_sign = tbs_data();
66
67 PK_Verifier verifier(pub_key, padding, format);
68 return verifier.verify_message(to_sign, sig);
69 }
70 catch(...)
71 {
72 return false;
73 }
74 }
virtual SecureVector< byte > tbs_data() const =0
AlgorithmIdentifier sig_algo
Definition signed_obj.h:85
std::string lookup(const OID &oid)
Definition oids.cpp:31
std::vector< std::string > split_on(const std::string &str, char delim)
Definition parsing.cpp:152
Signature_Format
Definition pubkey.h:24
@ DER_SEQUENCE
Definition pubkey.h:24
@ IEEE_1363
Definition pubkey.h:24

References Botan::Public_Key::algo_name(), Botan::OIDS::lookup(), Botan::AlgorithmIdentifier::oid, sig_algo, and Botan::split_on().

Referenced by Botan::EAC1_1_obj< Derived >::check_signature(), and get_concat_sig().

◆ do_decode()

void Botan::EAC_Signed_Object::do_decode ( )
protectedinherited

Definition at line 79 of file signed_obj.cpp.

80 {
81 try {
82 force_decode();
83 }
84 catch(Decoding_Error& e)
85 {
86 const std::string what = e.what();
87 throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
88 }
89 catch(Invalid_Argument& e)
90 {
91 const std::string what = e.what();
92 throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
93 }
94 }
std::string PEM_label_pref
Definition signed_obj.h:87
std::invalid_argument Invalid_Argument
Definition exceptn.h:20
Decoding_Error(const std::string &name)
Definition exceptn.h:140

◆ encode()

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.

96 {
97 if(encoding == PEM)
98 throw Invalid_Argument("EAC1_1_ADO::encode() cannot PEM encode an EAC object");
99
100 SecureVector<byte> concat_sig(
101 EAC1_1_obj<EAC1_1_ADO>::m_sig.get_concatenation());
102
103 out.write(DER_Encoder()
104 .start_cons(ASN1_Tag(7), APPLICATION)
105 .raw_bytes(tbs_bits)
106 .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
107 .end_cons()
108 .get_contents());
109 }
void encode(Pipe &out, X509_Encoding encoding) const
Definition cvc_ado.cpp:95
ECDSA_Signature m_sig
Definition eac_obj.h:36
SecureVector< byte > tbs_bits
Definition signed_obj.h:86
ASN1_Tag
Definition asn1_int.h:19
@ APPLICATION
Definition asn1_int.h:21
@ OCTET_STRING
Definition asn1_int.h:31

References Botan::APPLICATION, encode(), Botan::EAC1_1_obj< Derived >::m_sig, Botan::OCTET_STRING, Botan::PEM, Botan::EAC1_1_obj< EAC1_1_ADO >::tbs_bits, and Botan::Pipe::write().

Referenced by encode().

◆ get_car()

ASN1_Car Botan::EAC1_1_ADO::get_car ( ) const

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.

63 {
64 return m_car;
65 }

Referenced by operator==().

◆ get_concat_sig()

SecureVector< byte > Botan::EAC1_1_obj< EAC1_1_ADO >::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.

28 { return m_sig.get_concatenation(); }

Referenced by Botan::EAC1_1_ADO::operator==().

◆ get_request()

EAC1_1_Req Botan::EAC1_1_ADO::get_request ( ) const

Get the CVC request contained in this object.

Returns
the CVC request inside this CVC ADO request

Definition at line 123 of file cvc_ado.cpp.

124 {
125 return m_req;
126 }

◆ init()

void Botan::EAC1_1_obj< EAC1_1_ADO >::init ( DataSource & in)
inlineprotectedinherited

Definition at line 38 of file eac_obj.h.

39 {
40 try
41 {
43 }
44 catch(Decoding_Error)
45 {
46 throw Decoding_Error(PEM_label_pref + " decoding failed");
47 }
48 }

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

◆ make_signed()

MemoryVector< byte > Botan::EAC1_1_ADO::make_signed ( PK_Signer & signer,
const MemoryRegion< 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.

51 {
52 SecureVector<byte> concat_sig = signer.sign_message(tbs_bits, rng);
53
54 return DER_Encoder()
55 .start_cons(ASN1_Tag(7), APPLICATION)
56 .raw_bytes(tbs_bits)
57 .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
58 .end_cons()
59 .get_contents();
60 }

References Botan::APPLICATION, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), Botan::OCTET_STRING, Botan::DER_Encoder::raw_bytes(), Botan::PK_Signer::sign_message(), Botan::DER_Encoder::start_cons(), and Botan::EAC1_1_obj< EAC1_1_ADO >::tbs_bits.

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

◆ operator==()

bool Botan::EAC1_1_ADO::operator== ( EAC1_1_ADO const & rhs) const

Definition at line 116 of file cvc_ado.cpp.

117 {
118 return (this->get_concat_sig() == rhs.get_concat_sig()
119 && this->tbs_data() == rhs.tbs_data()
120 && this->get_car() == rhs.get_car());
121 }
virtual SecureVector< byte > get_concat_sig() const =0

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

◆ PEM_encode()

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 31 of file signed_obj.cpp.

32 {
33 Pipe pem;
34 pem.start_msg();
35 encode(pem, PEM);
36 pem.end_msg();
37 return pem.read_all_as_string();
38 }

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

Referenced by encode().

◆ signature_algorithm()

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 43 of file signed_obj.cpp.

44 {
45 return sig_algo;
46 }

References sig_algo.

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

◆ tbs_data()

SecureVector< 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 111 of file cvc_ado.cpp.

112 {
113 return tbs_bits;
114 }

References Botan::EAC1_1_obj< EAC1_1_ADO >::tbs_bits.

Referenced by operator==().

◆ EAC1_1_obj< EAC1_1_ADO >

friend class EAC1_1_obj< EAC1_1_ADO >
friend

Definition at line 89 of file cvc_ado.h.

References EAC1_1_ADO(), and Botan::operator!=().

Member Data Documentation

◆ m_sig

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

Definition at line 36 of file eac_obj.h.

◆ PEM_label_pref

std::string Botan::EAC_Signed_Object::PEM_label_pref
protectedinherited

Definition at line 87 of file signed_obj.h.

Referenced by Botan::EAC1_1_obj< Derived >::init().

◆ PEM_labels_allowed

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

Definition at line 88 of file signed_obj.h.

◆ sig_algo

AlgorithmIdentifier Botan::EAC_Signed_Object::sig_algo
protectedinherited

Definition at line 85 of file signed_obj.h.

Referenced by check_signature(), and signature_algorithm().

◆ tbs_bits


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