crypto sample: split into 4 functions
diff --git a/samplecode/crypto/app/app.c b/samplecode/crypto/app/app.c
index 0ed2c25..b1619a2 100644
--- a/samplecode/crypto/app/app.c
+++ b/samplecode/crypto/app/app.c
@@ -28,6 +28,11 @@
 #include "Enclave_u.h"
 
 
+int sha_256();
+int aes_gcm_128();
+int aes_cmac();
+int rsa();
+
 sgx_enclave_id_t global_eid = 0;
 
 typedef struct _sgx_errlist_t {
@@ -154,10 +159,6 @@
 /* Application entry */
 int SGX_CDECL main(int argc, char *argv[])
 {
-    sgx_status_t sgx_ret = SGX_SUCCESS;
-    sgx_status_t enclave_ret = SGX_SUCCESS;
-    uint32_t sealed_log_size = 1024;
-    uint8_t sealed_log[1024] = {0};
 
     (void)(argc);
     (void)(argv);
@@ -169,6 +170,21 @@
         return -1;
     }
 
+    if( sha_256()==-1){ return -1;};
+
+    if(aes_gcm_128()==-1){return -1;};
+
+    if(aes_cmac()==-1){return -1;}
+
+    if(rsa()==-1){return -1;}
+
+    /* Destroy the enclave */
+    sgx_destroy_enclave(global_eid);
+
+    return 0;
+}
+
+int sha_256(){
     // SHA-256 test case comes from
     // https://tools.ietf.org/html/rfc4634
     // TEST1
@@ -177,6 +193,9 @@
     size_t len = strlen(str);
     uint8_t * output_hash = (uint8_t *) malloc (32 + 1);
 
+    sgx_status_t enclave_ret = SGX_SUCCESS;
+    sgx_status_t sgx_ret = SGX_SUCCESS;
+
     printf("[+] sha256 input string is %s\n", str);
     printf("[+] Expected SHA256 hash: %s\n",
            "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
@@ -205,7 +224,9 @@
     }
     printf("\n");
     printf("[+] calc_sha256 success ...\n");
+}
 
+int aes_gcm_128(){
     // AES-GCM-128 test case comes from
     // http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf
     // Test case 2
@@ -215,7 +236,10 @@
     uint8_t aes_gcm_key[16] = {0};
     uint8_t aes_gcm_iv[12] = {0};
     uint8_t aes_gcm_ciphertext[16] = {0};
+
     uint8_t aes_gcm_mac[16] = {0};
+    sgx_status_t enclave_ret = SGX_SUCCESS;
+    sgx_status_t sgx_ret = SGX_SUCCESS;
 
     printf("[+] aes-gcm-128 args prepared!\n");
     printf("[+] aes-gcm-128 expected ciphertext: %s\n",
@@ -242,6 +266,7 @@
     }
 
     printf("[+] aes-gcm-128 ciphertext is: ");
+    int i;
     for(i = 0; i < 16; i ++) {
         printf("%02x", aes_gcm_ciphertext[i]);
     }
@@ -286,7 +311,10 @@
     printf("\n");
 
     printf("[+] aes-gcm-128 decrypt complete \n");
+}
 
+
+int aes_cmac(){
     // AES-CMAC test case comes from
     // https://tools.ietf.org/html/rfc4493
     // Example 3
@@ -295,6 +323,9 @@
     printf("[+] aes-cmac expected digest: %s\n",
            "51f0bebf7e3b9d92fc49741779363cfe");
 
+    sgx_status_t enclave_ret = SGX_SUCCESS;
+    sgx_status_t sgx_ret = SGX_SUCCESS;
+
     uint8_t cmac_key[] = {
 		0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
         0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
@@ -330,11 +361,18 @@
     }
 
     printf("[+] aes-cmac result is: ");
+    int i;
     for(i = 0; i < 16; i ++){
         printf("%02x", cmac_result[i]);
     }
     printf("\n");
 
+}
+
+int rsa(){
+    sgx_status_t enclave_ret = SGX_SUCCESS;
+    sgx_status_t sgx_ret = SGX_SUCCESS;
+
     uint8_t rsa_msg[] = {
         0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
         0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
@@ -368,9 +406,4 @@
         return -1;
     }
     printf("rsa_key success. \n");
-
-    /* Destroy the enclave */
-    sgx_destroy_enclave(global_eid);
-
-    return 0;
 }