Skip to content

Commit

Permalink
use shim apis + sanity checks
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Vavala <bruno.vavala@intel.com>
  • Loading branch information
bvavala committed Jul 17, 2020
1 parent 2c7edd9 commit 4360807
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions ecc_enclave/enclave/enclave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ int ecall_cc_invoke(const char* encoded_args,
ctx.u_shim_ctx = u_shim_ctx;
ctx.encoded_args = encoded_args;

{
int max_length = 1024;
char channel_id[max_length];
char mspid[max_length];
get_channel_id(channel_id, max_length, &ctx);
get_msp_id(mspid, max_length, &ctx);
LOG_DEBUG("(unverified) channel id: %s\n", channel_id);
LOG_DEBUG("(unverified) msp id: %s\n", mspid);
}

// call chaincode invoke logic: creates output and response
// output, response <- F(args, input)
int ret;
Expand Down
14 changes: 12 additions & 2 deletions ecc_enclave/enclave/shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,22 @@ void get_creator_name(

void get_channel_id(char* channel_id, uint32_t max_channel_id_len, shim_ctx_ptr_t ctx)
{
ocall_get_channel_id(channel_id, max_channel_id_len, ctx->u_shim_ctx);
if (max_channel_id_len > 0)
{
channel_id[0] = '\0';
ocall_get_channel_id(channel_id, max_channel_id_len, ctx->u_shim_ctx);
channel_id[max_channel_id_len - 1] = '\0';
}
}

void get_msp_id(char* msp_id, uint32_t max_msp_id_len, shim_ctx_ptr_t ctx)
{
ocall_get_msp_id(msp_id, max_msp_id_len, ctx->u_shim_ctx);
if (max_msp_id_len > 0)
{
msp_id[0] = '\0';
ocall_get_msp_id(msp_id, max_msp_id_len, ctx->u_shim_ctx);
msp_id[max_msp_id_len - 1] = '\0';
}
}

void get_state(
Expand Down

0 comments on commit 4360807

Please sign in to comment.