Botan 1.10.17

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Botan::EAC1_1_gen_CVC< Derived > Class Template Reference

`#include <cvc_gen_cert.h>`

Inheritance diagram for Botan::EAC1_1_gen_CVC< Derived >:

## Public Member Functions
SecureVector< byte > | BER_encode () const
bool | check_signature (class Public_Key &key) const
bool | check_signature (class Public_Key &key, const MemoryRegion< byte > &sig) const
| EAC1_1_gen_CVC ()
void | encode (Pipe &out, X509_Encoding encoding) const
ASN1_Chr | get_chr () const
SecureVector< byte > | get_concat_sig () const
bool | is_self_signed () const
std::string | PEM_encode () const
AlgorithmIdentifier | signature_algorithm () const
Public_Key * | subject_public_key () const
SecureVector< byte > | tbs_data () const
virtual | ~EAC1_1_gen_CVC ()

## Static Public Member Functions
static SecureVector< byte > | build_cert_body (MemoryRegion< byte > const &tbs)
static MemoryVector< byte > | make_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_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
SecureVector< byte > | tbs_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

## ◆ EAC1_1_gen_CVC()

template<typename Derived>

Botan::EAC1_1_gen_CVC< Derived >::EAC1_1_gen_CVC | ( |  | ) |
| inline

Definition at line 80 of file cvc_gen_cert.h.

80 { m_pk = 0; }
Botan::EAC1_1_gen_CVC::m_pk
ECDSA_PublicKey * m_pk
Definition: cvc_gen_cert.h:86

## ◆ ~EAC1_1_gen_CVC()

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.

83 { delete m_pk; }
Botan::EAC1_1_gen_CVC::m_pk
ECDSA_PublicKey * m_pk
Definition: cvc_gen_cert.h:86

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

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

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

## ◆ build_cert_body()

template<typename Derived >

SecureVector< byte > Botan::EAC1_1_gen_CVC< Derived >::build_cert_body | ( | MemoryRegion< byte > const & | tbs | ) |
| static

Build the DER encoded certifcate body of an object

Parameters

  tbs | the data to be signed

Returns
  the correctly encoded body of the object

Definition at line 128 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 }
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::APPLICATION
Definition: asn1_int.h:21

## ◆ check_signature() [1/2]

template<typename Derived>

bool Botan::EAC1_1_obj< Derived >::check_signature | ( | class Public_Key & | key | ) | const
| inline inherited

Definition at line 30 of file eac_obj.h.

31 {
32 return EAC_Signed_Object::check_signature(key, m_sig.DER_encode());
33 }
Botan::EAC_Signed_Object::check_signature
bool check_signature(class Public_Key &key, const MemoryRegion< byte > &sig) const
Definition: signed_obj.cpp:48
Botan::EAC1_1_obj::m_sig
ECDSA_Signature m_sig
Definition: eac_obj.h:36
Botan::ECDSA_Signature::DER_encode
MemoryVector< byte > DER_encode() const
Definition: ecdsa_sig.cpp:23

## ◆ 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

  key | the public key associated with this signed object
  sig | the 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.

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

50 {
51 try
52 {
53 std::vector<std::string> sig_info =
54 split_on(OIDS::lookup(sig_algo.oid), '/');
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 }
Botan::EAC_Signed_Object::tbs_data
virtual SecureVector< byte > tbs_data() const =0
Botan::EAC_Signed_Object::sig_algo
AlgorithmIdentifier sig_algo
Definition: signed_obj.h:85
Botan::Signature_Format
Signature_Format
Definition: pubkey.h:24
Botan::split_on
std::vector< std::string > split_on(const std::string &str, char delim)
Definition: parsing.cpp:152
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:31
Botan::AlgorithmIdentifier::oid
OID oid
Definition: alg_id.h:35
Botan::IEEE_1363
Definition: pubkey.h:24
Botan::DER_SEQUENCE
Definition: pubkey.h:24

## ◆ decode_info()

template<typename Derived >

void Botan::EAC1_1_gen_CVC< Derived >::decode_info | ( | DataSource & | source,
|  | SecureVector< byte > & | res_tbs_bits,
|  | ECDSA_Signature & | res_sig
| ) |  |
| static protected

Definition at line 160 of file cvc_gen_cert.h.

164 {
165 SecureVector<byte> concat_sig;
166 BER_Decoder(source)
167 .start_cons(ASN1_Tag(33))
168 .start_cons(ASN1_Tag(78))
169 .raw_bytes(res_tbs_bits)
170 .end_cons()
171 .decode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
172 .end_cons();
173 res_sig = decode_concatenation(concat_sig);
174 }
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::APPLICATION
Definition: asn1_int.h:21
Botan::decode_concatenation
ECDSA_Signature decode_concatenation(const MemoryRegion< byte > &concat)
Definition: ecdsa_sig.cpp:46

## ◆ do_decode()

void Botan::EAC_Signed_Object::do_decode | ( |  | ) |
| protected inherited

Definition at line 79 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 Botan::EAC1_1_Req::EAC1_1_Req().

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 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::EAC_Signed_Object::PEM_label_pref
std::string PEM_label_pref
Definition: signed_obj.h:87

## ◆ encode()

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

  out | the pipe to push the DER encoded version into
  encoding | the encoding to use. Must be DER.

Implements Botan::EAC_Signed_Object.

Definition at line 141 of file cvc_gen_cert.h.

142 {
143 SecureVector<byte> concat_sig(EAC1_1_obj<Derived>::m_sig.get_concatenation());
144 SecureVector<byte> der = DER_Encoder()
145 .start_cons(ASN1_Tag(33), APPLICATION)
146 .start_cons(ASN1_Tag(78), APPLICATION)
147 .raw_bytes(EAC1_1_obj<Derived>::tbs_bits)
148 .end_cons()
149 .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
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 }
Botan::EAC1_1_obj::m_sig
ECDSA_Signature m_sig
Definition: eac_obj.h:36
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::PEM
Definition: pubkey_enums.h:67
Botan::APPLICATION
Definition: asn1_int.h:21
Botan::EAC_Signed_Object::tbs_bits
SecureVector< byte > tbs_bits
Definition: signed_obj.h:86

## ◆ get_chr()

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.

97 {
98 return m_chr;
99 }
Botan::EAC1_1_gen_CVC::m_chr
ASN1_Chr m_chr
Definition: cvc_gen_cert.h:87

## ◆ get_concat_sig()

template<typename Derived>

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

28 { return m_sig.get_concatenation(); }
Botan::EAC1_1_obj::m_sig
ECDSA_Signature m_sig
Definition: eac_obj.h:36
Botan::ECDSA_Signature::get_concatenation
MemoryVector< byte > get_concatenation() const
Definition: ecdsa_sig.cpp:33

## ◆ init()

template<typename Derived>

void Botan::EAC1_1_obj< Derived >::init | ( | DataSource & | in | ) |
| inline protected inherited

Definition at line 38 of file eac_obj.h.

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 }
Botan::EAC1_1_obj::m_sig
ECDSA_Signature m_sig
Definition: eac_obj.h:36
Botan::EAC_Signed_Object::PEM_label_pref
std::string PEM_label_pref
Definition: signed_obj.h:87
Botan::EAC_Signed_Object::tbs_bits
SecureVector< byte > tbs_bits
Definition: signed_obj.h:86

## ◆ is_self_signed()

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.

102 {
103 return self_signed;
104 }
Botan::EAC1_1_gen_CVC::self_signed
bool self_signed
Definition: cvc_gen_cert.h:88

## ◆ make_signed()

template<typename Derived >

MemoryVector< byte > Botan::EAC1_1_gen_CVC< Derived >::make_signed | ( | PK_Signer & | signer,
|  | const MemoryRegion< byte > & | tbs_bits,
|  | RandomNumberGenerator & | rng
| ) |  |
| static

Create a signed generalized CVC object.

Parameters

  signer | the signer used to sign this object
  tbs_bits | the body the generalized CVC object to be signed
  rng | a random number generator

Returns
  the DER encoded signed generalized CVC object

Definition at line 107 of file cvc_gen_cert.h.

111 {
112 SecureVector<byte> concat_sig = signer.sign_message(tbs_bits, rng);
113
114 return DER_Encoder()
115 .start_cons(ASN1_Tag(33), APPLICATION)
116 .raw_bytes(tbs_bits)
117 .encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
118 .end_cons()
119 .get_contents();
120 }
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::APPLICATION
Definition: asn1_int.h:21
Botan::EAC_Signed_Object::tbs_bits
SecureVector< byte > tbs_bits
Definition: signed_obj.h:86

## ◆ 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.

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

32 {
33 Pipe pem;
34 pem.start_msg();
35 encode(pem, PEM);
36 pem.end_msg();
37 return pem.read_all_as_string();
38 }
Botan::EAC_Signed_Object::encode
virtual void encode(Pipe &pipe, X509_Encoding encoding=PEM) const =0
Botan::PEM
Definition: pubkey_enums.h:67

## ◆ 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.

References Botan::EAC_Signed_Object::sig_algo.

44 {
45 return sig_algo;
46 }
Botan::EAC_Signed_Object::sig_algo
AlgorithmIdentifier sig_algo
Definition: signed_obj.h:85

## ◆ subject_public_key()

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.

124 {
125 return new ECDSA_PublicKey(*m_pk);
126 }
Botan::EAC1_1_gen_CVC::m_pk
ECDSA_PublicKey * m_pk
Definition: cvc_gen_cert.h:86

## ◆ tbs_data()

template<typename Derived >

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

137 {
138 return build_cert_body(EAC1_1_obj<Derived>::tbs_bits);
139 }
Botan::EAC1_1_gen_CVC::build_cert_body
static SecureVector< byte > build_cert_body(MemoryRegion< byte > const &tbs)
Definition: cvc_gen_cert.h:128
Botan::EAC_Signed_Object::tbs_bits
SecureVector< byte > tbs_bits
Definition: signed_obj.h:86

## Friends And Related Function Documentation

## ◆ EAC1_1_obj< EAC1_1_gen_CVC >

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

## ◆ m_chr

template<typename Derived>

ASN1_Chr Botan::EAC1_1_gen_CVC< Derived >::m_chr
| protected

Definition at line 87 of file cvc_gen_cert.h.

## ◆ m_pk

template<typename Derived>

ECDSA_PublicKey* Botan::EAC1_1_gen_CVC< Derived >::m_pk
| protected

Definition at line 86 of file cvc_gen_cert.h.

Referenced by Botan::EAC1_1_gen_CVC< EAC1_1_Req >::EAC1_1_gen_CVC(), and Botan::EAC1_1_gen_CVC< EAC1_1_Req >::~EAC1_1_gen_CVC().

## ◆ m_sig

template<typename Derived>

ECDSA_Signature Botan::EAC1_1_obj< Derived >::m_sig
| protected inherited

Definition at line 36 of file eac_obj.h.

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

## ◆ PEM_label_pref

std::string Botan::EAC_Signed_Object::PEM_label_pref
| protected inherited

Definition at line 87 of file signed_obj.h.

Referenced by Botan::EAC_Signed_Object::do_decode(), and Botan::EAC1_1_obj< EAC1_1_Req >::init().

## ◆ PEM_labels_allowed

std::vector<std::string> Botan::EAC_Signed_Object::PEM_labels_allowed
| protected inherited

Definition at line 88 of file signed_obj.h.

## ◆ self_signed

template<typename Derived>

bool Botan::EAC1_1_gen_CVC< Derived >::self_signed
| protected

Definition at line 88 of file cvc_gen_cert.h.

## ◆ sig_algo

AlgorithmIdentifier Botan::EAC_Signed_Object::sig_algo
| protected inherited

Definition at line 85 of file signed_obj.h.

Referenced by Botan::EAC_Signed_Object::check_signature(), and Botan::EAC_Signed_Object::signature_algorithm().

## ◆ tbs_bits

SecureVector<byte> Botan::EAC_Signed_Object::tbs_bits
| protected inherited

Definition at line 86 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().

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

- src/cert/cvc/cvc_gen_cert.h