Browse Source

Upgrade to Linux 1.6 gold release

switch code to linux 1.6 opensource gold release
zhaohuidu 7 years ago
parent
commit
85947caa12
100 changed files with 2147 additions and 1578 deletions
  1. 4 0
      .gitignore
  2. 1 1
      License.txt
  3. 53 4
      Linux_SGXEclipsePlugin/build.sh
  4. 0 22
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_Project.htm
  5. 0 55
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_non_SGX_project.htm
  6. 0 54
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Enclave.htm
  7. 0 39
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Trusted_Library.htm
  8. 0 39
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Untrusted_Module.htm
  9. 0 25
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Building_and_Running_SGX_Code.htm
  10. 0 30
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Command_Reference.htm
  11. 0 31
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in.htm
  12. 0 37
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Creating_a_New_C_C_Project_with_SGX_Nature.htm
  13. 0 27
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Hash.htm
  14. 0 39
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Signed_Enclaves.htm
  15. 0 23
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Getting_Started.htm
  16. 0 40
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin.htm
  17. 0 42
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin.htm
  18. 0 23
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard_Extensions.htm
  19. 0 21
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introduction.htm
  20. 0 70
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Legal_Information.htm
  21. 0 27
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Prerequisites.htm
  22. 50 23
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css
  23. 0 31
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Running_Samples_Generated_for_Enclaves.htm
  24. 0 97
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_Build_Configurations.htm
  25. 0 30
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_title.htm
  26. 0 59
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Two_Steps_Sign_Enclave.htm
  27. 0 39
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_Enclave_Configuration_Files.htm
  28. 0 37
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_SGX_Enclave_Signing_Key.htm
  29. 95 96
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/content.html
  30. 44 90
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/toc.xml
  31. 0 1
      Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml
  32. 3 1
      Linux_SGXEclipsePlugin/build_directory/sites/site.xml
  33. 1 1
      Linux_SGXEclipsePlugin/clean.sh
  34. 8 7
      Linux_SGXEclipsePlugin/readme.txt
  35. 0 34
      Linux_SGXEclipsePlugin/src/main/groovy/preprocessHtml.groovy
  36. 4 12
      README.md
  37. 9 1
      SampleCode/LocalAttestation/Makefile
  38. 9 1
      SampleCode/PowerTransition/Makefile
  39. 12 1
      SampleCode/RemoteAttestation/Makefile
  40. 82 10
      SampleCode/RemoteAttestation/isv_app/isv_app.cpp
  41. 133 1
      SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp
  42. 85 0
      SampleCode/RemoteAttestation/service_provider/ecp.cpp
  43. 20 2
      SampleCode/RemoteAttestation/service_provider/ecp.h
  44. 9 13
      SampleCode/RemoteAttestation/service_provider/ias_ra.cpp
  45. 0 1
      SampleCode/RemoteAttestation/service_provider/ias_ra.h
  46. 14 3
      SampleCode/RemoteAttestation/service_provider/network_ra.cpp
  47. 18 15
      SampleCode/RemoteAttestation/service_provider/network_ra.h
  48. 13 13
      SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h
  49. 145 67
      SampleCode/RemoteAttestation/service_provider/service_provider.cpp
  50. 50 19
      SampleCode/RemoteAttestation/service_provider/service_provider.h
  51. 0 1
      SampleCode/SampleEnclave/Enclave/Enclave.config.xml
  52. 9 1
      SampleCode/SampleEnclave/Makefile
  53. 5 5
      common/inc/internal/arch.h
  54. 2 2
      common/inc/internal/linux/xsave_gnu.h
  55. 21 0
      common/inc/internal/oal/uae_oal_api.h
  56. 1 1
      common/inc/internal/se_version.h
  57. 2 1
      common/inc/sgx_quote.h
  58. 1 0
      common/inc/sgx_thread.h
  59. 69 2
      common/inc/sgx_tkey_exchange.h
  60. 25 0
      common/inc/sgx_uae_service.h
  61. 64 0
      common/inc/tlibc/setjmp.h
  62. 3 2
      download_prebuilt.sh
  63. 28 2
      external/epid/inc/epid_types.h
  64. 1 1
      external/rdrand/rdrand.h
  65. 14 2
      linux/installer/bin/install-sgx-psw.bin.tmpl
  66. 75 6
      linux/installer/bin/install-sgx-sdk.bin.tmpl
  67. 1 0
      linux/installer/common/psw/BOMs/psw_base.txt
  68. 1 1
      linux/installer/common/psw/Makefile
  69. 3 2
      linux/installer/common/psw/createTarball.sh
  70. 3 1
      linux/installer/common/psw/install.sh
  71. 1 0
      linux/installer/common/sdk/BOMs/sdk_base.txt
  72. 5 0
      linux/installer/common/sdk/BOMs/sdk_x64.txt
  73. 5 0
      linux/installer/common/sdk/BOMs/sdk_x86.txt
  74. 20 1
      linux/installer/common/sdk/Makefile
  75. 26 2
      linux/installer/common/sdk/createTarball.sh
  76. 40 5
      linux/installer/common/sdk/install.sh
  77. 10 0
      linux/installer/common/sdk/pkgconfig/template/libsgx_uae_service.pc
  78. 10 0
      linux/installer/common/sdk/pkgconfig/template/libsgx_uae_service_sim.pc
  79. 10 0
      linux/installer/common/sdk/pkgconfig/template/libsgx_urts.pc
  80. 10 0
      linux/installer/common/sdk/pkgconfig/template/libsgx_urts_sim.pc
  81. 3 3
      psw/ae/Makefile
  82. 21 12
      psw/ae/aesm_service/Makefile
  83. 5 7
      psw/ae/aesm_service/config/network/aesmd.conf
  84. 31 10
      psw/ae/aesm_service/include/oal/aesm_persistent_storage.h
  85. 1 0
      psw/ae/aesm_service/include/oal/error_report.h
  86. 2 0
      psw/ae/aesm_service/include/oal/internal_log.h
  87. 5 2
      psw/ae/aesm_service/source/aesm/application/AEClass.h
  88. 8 29
      psw/ae/aesm_service/source/aesm/application/aesm_config.cpp
  89. 1 3
      psw/ae/aesm_service/source/aesm/application/aesm_config.h
  90. 360 43
      psw/ae/aesm_service/source/aesm/application/aesm_logic.cpp
  91. 23 6
      psw/ae/aesm_service/source/aesm/application/aesm_logic.h
  92. 33 3
      psw/ae/aesm_service/source/aesm/extension/aesm_ecdsa.cpp
  93. 8 6
      psw/ae/aesm_service/source/aesm/extension/aesm_encode.cpp
  94. 5 6
      psw/ae/aesm_service/source/aesm/extension/aesm_encode.h
  95. 78 16
      psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.cpp
  96. 5 2
      psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.h
  97. 49 17
      psw/ae/aesm_service/source/aesm/extension/aesm_http_msg.cpp
  98. 69 19
      psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.cpp
  99. 4 2
      psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.h
  100. 109 0
      psw/ae/aesm_service/source/aesm/extension/aesm_xegd_blob.cpp

+ 4 - 0
.gitignore

@@ -13,3 +13,7 @@
 *_u.h
 *_t.c
 *_t.h
+
+#output files
+/build/
+/linux/installer/bin/*.bin

+ 1 - 1
License.txt

@@ -37,7 +37,7 @@ http://www.eclipse.org/legal/epl-v10.html
 
 ==============================================================
 
-libsgx_le.signed.so, libsgx_pve.signed.so and libsgx_qe.signed.so are licensed as Intel redistributable binary firmware and other blobs.
+libsgx_le.signed.so, libsgx_pce.signed.so, libsgx_pve.signed.so and libsgx_qe.signed.so are licensed as Intel redistributable binary firmware and other blobs.
 
  
 Copyright (c) Intel Corporation.

+ 53 - 4
Linux_SGXEclipsePlugin/build.sh

@@ -11,7 +11,7 @@ TRUNK_HOME=$(cd $(pwd)/../../ ; pwd)
 [ -n "${ECLIPSE_HOME}" ] || { echo "using default ECLIPSE_HOME=${TRUNK_HOME}/eclipse"; ECLIPSE_HOME=${TRUNK_HOME}/eclipse; }
 
 
-BUILD_RELEASE_ID_PREFIX=Linux_SGX_1.5
+BUILD_RELEASE_ID_PREFIX=Linux_SGX_1.6
 
 if [ "$RELEASE_ID" != "${RELEASE_ID%$BUILD_RELEASE_ID_PREFIX*}" ]; then
     echo "$BUILD_RELEASE_ID_PREFIX IS in $RELEASE_ID, so it is an triggered build. Change the RELEASE_ID to an accepted form."
@@ -126,6 +126,51 @@ ${ECLIPSE_HOME}/eclipse -nosplash \
   -installIU org.eclipse.pde.feature.group
 }
 
+function preBuild() {
+  local BUILDDIR="$1"
+  local BUILDDIRWORK="$2"
+  
+  local SITEFILE="$BUILDDIRWORK/sites/site.xml"
+  local FEATUREDIR="$BUILDDIRWORK/features"
+  local FEATUREFILE="feature.xml"
+  local PLUGINDIR="$BUILDDIRWORK/plugins"
+  local PLUGINFILE="META-INF/MANIFEST.MF"  
+
+  local ROOTDIR=$(dirname "$0")"/.."
+  local VERSION=$(awk '/STRFILEVER/ {print $3}' ${ROOTDIR}/common/inc/internal/se_version.h|sed 's/^\"\(.*\)\"$/\1/')
+  VERSION=$(echo "$VERSION" | awk -F'.' '{for(i=1; i<=NF&&i<=3; i++) if(i==1){version=$i} else{version=version"."$i}}; END{print version}')
+
+  if [[ "$VERSION" =~ ^[0-9]{1,}(.[0-9]{1,}){2}$ ]]; then
+    rm -fr "$BUILDDIRWORK"
+    cp -fr "$BUILDDIR" "$BUILDDIRWORK"
+
+    #site.xml
+    sed -i "s#[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{0,2\}\.qualifier#$VERSION\.qualifier#g" "$SITEFILE"
+
+    #feature
+    for DIR in $(ls "$FEATUREDIR"); do
+      sed -i "s#[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{0,2\}\.qualifier#$VERSION\.qualifier#g" "$FEATUREDIR/$DIR/$FEATUREFILE"
+    done
+
+    #plugin
+    for DIR in $(ls "$PLUGINDIR"); do
+      sed -i "s#[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{0,2\}\.qualifier#$VERSION\.qualifier#g" "$PLUGINDIR/$DIR/$PLUGINFILE"
+    done
+  fi
+}
+
+function postBuild() {
+  local BUILDDIR="$1"
+  local BUILDDIRWORK="$2"
+  local UPDATESITEDIR="updatesite"
+  
+  if [[ -d "$BUILDDIRWORK" ]] && [[ -d "$BUILDDIRWORK/$UPDATESITEDIR" ]]; then
+    rm -fr "$BUILDDIR/$UPDATESITEDIR"
+    cp -fr "$BUILDDIRWORK/$UPDATESITEDIR" "$BUILDDIR/$UPDATESITEDIR"
+    rm -fr "$BUILDDIRWORK"
+  fi
+}
+
 function buildPlugin() {
     pwd
 
@@ -136,6 +181,7 @@ function buildPlugin() {
   BASELOCATION="$ECLIPSE_HOME"
   BUILDVERSION="$RELEASE_ID"
   BUILDDIR="$PWD/build_directory"
+  BUILDDIRWORK="$PWD/.build_directory"
   BUILDCONFIG="$PWD/build_config"
   LAUNCHER=`findFirst "$ECLIPSE_HOME"/plugins/org.eclipse.equinox.launcher_*.jar`
   BUILDFILE=`findFirst "$ECLIPSE_HOME"/plugins/org.eclipse.pde.build_*/scripts/build.xml`
@@ -151,7 +197,9 @@ function buildPlugin() {
          "not detected. Found '$BUILDFILE'. Aborting."
     exit 1
   fi
-  
+
+  preBuild "$BUILDDIR" "$BUILDDIRWORK"
+
   #
   # -- Print configuration used and actually execute the build --  
   #
@@ -161,7 +209,7 @@ function buildPlugin() {
   echo "  Build File:   $BUILDFILE"
   echo "  Build Config: $BUILDCONFIG"
   echo "  Base Location: $BASELOCATION"
-  echo "  Build Directory: $BUILDDIR"
+  echo "  Build Directory: $BUILDDIRWORK"
   echo "  Build Version: $BUILDVERSION"
   echo "  Java:         " $(which java)
   java -version
@@ -174,12 +222,13 @@ function buildPlugin() {
     -jar $LAUNCHER \
     -application org.eclipse.ant.core.antRunner \
     -buildfile $BUILDFILE \
-    -DbuildDirectory=$BUILDDIR \
+    -DbuildDirectory=$BUILDDIRWORK \
     -DbaseLocation=$BASELOCATION \
     -Dbuilder=$BUILDCONFIG \
     -DforceContextQualifier=$BUILDVERSION \
       -v -v -v -v 
 
+  postBuild "$BUILDDIR" "$BUILDDIRWORK"
 }
 
 function findFirst() {

+ 0 - 22
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_Project.htm

@@ -1,22 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="383" MadCap:lastWidth="576">
-    <head><title>Adding SGX Nature to a Project</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Adding SGX Nature to a Project</h2>
-        <p>The <i>nature</i> of an Eclipse project is a concept defined by an Eclipse Platform which allows a plug-in to tag a project as a specific kind of project.   Intel(R) Software Guard Extensions  uses an <i>SGX nature</i> to add SGX-specific behavior to projects.  Project natures are defined by plug-ins, and are typically added or removed per-project when the user performs some action defined by the plug-in.</p>
-        <p>To use Intel(R) Software Guard Extensions Eclipse Plug-in in your project, you need to add SGX nature to it.   You may either add SGX nature to a pre-existing C/C++ project or create a project with SGX nature from start.  See <a href="Adding_SGX_Nature_to_a_non_SGX_project.htm">Adding SGX Nature to a non-SGX project</a> and <a href="Creating_a_New_C_C_Project_with_SGX_Nature.htm">Creating a New C/C++ Project with SGX Nature</a> for how to complete these tasks.</p>
-    </body>
-</html>

+ 0 - 55
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_SGX_Nature_to_a_non_SGX_project.htm

@@ -1,55 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1808" MadCap:lastWidth="563">
-    <head><title>Adding SGX Nature to a non-SGX project</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h3>Adding SGX Nature to a non-SGX project</h3>
-        <p>When you have a C/C++ project created without Intel SGX, you cannot use Intel SGX support.  In this case, you need to add SGX nature to this project to use Intel SGX support:</p>
-        <ol>
-            <li>Right-click on the project root <![CDATA[	]]></li>
-            <li>
-                <p>Select <b>Software Guard Extension Tools → Add SGX Nature</b></p>
-                <p>
-                    <img src="Resources/Images/Add_SGX_Nature.png" />
-                </p>
-                <p class="figcap">Add SGX Nature</p>
-            </li>
-        </ol>
-        <p>After you add the SGX nature to your project, you should see:</p>
-        <ul>
-            <li>
-                <p>A subdirectory <code>sgx</code> in the project which contains a  Makefile file.</p>
-                <p>
-                    <img src="Resources/Images/Makefile_for_Intel_SGX.png" />
-                </p>
-                <p class="figcap">Makefile for Intel(R) SGX</p>
-            </li>
-            <li>
-                <p>The Intel SGX tools as shown in the following graphic:</p>
-                <p>
-                    <img src="Resources/Images/Intel_SGX_Tools.png" />
-                </p>
-                <p class="figcap">Intel(R) SGX Tools</p>
-            </li>
-            <li>
-                <p>New configurations specific to SGX technology.  You may see the configurations for the project by clicking to the down arrow of button <img src="Resources/Images/Down_Arrow_Button.png" /> usually found at the top of the Eclipse window:</p>
-                <p>
-                    <img src="Resources/Images/Configurations_Specific_to_Intel_SGX_Technology.png" />
-                </p>
-                <p class="figcap">Configurations Specific to Intel(R) SGX Technology</p>
-            </li>
-        </ul>
-    </body>
-</html>

+ 0 - 54
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Enclave.htm

@@ -1,54 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="2003" MadCap:lastWidth="524">
-    <head><title>Adding an SGX Enclave</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Adding an SGX Enclave</h2>
-        <p>After you add the SGX nature to a project, you can start creating a minimal but complete skeleton for a new enclave:</p>
-        <ol>
-            <li>Right-click on the project root in <b>Project Explorer</b>.</li>
-            <li>
-                <p>Open the dialog <b>Add New SGX Enclave</b> by selecting <b>Software Guard Extensions Tools → Add SGX Enclave</b> from the contextual menu.</p>
-                <p>
-                    <img src="Resources/Images/Add_New_Intel_SGX_Enclave_Dialog.png" />
-                </p>
-                <p class="figcap">Add New Intel® SGX Enclave Dialog</p>
-            </li>
-            <li>
-                <p>Choose a name for the enclave in <b>Enclave name</b> field.  This name is used in the process of generation of the skeleton to give unicity to the source files and the name of the resulting executable, so you can add more than one enclave to the same project.</p>
-                <ul>
-                    <li>
-                        <p>If you do not select the <b>Generate sample untrusted application</b> checkbox, the plugin generates only a trusted file and a Makefile fragment to build and compile the trusted part. See the following graphic.   All the code for the enclave, including build Makefile, is put in a directory <code>&lt;root&gt;/sgx/enclave_&lt;name&gt;</code> .   C/C++ code for the enclave proper are in <code>&lt;root&gt;/sgx/enclave_&lt;name&gt;/trusted</code>.</p>
-                        <p>
-                            <img src="Resources/Images/Generated_Skeleton_for_an_Enclave.png" />
-                        </p>
-                        <p class="figcap">Generated Skeleton for an Enclave.  The option to Generate Sample was not Used</p>
-                    </li>
-                    <li>
-                        <p>If you select <b>Generate sample untrusted application</b> checkbox, a simple ready to work sample application is generated, including untrusted stubs and implementation for a sample OCALL and ECALL.</p>
-                        <p>
-                            <img src="Resources/Images/Generated_Sample_Untrusted_Application.png" />
-                        </p>
-                        <p class="figcap">Generated Sample Untrusted Application</p>
-                    </li>
-                </ul>
-            </li>
-        </ol>
-        <div class="NoteCont">
-            <p class="NoteTipHead">NOTE:</p>
-            <p>If you select the <b>Generate sample untrusted application</b> checkbox, ecalls from the untrusted part are not be resolved by Eclipse C/C++ indexer. These functions are marked with a red line. The declaration of these ecalls resides in the unstrusted stub header which is generated during the build proces and is not indexed by Eclipse. To resolve this problem, right-click on project root and select <b>Index → Freshen All Files</b>.</p>
-        </div>
-    </body>
-</html>

+ 0 - 39
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Trusted_Library.htm

@@ -1,39 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="887" MadCap:lastWidth="550">
-    <head><title>Adding an SGX Trusted Library</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Adding an SGX Trusted Library</h2>
-        <p>Trusted Static Libraries helps enclave author  have libraries of shared code to be reused by enclaves, in exactly the same manner as usual static <code>libxxx.a</code> libraries are used to share code between regular non-SGX applications.  The plugin adds a command to generate the skeleton of a trusted shared library.</p>
-        <p>To add a new SGX Trusted Library:</p>
-        <ol>
-            <li>
-                <p>Open <b>Add New SGX Static Trusted Library</b> dialog by right-click on the root of the project and select the appropriate command from <b>Software Guard Extensions Tools</b> menu:</p>
-                <p>
-                    <img src="Resources/Images/Add_New_SGX_Static_Trusted_Library_Dialog.png" />
-                </p>
-                <p class="figcap">Add New SGX Static Trusted Library Dialog</p>
-            </li>
-            <li>
-                <p>Choose a name for the library and click <b>OK</b>. A skeleton for a trusted library is generated in directory <code>&lt;root&gt;/sgx/trustedlib_&lt;name&gt;</code>:</p>
-                <p>
-                    <img src="Resources/Images/A_Generated_Trusted_Library.png" />
-                </p>
-                <p class="figcap">A Generated Trusted Library</p>
-            </li>
-        </ol>
-    </body>
-</html>

+ 0 - 39
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Adding_an_SGX_Untrusted_Module.htm

@@ -1,39 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="898" MadCap:lastWidth="550">
-    <head><title>Adding an SGX Untrusted Module</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Adding an SGX Untrusted Module</h2>
-        <p>Add an untrusted module to generate the untrusted stubs so you use an enclave, provided you have access to its <code>.edl</code> file.  The enclave might have been built in the current project or in a different project.</p>
-        <p>To use trusted functionality of an enclave for which its <code>*.edl</code> is known, use the command <b>Add SGX Untrusted Module</b>:</p>
-        <ol>
-            <li>
-                <p>Open dialog <b>Add Sgx Untrusted Module</b> by right-click-ing the project root in <b>Package Explorer</b> and chose the command from <b>Software Guard Extension Tools</b>.</p>
-                <p>
-                    <img src="Resources/Images/Add_SGX_Untrusted_Module.png" />
-                </p>
-                <p class="figcap">Add SGX Untrusted Module</p>
-            </li>
-            <li>
-                <p>Use the <b>Browse</b> button to navigate the file system using a file dialog, and click <b>OK</b>. The untrusted module is copied to <code>&lt;root&gt;/sgx/untrusted_&lt;edl file name&gt;</code>.  The selected <code>*.edl</code> is copied to the project.</p>
-                <p>
-                    <img src="Resources/Images/Copying_the_Untrusted_Module_to_a_Project.png" />
-                </p>
-                <p class="figcap">Copying the Untrusted Module to a Project</p>
-            </li>
-        </ol>
-    </body>
-</html>

+ 0 - 25
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Building_and_Running_SGX_Code.htm

@@ -1,25 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="210" MadCap:lastWidth="550">
-    <head><title>Building and Running SGX Code</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Building and Running SGX Code</h1>
-        <p>This section describes the following topics about building and running SGX code:</p>
-        <ul>
-            <li>SGX build configurations</li>
-            <li>Running samples generated for enclaves</li>
-        </ul>&#160;</body>
-</html>

+ 0 - 30
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Command_Reference.htm

@@ -1,30 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1060" MadCap:lastWidth="565">
-    <head><title>Command Reference</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Command Reference</h1>
-        <p>This topic provides the command reference for the following scenarios of using Intel(R) Software Guard Extensions Eclipse* Plug-in:</p>
-        <ul>
-            <li>Adding SGX nature to a project</li>
-            <li>Adding an SGX enclave</li>
-            <li>Adding an SGX trusted library</li>
-            <li>Adding an SGX untrusted module</li>
-            <li>Updating SGX enclave signing key</li>
-            <li>Updating enclave configuration files</li>
-            <li>Two steps sign enclave</li>
-        </ul>
-        <p>All commands brought by Intel(R) Software Guard Extensions Eclipse Plug-in are available by right-clicking on the Project root in Project explorer view in menu <b>Software Guard Extension Tools</b>:</p>&#160;<p><img src="Resources/Images/Project_Explorer.png" /></p><p class="figcap">Project Explorer</p>&#160;</body>
-</html>

+ 0 - 31
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in.htm

@@ -1,31 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="690" MadCap:lastWidth="524">
-    <head><title>Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
-        <p>If you do not install Intel(R) SGX SDK for Linux* OS in the default location, you need to specify the path for Intel SGX SDK  using the following steps:</p>
-        <ol>
-            <li>
-                <p>Go to <b>Window menu -&gt;Preferences</b>. Enter SGX in the filter text field to quickly locate the <b>SGX Preferences</b> page.</p>
-                <p>
-                    <img src="Resources/Images/SGX_Preference_Page.png" />
-                </p>
-                <p class="figcap">SGX Preference Page</p>
-            </li>
-            <li>Enter the path for Intel SGX SDK for Linux OS in the <b>SGX SDK Directory</b> field.</li>
-        </ol>
-    </body>
-</html>

+ 0 - 37
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Creating_a_New_C_C_Project_with_SGX_Nature.htm

@@ -1,37 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1000" MadCap:lastWidth="550">
-    <head><title>Creating a New C/C++ Project with SGX Nature</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h3>Creating a New C/C++ Project with SGX Nature</h3>
-        <p>You can create a new project with SGX nature. To create such a project, follow these steps:</p>
-        <ol>
-            <li>
-                <p>Open a standard Eclipse new project: <b>File menu → Project...</b>  . If you have installed Intel® Software Guard Extensions Eclipse Plug-in,  you can see the category C/C++ with SGX Enabled in the <b>New Project</b> dialog.</p>
-                <p>
-                    <img src="Resources/Images/New_Project.png" />
-                </p>
-                <p class="figcap">New Project</p>
-                <p>This category has 2 sub-categories, <b>SGX C project</b> and <b>SGX C++ project</b>.  These sub-categories are similar to the sub-categories C Project and C++ Project of standard C/C++ category.</p>
-            </li>
-            <li>Select one of the 2 sub-categories, SGX C project or SGX C++ project, and click <b>Next</b>.</li>
-            <li>Complete creating the project using the regular process of creating a standard C or C++ project.</li>
-        </ol>
-        <div class="NoteCont">
-            <p class="NoteTipHead">NOTE:</p>
-            <p>Projects created following the subcategories under <b>C/C++ with SGX Enabled</b> are identical with their standard counterparts, except that they have SGX Nature added.  There is no difference between creating a C or C++ project with SGX enabled, or creating a standard C/C++ project and launch <b>Add SGX nature</b> from it, as described in precedent paragraph.</p>
-        </div>
-    </body>
-</html>

File diff suppressed because it is too large
+ 0 - 27
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Hash.htm


+ 0 - 39
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Generate_Signed_Enclaves.htm

@@ -1,39 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="912" MadCap:lastWidth="614">
-    <head><title>Generate Signed Enclaves</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h3>Generate Signed Enclaves</h3>
-        <p>Generating signed enclave is the second step in the 2-Steps signing process.  You should have the following files to complete this step:</p>
-        <ul>
-            <li>The <code>.hex</code> file generated with <b>Generate Hash</b> command</li>
-            <li>The files produced from the external signing facility</li>
-            <li>The signature of the <code>.hex</code> file</li>
-            <li>The public verification key</li>
-        </ul>
-        <p>To generate signed encalves, use the following steps:</p>
-        <ol>
-            <li>
-                <p>Right-click on the project root, and go to <b>Software Guard Extensions Tools menu → Two Step Sign Enclave → Generate Signed Enclave</b>.</p>
-                <p>
-                    <img src="Resources/Images/Generate_Signed_Enclave_Dialog.png" />
-                </p>
-                <p>Generate Signed Enclave Dialog</p>
-            </li>
-            <li>Enter the inputs to all the fields and click <b>OK</b>.</li>
-        </ol>
-    </body>
-</html>

+ 0 - 23
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Getting_Started.htm

@@ -1,23 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="345" MadCap:lastWidth="576">
-    <head><title>Getting Started with Intel(R) Software Guard Extensions Eclipse* Plugin</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Getting Started with Intel(R) Software Guard Extensions Eclipse* Plugin</h1>
-        <p>This section contains steps to set up your Intel(R) Software Guard Extensions Eclipse* Plugin on a Linux* system, including necessary softwares, steps to install the product, and steps to configure your preferred product directory.</p>
-        <p>•	Pre-requisites</p>
-        <p>•	Installation Intel(R) Software Guard Extensions Eclipse* Plug-in</p>
-        <p>•	Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</p>&#160;</body>
-</html>

+ 0 - 40
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin.htm

@@ -1,40 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="1511" MadCap:lastWidth="681">
-    <head><title>Installing Intel(R) Software Guard Extensions Eclipse* Plug-in</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Installing Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
-        <p>Install Intel(R) Software Guard Extensions Eclipse* Plug-in as a regular Eclipse Plugin:</p>
-        <ol>
-            <li>Download the zip archive of Intel(R) Software Guard Extensions Eclipse Plug-in from Intel Site</li>
-            <li>
-                <p>Go to <b>Help menu -&gt; Install New Software</b>. Click the <b>Add</b> button for the <b>Work with</b> field to open the <b>Add Repository</b> dialog as shown in the following graphic:</p>
-                <p>
-                    <img src="Resources/Images/Add_Repository_Dialog.png" />
-                </p>
-                <p class="figcap">Add Repository Dialog</p>
-            </li>
-            <li>
-                <p>Enter  <code>SGX Archive</code> in the <b>Name</b> field .  Click the <b>Archive...</b> button and select the location of the downloaded archive as shown in the following graphic:</p>
-                <p>
-                    <img src="Resources/Images/The_Location_of_the_Plugin_zip_Archive.png" />
-                </p>
-                <p class="figcap">The Location of the Plugin zip Archive</p>
-            </li>
-            <li>Press <b>OK</b>  to add the archive as a repository.</li>
-            <li>In the <b>Install</b> dialog, select the <b>Software Guard Extensions Plugin</b> check-box and proceed with the usual steps.</li>
-        </ol>
-    </body>
-</html>

+ 0 - 42
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin.htm

@@ -1,42 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1175" MadCap:lastWidth="804">
-    <head><title>What is Intel(R) Software Guard Extensions?</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Introducing Intel(R) Software Guard Extensions</h2>
-        <p>Intel(R) Software Guard Extensions is a new Intel technology, whose objective is to enable a high level of protection of secrets. It operates by allocating hardware-protected memory where code and data reside. The protected memory area within an application process is called an enclave. Data within the enclave memory can only be accessed by code that resides within that enclave. Enclave code can be invoked by special instructions.</p>
-        <p>An enclave can be built and loaded as a shared object.</p>
-        <p>Throughout this document, Intel(R) SGX refers to Intel(R) Software Guard Extensions.</p>
-        <p>An Intel(R) SGX application design is different from the design of non- Intel(R) SGX application as it specifies dividing the application into two logical parts:</p>
-        <ul>
-            <li><i>Trusted</i> part. The code that accesses the secret resides here and it is called an enclave. More than one enclave can exist in an application.</li>
-            <li><i>Untrusted</i> part. This includes the rest of the modules in the application, that is outside in an enclave.</li>
-        </ul>
-        <p>The trusted components and untrusted components are developed as separate modules.</p>
-        <p>The trusted part or the enclave is implemented in C or C++. It is supplied as a collection of functions and data packaged in the form of a dynamically loaded library, a DLL in Windows* OS and a shared object in Linux* OS. It may be supplied either as a pre-built signed library or as a signed shared library built during compilation of the untrusted component.</p>
-        <p>Enclave functions within an enclave library are wrapped by auto-generated proxy and bridge functions that simplify the mechanism of using the Intel(R) SGX technology by developers.</p>
-        <p>The role of these functions is to handle the following tasks:</p>
-        <ul>
-            <li>Call an enclave function from untrusted code, also called an ECALL (enclave call).</li>
-            <li>Call an untrusted function from within an enclave, also called an OCALL (outside call).</li>
-            <li>Handle interrupts.</li>
-            <li>Handle exceptions.</li>
-        </ul>
-        <p>The proxy and bridge functions are generated by the <code>sgx_edger8r</code> tool provided by Intel(R) SGX SDK. It reads an <i>edl</i> file (Enclave Descriptor Language) which describes the functions that form the <i>trusted</i> and <i>untrusted</i> component boundaries within the application.</p>
-        <p>After the enclave is built, a signed version of it is created using the tool <code>sgx_sign</code> also provided by Intel(R) SGX SDK.  It is this signed version may be loaded and executed in the encrypted memory.</p>
-        <p>Enclaves may have some specific properties which are added as meta-information during the signing process.  The meta-information is stored in one configuration xml file per enclave, whose details may be seen in <i>Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS</i>.</p>
-    </body>
-</html>

+ 0 - 23
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introducing_Intel_Software_Guard_Extensions.htm

@@ -1,23 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="556" MadCap:lastWidth="576">
-    <head><title>What can be done with Linux SGX Eclipse Plugin?</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Introducing Intel(R) Software Guard Extensions Eclipse* Plugin</h2>
-        <p>The Intel(R) Software Guard Extensions Eclipse* Plug-in helps the enclave developer to maintain enclaves and untrusted related code inside Eclipse* C/C++ projects.   To use this support, add SGX nature to the C/C++ project.  See <a href="Adding_SGX_Nature_to_a_Project.htm">Adding SGX Nature to a Project</a> for details.</p>
-        <p>Once the SGX nature is added to a project, you will have access to the SGX commands.  SGX nature adds also a folder called <code>sgx</code> to the root of the project, and a Makefile inside it.   All resources of the project managed by Intel(R) Software Guard Extensions Eclipse Plug-inare located inside this directory.  You can build and run enclaves related code using GNU* Make tool through the Makefile.</p>
-        <p>The plugin is generating minimal but ready-to-work code skeletons, complete with their own Makefile having all the required make targets as to call <code>sgx_edger8r</code> tool to generate the proxies and bridges, compile these source, generate a shared object and finally, to sign the enclave with the <code>sgx_sign</code> tool.  This provide a starting point you may build upon.</p>
-    </body>
-</html>

+ 0 - 21
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Introduction.htm

@@ -1,21 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="387" MadCap:lastWidth="576">
-    <head><title>Introduction</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Introduction</h1>
-        <p>This <i>Developer Guide</i> is intended for use by Independent Service Vendors who wish to harden their Linux* applications using Intel(R) SGX Technology, code named Intel(R) Software Guard Extensions. The guide describes the procedure for installation of Intel(R) SGX Plugin for Eclipse* IDE and development of Intel(R) SGX components using the plugin. The Intel(R) SGX Plugin for Eclipse leverages on the Intel(R) Software Guard Extensions Evaluation SDK, which is a collection of APIs, libraries and tools that enable you to develop, build and debug Intel(R) SGX applications in C/C++.</p>
-        <p>To learn more about the Intel(R) Software Guard Extensions Evaluation SDK, see the <i>Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS</i>.</p>&#160;</body>
-</html>

+ 0 - 70
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Legal_Information.htm

@@ -1,70 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns="http://www.w3.org/1999/xhtml" MadCap:lastBlockDepth="5" MadCap:lastHeight="1269" MadCap:lastWidth="537" xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
-    <head><title xmlns="">Legal Information</title>
-        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1>Legal Information</h1>
-        <p>No license (express or implied, by estoppel or otherwise) to any intellectual 
- property rights is granted by this document.</p>
-        <p>Intel disclaims all express and implied warranties, including without 
- limitation, the implied warranties of merchantability, fitness for a particular 
- purpose, and non-infringement, as well as any warranty arising from course 
- of performance, course of dealing, or usage in trade.</p>
-        <p>This document contains information on products, services and/or processes 
- in development. &#160;All information provided here is subject to change 
- without notice. Contact your Intel representative to obtain the latest 
- forecast, schedule, specifications and roadmaps.</p>
-        <p>The products and services described may contain defects or errors known 
- as errata which may cause deviations from published specifications. Current 
- characterized errata are available on request.</p>
-        <p>Intel technologies features and benefits depend on system configuration 
- and may require enabled hardware, software or service activation. Learn 
- more at Intel.com, or from the OEM or retailer.</p>
-        <p>Copies of documents which have an order number and are referenced in 
- this document may be obtained by calling 1-800-548-4725 or by visiting 
- <a href="http://www.intel.com/design/literature.htm">www.intel.com/design/literature.htm</a>.</p>
-        <p>Intel, the Intel logo, Xeon, and Xeon Phi are trademarks of Intel Corporation 
- in the U.S. and/or other countries. </p>
-        <table style="border-left-style: solid;border-left-width: 1px;border-right-style: solid;border-right-width: 1px;border-top-style: solid;border-top-width: 1px;border-bottom-style: solid;border-bottom-width: 1px;">
-            <col />
-            <tr>
-                <th>
-                    <p>Optimization Notice</p>
-                </th>
-            </tr>
-            <tr bgcolor="#CCECFF">
-                <td>
-                    <p>Intel's compilers may or may not optimize to the same degree 
-		 for non-Intel microprocessors for optimizations that are not unique 
-		 to Intel microprocessors. These optimizations include SSE2, SSE3, 
-		 and SSSE3 instruction sets and other optimizations. Intel does 
-		 not guarantee the availability, functionality, or effectiveness 
-		 of any optimization on microprocessors not manufactured by Intel. 
-		 Microprocessor-dependent optimizations in this product are intended 
-		 for use with Intel microprocessors. Certain optimizations not 
-		 specific to Intel microarchitecture are reserved for Intel microprocessors. 
-		 Please refer to the applicable product User and Reference Guides 
-		 for more information regarding the specific instruction sets covered 
-		 by this notice.</p>
-                    <p style="text-align: right;">Notice revision #20110804</p>
-                </td>
-            </tr>
-        </table>
-        <p>* Other names and brands may be claimed as the property of others.</p>
-        <p>© 2016 Intel Corporation.</p>
-    </body>
-</html>

+ 0 - 27
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Prerequisites.htm

@@ -1,27 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="328" MadCap:lastWidth="550">
-    <head><title>Pre-requisites</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Pre-requisites</h2>
-        <p>To use Intel(R) Software Guard Extensions Eclipse Plug-in, install the following softwares:</p>
-        <ul>
-            <li>Eclipse* Mars 1 with CDT IDE for C/C++ Developpers (version 4.5.1).   To use this version, install Java* Development Kit (JDK) or Java* Runtime Environment (JRE)  version 1.8 or above.</li>
-            <li>gcc/g++ tools</li>
-            <li>Openssl*</li>
-            <li>Intel(R) SGX SDK for Linux* OS</li>
-        </ul>
-    </body>
-</html>

+ 50 - 23
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css

@@ -18,17 +18,16 @@ body
 	color: #333333;
 	background-color: #ffffff;
 	font-family: "Intel Clear", Verdana, Arial, sans-serif;
-	font-size: 12pt;
 	margin-left: 30px;
 	margin-right: 30px;
 	margin-bottom: 7%;
 	color: #333333;
 	background-color: #ffffff;
 	font-family: "Intel Clear", Verdana, Arial, sans-serif;
-	font-size: 12pt;
 	margin-left: 30px;
 	margin-right: 30px;
 	margin-bottom: 7%;
+	font-size: 12pt;
 }
 
 .RevUpdate
@@ -126,43 +125,43 @@ h3
 h4
 {
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 }
 
 h5
 {
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 }
 
 h6
 {
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 	color: #0071c5;
-	margin-top: 12pt;
+	margin-top: 10pt;
 	margin-bottom: 5pt;
 	padding-left: 0px;
-	font-size: 12pt;
+	font-size: 10pt;
 }
 
 .relinfo
@@ -178,22 +177,21 @@ h6
 
 caption
 {
-	font-size: 12pt;
 	font-weight: bold;
 	text-align: left;
-	font-size: 12pt;
 	font-weight: bold;
 	text-align: left;
+	font-size: 12pt;
 }
 
 .figcap
 {
 	margin-left: 24px;
-	font-size: 12pt;
+	font-size: 10pt;
 	font-weight: bold;
 	text-align: center;
 	margin-left: 24px;
-	font-size: 12pt;
+	font-size: 10pt;
 	font-weight: bold;
 	text-align: center;
 }
@@ -278,16 +276,15 @@ a.underlined
 
 p
 {
-	font-size: inherit;
 	margin-left: 0px;
 	line-height: 120%;
 	margin-top: 0;
 	margin-bottom: 10px;
-	font-size: inherit;
 	margin-left: 0px;
 	line-height: 120%;
 	margin-top: 0;
 	margin-bottom: 10px;
+	font-size: 12pt;
 }
 
 .p
@@ -312,12 +309,12 @@ table
 	border-collapse: collapse;
 	margin-left: 0px;
 	margin-top: 0.3em;
-	font-size: 12pt;
+	font-size: 10pt;
 	margin-bottom: 5pt;
 	border-collapse: collapse;
 	margin-left: 0px;
 	margin-top: 0.3em;
-	font-size: 12pt;
+	font-size: 10pt;
 }
 
 tr
@@ -336,6 +333,7 @@ DIV.Note
 	border-top-width: 1px;
 	border-bottom-style: solid;
 	border-bottom-width: 1px;
+	font-size: 10pt;
 }
 
 p.NoteTipHead
@@ -347,9 +345,9 @@ p.NoteTipHead
 	line-height: 15pt;
 	margin-left: 0.202cm;
 	font-family: "Verdana", "sans-serif";
-	font-size: 9pt;
 	text-transform: uppercase;
 	text-align: justify;
+	font-size: 12pt;
 }
 
 MadCap|xref
@@ -357,6 +355,7 @@ MadCap|xref
 	color: #0860a8;
 	mc-format: '{paratext}';
 	text-decoration: none;
+	font-size: 12pt;
 }
 
 div.NoteCont
@@ -365,16 +364,44 @@ div.NoteCont
 	border-bottom-width: 1px;
 	border-top-style: solid;
 	border-top-width: 1px;
+	font-size: 10pt;
 }
 
 p.figcap
 {
 	text-align: left;
+	font-size: 12pt;
 }
 
 th
 {
 	text-align: left;
+	font-size: 12pt;
+}
+
+ul
+{
+	font-size: 12pt;
+}
+
+ol
+{
+	font-size: 12pt;
+}
+
+li
+{
+	font-size: 12pt;
+}
+
+b
+{
+	font-size: 12pt;
+}
+
+code
+{
+	font-size: 12pt;
 }
 
 a:link

+ 0 - 31
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Running_Samples_Generated_for_Enclaves.htm

@@ -1,31 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="1123" MadCap:lastWidth="672">
-    <head><title>Running Samples Generated for Enclaves</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Running Samples Generated for Enclaves</h2>
-        <p>Intel(R) Software Guard Extensions Eclipse* Plugin provides an option to generate a sample application together with the enclave code when the enclave is created.  After the project is build, the sample application is built also and ready to run.  You can see the sample application named sample in the enclave directory in Project Explorer.  You can run this sample as a local C/C++ application as shown in the following figure:</p>
-        <p>
-            <img src="Resources/Images/Sample_Application.png" />
-        </p>
-        <p class="figcap">Sample Application</p>
-        <p>See the result of the execution in Eclipse console window as shown below:</p>
-        <p>
-            <img src="Resources/Images/The_Result_of_Running_Samples_Generated_for_Enclaves.png" />
-        </p>
-        <p class="figcap">The Result of Running Samples Generated for Enclaves</p>
-    </body>
-</html>

+ 0 - 97
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_Build_Configurations.htm

@@ -1,97 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="5" MadCap:lastHeight="2892" MadCap:lastWidth="554">
-    <head><title>SGX Build Configurations</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>SGX Build Configurations</h2>
-        <p>There are usually two types of builds that a regular non-SGX project defines:</p>
-        <ul>
-            <li>Debug</li>
-            <li>Release</li>
-        </ul>
-        <p>SGX-enabled projects add to this picture support to build and test SGX-enabled application on non-SGX platforms (or emulator) using simulation libraries. This approach doubles the set of build types, creating four possible combinations.  For these combinations, you need to use different sets of compilation and  linking flags and link different libraries.</p>
-        <p>The non-debug hardware build is meant to give production code, so it requires the maximum attention when signed. The Two Steps Sign schema is required for production enclaves, which involves an external signing facility, not part of Intel SGX SDK.  The other configurations are not meant for production but they have to be signed too.  The simplest and more convenient Single Step schema is used for them.</p>
-        <p>Again for testing purpose, you might want to experiment with a non-production enclave built with release compilation and linking flags, on a real hardware SGX-enabled platform. That would be an enclave built exactly as a production enclave, except for the sign process which would be Single Step. To support the construction of such enclave, there is a hardware non-debug build configuration dubbed <i>Prerelease</i>.</p>
-        <p>So there are five SGX related configurations when SGX Nature is added to a project:</p>
-        <p>
-            <img src="Resources/Images/Intel_SGX_Configurations.png" />
-        </p>
-        <p>Intel(R) SGX Configurations</p>
-        <p>The following table resumes the existing SGX configurations and relate them with compilation/linking flags (debug/non-debug) and signing scheme (single vs. two steps):</p>
-        <p class="tablecap">Intel(R) SGX Configurations</p>
-        <table style="width: 100%;border-left-style: solid;border-left-width: 1px;border-right-style: solid;border-right-width: 1px;border-top-style: solid;border-top-width: 1px;border-bottom-style: solid;border-bottom-width: 1px;">
-            <col />
-            <col />
-            <col />
-            <col />
-            <tbody>
-                <tr>
-                    <th>Configuration Name</th>
-                    <th>Simulation?</th>
-                    <th>Debug?</th>
-                    <th>Signing Schema</th>
-                </tr>
-                <tr>
-                    <td>SGX Hardware Debug</td>
-                    <td>Hardware</td>
-                    <td>Debug</td>
-                    <td>Single Step</td>
-                </tr>
-                <tr>
-                    <td>SGX Hardware Pre-release</td>
-                    <td>Hardware</td>
-                    <td>Non-debug</td>
-                    <td>Single Step</td>
-                </tr>
-                <tr>
-                    <td>SGX Hardware Release</td>
-                    <td>Hardware</td>
-                    <td>Non-debug</td>
-                    <td>Two Step</td>
-                </tr>
-                <tr>
-                    <td>SGX Simulation</td>
-                    <td>Simulation</td>
-                    <td>Non-debug</td>
-                    <td>Single Step</td>
-                </tr>
-                <tr>
-                    <td>SGX Simulation</td>
-                    <td>Debug	Simulation</td>
-                    <td>Debug</td>
-                    <td>Single step</td>
-                </tr>
-            </tbody>
-        </table>
-        <p>Intel® Software Guard Extensions Eclipse Plug-in uses standard GNU* make tool to build the trusted and the untrusted code, using the generated file <code>sgx/Makefile</code>.</p>
-        <p>This fact does not impose any restriction on the build tool chosen for the hosting project. Intel® Software Guard Extensions Eclipse* Plug-in uses its own build configurations which do not interfere with the configurations that you might have in your project.</p>
-        <p>When SGX configurations are selected, by default only code under <code>&lt;root&gt;/sgx</code> directory get built.</p>
-        <p>You can customize SGX configurations as any other Eclipse build configurations from the project properties dialog. For example:</p>
-        <ol>
-            <li>Right-click in Project Explorer Properties → C/C++ Build</li>
-            <li>Uncheck the Use default build command checkbox.</li>
-        </ol>
-        <p>Then you can customize and integrate SGX build process.  You can use Makefile instead of <code>sgx/Makefile</code> in the example shown in the following figure:</p>
-        <p>
-            <img src="Resources/Images/Customization_of_SGX_build_command.png" />
-        </p>
-        <p class="figcap">Customization of SGX Build Command			</p>
-        <p>The build process is done using standard Eclipse interface for build, by example from the main <b>Project</b> menu:			</p>
-        <p>
-            <img src="Resources/Images/Project_Menu.png" />
-        </p>
-        <p class="figcap">Project Menu			</p>
-    </body>
-</html>

+ 0 - 30
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/SGX_title.htm

@@ -1,30 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="391" MadCap:lastWidth="576">
-    <head><title>Intel(R) Software Guard Extensions</title>
-        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h1 class="firsttitle">Intel(R) Software Guard Extensions</h1>
-        <h2>Developer Reference</h2>
-        <p>Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for a
-pplication developers seeking to protect select code and data from disclosure or 
-modification. Intel(R) SGX makes such protections possible through the use of 
-enclaves. Enclaves are protected areas of execution. Application code can be put 
-into an enclave through special instructions and software made available to 
-developers by the Intel(R) SGX SDK.</p>
-        <p><a href="Legal_Information.htm">Legal Information</a>
-        </p>
-    </body>
-</html>

+ 0 - 59
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Two_Steps_Sign_Enclave.htm

@@ -1,59 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1991" MadCap:lastWidth="680">
-    <head><title>Two Steps Sign Enclave</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Two Steps Sign Enclave</h2>
-        <p>To help you develop enclaves, Intel(R) Software Guard Extensions Eclipse Plug-in generates all required structure including:</p>
-        <ul>
-            <li>c/c++ files and header files</li>
-            <li><code>.edl</code> file</li>
-            <li><code>*.config.xml</code> file</li>
-            <li>a sample Makefile</li>
-            <li>a sample signing key</li>
-        </ul>
-        <p>While these structure might be appropriate for development and debugging, you need a 2-step process to integrate your own signing schema for generating  production enclaves.</p>
-        <ol>
-            <li>Generate hash: the signer tool generates signing material from the unsigned compiled enclave and from the configuration file for the enclave.  The signed material comes as an opaque sequence of bytes which are put in a file with extension <code>.hex</code>. This file is used with the external signing facility.  You come back with a signature for the <code>.hex</code> file plus the public key of your signing facility, and proceed to Step 2.</li>
-            <li>Generate signed enclaves : the signer tool generates the final signed enclave.</li>
-        </ol>
-        <p>To complete this task, provide the following input parameters:</p>
-        <ul>
-            <li>The unsigned enclave</li>
-            <li>The configuration file</li>
-            <li>The output file produced when you generate hash (the <code>.hex</code> file)</li>
-            <li>The files produced by the external signing facility: the signature of the .hex file and public key for it</li>
-            <li>The plugin checks if the input parameters are consistent:</li>
-            <li>The <code>.hex</code> file matches the unsigned enclave and the configuration file,</li>
-            <li>The signed material is verified with the public key</li>
-        </ul>
-        <p>If the parameters are consistenet, the production signed enclave is produced.</p>
-        <div class="NoteCont">
-            <p class="NoteTipHead">NOTE:</p>
-            <p>If you generate signed enclave right after generating hash, you can only enter the parameters specific for generating signed enclave.</p>
-        </div>
-        <p>To use the two-step signing function, activate the configuration <b>SGX Hardware Release mode</b>. When this configuration is active, the compilation does not produce a signed enclave, as in the other SGX configurations; the process only produces unsigned enclaves.</p>
-        <p>
-            <img src="Resources/Images/Configure_SGX_Hardware_Release_Mode.png" />
-        </p>
-        <p class="figcap">Configure SGX Hardware Release Mode</p>
-        <p>When you configure the plugin in the <b>SGX Hardware Release Mode</b>, you can see the <b>Generate Hash</b> and <b>Generate Signed Enclave</b> options through <b>Software Guard Extension Tools-&gt;Two Step Sign Enclave</b>.</p>
-        <p>
-            <img src="Resources/Images/Two_Step_Sign_Enclave_Menu.png" />
-        </p>
-        <p class="figcap">Two Step Sign Enclave Menu</p>
-    </body>
-</html>

+ 0 - 39
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_Enclave_Configuration_Files.htm

@@ -1,39 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="987" MadCap:lastWidth="550">
-    <head><title>Updating Enclave Configuration Files</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Updating Enclave Configuration Files</h2>
-        <p>A configuration file is an important part in the definition of an enclave.  Intel(R) SGX SDK signer tool requires such *.xml configuration file as necessary input.</p>
-        <p>To update this configuration file, use the <b>Update Config</b> command:</p>
-        <ol>
-            <li>
-                <p>Right-click on the root project,  <b>Software Extension Guards Tools-&gt;Select Config File</b>.</p>
-                <p>
-                    <img src="Resources/Images/Select_Configuration_File.png" />
-                </p>
-                <p class="figcap">Select Configuration File</p>
-            </li>
-            <li>
-                <p>Click <b>OK</b> or double-click the selected configuration file to open the <b>Enclave Configuration Settings</b> dialog.</p>
-                <p>
-                    <img src="Resources/Images/Enclave_Configuration_Settings.png" />
-                </p>
-                <p class="figcap">Enclave Configuration Settings</p>
-                <p>For details on the meaning of the fields, see <i>Intel(R) Software Guard Extensions Developer Guide</i>.</p>
-            </li>
-        </ol>
-    </body>
-</html>

+ 0 - 37
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Updating_SGX_Enclave_Signing_Key.htm

@@ -1,37 +0,0 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1043" MadCap:lastWidth="652">
-    <head><title>Updating SGX Enclave Signing Key</title>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
-        <h2>Updating SGX Enclave Signing Key</h2>
-        <p>All skeletons enclave samples produced by the plugin contain a sample signing key.  You might want to import another sign key that you already have, or generate a new one.   Use the command <b>Update SGX Enclave Signing Key</b> to complete this task.</p>
-        <ol>
-            <li>Choose  <b>Update SGX Enclave Signing Key</b> by right-click on the project in <b>Project Explorer -&gt; Software Guard Extension Tools</b> menu. The <b>Import or (Re)Generate Enclave Signing Key</b> dialog appears.</li>
-            <li>In the <b>Import or (Re)Generate Enclave Signing Key</b> dialog, click <b>Select</b> to open a file dialog to select the output key.</li>
-            <li>
-                <p>Click <b>Improt Key</b> to update a selected signing key by copying another existing key  or click <b>Generate Key</b> to update the selected signing key by generating a new key. In both cases, the new signature key is put into the file in text field <b>Enclave Signing Key</b>.</p>
-                <p>
-                    <img src="Resources/Images/Import_or_Re_Generate_Enclave_Signing_Key.png" />
-                </p>
-                <p class="figcap">Import or (Re)Generate Enclave Signing Key</p>
-            </li>
-            <li>Click <b>OK</b> to update the enclave signing key.</li>
-        </ol>
-        <p>Under the hood, a new key is generated using openssl*, which needs to be installed on the machine:</p>
-        <p><code>openssl genrsa -out ../../../encl1_private.pem.key.pem -3 3072</code>
-        </p>
-        <p><![CDATA[	]]></p>
-    </body>
-</html>

+ 95 - 96
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/content.html

@@ -1,35 +1,34 @@
-<!--------------------------------------------------------------------------->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--------------------------------------------------------------------------->
+<?xml version='1.0' encoding='utf-8'?>
+<!-- 
+ Copyright (c) 2016 Intel Corporation.
 
-<?xml version="1.0" encoding="utf-8"?>
-<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="4" MadCap:lastHeight="1043" MadCap:lastWidth="652">
-    <head>
-        <link href="Resources/Stylesheets/intel_css_styles.css" rel="stylesheet" type="text/css" />
-    </head>
-    <body>
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
 
-<h1 class="firsttitle" id="SGX_title" >Intel(R) Software Guard Extensions Plug-in for Eclipse*</h1>
+ Contributors:
+     Intel Corporation - initial implementation and documentation
+ -->
+
+<html xmlns:MadCap='http://www.madcapsoftware.com/Schemas/MadCap.xsd' MadCap:lastBlockDepth='4' MadCap:lastHeight='1043' MadCap:lastWidth='652'>
+  <head>
+    <link href='Resources/Stylesheets/intel_css_styles.css' rel='stylesheet' type='text/css' />
+  </head>
+  <body>
+    <div id='SGX_title'>
+        <h1 class="firsttitle">Intel(R) Software Guard Extensions Plug-in for Eclipse*</h1>
         <h2>Developer Guide</h2>
-        <p>Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for a
-pplication developers seeking to protect select code and data from disclosure or 
+        <p>Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for application developers seeking to protect select code and data from disclosure or 
 modification. Intel(R) SGX makes such protections possible through the use of 
 enclaves. Enclaves are protected areas of execution. Application code can be put 
 into an enclave through special instructions and software made available to 
 developers by the Intel(R) SGX SDK.</p>
-        <p><a href="#Legal_Information">Legal Information</a>
+        <p><a href="Legal_Information.htm">Legal Information</a>
         </p>
-    
-
-<h1 id="Legal_Information" >Legal Information</h1>
+    </div>
+    <div id='Legal_Information'>
+        <h1>Legal Information</h1>
         <p>No license (express or implied, by estoppel or otherwise) to any intellectual 
  property rights is granted by this document.</p>
         <p>Intel disclaims all express and implied warranties, including without 
@@ -78,13 +77,13 @@ developers by the Intel(R) SGX SDK.</p>
         </table>
         <p>* Other names and brands may be claimed as the property of others.</p>
         <p>© 2016 Intel Corporation.</p>
-    
-
-<h1 id="Introduction" >Introduction</h1>
-        <p>This <i>Developer Guide</i> is intended for use by Independent Service Vendors who wish to harden their Linux* applications using Intel(R) SGX Technology, code named Intel(R) Software Guard Extensions. The guide describes the procedure for installation of Intel(R) SGX Plugin for Eclipse* IDE and development of Intel(R) SGX components using the plugin. The Intel(R) SGX Plugin for Eclipse leverages on the Intel(R) Software Guard Extensions Evaluation SDK, which is a collection of APIs, libraries and tools that enable you to develop, build and debug Intel(R) SGX applications in C/C++.</p>
-        <p>To learn more about the Intel(R) Software Guard Extensions Evaluation SDK, see the <i>Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS</i>.</p>&#160;
-
-<h2 id="Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin" >Introducing Intel(R) Software Guard Extensions</h2>
+    </div>
+    <div id='Introduction'>
+        <h1>Introduction</h1>
+        <p>This <i>Developer Guide</i> is intended for use by Independent Service Vendors who wish to harden their Linux* applications using Intel(R) SGX Technology, code named Intel(R) Software Guard Extensions. The guide describes the procedure for installation of Intel(R) SGX Plugin for Eclipse* IDE and development of Intel(R) SGX components using the plugin. The Intel(R) SGX Plugin for Eclipse leverages on the Intel(R) Software Guard Extensions SDK, which is a collection of APIs, libraries and tools that enable you to develop, build and debug Intel(R) SGX applications in C/C++.</p>
+        <p>To learn more about the Intel(R) Software Guard Extensions SDK, see the <i>Intel(R) Software Guard Extensions SDK for Linux* OS Developer Reference</i>.</p>&#160;</div>
+    <div id='Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin'>
+        <h2>Introducing Intel(R) Software Guard Extensions</h2>
         <p>Intel(R) Software Guard Extensions is a new Intel technology, whose objective is to enable a high level of protection of secrets. It operates by allocating hardware-protected memory where code and data reside. The protected memory area within an application process is called an enclave. Data within the enclave memory can only be accessed by code that resides within that enclave. Enclave code can be invoked by special instructions.</p>
         <p>An enclave can be built and loaded as a shared object.</p>
         <p>Throughout this document, Intel(R) SGX refers to Intel(R) Software Guard Extensions.</p>
@@ -105,22 +104,22 @@ developers by the Intel(R) SGX SDK.</p>
         </ul>
         <p>The proxy and bridge functions are generated by the <code>sgx_edger8r</code> tool provided by Intel(R) SGX SDK. It reads an <i>edl</i> file (Enclave Descriptor Language) which describes the functions that form the <i>trusted</i> and <i>untrusted</i> component boundaries within the application.</p>
         <p>After the enclave is built, a signed version of it is created using the tool <code>sgx_sign</code> also provided by Intel(R) SGX SDK.  It is this signed version may be loaded and executed in the encrypted memory.</p>
-        <p>Enclaves may have some specific properties which are added as meta-information during the signing process.  The meta-information is stored in one configuration xml file per enclave, whose details may be seen in <i>Intel(R) Software Guard Extensions Evaluation SDK for Linux* OS</i>.</p>
-    
-
-<h2 id="Introducing_Intel_Software_Guard_Extensions" >Introducing Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
-        <p>The Intel(R) Software Guard Extensions Eclipse* Plug-in helps the enclave developer to maintain enclaves and untrusted related code inside Eclipse* C/C++ projects.   To use this support, add SGX nature to the C/C++ project.  See <a href="#Adding_SGX_Nature_to_a_Project">Adding SGX Nature to a Project</a> for details.</p>
+        <p>Enclaves may have some specific properties which are added as meta-information during the signing process.  The meta-information is stored in one configuration xml file per enclave, whose details may be seen in <i>Intel(R) Software Guard Extensions SDK for Linux* OS</i>.</p>
+    </div>
+    <div id='Introducing_Intel_Software_Guard_Extensions'>
+        <h2>Introducing Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
+        <p>The Intel(R) Software Guard Extensions Eclipse* Plug-in helps the enclave developer to maintain enclaves and untrusted related code inside Eclipse* C/C++ projects.   To use this support, add SGX nature to the C/C++ project.  See <a href="Adding_SGX_Nature_to_a_Project.htm">Adding SGX Nature to a Project</a> for details.</p>
         <p>Once the SGX nature is added to a project, you will have access to the SGX commands.  SGX nature adds also a folder called <code>sgx</code> to the root of the project, and a Makefile inside it.   All resources of the project managed by Intel(R) Software Guard Extensions Eclipse Plug-inare located inside this directory.  You can build and run enclaves related code using GNU* Make tool through the Makefile.</p>
         <p>The plugin is generating minimal but ready-to-work code skeletons, complete with their own Makefile having all the required make targets as to call <code>sgx_edger8r</code> tool to generate the proxies and bridges, compile these source, generate a shared object and finally, to sign the enclave with the <code>sgx_sign</code> tool.  This provide a starting point you may build upon.</p>
-    
-
-<h1 id="Getting_Started" >Getting Started with Intel(R) Software Guard Extensions Eclipse* Plug-in</h1>
+    </div>
+    <div id='Getting_Started'>
+        <h1>Getting Started with Intel(R) Software Guard Extensions Eclipse* Plug-in</h1>
         <p>This section contains steps to set up your Intel(R) Software Guard Extensions Eclipse* Plug-in on a Linux* system, including necessary softwares, steps to install the product, and steps to configure your preferred product directory.</p>
         <p>•	Pre-requisites</p>
         <p>•	Installing Intel(R) Software Guard Extensions Eclipse* Plug-in</p>
-        <p>•	Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</p>&#160;
-
-<h2 id="Prerequisites" >Pre-requisites</h2>
+        <p>•	Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</p>&#160;</div>
+    <div id='Prerequisites'>
+        <h2>Pre-requisites</h2>
         <p>To use Intel(R) Software Guard Extensions Eclipse Plug-in, install the following softwares:</p>
         <ul>
             <li>Eclipse* Mars 1 with CDT IDE for C/C++ Developpers (version 4.5.1).   To use this version, install Java* Development Kit (JDK) or Java* Runtime Environment (JRE)  version 1.8 or above.</li>
@@ -128,9 +127,9 @@ developers by the Intel(R) SGX SDK.</p>
             <li>Openssl*</li>
             <li>Intel(R) SGX SDK for Linux* OS</li>
         </ul>
-    
-
-<h2 id="Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin" >Installing Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
+    </div>
+    <div id='Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin'>
+        <h2>Installing Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
         <p>Install Intel(R) Software Guard Extensions Eclipse* Plug-in as a regular Eclipse Plugin:</p>
         <ol>
             <li>Download the zip archive of Intel(R) Software Guard Extensions Eclipse Plug-in from Intel Site</li>
@@ -151,9 +150,9 @@ developers by the Intel(R) SGX SDK.</p>
             <li>Press <b>OK</b>  to add the archive as a repository.</li>
             <li>In the <b>Install</b> dialog, select the <b>Software Guard Extensions Plugin</b> check-box and proceed with the usual steps.</li>
         </ol>
-    
-
-<h2 id="Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in" >Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
+    </div>
+    <div id='Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in'>
+        <h2>Configuring Intel(R) Software Guard Extensions Eclipse* Plug-in</h2>
         <p>If you do not install Intel(R) SGX SDK for Linux* OS in the default location, you need to specify the path for Intel SGX SDK  using the following steps:</p>
         <ol>
             <li>
@@ -165,9 +164,9 @@ developers by the Intel(R) SGX SDK.</p>
             </li>
             <li>Enter the path for Intel SGX SDK for Linux OS in the <b>SGX SDK Directory</b> field.</li>
         </ol>
-    
-
-<h1 id="Command_Reference" >Command Reference</h1>
+    </div>
+    <div id='Command_Reference'>
+        <h1>Command Reference</h1>
         <p>This topic provides the command reference for the following scenarios of using Intel(R) Software Guard Extensions Eclipse* Plug-in:</p>
         <ul>
             <li>Adding SGX nature to a project</li>
@@ -178,14 +177,14 @@ developers by the Intel(R) SGX SDK.</p>
             <li>Updating enclave configuration files</li>
             <li>Two steps sign enclave</li>
         </ul>
-        <p>All commands brought by Intel(R) Software Guard Extensions Eclipse Plug-in are available by right-clicking on the Project root in Project explorer view in menu <b>Software Guard Extension Tools</b>:</p>&#160;<p><img src="Resources/Images/Project_Explorer.png" /></p><p class="figcap">Project Explorer</p>&#160;
-
-<h2 id="Adding_SGX_Nature_to_a_Project" >Adding SGX Nature to a Project</h2>
+        <p>All commands brought by Intel(R) Software Guard Extensions Eclipse Plug-in are available by right-clicking on the Project root in Project explorer view in menu <b>Software Guard Extension Tools</b>:</p>&#160;<p><img src="Resources/Images/Project_Explorer.png" /></p><p class="figcap">Project Explorer</p>&#160;</div>
+    <div id='Adding_SGX_Nature_to_a_Project'>
+        <h2>Adding SGX Nature to a Project</h2>
         <p>The <i>nature</i> of an Eclipse project is a concept defined by an Eclipse Platform which allows a plug-in to tag a project as a specific kind of project.   Intel(R) Software Guard Extensions  uses an <i>SGX nature</i> to add SGX-specific behavior to projects.  Project natures are defined by plug-ins, and are typically added or removed per-project when the user performs some action defined by the plug-in.</p>
-        <p>To use Intel(R) Software Guard Extensions Eclipse Plug-in in your project, you need to add SGX nature to it.   You may either add SGX nature to a pre-existing C/C++ project or create a project with SGX nature from start.  See <a href="#Adding_SGX_Nature_to_a_non_SGX_project">Adding SGX Nature to a non-SGX project</a> and <a href="#Creating_a_New_C_C_Project_with_SGX_Nature">Creating a New C/C++ Project with SGX Nature</a> for how to complete these tasks.</p>
-    
-
-<h3 id="Adding_SGX_Nature_to_a_non_SGX_project" >Adding SGX Nature to a non-SGX project</h3>
+        <p>To use Intel(R) Software Guard Extensions Eclipse Plug-in in your project, you need to add SGX nature to it.   You may either add SGX nature to a pre-existing C/C++ project or create a project with SGX nature from start.  See <a href="Adding_SGX_Nature_to_a_non_SGX_project.htm">Adding SGX Nature to a non-SGX project</a> and <a href="Creating_a_New_C_C_Project_with_SGX_Nature.htm">Creating a New C/C++ Project with SGX Nature</a> for how to complete these tasks.</p>
+    </div>
+    <div id='Adding_SGX_Nature_to_a_non_SGX_project'>
+        <h3>Adding SGX Nature to a non-SGX project</h3>
         <p>When you have a C/C++ project created without Intel SGX, you cannot use Intel SGX support.  In this case, you need to add SGX nature to this project to use Intel SGX support:</p>
         <ol>
             <li>Right-click on the project root <![CDATA[	]]></li>
@@ -221,9 +220,9 @@ developers by the Intel(R) SGX SDK.</p>
                 <p class="figcap">Configurations Specific to Intel(R) SGX Technology</p>
             </li>
         </ul>
-    
-
-<h3 id="Creating_a_New_C_C_Project_with_SGX_Nature" >Creating a New C/C++ Project with SGX Nature</h3>
+    </div>
+    <div id='Creating_a_New_C_C_Project_with_SGX_Nature'>
+        <h3>Creating a New C/C++ Project with SGX Nature</h3>
         <p>You can create a new project with SGX nature. To create such a project, follow these steps:</p>
         <ol>
             <li>
@@ -241,9 +240,9 @@ developers by the Intel(R) SGX SDK.</p>
             <p class="NoteTipHead">NOTE:</p>
             <p>Projects created following the subcategories under <b>C/C++ with SGX Enabled</b> are identical with their standard counterparts, except that they have SGX Nature added.  There is no difference between creating a C or C++ project with SGX enabled, or creating a standard C/C++ project and launch <b>Add SGX nature</b> from it, as described in precedent paragraph.</p>
         </div>
-    
-
-<h2 id="Adding_an_SGX_Enclave" >Adding an SGX Enclave</h2>
+    </div>
+    <div id='Adding_an_SGX_Enclave'>
+        <h2>Adding an SGX Enclave</h2>
         <p>After you add the SGX nature to a project, you can start creating a minimal but complete skeleton for a new enclave:</p>
         <ol>
             <li>Right-click on the project root in <b>Project Explorer</b>.</li>
@@ -278,9 +277,9 @@ developers by the Intel(R) SGX SDK.</p>
             <p class="NoteTipHead">NOTE:</p>
             <p>If you select the <b>Generate sample untrusted application</b> checkbox, ecalls from the untrusted part are not be resolved by Eclipse C/C++ indexer. These functions are marked with a red line. The declaration of these ecalls resides in the unstrusted stub header which is generated during the build proces and is not indexed by Eclipse. To resolve this problem, right-click on project root and select <b>Index → Freshen All Files</b>.</p>
         </div>
-    
-
-<h2 id="Adding_an_SGX_Trusted_Library" >Adding an SGX Trusted Library</h2>
+    </div>
+    <div id='Adding_an_SGX_Trusted_Library'>
+        <h2>Adding an SGX Trusted Library</h2>
         <p>Trusted Static Libraries helps enclave author  have libraries of shared code to be reused by enclaves, in exactly the same manner as usual static <code>libxxx.a</code> libraries are used to share code between regular non-SGX applications.  The plugin adds a command to generate the skeleton of a trusted shared library.</p>
         <p>To add a new SGX Trusted Library:</p>
         <ol>
@@ -299,9 +298,9 @@ developers by the Intel(R) SGX SDK.</p>
                 <p class="figcap">A Generated Trusted Library</p>
             </li>
         </ol>
-    
-
-<h2 id="Adding_an_SGX_Untrusted_Module" >Adding an SGX Untrusted Module</h2>
+    </div>
+    <div id='Adding_an_SGX_Untrusted_Module'>
+        <h2>Adding an SGX Untrusted Module</h2>
         <p>Add an untrusted module to generate the untrusted stubs so you use an enclave, provided you have access to its <code>.edl</code> file.  The enclave might have been built in the current project or in a different project.</p>
         <p>To use trusted functionality of an enclave for which its <code>*.edl</code> is known, use the command <b>Add SGX Untrusted Module</b>:</p>
         <ol>
@@ -320,9 +319,9 @@ developers by the Intel(R) SGX SDK.</p>
                 <p class="figcap">Copying the Untrusted Module to a Project</p>
             </li>
         </ol>
-    
-
-<h2 id="Updating_SGX_Enclave_Signing_Key" >Updating SGX Enclave Signing Key</h2>
+    </div>
+    <div id='Updating_SGX_Enclave_Signing_Key'>
+        <h2>Updating SGX Enclave Signing Key</h2>
         <p>All skeletons enclave samples produced by the plugin contain a sample signing key.  You might want to import another sign key that you already have, or generate a new one.   Use the command <b>Update SGX Enclave Signing Key</b> to complete this task.</p>
         <ol>
             <li>Choose  <b>Update SGX Enclave Signing Key</b> by right-click on the project in <b>Project Explorer -&gt; Software Guard Extension Tools</b> menu. The <b>Import or (Re)Generate Enclave Signing Key</b> dialog appears.</li>
@@ -340,9 +339,9 @@ developers by the Intel(R) SGX SDK.</p>
         <p><code>openssl genrsa -out ../../../encl1_private.pem.key.pem -3 3072</code>
         </p>
         <p><![CDATA[	]]></p>
-    
-
-<h2 id="Updating_Enclave_Configuration_Files" >Updating Enclave Configuration Files</h2>
+    </div>
+    <div id='Updating_Enclave_Configuration_Files'>
+        <h2>Updating Enclave Configuration Files</h2>
         <p>A configuration file is an important part in the definition of an enclave.  Intel(R) SGX SDK signer tool requires such *.xml configuration file as necessary input.</p>
         <p>To update this configuration file, use the <b>Update Config</b> command:</p>
         <ol>
@@ -362,9 +361,9 @@ developers by the Intel(R) SGX SDK.</p>
                 <p>For details on the meaning of the fields, see <i>Intel(R) Software Guard Extensions Developer Guide</i>.</p>
             </li>
         </ol>
-    
-
-<h2 id="Two_Steps_Sign_Enclave" >Two Steps Sign Enclave</h2>
+    </div>
+    <div id='Two_Steps_Sign_Enclave'>
+        <h2>Two Steps Sign Enclave</h2>
         <p>To help you develop enclaves, Intel(R) Software Guard Extensions Eclipse Plug-in generates all required structure including:</p>
         <ul>
             <li>c/c++ files and header files</li>
@@ -403,9 +402,9 @@ developers by the Intel(R) SGX SDK.</p>
             <img src="Resources/Images/Two_Step_Sign_Enclave_Menu.png" />
         </p>
         <p class="figcap">Two Step Sign Enclave Menu</p>
-    
-
-<h3 id="Generate_Hash" >Generate Hash</h3>
+    </div>
+    <div id='Generate_Hash'>
+        <h3>Generate Hash</h3>
         <p>Generating hash is the first step in the 2-Steps signing process.To generate hash, use the following steps:</p>
         <ol>
             <li>
@@ -431,9 +430,9 @@ developers by the Intel(R) SGX SDK.</p>
         </p>
         <p class="figcap">Generate Signed Enclave Dialog with Pre-configurations</p>
         <p>If you click <b>Cancel</b> in the <b>Generate Signed Enclave</b> dialog, you can continue the signing process later using the <b>Generate Signed Enclave</b> command.</p>
-    
-
-<h3 id="Generate_Signed_Enclaves" >Generate Signed Enclaves</h3>
+    </div>
+    <div id='Generate_Signed_Enclaves'>
+        <h3>Generate Signed Enclaves</h3>
         <p>Generating signed enclave is the second step in the 2-Steps signing process.  You should have the following files to complete this step:</p>
         <ul>
             <li>The <code>.hex</code> file generated with <b>Generate Hash</b> command</li>
@@ -452,16 +451,16 @@ developers by the Intel(R) SGX SDK.</p>
             </li>
             <li>Enter the inputs to all the fields and click <b>OK</b>.</li>
         </ol>
-    
-
-<h1 id="Building_and_Running_SGX_Code" >Building and Running SGX Code</h1>
+    </div>
+    <div id='Building_and_Running_SGX_Code'>
+        <h1>Building and Running SGX Code</h1>
         <p>This section describes the following topics about building and running SGX code:</p>
         <ul>
             <li>SGX build configurations</li>
             <li>Running samples generated for enclaves</li>
-        </ul>&#160;
-
-<h2 id="SGX_Build_Configurations" >SGX Build Configurations</h2>
+        </ul>&#160;</div>
+    <div id='SGX_Build_Configurations'>
+        <h2>SGX Build Configurations</h2>
         <p>There are usually two types of builds that a regular non-SGX project defines:</p>
         <ul>
             <li>Debug</li>
@@ -539,9 +538,9 @@ developers by the Intel(R) SGX SDK.</p>
             <img src="Resources/Images/Project_Menu.png" />
         </p>
         <p class="figcap">Project Menu			</p>
-    
-
-<h2 id="Running_Samples_Generated_for_Enclaves" >Running Samples Generated for Enclaves</h2>
+    </div>
+    <div id='Running_Samples_Generated_for_Enclaves'>
+        <h2>Running Samples Generated for Enclaves</h2>
         <p>Intel(R) Software Guard Extensions Eclipse* Plugin provides an option to generate a sample application together with the enclave code when the enclave is created.  After the project is build, the sample application is built also and ready to run.  You can see the sample application named sample in the enclave directory in Project Explorer.  You can run this sample as a local C/C++ application as shown in the following figure:</p>
         <p>
             <img src="Resources/Images/Sample_Application.png" />
@@ -552,6 +551,6 @@ developers by the Intel(R) SGX SDK.</p>
             <img src="Resources/Images/The_Result_of_Running_Samples_Generated_for_Enclaves.png" />
         </p>
         <p class="figcap">The Result of Running Samples Generated for Enclaves</p>
-    
-</body>
+    </div>
+  </body>
 </html>

+ 44 - 90
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/toc.xml

@@ -1,90 +1,44 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--                                                                       -->
-<!-- Copyright (c) 2016 Intel Corporation.				   -->
-<!-- 									   -->
-<!-- All rights reserved. This program and the accompanying materials	   -->
-<!-- are made available under the terms of the Eclipse Public License v1.0 -->
-<!-- which accompanies this distribution, and is available at		   -->
-<!-- http://www.eclipse.org/legal/epl-v10.html				   -->
-<!-- 									   -->
-<!-- Contributors:							   -->
-<!--     Intel Corporation - initial implementation and documentation	   -->
-<!--                                                                       -->
-<toc     label="Intel(R) SGX Plugin* Developer Guide"
-    topic="html/content.html#SGX_title" >
-  <topic
-    label="Legal Information"
-    href="html/content.html#Legal_Information" />
-  <topic
-    label="Introduction"
-    href="html/content.html#Introduction">
-    <topic
-      label="Introducing Intel(R) SGX"
-      href="html/content.html#Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin" />
-    <topic
-      label="Introducing Intel(R) SGX Plugin"
-      href="html/content.html#Introducing_Intel_Software_Guard_Extensions" />
-  </topic>
-  <topic
-    label="Getting Started with Intel(R) SGX Plugin"
-    href="html/content.html#Getting_Started">
-    <topic
-      label="Pre-requisites"
-      href="html/content.html#Prerequisites" />
-    <topic
-      label="Installing Intel(R) SGX Plugin"
-      href="html/content.html#Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin" />
-    <topic
-      label="Configuring Intel(R) SGX Plugin"
-      href="html/content.html#Configuring_Intel_Software_Guard_Extensions_Eclipse_Plugin" />
-  </topic>
-  <topic
-    label="Command Reference"
-    href="html/content.html#Command_Reference">
-    <topic
-      label="Adding SGX Nature to a Project"
-      href="html/content.html#Adding_SGX_Nature_to_a_Project">
-      <topic
-        label="Adding SGX Nature to a non-SGX project"
-        href="html/content.html#Adding_SGX_Nature_to_a_non_SGX_project" />
-      <topic
-        label="Creating a New C/C++ Project with SGX Nature"
-        href="html/content.html#Creating_a_New_C_C_Project_with_SGX_Nature" />
-    </topic>
-    <topic
-      label="Adding an SGX Enclave"
-      href="html/content.html#Adding_an_SGX_Enclave" />
-    <topic
-      label="Adding an SGX Trusted Library"
-      href="html/content.html#Adding_an_SGX_Trusted_Library" />
-    <topic
-      label="Adding an SGX Untrusted Module"
-      href="html/content.html#Adding_an_SGX_Untrusted_Module" />
-    <topic
-      label="Updating SGX Enclave Signing Key"
-      href="html/content.html#Updating_SGX_Enclave_Signing_Key" />
-    <topic
-      label="Updating Enclave Configuration Files"
-      href="html/content.html#Updating_Enclave_Configuration_Files" />
-    <topic
-      label="Two Steps Sign Enclave"
-      href="html/content.html#Two_Steps_Sign_Enclave">
-      <topic
-        label="Generate Hash"
-        href="html/content.html#Generate_Hash" />
-      <topic
-        label="Generate Signed Enclaves"
-        href="html/content.html#Generate_Signed_Enclaves" />
-    </topic>
-  </topic>
-  <topic
-    label="Building and Running SGX Code"
-    href="html/content.html#Building_and_Running_SGX_Code">
-    <topic
-      label="SGX Build Configurations"
-      href="html/content.html#SGX_Build_Configurations" />
-    <topic
-      label="Running Samples Generated for Enclaves"
-      href="html/content.html#Running_Samples_Generated_for_Enclaves" />
-  </topic>
-</toc>
+<?xml version='1.0' encoding='utf-8'?>
+<!-- 
+ Copyright (c) 2016 Intel Corporation.				   
+ 									   
+ All rights reserved. This program and the accompanying materials	   
+ are made available under the terms of the Eclipse Public License v1.0 
+ which accompanies this distribution, and is available at		   
+ http://www.eclipse.org/legal/epl-v10.html				   
+ 									   
+ Contributors:							   
+     Intel Corporation - initial implementation and documentation	   
+ -->
+
+<toc href='html/content.html#SGX_title' label='Intel(R) SGX Plugin Developer Guide'>
+  <topic label='Legal Information' href='html/content.html#Legal_Information' />
+  <topic label='Introduction' href='html/content.html#Introduction'>
+    <topic label='Introducing Intel(R) SGX' href='html/content.html#Introducing_Intel_Software_Guard _Extensions_Eclipse_Plugin' />
+    <topic label='Introducing Intel(R) SGX Plug-in' href='html/content.html#Introducing_Intel_Software_Guard_Extensions' />
+  </topic>
+  <topic label='Getting Started with Intel(R) SGX Plug-in' href='html/content.html#Getting_Started'>
+    <topic label='Pre-requisites' href='html/content.html#Prerequisites' />
+    <topic label='Installing Intel(R) SGX Plug-in' href='html/content.html#Installing_Intel_Software_Guard_Extensions_Eclipse_Plugin' />
+    <topic label='Configuring Intel(R) SGX Plug-in' href='html/content.html#Configuring_Intel_Software_Guard_Extensions_Eclipse_Plug-in' />
+  </topic>
+  <topic label='Command Reference' href='html/content.html#Command_Reference'>
+    <topic label='Adding SGX Nature to a Project' href='html/content.html#Adding_SGX_Nature_to_a_Project'>
+      <topic label='Adding SGX Nature to a non-SGX project' href='html/content.html#Adding_SGX_Nature_to_a_non_SGX_project' />
+      <topic label='Creating a New C/C++ Project with SGX Nature' href='html/content.html#Creating_a_New_C_C_Project_with_SGX_Nature' />
+    </topic>
+    <topic label='Adding an SGX Enclave' href='html/content.html#Adding_an_SGX_Enclave' />
+    <topic label='Adding an SGX Trusted Library' href='html/content.html#Adding_an_SGX_Trusted_Library' />
+    <topic label='Adding an SGX Untrusted Module' href='html/content.html#Adding_an_SGX_Untrusted_Module' />
+    <topic label='Updating SGX Enclave Signing Key' href='html/content.html#Updating_SGX_Enclave_Signing_Key' />
+    <topic label='Updating Enclave Configuration Files' href='html/content.html#Updating_Enclave_Configuration_Files' />
+    <topic label='Two Steps Sign Enclave' href='html/content.html#Two_Steps_Sign_Enclave'>
+      <topic label='Generate Hash' href='html/content.html#Generate_Hash' />
+      <topic label='Generate Signed Enclaves' href='html/content.html#Generate_Signed_Enclaves' />
+    </topic>
+  </topic>
+  <topic label='Building and Running SGX Code' href='html/content.html#Building_and_Running_SGX_Code'>
+    <topic label='SGX Build Configurations' href='html/content.html#SGX_Build_Configurations' />
+    <topic label='Running Samples Generated for Enclaves' href='html/content.html#Running_Samples_Generated_for_Enclaves' />
+  </topic>
+</toc>

+ 0 - 1
Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/trusted/Enclave1.config.xml

@@ -1,4 +1,3 @@
-<!-- Please refer to User's Guide for the explanation of each field -->
 <EnclaveConfiguration>
   <ProdID>0</ProdID>
   <ISVSVN>0</ISVSVN>

+ 3 - 1
Linux_SGXEclipsePlugin/build_directory/sites/site.xml

@@ -17,5 +17,7 @@
    <feature url="features/com.intel.sgx.feature_1.0.1.qualifier.jar" id="com.intel.sgx.feature" version="1.0.1.qualifier">
       <category name="com.intel.security.sgx"/>
    </feature>
-   <category-def name="com.intel.security.sgx" label="SGX Eclipse Plugin"/>
+   <category-def name="com.intel.security.sgx" label="SGX Eclipse Plugin">
+      <description>SGX Eclipse Plugin 1.0.1.qualifier</description>
+   </category-def>
 </site>

+ 1 - 1
Linux_SGXEclipsePlugin/clean.sh

@@ -13,7 +13,7 @@ rm -fv build_directory/features/com.intel.sgx.feature/build.xml
 rm -fv build_directory/features/com.intel.sgx.feature/*.zip
 rm -rfv build_directory/nestedJars
 rm -rfv build_directory/updatesite/sgx-eclipse-plugin
-find . -name "*.zip" | xargs rm -rfv
+find . -name "*.zip" ! -name  "eclipse_mars.v4.5.1_x64.zip" | xargs rm -rfv
 find . -name "javaCompiler*" | xargs rm -rfv
 find . -name "@*" | xargs rm -rfv
 find build_directory -maxdepth 1 -mindepth 1 | grep -v "features" | grep -v "plugins" | grep -v "sites" | grep -v "updatesite" | xargs rm -frv

+ 8 - 7
Linux_SGXEclipsePlugin/readme.txt

@@ -1,21 +1,22 @@
-The eclipse plugin build from commandline requires the following variables to be set
+The eclipse plugin build from command line requires the following variables to be set.
 
 $ECLIPSE_HOME - Path to eclipse home. In order to build the plugin eclipse needs to be installed.
-$RELEASE_ID - The release id for the plugin.
-
-The plugin has been tested with the following Eclipse ADT version
-
-Build: v22.3.0-887826
+$RELEASE_ID - The release id for the plugin. The release id should be changed for each source codes updates.
+$DELETE_CURRENT_ECLIPSE - Delete current eclipse or not. Generally this variable is set to false.
 
 The following plugins are pre-requisites to be installed in Eclipse before trying to build the plugin.
 
 1. Eclipse IDE for C/C++ Developers  4.5.1.20150917-1200 (tested_version)
 2. Eclipse PDE Plug-in Developer Resources   3.11.1.v20150904-0345 (tested_version)
 
+run ./build.sh from command line under current directory.
+Once the build script is run, the folder build_directory/updatesite/sgx-eclipse-plugin contains the update site. This is the path that needs to be provided to the eclipse while doing installation.
 
 If the sgx eclipse plugin is already installed to eclipse and to build and install a newer version, uninstall the old version and start eclipse with the -clean option.
 Then try to build the new version of the plugin and install it in eclipse.
 
 http://wiki.eclipse.org/FAQ_How_do_I_remove_a_plug-in%3F
 
-Once the build script is run, the folder build_directory/updatesite/sgx-eclipse-plugin contains the update site. This is the path that needs to be provided to the eclipse while doing installation.
+The plugin has been tested with the following Eclipse ADT version
+
+Build: v22.3.0-887826

+ 0 - 34
Linux_SGXEclipsePlugin/src/main/groovy/preprocessHtml.groovy

@@ -1,34 +0,0 @@
-import groovy.xml.MarkupBuilder
-import groovy.xml.StreamingMarkupBuilder
-
-
-println "Hello, Script!!!"
-
-
-
-def fragments = new XmlParser(false, true).parseText("<html><body></body></html>")
-
-def resultFile = new File('/home/mlutescu/0_WORK/SGXUserGuide/developer_guide_eclipse_plugin/Output/WebHelp/Content/test.html')
-
-if (resultFile.exists()) {
-    resultFile.delete()
-}
-
-def fltoc = new File('/home/mlutescu/0_WORK/SGXUserGuide/developer_guide_eclipse_plugin/Project/TOCs/Master.fltoc')
-def toc = (new XmlParser()).parse(fltoc)
-def contentDir = new File(fltoc, '../../../').canonicalPath
-
-def PrintWriter pw = new PrintWriter(new FileWriter(resultFile))
-
-
-toc.TocEntry['**'].each { tocEntry ->
-    def htmlFile = new File(contentDir, "${tocEntry.'@Link'}")
-
-
-    println htmlFile.text
-}
-
-
-
-println groovy.xml.XmlUtil.serialize( fragments)
-

+ 4 - 12
README.md

@@ -21,7 +21,7 @@ See CONTRIBUTING.md for details.
 
 Documentation
 -------------
-- [Intel(R) SGX for Linux\* OS][1] project home page on [01.org](http://01.org)
+- [Intel(R) SGX for Linux\* OS][1] project home page on [01.org](https://01.org)
 - [Intel(R) SGX Programming Reference][2]
 [1]: https://01.org/intel-softwareguard-extensions
 [2]: https://software.intel.com/sites/default/files/managed/48/88/329298-002.pdf
@@ -44,7 +44,7 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
   $ sudo apt-get install libcurl4-openssl-dev protobuf-compiler protobuf-c-compiler libprotobuf-dev libprotobuf-c0-dev
 ```
 - Use the script `download_prebuilt.sh` inside source code package to download prebuilt binaries to prebuilt folder  
-  You may need set http proxy for wget tool used by the script (such as `export http_proxy=http://test-proxy:test-port`)  
+  You may need set https proxy for wget tool used by the script (such as `export https_proxy=http://test-proxy:test-port`)  
 ```
   $ ./download_prebuilt.sh
 ```
@@ -92,16 +92,12 @@ Install Intel(R) SGX SDK
 ```
 
 ###Install Intel(R) SGX SDK
-To install Intel(R) SGX SDK, execute the installer with root privilege:
+To install Intel(R) SGX SDK, enter the following commands:
 ```
 $ cd linux/installer/bin
-$ sudo ./sgx_linux_x64_sdk_${version}.bin 
+$ ./sgx_linux_x64_sdk_${version}.bin 
 ```
 ###Test Intel(R) SGX SDK Package with the Sample Codes
-- Copy the sample codes installed by Intel(R) SGX SDK package into your work folder, such as  
-```
-  $ cp -r /opt/intel/sgxsdk/SampleCode ~
-```
 - Compile and run each sample codes in the simulation mode to make sure the package works well.  
 ```
   $ cd SampleCode/LocalAttestation
@@ -114,10 +110,6 @@ $ sudo ./sgx_linux_x64_sdk_${version}.bin
 If you use an SGX hardware enabled machine, you need to run the sample codes in the hardware mode.
 Ensure that you install SGX driver and Intel(R) SGX PSW installer on the machine.  
 See the topic, Install Intel(R) SGX PSW, on how to install the PSW package.
-- Copy the sample codes installed by the Intel(R) SGX SDK package into your work folder, such as  
-```
-  $ cp -r /opt/intel/sgxsdk/SampleCode ~
-```
 - Compile and run each sample codes in the debug mode.  
 ```
   $ cd SampleCode/LocalAttestation

+ 9 - 1
SampleCode/LocalAttestation/Makefile

@@ -131,6 +131,14 @@ Enclave_Cpp_Files_3 := $(wildcard Enclave3/*.cpp)
 Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I./LocalAttestationCode -I./Include
 
 Enclave_Compile_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
+
+# To generate a proper enclave, it is recommended to follow below guideline to link the trusted libraries:
+#    1. Link sgx_trts with the `--whole-archive' and `--no-whole-archive' options,
+#       so that the whole content of trts is included in the enclave.
+#    2. For other libraries, you just need to pull the required symbols.
+#       Use `--start-group' and `--end-group' to link these libraries.
+# Do NOT move the libraries linked with `--start-group' and `--end-group' within `--whole-archive' and `--no-whole-archive' options.
+# Otherwise, you may get some undesirable errors.
 Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
 	-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
 	-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -L. -lLocalAttestation_Trusted -l$(Service_Library_Name) -Wl,--end-group \
@@ -162,7 +170,7 @@ all: $(Trust_Lib_Name) $(UnTrustLib_Name) Enclave1.so Enclave2.so Enclave3.so $(
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <key1> -enclave Enclave1.so -out <$(Enclave_Name_1)> -config Enclave1/Enclave1.config.xml"
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <key2> -enclave Enclave2.so -out <$(Enclave_Name_2)> -config Enclave2/Enclave2.config.xml"
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <key3> -enclave Enclave3.so -out <$(Enclave_Name_3)> -config Enclave3/Enclave3.config.xml"
-	@echo "You can also sign the enclaves using an external signing tool. See User's Guide for more details."
+	@echo "You can also sign the enclaves using an external signing tool."
 	@echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW."
 else
 all: $(Trust_Lib_Name) $(UnTrustLib_Name) $(Enclave_Name_1) $(Enclave_Name_2) $(Enclave_Name_3) $(App_Name)

+ 9 - 1
SampleCode/PowerTransition/Makefile

@@ -124,6 +124,14 @@ Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX
 Enclave_Compile_CFlags := -nostdinc -ffreestanding -fvisibility=hidden -fpie \
 			 $(Enclave_Include_Paths)
 Enclave_Compile_CXXFlags := -nostdinc++ -std=c++03 $(Enclave_Compile_CFlags)
+
+# To generate a proper enclave, it is recommended to follow below guideline to link the trusted libraries:
+#    1. Link sgx_trts with the `--whole-archive' and `--no-whole-archive' options,
+#       so that the whole content of trts is included in the enclave.
+#    2. For other libraries, you just need to pull the required symbols.
+#       Use `--start-group' and `--end-group' to link these libraries.
+# Do NOT move the libraries linked with `--start-group' and `--end-group' within `--whole-archive' and `--no-whole-archive' options. 
+# Otherwise, you may get some undesirable errors.
 Enclave_Link_Flags := -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
 	-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
 	-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
@@ -154,7 +162,7 @@ all: $(App_Name) $(Enclave_Name)
 	@echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave."
 	@echo "To sign the enclave use the command:"
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <your key> -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)"
-	@echo "You can also sign the enclave using an external signing tool. See User's Guide for more details."
+	@echo "You can also sign the enclave using an external signing tool."
 	@echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW."
 else
 all: $(App_Name) $(Signed_Enclave_Name)

+ 12 - 1
SampleCode/RemoteAttestation/Makefile

@@ -65,6 +65,9 @@ else
         SGX_COMMON_CFLAGS += -O2
 endif
 
+ifeq ($(SUPPLIED_KEY_DERIVATION), 1)
+        SGX_COMMON_CFLAGS += -DSUPPLIED_KEY_DERIVATION
+endif
 ######## App Settings ########
 
 ifneq ($(SGX_MODE), HW)
@@ -130,6 +133,14 @@ Enclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX
 
 Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
 Enclave_Cpp_Flags := $(Enclave_C_Flags) -std=c++03 -nostdinc++
+
+# To generate a proper enclave, it is recommended to follow below guideline to link the trusted libraries:
+#    1. Link sgx_trts with the `--whole-archive' and `--no-whole-archive' options,
+#       so that the whole content of trts is included in the enclave.
+#    2. For other libraries, you just need to pull the required symbols.
+#       Use `--start-group' and `--end-group' to link these libraries.
+# Do NOT move the libraries linked with `--start-group' and `--end-group' within `--whole-archive' and `--no-whole-archive' options.
+# Otherwise, you may get some undesirable errors.
 Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
 	-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
 	-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -lsgx_tkey_exchange -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
@@ -161,7 +172,7 @@ all: libservice_provider.so $(App_Name) $(Enclave_Name)
 	@echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave."
 	@echo "To sign the enclave use the command:"
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <your key> -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)"
-	@echo "You can also sign the enclave using an external signing tool. See User's Guide for more details."
+	@echo "You can also sign the enclave using an external signing tool."
 	@echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW."
 else
 all: libservice_provider.so $(App_Name) $(Signed_Enclave_Name)

+ 82 - 10
SampleCode/RemoteAttestation/isv_app/isv_app.cpp

@@ -29,10 +29,14 @@
  *
  */
 
+// This sample is confined to the communication between a SGX client platform
+// and an ISV Application Server. 
+
 
 
 #include <stdio.h>
 #include <limits.h>
+#include <unistd.h>
 // Needed for definition of remote attestation messages.
 #include "remote_attestation_result.h"
 
@@ -48,6 +52,9 @@
 // Needed to create enclave and do ecall.
 #include "sgx_urts.h"
 
+// Needed to query extended epid group id.
+#include "sgx_uae_service.h"
+
 #include "service_provider.h"
 
 #ifndef SAFE_FREE
@@ -116,6 +123,10 @@ void PRINT_ATTESTATION_SERVICE_RESPONSE(
         fprintf(file, "MSG2 spid - ");
         PRINT_BYTE_ARRAY(file, &(p_msg2_body->spid), sizeof(p_msg2_body->spid));
 
+        fprintf(file, "MSG2 quote_type : %hx\n", p_msg2_body->quote_type);
+
+        fprintf(file, "MSG2 kdf_id : %hx\n", p_msg2_body->kdf_id);
+
         fprintf(file, "MSG2 sign_gb_ga - ");
         PRINT_BYTE_ARRAY(file, &(p_msg2_body->sign_gb_ga),
                          sizeof(p_msg2_body->sign_gb_ga));
@@ -154,19 +165,21 @@ void PRINT_ATTESTATION_SERVICE_RESPONSE(
 
 // This sample code doesn't have any recovery/retry mechanisms for the remote
 // attestation. Since the enclave can be lost due S3 transitions, apps
-// susceptible to S3 transtions should have logic to restart attestation in
-// these scenenarios.
+// susceptible to S3 transitions should have logic to restart attestation in
+// these scenarios.
 #define _T(x) x
 int main(int argc, char* argv[])
 {
     int ret = 0;
+    ra_samp_request_header_t *p_msg0_full = NULL;
+    ra_samp_response_header_t *p_msg0_resp_full = NULL;
     ra_samp_request_header_t *p_msg1_full = NULL;
     ra_samp_response_header_t *p_msg2_full = NULL;
     sgx_ra_msg3_t *p_msg3 = NULL;
     ra_samp_response_header_t* p_att_result_msg_full = NULL;
     sgx_enclave_id_t enclave_id = 0;
     int enclave_lost_retry_time = 1;
-    int busy_retry_time = 2;
+    int busy_retry_time = 4;
     sgx_ra_context_t context = INT_MAX;
     sgx_status_t status = SGX_SUCCESS;
     ra_samp_request_header_t* p_msg3_full = NULL;
@@ -204,7 +217,54 @@ int main(int argc, char* argv[])
         }
     }
 
-    // Remote attestaton will be initiated the ISV server challenges the ISV
+    // Preparation for remote attestation by configuring extended epid group id.
+    {
+        uint32_t extended_epid_group_id = 0;
+        ret = sgx_get_extended_epid_group_id(&extended_epid_group_id);
+        if (SGX_SUCCESS != ret)
+        {
+            ret = -1;
+            fprintf(OUTPUT, "\nError, call sgx_get_extended_epid_group_id fail [%s].",
+                __FUNCTION__);
+            return ret;
+        }
+        fprintf(OUTPUT, "\nCall sgx_get_extended_epid_group_id success.");
+
+        p_msg0_full = (ra_samp_request_header_t*)
+            malloc(sizeof(ra_samp_request_header_t)
+            +sizeof(uint32_t));
+        if (NULL == p_msg0_full)
+        {
+            ret = -1;
+            goto CLEANUP;
+        }
+        p_msg0_full->type = TYPE_RA_MSG0;
+        p_msg0_full->size = sizeof(uint32_t);
+
+        *(uint32_t*)((uint8_t*)p_msg0_full + sizeof(ra_samp_request_header_t)) = extended_epid_group_id;
+        {
+
+            fprintf(OUTPUT, "\nMSG0 body generated -\n");
+
+            PRINT_BYTE_ARRAY(OUTPUT, p_msg0_full->body, p_msg0_full->size);
+
+        }
+        // The ISV application sends msg0 to the SP.
+        // The ISV decides whether to support this extended epid group id.
+        fprintf(OUTPUT, "\nSending msg0 to remote attestation service provider.\n");
+
+        ret = ra_network_send_receive("http://SampleServiceProvider.intel.com/",
+            p_msg0_full,
+            &p_msg0_resp_full);
+        if (ret != 0)
+        {
+            fprintf(OUTPUT, "\nError, ra_network_send_receive for msg0 failed "
+                "[%s].", __FUNCTION__);
+            goto CLEANUP;
+        }
+        fprintf(OUTPUT, "\nSent MSG0 to remote attestation service.\n");
+    }
+    // Remote attestation will be initiated the ISV server challenges the ISV
     // app or if the ISV app detects it doesn't have the credentials
     // (shared secret) from a previous attestation required for secure
     // communication with the server.
@@ -225,7 +285,7 @@ int main(int argc, char* argv[])
                 ret = -1;
                 fprintf(OUTPUT, "\nError, call sgx_create_enclave fail [%s].",
                         __FUNCTION__);
-                return ret;
+                goto CLEANUP;
             }
             fprintf(OUTPUT, "\nCall sgx_create_enclave success.");
 
@@ -261,6 +321,7 @@ int main(int argc, char* argv[])
             ret = sgx_ra_get_msg1(context, enclave_id, sgx_ra_get_ga,
                                   (sgx_ra_msg1_t*)((uint8_t*)p_msg1_full
                                   + sizeof(ra_samp_request_header_t)));
+            sleep(3); // Wait 3s between retries
         } while (SGX_ERROR_BUSY == ret && busy_retry_time--);
         if(SGX_SUCCESS != ret)
         {
@@ -566,7 +627,9 @@ int main(int argc, char* argv[])
 
         bool attestation_passed = true;
         // Check the attestation result for pass or fail.
-        // @TODO:  Check the status.  This is ISV defined.
+        // Whether attestation passes or fails is a decision made by the ISV Server.
+        // When the ISV server decides to trust the enclave, then it will return success.
+        // When the ISV server decided to not trust the enclave, then it will return failure.
         if(0 != p_att_result_msg_full->status[0]
            || 0 != p_att_result_msg_full->status[1])
         {
@@ -575,13 +638,20 @@ int main(int argc, char* argv[])
             attestation_passed = false;
         }
 
-        // the SGX blob analysis API. The ISV will take action based on the
-        // update_info. (upgrade PSW or uCode), the second param should be 1 if
-        // the attestation failed, otherwise should be 0.
+        // The attestation result message should contain a field for the Platform
+        // Info Blob (PIB).  The PIB is returned by attestation server in the attestation report.
+        // It is not returned in all cases, but when it is, the ISV app
+        // should pass it to the blob analysis API called sgx_report_attestation_status()
+        // along with the trust decision from the ISV server.
+        // The ISV application will take action based on the update_info.
+        // returned in update_info by the API.  
+        // This call is stubbed out for the sample.
+        // 
         // sgx_update_info_bit_t update_info;
         // ret = sgx_report_attestation_status(
         //     &p_att_result_msg_body->platform_info_blob,
         //     attestation_passed ? 0 : 1, &update_info);
+
         // Get the shared secret sent by the server using SK (if attestation
         // passed)
         if(attestation_passed)
@@ -630,13 +700,15 @@ CLEANUP:
     sgx_destroy_enclave(enclave_id);
 
 
+    ra_free_network_response_buffer(p_msg0_resp_full);
     ra_free_network_response_buffer(p_msg2_full);
     ra_free_network_response_buffer(p_att_result_msg_full);
 
-    // p_msg3 is malloc'd by the untrused KE library. App needs to free.
+    // p_msg3 is malloc'd by the untrusted KE library. App needs to free.
     SAFE_FREE(p_msg3);
     SAFE_FREE(p_msg3_full);
     SAFE_FREE(p_msg1_full);
+    SAFE_FREE(p_msg0_full);
     printf("\nEnter a character before exit ...\n");
     getchar();
     return ret;

+ 133 - 1
SampleCode/RemoteAttestation/isv_enclave/isv_enclave.cpp

@@ -30,7 +30,7 @@
  */
 
 
-
+#include <assert.h>
 #include "isv_enclave_t.h"
 #include "sgx_tkey_exchange.h"
 #include "sgx_tcrypto.h"
@@ -69,6 +69,134 @@ static const sgx_ec256_public_t g_sp_pub_key = {
 uint8_t g_secret[8] = {0};
 
 
+#ifdef SUPPLIED_KEY_DERIVATION
+
+#pragma message ("Supplied key derivation function is used.")
+
+typedef struct _hash_buffer_t
+{
+    uint8_t counter[4];
+    sgx_ec256_dh_shared_t shared_secret;
+    uint8_t algorithm_id[4];
+} hash_buffer_t;
+
+const char ID_U[] = "SGXRAENCLAVE";
+const char ID_V[] = "SGXRASERVER";
+
+// Derive two keys from shared key and key id.
+bool derive_key(
+    const sgx_ec256_dh_shared_t *p_shared_key,
+    uint8_t key_id,
+    sgx_ec_key_128bit_t *first_derived_key,
+    sgx_ec_key_128bit_t *second_derived_key)
+{
+    sgx_status_t sgx_ret = SGX_SUCCESS;
+    hash_buffer_t hash_buffer;
+    sgx_sha_state_handle_t sha_context;
+    sgx_sha256_hash_t key_material;
+
+    memset(&hash_buffer, 0, sizeof(hash_buffer_t));
+    /* counter in big endian  */
+    hash_buffer.counter[3] = key_id;
+
+    /*convert from little endian to big endian */
+    for (size_t i = 0; i < sizeof(sgx_ec256_dh_shared_t); i++)
+    {
+        hash_buffer.shared_secret.s[i] = p_shared_key->s[sizeof(p_shared_key->s)-1 - i];
+    }
+
+    sgx_ret = sgx_sha256_init(&sha_context);
+    if (sgx_ret != SGX_SUCCESS)
+    {
+        return false;
+    }
+    sgx_ret = sgx_sha256_update((uint8_t*)&hash_buffer, sizeof(hash_buffer_t), sha_context);
+    if (sgx_ret != SGX_SUCCESS)
+    {
+        sgx_sha256_close(sha_context);
+        return false;
+    }
+    sgx_ret = sgx_sha256_update((uint8_t*)&ID_U, sizeof(ID_U), sha_context);
+    if (sgx_ret != SGX_SUCCESS)
+    {
+        sgx_sha256_close(sha_context);
+        return false;
+    }
+    sgx_ret = sgx_sha256_update((uint8_t*)&ID_V, sizeof(ID_V), sha_context);
+    if (sgx_ret != SGX_SUCCESS)
+    {
+        sgx_sha256_close(sha_context);
+        return false;
+    }
+    sgx_ret = sgx_sha256_get_hash(sha_context, &key_material);
+    if (sgx_ret != SGX_SUCCESS)
+    {
+        sgx_sha256_close(sha_context);
+        return false;
+    }
+    sgx_ret = sgx_sha256_close(sha_context);
+
+    assert(sizeof(sgx_ec_key_128bit_t)* 2 == sizeof(sgx_sha256_hash_t));
+    memcpy(first_derived_key, &key_material, sizeof(sgx_ec_key_128bit_t));
+    memcpy(second_derived_key, (uint8_t*)&key_material + sizeof(sgx_ec_key_128bit_t), sizeof(sgx_ec_key_128bit_t));
+
+    // memset here can be optimized away by compiler, so please use memset_s on
+    // windows for production code and similar functions on other OSes.
+    memset(&key_material, 0, sizeof(sgx_sha256_hash_t));
+
+    return true;
+}
+
+//isv defined key derivation function id
+#define ISV_KDF_ID 2
+
+typedef enum _derive_key_type_t
+{
+    DERIVE_KEY_SMK_SK = 0,
+    DERIVE_KEY_MK_VK,
+} derive_key_type_t;
+
+sgx_status_t key_derivation(const sgx_ec256_dh_shared_t* shared_key,
+    uint16_t kdf_id,
+    sgx_ec_key_128bit_t* smk_key,
+    sgx_ec_key_128bit_t* sk_key,
+    sgx_ec_key_128bit_t* mk_key,
+    sgx_ec_key_128bit_t* vk_key)
+{
+    bool derive_ret = false;
+
+    if (NULL == shared_key)
+    {
+        return SGX_ERROR_INVALID_PARAMETER;
+    }
+
+    if (ISV_KDF_ID != kdf_id)
+    {
+        //fprintf(stderr, "\nError, key derivation id mismatch in [%s].", __FUNCTION__);
+        return SGX_ERROR_KDF_MISMATCH;
+    }
+
+    derive_ret = derive_key(shared_key, DERIVE_KEY_SMK_SK,
+        smk_key, sk_key);
+    if (derive_ret != true)
+    {
+        //fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__);
+        return SGX_ERROR_UNEXPECTED;
+    }
+
+    derive_ret = derive_key(shared_key, DERIVE_KEY_MK_VK,
+        mk_key, vk_key);
+    if (derive_ret != true)
+    {
+        //fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__);
+        return SGX_ERROR_UNEXPECTED;
+    }
+    return SGX_SUCCESS;
+}
+#else
+#pragma message ("Default key derivation function is used.")
+#endif
+
 // This ecall is a wrapper of sgx_ra_init to create the trusted
 // KE exchange key context needed for the remote attestation
 // SIGMA API's. Input pointers aren't checked since the trusted stubs
@@ -99,7 +227,11 @@ sgx_status_t enclave_init_ra(
         if (ret != SGX_SUCCESS)
             return ret;
     }
+#ifdef SUPPLIED_KEY_DERIVATION
+    ret = sgx_ra_init_ex(&g_sp_pub_key, b_pse, key_derivation, p_context);
+#else
     ret = sgx_ra_init(&g_sp_pub_key, b_pse, p_context);
+#endif
     if(b_pse)
     {
         sgx_close_pse_session();

+ 85 - 0
SampleCode/RemoteAttestation/service_provider/ecp.cpp

@@ -74,6 +74,90 @@ bool verify_cmac128(
     return false;
 }
 
+
+#ifdef SUPPLIED_KEY_DERIVATION
+
+#pragma message ("Supplied key derivation function is used.")
+
+typedef struct _hash_buffer_t
+{
+    uint8_t counter[4];
+    sample_ec_dh_shared_t shared_secret;
+    uint8_t algorithm_id[4];
+} hash_buffer_t;
+
+const char ID_U[] = "SGXRAENCLAVE";
+const char ID_V[] = "SGXRASERVER";
+
+// Derive two keys from shared key and key id.
+bool derive_key(
+    const sample_ec_dh_shared_t *p_shared_key,
+    uint8_t key_id,
+    sample_ec_key_128bit_t *first_derived_key,
+    sample_ec_key_128bit_t *second_derived_key)
+{
+    sample_status_t sample_ret = SAMPLE_SUCCESS;
+    hash_buffer_t hash_buffer;
+    sample_sha_state_handle_t sha_context;
+    sample_sha256_hash_t key_material;
+    
+    memset(&hash_buffer, 0, sizeof(hash_buffer_t));
+
+    /* counter in big endian  */
+    hash_buffer.counter[3] = key_id;
+
+    /*convert from little endian to big endian */
+    for (size_t i = 0; i < sizeof(sample_ec_dh_shared_t) ; i++)
+    {
+        hash_buffer.shared_secret.s[i] = p_shared_key->s[sizeof(p_shared_key->s) - 1 - i];
+    }
+
+    sample_ret = sample_sha256_init(&sha_context);
+    if (sample_ret != SAMPLE_SUCCESS)
+    {
+        return false;
+    }
+    sample_ret = sample_sha256_update((uint8_t*)&hash_buffer, sizeof(hash_buffer_t), sha_context);
+    if (sample_ret != SAMPLE_SUCCESS)
+    {
+        sample_sha256_close(sha_context);
+        return false;
+    }
+    sample_ret = sample_sha256_update((uint8_t*)ID_U, sizeof(ID_U), sha_context);
+    if (sample_ret != SAMPLE_SUCCESS)
+    {
+        sample_sha256_close(sha_context);
+        return false;
+    }
+    sample_ret = sample_sha256_update((uint8_t*)ID_V, sizeof(ID_V), sha_context);
+    if (sample_ret != SAMPLE_SUCCESS)
+    {
+        sample_sha256_close(sha_context);
+        return false;
+    }
+    sample_ret = sample_sha256_get_hash(sha_context, &key_material);
+    if (sample_ret != SAMPLE_SUCCESS)
+    {
+        sample_sha256_close(sha_context);
+        return false;
+    }
+    sample_ret = sample_sha256_close(sha_context);
+
+    static_assert(sizeof(sample_ec_key_128bit_t)* 2 == sizeof(sample_sha256_hash_t), "structure size mismatch.");
+    memcpy(first_derived_key, &key_material, sizeof(sample_ec_key_128bit_t));
+    memcpy(second_derived_key, (uint8_t*)&key_material + sizeof(sample_ec_key_128bit_t), sizeof(sample_ec_key_128bit_t));
+
+    // memset here can be optimized away by compiler, so please use memset_s on
+    // windows for production code and similar functions on other OSes.
+    memset(&key_material, 0, sizeof(sample_sha256_hash_t));
+
+    return true;
+}
+
+#else
+
+#pragma message ("Default key derivation function is used.")
+
 #define EC_DERIVATION_BUFFER_SIZE(label_length) ((label_length) +4)
 
 const char str_SMK[] = "SMK";
@@ -170,3 +254,4 @@ bool derive_key(
     }
     return true;
 }
+#endif

+ 20 - 2
SampleCode/RemoteAttestation/service_provider/ecp.h

@@ -38,10 +38,10 @@
 #include "remote_attestation_result.h"
 
 #ifndef SAMPLE_FEBITSIZE
-#define SAMPLE_FEBITSIZE     256
+    #define SAMPLE_FEBITSIZE                    256
 #endif
 
-#define SAMPLE_ECP_KEY_SIZE  (SAMPLE_FEBITSIZE/8)
+#define SAMPLE_ECP_KEY_SIZE                     (SAMPLE_FEBITSIZE/8)
 
 typedef struct sample_ec_priv_t
 {
@@ -70,6 +70,22 @@ errno_t memcpy_s(void *dest, size_t numberOfElements, const void *src,
                  size_t count);
 
 
+#ifdef SUPPLIED_KEY_DERIVATION
+
+typedef enum _sample_derive_key_type_t
+{
+    SAMPLE_DERIVE_KEY_SMK_SK = 0,
+    SAMPLE_DERIVE_KEY_MK_VK,
+} sample_derive_key_type_t;
+
+bool derive_key(
+    const sample_ec_dh_shared_t *p_shared_key,
+    uint8_t key_id,
+    sample_ec_key_128bit_t *first_derived_key,
+    sample_ec_key_128bit_t *second_derived_key);
+
+#else
+
 typedef enum _sample_derive_key_type_t
 {
     SAMPLE_DERIVE_KEY_SMK = 0,
@@ -83,6 +99,8 @@ bool derive_key(
     uint8_t key_id,
     sample_ec_key_128bit_t *derived_key);
 
+#endif
+
 bool verify_cmac128(
     sample_ec_key_128bit_t mac_key,
     const uint8_t *p_data_buf,

+ 9 - 13
SampleCode/RemoteAttestation/service_provider/ias_ra.cpp

@@ -41,9 +41,9 @@
 #include <string.h>
 #include "ias_ra.h"
 
-// @TODO: This whole file is used as simulation of the interfaces to be
-// delivered the IAS. Once the interface definitions are made available by the
-// IAS, this file should be changed accordingly.
+//This whole file is used as simulation of the interfaces to be
+// delivered an attestation server. 
+
 
 #define UNUSED(expr) do { (void)(expr); } while (0)
 
@@ -75,12 +75,10 @@
 // This is the ECDSA NIST P-256 private key used to sign platform_info_blob.
 // This private
 // key and the public key in SDK untrusted KElibrary should be a temporary key
-// pair. For production parts the IAS will sign the platform_info_blob with the
+// pair. For production parts an attestation server will sign the platform_info_blob with the
 // production private key and the SDK untrusted KE library will have the public
 // key for verifcation.
-// @TODO:  This key will will not be available when the production backend
-// is avaialbe.  The remote attestation sample will need to change to use the
-// real backend. This will likely be an RSA2048 type of key.
+
 static const sample_ec256_private_t g_rk_priv_key =
 {{
     0x63,0x2c,0xd4,0x02,0x7a,0xdc,0x56,0xa5,
@@ -92,7 +90,7 @@ static const sample_ec256_private_t g_rk_priv_key =
 static sample_spid_t g_sim_spid = {"Service X"};
 
 
-// Simulates the IAS function for verifying the quote produce by
+// Simulates the attestation server function for verifying the quote produce by
 // the ISV enclave. It doesn't decrypt or verify the quote in
 // the simulation.  Just produces the attestaion verification
 // report with the platform info blob.
@@ -189,8 +187,7 @@ int ias_verify_attestation_evidence(
 }
 
 
-// Simulates retrieving the SIGRL for upon the SP request. Becaue the IAS
-// backend is not ready right now, we will return NULL.
+// Simulates retrieving the SIGRL for upon the SP request. 
 //
 // @param gid Group ID for the EPID key.
 // @param p_sig_rl_size Pointer to the output value of the full
@@ -217,8 +214,7 @@ int ias_get_sigrl(
         }
         *p_sig_rl_size = 0;
         *p_sig_rl = NULL;
-        // we should try to get sig_rl from IAS, but right now we will just
-        // skip it until the IAS backend is ready.
+        // we should try to get sig_rl from an attestation server
         break;
     }while (0);
 
@@ -226,7 +222,7 @@ int ias_get_sigrl(
 }
 
 
-// Used to simulate the enrollment function of the IAS.  It only
+// Used to simulate the enrollment function of an attestation server.  It only
 // gives back the SPID right now. In production, the enrollment
 // occurs out of context from an attestation attempt and only
 // occurs once.

+ 0 - 1
SampleCode/RemoteAttestation/service_provider/ias_ra.h

@@ -36,7 +36,6 @@
 
 #include "ecp.h"
 
-// These status should align with the definition in IAS API spec(rev 0.6)
 typedef enum {
     IAS_QUOTE_OK,
     IAS_QUOTE_SIGNATURE_INVALID,

+ 14 - 3
SampleCode/RemoteAttestation/service_provider/network_ra.cpp

@@ -66,7 +66,18 @@ int ra_network_send_receive(const char *server_url,
     switch(p_req->type)
     {
 
-        case TYPE_RA_MSG1:
+    case TYPE_RA_MSG0:
+        ret = sp_ra_proc_msg0_req((const sample_ra_msg0_t*)((uint8_t*)p_req
+            + sizeof(ra_samp_request_header_t)),
+            p_req->size);
+        if (0 != ret)
+        {
+            fprintf(stderr, "\nError, call sp_ra_proc_msg1_req fail [%s].",
+                __FUNCTION__);
+        }
+        break;
+
+    case TYPE_RA_MSG1:
         ret = sp_ra_proc_msg1_req((const sample_ra_msg1_t*)((uint8_t*)p_req
             + sizeof(ra_samp_request_header_t)),
             p_req->size,
@@ -82,7 +93,7 @@ int ra_network_send_receive(const char *server_url,
         }
         break;
 
-        case TYPE_RA_MSG3:
+    case TYPE_RA_MSG3:
         ret =sp_ra_proc_msg3_req((const sample_ra_msg3_t*)((uint8_t*)p_req +
             sizeof(ra_samp_request_header_t)),
             p_req->size,
@@ -98,7 +109,7 @@ int ra_network_send_receive(const char *server_url,
         }
         break;
 
-        default:
+    default:
         ret = -1;
         fprintf(stderr, "\nError, unknown ra message type. Type = %d [%s].",
             p_req->type, __FUNCTION__);

+ 18 - 15
SampleCode/RemoteAttestation/service_provider/network_ra.h

@@ -35,20 +35,23 @@
 #define _NETWORK_RA_H
 
 
-// Enum for all possible message types between the ISV app and
-// the ISV SP. Requests and responses in hte remote attestation
-// sample.
+/* Enum for all possible message types between the ISV app and
+ * the ISV SP. Requests and responses in the remote attestation
+ * sample.
+ */
 typedef enum _ra_msg_type_t
 {
-     TYPE_RA_MSG1 = 1,
+     TYPE_RA_MSG0,
+     TYPE_RA_MSG1,
      TYPE_RA_MSG2,
      TYPE_RA_MSG3,
      TYPE_RA_ATT_RESULT,
 }ra_msg_type_t;
 
-// Enum for all possible message types between the SP and IAS.
-// Network communication is not simulated in the remote
-// attestation sample.  Currently these aren't used.
+/* Enum for all possible message types between the SP and IAS.
+ * Network communication is not simulated in the remote
+ * attestation sample.  Currently these aren't used.
+ */
 typedef enum _ias_msg_type_t
 {
      TYPE_IAS_ENROLL,
@@ -60,18 +63,18 @@ typedef enum _ias_msg_type_t
 
 #pragma pack(1)
 typedef struct _ra_samp_request_header_t{
-    uint8_t type;  // set to one of ra_msg_type_t
-    uint32_t size; //size of request body,
-    uint8_t align[3];
+    uint8_t  type;     /* set to one of ra_msg_type_t*/
+    uint32_t size;     /*size of request body*/
+    uint8_t  align[3];
     uint8_t body[];
 }ra_samp_request_header_t;
 
 typedef struct _ra_samp_response_header_t{
-    uint8_t type;   // set to one of ra_msg_type_t
-    uint8_t status[2];
-    uint32_t size;  //size of the response body
-    uint8_t align[1];
-    uint8_t body[];
+    uint8_t  type;      /* set to one of ra_msg_type_t*/
+    uint8_t  status[2];
+    uint32_t size;      /*size of the response body*/
+    uint8_t  align[1];
+    uint8_t  body[];
 }ra_samp_response_header_t;
 
 #pragma pack()

+ 13 - 13
SampleCode/RemoteAttestation/service_provider/remote_attestation_result.h

@@ -38,8 +38,8 @@
 extern "C" {
 #endif
 
-#define SAMPLE_MAC_SIZE             16  // Message Authentication Code
-                                        // - 16 bytes
+#define SAMPLE_MAC_SIZE             16  /* Message Authentication Code*/
+                                        /* - 16 bytes*/
 typedef uint8_t                     sample_mac_t[SAMPLE_MAC_SIZE];
 
 #ifndef SAMPLE_FEBITSIZE
@@ -59,14 +59,14 @@ typedef struct sample_ec_sign256_t
 #define SAMPLE_SP_TAG_SIZE          16
 
 typedef struct sp_aes_gcm_data_t {
-    uint32_t        payload_size;       //  0: Size of the payload which is
-                                        //     encrypted
-    uint8_t         reserved[12];       //  4: Reserved bits
-    uint8_t	        payload_tag[SAMPLE_SP_TAG_SIZE];
-                                        // 16: AES-GMAC of the plain text,
-                                        //     payload, and the sizes
-    uint8_t         payload[];          // 32: Ciphertext of the payload
-                                        //     followed by the plain text
+    uint32_t        payload_size;       /*  0: Size of the payload which is*/
+                                        /*     encrypted*/
+    uint8_t         reserved[12];       /*  4: Reserved bits*/
+    uint8_t         payload_tag[SAMPLE_SP_TAG_SIZE];
+                                        /* 16: AES-GMAC of the plain text,*/
+                                        /*     payload, and the sizes*/
+    uint8_t         payload[];          /* 32: Ciphertext of the payload*/
+                                        /*     followed by the plain text*/
 } sp_aes_gcm_data_t;
 
 
@@ -75,8 +75,8 @@ typedef struct sp_aes_gcm_data_t {
 #define GID_SIZE 4
 #define PSVN_SIZE 18
 
-// @TODO: Modify at production to use the values specified by the Production
-// IAS API
+/* @TODO: Modify at production to use the values specified by an Production*/
+/* attestation server API*/
 typedef struct ias_platform_info_blob_t
 {
      uint8_t sample_epid_group_status;
@@ -92,7 +92,7 @@ typedef struct ias_platform_info_blob_t
 
 typedef struct sample_ra_att_result_msg_t {
     ias_platform_info_blob_t    platform_info_blob;
-    sample_mac_t                mac;    // mac_smk(attestation_status)
+    sample_mac_t                mac;    /* mac_smk(attestation_status)*/
     sp_aes_gcm_data_t           secret;
 } sample_ra_att_result_msg_t;
 

+ 145 - 67
SampleCode/RemoteAttestation/service_provider/service_provider.cpp

@@ -48,6 +48,17 @@
 #define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr) = NULL;}}
 #endif
 
+// This is supported extended epid group of SP. SP can support more than one
+// extended epid group with different extended epid group id and credentials.
+static const sample_extended_epid_group g_extended_epid_groups[] = {
+    {
+        0,
+        ias_enroll,
+        ias_get_sigrl,
+        ias_verify_attestation_evidence
+    }
+};
+
 // This is the private EC key of SP, the corresponding public EC key is
 // hard coded in isv_enclave. It is based on NIST P-256 curve.
 static const sample_ec256_private_t g_sp_priv_key = {
@@ -90,6 +101,7 @@ typedef struct _sp_db_item_t
 }sp_db_item_t;
 static sp_db_item_t g_sp_db;
 
+static const sample_extended_epid_group* g_sp_extended_epid_group_id= NULL;
 static bool g_is_sp_registered = false;
 static int g_sp_credentials = 0;
 static int g_authentication_token = 0;
@@ -98,6 +110,60 @@ uint8_t g_secret[8] = {0,1,2,3,4,5,6,7};
 
 sample_spid_t g_spid;
 
+
+// Verify message 0 then configure extended epid group.
+int sp_ra_proc_msg0_req(const sample_ra_msg0_t *p_msg0,
+    uint32_t msg0_size)
+{
+    int ret = -1;
+
+    if (!p_msg0 ||
+        (msg0_size != sizeof(sample_ra_msg0_t)))
+    {
+        return -1;
+    }
+    uint32_t extended_epid_group_id = p_msg0->extended_epid_group_id;
+
+    // Check to see if we have registered with the attestation server yet?
+    if (!g_is_sp_registered ||
+        (g_sp_extended_epid_group_id != NULL && g_sp_extended_epid_group_id->extended_epid_group_id != extended_epid_group_id))
+    {
+        // Check to see if the extended_epid_group_id is supported?
+        ret = SP_UNSUPPORTED_EXTENDED_EPID_GROUP;
+        for (size_t i = 0; i < sizeof(g_extended_epid_groups) / sizeof(sample_extended_epid_group); i++)
+        {
+            if (g_extended_epid_groups[i].extended_epid_group_id == extended_epid_group_id)
+            {
+                g_sp_extended_epid_group_id = &(g_extended_epid_groups[i]);
+                // In the product, the SP will establish a mutually
+                // authenticated SSL channel. During the enrollment process, the ISV
+                // registers it exchanges TLS certs with attestation server and obtains an SPID and
+                // Report Key from the attestation server.
+                // For a product attestation server, enrollment is an offline process.  See the 'on-boarding'
+                // documentation to get the information required.  The enrollment process is
+                // simulated by a call in this sample.
+                ret = g_sp_extended_epid_group_id->enroll(g_sp_credentials, &g_spid,
+                    &g_authentication_token);
+                if (0 != ret)
+                {
+                    ret = SP_IAS_FAILED;
+                    break;
+                }
+
+                g_is_sp_registered = true;
+                ret = SP_OK;
+                break;
+            }
+        }
+    }
+    else
+    {
+        ret = SP_OK;
+    }
+
+    return ret;
+}
+
 // Verify message 1 then generate and return message 2 to isv.
 int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
 						uint32_t msg1_size,
@@ -117,56 +183,24 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
         return -1;
     }
 
-    do
+    // Check to see if we have registered?
+    if (!g_is_sp_registered)
     {
-        // Check to see if we have registered with the IAS yet?
-        if(!g_is_sp_registered)
-        {
-            do
-            {
-                // @IAS_Q: What are the sp credentials?
-                // @IAS_Q: What is in the authentication token
-                // In the product, the SP will establish a mutually
-                // authenticated SSL channel. The authentication token is
-                // based on this channel.
-                // @TODO: Convert this call to a 'network' send/receive
-                // once the IAS server is a vaialable.
-                ret = ias_enroll(g_sp_credentials, &g_spid,
-                                 &g_authentication_token);
-                if(0 != ret)
-                {
-                    ret = SP_IAS_FAILED;
-                    break;
-                }
-
-                // IAS may support registering the Enclave Trust Policy.
-                // Just leave a place holder here
-                // @IAS_Q: What needs to be sent to the IAS with the policy
-                // that identifies the SP?
-                // ret = ias_register_enclave_policy(g_enclave_policy,
-                // g_authentication_token);
-                // if(0 != ret)
-                // {
-                //     break;
-                // }
-
-                g_is_sp_registered = true;
-                break;
-            } while(0);
-        }
+        return SP_UNSUPPORTED_EXTENDED_EPID_GROUP;
+    }
 
-        // Get the sig_rl from IAS using GID.
+    do
+    {
+        // Get the sig_rl from attestation server using GID.
         // GID is Base-16 encoded of EPID GID in little-endian format.
-        // @IAS_Q: Does the SP need to supply any authentication info to the
-        // IAS?  SPID?
-        // In the product, the SP and IAS will use an established channel for
+        // In the product, the SP and attesation server uses an established channel for
         // communication.
         uint8_t* sig_rl;
         uint32_t sig_rl_size = 0;
 
-        // @TODO: Convert this call to a 'network' send/receive
-        // once the IAS server is a vaialable.
-        ret = ias_get_sigrl(p_msg1->gid, &sig_rl_size, &sig_rl);
+        // The product interface uses a REST based message to get the SigRL.
+        
+        ret = g_sp_extended_epid_group_id->get_sigrl(p_msg1->gid, &sig_rl_size, &sig_rl);
         if(0 != ret)
         {
             fprintf(stderr, "\nError, ias_get_sigrl [%s].", __FUNCTION__);
@@ -187,7 +221,7 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
         sample_ret = sample_ecc256_open_context(&ecc_state);
         if(SAMPLE_SUCCESS != sample_ret)
         {
-            fprintf(stderr, "\nError, cannot get ECC cotext in [%s].",
+            fprintf(stderr, "\nError, cannot get ECC context in [%s].",
                              __FUNCTION__);
             ret = -1;
             break;
@@ -228,6 +262,28 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
             break;
         }
 
+#ifdef SUPPLIED_KEY_DERIVATION
+
+        // smk is only needed for msg2 generation.
+        derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_SMK_SK,
+            &g_sp_db.smk_key, &g_sp_db.sk_key);
+        if(derive_ret != true)
+        {
+            fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__);
+            ret = SP_INTERNAL_ERROR;
+            break;
+        }
+
+        // The rest of the keys are the shared secrets for future communication.
+        derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_MK_VK,
+            &g_sp_db.mk_key, &g_sp_db.vk_key);
+        if(derive_ret != true)
+        {
+            fprintf(stderr, "\nError, derive key fail in [%s].", __FUNCTION__);
+            ret = SP_INTERNAL_ERROR;
+            break;
+        }
+#else
         // smk is only needed for msg2 generation.
         derive_ret = derive_key(&dh_key, SAMPLE_DERIVE_KEY_SMK,
                                 &g_sp_db.smk_key);
@@ -265,6 +321,7 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
             ret = SP_INTERNAL_ERROR;
             break;
         }
+#endif
 
         uint32_t msg2_size = sizeof(sample_ra_msg2_t) + sig_rl_size;
         p_msg2_full = (ra_samp_response_header_t*)malloc(msg2_size
@@ -278,7 +335,8 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
         memset(p_msg2_full, 0, msg2_size + sizeof(ra_samp_response_header_t));
         p_msg2_full->type = TYPE_RA_MSG2;
         p_msg2_full->size = msg2_size;
-        // @TODO: Set the status properly based on real protocol communication.
+        // The simulated message2 always passes.  This would need to be set
+        // accordingly in a real service provider implementation.
         p_msg2_full->status[0] = 0;
         p_msg2_full->status[1] = 0;
         p_msg2 = (sample_ra_msg2_t *)p_msg2_full->body;
@@ -298,9 +356,13 @@ int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
         // signature type and to understand the implications of the choice!
         p_msg2->quote_type = SAMPLE_QUOTE_LINKABLE_SIGNATURE;
 
-
+#ifdef SUPPLIED_KEY_DERIVATION
+//isv defined key derivation function id
+#define ISV_KDF_ID 2
+        p_msg2->kdf_id = ISV_KDF_ID;
+#else
         p_msg2->kdf_id = SAMPLE_AES_CMAC_KDF_ID;
-
+#endif
         // Create gb_ga
         sample_ec_pub_t gb_ga[2];
         if(memcpy_s(&gb_ga[0], sizeof(gb_ga[0]), &g_sp_db.g_b,
@@ -394,6 +456,11 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
         return SP_INTERNAL_ERROR;
     }
 
+    // Check to see if we have registered?
+    if (!g_is_sp_registered)
+    {
+        return SP_UNSUPPORTED_EXTENDED_EPID_GROUP;
+    }
     do
     {
         // Compare g_a in message 3 with local g_a.
@@ -441,7 +508,17 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
 
         p_quote = (sample_quote_t *)p_msg3->quote;
 
-        // Verify the the report_data in the Quote matches the expected value.
+        // Check the quote version if needed. Only check the Quote.version field if the enclave
+        // identity fields have changed or the size of the quote has changed.  The version may
+        // change without affecting the legacy fields or size of the quote structure.
+        //if(p_quote->version < ACCEPTED_QUOTE_VERSION)
+        //{
+        //    fprintf(stderr,"\nError, quote version is too old.", __FUNCTION__);
+        //    ret = SP_QUOTE_VERSION_ERROR;
+        //    break;
+        //}
+
+        // Verify the report_data in the Quote matches the expected value.
         // The first 32 bytes of report_data are SHA256 HASH of {ga|gb|vk}.
         // The second 32 bytes of report_data are set to zero.
         sample_ret = sample_sha256_init(&sha_handle);
@@ -496,15 +573,14 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
             break;
         }
 
-        // Verify Enclave policy (IAS may provide an API for this if we
+        // Verify Enclave policy (an attestation server may provide an API for this if we
         // registered an Enclave policy)
 
-        // Verify quote with IAS.
-        // @IAS_Q: What is the proper JSON format for attestation evidence?
-        ias_att_report_t attestation_report;
-        // @TODO: Convert this call to a 'network' send/receive
-        // once the IAS server is a vaialable.
-        ret = ias_verify_attestation_evidence(p_quote, NULL,
+        // Verify quote with attestation server.
+        // In the product, an attestation server could use a REST message and JSON formatting to request
+        // attestation Quote verification.  The sample only simulates this interface.
+        ias_att_report_t attestation_report = {0};
+        ret = g_sp_extended_epid_group_id->verify_attestation_evidence(p_quote, NULL,
                                               &attestation_report);
         if(0 != ret)
         {
@@ -519,14 +595,13 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
                 attestation_report.revocation_reason);
         // attestation_report.info_blob;
         fprintf(OUTPUT, "\n\tpse_status: %d.",  attestation_report.pse_status);
-        // Check if Platform_Info_Blob is available.
-        // @TODO: Currenlty, the IAS spec says this will not be available if
-        // no info blob status flags are set. For now, assume it is always
-        // there until we have the full message format definition.
+        // Note: This sample always assumes the PIB is sent by attestation server.  In the product
+        // implementation, the attestation server could only send the PIB for certain attestation 
+        // report statuses.  A product SP implementation needs to handle cases
+        // where the PIB is zero length.
 
         // Respond the client with the results of the attestation.
-        uint32_t att_result_msg_size = sizeof(sample_ra_att_result_msg_t)
-                                       + attestation_report.policy_report_size;
+        uint32_t att_result_msg_size = sizeof(sample_ra_att_result_msg_t);
         p_att_result_msg_full =
             (ra_samp_response_header_t*)malloc(att_result_msg_size
             + sizeof(ra_samp_response_header_t) + sizeof(g_secret));
@@ -552,15 +627,13 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
         p_att_result_msg =
             (sample_ra_att_result_msg_t *)p_att_result_msg_full->body;
 
-        // @TODO: In the product, the HTTP response header itself will have
+        // In a product implementation of attestation server, the HTTP response header itself could have
         // an RK based signature that the service provider needs to check here.
 
         // The platform_info_blob signature will be verified by the client
-        // if needed. No need to have the Service Provider to check it.
+        // when sent. No need to have the Service Provider to check it.  The SP
+        // should pass it down to the application for further analysis.
 
-        // @TODO: Verify the enlcave policy report if they are to be supported
-        // by IAS. Otherwise, the SP will need to check the ISV enclave report
-        // itself.
         fprintf(OUTPUT, "\n\n\tEnclave Report:");
         fprintf(OUTPUT, "\n\tSignature Type: 0x%x", p_quote->sign_type);
         fprintf(OUTPUT, "\n\tSignature Basename: ");
@@ -602,7 +675,12 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
                 p_quote->report_body.isv_prod_id);
         fprintf(OUTPUT, "\n\tisv_svn: 0x%0x",p_quote->report_body.isv_svn);
         fprintf(OUTPUT, "\n");
-        // @TODO do a real check here.
+
+        // A product service provider needs to verify that its enclave properties 
+        // match what is expected.  The SP needs to check these values before
+        // trusting the enclave.  For the sample, we always pass the policy check.
+        // Attestation server only verifies the quote structure and signature.  It does not 
+        // check the identity of the enclave.
         bool isv_policy_passed = true;
 
         // Assemble Attestation Result Message

+ 50 - 19
SampleCode/RemoteAttestation/service_provider/service_provider.h

@@ -44,11 +44,13 @@ extern "C" {
 
 typedef enum {
     SP_OK,
+    SP_UNSUPPORTED_EXTENDED_EPID_GROUP,
     SP_INTEGRITY_FAILED,
     SP_QUOTE_VERIFICATION_FAILED,
     SP_IAS_FAILED,
     SP_INTERNAL_ERROR,
     SP_PROTOCOL_ERROR,
+    SP_QUOTE_VERSION_ERROR,
 } sp_ra_msg_status_t;
 
 #pragma pack(push,1)
@@ -62,7 +64,7 @@ typedef struct sample_ec_pub_t
     uint8_t gy[SAMPLE_ECP_KEY_SIZE];
 } sample_ec_pub_t;
 
-//fixed length to align with internal structure
+/*fixed length to align with internal structure*/
 typedef struct sample_ps_sec_prop_desc_t
 {
     uint8_t  sample_ps_sec_prop_desc[256];
@@ -76,41 +78,49 @@ typedef uint8_t                 sample_key_128bit_t[16];
 
 typedef sample_key_128bit_t     sample_ra_key_128_t;
 
+typedef struct sample_ra_msg0_t
+{
+    uint32_t                    extended_epid_group_id;
+} sample_ra_msg0_t;
+
+
 typedef struct sample_ra_msg1_t
 {
-    sample_ec_pub_t             g_a;        // the Endian-ness of Ga is
-                                            // Little-Endian
-    sample_epid_group_id_t      gid;        // the Endian-ness of GID is
-                                            // Little-Endian
+    sample_ec_pub_t             g_a;        /* the Endian-ness of Ga is
+                                                 Little-Endian*/
+    sample_epid_group_id_t      gid;        /* the Endian-ness of GID is
+                                                 Little-Endian*/
 } sample_ra_msg1_t;
 
-//Key Derivation Function ID : 0x0001  AES-CMAC Entropy Extraction and Key Expansion
+/*Key Derivation Function ID : 0x0001  AES-CMAC Entropy Extraction and Key Expansion*/
 const uint16_t SAMPLE_AES_CMAC_KDF_ID = 0x0001;
 
 typedef struct sample_ra_msg2_t
 {
-    sample_ec_pub_t             g_b;        // the Endian-ness of Gb is
-                                            // Little-Endian
-    sample_spid_t               spid;
-     uint16_t					 quote_type; /* unlinkable Quote(0) or linkable Quote(0) in little endian*/
-    uint16_t					 kdf_id;	 /* key derivation function id in little endian. 
+    sample_ec_pub_t             g_b;        /* the Endian-ness of Gb is
+                                                  Little-Endian*/
+    sample_spid_t               spid;       /* In little endian*/
+    uint16_t                    quote_type; /* unlinkable Quote(0) or linkable Quote(0) in little endian*/
+    uint16_t                    kdf_id;     /* key derivation function id in little endian. 
                                              0x0001 for AES-CMAC Entropy Extraction and Key Derivation */
-    sample_ec_sign256_t         sign_gb_ga; // In little endian
-    sample_mac_t                mac;        // mac_smk(g_b||spid||quote_type||
-                                            //         sign_gb_ga)
+    sample_ec_sign256_t         sign_gb_ga; /* In little endian*/
+    sample_mac_t                mac;        /* mac_smk(g_b||spid||quote_type||
+                                                       sign_gb_ga)*/
     uint32_t                    sig_rl_size;
-    uint8_t                  sig_rl[];
+    uint8_t                     sig_rl[];
 } sample_ra_msg2_t;
 
 typedef struct sample_ra_msg3_t
 {
-    sample_mac_t                mac;        // mac_smk(g_a||ps_sec_prop||quote)
-    sample_ec_pub_t             g_a;        // the Endian-ness of Ga is
-                                            // Little-Endian
+    sample_mac_t                mac;           /* mac_smk(g_a||ps_sec_prop||quote)*/
+    sample_ec_pub_t             g_a;           /* the Endian-ness of Ga is*/
+                                               /*  Little-Endian*/
     sample_ps_sec_prop_desc_t   ps_sec_prop;
-    uint8_t                  quote[];
+    uint8_t                     quote[];
 } sample_ra_msg3_t;
 
+int sp_ra_proc_msg0_req(const sample_ra_msg0_t *p_msg0,
+    uint32_t msg0_size);
 
 int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
 						uint32_t msg1_size,
@@ -123,6 +133,27 @@ int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
 int sp_ra_free_msg2(
     sample_ra_msg2_t *p_msg2);
 
+
+
+typedef int (*sample_enroll)(int sp_credentials, sample_spid_t* spid,
+    int* authentication_token);
+
+typedef int(*sample_get_sigrl)(const sample_epid_group_id_t gid, uint32_t* p_sig_rl_size,
+    uint8_t** p_sig_rl);
+
+typedef int(*sample_verify_attestation_evidence)(sample_quote_t* p_isv_quote,
+    uint8_t* pse_manifest,
+    ias_att_report_t* attestation_verification_report);
+
+
+typedef struct sample_extended_epid_group
+{
+    uint32_t extended_epid_group_id;
+    sample_enroll enroll;
+    sample_get_sigrl get_sigrl;
+    sample_verify_attestation_evidence verify_attestation_evidence;
+} sample_extended_epid_group;
+
 #ifdef  __cplusplus
 }
 #endif

+ 0 - 1
SampleCode/SampleEnclave/Enclave/Enclave.config.xml

@@ -1,4 +1,3 @@
-<!-- Please refer to User's Guide for the explanation of each field -->
 <EnclaveConfiguration>
   <ProdID>0</ProdID>
   <ISVSVN>0</ISVSVN>

+ 9 - 1
SampleCode/SampleEnclave/Makefile

@@ -119,6 +119,14 @@ Enclave_Include_Paths := -IInclude -IEnclave -I$(SGX_SDK)/include -I$(SGX_SDK)/i
 
 Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
 Enclave_Cpp_Flags := $(Enclave_C_Flags) -std=c++03 -nostdinc++
+
+# To generate a proper enclave, it is recommended to follow below guideline to link the trusted libraries:
+#    1. Link sgx_trts with the `--whole-archive' and `--no-whole-archive' options,
+#       so that the whole content of trts is included in the enclave.
+#    2. For other libraries, you just need to pull the required symbols.
+#       Use `--start-group' and `--end-group' to link these libraries.
+# Do NOT move the libraries linked with `--start-group' and `--end-group' within `--whole-archive' and `--no-whole-archive' options.
+# Otherwise, you may get some undesirable errors.
 Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
 	-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
 	-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
@@ -150,7 +158,7 @@ all: $(App_Name) $(Enclave_Name)
 	@echo "Please sign the $(Enclave_Name) first with your signing key before you run the $(App_Name) to launch and access the enclave."
 	@echo "To sign the enclave use the command:"
 	@echo "   $(SGX_ENCLAVE_SIGNER) sign -key <your key> -enclave $(Enclave_Name) -out <$(Signed_Enclave_Name)> -config $(Enclave_Config_File)"
-	@echo "You can also sign the enclave using an external signing tool. See User's Guide for more details."
+	@echo "You can also sign the enclave using an external signing tool."
 	@echo "To build the project in simulation mode set SGX_MODE=SIM. To build the project in prerelease mode set SGX_PRERELEASE=1 and SGX_MODE=HW."
 else
 all: $(App_Name) $(Signed_Enclave_Name)

+ 5 - 5
common/inc/internal/arch.h

@@ -269,9 +269,9 @@ se_static_assert(sizeof(token_t) == 304);
 
 typedef struct _wl_cert_t                           /* All fields except the mr_signer_list fields, are big-endian integer format */
 {
-    uint16_t                version;                /* ( 0) White List Cert format version. For 2015, only valid version is 1 */
+    uint16_t                version;                /* ( 0) White List Cert format version. Currently, only valid version is 1 */
     uint16_t                cert_type;              /* ( 2) White List Cert Type. For Enclave Signing Key White List Cert, must be 1 */
-    uint16_t                provider_id;            /* ( 4) Enclave Signing Key White List Provider ID to identify the key used to sign this Enclave signing Key White List Certificate. For 2015, only one White List Provider is approved: WLProviderID-ISecG = 0 */
+    uint16_t                provider_id;            /* ( 4) Enclave Signing Key White List Provider ID to identify the key used to sign this Enclave signing Key White List Certificate. Currently, only one White List Provider is approved: WLProviderID-ISecG = 0 */
     uint16_t                le_prod_id;             /* ( 6) Launch Enclave ProdID the White List Cert applies to. Linux LE-ProdID = 0x20 */
     uint32_t                wl_version;             /* ( 8) Version of the Enclave Signing Key White List. For a specific LE-ProdID, should increase on every WL Cert signing request */
     uint32_t                entry_number;           /* (12) Number of MRSIGNER entries in the Cert. If the White List Certificate allows enclave signed by any key to launch, the White List Cert must only contain one all-0 MRSIGNER entry. */
@@ -279,10 +279,10 @@ typedef struct _wl_cert_t                           /* All fields except the mr_
 }wl_cert_t;
 typedef struct _wl_provider_cert_t                  /* All fields are big endian */
 {
-    uint16_t                version;                /* ( 0) White List Cert format version. For 2015, only valid version is 1 */
+    uint16_t                version;                /* ( 0) White List Cert format version. Currently, only valid version is 1 */
     uint16_t                cert_type;              /* ( 2) White List Cert Type, For Enclave Signing Key White List Signer Cert, must be 0 */
-    uint16_t                provider_id;            /* ( 4) Enclave Signing Key White List Signer ID assigned by the White List Root CA. For 2015, only one White List Provider is approved: WLProviderID-ISecG = 0 */
-    uint16_t                root_id;                /* ( 6) Identify the White List Root CA key used to sign the Cert. For 2015, only one WLRootID is valid: WLRootID-iKGF-Key-0 = 0 */
+    uint16_t                provider_id;            /* ( 4) Enclave Signing Key White List Signer ID assigned by the White List Root CA. Currently, only one White List Provider is approved: WLProviderID-ISecG = 0 */
+    uint16_t                root_id;                /* ( 6) Identify the White List Root CA key used to sign the Cert. Currently, only one WLRootID is valid: WLRootID-iKGF-Key-0 = 0 */
     sgx_ec256_public_t      pub_key;                /* ( 8) ECDSA public key of the Enclave Signing Key White List Provider identified by WLProviderID */
     sgx_ec256_signature_t   signature;              /* (72) ECDSA Signature by WL Root CA identified by WLRootID */
 }wl_provider_cert_t;

+ 2 - 2
common/inc/internal/linux/xsave_gnu.h

@@ -37,12 +37,12 @@
 #ifdef __x86_64__
 #  define ASM_FXSAVE "rex64/fxsave"
 #  define ASM_FXRSTR "rex64/fxrstor"
-#  define ASM_XSAVE  "rex64/xsave"
+#  define ASM_XSAVE  ".byte 0x48,0x0f,0xae,0x21"
 #  define ASM_XRSTR  ".byte 0x48,0x0f,0xae,0x2f"
 #else
 #  define ASM_FXSAVE "fxsave"
 #  define ASM_FXRSTR "fxrstor"
-#  define ASM_XSAVE  "xsave"
+#  define ASM_XSAVE  ".byte 0x0f,0xae,0x21"
 #  define ASM_XRSTR  ".byte 0x0f,0xae,0x2f"
 #endif
 

+ 21 - 0
common/inc/internal/oal/uae_oal_api.h

@@ -118,6 +118,27 @@ uae_oal_status_t oal_invoke_service(
     uint32_t        timeout_usec,
     aesm_error_t    *response);
 
+uae_oal_status_t oal_get_whitelist_size(
+    uint32_t* p_whitelist_size,
+    uint32_t timeout_usec,
+    aesm_error_t* result);
+
+uae_oal_status_t oal_get_whitelist(
+    uint8_t* p_whitelist,
+    uint32_t whitelist_size,
+    uint32_t timeout_usec,
+    aesm_error_t *result);
+
+uae_oal_status_t oal_get_extended_epid_group_id(
+    uint32_t* extended_group_id,
+    uint32_t timeout_usec,
+    aesm_error_t *result);
+
+uae_oal_status_t oal_switch_extended_epid_group(
+    uint32_t x_group_id,
+    uint32_t timeout_usec,
+    aesm_error_t *result);
+
 sgx_status_t    oal_map_status(uae_oal_status_t status);
 sgx_status_t    oal_map_result(aesm_error_t result);
 

+ 1 - 1
common/inc/internal/se_version.h

@@ -28,5 +28,5 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
-#define STRFILEVER    "1.5.80.33399"
+#define STRFILEVER    "1.6.100.34922"
 

+ 2 - 1
common/inc/sgx_quote.h

@@ -78,7 +78,8 @@ typedef struct _quote_t
     uint16_t            sign_type;      /* 2   */
     sgx_epid_group_id_t epid_group_id;  /* 4   */
     sgx_isv_svn_t       qe_svn;         /* 8   */
-    uint8_t             reserved[6];    /* 10  */
+    sgx_isv_svn_t       pce_svn;        /* 10  */
+    uint32_t            xeid;           /* 12  */
     sgx_basename_t      basename;       /* 16  */
     sgx_report_body_t   report_body;    /* 48  */
     uint32_t            signature_len;  /* 432 */

+ 1 - 0
common/inc/sgx_thread.h

@@ -105,6 +105,7 @@ int SGXAPI sgx_thread_cond_signal(sgx_thread_cond_t *cond);
 int SGXAPI sgx_thread_cond_broadcast(sgx_thread_cond_t *cond);
 
 sgx_thread_t SGXAPI sgx_thread_self(void);
+int sgx_thread_equal(sgx_thread_t a, sgx_thread_t b);
 
 #ifdef __cplusplus
 }

+ 69 - 2
common/inc/sgx_tkey_exchange.h

@@ -58,8 +58,6 @@ extern "C" {
  *                      SGX_ERROR_INVALID_PARAMETER     Indicates an error that
  *                                                      the input parameters are
  *                                                      invalid.
- *                      SGX_ERROR_KDF_MISMATCH          Indicates key derivation
- *                                                      function doesn't match.
  *                      SGX_ERROR_OUT_OF_MEMORY         There is not enough
  *                                                      memory available to
  *                                                      complete this operation.
@@ -73,6 +71,75 @@ sgx_status_t SGXAPI sgx_ra_init(
     int b_pse,
     sgx_ra_context_t *p_context);
 
+/*
+ * The sgx_ra_derive_secret_keys_t function should takes the Diffie-Hellman
+ * shared secret as input to allow the ISV enclave to generate their own derived
+ * shared keys (SMK, SK, MK and VK).
+ *
+ * @param p_shared_key The the Diffie-Hellman shared secret.
+ * @param kdf_id,      Key Derivation Function ID 
+ * @param p_smk_key    The output SMK.
+ * @param p_sk_key     The output SK.
+ * @param p_mk_key     The output MK.
+ * @param p_vk_key     The output VK.
+ * @return sgx_status_t SGX_SUCCESS                     Indicates success.
+ *                      SGX_ERROR_INVALID_PARAMETER     Indicates an error that
+ *                                                      the input parameters are
+ *                                                      invalid.
+ *                      SGX_ERROR_KDF_MISMATCH          Indicates key derivation
+ *                                                      function doesn't match.
+ *                      SGX_ERROR_OUT_OF_MEMORY         There is not enough
+ *                                                      memory available to
+ *                                                      complete this operation.
+ *                      SGX_ERROR_UNEXPECTED            Indicates an unexpected
+ *                                                      error occurs.
+ */
+
+typedef sgx_status_t(*sgx_ra_derive_secret_keys_t)(
+    const sgx_ec256_dh_shared_t* p_shared_key,
+    uint16_t kdf_id,
+    sgx_ec_key_128bit_t* p_smk_key,
+    sgx_ec_key_128bit_t* p_sk_key,
+    sgx_ec_key_128bit_t* p_mk_key,
+    sgx_ec_key_128bit_t* p_vk_key);
+
+/*
+ * The sgx_ra_init_ex function creates a context for the remote attestation and
+ * key exchange process asociated with a key derive function.
+ *
+ * @param p_pub_key The EC public key of the service provider based on the NIST
+ *                  P-256 elliptic curve.
+ * @param b_pse     If true, platform service information is needed in message
+ *                  3. The caller should make sure a PSE session has been
+ *                  established using sgx_create_pse_session before attempting
+ *                  to establish a remote attestation and key exchange session
+ *                  involving platform service information.
+ * @param derive_key_cb A pointer to a call back routine matching the
+ *                      function prototype of sgx_ra_derive_secret_keys_t.  This
+ *                      function takes the Diffie-Hellman shared secret as input
+ *                      to allow the ISV enclave to generate their own derived
+ *                      shared keys (SMK, SK, MK and VK).
+ * @param p_context The output context for the subsequent remote attestation
+ *                  and key exchange process, to be used in sgx_ra_get_msg1 and
+ *                  sgx_ra_get_msg2.
+ * @return sgx_status_t SGX_SUCCESS                     Indicates success.
+ *                      SGX_ERROR_INVALID_PARAMETER     Indicates an error that
+ *                                                      the input parameters are
+ *                                                      invalid.
+ *                      SGX_ERROR_OUT_OF_MEMORY         There is not enough
+ *                                                      memory available to
+ *                                                      complete this operation.
+ *                      SGX_ERROR_AE_SESSION_INVALID    Session is invalid or
+ *                                                      ended by server.
+ *                      SGX_ERROR_UNEXPECTED            Indicates an unexpected
+ *                                                      error occurs.
+ */
+
+sgx_status_t SGXAPI sgx_ra_init_ex(
+    const sgx_ec256_public_t *p_pub_key,
+    int b_pse,
+    sgx_ra_derive_secret_keys_t derive_key_cb,
+    sgx_ra_context_t *p_context);
 /*
  * The sgx_ra_get_keys function is used to get the negotiated keys of a remote
  * attestation and key exchange session. This function should only be called

+ 25 - 0
common/inc/sgx_uae_service.h

@@ -121,6 +121,31 @@ sgx_status_t SGXAPI sgx_get_quote(
  */
 sgx_status_t SGXAPI sgx_get_ps_cap(sgx_ps_cap_t* p_sgx_ps_cap);
 
+/**
+ * Get the white list's size
+ *
+ * @param p_whitelist_size Save the size of the white list.
+ * @return if OK, return SGX_SUCCESS
+ */
+sgx_status_t SGXAPI sgx_get_whitelist_size(uint32_t* p_whitelist_size);
+
+/**
+ * Get the white list value
+ *
+ * @param p_whitelist Save the white list value
+ * @param whitelist_size The size of the white list and the read data size is whitelist_size
+ * @return if OK, return SGX_SUCCESS
+ */
+sgx_status_t SGXAPI sgx_get_whitelist(uint8_t* p_whitelist, uint32_t whitelist_size);
+
+/**
+ * Get the extended epid group id
+ *
+ * @param p_extended_epid_group_id Save the extended epid group id.
+ * @return if OK, return SGX_SUCCESS
+ */
+sgx_status_t SGXAPI sgx_get_extended_epid_group_id(uint32_t* p_extended_epid_group_id);
+
 #define SGX_IS_TRUSTED_TIME_AVAILABLE(cap)           ((((uint32_t)PS_CAP_TRUSTED_TIME)&((cap).ps_cap0))!=0)
 #define SGX_IS_MONOTONIC_COUNTER_AVAILABLE(cap)      ((((uint32_t)PS_CAP_MONOTONIC_COUNTER)&((cap).ps_cap0))!=0)
 

+ 64 - 0
common/inc/tlibc/setjmp.h

@@ -0,0 +1,64 @@
+/*	$NetBSD: setjmp.h,v 1.26 2011/11/05 09:27:06 joerg Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)setjmp.h	8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_
+
+#ifndef _JB_ATTRIBUTES
+#define _JB_ATTRIBUTES	/**/
+#else
+#endif
+#ifndef _BSD_JBSLOT_T_
+#define	_BSD_JBSLOT_T_	long
+#endif
+
+#define _JBLEN 8 
+
+typedef _BSD_JBSLOT_T_ jmp_buf[_JBLEN] _JB_ATTRIBUTES;
+
+#include <sys/cdefs.h>
+#define __returns_twice __attribute__((__returns_twice__))
+#define __dead 
+
+__BEGIN_DECLS
+int	_setjmp(jmp_buf) __returns_twice;
+void	_longjmp(jmp_buf, int) __dead;
+__END_DECLS
+
+#endif /* !_SETJMP_H_ */
+

+ 3 - 2
download_prebuilt.sh

@@ -33,10 +33,11 @@
 
 top_dir=`dirname $0`
 out_dir=$top_dir/psw/ae/data/prebuilt
-server_url=https://01.org/sites/default/files/downloads/intelr-software-guard-extensions-linux-os/sgxprebuilt-1.5.80.27216.tar
+file_name=sgxprebuilt-1.6.100.34040.tar
+server_url=https://download.01.org/intel-sgx/linux-1.6/$file_name
 wget $server_url -P $out_dir
 if [ $? -ne 0 ]; then
     echo "Fail to download file $server_url"
     exit -1
 fi
-pushd $out_dir;tar -xf sgxprebuilt-1.5.80.27216.tar;rm -rf sgxprebuilt-1.5.80.27216.tar;popd
+pushd $out_dir;tar -xf $file_name;rm -rf $file_name;popd

+ 28 - 2
external/epid/inc/epid_types.h

@@ -92,9 +92,9 @@ typedef struct G2ElemStr {
 } G2ElemStr;
 
 /// Serialized GT element
-typedef struct GtElemStr {
+typedef struct GTElemStr {
   FqElemStr x[12];  ///< an integer between [0, q-1]
-} GtElemStr;
+} GTElemStr;
 
 typedef FpElemStr PElemStr;
 typedef OctStr32 RLver_t;
@@ -282,6 +282,32 @@ typedef struct VerifierRl {
   G1ElemStr K[1];    ///< elements in G1 (flexible array)
 } VerifierRl;
 
+/*!
+* \brief
+* member pre-computation blob
+*
+* \note e12 = 0 implies that this blob is not valid
+*/
+typedef struct _MemberPrecomp {
+  GTElemStr e12;  ///< an element in GT
+  GTElemStr e22;  ///< an element in GT
+  GTElemStr e2w;  ///< an element in GT
+  GTElemStr ea2;  ///< an element in GT
+} MemberPrecomp;
+
+/*!
+ * \brief
+ * verifier pre-computation blob
+ *
+ * \note e12 = 0 implies that this blob is not valid
+*/
+typedef struct _VerifierPrecomp {
+  GTElemStr e12;  ///< an element in GT
+  GTElemStr e22;  ///< an element in GT
+  GTElemStr e2w;  ///< an element in GT
+  GTElemStr eg12;  ///< an element in GT
+} VerifierPrecomp;
+
 /// element to store seed values for later rekey
 typedef G1ElemStr ReKeySeed;
 

+ 1 - 1
external/rdrand/rdrand.h

@@ -1,4 +1,4 @@
-/* Copyright © 2012, Intel Corporation.  All rights reserved.
+/* Copyright © 2012, Intel Corporation.  All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

+ 14 - 2
linux/installer/bin/install-sgx-psw.bin.tmpl

@@ -32,8 +32,14 @@
 
 modinfo isgx &> /dev/null
 if [[ $? != "0" ]]; then
-    echo "Please install the driver package before the PSW package"
-    exit 4
+    lsmod | grep isgx &> /dev/null
+    if [[ $? = "0" ]]; then
+        echo "Warning: You did not follow the document to install the driver package"
+        echo
+    else
+        echo "Please install the driver package before the PSW package"
+        exit 4
+    fi
 fi
 
 set -e
@@ -58,6 +64,12 @@ if [[ $ARCH != $PKG_ARCH ]]; then
     exit 4
 fi
 
+INSTALL_PATH=/opt/intel/sgxpsw
+if [ -d "$INSTALL_PATH" ]; then
+    echo "$PKG_NAME already exists in $INSTALL_PATH, please uninstall it first!"
+    exit 4
+fi
+
 PATH=/usr/bin:/bin
 umask 022
 

+ 75 - 6
linux/installer/bin/install-sgx-sdk.bin.tmpl

@@ -34,10 +34,43 @@ set -e
 
 PKG_NAME="Intel SGX SDK"
 
-if test $(id -u) -ne 0; then
-    echo "Root privilege is required to install $PKG_NAME."
-    exit 4
-fi
+select_install_path()
+{
+    USER_INPUT_PATH=$(pwd)
+    echo
+    echo -n "Do you want to install in current directory? [yes/no] : "
+    read ANSWER
+
+    if [ "$ANSWER" == "yes" ]; then
+        if [ ! -d "$USER_INPUT_PATH" ] || [ ! -w "$USER_INPUT_PATH" ]; then
+            echo "Can not install in $USER_INPUT_PATH, please check the permission!"
+            exit 4
+        fi
+    else
+        echo
+        echo -n "Please input the directory which you want to install in : "
+        read USER_INPUT_PATH
+
+        eval USER_INPUT_PATH="$USER_INPUT_PATH"
+
+        if [ -d "$USER_INPUT_PATH" ]; then
+            if [ ! -w "$USER_INPUT_PATH" ]; then
+                echo "Can not install in $USER_INPUT_PATH, please check the permission!"
+                exit 4
+            fi
+        else
+            mkdir -p "$USER_INPUT_PATH"
+            if [ "$?" != "0" ]; then
+                echo "Can not install in $USER_INPUT_PATH, please check the permission!"
+                exit 4
+            fi
+        fi
+    fi
+
+    USER_INPUT_PATH=$(cd "$USER_INPUT_PATH"; pwd -P)
+}
+
+select_install_path
 
 PATH=/usr/bin:/bin
 umask 022
@@ -79,13 +112,49 @@ echo " done."
 
 pushd ${SDK_TEMP_FOLDER}
 
+sed -i "s#\(SGX_PACKAGES_PATH=\).*#\1$USER_INPUT_PATH#" scripts/installConfig
 source scripts/installConfig
-make install
+make install INSTALLER_FORM=BIN
 
 popd
 
-${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/scripts/install.sh
+${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/scripts/install.sh BIN
 
 rm -fr ${SDK_TEMP_FOLDER}
 
+export_the_simulation()
+{
+    if [ ! -d ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs ]; then
+        mkdir ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs
+    else
+        rm -f ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs/libsgx_urts_sim.so
+        rm -f ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs/libsgx_uae_service_sim.so
+    fi
+    ln -s ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/${LIB_DIR}/libsgx_urts_sim.so ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs/ 
+    ln -s ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/${LIB_DIR}/libsgx_uae_service_sim.so ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/sdk_libs/ 
+} 
+
+generate_environment_script()
+{
+    cat > ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/environment <<EOF
+export SGX_SDK=${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}
+export PATH=\$PATH:\$SGX_SDK/$(dirname ${BIN_DIR}):\$SGX_SDK/${BIN_DIR}
+export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:\$SGX_SDK/pkgconfig
+if [ -z "\$LD_LIBRARY_PATH" ]; then
+     export LD_LIBRARY_PATH=\$SGX_SDK/sdk_libs
+else
+     export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$SGX_SDK/sdk_libs
+fi
+
+EOF
+}
+
+export_the_simulation
+generate_environment_script
+
+echo """
+Please set the environment variables with below command:
+"
+echo -e "\033[32;49;1msource ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/environment\033[39;49;0m"
+
 exit 0

+ 1 - 0
linux/installer/common/psw/BOMs/psw_base.txt

@@ -6,6 +6,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/build/linux/libsgx_le.signed.so	<installdir>/package/aesm/libsgx_le.signed.so	0	main	STP
 <deliverydir>/build/linux/libsgx_pve.signed.so	<installdir>/package/aesm/libsgx_pve.signed.so	0	main	STP
 <deliverydir>/build/linux/libsgx_qe.signed.so	<installdir>/package/aesm/libsgx_qe.signed.so	0	main	STP
+<deliverydir>/build/linux/libsgx_pce.signed.so	<installdir>/package/aesm/libsgx_pce.signed.so	0	main	STP
 <deliverydir>/linux/installer/common/psw/install.sh	<installdir>/scripts/install.sh	0	main	STP
 <deliverydir>/linux/installer/common/psw/Makefile	<installdir>/Makefile	0	main	STP
 <deliverydir>/psw/ae/aesm_service/config/network/aesmd.conf	<installdir>/package/aesm/conf/aesmd.conf	0	main	STP

+ 1 - 1
linux/installer/common/psw/Makefile

@@ -34,7 +34,7 @@ include scripts/installConfig
 SOURCE_FOLDER=package
 SCRIPTS_FOLDER=scripts
 
-INSTALL_PATH=$(DESTDIR)/$(SGX_PACKAGES_PATH)/$(PSW_PKG_NAME)
+INSTALL_PATH=$(shell readlink -m $(DESTDIR)/$(SGX_PACKAGES_PATH)/$(PSW_PKG_NAME))
 SOURCE_INSTALL_PATH=$(INSTALL_PATH)
 SCRIPTS_INSTALL_PATH=$(INSTALL_PATH)/$(SCRIPTS_FOLDER)
 PSW_LIB_PATH=$(SOURCE_INSTALL_PATH)/$(LIB_DIR)

+ 3 - 2
linux/installer/common/psw/createTarball.sh

@@ -53,6 +53,9 @@ get_arch()
 
 ARCH=$(get_arch)
 
+# Get the configuration for this package
+source ${SCRIPT_DIR}/installConfig.${ARCH}
+
 # Fetch the gen_source script
 cp ${LINUX_INSTALLER_COMMON_DIR}/gen_source/gen_source.py ${SCRIPT_DIR}
 
@@ -62,8 +65,6 @@ python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/psw_${ARCH}.txt --cleanup=false
 python ${SCRIPT_DIR}/gen_source.py --bom=../licenses/BOM_license.txt --cleanup=false
 
 # Create the tarball
-source ${SCRIPT_DIR}/installConfig.${ARCH}
-
 pushd ${INSTALL_PATH} &> /dev/null
 tar -zcvf ${TARBALL_NAME} *
 popd &> /dev/null

+ 3 - 1
linux/installer/common/psw/install.sh

@@ -122,6 +122,8 @@ rm -f /usr/lib/libsgx_urts.so
 # Removing AESM folder
 rm -fr $PSW_DST_PATH
 
+# Removing AESM user and group
+/usr/sbin/userdel aesmd
 EOF
 
 chmod +x $PSW_DST_PATH/uninstall.sh
@@ -135,7 +137,7 @@ fi
 
 echo -e "\nuninstall.sh script generated in $PSW_DST_PATH\n"
 
-echo -e "Installation successful!"
+echo -e "Installation is successful!"
 
 rm -fr $PSW_DST_PATH/scripts
 

+ 1 - 0
linux/installer/common/sdk/BOMs/sdk_base.txt

@@ -60,6 +60,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/common/inc/tlibc/unistd.h	<installdir>/package/include/tlibc/unistd.h	0	main	STP
 <deliverydir>/common/inc/tlibc/wchar.h	<installdir>/package/include/tlibc/wchar.h	0	main	STP
 <deliverydir>/common/inc/tlibc/wctype.h	<installdir>/package/include/tlibc/wctype.h	0	main	STP
+<deliverydir>/common/inc/tlibc/setjmp.h	<installdir>/package/include/tlibc/setjmp.h	0	main	STP
 <deliverydir>/common/src/se_memory.c	<installdir>/package/ptrace/se_memory.c	0	main	STP
 <deliverydir>/common/src/se_trace.c	<installdir>/package/ptrace/se_trace.c	0	main	STP
 <deliverydir>/linux/installer/common/sdk/install.sh	<installdir>/scripts/install.sh	0	main	STP

+ 5 - 0
linux/installer/common/sdk/BOMs/sdk_x64.txt

@@ -13,6 +13,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/build/linux/libsgx_tservice_sim.a	<installdir>/package/lib64/libsgx_tservice_sim.a	0	main	STP
 <deliverydir>/build/linux/libsgx_tstdc.a	<installdir>/package/lib64/libsgx_tstdc.a	0	main	STP
 <deliverydir>/build/linux/libsgx_tstdcxx.a	<installdir>/package/lib64/libsgx_tstdcxx.a	0	main	STP
+<deliverydir>/build/linux/libsgx_tsetjmp.a	<installdir>/package/lib64/libsgx_tsetjmp.a	0	main	STP
 <deliverydir>/build/linux/libsgx_uae_service_deploy.so	<installdir>/package/lib64/libsgx_uae_service.so	0	main	STP
 <deliverydir>/build/linux/libsgx_uae_service_sim.so	<installdir>/package/lib64/libsgx_uae_service_sim.so	0	main	STP
 <deliverydir>/build/linux/libsgx_ukey_exchange.a	<installdir>/package/lib64/libsgx_ukey_exchange.a	0	main	STP
@@ -23,3 +24,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/build/linux/sgx_edger8r	<installdir>/package/bin/x64/sgx_edger8r	0	main	STP
 <deliverydir>/build/linux/sgx_sign	<installdir>/package/bin/x64/sgx_sign	0	main	STP
 <deliverydir>/linux/installer/common/sdk/installConfig.x64	<installdir>/scripts/installConfig	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x64/libsgx_uae_service_sim.pc	<installdir>/package/pkgconfig/libsgx_uae_service_sim.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x64/libsgx_urts_sim.pc	<installdir>/package/pkgconfig/libsgx_urts_sim.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x64/libsgx_uae_service.pc	<installdir>/package/pkgconfig/libsgx_uae_service.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x64/libsgx_urts.pc	<installdir>/package/pkgconfig/libsgx_urts.pc	0	main	STP

+ 5 - 0
linux/installer/common/sdk/BOMs/sdk_x86.txt

@@ -13,6 +13,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/build/linux/libsgx_tservice_sim.a	<installdir>/package/lib/libsgx_tservice_sim.a	0	main	STP
 <deliverydir>/build/linux/libsgx_tstdc.a	<installdir>/package/lib/libsgx_tstdc.a	0	main	STP
 <deliverydir>/build/linux/libsgx_tstdcxx.a	<installdir>/package/lib/libsgx_tstdcxx.a	0	main	STP
+<deliverydir>/build/linux/libsgx_tsetjmp.a	<installdir>/package/lib/libsgx_tsetjmp.a	0	main	STP
 <deliverydir>/build/linux/libsgx_uae_service_deploy.so	<installdir>/package/lib/libsgx_uae_service.so	0	main	STP
 <deliverydir>/build/linux/libsgx_uae_service_sim.so	<installdir>/package/lib/libsgx_uae_service_sim.so	0	main	STP
 <deliverydir>/build/linux/libsgx_ukey_exchange.a	<installdir>/package/lib/libsgx_ukey_exchange.a	0	main	STP
@@ -23,3 +24,7 @@ DeliveryName	InstallName	FileCheckSum	FileFeature	FileOwner
 <deliverydir>/build/linux/sgx_edger8r	<installdir>/package/bin/x86/sgx_edger8r	0	main	STP
 <deliverydir>/build/linux/sgx_sign	<installdir>/package/bin/x86/sgx_sign	0	main	STP
 <deliverydir>/linux/installer/common/sdk/installConfig.x86	<installdir>/scripts/installConfig	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x86/libsgx_uae_service_sim.pc	<installdir>/package/pkgconfig/libsgx_uae_service_sim.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x86/libsgx_urts_sim.pc	<installdir>/package/pkgconfig/libsgx_urts_sim.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x86/libsgx_uae_service.pc	<installdir>/package/pkgconfig/libsgx_uae_service.pc	0	main	STP
+<deliverydir>/linux/installer/common/sdk/pkgconfig/x86/libsgx_urts.pc	<installdir>/package/pkgconfig/libsgx_urts.pc	0	main	STP

+ 20 - 1
linux/installer/common/sdk/Makefile

@@ -34,7 +34,7 @@ include scripts/installConfig
 SOURCE_FOLDER=package
 SCRIPTS_FOLDER=scripts
 
-INSTALL_PATH=$(DESTDIR)/$(SGX_PACKAGES_PATH)/$(SDK_PKG_NAME)
+INSTALL_PATH=$(shell readlink -m $(DESTDIR)/$(SGX_PACKAGES_PATH)/$(SDK_PKG_NAME))
 SOURCE_INSTALL_PATH=$(INSTALL_PATH)
 SCRIPTS_INSTALL_PATH=$(INSTALL_PATH)/$(SCRIPTS_FOLDER)
 SDK_LIB_PATH=$(SOURCE_INSTALL_PATH)/$(LIB_DIR)
@@ -44,8 +44,27 @@ default:
 install:
 	install -d $(SOURCE_INSTALL_PATH)
 	install -d $(SCRIPTS_INSTALL_PATH)
+
+ifneq ($(INSTALLER_FORM),BIN)
 	install -d $(DESTDIR)/usr/lib
+	install -d $(DESTDIR)/usr/lib/pkgconfig
+endif
+
 	cp -r $(SOURCE_FOLDER)/* $(SOURCE_INSTALL_PATH)
 	install $(SCRIPTS_FOLDER)/* $(SCRIPTS_INSTALL_PATH)
+
+ifeq ($(INSTALLER_FORM),BIN)
+	@sed -i "s#\(prefix=\).*#\1$(INSTALL_PATH)#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_uae_service_sim.pc
+	@sed -i "s#\(prefix=\).*#\1$(INSTALL_PATH)#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_urts_sim.pc
+	@sed -i "s#\(prefix=\).*#\1$(INSTALL_PATH)#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_uae_service.pc
+	@sed -i "s#\(prefix=\).*#\1$(INSTALL_PATH)#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_urts.pc
+else
+	@sed -i "s#\(libdir=\).*#\1/usr/lib#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_uae_service_sim.pc
+	@sed -i "s#\(libdir=\).*#\1/usr/lib#" $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_urts_sim.pc
 	mv $(SDK_LIB_PATH)/libsgx_uae_service_sim.so $(DESTDIR)/usr/lib
 	mv $(SDK_LIB_PATH)/libsgx_urts_sim.so $(DESTDIR)/usr/lib
+	mv $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_uae_service_sim.pc $(DESTDIR)/usr/lib/pkgconfig
+	mv $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_urts_sim.pc $(DESTDIR)/usr/lib/pkgconfig
+	mv $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_uae_service.pc $(DESTDIR)/usr/lib/pkgconfig
+	mv $(SOURCE_INSTALL_PATH)/pkgconfig/libsgx_urts.pc $(DESTDIR)/usr/lib/pkgconfig
+endif

+ 26 - 2
linux/installer/common/sdk/createTarball.sh

@@ -53,6 +53,32 @@ get_arch()
 
 ARCH=$(get_arch)
 
+# Get the configuration for this package
+source ${SCRIPT_DIR}/installConfig.${ARCH}
+
+generate_pkgconfig_files() {
+    local TEMPLATE_FOLDER=${SCRIPT_DIR}/pkgconfig/template
+    local TARGET_FOLDER=${SCRIPT_DIR}/pkgconfig/${ARCH}
+    local VERSION="$1"
+
+    # Create pkgconfig folder for this architecture
+    rm -fr ${TARGET_FOLDER}
+    mkdir -p ${TARGET_FOLDER}
+
+    # Copy the template files into the folder
+    for pkgconfig_file in $(ls -1 ${TEMPLATE_FOLDER}); do
+        sed -e "s:@LIB_FOLDER_NAME@:$LIB_DIR:" \
+            -e "s:@SGX_VERSION@:$VERSION:" \
+            ${TEMPLATE_FOLDER}/$pkgconfig_file > ${TARGET_FOLDER}/$pkgconfig_file
+    done
+}
+
+# Get SGX version
+SGX_VERSION=$(awk '/STRFILEVER/ {print $3}' ${ROOT_DIR}/common/inc/internal/se_version.h|sed 's/^\"\(.*\)\"$/\1/')
+
+# Generate pkgconfig files
+generate_pkgconfig_files $SGX_VERSION
+
 # Fetch the gen_source script
 cp ${LINUX_INSTALLER_COMMON_DIR}/gen_source/gen_source.py ${SCRIPT_DIR}
 
@@ -62,8 +88,6 @@ python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/sdk_${ARCH}.txt --cleanup=false
 python ${SCRIPT_DIR}/gen_source.py --bom=../licenses/BOM_license.txt --cleanup=false
 
 # Create the tarball
-source ${SCRIPT_DIR}/installConfig.${ARCH}
-
 pushd ${INSTALL_PATH} &> /dev/null
 tar -zcvf ${TARBALL_NAME} *
 popd &> /dev/null

+ 40 - 5
linux/installer/common/sdk/install.sh

@@ -38,9 +38,14 @@ source ${SCRIPT_DIR}/installConfig
 
 # Generate the script to preload SGX ptrace library for gdb
 SDK_DST_PATH=${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}
-GDB_SCRIPT=/usr/bin/sgx-gdb
 SDK_LIB_PATH=${SDK_DST_PATH}/${LIB_DIR}
 
+if [ "$1" == "BIN" ]; then
+    GDB_SCRIPT=${SDK_DST_PATH}/bin/sgx-gdb
+else
+    GDB_SCRIPT=/usr/bin/sgx-gdb
+fi
+
 generate_gdb_script()
 {
     cat > $GDB_SCRIPT <<EOF
@@ -65,7 +70,7 @@ shopt -s expand_aliases
 GDB_SGX_PLUGIN_PATH=$SDK_LIB_PATH/gdb-sgx-plugin
 SGX_LIBRARY_PATH=$SDK_LIB_PATH
 export PYTHONPATH=\$GDB_SGX_PLUGIN_PATH
-LD_PRELOAD=\$SGX_LIBRARY_PATH/libsgx_ptrace.so /usr/bin/gdb -iex "directory \$GDB_SGX_PLUGIN_PATH" -iex "source \$GDB_SGX_PLUGIN_PATH/gdb_sgx_plugin.py" -iex "set environment LD_PRELOAD" "\$@"
+LD_PRELOAD=\$SGX_LIBRARY_PATH/libsgx_ptrace.so /usr/bin/gdb -iex "directory \$GDB_SGX_PLUGIN_PATH" -iex "source \$GDB_SGX_PLUGIN_PATH/gdb_sgx_plugin.py" -iex "set environment LD_PRELOAD" -iex "add-auto-load-safe-path /usr/lib" "\$@"
 EOF
 
     chmod +x $GDB_SCRIPT
@@ -73,8 +78,9 @@ EOF
 
 generate_gdb_script
 
-
-cat > $SDK_DST_PATH/uninstall.sh <<EOF
+generate_uninstall_script()
+{
+    cat > $SDK_DST_PATH/uninstall.sh <<EOF
 #!/usr/bin/env bash
 
 if test \$(id -u) -ne 0; then
@@ -86,6 +92,12 @@ fi
 rm -f /usr/lib/libsgx_uae_service_sim.so
 rm -f /usr/lib/libsgx_urts_sim.so
 
+# Removing pkg-config files
+rm -f /usr/lib/pkgconfig/libsgx_uae_service.pc
+rm -f /usr/lib/pkgconfig/libsgx_urts.pc
+rm -f /usr/lib/pkgconfig/libsgx_uae_service_sim.pc
+rm -f /usr/lib/pkgconfig/libsgx_urts_sim.pc
+
 # Removing sgx-gdb script
 rm -f $GDB_SCRIPT
 
@@ -93,11 +105,34 @@ rm -f $GDB_SCRIPT
 rm -fr $SDK_DST_PATH
 
 EOF
+}
+
+generate_uninstall_script_for_bin()
+{
+    cat > $SDK_DST_PATH/uninstall.sh <<EOF
+#!/usr/bin/env bash
+
+# Removing the SDK folder
+rm -fr $SDK_DST_PATH 2> /dev/null
+
+if [ \$? -ne 0 ]; then
+    echo "Superuser privilege is required."
+    exit 1
+fi
+
+EOF
+}
+
+if [ "$1" == "BIN" ]; then
+    generate_uninstall_script_for_bin
+else
+    generate_uninstall_script
+fi
 
 chmod +x $SDK_DST_PATH/uninstall.sh
 
 echo -e "uninstall.sh script generated in $SDK_DST_PATH\n"
-echo -e "Installation successful! The SDK package can be found in $SDK_DST_PATH"
+echo -e "Installation is successful! The SDK package can be found in $SDK_DST_PATH"
 
 rm -fr $SDK_DST_PATH/scripts
 

+ 10 - 0
linux/installer/common/sdk/pkgconfig/template/libsgx_uae_service.pc

@@ -0,0 +1,10 @@
+prefix=/opt/intel/sgxsdk
+includedir=${prefix}/include
+libdir=${prefix}/@LIB_FOLDER_NAME@
+
+Name: libsgx_uae_service
+Description: SGX uAE service library
+Version: @SGX_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lsgx_uae_service
+Libs.private: -lsgx_urts

+ 10 - 0
linux/installer/common/sdk/pkgconfig/template/libsgx_uae_service_sim.pc

@@ -0,0 +1,10 @@
+prefix=/opt/intel/sgxsdk
+includedir=${prefix}/include
+libdir=${prefix}/@LIB_FOLDER_NAME@
+
+Name: libsgx_uae_service_sim
+Description: SGX uAE service simulation library
+Version: @SGX_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lsgx_uae_service_sim
+Libs.private: -lsgx_urts_sim

+ 10 - 0
linux/installer/common/sdk/pkgconfig/template/libsgx_urts.pc

@@ -0,0 +1,10 @@
+prefix=/opt/intel/sgxsdk
+includedir=${prefix}/include
+libdir=${prefix}/@LIB_FOLDER_NAME@
+
+Name: libsgx_urts
+Description: SGX uRTS library
+Version: @SGX_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lsgx_urts
+Libs.private: -lsgx_uae_service

+ 10 - 0
linux/installer/common/sdk/pkgconfig/template/libsgx_urts_sim.pc

@@ -0,0 +1,10 @@
+prefix=/opt/intel/sgxsdk
+includedir=${prefix}/include
+libdir=${prefix}/@LIB_FOLDER_NAME@
+
+Name: libsgx_urts_sim
+Description: SGX uRTS simulation library
+Version: @SGX_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lsgx_urts_sim
+Libs.private: -lsgx_uae_service_sim

+ 3 - 3
psw/ae/Makefile

@@ -40,10 +40,10 @@ else
 endif
 
 .PHONY: all
-all: $(CURL_RESULT) LE AESM COPY_PVE_QE| $(BUILD_DIR)
+all: $(CURL_RESULT) LE AESM COPY_PVE_QE_PCE| $(BUILD_DIR)
 
-.PHONY: COPY_PVE_QE
-COPY_PVE_QE: | $(BUILD_DIR)
+.PHONY: COPY_PVE_QE_PCE
+COPY_PVE_QE_PCE: | $(BUILD_DIR)
 	$(CP) data/prebuilt/* $(BUILD_DIR)
 
 .PHONY: AESM

+ 21 - 12
psw/ae/aesm_service/Makefile

@@ -60,6 +60,7 @@ INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/oal/
 INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/protobuf/
 INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/pve/
 INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/qe/
+INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/pce/
 INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/storage/
 INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux 
 
@@ -72,7 +73,6 @@ INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/epid_provision
 INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid/inc                        
 
 INCLUDE += -I$(LINUX_EXTERNAL_DIR)/crypto_px/include/              \
-           -I$(LINUX_EXTERNAL_DIR)/tinyxml/                        \
            -I$(LINUX_EXTERNAL_DIR)/                                                 \
            -I$(LINUX_EXTERNAL_DIR)/rdrand \
            -I$(IPC_COMMON_INC_DIR) \
@@ -113,13 +113,12 @@ TRTSLIB := -lsgx_trts
 WHITE_LIST_FILE := $(LINUX_PSW_DIR)/ae/data/prebuilt/white_list_cert_to_be_verify.bin
 
 TCRYPTO_LIBDIR  := $(LINUX_SDK_DIR)/tlibcrypto
-PROTOBUF_LIBDIR := $(LINUX_PROTOBUF)/intel64
 VTUNE_LIBDIR := $(LINUX_EXTERNAL_DIR)/vtune/linux/sdk/src/ittnotify
 RDRAND_LIBDIR :=$(LINUX_EXTERNAL_DIR)/rdrand/src
 RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile
 
 ifeq ($(ARCH), x86)
-    PROTOBUF_LIBDIR = $(LINUX_PROTOBUF)/ia32
+    VTUNE_LIBDIR = $(LINUX_EXTERNAL_DIR)/vtune/linux/lib32
 endif
 
 
@@ -131,15 +130,11 @@ EXTERNAL_LIB += -L$(LINUX_SE_WRAPPER) -lwrapper -lrt
 EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand
 EXTERNAL_LIB += -L$(VTUNE_LIBDIR) -littnotify
 
-vpath %.cpp $(COMMON_DIR)/src $(LINUX_EXTERNAL_DIR)/tinyxml ./source/epid_provision $(LINUX_PSW_DIR)/ae/common  $(AESM_APPLICATION) $(AESM_EXTENSION) $(AESM_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(COMMON_DIR)/src $(TOP_DIR)/sdk/tseal
+vpath %.cpp $(COMMON_DIR)/src ./source/epid_provision $(LINUX_PSW_DIR)/ae/common  $(AESM_APPLICATION) $(AESM_EXTENSION) $(AESM_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(COMMON_DIR)/src $(TOP_DIR)/sdk/tseal
 vpath %.cc $(IPC_COMMON_PROTO_DIR)
 vpath %.c $(TOP_DIR)/sdk/tlibc/string
 
-COMMON_SRC := tinyxmlparser.cpp            \
-              tinyxmlerror.cpp             \
-              tinyxml.cpp                  \
-              tinystr.cpp                  \
-              ./source/le/LEClass.cpp                  \
+COMMON_SRC := ./source/le/LEClass.cpp                  \
               ./source/oal/aesm_util.cpp                \
               ./source/storage/persistent_storage_table.cpp \
               aesm_logic.cpp  \
@@ -158,8 +153,10 @@ COMMON_SRC := tinyxmlparser.cpp            \
 
 COMMON_SRC += ./source/qe/QEClass.cpp                  \
               ./source/pve/PVEClass.cpp                \
+              ./source/pce/PCEClass.cpp                \
               aesm_encode.cpp              \
               aesm_epid_blob.cpp           \
+              aesm_xegd_blob.cpp            \
               epid_provision_msg1.cpp \
               epid_provision_msg2.cpp \
               epid_provision_msg4.cpp \
@@ -169,6 +166,7 @@ COMMON_SRC += ./source/qe/QEClass.cpp                  \
               ./source/qe/qe_logic.cpp \
               ./source/pve/pve_logic.cpp \
               platform_info_logic.cpp \
+              platform_info_facility.cpp \
               pve_pub_key.cpp \
               pek_pub_key.cpp \
               ./source/network/network_encoding_wrapper.cpp \
@@ -194,6 +192,14 @@ IPC_SRC  :=  $(IPC_COMMON_SRC_DIR)/AECloseSessionRequest.cpp    \
              $(IPC_COMMON_SRC_DIR)/AEGetLaunchTokenRequest.cpp  \
              $(IPC_COMMON_SRC_DIR)/AEGetPsCapRequest.cpp  \
              $(IPC_COMMON_SRC_DIR)/AEGetPsCapResponse.cpp  \
+             $(IPC_COMMON_SRC_DIR)/AEGetWhiteListSizeRequest.cpp \
+             $(IPC_COMMON_SRC_DIR)/AEGetWhiteListSizeResponse.cpp \
+             $(IPC_COMMON_SRC_DIR)/AEGetWhiteListRequest.cpp \
+             $(IPC_COMMON_SRC_DIR)/AEGetWhiteListResponse.cpp \
+             $(IPC_COMMON_SRC_DIR)/AESGXGetExtendedEpidGroupIdRequest.cpp \
+             $(IPC_COMMON_SRC_DIR)/AESGXGetExtendedEpidGroupIdResponse.cpp \
+             $(IPC_COMMON_SRC_DIR)/AESGXSwitchExtendedEpidGroupRequest.cpp \
+             $(IPC_COMMON_SRC_DIR)/AESGXSwitchExtendedEpidGroupResponse.cpp \
              $(IPC_COMMON_SRC_DIR)/AEReportAttestationRequest.cpp \
              $(IPC_COMMON_SRC_DIR)/AEReportAttestationResponse.cpp \
              $(IPC_COMMON_SRC_DIR)/SocketTransporter.cpp \
@@ -257,13 +263,14 @@ $(LIBNAME): $(COMMON_OBJ)
 consttime_memequal.o :consttime_memequal.c
 	$(CC) $(filter-out -O2,$(CFLAGS)) -fPIC -O1 $(INCLUDE) -c $< -o $@
 
-$(APPNAME): $(OBJ) $(LIBNAME) sgx_tcrypto -lrdrand
+$(APPNAME): $(OBJ) $(LIBNAME) sgx_tcrypto -lrdrand urts
 	$(CXX) $(CXXFLAGS) $(OBJ) $(LIBNAME) $(LDUFLAGS) $(EXTERNAL_LIB)   -o $@ -ldl
 $(IPC_SRC): PROTPBUF
 
 ./source/le/LEClass.o: ${AESM_EXTENSION}/launch_enclave_u.c
 ./source/pve/PVEClass.o: ${AESM_EXTENSION}/provision_enclave_u.c
 ./source/qe/QEClass.o: ${AESM_EXTENSION}/quoting_enclave_u.c
+./source/pce/PCEClass.o: ${AESM_EXTENSION}/pce_u.c
 uecall_bridge.o: ${AESM_EXTENSION}/pse_pr_u.c
 
 -lrdrand: $(RDRAND_MAKEFILE)
@@ -288,6 +295,8 @@ ${AESM_EXTENSION}/quoting_enclave_u.c: ${LINUX_PSW_DIR}/ae/qe/quoting_enclave.ed
 ${AESM_EXTENSION}/pse_pr_u.c:  ${LINUX_PSW_DIR}/ae/pse/pse_pr/pse_pr.edl
 	@$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
 
+${AESM_EXTENSION}/pce_u.c:  ${LINUX_PSW_DIR}/ae/pce/pce.edl
+	@$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
 .PHONY: PROTPBUF
 PROTPBUF:
 	$(MAKE) -C $(IPC_COMMON_PROTO_DIR)
@@ -307,13 +316,13 @@ clean:
 	@$(RM) $(APPNAME)
 	@$(RM) $(LIBNAME)
 	$(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean
+	$(MAKE) -C $(LINUX_PSW_DIR)/urts/linux clean
 	@$(RM) source/le/*.o
 	@$(RM) source/pve/*.o
-	@$(RM) source/pve/*.o
+	@$(RM) source/pce/*.o
 	@$(RM) source/network/*.o
 	@$(RM) source/oal/*.o
 	@$(RM) source/qe/*.o
-	@$(RM) source/qe/*.o
 	@$(RM) source/storage/*.o
 	@$(RM) $(AESM_EXTENSION)/*_u.c $(AESM_EXTENSION)/*_u.h
 ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE)))

+ 5 - 7
psw/ae/aesm_service/config/network/aesmd.conf

@@ -1,10 +1,8 @@
 #Line with comments only
 
 	  #empty line with comment
-#proxy type = direct #direct type means no proxy used
-#proxy type = default #system default proxy
-#proxy type = manual #aesm proxy should be specified for manual proxy type
-#aesm proxy = http://proxyuser:passwd@proxy_url:proxy_port
-#endpoint url = http://sample_endpoint_url:8080
-#pse rl url = http://sample_pse_rl_url/rl
-#pse ocsp url = https://sample_ocsp_url/ocsp
+#proxy type    = direct #direct type means no proxy used
+#proxy type    = default #system default proxy
+#proxy type    = manual #aesm proxy should be specified for manual proxy type
+#aesm proxy    = http://proxyuser:passwd@proxy_url:proxy_port
+#whitelist url = http://sample_while_list_url/

+ 31 - 10
psw/ae/aesm_service/include/oal/aesm_persistent_storage.h

@@ -54,8 +54,11 @@ typedef enum _aesm_data_id_t{
     PVE_ENCLAVE_FID,
     PSE_OP_ENCLAVE_FID,
     PSE_PR_ENCLAVE_FID,
+    PCE_ENCLAVE_FID,
     LE_PROD_SIG_STRUCT_FID,
     /*some normal persistent storages*/
+    EXTENDED_EPID_GROUP_ID_FID,
+    EXTENDED_EPID_GROUP_BLOB_INFO_FID,
     PROVISION_PEK_BLOB_FID,
     EPID_DATA_BLOB_FID,
     AESM_SERVER_URL_FID,
@@ -92,43 +95,61 @@ typedef enum _aesm_data_id_t{
 aesm_data_id_t operator++(aesm_data_id_t& id, int);
 
 typedef aesm_data_id_t aesm_enclave_id_t;
-
-/*Function to get pathname of a file object such as vmc database, aesm_get_cpathname is alias of function aesm_get_pathname
+#define DEFAULT_EGID 0
+#define INVALID_EGID 0xFFFFFFFF
+/*Function to get pathname of a file object such as vmc database
  *@type: input for the type of the storage
  *@data_id: id of persistent storage
  *@buf: start address  of the buffer to receive the zero terminated path file name of the data
  *@buf_size: size in char of the buffer 'buf'
- *@return AESM_SUCCESS on success or error code if faileda
+ *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *       the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *@return AESM_SUCCESS on success or error code if failed
  */
-ae_error_t aesm_get_pathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size);
-ae_error_t aesm_get_cpathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size);
+ae_error_t aesm_get_pathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size, uint32_t xgid = INVALID_EGID);
+ae_error_t aesm_get_cpathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size, uint32_t xgid = INVALID_EGID);
 
 /*Function to query size of data in persistent storage
  *@type: input for the type of storage
  *@data_id: id of persistent storage
  *@p_size: output parameter to return size of the data blob
+ *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *       the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  *@return AESM_SUCCESS on success or error code if failed
  */
-ae_error_t aesm_query_data_size(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t *p_size);
+ae_error_t aesm_query_data_size(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t *p_size, uint32_t xgid = INVALID_EGID);
 
 /*Function to read data from persistent storage
  *@type: input type of the storage
  *@data_id: id of persistent storage
  *@buf: start  address of the buffer to receive data from persistent storage
  *@p_size: the input value *p_size is size of the buffer and output the size in bytes of data read
+ *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *       the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  *@return AESM_SUCCESS on success or error code if failed
  *  The functin will not check whether there're too much data in the persistent storage to be read
  */
-ae_error_t aesm_read_data(aesm_data_type_t type, aesm_data_id_t data_id, uint8_t *buf, uint32_t *p_size);
+ae_error_t aesm_read_data(aesm_data_type_t type, aesm_data_id_t data_id, uint8_t *buf, uint32_t *p_size, uint32_t xgid = INVALID_EGID);
 
-/*Function to write data to persistent storage
+/*Function to write data tp persistent storage
  *@type: input type of the storage
  *@data_id: id of persistent storage
  *@buf: start  address of the buffer where the data is to be saved to persistent storage
- *@size: size in bytes of the input data in buf
+ *@size: size in bytes of the ti be saved
+ *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *       the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  *@return AESM_SUCCESS on success or error code if failed
+ *  The functin will not check whether there're too much data in the persistent storage to be read
  */
-ae_error_t aesm_write_data(aesm_data_type_t type, aesm_data_id_t data_id, const uint8_t *buf, uint32_t size);
+ae_error_t aesm_write_data(aesm_data_type_t type, aesm_data_id_t data_id, const uint8_t *buf, uint32_t size, uint32_t xgid = INVALID_EGID);
 
+/*Function to remove data persistent storage
+ *@type: input type of the storage
+ *@data_id: id of persistent storage
+ *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *       the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
+ *@return AESM_SUCCESS on success or error code if failed 
+ */
+ae_error_t aesm_remove_data(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t xgid = INVALID_EGID);
 #endif
 

+ 1 - 0
psw/ae/aesm_service/include/oal/error_report.h

@@ -50,6 +50,7 @@ extern "C" {
 #define AESM_LOG_WARN(format, args...)  aesm_log_report(AESM_LOG_REPORT_WARNING, format, ## args)
 #define AESM_LOG_INIT() aesm_log_init()
 #define AESM_LOG_FINI() aesm_log_fini()
+#define AESM_LOG_ERROR_UNICODE AESM_LOG_ERROR
 
 #endif/*__OAL_ERROR_REPORT_H__*/
 

+ 2 - 0
psw/ae/aesm_service/include/oal/internal_log.h

@@ -75,6 +75,8 @@ extern "C" {
 #define SGX_DBGPRINT_PRINT_TWO_STRINGS(x,y)                 AESM_DBG_WARN("%s %s",x, y)
 #define SGX_DBGPRINT_PRINT_TWO_STRINGS_ONE_INT(x,y,z)       AESM_DBG_WARN("%s %s %d", x,y,z)
 #define SGX_DBGPRINT_PRINT_FIVE_STRINGS(a,b,c,d,e)          AESM_DBG_WARN("%s %s %s %s %s",a,b,c,d,e)
+#define SGX_DBGPRINT_PRINT_UNICODE_STRING_LTP(x)            AESM_DBG_WARN("%s", x)
+#define SGX_DBGPRINT_PRINT_ANSI_STRING(x)                   AESM_DBG_WARN("%s",x)
 #define SGX_DBGPRINT_PRINT_STRING_LTP(x)                    AESM_DBG_WARN("%s",x)
 #define SGX_DBGPRINT_PRINT_STRING(x)                        AESM_DBG_WARN("%s",x)
 

+ 5 - 2
psw/ae/aesm_service/source/aesm/application/AEClass.h

@@ -28,7 +28,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
-
 #ifndef _AE_CLASS_H_
 #define _AE_CLASS_H_
 #include "sgx_eid.h"
@@ -125,9 +124,13 @@ ae_error_t SingletonEnclave<T>::load_enclave()
         AESM_DBG_ERROR("AE SERVER NOT AVAILABLE in load enclave: %s",enclave_path);
         return AE_SERVER_NOT_AVAILABLE;
     }
+    if(ret == SGX_ERROR_OUT_OF_EPC){
+        AESM_DBG_ERROR("No enough EPC to load AE: %s",enclave_path);
+        return AESM_AE_OUT_OF_EPC;
+    }
     if (ret != SGX_SUCCESS){
         AESM_DBG_ERROR("Create Enclave failed:%d",ret);
-        return AE_FAILURE;
+        return AE_SERVER_NOT_AVAILABLE;
     }
     AESM_DBG_INFO("enclave %d loaded with id 0X%llX",aesm_enclave_id,m_enclave_id);
 

+ 8 - 29
psw/ae/aesm_service/source/aesm/application/aesm_config.cpp

@@ -33,6 +33,7 @@
 #include "aesm_config.h"
 #include "aesm_proxy_type.h"
 #include "oal.h"
+#include "default_url_info.hh"
 #include <sys/types.h>
 #include <regex.h>
 #include <stdio.h>
@@ -45,9 +46,7 @@
 enum _config_value_t{
     config_comment,
     config_space,
-    config_endpoint_url,
-    config_pse_rl_url,
-    config_pse_ocsp_url,
+    config_white_list_url,
     config_aesm_proxy_url,
     config_aesm_proxy_type,
     config_value_nums
@@ -59,9 +58,7 @@ struct _config_patterns_t{
 }config_patterns[]={
     {config_comment, "^[[:blank:]]*#"},   //matching a line with comments only (It is started by #)
     {config_space, "^[[:blank:]]*$"},   //matching empty line
-    {config_endpoint_url, "^[[:blank:]]*endpoint[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: endpoint url = ....
-    {config_pse_rl_url, "^[[:blank:]]*pse[[:blank:]]*rl[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: pse rl url = ...
-    {config_pse_ocsp_url, "^[[:blank:]]*pse[[:blank:]]*ocsp[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: pse ocsp url = ...
+    {config_white_list_url, "^[[:blank:]]*whitelist[[:blank:]]*url[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: whilelist url = ....
     {config_aesm_proxy_url,"^[[:blank:]]*aesm[[:blank:]]*proxy[[:blank:]]*=" URL_PATTERN OPTION_COMMENT "$"}, //matching line in format: aesm proxy = ...
     {config_aesm_proxy_type, "^[[:blank:]]*proxy[[:blank:]]*type[[:blank:]]*=[[:blank:]]([^[:blank:]]+)[[:blank:]]*" OPTION_COMMENT "$"}//matching line in format: proxy type = [direct|default|manual]
 };
@@ -143,28 +140,12 @@ static bool config_process_one_line(const char *line, config_entry_t entries[],
             case config_space:
                  //ignore comment and space only line
                  break;
-            case config_endpoint_url://Matching Endpoint URL setting
+            case config_white_list_url://Matching White List URL setting
                  if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){
-                     AESM_DBG_ERROR("too long endpoint url in config file");
+                     AESM_DBG_ERROR("too long white list url in config file");
                  }else{
-                     memcpy(infos.endpoint_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so);
-                     infos.endpoint_url[matches[1].rm_eo-matches[1].rm_so]='\0';
-                 }
-                 break;
-            case config_pse_rl_url:
-                 if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){
-                     AESM_DBG_ERROR("too long pse pr url in config file");
-                 }else{
-                     memcpy(infos.pse_rl_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so);
-                     infos.pse_rl_url[matches[1].rm_eo-matches[1].rm_so]='\0';
-                 }
-                 break;
-            case config_pse_ocsp_url:
-                 if(matches[1].rm_eo-matches[1].rm_so>=MAX_PATH){
-                     AESM_DBG_ERROR("too long pse ocsp url in config file");
-                 }else{
-                     memcpy(infos.pse_ocsp_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so);
-                     infos.pse_ocsp_url[matches[1].rm_eo-matches[1].rm_so]='\0';
+                     memcpy(infos.white_list_url, line+matches[1].rm_so,matches[1].rm_eo-matches[1].rm_so);
+                     infos.white_list_url[matches[1].rm_eo-matches[1].rm_so]='\0';
                  }
                  break;
            case config_aesm_proxy_url:
@@ -200,9 +181,7 @@ bool read_aesm_config(aesm_config_infos_t& infos)
     config_entry_t entries[config_value_nums];
     memset(&entries,0,sizeof(entries));
     memset(&infos, 0, sizeof(aesm_config_infos_t));
-    strcpy(infos.endpoint_url, DEFAULT_URL);
-    strcpy(infos.pse_rl_url,   DEFAULT_PSE_RL_URL);
-    strcpy(infos.pse_ocsp_url, DEFAULT_PSE_OCSP_URL);
+    strcpy(infos.white_list_url, DEFAULT_WHITE_LIST_URL);
     
     infos.proxy_type = AESM_PROXY_TYPE_DEFAULT_PROXY;
     FILE *f =fopen(AESM_CONFIG_FILE, "r");

+ 1 - 3
psw/ae/aesm_service/source/aesm/application/aesm_config.h

@@ -35,9 +35,7 @@
 #include "aesm_logic.h"
 typedef struct _aesm_config_infos_t{
     uint32_t proxy_type;
-    char endpoint_url[MAX_PATH];
-    char pse_rl_url[MAX_PATH];
-    char pse_ocsp_url[MAX_PATH];
+    char white_list_url[MAX_PATH];
     char aesm_proxy[MAX_PATH];
 }aesm_config_infos_t;
 #endif

+ 360 - 43
psw/ae/aesm_service/source/aesm/application/aesm_logic.cpp

@@ -34,6 +34,7 @@
 #include "QEClass.h"
 #include "LEClass.h"
 #include "PVEClass.h"
+#include "PCEClass.h"
 
 #include "arch.h"
 #include "sgx_report.h"
@@ -46,6 +47,7 @@
 #include "oal/aesm_thread.h"
 #include "aesm_encode.h"
 #include "aesm_epid_blob.h"
+#include "aesm_xegd_blob.h"
 #include "aesm_logic.h"
 #include "pve_logic.h"
 #include "qe_logic.h"
@@ -64,6 +66,7 @@
 #include "prof_fun.h"
 #include "aesm_long_lived_thread.h"
 #include "sgx_profile.h"
+#include "service_enclave_mrsigner.hh"
 
 #define CHECK_SERVICE_STATUS     if (!is_service_running()) return AESM_SERVICE_STOPPED;
 #define CHECK_SGX_STATUS         if (g_sgx_device_status != SGX_ENABLED) return AESM_SGX_DEVICE_NOT_AVAILABLE;
@@ -74,13 +77,60 @@ AESMLogicMutex AESMLogic::_le_mutex;
 
 bool AESMLogic::_is_qe_psvn_set;
 bool AESMLogic::_is_pse_psvn_set;
+bool AESMLogic::_is_pce_psvn_set;
 psvn_t AESMLogic::_qe_psvn;
+psvn_t AESMLogic::_pce_psvn;
 psvn_t AESMLogic::_pse_psvn;
 
+uint32_t AESMLogic::active_extended_epid_group_id;
+
+static ae_error_t read_global_extended_epid_group_id(uint32_t *xeg_id)
+{
+    char path_name[MAX_PATH];
+    ae_error_t ae_ret = aesm_get_pathname(FT_PERSISTENT_STORAGE, EXTENDED_EPID_GROUP_ID_FID, path_name, MAX_PATH);
+    if(AE_SUCCESS != ae_ret){
+        return ae_ret;
+    }
+    FILE * f = fopen(path_name, "r");
+    if( f == NULL){
+        return OAL_CONFIG_FILE_ERROR;
+    }
+    ae_ret = OAL_CONFIG_FILE_ERROR;
+    if(fscanf(f, "%u", xeg_id)==1){
+        ae_ret = AE_SUCCESS;
+    }
+    fclose(f);
+    return ae_ret;
+}
+static ae_error_t set_global_extended_epid_group_id(uint32_t xeg_id)
+{
+    char path_name[MAX_PATH];
+    ae_error_t ae_ret = aesm_get_pathname(FT_PERSISTENT_STORAGE, EXTENDED_EPID_GROUP_ID_FID, path_name, MAX_PATH);
+    if(AE_SUCCESS != ae_ret){
+        return ae_ret;
+    }
+    FILE *f = fopen(path_name, "w");
+    if(f == NULL){
+        return OAL_CONFIG_FILE_ERROR;
+    }
+    ae_ret = OAL_CONFIG_FILE_ERROR;
+    if(fprintf(f, "%u", xeg_id)>0){
+        ae_ret = AE_SUCCESS;
+    }
+    fclose(f);
+    return ae_ret;
+}
+
+uint32_t AESMLogic::get_active_extended_epid_group_id()
+{
+    return active_extended_epid_group_id;
+}
+
 static ae_error_t thread_to_load_qe(aesm_thread_arg_type_t arg)
 {
     epid_blob_with_cur_psvn_t epid_data;
     ae_error_t ae_ret = AE_FAILURE;
+    uint32_t epid_xeid = 0;
     UNUSED(arg);
     AESM_DBG_TRACE("start to load qe");
     memset(&epid_data, 0, sizeof(epid_data));
@@ -94,7 +144,50 @@ static ae_error_t thread_to_load_qe(aesm_thread_arg_type_t arg)
             AESM_DBG_WARN("fail to load QE: %d", ae_ret);
         }else{
             AESM_DBG_TRACE("QE loaded successfully");
+            bool resealed = false;
+            // Just take this chance to reseal EPID blob in case TCB is
+            // upgraded, return value is ignored and no provisioning is
+            // triggered.
+            ae_ret = static_cast<ae_error_t>(CQEClass::instance().verify_blob(
+                epid_data.trusted_epid_blob,
+                SGX_TRUSTED_EPID_BLOB_SIZE_PAK,
+                &resealed));
+            if(AE_SUCCESS != ae_ret)
+            {
+                AESM_DBG_WARN("Failed to verify EPID blob: %d", ae_ret);
+                // The EPID blob is invalid.
+                EPIDBlob::instance().remove();
+            }else{
+                // Check whether EPID blob XEGDID is aligned with active extended group id if it exists.
+                if ((EPIDBlob::instance().get_extended_epid_group_id(&epid_xeid) == AE_SUCCESS) && (epid_xeid == AESMLogic::get_active_extended_epid_group_id())) {
+                    AESM_DBG_TRACE("EPID blob Verified");
+                    // XEGDID is aligned
+                    if (true == resealed)
+                    {
+                        AESM_DBG_TRACE("EPID blob is resealed");
+                        if ((ae_ret = EPIDBlob::instance().write(epid_data))
+                            != AE_SUCCESS)
+                        {
+                            AESM_DBG_WARN("Failed to update epid blob: %d", ae_ret);
+                        }
+                    }
+                }
+                else { // XEGDID is NOT aligned
+                    AESM_DBG_TRACE("XEGDID mismatch in EPIDBlob, loading PCE ...");
+                    EPIDBlob::instance().remove();
+                    ae_ret = CPCEClass::instance().load_enclave();
+                    if (AE_SUCCESS != ae_ret)
+                    {
+                        AESM_DBG_WARN("fail to load PCE: %d", ae_ret);
+                    }
+                    else{
+                        AESM_DBG_TRACE("PCE loaded successfully");
+                    }
+                }
+            }
         }
+    }else{
+        AESM_DBG_TRACE("Fail to read EPID Blob");
     }
     AESM_DBG_TRACE("QE Thread finished succ");
     return AE_SUCCESS;
@@ -110,6 +203,24 @@ ae_error_t AESMLogic::service_start()
 
     //ippInit();//no ippInit available for c version ipp
     AESM_DBG_INFO("aesm service is starting");
+
+    //Try to read current active extended epid group id
+    ae_ret = read_global_extended_epid_group_id(&AESMLogic::active_extended_epid_group_id);
+    if (AE_SUCCESS != ae_ret){
+        AESM_DBG_INFO("Fail to read extended epid group id, default extended epid group used");
+        AESMLogic::active_extended_epid_group_id = DEFAULT_EGID; //use default extended epid group id 0 if it is not available from data file
+
+    }
+    else{
+        AESM_DBG_INFO("active extended group id %d used", AESMLogic::active_extended_epid_group_id);
+    }
+    extended_epid_group_blob_t xegb;
+    aesm_server_url_infos_t urls;
+    if (AE_SUCCESS != (XEGDBlob::verify_xegd_by_xgid(active_extended_epid_group_id)) ||
+        AE_SUCCESS != (EndpointSelectionInfo::verify_file_by_xgid(active_extended_epid_group_id))){//try to load XEGD and URL file to make sure it is valid
+        AESMLogic::active_extended_epid_group_id = DEFAULT_EGID;//If the active extended epid group id read from data file is not valid, switch to default extended epid group id
+    }
+
     ae_ret = CLEClass::instance().load_enclave();
     if(AE_SUCCESS != ae_ret)
     {
@@ -126,7 +237,8 @@ ae_error_t AESMLogic::service_start()
     }else{
         (void)aesm_free_thread(qe_thread);//release thread handle to free memory
     }
-        
+ 
+    start_white_list_thread();       
     AESM_DBG_TRACE("aesm service is started");
 
     return AE_SUCCESS;
@@ -134,7 +246,9 @@ ae_error_t AESMLogic::service_start()
 
 void AESMLogic::service_stop()
 {
+    stop_all_long_lived_threads();//waiting for pending threads util timeout
     CPVEClass::instance().unload_enclave();
+    CPCEClass::instance().unload_enclave();
     CQEClass::instance().unload_enclave();
     CLEClass::instance().unload_enclave();
     stop_all_long_lived_threads();
@@ -234,16 +348,21 @@ aesm_error_t AESMLogic::get_launch_token(
         return AESM_PARAMETER_ERROR;
     }
     ae_error_t ae_ret = CLEClass::instance().load_enclave();
-    if(ae_ret == AE_SERVER_NOT_AVAILABLE)
+    if(ae_ret == AESM_AE_NO_DEVICE)
     {
         AESM_LOG_ERROR("%s", g_event_string_table[SGX_EVENT_SERVICE_UNAVAILABLE]);
         AESM_DBG_FATAL("LE not loaded due to AE_SERVER_NOT_AVAILABLE, possible SGX Env Not Ready");
         return AESM_NO_DEVICE_ERROR;
     }
+    else if(ae_ret == AESM_AE_OUT_OF_EPC)
+    {
+        AESM_DBG_WARN("LE not loaded due to out of EPC", ae_ret);
+        return AESM_OUT_OF_EPC;
+    }
     else if(AE_FAILED(ae_ret))
     {
         AESM_DBG_ERROR("LE not loaded:%d", ae_ret);
-        return AESM_UNEXPECTED_ERROR;
+        return AESM_SERVICE_UNAVAILABLE;
     }
     ret_le = static_cast<ae_error_t>(CLEClass::instance().get_launch_token(
         const_cast<uint8_t *>(mrenclave), mrenclave_size,
@@ -297,6 +416,24 @@ ae_error_t AESMLogic::get_qe_isv_svn(uint16_t& isv_svn)
     return AE_SUCCESS;
 }
 
+
+ae_error_t AESMLogic::get_pce_isv_svn(uint16_t& isv_svn)
+{
+    if(!_is_pce_psvn_set){
+        ae_error_t ae_err = CPCEClass::instance().load_enclave();
+        if(AE_SUCCESS != ae_err){
+            AESM_DBG_ERROR("Fail to load PCE Enclave:%d",ae_err);
+            return ae_err;
+        }
+    }
+    assert(_is_pce_psvn_set);
+    if(0!=memcpy_s(&isv_svn, sizeof(isv_svn), &_pce_psvn.isv_svn, sizeof(_pce_psvn.isv_svn))){
+        AESM_DBG_ERROR("memcpy failed");
+        return AE_FAILURE;
+    }
+    return AE_SUCCESS;
+}
+
 ae_error_t AESMLogic::get_pse_isv_svn(uint16_t& isv_svn)
 {
     return AE_FAILURE;
@@ -321,41 +458,62 @@ ae_error_t AESMLogic::get_qe_cpu_svn(sgx_cpu_svn_t& cpu_svn)
 
 
 
-ae_error_t AESMLogic::set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn)
+ae_error_t AESMLogic::set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn, uint32_t mrsigner_index)
 {
     if(prod_id == QE_PROD_ID){
-        if(_is_qe_psvn_set){
-            if(0!=memcmp(&_qe_psvn.isv_svn, &isv_svn, sizeof(isv_svn))||
-                0!=memcmp(&_qe_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){
-                    AESM_DBG_ERROR("PSVN unmatched for QE/PVE");
-                    return AE_PSVN_UNMATCHED_ERROR;
+        if(mrsigner_index == AE_MR_SIGNER){
+            if(_is_qe_psvn_set){
+                if(0!=memcmp(&_qe_psvn.isv_svn, &isv_svn, sizeof(isv_svn))||
+                    0!=memcmp(&_qe_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("PSVN unmatched for QE/PVE");
+                        return AE_PSVN_UNMATCHED_ERROR;
+                }
+            }else{
+                if(0!=memcpy_s(&_qe_psvn.isv_svn, sizeof(_qe_psvn.isv_svn), &isv_svn, sizeof(isv_svn))||
+                    0!=memcpy_s(&_qe_psvn.cpu_svn, sizeof(_qe_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("memcpy failed");
+                        return AE_FAILURE;
+                }
+                AESM_DBG_TRACE("get QE or PvE isv_svn=%d",(int)isv_svn);
+                _is_qe_psvn_set = true;
+                return AE_SUCCESS;
             }
-        }else{
-            if(0!=memcpy_s(&_qe_psvn.isv_svn, sizeof(_qe_psvn.isv_svn), &isv_svn, sizeof(isv_svn))||
-                0!=memcpy_s(&_qe_psvn.cpu_svn, sizeof(_qe_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){
-                    AESM_DBG_ERROR("memcpy failed");
-                    return AE_FAILURE;
+        }else if(mrsigner_index==PCE_MR_SIGNER){
+            if(_is_pce_psvn_set){
+                if(0!=memcmp(&_pce_psvn.isv_svn, &isv_svn, sizeof(isv_svn))||
+                    0!=memcmp(&_pce_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("PSVN unmatched for PCE");
+                        return AE_PSVN_UNMATCHED_ERROR;
+                }
+            }else{
+                if(0!=memcpy_s(&_pce_psvn.isv_svn, sizeof(_pce_psvn.isv_svn), &isv_svn, sizeof(isv_svn))||
+                    0!=memcpy_s(&_pce_psvn.cpu_svn, sizeof(_pce_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("memcpy failed");
+                        return AE_FAILURE;
+                }
+                AESM_DBG_TRACE("get PCE isv_svn=%d", (int)isv_svn);
+                _is_pce_psvn_set = true;
+                return AE_SUCCESS;
             }
-            AESM_DBG_TRACE("get QE or PvE isv_svn=%d",(int)isv_svn);
-            _is_qe_psvn_set = true;
-            return AE_SUCCESS;
         }
     }else if(prod_id == PSE_PROD_ID){
-        if(_is_pse_psvn_set){
-            if(0!=memcmp(&_pse_psvn.isv_svn, &isv_svn, sizeof(isv_svn))||
-                0!=memcmp(&_pse_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){
-                    AESM_DBG_ERROR("PSVN unmatched for PSE");
-                    return AE_PSVN_UNMATCHED_ERROR;
+        if(mrsigner_index == AE_MR_SIGNER){
+            if(_is_pse_psvn_set){
+                if(0!=memcmp(&_pse_psvn.isv_svn, &isv_svn, sizeof(isv_svn))||
+                    0!=memcmp(&_pse_psvn.cpu_svn, &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("PSVN unmatched for PSE");
+                        return AE_PSVN_UNMATCHED_ERROR;
+                }
+            }else{
+                if(0!=memcpy_s(&_pse_psvn.isv_svn, sizeof(_pse_psvn.isv_svn), &isv_svn, sizeof(isv_svn))||
+                    0!=memcpy_s(&_pse_psvn.cpu_svn, sizeof(_pse_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){
+                        AESM_DBG_ERROR("memcpy failed");
+                        return AE_FAILURE;
+                }
+                AESM_DBG_TRACE("get PSE isv_svn=%d", (int)isv_svn);
+                _is_pse_psvn_set = true;
+               return AE_SUCCESS;
             }
-        }else{
-            if(0!=memcpy_s(&_pse_psvn.isv_svn, sizeof(_pse_psvn.isv_svn), &isv_svn, sizeof(isv_svn))||
-                0!=memcpy_s(&_pse_psvn.cpu_svn, sizeof(_pse_psvn.cpu_svn), &cpu_svn, sizeof(sgx_cpu_svn_t))){
-                    AESM_DBG_ERROR("memcpy failed");
-                    return AE_FAILURE;
-            }
-            AESM_DBG_TRACE("get PSE isv_svn=%d", (int)isv_svn);
-            _is_pse_psvn_set = true;
-            return AE_SUCCESS;
         }
     }
     return AE_SUCCESS;
@@ -369,16 +527,25 @@ sgx_status_t AESMLogic::get_launch_token(const enclave_css_t* signature,
     AESMLogicLock lock(_le_mutex);
 
     ae_error_t ret_le = AE_SUCCESS;
+    uint32_t mrsigner_index = UINT32_MAX;
     // load LE to get launch token
     if((ret_le=CLEClass::instance().load_enclave()) != AE_SUCCESS)
     {
-        if(ret_le == AE_SERVER_NOT_AVAILABLE)
+        if(ret_le == AESM_AE_NO_DEVICE)
         {
-            AESM_DBG_FATAL("LE not loaded due to AE_SERVER_NOT_AVAILABLE, possible SGX Env Not Ready");
+            AESM_DBG_FATAL("LE not loaded due to no SGX device available, possible SGX Env Not Ready");
             return SGX_ERROR_NO_DEVICE;
         }
-        AESM_DBG_FATAL("fail to load LE:%d",ret_le);
-        return SGX_ERROR_UNEXPECTED;
+        else if(ret_le == AESM_AE_OUT_OF_EPC)
+        {
+            AESM_DBG_FATAL("LE not loaded due to out of EPC");
+            return SGX_ERROR_OUT_OF_EPC;
+        }
+        else
+        {
+            AESM_DBG_FATAL("fail to load LE:%d",ret_le);
+            return SGX_ERROR_SERVICE_UNAVAILABLE;
+        }
     }
 
 
@@ -390,7 +557,8 @@ sgx_status_t AESMLogic::get_launch_token(const enclave_css_t* signature,
         const_cast<uint8_t*>(reinterpret_cast<const uint8_t *>(attribute)),
         sizeof(sgx_attributes_t),
         reinterpret_cast<uint8_t*>(launch_token),
-        sizeof(token_t)));
+        sizeof(token_t),
+        &mrsigner_index));
     switch (ret_le)
     {
     case AE_SUCCESS:
@@ -411,7 +579,7 @@ sgx_status_t AESMLogic::get_launch_token(const enclave_css_t* signature,
     }
 
     token_t *lt = reinterpret_cast<token_t *>(launch_token);
-    ret_le = set_psvn(signature->body.isv_prod_id, signature->body.isv_svn, lt->cpu_svn_le);
+    ret_le = set_psvn(signature->body.isv_prod_id, signature->body.isv_svn, lt->cpu_svn_le, mrsigner_index);
     if(AE_PSVN_UNMATCHED_ERROR == ret_le)
     {
         //QE or PSE has been changed, but AESM doesn't restart. Will not provide service.
@@ -428,7 +596,7 @@ aesm_error_t AESMLogic::create_session(
     uint32_t* session_id,
     uint8_t* se_dh_msg1, uint32_t se_dh_msg1_size)
 {
-    return AESM_SERVICE_NOT_AVAILABLE;
+    return AESM_SERVICE_UNAVAILABLE;
 }
 
 aesm_error_t AESMLogic::exchange_report(
@@ -436,20 +604,20 @@ aesm_error_t AESMLogic::exchange_report(
     const uint8_t* se_dh_msg2, uint32_t se_dh_msg2_size,
     uint8_t* se_dh_msg3, uint32_t se_dh_msg3_size)
 {
-    return AESM_SERVICE_NOT_AVAILABLE;
+    return AESM_SERVICE_UNAVAILABLE;
 }
 
 aesm_error_t AESMLogic::close_session(
     uint32_t session_id)
 {
-    return AESM_SERVICE_NOT_AVAILABLE; 
+    return AESM_SERVICE_UNAVAILABLE; 
 }
 
 aesm_error_t AESMLogic::invoke_service(
     const uint8_t* pse_message_req, uint32_t pse_message_req_size,
     uint8_t* pse_message_resp, uint32_t pse_message_resp_size)
 {
-    return AESM_SERVICE_NOT_AVAILABLE;;
+    return AESM_SERVICE_UNAVAILABLE;;
 }
 
 aesm_error_t AESMLogic::get_ps_cap(
@@ -469,6 +637,7 @@ aesm_error_t AESMLogic::init_quote(
 {
     ae_error_t ret = AE_SUCCESS;
     uint16_t qe_isv_svn = 0xFFFF;
+    uint16_t pce_isv_svn = 0xFFFF;
     sgx_cpu_svn_t qe_cpu_svn;
     memset(&qe_cpu_svn, 0, sizeof(qe_cpu_svn));
     AESM_DBG_INFO("init_quote");
@@ -479,19 +648,42 @@ aesm_error_t AESMLogic::init_quote(
     }
     AESMLogicLock lock(_qe_pve_mutex);
     CHECK_EPID_PROVISIONG_STATUS;
+    ret = get_pce_isv_svn(pce_isv_svn);
+    if(AE_SUCCESS != ret)
+    {
+        if(AESM_AE_OUT_OF_EPC == ret)
+            return AESM_OUT_OF_EPC;
+        else if(AESM_AE_NO_DEVICE == ret)
+            return AESM_NO_DEVICE_ERROR;
+        else if(AE_SERVER_NOT_AVAILABLE == ret)
+            return AESM_SERVICE_UNAVAILABLE;
+        return AESM_UNEXPECTED_ERROR;
+    }
     ret = get_qe_cpu_svn(qe_cpu_svn);
     if(AE_SUCCESS != ret)
     {
+        if(AESM_AE_OUT_OF_EPC == ret)
+            return AESM_OUT_OF_EPC;
+        else if(AESM_AE_NO_DEVICE == ret)
+            return AESM_NO_DEVICE_ERROR;
+        else if(AE_SERVER_NOT_AVAILABLE == ret)
+            return AESM_SERVICE_UNAVAILABLE;
         return AESM_UNEXPECTED_ERROR;
     }
     ret = get_qe_isv_svn(qe_isv_svn);
     if(AE_SUCCESS != ret)
     {
+        if(AESM_AE_OUT_OF_EPC == ret)
+            return AESM_OUT_OF_EPC;
+        else if(AESM_AE_NO_DEVICE == ret)
+            return AESM_NO_DEVICE_ERROR;
+        else if(AE_SERVER_NOT_AVAILABLE == ret)
+            return AESM_SERVICE_UNAVAILABLE;
         return AESM_UNEXPECTED_ERROR;
     }
     return QEAESMLogic::init_quote(
                reinterpret_cast<sgx_target_info_t *>(target_info),
-               gid, gid_size, qe_isv_svn, qe_cpu_svn);
+               gid, gid_size, pce_isv_svn, qe_isv_svn, qe_cpu_svn);
 }
 
 aesm_error_t AESMLogic::get_quote(const uint8_t *report, uint32_t report_size,
@@ -502,6 +694,8 @@ aesm_error_t AESMLogic::get_quote(const uint8_t *report, uint32_t report_size,
                              uint8_t *qe_report, uint32_t qe_report_size,
                              uint8_t *quote, uint32_t buf_size)
 {
+    ae_error_t ret = AE_SUCCESS;
+    uint16_t pce_isv_svn = 0xFFFF;
     AESM_DBG_INFO("get_quote");
     if(sizeof(sgx_report_t) != report_size ||
        sizeof(sgx_spid_t) != spid_size)
@@ -516,8 +710,19 @@ aesm_error_t AESMLogic::get_quote(const uint8_t *report, uint32_t report_size,
     }
     AESMLogicLock lock(_qe_pve_mutex);
     CHECK_EPID_PROVISIONG_STATUS;
+    ret = get_pce_isv_svn(pce_isv_svn);
+    if(AE_SUCCESS != ret)
+    {
+        if(AESM_AE_OUT_OF_EPC == ret)
+            return AESM_OUT_OF_EPC;
+        else if(AESM_AE_NO_DEVICE == ret)
+            return AESM_NO_DEVICE_ERROR;
+        else if(AE_SERVER_NOT_AVAILABLE == ret)
+            return AESM_SERVICE_UNAVAILABLE;
+        return AESM_UNEXPECTED_ERROR;
+    }
     return QEAESMLogic::get_quote(report, quote_type, spid, nonce, sigrl,
-                                  sigrl_size, qe_report, quote, buf_size);
+                                  sigrl_size, qe_report, quote, buf_size, pce_isv_svn);
 }
 
 uint32_t AESMLogic::endpoint_selection(endpoint_selection_infos_t& es_info)
@@ -538,6 +743,84 @@ aesm_error_t AESMLogic::report_attestation_status(
     return PlatformInfoLogic::report_attestation_status(platform_info, platform_info_size, attestation_status, update_info, update_info_size);
 }
 
+uint32_t AESMLogic::is_gid_matching_result_in_epid_blob(const GroupID& gid)
+{
+    AESMLogicLock lock(_qe_pve_mutex);
+    EPIDBlob& epid_blob = EPIDBlob::instance();
+    uint32_t le_gid;
+    if(epid_blob.get_sgx_gid(&le_gid)!=AE_SUCCESS){//get littlen endian gid
+        return GIDMT_UNEXPECTED_ERROR;
+    }
+    le_gid=_htonl(le_gid);//use bigendian gid
+    se_static_assert(sizeof(le_gid)==sizeof(gid));
+    if(memcmp(&le_gid,&gid,sizeof(gid))!=0){
+        return GIDMT_UNMATCHED;
+    }
+    return GIDMT_MATCHED;
+}
+
+ae_error_t AESMLogic::get_white_list_size_without_lock(uint32_t *white_list_cert_size)
+{
+    uint32_t white_cert_size = 0;
+    ae_error_t ae_ret = aesm_query_data_size(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_FID, &white_cert_size);
+    if (AE_SUCCESS == ae_ret)
+    {
+        if (white_cert_size != 0){//file existing and not 0 size
+            *white_list_cert_size = white_cert_size;
+            return AE_SUCCESS;
+        }
+        else
+            return AE_FAILURE;
+    }
+    else
+    {
+        return ae_ret;
+    }
+}
+
+aesm_error_t AESMLogic::get_white_list_size(
+        uint32_t* white_list_cert_size)
+{
+    if (NULL == white_list_cert_size){
+        return AESM_PARAMETER_ERROR;
+    }
+    CHECK_SERVICE_STATUS;
+    AESMLogicLock lock(_le_mutex);
+    CHECK_SERVICE_STATUS;
+    ae_error_t ae_ret = get_white_list_size_without_lock(white_list_cert_size);
+    if (AE_SUCCESS == ae_ret)
+        return AESM_SUCCESS;
+    else
+        return AESM_UNEXPECTED_ERROR;
+}
+
+
+aesm_error_t AESMLogic::get_white_list(
+    uint8_t *white_list_cert, uint32_t buf_size)
+{
+    uint32_t white_cert_size=0;
+    if (NULL == white_list_cert){
+        return AESM_PARAMETER_ERROR;
+    }
+    CHECK_SERVICE_STATUS;
+    AESMLogicLock lock(_le_mutex);
+    CHECK_SERVICE_STATUS;
+    ae_error_t ae_ret = get_white_list_size_without_lock(&white_cert_size);
+    if (AE_SUCCESS != ae_ret)
+        return AESM_UNEXPECTED_ERROR;
+    if (white_cert_size != buf_size)
+    {
+        return AESM_PARAMETER_ERROR;
+    }
+
+    ae_ret = aesm_read_data(FT_PERSISTENT_STORAGE, AESM_WHITE_LIST_CERT_FID, white_list_cert, &white_cert_size);
+    if (AE_SUCCESS != ae_ret){
+        AESM_DBG_WARN("Fail to read white cert list file");
+        return AESM_UNEXPECTED_ERROR;
+    }
+    return AESM_SUCCESS;
+}
+
 ae_error_t sgx_error_to_ae_error(sgx_status_t status)
 {
     if(SGX_ERROR_OUT_OF_MEMORY == status)
@@ -547,3 +830,37 @@ ae_error_t sgx_error_to_ae_error(sgx_status_t status)
     return AE_FAILURE;
 }
 
+aesm_error_t AESMLogic::switch_extended_epid_group(
+    uint32_t extended_epid_group_id
+    )
+{
+    AESM_DBG_INFO("AESMLogic::switch_extended_epid_group");
+    ae_error_t ae_ret;
+    extended_epid_group_blob_t xegb;
+    aesm_server_url_infos_t urls;
+    if ((ae_ret = XEGDBlob::verify_xegd_by_xgid(extended_epid_group_id)) != AE_SUCCESS ||
+        (ae_ret = EndpointSelectionInfo::verify_file_by_xgid(extended_epid_group_id)) != AE_SUCCESS){
+        AESM_DBG_INFO("Fail to switch to extended epid group to %d due to XEGD blob for URL blob not available", extended_epid_group_id);
+        return AESM_PARAMETER_ERROR;
+    }
+    ae_ret = set_global_extended_epid_group_id(extended_epid_group_id);
+    if (ae_ret != AE_SUCCESS){
+        AESM_DBG_INFO("Fail to switch to extended epid group %d", extended_epid_group_id);
+        return AESM_UNEXPECTED_ERROR;
+    }
+
+    AESM_DBG_INFO("Succ to switch to extended epid group %d in data file, restart aesm required to use it", extended_epid_group_id);
+    return AESM_SUCCESS;
+}
+aesm_error_t AESMLogic::get_extended_epid_group_id(
+    uint32_t* extended_epid_group_id)
+{
+    AESM_DBG_INFO("AESMLogic::get_extended_epid_group");
+    if (NULL == extended_epid_group_id)
+    {
+        return AESM_PARAMETER_ERROR;
+    }
+    *extended_epid_group_id = get_active_extended_epid_group_id();
+    return AESM_SUCCESS;
+}
+

+ 23 - 6
psw/ae/aesm_service/source/aesm/application/aesm_logic.h

@@ -49,7 +49,7 @@
 
 #include "default_url_info.hh"
 
-/*File to declare AESMLogic Class */
+/*File to declare AESMLogic Class and facility class(Mutex/Lock) for it*/
 
 const uint32_t THREAD_TIMEOUT = 5000;
 
@@ -82,15 +82,19 @@ class AESMLogic{
 public:
     static AESMLogicMutex _qe_pve_mutex, _pse_mutex, _le_mutex; /*mutex to lock external interface*/
 private:
-    static psvn_t _qe_psvn, _pse_psvn; /*two different cpu svn used although they're same. We should only access qe_psvn when qe_pve_mutex is acquired and only access pse_psvn when pse_mutext is acquired*/
-    static bool _is_qe_psvn_set, _is_pse_psvn_set;
-    static ae_error_t set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn);
+    static psvn_t _qe_psvn, _pse_psvn, _pce_psvn;   /*different cpu svn used although they're same. We should only access _qe_psvn/_pce_svn when qe_pve_mutex is acquired and only access _pse_psvn when pse_mutext is acquired*/
+    static bool _is_qe_psvn_set, _is_pse_psvn_set, _is_pce_psvn_set;
+    static uint32_t active_extended_epid_group_id;
+    static ae_error_t set_psvn(uint16_t prod_id, uint16_t isv_svn, sgx_cpu_svn_t cpu_svn, uint32_t mrsigner_index);
     static ae_error_t save_unverified_white_list(const uint8_t *white_list_cert, uint32_t white_list_cert_size);
+    static ae_error_t get_white_list_size_without_lock(uint32_t *white_list_cert_size);
 public:
-    static ae_error_t get_qe_isv_svn(uint16_t& isv_svn);/*This function should only be called when _qe_pve_mutex is acquired*/
+    static ae_error_t get_qe_isv_svn(uint16_t& isv_svn);     /*This function should only be called when _qe_pve_mutex is acquired*/
     static ae_error_t get_qe_cpu_svn(sgx_cpu_svn_t& cpu_svn);/*This function should only be called when _qe_pve_mutex is acquired*/
-    static ae_error_t get_pse_isv_svn(uint16_t& isv_svn); /*This function should only be called when _pse_mutex is acquired*/
+    static ae_error_t get_pse_isv_svn(uint16_t& isv_svn);    /*This function should only be called when _pse_mutex is acquired*/
     static ae_error_t get_pse_cpu_svn(sgx_cpu_svn_t& cpu_svn);/*This function should only be called when _pse_mutex is acquired*/
+    static ae_error_t get_pce_isv_svn(uint16_t& isv_svn);
+    static uint32_t   get_active_extended_epid_group_id(void);
 
     static ae_error_t service_start();
     static void service_stop();
@@ -138,6 +142,8 @@ public:
         uint64_t* ps_cap);
 
     static uint32_t endpoint_selection(endpoint_selection_infos_t& es_info);
+    enum {GIDMT_UNMATCHED, GIDMT_NOT_AVAILABLE, GIDMT_MATCHED,GIDMT_UNEXPECTED_ERROR};
+    static uint32_t is_gid_matching_result_in_epid_blob(const GroupID& gid);
 
     static aesm_error_t report_attestation_status(
         uint8_t* platform_info, uint32_t platform_info_size,
@@ -147,6 +153,17 @@ public:
     static aesm_error_t white_list_register(
         const uint8_t *white_list_cert, uint32_t white_list_cert_size);
 
+    static aesm_error_t get_white_list_size(
+        uint32_t* white_list_cert_size);
+
+    static aesm_error_t get_white_list(
+        uint8_t *white_list_cert, uint32_t buf_size);
+
+    static aesm_error_t get_extended_epid_group_id(
+        uint32_t* extended_epid_group_id);
+
+    static aesm_error_t switch_extended_epid_group( 
+        uint32_t extended_epid_group_id );
 };
 #endif
 

+ 33 - 3
psw/ae/aesm_service/source/aesm/extension/aesm_ecdsa.cpp

@@ -32,12 +32,26 @@
 #include "sgx_tcrypto.h"
 #include "aeerror.h"
 #include "tlv_common.h"
-#include "cipher.h"
+#include "pek_pub_key.h"
+#include "peksk_pub.hh"
 
-ae_error_t aesm_check_pek_signature(const signed_pek_t& signed_pek)
+ae_error_t aesm_check_pek_signature(const signed_pek_t& signed_pek, const extended_epid_group_blob_t& xegb)
 {
     uint8_t result = SGX_EC_INVALID_SIGNATURE;
-    sgx_status_t sgx_code = check_pek_signature(signed_pek, &result);
+    uint32_t i;
+    sgx_status_t sgx_code;
+    const uint8_t *p = (const uint8_t *)&xegb;
+    for (i = 0; i < sizeof(xegb); i++){
+        if (p[i] != 0){
+            break;
+        }
+    }
+    if (i == sizeof(xegb)){//if all bytes of xegb is 0, using hardcoded PEKSK public key
+        sgx_code = check_pek_signature(signed_pek, (const sgx_ec256_public_t*)&g_pek_pub_key_little_endian, &result);
+    }
+    else{
+        sgx_code = check_pek_signature(signed_pek, (const sgx_ec256_public_t*)xegb.pek_sk, &result);
+    }
     if(sgx_code == SGX_ERROR_OUT_OF_MEMORY)
         return AE_OUT_OF_MEMORY_ERROR;
     else if(sgx_code != SGX_SUCCESS)
@@ -48,3 +62,19 @@ ae_error_t aesm_check_pek_signature(const signed_pek_t& signed_pek)
         return AE_SUCCESS;//PEK Singatue verified successfully
 }
 
+ae_error_t aesm_verify_xegb(const extended_epid_group_blob_t& signed_xegb)
+{
+    uint8_t result = SGX_EC_INVALID_SIGNATURE;
+    sgx_status_t sgx_code = verify_xegb(signed_xegb, &result);
+    if (sgx_code == SGX_ERROR_INVALID_PARAMETER)
+        return AE_INVALID_PARAMETER; 
+    else if(sgx_code == SGX_ERROR_OUT_OF_MEMORY)
+        return AE_OUT_OF_MEMORY_ERROR;
+    else if (sgx_code != SGX_SUCCESS)
+        return AE_FAILURE; //unknown error code
+    else if (result != SGX_EC_VALID)//sgx_code is SGX_SUCCESS
+        return AE_INVALID_PARAMETER; //signature verification failed
+    else
+        return AE_SUCCESS;//XEGB Signature verified successfully
+}
+

+ 8 - 6
psw/ae/aesm_service/source/aesm/extension/aesm_encode.cpp

@@ -40,7 +40,6 @@
 #include <openssl/buffer.h>
 #include <openssl/x509v3.h>
 #include <list>
-
 /**
 * Method converts byte containing value from 0x00-0x0F into its corresponding ASCII code, 
 * e.g. converts 0x00 to '0', 0x0A to 'A'. 
@@ -69,7 +68,7 @@ static uint8_t convert_value_to_ascii(uint8_t in)
 * e.g. converts '0' to 0x00, 'A' to 0x0A. 
 *
 * @param in char containing ASCII code (allowed values: '0-9', 'a-f', 'A-F')
-* @param val output parameter containing converted value, if method suceeds.
+* @param val output parameter containing converted value, if method succeeds.
 *
 * @return true if conversion succeeds, false otherwise
 */
@@ -102,6 +101,7 @@ static bool convert_ascii_to_value(uint8_t in, uint8_t& val)
 //The out_size must always be 2*in_size since each byte into encoded by 2 characters
 static bool byte_array_to_hex_string(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t out_size)
 {
+    if(in_size>UINT32_MAX/2)return false;
     if(in_buf==NULL||out_buf==NULL|| out_size!=in_size*2 )return false;
 
     for(uint32_t i=0; i< in_size; i++)
@@ -120,6 +120,7 @@ static bool byte_array_to_hex_string(const uint8_t *in_buf, uint32_t in_size, ui
 //The in_size must be even number and equals 2*out_size
 static bool hex_string_to_byte_array(const uint8_t *in_buf, uint32_t in_size, uint8_t *out_buf, uint32_t out_size)
 {
+    if(out_size>UINT32_MAX/2)return false;
     if(in_buf==NULL||out_buf==NULL||out_size*2!=in_size)return false;
 
     for(uint32_t i=0;i<out_size;i++)
@@ -207,17 +208,17 @@ ret_point:
   return ret;
 }
 
-//Function to give an upbound of size of data after BASE64 decoding
+//Function to give an upper bound of size of data after BASE64 decoding
 //@param length: the length in bytes of BASE64 encoded data
-//@return an upbound of length in bytes of decoded data
+//@return an upper bound of length in bytes of decoded data
 static uint32_t get_unbase_64_length(uint32_t length)
 {
     return (length * 3 / 4) + ((length * 3 % 4 > 0) ? 1 : 0 );
 }
 
-//Function to give an upbound of size of data after BASR64 encoding
+//Function to give an upper bound of size of data after BASR64 encoding
 //@param length: the length in bytes of data to be encoded
-//@return an upbound of length in bytes of data after encoding
+//@return an upper bound of length in bytes of data after encoding
 static uint32_t get_base_64_length_upbound(uint32_t length)
 {
     uint32_t extra = (length+9)/10+50;//using enough extra memory
@@ -274,3 +275,4 @@ bool decode_response(const uint8_t *input_buf, uint32_t input_len, uint8_t *resp
         return false;
     return true;
 }
+

+ 5 - 6
psw/ae/aesm_service/source/aesm/extension/aesm_encode.h

@@ -37,17 +37,16 @@
 extern "C"{
 #endif
 
-uint32_t certPseSvn();
 
-/*Function to provide an upbound of buffer size of encoded message for an input request
+/*Function to provide an upper bound of buffer size of encoded message for an input request
  *@param req, the header for the input request such as ProvMsg1 or ProvMsg3
- *@return an upbound of the required buffer size for the encoded message
- */
+ *@return an upper bound of the required buffer size for the encoded message
+*/
 uint32_t get_request_encoding_length(const uint8_t *req);
 
-/*Function to provide an upbound of the response body size given the length of encoded response message
+/*Function to provide an upper bound of the response body size given the length of encoded response message
  *@param buf_len, the length of the encoded message for an response message
- *@return an upbound of the length in bytes of decoded response message body such as ProvMsg2 or ProvMsg4
+ *@return an upper bound of the length in bytes of decoded response message body such as ProvMsg2 or ProvMsg4
  */
 uint32_t get_response_decoding_length(uint32_t buf_len);
 

+ 78 - 16
psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.cpp

@@ -45,8 +45,7 @@ ae_error_t EPIDBlob::read(epid_blob_with_cur_psvn_t& blob)
             goto CLEANUP_READ_FILE;
         }
 
-        if( data_size != sizeof(blob_cache) )
-        {
+        if (data_size != sizeof(blob_cache)){
             ae_ret = QE_EPIDBLOB_ERROR;
             goto CLEANUP_READ_FILE;
         }
@@ -107,22 +106,26 @@ ae_error_t EPIDBlob::get_sgx_gid(uint32_t* pgid)
     epid_blob_with_cur_psvn_t epid_blob;
     sgx_sealed_data_t *sealed_epid = reinterpret_cast<sgx_sealed_data_t *>(epid_blob.trusted_epid_blob);
 
-    if (NULL != pgid) {
+    if (NULL == pgid)
+        return AE_INVALID_PARAMETER;
+    //
+    // get the epid blob
+    //
+    aesm_result = this->read(epid_blob);
+    if (AE_SUCCESS == aesm_result) {
         //
-        // get the epid blob
+        // get the gid
         //
-        aesm_result = this->read(epid_blob);
-        if (AE_SUCCESS == aesm_result) {
-            //
-            // get the gid
-            //
-            uint32_t plain_text_offset = sealed_epid->plain_text_offset;
-            se_plaintext_epid_data_t* plain_text = reinterpret_cast<se_plaintext_epid_data_t *>(epid_blob.trusted_epid_blob + sizeof(sgx_sealed_data_t) + plain_text_offset);
-            if(memcpy_s(pgid, sizeof(*pgid), &plain_text->epid_group_cert.gid, sizeof(plain_text->epid_group_cert.gid)))	//read gid from EPID Data blob
-            {
-                AESM_DBG_ERROR("memcpy_s failed");
-                aesm_result = AE_FAILURE;
-            }
+        uint32_t plain_text_offset = sealed_epid->plain_text_offset;
+        se_plaintext_epid_data_pak_t* plain_text = reinterpret_cast<se_plaintext_epid_data_pak_t *>(epid_blob.trusted_epid_blob + sizeof(sgx_sealed_data_t) + plain_text_offset);
+         
+         if(memcpy_s(pgid, sizeof(*pgid), &plain_text->epid_group_cert.gid, sizeof(plain_text->epid_group_cert.gid)))	//read gid from EPID Data blob
+         {
+             AESM_DBG_ERROR("memcpy_s failed");
+             aesm_result = AE_FAILURE;
+         }
+         else
+         {
             //
             // return little-endian
             //
@@ -135,5 +138,64 @@ ae_error_t EPIDBlob::get_sgx_gid(uint32_t* pgid)
     }
 
     return aesm_result;
+}
+
+
+ae_error_t EPIDBlob::get_extended_epid_group_id(uint32_t* pxeid)
+{
+    ae_error_t aesm_result = AE_SUCCESS;
+    epid_blob_with_cur_psvn_t epid_blob;
+    sgx_sealed_data_t *sealed_epid = reinterpret_cast<sgx_sealed_data_t *>(epid_blob.trusted_epid_blob);
+
+    if (NULL == pxeid)
+        return AE_INVALID_PARAMETER;
+    //
+    // get the epid blob
+    //
+    aesm_result = this->read(epid_blob);
+    if (AE_SUCCESS == aesm_result) {
+        //
+        // get the xeid
+        //
+        uint32_t plain_text_offset = sealed_epid->plain_text_offset;
+        se_plaintext_epid_data_pak_t* plain_text_new = reinterpret_cast<se_plaintext_epid_data_pak_t*>(epid_blob.trusted_epid_blob + sizeof(sgx_sealed_data_t)+plain_text_offset);
+        switch (plain_text_new->epid_key_version)
+        {
+        case EPID_KEY_BLOB_VERSION_PAK:
+            
+            if (memcpy_s(pxeid, sizeof(*pxeid), &plain_text_new->xeid, sizeof(plain_text_new->xeid)))	//read extended_epid_group_id from EPID Data blob
+            {
+                AESM_DBG_ERROR("memcpy_s failed");
+                aesm_result = AE_FAILURE;
+            }
+            else
+            {
+                //
+                // return little-endian
+                //
+                AESM_DBG_TRACE(": get gid %d from epid blob", *pxeid);
+                aesm_result = AE_SUCCESS;
+            }
+            break;
+        default:
+            AESM_DBG_ERROR("unexpected epid_key_version");
+            aesm_result = AE_FAILURE;
+            break;
+        }
+    }
+    return aesm_result;
+
+}
+
 
+ae_error_t EPIDBlob::remove(void)
+{
+    ae_error_t ae_ret = AE_FAILURE;
+    status = not_available;
+    if ((ae_ret = aesm_remove_data(FT_PERSISTENT_STORAGE, EPID_DATA_BLOB_FID)) != AE_SUCCESS){
+        status = not_initialized;
+        return ae_ret;
+    }
+    status = not_initialized;
+    return AE_SUCCESS;
 }

+ 5 - 2
psw/ae/aesm_service/source/aesm/extension/aesm_epid_blob.h

@@ -44,10 +44,11 @@
 #include "internal/se_rwlock.h"
 
 typedef struct _epid_blob_with_cur_psvn_t{
-    uint8_t trusted_epid_blob[HARD_CODED_EPID_BLOB_SIZE];
-    psvn_t  cur_psvn;
+    uint8_t trusted_epid_blob[SGX_TRUSTED_EPID_BLOB_SIZE_PAK];
+    bk_platform_info_t   cur_pi;
 }epid_blob_with_cur_psvn_t;
 
+
 #define SGX_EPID_BLOB_SIZE sizeof(epid_blob_with_cur_psvn_t)
 
 class EPIDBlob: public Singleton<EPIDBlob>{
@@ -60,6 +61,8 @@ public:
     ae_error_t read(epid_blob_with_cur_psvn_t& blob);
     ae_error_t write(const epid_blob_with_cur_psvn_t& blob);
     ae_error_t get_sgx_gid(uint32_t* pgid);/*get little endian gid from epid data blob*/
+    ae_error_t get_extended_epid_group_id(uint32_t* pxeid);//get little endian extended_epid_group_id from epid data blob
+    ae_error_t remove(void);
 };
 #endif/*_AESM_EPID_BLOB_H_*/
 

+ 49 - 17
psw/ae/aesm_service/source/aesm/extension/aesm_http_msg.cpp

@@ -59,6 +59,9 @@ static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
     network_malloc_info_t* s=reinterpret_cast<network_malloc_info_t *>(stream);
     uint32_t start=0;
     if(s->base==NULL){
+        if(UINT32_MAX/size<nmemb){
+              return 0;//buffer overflow
+        }
         s->base = reinterpret_cast<char *>(malloc(size*nmemb));
         s->size = static_cast<uint32_t>(size*nmemb);
         if(s->base==NULL){
@@ -67,6 +70,9 @@ static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
         }
     }else{
         uint32_t newsize = s->size+static_cast<uint32_t>(size*nmemb);
+        if((UINT32_MAX-s->size)/size<nmemb){
+             return 0;//buffer overflow
+        }
         char *p=reinterpret_cast<char *>(malloc(newsize));
         if(p == NULL){
             free(s->base);
@@ -105,6 +111,7 @@ static ae_error_t http_network_init(CURL **curl, const char *url, bool is_ocsp)
     }
     if((cc=curl_easy_setopt(*curl, CURLOPT_URL, url_path.c_str()))!=CURLE_OK){
        AESM_DBG_ERROR("fail error code %d in set url %s",(int)cc, url_path.c_str());
+       curl_easy_cleanup(*curl);
        return AE_FAILURE;
     }
     (void)curl_easy_setopt(*curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
@@ -123,44 +130,62 @@ static ae_error_t http_network_send_data(CURL *curl, const char *req_msg, uint32
 {
     AESM_DBG_TRACE("send data method=%d",method);
     struct curl_slist *headers=NULL;
+    struct curl_slist *tmp=NULL;
+    ae_error_t ae_ret = AE_SUCCESS;
     CURLcode cc=CURLE_OK;
+    int num_bytes = 0;
     if(is_ocsp){
-        headers = curl_slist_append(headers, "Accept: application/ocsp-response");
-        if(headers==NULL){
+        tmp = curl_slist_append(headers, "Accept: application/ocsp-response");
+        if(tmp==NULL){
             AESM_DBG_ERROR("fail in add accept ocsp-response header");
-            return AE_FAILURE;
+            ae_ret = AE_FAILURE;
+            goto fini;
         }
-        headers = curl_slist_append(headers, "Content-Type: application/ocsp-request");
-        if(headers == NULL){
+        headers = tmp;
+        tmp = curl_slist_append(headers, "Content-Type: application/ocsp-request");
+        if(tmp == NULL){
            AESM_DBG_ERROR("fail in add content type ocsp-request");
-           return AE_FAILURE;
+           ae_ret = AE_FAILURE;
+           goto fini;
         }
+        headers=tmp;
         AESM_DBG_TRACE("ocsp request");
     }
     char buf[50];
-    sprintf(buf, "Content-Length: %u", (unsigned int)msg_size);
-    headers = curl_slist_append(headers, buf);
-    if(headers == NULL){
+    num_bytes = snprintf(buf,sizeof(buf), "Content-Length: %u", (unsigned int)msg_size);
+    if(num_bytes<0 || num_bytes>=sizeof(buf)){
+         AESM_DBG_ERROR("fail to prepare string Content-Length");
+         ae_ret = AE_FAILURE;
+         goto fini;
+    }
+    tmp = curl_slist_append(headers, buf);
+    if(tmp == NULL){
          AESM_DBG_ERROR("fail to add content-length header");
-         return AE_FAILURE;
+         ae_ret = AE_FAILURE;
+         goto fini;
     }
+    headers=tmp;
     if((cc=curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers))!=CURLE_OK){
         AESM_DBG_ERROR("fail to set http header:%d",(int)cc);
-        return AE_FAILURE;
+        ae_ret = AE_FAILURE;
+        goto fini;
     }
     if(method == POST){
         if((cc=curl_easy_setopt(curl, CURLOPT_POSTFIELDS, req_msg))!=CURLE_OK){
             AESM_DBG_ERROR("fail to set POST fields:%d",(int)cc);
-            return AE_FAILURE;
+            ae_ret = AE_FAILURE;
+            goto fini;
         }
         if((cc=curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msg_size))!=CURLE_OK){
             AESM_DBG_ERROR("fail to set POST fields size:%d",(int)cc);
-            return AE_FAILURE;
+            ae_ret = AE_FAILURE;
+            goto fini;
         }
     }
     if((cc=curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback))!=CURLE_OK){
         AESM_DBG_ERROR("Fail to set callback function:%d",(int)cc);
-        return AE_FAILURE;
+        ae_ret = AE_FAILURE;
+        goto fini;
     }
 
     network_malloc_info_t malloc_info;
@@ -168,19 +193,26 @@ static ae_error_t http_network_send_data(CURL *curl, const char *req_msg, uint32
     malloc_info.size = 0;
     if((cc=curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<void *>(&malloc_info)))!=CURLE_OK){
        AESM_DBG_ERROR("fail to set write back function parameter:%d",(int)cc);
-       return AE_FAILURE;
+       ae_ret = AE_FAILURE;
+       goto fini;
     }
     if((cc=curl_easy_perform(curl))!=CURLE_OK){
         if(malloc_info.base){
             free(malloc_info.base);
         }
         AESM_DBG_ERROR("fail in connect:%d",(int)cc);
-        return OAL_NETWORK_UNAVAILABLE_ERROR;
+        ae_ret = OAL_NETWORK_UNAVAILABLE_ERROR;
+        goto fini;
     }
     *resp_msg = malloc_info.base;
     resp_size = malloc_info.size;
     AESM_DBG_TRACE("get response size=%d",resp_size);
-    return AE_SUCCESS;
+    ae_ret = AE_SUCCESS;
+fini:
+    if(headers!=NULL){
+        curl_slist_free_all(headers);
+    }
+    return ae_ret;
 }
 
 static void http_network_fini(CURL *curl)

+ 69 - 19
psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.cpp

@@ -30,7 +30,6 @@
  */
 
 
-
 #include "aesm_long_lived_thread.h"
 #include "pve_logic.h"
 #include "platform_info_logic.h"
@@ -40,6 +39,7 @@
 #include <time.h>
 #include <assert.h>
 #include <list>
+#include "LEClass.h"
 
 enum _thread_state
 {
@@ -56,6 +56,7 @@ enum _io_cache_state
 };
 
 #define MAX_OUTPUT_CACHE 50
+#define THREAD_INFINITE_TICK_COUNT 0xFFFFFFFFFFFFFFFFLL
 class ThreadStatus;
 class BaseThreadIOCache;
 typedef ae_error_t (*long_lived_thread_func_t)(BaseThreadIOCache *cache);
@@ -176,18 +177,18 @@ public:
     }
     void set_status_finish(BaseThreadIOCache* ioc);//only called at the end of aesm_long_lived_thread_entry
     void deref(BaseThreadIOCache* iocache);
-    ae_error_t wait_iocache(BaseThreadIOCache* ioc);
+    ae_error_t wait_iocache_timeout(BaseThreadIOCache* ioc, uint64_t stop_tick_count);
 
     //create thread and wait at most 'timeout' for the thread to be finished
     // It will first look up whether there is a previous run with same input before starting the thread
     // we should not delete ioc after calling to this function
     ae_error_t set_thread_start(BaseThreadIOCache* ioc,  BaseThreadIOCache *&out_ioc, uint32_t timeout=THREAD_TIMEOUT);
 
-    void stop_thread();//We need wait for thread to be terminated and all thread_handle in list to be closed
+    void stop_thread(uint64_t stop_milli_second);//We need wait for thread to be terminated and all thread_handle in list to be closed
 
-    ~ThreadStatus(){stop_thread();}//ThreadStatus instance should be global object. Otherwise, it is possible that the object is destroyed before a thread waiting for and IOCache got notified and causing exception
+    ~ThreadStatus(){stop_thread(THREAD_INFINITE_TICK_COUNT);}//ThreadStatus instance should be global object. Otherwise, it is possible that the object is destroyed before a thread waiting for and IOCache got notified and causing exception
 
-    ae_error_t wait_for_cur_thread(void);
+    ae_error_t wait_for_cur_thread(uint64_t millisecond);
 
     //function to query whether current thread is idle,
     //if it is idle, return true and reset clock to current clock value
@@ -218,7 +219,7 @@ static ae_error_t aesm_long_lived_thread_entry(aesm_thread_arg_type_t arg)
     return ae_err;
 }
 
-void ThreadStatus::stop_thread()
+void ThreadStatus::stop_thread(uint64_t stop_tick_count)
 {
     //change state to stop
     thread_mutex.lock();
@@ -237,7 +238,7 @@ void ThreadStatus::stop_thread()
            BaseThreadIOCache *p=*it;
            p->ref_count++;
            thread_mutex.unlock();
-           wait_iocache(p);
+           wait_iocache_timeout(p, stop_tick_count);
            thread_mutex.lock();
         }else{
             break;
@@ -249,9 +250,15 @@ void ThreadStatus::stop_thread()
     //Leave memory leak here is OK and all pointer to BaseThreadIOCache will not be released
 }
 
-ae_error_t ThreadStatus::wait_for_cur_thread(void)
+ae_error_t ThreadStatus::wait_for_cur_thread(uint64_t millisecond)
 {
     BaseThreadIOCache *ioc=NULL;
+    uint64_t stop_tick_count;
+    if(millisecond == AESM_THREAD_INFINITE){
+        stop_tick_count = THREAD_INFINITE_TICK_COUNT;
+    }else{
+        stop_tick_count = se_get_tick_count() + (millisecond*se_get_tick_count_freq()+500)/1000;
+    }
     thread_mutex.lock();
     if(cur_iocache!=NULL){
         ioc = cur_iocache;
@@ -259,25 +266,34 @@ ae_error_t ThreadStatus::wait_for_cur_thread(void)
     }
     thread_mutex.unlock();
     if(ioc!=NULL){
-        return wait_iocache(ioc);
+        return wait_iocache_timeout(ioc, stop_tick_count);
     }
     return AE_SUCCESS;
 }
 
-ae_error_t ThreadStatus::wait_iocache(BaseThreadIOCache* ioc)
+ae_error_t ThreadStatus::wait_iocache_timeout(BaseThreadIOCache* ioc, uint64_t stop_tick_count)
 {
     ae_error_t ae_ret=AE_SUCCESS;
+    uint64_t cur_tick_count = se_get_tick_count();
+    uint64_t freq = se_get_tick_count_freq();
     bool need_wait=false;
     aesm_thread_t handle=NULL;
     thread_mutex.lock();
-    if(ioc->thread_handle!=NULL){
+    if(ioc->thread_handle!=NULL&&(cur_tick_count<stop_tick_count||stop_tick_count==THREAD_INFINITE_TICK_COUNT)){
         AESM_DBG_TRACE("wait for busy ioc %p(refcount=%d)",ioc,ioc->ref_count);
         need_wait = true;
         handle = ioc->thread_handle;
     }
     thread_mutex.unlock();
     if(need_wait){
-        ae_ret= aesm_wait_thread(handle, &ae_ret, AESM_THREAD_INFINITE);
+        unsigned long diff_time;
+        if(stop_tick_count == THREAD_INFINITE_TICK_COUNT){
+            diff_time = AESM_THREAD_INFINITE;
+        }else{
+            double wtime=(double)(stop_tick_count-cur_tick_count)*1000.0/(double)freq;
+            diff_time = (unsigned long)(wtime+0.5);
+        }
+        ae_ret= aesm_wait_thread(handle, &ae_ret, diff_time);
     }
     deref(ioc);
     return ae_ret;
@@ -384,10 +400,10 @@ static time_t get_timeout_via_ae_error(ae_error_t ae)
     case PVE_REVOKED_ERROR:
     case PVE_MSG_ERROR:
     case PVE_PERFORMANCE_REKEY_NOT_SUPPORTED:
-    case PSW_UPDATED_REQUIRED:
+    case PSW_UPDATE_REQUIRED:
         return cur+TIMEOUT_LONG_TIME;
     default:
-        return cur+TIMEOUT_FOR_A_WHILE;//not retry too quickly for unknown error
+        return cur+TIMEOUT_SHORT_TIME;//retry quicky for unknown error
     }
 }
 
@@ -432,6 +448,9 @@ bool ThreadStatus::query_status_and_reset_clock(void)
 static ThreadStatus epid_thread;
 
 
+static ThreadStatus white_list_thread;
+
+
 class EpidProvIOCache:public BaseThreadIOCache{
     bool performance_rekey;//input
 protected:
@@ -449,17 +468,40 @@ public:
     }
 };
 
+class WhiteListIOCache :public BaseThreadIOCache{
+//no input to be cached for white list pulling
+protected:
+    WhiteListIOCache(void){
+    }
+    virtual ae_error_t entry(void);
+    virtual ThreadStatus& get_thread();
+    friend ae_error_t start_white_list_thread(unsigned long timeout);
+public:
+    virtual bool operator==(const BaseThreadIOCache& oc)const{
+        const WhiteListIOCache *p = dynamic_cast<const WhiteListIOCache*>(&oc);
+        if (p == NULL) return false;
+        return true;
+    }
+};
 
 ThreadStatus& EpidProvIOCache::get_thread()
 {
     return epid_thread;
 }
 
+ThreadStatus& WhiteListIOCache::get_thread()
+{
+    return white_list_thread;
+}
 
 ae_error_t EpidProvIOCache::entry()
 {
     return ae_ret = PvEAESMLogic::epid_provision_thread_func(performance_rekey); 
 }
+ae_error_t WhiteListIOCache::entry()
+{
+    return ae_ret = CLEClass::update_white_list_by_url();
+}
 
 
 //start implementation of external functions
@@ -494,17 +536,25 @@ ae_error_t start_epid_provision_thread(bool performance_rekey, unsigned long tim
     FINI_THREAD()
 }
 
+ae_error_t start_white_list_thread(unsigned long timeout)
+{
+    INIT_THREAD(WhiteListIOCache, timeout, ())
+    FINI_THREAD()
+}
 bool query_pve_thread_status(void)
 {
     return epid_thread.query_status_and_reset_clock();
 }
-
-ae_error_t wait_pve_thread(void)
+ae_error_t wait_pve_thread(uint64_t time_out_milliseconds)
 {
-    return epid_thread.wait_for_cur_thread();
+    return epid_thread.wait_for_cur_thread(time_out_milliseconds);
 }
 
-void stop_all_long_lived_threads(void)
+void stop_all_long_lived_threads(uint64_t time_out_milliseconds)
 {
-    epid_thread.stop_thread();
+    uint64_t freq = se_get_tick_count_freq();
+    uint64_t stop_tick_count = se_get_tick_count()+(time_out_milliseconds*freq+500)/1000;
+    epid_thread.stop_thread(stop_tick_count);
+    white_list_thread.stop_thread(stop_tick_count);
 }
+

+ 4 - 2
psw/ae/aesm_service/source/aesm/extension/aesm_long_lived_thread.h

@@ -33,9 +33,11 @@
 #define _AESM_LONG_LIVED_THREAD_H_
 #include "aesm_logic.h"
 
+#define AESM_STOP_TIMEOUT (60*1000) /*waiting for 1 minute at most*/
 extern ae_error_t start_epid_provision_thread(bool performance_rekey, unsigned long timeout=THREAD_TIMEOUT);
+extern ae_error_t start_white_list_thread(unsigned long timeout=THREAD_TIMEOUT);
 extern bool query_pve_thread_status(void);/*return true if idle and reset clock for thread*/
-extern ae_error_t wait_pve_thread(void);
-extern void stop_all_long_lived_threads(void);
+extern ae_error_t wait_pve_thread(uint64_t time_out_milliseconds=AESM_THREAD_INFINITE);
+extern void stop_all_long_lived_threads(uint64_t time_out_milliseconds=AESM_STOP_TIMEOUT);
 #endif
 

+ 109 - 0
psw/ae/aesm_service/source/aesm/extension/aesm_xegd_blob.cpp

@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2011-2016 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *   * Neither the name of Intel Corporation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#include <stdio.h>
+#include "aesm_xegd_blob.h"
+#include "endpoint_select_info.h"
+#include "internal/se_memcpy.h"
+#include "oal/oal.h"
+#include "byte_order.h"
+#include "aesm_epid_blob.h"
+
+ae_error_t XEGDBlob::verify_xegd_by_xgid(uint32_t xgid)
+{
+    extended_epid_group_blob_t blob;
+    if (xgid == DEFAULT_EGID){//always return success for default xgid
+        return AE_SUCCESS;
+    }
+    uint32_t data_size = sizeof(blob);
+    ae_error_t ae_ret = aesm_read_data(FT_PERSISTENT_STORAGE, EXTENDED_EPID_GROUP_BLOB_INFO_FID, reinterpret_cast<uint8_t *>(&blob), &data_size, xgid);
+    if (AE_SUCCESS != ae_ret){
+        return ae_ret;
+    }
+    if (data_size != sizeof(blob)){
+        return OAL_CONFIG_FILE_ERROR;
+    }
+    ae_ret = verify(blob);
+    return ae_ret;
+}
+
+ae_error_t XEGDBlob::read(extended_epid_group_blob_t& blob)
+{
+    ae_error_t ae_ret = AE_FAILURE;
+    if(status == not_initialized){
+        uint32_t data_size = sizeof(blob_cache);
+        if ((ae_ret = aesm_read_data(FT_PERSISTENT_STORAGE, EXTENDED_EPID_GROUP_BLOB_INFO_FID, reinterpret_cast<uint8_t *>(&blob_cache), &data_size, AESMLogic::get_active_extended_epid_group_id())) != AE_SUCCESS){
+            goto CLEANUP_READ_FILE;
+        }
+        if (data_size != sizeof(blob_cache)){
+            ae_ret = OAL_CONFIG_FILE_ERROR;
+            goto CLEANUP_READ_FILE;
+        }
+        ae_ret = verify(blob_cache);
+        if (AE_SUCCESS != ae_ret){
+            AESM_DBG_ERROR("signature error in XEGD file");
+            goto CLEANUP_READ_FILE;
+        }
+        status = update_to_date;
+CLEANUP_READ_FILE:
+        if (status != update_to_date){
+            if (AESMLogic::get_active_extended_epid_group_id() == DEFAULT_EGID){
+                memset(&blob_cache, 0, sizeof(blob_cache));//indicate other part to use default data
+                status = update_to_date;
+            }
+            else{
+                status = not_available;//xegd blob lost
+            }
+        }
+    }
+    if(status == update_to_date){
+        if(memcpy_s(&blob, sizeof(blob), &blob_cache, sizeof(blob_cache))!=0){
+            status = not_available; //invalid
+            ae_ret = AE_FAILURE;
+        }else{
+            ae_ret = AE_SUCCESS;
+        }
+    }
+    return ae_ret;
+}
+
+ae_error_t aesm_verify_xegb(const extended_epid_group_blob_t& signed_xegb);
+
+ae_error_t XEGDBlob::verify(const extended_epid_group_blob_t& signed_xegb)
+{
+    ae_error_t aesm_result = aesm_verify_xegb(signed_xegb);
+    if (AE_SUCCESS != aesm_result)
+    {
+        AESM_DBG_ERROR("Extended EPID Group Blob Signature verifcation not passed:%d", aesm_result);
+        return aesm_result;
+    }
+    return aesm_result;
+}
+

Some files were not shown because too many files changed in this diff