2 #include "ypc/core_t/analyzer/interface/keymgr_interface.h"
3 #include "ypc/core_t/analyzer/internal/data_streams/multi_data_stream.h"
4 #include "ypc/core_t/analyzer/internal/data_streams/noinput_data_stream.h"
5 #include "ypc/core_t/analyzer/internal/data_streams/raw_data_stream.h"
6 #include "ypc/core_t/analyzer/internal/data_streams/sealed_data_stream.h"
7 #include "ypc/core_t/analyzer/internal/keymgr_session.h"
8 #include "ypc/core_t/analyzer/raw_data_provider.h"
9 #include "ypc/core_t/analyzer/sealed_data_provider.h"
10 #include "ypc/core_t/analyzer/var/data_source_var.h"
11 #include "ypc/corecommon/nt_cols.h"
12 #include "ypc/corecommon/package.h"
13 #include "ypc/stbox/ebyte.h"
14 #include "ypc/stbox/stx_status.h"
21 template <
typename Crypto>
25 uint32_t init_data_source(
const uint8_t *data_source_info, uint32_t len) {
29 return stbox::stx_status::success;
31 uint32_t check_actual_data_hash() {
32 auto p = m_datasource.get();
33 if (p->data_hash() != p->expect_data_hash()) {
34 LOG(ERROR) <<
"expect " << p->expect_data_hash() <<
", got "
36 return stbox::stx_status::data_hash_not_same_as_expect;
38 return stbox::stx_status::success;
42 template <
typename Crypto>
46 uint32_t check_actual_data_hash() {
return stbox::stx_status::success; }
49 template <
typename Crypto>
57 uint32_t init_data_source(
const uint8_t *data_source_info, uint32_t len) {
60 ntt::sealed_data_info_t>::type>::from_bytes(data_source_info, len);
61 auto ret = keymgr_session::init_keymgr_session();
63 LOG(ERROR) <<
"init_keymgr_session failed: " << stbox::status_string(ret);
66 stbox::bytes private_key, dian_pkey;
67 ret = keymgr_interface_t::request_private_key_for_public_key(
68 pkg.get<ntt::pkey>(), private_key, dian_pkey);
70 LOG(ERROR) <<
"request_private_key_for_public_key failed: "
71 << stbox::status_string(ret);
75 m_ds_use_pkey = pkg.get<ntt::pkey>() + pkg.get<ntt::data_hash>();
77 pkg.get<ntt::data_hash>(), private_key));
78 return stbox::stx_status::success;
81 uint32_t check_actual_data_hash() {
82 auto p = m_datasource.get();
83 if (p->data_hash() != p->expect_data_hash()) {
84 LOG(ERROR) <<
"expect " << p->expect_data_hash() <<
", got "
86 return stbox::stx_status::data_hash_not_same_as_expect;
88 return stbox::stx_status::success;
92 template <
typename Crypto>
100 uint32_t init_data_source(
const uint8_t *data_source_info, uint32_t len) {
103 ntt::multi_sealed_data_info_t>::type>::from_bytes(data_source_info,
105 auto ret = keymgr_session::init_keymgr_session();
107 LOG(ERROR) <<
"init_keymgr_session failed: " << stbox::status_string(ret);
110 auto infos = pkg.get<ntt::sealed_data_info_vector>();
111 for (
auto sdi : infos) {
112 if (sdi.get<ntt::pkey>().size() != 0) {
113 stbox::bytes private_key, dian_pkey;
114 ret = keymgr_interface_t::request_private_key_for_public_key(
115 sdi.get<ntt::pkey>(), private_key, dian_pkey);
116 auto hash = sdi.get<ntt::data_hash>();
118 LOG(ERROR) <<
"request_private_key_for_public_key for data hash "
119 << hash <<
" failed: " << stbox::status_string(ret);
122 m_ds_use_pkey.push_back(sdi.get<ntt::pkey>() +
123 sdi.get<ntt::data_hash>());
124 m_datasource.push_back(std::shared_ptr<data_source_with_dhash>(
128 m_datasource.push_back(std::shared_ptr<data_source_with_dhash>(
132 return stbox::stx_status::success;
135 uint32_t check_actual_data_hash() {
136 for (
auto ds : m_datasource) {
137 if (ds->data_hash() != ds->expect_data_hash()) {
138 LOG(ERROR) <<
"expect " << ds->expect_data_hash() <<
", got "
140 return stbox::stx_status::data_hash_not_same_as_expect;
143 return stbox::stx_status::success;