Project

General

Profile

Actions

Task #3192

closed

Draft abstraction of GEP consumer

Added by Zhiyi Zhang over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
09/08/2015
Due date:
% Done:

100%

Estimated time:

Description

Consumer in GEP is mainly the group member that will consume the data produced by the producer.

The core process of data consuming is as below:

  1. get the data packet and validate the packet
  2. get the encrypted C-KEY packet and validate the packet
  3. get the encrypted D-KEY packet and validate the packet
  4. decrypt the D-KEY with the private key of consumer
  5. decrypt the C-KEY with the D-KEY
  6. decrypt the data with C-KEY

Here is the abstraction of consumer:

/**
 * @brief Consumer in group-based encryption protocol
 */
class Consumer
{
public:
  class Error : public std::runtime_error
  {
  public:
    explicit
    Error(const std::string& what)
      : std::runtime_error(what)
    {
    }
  };

public:
  Consumer(Face& face, const algo::RsaPrivateKey& decryptKey);

  /**
   * @brief Get the data buffer published by producer
   */
  Buffer
  consume(const Name& dataName);

PUBLIC_WITH_TESTS_ELSE_PRIVATE:
  /**
   * @brief authenticate the Data packet
   */
  bool
  authenticateData(const Data& Data);

  /**
   * @brief authenticate the C-KEY data
   */
  bool
  authenticateCKey(const Data& cKeyData);

  /**
   * @brief authenticate the D-KEY data
   */
  bool
  authenticateDKey(const Data& dKeyData);

  /**
   * @brief Get the data packet by sending interest
   */
  Data
  sendInterest(const Name& dataName);

  /**
   * @brief decrypt buffer by rsa decrypt key
   */
  Buffer
  decryptGroupDKey(const Data& DKeyData, algo::RsaPrivateKey decryptKey) const;

  /**
   * @brief Decrypt buffer by aes decrypt key
   */
  Buffer
  decryptGroupCKey(const Data& CKeyData, algo::RsaPrivateKey decryptKey) const;

  /**
   * @brief Decrypt buffer by aes decrypt key
   */
  Buffer
  decryptGroupData(const Data& Data, algo::AesDecryptKey decryptKey) const;

  /**
   * @brief Fetch the data packet replying @p interest
   */
  void
  getResultFromInterest(const Interest& interest);

  /**
   * @brief Callback method when there is a packet @p data replying @p interest
   */
  void
  onData(const Interest& interest, const Data& data);

  /**
   * @brief Callback method when there is no packet @p data replying @p interest within timeout
   */
  void
  onTimeout(const Interest& interest);

private:
  enum ResultSign {
    RESULT_DATA = 0,
    RESULT_TIMEOUT = 1,
    RESULT_DEFAULT = 255
  };

private:
  ResultSign m_sign;
  Data m_result;

  ValidatorConfig m_validator;
  Face& m_face;
  algo::RsaPrivateKey m_decryptKey;
};
Actions #1

Updated by Zhiyi Zhang over 8 years ago

  • Description updated (diff)
Actions #2

Updated by Yingdi Yu about 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF