/*! * \file pki_layer.hh * \brief Header file for ITS HTTP protocol layer. * \author ETSI STF549 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include #include "t_layer.hh" #include "etsi_ts102941_types_enrolment_inner_request.hh" #include "etsi_ts102941_types_enrolment_inner_response.hh" #include "etsi_ts103097_data_codec.hh" namespace LibItsPki__TestSystem { class PkiPort; //! Forward declaration of TITAN class } namespace LibItsPki__TypesAndValues { class AcSetSecurityData; //! Forward declaration of TITAN class } class OCTETSTRING; //! Forward declaration of TITAN class /*! * \class pki_layer * \brief This class provides a factory class to create an tcp_layer class instance */ class pki_layer : public t_layer { params _params; etsi_ts102941_types_enrolment_inner_request _etsi_ts102941_types_enrolment_inner_request; etsi_ts102941_types_enrolment_inner_response _etsi_ts102941_types_enrolment_inner_response; etsi_ts103097_data_codec _codec; std::unique_ptr _ac_set_security_data; public: //! \publicsection /*! * \brief Specialised constructor * Create a new instance of the pki_layer class * \param[in] p_type \todo * \param[in] p_param \todo */ pki_layer() : t_layer(), _params(), _etsi_ts102941_types_enrolment_inner_request(), _etsi_ts102941_types_enrolment_inner_response(), _codec(), _ac_set_security_data(nullptr) { }; /*! * \brief Specialised constructor * Create a new instance of the pki_layer class * \param[in] p_type \todo * \param[in] p_param \todo */ pki_layer(const std::string& p_type, const std::string& p_param); /*! * \brief Default destructor */ virtual ~pki_layer() { }; /*! * \fn void sendMsg(const EtsiTs102941TypesEnrolment::InnerEcRequest& p_inner_ec_request, params& p_param); * \brief Send HTTP message to the lower layers * \param[in] p_inner_ec_request The InnerEcRequest message to be sent * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters */ void sendMsg(const EtsiTs102941TypesEnrolment::InnerEcRequest& p_inner_ec_request, params& p_param); /*! * \fn void sendMsg(const EtsiTs102941TypesEnrolment::InnerEcResponse& p_inner_ec_request, params& p_param); * \brief Send HTTP message to the lower layers * \param[in] p_inner_ec_request The InnerEcResponse message to be sent * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters */ void sendMsg(const EtsiTs102941TypesEnrolment::InnerEcResponse& p_inner_ec_request, params& p_param); /*! * \virtual * \fn void send_data(OCTETSTRING& data, params& params); * \brief Send bytes formated data to the lower layers * \param[in] p_data The data to be sent * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters */ virtual void send_data(OCTETSTRING& data, params& params); /*! * \virtual * \fn void receive_data(OCTETSTRING& data, params& params); * \brief Receive bytes formated data from the lower layers * \param[in] p_data The bytes formated data received * \param[in] p_params Some lower layers parameters values when data was received */ virtual void receive_data(OCTETSTRING& data, params& info); private: void set_pki_keys(const LibItsPki__TypesAndValues::AcSetSecurityData& p_ac_set_security_data); int generate_inner_ec_request_signed_for_pop(const OCTETSTRING& p_inner_ec_request, OCTETSTRING& p_etsi_ts_102941_data); /*! * \fn int sign_and_encrypt_payload(const OCTETSTRING& p_data, OCTETSTRING& p_secured_data); * \brief Sign and encryptpayload * \param[in] p_data The bytes formated data received * \param[in] p_params Some lower layers parameters values when data was received */ int sign_and_encrypt_payload(const OCTETSTRING& p_data, OCTETSTRING& p_secured_data); }; // End of class pki_layer