3 #include "hpda/extractor/extractor_base.h" 
    4 #include "ypc/common/limits.h" 
    5 #include "ypc/core_t/analyzer/data_source.h" 
    6 #include "ypc/core_t/ecommon/package.h" 
    7 #include "ypc/corecommon/package.h" 
    8 #include "ypc/stbox/ebyte.h" 
    9 #include "ypc/stbox/stx_common.h" 
   10 #include "ypc/stbox/tsgx/channel/dh_session_initiator.h" 
   11 #include "ypc/stbox/tsgx/log.h" 
   12 #include <ff/util/ntobject.h> 
   15 template <
typename Crypto>
 
   20                        const stbox::bytes &private_key)
 
   23     crypto::hash_256(stbox::bytes(
"Fidelius"), m_actual_data_hash);
 
   24     m_data_reach_end = 
false;
 
   30     if (m_data_reach_end) {
 
   33     if (m_item_index + 1 < m_items.size()) {
 
   37       uint8_t *t_sealed_data;
 
   38       uint32_t t_sealed_data_len;
 
   39       auto ret = stbox::ocall_cast<uint32_t>(next_data_batch)(
 
   40           m_expect_data_hash.data(), m_expect_data_hash.size(), &t_sealed_data,
 
   43       if (ret != stbox::stx_status::success) {
 
   44         m_data_reach_end = 
true;
 
   48       stbox::bytes sealed_data(t_sealed_data_len);
 
   49       memcpy(sealed_data.data(), t_sealed_data, t_sealed_data_len);
 
   52       stbox::ocall_cast<void>(free_data_batch)(t_sealed_data);
 
   56       ret = crypto::decrypt_message_with_prefix(
 
   57           m_private_key, sealed_data, msg, ypc::utc::crypto_prefix_arbitrary);
 
   59         LOG(ERROR) << 
"decrypt_message_with_prefix fail: " 
   60                    << stbox::status_string(ret);
 
   61         m_data_reach_end = 
true;
 
   67         m_items = pkg.get<ntt::batch_data>();
 
   68         if (m_items.size() == 0) {
 
   69           m_data_reach_end = 
true;
 
   73         for (
auto b : m_items) {
 
   74           stbox::bytes k = m_actual_data_hash + b;
 
   75           crypto::hash_256(k, m_actual_data_hash);
 
   80       } 
catch (
const std::exception &e) {
 
   81         LOG(ERROR) << 
"make_package got: " << e.what();
 
   82         m_data_reach_end = 
true;
 
   89   virtual data_source_output_t output_value() {
 
   90     data_source_output_t ret;
 
   95   virtual const bytes &data_hash()
 const { 
return m_actual_data_hash; }
 
   96   const bytes &private_key()
 const { 
return m_private_key; }
 
   99   bytes m_actual_data_hash;
 
  100   std::vector<stbox::bytes> m_items;