Botan  1.11.10
cvc_ado.h
Go to the documentation of this file.
1 /*
2 * EAC1_1 CVC ADO
3 * (C) 2008 Falko Strenzke
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_EAC_CVC_ADO_H__
9 #define BOTAN_EAC_CVC_ADO_H__
10 
11 #include <botan/eac_obj.h>
12 #include <botan/eac_asn_obj.h>
13 #include <botan/cvc_req.h>
14 #include <string>
15 
16 namespace Botan {
17 
18 /**
19 * This class represents a TR03110 (EAC) v1.1 CVC ADO request
20 */
21 
22  // CRTP continuation from EAC1_1_obj
23 class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO>
24  {
25  public:
26  friend class EAC1_1_obj<EAC1_1_ADO>;
27 
28  /**
29  * Construct a CVC ADO request from a DER encoded CVC ADO request file.
30  * @param str the path to the DER encoded file
31  */
32  EAC1_1_ADO(const std::string& str);
33 
34  /**
35  * Construct a CVC ADO request from a data source
36  * @param source the data source
37  */
38  EAC1_1_ADO(DataSource& source);
39 
40  /**
41  * Create a signed CVC ADO request from to be signed (TBS) data
42  * @param signer the signer used to sign the CVC ADO request
43  * @param tbs_bits the TBS data to sign
44  * @param rng a random number generator
45  */
46  static std::vector<byte> make_signed(
47  PK_Signer& signer,
48  const std::vector<byte>& tbs_bits,
50 
51  /**
52  * Get the CAR of this CVC ADO request
53  * @result the CAR of this CVC ADO request
54  */
55  ASN1_Car get_car() const;
56 
57  /**
58  * Get the CVC request contained in this object.
59  * @result the CVC request inside this CVC ADO request
60  */
61  EAC1_1_Req get_request() const;
62 
63  /**
64  * Encode this object into a pipe. Only DER is supported.
65  * @param out the pipe to encode this object into
66  * @param encoding the encoding type to use, must be DER
67  */
68  void encode(Pipe& out, X509_Encoding encoding) const;
69 
70  bool operator==(EAC1_1_ADO const& rhs) const;
71 
72  /**
73  * Get the TBS data of this CVC ADO request.
74  * @result the TBS data
75  */
76  std::vector<byte> tbs_data() const;
77 
78  virtual ~EAC1_1_ADO() {}
79  private:
80  ASN1_Car m_car;
81  EAC1_1_Req m_req;
82 
83  void force_decode();
84  static void decode_info(DataSource& source,
85  std::vector<byte> & res_tbs_bits,
86  ECDSA_Signature & res_sig);
87  };
88 
89 inline bool operator!=(EAC1_1_ADO const& lhs, EAC1_1_ADO const& rhs)
90  {
91  return (!(lhs == rhs));
92  }
93 
94 }
95 
96 #endif
97 
98 
bool operator!=(const OctetString &s1, const OctetString &s2)
Definition: symkey.cpp:105
virtual ~EAC1_1_ADO()
Definition: cvc_ado.h:78
bool operator==(const OctetString &s1, const OctetString &s2)
Definition: symkey.cpp:97
X509_Encoding
Definition: x509_key.h:21
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
Definition: pem.cpp:19