<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SharedSecret Inside/Outside enclave in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094088#M926</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I tried to generate the shared DH key inside the enclave using the ecc_compute_shared_dhkey but i noticed that the generated key is different from the one created by the IPP library in the code provided(same run). Using this generated shared key i continued the control flow of the server and generated the KDK,SMK,SK,VK keys but as hinted/expected the client failed to process msg1 with a MAC_MISMATCH error(cmac(smk,msg)).&lt;/P&gt;

&lt;P&gt;I also tried to generate the shared key(inside the enclave) using the ipps functions(ippsECCPSharedSecretDH() etc.) but the key generated matched the one generated by the enclave's own function.&lt;/P&gt;

&lt;P&gt;Am i doing something wrong or is this the intended behaviour??&lt;/P&gt;

&lt;P&gt;Thanks in advance for any contribution.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2017 09:21:07 GMT</pubDate>
    <dc:creator>kalogiannis__konstan</dc:creator>
    <dc:date>2017-02-13T09:21:07Z</dc:date>
    <item>
      <title>SharedSecret Inside/Outside enclave</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094088#M926</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I tried to generate the shared DH key inside the enclave using the ecc_compute_shared_dhkey but i noticed that the generated key is different from the one created by the IPP library in the code provided(same run). Using this generated shared key i continued the control flow of the server and generated the KDK,SMK,SK,VK keys but as hinted/expected the client failed to process msg1 with a MAC_MISMATCH error(cmac(smk,msg)).&lt;/P&gt;

&lt;P&gt;I also tried to generate the shared key(inside the enclave) using the ipps functions(ippsECCPSharedSecretDH() etc.) but the key generated matched the one generated by the enclave's own function.&lt;/P&gt;

&lt;P&gt;Am i doing something wrong or is this the intended behaviour??&lt;/P&gt;

&lt;P&gt;Thanks in advance for any contribution.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 09:21:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094088#M926</guid>
      <dc:creator>kalogiannis__konstan</dc:creator>
      <dc:date>2017-02-13T09:21:07Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094089#M927</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Could you clarify two things first?&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;Inside what enclave did you try to compute the shared key? What parameters are you using in the sgx_ecc256_compute_shared_dhkey?&lt;/LI&gt;
	&lt;LI&gt;What do you mean by "&lt;SPAN style="font-size: 12px;"&gt;the client failed to process msg1 with a MAC_MISMATCH", since the sgx_ra_msg1_t doesn't have a MAC? The msg1 consists of only the GID and the SP's public key.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 10:41:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094089#M927</guid>
      <dc:creator>Rodolfo_S_</dc:creator>
      <dc:date>2017-02-13T10:41:32Z</dc:date>
    </item>
    <item>
      <title>Quote:Rodolfo S. wrote:</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094090#M928</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Rodolfo S. wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Could you clarify two things first?&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;Inside what enclave did you try to compute the shared key? What parameters are you using in the sgx_ecc256_compute_shared_dhkey?&lt;/LI&gt;
	&lt;LI&gt;What do you mean by "the client failed to process msg1 with a MAC_MISMATCH", since the sgx_ra_msg1_t doesn't have a MAC? The msg1 consists of only the GID and the SP's public key.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;1. The enclave is in Prerelease x64. The server is running in release(tested in prerelease too). The function I'm utilizing looks something like this:&lt;SPAN style="font-size: 1em;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;static sgx_ec256_private_t spPrivKeyBlob ={....};
sgx_ec256_public_t *remotepub = (sgx_ec256_public_t*)malloc(sizeof(sgx_ec256_public_t));
sgx_ec256_dh_shared_t *sharedkey = (sgx_ec256_dh_shared_t*)malloc(sizeof(sgx_ec256_dh_shared_t));
sgx_ecc_state_handle_t* myhandle = (sgx_ecc_state_handle_t*)malloc(sizeof(sgx_ecc_state_handle_t));

void ComputeShared(unsigned char* gX, unsigned char* gY,unsigned char* my_shared){
        ret = sgx_ecc256_open_context(myhandle);
        memcpy(remotepub-&amp;gt;gx, gX, 32);
        memcpy(remotepub-&amp;gt;gy, gY, 32);
        ret = sgx_ecc256_compute_shared_dhkey(&amp;amp;spPrivKeyBlob, remotepub, sharedkey, *myhandle);
        .
        .
}&lt;/PRE&gt;

&lt;P&gt;I'm passing the public key of the client from the server application to the wrapper and then to the enclave like that:&lt;/P&gt;

&lt;PRE class="brush:csharp;"&gt;byte[] my_shared = new byte[32];
myfunction(gaXLittleEndian, gaYLittleEndian,my_shared);&lt;/PRE&gt;

&lt;PRE class="brush:cpp;"&gt;__declspec(dllexport) void myfunction(unsigned char* gX, unsigned char* gY,unsigned char* sharedkey){&lt;/PRE&gt;

&lt;P&gt;2. Forgive me on this,that was a typo, I'm talking about the msg2 sent from the server to the client. The client then calls proc_msg2 to generate msg3 for the server. Proc_msg2 is the one failing with MAC_MISMATCH.&lt;/P&gt;

&lt;P&gt;Edit while writing this:&lt;/P&gt;

&lt;P&gt;Changing the&amp;nbsp;&lt;SPAN style="font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, Menlo, Monaco, &amp;quot;DejaVu Sans Mono&amp;quot;, monospace, sans-serif; font-size: 13.008px;"&gt;sgx_ecc_state_handle_t to uninitialized and letting the open_context allocate the memory, ecc256_compute_shared gives me an 0x001(UNEXPECTED_ERROR) and fails. Everything else is unchanged from the above supplied paradigm.&lt;BR /&gt;
	&lt;BR /&gt;
	Edit2:&lt;BR /&gt;
	Correcting the first's edit mistake(that gave UNEXPECTED_ERROR), the shared key generated falls to the same problem of the first approach.&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks in advance for an help provided.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 12:17:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/SharedSecret-Inside-Outside-enclave/m-p/1094090#M928</guid>
      <dc:creator>kalogiannis__konstan</dc:creator>
      <dc:date>2017-02-13T12:17:00Z</dc:date>
    </item>
  </channel>
</rss>

