-
Notifications
You must be signed in to change notification settings - Fork 93
Changes to verify MR enclave value in client side #658
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,20 +13,30 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
#include <string> | ||
#include <stdio.h> | ||
#include <iostream> | ||
#include <string.h> | ||
#include <string> | ||
|
||
#include <sgx_utils.h> | ||
#include <sgx_quote.h> | ||
|
||
#include "ias_attestation_util.h" | ||
#include "verify-report.h" | ||
#include "tcf_error.h" | ||
#include "parson.h" | ||
#include "jsonvalue.h" | ||
#include "types.h" | ||
|
||
bool verify_ias_report_signature(const std::string& signing_cert_pem, | ||
const std::string& ias_report, | ||
const std::string& ias_signature) { | ||
const std::string& ias_report, | ||
const std::string& ias_signature) { | ||
/* Verify IAS report signature | ||
* @param signing_cert_pem signing certificate | ||
* @param ias_report attestion report | ||
* @param ias_signature attestation report signature | ||
* Returns true if signature verification success | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change Return to @return |
||
* otherwise false | ||
*/ | ||
|
||
// Parse JSON serialized IAS report | ||
JsonValue report_parsed(json_parse_string(ias_report.c_str())); | ||
|
@@ -54,3 +64,30 @@ bool verify_quote(const std::string& ias_report, int group_out_of_date_is_ok) { | |
return quote_status; | ||
} | ||
|
||
bool verify_mr_enclave_value(const std::string& enclave_quote_body, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add function comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
const std::string& mr_enclave) { | ||
/* Verify MR enclave in the attestation | ||
* report and compare with the value passed | ||
* @param enclave_quote_body Enclave quote body | ||
* @param mr_enclave MR enclave value in hex format | ||
* Return true if comparision matches otherwise false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change Return to @return |
||
**/ | ||
if (mr_enclave.size() != 0) { | ||
/* Extract ReportData and MR_ENCLAVE from isvEnclaveQuoteBody | ||
present in Verification Report */ | ||
ByteArray quote_bytes = Base64EncodedStringToByteArray( | ||
enclave_quote_body.c_str()); | ||
sgx_quote_t* quote_body = reinterpret_cast<sgx_quote_t*>( | ||
quote_bytes.data()); | ||
sgx_report_body_t* report_body = "e_body->report_body; | ||
sgx_measurement_t mr_enclave_from_report = *(&report_body->mr_enclave); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue with above approach is it brings SGX SDK dependency on common/cpp module. So we need to install SGX SDK in client Dockerfile ? All this is done just to extract the mrencalve value from quote. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to do mrenclave verification at python layer either using
or
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are using python client for doing to MR enclave check and we are depend on C++ sgx sdk. Is there problem if we bring SGX sdk dependency in common/cpp? Anyway we are using sgx sdk for verifying signature and quote verification. Porting C++ structure to python is not right thing to do. It may lead to inconsistencies. I am not clear on option 2. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of design goals of Avalon is to hide SGX complexities from Avalon clients. If we make Avalon clients install SGX SDK we are moving away from that goal. Sawtooth PoET for example solves this by doing AVR verification at Python layer and it uses the python struct. Another option is used a fixed offset in AVR quote (based on IAS attestation API spec) |
||
ByteArray mr_enclave_bytes = HexEncodedStringToByteArray(mr_enclave); | ||
if (memcmp(mr_enclave_from_report.m, mr_enclave_bytes.data(), | ||
SGX_HASH_SIZE) == 0) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,9 @@ FROM ubuntu:bionic as common_cpp_image | |
RUN apt-get update \ | ||
&& apt-get install -y -q \ | ||
pkg-config \ | ||
wget \ | ||
cmake \ | ||
libprotobuf-dev \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We dont need protobuf. please remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is required otherwise below dpkg complain while installing packages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
make | ||
|
||
|
||
|
@@ -112,6 +114,27 @@ COPY --from=openssl_image /usr/local/bin /usr/local/bin | |
COPY --from=openssl_image /usr/local/include /usr/local/include | ||
COPY --from=openssl_image /usr/local/lib /usr/local/lib | ||
|
||
# Intel SGX common library and SDK are installed in /opt/intel directory. | ||
# Installation of Intel SGX libsgx-common packages requires | ||
# /etc/init directory. In the Docker image this directory doesn't exist. | ||
# Hence creating /etc/init directory. | ||
RUN mkdir -p /opt/intel \ | ||
&& mkdir -p /etc/init | ||
WORKDIR /opt/intel | ||
|
||
# Install Intel SGX common library | ||
RUN wget https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu18.04-server/libsgx-enclave-common_2.7.101.3-bionic1_amd64.deb \ | ||
&& dpkg -i libsgx-enclave-common_2.7.101.3-bionic1_amd64.deb | ||
|
||
# Install Intel SGX SDK | ||
RUN SGX_SDK_FILE=sgx_linux_x64_sdk_2.7.101.3.bin \ | ||
&& wget --no-check-certificate https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu18.04-server/$SGX_SDK_FILE \ | ||
&& echo "yes" | bash ./$SGX_SDK_FILE \ | ||
&& rm $SGX_SDK_FILE \ | ||
&& echo ". /opt/intel/sgxsdk/environment" >> /etc/environment | ||
|
||
ENV SGX_SDK=/opt/intel/sgxsdk | ||
|
||
RUN ldconfig \ | ||
&& ln -s /etc/ssl/certs/* /usr/local/ssl/certs/ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need SGX SDK dependency for untrusted part.? SGX SDK dependency previously was based on the condition
if(NOT UNTRUSTED_ONLY)
.