From c11313e25c077743ec9fb88d4463a18370dcb881 Mon Sep 17 00:00:00 2001
From: zgzxx <zhangguangzhi3@huawei.com>
Date: Thu, 11 Mar 2021 10:46:05 +0800
Subject: [PATCH 4/6] parse new error code and del redundant print

---
 inc/host_inc/status.h           | 2 +-
 src/host_src/enclave_internal.c | 2 +-
 src/host_src/sgx/sgx_enclave.c  | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/inc/host_inc/status.h b/inc/host_inc/status.h
index 84c092a..1d18d2e 100644
--- a/inc/host_inc/status.h
+++ b/inc/host_inc/status.h
@@ -56,7 +56,7 @@ typedef enum _enclave_result_t
     CC_ERROR_INVALID_ISVSVN,         /* The isv svn is greater than the enclave's isv svn */
     CC_ERROR_INVALID_KEYNAME,        /* The key name is an unsupported value */  
     CC_ERROR_AE_INVALID_EPIDBLOB,    /* Indicates epid blob verification error */
-    CC_ERROR_SERVICE_INVALID_PRIVILEGE,  /* Enclave has no privilege to get launch token */
+    CC_ERROR_SERVICE_INVALID_PRIVILEGE,  /* Enclave not authorized to run */
     CC_ERROR_EPID_MEMBER_REVOKED,        /* The EPID group membership is revoked */
     CC_ERROR_UPDATE_NEEDED,          /* SDK need to be update*/
     CC_ERROR_MC_NOT_FOUND,           /* The Monotonic Counter doesn't exist or has been invalided */
diff --git a/src/host_src/enclave_internal.c b/src/host_src/enclave_internal.c
index 9a172bd..962fc07 100644
--- a/src/host_src/enclave_internal.c
+++ b/src/host_src/enclave_internal.c
@@ -64,7 +64,7 @@ static err2str g_secgearerror [] =
     {CC_ERROR_INVALID_ISVSVN,             "The isv svn is greater than the enclave's isv svn."},
     {CC_ERROR_INVALID_KEYNAME,            "The key name is an unsupported value."},
     {CC_ERROR_AE_INVALID_EPIDBLOB,        "Indicates epid blob verification error."},
-    {CC_ERROR_SERVICE_INVALID_PRIVILEGE,  "Enclave has no privilege to get launch token."},
+    {CC_ERROR_SERVICE_INVALID_PRIVILEGE,  "Enclave not authorized to run."},
     {CC_ERROR_EPID_MEMBER_REVOKED,        "The EPID group membership is revoked."},
     {CC_ERROR_UPDATE_NEEDED,              "SDK need to be update."},
     {CC_ERROR_MC_NOT_FOUND,               "The Monotonic Counter doesn't exist or has been invalided."},
diff --git a/src/host_src/sgx/sgx_enclave.c b/src/host_src/sgx/sgx_enclave.c
index b37c748..a40c408 100644
--- a/src/host_src/sgx/sgx_enclave.c
+++ b/src/host_src/sgx/sgx_enclave.c
@@ -59,6 +59,8 @@ cc_enclave_result_t conversion_res_status(uint32_t enclave_res, enclave_type_ver
                 return CC_ERROR_OUT_OF_TCS;
             case SGX_ERROR_ENCLAVE_CRASHED:
                 return CC_ERROR_ENCLAVE_DEAD;
+            case SGX_ERROR_SERVICE_INVALID_PRIVILEGE:
+                return CC_ERROR_SERVICE_INVALID_PRIVILEGE;
             default:
                 return CC_ERROR_UNEXPECTED;
         }
@@ -131,7 +133,7 @@ cc_enclave_result_t _sgx_create(cc_enclave_t **enclave, const enclave_features_t
                     NULL, &(l_context->edi), NULL);
             if (sgx_res != SGX_SUCCESS) {
                 res = conversion_res_status(sgx_res, (*enclave)->type);
-                print_error_goto("Failed to create sgx enclave %s\n",cc_enclave_res2_str(res));
+                print_error_goto("Failed to create sgx enclave\n");
             }
             break;
         case 1:
-- 
2.27.0

