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

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_Req (const std::string &str)
 EAC1_1_Req (DataSource &source)
void encode (Pipe &out, X509_Encoding encoding) const
ASN1_Chr get_chr () const
SecureVector< 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
SecureVector< bytetbs_data () const
virtual ~EAC1_1_Req ()

Static Public Member Functions

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

◆ EAC1_1_Req() [1/2]

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.

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

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

Referenced by Botan::CVC_EAC::create_cvc_req(), EAC1_1_ADO, and operator==().

◆ EAC1_1_Req() [2/2]

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.

46 {
47 DataSource_Stream stream(in, true);
48 init(stream);
49 self_signed = true;
50 do_decode();
51 }

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

◆ ~EAC1_1_Req()

virtual Botan::EAC1_1_Req::~EAC1_1_Req ( )
inlinevirtual

Definition at line 43 of file cvc_req.h.

43{}

Member Function Documentation

◆ BER_encode()

BER encode this object.

Returns
result containing the BER representation of this object.

Definition at line 72 of file signed_obj.cpp.

20 {
21 Pipe ber;
22 ber.start_msg();
24 ber.end_msg();
25 return ber.read_all();
26 }

◆ build_cert_body()

SecureVector< byte > Botan::EAC1_1_gen_CVC< EAC1_1_Req >::build_cert_body ( MemoryRegion< byte > const & 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

Definition at line 66 of file cvc_gen_cert.h.

129 {
130 return DER_Encoder()
131 .start_cons(ASN1_Tag(78), APPLICATION)
132 .raw_bytes(tbs)
133 .end_cons().get_contents();
134 }

◆ check_signature() [1/2]

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.

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

50 {
51 try
52 {
55
56 if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
57 {
58 return false;
59 }
60
63 (pub_key.message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
64
66
68 return verifier.verify_message(to_sign, sig);
69 }
70 catch(...)
71 {
72 return false;
73 }
74 }

◆ decode_info()

void Botan::EAC1_1_gen_CVC< EAC1_1_Req >::decode_info ( DataSource & source,
SecureVector< byte > & res_tbs_bits,
ECDSA_Signature & res_sig )
staticprotectedinherited

Definition at line 90 of file cvc_gen_cert.h.

164 {
167 .start_cons(ASN1_Tag(33))
168 .start_cons(ASN1_Tag(78))
169 .raw_bytes(res_tbs_bits)
170 .end_cons()
172 .end_cons();
174 }
BER_Decoder(DataSource &)
Definition ber_dec.cpp:264

◆ do_decode()

void Botan::EAC_Signed_Object::do_decode ( )
protectedinherited

Definition at line 82 of file signed_obj.cpp.

80 {
81 try {
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 }
Decoding_Error(const std::string &name)
Definition exceptn.h:140

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

◆ encode()

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.

Definition at line 53 of file cvc_gen_cert.h.

142 {
145 .start_cons(ASN1_Tag(33), APPLICATION)
146 .start_cons(ASN1_Tag(78), APPLICATION)
148 .end_cons()
150 .end_cons()
151 .get_contents();
152
153 if (encoding == PEM)
154 throw Invalid_Argument("EAC1_1_gen_CVC::encode() cannot PEM encode an EAC object");
155 else
156 out.write(der);
157 }
void encode(Pipe &out, X509_Encoding encoding) const

◆ get_chr()

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

Definition at line 45 of file cvc_gen_cert.h.

97 {
98 return m_chr;
99 }

◆ get_concat_sig()

SecureVector< byte > Botan::EAC1_1_obj< EAC1_1_Req >::get_concat_sig ( ) const
inlineinherited

Return the signature as a concatenation of the encoded parts.

Returns
the concatenated signature

Definition at line 27 of file eac_obj.h.

28 { return m_sig.get_concatenation(); }

◆ init()

void Botan::EAC1_1_obj< EAC1_1_Req >::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_Req::EAC1_1_Req(), and Botan::EAC1_1_Req::EAC1_1_Req().

◆ is_self_signed()

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

Definition at line 39 of file cvc_gen_cert.h.

102 {
103 return self_signed;
104 }

◆ make_signed()

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

Definition at line 75 of file cvc_gen_cert.h.

111 {
113
114 return DER_Encoder()
115 .start_cons(ASN1_Tag(33), APPLICATION)
116 .raw_bytes(tbs_bits)
118 .end_cons()
119 .get_contents();
120 }

◆ operator==()

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.

15 {
16 return (this->tbs_data() == rhs.tbs_data() &&
17 this->get_concat_sig() == rhs.get_concat_sig());
18 }
virtual SecureVector< byte > tbs_data() const =0

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

Referenced by EAC1_1_ADO.

◆ 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 78 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 }

◆ signature_algorithm()

Get the signature algorithm identifier used to sign this object.

Returns
the signature algorithm identifier

Definition at line 48 of file signed_obj.cpp.

44 {
45 return sig_algo;
46 }

◆ subject_public_key()

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

Definition at line 33 of file cvc_gen_cert.h.

124 {
125 return new ECDSA_PublicKey(*m_pk);
126 }

◆ tbs_data()

SecureVector< 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.

Definition at line 59 of file cvc_gen_cert.h.

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

◆ EAC1_1_ADO

friend class EAC1_1_ADO
friend

Definition at line 22 of file cvc_req.h.

References EAC1_1_ADO, EAC1_1_Req(), and operator==().

Referenced by EAC1_1_ADO.

◆ EAC1_1_obj< EAC1_1_Req >

friend class EAC1_1_obj< EAC1_1_Req >
friend

Definition at line 22 of file cvc_req.h.

Member Data Documentation

◆ m_chr

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

Definition at line 87 of file cvc_gen_cert.h.

◆ m_pk

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

Definition at line 86 of file cvc_gen_cert.h.

◆ m_sig

ECDSA_Signature Botan::EAC1_1_obj< EAC1_1_Req >::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.

◆ PEM_labels_allowed

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

Definition at line 88 of file signed_obj.h.

◆ self_signed

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

Definition at line 88 of file cvc_gen_cert.h.

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

◆ sig_algo

Definition at line 85 of file signed_obj.h.

◆ tbs_bits

Definition at line 86 of file signed_obj.h.


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