@@ -40,15 +40,17 @@ DEFINE_string(output, "", "output file to save secret when get/getpub");
4040// =============================================================
4141static 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
5860static 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() {
7579static 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