Botan
1.11.15
|
00001 /* 00002 * EAC1_1 CVC ADO 00003 * (C) 2008 Falko Strenzke 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_EAC_CVC_ADO_H__ 00009 #define BOTAN_EAC_CVC_ADO_H__ 00010 00011 #include <botan/eac_obj.h> 00012 #include <botan/eac_asn_obj.h> 00013 #include <botan/cvc_req.h> 00014 #include <string> 00015 00016 namespace Botan { 00017 00018 /** 00019 * This class represents a TR03110 (EAC) v1.1 CVC ADO request 00020 */ 00021 00022 // CRTP continuation from EAC1_1_obj 00023 class BOTAN_DLL EAC1_1_ADO : public EAC1_1_obj<EAC1_1_ADO> 00024 { 00025 public: 00026 friend class EAC1_1_obj<EAC1_1_ADO>; 00027 00028 /** 00029 * Construct a CVC ADO request from a DER encoded CVC ADO request file. 00030 * @param str the path to the DER encoded file 00031 */ 00032 EAC1_1_ADO(const std::string& str); 00033 00034 /** 00035 * Construct a CVC ADO request from a data source 00036 * @param source the data source 00037 */ 00038 EAC1_1_ADO(DataSource& source); 00039 00040 /** 00041 * Create a signed CVC ADO request from to be signed (TBS) data 00042 * @param signer the signer used to sign the CVC ADO request 00043 * @param tbs_bits the TBS data to sign 00044 * @param rng a random number generator 00045 */ 00046 static std::vector<byte> make_signed( 00047 PK_Signer& signer, 00048 const std::vector<byte>& tbs_bits, 00049 RandomNumberGenerator& rng); 00050 00051 /** 00052 * Get the CAR of this CVC ADO request 00053 * @result the CAR of this CVC ADO request 00054 */ 00055 ASN1_Car get_car() const; 00056 00057 /** 00058 * Get the CVC request contained in this object. 00059 * @result the CVC request inside this CVC ADO request 00060 */ 00061 EAC1_1_Req get_request() const; 00062 00063 /** 00064 * Encode this object into a pipe. Only DER is supported. 00065 * @param out the pipe to encode this object into 00066 * @param encoding the encoding type to use, must be DER 00067 */ 00068 void encode(Pipe& out, X509_Encoding encoding) const; 00069 00070 bool operator==(EAC1_1_ADO const& rhs) const; 00071 00072 /** 00073 * Get the TBS data of this CVC ADO request. 00074 * @result the TBS data 00075 */ 00076 std::vector<byte> tbs_data() const; 00077 00078 virtual ~EAC1_1_ADO() {} 00079 private: 00080 ASN1_Car m_car; 00081 EAC1_1_Req m_req; 00082 00083 void force_decode(); 00084 static void decode_info(DataSource& source, 00085 std::vector<byte> & res_tbs_bits, 00086 ECDSA_Signature & res_sig); 00087 }; 00088 00089 inline bool operator!=(EAC1_1_ADO const& lhs, EAC1_1_ADO const& rhs) 00090 { 00091 return (!(lhs == rhs)); 00092 } 00093 00094 } 00095 00096 #endif 00097 00098