|
@@ -84,62 +84,48 @@ uint32_t process_protobuf_dh_msg3(protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* op_ciphertext, uint8_t* op_encrypted_tag)
|
|
|
+uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* op_ciphertext, uint32_t* length)
|
|
|
{
|
|
|
- uint8_t hash[32]; uint32_t return_status;
|
|
|
- unsigned char key[16]; uint32_t count;
|
|
|
- for(count=0;count<16;count++)
|
|
|
- key[count]=global_session_info.active.AEK[count];
|
|
|
- return_status=generate_rsa_keypair_hash(hash);
|
|
|
- if(return_status!=0)
|
|
|
- return return_status;
|
|
|
-
|
|
|
- uint8_t ciphertext[32];
|
|
|
- uint8_t encryption_tag[16];
|
|
|
- int ciphertext_len=32;
|
|
|
+ uint8_t hash[32]={0x54,0x24,0x5d,0x63,0x5c,0x8f,0xec,0xcf,0x37,0xb9,0xcf,0x9e,0xb8,0xd3,0x22,0x04,0x57,0x5b,0xb2,0xfc,0xa6,0xd3,0x11,0xfb,0x87,0xb7,0x01,0x06,0x2f,0x18,0x25,0xc1};
|
|
|
+ uint32_t return_status;
|
|
|
+ unsigned char key[16]; uint32_t counter;
|
|
|
+ for(counter=0;counter<16;counter++)
|
|
|
+ key[counter]=global_session_info.active.AEK[counter];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ uint8_t tag[16];
|
|
|
+ int ciphertext_len;
|
|
|
uint8_t iv[12];
|
|
|
-
|
|
|
- memset(iv, 0, 12);
|
|
|
-
|
|
|
-
|
|
|
- return_status=aes_cipher(1, key, iv, hash, 32, op_ciphertext, &ciphertext_len, op_encrypted_tag);
|
|
|
-
|
|
|
+ memset(iv, 0, 12);
|
|
|
+ return_status=aes_cipher(1, key, iv, hash, 32, op_ciphertext, &ciphertext_len, tag);
|
|
|
+ if(return_status == 0)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
- for(count=0;count<32; count++)
|
|
|
- *(op_ciphertext+count) = ciphertext[count];
|
|
|
-
|
|
|
- for(count=0;count<16;count++)
|
|
|
- *(op_encrypted_tag+count) = encryption_tag[count];
|
|
|
+ for(counter=0;counter<12;counter++)
|
|
|
+ op_ciphertext[counter+ ciphertext_len] = iv[counter];
|
|
|
+ for(counter=0;counter<16;counter++)
|
|
|
+ op_ciphertext[counter+ ciphertext_len + 12] = tag[counter];
|
|
|
+ ciphertext_len+=28;
|
|
|
+ *length=ciphertext_len;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for(count=0;count<32;count++)
|
|
|
- {
|
|
|
- printf("0x%02x ", hash[count]);
|
|
|
- }
|
|
|
- printf("\n");
|
|
|
- fflush(stdout);
|
|
|
-*/ for(count=0;count<32;count++)
|
|
|
+ for(counter=0;counter<32;counter++)
|
|
|
{
|
|
|
- printf("0x%02x ", op_ciphertext[count]);
|
|
|
+ printf("0x%02x ", op_ciphertext[counter]);
|
|
|
}
|
|
|
+ printf("IV:\n");
|
|
|
+ for(counter=32;counter<44;counter++)
|
|
|
+ {
|
|
|
+ printf("0x%02x ", op_ciphertext[counter]);
|
|
|
+ }
|
|
|
+ printf("Tag:\n");
|
|
|
+
|
|
|
+ for(counter=44;counter<60;counter++)
|
|
|
+ {
|
|
|
+ printf("0x%02x ", op_ciphertext[counter]);
|
|
|
+ }
|
|
|
printf("\n");
|
|
|
fflush(stdout);
|
|
|
- for(count=0;count<16;count++)
|
|
|
- {
|
|
|
- printf("0x%02x ", op_encrypted_tag[count]);
|
|
|
- }
|
|
|
- printf("\n"); fflush(stdout);
|
|
|
-
|
|
|
- {
|
|
|
- printf("0x%02x ", op_ciphertext[count]);
|
|
|
- }
|
|
|
- printf("\n"); fflush(stdout);
|
|
|
-*/
|
|
|
return return_status;
|
|
|
}
|
|
|
|