Task #3192
Updated by Zhiyi Zhang over 9 years ago
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 Consumer(const algo::RsaPrivateKey& decryptKey); /** * @brief Get the data buffer published by producer */ Buffer consume(const Name& dataName); PUBLIC_WITH_TESTS_ELSE_PRIVATE: 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 authenticate the data */ Buffer bool decryptGroupDKey(const authenticate(const Data& DKeyData, algo::RsaPrivateKey decryptKey) const; data); /** * @brief Decrypt decrypt buffer by aes rsa decrypt key */ Buffer decryptGroupCKey(const Data& CKeyData, decryptBuffer(const uint8_t* cipherBuffer, const algo::RsaPrivateKey decryptKey) const; /** * @brief Decrypt decrypt buffer by aes decrypt key */ Buffer decryptGroupData(const Data& Data, decryptBuffer(const uint8_t* cipherBuffer, const 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& Face m_face; algo::RsaPrivateKey m_decryptKey; };