sgx_rijndael128GCM_encrypt does not encrypt

Viewed 25

I am trying to use sgx_rijndael128GCM_encrypt to encrypt some data but the buffer remains empaty. I dont know why or what i am doing wrong. This is the code I am using, if there is any errors please mention them. As far as I think, there will be some changes in line 2, where i am calculating aesgcm_len or maybe i am using the wrong key. But if the key is wrong then it should show some errors. Please guide me. Thank you in advance.

               uint8_t *plaintext = (uint8_t *)item->certificate;
           size_t aesgcm_len =4 + ((((double)sizee)/16))*16 +16;
           item->encrypteee = (uint8_t*)malloc(aesgcm_len);
           sgx_aes_gcm_128bit_tag_t mac;
           const sgx_aes_gcm_128bit_key_t aes_key= { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
           //sgx_read_rand((unsigned char *) &aes_key, sizeof(sgx_aes_gcm_128bit_key_t));
           uint8_t iv[12];
           memset(iv,0,12);
           ((int*)item->encrypteee)[0]=sizee;
           
           sgx_status_t res;
            res= sgx_rijndael128GCM_encrypt(&aes_key, plaintext, sizee, (uint8_t*)item->encrypteee+4,iv,12 ,NULL,0,&mac);
            if (res != SGX_SUCCESS) {
                //printf("encryption error");
                free(wallet);
                return ERR_FAIL_UNSEAL;
            }
0 Answers
Related