YPC  0.2.0
keymgr_sgx_module.h
1 #pragma once
2 #include "ypc/core/byte.h"
3 #include "ypc/core/ref.h"
4 #include "ypc/stbox/ebyte.h"
5 #include "ypc/stbox/stx_status.h"
6 #include "ypc/stbox/tsgx/channel/dh_cdef.h"
7 #include "ypc/stbox/usgx/sgx_module.h"
8 #include "ypc/version.h"
9 #include <sgx_dh.h>
10 #include <sgx_eid.h>
11 #include <sgx_error.h>
12 
13 using stx_status = stbox::stx_status;
14 using bref = ypc::bref;
15 class keymgr_sgx_module : public stbox::sgx_module {
16 public:
17  explicit keymgr_sgx_module(const char *mod_path);
18  virtual ~keymgr_sgx_module() = default;
19 
21  ypc::version get_keymgr_version();
22 
23  uint32_t get_ecc_sealed_private_key_size();
24  uint32_t generate_ecc_key_pair(bref &public_key, bref &sealed_private_key);
25 
26  uint32_t sign_message(const uint8_t *sealed_private_key, uint32_t sealed_size,
27  const uint8_t *data, uint32_t data_size, bref &sig);
28 
29  uint32_t verify_signature(const uint8_t *data, uint32_t data_size,
30  const uint8_t *sig, uint32_t sig_size,
31  const uint8_t *public_key, uint32_t pkey_size);
32 
33  uint32_t encrypt_message(const uint8_t *public_key, uint32_t pkey_size,
34  const uint8_t *data, uint32_t data_size,
35  ypc::bref &cipher);
36 
37  uint32_t decrypt_message(const uint8_t *sealed_private_key,
38  uint32_t sealed_size, const uint8_t *cipher,
39  uint32_t cipher_size, bref &data);
40 
41  uint32_t session_request(sgx_dh_msg1_t *dh_msg1, uint32_t *session_id);
42 
43  uint32_t exchange_report(sgx_dh_msg2_t *dh_msg2, sgx_dh_msg3_t *dh_msg3,
44  uint32_t session_id);
45  uint32_t generate_response(secure_message_t *req_message,
46  size_t req_message_size, size_t max_payload_size,
47  secure_message_t *resp_message,
48  size_t resp_message_size, uint32_t session_id);
49  uint32_t end_session(uint32_t session_id);
50 
51  uint32_t forward_private_key(const uint8_t *encrypted_private_key,
52  uint32_t cipher_size, const uint8_t *epublic_key,
53  uint32_t epkey_size, const uint8_t *ehash,
54  uint32_t ehash_size, const uint8_t *sig,
55  uint32_t sig_size);
56 
57  // uint32_t
58  // forward_extra_data_usage_license(const ypc::bytes &enclave_pkey,
59  // const ypc::bytes &data_hash,
60  // const ypc::bytes &data_usage_license);
61 
62  uint32_t set_access_control_policy(const ypc::bytes &policy);
63 
64  uint32_t create_report_for_pkey(const sgx_target_info_t *p_qe3_target,
65  const stbox::bytes &pkey,
66  sgx_report_t *p_report);
67 };
ypc::ref
Definition: ref.h:6
keymgr_sgx_module
Definition: keymgr_sgx_module.h:15
ypc::version
Definition: version.h:7
byte.h
ypc::utc::bytes< byte_t, ::ypc::utc::byte_encode::raw_bytes >