Skip to content

Commit

Permalink
Update handling of empty format settings for SGX ECDSA evidence
Browse files Browse the repository at this point in the history
Signed-off-by: Shanwei Cen <[email protected]>
  • Loading branch information
shnwc committed Dec 14, 2020
1 parent 15113e0 commit 71ee700
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
8 changes: 6 additions & 2 deletions host/sgx/sgxquote.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ oe_result_t oe_sgx_qe_get_quote(
}
else // ECDSA
{
// For EPID, opt_params_size should be zero.
if (opt_params_size)
// For ECDSA, opt_params_size should be zero.
if (opt_params || opt_params_size)
OE_RAISE(OE_INVALID_PARAMETER);
}

Expand All @@ -734,6 +734,10 @@ oe_result_t oe_sgx_qe_get_quote(
}
else
{
// Only ECDSA is supported, opt_params_size should be zero.
if (opt_params || opt_params_size)
OE_RAISE(OE_INVALID_PARAMETER);

if (quote_size > OE_MAX_UINT32)
OE_RAISE(OE_INVALID_PARAMETER);

Expand Down
31 changes: 20 additions & 11 deletions samples/attestation/common/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,28 @@ int ecall_dispatcher::get_enclave_format_settings(
goto exit;
}

// Allocate memory on the host and copy the format settings over.
// TODO: the following code is not TEE-agnostic, as it assumes the
// enclave can directly write into host memory
*format_settings_buffer = (uint8_t*)oe_host_malloc(format_settings_size);
if (*format_settings_buffer == nullptr)
if (format_settings && format_settings_size)
{
ret = OE_OUT_OF_MEMORY;
TRACE_ENCLAVE("copying format_settings failed, out of memory");
goto exit;
// Allocate memory on the host and copy the format settings over.
// TODO: the following code is not TEE-agnostic, as it assumes the
// enclave can directly write into host memory
*format_settings_buffer =
(uint8_t*)oe_host_malloc(format_settings_size);
if (*format_settings_buffer == nullptr)
{
ret = OE_OUT_OF_MEMORY;
TRACE_ENCLAVE("copying format_settings failed, out of memory");
goto exit;
}
memcpy(*format_settings_buffer, format_settings, format_settings_size);
*format_settings_buffer_size = format_settings_size;
oe_verifier_free_format_settings(format_settings);
}
else
{
*format_settings_buffer = nullptr;
*format_settings_buffer_size = 0;
}
memcpy(*format_settings_buffer, format_settings, format_settings_size);
*format_settings_buffer_size = format_settings_size;
oe_verifier_free_format_settings(format_settings);
ret = 0;

exit:
Expand Down

0 comments on commit 71ee700

Please sign in to comment.