Skip to content

Commit a5010a3

Browse files
author
Junxian.Xiao
committed
integrity protection and nonce for TA secret interfaces
1 parent c848f9e commit a5010a3

18 files changed

+612
-484
lines changed

client/cpp_occlum/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Set the PCCS for UAL inside occlum image by environment variable
4545
export UA_ENV_PCCS_URL=https://<pccs-address>:8081/sgx/certification/v3/
4646
```
4747

48-
Finally, run aecs_client_get_secret application in occlum for test
48+
Finally, run aecs_client_cli application in occlum for test
4949

5050
```
5151
cd client/cpp_occlum

client/cpp_occlum/bom_aecs_client_gnu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ targets:
66
copy:
77
- from: ../build/out
88
files:
9-
- name: aecs_client_get_secret
9+
- name: aecs_client_cli
1010
- target: /opt/occlum/glibc/lib/
1111
copy:
1212
- files:

client/cpp_occlum/occlum_aecs_client_lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ target_link_libraries(
5858
add_dependencies(${AECS_CLIENT_LIB} yaml-cpp ${UAL_LIBS_NAME})
5959

6060
# Generate the test application
61-
set(APP aecs_client_get_secret)
61+
set(APP aecs_client_cli)
6262
file(GLOB APP_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
6363
add_executable(${APP} ${APP_SRCS})
6464
target_link_libraries(

client/cpp_occlum/occlum_aecs_client_lib/occlum_aecs_client_main.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ DEFINE_string(output, "", "output file to save secret when get/getpub");
4040
//=============================================================
4141
static int DoCreateSecret() {
4242
std::string aecs_ra_policy = "";
43+
std::string report_hex_user_data = "31323334";
4344
printf("[Create Secret]\n");
4445
printf(" AECS Server: %s\n", FLAGS_endpoint.c_str());
4546
printf(" Template File: %s\n", FLAGS_policy.c_str());
4647

4748
// Use the C-ABI interface to get secret public key
4849
int ret = aecs_client_create_ta_secret(
49-
FLAGS_endpoint.c_str(), aecs_ra_policy.c_str(), FLAGS_policy.c_str());
50+
FLAGS_endpoint.c_str(), aecs_ra_policy.c_str(), FLAGS_policy.c_str(),
51+
report_hex_user_data.c_str(), FLAGS_nonce.c_str());
5052
if (ret != 0) {
51-
printf("Fail to create secret: %d!\n", ret);
53+
printf("Fail to create secret: 0x%X!\n", ret);
5254
return ret;
5355
}
5456

@@ -57,15 +59,17 @@ static int DoCreateSecret() {
5759

5860
static int DoDestroySecret() {
5961
std::string aecs_ra_policy = "";
62+
std::string report_hex_user_data = "31323334";
6063
printf("[Destroy Secret]\n");
6164
printf(" AECS Server: %s\n", FLAGS_endpoint.c_str());
6265
printf(" Secret Name: %s\n", FLAGS_secret.c_str());
6366

6467
// Use the C-ABI interface to get secret public key
6568
int ret = aecs_client_destroy_ta_secret(
66-
FLAGS_endpoint.c_str(), aecs_ra_policy.c_str(), FLAGS_secret.c_str());
69+
FLAGS_endpoint.c_str(), aecs_ra_policy.c_str(), FLAGS_secret.c_str(),
70+
report_hex_user_data.c_str(), FLAGS_nonce.c_str());
6771
if (ret != 0) {
68-
printf("Fail to destroy secret: %d!\n", ret);
72+
printf("Fail to destroy secret: 0x%X!\n", ret);
6973
return ret;
7074
}
7175

@@ -75,6 +79,7 @@ static int DoDestroySecret() {
7579
static int DoGetSecret() {
7680
std::string aecs_ra_policy = "";
7781
std::string secret_policy = "{}";
82+
std::string report_hex_user_data = "31323334";
7883
printf("[Get secret]\n");
7984
printf(" AECS Server: %s\n", FLAGS_endpoint.c_str());
8085
printf(" Service Name: %s\n", FLAGS_action.c_str());
@@ -85,10 +90,10 @@ static int DoGetSecret() {
8590
// Use the C-ABI interface to get secret
8691
int ret = aecs_client_get_secret_file(
8792
FLAGS_endpoint.c_str(), aecs_ra_policy.c_str(), FLAGS_service.c_str(),
88-
FLAGS_secret.c_str(), secret_policy.data(), FLAGS_nonce.c_str(),
89-
FLAGS_output.c_str());
93+
FLAGS_secret.c_str(), secret_policy.data(), report_hex_user_data.data(),
94+
FLAGS_nonce.c_str(), FLAGS_output.c_str());
9095
if (ret != 0) {
91-
printf("Fail to get secret from aecs: %d!\n", ret);
96+
printf("Fail to get secret from aecs: 0x%X!\n", ret);
9297
return ret;
9398
}
9499

@@ -97,7 +102,7 @@ static int DoGetSecret() {
97102
using kubetee::utils::FsReadString;
98103
ret = FsReadString(FLAGS_output, &secret_str);
99104
if (ret != 0) {
100-
printf("Fail to read the secret file: %d\n", ret);
105+
printf("Fail to read the secret file: 0x%X\n", ret);
101106
return ret;
102107
} else {
103108
printf("[Secret] %s\n", secret_str.c_str());
@@ -122,7 +127,7 @@ static int DoGetSecretPublic() {
122127
FLAGS_secret.c_str(), secret_policy.data(), FLAGS_nonce.c_str(),
123128
FLAGS_output.c_str());
124129
if (ret != 0) {
125-
printf("Fail to get secret public key from aecs: %d!\n", ret);
130+
printf("Fail to get secret public key from aecs: 0x%X!\n", ret);
126131
return ret;
127132
}
128133

@@ -131,7 +136,7 @@ static int DoGetSecretPublic() {
131136
using kubetee::utils::FsReadString;
132137
ret = FsReadString(FLAGS_output, &secret_str);
133138
if (ret != 0) {
134-
printf("Fail to read the secret file: %d\n", ret);
139+
printf("Fail to read the secret file: 0x%X\n", ret);
135140
return ret;
136141
} else {
137142
printf("[Secret] %s\n", secret_str.c_str());
@@ -165,6 +170,6 @@ int main(int argc, char** argv) {
165170
ret = AECS_ERROR_PARAMETER_INVALID_ACTION;
166171
}
167172

168-
printf("Action done: %d\n", ret);
173+
printf("Action done: 0x%X\n", ret);
169174
return ret;
170175
}

0 commit comments

Comments
 (0)