Skip to content

Commit

Permalink
Make SGX AGE test enclave reusable
Browse files Browse the repository at this point in the history
The entry points into the SgxAgeRemoteAssertionGeneratorTestEnclave are
applicable to any SGX assertion generator. Rename the class to
SgxRemoteAssertionGeneratorTestEnclave and set the type of assertion
generator in enclave initialization routine. This way, the enclave may
be used for different assertion generators beyond the AGE one.

PiperOrigin-RevId: 288501012
Change-Id: I77822a70d4f7918c9e60674126d69d02c7dc10a3
  • Loading branch information
sethmoo committed Jan 7, 2020
1 parent 25f4f06 commit 6f809ed
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 141 deletions.
24 changes: 12 additions & 12 deletions asylo/identity/attestation/sgx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ cc_proto_library(
)

proto_library(
name = "sgx_age_remote_assertion_generator_test_enclave_proto",
srcs = ["sgx_age_remote_assertion_generator_test_enclave.proto"],
name = "sgx_remote_assertion_generator_test_enclave_proto",
srcs = ["sgx_remote_assertion_generator_test_enclave.proto"],
deps = [
"//asylo:enclave_proto",
"//asylo/crypto:certificate_proto",
Expand All @@ -45,8 +45,8 @@ proto_library(
)

cc_proto_library(
name = "sgx_age_remote_assertion_generator_test_enclave_cc_proto",
deps = ["sgx_age_remote_assertion_generator_test_enclave_proto"],
name = "sgx_remote_assertion_generator_test_enclave_cc_proto",
deps = ["sgx_remote_assertion_generator_test_enclave_proto"],
)

cc_library(
Expand Down Expand Up @@ -77,13 +77,13 @@ cc_library(
)

sgx_cc_unsigned_enclave(
name = "sgx_age_remote_assertion_generator_test_enclave_unsigned.so",
name = "sgx_remote_assertion_generator_test_enclave_unsigned.so",
testonly = 1,
srcs = ["sgx_age_remote_assertion_generator_test_enclave.cc"],
srcs = ["sgx_remote_assertion_generator_test_enclave.cc"],
copts = ASYLO_DEFAULT_COPTS,
deps = [
":sgx_age_remote_assertion_generator",
":sgx_age_remote_assertion_generator_test_enclave_cc_proto",
":sgx_remote_assertion_generator_test_enclave_cc_proto",
"//asylo:enclave_cc_proto",
"//asylo:enclave_runtime",
"//asylo/identity/sgx:sgx_identity_util",
Expand All @@ -92,10 +92,10 @@ sgx_cc_unsigned_enclave(
)

sgx_debug_sign_enclave(
name = "sgx_age_remote_assertion_generator_test_enclave.so",
name = "sgx_remote_assertion_generator_test_enclave.so",
testonly = 1,
config = "//asylo/grpc/util:grpc_enclave_config",
unsigned = "sgx_age_remote_assertion_generator_test_enclave_unsigned.so",
unsigned = "sgx_remote_assertion_generator_test_enclave_unsigned.so",
)

enclave_test(
Expand All @@ -108,16 +108,16 @@ enclave_test(
copts = ASYLO_DEFAULT_COPTS,
enclaves = {
"assertion_generator_enclave": "//asylo/identity/attestation/sgx/internal:remote_assertion_generator_enclave_no_flc.so",
"sgx_age_remote_assertion_generator_test_enclave": ":sgx_age_remote_assertion_generator_test_enclave.so",
"sgx_remote_assertion_generator_test_enclave": ":sgx_remote_assertion_generator_test_enclave.so",
},
test_args = [
"--assertion_generator_enclave_path='{assertion_generator_enclave}'",
"--generator_test_enclave_path='{sgx_age_remote_assertion_generator_test_enclave}'",
"--generator_test_enclave_path='{sgx_remote_assertion_generator_test_enclave}'",
],
deps = [
":sgx_age_remote_assertion_authority_config_cc_proto",
":sgx_age_remote_assertion_generator",
":sgx_age_remote_assertion_generator_test_enclave_cc_proto",
":sgx_remote_assertion_generator_test_enclave_cc_proto",
"//asylo:enclave_cc_proto",
"//asylo:enclave_client",
"//asylo/crypto:certificate_cc_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "asylo/enclave_manager.h"
#include "asylo/identity/attestation/sgx/internal/remote_assertion_generator_enclave.pb.h"
#include "asylo/identity/attestation/sgx/sgx_age_remote_assertion_authority_config.pb.h"
#include "asylo/identity/attestation/sgx/sgx_age_remote_assertion_generator_test_enclave.pb.h"
#include "asylo/identity/attestation/sgx/sgx_remote_assertion_generator_test_enclave.pb.h"
#include "asylo/identity/descriptions.h"
#include "asylo/identity/enclave_assertion_authority.h"
#include "asylo/identity/identity.pb.h"
Expand Down Expand Up @@ -195,6 +195,11 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
test_enclave_config_ = new EnclaveConfig;
*test_enclave_config_->add_enclave_assertion_authority_configs() =
GetSgxLocalAssertionAuthorityTestConfig();
SetSgxAgeRemoteAssertionDescription(
test_enclave_config_
->MutableExtension(
sgx::sgx_remote_assertion_generator_test_enclave_config)
->mutable_description());

// Create an EnclaveLoadConfig object.
EnclaveLoadConfig load_config;
Expand Down Expand Up @@ -246,14 +251,13 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
EnclaveOutput enclave_output;
*enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_sgx_self_identity_input() = sgx::SgxSelfIdentityInput();

ASYLO_RETURN_IF_ERROR(
test_enclave_client_->EnterAndRun(enclave_input, &enclave_output));
return enclave_output
.GetExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_output)
.GetExtension(sgx::sgx_remote_assertion_generator_test_enclave_output)
.sgx_self_identity_output()
.identity();
}
Expand All @@ -264,7 +268,7 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
EnclaveOutput enclave_output;
*enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_reset_generator_input() = sgx::ResetGeneratorInput();

return test_enclave_client_->EnterAndRun(enclave_input, &enclave_output);
Expand All @@ -276,14 +280,13 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
EnclaveOutput enclave_output;
*enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_is_initialized_input() = sgx::IsInitializedInput();

ASYLO_RETURN_IF_ERROR(
test_enclave_client_->EnterAndRun(enclave_input, &enclave_output));
return enclave_output
.GetExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_output)
.GetExtension(sgx::sgx_remote_assertion_generator_test_enclave_output)
.is_initialized_output()
.is_initialized();
}
Expand All @@ -294,7 +297,7 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
EnclaveOutput enclave_output;
enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_initialize_input()
->set_config(config);

Expand All @@ -307,14 +310,13 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
EnclaveOutput enclave_output;
*enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_create_assertion_offer_input() =
sgx::CreateAssertionOfferInput::default_instance();
ASYLO_RETURN_IF_ERROR(
test_enclave_client_->EnterAndRun(enclave_input, &enclave_output));
return enclave_output
.GetExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_output)
.GetExtension(sgx::sgx_remote_assertion_generator_test_enclave_output)
.create_assertion_offer_output()
.offer();
}
Expand All @@ -326,14 +328,13 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
sgx::CanGenerateInput *can_generate_input =
enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_can_generate_input();
*can_generate_input->mutable_request() = request;
ASYLO_RETURN_IF_ERROR(
test_enclave_client_->EnterAndRun(enclave_input, &enclave_output));
return enclave_output
.GetExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_output)
.GetExtension(sgx::sgx_remote_assertion_generator_test_enclave_output)
.can_generate_output()
.can_generate();
}
Expand All @@ -347,15 +348,14 @@ class SgxAgeRemoteAssertionGeneratorTest : public ::testing::Test {
sgx::GenerateInput *generate_input =
enclave_input
.MutableExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_input)
sgx::sgx_remote_assertion_generator_test_enclave_input)
->mutable_generate_input();
generate_input->set_user_data(user_data);
*generate_input->mutable_request() = request;
ASYLO_RETURN_IF_ERROR(
test_enclave_client_->EnterAndRun(enclave_input, &enclave_output));
return enclave_output
.GetExtension(
sgx::sgx_age_remote_assertion_generator_test_enclave_output)
.GetExtension(sgx::sgx_remote_assertion_generator_test_enclave_output)
.generate_output()
.assertion();
}
Expand Down

This file was deleted.

Loading

0 comments on commit 6f809ed

Please sign in to comment.