Botan 1.10.17

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::EAC_Signed_Object Class Referenceabstract

`#include <signed_obj.h>`

Inheritance diagram for Botan::EAC_Signed_Object:

## Public Member Functions
SecureVector< byte > | BER_encode () const
bool | check_signature (class Public_Key &key, const MemoryRegion< byte > &sig) const
virtual void | encode (Pipe &pipe, X509_Encoding encoding=PEM) const =0
virtual SecureVector< byte > | get_concat_sig () const =0
std::string | PEM_encode () const
AlgorithmIdentifier | signature_algorithm () const
virtual SecureVector< byte > | tbs_data () const =0
virtual | ~EAC_Signed_Object ()

## Protected Member Functions
void | do_decode ()
| EAC_Signed_Object ()

## Protected Attributes
std::string | PEM_label_pref
std::vector< std::string > | PEM_labels_allowed
AlgorithmIdentifier | sig_algo
SecureVector< byte > | tbs_bits

## Detailed Description

This class represents abstract signed EAC object

Definition at line 22 of file signed_obj.h.

## Constructor & Destructor Documentation

## ◆ ~EAC_Signed_Object()

virtual Botan::EAC_Signed_Object::~EAC_Signed_Object | ( |  | ) |
| inline virtual

Definition at line 80 of file signed_obj.h.

80 {}

## ◆ EAC_Signed_Object()

Botan::EAC_Signed_Object::EAC_Signed_Object | ( |  | ) |
| inline protected

Definition at line 83 of file signed_obj.h.

83 {}

## Member Function Documentation

## ◆ BER_encode()

SecureVector< byte > Botan::EAC_Signed_Object::BER_encode | ( |  | ) | const

BER encode this object.

Returns
  result containing the BER representation of this object.

Definition at line 19 of file signed_obj.cpp.

References 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

## ◆ check_signature()

bool Botan::EAC_Signed_Object::check_signature | ( | class Public_Key & | key,
|  | const MemoryRegion< byte > & | sig
| ) |  | const

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, sig_algo, Botan::split_on(), 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

## ◆ do_decode()

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

Definition at line 79 of file signed_obj.cpp.

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

virtual void Botan::EAC_Signed_Object::encode | ( | Pipe & | pipe,
|  | X509_Encoding | encoding = `PEM`
| ) |  | const
| pure virtual

Write this object DER encoded into a specified pipe.

Parameters

  pipe | the pipe to write the encoded object to
  encoding | the encoding type to use

Implemented in Botan::EAC1_1_ADO, Botan::EAC1_1_gen_CVC< Derived >, Botan::EAC1_1_gen_CVC< EAC1_1_CVC >, and Botan::EAC1_1_gen_CVC< EAC1_1_Req >.

Referenced by BER_encode(), and PEM_encode().

## ◆ get_concat_sig()

virtual SecureVector<byte> Botan::EAC_Signed_Object::get_concat_sig | ( |  | ) | const
| pure virtual

Get the signature of this object as a concatenation, i.e. if the signature consists of multiple parts (like in the case of ECDSA) these will be concatenated.

Returns
  signature as a concatenation of its parts

Implemented in Botan::EAC1_1_obj< Derived >, Botan::EAC1_1_obj< EAC1_1_ADO >, Botan::EAC1_1_obj< EAC1_1_CVC >, and Botan::EAC1_1_obj< EAC1_1_Req >.

## ◆ PEM_encode()

std::string Botan::EAC_Signed_Object::PEM_encode | ( |  | ) | const

PEM encode this object.

Returns
  result containing the PEM representation of this object.

Definition at line 31 of file signed_obj.cpp.

References 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

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

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

## ◆ tbs_data()

virtual SecureVector<byte> Botan::EAC_Signed_Object::tbs_data | ( |  | ) | const
| pure virtual

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

Returns
  DER encoded TBS data of this object

Implemented in Botan::EAC1_1_ADO, Botan::EAC1_1_gen_CVC< Derived >, Botan::EAC1_1_gen_CVC< EAC1_1_CVC >, and Botan::EAC1_1_gen_CVC< EAC1_1_Req >.

Referenced by check_signature().

## Member Data Documentation

## ◆ PEM_label_pref

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

Definition at line 87 of file signed_obj.h.

Referenced by 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

Definition at line 88 of file signed_obj.h.

## ◆ sig_algo

AlgorithmIdentifier Botan::EAC_Signed_Object::sig_algo
| protected

Definition at line 85 of file signed_obj.h.

Referenced by check_signature(), and signature_algorithm().

## ◆ tbs_bits

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

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 files:

- src/cert/cvc/signed_obj.h
- src/cert/cvc/signed_obj.cpp