Commit cf2b30d8 authored by garciay's avatar garciay
Browse files

STF525: Doxygen help support

parent 06343993
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -270,19 +270,12 @@ namespace LibItsSecurity__Functions
    p__tag = OCTETSTRING(ec.tag().size(), ec.tag().data());
    loggers::get_instance().log_to_hexa("fx__encryptWithEciesNistp256WithSha256: p__tag: ", p__tag);

    // Encrypt symmetric key
    // Encrypt the symmetric key
    OCTETSTRING encSymKey = OCTETSTRING(ec.nonce().size(), ec.symmetric_encryption_key().data());
    loggers::get_instance().log_to_hexa("fx__encryptWithEciesNistp256WithSha256: p__encSymKey: ", encSymKey);







    // Create new instance of ECC
    // 1. Create new instance of ECC
    security_ecc ec_ecies(ec_elliptic_curves::nist_p_256);
    // Generate (Private,Public) keys
    // 2. Generate (Private,Public) keys
    ec_ecies.generate();
    // Generate ephemeral key and derive it
    std::vector<unsigned char> peer_public_key_x(static_cast<const unsigned char *>(p__peerPublicKeyX), p__peerPublicKeyX.lengthof() + static_cast<const unsigned char *>(p__peerPublicKeyX));
@@ -294,7 +287,7 @@ namespace LibItsSecurity__Functions
      loggers::get_instance().warning("fx__encryptWithEciesNistp256WithSha256: Failed to generate and derive sender's ephemeral key");
      return OCTETSTRING();
    }
    // Encrypt the symmetric encryption key using existing nonce and symmetric encryption key
    // 3. Encrypt the symmetric encryption key using existing nonce and symmetric encryption key
    std::vector<unsigned char> enc_eph_key;
    if (ec.encrypt(encryption_algotithm::aes_128_ccm, ec_ecies.ephemeral_key(), ec.nonce(), ec.symmetric_encryption_key(), enc_eph_key) == -1) {
      loggers::get_instance().warning("fx__encryptWithEciesNistp256WithSha256: Failed to encrypt message");
@@ -312,6 +305,8 @@ namespace LibItsSecurity__Functions
  }
  
  OCTETSTRING fx__decryptWithEciesNistp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__publicKeyX, const OCTETSTRING& p__publicKeyY, const OCTETSTRING& p__nonce, const OCTETSTRING& p__tag) {


	  OCTETSTRING os;

    os = OCTETSTRING();

ccsrc/Framework/TLayer.hh

deleted100644 → 0
+0 −35
Original line number Diff line number Diff line
/*!
 * \file      t_layer.hh
 * \brief     Header file for ITS abstract protocol layer definition.
 * \author    ETSI STF525
 * \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 "Layer.hh"

template <typename TPort> class TLayer : public Layer {
  typedef std::vector<TPort*> TPortList;
  typedef typename std::vector<TPort*>::iterator TPortListIterator;

  TPortList upperPorts;

public:
  explicit TLayer() : Layer(), upperPorts() { };
  explicit TLayer(const std::string& p_type) : Layer(p_type), upperPorts() { };
  void addUpperPort(TPort * p_port) { upperPorts.push_back(p_port); };
  void removeUpperPort(TPort*);

protected:
  template <typename TMessage>
  inline void toAllUpperPorts(const TMessage& m, const Params& param) {
    for(TPortListIterator it=upperPorts.begin(); it<upperPorts.end(); ++it){
      (*it)->receiveMsg(m, param);
    }
  }
}; // End of class TLayer
+36 −38
Original line number Diff line number Diff line
@@ -23,12 +23,12 @@ class CHARSTRING; //! Forward declaration of TITAN class
class INTEGER;     //! Forward declaration of TITAN class

/*!
 * \class Layer
 * \class layer
 * \brief  This class provides basic description of an ITS protocol layer
 */
class Layer {
  std::vector<Layer*> upperLayers; //! List of the upper protocol layers
  std::vector<Layer*> lowerLayers; //! List of the lower protocol layers
class layer {
  std::vector<layer*> upperLayers; //! List of the upper protocol layers
  std::vector<layer*> lowerLayers; //! List of the lower protocol layers

protected:
  std::string type; //! Type description, it indicates the protocol type (e.g. CAM, DENM, GN, ETH, PCAP...)
@@ -36,47 +36,45 @@ protected:
public: //! \publicsection
  /*!
   * \brief Default constructor
   *        Create a new instance of the Layer class
   * \todo Remove logs
   *        Create a new instance of the layer class
   */
  explicit Layer() : upperLayers(), lowerLayers(), type(std::string("")) { };
  explicit layer() : upperLayers(), lowerLayers(), type(std::string("")) { };

  /*!
   * \brief Specialized constructor
   *        Create a new instance of the Layer class with its type description
   * \remark This constructor is called by the Layer factory
   *        Create a new instance of the layer class with its type description
   * \param[in] p_type The port type name (e.g. GN for the GeoNetworking layer)
   * \remark This constructor is called by the layer factory
   * \see layer_factory
   * \todo Remove logs
   */
  explicit Layer(const std::string& p_type) : upperLayers(), lowerLayers(), type(std::string(p_type.begin(), p_type.end())) { };
  explicit layer(const std::string& p_type) : upperLayers(), lowerLayers(), type(std::string(p_type.begin(), p_type.end())) { };

  /*!
   * \brief Default destructor
   * \todo Remove logs
   */
  virtual ~Layer() {
  virtual ~layer() {
    // Double linked list, only remove layers in lowerLayers from the lowest one
    std::for_each(lowerLayers.rbegin(), lowerLayers.rend(), [](Layer* it) { delete it; } );
    std::for_each(lowerLayers.rbegin(), lowerLayers.rend(), [](layer* it) { delete it; } );
    lowerLayers.clear();
    upperLayers.clear();
  };

  /*!
   * \fn void deleteLayer();
   * \fn void delete_layer();
   * \brief Delete this layer
   * \todo To be done
   * \todo To be implemented
   */
  void deleteLayer() { };
  void delete_layer() { };

public: //! \publicsection
  /*!
   * \inline
   * \fn void addUpperLayer(Layer* p_layer);
   * \fn void add_upper_layer(layer* p_layer);
   * \brief Add a new layer in the list of the upper layer
   * \param[in] p_layer The layer protocol to be removed
   * \todo Remove logs
   */
  inline void addUpperLayer(Layer* p_layer) { 
  inline void add_upper_layer(layer* p_layer) {
    if (p_layer != NULL) {
      upperLayers.push_back(p_layer);
      p_layer->lowerLayers.push_back(this);
@@ -84,34 +82,34 @@ public: //! \publicsection
  };

  /*!
   * \fn void removeUpperLayer(Layer* p_layer);
   * \fn void remove_upper_layer(layer* p_layer);
   * \brief Remove the specified upper layer protocol from the list of the upper layer
   * \param[in] p_layer The layer protocol to be removed
   * \todo To be implemented
   */
  void removeUpperLayer(Layer* p_layer) {  };
  void remove_upper_layer(layer* p_layer) {  };

  /*!
   * \virtual
   * \fn void sendData(OCTETSTRING& data, Params& params);
   * \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
   * \todo Remove the logs
   * \virtual
   */
  virtual void sendData(OCTETSTRING& p_data, Params& p_params) { };
  virtual void send_data(OCTETSTRING& p_data, Params& p_params) { };

  /*!
   * \virtual
   * \fn void receiveData(OCTETSTRING& data, Params& params);
   * \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
   * \todo Remove the logs
   * \virtual
   */
  virtual void receiveData(OCTETSTRING& p_data, Params& p_params) { }
  virtual void receive_data(OCTETSTRING& p_data, Params& p_params) { }

  /*!
   * \inline
@@ -122,25 +120,25 @@ public: //! \publicsection
  inline const std::string& to_string() const { return type; };

protected: //! \protectedsection
  inline void toAllLayers(std::vector<Layer*>&layers, OCTETSTRING& data, Params& params) {
    for (std::vector<Layer*>::const_iterator it = layers.cbegin(); it != layers.cend(); ++it) {
      Layer * p = *it;
      p->receiveData(data, params); // FIXME BUG I 
  inline void to_all_layers(std::vector<layer*>&layers, OCTETSTRING& data, Params& params) {
    for (std::vector<layer*>::const_iterator it = layers.cbegin(); it != layers.cend(); ++it) {
      layer* p = *it;
      p->receive_data(data, params); // FIXME BUG I 
    } // End of 'for' statement
  };

  inline void receiveToAllLayers(OCTETSTRING& data, Params& params) {
    for (std::vector<Layer*>::const_iterator it = upperLayers.cbegin(); it != upperLayers.cend(); ++it) {
      Layer * p = *it;
      p->receiveData(data, params);
  inline void receive_to_all_layers(OCTETSTRING& data, Params& params) {
    for (std::vector<layer*>::const_iterator it = upperLayers.cbegin(); it != upperLayers.cend(); ++it) {
      layer* p = *it;
      p->receive_data(data, params);
    } // End of 'for' statement
  };

  inline void sendToAllLayers(OCTETSTRING& data, Params& params)  {
    for (std::vector<Layer*>::const_iterator it = lowerLayers.cbegin(); it != lowerLayers.cend(); ++it) {
      Layer * p = *it;
      p->sendData(data, params);
  inline void send_to_all_layers(OCTETSTRING& data, Params& params)  {
    for (std::vector<layer*>::const_iterator it = lowerLayers.cbegin(); it != lowerLayers.cend(); ++it) {
      layer* p = *it;
      p->send_data(data, params);
    } // End of 'for' statement
  };
}; // End of class Layer
}; // End of class layer
+8 −8
Original line number Diff line number Diff line
@@ -15,11 +15,11 @@
#include <vector>
#include <algorithm>

#include "Layer.hh"
#include "layer.hh"

/*!
 * \class layer_factory
 * \brief  This class provides a factory class to create Layer class instances
 * \brief  This class provides a factory class to create layer class instances
 * \abstract
 */
class layer_factory {
@@ -30,25 +30,25 @@ public: //! \publicsection
   */
  layer_factory() {};
  /*!
   * \fn Layer * create_layer(const std::string & type, const std::string & param);
   * \fn layer* create_layer(const std::string & type, const std::string & param);
   * \brief  Create the layers stack based on the provided layers stack description (cf. remark)
   * \param[in] p_type The provided layers stack description
   * \param[in] p_params Optional parameters
   * \return 0 on success, -1 otherwise
   * \remark The description below introduces layers stack in case of ITS project:
   *     CAM Layer
   *     CAM layer
   *       next_header     : btpA|btpB (overwrite BTP.type)
   *       header_type     : tsb|gbc
   *       header_sub_type : sh (single hop)
   *     DENM Layer
   *     DENM layer
   *       next_header     : btpA|btpB (overwrite BTP.type)
   *       header_type     : tsb|gbc
   *     BTP Layer
   *     BTP layer
   *       type            : btpA|btpB
   *       destination port: dst_port
   *       source port     : src_port
   *       device_mode     : Set to 1 if the layer shall encapsulate upper layer PDU
   *     GN Layer
   *     GN layer
   *       its_aid                : ITS AID as defined by ETSI TS 102 965 V1.2.1. Default: 141
   *       ll_address             : GeoNetworking address of the Test System
   *       latitude               : latitude of the Test System
@@ -109,6 +109,6 @@ NodeC.geoNetworkingPort.params := "GN(ll_address=70b3d5791b48,latitude=43551050,
   *         system.utPort.params := "UT_GN/UDP(dst_ip=192.168.1.1,dst_port=12346,src_ip=192.168.156.4,src_port=12345)/ETH(mac_src=026f8338c1e5,mac_dst=0A0027000011,eth_type=0800)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=and udp port 12346)"
   * \pure
   */
  virtual Layer* create_layer(const std::string & p_type, const std::string & p_params) = 0;
  virtual layer* create_layer(const std::string & p_type, const std::string & p_params) = 0;
}; // End of class layer_factory
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ private: //! \privatesection
  typedef std::map<std::string, layer_factory*> LayerFactoryMap;

  static layer_stack_builder * _instance;                        //! Smart pointer to the unique instance of the logger framework
  std::map<std::string, layer_factory*> _layer_factories; //! The list of the registered \see TLayer factories
  std::map<std::string, layer_factory*> _layer_factories; //! The list of the registered \see t_layer factories

  /*!
   * \brief Default constructor
@@ -57,11 +57,11 @@ private: //! \privatesection

public: //! \publicsection
  /*!
   * \fn Layer* create_layer_stack(const char* p_layer_stack_description);
   * \fn layer* create_layer_stack(const char* p_layer_stack_description);
   * \brief Add a new layer factory
   * \param[in] p_layer_stack_description A textual description of the layer to create
   * \return The created layer object on success, nullptr otherwise
   */
  Layer* create_layer_stack(const char* p_layer_stack_description);
  layer* create_layer_stack(const char* p_layer_stack_description);
}; // End of class layer_stack_builder
Loading