<?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 sgx_create_enclave function in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123490#M1603</link>
    <description>&lt;P&gt;sgx_create_enclave function can't be called as part of initialization of a application DLL. In a process, we can't&amp;nbsp;a DLL, while another DLL&lt;BR /&gt;
	loading/initialization is in progress. This constrains is applicable to non SGX application also.&lt;/P&gt;

&lt;P&gt;We can call "sgx_create_enclave" from other part of application DLL except the DLL initialization code."sgx_create_enclave" is part of&lt;BR /&gt;
	untrusted the library (URts). We can add required untrusted library in the project settings and header file ("sgx_urts.h") in the application&lt;BR /&gt;
	&amp;nbsp;DLL and can call the "sgx_create_enclave" in application DLL.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2017 11:22:22 GMT</pubDate>
    <dc:creator>Prabu_R_Intel</dc:creator>
    <dc:date>2017-03-21T11:22:22Z</dc:date>
    <item>
      <title>Failed when using Enclave in Windows Schannel</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123488#M1601</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wrote a simple SSL program using Windows Schannel (just created socket and do SSL handshake). It worked well without loading enclave. However, when the program loaded enclave, it failed at "AcquireCredentialHandle" and never returned. It has troubled me for several days and still not solved.&lt;/P&gt;

&lt;P&gt;Does anybody know why and how to solve it?&lt;/P&gt;

&lt;P&gt;thx a lot.&lt;/P&gt;

&lt;P&gt;-Huorong Li&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 13:12:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123488#M1601</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-20T13:12:35Z</dc:date>
    </item>
    <item>
      <title>PS:</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123489#M1602</link>
      <description>&lt;P&gt;PS:&lt;/P&gt;

&lt;P&gt;I'm sure that the problem was caused by calling "&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;sgx_create_enclave&lt;/SPAN&gt;" in my DLL, and I found an useful info from "Intel SGX SDK Developer Reference for Windows OS v1.7.pdf":&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;&lt;SPAN class="fontstyle0"&gt;Do not call the &lt;/SPAN&gt;&lt;SPAN class="fontstyle2"&gt;sgx_create_enclave &lt;/SPAN&gt;&lt;SPAN class="fontstyle0"&gt;function as part of initialization of a&lt;BR /&gt;
		DLL. For instance, &lt;/SPAN&gt;&lt;SPAN class="fontstyle2"&gt;sgx_create_enclave &lt;/SPAN&gt;&lt;SPAN class="fontstyle0"&gt;hangs when it is called from the&lt;BR /&gt;
		global object constructor of a C++ class in a DLL.&lt;/SPAN&gt;&lt;BR style="line-height: normal; text-align: -webkit-auto; text-size-adjust: auto;" /&gt;
		&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And I've tried put "&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;sgx_create_enclave&lt;/SPAN&gt;" in different place in DLL, but all failed. What does "&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;initialization of a&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;DLL&lt;/SPAN&gt;" actually mean? Does it mean that we should NOT call "&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;sgx_create_enclave&lt;/SPAN&gt;" in a DLL? if not, what is the right way to call "&lt;SPAN style="font-size: 13.008px; font-style: italic;"&gt;sgx_create_enclave&lt;/SPAN&gt;" in a DLL?&lt;/P&gt;

&lt;P&gt;Thx,&lt;/P&gt;

&lt;P&gt;-Huorong Li&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 06:34:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123489#M1602</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-21T06:34:26Z</dc:date>
    </item>
    <item>
      <title>sgx_create_enclave function</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123490#M1603</link>
      <description>&lt;P&gt;sgx_create_enclave function can't be called as part of initialization of a application DLL. In a process, we can't&amp;nbsp;a DLL, while another DLL&lt;BR /&gt;
	loading/initialization is in progress. This constrains is applicable to non SGX application also.&lt;/P&gt;

&lt;P&gt;We can call "sgx_create_enclave" from other part of application DLL except the DLL initialization code."sgx_create_enclave" is part of&lt;BR /&gt;
	untrusted the library (URts). We can add required untrusted library in the project settings and header file ("sgx_urts.h") in the application&lt;BR /&gt;
	&amp;nbsp;DLL and can call the "sgx_create_enclave" in application DLL.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 11:22:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123490#M1603</guid>
      <dc:creator>Prabu_R_Intel</dc:creator>
      <dc:date>2017-03-21T11:22:22Z</dc:date>
    </item>
    <item>
      <title>Quote:Prabu Rajathirumoni</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123491#M1604</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Prabu Rajathirumoni wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;sgx_create_enclave function can't be called as part of initialization of a application DLL. In a process, we can't&amp;nbsp;a DLL, while another DLL&lt;BR /&gt;
	loading/initialization is in progress. This constrains is applicable to non SGX application also.&lt;/P&gt;

&lt;P&gt;We can call "sgx_create_enclave" from other part of application DLL except the DLL initialization code."sgx_create_enclave" is part of&lt;BR /&gt;
	untrusted the library (URts). We can add required untrusted library in the project settings and header file ("sgx_urts.h") in the application&lt;BR /&gt;
	&amp;nbsp;DLL and can call the "sgx_create_enclave" in application DLL.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Hi&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;Prabu Rajathirumoni,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;Thanks for your reply.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;However, I'm still not clear what "part of initialization of a application DLL" means. Could you give me an example?. For example, Windows DLL's entry is DLLMain, is it right the "part of initialization of a application DLL", and the code in DLLMain is so-called "DLL initialization code"? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;PS: I use Visual Studio 2015 with SGX SDK, and it seems that sgx librares are add to project settings by default.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 12:14:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123491#M1604</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-21T12:14:25Z</dc:date>
    </item>
    <item>
      <title>Please read:</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123492#M1605</link>
      <description>&lt;P&gt;Please read:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx"&gt;https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Basically, if you write a DLL when that DLL gets loaded, its DllMain() method is called automatically.&amp;nbsp;Inside&amp;nbsp;that DllMain(), you cannot load another DLL. The URL above has more details of additional restrictions.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 13:22:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123492#M1605</guid>
      <dc:creator>Francisco_C_Intel</dc:creator>
      <dc:date>2017-03-21T13:22:42Z</dc:date>
    </item>
    <item>
      <title>Quote:Francisco C. (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123493#M1606</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Francisco C. (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Please read:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx" rel="nofollow"&gt;https://msdn.microsoft.com/en-us/library/windows/desktop/dn633971(v=vs.85).aspx&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Basically, if you write a DLL when that DLL gets loaded, its DllMain() method is called automatically.&amp;nbsp;Inside&amp;nbsp;that DllMain(), you cannot load another DLL. The URL above has more details of additional restrictions.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;Still, I'm sure that I do NOT call sgx_create_enclave in DllMain. Here's my DllMain function:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;BOOL WINAPI DllMain(&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;IN CONST HINSTANCE &amp;nbsp; &amp;nbsp;hInstDLL,&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;IN CONST DWORD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dwReason,&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;IN CONST LPVOID &amp;nbsp; &amp;nbsp; &amp;nbsp; lpvReserved&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;)&lt;BR /&gt;
		{&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;UNREFERENCED_PARAMETER(lpvReserved);&lt;/P&gt;

	&lt;P&gt;&amp;nbsp;&lt;/P&gt;

	&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (dwReason == DLL_PROCESS_ATTACH)&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;srand(time(NULL));&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;else if (dwReason == DLL_PROCESS_DETACH)&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;

	&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp;return TRUE;&lt;BR /&gt;
		}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;However&lt;/SPAN&gt;, no mater where I placed sgx_create_enclave to, it always failed and&amp;nbsp;&lt;SPAN style="font-size: 1em;"&gt;once I commented the code, it success.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 16:08:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123493#M1606</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-21T16:08:43Z</dc:date>
    </item>
    <item>
      <title>I assume that wrapper</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123494#M1607</link>
      <description>&lt;P&gt;I assume that wrapper function containing "sgx_create_enclave"&amp;nbsp; is defined in your application DLL.For enclave loading and initialization, this wrapper function is called from Application source.&lt;/P&gt;

&lt;P&gt;Please check the below link for loading the enclave through application(C#) dll&lt;BR /&gt;
	&lt;A href="https://software.intel.com/en-us/articles/csharp-application-with-intel-software-guard-extension"&gt;https://software.intel.com/en-us/articles/csharp-application-with-intel-software-guard-extension&lt;/A&gt;&lt;BR /&gt;
	This writeup is written based on loading an enclave from C# application source by writting managed and unmanaged code (both are dlls).If your application is written in C/C++, then there is no need for managed/unmanaged code.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 11:32:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123494#M1607</guid>
      <dc:creator>Prabu_R_Intel</dc:creator>
      <dc:date>2017-03-22T11:32:01Z</dc:date>
    </item>
    <item>
      <title>I do use native C/C++, not C#</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123495#M1608</link>
      <description>&lt;P&gt;I do use native C/C++, not C#&lt;SPAN style="font-size: 1em;"&gt;, and I'm sure sgx_create_enclave is not called directly or indirectly in DllMain, which is the initialization part of the DLL.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Prabu Rajathirumoni wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;I assume that wrapper function containing "sgx_create_enclave"&amp;nbsp; is defined in your application DLL.For enclave loading and initialization, this wrapper function is called from Application source.&lt;/P&gt;

&lt;P&gt;Please check the below link for loading the enclave through application(C#) dll&lt;BR /&gt;
	&lt;A href="https://software.intel.com/en-us/articles/csharp-application-with-intel-software-guard-extension"&gt;https://software.intel.com/en-us/articles/csharp-application-with-intel-software-guard-extension&lt;/A&gt;&lt;BR /&gt;
	This writeup is written based on loading an enclave from C# application source by writting managed and unmanaged code (both are dlls).If your application is written in C/C++, then there is no need for managed/unmanaged code.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 13:06:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123495#M1608</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-22T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Since the above shared write</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123496#M1609</link>
      <description>&lt;P&gt;Since the above shared write-up uses the DLL written in C/C++ to call the enclave, I thought it might be useful for your reference.&lt;/P&gt;

&lt;P&gt;Could you please share me the "App-&amp;gt;DLL-&amp;gt;Enclave" communication part of the code , let me try&amp;nbsp;to fix the&amp;nbsp;issue ?&amp;nbsp;. Otherwise I can build&amp;nbsp; a simple Intel SGX application with a light weight application DLL that calls enclave.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 19:13:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123496#M1609</guid>
      <dc:creator>Prabu_R_Intel</dc:creator>
      <dc:date>2017-03-23T19:13:36Z</dc:date>
    </item>
    <item>
      <title>Thanks a lot for your help.</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123497#M1610</link>
      <description>&lt;P&gt;Thanks a lot for your help.&lt;/P&gt;

&lt;P&gt;My DLL is implemented as a CNG Provider. Basically, It should be used in CNG context i.e. "App-&amp;gt;CNG-&amp;gt;DLL-&amp;gt;Enclave". However, to make the CNG Provider DLL available to App, especially for App using Schannel to do TLS, a lot configuration should be done on OS, including installing kernel mode drivers.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;I have done such tests (both "App-&amp;gt;DLL-&amp;gt;Enclave" and "App-&amp;gt;CNG-&amp;gt;DLL-&amp;gt;Enclave", App not calling&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;AcquireCredentialHandle&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.008px;"&gt;) with My DLL. Both of them did work.&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;nbsp;It's almost sure that in&amp;nbsp;AcquireCredentialHandle context, something breaks the sgx_create_enclave "calling rule".&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;For AcquireCredentialHandle,&amp;nbsp;&lt;/SPAN&gt;not useful feedback from Microsoft c&lt;SPAN style="font-size: 13.008px;"&gt;urrently&lt;/SPAN&gt;.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;PS:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;I've partly solved this problem by using following trick:&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Create enclave in App main routine, save the handle (enclave id) to a file. The DLL get the handle from the file.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;However, it requires that creating enclave MUST be in the same process with the DLL. So it does not apply in Windows native application like IE.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 01:54:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Failed-when-using-Enclave-in-Windows-Schannel/m-p/1123497#M1610</guid>
      <dc:creator>Huorong_L_</dc:creator>
      <dc:date>2017-03-24T01:54:31Z</dc:date>
    </item>
  </channel>
</rss>

