diff --git a/sgx-jvm/jvm-enclave/common/rpc/start_thread.edl b/sgx-jvm/jvm-enclave/common/rpc/start_thread.edl
index 4a043b372b..6bab6a0aeb 100644
--- a/sgx-jvm/jvm-enclave/common/rpc/start_thread.edl
+++ b/sgx-jvm/jvm-enclave/common/rpc/start_thread.edl
@@ -4,6 +4,6 @@ enclave {
public void create_new_thread(unsigned int nonce);
};
untrusted {
- void request_new_thread([enclave_id] uint64_t enclave_id, uint32_t nonce);
+ void request_new_thread(uint64_t enclave_id, uint32_t nonce);
};
};
diff --git a/sgx-jvm/jvm-enclave/enclave/enclave_start_thread.cpp b/sgx-jvm/jvm-enclave/enclave/enclave_start_thread.cpp
index 419b741422..06a3e3fbdf 100644
--- a/sgx-jvm/jvm-enclave/enclave/enclave_start_thread.cpp
+++ b/sgx-jvm/jvm-enclave/enclave/enclave_start_thread.cpp
@@ -35,7 +35,11 @@ thread_data_t *start_thread(void (*routine)(void *), void *param) {
aex_assert(new_thread_map.find(nonce) == new_thread_map.end());
new_thread_map[nonce] = thread_init_data;
}
- request_new_thread(nonce);
+
+ // TODO use MRENCLAVE instead of enclave_id (this is currently not used)
+ uint64_t enclave_id = 0L;
+
+ request_new_thread(enclave_id, nonce);
sgx_thread_cond_wait(&thread_started, &thread_started_mutex);
sgx_thread_mutex_guard started_thread_data_map_guard(&started_thread_data_map_mutex);
auto thread_data_iter = started_thread_data_map.find(nonce);
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml
index a01006f811..968a22e109 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/buildUpdateSite.xml
@@ -1,13 +1,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/customTargets.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/customTargets.xml
index 0a7316b142..24d4c339b4 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/customTargets.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_config/customTargets.xml
@@ -192,17 +192,17 @@
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath
index 791c66decf..bd72e048b2 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.classpath
@@ -1,18 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project
index 76c2e17b70..85b69bd9ed 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/.project
@@ -1,39 +1,39 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- com.intel.sgx.userguide
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.intel.sgx.userguide
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF
index 6e725a3f1c..0345f814b9 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/META-INF/MANIFEST.MF
@@ -6,6 +6,6 @@ Bundle-SymbolicName: com.intel.sgx.userguide;singleton:=true
Bundle-Version: 1.0.1.qualifier
Bundle-Activator: com.intel.sgx.userguide.Activator
Bundle-Vendor: INTEL
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties
index b148cda4b4..95f7743419 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/build.properties
@@ -1,19 +1,19 @@
-#########################################################################
-# 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 #
-#########################################################################
-
-source.. = src/
-output.. = bin/
-bin.includes = plugin.xml,\
- META-INF/,\
- .,\
- html/,\
- *.xml
+#########################################################################
+# 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 #
+#########################################################################
+
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ html/,\
+ *.xml
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css
index 859063f2e1..b7f1f186ef 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/html/Resources/Stylesheets/intel_css_styles.css
@@ -1,470 +1,470 @@
-/*************************************************************************/
-/* 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 */
-/*************************************************************************/
-/**/
-
-/*begin-old-version{{*/
-
-body
-{
- color: #333333;
- background-color: #ffffff;
- font-family: "Intel Clear", Verdana, Arial, sans-serif;
- margin-left: 30px;
- margin-right: 30px;
- margin-bottom: 7%;
- color: #333333;
- background-color: #ffffff;
- font-family: "Intel Clear", Verdana, Arial, sans-serif;
- margin-left: 30px;
- margin-right: 30px;
- margin-bottom: 7%;
- font-size: 12pt;
-}
-
-.RevUpdate
-{
- background-color: #FFFF99;
- font-weight: normal;
- line-height: 100%;
- background-color: #FFFF99;
- font-weight: normal;
- line-height: 100%;
-}
-
-.NonStdFortran
-{
- color: #007F00;
- color: #007F00;
-}
-
-body.OH_VSIP_body
-{
- margin-left: 30px;
- margin-left: 30px;
-}
-
-DIV.OH_outerContent
-{
- border: 0px none #FFFFFF;
- border: 0px none #ffffff;
-}
-
-h1
-{
- color: #0071c5;
- font-size: 15pt;
- font-weight: normal;
- padding-bottom: 1px;
- margin-left: 0pt;
- margin-bottom: 0px;
- color: #0071c5;
- font-size: 15pt;
- font-weight: normal;
- padding-bottom: 1px;
- margin-left: 0pt;
- margin-bottom: 0px;
-}
-
-h1.firsttitle
-{
- font-weight: normal;
- border-bottom: 0 none;
- margin-left: 0;
- font-size: 18pt;
- border-bottom: 1px solid #0071c5;
- line-height: 100%;
- padding-bottom: 10px;
- margin-bottom: 20px;
- margin-top: 20px;
- font-weight: normal;
- border-bottom: 0 none;
- margin-left: 0;
- font-size: 18pt;
- border-bottom: 1px solid #0071c5;
- line-height: 100%;
- padding-bottom: 10px;
- margin-bottom: 20px;
- margin-top: 20px;
-}
-
-h2
-{
- color: #0071c5;
- margin-top: 15pt;
- margin-bottom: 5pt;
- font-size: 12pt;
- color: #0071c5;
- margin-top: 15pt;
- margin-bottom: 5pt;
- font-size: 12pt;
-}
-
-h3
-{
- color: #333333;
- font-weight: bold;
- margin-top: 15pt;
- margin-bottom: 5pt;
- font-size: 11pt;
- color: #333333;
- font-weight: bold;
- margin-top: 15pt;
- margin-bottom: 5pt;
- font-size: 11pt;
-}
-
-h4
-{
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
-}
-
-h5
-{
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
-}
-
-h6
-{
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
- color: #0071c5;
- margin-top: 10pt;
- margin-bottom: 5pt;
- padding-left: 0px;
- font-size: 10pt;
-}
-
-.relinfo
-{
- padding-left: 30px;
- padding-left: 30px;
-}
-
-.tablecap
-{
- color: #0071c5;
-}
-
-caption
-{
- font-weight: bold;
- text-align: left;
- font-weight: bold;
- text-align: left;
- font-size: 12pt;
-}
-
-.figcap
-{
- margin-left: 24px;
- font-size: 10pt;
- font-weight: bold;
- text-align: center;
- margin-left: 24px;
- font-size: 10pt;
- font-weight: bold;
- text-align: center;
-}
-
-.sectiontitle
-{
- padding-left: 0px;
- padding-left: 0px;
-}
-
-.linklist
-{
- padding-left: 0px;
- padding-left: 0px;
-}
-
-h1.topictitle1
-{
- color: #0071c5;
- font-size: 18pt;
- margin-left: 0pt;
- margin-bottom: 15px;
- color: #0071c5;
- font-size: 18pt;
- margin-left: 0pt;
- margin-bottom: 15px;
-}
-
-#header_text
-{
- color: #0071C5;
- text-align: right;
- color: #0071C5;
- text-align: right;
-}
-
-.titlepage
-{
- margin-right: 15%;
- margin-right: 15%;
-}
-
-.familylinks
-{
- margin-top: 1em;
- margin-top: 1em;
-}
-
-a.start
-{
- font-size: 18pt;
- text-decoration: underline;
- font-size: 18pt;
- text-decoration: underline;
-}
-
-a.underlined
-{
- text-decoration: underline;
- text-decoration: underline;
-}
-
-.shortdesc
-{
- font-size: inherit;
- padding-left: inherit;
- line-height: 16pt;
- margin-top: 0px;
- margin-bottom: 0.5em;
- font-size: inherit;
- padding-left: inherit;
- line-height: 16pt;
- margin-top: 0px;
- margin-bottom: 0.5em;
-}
-
-.shortdesc-it
-{
- font-style: italic;
- font-style: italic;
-}
-
-p
-{
- margin-left: 0px;
- line-height: 120%;
- margin-top: 0;
- margin-bottom: 10px;
- margin-left: 0px;
- line-height: 120%;
- margin-top: 0;
- margin-bottom: 10px;
- font-size: 12pt;
-}
-
-.p
-{
- font-size: inherit;
- margin-left: 0px;
- line-height: 170%;
- margin-top: 0;
- margin-bottom: 5pt;
- padding-left: 0pt;
- font-size: inherit;
- margin-left: 0px;
- line-height: 170%;
- margin-top: 0;
- margin-bottom: 5pt;
- padding-left: 0pt;
-}
-
-table
-{
- margin-bottom: 5pt;
- border-collapse: collapse;
- margin-left: 0px;
- margin-top: 0.3em;
- font-size: 10pt;
- margin-bottom: 5pt;
- border-collapse: collapse;
- margin-left: 0px;
- margin-top: 0.3em;
- font-size: 10pt;
-}
-
-tr
-{
- vertical-align: top;
- vertical-align: top;
-}
-
-DIV.Note
-{
- margin-top: 20pt;
- margin-bottom: 20pt;
- margin-right: 0.46cm;
- padding-left: 5px;
- border-top-style: solid;
- border-top-width: 1px;
- border-bottom-style: solid;
- border-bottom-width: 1px;
- font-size: 10pt;
-}
-
-p.NoteTipHead
-{
- font-weight: bold;
- font-style: italic;
- margin-top: 9pt;
- margin-bottom: 3pt;
- line-height: 15pt;
- margin-left: 0.202cm;
- font-family: "Verdana", "sans-serif";
- text-transform: uppercase;
- text-align: justify;
- font-size: 12pt;
-}
-
-MadCap|xref
-{
- color: #0860a8;
- mc-format: '{paratext}';
- text-decoration: none;
- font-size: 12pt;
-}
-
-div.NoteCont
-{
- border-bottom-style: solid;
- 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
-{
- color: #0071c5;
- text-decoration: none;
- color: #0071c5;
- text-decoration: none;
-}
-
-a:visited
-{
- color: #0071c5;
- text-decoration: none;
- color: #0071c5;
- text-decoration: none;
-}
-
-a:hover
-{
- color: #00aeef;
- text-decoration: underline;
- color: #00aeef;
- text-decoration: underline;
-}
-
-a:active
-{
- color: #0071c5;
- text-decoration: underline;
- color: #0071c5;
- text-decoration: underline;
-}
-
-a.start:visited
-{
- color: #0071c5;
- text-decoration: underline;
- color: #0071c5;
- text-decoration: underline;
-}
-
-a.start:active
-{
- color: #0071c5;
- text-decoration: underline;
- color: #0071c5;
- text-decoration: underline;
-}
-
-a.underlined:visited
-{
- color: #0071c5;
- text-decoration: underline;
- color: #0071c5;
- text-decoration: underline;
-}
-
-a.underlined:active
-{
- color: #0071c5;
- text-decoration: underline;
- color: #0071c5;
- text-decoration: underline;
-}
-
+/*************************************************************************/
+/* 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 */
+/*************************************************************************/
+/**/
+
+/*begin-old-version{{*/
+
+body
+{
+ color: #333333;
+ background-color: #ffffff;
+ font-family: "Intel Clear", Verdana, Arial, sans-serif;
+ margin-left: 30px;
+ margin-right: 30px;
+ margin-bottom: 7%;
+ color: #333333;
+ background-color: #ffffff;
+ font-family: "Intel Clear", Verdana, Arial, sans-serif;
+ margin-left: 30px;
+ margin-right: 30px;
+ margin-bottom: 7%;
+ font-size: 12pt;
+}
+
+.RevUpdate
+{
+ background-color: #FFFF99;
+ font-weight: normal;
+ line-height: 100%;
+ background-color: #FFFF99;
+ font-weight: normal;
+ line-height: 100%;
+}
+
+.NonStdFortran
+{
+ color: #007F00;
+ color: #007F00;
+}
+
+body.OH_VSIP_body
+{
+ margin-left: 30px;
+ margin-left: 30px;
+}
+
+DIV.OH_outerContent
+{
+ border: 0px none #FFFFFF;
+ border: 0px none #ffffff;
+}
+
+h1
+{
+ color: #0071c5;
+ font-size: 15pt;
+ font-weight: normal;
+ padding-bottom: 1px;
+ margin-left: 0pt;
+ margin-bottom: 0px;
+ color: #0071c5;
+ font-size: 15pt;
+ font-weight: normal;
+ padding-bottom: 1px;
+ margin-left: 0pt;
+ margin-bottom: 0px;
+}
+
+h1.firsttitle
+{
+ font-weight: normal;
+ border-bottom: 0 none;
+ margin-left: 0;
+ font-size: 18pt;
+ border-bottom: 1px solid #0071c5;
+ line-height: 100%;
+ padding-bottom: 10px;
+ margin-bottom: 20px;
+ margin-top: 20px;
+ font-weight: normal;
+ border-bottom: 0 none;
+ margin-left: 0;
+ font-size: 18pt;
+ border-bottom: 1px solid #0071c5;
+ line-height: 100%;
+ padding-bottom: 10px;
+ margin-bottom: 20px;
+ margin-top: 20px;
+}
+
+h2
+{
+ color: #0071c5;
+ margin-top: 15pt;
+ margin-bottom: 5pt;
+ font-size: 12pt;
+ color: #0071c5;
+ margin-top: 15pt;
+ margin-bottom: 5pt;
+ font-size: 12pt;
+}
+
+h3
+{
+ color: #333333;
+ font-weight: bold;
+ margin-top: 15pt;
+ margin-bottom: 5pt;
+ font-size: 11pt;
+ color: #333333;
+ font-weight: bold;
+ margin-top: 15pt;
+ margin-bottom: 5pt;
+ font-size: 11pt;
+}
+
+h4
+{
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+}
+
+h5
+{
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+}
+
+h6
+{
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+ color: #0071c5;
+ margin-top: 10pt;
+ margin-bottom: 5pt;
+ padding-left: 0px;
+ font-size: 10pt;
+}
+
+.relinfo
+{
+ padding-left: 30px;
+ padding-left: 30px;
+}
+
+.tablecap
+{
+ color: #0071c5;
+}
+
+caption
+{
+ font-weight: bold;
+ text-align: left;
+ font-weight: bold;
+ text-align: left;
+ font-size: 12pt;
+}
+
+.figcap
+{
+ margin-left: 24px;
+ font-size: 10pt;
+ font-weight: bold;
+ text-align: center;
+ margin-left: 24px;
+ font-size: 10pt;
+ font-weight: bold;
+ text-align: center;
+}
+
+.sectiontitle
+{
+ padding-left: 0px;
+ padding-left: 0px;
+}
+
+.linklist
+{
+ padding-left: 0px;
+ padding-left: 0px;
+}
+
+h1.topictitle1
+{
+ color: #0071c5;
+ font-size: 18pt;
+ margin-left: 0pt;
+ margin-bottom: 15px;
+ color: #0071c5;
+ font-size: 18pt;
+ margin-left: 0pt;
+ margin-bottom: 15px;
+}
+
+#header_text
+{
+ color: #0071C5;
+ text-align: right;
+ color: #0071C5;
+ text-align: right;
+}
+
+.titlepage
+{
+ margin-right: 15%;
+ margin-right: 15%;
+}
+
+.familylinks
+{
+ margin-top: 1em;
+ margin-top: 1em;
+}
+
+a.start
+{
+ font-size: 18pt;
+ text-decoration: underline;
+ font-size: 18pt;
+ text-decoration: underline;
+}
+
+a.underlined
+{
+ text-decoration: underline;
+ text-decoration: underline;
+}
+
+.shortdesc
+{
+ font-size: inherit;
+ padding-left: inherit;
+ line-height: 16pt;
+ margin-top: 0px;
+ margin-bottom: 0.5em;
+ font-size: inherit;
+ padding-left: inherit;
+ line-height: 16pt;
+ margin-top: 0px;
+ margin-bottom: 0.5em;
+}
+
+.shortdesc-it
+{
+ font-style: italic;
+ font-style: italic;
+}
+
+p
+{
+ margin-left: 0px;
+ line-height: 120%;
+ margin-top: 0;
+ margin-bottom: 10px;
+ margin-left: 0px;
+ line-height: 120%;
+ margin-top: 0;
+ margin-bottom: 10px;
+ font-size: 12pt;
+}
+
+.p
+{
+ font-size: inherit;
+ margin-left: 0px;
+ line-height: 170%;
+ margin-top: 0;
+ margin-bottom: 5pt;
+ padding-left: 0pt;
+ font-size: inherit;
+ margin-left: 0px;
+ line-height: 170%;
+ margin-top: 0;
+ margin-bottom: 5pt;
+ padding-left: 0pt;
+}
+
+table
+{
+ margin-bottom: 5pt;
+ border-collapse: collapse;
+ margin-left: 0px;
+ margin-top: 0.3em;
+ font-size: 10pt;
+ margin-bottom: 5pt;
+ border-collapse: collapse;
+ margin-left: 0px;
+ margin-top: 0.3em;
+ font-size: 10pt;
+}
+
+tr
+{
+ vertical-align: top;
+ vertical-align: top;
+}
+
+DIV.Note
+{
+ margin-top: 20pt;
+ margin-bottom: 20pt;
+ margin-right: 0.46cm;
+ padding-left: 5px;
+ border-top-style: solid;
+ border-top-width: 1px;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ font-size: 10pt;
+}
+
+p.NoteTipHead
+{
+ font-weight: bold;
+ font-style: italic;
+ margin-top: 9pt;
+ margin-bottom: 3pt;
+ line-height: 15pt;
+ margin-left: 0.202cm;
+ font-family: "Verdana", "sans-serif";
+ text-transform: uppercase;
+ text-align: justify;
+ font-size: 12pt;
+}
+
+MadCap|xref
+{
+ color: #0860a8;
+ mc-format: '{paratext}';
+ text-decoration: none;
+ font-size: 12pt;
+}
+
+div.NoteCont
+{
+ border-bottom-style: solid;
+ 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
+{
+ color: #0071c5;
+ text-decoration: none;
+ color: #0071c5;
+ text-decoration: none;
+}
+
+a:visited
+{
+ color: #0071c5;
+ text-decoration: none;
+ color: #0071c5;
+ text-decoration: none;
+}
+
+a:hover
+{
+ color: #00aeef;
+ text-decoration: underline;
+ color: #00aeef;
+ text-decoration: underline;
+}
+
+a:active
+{
+ color: #0071c5;
+ text-decoration: underline;
+ color: #0071c5;
+ text-decoration: underline;
+}
+
+a.start:visited
+{
+ color: #0071c5;
+ text-decoration: underline;
+ color: #0071c5;
+ text-decoration: underline;
+}
+
+a.start:active
+{
+ color: #0071c5;
+ text-decoration: underline;
+ color: #0071c5;
+ text-decoration: underline;
+}
+
+a.underlined:visited
+{
+ color: #0071c5;
+ text-decoration: underline;
+ color: #0071c5;
+ text-decoration: underline;
+}
+
+a.underlined:active
+{
+ color: #0071c5;
+ text-decoration: underline;
+ color: #0071c5;
+ text-decoration: underline;
+}
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml
index 533d28bf13..91e36be341 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/plugin.xml
@@ -1,24 +1,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java
index f10dec9896..607af38562 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx.userguide/src/com/intel/sgx/userguide/Activator.java
@@ -1,73 +1,73 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-package com.intel.sgx.userguide;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "com.intel.sgx.userguide"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+package com.intel.sgx.userguide;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.intel.sgx.userguide"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties
index d055ac2fdc..c9a5f18598 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/build.properties
@@ -1,24 +1,24 @@
-#########################################################################
-# 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 #
-#########################################################################
-
-
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- templates/,\
- discovery/,\
- build.properties,\
- OSGI-INF/,\
- OSGI-INF/l10n/bundle.properties
-jre.compilation.profile = JavaSE-1.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 #
+#########################################################################
+
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ templates/,\
+ discovery/,\
+ build.properties,\
+ OSGI-INF/,\
+ OSGI-INF/l10n/bundle.properties
+jre.compilation.profile = JavaSE-1.8
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java
index 580330b423..2849bd0834 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/Activator.java
@@ -1,75 +1,75 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-package com.intel.sgx;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID = "com.intel.sgx";//$NON-NLS-1$
-
- private static Activator plugin;
-
- public Activator() {
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- public static Activator getDefault() {
- return plugin;
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- public static void log(Exception e) {
- plugin.getLog().log(newStatus(e));
- }
-
- public static IStatus newStatus(Exception e) {
- return new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e);
- }
-
- public static URL findFile(Path path) {
- return FileLocator.find(plugin.getBundle(), path, null);
- }
-
- public static Bundle getBundle(String id){
- for(Bundle bundle : plugin.getBundle().getBundleContext().getBundles()){
- if(bundle.getSymbolicName().equals(id))
- return bundle;
- }
- return null;
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+package com.intel.sgx;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "com.intel.sgx";//$NON-NLS-1$
+
+ private static Activator plugin;
+
+ public Activator() {
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ public static void log(Exception e) {
+ plugin.getLog().log(newStatus(e));
+ }
+
+ public static IStatus newStatus(Exception e) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e);
+ }
+
+ public static URL findFile(Path path) {
+ return FileLocator.find(plugin.getBundle(), path, null);
+ }
+
+ public static Bundle getBundle(String id){
+ for(Bundle bundle : plugin.getBundle().getBundleContext().getBundles()){
+ if(bundle.getSymbolicName().equals(id))
+ return bundle;
+ }
+ return null;
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java
index 59cdc66e33..94ec54bc28 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/CConfigurationDataProvider2.java
@@ -1,46 +1,46 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx;
-
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public class CConfigurationDataProvider2 extends CConfigurationDataProvider {
-
- public CConfigurationDataProvider2() {
- }
-
- @Override
- public CConfigurationData loadConfiguration(ICConfigurationDescription des,
- IProgressMonitor monitor) throws CoreException {
- return null;
- }
-
- @Override
- public CConfigurationData createConfiguration(
- ICConfigurationDescription des,
- ICConfigurationDescription baseDescription,
- CConfigurationData baseData, boolean clone, IProgressMonitor monitor)
- throws CoreException {
- return null;
- }
-
- @Override
- public void removeConfiguration(ICConfigurationDescription des,
- CConfigurationData data, IProgressMonitor monitor) {
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class CConfigurationDataProvider2 extends CConfigurationDataProvider {
+
+ public CConfigurationDataProvider2() {
+ }
+
+ @Override
+ public CConfigurationData loadConfiguration(ICConfigurationDescription des,
+ IProgressMonitor monitor) throws CoreException {
+ return null;
+ }
+
+ @Override
+ public CConfigurationData createConfiguration(
+ ICConfigurationDescription des,
+ ICConfigurationDescription baseDescription,
+ CConfigurationData baseData, boolean clone, IProgressMonitor monitor)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public void removeConfiguration(ICConfigurationDescription des,
+ CConfigurationData data, IProgressMonitor monitor) {
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java
index 43f13da5f9..b205b73c64 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/SdkPathVariableProvider.java
@@ -1,70 +1,70 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx;
-import java.io.File;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.variableresolvers.PathVariableResolver;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import com.intel.sgx.preferences.PreferenceConstants;
-import com.intel.sgx.preferences.SGXPreferencePage;
-
-public class SdkPathVariableProvider extends PathVariableResolver {
-
- public SdkPathVariableProvider() {
- super();
- }
-
- @Override
- public String[] getVariableNames(String variable, IResource resource) {
- String variableNames[] = {"SGX_SDK_DIR_PATH"};
- return (variableNames);
- }
-
- @Override
- public String getValue(String variable, IResource resource) {
- if(variable.equals("SGX_SDK_DIR_PATH")) {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String SDKPath = store.getString(PreferenceConstants.SDK_PATH);
- IPath SDKCanonicalPath= new Path(SDKPath);
- return(SDKCanonicalPath.append("Include").toOSString());
- }
- return null;
- }
-
- public static String getSGXSdkLocation() {
- return Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH);
- }
-
- public static boolean isSGXSdkLocationValid() {
- String location = getSGXSdkLocation();
- if (location.length() == 0)
- return false;
-
- return isValidSGXSdkLocation(location);
- }
-
- public static boolean isValidSGXSdkLocation(String location) {
- File dir = new File(location);
- if (!dir.isDirectory())
- return false;
-
- return new PreferenceConstants.SGXSDK64Descriptor(dir).getSignerPath().canExecute()
- || new PreferenceConstants.SGXSDK32Descriptor(dir).getSignerPath().canExecute();
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx;
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.variableresolvers.PathVariableResolver;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import com.intel.sgx.preferences.PreferenceConstants;
+import com.intel.sgx.preferences.SGXPreferencePage;
+
+public class SdkPathVariableProvider extends PathVariableResolver {
+
+ public SdkPathVariableProvider() {
+ super();
+ }
+
+ @Override
+ public String[] getVariableNames(String variable, IResource resource) {
+ String variableNames[] = {"SGX_SDK_DIR_PATH"};
+ return (variableNames);
+ }
+
+ @Override
+ public String getValue(String variable, IResource resource) {
+ if(variable.equals("SGX_SDK_DIR_PATH")) {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String SDKPath = store.getString(PreferenceConstants.SDK_PATH);
+ IPath SDKCanonicalPath= new Path(SDKPath);
+ return(SDKCanonicalPath.append("Include").toOSString());
+ }
+ return null;
+ }
+
+ public static String getSGXSdkLocation() {
+ return Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH);
+ }
+
+ public static boolean isSGXSdkLocationValid() {
+ String location = getSGXSdkLocation();
+ if (location.length() == 0)
+ return false;
+
+ return isValidSGXSdkLocation(location);
+ }
+
+ public static boolean isValidSGXSdkLocation(String location) {
+ File dir = new File(location);
+ if (!dir.isDirectory())
+ return false;
+
+ return new PreferenceConstants.SGXSDK64Descriptor(dir).getSignerPath().canExecute()
+ || new PreferenceConstants.SGXSDK32Descriptor(dir).getSignerPath().canExecute();
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java
index c0eb394532..d41e96140d 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/build/SGXSDKCommandLauncher.java
@@ -1,38 +1,38 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-/**
- * This class follows the same solution provided in the NDK_PLUGIN for NDKCommandLauncher.
- */
-package com.intel.sgx.build;
-
-import org.eclipse.cdt.core.CommandLauncher;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-
-import com.intel.sgx.SdkPathVariableProvider;
-/**
- * This launches the sgx-ndk-build.
- */
-public class SGXSDKCommandLauncher extends CommandLauncher {
-
- @Override
- public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory,
- IProgressMonitor monitor)
- throws CoreException {
-
- return super.execute(commandPath, args, env, changeToDirectory, monitor);
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * This class follows the same solution provided in the NDK_PLUGIN for NDKCommandLauncher.
+ */
+package com.intel.sgx.build;
+
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import com.intel.sgx.SdkPathVariableProvider;
+/**
+ * This launches the sgx-ndk-build.
+ */
+public class SGXSDKCommandLauncher extends CommandLauncher {
+
+ @Override
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory,
+ IProgressMonitor monitor)
+ throws CoreException {
+
+ return super.execute(commandPath, args, env, changeToDirectory, monitor);
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java
index 8c616ea013..3cd9bbd5a7 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddEnclaveFileDialog.java
@@ -1,126 +1,126 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import javax.swing.JOptionPane;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import com.intel.sgx.handlers.AddEnclave;
-
-public class AddEnclaveFileDialog extends SGXDialogBase {
-
- private Text fileNameField;
- private AddEnclave addHandler;
- private boolean generateApp = true;
-
- public AddEnclaveFileDialog(Shell shell, AddEnclave addHandler) {
- super(shell);
- this.addHandler = addHandler;
- this.shell = shell;
- // setShellStyle(SWT.RESIZE | SWT.TITLE);
- }
-
- public boolean generateApp()
- {
- return generateApp;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1,false);
- composite.setLayout(gridLayout);
-
- final Group container = new Group(composite, SWT.NONE);
- container.setLayout(new GridLayout(3,false));
- GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
- innergrid1.horizontalSpan = 3;
- container.setLayoutData(innergrid1);
-
- addLabel(container, "Enter the name of the Enclave. Make sure the name is unique within the hosting application.");
-
- final Label fileNameLabel = new Label(container, SWT.NONE);
- fileNameLabel.setText("Enclave name:");
- fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
-
- fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER);
- GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL);
- textGridData1.minimumWidth = 400;
- textGridData1.grabExcessHorizontalSpace = true;
- fileNameField.setLayoutData(textGridData1);
-
- Button generateUntrustedApp = new Button(container, SWT.CHECK);
- generateUntrustedApp.setText("Generate sample untrusted application?");
- generateUntrustedApp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false, 3, 1));
- generateUntrustedApp.setSelection(true);
-
- generateUntrustedApp.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent event) {
- Button btn = (Button) event.getSource();
- generateApp = btn.getSelection();
- }
- });
-
- container.layout();
- composite.layout();
- return composite;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Add New Intel(R) SGX Enclave Dialog");
- newShell.layout();
- }
-
- @Override
- protected
- void okPressed() {
- addHandler.edlFilename = fileNameField.getText();
- if(!fileNameField.getText().isEmpty()
- ){
- if(Character.isDigit(fileNameField.getText().charAt(0)))
- {
- JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- else
- super.okPressed();
- }
- }
-
- @Override
- protected Point getInitialSize(){
- return new Point(675,200);
- }
-
- public String getFileName() {
- return fileNameField.getText();
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import javax.swing.JOptionPane;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.intel.sgx.handlers.AddEnclave;
+
+public class AddEnclaveFileDialog extends SGXDialogBase {
+
+ private Text fileNameField;
+ private AddEnclave addHandler;
+ private boolean generateApp = true;
+
+ public AddEnclaveFileDialog(Shell shell, AddEnclave addHandler) {
+ super(shell);
+ this.addHandler = addHandler;
+ this.shell = shell;
+ // setShellStyle(SWT.RESIZE | SWT.TITLE);
+ }
+
+ public boolean generateApp()
+ {
+ return generateApp;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1,false);
+ composite.setLayout(gridLayout);
+
+ final Group container = new Group(composite, SWT.NONE);
+ container.setLayout(new GridLayout(3,false));
+ GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
+ innergrid1.horizontalSpan = 3;
+ container.setLayoutData(innergrid1);
+
+ addLabel(container, "Enter the name of the Enclave. Make sure the name is unique within the hosting application.");
+
+ final Label fileNameLabel = new Label(container, SWT.NONE);
+ fileNameLabel.setText("Enclave name:");
+ fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
+
+ fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER);
+ GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL);
+ textGridData1.minimumWidth = 400;
+ textGridData1.grabExcessHorizontalSpace = true;
+ fileNameField.setLayoutData(textGridData1);
+
+ Button generateUntrustedApp = new Button(container, SWT.CHECK);
+ generateUntrustedApp.setText("Generate sample untrusted application?");
+ generateUntrustedApp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false, 3, 1));
+ generateUntrustedApp.setSelection(true);
+
+ generateUntrustedApp.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ Button btn = (Button) event.getSource();
+ generateApp = btn.getSelection();
+ }
+ });
+
+ container.layout();
+ composite.layout();
+ return composite;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Add New Intel(R) SGX Enclave Dialog");
+ newShell.layout();
+ }
+
+ @Override
+ protected
+ void okPressed() {
+ addHandler.edlFilename = fileNameField.getText();
+ if(!fileNameField.getText().isEmpty()
+ ){
+ if(Character.isDigit(fileNameField.getText().charAt(0)))
+ {
+ JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else
+ super.okPressed();
+ }
+ }
+
+ @Override
+ protected Point getInitialSize(){
+ return new Point(675,200);
+ }
+
+ public String getFileName() {
+ return fileNameField.getText();
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java
index 9a2c5cc3ce..f1e20a129f 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/AddTrustedStaticLibFileDialog.java
@@ -1,109 +1,109 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import javax.swing.JOptionPane;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import com.intel.sgx.handlers.AddTrustedStaticLib;
-
-public class AddTrustedStaticLibFileDialog extends SGXDialogBase {
-
- private Text fileNameField;
- private AddTrustedStaticLib addHandler;
- private boolean generateApp = false;
-
- public AddTrustedStaticLibFileDialog(Shell shell, AddTrustedStaticLib addHandler) {
- super(shell);
- this.addHandler = addHandler;
- this.shell = shell;
- // setShellStyle(SWT.RESIZE | SWT.TITLE);
- }
-
- public boolean generateApp()
- {
- return generateApp;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1,false);
- composite.setLayout(gridLayout);
-
- final Group container = new Group(composite, SWT.NONE);
- container.setLayout(new GridLayout(3,false));
- GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
- innergrid1.horizontalSpan = 3;
- container.setLayoutData(innergrid1);
-
- addLabel(container, "Enter the name of the Static Trusted Library.");
- addLabel(container, "Make sure the name is unique within the hosting application.");
-
- final Label fileNameLabel = new Label(container, SWT.NONE);
- fileNameLabel.setText("Static Trusted Library Name:");
- fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
-
- fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER);
- GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL);
- textGridData1.minimumWidth = 400;
- textGridData1.grabExcessHorizontalSpace = true;
- fileNameField.setLayoutData(textGridData1);
-
- composite.layout();
-
- return composite;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Add New Intel(R) SGX Static Trusted Library Dialog");
- }
-
- @Override
- protected
- void okPressed(){
- addHandler.edlFilename = fileNameField.getText();
- if(!fileNameField.getText().isEmpty()
- ){
- if(Character.isDigit(fileNameField.getText().charAt(0)))
- {
- JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error",
- JOptionPane.ERROR_MESSAGE);
- }
- else
- super.okPressed();
- }
- }
-
- @Override
- protected Point getInitialSize(){
- return new Point(675,200);
- }
-
- public String getFileName() {
- return fileNameField.getText();
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import javax.swing.JOptionPane;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.intel.sgx.handlers.AddTrustedStaticLib;
+
+public class AddTrustedStaticLibFileDialog extends SGXDialogBase {
+
+ private Text fileNameField;
+ private AddTrustedStaticLib addHandler;
+ private boolean generateApp = false;
+
+ public AddTrustedStaticLibFileDialog(Shell shell, AddTrustedStaticLib addHandler) {
+ super(shell);
+ this.addHandler = addHandler;
+ this.shell = shell;
+ // setShellStyle(SWT.RESIZE | SWT.TITLE);
+ }
+
+ public boolean generateApp()
+ {
+ return generateApp;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1,false);
+ composite.setLayout(gridLayout);
+
+ final Group container = new Group(composite, SWT.NONE);
+ container.setLayout(new GridLayout(3,false));
+ GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
+ innergrid1.horizontalSpan = 3;
+ container.setLayoutData(innergrid1);
+
+ addLabel(container, "Enter the name of the Static Trusted Library.");
+ addLabel(container, "Make sure the name is unique within the hosting application.");
+
+ final Label fileNameLabel = new Label(container, SWT.NONE);
+ fileNameLabel.setText("Static Trusted Library Name:");
+ fileNameLabel.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
+
+ fileNameField = new Text(container,SWT.SINGLE | SWT.BORDER);
+ GridData textGridData1 = new GridData(GridData.FILL_HORIZONTAL);
+ textGridData1.minimumWidth = 400;
+ textGridData1.grabExcessHorizontalSpace = true;
+ fileNameField.setLayoutData(textGridData1);
+
+ composite.layout();
+
+ return composite;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Add New Intel(R) SGX Static Trusted Library Dialog");
+ }
+
+ @Override
+ protected
+ void okPressed(){
+ addHandler.edlFilename = fileNameField.getText();
+ if(!fileNameField.getText().isEmpty()
+ ){
+ if(Character.isDigit(fileNameField.getText().charAt(0)))
+ {
+ JOptionPane.showMessageDialog(null, "Enclave names starting with digits are not allowed.", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else
+ super.okPressed();
+ }
+ }
+
+ @Override
+ protected Point getInitialSize(){
+ return new Point(675,200);
+ }
+
+ public String getFileName() {
+ return fileNameField.getText();
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java
index fdba448164..3f972538c7 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog1.java
@@ -1,72 +1,72 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import com.intel.sgx.handlers.TwoStepSignHandlerBase;
-
-public class TwoStepSignStep1Dialog1 extends TwoStepSignDialogBase {
-
- final private TwoStepSignHandlerBase handler;
-
- public TwoStepSignStep1Dialog1(Shell parentShell, TwoStepSignHandlerBase handler) {
- super(parentShell);
- this.handler = handler;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1, false);
- composite.setLayout(gridLayout);
-
- enclaveFileField = addGroup(composite, "Unsigned Enclave Path:",
- "Select Enclave for which to generate the Hash.",
- "Enclave Path:", "Select Enclave", enclaveFileSelectionListener);
-
- hashFileField = addGroup(composite, "Generate Hash:",
- "Select Location to Output Hash File.", "Hash File Location:",
- "Select File Path", hashFileSelectionListener);
-
- configFileField = addGroup(composite, "Configuration File:",
- "Select Input Configuration XML File. ",
- "Configuration File:", "Select Config",
- configFileSelectionListener);
-
- composite.pack(true);
- return composite;
- }
-
- @Override
- protected void okPressed() {
- handler.enclaveFile = enclaveFileField.getText();
- handler.hashFile = hashFileField.getText();
- handler.configFile = configFileField.getText();
-
- super.okPressed();
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Two Step Enclave Sign - Generate Hash");
- }
-
-
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import com.intel.sgx.handlers.TwoStepSignHandlerBase;
+
+public class TwoStepSignStep1Dialog1 extends TwoStepSignDialogBase {
+
+ final private TwoStepSignHandlerBase handler;
+
+ public TwoStepSignStep1Dialog1(Shell parentShell, TwoStepSignHandlerBase handler) {
+ super(parentShell);
+ this.handler = handler;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1, false);
+ composite.setLayout(gridLayout);
+
+ enclaveFileField = addGroup(composite, "Unsigned Enclave Path:",
+ "Select Enclave for which to generate the Hash.",
+ "Enclave Path:", "Select Enclave", enclaveFileSelectionListener);
+
+ hashFileField = addGroup(composite, "Generate Hash:",
+ "Select Location to Output Hash File.", "Hash File Location:",
+ "Select File Path", hashFileSelectionListener);
+
+ configFileField = addGroup(composite, "Configuration File:",
+ "Select Input Configuration XML File. ",
+ "Configuration File:", "Select Config",
+ configFileSelectionListener);
+
+ composite.pack(true);
+ return composite;
+ }
+
+ @Override
+ protected void okPressed() {
+ handler.enclaveFile = enclaveFileField.getText();
+ handler.hashFile = hashFileField.getText();
+ handler.configFile = configFileField.getText();
+
+ super.okPressed();
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Two Step Enclave Sign - Generate Hash");
+ }
+
+
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java
index 4c2852f9f4..d66743e412 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog2.java
@@ -1,89 +1,89 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class TwoStepSignStep1Dialog2 extends TwoStepSignDialogBase {
-
- final private String hashFile;
-
- public TwoStepSignStep1Dialog2(Shell parentShell, String hashFile) {
- super(parentShell);
- this.hashFile = hashFile;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1,false);
- composite.setLayout(gridLayout);
-
- addGroup1(composite);
- addGroup3(composite);
-
-
- return composite;
- }
-
- private void addGroup1(Composite composite) {
- final Group container = new Group(composite, SWT.None);
- container.setLayout(new GridLayout(3,false));
- GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
- innergrid1.horizontalSpan = 3;
- container.setLayoutData(innergrid1);
- container.setText("Hash File:");
-
- final Label messageLabel = new Label(container, SWT.NONE);
- messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
- messageLabel.setText("Hash File Generated at Location:");
-
- final Label messageLabel1 = new Label(container, SWT.NONE);
- messageLabel1.setText(hashFile);
-
- messageLabel1.setLayoutData(new GridData(GridData.BEGINNING));
- }
-
- private void addGroup3(Composite composite) {
- final Group container3 = new Group(composite, SWT.None);
- container3.setLayout(new GridLayout(3,false));
- GridData innergrid3 = new GridData(GridData.FILL_HORIZONTAL);
- innergrid3.horizontalSpan = 3;
- container3.setLayoutData(innergrid3);
- container3.setText("Generate Signed Enclave (Step-2):");
-
- final Label messageLabel4 = new Label(container3, SWT.NONE);
- messageLabel4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
- messageLabel4.setText("To Generate Signed Enclave Now: Click OK");
-
- final Label messageLabel5 = new Label(container3, SWT.NONE);
- messageLabel5.setLayoutData(new GridData(GridData.CENTER, GridData.END, false, false, 3, 1));
- messageLabel5.setText("To Generate Signed Enclave Later: Click Cancel");
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Two Step Enclave Sign - Generate Hash");
- }
-
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class TwoStepSignStep1Dialog2 extends TwoStepSignDialogBase {
+
+ final private String hashFile;
+
+ public TwoStepSignStep1Dialog2(Shell parentShell, String hashFile) {
+ super(parentShell);
+ this.hashFile = hashFile;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1,false);
+ composite.setLayout(gridLayout);
+
+ addGroup1(composite);
+ addGroup3(composite);
+
+
+ return composite;
+ }
+
+ private void addGroup1(Composite composite) {
+ final Group container = new Group(composite, SWT.None);
+ container.setLayout(new GridLayout(3,false));
+ GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
+ innergrid1.horizontalSpan = 3;
+ container.setLayoutData(innergrid1);
+ container.setText("Hash File:");
+
+ final Label messageLabel = new Label(container, SWT.NONE);
+ messageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
+ messageLabel.setText("Hash File Generated at Location:");
+
+ final Label messageLabel1 = new Label(container, SWT.NONE);
+ messageLabel1.setText(hashFile);
+
+ messageLabel1.setLayoutData(new GridData(GridData.BEGINNING));
+ }
+
+ private void addGroup3(Composite composite) {
+ final Group container3 = new Group(composite, SWT.None);
+ container3.setLayout(new GridLayout(3,false));
+ GridData innergrid3 = new GridData(GridData.FILL_HORIZONTAL);
+ innergrid3.horizontalSpan = 3;
+ container3.setLayoutData(innergrid3);
+ container3.setText("Generate Signed Enclave (Step-2):");
+
+ final Label messageLabel4 = new Label(container3, SWT.NONE);
+ messageLabel4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
+ messageLabel4.setText("To Generate Signed Enclave Now: Click OK");
+
+ final Label messageLabel5 = new Label(container3, SWT.NONE);
+ messageLabel5.setLayoutData(new GridData(GridData.CENTER, GridData.END, false, false, 3, 1));
+ messageLabel5.setText("To Generate Signed Enclave Later: Click Cancel");
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Two Step Enclave Sign - Generate Hash");
+ }
+
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java
index 976f1c21b3..f62801a705 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep1Dialog3.java
@@ -1,105 +1,105 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import com.intel.sgx.handlers.TwoStepSignHandlerBase;
-
-public class TwoStepSignStep1Dialog3 extends TwoStepSignDialogBase {
-
- final private TwoStepSignHandlerBase handler;
-
- public TwoStepSignStep1Dialog3(Shell parentShell, TwoStepSignHandlerBase handler) {
- super(parentShell);
- this.handler = handler;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1, false);
- composite.setLayout(gridLayout);
-
- addInfoGroup(composite);
-
- externalSignPublicKeyFileField = addGroup(composite, "Public Key:",
- "Select the Public Key file obtained from signing facility",
- "Public Key:", "Select", publicKeyLocationSelectionListener);
-
- externalSignedHashFileField = addGroup(composite, "Signature:",
- "Select the Signature file obtained from signing facility.",
- "Signature:",
- "Select", externalSignedHashFileSelectionListener);
-
-
- outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:",
- "Select where to save the output Signed Enclave.",
- "Signed Enclave:",
- "Select", outputSignedEnclaveListener);
-
- return composite;
- }
-
- protected void addInfoGroup(Composite composite) {
- final Group container = new Group(composite, SWT.None);
- container.setLayout(new GridLayout(3,false));
- GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
- innergrid1.horizontalSpan = 3;
- container.setLayoutData(innergrid1);
- container.setText("Hash and Enclave:");
-
-
- addInfoKeyValue(container, "Enclave File:", handler.enclaveFile);
- addInfoKeyValue(container, "Config File:", handler.configFile);
- addInfoKeyValue(container, "Hash File:", handler.hashFile);
- }
-
- private void addInfoKeyValue(final Group container, String key,
- String value) {
- final Label messageLabel2 = new Label(container, SWT.NONE);
- messageLabel2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
- messageLabel2.setText(key);
-
- final Label messageLabel3 = new Label(container, SWT.NONE);
- messageLabel3.setText(value);
- messageLabel3.setLayoutData(new GridData(GridData.BEGINNING));
- }
-
- @Override
- protected void okPressed() {
- handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText();
- handler.externallySignedHashFile = externalSignedHashFileField.getText();
- handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText();
- super.okPressed();
- }
-
-
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Two Step Enclave Sign - Generate Signed Enclave");
- }
-
-
-
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import com.intel.sgx.handlers.TwoStepSignHandlerBase;
+
+public class TwoStepSignStep1Dialog3 extends TwoStepSignDialogBase {
+
+ final private TwoStepSignHandlerBase handler;
+
+ public TwoStepSignStep1Dialog3(Shell parentShell, TwoStepSignHandlerBase handler) {
+ super(parentShell);
+ this.handler = handler;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1, false);
+ composite.setLayout(gridLayout);
+
+ addInfoGroup(composite);
+
+ externalSignPublicKeyFileField = addGroup(composite, "Public Key:",
+ "Select the Public Key file obtained from signing facility",
+ "Public Key:", "Select", publicKeyLocationSelectionListener);
+
+ externalSignedHashFileField = addGroup(composite, "Signature:",
+ "Select the Signature file obtained from signing facility.",
+ "Signature:",
+ "Select", externalSignedHashFileSelectionListener);
+
+
+ outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:",
+ "Select where to save the output Signed Enclave.",
+ "Signed Enclave:",
+ "Select", outputSignedEnclaveListener);
+
+ return composite;
+ }
+
+ protected void addInfoGroup(Composite composite) {
+ final Group container = new Group(composite, SWT.None);
+ container.setLayout(new GridLayout(3,false));
+ GridData innergrid1 = new GridData(GridData.FILL_HORIZONTAL);
+ innergrid1.horizontalSpan = 3;
+ container.setLayoutData(innergrid1);
+ container.setText("Hash and Enclave:");
+
+
+ addInfoKeyValue(container, "Enclave File:", handler.enclaveFile);
+ addInfoKeyValue(container, "Config File:", handler.configFile);
+ addInfoKeyValue(container, "Hash File:", handler.hashFile);
+ }
+
+ private void addInfoKeyValue(final Group container, String key,
+ String value) {
+ final Label messageLabel2 = new Label(container, SWT.NONE);
+ messageLabel2.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
+ messageLabel2.setText(key);
+
+ final Label messageLabel3 = new Label(container, SWT.NONE);
+ messageLabel3.setText(value);
+ messageLabel3.setLayoutData(new GridData(GridData.BEGINNING));
+ }
+
+ @Override
+ protected void okPressed() {
+ handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText();
+ handler.externallySignedHashFile = externalSignedHashFileField.getText();
+ handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText();
+ super.okPressed();
+ }
+
+
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Two Step Enclave Sign - Generate Signed Enclave");
+ }
+
+
+
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java
index acd9e99627..af2f981384 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/dialogs/TwoStepSignStep2Dialog.java
@@ -1,92 +1,92 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.dialogs;
-
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import com.intel.sgx.handlers.TwoStepSignHandlerBase;
-import com.intel.sgx.handlers.TwoStepSignStep2;
-
-public class TwoStepSignStep2Dialog extends TwoStepSignDialogBase{
-
- final private TwoStepSignHandlerBase handler;
-
-
- public TwoStepSignStep2Dialog(Shell parentShell, TwoStepSignHandlerBase handler) {
- super(parentShell);
- this.handler = handler;
- }
-
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout(1,false);
- composite.setLayout(gridLayout);
-
-
-
- enclaveFileField= addGroup(composite, "Enclave:",
- "Select the unsigned enclave file",
- "Unsigned Enclave File:", "Select", enclaveFileSelectionListener);
-
- configFileField = addGroup(composite, "Configuration File:",
- "Select Input Configuration XML File. ",
- "Configuration File:", "Select Config",
- configFileSelectionListener);
-
- hashFileField= addGroup(composite, "Hash:",
- "Select the Hash file obtained from previous step",
- "Hash File:", "Select", hashFileSelectionListener);
-
- externalSignPublicKeyFileField= addGroup(composite, "Public Key:",
- "Select the Public Key file obtained from external signing facility",
- "Public Key:", "Select", publicKeyLocationSelectionListener);
-
- externalSignedHashFileField = addGroup(composite, "Signature:",
- "Select the Signature file obtained from signing facility.",
- "Signature:",
- "Select", externalSignedHashFileSelectionListener);
-
- outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:",
- "Select where to save the output Signed Enclave.",
- "Signed Enclave:",
- "Select", outputSignedEnclaveListener);
-
- return composite;
- }
-
-
- @Override
- protected void okPressed() {
- handler.enclaveFile = enclaveFileField.getText();
- handler.hashFile = hashFileField.getText();
- handler.configFile = configFileField.getText();
- handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText();
- handler.externallySignedHashFile = externalSignedHashFileField.getText();
- handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText();
-
- super.okPressed();
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Two Step Enclave Sign - Generate Signed Enclave");
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.dialogs;
+
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import com.intel.sgx.handlers.TwoStepSignHandlerBase;
+import com.intel.sgx.handlers.TwoStepSignStep2;
+
+public class TwoStepSignStep2Dialog extends TwoStepSignDialogBase{
+
+ final private TwoStepSignHandlerBase handler;
+
+
+ public TwoStepSignStep2Dialog(Shell parentShell, TwoStepSignHandlerBase handler) {
+ super(parentShell);
+ this.handler = handler;
+ }
+
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ final GridLayout gridLayout = new GridLayout(1,false);
+ composite.setLayout(gridLayout);
+
+
+
+ enclaveFileField= addGroup(composite, "Enclave:",
+ "Select the unsigned enclave file",
+ "Unsigned Enclave File:", "Select", enclaveFileSelectionListener);
+
+ configFileField = addGroup(composite, "Configuration File:",
+ "Select Input Configuration XML File. ",
+ "Configuration File:", "Select Config",
+ configFileSelectionListener);
+
+ hashFileField= addGroup(composite, "Hash:",
+ "Select the Hash file obtained from previous step",
+ "Hash File:", "Select", hashFileSelectionListener);
+
+ externalSignPublicKeyFileField= addGroup(composite, "Public Key:",
+ "Select the Public Key file obtained from external signing facility",
+ "Public Key:", "Select", publicKeyLocationSelectionListener);
+
+ externalSignedHashFileField = addGroup(composite, "Signature:",
+ "Select the Signature file obtained from signing facility.",
+ "Signature:",
+ "Select", externalSignedHashFileSelectionListener);
+
+ outputSignedEnclaveFileField = addGroup(composite, "Signed Enclave:",
+ "Select where to save the output Signed Enclave.",
+ "Signed Enclave:",
+ "Select", outputSignedEnclaveListener);
+
+ return composite;
+ }
+
+
+ @Override
+ protected void okPressed() {
+ handler.enclaveFile = enclaveFileField.getText();
+ handler.hashFile = hashFileField.getText();
+ handler.configFile = configFileField.getText();
+ handler.externalSignPublicKeyFile = externalSignPublicKeyFileField.getText();
+ handler.externallySignedHashFile = externalSignedHashFileField.getText();
+ handler.outputSignedEnclaveFile = outputSignedEnclaveFileField.getText();
+
+ super.okPressed();
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Two Step Enclave Sign - Generate Signed Enclave");
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java
index 2c48b2fb39..5ee697b3de 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveredPathInfo.java
@@ -1,202 +1,202 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.discovery;
-
-import java.util.List;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-
-import com.intel.sgx.Activator;
-/*
- * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code.
- */
-public class SGXSDKDiscoveredPathInfo implements IDiscoveredPathInfo {
-
- private final IProject mProject;
- private long mLastUpdate = IFile.NULL_STAMP;
- private IPath[] mIncludePaths;
- private Map mSymbols;
- private boolean mNeedReindexing = false;
- private static final IPath LINUX_MK = new Path("sgx/Makefile");
-
- //Keys for preferences
- // public static final String LAST_UPDATE = "lastUpdate"; //$NON-NLS-1$
-
-
- public SGXSDKDiscoveredPathInfo(IProject project) {
- this.mProject = project;
- load();
- }
-
- @Override
- public IProject getProject() {
- return mProject;
- }
-
- @Override
- public IPath[] getIncludePaths() {
- if (mNeedReindexing) {
- CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(mProject));
- mNeedReindexing = false;
- }
- return mIncludePaths;
- }
-
- void setIncludePaths(List pathStrings) {
- mIncludePaths = new IPath[pathStrings.size()];
- int i = 0;
- for (String path : pathStrings)
- mIncludePaths[i++] = new Path(path);
- mNeedReindexing = true;
- }
-
- @Override
- public Map getSymbols() {
- if (mSymbols == null)
- mSymbols = new HashMap();
- return mSymbols;
- }
-
- void setSymbols(Map symbols) {
- this.mSymbols = symbols;
- }
-
- @Override
- public IDiscoveredScannerInfoSerializable getSerializable() {
- return null;
- }
-
- public void update(IProgressMonitor monitor) throws CoreException {
- if (!needUpdating())
- return;
-
- new SGXSDKDiscoveryUpdater(this).runUpdate(monitor);
-
- if (mIncludePaths != null && mSymbols != null) {
- recordUpdate();
- save();
- }
- }
-
- private boolean needUpdating() {
-
-
- if (mLastUpdate == IFile.NULL_STAMP) {
- return true;
- }
-
- return mProject.getFile(LINUX_MK).getLocalTimeStamp() > mLastUpdate;
- }
-
- private void recordUpdate() {
- mLastUpdate = mProject.getFile(LINUX_MK).getLocalTimeStamp();
- }
-
- public void delete() {
- mLastUpdate = IFile.NULL_STAMP;
- }
-
- private File getInfoFile() {
- File stateLoc = Activator.getDefault().getStateLocation().toFile();
- return new File(stateLoc, mProject.getName() + ".pathInfo"); //$NON-NLS-1$
- }
-
- private void save() {
- try {
- File infoFile = getInfoFile();
- infoFile.getParentFile().mkdirs();
- PrintStream out = new PrintStream(infoFile);
-
- out.print("t,"); //$NON-NLS-1$
- out.print(mLastUpdate);
- out.println();
-
- for (IPath include : mIncludePaths) {
- out.print("i,"); //$NON-NLS-1$
- out.print(include.toPortableString());
- out.println();
- }
-
- for (Entry symbol : mSymbols.entrySet()) {
- out.print("d,"); //$NON-NLS-1$
- out.print(symbol.getKey());
- out.print(","); //$NON-NLS-1$
- out.print(symbol.getValue());
- out.println();
- }
-
- out.close();
- } catch (IOException e) {
- Activator.log(e);
- }
-
- }
-
- private void load() {
- try {
- File infoFile = getInfoFile();
- if (!infoFile.exists())
- return;
-
- long timestamp = IFile.NULL_STAMP;
- List includes = new ArrayList();
- Map defines = new HashMap();
-
- BufferedReader reader = new BufferedReader(new FileReader(infoFile));
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- switch (line.charAt(0)) {
- case 't':
- timestamp = Long.valueOf(line.substring(2));
- break;
- case 'i':
- includes.add(Path.fromPortableString(line.substring(2)));
- break;
- case 'd':
- int n = line.indexOf(',', 2);
- if (n == -1)
- defines.put(line.substring(2), ""); //$NON-NLS-1$
- else
- defines.put(line.substring(2, n), line.substring(n + 1));
- break;
- }
- }
- reader.close();
-
- mLastUpdate = timestamp;
- mIncludePaths = includes.toArray(new IPath[includes.size()]);
- mSymbols = defines;
- } catch (IOException e) {
- Activator.log(e);
- }
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.discovery;
+
+import java.util.List;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import com.intel.sgx.Activator;
+/*
+ * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code.
+ */
+public class SGXSDKDiscoveredPathInfo implements IDiscoveredPathInfo {
+
+ private final IProject mProject;
+ private long mLastUpdate = IFile.NULL_STAMP;
+ private IPath[] mIncludePaths;
+ private Map mSymbols;
+ private boolean mNeedReindexing = false;
+ private static final IPath LINUX_MK = new Path("sgx/Makefile");
+
+ //Keys for preferences
+ // public static final String LAST_UPDATE = "lastUpdate"; //$NON-NLS-1$
+
+
+ public SGXSDKDiscoveredPathInfo(IProject project) {
+ this.mProject = project;
+ load();
+ }
+
+ @Override
+ public IProject getProject() {
+ return mProject;
+ }
+
+ @Override
+ public IPath[] getIncludePaths() {
+ if (mNeedReindexing) {
+ CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(mProject));
+ mNeedReindexing = false;
+ }
+ return mIncludePaths;
+ }
+
+ void setIncludePaths(List pathStrings) {
+ mIncludePaths = new IPath[pathStrings.size()];
+ int i = 0;
+ for (String path : pathStrings)
+ mIncludePaths[i++] = new Path(path);
+ mNeedReindexing = true;
+ }
+
+ @Override
+ public Map getSymbols() {
+ if (mSymbols == null)
+ mSymbols = new HashMap();
+ return mSymbols;
+ }
+
+ void setSymbols(Map symbols) {
+ this.mSymbols = symbols;
+ }
+
+ @Override
+ public IDiscoveredScannerInfoSerializable getSerializable() {
+ return null;
+ }
+
+ public void update(IProgressMonitor monitor) throws CoreException {
+ if (!needUpdating())
+ return;
+
+ new SGXSDKDiscoveryUpdater(this).runUpdate(monitor);
+
+ if (mIncludePaths != null && mSymbols != null) {
+ recordUpdate();
+ save();
+ }
+ }
+
+ private boolean needUpdating() {
+
+
+ if (mLastUpdate == IFile.NULL_STAMP) {
+ return true;
+ }
+
+ return mProject.getFile(LINUX_MK).getLocalTimeStamp() > mLastUpdate;
+ }
+
+ private void recordUpdate() {
+ mLastUpdate = mProject.getFile(LINUX_MK).getLocalTimeStamp();
+ }
+
+ public void delete() {
+ mLastUpdate = IFile.NULL_STAMP;
+ }
+
+ private File getInfoFile() {
+ File stateLoc = Activator.getDefault().getStateLocation().toFile();
+ return new File(stateLoc, mProject.getName() + ".pathInfo"); //$NON-NLS-1$
+ }
+
+ private void save() {
+ try {
+ File infoFile = getInfoFile();
+ infoFile.getParentFile().mkdirs();
+ PrintStream out = new PrintStream(infoFile);
+
+ out.print("t,"); //$NON-NLS-1$
+ out.print(mLastUpdate);
+ out.println();
+
+ for (IPath include : mIncludePaths) {
+ out.print("i,"); //$NON-NLS-1$
+ out.print(include.toPortableString());
+ out.println();
+ }
+
+ for (Entry symbol : mSymbols.entrySet()) {
+ out.print("d,"); //$NON-NLS-1$
+ out.print(symbol.getKey());
+ out.print(","); //$NON-NLS-1$
+ out.print(symbol.getValue());
+ out.println();
+ }
+
+ out.close();
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+
+ }
+
+ private void load() {
+ try {
+ File infoFile = getInfoFile();
+ if (!infoFile.exists())
+ return;
+
+ long timestamp = IFile.NULL_STAMP;
+ List includes = new ArrayList();
+ Map defines = new HashMap();
+
+ BufferedReader reader = new BufferedReader(new FileReader(infoFile));
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ switch (line.charAt(0)) {
+ case 't':
+ timestamp = Long.valueOf(line.substring(2));
+ break;
+ case 'i':
+ includes.add(Path.fromPortableString(line.substring(2)));
+ break;
+ case 'd':
+ int n = line.indexOf(',', 2);
+ if (n == -1)
+ defines.put(line.substring(2), ""); //$NON-NLS-1$
+ else
+ defines.put(line.substring(2, n), line.substring(n + 1));
+ break;
+ }
+ }
+ reader.close();
+
+ mLastUpdate = timestamp;
+ mIncludePaths = includes.toArray(new IPath[includes.size()]);
+ mSymbols = defines;
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java
index 4c10fccdcc..61e4618d7d 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/discovery/SGXSDKDiscoveryUpdater.java
@@ -1,310 +1,310 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.discovery;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-
-import com.intel.sgx.Activator;
-import com.intel.sgx.build.SGXSDKCommandLauncher;
-
-/*
- * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code.
- */
-public class SGXSDKDiscoveryUpdater {
- private final SGXSDKDiscoveredPathInfo mPathInfo;
- private final IProject mProject;
-
- private boolean mCPlusPlus = false;
- private String mCommand;
- private List mArguments = new ArrayList();
-
- public SGXSDKDiscoveryUpdater(SGXSDKDiscoveredPathInfo pathInfo) {
- mPathInfo = pathInfo;
- mProject = pathInfo.getProject();
- }
-
- public void runUpdate(IProgressMonitor monitor) throws CoreException {
- try {
- // Run make -nB to get the list of commands
- IPath commandPath = new Path("make"); //$NON-NLS-1$
- String[] args = {"-f", "sgx/Makefile", "-n", "-B" }; //$NON-NLS-1$
- String[] env = calcEnvironment();
- File projectDir = new File(mProject.getLocationURI());
- IPath changeToDirectory = new Path(projectDir.getAbsolutePath());
- Process proc = new SGXSDKCommandLauncher().execute(commandPath, args, env,changeToDirectory, monitor);
- if (proc == null) {
- return;
- }
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- String line = reader.readLine();
- while (line != null) {
- checkBuildLine(line);
- line = reader.readLine();
- }
-
- if (mCommand == null) {
- return;
- }
-
- // Run the unique commands with special gcc options to extract the
- // symbols and paths
- // -E -P -v -dD
- mArguments.add("-E"); //$NON-NLS-1$
- mArguments.add("-P"); //$NON-NLS-1$
- mArguments.add("-v"); //$NON-NLS-1$
- mArguments.add("-dD"); //$NON-NLS-1$
-
- URL url = Activator.findFile(new Path("discovery/" + (mCPlusPlus ? "test.cpp" : "test.c"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- File testFile = new File(FileLocator.toFileURL(url).toURI());
- String testFileName = testFile.getAbsolutePath().replace('\\', '/');
- mArguments.add(testFileName);
-
- args = mArguments.toArray(new String[mArguments.size()]);
- proc = new SGXSDKCommandLauncher().execute(new Path(mCommand), args, env,changeToDirectory, monitor);
-
- final InputStream errStream = proc.getErrorStream();
- new Thread() {
- @Override
- public void run() {
- checkIncludes(errStream);
- };
- }.start();
-
- checkDefines(proc.getInputStream());
- } catch (IOException e) {
- throw new CoreException(Activator.newStatus(e));
- } catch (URISyntaxException e) {
- throw new CoreException(Activator.newStatus(e));
- }
- }
-
- private String[] calcEnvironment() throws CoreException {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(mProject);
- IBuilder builder = info.getDefaultConfiguration().getBuilder();
- HashMap envMap = new HashMap();
- if (builder.appendEnvironment()) {
- ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(builder.getParent().getParent());
- IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
- IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
- for (IEnvironmentVariable var : vars) {
- envMap.put(var.getName(), var.getValue());
- }
- }
- // Add variables from build info
- Map builderEnv = builder.getExpandedEnvironment();
- if (builderEnv != null)
- envMap.putAll(builderEnv);
- List strings = new ArrayList(envMap.size());
- for (Entry entry : envMap.entrySet()) {
- StringBuffer buffer = new StringBuffer(entry.getKey());
- buffer.append('=').append(entry.getValue());
- strings.add(buffer.toString());
- }
- return strings.toArray(new String[strings.size()]);
- }
-
- private static class Line {
- private final String line;
- private int pos;
-
- public Line(String line) {
- this.line = line;
- }
-
- public Line(String line, int pos) {
- this(line);
- this.pos = pos;
- }
-
- public String getToken() {
- skipWhiteSpace();
- if (pos == line.length())
- return null;
-
- int start = pos;
- boolean inQuote = false;
-
- while (true) {
- char c = line.charAt(pos);
- if (c == ' ') {
- if (!inQuote)
- return line.substring(start, pos);
- } else if (c == '"') {
- inQuote = !inQuote;
- }
-
- if (++pos == line.length())
- return null;
- }
-
- }
-
- private String getRemaining() {
- if (pos == line.length())
- return null;
-
- skipWhiteSpace();
- String rc = line.substring(pos);
- pos = line.length();
- return rc;
- }
-
- private void skipWhiteSpace() {
- while (true) {
- if (pos == line.length())
- return;
- char c = line.charAt(pos);
- if (c == ' ')
- pos++;
- else
- return;
- }
- }
- }
-
- private void checkBuildLine(String text) {
- Line line = new Line(text);
- String cmd = line.getToken();
- if (cmd == null) {
- return;
- } else if (cmd.endsWith("g++")) { //$NON-NLS-1$
- if (mCommand == null || !mCPlusPlus) {
- mCommand = cmd;
- mCPlusPlus = true;
- }
- gatherOptions(line);
- } else if (cmd.endsWith("gcc")) { //$NON-NLS-1$
- if (mCommand == null){
- mCommand = cmd;
- }
- gatherOptions(line);
- }
-
- }
-
- private void gatherOptions(Line line) {
- for (String option = line.getToken(); option != null; option = line.getToken()) {
- if (option.startsWith("-")) { //$NON-NLS-1$
- // only look at options
- if (option.equals("-I")) { //$NON-NLS-1$
- String dir = line.getToken();
- if (dir != null)
- addArg(option + dir);
- } else if (option.startsWith("-I")) { //$NON-NLS-1$
- addArg(option);
- } else if (option.equals("-D")) { //$NON-NLS-1$
- String def = line.getToken();
- if (def != null)
- addArg(option + def);
- } else if (option.startsWith("-D")) { //$NON-NLS-1$
- addArg(option);
- } else if (option.startsWith("-f")) { //$NON-NLS-1$
- addArg(option);
- } else if (option.startsWith("-m")) { //$NON-NLS-1$
- addArg(option);
- } else if (option.startsWith("--sysroot")) { //$NON-NLS-1$
- addArg(option);
- }
- }
- }
- }
-
- private void addArg(String arg) {
- if (!mArguments.contains(arg))
- mArguments.add(arg);
- }
-
- private void checkIncludes(InputStream in) {
- try {
- List includes = new ArrayList();
- boolean inIncludes1 = false;
- boolean inIncludes2 = false;
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- while (line != null) {
- if (!inIncludes1) {
- if (line.equals("#include \"...\" search starts here:")) //$NON-NLS-1$
- inIncludes1 = true;
- } else {
- if (!inIncludes2) {
- if (line.equals("#include <...> search starts here:")) //$NON-NLS-1$
- inIncludes2 = true;
- else
- includes.add(line.trim());
- } else {
- if (line.equals("End of search list.")) { //$NON-NLS-1$
- mPathInfo.setIncludePaths(includes);
- } else {
- includes.add(line.trim());
- }
- }
- }
- line = reader.readLine();
- }
- } catch (IOException e) {
- Activator.log(e);
- }
- }
-
- private void checkDefines(InputStream in) {
- try {
- Map defines = new HashMap();
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line = reader.readLine();
- while (line != null) {
- if (line.startsWith("#define")) { //$NON-NLS-1$
- Line l = new Line(line, 7);
- String var = l.getToken();
- if (var == null)
- continue;
- String value = l.getRemaining();
- if (value == null)
- value = ""; //$NON-NLS-1$
- defines.put(var, value);
- }
- line = reader.readLine();
- }
- mPathInfo.setSymbols(defines);
- } catch (IOException e) {
- Activator.log(e);
- }
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.discovery;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import com.intel.sgx.Activator;
+import com.intel.sgx.build.SGXSDKCommandLauncher;
+
+/*
+ * This code has been taken from the NDK plugin for Linux. If there is an update to this code there, then refactor this code.
+ */
+public class SGXSDKDiscoveryUpdater {
+ private final SGXSDKDiscoveredPathInfo mPathInfo;
+ private final IProject mProject;
+
+ private boolean mCPlusPlus = false;
+ private String mCommand;
+ private List mArguments = new ArrayList();
+
+ public SGXSDKDiscoveryUpdater(SGXSDKDiscoveredPathInfo pathInfo) {
+ mPathInfo = pathInfo;
+ mProject = pathInfo.getProject();
+ }
+
+ public void runUpdate(IProgressMonitor monitor) throws CoreException {
+ try {
+ // Run make -nB to get the list of commands
+ IPath commandPath = new Path("make"); //$NON-NLS-1$
+ String[] args = {"-f", "sgx/Makefile", "-n", "-B" }; //$NON-NLS-1$
+ String[] env = calcEnvironment();
+ File projectDir = new File(mProject.getLocationURI());
+ IPath changeToDirectory = new Path(projectDir.getAbsolutePath());
+ Process proc = new SGXSDKCommandLauncher().execute(commandPath, args, env,changeToDirectory, monitor);
+ if (proc == null) {
+ return;
+ }
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = reader.readLine();
+ while (line != null) {
+ checkBuildLine(line);
+ line = reader.readLine();
+ }
+
+ if (mCommand == null) {
+ return;
+ }
+
+ // Run the unique commands with special gcc options to extract the
+ // symbols and paths
+ // -E -P -v -dD
+ mArguments.add("-E"); //$NON-NLS-1$
+ mArguments.add("-P"); //$NON-NLS-1$
+ mArguments.add("-v"); //$NON-NLS-1$
+ mArguments.add("-dD"); //$NON-NLS-1$
+
+ URL url = Activator.findFile(new Path("discovery/" + (mCPlusPlus ? "test.cpp" : "test.c"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ File testFile = new File(FileLocator.toFileURL(url).toURI());
+ String testFileName = testFile.getAbsolutePath().replace('\\', '/');
+ mArguments.add(testFileName);
+
+ args = mArguments.toArray(new String[mArguments.size()]);
+ proc = new SGXSDKCommandLauncher().execute(new Path(mCommand), args, env,changeToDirectory, monitor);
+
+ final InputStream errStream = proc.getErrorStream();
+ new Thread() {
+ @Override
+ public void run() {
+ checkIncludes(errStream);
+ };
+ }.start();
+
+ checkDefines(proc.getInputStream());
+ } catch (IOException e) {
+ throw new CoreException(Activator.newStatus(e));
+ } catch (URISyntaxException e) {
+ throw new CoreException(Activator.newStatus(e));
+ }
+ }
+
+ private String[] calcEnvironment() throws CoreException {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(mProject);
+ IBuilder builder = info.getDefaultConfiguration().getBuilder();
+ HashMap envMap = new HashMap();
+ if (builder.appendEnvironment()) {
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(builder.getParent().getParent());
+ IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+ IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+ for (IEnvironmentVariable var : vars) {
+ envMap.put(var.getName(), var.getValue());
+ }
+ }
+ // Add variables from build info
+ Map builderEnv = builder.getExpandedEnvironment();
+ if (builderEnv != null)
+ envMap.putAll(builderEnv);
+ List strings = new ArrayList(envMap.size());
+ for (Entry entry : envMap.entrySet()) {
+ StringBuffer buffer = new StringBuffer(entry.getKey());
+ buffer.append('=').append(entry.getValue());
+ strings.add(buffer.toString());
+ }
+ return strings.toArray(new String[strings.size()]);
+ }
+
+ private static class Line {
+ private final String line;
+ private int pos;
+
+ public Line(String line) {
+ this.line = line;
+ }
+
+ public Line(String line, int pos) {
+ this(line);
+ this.pos = pos;
+ }
+
+ public String getToken() {
+ skipWhiteSpace();
+ if (pos == line.length())
+ return null;
+
+ int start = pos;
+ boolean inQuote = false;
+
+ while (true) {
+ char c = line.charAt(pos);
+ if (c == ' ') {
+ if (!inQuote)
+ return line.substring(start, pos);
+ } else if (c == '"') {
+ inQuote = !inQuote;
+ }
+
+ if (++pos == line.length())
+ return null;
+ }
+
+ }
+
+ private String getRemaining() {
+ if (pos == line.length())
+ return null;
+
+ skipWhiteSpace();
+ String rc = line.substring(pos);
+ pos = line.length();
+ return rc;
+ }
+
+ private void skipWhiteSpace() {
+ while (true) {
+ if (pos == line.length())
+ return;
+ char c = line.charAt(pos);
+ if (c == ' ')
+ pos++;
+ else
+ return;
+ }
+ }
+ }
+
+ private void checkBuildLine(String text) {
+ Line line = new Line(text);
+ String cmd = line.getToken();
+ if (cmd == null) {
+ return;
+ } else if (cmd.endsWith("g++")) { //$NON-NLS-1$
+ if (mCommand == null || !mCPlusPlus) {
+ mCommand = cmd;
+ mCPlusPlus = true;
+ }
+ gatherOptions(line);
+ } else if (cmd.endsWith("gcc")) { //$NON-NLS-1$
+ if (mCommand == null){
+ mCommand = cmd;
+ }
+ gatherOptions(line);
+ }
+
+ }
+
+ private void gatherOptions(Line line) {
+ for (String option = line.getToken(); option != null; option = line.getToken()) {
+ if (option.startsWith("-")) { //$NON-NLS-1$
+ // only look at options
+ if (option.equals("-I")) { //$NON-NLS-1$
+ String dir = line.getToken();
+ if (dir != null)
+ addArg(option + dir);
+ } else if (option.startsWith("-I")) { //$NON-NLS-1$
+ addArg(option);
+ } else if (option.equals("-D")) { //$NON-NLS-1$
+ String def = line.getToken();
+ if (def != null)
+ addArg(option + def);
+ } else if (option.startsWith("-D")) { //$NON-NLS-1$
+ addArg(option);
+ } else if (option.startsWith("-f")) { //$NON-NLS-1$
+ addArg(option);
+ } else if (option.startsWith("-m")) { //$NON-NLS-1$
+ addArg(option);
+ } else if (option.startsWith("--sysroot")) { //$NON-NLS-1$
+ addArg(option);
+ }
+ }
+ }
+ }
+
+ private void addArg(String arg) {
+ if (!mArguments.contains(arg))
+ mArguments.add(arg);
+ }
+
+ private void checkIncludes(InputStream in) {
+ try {
+ List includes = new ArrayList();
+ boolean inIncludes1 = false;
+ boolean inIncludes2 = false;
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ while (line != null) {
+ if (!inIncludes1) {
+ if (line.equals("#include \"...\" search starts here:")) //$NON-NLS-1$
+ inIncludes1 = true;
+ } else {
+ if (!inIncludes2) {
+ if (line.equals("#include <...> search starts here:")) //$NON-NLS-1$
+ inIncludes2 = true;
+ else
+ includes.add(line.trim());
+ } else {
+ if (line.equals("End of search list.")) { //$NON-NLS-1$
+ mPathInfo.setIncludePaths(includes);
+ } else {
+ includes.add(line.trim());
+ }
+ }
+ }
+ line = reader.readLine();
+ }
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+
+ private void checkDefines(InputStream in) {
+ try {
+ Map defines = new HashMap();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.startsWith("#define")) { //$NON-NLS-1$
+ Line l = new Line(line, 7);
+ String var = l.getToken();
+ if (var == null)
+ continue;
+ String value = l.getRemaining();
+ if (value == null)
+ value = ""; //$NON-NLS-1$
+ defines.put(var, value);
+ }
+ line = reader.readLine();
+ }
+ mPathInfo.setSymbols(defines);
+ } catch (IOException e) {
+ Activator.log(e);
+ }
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java
index e998de690b..8fdb6e6a48 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddEnclave.java
@@ -1,213 +1,213 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-import org.eclipse.cdt.core.templateengine.TemplateCore;
-import org.eclipse.cdt.core.templateengine.TemplateEngine;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import com.intel.sgx.Activator;
-import com.intel.sgx.dialogs.AddEnclaveFileDialog;
-import com.intel.sgx.preferences.PreferenceConstants;
-
-public class AddEnclave extends ModuleCreationBaseHandler implements IHandler {
-
- public String edlFilename = "";
- public String linuxMakePath = "";
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String edlBasename,linuxPath,enclaveBasename;
- IProject project = null;
-
- // Display display = Display.getCurrent();
- // Shell shell = new Shell(display);
- Shell shell = null;
- AddEnclaveFileDialog dialog = new AddEnclaveFileDialog(shell, this);
- if (dialog.open() != InputDialog.OK) {
- return null;
- }
-
- if((edlFilename.isEmpty())){
- System.err.println("No Enclave selected to Import.");
- return null;
- }
-
- edlBasename = edlFilename;
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- Object element = null;
- if (selection instanceof IStructuredSelection) {
- element = ((IStructuredSelection) selection).getFirstElement();
- if (element instanceof IResource) {
- project = ((IResource) element).getProject();
- }
- }
- if (!project.exists()) {
- System.err.println("Error: Project not found");
- return null;
- }
-
- for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){
- }
-
-
-
-
- IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename));
-
-
- if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){
- linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString();
- enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString();
- }
-
- else{
- linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString();
- enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString();
- }
-
- IProgressMonitor monitor = new NullProgressMonitor();
- TemplateCore template = null;
- if(isCPProject(project))
- if(dialog.generateApp())
- {
- template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++WithSample");
- }
- else
- {
- template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++Minimal");
- }
- else
- if(dialog.generateApp())
- {
- template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCWithSample");
- }
- else
- {
- template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCMinimal");
- }
-
- Map valueStore = template.getValueStore();
- valueStore.put("projectName", project.getName());
- valueStore.put("workspacePath", linuxPath);
- valueStore.put("baseName", enclaveBasename);
- valueStore.put("enclaveName",edlFilename);
- valueStore.put("EnclaveName",capitalize(edlFilename));
- valueStore.put("ENCLAVENAME",edlFilename.toUpperCase());
- valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH));
-
- IStatus[] statuses = template.executeTemplateProcesses(monitor, false);
- for(IStatus e: statuses)
- {
- }
-
- ManagedBuildManager.saveBuildInfo(project, true);
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- Activator.log(e);
- e.printStackTrace();
- }
-
-
- return null;
- }
-
- private String capitalize(final String line) {
- return Character.toUpperCase(line.charAt(0)) + line.substring(1);
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean isHandled() {
- return true;
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
-
- public void setFilename(String filename) {
- edlFilename = filename;
- }
-
-
-
-
- public static void copyFile(File source, File dest) throws IOException {
- byte[] bytes = new byte[4092];
- if (source != null && dest != null) {
- if (source.isFile()) {
- FileInputStream in = null;
- FileOutputStream out = null;
- try {
- in = new FileInputStream(source);
- out = new FileOutputStream(dest);
- int len;
- while ((len = in.read(bytes)) != -1) {
- out.write(bytes, 0, len);
- }
- } catch (Exception e) {
- Activator.log(e);
- System.err.println("Error: " + e.toString());
- } finally {
- try {
- if (in != null)
- in.close();
- } finally {
- if (out != null)
- out.close();
- }
- }
- }
- }
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.intel.sgx.Activator;
+import com.intel.sgx.dialogs.AddEnclaveFileDialog;
+import com.intel.sgx.preferences.PreferenceConstants;
+
+public class AddEnclave extends ModuleCreationBaseHandler implements IHandler {
+
+ public String edlFilename = "";
+ public String linuxMakePath = "";
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ String edlBasename,linuxPath,enclaveBasename;
+ IProject project = null;
+
+ // Display display = Display.getCurrent();
+ // Shell shell = new Shell(display);
+ Shell shell = null;
+ AddEnclaveFileDialog dialog = new AddEnclaveFileDialog(shell, this);
+ if (dialog.open() != InputDialog.OK) {
+ return null;
+ }
+
+ if((edlFilename.isEmpty())){
+ System.err.println("No Enclave selected to Import.");
+ return null;
+ }
+
+ edlBasename = edlFilename;
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ Object element = null;
+ if (selection instanceof IStructuredSelection) {
+ element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof IResource) {
+ project = ((IResource) element).getProject();
+ }
+ }
+ if (!project.exists()) {
+ System.err.println("Error: Project not found");
+ return null;
+ }
+
+ for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){
+ }
+
+
+
+
+ IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename));
+
+
+ if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){
+ linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString();
+ enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString();
+ }
+
+ else{
+ linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString();
+ enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString();
+ }
+
+ IProgressMonitor monitor = new NullProgressMonitor();
+ TemplateCore template = null;
+ if(isCPProject(project))
+ if(dialog.generateApp())
+ {
+ template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++WithSample");
+ }
+ else
+ {
+ template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveC++Minimal");
+ }
+ else
+ if(dialog.generateApp())
+ {
+ template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCWithSample");
+ }
+ else
+ {
+ template = TemplateEngine.getDefault().getTemplateById("SGXEnclaveCMinimal");
+ }
+
+ Map valueStore = template.getValueStore();
+ valueStore.put("projectName", project.getName());
+ valueStore.put("workspacePath", linuxPath);
+ valueStore.put("baseName", enclaveBasename);
+ valueStore.put("enclaveName",edlFilename);
+ valueStore.put("EnclaveName",capitalize(edlFilename));
+ valueStore.put("ENCLAVENAME",edlFilename.toUpperCase());
+ valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH));
+
+ IStatus[] statuses = template.executeTemplateProcesses(monitor, false);
+ for(IStatus e: statuses)
+ {
+ }
+
+ ManagedBuildManager.saveBuildInfo(project, true);
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ Activator.log(e);
+ e.printStackTrace();
+ }
+
+
+ return null;
+ }
+
+ private String capitalize(final String line) {
+ return Character.toUpperCase(line.charAt(0)) + line.substring(1);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ public void setFilename(String filename) {
+ edlFilename = filename;
+ }
+
+
+
+
+ public static void copyFile(File source, File dest) throws IOException {
+ byte[] bytes = new byte[4092];
+ if (source != null && dest != null) {
+ if (source.isFile()) {
+ FileInputStream in = null;
+ FileOutputStream out = null;
+ try {
+ in = new FileInputStream(source);
+ out = new FileOutputStream(dest);
+ int len;
+ while ((len = in.read(bytes)) != -1) {
+ out.write(bytes, 0, len);
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ System.err.println("Error: " + e.toString());
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } finally {
+ if (out != null)
+ out.close();
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java
index efeeeedd3a..0fd9a87541 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/AddTrustedStaticLib.java
@@ -1,193 +1,193 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-import org.eclipse.cdt.core.templateengine.TemplateCore;
-import org.eclipse.cdt.core.templateengine.TemplateEngine;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import com.intel.sgx.Activator;
-import com.intel.sgx.dialogs.AddTrustedStaticLibFileDialog;
-import com.intel.sgx.preferences.PreferenceConstants;
-
-public class AddTrustedStaticLib extends ModuleCreationBaseHandler implements IHandler {
-
- public String edlFilename = "";
- public String linuxMakePath = "";
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String edlBasename,linuxPath,enclaveBasename;
- IProject project = null;
-
- // Display display = Display.getCurrent();
- // Shell shell = new Shell(display);
- Shell shell = null;
- AddTrustedStaticLibFileDialog dialog = new AddTrustedStaticLibFileDialog(shell, this);
- if (dialog.open() != InputDialog.OK) {
- return null;
- }
-
- if((edlFilename.isEmpty() )){
- System.err.println("No Enclave selected to Import.");
- return null;
- }
-
- edlBasename = edlFilename;
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- Object element = null;
- if (selection instanceof IStructuredSelection) {
- element = ((IStructuredSelection) selection).getFirstElement();
- if (element instanceof IResource) {
- project = ((IResource) element).getProject();
- }
- }
- if (!project.exists()) {
- System.err.println("Error: Project not found");
- return null;
- }
-
- for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){
- }
-
-
-
-
- IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename));
-
-
- if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){
- linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString();
- enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString();
- }
-
- else{
- linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString();
- enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString();
- }
-
- IProgressMonitor monitor = new NullProgressMonitor();
- TemplateCore template = null;
- if(isCPProject(project))
- template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryC++Minimal");
- else
- template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryCMinimal");
-
- Map valueStore = template.getValueStore();
- valueStore.put("projectName", project.getName());
- valueStore.put("workspacePath", linuxPath);
- valueStore.put("baseName", enclaveBasename);
- valueStore.put("enclaveName",edlFilename);
- valueStore.put("EnclaveName",capitalize(edlFilename));
- valueStore.put("ENCLAVENAME",edlFilename.toUpperCase());
- valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH));
-
- IStatus[] statuses = template.executeTemplateProcesses(monitor, false);
-
-
- ManagedBuildManager.saveBuildInfo(project, true);
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- Activator.log(e);
- e.printStackTrace();
- }
- return null;
- }
-
- private String capitalize(final String line) {
- return Character.toUpperCase(line.charAt(0)) + line.substring(1);
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean isHandled() {
- return true;
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
-
- public void setFilename(String filename) {
- edlFilename = filename;
- }
-
- public static void copyFile(File source, File dest) throws IOException {
- byte[] bytes = new byte[4092];
- if (source != null && dest != null) {
- if (source.isFile()) {
- FileInputStream in = null;
- FileOutputStream out = null;
- try {
- in = new FileInputStream(source);
- out = new FileOutputStream(dest);
- int len;
- while ((len = in.read(bytes)) != -1) {
- out.write(bytes, 0, len);
- }
- } catch (Exception e) {
- Activator.log(e);
- System.err.println("Error: " + e.toString());
- } finally {
- try {
- if (in != null)
- in.close();
- } finally {
- if (out != null)
- out.close();
- }
- }
- }
- }
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.intel.sgx.Activator;
+import com.intel.sgx.dialogs.AddTrustedStaticLibFileDialog;
+import com.intel.sgx.preferences.PreferenceConstants;
+
+public class AddTrustedStaticLib extends ModuleCreationBaseHandler implements IHandler {
+
+ public String edlFilename = "";
+ public String linuxMakePath = "";
+
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ String edlBasename,linuxPath,enclaveBasename;
+ IProject project = null;
+
+ // Display display = Display.getCurrent();
+ // Shell shell = new Shell(display);
+ Shell shell = null;
+ AddTrustedStaticLibFileDialog dialog = new AddTrustedStaticLibFileDialog(shell, this);
+ if (dialog.open() != InputDialog.OK) {
+ return null;
+ }
+
+ if((edlFilename.isEmpty() )){
+ System.err.println("No Enclave selected to Import.");
+ return null;
+ }
+
+ edlBasename = edlFilename;
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ Object element = null;
+ if (selection instanceof IStructuredSelection) {
+ element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof IResource) {
+ project = ((IResource) element).getProject();
+ }
+ }
+ if (!project.exists()) {
+ System.err.println("Error: Project not found");
+ return null;
+ }
+
+ for (IConfigurationElement i : Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.core.resources.projectNature")){
+ }
+
+
+
+
+ IPath linuxMkRelPath = (Path.fromOSString(linuxMakePath)).makeRelativeTo(project.getLocation().append("sgx").append("enclave_"+edlBasename));
+
+
+ if(linuxMkRelPath.removeLastSegments(1).lastSegment().toString().equalsIgnoreCase("sgx")){
+ linuxPath = linuxMkRelPath.removeLastSegments(3).toOSString();
+ enclaveBasename = linuxMkRelPath.removeLastSegments(2).lastSegment().toString();
+ }
+
+ else{
+ linuxPath = linuxMkRelPath.removeLastSegments(2).toOSString();
+ enclaveBasename = linuxMkRelPath.removeLastSegments(1).lastSegment().toString();
+ }
+
+ IProgressMonitor monitor = new NullProgressMonitor();
+ TemplateCore template = null;
+ if(isCPProject(project))
+ template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryC++Minimal");
+ else
+ template = TemplateEngine.getDefault().getTemplateById("SGXTrustedStaticLibraryCMinimal");
+
+ Map valueStore = template.getValueStore();
+ valueStore.put("projectName", project.getName());
+ valueStore.put("workspacePath", linuxPath);
+ valueStore.put("baseName", enclaveBasename);
+ valueStore.put("enclaveName",edlFilename);
+ valueStore.put("EnclaveName",capitalize(edlFilename));
+ valueStore.put("ENCLAVENAME",edlFilename.toUpperCase());
+ valueStore.put("SdkPathFromPlugin", Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.SDK_PATH));
+
+ IStatus[] statuses = template.executeTemplateProcesses(monitor, false);
+
+
+ ManagedBuildManager.saveBuildInfo(project, true);
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ Activator.log(e);
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private String capitalize(final String line) {
+ return Character.toUpperCase(line.charAt(0)) + line.substring(1);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ public void setFilename(String filename) {
+ edlFilename = filename;
+ }
+
+ public static void copyFile(File source, File dest) throws IOException {
+ byte[] bytes = new byte[4092];
+ if (source != null && dest != null) {
+ if (source.isFile()) {
+ FileInputStream in = null;
+ FileOutputStream out = null;
+ try {
+ in = new FileInputStream(source);
+ out = new FileOutputStream(dest);
+ int len;
+ while ((len = in.read(bytes)) != -1) {
+ out.write(bytes, 0, len);
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ System.err.println("Error: " + e.toString());
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } finally {
+ if (out != null)
+ out.close();
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java
index 058e622996..160dc14b56 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/RemoveEnclave.java
@@ -1,169 +1,169 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import com.intel.sgx.Activator;
-import com.intel.sgx.dialogs.RemoveEnclaveFileDialog;
-
-public class RemoveEnclave implements IHandler {
-
- public String edlFilename = "";
- private IPath edlCanonicalFilename;
-
- @Override
- public void addHandlerListener(IHandlerListener handlerListener) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String edlBasename;
- IProject project = null;
-
- // Display display = Display.getCurrent();
- // Shell shell = new Shell(display);
-
- RemoveEnclaveFileDialog dialog = new RemoveEnclaveFileDialog(null, this);
-
- if (dialog.open() != InputDialog.OK) {
- return null;
- }
-
- edlCanonicalFilename = Path.fromOSString(edlFilename);
- edlBasename = edlCanonicalFilename.lastSegment();
-
- if(edlBasename.isEmpty()){
- return null;
- }
-
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- Object element = null;
- if(selection instanceof IStructuredSelection) {
- element = ((IStructuredSelection)selection).getFirstElement();
- if (element instanceof IResource) {
- project= ((IResource)element).getProject();
- }
- }
- if (!project.exists()) {
- System.err.println("Error: Project not found");
- return null;
- }
-
- IPath targetRelPath = project.getProjectRelativePath().append("sgx").append("enclave_" + edlBasename);
-
- try {
- for (int i=1;i<=targetRelPath.segmentCount();i++) {
- IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i));
-
- if (subfolder.exists()){
- if(subfolder.getProjectRelativePath().toOSString().contains("enclave_"+edlBasename)){
- subfolder.delete(true, true, null);
- break;
- }
- }
- }
- targetRelPath = project.getProjectRelativePath().append("sgx").append(edlBasename);
- for (int i=1;i<=targetRelPath.segmentCount();i++) {
- IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i));
-
- if (subfolder.exists()){
- if(subfolder.getProjectRelativePath().toOSString().contains(edlBasename)){
- subfolder.delete(true, true, null);
- break;
- }
- }
- }
- } catch (Exception e) {
- Activator.log(e);
- }
-
- try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e) {
- Activator.log(e);
- } catch (IllegalArgumentException e){
- Activator.log(e);
- }
-
- return null;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean isHandled() {
- return true;
- }
-
- @Override
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
-
- public static void copyFile(File source, File dest) throws IOException {
- byte[] bytes = new byte[4092];
- if (source != null && dest != null) {
- if (source.isFile()) {
- FileInputStream in = null;
- FileOutputStream out = null;
- try {
- in = new FileInputStream(source);
- out = new FileOutputStream(dest);
- int len;
- while ((len = in.read(bytes)) != -1) {
- out.write(bytes, 0, len);
- }
- } catch (Exception e) {
- System.err.println("Error: " + e.toString());
- Activator.log(e);
- } finally {
- try {
- if (in != null)
- in.close();
- } finally {
- if (out != null)
- out.close();
- }
- }
- }
- }
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import com.intel.sgx.Activator;
+import com.intel.sgx.dialogs.RemoveEnclaveFileDialog;
+
+public class RemoveEnclave implements IHandler {
+
+ public String edlFilename = "";
+ private IPath edlCanonicalFilename;
+
+ @Override
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ String edlBasename;
+ IProject project = null;
+
+ // Display display = Display.getCurrent();
+ // Shell shell = new Shell(display);
+
+ RemoveEnclaveFileDialog dialog = new RemoveEnclaveFileDialog(null, this);
+
+ if (dialog.open() != InputDialog.OK) {
+ return null;
+ }
+
+ edlCanonicalFilename = Path.fromOSString(edlFilename);
+ edlBasename = edlCanonicalFilename.lastSegment();
+
+ if(edlBasename.isEmpty()){
+ return null;
+ }
+
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ Object element = null;
+ if(selection instanceof IStructuredSelection) {
+ element = ((IStructuredSelection)selection).getFirstElement();
+ if (element instanceof IResource) {
+ project= ((IResource)element).getProject();
+ }
+ }
+ if (!project.exists()) {
+ System.err.println("Error: Project not found");
+ return null;
+ }
+
+ IPath targetRelPath = project.getProjectRelativePath().append("sgx").append("enclave_" + edlBasename);
+
+ try {
+ for (int i=1;i<=targetRelPath.segmentCount();i++) {
+ IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i));
+
+ if (subfolder.exists()){
+ if(subfolder.getProjectRelativePath().toOSString().contains("enclave_"+edlBasename)){
+ subfolder.delete(true, true, null);
+ break;
+ }
+ }
+ }
+ targetRelPath = project.getProjectRelativePath().append("sgx").append(edlBasename);
+ for (int i=1;i<=targetRelPath.segmentCount();i++) {
+ IFolder subfolder = project.getFolder(targetRelPath.uptoSegment(i));
+
+ if (subfolder.exists()){
+ if(subfolder.getProjectRelativePath().toOSString().contains(edlBasename)){
+ subfolder.delete(true, true, null);
+ break;
+ }
+ }
+ }
+ } catch (Exception e) {
+ Activator.log(e);
+ }
+
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ Activator.log(e);
+ } catch (IllegalArgumentException e){
+ Activator.log(e);
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ @Override
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ public static void copyFile(File source, File dest) throws IOException {
+ byte[] bytes = new byte[4092];
+ if (source != null && dest != null) {
+ if (source.isFile()) {
+ FileInputStream in = null;
+ FileOutputStream out = null;
+ try {
+ in = new FileInputStream(source);
+ out = new FileOutputStream(dest);
+ int len;
+ while ((len = in.read(bytes)) != -1) {
+ out.write(bytes, 0, len);
+ }
+ } catch (Exception e) {
+ System.err.println("Error: " + e.toString());
+ Activator.log(e);
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } finally {
+ if (out != null)
+ out.close();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java
index b445c5ea8a..7fe93db380 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/SGXSDKWizardHandler.java
@@ -1,38 +1,38 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.ui.wizards.STDWizardHandler;
-
-public class SGXSDKWizardHandler extends STDWizardHandler {
-
- public SGXSDKWizardHandler() {
- super(null, null);
- }
-
-
- @Override
- public IToolChain[] getSelectedToolChains() {
- IToolChain[] tcs = ManagedBuildManager.getRealToolChains();
- for (IToolChain tc : tcs) {
- if (tc.getId().equals("com.intel.sgx.SGXtoolChain"))
- return new IToolChain[] {
- tc
- };
- }
- return super.getSelectedToolChains();
- }
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.ui.wizards.STDWizardHandler;
+
+public class SGXSDKWizardHandler extends STDWizardHandler {
+
+ public SGXSDKWizardHandler() {
+ super(null, null);
+ }
+
+
+ @Override
+ public IToolChain[] getSelectedToolChains() {
+ IToolChain[] tcs = ManagedBuildManager.getRealToolChains();
+ for (IToolChain tc : tcs) {
+ if (tc.getId().equals("com.intel.sgx.SGXtoolChain"))
+ return new IToolChain[] {
+ tc
+ };
+ }
+ return super.getSelectedToolChains();
+ }
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java
index cb2f3649bd..bd63c3818b 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep1.java
@@ -1,74 +1,74 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import org.eclipse.jface.dialogs.InputDialog;
-
-import com.intel.sgx.dialogs.SGXDialogBase;
-import com.intel.sgx.dialogs.TwoStepSignStep1Dialog1;
-import com.intel.sgx.dialogs.TwoStepSignStep1Dialog2;
-import com.intel.sgx.dialogs.TwoStepSignStep1Dialog3;
-
-// Generate Hash
-public class TwoStepSignStep1 extends TwoStepSignHandlerBase {
-
- public TwoStepSignStep1() {
- }
-
- @Override
- protected Object executeSGXStuff() throws ErrorException, CancelException {
-
- initializeSigntool();
-
- showDialog1();
- showDialog2();
- showDialog3();
- return null;
- }
-
- private void showDialog1() throws CancelException, ErrorException {
-
- TwoStepSignStep1Dialog1 dialog1 = new TwoStepSignStep1Dialog1(shell, this);
- if (dialog1.open() != InputDialog.OK) {
- cancel();
- }
-
- executeGenData();
-
- }
-
- private void showDialog2() throws CancelException {
- TwoStepSignStep1Dialog2 dialog2 = new TwoStepSignStep1Dialog2(shell,
- hashFile);
-
- if (dialog2.open() != InputDialog.OK) {
- cancel();
- }
- }
-
- protected void showDialog3() throws CancelException, ErrorException {
- SGXDialogBase dialog3 = new TwoStepSignStep1Dialog3(shell, this);
- if (dialog3.open() != InputDialog.OK) {
- cancel();
- }
-
- validateExternalSignPublicKeyFile();
-
- validateExternallySignedHashFile();
-
- executeCatSig();
-
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import org.eclipse.jface.dialogs.InputDialog;
+
+import com.intel.sgx.dialogs.SGXDialogBase;
+import com.intel.sgx.dialogs.TwoStepSignStep1Dialog1;
+import com.intel.sgx.dialogs.TwoStepSignStep1Dialog2;
+import com.intel.sgx.dialogs.TwoStepSignStep1Dialog3;
+
+// Generate Hash
+public class TwoStepSignStep1 extends TwoStepSignHandlerBase {
+
+ public TwoStepSignStep1() {
+ }
+
+ @Override
+ protected Object executeSGXStuff() throws ErrorException, CancelException {
+
+ initializeSigntool();
+
+ showDialog1();
+ showDialog2();
+ showDialog3();
+ return null;
+ }
+
+ private void showDialog1() throws CancelException, ErrorException {
+
+ TwoStepSignStep1Dialog1 dialog1 = new TwoStepSignStep1Dialog1(shell, this);
+ if (dialog1.open() != InputDialog.OK) {
+ cancel();
+ }
+
+ executeGenData();
+
+ }
+
+ private void showDialog2() throws CancelException {
+ TwoStepSignStep1Dialog2 dialog2 = new TwoStepSignStep1Dialog2(shell,
+ hashFile);
+
+ if (dialog2.open() != InputDialog.OK) {
+ cancel();
+ }
+ }
+
+ protected void showDialog3() throws CancelException, ErrorException {
+ SGXDialogBase dialog3 = new TwoStepSignStep1Dialog3(shell, this);
+ if (dialog3.open() != InputDialog.OK) {
+ cancel();
+ }
+
+ validateExternalSignPublicKeyFile();
+
+ validateExternallySignedHashFile();
+
+ executeCatSig();
+
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java
index f19738036c..08fe8b68bf 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/src/com/intel/sgx/handlers/TwoStepSignStep2.java
@@ -1,39 +1,39 @@
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
-
-
-package com.intel.sgx.handlers;
-
-import org.eclipse.jface.dialogs.InputDialog;
-
-import com.intel.sgx.dialogs.TwoStepSignStep2Dialog;
-
-// Sign
-public class TwoStepSignStep2 extends TwoStepSignHandlerBase {
-
- public TwoStepSignStep2() {
- }
-
- @Override
- protected Object executeSGXStuff() throws ErrorException, CancelException {
- initializeSigntool();
-
- TwoStepSignStep2Dialog dialog = new TwoStepSignStep2Dialog(shell, this);
- if(dialog.open() != InputDialog.OK) {
- cancel();
- }
-
- executeCatSig();
- return null;
- }
-
-}
+///////////////////////////////////////////////////////////////////////////
+// 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 //
+///////////////////////////////////////////////////////////////////////////
+
+
+package com.intel.sgx.handlers;
+
+import org.eclipse.jface.dialogs.InputDialog;
+
+import com.intel.sgx.dialogs.TwoStepSignStep2Dialog;
+
+// Sign
+public class TwoStepSignStep2 extends TwoStepSignHandlerBase {
+
+ public TwoStepSignStep2() {
+ }
+
+ @Override
+ protected Object executeSGXStuff() throws ErrorException, CancelException {
+ initializeSigntool();
+
+ TwoStepSignStep2Dialog dialog = new TwoStepSignStep2Dialog(shell, this);
+ if(dialog.open() != InputDialog.OK) {
+ cancel();
+ }
+
+ executeCatSig();
+ return null;
+ }
+
+}
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml
index ed5cbba697..5f36a93377 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/ctemplate.xml
@@ -1,83 +1,83 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml
index 8ad900de61..0f657a5fd3 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxstaticlibtemplate.xml
@@ -1,109 +1,109 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml
index a07ed1479c..c8c0ce106f 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/SGXtemplates/cxxtemplate.xml
@@ -1,44 +1,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml
index 6210afff28..0325b1601f 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/resources/Basename.config.xml
@@ -1,9 +1,9 @@
-
- $(ProdID)
- $(IsvSvn)
- $(ThreadStackSize)
- $(GlobalHeapSize)
- $(TcsNumber)
- $(TcsPolicy)
- $(DisableDebug)
-
+
+ $(ProdID)
+ $(IsvSvn)
+ $(ThreadStackSize)
+ $(GlobalHeapSize)
+ $(TcsNumber)
+ $(TcsPolicy)
+ $(DisableDebug)
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/sites/site.xml b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/sites/site.xml
index 7fc74459bc..2883e3e2ed 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/sites/site.xml
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/build_directory/sites/site.xml
@@ -1,23 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- This website hosts an evaluation version of the Eclipse Plug-in developed for Secure Guard Extensions Application development for Linux platforms.
-
-
-
-
-
- Intel(R) SGX Eclipse Plugin 1.0.1.qualifier
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This website hosts an evaluation version of the Eclipse Plug-in developed for Secure Guard Extensions Application development for Linux platforms.
+
+
+
+
+
+ Intel(R) SGX Eclipse Plugin 1.0.1.qualifier
+
+
diff --git a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/readme.txt b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/readme.txt
index 244c4a5a14..a767f8ca32 100644
--- a/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/readme.txt
+++ b/sgx-jvm/linux-sgx/Linux_SGXEclipsePlugin/readme.txt
@@ -1,22 +1,22 @@
-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 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 Intel(R) Software Guard Extensions (Intel(R) 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
-
-The plugin has been tested with the following Eclipse ADT version
-
-Build: v22.3.0-887826
+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 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 Intel(R) Software Guard Extensions (Intel(R) 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
+
+The plugin has been tested with the following Eclipse ADT version
+
+Build: v22.3.0-887826
diff --git a/sgx-jvm/linux-sgx/README.md b/sgx-jvm/linux-sgx/README.md
index a6d275aa13..948d0f5104 100644
--- a/sgx-jvm/linux-sgx/README.md
+++ b/sgx-jvm/linux-sgx/README.md
@@ -11,8 +11,6 @@ The Linux\* Intel(R) SGX software stack is comprised of the Intel(R) SGX driver,
The [linux-sgx-driver](https://github.com/01org/linux-sgx-driver) project hosts the out-of-tree driver for the Linux\* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete.
-**Note** This repository includes a subset of the Intel(R) Integrated Performance Primitives (IPP) Cryptography library under [external/crypto_px](external/crypto_px). It is provided as reference implementation for the cryptographic primitives used in SDK and PSW. The primitives are written in pure C and are not optimized for performance. Instructions are provided below for building the SDK and PSW with both precompiled optimized IPP binaries and the non-optimized source code version.
-
License
-------
See [License.txt](License.txt) for details.
@@ -30,12 +28,14 @@ Build and Install the Intel(R) SGX Driver
-----------------------------------------
Follow the instructions in the [linux-sgx-driver](https://github.com/01org/linux-sgx-driver) project to build and install the Intel(R) SGX driver.
+**Note:** **SGX 2.0** feature support in the SDK and PSW depends on processor and driver support for the SGX 2.0 instruction set. Please consult the README in the driver for instructions on building the SGX 2.0 Linux Driver. Upcoming CPU releases will include hardware support for SGX 2.0.
+
Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
-------------------------------------------------------
### Prerequisites:
- Ensure that you have one of the following required operating systems:
* Ubuntu\* Desktop-16.04-LTS 64bits
- * Red Hat Enterprise Linux Server release 7.3 64bits
+ * Red Hat Enterprise Linux Server release 7.4 64bits
* CentOS 7.3.1611 64bits
- Use the following command(s) to install the required tools to build the Intel(R) SGX SDK:
@@ -43,7 +43,7 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
```
$ sudo apt-get install build-essential ocaml automake autoconf libtool wget python
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
$ sudo yum groupinstall 'Development Tools'
$ sudo yum install ocaml wget python
@@ -53,9 +53,9 @@ Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package
```
$ sudo apt-get install libssl-dev libcurl4-openssl-dev protobuf-compiler libprotobuf-dev
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
- $ sudo yum install openssl-devel libcurl-devel protobuf-compiler protobuf-devel
+ $ sudo yum install openssl-devel libcurl-devel protobuf-devel
```
- Use the script ``download_prebuilt.sh`` inside source code package to download prebuilt binaries to prebuilt folder
You may need set an https proxy for the `wget` tool used by the script (such as ``export https_proxy=http://test-proxy:test-port``)
@@ -72,11 +72,14 @@ The following steps describe how to build the Intel(R) SGX SDK and PSW. You can
You can find the tools and libraries generated in the `build/linux` directory.
**Note**: You can also go to the `sdk` folder and use the `make` command to build the Intel(R) SGX SDK component only. However, building the PSW component is dependent on the result of building the Intel(R) SGX SDK.
-- The default build uses precompiled optimized libraries, which are downloaded by the script ``./download_prebuilt.sh``.
- You can also use the non-optimized source code version implementation instead by entering the following command:
+- This repository supports to build the Intel(R) SGX SDK based on either precompiled optimized IPP/string/math libraries or open sourced version of SGXSSL/string/math libraries.
+ The default build uses precompiled optimized libraries, which are downloaded by the script ``./download_prebuilt.sh``.
+ You can also use the open sourced version implementation instead by entering the following command:
```
$ make USE_OPT_LIBS=0
```
+ **Note**: Building the Intel(R) SGX PSW with open sourced SGXSSL/string/math libraries is not supported. The above command builds Intel(R) SGX SDK only and the build of PSW part will be skipped.
+
- To build Intel(R) SGX SDK and PSW with debug information, enter the following command:
```
$ make DEBUG=1
@@ -123,14 +126,14 @@ Install the Intel(R) SGX SDK
### Prerequisites
- Ensure that you have one of the following operating systems:
* Ubuntu\* Desktop-16.04-LTS 64bits
- * Red Hat Enterprise Linux Server release 7.3 64bits
+ * Red Hat Enterprise Linux Server release 7.4 64bits
* CentOS 7.3.1611 64bits
- Use the following command to install the required tool to use Intel(R) SGX SDK:
* On Ubuntu 16.04:
```
$ sudo apt-get install build-essential python
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
$ sudo yum groupinstall 'Development Tools'
$ sudo yum install python
@@ -142,6 +145,10 @@ To install the Intel(R) SGX SDK, invoke the installer, as follows:
$ cd linux/installer/bin
$ ./sgx_linux_x64_sdk_${version}.bin
```
+NOTE: You need to set up the needed environment variables before compiling your code. To do so, run:
+```
+ $ source ${sgx-sdk-install-path}/environment
+```
### Test the Intel(R) SGX SDK Package with the Code Samples
- Compile and run each code sample in Simulation mode to make sure the package works well:
```
@@ -150,26 +157,26 @@ $ ./sgx_linux_x64_sdk_${version}.bin
$ ./app
```
Use similar commands for other sample codes.
+
### Compile and Run the Code Samples in the Hardware Mode
If you use an Intel SGX hardware enabled machine, you can run the code samples in Hardware mode.
Ensure that you install Intel(R) SGX driver and Intel(R) SGX PSW installer on the machine.
See the earlier topic, *Build and Install the Intel(R) SGX Driver*, for information on how to install the Intel(R) SGX driver.
See the later topic, *Install Intel(R) SGX PSW*, for information on how to install the PSW package.
-- Compile and run each code sample in Hardware mode, debug build, as follows:
+- Compile and run each code sample in Hardware mode, Debug build, as follows:
```
$ cd SampleCode/LocalAttestation
$ make
$ ./app
```
- Use similar commands for other code samples.
-
+ Use similar commands for other code samples.
Install the Intel(R) SGX PSW
-------------------------
+----------------------------
### Prerequisites
- Ensure that you have one of the following operating systems:
* Ubuntu\* Desktop-16.04-LTS 64bits
- * Red Hat Enterprise Linux Server release 7.3 64bits
+ * Red Hat Enterprise Linux Server release 7.4 64bits
* CentOS 7.3.1611 64bits
- Ensure that you have a system with the following required hardware:
* 6th Generation Intel(R) Core(TM) Processor or newer
@@ -180,7 +187,7 @@ Install the Intel(R) SGX PSW
```
$ sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
$ sudo yum install openssl-devel libcurl-devel protobuf-devel
```
@@ -193,7 +200,7 @@ Install the Intel(R) SGX PSW
$ sudo alien --scripts iclsClient-1.45.449.12-1.x86_64.rpm
$ sudo dpkg -i iclsclient_1.45.449.12-2_amd64.deb
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
$ sudo yum install iclsClient-1.45.449.12-1.x86_64.rpm
```
@@ -203,7 +210,7 @@ Install the Intel(R) SGX PSW
$ sudo apt-get install uuid-dev libxml2-dev cmake pkg-config
$ cmake .;make;sudo make install;sudo systemctl enable jhi
```
- * On Red Hat Enterprise Linux 7.3 and CentOS 7.3:
+ * On Red Hat Enterprise Linux 7.4 and CentOS 7.3:
```
$ sudo yum install libuuid-devel libxml2-devel cmake pkgconfig
$ cmake .;make;sudo make install;sudo ldconfig;sudo systemctl enable jhi
diff --git a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/Enclave.edl b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/Enclave.edl
index f6a4376644..b3de60cd9c 100644
--- a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/Enclave.edl
+++ b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/Enclave.edl
@@ -41,7 +41,7 @@ enclave {
*/
from "TrustedLibrary/Libcxx.edl" import *;
- from "sgx_tstdc.edl" import sgx_thread_wait_untrusted_event_ocall, sgx_thread_set_untrusted_event_ocall, sgx_thread_setwait_untrusted_events_ocall, sgx_thread_set_multiple_untrusted_events_ocall;
+ from "sgx_tstdc.edl" import *;
/*
* ocall_print_string - invokes OCALL to display string buffer inside the enclave.
diff --git a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/TrustedLibrary/Libcxx.cpp b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/TrustedLibrary/Libcxx.cpp
index 781feef33c..0059adc846 100644
--- a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/TrustedLibrary/Libcxx.cpp
+++ b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/Enclave/TrustedLibrary/Libcxx.cpp
@@ -330,7 +330,7 @@ void ecall_cxx11_algorithms_demo()
printf("[cxx11_algorithms] Some elements in { 0 1 2 3 4 5 } are even is %s. \n", are_any_of ? "true" : "false");
bool are_none_of = none_of(begin(v), end(v), [](int e) { return e % 2 == 0; });
- printf("[cxx11_algorithms] Some elements in { 0 1 2 3 4 5 } are even is %s. \n", are_none_of ? "true" : "false");
+ printf("[cxx11_algorithms] None elements in { 0 1 2 3 4 5 } are even is %s. \n", are_none_of ? "true" : "false");
printf("\n"); // end of demo
}
@@ -594,10 +594,10 @@ void ecall_new_container_classes_demo()
const int searchVal = 3;
std::unordered_set::const_iterator got = set_of_numbers.find(searchVal);
- if (got == set_of_numbers.end())
+ if (got != set_of_numbers.end())
printf("[new_container_classes] unordered_set { 0, 1, 2, 3, 4, 5} has value 3.\n");
else
- printf("[new_container_classes] unordered_set { 0, 1, 2, 3, 4, 5} it does not have value 3.\n");
+ printf("[new_container_classes] unordered_set { 0, 1, 2, 3, 4, 5} does not have value 3.\n");
// unordered_multiset
// container used for fast acces that groups non unique elements in buckets based on their hash
diff --git a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/README.txt b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/README.txt
index 30a7f1795a..0acdaee937 100644
--- a/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/Cxx11SGXDemo/README.txt
@@ -26,7 +26,9 @@ The project demonstrates serveral C++11 features inside the Enclave:
How to Build/Execute the C++11 sample program
---------------------------------------------
1. Install Intel(R) Software Guard Extensions (Intel(R) SGX) SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -39,6 +41,6 @@ How to Build/Execute the C++11 sample program
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
diff --git a/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/App/App.cpp b/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/App/App.cpp
index 329e9c1628..a80ce7607e 100644
--- a/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/App/App.cpp
+++ b/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/App/App.cpp
@@ -118,7 +118,7 @@ int _tmain(int argc, _TCHAR* argv[])
printf("\nLoad Enclave Failure");
}
- printf("\nAvaliable Enclaves");
+ printf("\nAvailable Enclaves");
printf("\nEnclave1 - EnclaveID %" PRIx64, e1_enclave_id);
printf("\nEnclave2 - EnclaveID %" PRIx64, e2_enclave_id);
printf("\nEnclave3 - EnclaveID %" PRIx64, e3_enclave_id);
diff --git a/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/README.txt b/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/README.txt
index 9c9d97d7b4..6117cee435 100644
--- a/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/LocalAttestation/README.txt
@@ -9,7 +9,9 @@ The project demonstrates:
How to Build/Execute the Sample Code
------------------------------------
1. Install Intel(R) Software Guard Extensions (Intel(R) SGX) SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -22,6 +24,6 @@ How to Build/Execute the Sample Code
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
diff --git a/sgx-jvm/linux-sgx/SampleCode/PowerTransition/Makefile b/sgx-jvm/linux-sgx/SampleCode/PowerTransition/Makefile
index ab392221d6..ca977307f0 100644
--- a/sgx-jvm/linux-sgx/SampleCode/PowerTransition/Makefile
+++ b/sgx-jvm/linux-sgx/SampleCode/PowerTransition/Makefile
@@ -90,7 +90,7 @@ else
App_Compile_CFlags += -DNDEBUG -UEDEBUG -UDEBUG
endif
-App_Compile_CXXFlags := -std=c++0x $(App_Compile_CFlags)
+App_Compile_CXXFlags := -std=c++11 $(App_Compile_CFlags)
App_Link_Flags := -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name) -lpthread
ifneq ($(SGX_MODE), HW)
diff --git a/sgx-jvm/linux-sgx/SampleCode/PowerTransition/README.txt b/sgx-jvm/linux-sgx/SampleCode/PowerTransition/README.txt
index 0f9e256bed..fe2c4b93ca 100644
--- a/sgx-jvm/linux-sgx/SampleCode/PowerTransition/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/PowerTransition/README.txt
@@ -8,7 +8,9 @@ Software Guard Extensions projects development.
How to Build/Execute the Sample Code
------------------------------------
1. Install Intel(R) Software Guard Extensions (Intel(R) SGX) SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -21,6 +23,6 @@ How to Build/Execute the Sample Code
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
diff --git a/sgx-jvm/linux-sgx/SampleCode/RemoteAttestation/README.txt b/sgx-jvm/linux-sgx/SampleCode/RemoteAttestation/README.txt
index d6f5cb5d6a..c39090047a 100644
--- a/sgx-jvm/linux-sgx/SampleCode/RemoteAttestation/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/RemoteAttestation/README.txt
@@ -9,7 +9,9 @@ The project demonstrates:
How to Build/Execute the Sample Code
------------------------------------
1. Install Intel(R) Software Guard Extensions (Intel(R) SGX) SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -22,6 +24,6 @@ How to Build/Execute the Sample Code
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/App.cpp b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/App.cpp
index b0ecd6152b..30723b697d 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/App.cpp
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/App.cpp
@@ -146,7 +146,7 @@ void print_error_message(sgx_status_t ret)
}
if (idx == ttl)
- printf("Error: Unexpected error occurred.\n");
+ printf("Error code is 0x%X. Please refer to the \"Intel SGX SDK Developer Reference\" for more details.\n", ret);
}
/* Initialize the enclave:
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp
index 749e8d4aa1..85c26cd7ef 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/App/TrustedLibrary/Libc.cpp
@@ -44,7 +44,7 @@ void ecall_libc_functions(void)
if (ret != SGX_SUCCESS)
abort();
- int cpuid[4] = {0x1, 0x0, 0x0, 0x0};
+ int cpuid[4] = {0x0, 0x0, 0x0, 0x0};
ret = ecall_sgx_cpuid(global_eid, cpuid, 0x0);
if (ret != SGX_SUCCESS)
abort();
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl
index 6b5aa3e6c9..eff2f53ae5 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/TrustedLibrary/Libc.edl
@@ -50,6 +50,6 @@ enclave {
/*
* Utilize SGX version __cpuid() in enclave.
*/
- public void ecall_sgx_cpuid([in, out] int cpuinfo[4], int leaf);
+ public void ecall_sgx_cpuid([out] int cpuinfo[4], int leaf);
};
};
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.01.xml b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.01.xml
new file mode 100644
index 0000000000..ca652963fc
--- /dev/null
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.01.xml
@@ -0,0 +1,28 @@
+
+ 0
+ 0
+
+
+
+
+ 10
+ 10
+ 10
+
+ 1
+
+
+ 0x40000
+
+
+
+ 0x100000
+ 0x100000
+ 0x100000
+
+
+ 0
+ 0
+ 0xFFFFFFFF
+
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.02.xml b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.02.xml
new file mode 100644
index 0000000000..126eac07b5
--- /dev/null
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.02.xml
@@ -0,0 +1,25 @@
+
+ 0
+ 0
+ 0x40000
+
+
+ 0x100000
+ 0x40000
+ 0x1000
+
+ 10
+ 10
+ 10
+ 1
+
+ 0
+ 0
+ 0xFFFFFFFF
+
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.03.xml b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.03.xml
new file mode 100644
index 0000000000..ef642799b2
--- /dev/null
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.03.xml
@@ -0,0 +1,27 @@
+
+ 0
+ 0
+
+
+ 10
+ 3
+ 1
+
+
+
+ 0x40000
+ 0x40000
+
+
+
+ 0x100000
+
+
+ 0
+ 0
+ 0xFFFFFFFF
+
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.04.xml b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.04.xml
new file mode 100644
index 0000000000..a72d611b57
--- /dev/null
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/Enclave/config.04.xml
@@ -0,0 +1,23 @@
+
+ 0
+ 0
+
+ 10
+ 3
+ 1
+
+
+
+ 0x40000
+ 0x2000
+
+ 0x100000
+
+
+ 0
+ 0
+ 0xFFFFFFFF
+
diff --git a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/README.txt b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/README.txt
index cd601fa16b..055a950c0c 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/SampleEnclave/README.txt
@@ -11,7 +11,9 @@ Extensions (Intel(R) SGX) SDK:
How to Build/Execute the Sample Code
------------------------------------
1. Install Intel(R) SGX SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -24,7 +26,44 @@ How to Build/Execute the Sample Code
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
+------------------------------------------
+Explanation about Configuration Parameters
+------------------------------------------
+TCSMaxNum, TCSNum, TCSMinPool
+
+ These three parameters will determine whether a thread will be created
+ dynamically when there is no available thread to do the work.
+
+
+StackMaxSize, StackMinSize
+
+ For a dynamically created thread, StackMinSize is the amount of stack available
+ once the thread is created and StackMaxSize is the total amount of stack that
+ thread can use. The gap between StackMinSize and StackMaxSize is the stack
+ dynamically expanded as necessary at runtime.
+
+ For a static thread, only StackMaxSize is relevant which specifies the total
+ amount of stack available to the thread.
+
+
+HeapMaxSize, HeapInitSize, HeapMinSize
+
+ HeapMinSize is the amount of heap available once the enclave is initialized.
+
+ HeapMaxSize is the total amount of heap an enclave can use. The gap between
+ HeapMinSize and HeapMaxSize is the heap dynamically expanded as necessary
+ at runtime.
+
+ HeapInitSize is here for compatibility.
+
+-------------------------------------------------
+Sample configuration files for the Sample Enclave
+-------------------------------------------------
+config.01.xml: There is no dynamic thread, no dynamic heap expansion.
+config.02.xml: There is no dynamic thread. But dynamic heap expansion can happen.
+config.03.xml: There are dynamic threads. For a dynamic thread, there's no stack expansion.
+config.04.xml: There are dynamic threads. For a dynamic thread, stack will expanded as necessary.
diff --git a/sgx-jvm/linux-sgx/SampleCode/SealedData/DRM_enclave/DRM_enclave.cpp b/sgx-jvm/linux-sgx/SampleCode/SealedData/DRM_enclave/DRM_enclave.cpp
index 3879a682df..042f1cde30 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SealedData/DRM_enclave/DRM_enclave.cpp
+++ b/sgx-jvm/linux-sgx/SampleCode/SealedData/DRM_enclave/DRM_enclave.cpp
@@ -114,11 +114,11 @@ static uint32_t verify_sealed_data(
break;
case SGX_ERROR_INVALID_ISVSVN:
/* Indicates isv_svn field of the sealed data is greater than
- the enclave’s ISVSVN. This is a downgraded enclave.*/
+ the enclave's ISVSVN. This is a downgraded enclave.*/
break;
case SGX_ERROR_INVALID_CPUSVN:
/* Indicates cpu_svn field of the sealed data is greater than
- the platform’s cpu_svn. enclave is on a downgraded platform.*/
+ the platform's cpu_svn. enclave is on a downgraded platform.*/
break;
case SGX_ERROR_INVALID_KEYNAME:
/*Indicates key_name field of the sealed data is incorrect.*/
@@ -504,11 +504,11 @@ uint32_t perform_time_based_policy(const uint8_t* sealed_log,
break;
case SGX_ERROR_INVALID_ISVSVN:
/* Indicates isv_svn field of the sealed data is greater than the
- enclave’s ISVSVN. This is a downgraded enclave.*/
+ enclave's ISVSVN. This is a downgraded enclave.*/
break;
case SGX_ERROR_INVALID_CPUSVN:
/* Indicates cpu_svn field of the sealed data is greater than the
- platform’s cpu_svn. enclave is on a downgraded platform.*/
+ platform's cpu_svn. enclave is on a downgraded platform.*/
break;
case SGX_ERROR_INVALID_KEYNAME:
/*Indicates key_name field of the sealed data is incorrect.*/
diff --git a/sgx-jvm/linux-sgx/SampleCode/SealedData/README.txt b/sgx-jvm/linux-sgx/SampleCode/SealedData/README.txt
index 7c1723dd3c..3a3a3c26b6 100644
--- a/sgx-jvm/linux-sgx/SampleCode/SealedData/README.txt
+++ b/sgx-jvm/linux-sgx/SampleCode/SealedData/README.txt
@@ -11,7 +11,9 @@ replay-protected policy, and Trusted Time to enforce time based policy
How to Build/Execute the Sample Code
------------------------------------
1. Install Intel(R) Software Guard Extensions (Intel(R) SGX) SDK for Linux* OS
-2. Build the project with the prepared Makefile:
+2. Make sure your environment is set:
+ $ source ${sgx-sdk-install-path}/environment
+3. Build the project with the prepared Makefile:
a. Hardware Mode, Debug build:
$ make
b. Hardware Mode, Pre-release build:
@@ -24,6 +26,6 @@ How to Build/Execute the Sample Code
$ make SGX_MODE=SIM SGX_PRERELEASE=1 SGX_DEBUG=0
f. Simulation Mode, Release build:
$ make SGX_MODE=SIM SGX_DEBUG=0
-3. Execute the binary directly:
+4. Execute the binary directly:
$ ./app
-4. Remember to "make clean" before switching build mode
+5. Remember to "make clean" before switching build mode
diff --git a/sgx-jvm/linux-sgx/buildenv.mk b/sgx-jvm/linux-sgx/buildenv.mk
index dacbcb2244..759c07ac55 100644
--- a/sgx-jvm/linux-sgx/buildenv.mk
+++ b/sgx-jvm/linux-sgx/buildenv.mk
@@ -75,10 +75,10 @@ else
endif
ifdef DEBUG
- COMMON_FLAGS += -ggdb -DDEBUG -UNDEBUG
+ COMMON_FLAGS += -O0 -ggdb -DDEBUG -UNDEBUG
COMMON_FLAGS += -DSE_DEBUG_LEVEL=SE_TRACE_DEBUG
else
- COMMON_FLAGS += -O2 -UDEBUG -DNDEBUG
+ COMMON_FLAGS += -O2 -D_FORTIFY_SOURCE=2 -UDEBUG -DNDEBUG
endif
ifdef SE_SIM
@@ -99,13 +99,7 @@ CFLAGS += -Wjump-misses-init -Wstrict-prototypes -Wunsuffixed-float-constants
# additional warnings flags for C++
CXXFLAGS += -Wnon-virtual-dtor
-# for static_assert()
-CXXFLAGS += -std=c++0x
-
-# Disable cxx11 abi
-CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0
-
-CXXFLAGS += $(EXTRA_CXXFLAGS)
+CXXFLAGS += -std=c++11
.DEFAULT_GOAL := all
# this turns off the RCS / SCCS implicit rules of GNU Make
@@ -153,6 +147,9 @@ endif
CFLAGS += $(COMMON_FLAGS)
CXXFLAGS += $(COMMON_FLAGS)
+# Enable the security flags
+COMMON_LDFLAGS := -Wl,-z,relro,-z,now,-z,noexecstack
+
# Compiler and linker options for an Enclave
#
# We are using '--export-dynamic' so that `g_global_data_sim' etc.
@@ -163,31 +160,25 @@ CXXFLAGS += $(COMMON_FLAGS)
# as `global' in the LD version script.
ENCLAVE_CFLAGS = -ffreestanding -nostdinc -fvisibility=hidden -fpie
ENCLAVE_CXXFLAGS = $(ENCLAVE_CFLAGS) -nostdinc++
-ENCLAVE_LDFLAGS = -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
+ENCLAVE_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
-Wl,--defsym,__ImageBase=0
# Choose to use the optimized libraries (IPP/String/Math) by default.
-# Users could also use the non-optimized source code version by
+# Users could also use the source code version (SGXSSL/String/Math) by
# explicitly specifying 'USE_OPT_LIBS=0'
USE_OPT_LIBS ?= 1
+
ifeq ($(ARCH), x86_64)
IPP_SUBDIR = intel64
else
IPP_SUBDIR = ia32
endif
-ifneq ($(USE_OPT_LIBS), 0)
- SGX_IPP_DIR := $(ROOT_DIR)/external/ippcp_internal
- SGX_IPP_INC := $(SGX_IPP_DIR)/inc
- IPP_LIBS_DIR := $(SGX_IPP_DIR)/lib/linux/$(IPP_SUBDIR)
- LD_IPP := -lippcp -lippcore
-else
- SGX_IPP_DIR := $(ROOT_DIR)/external/crypto_px
- SGX_IPP_INC := $(SGX_IPP_DIR)/include
- IPP_LIBS_DIR := $(SGX_IPP_DIR)
- LD_IPP := -lcrypto_px
-endif
+SGX_IPP_DIR := $(ROOT_DIR)/external/ippcp_internal
+SGX_IPP_INC := $(SGX_IPP_DIR)/inc
+IPP_LIBS_DIR := $(SGX_IPP_DIR)/lib/linux/$(IPP_SUBDIR)
+LD_IPP := -lippcp -lippcore
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/arch.h b/sgx-jvm/linux-sgx/common/inc/internal/arch.h
index 1b2cb2a2dd..bb372f2663 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/arch.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/arch.h
@@ -158,6 +158,10 @@ typedef uint64_t si_flags_t;
#define SI_FLAG_SECS (0x00<
+#include "sgx_report.h"
+#include "sgx_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+sgx_status_t sgx_EVP_Digest(const EVP_MD *type, const uint8_t *p_src, unsigned int src_len, uint8_t *digest, unsigned int *digest_len);
+sgx_status_t sgx_cmac128_msg(const sgx_key_128bit_t key, const uint8_t *p_src, unsigned int src_len, sgx_mac_t *p_mac);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/enclave_creator.h b/sgx-jvm/linux-sgx/common/inc/internal/enclave_creator.h
index 3cc5c6371c..6a01c86340 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/enclave_creator.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/enclave_creator.h
@@ -49,6 +49,8 @@
#include "uncopyable.h"
#include
#include "file.h"
+#include "isgx_user.h"
+
// this is the interface to both hardware, simulation and signing mode
class EnclaveCreator : private Uncopyable
@@ -68,12 +70,19 @@ public:
virtual int destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t enclave_size = 0) = 0;
virtual int initialize(sgx_enclave_id_t enclave_id) = 0;
virtual bool use_se_hw() const = 0;
+ virtual bool is_EDMM_supported(sgx_enclave_id_t enclave_id) = 0;
+ virtual bool is_driver_compatible() = 0;
virtual int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag) = 0;
virtual bool get_plat_cap(sgx_misc_attribute_t *se_attr) = 0;
#ifdef SE_1P5_VERTICAL
virtual uint32_t handle_page_fault(uint64_t pf_address) { UNUSED(pf_address); return (uint32_t)SGX_ERROR_UNEXPECTED; }
#endif
+ virtual int emodpr(uint64_t addr, uint64_t size, uint64_t flag) = 0;
+ virtual int mktcs(uint64_t tcs_addr) = 0;
+ virtual int trim_range(uint64_t fromaddr, uint64_t toaddr) = 0;
+ virtual int trim_accept(uint64_t addr) = 0;
+ virtual int remove_range(uint64_t fromaddr, uint64_t numpages) = 0;
// destructor
virtual ~EnclaveCreator() {};
};
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/global_data.h b/sgx-jvm/linux-sgx/common/inc/internal/global_data.h
index cdebf487e4..fa9f6d4a0e 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/global_data.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/global_data.h
@@ -41,15 +41,21 @@
#include "se_types.h"
#include "thread_data.h"
+#include "metadata.h"
+#include "rts.h"
+#define LAYOUT_ENTRY_NUM 38
typedef struct _global_data_t
{
sys_word_t enclave_size;
sys_word_t heap_offset;
sys_word_t heap_size;
- uint32_t thread_policy;
- uint32_t reserved;
+ sys_word_t thread_policy;
thread_data_t td_template;
+ uint8_t tcs_template[TCS_TEMPLATE_SIZE];
+ uint32_t layout_entry_num;
+ uint32_t reserved;
+ layout_t layout_table[LAYOUT_ENTRY_NUM];
} global_data_t;
#define ENCLAVE_INIT_NOT_STARTED 0
@@ -62,7 +68,11 @@ extern "C" {
#endif
extern SE_DECLSPEC_EXPORT global_data_t const volatile g_global_data;
extern uint32_t g_enclave_state;
+extern sdk_version_t g_sdk_version;
+extern int EDMM_supported;
extern uint8_t __ImageBase;
+extern int g_xsave_enabled;
+
#ifdef __cplusplus
}
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/global_init.h b/sgx-jvm/linux-sgx/common/inc/internal/global_init.h
index 5bee7de52d..783daf20ce 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/global_init.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/global_init.h
@@ -40,6 +40,7 @@ extern "C" {
#endif
void init_global_object(void);
+void uninit_global_object(void);
#ifdef __cplusplus
}
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/inst.h b/sgx-jvm/linux-sgx/common/inc/internal/inst.h
index d5af1200d4..5f406141b4 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/inst.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/inst.h
@@ -45,6 +45,7 @@ typedef enum {
SE_EENTER,
SE_ERESUME,
SE_EEXIT,
+ SE_EACCEPT,
SE_LAST_RING3,
SE_ECREATE = 0x0,
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/linux/linux-regs.h b/sgx-jvm/linux-sgx/common/inc/internal/linux/linux-regs.h
index b7396f389e..befc4283a7 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/linux/linux-regs.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/linux/linux-regs.h
@@ -85,6 +85,9 @@
#define SE_EGETKEY 1
#define SE_EENTER 2
#define SE_EEXIT 4
+#define SE_EACCEPT 5
+#define SE_EMODPE 6
+
#define SE_ECREATE 0
#define SE_EADD 1
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/metadata.h b/sgx-jvm/linux-sgx/common/inc/internal/metadata.h
index 8fa482563e..9a25cabc10 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/metadata.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/metadata.h
@@ -37,16 +37,22 @@
#pragma pack(1)
/* version of metadata */
-#define MAJOR_VERSION 1 /* MAJOR_VERSION should not larger than 0ffffffff */
-#define MINOR_VERSION 4 /* MINOR_VERSION should not larger than 0ffffffff */
+#define MAJOR_VERSION 2 //MAJOR_VERSION should not larger than 0ffffffff
+#define MINOR_VERSION 1 //MINOR_VERSION should not larger than 0ffffffff
+
+#define SGX_1_9_MAJOR_VERSION 1 //MAJOR_VERSION should not larger than 0ffffffff
+#define SGX_1_9_MINOR_VERSION 4 //MINOR_VERSION should not larger than 0ffffffff
#define SGX_1_5_MAJOR_VERSION 1 //MAJOR_VERSION should not larger than 0ffffffff
#define SGX_1_5_MINOR_VERSION 3 //MINOR_VERSION should not larger than 0ffffffff
+
#define META_DATA_MAKE_VERSION(major, minor) (((uint64_t)major)<<32 | minor)
#define METADATA_MAGIC 0x86A80294635D0E4CULL
-#define METADATA_SIZE 0x1000
+#define METADATA_SIZE 0x3000
+#define TCS_TEMPLATE_SIZE 72
+
/* TCS Policy bit masks */
#define TCS_POLICY_BIND 0x00000000 /* If set, the TCS is bound to the application thread */
#define TCS_POLICY_UNBIND 0x00000001
@@ -58,7 +64,9 @@
#define SSA_FRAME_SIZE_MIN 1
#define SSA_FRAME_SIZE_MAX 2
#define STACK_SIZE_MIN 0x1000
-#define HEAP_SIZE_MIN 0
+#define STACK_SIZE_MAX 0x40000
+#define HEAP_SIZE_MIN 0x1000
+#define HEAP_SIZE_MAX 0x1000000
#define DEFAULT_MISC_SELECT 0
#define DEFAULT_MISC_MASK 0xFFFFFFFF
@@ -78,13 +86,27 @@ typedef enum
#define GROUP_FLAG (1<<12)
#define GROUP_ID(x) (GROUP_FLAG | x)
#define IS_GROUP_ID(x) !!((x) & GROUP_FLAG)
-#define LAYOUT_ID_HEAP 1
-#define LAYOUT_ID_TCS 2
-#define LAYOUT_ID_TD 3
-#define LAYOUT_ID_SSA 4
-#define LAYOUT_ID_STACK 5
-#define LAYOUT_ID_THREAD_GROUP GROUP_ID(6)
-#define LAYOUT_ID_GUARD 7
+#define LAYOUT_ID_HEAP_MIN 1
+#define LAYOUT_ID_HEAP_INIT 2
+#define LAYOUT_ID_HEAP_MAX 3
+#define LAYOUT_ID_TCS 4
+#define LAYOUT_ID_TD 5
+#define LAYOUT_ID_SSA 6
+#define LAYOUT_ID_STACK_MAX 7
+#define LAYOUT_ID_STACK_MIN 8
+#define LAYOUT_ID_THREAD_GROUP GROUP_ID(9)
+#define LAYOUT_ID_GUARD 10
+#define LAYOUT_ID_HEAP_DYN_MIN 11
+#define LAYOUT_ID_HEAP_DYN_INIT 12
+#define LAYOUT_ID_HEAP_DYN_MAX 13
+#define LAYOUT_ID_TCS_DYN 14
+#define LAYOUT_ID_TD_DYN 15
+#define LAYOUT_ID_SSA_DYN 16
+#define LAYOUT_ID_STACK_DYN_MAX 17
+#define LAYOUT_ID_STACK_DYN_MIN 18
+#define LAYOUT_ID_THREAD_GROUP_DYN GROUP_ID(19)
+
+
/*
** layout table example
@@ -138,12 +160,12 @@ typedef struct _metadata_t
uint32_t ssa_frame_size; /* The size of SSA frame in page */
uint32_t max_save_buffer_size; /* Max buffer size is 2632 */
uint32_t desired_misc_select;
- uint32_t reserved;
+ uint32_t tcs_min_pool; /* TCS min pool*/
uint64_t enclave_size; /* enclave virtual size */
sgx_attributes_t attributes; /* XFeatureMask to be set in SECS. */
enclave_css_t enclave_css; /* The enclave signature */
data_directory_t dirs[DIR_NUM];
- uint8_t data[2208];
+ uint8_t data[10400];
}metadata_t;
se_static_assert(sizeof(metadata_t) == METADATA_SIZE);
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/rts.h b/sgx-jvm/linux-sgx/common/inc/internal/rts.h
index 2d62d92d9c..4c737c8800 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/rts.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/rts.h
@@ -63,12 +63,29 @@ typedef enum
SDK_VERSION_2_0
} sdk_version_t;
-typedef struct _cpu_feature_sdk_version
+typedef struct _system_features
{
uint64_t cpu_features;
sdk_version_t version;
-}cpu_sdk_info_t;
+ /* system feature set array. MSb of each element indicates whether this is
+ * the last element. This will help tRTS to know when it can stop walking
+ * through the array searching for certain features.
+ */
+ uint64_t system_feature_set[1];
+}system_features_t;
+
+// current system_feature_set only contains one element of type uint64_t, the highest
+// bit is bit 63
+#define SYS_FEATURE_MSb 63
+
+#define OCALL_FLAG 0x4F434944
+
+typedef enum
+{
+ EDMM_TRIM = -2,
+ EDMM_TRIM_COMMIT = -3,
+ EDMM_MODPR = -4,
+}edmm_ocall_t;
-#define OCALL_FLAG 0x4F434944
#endif
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/rts_cmd.h b/sgx-jvm/linux-sgx/common/inc/internal/rts_cmd.h
index 8eaea8c657..831ca19057 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/rts_cmd.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/rts_cmd.h
@@ -30,10 +30,12 @@
*/
/* ECALL command */
-#define ECMD_ECALL 0
-#define ECMD_INIT_ENCLAVE -1
-#define ECMD_ORET -2
-#define ECMD_EXCEPT -3
+#define ECMD_ECALL 0
+#define ECMD_INIT_ENCLAVE -1
+#define ECMD_ORET -2
+#define ECMD_EXCEPT -3
+#define ECMD_MKTCS -4
+#define ECMD_UNINIT_ENCLAVE -5
/* OCALL command */
#define OCMD_ERET -1
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/se_lock.hpp b/sgx-jvm/linux-sgx/common/inc/internal/se_lock.hpp
index c7bd1d16a5..7d5dcb9d44 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/se_lock.hpp
+++ b/sgx-jvm/linux-sgx/common/inc/internal/se_lock.hpp
@@ -49,6 +49,21 @@ private:
se_mutex_t m_mutex;
};
+class Cond: private Uncopyable
+{
+public:
+ Cond(){se_mutex_init(&m_mutex); se_thread_cond_init(&m_cond);}
+ ~Cond(){se_mutex_destroy(&m_mutex); se_thread_cond_destroy(&m_cond);}
+ void lock(){se_mutex_lock(&m_mutex);}
+ void unlock(){se_mutex_unlock(&m_mutex);}
+ void wait(){se_thread_cond_wait(&m_cond, &m_mutex);}
+ void signal(){se_thread_cond_signal(&m_cond);}
+ void broadcast(){se_thread_cond_broadcast(&m_cond);}
+private:
+ se_mutex_t m_mutex;
+ se_cond_t m_cond;
+};
+
class LockGuard: private Uncopyable
{
public:
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/se_page_attr.h b/sgx-jvm/linux-sgx/common/inc/internal/se_page_attr.h
index 1a27b54ed5..9253e1a36a 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/se_page_attr.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/se_page_attr.h
@@ -32,16 +32,29 @@
#ifndef _SE_PAGE_ATTR_H_
#define _SE_PAGE_ATTR_H_
+// layout.entry.attribute is 16-bit length
typedef enum
{
DoEADD = 0,
DoEEXTEND,
+ DoEREMOVE,
+ DoPostADD,
+ DoPostREMOVE,
+ DynTHREAD,
+ GrowDOWN,
} ATTRIBUTE_BITS_t;
-typedef enum
-{
- ADD_PAGE_ONLY = 1<
#include
#include
-typedef pthread_mutex_t se_mutex_t;
+typedef pthread_mutex_t se_mutex_t;
+typedef pthread_cond_t se_cond_t;
typedef pid_t se_thread_id_t;
typedef pthread_key_t se_tls_index_t;
@@ -58,6 +59,12 @@ int se_mutex_lock(se_mutex_t* mutex);
int se_mutex_unlock(se_mutex_t* mutex);
int se_mutex_destroy(se_mutex_t* mutex);
+void se_thread_cond_init(se_cond_t* cond);
+int se_thread_cond_wait(se_cond_t *cond, se_mutex_t *mutex);
+int se_thread_cond_signal(se_cond_t *cond);
+int se_thread_cond_broadcast(se_cond_t *cond);
+int se_thread_cond_destroy(se_cond_t* cond);
+
unsigned int se_get_threadid(void);
/* tls functions */
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/se_version.h b/sgx-jvm/linux-sgx/common/inc/internal/se_version.h
index b08d6fe89e..316ae446c9 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/se_version.h
+++ b/sgx-jvm/linux-sgx/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.9.100.39124"
+#define STRFILEVER "2.0.40950"
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/sgx_ecc256_internal.h b/sgx-jvm/linux-sgx/common/inc/internal/sgx_ecc256_internal.h
new file mode 100644
index 0000000000..6882e8ae13
--- /dev/null
+++ b/sgx-jvm/linux-sgx/common/inc/internal/sgx_ecc256_internal.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011-2017 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.
+ *
+ */
+
+#ifndef _SGX_ECC256_INTERNAL_H
+#define _SGX_ECC256_INTERNAL_H
+
+#include "sgx_tcrypto.h"
+
+typedef struct _sgx_ec256_shared_point_t
+{
+ uint8_t x[SGX_ECP256_KEY_SIZE];
+ uint8_t y[SGX_ECP256_KEY_SIZE];
+} sgx_ec256_shared_point_t;
+
+#ifdef __cplusplus
+extern "C"
+#endif
+
+/* NOTE: The function is for internal use ONLY
+ *
+ * Computes a point with scalar multiplication based on private B key (local) and remote public Ga Key
+ * Parameters:
+ * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h
+ * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system
+ * sgx_ec256_private_t *p_private_b - Pointer to the local private key
+ * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key
+ * Output: sgx_ec256_shared_point_t *p_shared_key - Pointer to the target shared point
+ */
+sgx_status_t SGXAPI sgx_ecc256_compute_shared_point(sgx_ec256_private_t *p_private_b,
+ sgx_ec256_public_t *p_public_ga,
+ sgx_ec256_shared_point_t *p_shared_key,
+ sgx_ecc_state_handle_t ecc_handle);
+
+
+#endif
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/thread_data.h b/sgx-jvm/linux-sgx/common/inc/internal/thread_data.h
index aee91226c2..108d8b8b8f 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/thread_data.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/thread_data.h
@@ -93,8 +93,8 @@ typedef struct _thread_data_t
sys_word_t first_ssa_gpr; /* set by urts, relative to TCS */
sys_word_t stack_guard; /* GCC expects start_guard at 0x14 on x86 and 0x28 on x64 */
- sys_word_t reserved;
- sys_word_t ssa_frame_size; /* set by urts, in pages (se_ptrace.c needs to know its offset). */
+ sys_word_t reserved;
+ sys_word_t xsave_size; /* in bytes (se_ptrace.c needs to know its offset).*/
sys_word_t last_error; /* init to be 0. Used by trts. */
#ifdef TD_SUPPORT_MULTI_PLATFORM
@@ -110,6 +110,7 @@ typedef struct _thread_data_t
intptr_t exception_flag;
#endif
sys_word_t cxx_thread_info[6];
+ sys_word_t stack_commit_addr;
} thread_data_t;
#ifdef __cplusplus
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/trts_inst.h b/sgx-jvm/linux-sgx/common/inc/internal/trts_inst.h
index c7a30bd9e8..6a96dc1ae9 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/trts_inst.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/trts_inst.h
@@ -33,6 +33,7 @@
#define _TRTS_INST_H_
#include "sgx.h"
+#include "arch.h"
/* Attention:
* if the following alignment requirement changes, go to selib to
@@ -55,14 +56,28 @@ typedef enum _egetkey_status_t
EGETKEY_INVALID_KEYNAME = BIT_ERROR(8),
} egetkey_status_t;
+struct ms_tcs
+{
+ void * ptcs;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
+int sgx_accept_forward(si_flags_t sfl, size_t lo, size_t hi);
void do_ereport(const sgx_target_info_t *target_info, const sgx_report_data_t *report_data, sgx_report_t *report);
int do_egetkey(const sgx_key_request_t *key_request, sgx_key_128bit_t *key);
uint32_t do_rdrand(uint32_t *rand);
-
+int do_eaccept(const sec_info_t *, size_t);
+int do_emodpe(const sec_info_t*, size_t);
+int apply_EPC_pages(void *start_address, size_t page_number);
+int apply_pages_within_exception(void *start_address, size_t page_count);
+int trim_EPC_pages(void *start_address, size_t page_number);
+sgx_status_t SGXAPI sgx_trts_mprotect(size_t start, size_t size, uint64_t perms);
+sgx_status_t do_add_thread(void *ms);
+int is_dynamic_thread(void *tcs);
+uint32_t get_dynamic_stack_max_page(void);
#ifdef __cplusplus
}
#endif
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/util.h b/sgx-jvm/linux-sgx/common/inc/internal/util.h
index 2920cfcc22..d572d6464c 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/util.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/util.h
@@ -52,8 +52,8 @@
#define SE_BULK_PAGE_FRAME_MASK (SE_BULK_PAGE_FRAME_SIZE-1)
#define SE_BULK_PAGE_SHIFT (SE_PAGE_SHIFT + SE_BULK_PAGE_FRAME_SHIFT)
#define SE_BULK_PAGE_SIZE (1 << SE_BULK_PAGE_SHIFT)
-#define SE_GUARD_PAGE_SHIFT SE_PAGE_SHIFT
-#define SE_GUARD_PAGE_SIZE SE_PAGE_SIZE
+#define SE_GUARD_PAGE_SHIFT 16
+#define SE_GUARD_PAGE_SIZE (1 << SE_GUARD_PAGE_SHIFT)
#define ROUND_TO(x, align) (((x) + ((align)-1)) & ~((align)-1))
#define ROUND_TO_PAGE(x) ROUND_TO(x, SE_PAGE_SIZE)
diff --git a/sgx-jvm/linux-sgx/common/inc/internal/xsave.h b/sgx-jvm/linux-sgx/common/inc/internal/xsave.h
index 53adb63e13..188378b04b 100644
--- a/sgx-jvm/linux-sgx/common/inc/internal/xsave.h
+++ b/sgx-jvm/linux-sgx/common/inc/internal/xsave.h
@@ -46,11 +46,8 @@
extern "C" {
#endif
-#include "linux/xsave_gnu.h"
+void init_xsave_info();
-/* implemented in urts_xsave.cpp/trts_xsave.cpp */
-void save_and_clean_xfeature_regs(uint8_t *buffer);
-void restore_xfeature_regs(const uint8_t *buffer);
/* trts_xsave.cpp */
uint64_t get_xfeature_state();
diff --git a/sgx-jvm/linux-sgx/common/inc/sgx_capable.h b/sgx-jvm/linux-sgx/common/inc/sgx_capable.h
index d139cd75ea..97cfc72ecf 100644
--- a/sgx-jvm/linux-sgx/common/inc/sgx_capable.h
+++ b/sgx-jvm/linux-sgx/common/inc/sgx_capable.h
@@ -1,33 +1,33 @@
/*
-* Copyright 2011-2017 Intel Corporation
-*
-* 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 copyright holder 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
-* HOLDER 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.
-*/
+ * Copyright (C) 2011-2017 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.
+ *
+ */
#pragma once
@@ -37,10 +37,6 @@
#include "sgx_error.h"
#include "sgx_defs.h"
-#if defined(_MSC_VER)
-#include
-#endif
-
typedef enum _sgx_device_status_t {
SGX_ENABLED,
SGX_DISABLED_REBOOT_REQUIRED, /* A reboot is required to finish enabling SGX */
@@ -87,4 +83,3 @@ sgx_status_t SGXAPI sgx_cap_get_status(sgx_device_status_t* sgx_device_status);
#endif
#endif
-
diff --git a/sgx-jvm/linux-sgx/common/inc/sgx_error.h b/sgx-jvm/linux-sgx/common/inc/sgx_error.h
index f15da687af..a991776f81 100644
--- a/sgx-jvm/linux-sgx/common/inc/sgx_error.h
+++ b/sgx-jvm/linux-sgx/common/inc/sgx_error.h
@@ -65,6 +65,7 @@ typedef enum _status_t
SGX_ERROR_MODE_INCOMPATIBLE = SGX_MK_ERROR(0x200e), /* The target enclave 32/64 bit mode or sim/hw mode is incompatible with the mode of current uRTS. */
SGX_ERROR_ENCLAVE_FILE_ACCESS = SGX_MK_ERROR(0x200f), /* Can't open enclave file. */
SGX_ERROR_INVALID_MISC = SGX_MK_ERROR(0x2010), /* The MiscSelct/MiscMask settings are not correct.*/
+ SGX_ERROR_INVALID_LAUNCH_TOKEN = SGX_MK_ERROR(0x2011), /* The launch token is not correct.*/
SGX_ERROR_MAC_MISMATCH = SGX_MK_ERROR(0x3001), /* Indicates verification error for reports, sealed datas, etc */
SGX_ERROR_INVALID_ATTRIBUTE = SGX_MK_ERROR(0x3002), /* The enclave is not authorized */
diff --git a/sgx-jvm/linux-sgx/common/inc/sgx_tcrypto.h b/sgx-jvm/linux-sgx/common/inc/sgx_tcrypto.h
index 7b6976a611..72cba8a2aa 100644
--- a/sgx-jvm/linux-sgx/common/inc/sgx_tcrypto.h
+++ b/sgx-jvm/linux-sgx/common/inc/sgx_tcrypto.h
@@ -30,7 +30,7 @@
*/
-
+
/**
* File: sgx_tcrypto.h
* Description:
@@ -61,12 +61,6 @@ typedef struct _sgx_ec256_dh_shared_t
uint8_t s[SGX_ECP256_KEY_SIZE];
} sgx_ec256_dh_shared_t;
-typedef struct _sgx_ec256_dh_shared512_t
-{
- uint8_t x[SGX_ECP256_KEY_SIZE];
- uint8_t y[SGX_ECP256_KEY_SIZE];
-} sgx_ec256_dh_shared512_t;
-
typedef struct _sgx_ec256_private_t
{
uint8_t r[SGX_ECP256_KEY_SIZE];
@@ -90,11 +84,12 @@ typedef struct _sgx_rsa3072_public_key_t
uint8_t exp[SGX_RSA3072_PUB_EXP_SIZE];
} sgx_rsa3072_public_key_t;
-typedef struct _sgx_rsa3072_private_key_t
+typedef struct _sgx_rsa3072_key_t
{
uint8_t mod[SGX_RSA3072_KEY_SIZE];
- uint8_t exp[SGX_RSA3072_PRI_EXP_SIZE];
-} sgx_rsa3072_private_key_t;
+ uint8_t d[SGX_RSA3072_PRI_EXP_SIZE];
+ uint8_t e[SGX_RSA3072_PUB_EXP_SIZE];
+} sgx_rsa3072_key_t;
typedef uint8_t sgx_rsa3072_signature_t[SGX_RSA3072_KEY_SIZE];
@@ -310,8 +305,8 @@ extern "C" {
* Parameters:
* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h
* Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to the key used in encryption/decryption operation
- * uint8_t *p_src - Pointer to the input stream to be MAC’d
- * uint32_t src_len - Length of the input stream to be MAC’d
+ * uint8_t *p_src - Pointer to the input stream to be MAC'd
+ * uint32_t src_len - Length of the input stream to be MAC'd
* Output: sgx_cmac_gcm_128bit_tag_t *p_mac - Pointer to the resultant MAC
*/
sgx_status_t SGXAPI sgx_rijndael128_cmac_msg(const sgx_cmac_128bit_key_t *p_key,
@@ -354,16 +349,17 @@ extern "C" {
*/
sgx_status_t SGXAPI sgx_cmac128_close(sgx_cmac_state_handle_t cmac_handle);
-
/** AES-CTR 128-bit - Only 128-bit key size is supported.
*
* These functions encrypt/decrypt the input data stream of a variable length according
* to the CTR mode as specified in [NIST SP 800-38A]. The counter can be thought of as
- * an IV which increments on successive encryption or decrytion calls. For a given
+ * an IV which increments on successive encryption or decryption calls. For a given
* dataset or data stream the incremented counter block should be used on successive
* calls of the encryption/decryption process for that given stream. However for
* new or different datasets/streams, the same counter should not be reused, instead
* intialize the counter for the new data set.
+ * Note: SGXSSL based version doesn't support user given ctr_inc_bits. It use OpenSSL's implementation
+ * which divide the counter block into two parts ([IV][counter])
*
* sgx_aes_ctr_encrypt
* Return: If source, key, counter, or destination pointer is NULL,
@@ -393,7 +389,7 @@ extern "C" {
* Output:
* uint8_t *p_dst - Pointer to the cipher text.
* Size of buffer should be >= src_len.
- */
+ */
sgx_status_t SGXAPI sgx_aes_ctr_encrypt(
const sgx_aes_ctr_128bit_key_t *p_key,
const uint8_t *p_src,
@@ -401,6 +397,7 @@ extern "C" {
uint8_t *p_ctr,
const uint32_t ctr_inc_bits,
uint8_t *p_dst);
+
sgx_status_t SGXAPI sgx_aes_ctr_decrypt(
const sgx_aes_ctr_128bit_key_t *p_key,
const uint8_t *p_src,
@@ -410,6 +407,7 @@ extern "C" {
uint8_t *p_dst);
+
/**
* Elliptic Curve Cryptography based on GF(p), 256 bit.
*
@@ -479,6 +477,7 @@ extern "C" {
sgx_ec256_public_t *p_public,
sgx_ecc_state_handle_t ecc_handle);
+
/** Checks whether the input point is a valid point on the given elliptic curve.
* Parameters:
* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h
@@ -490,6 +489,7 @@ extern "C" {
const sgx_ecc_state_handle_t ecc_handle,
int *p_valid);
+
/** Computes DH shared key based on own (local) private key and remote public Ga Key.
* NOTE: Caller code allocates memory for Shared key pointer to be populated
*
@@ -543,20 +543,8 @@ extern "C" {
sgx_ec256_dh_shared_t *p_shared_key,
sgx_ecc_state_handle_t ecc_handle);
- /* Computes 512-bit DH shared key based on private B key (local) and remote public Ga Key
- * Parameters:
- * Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h
- * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to the ECC crypto system
- * sgx_ec256_private_t *p_private_b - Pointer to the local private key
- * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key
- * Output: sgx_ec256_dh_shared512_t *p_shared_key - Pointer to the 512-bit shared DH key
- */
- sgx_status_t SGXAPI sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b,
- sgx_ec256_public_t *p_public_ga,
- sgx_ec256_dh_shared512_t *p_shared_key,
- sgx_ecc_state_handle_t ecc_handle);
-
- /** Computes signature for data based on private key.
+
+ /** Computes signature for data based on private key.
*
* A message digest is a fixed size number derived from the original message with
* an applied hash function over the binary code of the message. (SHA256 in this case)
@@ -634,12 +622,13 @@ extern "C" {
* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h
* Inputs: uint8_t *p_data - Pointer to the data to be signed
* uint32_t data_size - Size of the data to be signed
- * sgx_rsa3072_private_key_t *p_private - Pointer to the private key
+ * sgx_rsa3072_key_t *p_key - Pointer to the RSA key.
+ * Note: In IPP based version p_key->e is unused, hence it can be NULL.
* Output: sgx_rsa3072_signature_t *p_signature - Pointer to the signature output
*/
sgx_status_t sgx_rsa3072_sign(const uint8_t *p_data,
uint32_t data_size,
- const sgx_rsa3072_private_key_t *p_private,
+ const sgx_rsa3072_key_t *p_key,
sgx_rsa3072_signature_t *p_signature);
/** Verifies the signature for the given data based on the RSA 3072 public key.
diff --git a/sgx-jvm/linux-sgx/common/inc/sgx_tstdc.edl b/sgx-jvm/linux-sgx/common/inc/sgx_tstdc.edl
index e5cd26f039..d561c6d384 100644
--- a/sgx-jvm/linux-sgx/common/inc/sgx_tstdc.edl
+++ b/sgx-jvm/linux-sgx/common/inc/sgx_tstdc.edl
@@ -31,7 +31,7 @@
enclave {
untrusted {
- [cdecl] void sgx_oc_cpuidex([in, out] int cpuinfo[4], int leaf, int subleaf);
+ [cdecl] void sgx_oc_cpuidex([out] int cpuinfo[4], int leaf, int subleaf);
/* Go outside and wait on my untrusted event */
[cdecl] int sgx_thread_wait_untrusted_event_ocall([user_check] const void *self);
diff --git a/sgx-jvm/linux-sgx/common/inc/stdc++/new b/sgx-jvm/linux-sgx/common/inc/stdc++/new
index 17553e9f06..dbed7840e1 100644
--- a/sgx-jvm/linux-sgx/common/inc/stdc++/new
+++ b/sgx-jvm/linux-sgx/common/inc/stdc++/new
@@ -59,7 +59,7 @@ void* SGXAPI operator new (size_t, void*);
void* SGXAPI operator new[] (size_t, const std::nothrow_t&);
void* SGXAPI operator new[] (size_t, void*);
-void SGXAPI operator delete (void*) throw ();
+void SGXAPI operator delete (void*);
void SGXAPI operator delete (void*, const std::nothrow_t&);
void SGXAPI operator delete (void*, void*);
void SGXAPI operator delete[] (void*);
diff --git a/sgx-jvm/linux-sgx/common/inc/tlibc/mbusafecrt.h b/sgx-jvm/linux-sgx/common/inc/tlibc/mbusafecrt.h
new file mode 100644
index 0000000000..466c55041b
--- /dev/null
+++ b/sgx-jvm/linux-sgx/common/inc/tlibc/mbusafecrt.h
@@ -0,0 +1,83 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/***
+* mbusafecrt.h - public declarations for SafeCRT lib
+*
+
+*
+* Purpose:
+* This file contains the public declarations SafeCRT
+* functions ported to MacOS. These are the safe versions of
+* functions standard functions banned by SWI
+*
+
+****/
+
+/* shields! */
+
+#ifndef MBUSAFECRT_H
+#define MBUSAFECRT_H
+#include
+#include
+#include
+typedef wchar_t WCHAR;
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+extern errno_t strcat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc );
+extern errno_t wcscat_s( WCHAR* ioDest, size_t inDestBufferSize, const WCHAR* inSrc );
+
+extern errno_t strncat_s( char* ioDest, size_t inDestBufferSize, const char* inSrc, size_t inCount );
+extern errno_t wcsncat_s( WCHAR* ioDest, size_t inDestBufferSize, const WCHAR* inSrc, size_t inCount );
+
+extern errno_t strcpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc );
+extern errno_t wcscpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR* inSrc );
+
+extern errno_t strncpy_s( char* outDest, size_t inDestBufferSize, const char* inSrc, size_t inCount );
+extern errno_t wcsncpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR* inSrc, size_t inCount );
+
+extern char* strtok_s( char* inString, const char* inControl, char** ioContext );
+extern WCHAR* wcstok_s( WCHAR* inString, const WCHAR* inControl, WCHAR** ioContext );
+
+extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );
+
+extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
+extern errno_t _itow_s( int inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
+
+extern errno_t _ltoa_s( long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
+extern errno_t _ltow_s( long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
+
+extern errno_t _ultoa_s( unsigned long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
+extern errno_t _ultow_s( unsigned long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
+
+extern errno_t _i64toa_s( long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
+extern errno_t _i64tow_s( long long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
+
+extern errno_t _ui64toa_s( unsigned long long inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
+extern errno_t _ui64tow_s( unsigned long long inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );
+
+extern int sprintf_s( char *string, size_t sizeInBytes, const char *format, ... );
+extern int swprintf_s( WCHAR *string, size_t sizeInWords, const WCHAR *format, ... );
+
+extern int _snprintf_s( char *string, size_t sizeInBytes, size_t count, const char *format, ... );
+extern int _snwprintf_s( WCHAR *string, size_t sizeInWords, size_t count, const WCHAR *format, ... );
+
+extern int _vsprintf_s( char* string, size_t sizeInBytes, const char* format, va_list arglist );
+extern int _vsnprintf_s( char* string, size_t sizeInBytes, size_t count, const char* format, va_list arglist );
+
+extern int _vswprintf_s( WCHAR* string, size_t sizeInWords, const WCHAR* format, va_list arglist );
+extern int _vsnwprintf_s( WCHAR* string, size_t sizeInWords, size_t count, const WCHAR* format, va_list arglist );
+
+extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
+extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* MBUSAFECRT_H */
diff --git a/sgx-jvm/linux-sgx/common/inc/tlibc/stdlib.h b/sgx-jvm/linux-sgx/common/inc/tlibc/stdlib.h
index 936042ec26..6b811a83e3 100644
--- a/sgx-jvm/linux-sgx/common/inc/tlibc/stdlib.h
+++ b/sgx-jvm/linux-sgx/common/inc/tlibc/stdlib.h
@@ -93,25 +93,21 @@ typedef struct {
__BEGIN_DECLS
_TLIBC_NORETURN_ void _TLIBC_CDECL_ abort(void);
+int _TLIBC_CDECL_ atexit(void (*)(void));
int _TLIBC_CDECL_ abs(int);
double _TLIBC_CDECL_ atof(const char *);
int _TLIBC_CDECL_ atoi(const char *);
long _TLIBC_CDECL_ atol(const char *);
void * _TLIBC_CDECL_ bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
-div_t _TLIBC_CDECL_ div(int, int);
void * _TLIBC_CDECL_ calloc(size_t, size_t);
+div_t _TLIBC_CDECL_ div(int, int);
void _TLIBC_CDECL_ free(void *);
-void * _TLIBC_CDECL_ malloc(size_t);
-void * _TLIBC_CDECL_ memalign(size_t, size_t);
-void * _TLIBC_CDECL_ realloc(void *, size_t);
-void * _TLIBC_CDECL_ __tlibc_calloc(size_t, size_t);
-void _TLIBC_CDECL_ __tlibc_free(void *);
-void * _TLIBC_CDECL_ __tlibc_malloc(size_t);
-void * _TLIBC_CDECL_ __tlibc_memalign(size_t, size_t);
-void * _TLIBC_CDECL_ __tlibc_realloc(void *, size_t);
long _TLIBC_CDECL_ labs(long);
ldiv_t _TLIBC_CDECL_ ldiv(long, long);
+void * _TLIBC_CDECL_ malloc(size_t);
+void * _TLIBC_CDECL_ memalign(size_t, size_t);
void _TLIBC_CDECL_ qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+void * _TLIBC_CDECL_ realloc(void *, size_t);
double _TLIBC_CDECL_ strtod(const char *, char **);
long _TLIBC_CDECL_ strtol(const char *, char **, int);
float _TLIBC_CDECL_ strtof(const char *, char **);
diff --git a/sgx-jvm/linux-sgx/common/src/crypto_cmac_128.cpp b/sgx-jvm/linux-sgx/common/src/crypto_cmac_128.cpp
new file mode 100644
index 0000000000..be8a52a4ea
--- /dev/null
+++ b/sgx-jvm/linux-sgx/common/src/crypto_cmac_128.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2011-2017 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 "crypto_wrapper.h"
+#include
+#include
+#include
+#include
+#include
+
+sgx_status_t sgx_cmac128_msg(const sgx_key_128bit_t key, const uint8_t *p_src, unsigned int src_len, sgx_mac_t *p_mac)
+{
+ if(!key || !p_src || src_len == 0 || !p_mac)
+ {
+ return SGX_ERROR_INVALID_PARAMETER;
+ }
+ CMAC_CTX *cmac_ctx = NULL;
+ size_t mac_len;
+
+ if(!(cmac_ctx = CMAC_CTX_new()))
+ {
+ return SGX_ERROR_OUT_OF_MEMORY;
+ }
+ if(!CMAC_Init(cmac_ctx, key, sizeof(sgx_key_128bit_t), EVP_aes_128_cbc(), NULL))
+ {
+ CMAC_CTX_free(cmac_ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ if(!CMAC_Update(cmac_ctx, p_src, src_len))
+ {
+ CMAC_CTX_free(cmac_ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ if(!CMAC_Final(cmac_ctx, (uint8_t *)p_mac, &mac_len))
+ {
+ CMAC_CTX_free(cmac_ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ CMAC_CTX_free(cmac_ctx);
+ assert(mac_len == sizeof(sgx_mac_t));
+ return SGX_SUCCESS;
+
+}
diff --git a/sgx-jvm/linux-sgx/common/src/crypto_evp_digest.cpp b/sgx-jvm/linux-sgx/common/src/crypto_evp_digest.cpp
new file mode 100644
index 0000000000..c38a01ee30
--- /dev/null
+++ b/sgx-jvm/linux-sgx/common/src/crypto_evp_digest.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2011-2017 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
+#include
+#include
+#include "crypto_wrapper.h"
+
+
+sgx_status_t sgx_EVP_Digest(const EVP_MD *type, const uint8_t *p_src, unsigned int src_len, uint8_t *digest, unsigned int *digest_len)
+{
+ if(!type || !p_src || src_len == 0 || !digest || digest_len == 0)
+ return SGX_ERROR_INVALID_PARAMETER;
+
+ uint8_t tmp_digest[EVP_MAX_MD_SIZE];
+ memset(tmp_digest, 0, EVP_MAX_MD_SIZE);
+ unsigned int tmp_digest_len;
+
+ unsigned int digest_buf_len = *digest_len;
+
+ EVP_MD_CTX *ctx;
+ if(NULL == (ctx = EVP_MD_CTX_create()))
+ return SGX_ERROR_OUT_OF_MEMORY;
+
+ if(!EVP_DigestInit_ex(ctx, type, NULL))
+ {
+ EVP_MD_CTX_destroy(ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ if(!EVP_DigestUpdate(ctx, p_src, src_len))
+ {
+ EVP_MD_CTX_destroy(ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ if(!EVP_DigestFinal_ex(ctx, tmp_digest, &tmp_digest_len))
+ {
+ EVP_MD_CTX_destroy(ctx);
+ return SGX_ERROR_UNEXPECTED;
+ }
+ EVP_MD_CTX_destroy(ctx);
+
+ if(tmp_digest_len > digest_buf_len)
+ {
+ return SGX_ERROR_UNEXPECTED;
+ }
+ if(memcpy_s(digest, digest_buf_len, tmp_digest, tmp_digest_len))
+ return SGX_ERROR_UNEXPECTED;
+
+ *digest_len = tmp_digest_len;
+ return SGX_SUCCESS;
+}
diff --git a/sgx-jvm/linux-sgx/common/src/linux/xsave_gnu.S b/sgx-jvm/linux-sgx/common/src/linux/xsave_gnu.S
new file mode 100644
index 0000000000..364e1d3e8a
--- /dev/null
+++ b/sgx-jvm/linux-sgx/common/src/linux/xsave_gnu.S
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2011-2017 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.
+ *
+ */
+
+
+.file "xsave_gnu.S"
+
+#include "linux/linux-regs.h"
+
+.macro DO_XSAVEC
+#if defined(LINUX64)
+ .byte 0x48, 0x0f, 0xc7, 0x21
+#else
+ .byte 0x0f, 0xc7, 0x21
+#endif
+.endm
+.macro DO_XRSTOR
+#if defined(LINUX64)
+ .byte 0x48, 0x0f, 0xae, 0x29
+#else
+ .byte 0x0f, 0xae, 0x29
+#endif
+.endm
+.macro DO_FXSAVE
+#if defined(LINUX64)
+ .byte 0x48, 0x0f, 0xae, 0x01
+#else
+ .byte 0x0f, 0xae, 0x01
+#endif
+.endm
+.macro DO_FXRSTOR
+#if defined(LINUX64)
+ .byte 0x48, 0x0f, 0xae, 0x09
+#else
+ .byte 0x0f, 0xae, 0x09
+#endif
+.endm
+
+.text
+DECLARE_LOCAL_FUNC restore_xregs
+#if defined(LINUX32)
+ mov SE_WORDSIZE(%esp), %ecx
+ lea g_xsave_enabled, %eax
+#else
+ mov %rdi, %rcx
+ mov g_xsave_enabled@GOTPCREL(%rip), %rax
+#endif
+ movl (%xax), %eax
+ cmpl $0, %eax
+ jz 1f
+ xor %xax, %xax
+ xor %xdx, %xdx
+ mov $0xFFFFFFFF, %eax
+ mov $0xFFFFFFFF, %edx
+ DO_XRSTOR
+ jmp 2f
+1:
+ DO_FXRSTOR
+2:
+ ret
+
+DECLARE_LOCAL_FUNC save_xregs
+#if defined(LINUX32)
+ mov SE_WORDSIZE(%esp), %ecx
+ lea g_xsave_enabled, %eax
+#else
+ mov %rdi, %rcx
+ mov g_xsave_enabled@GOTPCREL(%rip), %rax
+#endif
+ fwait
+ movl (%xax), %eax
+ cmpl $0, %eax
+ jz 1f
+ xor %xax, %xax
+ xor %xdx, %xdx
+ mov $0xFFFFFFFF, %eax
+ mov $0xFFFFFFFF, %edx
+ DO_XSAVEC
+ jmp 2f
+1:
+ DO_FXSAVE
+2:
+ ret
+
diff --git a/sgx-jvm/linux-sgx/common/src/se_thread.c b/sgx-jvm/linux-sgx/common/src/se_thread.c
index d35400b06c..59f9ea1805 100644
--- a/sgx-jvm/linux-sgx/common/src/se_thread.c
+++ b/sgx-jvm/linux-sgx/common/src/se_thread.c
@@ -49,6 +49,17 @@ int se_mutex_lock(se_mutex_t* mutex) { return (0 == pthread_mutex_lock(mutex));
int se_mutex_unlock(se_mutex_t* mutex) { return (0 == pthread_mutex_unlock(mutex)); }
int se_mutex_destroy(se_mutex_t* mutex) { return (0 == pthread_mutex_destroy(mutex));}
+void se_thread_cond_init(se_cond_t* cond)
+{
+ se_cond_t tmp = PTHREAD_COND_INITIALIZER;
+ memcpy(cond, &tmp, sizeof(tmp));
+}
+
+int se_thread_cond_wait(se_cond_t *cond, se_mutex_t *mutex){return (0 == pthread_cond_wait(cond, mutex));}
+int se_thread_cond_signal(se_cond_t *cond){return (0 == pthread_cond_signal(cond));}
+int se_thread_cond_broadcast(se_cond_t *cond){return (0 == pthread_cond_broadcast(cond));}
+int se_thread_cond_destroy(se_cond_t* cond){return (0 == pthread_cond_destroy(cond));}
+
unsigned int se_get_threadid(void) { return (unsigned)syscall(__NR_gettid);}
/* tls functions */
int se_tls_alloc(se_tls_index_t *tls_index) { return !pthread_key_create(tls_index, NULL); }
diff --git a/sgx-jvm/linux-sgx/download_prebuilt.sh b/sgx-jvm/linux-sgx/download_prebuilt.sh
index 21cf639de5..f3a656ed01 100755
--- a/sgx-jvm/linux-sgx/download_prebuilt.sh
+++ b/sgx-jvm/linux-sgx/download_prebuilt.sh
@@ -33,13 +33,13 @@
top_dir=`dirname $0`
out_dir=$top_dir
-optlib_name=optimized_libs-1.9.100.39124.tar
-ae_file_name=prebuilt-ae-1.9.100.39124.tar
-server_url_path=https://download.01.org/intel-sgx/linux-1.9/
+optlib_name=optimized_libs-2.0.tar
+ae_file_name=prebuilt-ae-2.0.tar
+server_url_path=https://download.01.org/intel-sgx/linux-2.0/
server_optlib_url=$server_url_path/$optlib_name
server_ae_url=$server_url_path/$ae_file_name
optlib_sha256=239cae39f87934d56c4eb919a4702c6ac82c19957b9a8d56c02b10eb4e27f573
-ae_sha256=c2f86a1e8483b91c5517c99d196599492f3106d4b2f9f7523fd9eaf59b9ed37b
+ae_sha256=3dfac14590a74aa860ea88ca9d1e2e112efb300c622e9ea02b3fa4bd69c50b07
rm -rf $out_dir/$optlib_name
wget $server_optlib_url -P $out_dir
if [ $? -ne 0 ]; then
diff --git a/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/jhi.h b/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/jhi.h
index 846d28a598..ddf94bdc28 100644
--- a/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/jhi.h
+++ b/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/jhi.h
@@ -518,4 +518,4 @@ JHI_GetVersionInfo (
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/typedefs.h b/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/typedefs.h
index 5e4b02fb96..bd591791f4 100644
--- a/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/typedefs.h
+++ b/sgx-jvm/linux-sgx/external/DALSdk/JHI/linux/typedefs.h
@@ -98,4 +98,4 @@ typedef char FILECHAR;
#endif
#endif
-#endif // _TYPEDEFS_H
\ No newline at end of file
+#endif // _TYPEDEFS_H
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippbase.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippbase.h
deleted file mode 100755
index 202cda8f26..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippbase.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __IPPBASE_H__
-#define __IPPBASE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define __STDCALL __stdcall
- #define __CDECL __cdecl
- #define __INT64 __int64
- #define __UINT64 unsigned __int64
-#else
- #define __STDCALL
- #define __CDECL
- #define __INT64 long long
- #define __UINT64 unsigned long long
-#endif
-
-#define IPP_PI ( 3.14159265358979323846 ) /* ANSI C does not support M_PI */
-#define IPP_2PI ( 6.28318530717958647692 ) /* 2*pi */
-#define IPP_PI2 ( 1.57079632679489661923 ) /* pi/2 */
-#define IPP_PI4 ( 0.78539816339744830961 ) /* pi/4 */
-#define IPP_PI180 ( 0.01745329251994329577 ) /* pi/180 */
-#define IPP_RPI ( 0.31830988618379067154 ) /* 1/pi */
-#define IPP_SQRT2 ( 1.41421356237309504880 ) /* sqrt(2) */
-#define IPP_SQRT3 ( 1.73205080756887729353 ) /* sqrt(3) */
-#define IPP_LN2 ( 0.69314718055994530942 ) /* ln(2) */
-#define IPP_LN3 ( 1.09861228866810969139 ) /* ln(3) */
-#define IPP_E ( 2.71828182845904523536 ) /* e */
-#define IPP_RE ( 0.36787944117144232159 ) /* 1/e */
-#define IPP_EPS23 ( 1.19209289e-07f )
-#define IPP_EPS52 ( 2.2204460492503131e-016 )
-
-#define IPP_MAX_8U ( 0xFF )
-#define IPP_MAX_16U ( 0xFFFF )
-#define IPP_MAX_32U ( 0xFFFFFFFF )
-#define IPP_MIN_8U ( 0 )
-#define IPP_MIN_16U ( 0 )
-#define IPP_MIN_32U ( 0 )
-#define IPP_MIN_8S (-128 )
-#define IPP_MAX_8S ( 127 )
-#define IPP_MIN_16S (-32768 )
-#define IPP_MAX_16S ( 32767 )
-#define IPP_MIN_32S (-2147483647 - 1 )
-#define IPP_MAX_32S ( 2147483647 )
-#define IPP_MIN_64U ( 0 )
-
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define IPP_MAX_64S ( 9223372036854775807i64 )
- #define IPP_MIN_64S (-9223372036854775807i64 - 1 )
- #define IPP_MAX_64U ( 0xffffffffffffffffL ) /* 18446744073709551615 */
-#else
- #define IPP_MAX_64S ( 9223372036854775807LL )
- #define IPP_MIN_64S (-9223372036854775807LL - 1 )
- #define IPP_MAX_64U ( 0xffffffffffffffffLL ) /* 18446744073709551615 */
-#endif
-
-#define IPP_MINABS_32F ( 1.175494351e-38f )
-#define IPP_MAXABS_32F ( 3.402823466e+38f )
-#define IPP_EPS_32F ( 1.192092890e-07f )
-#define IPP_MINABS_64F ( 2.2250738585072014e-308 )
-#define IPP_MAXABS_64F ( 1.7976931348623158e+308 )
-#define IPP_EPS_64F ( 2.2204460492503131e-016 )
-
-#define IPP_MAX( a, b ) ( ((a) > (b)) ? (a) : (b) )
-#define IPP_MIN( a, b ) ( ((a) < (b)) ? (a) : (b) )
-
-#define IPP_ABS( a ) ( ((a) < 0) ? (-(a)) : (a) )
-
-typedef struct {
- int major; /* e.g. 1 */
- int minor; /* e.g. 2 */
- int majorBuild; /* e.g. 3 */
- int build; /* e.g. 10, always >= majorBuild */
- char targetCpu[4]; /* corresponding to Intel(R) processor */
- const char* Name; /* e.g. "ippsw7" */
- const char* Version; /* e.g. "v1.2 Beta" */
- const char* BuildDate; /* e.g. "Jul 20 99" */
-} IppLibraryVersion;
-
-typedef unsigned char Ipp8u;
-typedef unsigned short Ipp16u;
-typedef unsigned int Ipp32u;
-typedef signed char Ipp8s;
-typedef signed short Ipp16s;
-typedef signed int Ipp32s;
-typedef float Ipp32f;
-typedef __INT64 Ipp64s;
-typedef __UINT64 Ipp64u;
-typedef double Ipp64f;
-typedef Ipp16s Ipp16f;
-
-typedef struct {
- Ipp8s re;
- Ipp8s im;
-} Ipp8sc;
-
-typedef struct {
- Ipp16s re;
- Ipp16s im;
-} Ipp16sc;
-
-typedef struct {
- Ipp16u re;
- Ipp16u im;
-} Ipp16uc;
-
-typedef struct {
- Ipp32s re;
- Ipp32s im;
-} Ipp32sc;
-
-typedef struct {
- Ipp32f re;
- Ipp32f im;
-} Ipp32fc;
-
-typedef struct {
- Ipp64s re;
- Ipp64s im;
-} Ipp64sc;
-
-typedef struct {
- Ipp64f re;
- Ipp64f im;
-} Ipp64fc;
-
-typedef enum {
- ippUndef = -1,
- ipp1u = 0,
- ipp8u = 1,
- ipp8uc = 2,
- ipp8s = 3,
- ipp8sc = 4,
- ipp16u = 5,
- ipp16uc = 6,
- ipp16s = 7,
- ipp16sc = 8,
- ipp32u = 9,
- ipp32uc = 10,
- ipp32s = 11,
- ipp32sc = 12,
- ipp32f = 13,
- ipp32fc = 14,
- ipp64u = 15,
- ipp64uc = 16,
- ipp64s = 17,
- ipp64sc = 18,
- ipp64f = 19,
- ipp64fc = 20
-} IppDataType;
-
-typedef enum {
- ippFalse = 0,
- ippTrue = 1
-} IppBool;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IPPBASE_H__ */
-
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcore.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippcore.h
deleted file mode 100755
index ec5185923c..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcore.h
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined( __IPPCORE_H__ ) || defined( _OWN_BLDPCS )
-#define __IPPCORE_H__
-
-#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall)
- #define _IPP_STDCALL_CDECL
- #undef __stdcall
-#endif
-
-#ifndef __IPPDEFS_H__
- #include "ippdefs.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if !defined( _IPP_NO_DEFAULT_LIB )
- #if defined( _IPP_SEQUENTIAL_DYNAMIC )
- #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcore" )
- #elif defined( _IPP_SEQUENTIAL_STATIC )
- #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcoremt" )
- #elif defined( _IPP_PARALLEL_DYNAMIC )
- #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcore" )
- #elif defined( _IPP_PARALLEL_STATIC )
- #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcoremt" )
- #endif
-#endif
-
-/* /////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-// Functions declarations
-////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////// */
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippGetLibVersion
-// Purpose: getting of the library version
-// Returns: the structure of information about version
-// of ippcore library
-// Parameters:
-//
-// Notes: not necessary to release the returned structure
-*/
-IPPAPI( const IppLibraryVersion*, ippGetLibVersion, (void) )
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippGetStatusString
-// Purpose: convert the library status code to a readable string
-// Parameters:
-// StsCode IPP status code
-// Returns: pointer to string describing the library status code
-//
-// Notes: don't free the pointer
-*/
-IPPAPI( const char*, ippGetStatusString, ( IppStatus StsCode ) )
-
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippGetCpuClocks
-// Purpose: reading of time stamp counter (TSC) register value
-// Returns: TSC value
-//
-// Note: An hardware exception is possible if TSC reading is not supported by
-/ the current chipset
-*/
-
-IPPAPI( Ipp64u, ippGetCpuClocks, (void) )
-
-
-/* ///////////////////////////////////////////////////////////////////////////
-// Names: ippSetFlushToZero,
-// ippSetDenormAreZero.
-//
-// Purpose: ippSetFlushToZero enables or disables the flush-to-zero mode,
-// ippSetDenormAreZero enables or disables the denormals-are-zeros
-// mode.
-//
-// Arguments:
-// value - !0 or 0 - set or clear the corresponding bit of MXCSR
-// pUMask - pointer to user store current underflow exception mask
-// ( may be NULL if don't want to store )
-//
-// Return:
-// ippStsNoErr - Ok
-// ippStsCpuNotSupportedErr - the mode is not supported
-*/
-
-IPPAPI( IppStatus, ippSetFlushToZero, ( int value, unsigned int* pUMask ))
-IPPAPI( IppStatus, ippSetDenormAreZeros, ( int value ))
-
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippAlignPtr
-// Purpose: pointer aligning
-// Returns: aligned pointer
-//
-// Parameter:
-// ptr - pointer
-// alignBytes - number of bytes to align
-//
-*/
-IPPAPI( void*, ippAlignPtr, ( void * ptr, int alignBytes ) )
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Functions to allocate and free memory
-///////////////////////////////////////////////////////////////////////////// */
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippMalloc
-// Purpose: 64-byte aligned memory allocation
-// Parameter:
-// len number of bytes
-// Returns: pointer to allocated memory
-//
-// Notes: the memory allocated by ippMalloc has to be free by ippFree
-// function only.
-*/
-
-IPPAPI( void*, ippMalloc, (int length) )
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippFree
-// Purpose: free memory allocated by the ippMalloc function
-// Parameter:
-// ptr pointer to the memory allocated by the ippMalloc function
-//
-// Notes: use the function to free memory allocated by ippMalloc
-*/
-IPPAPI( void, ippFree, (void* ptr) )
-
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippInit
-// Purpose: Automatic switching to best for current cpu library code using.
-// Returns:
-// ippStsNoErr
-//
-// Parameter: nothing
-//
-// Notes: At the moment of this function execution no any other IPP function
-// has to be working
-*/
-IPPAPI( IppStatus, ippInit, ( void ))
-
-
-/* ////////////////////////////////////////////////////////////////////////////
-// Name: ippGetCpuFreqMhz
-//
-// Purpose: the function estimates cpu frequency and returns
-// its value in MHz as a integer
-//
-// Return:
-// ippStsNoErr Ok
-// ippStsNullPtrErr null pointer to the freq value
-// ippStsSizeErr wrong num of tries, internal var
-// Arguments:
-// pMhz pointer to the integer to write
-// cpu freq value estimated
-//
-// Notes: no exact value is guaranteed, the value could
-// vary with cpu workloading
-*/
-
-IPPAPI(IppStatus, ippGetCpuFreqMhz, ( int* pMhz ) )
-
-/* ////////////////////////////////////////////////////////////////////////////
-// Name: ippSetNumThreads
-//
-// Purpose:
-//
-// Return:
-// ippStsNoErr Ok
-// ippStsNoOperation For static library internal threading is not supported
-// ippStsSizeErr Desired number of threads less or equal zero
-//
-// Arguments:
-// numThr Desired number of threads
-*/
-IPPAPI( IppStatus, ippSetNumThreads, ( int numThr ) )
-
-/* ////////////////////////////////////////////////////////////////////////////
-// Name: ippGetNumThreads
-//
-// Purpose:
-//
-// Return:
-// ippStsNoErr Ok
-// ippStsNullPtrErr Pointer to numThr is Null
-// ippStsNoOperation For static library internal threading is not supported
-// and return value is always == 1
-//
-// Arguments:
-// pNumThr Pointer to memory location where to store current numThr
-*/
-IPPAPI( IppStatus, ippGetNumThreads, (int* pNumThr) )
-
-/* ////////////////////////////////////////////////////////////////////////////
-// Name: ippGetMaxCacheSizeB
-//
-// Purpose: Detects maximal from the sizes of L2 or L3 in bytes
-//
-// Return:
-// ippStsNullPtrErr The result's pointer is NULL.
-// ippStsNotSupportedCpu The cpu is not supported.
-// ippStsUnknownCacheSize The cpu is supported, but the size of the cache is unknown.
-// ippStsNoErr Ok
-//
-// Arguments:
-// pSizeByte Pointer to the result
-//
-// Note:
-// 1). Intel(R) processors are supported only.
-// 2). Intel(R) Itanium(R) processors and platforms with Intel XScale(R) technology are unsupported
-// 3). For unsupported processors the result is "0",
-// and the return status is "ippStsNotSupportedCpu".
-// 4). For supported processors the result is "0",
-// and the return status is "ippStsUnknownCacheSize".
-// if sizes of the cache is unknown.
-//
-*/
-IPPAPI( IppStatus, ippGetMaxCacheSizeB, ( int* pSizeByte ) )
-
-/*
-// Name: ippGetCpuFeatures
-// Purpose: Detects CPU features.
-// Parameters:
-// pFeaturesMask Pointer to the features mask.
-// Nonzero value of bit means the corresponding feature is supported.
-// Features mask values are defined in the ippdefs.h
-// [ 0] - MMX ( ippCPUID_MMX )
-// [ 1] - SSE ( ippCPUID_SSE )
-// [ 2] - SSE2 ( ippCPUID_SSE2 )
-// [ 3] - SSE3 ( ippCPUID_SSE3 )
-// [ 4] - SSSE3 ( ippCPUID_SSSE3 )
-// [ 5] - MOVBE ( ippCPUID_MOVBE )
-// [ 6] - SSE41 ( ippCPUID_SSE41 )
-// [ 7] - SSE42 ( ippCPUID_SSE42 )
-// [ 8] - AVX ( ippCPUID_AVX )
-// [ 9] - ENABLEDBYOS( ippAVX_ENABLEDBYOS )
-// [10] - AES ( ippCPUID_AES )
-// [11] - PCLMULQDQ ( ippCPUID_CLMUL )
-// [12] - ABR ( ippCPUID_ABR )
-// [13] - RDRAND ( ippCPUID_RDRAND )
-// [14] - F16C ( ippCPUID_F16C )
-// [15] - AVX2 ( ippCPUID_AVX2 )
-// [16] - ADOX/ADCX ( ippCPUID_ADCOX ) ADCX and ADOX instructions
-// [17] - RDSEED ( ippCPUID_RDSEED ) The RDSEED instruction
-// [18] - PREFETCHW ( ippCPUID_PREFETCHW ) The PREFETCHW instruction
-// [19] - SHA ( ippCPUID_SHA ) Intel (R) SHA Extensions
-// [20:63] - Reserved
-//
-// pCpuidInfoRegs Pointer to the 4-element vector.
-// Result of CPUID.1 are stored in this vector.
-// [0] - register EAX
-// [1] - register EBX
-// [2] - register ECX
-// [3] - register EDX
-// If pointer pCpuidInfoRegs is set to NULL, registers are not stored.
-//
-// Returns:
-// ippStsNullPtrErr The pointer to the features mask (pFeaturesMask) is NULL.
-// ippStsNotSupportedCpu CPU is not supported.
-// ippStsNoErr Ok
-//
-// Note: Only IA-32 and Intel(R) 64 are supported
-*/
-IPPAPI( IppStatus, ippGetCpuFeatures, ( Ipp64u* pFeaturesMask,
- Ipp32u pCpuidInfoRegs[4] ) )
-
-/*
-// Name: ippGetEnabledCpuFeatures
-// Purpose: Detects enabled features for loaded libraries
-// Returns: Features mask
-// Features mask values are defined in the ippdefs.h
-// [ 0] - ippCPUID_MMX
-// [ 1] - ippCPUID_SSE
-// [ 2] - ippCPUID_SSE2
-// [ 3] - ippCPUID_SSE3
-// [ 4] - ippCPUID_SSSE3
-// [ 5] - ippCPUID_MOVBE
-// [ 6] - ippCPUID_SSE41
-// [ 7] - ippCPUID_SSE42
-// [ 8] - ippCPUID_AVX
-// [ 9] - ippAVX_ENABLEDBYOS
-// [10] - ippCPUID_AES
-// [11] - ippCPUID_CLMUL
-// [12] - ippCPUID_ABR
-// [13] - ippCPUID_RDRAND
-// [14] - ippCPUID_F16C
-// [15] - ippCPUID_AVX2
-// [16] - ippCPUID_ADCOX
-// [17] - ippCPUID_RDSEED
-// [18] - ippCPUID_PREFETCHW
-// [19] - ippCPUID_SHA
-// [20:63] - Reserved
-//
-*/
-IPPAPI( Ipp64u, ippGetEnabledCpuFeatures, ( void ) )
-
-/* ////////////////////////////////////////////////////////////////////////////
-// Name: ippSetCpuFeatures
-//
-// Purpose: Changes the set of enabled/disabled CPU features.
-// This function sets the processor-specific code of the Intel IPP
-// library according to the processor features specified in cpuFeatures.
-//
-// Return:
-// ippStsNoErr No errors.
-// Warnings:
-// ippStsFeatureNotSupported Current CPU doesn't support at least 1 of the
-// desired features;
-// ippStsUnknownFeature At least one of the desired features is unknown;
-// ippStsFeaturesCombination Wrong combination of features;
-// ippStsCpuMismatch Indicates that the specified processor features
-// are not valid. Previously set code is used.
-//
-// Arguments:
-// cpuFeatures Desired features to support by the library
-// (see ippdefs.h for ippCPUID_XX definition)
-//
-// NOTE: this function can re-initializes dispatcher and after the
-// call another library (letter) may work
-// CAUTION: At the moment of this function excecution no any other IPP
-// function has to be working
-//
-// The next pre-defined sets of features can be used:
-// 32-bit code:
-// #define PX_FM ( ippCPUID_MMX | ippCPUID_SSE )
-// #define W7_FM ( PX_FM | ippCPUID_SSE2 )
-// #define V8_FM ( W7_FM | ippCPUID_SSE3 | ippCPUID_SSSE3 )
-// #define S8_FM ( V8_FM | ippCPUID_MOVBE )
-// #define P8_FM ( V8_FM | ippCPUID_SSE41 | ippCPUID_SSE42 | ippCPUID_AES | ippCPUID_CLMUL | ippCPUID_SHA )
-// #define G9_FM ( P8_FM | ippCPUID_AVX | ippAVX_ENABLEDBYOS | ippCPUID_RDRAND | ippCPUID_F16C )
-// #define H9_FM ( G9_FM | ippCPUID_AVX2 | ippCPUID_MOVBE | ippCPUID_ADCOX | ippCPUID_RDSEED | ippCPUID_PREFETCHW )
-//
-// 64-bit code:
-// #define PX_FM ( ippCPUID_MMX | ippCPUID_SSE | ippCPUID_SSE2 )
-// #define M7_FM ( PX_FM | ippCPUID_SSE3 )
-// #define N8_FM ( S8_FM )
-// #define U8_FM ( V8_FM )
-// #define Y8_FM ( P8_FM )
-// #define E9_FM ( G9_FM )
-// #define L9_FM ( H9_FM )
-//
-*/
-
-IPPAPI( IppStatus, ippSetCpuFeatures,( Ipp64u cpuFeatures ))
-
-#if defined (_IPP_STDCALL_CDECL)
- #undef _IPP_STDCALL_CDECL
- #define __stdcall __cdecl
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IPPCORE_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcp.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippcp.h
deleted file mode 100755
index 48d1d81cce..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcp.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined( __IPPCP_H__ ) || defined( _OWN_BLDPCS )
-#define __IPPCP_H__
-
-
-#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall)
- #define _IPP_STDCALL_CDECL
- #undef __stdcall
-#endif
-
-
-#ifndef __IPPDEFS_H__
- #include "ippdefs.h"
-#endif
-
-#ifndef __IPPCPDEFS_H__
- #include "ippcpdefs.h"
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* /////////////////////////////////////////////////////////////////////////////
-// Name: ippcpGetLibVersion
-// Purpose: getting of the library version
-// Returns: the structure of information about version of ippCP library
-// Parameters:
-//
-// Notes: not necessary to release the returned structure
-*/
-IPPAPI( const IppLibraryVersion*, ippcpGetLibVersion, (void) )
-
-
-/*
-// AES
-*/
-IPPAPI(IppStatus, ippsAESGetSize,(int *pSize))
-IPPAPI(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx, int ctxSize))
-
-/* AES-CTR */
-IPPAPI(IppStatus, ippsAESEncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
- const IppsAESSpec* pCtx,
- Ipp8u* pCtrValue, int ctrNumBitSize))
-IPPAPI(IppStatus, ippsAESDecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len,
- const IppsAESSpec* pCtx,
- Ipp8u* pCtrValue, int ctrNumBitSize))
-
-/* AES-GCM */
-IPPAPI(IppStatus, ippsAES_GCMGetSize,(int * pSize))
-IPPAPI(IppStatus, ippsAES_GCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_GCMState* pState, int ctxSize))
-
-IPPAPI(IppStatus, ippsAES_GCMReset,(IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMProcessIV,(const Ipp8u* pIV, int ivLen,
- IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMProcessAAD,(const Ipp8u* pAAD, int ivAAD,
- IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMStart,(const Ipp8u* pIV, int ivLen,
- const Ipp8u* pAAD, int aadLen,
- IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_GCMState* pState))
-IPPAPI(IppStatus, ippsAES_GCMGetTag,(Ipp8u* pDstTag, int tagLen, const IppsAES_GCMState* pState))
-
-/* AES-CMAC */
-IPPAPI(IppStatus, ippsAES_CMACGetSize,(int* pSize))
-IPPAPI(IppStatus, ippsAES_CMACInit,(const Ipp8u* pKey, int keyLen, IppsAES_CMACState* pState, int ctxSize))
-
-IPPAPI(IppStatus, ippsAES_CMACUpdate,(const Ipp8u* pSrc, int len, IppsAES_CMACState* pState))
-IPPAPI(IppStatus, ippsAES_CMACFinal,(Ipp8u* pMD, int mdLen, IppsAES_CMACState* pState))
-IPPAPI(IppStatus, ippsAES_CMACGetTag,(Ipp8u* pMD, int mdLen, const IppsAES_CMACState* pState))
-
-/*
-// hash
-*/
-IPPAPI(IppStatus, ippsHashGetSize,(int* pSize))
-IPPAPI(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId hashAlg))
-
-IPPAPI(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashGetTag,(Ipp8u* pMD, int tagLen, const IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx))
-IPPAPI(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int len, Ipp8u* pMD, IppHashAlgId hashAlg))
-
-IPPAPI(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg))
-
-IPPAPI(IppStatus, ippsHMAC_GetSize,(int* pSize))
-IPPAPI(IppStatus, ippsHMAC_Init,(const Ipp8u* pKey, int keyLen, IppsHMACState* pCtx, IppHashAlgId hashAlg))
-
-IPPAPI(IppStatus, ippsHMAC_Update,(const Ipp8u* pSrc, int len, IppsHMACState* pCtx))
-IPPAPI(IppStatus, ippsHMAC_Final,(Ipp8u* pMD, int mdLen, IppsHMACState* pCtx))
-IPPAPI(IppStatus, ippsHMAC_GetTag,(Ipp8u* pMD, int mdLen, const IppsHMACState* pCtx))
-IPPAPI(IppStatus, ippsHMAC_Message,(const Ipp8u* pMsg, int msgLen,
- const Ipp8u* pKey, int keyLen,
- Ipp8u* pMD, int mdLen,
- IppHashAlgId hashAlg))
-
-/*
-// Big Number Integer Arithmetic
-*/
-IPPAPI(IppStatus, ippsBigNumGetSize,(int length, int* pSize))
-IPPAPI(IppStatus, ippsBigNumInit,(int length, IppsBigNumState* pBN))
-
-IPPAPI(IppStatus, ippsSet_BN,(IppsBigNumSGN sgn,
- int length, const Ipp32u* pData,
- IppsBigNumState* pBN))
-IPPAPI(IppStatus, ippsRef_BN,(IppsBigNumSGN* pSgn, int* bitSize, Ipp32u** const ppData,
- const IppsBigNumState* pBN))
-
-IPPAPI(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-IPPAPI(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-IPPAPI(IppStatus, ippsMod_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR))
-IPPAPI(IppStatus, ippsModInv_BN,(IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pInv))
-IPPAPI(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR))
-IPPAPI(IppStatus, ippsCmpZero_BN,(const IppsBigNumState* pBN, Ipp32u* pResult))
-IPPAPI(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u* pResult))
-IPPAPI(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-IPPAPI(IppStatus, ippsGcd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pGCD))
-
-IPPAPI(IppStatus, ippsSetOctString_BN,(const Ipp8u* pStr, int strLen, IppsBigNumState* pBN))
-IPPAPI(IppStatus, ippsGetOctString_BN,(Ipp8u* pStr, int strLen, const IppsBigNumState* pBN))
-
-/*
-// Montgomery Operations
-*/
-IPPAPI(IppStatus, ippsMontGetSize,(IppsExpMethod method, int length, int* pSize))
-IPPAPI(IppStatus, ippsMontInit,(IppsExpMethod method, int length, IppsMontState* pCtx))
-IPPAPI(IppStatus, ippsMontSet,(const Ipp32u* pModulo, int size, IppsMontState* pCtx))
-IPPAPI(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* m, IppsBigNumState* pR))
-
-/*
-// PRNG
-*/
-IPPAPI(IppStatus, ippsPRNGGetSize,(int* pSize))
-IPPAPI(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pCtx))
-IPPAPI(IppStatus, ippsPRNGen, (Ipp32u* pRand, int nBits, void* pCtx))
-
-/*
-// Prime Number Generation
-*/
-IPPAPI(IppStatus, ippsPrimeGetSize,(int nMaxBits, int* pSize))
-IPPAPI(IppStatus, ippsPrimeInit, (int nMaxBits, IppsPrimeState* pCtx))
-
-
-/*
-// RSA
-*/
-IPPAPI(IppStatus, ippsRSA_GetSizePublicKey,(int rsaModulusBitSize, int pubicExpBitSize, int* pKeySize))
-IPPAPI(IppStatus, ippsRSA_InitPublicKey,(int rsaModulusBitSize, int publicExpBitSize,
- IppsRSAPublicKeyState* pKey, int keyCtxSize))
-IPPAPI(IppStatus, ippsRSA_SetPublicKey,(const IppsBigNumState* pModulus,
- const IppsBigNumState* pPublicExp,
- IppsRSAPublicKeyState* pKey))
-IPPAPI(IppStatus, ippsRSA_GetPublicKey,(IppsBigNumState* pModulus,
- IppsBigNumState* pPublicExp,
- const IppsRSAPublicKeyState* pKey))
-
-IPPAPI(IppStatus, ippsRSA_GetSizePrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, int* pKeySize))
-IPPAPI(IppStatus, ippsRSA_InitPrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize,
- IppsRSAPrivateKeyState* pKey, int keyCtxSize))
-IPPAPI(IppStatus, ippsRSA_SetPrivateKeyType1,(const IppsBigNumState* pModulus,
- const IppsBigNumState* pPrivateExp,
- IppsRSAPrivateKeyState* pKey))
-
-IPPAPI(IppStatus, ippsRSA_GetSizePrivateKeyType2,(int factorPbitSize, int factorQbitSize, int* pKeySize))
-IPPAPI(IppStatus, ippsRSA_InitPrivateKeyType2,(int factorPbitSize, int factorQbitSize,
- IppsRSAPrivateKeyState* pKey, int keyCtxSize))
-IPPAPI(IppStatus, ippsRSA_SetPrivateKeyType2,(const IppsBigNumState* pFactorP,
- const IppsBigNumState* pFactorQ,
- const IppsBigNumState* pCrtExpP,
- const IppsBigNumState* pCrtExpQ,
- const IppsBigNumState* pInverseQ,
- IppsRSAPrivateKeyState* pKey))
-
-IPPAPI(IppStatus, ippsRSA_GetBufferSizePublicKey,(int* pBufferSize, const IppsRSAPublicKeyState* pKey))
-IPPAPI(IppStatus, ippsRSA_GetBufferSizePrivateKey,(int* pBufferSize, const IppsRSAPrivateKeyState* pKey))
-
-IPPAPI(IppStatus, ippsRSA_Encrypt,(const IppsBigNumState* pPtxt,
- IppsBigNumState* pCtxt,
- const IppsRSAPublicKeyState* pKey,
- Ipp8u* pScratchBuffer))
-IPPAPI(IppStatus, ippsRSA_Decrypt,(const IppsBigNumState* pCtxt,
- IppsBigNumState* pPtxt,
- const IppsRSAPrivateKeyState* pKey,
- Ipp8u* pScratchBuffer))
-
-IPPAPI(IppStatus, ippsRSA_ValidateKeys,(int* pResult,
- const IppsRSAPublicKeyState* pPublicKey,
- const IppsRSAPrivateKeyState* pPrivateKeyType2,
- const IppsRSAPrivateKeyState* pPrivateKeyType1,
- Ipp8u* pScratchBuffer,
- int nTrials,
- IppsPrimeState* pPrimeGen,
- IppBitSupplier rndFunc, void* pRndParam))
-
-/* encryption scheme: RSAES-OAEP */
-IPPAPI(IppStatus, ippsRSAEncrypt_OAEP,(const Ipp8u* pSrc, int srcLen,
- const Ipp8u* pLabel, int labLen,
- const Ipp8u* pSeed,
- Ipp8u* pDst,
- const IppsRSAPublicKeyState* pKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-IPPAPI(IppStatus, ippsRSA_OAEPEncrypt_SHA256,(const Ipp8u* pSrc, int srcLen,
- const Ipp8u* pLabel, int labLen,
- const Ipp8u* pSeed,
- Ipp8u* pDst,
- const IppsRSAPublicKeyState* pKey,
- Ipp8u* pBuffer))
-
-/* signature scheme : RSA-SSA-PKCS1-v1_5 */
-IPPAPI(IppStatus, ippsRSASign_PKCS1v15,(const Ipp8u* pMsg, int msgLen,
- Ipp8u* pSign,
- const IppsRSAPrivateKeyState* pPrvKey,
- const IppsRSAPublicKeyState* pPubKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-
-
-IPPAPI(IppStatus, ippsRSAVerify_PKCS1v15,(const Ipp8u* pMsg, int msgLen,
- const Ipp8u* pSign, int* pIsValid,
- const IppsRSAPublicKeyState* pKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-
-
-/*
-// EC Cryptography
-*/
-IPPAPI(IppStatus, ippsECCPGetSize,(int feBitSize, int* pSize))
-IPPAPI(IppStatus, ippsECCPInit,(int feBitSize, IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPSet,(const IppsBigNumState* pPrime,
- const IppsBigNumState* pA, const IppsBigNumState* pB,
- const IppsBigNumState* pGX,const IppsBigNumState* pGY,const IppsBigNumState* pOrder,
- int cofactor,
- IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPSetStd,(IppECCType flag, IppsECCPState* pECC))
-
-
-IPPAPI(IppStatus, ippsECCPPointGetSize,(int feBitSize, int* pSize))
-IPPAPI(IppStatus, ippsECCPPointInit,(int feBitSize, IppsECCPPointState* pPoint))
-
-IPPAPI(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX, const IppsBigNumState* pY,
- IppsECCPPointState* pPoint, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint, IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX, IppsBigNumState* pY,
- const IppsECCPPointState* pPoint, IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP,
- IppECResult* pResult, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ,
- IppECResult* pResult, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPNegativePoint,(const IppsECCPPointState* pP,
- IppsECCPPointState* pR, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP, const IppsECCPPointState* pQ,
- IppsECCPPointState* pR, IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP, const IppsBigNumState* pK,
- IppsECCPPointState* pR, IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPGenKeyPair,(IppsBigNumState* pPrivate, IppsECCPPointState* pPublic,
- IppsECCPState* pECC,
- IppBitSupplier rndFunc, void* pRndParam))
-IPPAPI(IppStatus, ippsECCPPublicKey,(const IppsBigNumState* pPrivate,
- IppsECCPPointState* pPublic,
- IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPSetKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic,
- IppBool regular,
- IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA,
- const IppsECCPPointState* pPublicB,
- IppsBigNumState* pShare,
- IppsECCPState* pECC))
-
-IPPAPI(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest,
- const IppsBigNumState* pPrivate,
- IppsBigNumState* pSignX, IppsBigNumState* pSignY,
- IppsECCPState* pECC))
-IPPAPI(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest,
- const IppsBigNumState* pSignX, const IppsBigNumState* pSignY,
- IppECResult* pResult,
- IppsECCPState* pECC))
-
-#ifdef __cplusplus
-}
-#endif
-
-#if defined (_IPP_STDCALL_CDECL)
- #undef _IPP_STDCALL_CDECL
- #define __stdcall __cdecl
-#endif
-
-#endif /* __IPPCP_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcpdefs.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippcpdefs.h
deleted file mode 100755
index 612ed50dec..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippcpdefs.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __IPPCPDEFS_H__
-#define __IPPCPDEFS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-// AES
-*/
-#define IPP_AES_BLOCK_BITSIZE (128) /* cipher blocksizes (bits) */
-
-typedef enum { /* cipher keysizes (bits) */
- ippRijndaelKey128 = 128, IppsRijndaelKey128 = 128, /* 128-bit key */
- ippRijndaelKey192 = 192, IppsRijndaelKey192 = 192, /* 192-bit key */
- ippRijndaelKey256 = 256, IppsRijndaelKey256 = 256 /* 256-bit key */
-} IppsRijndaelKeyLength;
-
-typedef struct _cpRijndael128 IppsAESSpec;
-typedef struct _cpAES_GCM IppsAES_GCMState;
-typedef struct _cpAES_CMAC IppsAES_CMACState;
-
-
-/*
-// hash
-*/
-typedef enum {
- ippHashAlg_Unknown,
- ippHashAlg_SHA1,
- ippHashAlg_SHA256,
- ippHashAlg_SHA224,
- ippHashAlg_SHA512,
- ippHashAlg_SHA384,
- ippHashAlg_MD5,
- ippHashAlg_SHA512_224,
- ippHashAlg_SHA512_256,
- ippHashAlg_MaxNo
-} IppHashAlgId;
-
-#define IPP_ALG_HASH_UNKNOWN (ippHashAlg_Unknown) /* unknown */
-#define IPP_ALG_HASH_SHA1 (ippHashAlg_SHA1) /* SHA1 */
-#define IPP_ALG_HASH_SHA256 (ippHashAlg_SHA256) /* SHA256 */
-#define IPP_ALG_HASH_SHA224 (ippHashAlg_SHA224) /* SHA224 or SHA256/224 */
-#define IPP_ALG_HASH_SHA512 (ippHashAlg_SHA512) /* SHA512 */
-#define IPP_ALG_HASH_SHA384 (ippHashAlg_SHA384) /* SHA384 or SHA512/384 */
-#define IPP_ALG_HASH_MD5 (ippHashAlg_MD5) /* MD5 */
-#define IPP_ALG_HASH_SHA512_224 (ippHashAlg_SHA512_224) /* SHA512/224 */
-#define IPP_ALG_HASH_SHA512_256 (ippHashAlg_SHA512_256) /* SHA512/256 */
-#define IPP_ALG_HASH_LIMIT (ippHashAlg_MaxNo) /* hash alg limiter*/
-
-#define IPP_SHA1_DIGEST_BITSIZE 160 /* digest size (bits) */
-#define IPP_SHA256_DIGEST_BITSIZE 256
-#define IPP_SHA224_DIGEST_BITSIZE 224
-#define IPP_SHA384_DIGEST_BITSIZE 384
-#define IPP_SHA512_DIGEST_BITSIZE 512
-#define IPP_MD5_DIGEST_BITSIZE 128
-#define IPP_SHA512_224_DIGEST_BITSIZE 224
-#define IPP_SHA512_256_DIGEST_BITSIZE 256
-
-typedef struct _cpHashCtx IppsHashState;
-typedef struct _cpHMAC IppsHMACState;
-
-
-/*
-// Big Number Integer Arithmetic
-*/
-#define BN_MAXBITSIZE (16*1024) /* bn max size (bits) */
-
-/* operation results */
-#define IPP_IS_EQ (0)
-#define IPP_IS_GT (1)
-#define IPP_IS_LT (2)
-#define IPP_IS_NE (3)
-#define IPP_IS_NA (4)
-
-#define IPP_IS_PRIME (5)
-#define IPP_IS_COMPOSITE (6)
-
-#define IPP_IS_VALID (7)
-#define IPP_IS_INVALID (8)
-#define IPP_IS_INCOMPLETE (9)
-#define IPP_IS_ATINFINITY (10)
-
-#define IS_ZERO IPP_IS_EQ
-#define GREATER_THAN_ZERO IPP_IS_GT
-#define LESS_THAN_ZERO IPP_IS_LT
-#define IS_PRIME IPP_IS_PRIME
-#define IS_COMPOSITE IPP_IS_COMPOSITE
-#define IS_VALID_KEY IPP_IS_VALID
-#define IS_INVALID_KEY IPP_IS_INVALID
-#define IS_INCOMPLETED_KEY IPP_IS_INCOMPLETE
-
-typedef enum {
- ippBigNumNEG = 0, IppsBigNumNEG = 0,
- ippBigNumPOS = 1, IppsBigNumPOS = 1
-} IppsBigNumSGN;
-
-typedef enum {
- ippBinaryMethod = 0, IppsBinaryMethod = 0,
- ippSlidingWindows = 1, IppsSlidingWindows = 1
-} IppsExpMethod;
-
-typedef struct _cpBigNum IppsBigNumState;
-typedef struct _cpMontgomery IppsMontState;
-typedef struct _cpPRNG IppsPRNGState;
-typedef struct _cpPrime IppsPrimeState;
-
-/* External Bit Supplier */
-typedef IppStatus (__STDCALL *IppBitSupplier)(Ipp32u* pRand, int nBits, void* pEbsParams);
-
-
-/*
-// RSA
-*/
-#define MIN_RSA_SIZE (8)
-#define MAX_RSA_SIZE (4096)
-
-typedef struct _cpRSA IppsRSAState;
-typedef struct _cpRSA_public_key IppsRSAPublicKeyState;
-typedef struct _cpRSA_private_key IppsRSAPrivateKeyState;
-
-
-/*
-// EC Cryptography
-*/
-#define EC_GFP_MAXBITSIZE (1024)
-
-typedef struct _cpECCP IppsECCPState;
-typedef struct _cpECCPPoint IppsECCPPointState;
-
-/* operation result */
-typedef enum {
- ippECValid, /* validation pass successfully */
-
- ippECCompositeBase, /* field based on composite */
- ippECComplicatedBase, /* number of non-zero terms in the polynomial (> PRIME_ARR_MAX) */
- ippECIsZeroDiscriminant,/* zero discriminant */
- ippECCompositeOrder, /* composite order of base point */
- ippECInvalidOrder, /* invalid base point order */
- ippECIsWeakMOV, /* weak Meneze-Okamoto-Vanstone reduction attack */
- ippECIsWeakSSSA, /* weak Semaev-Smart,Satoh-Araki reduction attack */
- ippECIsSupersingular, /* supersingular curve */
-
- ippECInvalidPrivateKey, /* !(0 < Private < order) */
- ippECInvalidPublicKey, /* (order*PublicKey != Infinity) */
- ippECInvalidKeyPair, /* (Private*BasePoint != PublicKey) */
-
- ippECPointOutOfGroup, /* out of group (order*P != Infinity) */
- ippECPointIsAtInfinite, /* point (P=(Px,Py)) at Infinity */
- ippECPointIsNotValid, /* point (P=(Px,Py)) out-of EC */
-
- ippECPointIsEqual, /* compared points are equal */
- ippECPointIsNotEqual, /* compared points are different */
-
- ippECInvalidSignature /* invalid signature */
-} IppECResult;
-
-typedef enum {
- ippECarbitrary =0x00000, IppECCArbitrary = 0x00000, /* arbitrary ECC */
-
- ippECPstd = 0x10000, IppECCPStd = 0x10000, /* random (recommended) EC over FG(p): */
- ippECPstd112r1 = ippECPstd, IppECCPStd112r1 = IppECCPStd, /* secp112r1 curve */
- ippECPstd112r2 = ippECPstd+1, IppECCPStd112r2 = IppECCPStd+1, /* secp112r2 curve */
- ippECPstd128r1 = ippECPstd+2, IppECCPStd128r1 = IppECCPStd+2, /* secp128r1 curve */
- ippECPstd128r2 = ippECPstd+3, IppECCPStd128r2 = IppECCPStd+3, /* secp128r2 curve */
- ippECPstd160r1 = ippECPstd+4, IppECCPStd160r1 = IppECCPStd+4, /* secp160r1 curve */
- ippECPstd160r2 = ippECPstd+5, IppECCPStd160r2 = IppECCPStd+5, /* secp160r2 curve */
- ippECPstd192r1 = ippECPstd+6, IppECCPStd192r1 = IppECCPStd+6, /* secp192r1 curve */
- ippECPstd224r1 = ippECPstd+7, IppECCPStd224r1 = IppECCPStd+7, /* secp224r1 curve */
- ippECPstd256r1 = ippECPstd+8, IppECCPStd256r1 = IppECCPStd+8, /* secp256r1 curve */
- ippECPstd384r1 = ippECPstd+9, IppECCPStd384r1 = IppECCPStd+9, /* secp384r1 curve */
- ippECPstd521r1 = ippECPstd+10, IppECCPStd521r1 = IppECCPStd+10, /* secp521r1 curve */
-} IppsECType, IppECCType;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IPPCPDEFS_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippdefs.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippdefs.h
deleted file mode 100755
index 1e78d0c76f..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippdefs.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __IPPDEFS_H__
-#define __IPPDEFS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if defined (_WIN64)
-#define _INTEL_PLATFORM "intel64/"
-#elif defined (_WIN32)
-#define _INTEL_PLATFORM "ia32/"
-#endif
-
-#if !defined( IPPAPI )
-
- #if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 ))
- #if defined( _MSC_VER ) || defined( __ICL )
- #define IPPAPI( type,name,arg ) \
- __declspec(dllimport) type __STDCALL name arg;
- #else
- #define IPPAPI( type,name,arg ) type __STDCALL name arg;
- #endif
- #else
- #define IPPAPI( type,name,arg ) type __STDCALL name arg;
- #endif
-
-#endif
-
-#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER)) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
- #if( __INTEL_COMPILER >= 1100 ) /* icl 11.0 supports additional comment */
- #if( _MSC_VER >= 1400 )
- #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
- #else
- #pragma message ("your icl version supports additional comment for deprecated functions but it can't be displayed")
- #pragma message ("because internal _MSC_VER macro variable setting requires compatibility with MSVC7.1")
- #pragma message ("use -Qvc8 switch for icl command line to see these additional comments")
- #define IPP_DEPRECATED( comment ) __declspec( deprecated )
- #endif
- #elif( _MSC_FULL_VER >= 140050727 )&&( !defined( __INTEL_COMPILER )) /* VS2005 supports additional comment */
- #define IPP_DEPRECATED( comment ) __declspec( deprecated ( comment ))
- #elif( _MSC_VER <= 1200 )&&( !defined( __INTEL_COMPILER )) /* VS 6 doesn't support deprecation */
- #define IPP_DEPRECATED( comment )
- #else
- #define IPP_DEPRECATED( comment ) __declspec( deprecated )
- #endif
-#elif (defined(__ICC) || defined(__ECC) || defined( __GNUC__ )) && !defined( _PCS ) && !defined( _PCS_GENSTUBS )
- #if defined( __GNUC__ )
- #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
- #define IPP_DEPRECATED( message ) __attribute__(( deprecated( message )))
- #else
- #define IPP_DEPRECATED( message ) __attribute__(( deprecated ))
- #endif
- #else
- #define IPP_DEPRECATED( comment ) __attribute__(( deprecated ))
- #endif
-#else
- #define IPP_DEPRECATED( comment )
-#endif
-
-#if (defined( __ICL ) || defined( __ECL ) || defined(_MSC_VER))
- #if !defined( _IPP_NO_DEFAULT_LIB )
- #if (( defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC )) || \
- (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && defined( _IPP_SEQUENTIAL_STATIC )))
- #elif (!defined( _IPP_PARALLEL_DYNAMIC ) && !defined( _IPP_PARALLEL_STATIC ) && !defined( _IPP_SEQUENTIAL_DYNAMIC ) && !defined( _IPP_SEQUENTIAL_STATIC ))
- #define _IPP_NO_DEFAULT_LIB
- #else
- #error Illegal combination of _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC, only one definition can be defined
- #endif
- #endif
-#else
- #define _IPP_NO_DEFAULT_LIB
- #if (defined( _IPP_PARALLEL_DYNAMIC ) || defined( _IPP_PARALLEL_STATIC ) || defined(_IPP_SEQUENTIAL_DYNAMIC) || defined(_IPP_SEQUENTIAL_STATIC))
- #pragma message ("defines _IPP_PARALLEL_DYNAMIC/_IPP_PARALLEL_STATIC/_IPP_SEQUENTIAL_DYNAMIC/_IPP_SEQUENTIAL_STATIC do not have any effect in current configuration")
- #endif
-#endif
-
-#if !defined( _IPP_NO_DEFAULT_LIB )
- #if defined( _IPP_PARALLEL_STATIC )
- #pragma comment( lib, "libircmt" )
- #pragma comment( lib, "libmmt" )
- #pragma comment( lib, "svml_dispmt" )
- #pragma comment( lib, "libiomp5md" )
- #endif
-#endif
-
-#include "ippbase.h"
-#include "ipptypes.h"
-
-extern const IppiRect ippRectInfinite;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IPPDEFS_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ipptypes.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ipptypes.h
deleted file mode 100755
index dedb27991c..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ipptypes.h
+++ /dev/null
@@ -1,1104 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __IPPTYPES_H__
-#define __IPPTYPES_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*****************************************************************************/
-/* Below are ippCore domain specific definitions */
-/*****************************************************************************/
-#if !defined( _OWN_BLDPCS )
-
-#define ippCPUID_MMX 0x00000001 /* Intel Architecture MMX technology supported */
-#define ippCPUID_SSE 0x00000002 /* Streaming SIMD Extensions */
-#define ippCPUID_SSE2 0x00000004 /* Streaming SIMD Extensions 2 */
-#define ippCPUID_SSE3 0x00000008 /* Streaming SIMD Extensions 3 */
-#define ippCPUID_SSSE3 0x00000010 /* Supplemental Streaming SIMD Extensions 3 */
-#define ippCPUID_MOVBE 0x00000020 /* The processor supports MOVBE instruction */
-#define ippCPUID_SSE41 0x00000040 /* Streaming SIMD Extensions 4.1 */
-#define ippCPUID_SSE42 0x00000080 /* Streaming SIMD Extensions 4.2 */
-#define ippCPUID_AVX 0x00000100 /* Advanced Vector Extensions instruction set */
-#define ippAVX_ENABLEDBYOS 0x00000200 /* The operating system supports AVX */
-#define ippCPUID_AES 0x00000400 /* AES instruction */
-#define ippCPUID_CLMUL 0x00000800 /* PCLMULQDQ instruction */
-#define ippCPUID_ABR 0x00001000 /* Reserved */
-#define ippCPUID_RDRAND 0x00002000 /* Read Random Number instructions */
-#define ippCPUID_F16C 0x00004000 /* Float16 instructions */
-#define ippCPUID_AVX2 0x00008000 /* Advanced Vector Extensions 2 instruction set */
-#define ippCPUID_ADCOX 0x00010000 /* ADCX and ADOX instructions */
-#define ippCPUID_RDSEED 0x00020000 /* The RDSEED instruction */
-#define ippCPUID_PREFETCHW 0x00040000 /* The PREFETCHW instruction */
-#define ippCPUID_SHA 0x00080000 /* Intel (R) SHA Extensions */
-#define ippCPUID_AVX512F 0x00100000 /* AVX-512 Foundation instructions */
-#define ippCPUID_AVX512CD 0x00200000 /* AVX-512 Conflict Detection instructions */
-#define ippCPUID_AVX512ER 0x00400000 /* AVX-512 Exponential & Reciprocal instructions*/
-#define ippCPUID_AVX512PF 0x00800000 /* AVX-512 Prefetch instructions */
-#define ippCPUID_AVX512BW 0x01000000 /* AVX-512 Byte & Word instructions */
-#define ippCPUID_AVX512DQ 0x02000000 /* AVX-512 DWord & QWord instructions */
-#define ippCPUID_AVX512VL 0x04000000 /* AVX-512 Vector Length extensions */
-#define ippCPUID_KNC 0x80000000 /* Intel(R) Xeon Phi(TM) Coprocessor */
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define ippCPUID_NOCHECK 0x8000000000000000L /* Force ippSetCpuFeatures to set CPU features without check */
-#else
- #define ippCPUID_NOCHECK 0x8000000000000000LL
-#endif
-
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define ippCPUID_GETINFO_A 0x616f666e69746567L /* Force ipp_GetCpuFeatures to work as cpuid instruction */
-#else
- #define ippCPUID_GETINFO_A 0x616f666e69746567LL
-#endif
-
-#define IPP_COUNT_OF( obj ) (sizeof(obj)/sizeof(obj[0]))
-
-/*****************************************************************************/
-/* Below are ippSP domain specific definitions */
-/*****************************************************************************/
-typedef enum {
- ippRndZero,
- ippRndNear,
- ippRndFinancial,
- ippRndHintAccurate=0x10
-} IppRoundMode;
-
-
-typedef enum {
- ippAlgHintNone,
- ippAlgHintFast,
- ippAlgHintAccurate
-} IppHintAlgorithm;
-
-typedef enum {
- ippCmpLess,
- ippCmpLessEq,
- ippCmpEq,
- ippCmpGreaterEq,
- ippCmpGreater
-} IppCmpOp;
-
-typedef enum {
- ippAlgAuto = 0x00000000,
- ippAlgDirect = 0x00000001,
- ippAlgFFT = 0x00000002,
- ippAlgMask = 0x000000FF
-} IppAlgType;
-
-typedef enum {
- ippsNormNone = 0x00000000, /* default */
- ippsNormA = 0x00000100, /* biased normalization */
- ippsNormB = 0x00000200, /* unbiased normalization */
- ippsNormMask = 0x0000FF00
-} IppsNormOp;
-
-typedef enum {
- ippNormInf = 0x00000001,
- ippNormL1 = 0x00000002,
- ippNormL2 = 0x00000004
-} IppNormType;
-
-enum {
- IPP_FFT_DIV_FWD_BY_N = 1,
- IPP_FFT_DIV_INV_BY_N = 2,
- IPP_FFT_DIV_BY_SQRTN = 4,
- IPP_FFT_NODIV_BY_ANY = 8
-};
-
-enum {
- IPP_DIV_FWD_BY_N = 1,
- IPP_DIV_INV_BY_N = 2,
- IPP_DIV_BY_SQRTN = 4,
- IPP_NODIV_BY_ANY = 8
-};
-
-typedef struct {
- Ipp32f rho;
- Ipp32f theta;
-} IppPointPolar;
-
-typedef enum {ippWinBartlett,ippWinBlackman,ippWinHamming,ippWinHann,ippWinRect} IppWinType;
-
-typedef enum { ippButterworth, ippChebyshev1 } IppsIIRFilterType;
-
-typedef enum { ippZCR=0, ippZCXor, ippZCC } IppsZCType;
-
-#if !defined( _OWN_BLDPCS )
-
-typedef struct {
- int left;
- int right;
-} IppsROI;
-
-typedef struct RandUniState_8u IppsRandUniState_8u;
-typedef struct RandUniState_16s IppsRandUniState_16s;
-typedef struct RandUniState_32f IppsRandUniState_32f;
-typedef struct RandUniState_64f IppsRandUniState_64f;
-
-typedef struct RandGaussState_8u IppsRandGaussState_8u;
-typedef struct RandGaussState_16s IppsRandGaussState_16s;
-typedef struct RandGaussState_32f IppsRandGaussState_32f;
-typedef struct RandGaussState_64f IppsRandGaussState_64f;
-
-typedef struct FFTSpec_C_32fc IppsFFTSpec_C_32fc;
-typedef struct FFTSpec_C_32f IppsFFTSpec_C_32f;
-typedef struct FFTSpec_R_32f IppsFFTSpec_R_32f;
-
-typedef struct FFTSpec_C_64fc IppsFFTSpec_C_64fc;
-typedef struct FFTSpec_C_64f IppsFFTSpec_C_64f;
-typedef struct FFTSpec_R_64f IppsFFTSpec_R_64f;
-
-typedef struct DFTSpec_C_32fc IppsDFTSpec_C_32fc;
-typedef struct DFTSpec_C_32f IppsDFTSpec_C_32f;
-typedef struct DFTSpec_R_32f IppsDFTSpec_R_32f;
-
-typedef struct DFTSpec_C_64fc IppsDFTSpec_C_64fc;
-typedef struct DFTSpec_C_64f IppsDFTSpec_C_64f;
-typedef struct DFTSpec_R_64f IppsDFTSpec_R_64f;
-
-typedef struct DCTFwdSpec_32f IppsDCTFwdSpec_32f;
-typedef struct DCTInvSpec_32f IppsDCTInvSpec_32f;
-
-typedef struct DCTFwdSpec_64f IppsDCTFwdSpec_64f;
-typedef struct DCTInvSpec_64f IppsDCTInvSpec_64f;
-
-typedef struct sWTFwdState_32f IppsWTFwdState_32f;
-typedef struct sWTFwdState_8u32f IppsWTFwdState_8u32f;
-typedef struct sWTFwdState_16s32f IppsWTFwdState_16s32f;
-typedef struct sWTFwdState_16u32f IppsWTFwdState_16u32f;
-typedef struct sWTInvState_32f IppsWTInvState_32f;
-typedef struct sWTInvState_32f8u IppsWTInvState_32f8u;
-typedef struct sWTInvState_32f16s IppsWTInvState_32f16s;
-typedef struct sWTInvState_32f16u IppsWTInvState_32f16u;
-
-typedef struct IIRState_32f IppsIIRState_32f;
-typedef struct IIRState_32fc IppsIIRState_32fc;
-typedef struct IIRState32f_16s IppsIIRState32f_16s;
-typedef struct IIRState32fc_16sc IppsIIRState32fc_16sc;
-typedef struct IIRState_64f IppsIIRState_64f;
-typedef struct IIRState_64fc IppsIIRState_64fc;
-typedef struct IIRState64f_32f IppsIIRState64f_32f;
-typedef struct IIRState64fc_32fc IppsIIRState64fc_32fc;
-typedef struct IIRState64f_32s IppsIIRState64f_32s;
-typedef struct IIRState64fc_32sc IppsIIRState64fc_32sc;
-typedef struct IIRState64f_16s IppsIIRState64f_16s;
-typedef struct IIRState64fc_16sc IppsIIRState64fc_16sc;
-
-typedef struct FIRSpec_32f IppsFIRSpec_32f;
-typedef struct FIRSpec_64f IppsFIRSpec_64f;
-typedef struct FIRSpec_32fc IppsFIRSpec_32fc;
-typedef struct FIRSpec_64fc IppsFIRSpec_64fc;
-
-typedef struct FIRLMSState_32f IppsFIRLMSState_32f;
-typedef struct FIRLMSState32f_16s IppsFIRLMSState32f_16s;
-
-typedef struct HilbertSpec IppsHilbertSpec;
-
-typedef struct FIRSparseState_32f IppsFIRSparseState_32f;
-typedef struct IIRSparseState_32f IppsIIRSparseState_32f;
-
-typedef struct ResamplingPolyphase_16s IppsResamplingPolyphase_16s;
-typedef struct ResamplingPolyphaseFixed_16s IppsResamplingPolyphaseFixed_16s;
-typedef struct ResamplingPolyphase_32f IppsResamplingPolyphase_32f;
-typedef struct ResamplingPolyphaseFixed_32f IppsResamplingPolyphaseFixed_32f;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippIP domain specific definitions */
-/*****************************************************************************/
-#define IPP_TEMPORAL_COPY 0x0
-#define IPP_NONTEMPORAL_STORE 0x01
-#define IPP_NONTEMPORAL_LOAD 0x02
-
-typedef int IppEnum;
-
-#define IPP_DEG_TO_RAD( deg ) ( (deg)/180.0 * IPP_PI )
-
-typedef enum {
- ippiNormNone = 0x00000000, /* default */
- ippiNorm = 0x00000100, /* normalized form */
- ippiNormCoefficient = 0x00000200, /* correlation coefficient in the range [-1.0 ... 1.0] */
- ippiNormMask = 0x0000FF00
-} IppiNormOp;
-
-typedef enum {
- ippiROIFull = 0x00000000,
- ippiROIValid = 0x00010000,
- ippiROISame = 0x00020000,
- ippiROIMask = 0x00FF0000
-} IppiROIShape;
-
-typedef enum {
- ippC0 = 0,
- ippC1 = 1,
- ippC2 = 2,
- ippC3 = 3,
- ippC4 = 4,
- ippP2 = 5,
- ippP3 = 6,
- ippP4 = 7,
- ippAC1 = 8,
- ippAC4 = 9,
- ippA0C4 = 10,
- ippAP4 = 11
-} IppChannels;
-
-typedef enum _IppiBorderType {
- ippBorderConst = 0,
- ippBorderRepl = 1,
- ippBorderWrap = 2,
- ippBorderMirror = 3, /* left border: 012... -> 21012... */
- ippBorderMirrorR = 4, /* left border: 012... -> 210012... */
- ippBorderInMem = 6,
- ippBorderTransp = 7,
- ippBorderInMemTop = 0x0010,
- ippBorderInMemBottom = 0x0020,
- ippBorderInMemLeft = 0x0040,
- ippBorderInMemRight = 0x0080
-} IppiBorderType;
-
-typedef enum {
- ippAxsHorizontal,
- ippAxsVertical,
- ippAxsBoth,
- ippAxs45,
- ippAxs135
-} IppiAxis;
-
-typedef struct {
- int x;
- int y;
- int width;
- int height;
-} IppiRect;
-
-typedef struct {
- int x;
- int y;
-} IppiPoint;
-
-typedef struct {
- int width;
- int height;
-} IppiSize;
-
-typedef struct {
- Ipp32f x;
- Ipp32f y;
-} IppiPoint_32f;
-
-typedef enum _IppiMaskSize {
- ippMskSize1x3 = 13,
- ippMskSize1x5 = 15,
- ippMskSize3x1 = 31,
- ippMskSize3x3 = 33,
- ippMskSize5x1 = 51,
- ippMskSize5x5 = 55
-} IppiMaskSize;
-
-enum {
- IPPI_INTER_NN = 1,
- IPPI_INTER_LINEAR = 2,
- IPPI_INTER_CUBIC = 4,
- IPPI_INTER_CUBIC2P_BSPLINE, /* two-parameter cubic filter (B=1, C=0) */
- IPPI_INTER_CUBIC2P_CATMULLROM, /* two-parameter cubic filter (B=0, C=1/2) */
- IPPI_INTER_CUBIC2P_B05C03, /* two-parameter cubic filter (B=1/2, C=3/10) */
- IPPI_INTER_SUPER = 8,
- IPPI_INTER_LANCZOS = 16,
- IPPI_ANTIALIASING = (1 << 29),
- IPPI_SUBPIXEL_EDGE = (1 << 30),
- IPPI_SMOOTH_EDGE = (1 << 31)
-};
-
-typedef enum {
- ippNearest = IPPI_INTER_NN,
- ippLinear = IPPI_INTER_LINEAR,
- ippCubic = IPPI_INTER_CUBIC2P_CATMULLROM,
- ippLanczos = IPPI_INTER_LANCZOS,
- ippHahn = 0,
- ippSuper = IPPI_INTER_SUPER
-} IppiInterpolationType;
-
-typedef enum {
- ippPolyphase_1_2,
- ippPolyphase_3_5,
- ippPolyphase_2_3,
- ippPolyphase_7_10,
- ippPolyphase_3_4
-} IppiFraction;
-
-enum {
- IPP_FASTN_ORIENTATION = 0x0001,
- IPP_FASTN_NMS = 0x0002,
- IPP_FASTN_CIRCLE = 0X0004,
- IPP_FASTN_SCORE_MODE0 = 0X0020
-};
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum {
- ippAlphaOver,
- ippAlphaIn,
- ippAlphaOut,
- ippAlphaATop,
- ippAlphaXor,
- ippAlphaPlus,
- ippAlphaOverPremul,
- ippAlphaInPremul,
- ippAlphaOutPremul,
- ippAlphaATopPremul,
- ippAlphaXorPremul,
- ippAlphaPlusPremul
-} IppiAlphaType;
-
-typedef struct DeconvFFTState_32f_C1R IppiDeconvFFTState_32f_C1R;
-typedef struct DeconvFFTState_32f_C3R IppiDeconvFFTState_32f_C3R;
-typedef struct DeconvLR_32f_C1R IppiDeconvLR_32f_C1R;
-typedef struct DeconvLR_32f_C3R IppiDeconvLR_32f_C3R;
-
-typedef enum {
- ippiFilterBilateralGauss = 100,
- ippiFilterBilateralGaussFast = 101
-} IppiFilterBilateralType;
-
-typedef struct FilterBilateralSpec IppiFilterBilateralSpec;
-
-typedef enum {
- ippDistNormL1 = 0x00000002
-} IppiDistanceMethodType;
-
-typedef enum {
- ippResizeFilterHann,
- ippResizeFilterLanczos
-} IppiResizeFilterType;
-
-typedef struct ResizeFilterState IppiResizeFilterState;
-
-typedef struct {
- Ipp32u borderLeft;
- Ipp32u borderTop;
- Ipp32u borderRight;
- Ipp32u borderBottom;
-} IppiBorderSize;
-
-typedef enum {
- ippWarpForward,
- ippWarpBackward,
-} IppiWarpDirection;
-
-typedef enum {
- ippWarpAffine,
- ippWarpPerspective,
- ippWarpBilinear,
-} IppiWarpTransformType;
-
-
-typedef struct ResizeSpec_32f IppiResizeSpec_32f;
-typedef struct ResizeYUV422Spec IppiResizeYUV422Spec;
-typedef struct ResizeYUV420Spec IppiResizeYUV420Spec;
-
-typedef struct ResizeSpec_64f IppiResizeSpec_64f;
-
-typedef struct IppiWarpSpec IppiWarpSpec;
-
-typedef struct FilterBorderSpec IppiFilterBorderSpec;
-
-typedef struct ThresholdAdaptiveSpec IppiThresholdAdaptiveSpec;
-
-typedef struct HistogramSpec IppiHistogramSpec;
-
-typedef struct {
- int cvCompatible; /* openCV compatible output format */
- int cellSize; /* squre cell size (pixels) */
- int blockSize; /* square block size (pixels) */
- int blockStride; /* block displacement (the same for x- and y- directions) */
- int nbins; /* required number of bins */
- Ipp32f sigma; /* gaussian factor of HOG block weights */
- Ipp32f l2thresh; /* normalization factor */
- IppiSize winSize; /* detection window size (pixels) */
-} IppiHOGConfig;
-
-typedef struct FFT2DSpec_C_32fc IppiFFTSpec_C_32fc;
-typedef struct FFT2DSpec_R_32f IppiFFTSpec_R_32f;
-
-typedef struct DFT2DSpec_C_32fc IppiDFTSpec_C_32fc;
-typedef struct DFT2DSpec_R_32f IppiDFTSpec_R_32f;
-
-typedef struct DCT2DFwdSpec_32f IppiDCTFwdSpec_32f;
-typedef struct DCT2DInvSpec_32f IppiDCTInvSpec_32f;
-
-typedef struct iWTFwdSpec_32f_C1R IppiWTFwdSpec_32f_C1R;
-typedef struct iWTInvSpec_32f_C1R IppiWTInvSpec_32f_C1R;
-typedef struct iWTFwdSpec_32f_C3R IppiWTFwdSpec_32f_C3R;
-typedef struct iWTInvSpec_32f_C3R IppiWTInvSpec_32f_C3R;
-
-typedef struct MomentState64f IppiMomentState_64f;
-typedef Ipp64f IppiHuMoment_64f[7];
-
-typedef struct LUT_Spec IppiLUT_Spec;
-
-#define IPP_HOG_MAX_CELL (16) /* max size of CELL */
-#define IPP_HOG_MAX_BLOCK (64) /* max size of BLOCK */
-#define IPP_HOG_MAX_BINS (16) /* max number of BINS */
-
-typedef struct _ipHOG IppiHOGSpec;
-
-#endif /* _OWN_BLDPCS */
-
-
- /**** Below are 3D Image (Volume) Processing specific definitions ****/
-
-typedef struct {
- int width;
- int height;
- int depth;
-} IpprVolume;
-
-typedef struct {
- int x;
- int y;
- int z;
- int width;
- int height;
- int depth;
-} IpprCuboid;
-
-typedef struct {
- int x;
- int y;
- int z;
-} IpprPoint;
-
-/*****************************************************************************/
-/* Below are ippCV domain specific definitions */
-/*****************************************************************************/
-
-typedef enum _IppiDifferentialKernel
-{
- ippFilterSobelVert,
- ippFilterSobelHoriz,
- ippFilterSobel,
- ippFilterScharrVert,
- ippFilterScharrHoriz,
- ippFilterScharr,
- ippFilterCentralDiffVert,
- ippFilterCentralDiffHoriz,
- ippFilterCentralDiff,
-}IppiDifferentialKernel;
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum _IppiKernelType {
- ippKernelSobel = 0,
- ippKernelScharr = 1,
- ippKernelSobelNeg = 2
-} IppiKernelType;
-
-typedef enum _IppiNorm {
- ippiNormInf = 0,
- ippiNormL1 = 1,
- ippiNormL2 = 2,
- ippiNormFM = 3
-} IppiNorm;
-
-typedef struct ipcvMorphState IppiMorphState;
-typedef struct ipcvMorphAdvState IppiMorphAdvState;
-typedef struct ipcvMorphGrayState_8u IppiMorphGrayState_8u;
-typedef struct ipcvMorphGrayState_32f IppiMorphGrayState_32f;
-
-typedef struct ipcvConvState IppiConvState;
-
-typedef struct _IppiConnectedComp {
- Ipp64f area; /* area of the segmented component */
- Ipp64f value[3];/* gray scale value of the segmented component */
- IppiRect rect; /* bounding rectangle of the segmented component */
-} IppiConnectedComp;
-
-typedef struct PyramidState IppiPyramidState;
-
-typedef IppiPyramidState IppiPyramidDownState_8u_C1R;
-typedef IppiPyramidState IppiPyramidDownState_16u_C1R;
-typedef IppiPyramidState IppiPyramidDownState_32f_C1R;
-typedef IppiPyramidState IppiPyramidDownState_8u_C3R;
-typedef IppiPyramidState IppiPyramidDownState_16u_C3R;
-typedef IppiPyramidState IppiPyramidDownState_32f_C3R;
-typedef IppiPyramidState IppiPyramidUpState_8u_C1R;
-typedef IppiPyramidState IppiPyramidUpState_16u_C1R;
-typedef IppiPyramidState IppiPyramidUpState_32f_C1R;
-typedef IppiPyramidState IppiPyramidUpState_8u_C3R;
-typedef IppiPyramidState IppiPyramidUpState_16u_C3R;
-typedef IppiPyramidState IppiPyramidUpState_32f_C3R;
-
-
-typedef struct _IppiPyramid {
- Ipp8u **pImage;
- IppiSize *pRoi;
- Ipp64f *pRate;
- int *pStep;
- Ipp8u *pState;
- int level;
-} IppiPyramid;
-
-typedef struct OptFlowPyrLK IppiOptFlowPyrLK;
-
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_8u_C1R;
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_16u_C1R;
-typedef IppiOptFlowPyrLK IppiOptFlowPyrLK_32f_C1R;
-
-typedef struct ipcvHaarClassifier_32f IppiHaarClassifier_32f;
-typedef struct ipcvHaarClassifier_32s IppiHaarClassifier_32s;
-
-typedef struct ipcvFGHistogramState_8u_C1R IppFGHistogramState_8u_C1R;
-typedef struct ipcvFGHistogramState_8u_C3R IppFGHistogramState_8u_C3R;
-
-typedef struct ipcvFGGaussianState_8u_C1R IppFGGaussianState_8u_C1R;
-typedef struct ipcvFGGaussianState_8u_C3R IppFGGaussianState_8u_C3R;
-
-typedef enum _IppiInpaintFlag {
- IPP_INPAINT_TELEA = 0,
- IPP_INPAINT_NS = 1
-} IppiInpaintFlag;
-
-typedef struct ippcvFilterGaussianSpec IppFilterGaussianSpec;
-
-typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C1R;
-typedef struct ipcvInpaintState_8u IppiInpaintState_8u_C3R;
-
-typedef struct HoughProbSpec IppiHoughProbSpec;
-
-typedef struct FastNSpec IppiFastNSpec;
-
-typedef struct _IppiCornerFastN {
- int x;
- int y;
- int cornerType;
- int orientation;
- float angle;
- float score;
-} IppiCornerFastN;
-
-typedef struct FGMMState_8u_C3R IppFGMMState_8u_C3R;
-
-typedef struct
-{
- unsigned int numFrames;
- unsigned int maxNGauss;
- Ipp32f varInit;
- Ipp32f varMin;
- Ipp32f varMax;
- Ipp32f varWBRatio;
- Ipp32f bckgThr;
- Ipp32f varNGRatio;
- Ipp32f reduction;
- Ipp8u shadowValue;
- char shadowFlag;
- Ipp32f shadowRatio;
-} IppFGMModel;
-
-#endif /* _OWN_BLDPCS */
-
-#define IPP_SEGMENT_QUEUE 0x01
-#define IPP_SEGMENT_DISTANCE 0x02
-#define IPP_SEGMENT_BORDER_4 0x40
-#define IPP_SEGMENT_BORDER_8 0x80
-
-#define IPP_TRUNC(a,b) ((a)&~((b)-1))
-#define IPP_APPEND(a,b) (((a)+(b)-1)&~((b)-1))
-
-/*****************************************************************************/
-/* Below are ippCC domain specific definitions */
-/*****************************************************************************/
-enum {
- IPP_UPPER = 1,
- IPP_LEFT = 2,
- IPP_CENTER = 4,
- IPP_RIGHT = 8,
- IPP_LOWER = 16,
- IPP_UPPER_LEFT = 32,
- IPP_UPPER_RIGHT = 64,
- IPP_LOWER_LEFT = 128,
- IPP_LOWER_RIGHT = 256
-};
-
-#if !defined( _OWN_BLDPCS )
-
-typedef enum {
- ippDitherNone,
- ippDitherFS,
- ippDitherJJN,
- ippDitherStucki,
- ippDitherBayer
-} IppiDitherType;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippCH domain specific definitions */
-/*****************************************************************************/
-
-#if !defined( _OWN_BLDPCS )
-
-typedef struct {
- void *pFind;
- int lenFind;
-} IppRegExpFind;
-
-typedef struct RegExpState IppRegExpState;
-
-typedef enum {
- ippFmtASCII = 0,
- ippFmtUTF8
-} IppRegExpFormat;
-
-typedef struct RegExpReplaceState IppRegExpReplaceState;
-
-#endif /* _OWN_BLDPCS */
-
-/*****************************************************************************/
-/* Below are ippDC domain specific definitions */
-/*****************************************************************************/
-
-#if !defined ( _OWN_BLDPCS )
-
-typedef struct MTFState_8u IppMTFState_8u;
-
-typedef enum {
- ippBWTItohTanakaLimSort,
- ippBWTItohTanakaUnlimSort,
- ippBWTSuffixSort,
- ippBWTAutoSort
-} IppBWTSortAlgorithmHint;
-
-typedef struct LZSSState_8u IppLZSSState_8u;
-
-typedef struct LZ77State_8u IppLZ77State_8u;
-typedef enum{
- IppLZ77FastCompr,
- IppLZ77AverageCompr,
- IppLZ77BestCompr
-} IppLZ77ComprLevel;
-typedef enum{
- IppLZ77NoChcksm,
- IppLZ77Adler32,
- IppLZ77CRC32
-} IppLZ77Chcksm;
-typedef enum {
- IppLZ77NoFlush,
- IppLZ77SyncFlush,
- IppLZ77FullFlush,
- IppLZ77FinishFlush
-} IppLZ77Flush;
-typedef struct IppLZ77Pairs_16u {
- Ipp16u length;
- Ipp16u offset;
-} IppLZ77Pair;
-typedef enum {
- IppLZ77StatusInit,
- IppLZ77StatusLZ77Process,
- IppLZ77StatusHuffProcess,
- IppLZ77StatusFinal
-} IppLZ77DeflateStatus;
-typedef enum {
- IppLZ77UseFixed,
- IppLZ77UseDynamic,
- IppLZ77UseStored
-} IppLZ77HuffMode;
-typedef enum {
- IppLZ77InflateStatusInit,
- IppLZ77InflateStatusHuffProcess,
- IppLZ77InflateStatusLZ77Process,
- IppLZ77InflateStatusFinal
-} IppLZ77InflateStatus;
-
-typedef struct IppInflateState {
- const Ipp8u* pWindow; /* pointer to the sliding window
- (the dictionary for the LZ77 algorithm) */
- unsigned int winSize; /* size of the sliding window */
- unsigned int tableType; /* type of Huffman code tables
- (for example, 0 - tables for Fixed Huffman codes) */
- unsigned int tableBufferSize; /* (ENOUGH = 2048) * (sizeof(code) = 4) -
- sizeof(IppInflateState) */
-} IppInflateState;
-
-typedef enum { /* this type is used as a translator of the inflate_mode type from zlib */
- ippTYPE,
- ippLEN,
- ippLENEXT
-} IppInflateMode;
-
-typedef struct {
- Ipp16u freq;
- Ipp16u code;
-} IppDeflateFreqTable;
-
-typedef struct {
- Ipp16u code;
- Ipp16u len;
-} IppDeflateHuffCode;
-
-typedef struct RLEState_BZ2 IppRLEState_BZ2;
-
-typedef struct EncodeHuffState_BZ2 IppEncodeHuffState_BZ2;
-
-typedef struct DecodeHuffState_BZ2 IppDecodeHuffState_BZ2;
-
-typedef enum {
- IppLZO1XST, /* Single-threaded, generic LZO-compatible*/
- IppLZO1XMT /* Multi-threaded */
-} IppLZOMethod ;
-
-typedef struct LZOState_8u IppLZOState_8u;
-
-#endif /* _OWN_BLDPCS */
-
-/* /////////////////////////////////////////////////////////////////////////////
-// The following enumerator defines a status of IPP operations
-// negative value means error
-*/
-typedef enum {
- /* errors */
- ippStsNotSupportedModeErr = -9999,/* The requested mode is currently not supported. */
- ippStsCpuNotSupportedErr = -9998,/* The target CPU is not supported. */
- ippStsInplaceModeNotSupportedErr = -9997,/* The inplace operation is currently not supported. */
-
- ippStsIIRIIRLengthErr = -234, /* Vector length for IIRIIR function is less than 3*(IIR order) */
- ippStsWarpTransformTypeErr = -233, /* The warp transform type is illegal */
- ippStsExceededSizeErr = -232, /* Requested size exceeded the maximum supported ROI size */
- ippStsWarpDirectionErr = -231, /* The warp transform direction is illegal */
-
- ippStsFilterTypeErr = -230, /* The filter type is incorrect or not supported */
-
- ippStsNormErr = -229, /* The norm is incorrect or not supported */
-
- ippStsAlgTypeErr = -228, /* Algorithm type is not supported. */
- ippStsMisalignedOffsetErr = -227, /* The offset is not aligned with an element. */
-
- ippStsQuadraticNonResidueErr = -226, /* SQRT operation on quadratic non-residue value. */
-
- ippStsBorderErr = -225, /* Illegal value for border type.*/
-
- ippStsDitherTypeErr = -224, /* Dithering type is not supported. */
- ippStsH264BufferFullErr = -223, /* Buffer for the output bitstream is full. */
- ippStsWrongAffinitySettingErr= -222, /* An affinity setting does not correspond to the affinity setting that was set by f.ippSetAffinity(). */
- ippStsLoadDynErr = -221, /* Error when loading the dynamic library. */
-
- ippStsPointAtInfinity = -220, /* Point at infinity is detected. */
-
- ippStsUnknownStatusCodeErr = -216, /* Unknown status code. */
-
- ippStsOFBSizeErr = -215, /* Incorrect value for crypto OFB block size. */
- ippStsLzoBrokenStreamErr = -214, /* LZO safe decompression function cannot decode LZO stream. */
-
- ippStsRoundModeNotSupportedErr = -213, /* Rounding mode is not supported. */
- ippStsDecimateFractionErr = -212, /* Fraction in Decimate is not supported. */
- ippStsWeightErr = -211, /* Incorrect value for weight. */
-
- ippStsQualityIndexErr = -210, /* Cannot calculate the quality index for an image filled with a constant. */
- ippStsIIRPassbandRippleErr = -209, /* Ripple in passband for Chebyshev1 design is less than zero, equal to zero, or greater than 29. */
- ippStsFilterFrequencyErr = -208, /* Cutoff frequency of filter is less than zero, equal to zero, or greater than 0.5. */
- ippStsFIRGenOrderErr = -207, /* Order of the FIR filter for design is less than 1. */
- ippStsIIRGenOrderErr = -206, /* Order of the IIR filter for design is less than 1, or greater than 12. */
-
- ippStsConvergeErr = -205, /* The algorithm does not converge. */
- ippStsSizeMatchMatrixErr = -204, /* The sizes of the source matrices are unsuitable. */
- ippStsCountMatrixErr = -203, /* Count value is less than, or equal to zero. */
- ippStsRoiShiftMatrixErr = -202, /* RoiShift value is negative or not divisible by the size of the data type. */
-
- ippStsResizeNoOperationErr = -201, /* One of the output image dimensions is less than 1 pixel. */
- ippStsSrcDataErr = -200, /* The source buffer contains unsupported data. */
- ippStsMaxLenHuffCodeErr = -199, /* Huff: Max length of Huffman code is more than the expected one. */
- ippStsCodeLenTableErr = -198, /* Huff: Invalid codeLenTable. */
- ippStsFreqTableErr = -197, /* Huff: Invalid freqTable. */
-
- ippStsIncompleteContextErr = -196, /* Crypto: set up of context is not complete. */
-
- ippStsSingularErr = -195, /* Matrix is singular. */
- ippStsSparseErr = -194, /* Positions of taps are not in ascending order, or are negative, or repetitive. */
- ippStsBitOffsetErr = -193, /* Incorrect bit offset value. */
- ippStsQPErr = -192, /* Incorrect quantization parameter value. */
- ippStsVLCErr = -191, /* Illegal VLC or FLC is detected during stream decoding. */
- ippStsRegExpOptionsErr = -190, /* RegExp: Options for the pattern are incorrect. */
- ippStsRegExpErr = -189, /* RegExp: The structure pRegExpState contains incorrect data. */
- ippStsRegExpMatchLimitErr = -188, /* RegExp: The match limit is exhausted. */
- ippStsRegExpQuantifierErr = -187, /* RegExp: Incorrect quantifier. */
- ippStsRegExpGroupingErr = -186, /* RegExp: Incorrect grouping. */
- ippStsRegExpBackRefErr = -185, /* RegExp: Incorrect back reference. */
- ippStsRegExpChClassErr = -184, /* RegExp: Incorrect character class. */
- ippStsRegExpMetaChErr = -183, /* RegExp: Incorrect metacharacter. */
- ippStsStrideMatrixErr = -182, /* Stride value is not positive or not divisible by the size of the data type. */
- ippStsCTRSizeErr = -181, /* Incorrect value for crypto CTR block size. */
- ippStsJPEG2KCodeBlockIsNotAttached =-180, /* Codeblock parameters are not attached to the state structure. */
- ippStsNotPosDefErr = -179, /* Matrix is not positive definite. */
-
- ippStsEphemeralKeyErr = -178, /* ECC: Invalid ephemeral key. */
- ippStsMessageErr = -177, /* ECC: Invalid message digest. */
- ippStsShareKeyErr = -176, /* ECC: Invalid share key. */
- ippStsIvalidPublicKey = -175, /* ECC: Invalid public key. */
- ippStsIvalidPrivateKey = -174, /* ECC: Invalid private key. */
- ippStsOutOfECErr = -173, /* ECC: Point out of EC. */
- ippStsECCInvalidFlagErr = -172, /* ECC: Invalid Flag. */
-
- ippStsMP3FrameHeaderErr = -171, /* Error in fields of the IppMP3FrameHeader structure. */
- ippStsMP3SideInfoErr = -170, /* Error in fields of the IppMP3SideInfo structure. */
-
- ippStsBlockStepErr = -169, /* Step for Block is less than 8. */
- ippStsMBStepErr = -168, /* Step for MB is less than 16. */
-
- ippStsAacPrgNumErr = -167, /* AAC: Invalid number of elements for one program. */
- ippStsAacSectCbErr = -166, /* AAC: Invalid section codebook. */
- ippStsAacSfValErr = -164, /* AAC: Invalid scalefactor value. */
- ippStsAacCoefValErr = -163, /* AAC: Invalid quantized coefficient value. */
- ippStsAacMaxSfbErr = -162, /* AAC: Invalid coefficient index. */
- ippStsAacPredSfbErr = -161, /* AAC: Invalid predicted coefficient index. */
- ippStsAacPlsDataErr = -160, /* AAC: Invalid pulse data attributes. */
- ippStsAacGainCtrErr = -159, /* AAC: Gain control is not supported. */
- ippStsAacSectErr = -158, /* AAC: Invalid number of sections. */
- ippStsAacTnsNumFiltErr = -157, /* AAC: Invalid number of TNS filters. */
- ippStsAacTnsLenErr = -156, /* AAC: Invalid length of TNS region. */
- ippStsAacTnsOrderErr = -155, /* AAC: Invalid order of TNS filter. */
- ippStsAacTnsCoefResErr = -154, /* AAC: Invalid bit-resolution for TNS filter coefficients. */
- ippStsAacTnsCoefErr = -153, /* AAC: Invalid coefficients of TNS filter. */
- ippStsAacTnsDirectErr = -152, /* AAC: Invalid direction TNS filter. */
- ippStsAacTnsProfileErr = -151, /* AAC: Invalid TNS profile. */
- ippStsAacErr = -150, /* AAC: Internal error. */
- ippStsAacBitOffsetErr = -149, /* AAC: Invalid current bit offset in bitstream. */
- ippStsAacAdtsSyncWordErr = -148, /* AAC: Invalid ADTS syncword. */
- ippStsAacSmplRateIdxErr = -147, /* AAC: Invalid sample rate index. */
- ippStsAacWinLenErr = -146, /* AAC: Invalid window length (not short or long). */
- ippStsAacWinGrpErr = -145, /* AAC: Invalid number of groups for current window length. */
- ippStsAacWinSeqErr = -144, /* AAC: Invalid window sequence range. */
- ippStsAacComWinErr = -143, /* AAC: Invalid common window flag. */
- ippStsAacStereoMaskErr = -142, /* AAC: Invalid stereo mask. */
- ippStsAacChanErr = -141, /* AAC: Invalid channel number. */
- ippStsAacMonoStereoErr = -140, /* AAC: Invalid mono-stereo flag. */
- ippStsAacStereoLayerErr = -139, /* AAC: Invalid this Stereo Layer flag. */
- ippStsAacMonoLayerErr = -138, /* AAC: Invalid this Mono Layer flag. */
- ippStsAacScalableErr = -137, /* AAC: Invalid scalable object flag. */
- ippStsAacObjTypeErr = -136, /* AAC: Invalid audio object type. */
- ippStsAacWinShapeErr = -135, /* AAC: Invalid window shape. */
- ippStsAacPcmModeErr = -134, /* AAC: Invalid PCM output interleaving indicator. */
- ippStsVLCUsrTblHeaderErr = -133, /* VLC: Invalid header inside table. */
- ippStsVLCUsrTblUnsupportedFmtErr = -132, /* VLC: Table format is not supported. */
- ippStsVLCUsrTblEscAlgTypeErr = -131, /* VLC: Ecs-algorithm is not supported. */
- ippStsVLCUsrTblEscCodeLengthErr = -130, /* VLC: Esc-code length inside table header is incorrect. */
- ippStsVLCUsrTblCodeLengthErr = -129, /* VLC: Code length inside table is incorrect. */
- ippStsVLCInternalTblErr = -128, /* VLC: Invalid internal table. */
- ippStsVLCInputDataErr = -127, /* VLC: Invalid input data. */
- ippStsVLCAACEscCodeLengthErr = -126, /* VLC: Invalid AAC-Esc code length. */
- ippStsNoiseRangeErr = -125, /* Noise value for Wiener Filter is out of range. */
- ippStsUnderRunErr = -124, /* Error in data under run. */
- ippStsPaddingErr = -123, /* Detected padding error indicates the possible data corruption. */
- ippStsCFBSizeErr = -122, /* Incorrect value for crypto CFB block size. */
- ippStsPaddingSchemeErr = -121, /* Invalid padding scheme. */
- ippStsInvalidCryptoKeyErr = -120, /* A compromised key causes suspansion of the requested cryptographic operation. */
- ippStsLengthErr = -119, /* Incorrect value for string length. */
- ippStsBadModulusErr = -118, /* Bad modulus caused a failure in module inversion. */
- ippStsLPCCalcErr = -117, /* Cannot evaluate linear prediction. */
- ippStsRCCalcErr = -116, /* Cannot compute reflection coefficients. */
- ippStsIncorrectLSPErr = -115, /* Incorrect values for Linear Spectral Pair. */
- ippStsNoRootFoundErr = -114, /* No roots are found for equation. */
- ippStsJPEG2KBadPassNumber = -113, /* Pass number exceeds allowed boundaries [0,nOfPasses-1]. */
- ippStsJPEG2KDamagedCodeBlock= -112, /* Codeblock for decoding contains damaged data. */
- ippStsH263CBPYCodeErr = -111, /* Illegal Huffman code is detected through CBPY stream processing. */
- ippStsH263MCBPCInterCodeErr = -110, /* Illegal Huffman code is detected through MCBPC Inter stream processing. */
- ippStsH263MCBPCIntraCodeErr = -109, /* Illegal Huffman code is detected through MCBPC Intra stream processing. */
- ippStsNotEvenStepErr = -108, /* Step value is not pixel multiple. */
- ippStsHistoNofLevelsErr = -107, /* Number of levels for histogram is less than 2. */
- ippStsLUTNofLevelsErr = -106, /* Number of levels for LUT is less than 2. */
- ippStsMP4BitOffsetErr = -105, /* Incorrect bit offset value. */
- ippStsMP4QPErr = -104, /* Incorrect quantization parameter. */
- ippStsMP4BlockIdxErr = -103, /* Incorrect block index. */
- ippStsMP4BlockTypeErr = -102, /* Incorrect block type. */
- ippStsMP4MVCodeErr = -101, /* Illegal Huffman code is detected during MV stream processing. */
- ippStsMP4VLCCodeErr = -100, /* Illegal Huffman code is detected during VLC stream processing. */
- ippStsMP4DCCodeErr = -99, /* Illegal code is detected during DC stream processing. */
- ippStsMP4FcodeErr = -98, /* Incorrect fcode value. */
- ippStsMP4AlignErr = -97, /* Incorrect buffer alignment . */
- ippStsMP4TempDiffErr = -96, /* Incorrect temporal difference. */
- ippStsMP4BlockSizeErr = -95, /* Incorrect size of a block or macroblock. */
- ippStsMP4ZeroBABErr = -94, /* All BAB values are equal to zero. */
- ippStsMP4PredDirErr = -93, /* Incorrect prediction direction. */
- ippStsMP4BitsPerPixelErr = -92, /* Incorrect number of bits per pixel. */
- ippStsMP4VideoCompModeErr = -91, /* Incorrect video component mode. */
- ippStsMP4LinearModeErr = -90, /* Incorrect DC linear mode. */
- ippStsH263PredModeErr = -83, /* Incorrect Prediction Mode value. */
- ippStsH263BlockStepErr = -82, /* The step value is less than 8. */
- ippStsH263MBStepErr = -81, /* The step value is less than 16. */
- ippStsH263FrameWidthErr = -80, /* The frame width is less than 8. */
- ippStsH263FrameHeightErr = -79, /* The frame height is less than, or equal to zero. */
- ippStsH263ExpandPelsErr = -78, /* Expand pixels number is less than 8. */
- ippStsH263PlaneStepErr = -77, /* Step value is less than the plane width. */
- ippStsH263QuantErr = -76, /* Quantizer value is less than, or equal to zero, or greater than 31. */
- ippStsH263MVCodeErr = -75, /* Illegal Huffman code is detected during MV stream processing. */
- ippStsH263VLCCodeErr = -74, /* Illegal Huffman code is detected during VLC stream processing. */
- ippStsH263DCCodeErr = -73, /* Illegal code is detected during DC stream processing. */
- ippStsH263ZigzagLenErr = -72, /* Zigzag compact length is more than 64. */
- ippStsFBankFreqErr = -71, /* Incorrect value for the filter bank frequency parameter. */
- ippStsFBankFlagErr = -70, /* Incorrect value for the filter bank parameter. */
- ippStsFBankErr = -69, /* Filter bank is not correctly initialized. */
- ippStsNegOccErr = -67, /* Occupation count is negative. */
- ippStsCdbkFlagErr = -66, /* Incorrect value for the codebook flag parameter. */
- ippStsSVDCnvgErr = -65, /* SVD algorithm does not converge. */
- ippStsJPEGHuffTableErr = -64, /* JPEG Huffman table is destroyed. */
- ippStsJPEGDCTRangeErr = -63, /* JPEG DCT coefficient is out of range. */
- ippStsJPEGOutOfBufErr = -62, /* Attempt to access out of the buffer limits. */
- ippStsDrawTextErr = -61, /* System error in the draw text operation. */
- ippStsChannelOrderErr = -60, /* Incorrect order of the destination channels. */
- ippStsZeroMaskValuesErr = -59, /* All values of the mask are equal to zero. */
- ippStsQuadErr = -58, /* The quadrangle is nonconvex or degenerates into triangle, line, or point */
- ippStsRectErr = -57, /* Size of the rectangle region is less than, or equal to 1. */
- ippStsCoeffErr = -56, /* Incorrect values for transformation coefficients. */
- ippStsNoiseValErr = -55, /* Incorrect value for noise amplitude for dithering. */
- ippStsDitherLevelsErr = -54, /* Number of dithering levels is out of range. */
- ippStsNumChannelsErr = -53, /* Number of channels is incorrect, or not supported. */
- ippStsCOIErr = -52, /* COI is out of range. */
- ippStsDivisorErr = -51, /* Divisor is equal to zero, function is aborted. */
- ippStsAlphaTypeErr = -50, /* Illegal type of image compositing operation. */
- ippStsGammaRangeErr = -49, /* Gamma range bounds is less than, or equal to zero. */
- ippStsGrayCoefSumErr = -48, /* Sum of the conversion coefficients must be less than, or equal to 1. */
- ippStsChannelErr = -47, /* Illegal channel number. */
- ippStsToneMagnErr = -46, /* Tone magnitude is less than, or equal to zero. */
- ippStsToneFreqErr = -45, /* Tone frequency is negative, or greater than, or equal to 0.5. */
- ippStsTonePhaseErr = -44, /* Tone phase is negative, or greater than, or equal to 2*PI. */
- ippStsTrnglMagnErr = -43, /* Triangle magnitude is less than, or equal to zero. */
- ippStsTrnglFreqErr = -42, /* Triangle frequency is negative, or greater than, or equal to 0.5. */
- ippStsTrnglPhaseErr = -41, /* Triangle phase is negative, or greater than, or equal to 2*PI. */
- ippStsTrnglAsymErr = -40, /* Triangle asymmetry is less than -PI, or greater than, or equal to PI. */
- ippStsHugeWinErr = -39, /* Kaiser window is too big. */
- ippStsJaehneErr = -38, /* Magnitude value is negative. */
- ippStsStrideErr = -37, /* Stride value is less than the length of the row. */
- ippStsEpsValErr = -36, /* Negative epsilon value. */
- ippStsWtOffsetErr = -35, /* Invalid offset value for wavelet filter. */
- ippStsAnchorErr = -34, /* Anchor point is outside the mask. */
- ippStsMaskSizeErr = -33, /* Invalid mask size. */
- ippStsShiftErr = -32, /* Shift value is less than zero. */
- ippStsSampleFactorErr = -31, /* Sampling factor is less than, or equal to zero. */
- ippStsSamplePhaseErr = -30, /* Phase value is out of range: 0 <= phase < factor. */
- ippStsFIRMRFactorErr = -29, /* MR FIR sampling factor is less than, or equal to zero. */
- ippStsFIRMRPhaseErr = -28, /* MR FIR sampling phase is negative, or greater than, or equal to the sampling factor. */
- ippStsRelFreqErr = -27, /* Relative frequency value is out of range. */
- ippStsFIRLenErr = -26, /* Length of a FIR filter is less than, or equal to zero. */
- ippStsIIROrderErr = -25, /* Order of an IIR filter is not valid. */
- ippStsDlyLineIndexErr = -24, /* Invalid value for the delay line sample index. */
- ippStsResizeFactorErr = -23, /* Resize factor(s) is less than, or equal to zero. */
- ippStsInterpolationErr = -22, /* Invalid interpolation mode. */
- ippStsMirrorFlipErr = -21, /* Invalid flip mode. */
- ippStsMoment00ZeroErr = -20, /* Moment value M(0,0) is too small to continue calculations. */
- ippStsThreshNegLevelErr = -19, /* Negative value of the level in the threshold operation. */
- ippStsThresholdErr = -18, /* Invalid threshold bounds. */
- ippStsContextMatchErr = -17, /* Context parameter does not match the operation. */
- ippStsFftFlagErr = -16, /* Invalid value for the FFT flag parameter. */
- ippStsFftOrderErr = -15, /* Invalid value for the FFT order parameter. */
- ippStsStepErr = -14, /* Step value is not valid. */
- ippStsScaleRangeErr = -13, /* Scale bounds are out of range. */
- ippStsDataTypeErr = -12, /* Data type is incorrect or not supported. */
- ippStsOutOfRangeErr = -11, /* Argument is out of range, or point is outside the image. */
- ippStsDivByZeroErr = -10, /* An attempt to divide by zero. */
- ippStsMemAllocErr = -9, /* Memory allocated for the operation is not enough.*/
- ippStsNullPtrErr = -8, /* Null pointer error. */
- ippStsRangeErr = -7, /* Incorrect values for bounds: the lower bound is greater than the upper bound. */
- ippStsSizeErr = -6, /* Incorrect value for data size. */
- ippStsBadArgErr = -5, /* Incorrect arg/param of the function. */
- ippStsNoMemErr = -4, /* Not enough memory for the operation. */
- ippStsSAReservedErr3 = -3, /* Unknown/unspecified error, -3. */
- ippStsErr = -2, /* Unknown/unspecified error, -2. */
- ippStsSAReservedErr1 = -1, /* Unknown/unspecified error, -1. */
-
- /* no errors */
- ippStsNoErr = 0, /* No errors. */
-
- /* warnings */
- ippStsNoOperation = 1, /* No operation has been executed. */
- ippStsMisalignedBuf = 2, /* Misaligned pointer in operation in which it must be aligned. */
- ippStsSqrtNegArg = 3, /* Negative value(s) for the argument in the Sqrt function. */
- ippStsInvZero = 4, /* INF result. Zero value was met by InvThresh with zero level. */
- ippStsEvenMedianMaskSize= 5, /* Even size of the Median Filter mask was replaced with the odd one. */
- ippStsDivByZero = 6, /* Zero value(s) for the divisor in the Div function. */
- ippStsLnZeroArg = 7, /* Zero value(s) for the argument in the Ln function. */
- ippStsLnNegArg = 8, /* Negative value(s) for the argument in the Ln function. */
- ippStsNanArg = 9, /* Argument value is not a number. */
- ippStsJPEGMarker = 10, /* JPEG marker in the bitstream. */
- ippStsResFloor = 11, /* All result values are floored. */
- ippStsOverflow = 12, /* Overflow in the operation. */
- ippStsLSFLow = 13, /* Quantized LP synthesis filter stability check is applied at the low boundary of [0,pi]. */
- ippStsLSFHigh = 14, /* Quantized LP synthesis filter stability check is applied at the high boundary of [0,pi]. */
- ippStsLSFLowAndHigh = 15, /* Quantized LP synthesis filter stability check is applied at both boundaries of [0,pi]. */
- ippStsZeroOcc = 16, /* Zero occupation count. */
- ippStsUnderflow = 17, /* Underflow in the operation. */
- ippStsSingularity = 18, /* Singularity in the operation. */
- ippStsDomain = 19, /* Argument is out of the function domain. */
- ippStsNonIntelCpu = 20, /* The target CPU is not Genuine Intel. */
- ippStsCpuMismatch = 21, /* Cannot set the library for the given CPU. */
- ippStsNoIppFunctionFound = 22, /* Application does not contain Intel IPP function calls. */
- ippStsDllNotFoundBestUsed = 23, /* Dispatcher cannot find the newest version of the Intel IPP dll. */
- ippStsNoOperationInDll = 24, /* The function does nothing in the dynamic version of the library. */
- ippStsInsufficientEntropy= 25, /* Generation of the prime/key failed due to insufficient entropy in the random seed and stimulus bit string. */
- ippStsOvermuchStrings = 26, /* Number of destination strings is more than expected. */
- ippStsOverlongString = 27, /* Length of one of the destination strings is more than expected. */
- ippStsAffineQuadChanged = 28, /* 4th vertex of destination quad is not equal to customer's one. */
- ippStsWrongIntersectROI = 29, /* ROI has no intersection with the source or destination ROI. No operation. */
- ippStsWrongIntersectQuad = 30, /* Quadrangle has no intersection with the source or destination ROI. No operation. */
- ippStsSmallerCodebook = 31, /* Size of created codebook is less than the cdbkSize argument. */
- ippStsSrcSizeLessExpected = 32, /* DC: Size of the source buffer is less than the expected one. */
- ippStsDstSizeLessExpected = 33, /* DC: Size of the destination buffer is less than the expected one. */
- ippStsStreamEnd = 34, /* DC: The end of stream processed. */
- ippStsDoubleSize = 35, /* Width or height of image is odd. */
- ippStsNotSupportedCpu = 36, /* The CPU is not supported. */
- ippStsUnknownCacheSize = 37, /* The CPU is supported, but the size of the cache is unknown. */
- ippStsSymKernelExpected = 38, /* The Kernel is not symmetric. */
- ippStsEvenMedianWeight = 39, /* Even weight of the Weighted Median Filter is replaced with the odd one. */
- ippStsWrongIntersectVOI = 40, /* VOI has no intersection with the source or destination volume. No operation. */
- ippStsI18nMsgCatalogInvalid=41, /* Message Catalog is invalid, English message returned. */
- ippStsI18nGetMessageFail = 42, /* Failed to fetch a localized message, English message returned. For more information use errno on Linux* OS and GetLastError on Windows* OS. */
- ippStsWaterfall = 43, /* Cannot load required library, waterfall is used. */
- ippStsPrevLibraryUsed = 44, /* Cannot load required library, previous dynamic library is used. */
- ippStsLLADisabled = 45, /* OpenMP* Low Level Affinity is disabled. */
- ippStsNoAntialiasing = 46, /* The mode does not support antialiasing. */
- ippStsRepetitiveSrcData = 47, /* DC: The source data is too repetitive. */
- ippStsSizeWrn = 48, /* The size does not allow to perform full operation. */
- ippStsFeatureNotSupported = 49, /* Current CPU doesn't support at least 1 of the desired features. */
- ippStsUnknownFeature = 50, /* At least one of the desired features is unknown. */
- ippStsFeaturesCombination = 51, /* Wrong combination of features. */
- ippStsAccurateModeNotSupported = 52 /* Accurate mode is not supported. */
-} IppStatus;
-
-#define ippStsOk ippStsNoErr
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __IPPTYPES_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/include/ippversion.h b/sgx-jvm/linux-sgx/external/crypto_px/include/ippversion.h
deleted file mode 100755
index 478ac0b0cf..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/include/ippversion.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined( __IPPVERSION_H__ )
-#define __IPPVERSION_H__
-
-#define IPP_VERSION_MAJOR 9
-#define IPP_VERSION_MINOR 0
-#define IPP_VERSION_UPDATE 2
-
-#define IPP_VERSION_STR "9.0.2"
-
-#endif /* __IPPVERSION_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/cpudef.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/include/cpudef.h
deleted file mode 100644
index 3d9cde6c64..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/cpudef.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __CPUDEF_H__
-#define __CPUDEF_H__
-
-#include "ippcore.h"
-
-#if defined( __cplusplus )
-extern "C" {
-#endif
-
-#undef __CDECL
-#if defined( _WIN32 ) || defined ( _WIN64 )
- #define __CDECL __cdecl
-#else
- #define __CDECL
-#endif
-
-
-/* Intel CPU informator */
-
-typedef struct {
- int family;
- int stepping;
- int model;
- int type;
- int feature;
- int tlb;
- int cache;
- int mmx;
- int freq;
- int ssx;
- int wni;
- int htt;
- int pni;
- int em64t;
- int mni;
- int phcores;
- int sse41;
- int sse42;
- int ext_family;
- int ext_model;
- int movbe_instr;
- int avx;
- int xsavexgetbv;
-} ippIntelCpuId;
-
-int __CDECL ownGetMaskFeatures( Ipp64u* pFeaturesMask );
-int __CDECL ownGetFeature( Ipp64u MaskOfFeature );
-int __CDECL ipp_is_avx_extension( void );
-
-__INT64 __CDECL ipp_get_pentium_counter (void);
-int __CDECL ipp_is_mmx_extension (void);
-int __CDECL ipp_is_ssx_extension (void);
-int __CDECL ipp_is_wni_extension (void);
-int __CDECL ipp_is_htt_extension( void );
-int __CDECL ipp_is_pni_extension( void );
-int __CDECL ipp_is_mni_extension( void );
-int __CDECL ipp_is_sse41_extension( void );
-int __CDECL ipp_is_sse42_extension( void );
-int __CDECL ipp_is_movbe( void );
-int __CDECL ipp_get_cores_on_die( void );
-int __CDECL ipp_is_em64t_extension( void );
-int __CDECL ipp_has_cpuid ( void );
-int __CDECL ipp_has_rdtsc( void );
-
-void __CDECL ipp_get_pentium_ident ( ippIntelCpuId* cpuid );
-int __CDECL ipp_is_GenuineIntel ( void );
-int __CDECL ipp_max_cpuid_input( void );
-int __CDECL ipp_get_cpuid( int regs[4], int valEAX, int valECX );
-void __CDECL ipp_get_cache_line_size( int* szCacheLine );
-
-int __CDECL ipp_isnan( double x );
-int __CDECL ipp_finite( double x );
-int __CDECL ipp_isnan_32f( float x );
-int __CDECL ipp_finite_32f( float x );
-#define ipp_isfinite ipp_finite
-
-unsigned int __CDECL ipp_control87 ( unsigned int newcw, unsigned int mask );
-unsigned int __CDECL ipp_status87 ( void );
-unsigned int __CDECL ipp_clear87 ( void );
-
-unsigned int __CDECL ipp_clear_ssx (void);
-/* topology/affinity */
-
-/* here are definitions of the CW bits exactly as x87 and ssx have */
-
-#define IPP_FPU_MASK_RC 0x0c00
-#define IPP_FPU_MASK_PC 0x0300
-#define IPP_FPU_MASK_RCPC 0x0f00
-
-#define IPP_FPU_RC_NEAR 0x0000
-#define IPP_FPU_RC_DOWN 0x0400
-#define IPP_FPU_RC_UP 0x0800
-#define IPP_FPU_RC_ZERO 0x0c00
-
-#define IPP_FPU_PC_24 0x0000
-#define IPP_FPU_PC_53 0x0200
-#define IPP_FPU_PC_64 0x0300
-
-
-unsigned int __CDECL ipp_set_rcpc_fpu( unsigned int newrcpc, unsigned int mask);
-void __CDECL ipp_set_cw_fpu( unsigned int cw );
-
-#define IPP_SSX_RC_NEAR 0x0000
-#define IPP_SSX_RC_DOWN 0x2000
-#define IPP_SSX_RC_UP 0x4000
-#define IPP_SSX_RC_ZERO 0x6000
-#define IPP_SSX_MASK_RC 0x6000
-
-
-unsigned int __CDECL ipp_set_rc_ssx( unsigned int newrc );
-void __CDECL ipp_set_cw_ssx( unsigned int cw );
-
-/* ================= FPU section ===================== */
-
-/* Control bits - disable exceptions */
-#define FPU_EXC_MSK 0x003f /* Exception Masks Mask */
-#define FPU_MSK_INVALID 0x0001 /* invalid operation */
-#define FPU_MSK_DENORMAL 0x0002 /* denormalized operand */
-#define FPU_MSK_ZERODIV 0x0004 /* zero divide */
-#define FPU_MSK_OVERFLOW 0x0008 /* overflow */
-#define FPU_MSK_UNDERFLOW 0x0010 /* underflow */
-#define FPU_MSK_INEXACT 0x0020 /* inexact (precision) */
-
-/* Status bits - exceptions */
-#define FPU_EXC_FLG 0x003f /* Exception Flags Mask */
-#define FPU_FLG_INVALID 0x0001 /* invalid operation */
-#define FPU_FLG_DENORMAL 0x0002 /* denormalized operand */
-#define FPU_FLG_ZERODIV 0x0004 /* zero divide */
-#define FPU_FLG_OVERFLOW 0x0008 /* overflow */
-#define FPU_FLG_UNDERFLOW 0x0010 /* underflow */
-#define FPU_FLG_INEXACT 0x0020 /* inexact (precision) */
-
-/* Control bits - rounding control */
-#define FPU_RND 0x0c00 /* Rounding Control Mask */
-#define FPU_RND_NEAR 0x0000 /* near */
-#define FPU_RND_DOWN 0x0400 /* down */
-#define FPU_RND_UP 0x0800 /* up */
-#define FPU_RND_CHOP 0x0c00 /* chop */
-
-/* Control bits - precision control */
-#define FPU_PRC 0x0300 /* Precision Control Mask */
-#define FPU_PRC_64 0x0300 /* 64 bits */
-#define FPU_PRC_53 0x0200 /* 53 bits */
-#define FPU_PRC_24 0x0000 /* 24 bits */
-
-/* Control bits - all masks */
-#define FPU_ALL 0x0f3f /* all masks */
-
-/* ============= definition for control/status world ============== */
-
-#define FPU_SET_EXC_MASK(mask) ps_set_cw_fpu(mask,FPU_EXC_MSK)
-#define FPU_GET_EXC_MASK() (ps_set_cw_fpu(0,0) & FPU_EXC_MSK)
-
-#define FPU_GET_EXC_FLAG() (ps_get_sw_fpu() & FPU_EXC_FLG)
-
-#define FPU_SET_RND_MODE(mode) ps_set_cw_fpu(mode,FPU_RND)
-#define FPU_GET_RND_MODE() (ps_set_cw_fpu(0,0) & FPU_RND)
-
-#define FPU_SET_PRC_MODE(mode) ps_set_cw_fpu(mode,FPU_PRC)
-#define FPU_GET_PRC_MODE() (ps_set_cw_fpu(0,0) & FPU_PRC)
-
-unsigned int __CDECL ps_set_cw_fpu( unsigned int newcw, unsigned int msk);
-unsigned int __CDECL ps_get_cw_fpu(void);
-unsigned int __CDECL ps_get_sw_fpu(void);
-unsigned int __CDECL ps_clear_fpu(void);
-
-/* ======================= SSX section ============================ */
-
-/* Control bits - disable exceptions */
-#define SSX_EXC_MSK 0x1f80 /* Disabling exception mask */
-#define SSX_MSK_INEXACT 0x1000 /* precision (inexact) */
-#define SSX_MSK_UNDERFLOW 0x0800 /* underflow */
-#define SSX_MSK_OVERFLOW 0x0400 /* overflow */
-#define SSX_MSK_ZERODIV 0x0200 /* divide by zero */
-#define SSX_MSK_DENORMAL 0x0100 /* denormalized */
-#define SSX_MSK_INVALID 0x0080 /* invalid operation */
-
-/* Status bits - exceptions */
-#define SSX_EXC_FLG 0x003f /* Exception flags mask */
-#define SSX_FLG_INEXACT 0x0020 /* precision (inexact) */
-#define SSX_FLG_UNDERFLOW 0x0010 /* underflow */
-#define SSX_FLG_OVERFLOW 0x0008 /* overflow */
-#define SSX_FLG_ZERODIV 0x0004 /* divide by zero */
-#define SSX_FLG_DENORMAL 0x0002 /* denormalized */
-#define SSX_FLG_INVALID 0x0001 /* invalid operation */
-
-/* Control bits - rounding control */
-#define SSX_RND 0x6000 /* Rounding control mask */
-#define SSX_RND_NEAR 0x0000 /* near */
-#define SSX_RND_DOWN 0x2000 /* down */
-#define SSX_RND_UP 0x4000 /* up */
-#define SSX_RND_CHOP 0x6000 /* chop */
-
-/* Control bits - flush to zero mode */
-#define SSX_FZ 0x8000 /* Flush to zero mask */
-#define SSX_FZ_ENABLE 0x8000 /* flush to zero */
-#define SSX_FZ_DISABLE 0x0000 /* not flush to zero */
-
-/* Control bits - denormals are zero mode */
-#define SSX_DAZ 0x0040 /* denorm. are zero mask */
-#define SSX_DAZ_ENABLE 0x0040 /* denorm. are zero */
-#define SSX_DAZ_DISABLE 0x0000 /* denorm. are not zero */
-
-#define SSX_ALL 0xffbf /* All masks */
-
-/* ==================== definition for SSX register =============== */
-
-#define SSX_SET_EXC_MASK(mask) ps_set_ssx(mask,SSX_EXC_MSK)
-#define SSX_GET_EXC_MASK() (ps_get_ssx() & SSX_EXC_MSK)
-
-#define SSX_SET_EXC_FLAG(flag) ps_set_ssx(flag,SSX_EXC_FLG)
-#define SSX_GET_EXC_FLAG() (ps_get_ssx() & SSX_EXC_FLG)
-
-#define SSX_SET_RND_MODE(mode) ps_set_ssx(mode,SSX_RND)
-#define SSX_GET_RND_MODE() (ps_get_ssx() & SSX_RND)
-
-#define SSX_SET_FZ_MODE(mode) ps_set_ssx(mode,SSX_FZ)
-#define SSX_GET_FZ_MODE() (ps_get_ssx() & SSX_FZ)
-
-#define SSX_SET_DAZ_MODE(mode) ps_set_ssx(mode,SSX_DAZ)
-#define SSX_GET_DAZ_MODE() (ps_get_ssx() & SSX_DAZ)
-
-unsigned int __CDECL ps_set_ssx(unsigned int newssx, unsigned int msk);
-unsigned int __CDECL ps_get_ssx(void);
-unsigned int __CDECL ipp_tst_daz_ssx(void);
-
-#if defined( __cplusplus )
-}
-#endif
-
-#endif /* __CPUDEF_H__ */
-
-/* ////////////////////////// End of file "cpudef.h" //////////////////////// */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.gen b/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.gen
deleted file mode 100644
index 51c4a2d51d..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.gen
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_IPP_DYNAMIC) || defined(_CORE)
-#include "owndefs.h"
-
-#ifndef _IPP_VERSION
-#define _IPP_VERSION ""
-#endif
-
-#define GET_LIB_NAME01(pref) pref ## GetLibVersion
-
-#define GET_LIB_NAME(pref) GET_LIB_NAME01(pref)
-
-#define LIBVERNAME s_libVer
-
-#define SLIBVERNAME LIBVERNAME
-#include "ippverstr.gen"
-
-#include "cpudef.h"
-
-extern int ippJumpIndexForMergedDLL;
-
-IPPFUN( const IppLibraryVersion*, GET_LIB_NAME(LIB_PREFIX), (void) )
-{
- return &LIBVERNAME;
-}
-#endif
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.h
deleted file mode 100644
index ef6868a967..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippver.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (C) 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 "ippversion.h"
-#ifndef BASE_VERSION
-#define BASE_VERSION() IPP_VERSION_MAJOR,IPP_VERSION_MINOR,IPP_VERSION_UPDATE
-#endif
-
-#ifndef STR_VERSION
- #ifdef IPP_REVISION
- #define STR_VERSION() IPP_VERSION_STR " (r" STR( IPP_REVISION ) ")"
- #else
- #define STR_VERSION() IPP_VERSION_STR " (-)"
- #endif
-#endif
-
-
-/* ////////////////////////////// End of file /////////////////////////////// */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippverstr.gen b/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippverstr.gen
deleted file mode 100644
index edbcad3309..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/ippverstr.gen
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifdef _IPP_OMP_STATIC
-#define LIB_THREADS " threaded"
-#define CORE_THREADS " (threaded)"
-#else
-#define LIB_THREADS ""
-#define CORE_THREADS ""
-#endif
-
-#define GET_LIBRARY_NAME( cpu, is ) #cpu, IPP_LIB_SHORTNAME() " " is " (" #cpu LIB_THREADS ")"
-
-static const IppLibraryVersion SLIBVERNAME = {
-
-/* major, minor, update (ex-majorBuild) */
- BASE_VERSION(),
-
-#if defined IPP_REVISION
- IPP_REVISION,
-#else
- -1,
-#endif /* IPP_REVISION */
-
-#if defined( _CORE )
- /*GET_LIBRARY_NAME( core )*/
- "core",
- "ippCore" CORE_THREADS
-
-#elif ( _IPP_ARCH == _IPP_ARCH_IA32 ) || ( _IPP_ARCH == _IPP_ARCH_LP32 )
- #if ( _IPP == _IPP_M5 )
- GET_LIBRARY_NAME( m5, "586" )
- #elif ( _IPP == _IPP_H9 )
- GET_LIBRARY_NAME( h9, "AVX2" )
- #elif ( _IPP == _IPP_G9 )
- GET_LIBRARY_NAME( g9, "AVX" )
- #elif ( _IPP == _IPP_P8 )
- GET_LIBRARY_NAME( p8, "SSE4.2" )
- #elif ( _IPPLP32 == _IPPLP32_S8 )
- GET_LIBRARY_NAME( s8, "Atom" )
- #elif ( _IPP == _IPP_V8 )
- GET_LIBRARY_NAME( v8, "SSSE3" )
- #elif ( _IPP == _IPP_W7 )
- GET_LIBRARY_NAME( w7, "SSE2" )
- #else
- GET_LIBRARY_NAME( px, "PX" )
- #endif
-
-#elif ( _IPP_ARCH == _IPP_ARCH_EM64T ) || ( _IPP_ARCH == _IPP_ARCH_LP64 )
- #if ( _IPP32E == _IPP32E_K0 )
- GET_LIBRARY_NAME( k0, "AVX-512F/CD/BW/DQ/VL" )
- #elif ( _IPP32E == _IPP32E_N0 )
- GET_LIBRARY_NAME( n0, "AVX-512F/CD/ER/PF" )
- #elif ( _IPP32E == _IPP32E_E9 )
- GET_LIBRARY_NAME( e9, "AVX" )
- #elif ( _IPP32E == _IPP32E_L9 )
- GET_LIBRARY_NAME( l9, "AVX2" )
- #elif ( _IPP32E == _IPP32E_Y8 )
- GET_LIBRARY_NAME( y8, "SSE4.2" )
- #elif ( _IPPLP64 == _IPPLP64_N8 )
- GET_LIBRARY_NAME( n8, "Atom" )
- #elif ( _IPP32E == _IPP32E_U8 )
- GET_LIBRARY_NAME( u8, "SSSE3" )
- #elif ( _IPP32E == _IPP32E_M7 )
- GET_LIBRARY_NAME( m7, "SSE3" )
- #else
- GET_LIBRARY_NAME( mx, "PX" )
- #endif
-
-#elif ( _IPP_ARCH == _IPP_ARCH_LRB2 )
- #if ( _IPPLRB == _IPPLRB_BX )
- GET_LIBRARY_NAME( bx, "PX" )
- #elif ( _IPPLRB == _IPPLRB_B2 )
- GET_LIBRARY_NAME( b2, "KNC" )
- #endif
-
-#else
- #error ARCH not supported
-
-#endif
-
-#if defined( TICKTOCK )
- "+"
-#endif
-
-/* release Version (by Manager) */
- ,STR_VERSION()
-
-/* BuildDate (by QA person) */
- ,__DATE__
-
-};
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/owndefs.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/include/owndefs.h
deleted file mode 100644
index 6d9b386375..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/include/owndefs.h
+++ /dev/null
@@ -1,944 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __OWNDEFS_H__
-#define __OWNDEFS_H__
-
-#if defined( _VXWORKS )
- #include
- #undef NONE
-#endif
-
-#include "ippdefs.h"
-
-#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
- #define __INLINE static __inline
-#elif defined( __GNUC__ )
- #define __INLINE static __inline__
-#else
- #define __INLINE static
-#endif
-
-#if defined(__INTEL_COMPILER)
- #define __RESTRICT restrict
-#elif !defined( __RESTRICT )
- #define __RESTRICT
-#endif
-
-#if defined( IPP_W32DLL )
- #if defined( _MSC_VER ) || defined( __INTEL_COMPILER )
- #define IPPFUN(type,name,arg) __declspec(dllexport) type __STDCALL name arg
- #else
- #define IPPFUN(type,name,arg) extern type __STDCALL name arg
- #endif
-#else
- #define IPPFUN(type,name,arg) extern type __STDCALL name arg
-#endif
-
-
-/* structure represeting 128 bit unsigned integer type */
-
-typedef struct{
- Ipp64u low;
- Ipp64u high;
-}Ipp128u;
-
-#define _IPP_PX 0 /* pure C-code ia32 */
-#define _IPP_M5 1 /* Quark (Pentium) - x86+x87 ia32 */
-#define _IPP_M6 2 /* Pentium MMX - MMX ia32 */
-#define _IPP_A6 4 /* Pentium III - SSE ia32 */
-#define _IPP_W7 8 /* Pentium 4 - SSE2 ia32 */
-#define _IPP_T7 16 /* Pentium with x64 support (Nocona) - SSE3 ia32 */
-#define _IPP_V8 32 /* Merom - SSSE3 ia32 */
-#define _IPP_P8 64 /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */
-#define _IPP_G9 128 /* SandyBridge (GSSE) - AVX ia32 */
-#define _IPP_H9 256 /* Haswell (AVX2) ia32 */
-#define _IPP_I0 512 /* KNL (AVX-512) ia32 */
-#define _IPP_S0 1024 /* SkyLake Xeon (AVX-512) ia32 */
-
-#define _IPPXSC_PX 0
-#define _IPPXSC_S1 1
-#define _IPPXSC_S2 2
-#define _IPPXSC_C2 4
-
-#define _IPPLRB_PX 0
-#define _IPPLRB_B1 1
-#define _IPPLRB_B2 2
-
-#define _IPP64_PX _IPP_PX
-#define _IPP64_I7 64
-
-#define _IPP32E_PX _IPP_PX /* pure C-code x64 */
-#define _IPP32E_M7 32 /* Pentium with x64 support (Nocona) - SSE3 x64 */
-#define _IPP32E_U8 64 /* Merom - SSSE3 x64 */
-#define _IPP32E_Y8 128 /* Penryn - SSE4.1 + tick for SSE4.2 x64 */
-#define _IPP32E_E9 256 /* SandyBridge (GSSE) - AVX x64 */
-#define _IPP32E_L9 512 /* Haswell (AVX2) x64 */
-#define _IPP32E_N0 1024 /* KNL (AVX-512) x64 */
-#define _IPP32E_K0 2048 /* SkyLake Xeon (AVX-512) x64 */
-
-#define _IPPLP32_PX _IPP_PX
-#define _IPPLP32_S8 1 /* old Atom (SSSE3+movbe) (Silverthorne) ia32 */
-
-#define _IPPLP64_PX _IPP_PX
-#define _IPPLP64_N8 1 /* old Atom (SSSE3+movbe) (Silverthorne) x64 */
-
-#if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300)
- #define __ALIGN8 __declspec (align(8))
- #define __ALIGN16 __declspec (align(16))
-#if !defined( OSX32 )
- #define __ALIGN32 __declspec (align(32))
-#else
- #define __ALIGN32 __declspec (align(16))
-#endif
- #define __ALIGN64 __declspec (align(64))
-#elif defined (__GNUC__)
- #define __ALIGN8 __attribute((aligned(8)))
- #define __ALIGN16 __attribute((aligned(16)))
- #define __ALIGN32 __attribute((aligned(32)))
- #define __ALIGN64 __attribute((aligned(64)))
-#else
- #define __ALIGN8
- #define __ALIGN16
- #define __ALIGN32
- #define __ALIGN64
-#endif
-
-#if defined ( _M5 ) /* Quark (Pentium) - x86+x87 ia32 */
- #define _IPP _IPP_M5
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined ( _M6 ) /* Pentium MMX - MMX ia32 */
- #define _IPP _IPP_M6
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _A6 ) /* Pentium III - SSE ia32 */
- #define _IPP _IPP_A6
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _W7 ) /* Pentium 4 - SSE2 ia32 */
- #define _IPP _IPP_W7
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _T7 ) /* Pentium with x64 support (Nocona) - SSE3 ia32 */
- #define _IPP _IPP_T7
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _V8 ) /* Merom - SSSE3 ia32 */
- #define _IPP _IPP_V8
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _P8 ) /* Penryn - SSE4.1 + tick for SSE4.2 ia32 */
- #define _IPP _IPP_P8
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _G9 ) /* SandyBridge (GSSE) - AVX ia32 */
- #define _IPP _IPP_G9
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _H9 ) /* Haswell (AVX2) ia32 */
- #define _IPP _IPP_H9
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _M7 ) /* Pentium with x64 support (Nocona) - SSE3 x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_M7
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _U8 ) /* Merom - SSSE3 x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_U8
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _Y8 ) /* Penryn - SSE4.1 + tick for SSE4.2 x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_Y8
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _E9 ) /* SandyBridge (GSSE) - AVX x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_E9
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _L9 ) /* Haswell (AVX2) x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_L9
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _N0 ) /* KNL (AVX-512) x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_N0
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _K0 ) /* SkyLake Xeon (AVX-512) x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_K0
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _B2 ) /* KNC (MIC) */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_B2
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _S8 ) /* old Atom (SSSE3+movbe) (Silverthorne) ia32 */
- #define _IPP _IPP_V8
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_S8
- #define _IPPLP64 _IPPLP64_PX
-
-#elif defined( _N8 ) /* old Atom (SSSE3+movbe) (Silverthorne) x64 */
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_U8
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_N8
-
-#else
- #define _IPP _IPP_PX
- #define _IPP32E _IPP32E_PX
- #define _IPPLRB _IPPLRB_PX
- #define _IPPLP32 _IPPLP32_PX
- #define _IPPLP64 _IPPLP64_PX
-
-#endif
-
-
-#define _IPP_ARCH_IA32 1
-#define _IPP_ARCH_IA64 2
-#define _IPP_ARCH_EM64T 4
-#define _IPP_ARCH_XSC 8
-#define _IPP_ARCH_LRB 16
-#define _IPP_ARCH_LP32 32
-#define _IPP_ARCH_LP64 64
-#define _IPP_ARCH_LRB2 128
-
-#if defined ( _ARCH_IA32 )
- #define _IPP_ARCH _IPP_ARCH_IA32
-
-#elif defined( _ARCH_EM64T )
- #define _IPP_ARCH _IPP_ARCH_EM64T
-
-#elif defined( _ARCH_LRB2 )
- #define _IPP_ARCH _IPP_ARCH_LRB2
-
-#elif defined( _ARCH_LP32 )
- #define _IPP_ARCH _IPP_ARCH_LP32
-
-#elif defined( _ARCH_LP64 )
- #define _IPP_ARCH _IPP_ARCH_LP64
-
-#else
- #if defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__)
- #define _IPP_ARCH _IPP_ARCH_EM64T
-
- #else
- #define _IPP_ARCH _IPP_ARCH_IA32
-
- #endif
-#endif
-
-#if ((_IPP_ARCH == _IPP_ARCH_IA32) || (_IPP_ARCH == _IPP_ARCH_LP32))
-__INLINE
-Ipp32s IPP_INT_PTR( const void* ptr ) {
- union {
- void* Ptr;
- Ipp32s Int;
- } dd;
- dd.Ptr = (void*)ptr;
- return dd.Int;
-}
-
-__INLINE
-Ipp32u IPP_UINT_PTR( const void* ptr ) {
- union {
- void* Ptr;
- Ipp32u Int;
- } dd;
- dd.Ptr = (void*)ptr;
- return dd.Int;
-}
-#elif ((_IPP_ARCH == _IPP_ARCH_EM64T) || (_IPP_ARCH == _IPP_ARCH_LRB2) || (_IPP_ARCH == _IPP_ARCH_LP64))
-__INLINE
-Ipp64s IPP_INT_PTR( const void* ptr ) {
- union {
- void* Ptr;
- Ipp64s Int;
- } dd;
- dd.Ptr = (void*)ptr;
- return dd.Int;
-}
-
-__INLINE
-Ipp64u IPP_UINT_PTR( const void* ptr ) {
- union {
- void* Ptr;
- Ipp64u Int;
- } dd;
- dd.Ptr = (void*)ptr;
- return dd.Int;
-}
-#else
- #define IPP_INT_PTR( ptr ) ( (long)(ptr) )
- #define IPP_UINT_PTR( ptr ) ( (unsigned long)(ptr) )
-#endif
-
-#define IPP_ALIGN_TYPE(type, align) ((align)/sizeof(type)-1)
-#define IPP_BYTES_TO_ALIGN(ptr, align) ((-(IPP_INT_PTR(ptr)&((align)-1)))&((align)-1))
-#define IPP_ALIGNED_PTR(ptr, align) (void*)( (unsigned char*)(ptr) + (IPP_BYTES_TO_ALIGN( ptr, align )) )
-
-#define IPP_ALIGNED_SIZE(size, align) (((size)+(align)-1)&~((align)-1))
-
-#define IPP_MALLOC_ALIGNED_BYTES 64
-#define IPP_MALLOC_ALIGNED_8BYTES 8
-#define IPP_MALLOC_ALIGNED_16BYTES 16
-#define IPP_MALLOC_ALIGNED_32BYTES 32
-
-#define IPP_ALIGNED_ARRAY(align,arrtype,arrname,arrlength)\
- char arrname##AlignedArrBuff[sizeof(arrtype)*(arrlength)+IPP_ALIGN_TYPE(char, align)];\
- arrtype *arrname = (arrtype*)IPP_ALIGNED_PTR(arrname##AlignedArrBuff,align)
-
-#if defined( __cplusplus )
-extern "C" {
-#endif
-
-/* /////////////////////////////////////////////////////////////////////////////
-
- IPP Context Identification
-
- /////////////////////////////////////////////////////////////////////////// */
-
-#define IPP_CONTEXT( a, b, c, d) \
- (int)(((unsigned)(a) << 24) | ((unsigned)(b) << 16) | \
- ((unsigned)(c) << 8) | (unsigned)(d))
-
-typedef enum {
- idCtxUnknown = 0,
- idCtxFFT_C_16sc,
- idCtxFFT_C_16s,
- idCtxFFT_R_16s,
- idCtxFFT_C_32fc,
- idCtxFFT_C_32f,
- idCtxFFT_R_32f,
- idCtxFFT_C_64fc,
- idCtxFFT_C_64f,
- idCtxFFT_R_64f,
- idCtxDFT_C_16sc,
- idCtxDFT_C_16s,
- idCtxDFT_R_16s,
- idCtxDFT_C_32fc,
- idCtxDFT_C_32f,
- idCtxDFT_R_32f,
- idCtxDFT_C_64fc,
- idCtxDFT_C_64f,
- idCtxDFT_R_64f,
- idCtxDCTFwd_16s,
- idCtxDCTInv_16s,
- idCtxDCTFwd_32f,
- idCtxDCTInv_32f,
- idCtxDCTFwd_64f,
- idCtxDCTInv_64f,
- idCtxFFT2D_C_32fc,
- idCtxFFT2D_R_32f,
- idCtxDFT2D_C_32fc,
- idCtxDFT2D_R_32f,
- idCtxFFT2D_R_32s,
- idCtxDFT2D_R_32s,
- idCtxDCT2DFwd_32f,
- idCtxDCT2DInv_32f,
- idCtxMoment64f,
- idCtxMoment64s,
- idCtxRandUni_8u,
- idCtxRandUni_16s,
- idCtxRandUni_32f,
- idCtxRandUni_64f,
- idCtxRandGauss_8u,
- idCtxRandGauss_16s,
- idCtxRandGauss_32f,
- idCtxRandGauss_64f,
- idCtxWTFwd_32f,
- idCtxWTFwd_8u32f,
- idCtxWTFwd_8s32f,
- idCtxWTFwd_16u32f,
- idCtxWTFwd_16s32f,
- idCtxWTFwd2D_32f_C1R,
- idCtxWTInv2D_32f_C1R,
- idCtxWTFwd2D_32f_C3R,
- idCtxWTInv2D_32f_C3R,
- idCtxWTInv_32f,
- idCtxWTInv_32f8u,
- idCtxWTInv_32f8s,
- idCtxWTInv_32f16u,
- idCtxWTInv_32f16s,
- idCtxMDCTFwd_32f,
- idCtxMDCTInv_32f,
- idCtxMDCTFwd_16s,
- idCtxFIRBlock_32f,
- idCtxFDP_32f,
- idCtxRLMS_32f = IPP_CONTEXT( 'L', 'M', 'S', '1'),
- idCtxRLMS32f_16s = IPP_CONTEXT( 'L', 'M', 'S', 0 ),
- idCtxIIRAR_32f = IPP_CONTEXT( 'I', 'I', '0', '1'),
- idCtxIIRBQ_32f = IPP_CONTEXT( 'I', 'I', '0', '2'),
- idCtxIIRAR_32fc = IPP_CONTEXT( 'I', 'I', '0', '3'),
- idCtxIIRBQ_32fc = IPP_CONTEXT( 'I', 'I', '0', '4'),
- idCtxIIRAR32f_16s = IPP_CONTEXT( 'I', 'I', '0', '5'),
- idCtxIIRBQ32f_16s = IPP_CONTEXT( 'I', 'I', '0', '6'),
- idCtxIIRAR32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '7'),
- idCtxIIRBQ32fc_16sc = IPP_CONTEXT( 'I', 'I', '0', '8'),
- idCtxIIRAR32s_16s = IPP_CONTEXT( 'I', 'I', '0', '9'),
- idCtxIIRBQ32s_16s = IPP_CONTEXT( 'I', 'I', '1', '0'),
- idCtxIIRAR32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '1'),
- idCtxIIRBQ32sc_16sc = IPP_CONTEXT( 'I', 'I', '1', '2'),
- idCtxIIRAR_64f = IPP_CONTEXT( 'I', 'I', '1', '3'),
- idCtxIIRBQ_64f = IPP_CONTEXT( 'I', 'I', '1', '4'),
- idCtxIIRAR_64fc = IPP_CONTEXT( 'I', 'I', '1', '5'),
- idCtxIIRBQ_64fc = IPP_CONTEXT( 'I', 'I', '1', '6'),
- idCtxIIRAR64f_32f = IPP_CONTEXT( 'I', 'I', '1', '7'),
- idCtxIIRBQ64f_32f = IPP_CONTEXT( 'I', 'I', '1', '8'),
- idCtxIIRAR64fc_32fc = IPP_CONTEXT( 'I', 'I', '1', '9'),
- idCtxIIRBQ64fc_32fc = IPP_CONTEXT( 'I', 'I', '2', '0'),
- idCtxIIRAR64f_32s = IPP_CONTEXT( 'I', 'I', '2', '1'),
- idCtxIIRBQ64f_32s = IPP_CONTEXT( 'I', 'I', '2', '2'),
- idCtxIIRAR64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '3'),
- idCtxIIRBQ64fc_32sc = IPP_CONTEXT( 'I', 'I', '2', '4'),
- idCtxIIRAR64f_16s = IPP_CONTEXT( 'I', 'I', '2', '5'),
- idCtxIIRBQ64f_16s = IPP_CONTEXT( 'I', 'I', '2', '6'),
- idCtxIIRAR64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '7'),
- idCtxIIRBQ64fc_16sc = IPP_CONTEXT( 'I', 'I', '2', '8'),
- idCtxIIRBQDF1_32f = IPP_CONTEXT( 'I', 'I', '2', '9'),
- idCtxIIRBQDF164f_32s= IPP_CONTEXT( 'I', 'I', '3', '0'),
- idCtxFIRSR_32f = IPP_CONTEXT( 'F', 'I', '0', '1'),
- idCtxFIRSR_32fc = IPP_CONTEXT( 'F', 'I', '0', '2'),
- idCtxFIRMR_32f = IPP_CONTEXT( 'F', 'I', '0', '3'),
- idCtxFIRMR_32fc = IPP_CONTEXT( 'F', 'I', '0', '4'),
- idCtxFIRSR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '5'),
- idCtxFIRSR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '6'),
- idCtxFIRMR32f_16s = IPP_CONTEXT( 'F', 'I', '0', '7'),
- idCtxFIRMR32fc_16sc = IPP_CONTEXT( 'F', 'I', '0', '8'),
- idCtxFIRSR32s_16s = IPP_CONTEXT( 'F', 'I', '0', '9'),
- idCtxFIRSR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '0'),
- idCtxFIRMR32s_16s = IPP_CONTEXT( 'F', 'I', '1', '1'),
- idCtxFIRMR32sc_16sc = IPP_CONTEXT( 'F', 'I', '1', '2'),
- idCtxFIRSR_64f = IPP_CONTEXT( 'F', 'I', '1', '3'),
- idCtxFIRSR_64fc = IPP_CONTEXT( 'F', 'I', '1', '4'),
- idCtxFIRMR_64f = IPP_CONTEXT( 'F', 'I', '1', '5'),
- idCtxFIRMR_64fc = IPP_CONTEXT( 'F', 'I', '1', '6'),
- idCtxFIRSR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '7'),
- idCtxFIRSR64fc_32fc = IPP_CONTEXT( 'F', 'I', '1', '8'),
- idCtxFIRMR64f_32f = IPP_CONTEXT( 'F', 'I', '1', '9'),
- idCtxFIRMR64fc_32fc = IPP_CONTEXT( 'F', 'I', '2', '0'),
- idCtxFIRSR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '1'),
- idCtxFIRSR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '2'),
- idCtxFIRMR64f_32s = IPP_CONTEXT( 'F', 'I', '2', '3'),
- idCtxFIRMR64fc_32sc = IPP_CONTEXT( 'F', 'I', '2', '4'),
- idCtxFIRSR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '5'),
- idCtxFIRSR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '6'),
- idCtxFIRMR64f_16s = IPP_CONTEXT( 'F', 'I', '2', '7'),
- idCtxFIRMR64fc_16sc = IPP_CONTEXT( 'F', 'I', '2', '8'),
- idCtxFIRSR_16s = IPP_CONTEXT( 'F', 'I', '2', '9'),
- idCtxFIRMR_16s = IPP_CONTEXT( 'F', 'I', '3', '0'),
- idCtxFIRSRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '1'),
- idCtxFIRMRStream_16s= IPP_CONTEXT( 'F', 'I', '3', '2'),
- idCtxFIRSRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '3'),
- idCtxFIRMRStream_32f= IPP_CONTEXT( 'F', 'I', '3', '4'),
- idCtxRLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'R'),
- idCtxCLMS32s_16s = IPP_CONTEXT( 'L', 'M', 'S', 'C'),
- idCtxEncode_JPEG2K,
- idCtxDES = IPP_CONTEXT( ' ', 'D', 'E', 'S'),
- idCtxBlowfish = IPP_CONTEXT( ' ', ' ', 'B', 'F'),
- idCtxRijndael = IPP_CONTEXT( ' ', 'R', 'I', 'J'),
- idCtxSMS4 = IPP_CONTEXT( 'S', 'M', 'S', '4'),
- idCtxTwofish = IPP_CONTEXT( ' ', ' ', 'T', 'F'),
- idCtxARCFOUR = IPP_CONTEXT( ' ', 'R', 'C', '4'),
- idCtxRC564 = IPP_CONTEXT( 'R', 'C', '5', '1'),
- idCtxRC5128 = IPP_CONTEXT( 'R', 'C', '5', '2'),
- idCtxSHA1 = IPP_CONTEXT( 'S', 'H', 'S', '1'),
- idCtxSHA224 = IPP_CONTEXT( 'S', 'H', 'S', '3'),
- idCtxSHA256 = IPP_CONTEXT( 'S', 'H', 'S', '2'),
- idCtxSHA384 = IPP_CONTEXT( 'S', 'H', 'S', '4'),
- idCtxSHA512 = IPP_CONTEXT( 'S', 'H', 'S', '5'),
- idCtxMD5 = IPP_CONTEXT( ' ', 'M', 'D', '5'),
- idCtxHMAC = IPP_CONTEXT( 'H', 'M', 'A', 'C'),
- idCtxDAA = IPP_CONTEXT( ' ', 'D', 'A', 'A'),
- idCtxBigNum = IPP_CONTEXT( 'B', 'I', 'G', 'N'),
- idCtxMontgomery = IPP_CONTEXT( 'M', 'O', 'N', 'T'),
- idCtxPrimeNumber = IPP_CONTEXT( 'P', 'R', 'I', 'M'),
- idCtxPRNG = IPP_CONTEXT( 'P', 'R', 'N', 'G'),
- idCtxRSA = IPP_CONTEXT( ' ', 'R', 'S', 'A'),
- idCtxRSA_PubKey = IPP_CONTEXT( 'R', 'S', 'A', '0'),
- idCtxRSA_PrvKey1 = IPP_CONTEXT( 'R', 'S', 'A', '1'),
- idCtxRSA_PrvKey2 = IPP_CONTEXT( 'R', 'S', 'A', '2'),
- idCtxDSA = IPP_CONTEXT( ' ', 'D', 'S', 'A'),
- idCtxECCP = IPP_CONTEXT( ' ', 'E', 'C', 'P'),
- idCtxECCB = IPP_CONTEXT( ' ', 'E', 'C', 'B'),
- idCtxECCPPoint = IPP_CONTEXT( 'P', 'E', 'C', 'P'),
- idCtxECCBPoint = IPP_CONTEXT( 'P', 'E', 'C', 'B'),
- idCtxDH = IPP_CONTEXT( ' ', ' ', 'D', 'H'),
- idCtxDLP = IPP_CONTEXT( ' ', 'D', 'L', 'P'),
- idCtxCMAC = IPP_CONTEXT( 'C', 'M', 'A', 'C'),
- idCtxRFFT2_8u,
- idCtxHilbert_32f32fc,
- idCtxHilbert_16s32fc,
- idCtxHilbert_16s16sc,
- idCtxTone_16s,
- idCtxTriangle_16s,
- idCtxDFTOutOrd_C_32fc,
- idCtxDFTOutOrd_C_64fc,
- idCtxFFT_C_32sc,
- idCtxFFT_C_32s,
- idCtxFFT_R_32s,
- idCtxFFT_R_16s32s,
- idCtxDecodeProgr_JPEG2K,
- idCtxWarp_MPEG4,
- idCtxQuantInvIntra_MPEG4,
- idCtxQuantInvInter_MPEG4,
- idCtxQuantIntra_MPEG4,
- idCtxQuantInter_MPEG4,
- idCtxAnalysisFilter_SBR_C_32f32fc,
- idCtxAnalysisFilter_SBR_C_32f,
- idCtxAnalysisFilter_SBR_R_32f,
- idCtxSynthesisFilter_SBR_C_32fc32f,
- idCtxSynthesisFilter_SBR_C_32f,
- idCtxSynthesisFilter_SBR_R_32f,
- idCtxSynthesisDownFilter_SBR_C_32fc32f,
- idCtxSynthesisDownFilter_SBR_C_32f,
- idCtxSynthesisDownFilter_SBR_R_32f,
- idCtxVLCEncode,
- idCtxVLCDecode,
- idCtxAnalysisFilter_SBR_C_32s32sc,
- idCtxAnalysisFilter_SBR_R_32s,
- idCtxSynthesisFilter_SBR_C_32sc32s,
- idCtxSynthesisFilter_SBR_R_32s,
- idCtxSynthesisDownFilter_SBR_C_32sc32s,
- idCtxSynthesisDownFilter_SBR_R_32s,
- idCtxSynthesisFilter_PQMF_MP3_32f,
- idCtxAnalysisFilter_PQMF_MP3_32f,
- idCtxResampleRow,
- idCtxAnalysisFilter_SBR_Enc_C_32f32fc,
- idCtxSynthesisFilter_DTS_32f,
- idCtxFilterBilateralGauss_8u,
- idCtxFilterBilateralGaussFast_8u,
- idCtxBGF,
- idCtxPolyGF,
- idCtxRSenc,
- idCtxRSdec,
- idCtxSnow3g = IPP_CONTEXT( 'S', 'n', 'o', 'w'),
- idCtxSnow3gF8,
- idCtxSnow3gF9,
- idCtxKasumi = IPP_CONTEXT( 'K', 'a', 's', 'u'),
- idCtxKasumiF8,
- idCtxKasumiF9,
- idCtxResizeHannFilter_8u,
- idCtxResizeLanczosFilter_8u,
- idCtxAESXCBC,
- idCtxAESCCM,
- idCtxAESGCM,
- idCtxMsgCatalog,
- idCtxGFP,
- idCtxGFPE,
- idCtxGFPX,
- idCtxGFPXE,
- idCtxGFPXQX,
- idCtxGFPXQXE,
- idCtxGFPEC,
- idCtxGFPPoint,
- idCtxGFPXEC,
- idCtxGFPXECPoint,
- idCtxPairing,
- idCtxResize_32f,
- idCtxResizeYUV420,
- idCtxResizeYUV422,
- idCtxResize_64f,
- idCtxFilterBilateralBorder,
- idCtxThresholdAdaptiveGauss,
- idCtxHOG,
- idCtxFastN,
- idCtxHash,
- idCtxSM3
-} IppCtxId;
-
-
-
-
-/* /////////////////////////////////////////////////////////////////////////////
- Helpers
- /////////////////////////////////////////////////////////////////////////// */
-
-#define IPP_NOERROR_RET() return ippStsNoErr
-#define IPP_ERROR_RET( ErrCode ) return (ErrCode)
-
-#ifdef _IPP_DEBUG
-
- #define IPP_BADARG_RET( expr, ErrCode )\
- {if (expr) { IPP_ERROR_RET( ErrCode ); }}
-
-#else
-
- #define IPP_BADARG_RET( expr, ErrCode )
-
-#endif
-
-
- #define IPP_BAD_SIZE_RET( n )\
- IPP_BADARG_RET( (n)<=0, ippStsSizeErr )
-
- #define IPP_BAD_STEP_RET( n )\
- IPP_BADARG_RET( (n)<=0, ippStsStepErr )
-
- #define IPP_BAD_PTR1_RET( ptr )\
- IPP_BADARG_RET( NULL==(ptr), ippStsNullPtrErr )
-
- #define IPP_BAD_PTR2_RET( ptr1, ptr2 )\
- {IPP_BAD_PTR1_RET( ptr1 ); IPP_BAD_PTR1_RET( ptr2 )}
-
- #define IPP_BAD_PTR3_RET( ptr1, ptr2, ptr3 )\
- {IPP_BAD_PTR2_RET( ptr1, ptr2 ); IPP_BAD_PTR1_RET( ptr3 )}
-
- #define IPP_BAD_PTR4_RET( ptr1, ptr2, ptr3, ptr4 )\
- {IPP_BAD_PTR2_RET( ptr1, ptr2 ); IPP_BAD_PTR2_RET( ptr3, ptr4 )}
-
- #define IPP_BAD_ISIZE_RET(roi) \
- IPP_BADARG_RET( ((roi).width<=0 || (roi).height<=0), ippStsSizeErr)
-
-/* ////////////////////////////////////////////////////////////////////////// */
-/* internal messages */
-
-#define MSG_LOAD_DLL_ERR (-9700) /* Error at loading of %s library */
-#define MSG_NO_DLL (-9701) /* No DLLs were found in the Waterfall procedure */
-#define MSG_NO_SHARED (-9702) /* No shared libraries were found in the Waterfall procedure */
-
-/* ////////////////////////////////////////////////////////////////////////// */
-
-
-typedef union { /* double precision */
- Ipp64s hex;
- Ipp64f fp;
-} IppFP_64f;
-
-typedef union { /* single precision */
- Ipp32s hex;
- Ipp32f fp;
-} IppFP_32f;
-
-
-extern const IppFP_32f ippConstantOfNAN_32f;
-extern const IppFP_64f ippConstantOfNAN_64f;
-
-extern const IppFP_32f ippConstantOfINF_32f;
-extern const IppFP_64f ippConstantOfINF_64f;
-extern const IppFP_32f ippConstantOfINF_NEG_32f;
-extern const IppFP_64f ippConstantOfINF_NEG_64f;
-
-#define NAN_32F (ippConstantOfNAN_32f.fp)
-#define NAN_64F (ippConstantOfNAN_64f.fp)
-#define INF_32F (ippConstantOfINF_32f.fp)
-#define INF_64F (ippConstantOfINF_64f.fp)
-#define INF_NEG_32F (ippConstantOfINF_NEG_32f.fp)
-#define INF_NEG_64F (ippConstantOfINF_NEG_64f.fp)
-
-/* ////////////////////////////////////////////////////////////////////////// */
-
-typedef enum {
- ippunreg=-1,
- ippac = 0,
- ippcc = 1,
- ippch = 2,
- ippcp = 3,
- ippcv = 4,
- ippdc = 5,
- ippdi = 6,
- ippgen = 7,
- ippi = 8,
- ippj = 9,
- ippm = 10,
- ippr = 11,
- ipps = 12,
- ippsc = 13,
- ippsr = 14,
- ippvc = 15,
- ippvm = 16,
- ippmsdk = 17,
- ippcpepid = 18,
- ippe = 19,
- ipprs = 20,
- ippsq = 21,
- ippnomore
-} IppDomain;
-
-int __CDECL ownGetNumThreads( void );
-int __CDECL ownGetFeature( Ipp64u MaskOfFeature ); /* the main function of tick-tock dispatcher */
-
-#ifdef _IPP_DYNAMIC
-typedef IppStatus (__STDCALL *DYN_RELOAD)( int );
-void __CDECL ownRegisterLib( IppDomain, DYN_RELOAD );
-void __CDECL ownUnregisterLib( IppDomain );
-#endif
-
-/* the number of threads available for any ipp function that uses OMP; */
-/* at the ippxx.dll loading time is equal to the number of logical processors, */
-/* and can be changed ONLY externally by library user to any desired number */
-/* by means of ippSetNumThreads() function */
-#define IPP_GET_NUM_THREADS() ( ownGetNumThreads() )
-#define IPP_OMP_NUM_THREADS() num_threads( IPP_GET_NUM_THREADS() )
-#define IPP_OMP_LIMIT_MAX_NUM_THREADS(n) num_threads( IPP_MIN(IPP_GET_NUM_THREADS(),(n)))
-
-
-/* ////////////////////////////////////////////////////////////////////////// */
-
-/* Define NULL pointer value */
-#ifndef NULL
-#ifdef __cplusplus
-#define NULL 0
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
-#define UNREFERENCED_PARAMETER(p) (p)=(p)
-
-#if defined( _IPP_MARK_LIBRARY )
-static char G[] = {73, 80, 80, 71, 101, 110, 117, 105, 110, 101, 243, 193, 210, 207, 215};
-#endif
-
-
-#define STR2(x) #x
-#define STR(x) STR2(x)
-#define MESSAGE( desc )\
- message(__FILE__ "(" STR(__LINE__) "):" #desc)
-
-/*
-// endian definition
-*/
-#define IPP_LITTLE_ENDIAN (0)
-#define IPP_BIG_ENDIAN (1)
-
-#if defined( _IPP_LE )
- #define IPP_ENDIAN IPP_LITTLE_ENDIAN
-
-#elif defined( _IPP_BE )
- #define IPP_ENDIAN IPP_BIG_ENDIAN
-
-#else
- #if defined( __ARMEB__ )
- #define IPP_ENDIAN IPP_BIG_ENDIAN
-
- #else
- #define IPP_ENDIAN IPP_LITTLE_ENDIAN
-
- #endif
-#endif
-
-
-/* ////////////////////////////////////////////////////////////////////////// */
-
-/* intrinsics */
-#if (_IPP >= _IPP_A6) || (_IPP32E >= _IPP32E_M7)
- #if defined(__INTEL_COMPILER) || (_MSC_VER >= 1300)
- #if (_IPP == _IPP_A6)
- #include "xmmintrin.h"
- #elif (_IPP == _IPP_W7)
- #if defined(__INTEL_COMPILER)
- #include "emmintrin.h"
- #else
- #undef _W7
- #include "emmintrin.h"
- #define _W7
- #endif
- #define _mm_loadu _mm_loadu_si128
- #elif (_IPP == _IPP_T7) || (_IPP32E == _IPP32E_M7)
- #if defined(__INTEL_COMPILER)
- #include "pmmintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER >= 140050110)
- #include "intrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER < 140050110)
- #include "emmintrin.h"
- #define _mm_loadu _mm_loadu_si128
- #endif
- #elif (_IPP == _IPP_V8) || (_IPP32E == _IPP32E_U8)
- #if defined(__INTEL_COMPILER)
- #include "tmmintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER >= 140050110)
- #include "intrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER < 140050110)
- #include "emmintrin.h"
- #define _mm_loadu _mm_loadu_si128
- #endif
- #elif (_IPP == _IPP_P8) || (_IPP32E == _IPP32E_Y8)
- #if defined(__INTEL_COMPILER)
- #include "smmintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER >= 140050110)
- #include "intrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER < 140050110)
- #include "emmintrin.h"
- #define _mm_loadu _mm_loadu_si128
- #endif
- #elif (_IPP >= _IPP_G9) || (_IPP32E >= _IPP32E_E9)
- #if defined(__INTEL_COMPILER)
- #include "immintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER >= 160021003)
- #include "immintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #endif
- #endif
- #endif
-#elif (_IPPLP32 >= _IPPLP32_S8) || (_IPPLP64 >= _IPPLP64_N8)
- #if defined(__INTEL_COMPILER)
- #include "tmmintrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER >= 140050110)
- #include "intrin.h"
- #define _mm_loadu _mm_lddqu_si128
- #elif (_MSC_FULL_VER < 140050110)
- #include "emmintrin.h"
- #define _mm_loadu _mm_loadu_si128
- #endif
-#elif (_IPPLRB >= _IPPLRB_B2)
- #if defined(__INTEL_COMPILER) || defined(_REF_LIB)
- #include "immintrin.h"
- #endif
-#endif
-
-// **** intrinsics for bit casting ****
-#if defined(__INTEL_COMPILER)
-extern unsigned int __intel_castf32_u32(float val);
-extern float __intel_castu32_f32(unsigned int val);
-extern unsigned __int64 __intel_castf64_u64(double val);
-extern double __intel_castu64_f64(unsigned __int64 val);
- #define __CAST_32f32u(val) __intel_castf32_u32((Ipp32f)val)
- #define __CAST_32u32f(val) __intel_castu32_f32((Ipp32u)val)
- #define __CAST_64f64u(val) __intel_castf64_u64((Ipp64f)val)
- #define __CAST_64u64f(val) __intel_castu64_f64((Ipp64u)val)
-#else
- #define __CAST_32f32u(val) ( *((Ipp32u*)&val) )
- #define __CAST_32u32f(val) ( *((Ipp32f*)&val) )
- #define __CAST_64f64u(val) ( *((Ipp64u*)&val) )
- #define __CAST_64u64f(val) ( *((Ipp64f*)&val) )
-#endif
-
-
-// short names for vector registers casting
-#define _pd2ps _mm_castpd_ps
-#define _ps2pd _mm_castps_pd
-#define _pd2pi _mm_castpd_si128
-#define _pi2pd _mm_castsi128_pd
-#define _ps2pi _mm_castps_si128
-#define _pi2ps _mm_castsi128_ps
-
-#define _ypd2ypi _mm256_castpd_si256
-#define _ypi2ypd _mm256_castsi256_pd
-#define _yps2ypi _mm256_castps_si256
-#define _ypi2yps _mm256_castsi256_ps
-#define _ypd2yps _mm256_castpd_ps
-#define _yps2ypd _mm256_castps_pd
-
-#define _yps2ps _mm256_castps256_ps128
-#define _ypi2pi _mm256_castsi256_si128
-#define _ypd2pd _mm256_castpd256_pd128
-#define _ps2yps _mm256_castps128_ps256
-#define _pi2ypi _mm256_castsi128_si256
-#define _pd2ypd _mm256_castpd128_pd256
-
-
-#if defined(__INTEL_COMPILER)
-#define __IVDEP ivdep
-#else
-#define __IVDEP message("message :: 'ivdep' is not defined")
-#endif
-//usage: #pragma __IVDEP
-
-/* //////////////////////////////////////////////////////////////////////////
- _IPP_DATA shoul be defined only:
- - if compile not merged library
- - only for 1 CPU for merged library to avoid data duplication
-*/
-#if defined( _MERGED_BLD ) && ( defined(_G9) || defined(_E9) ) /* compile data only for g9 and e9 CPU */
- #define _IPP_DATA 1
-#elif !defined( _MERGED_BLD ) /* compile data if it isn't merged library */
- #define _IPP_DATA 1
-#endif
-
-
-#if defined( __cplusplus )
-}
-#endif
-
-#endif /* __OWNDEFS_H__ */
-
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/owncp.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/owncp.h
deleted file mode 100644
index 5793989761..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/owncp.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#ifndef __OWNCP_H__
-#define __OWNCP_H__
-
-#ifndef __OWNDEFS_H__
- #include "owndefs.h"
-#endif
-
-#ifndef __IPPCP_H__
- #include "ippcp.h"
-#endif
-
-#pragma warning( disable : 4324)
-
-/* ippCP length */
-typedef int cpSize;
-
-/*
-// common macros & definitions
-*/
-
-/* size of cache line (bytes) */
-#define CACHE_LINE_SIZE (64)
-#define LOG_CACHE_LINE_SIZE (6)
-
-/* swap data & pointers */
-#define SWAP_PTR(ATYPE, pX,pY) { ATYPE* aPtr=(pX); (pX)=(pY); (pY)=aPtr; }
-#define SWAP(x,y) {(x)^=(y); (y)^=(x); (x)^=(y);}
-
-/* alignment value */
-#define ALIGN_VAL ((int)sizeof(void*))
-
-/* bitsize */
-#define BYTESIZE (8)
-#define BITSIZE(x) ((int)(sizeof(x)*BYTESIZE))
-
-/* bit length -> byte/word length conversion */
-#define BITS2WORD8_SIZE(x) (((x)+ 7)>>3)
-#define BITS2WORD16_SIZE(x) (((x)+15)>>4)
-#define BITS2WORD32_SIZE(x) (((x)+31)>>5)
-#define BITS2WORD64_SIZE(x) (((x)+63)>>6)
-
-/* WORD and DWORD manipulators */
-#define LODWORD(x) ((Ipp32u)(x))
-#define HIDWORD(x) ((Ipp32u)(((Ipp64u)(x) >>32) & 0xFFFFFFFF))
-
-#define MAKEHWORD(bLo,bHi) ((Ipp16u)(((Ipp8u)(bLo)) | ((Ipp16u)((Ipp8u)(bHi))) << 8))
-#define MAKEWORD(hLo,hHi) ((Ipp32u)(((Ipp16u)(hLo)) | ((Ipp32u)((Ipp16u)(hHi))) << 16))
-#define MAKEDWORD(wLo,wHi) ((Ipp64u)(((Ipp32u)(wLo)) | ((Ipp64u)((Ipp32u)(wHi))) << 32))
-
-/* extract byte */
-#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n))))
-
-/* hexString <-> Ipp32u conversion */
-#define HSTRING_TO_U32(ptrByte) \
- (((ptrByte)[0]) <<24) \
- +(((ptrByte)[1]) <<16) \
- +(((ptrByte)[2]) <<8) \
- +((ptrByte)[3])
-#define U32_TO_HSTRING(ptrByte, x) \
- (ptrByte)[0] = (Ipp8u)((x)>>24); \
- (ptrByte)[1] = (Ipp8u)((x)>>16); \
- (ptrByte)[2] = (Ipp8u)((x)>>8); \
- (ptrByte)[3] = (Ipp8u)(x)
-
-/* 32- and 64-bit masks for MSB of nbits-sequence */
-#define MAKEMASK32(nbits) (0xFFFFFFFF >>((32 - ((nbits)&0x1F)) &0x1F))
-#define MAKEMASK64(nbits) (0xFFFFFFFFFFFFFFFF >>((64 - ((nbits)&0x3F)) &0x3F))
-
-/* Logical Shifts (right and left) of WORD */
-#define LSR32(x,nBits) ((x)>>(nBits))
-#define LSL32(x,nBits) ((x)<<(nBits))
-
-/* Rorate (right and left) of WORD */
-#if defined(_MSC_VER)
-# include
-# define ROR32(x, nBits) _lrotr((x),(nBits))
-# define ROL32(x, nBits) _lrotl((x),(nBits))
-#else
-# define ROR32(x, nBits) (LSR32((x),(nBits)) | LSL32((x),32-(nBits)))
-# define ROL32(x, nBits) ROR32((x),(32-(nBits)))
-#endif
-
-/* Logical Shifts (right and left) of DWORD */
-#define LSR64(x,nBits) ((x)>>(nBits))
-#define LSL64(x,nBits) ((x)<<(nBits))
-
-/* Rorate (right and left) of DWORD */
-#define ROR64(x, nBits) (LSR64((x),(nBits)) | LSL64((x),64-(nBits)))
-#define ROL64(x, nBits) ROR64((x),(64-(nBits)))
-
-/* change endian */
-#if defined(_MSC_VER)
-# define ENDIANNESS(x) _byteswap_ulong((x))
-# define ENDIANNESS32(x) ENDIANNESS((x))
-# define ENDIANNESS64(x) _byteswap_uint64((x))
-#else
-# define ENDIANNESS(x) ((ROR32((x), 24) & 0x00ff00ff) | (ROR32((x), 8) & 0xff00ff00))
-# define ENDIANNESS32(x) ENDIANNESS((x))
-# define ENDIANNESS64(x) MAKEDWORD(ENDIANNESS(HIDWORD((x))), ENDIANNESS(LODWORD((x))))
-#endif
-
-#define IPP_MAKE_MULTIPLE_OF_8(x) ((x) = ((x)+7)&(~7))
-#define IPP_MAKE_MULTIPLE_OF_16(x) ((x) = ((x)+15)&(~15))
-
-/* 64-bit constant */
-#if !defined(__GNUC__)
- #define CONST_64(x) (x) /*(x##i64)*/
-#else
- #define CONST_64(x) (x##LL)
-#endif
-
-/* copy under mask */
-#define MASKED_COPY_BNU(dst, mask, src1, src2, len) { \
- cpSize i; \
- for(i=0; i<(len); i++) (dst)[i] = ((mask) & (src1)[i]) | (~(mask) & (src2)[i]); \
-}
-
-#endif /* __OWNCP_H__ */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c
deleted file mode 100644
index 0443664763..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthcmacca.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpcmac.h"
-#include "pcpaesm.h"
-#include "pcptool.h"
-
-#include "pcprijtables.h"
-
-/*F*
-// Name: ippsAES_CMACGetSize
-//
-// Purpose: Returns size of AES-CMAC context (in bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSzie == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to the AES-CMAC size of context
-//
-*F*/
-static int cpSizeofCtx_AESCMAC(void)
-{
- return sizeof(IppsAES_CMACState) + AESCMAC_ALIGNMENT-1;
-}
-
-IPPFUN(IppStatus, ippsAES_CMACGetSize,(int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = cpSizeofCtx_AESCMAC();
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsAES_CMACInit
-//
-// Purpose: Init AES-CMAC context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// ippStsMemAllocErr size of buffer is not match fro operation
-// ippStsLengthErr keyLen != 16
-// keyLen != 24
-// keyLen != 32
-// ippStsNoErr no errors
-//
-// Parameters:
-// pKey pointer to the secret key
-// keyLen length of secret key
-// pCtx pointer to the CMAC context
-// ctxSize available size (in bytes) of buffer above
-//
-*F*/
-static
-void init(IppsAES_CMACState* pCtx)
-{
- /* buffer is empty */
- CMAC_INDX(pCtx) = 0;
- /* zeros MAC */
- PaddBlock(0, CMAC_MAC(pCtx), MBS_RIJ128);
-}
-
-static
-void LogicalLeftSift16(const Ipp8u* pSrc, Ipp8u* pDst)
-{
- Ipp32u carry = 0;
- int n;
- for(n=0; n<16; n++) {
- Ipp32u x = pSrc[16-1-n] + pSrc[16-1-n] + carry;
- pDst[16-1-n] = (Ipp8u)x;
- carry = (x>>8) & 0xFF;
- }
-}
-
-IPPFUN(IppStatus, ippsAES_CMACInit,(const Ipp8u* pKey, int keyLen, IppsAES_CMACState* pCtx, int ctxSize))
-{
- /* test pCtx pointer */
- IPP_BAD_PTR1_RET(pCtx);
-
- /* test available size of context buffer */
- IPP_BADARG_RET(ctxSize>7)) & 0x87); /* ^ Rb changed for constant time execution */
-
- /* precompute k2 subkey */
- msb = (CMAC_K1(pCtx))[0];
- LogicalLeftSift16(CMAC_K1(pCtx),CMAC_K2(pCtx));
- (CMAC_K2(pCtx))[MBS_RIJ128-1] ^= (Ipp8u)((0-(msb>>7)) & 0x87); /* ^ Rb changed for constant time execution */
- }
-
- return sts;
- }
-}
-
-
-/*F*
-// Name: ippsAES_CMACUpdate
-//
-// Purpose: Updates intermadiate digest based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrc == NULL
-// pCtx == NULL
-// ippStsContextMatchErr !VALID_AESCMAC_ID()
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pCtx pointer to the CMAC context
-//
-*F*/
-static
-void AES_CMAC_processing(Ipp8u* pDigest, const Ipp8u* pSrc, int processedLen, const IppsAESSpec* pAES)
-{
- /* setup encoder method */
- RijnCipher encoder = RIJ_ENCODER(pAES);
-
- while(processedLen) {
- ((Ipp32u*)pDigest)[0] ^= ((Ipp32u*)pSrc)[0];
- ((Ipp32u*)pDigest)[1] ^= ((Ipp32u*)pSrc)[1];
- ((Ipp32u*)pDigest)[2] ^= ((Ipp32u*)pSrc)[2];
- ((Ipp32u*)pDigest)[3] ^= ((Ipp32u*)pSrc)[3];
-
- encoder(pDigest, pDigest, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
-
- pSrc += MBS_RIJ128;
- processedLen -= MBS_RIJ128;
- }
-}
-
-IPPFUN(IppStatus, ippsAES_CMACUpdate,(const Ipp8u* pSrc, int len, IppsAES_CMACState* pCtx))
-{
- int processedLen;
-
- /* test context pointer */
- IPP_BAD_PTR1_RET(pCtx);
- /* use aligned context */
- pCtx = (IppsAES_CMACState*)( IPP_ALIGNED_PTR(pCtx, AESCMAC_ALIGNMENT) );
-
- /* test ID */
- IPP_BADARG_RET(!VALID_AESCMAC_ID(pCtx), ippStsContextMatchErr);
- /* test input message and it's length */
- IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- if(!len)
- return ippStsNoErr;
-
- {
- /*
- // test internal buffer filling
- */
- if(CMAC_INDX(pCtx)) {
- /* copy from input stream to the internal buffer as match as possible */
- processedLen = IPP_MIN(len, (MBS_RIJ128 - CMAC_INDX(pCtx)));
- CopyBlock(pSrc, CMAC_BUFF(pCtx)+CMAC_INDX(pCtx), processedLen);
-
- /* internal buffer filling */
- CMAC_INDX(pCtx) += processedLen;
-
- /* update message pointer and length */
- pSrc += processedLen;
- len -= processedLen;
-
- if(!len)
- return ippStsNoErr;
-
- /* update CMAC if buffer full but not the last */
- if(MBS_RIJ128==CMAC_INDX(pCtx) ) {
- const IppsAESSpec* pAES = &CMAC_CIPHER(pCtx);
- /* setup encoder method */
- RijnCipher encoder = RIJ_ENCODER(pAES);
- XorBlock16(CMAC_BUFF(pCtx), CMAC_MAC(pCtx), CMAC_MAC(pCtx));
-
- encoder(CMAC_MAC(pCtx), CMAC_MAC(pCtx), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
-
- CMAC_INDX(pCtx) = 0;
- }
- }
-
- /*
- // main part
- */
- processedLen = len & ~(MBS_RIJ128-1);
- if(!(len & (MBS_RIJ128-1)))
- processedLen -= MBS_RIJ128;
- if(processedLen) {
- const IppsAESSpec* pAES = &CMAC_CIPHER(pCtx);
-
- AES_CMAC_processing(CMAC_MAC(pCtx), pSrc, processedLen, pAES);
-
- /* update message pointer and length */
- pSrc += processedLen;
- len -= processedLen;
- }
-
- /*
- // remaind
- */
- if(len) {
- CopyBlock(pSrc, (Ipp8u*)(&CMAC_BUFF(pCtx)), len);
- /* update internal buffer filling */
- CMAC_INDX(pCtx) += len;
- }
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsAES_CMACFinal
-//
-// Purpose: Stop message digesting and return MD.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pCtx == NULL
-// ippStsContextMatchErr !VALID_AESCMAC_ID()
-// ippStsLengthErr MBS_RIJ128 < mdLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD pointer to the output message digest
-// mdLen requested length of the message digest
-// pCtx pointer to the CMAC context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_CMACFinal,(Ipp8u* pMD, int mdLen, IppsAES_CMACState* pCtx))
-{
- /* test context pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- /* use aligned context */
- pCtx = (IppsAES_CMACState*)( IPP_ALIGNED_PTR(pCtx, AESCMAC_ALIGNMENT) );
-
- IPP_BADARG_RET(!VALID_AESCMAC_ID(pCtx), ippStsContextMatchErr);
- /* test DAC pointer */
- IPP_BAD_PTR1_RET(pMD);
- IPP_BADARG_RET((mdLen<1)||(MBS_RIJ128idCtx)
-#define AESGCM_STATE(stt) ((stt)->state)
-
-#define AESGCM_IV_LEN(stt) ((stt)->ivLen)
-#define AESGCM_AAD_LEN(stt) ((stt)->aadLen)
-#define AESGCM_TXT_LEN(stt) ((stt)->txtLen)
-
-#define AESGCM_BUFLEN(stt) ((stt)->bufLen)
-#define AESGCM_COUNTER(stt) ((stt)->counter)
-#define AESGCM_ECOUNTER0(stt) ((stt)->ecounter0)
-#define AESGCM_ECOUNTER(stt) ((stt)->ecounter)
-#define AESGCM_GHASH(stt) ((stt)->ghash)
-
-#define AESGCM_HASH(stt) ((stt)->hashFun)
-#define AESGCM_AUTH(stt) ((stt)->authFun)
-#define AESGCM_ENC(stt) ((stt)->encFun)
-#define AESGCM_DEC(stt) ((stt)->decFun)
-
-#define AESGCM_CIPHER(stt) (IppsAESSpec*)(&((stt)->cipher))
-
-#define AESGCM_HKEY(stt) ((stt)->multiplier)
-#define AESGCM_CPWR(stt) ((stt)->multiplier)
-#define AES_GCM_MTBL(stt) ((stt)->multiplier)
-
-#define AESGCM_VALID_ID(stt) (AESGCM_ID((stt))==idCtxAESGCM)
-
-
-__INLINE void IncrementCounter32(Ipp8u* pCtr)
-{
- int i;
- for(i=BLOCK_SIZE-1; i>=CTR_POS && 0==(Ipp8u)(++pCtr[i]); i--) ;
-}
-
-
-void AesGcmPrecompute_table2K(Ipp8u* pPrecomputeData, const Ipp8u* pHKey);
-void AesGcmMulGcm_table2K(Ipp8u* pGhash, const Ipp8u* pHkey, const void* pParam);
-void AesGcmAuth_table2K(Ipp8u* pGhash, const Ipp8u* pSrc, int len, const Ipp8u* pHkey, const void* pParam);
-void wrpAesGcmEnc_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
-void wrpAesGcmDec_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pCtx);
-
-extern const Ipp16u AesGcmConst_table[256]; /* precomputed reduction table */
-
-#endif /* _CP_AESAUTH_GCM_H*/
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c
deleted file mode 100644
index bf8d8264b4..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesauthgcmca.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-#include "pcpaesauthgcm.h"
-#include "pcptool.h"
-
-#include "pcprijtables.h"
-
-/*F*
-// Name: ippsAES_GCMGetSize
-//
-// Purpose: Returns size of AES_GCM state (in bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to size of context
-//
-*F*/
-static int cpSizeofCtx_AESGCM(void)
-{
- int precomp_size;
-
- precomp_size = PRECOMP_DATA_SIZE_FAST2K;
-
- /* decrease precomp_size as soon as BLOCK_SIZE bytes already reserved in context */
- precomp_size -= BLOCK_SIZE;
-
- return sizeof(IppsAES_GCMState)
- +precomp_size
- +AESGCM_ALIGNMENT-1;
-}
-
-IPPFUN(IppStatus, ippsAES_GCMGetSize,(int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = cpSizeofCtx_AESGCM();
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsAES_GCMReset
-//
-// Purpose: Resets AES_GCM context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState== NULL
-// ippStsContextMatchErr pState points on invalid context
-// ippStsNoErr no errors
-//
-// Parameters:
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMReset,(IppsAES_GCMState* pState))
-{
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pState);
-
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test context validity */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
-
- /* reset GCM */
- AESGCM_STATE(pState) = GcmInit;
- AESGCM_IV_LEN(pState) = CONST_64(0);
- AESGCM_AAD_LEN(pState) = CONST_64(0);
- AESGCM_TXT_LEN(pState) = CONST_64(0);
-
- AESGCM_BUFLEN(pState) = 0;
- PaddBlock(0, AESGCM_COUNTER(pState), BLOCK_SIZE);
- PaddBlock(0, AESGCM_ECOUNTER(pState), BLOCK_SIZE);
- PaddBlock(0, AESGCM_ECOUNTER0(pState), BLOCK_SIZE);
- PaddBlock(0, AESGCM_GHASH(pState), BLOCK_SIZE);
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsAES_GCMInit
-//
-// Purpose: Init AES_GCM context for future usage.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// ippStsMemAllocErr size of buffer is not match fro operation
-// ippStsLengthErr keyLen != 16 &&
-// != 24 &&
-// != 32
-// ippStsNoErr no errors
-//
-// Parameters:
-// pKey pointer to the secret key
-// keyLen length of secret key
-// pState pointer to the AES-GCM context
-// ctxSize available size (in bytes) of buffer above
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_GCMState* pState, int ctxSize))
-{
- /* test pCtx pointer */
- IPP_BAD_PTR1_RET(pState);
-
- /* test available size of context buffer */
- IPP_BADARG_RET(ctxSize0
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsLengthErr ivLen <0
-// ippStsBadArgErr illegal sequence call
-// ippStsNoErr no errors
-//
-// Parameters:
-// pIV pointer to the IV
-// ivLen length of IV (it could be 0)
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMProcessIV,(const Ipp8u* pIV, int ivLen, IppsAES_GCMState* pState))
-{
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pState);
-
- /* test IV pointer and length */
- IPP_BADARG_RET(ivLen && !pIV, ippStsNullPtrErr);
- IPP_BADARG_RET(ivLen<0, ippStsLengthErr);
-
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test context validity */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
-
- IPP_BADARG_RET(!(GcmInit==AESGCM_STATE(pState) || GcmIVprocessing==AESGCM_STATE(pState)), ippStsBadArgErr);
-
- /* switch IVprocessing on */
- AESGCM_STATE(pState) = GcmIVprocessing;
-
- /* test if buffer is not empty */
- if(AESGCM_BUFLEN(pState)) {
- int locLen = IPP_MIN(ivLen, BLOCK_SIZE-AESGCM_BUFLEN(pState));
- XorBlock(pIV, AESGCM_COUNTER(pState)+AESGCM_BUFLEN(pState), AESGCM_COUNTER(pState)+AESGCM_BUFLEN(pState), locLen);
- AESGCM_BUFLEN(pState) += locLen;
-
- /* if buffer full */
- if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) {
- MulGcm_ ghashFunc = AESGCM_HASH(pState);
- ghashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table);
- AESGCM_BUFLEN(pState) = 0;
- }
-
- AESGCM_IV_LEN(pState) += locLen;
- pIV += locLen;
- ivLen -= locLen;
- }
-
- /* process main part of IV */
- {
- int lenBlks = ivLen & (-BLOCK_SIZE);
- if(lenBlks) {
- Auth_ authFunc = AESGCM_AUTH(pState);
-
- authFunc(AESGCM_COUNTER(pState), pIV, lenBlks, AESGCM_HKEY(pState), AesGcmConst_table);
-
- AESGCM_IV_LEN(pState) += lenBlks;
- pIV += lenBlks;
- ivLen -= lenBlks;
- }
- }
-
- /* copy the rest of IV into the buffer */
- if(ivLen) {
- XorBlock(pIV, AESGCM_COUNTER(pState), AESGCM_COUNTER(pState), ivLen);
- AESGCM_IV_LEN(pState) += ivLen;
- AESGCM_BUFLEN(pState) += ivLen;
- }
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsAES_GCMProcessAAD
-//
-// Purpose: AAD processing.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// pAAD == NULL, aadLen>0
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsLengthErr aadLen <0
-// ippStsBadArgErr illegal sequence call
-// ippStsNoErr no errors
-//
-// Parameters:
-// pAAD pointer to the AAD
-// aadlen length of AAD (it could be 0)
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMProcessAAD,(const Ipp8u* pAAD, int aadLen, IppsAES_GCMState* pState))
-{
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pState);
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test if context is valid */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
-
- /* test AAD pointer and length */
- IPP_BADARG_RET(aadLen && !pAAD, ippStsNullPtrErr);
- IPP_BADARG_RET(aadLen<0, ippStsLengthErr);
-
- IPP_BADARG_RET(!(GcmIVprocessing==AESGCM_STATE(pState) || GcmAADprocessing==AESGCM_STATE(pState)), ippStsBadArgErr);
-
- {
- /* get method */
- MulGcm_ hashFunc = AESGCM_HASH(pState);
-
- if( GcmIVprocessing==AESGCM_STATE(pState) ) {
- IPP_BADARG_RET(0==AESGCM_IV_LEN(pState), ippStsBadArgErr);
-
- /* complete IV processing */
- if(CTR_POS==AESGCM_IV_LEN(pState)) {
- /* apply special format if IV length is 12 bytes */
- AESGCM_COUNTER(pState)[12] = 0;
- AESGCM_COUNTER(pState)[13] = 0;
- AESGCM_COUNTER(pState)[14] = 0;
- AESGCM_COUNTER(pState)[15] = 1;
- }
- else {
- /* process the rest of IV */
- if(AESGCM_BUFLEN(pState))
- hashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table);
-
- /* add IV bit length */
- {
- Ipp64u ivBitLen = AESGCM_IV_LEN(pState)*BYTESIZE;
- Ipp8u tmp[BLOCK_SIZE];
- PaddBlock(0, tmp, BLOCK_SIZE-8);
- U32_TO_HSTRING(tmp+8, HIDWORD(ivBitLen));
- U32_TO_HSTRING(tmp+12, LODWORD(ivBitLen));
- XorBlock16(tmp, AESGCM_COUNTER(pState), AESGCM_COUNTER(pState));
- hashFunc(AESGCM_COUNTER(pState), AESGCM_HKEY(pState), AesGcmConst_table);
- }
- }
-
- /* prepare initial counter */
- {
- IppsAESSpec* pAES = AESGCM_CIPHER(pState);
- RijnCipher encoder = RIJ_ENCODER(pAES);
- encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER0(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
- }
-
- /* switch mode and init counters */
- AESGCM_STATE(pState) = GcmAADprocessing;
- AESGCM_AAD_LEN(pState) = CONST_64(0);
- AESGCM_BUFLEN(pState) = 0;
- }
-
- /*
- // AAD processing
- */
-
- /* test if buffer is not empty */
- if(AESGCM_BUFLEN(pState)) {
- int locLen = IPP_MIN(aadLen, BLOCK_SIZE-AESGCM_BUFLEN(pState));
- XorBlock(pAAD, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen);
- AESGCM_BUFLEN(pState) += locLen;
-
- /* if buffer full */
- if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) {
- hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table);
- AESGCM_BUFLEN(pState) = 0;
- }
-
- AESGCM_AAD_LEN(pState) += locLen;
- pAAD += locLen;
- aadLen -= locLen;
- }
-
- /* process main part of AAD */
- {
- int lenBlks = aadLen & (-BLOCK_SIZE);
- if(lenBlks) {
- Auth_ authFunc = AESGCM_AUTH(pState);
-
- authFunc(AESGCM_GHASH(pState), pAAD, lenBlks, AESGCM_HKEY(pState), AesGcmConst_table);
-
- AESGCM_AAD_LEN(pState) += lenBlks;
- pAAD += lenBlks;
- aadLen -= lenBlks;
- }
- }
-
- /* copy the rest of AAD into the buffer */
- if(aadLen) {
- XorBlock(pAAD, AESGCM_GHASH(pState), AESGCM_GHASH(pState), aadLen);
- AESGCM_AAD_LEN(pState) += aadLen;
- AESGCM_BUFLEN(pState) = aadLen;
- }
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsAES_GCMStart
-//
-// Purpose: Start the process of encryption or decryption and authentication tag generation.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// pIV == NULL, ivLen>0
-// pAAD == NULL, aadLen>0
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsLengthErr ivLen < 0
-// aadLen < 0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pIV pointer to the IV (nonce)
-// ivLen length of the IV in bytes
-// pAAD pointer to the Addition Authenticated Data (header)
-// aadLen length of the AAD in bytes
-// pState pointer to the AES-GCM state
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMStart,(const Ipp8u* pIV, int ivLen,
- const Ipp8u* pAAD, int aadLen,
- IppsAES_GCMState* pState))
-{
- IppStatus sts = ippsAES_GCMReset(pState);
- if(ippStsNoErr==sts)
- sts = ippsAES_GCMProcessIV(pIV, ivLen, pState);
- if(ippStsNoErr==sts)
- sts = ippsAES_GCMProcessAAD(pAAD, aadLen, pState);
- return sts;
-}
-
-
-/*F*
-// Name: ippsAES_GCMEncrypt
-//
-// Purpose: Encrypts a data buffer in the GCM mode.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrc == NULL
-// pDst == NULL
-// pState == NULL
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsLengthErr txtLen<0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc Pointer to plaintext.
-// pDst Pointer to ciphertext.
-// len Length of the plaintext and ciphertext in bytes
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int txtLen,
- IppsAES_GCMState* pState))
-{
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pState);
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test state ID */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
- /* test context validity */
- IPP_BADARG_RET(!(GcmAADprocessing==AESGCM_STATE(pState) || GcmTXTprocessing==AESGCM_STATE(pState)), ippStsBadArgErr);
-
- /* test text pointers and length */
- IPP_BAD_PTR2_RET(pSrc, pDst);
- IPP_BADARG_RET(txtLen<0, ippStsLengthErr);
-
-
- {
- /* get method */
- IppsAESSpec* pAES = AESGCM_CIPHER(pState);
- RijnCipher encoder = RIJ_ENCODER(pAES);
- MulGcm_ hashFunc = AESGCM_HASH(pState);
-
- if( GcmAADprocessing==AESGCM_STATE(pState) ) {
- /* complete AAD processing */
- if(AESGCM_BUFLEN(pState))
- hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table);
-
- /* increment counter block */
- IncrementCounter32(AESGCM_COUNTER(pState));
- /* and encrypt counter */
- encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
-
- /* switch mode and init counters */
- AESGCM_STATE(pState) = GcmTXTprocessing;
- AESGCM_TXT_LEN(pState) = CONST_64(0);
- AESGCM_BUFLEN(pState) = 0;
- }
-
- /*
- // process text (encrypt and authenticate)
- */
- /* process partial block */
- if(AESGCM_BUFLEN(pState)) {
- int locLen = IPP_MIN(txtLen, BLOCK_SIZE-AESGCM_BUFLEN(pState));
- /* ctr encryption */
- XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, locLen);
- /* authentication */
- XorBlock(pDst, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen);
-
- AESGCM_BUFLEN(pState) += locLen;
- AESGCM_TXT_LEN(pState) += locLen;
- pSrc += locLen;
- pDst += locLen;
- txtLen -= locLen;
-
- /* if buffer full */
- if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) {
- /* hash buffer */
- hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table);
- AESGCM_BUFLEN(pState) = 0;
-
- /* increment counter block */
- IncrementCounter32(AESGCM_COUNTER(pState));
- /* and encrypt counter */
- encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
- }
- }
-
- /* process the main part of text */
- {
- int lenBlks = txtLen & (-BLOCK_SIZE);
- if(lenBlks) {
- Encrypt_ encFunc = AESGCM_ENC(pState);
-
- encFunc(pDst, pSrc, lenBlks, pState);
-
- AESGCM_TXT_LEN(pState) += lenBlks;
- pSrc += lenBlks;
- pDst += lenBlks;
- txtLen -= lenBlks;
- }
- }
-
- /* process the rest of text */
- if(txtLen) {
- XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, txtLen);
- XorBlock(pDst, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), txtLen);
-
- AESGCM_BUFLEN(pState) += txtLen;
- AESGCM_TXT_LEN(pState) += txtLen;
- }
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsAES_GCMDecrypt
-//
-// Purpose: Decrypts a data buffer in the GCM mode.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrc == NULL
-// pDst == NULL
-// pState == NULL
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsLengthErr txtLen<0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc Pointer to ciphertext.
-// pDst Pointer to plaintext.
-// len Length of the plaintext and ciphertext in bytes
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int txtLen, IppsAES_GCMState* pState))
-{
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pState);
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test state ID */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
- /* test context validity */
- IPP_BADARG_RET(!(GcmAADprocessing==AESGCM_STATE(pState) || GcmTXTprocessing==AESGCM_STATE(pState)), ippStsBadArgErr);
-
- /* test text pointers and length */
- IPP_BAD_PTR2_RET(pSrc, pDst);
- IPP_BADARG_RET(txtLen<0, ippStsLengthErr);
-
-
- {
- /* get method */
- IppsAESSpec* pAES = AESGCM_CIPHER(pState);
- RijnCipher encoder = RIJ_ENCODER(pAES);
- MulGcm_ hashFunc = AESGCM_HASH(pState);
-
- if( GcmAADprocessing==AESGCM_STATE(pState) ) {
- /* complete AAD processing */
- if(AESGCM_BUFLEN(pState))
- hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table);
-
- /* increment counter block */
- IncrementCounter32(AESGCM_COUNTER(pState));
- /* and encrypt counter */
- encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
-
- /* switch mode and init counters */
- AESGCM_BUFLEN(pState) = 0;
- AESGCM_TXT_LEN(pState) = CONST_64(0);
- AESGCM_STATE(pState) = GcmTXTprocessing;
- }
-
- /*
- // process text (authenticate and decrypt )
- */
- /* process partial block */
- if(AESGCM_BUFLEN(pState)) {
- int locLen = IPP_MIN(txtLen, BLOCK_SIZE-AESGCM_BUFLEN(pState));
- /* authentication */
- XorBlock(pSrc, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), locLen);
- /* ctr decryption */
- XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, locLen);
-
- AESGCM_BUFLEN(pState) += locLen;
- AESGCM_TXT_LEN(pState) += locLen;
- pSrc += locLen;
- pDst += locLen;
- txtLen -= locLen;
-
- /* if buffer full */
- if(BLOCK_SIZE==AESGCM_BUFLEN(pState)) {
- /* hash buffer */
- hashFunc(AESGCM_GHASH(pState), AESGCM_HKEY(pState), AesGcmConst_table);
- AESGCM_BUFLEN(pState) = 0;
-
- /* increment counter block */
- IncrementCounter32(AESGCM_COUNTER(pState));
- /* and encrypt counter */
- encoder(AESGCM_COUNTER(pState), AESGCM_ECOUNTER(pState), RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
- }
- }
-
- /* process the main part of text */
- {
- int lenBlks = txtLen & (-BLOCK_SIZE);
- if(lenBlks) {
- Decrypt_ decFunc = AESGCM_DEC(pState);
-
- decFunc(pDst, pSrc, lenBlks, pState);
-
- AESGCM_TXT_LEN(pState) += lenBlks;
- pSrc += lenBlks;
- pDst += lenBlks;
- txtLen -= lenBlks;
- }
- }
-
- /* process the rest of text */
- if(txtLen) {
- /* ctr encryption */
- XorBlock(pSrc, AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), AESGCM_GHASH(pState)+AESGCM_BUFLEN(pState), txtLen);
- XorBlock(pSrc, AESGCM_ECOUNTER(pState)+AESGCM_BUFLEN(pState), pDst, txtLen);
-
- AESGCM_BUFLEN(pState) += txtLen;
- AESGCM_TXT_LEN(pState) += txtLen;
- }
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsAES_GCMGetTag
-//
-// Purpose: Generates authentication tag in the GCM mode.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pDstTag == NULL
-// pState == NULL
-// ippStsLengthErr tagLen<=0 || tagLen>16
-// ippStsContextMatchErr !AESGCM_VALID_ID()
-// ippStsNoErr no errors
-//
-// Parameters:
-// pDstTag pointer to the authentication tag.
-// tagLen length of the authentication tag *pDstTag in bytes
-// pState pointer to the context
-//
-*F*/
-IPPFUN(IppStatus, ippsAES_GCMGetTag,(Ipp8u* pTag, int tagLen, const IppsAES_GCMState* pState))
-{
- /* test State pointer */
- IPP_BAD_PTR1_RET(pState);
- /* use aligned context */
- pState = (IppsAES_GCMState*)( IPP_ALIGNED_PTR(pState, AESGCM_ALIGNMENT) );
- /* test state ID */
- IPP_BADARG_RET(!AESGCM_VALID_ID(pState), ippStsContextMatchErr);
-
- /* test tag pointer and length */
- IPP_BAD_PTR1_RET(pTag);
- IPP_BADARG_RET(tagLen<=0 || tagLen>BLOCK_SIZE, ippStsLengthErr);
-
-
- {
- /* get method */
- MulGcm_ hashFunc = AESGCM_HASH(pState);
-
- __ALIGN16 Ipp8u tmpHash[BLOCK_SIZE];
- Ipp8u tmpCntr[BLOCK_SIZE];
-
- /* local copy of AAD and text counters (in bits) */
- Ipp64u aadBitLen = AESGCM_AAD_LEN(pState)*BYTESIZE;
- Ipp64u txtBitLen = AESGCM_TXT_LEN(pState)*BYTESIZE;
-
- /* do local copy of ghash */
- CopyBlock16(AESGCM_GHASH(pState), tmpHash);
-
- /* complete text processing */
- if(AESGCM_BUFLEN(pState)) {
- hashFunc(tmpHash, AESGCM_HKEY(pState), AesGcmConst_table);
- }
-
- /* process lengths of AAD and text */
- U32_TO_HSTRING(tmpCntr, HIDWORD(aadBitLen));
- U32_TO_HSTRING(tmpCntr+4, LODWORD(aadBitLen));
- U32_TO_HSTRING(tmpCntr+8, HIDWORD(txtBitLen));
- U32_TO_HSTRING(tmpCntr+12,LODWORD(txtBitLen));
-
- XorBlock16(tmpHash, tmpCntr, tmpHash);
- hashFunc(tmpHash, AESGCM_HKEY(pState), AesGcmConst_table);
-
- /* add encrypted initial counter */
- XorBlock16(tmpHash, AESGCM_ECOUNTER0(pState), tmpHash);
-
- /* return tag of required lenth */
- CopyBlock(tmpHash, pTag, tagLen);
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c
deleted file mode 100644
index ca4f51afe1..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtableca.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-const Ipp16u AesGcmConst_table[256] = {
-0x0000, 0xc201, 0x8403, 0x4602, 0x0807, 0xca06, 0x8c04, 0x4e05, 0x100e, 0xd20f, 0x940d, 0x560c, 0x1809, 0xda08, 0x9c0a, 0x5e0b,
-0x201c, 0xe21d, 0xa41f, 0x661e, 0x281b, 0xea1a, 0xac18, 0x6e19, 0x3012, 0xf213, 0xb411, 0x7610, 0x3815, 0xfa14, 0xbc16, 0x7e17,
-0x4038, 0x8239, 0xc43b, 0x063a, 0x483f, 0x8a3e, 0xcc3c, 0x0e3d, 0x5036, 0x9237, 0xd435, 0x1634, 0x5831, 0x9a30, 0xdc32, 0x1e33,
-0x6024, 0xa225, 0xe427, 0x2626, 0x6823, 0xaa22, 0xec20, 0x2e21, 0x702a, 0xb22b, 0xf429, 0x3628, 0x782d, 0xba2c, 0xfc2e, 0x3e2f,
-0x8070, 0x4271, 0x0473, 0xc672, 0x8877, 0x4a76, 0x0c74, 0xce75, 0x907e, 0x527f, 0x147d, 0xd67c, 0x9879, 0x5a78, 0x1c7a, 0xde7b,
-0xa06c, 0x626d, 0x246f, 0xe66e, 0xa86b, 0x6a6a, 0x2c68, 0xee69, 0xb062, 0x7263, 0x3461, 0xf660, 0xb865, 0x7a64, 0x3c66, 0xfe67,
-0xc048, 0x0249, 0x444b, 0x864a, 0xc84f, 0x0a4e, 0x4c4c, 0x8e4d, 0xd046, 0x1247, 0x5445, 0x9644, 0xd841, 0x1a40, 0x5c42, 0x9e43,
-0xe054, 0x2255, 0x6457, 0xa656, 0xe853, 0x2a52, 0x6c50, 0xae51, 0xf05a, 0x325b, 0x7459, 0xb658, 0xf85d, 0x3a5c, 0x7c5e, 0xbe5f,
-0x00e1, 0xc2e0, 0x84e2, 0x46e3, 0x08e6, 0xcae7, 0x8ce5, 0x4ee4, 0x10ef, 0xd2ee, 0x94ec, 0x56ed, 0x18e8, 0xdae9, 0x9ceb, 0x5eea,
-0x20fd, 0xe2fc, 0xa4fe, 0x66ff, 0x28fa, 0xeafb, 0xacf9, 0x6ef8, 0x30f3, 0xf2f2, 0xb4f0, 0x76f1, 0x38f4, 0xfaf5, 0xbcf7, 0x7ef6,
-0x40d9, 0x82d8, 0xc4da, 0x06db, 0x48de, 0x8adf, 0xccdd, 0x0edc, 0x50d7, 0x92d6, 0xd4d4, 0x16d5, 0x58d0, 0x9ad1, 0xdcd3, 0x1ed2,
-0x60c5, 0xa2c4, 0xe4c6, 0x26c7, 0x68c2, 0xaac3, 0xecc1, 0x2ec0, 0x70cb, 0xb2ca, 0xf4c8, 0x36c9, 0x78cc, 0xbacd, 0xfccf, 0x3ece,
-0x8091, 0x4290, 0x0492, 0xc693, 0x8896, 0x4a97, 0x0c95, 0xce94, 0x909f, 0x529e, 0x149c, 0xd69d, 0x9898, 0x5a99, 0x1c9b, 0xde9a,
-0xa08d, 0x628c, 0x248e, 0xe68f, 0xa88a, 0x6a8b, 0x2c89, 0xee88, 0xb083, 0x7282, 0x3480, 0xf681, 0xb884, 0x7a85, 0x3c87, 0xfe86,
-0xc0a9, 0x02a8, 0x44aa, 0x86ab, 0xc8ae, 0x0aaf, 0x4cad, 0x8eac, 0xd0a7, 0x12a6, 0x54a4, 0x96a5, 0xd8a0, 0x1aa1, 0x5ca3, 0x9ea2,
-0xe0b5, 0x22b4, 0x64b6, 0xa6b7, 0xe8b2, 0x2ab3, 0x6cb1, 0xaeb0, 0xf0bb, 0x32ba, 0x74b8, 0xb6b9, 0xf8bc, 0x3abd, 0x7cbf, 0xbebe
-};
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c
deleted file mode 100644
index edbdfd291a..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesgcmtbl2kca.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-#include "pcpaesauthgcm.h"
-#include "pcptool.h"
-
-#include "pcprijtables.h"
-
-
-/*
-// AES-GCM precomputations.
-*/
-static void RightShiftBlock16(Ipp8u* pBlock)
-{
- Ipp8u v0 = 0;
- int i;
- for(i=0; i<16; i++) {
- Ipp8u v1 = pBlock[i];
- Ipp8u tmp = (Ipp8u)( (v1>>1) | (v0<<7) );
- pBlock[i] = tmp;
- v0 = v1;
- }
-}
-void AesGcmPrecompute_table2K(Ipp8u* pPrecomputeData, const Ipp8u* pHKey)
-{
- Ipp8u t[BLOCK_SIZE];
- int n;
-
- CopyBlock16(pHKey, t);
-
- for(n=0; n<128-24; n++) {
- /* get msb */
- int hBit = t[15]&1;
-
- int k = n%32;
- if(k<4) {
- CopyBlock16(t, pPrecomputeData +1024 +(n/32)*256 +(Ipp32u)(1<<(7-k)));
- }
- else if(k<8) {
- CopyBlock16(t, pPrecomputeData +(n/32)*256 +(Ipp32u)(1<<(11-k)));
- }
-
- /* shift */
- RightShiftBlock16(t);
- /* xor if msb=1 */
- if(hBit)
- t[0] ^= 0xe1;
- }
-
- for(n=0; n<4; n++) {
- int m, k;
- XorBlock16(pPrecomputeData +n*256, pPrecomputeData +n*256, pPrecomputeData +n*256);
- XorBlock16(pPrecomputeData +1024 +n*256, pPrecomputeData +1024 +n*256, pPrecomputeData +1024 +n*256);
- for(m=2; m<=8; m*=2)
- for(k=1; k=BLOCK_SIZE) {
- /* add src */
- XorBlock16(pSrc, pHash, pHash);
- /* hash it */
- AesGcmMulGcm_table2K(pHash, pHKey, AesGcmConst_table);
-
- pSrc += BLOCK_SIZE;
- len -= BLOCK_SIZE;
- }
-}
-
-
-/*
-// encrypts and authenticates n*BLOCK_SIZE bytes
-*/
-void wrpAesGcmEnc_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pState)
-{
- Ipp8u* pHashedData = pDst;
- int hashedDataLen = len;
-
- Ipp8u* pCounter = AESGCM_COUNTER(pState);
- Ipp8u* pECounter = AESGCM_ECOUNTER(pState);
-
- IppsAESSpec* pAES = AESGCM_CIPHER(pState);
- RijnCipher encoder = RIJ_ENCODER(pAES);
-
- while(len>=BLOCK_SIZE) {
- /* encrypt whole AES block */
- XorBlock16(pSrc, pECounter, pDst);
-
- pSrc += BLOCK_SIZE;
- pDst += BLOCK_SIZE;
- len -= BLOCK_SIZE;
-
- /* increment counter block */
- IncrementCounter32(pCounter);
- /* and encrypt counter */
- encoder(pCounter, pECounter, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
- }
-
- AesGcmAuth_table2K(AESGCM_GHASH(pState), pHashedData, hashedDataLen, AESGCM_HKEY(pState), AesGcmConst_table);
-}
-
-
-/*
-// authenticates and decrypts n*BLOCK_SIZE bytes
-*/
-void wrpAesGcmDec_table2K(Ipp8u* pDst, const Ipp8u* pSrc, int len, IppsAES_GCMState* pState)
-{
- AesGcmAuth_table2K(AESGCM_GHASH(pState), pSrc, len, AESGCM_HKEY(pState), AesGcmConst_table);
-
- {
- Ipp8u* pCounter = AESGCM_COUNTER(pState);
- Ipp8u* pECounter = AESGCM_ECOUNTER(pState);
-
- IppsAESSpec* pAES = AESGCM_CIPHER(pState);
- RijnCipher encoder = RIJ_ENCODER(pAES);
-
- while(len>=BLOCK_SIZE) {
- /* encrypt whole AES block */
- XorBlock16(pSrc, pECounter, pDst);
-
- pSrc += BLOCK_SIZE;
- pDst += BLOCK_SIZE;
- len -= BLOCK_SIZE;
-
- /* increment counter block */
- IncrementCounter32(pCounter);
- /* and encrypt counter */
- encoder(pCounter, pECounter, RIJ_NR(pAES), RIJ_EKEYS(pAES), RijEncSbox);
- }
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesm.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesm.h
deleted file mode 100644
index 924fcf238e..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesm.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_AES_H)
-#define _PCP_AES_H
-
-#include "pcprij.h"
-
-/* alignment of AES context */
-#define AES_ALIGNMENT (RIJ_ALIGNMENT)
-
-/* valid AES context ID */
-#define VALID_AES_ID(ctx) (RIJ_ID((ctx))==idCtxRijndael)
-
-/* size of AES context */
-__INLINE int cpSizeofCtx_AES(void)
-{
- return sizeof(IppsAESSpec)
- +(AES_ALIGNMENT-1);
-}
-
-#endif /* _PCP_AES_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c
deleted file mode 100644
index 6aac2fc218..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesmctrca.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-
-#include "owncp.h"
-#include "pcpaesm.h"
-#include "pcptool.h"
-
-#include "pcprijtables.h"
-
-/*
-// AES-CRT processing.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// pSrc == NULL
-// pDst == NULL
-// pCtrValue ==NULL
-// ippStsContextMatchErr !VALID_AES_ID()
-// ippStsLengthErr len <1
-// ippStsCTRSizeErr 128 < ctrNumBitSize < 1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the source data buffer
-// pDst pointer to the target data buffer
-// dataLen input/output buffer length (in bytes)
-// pCtx pointer to rge AES context
-// pCtrValue pointer to the counter block
-// ctrNumBitSize counter block size (bits)
-//
-// Note:
-// counter will updated on return
-//
-*/
-static
-IppStatus cpProcessAES_ctr(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
- const IppsAESSpec* pCtx,
- Ipp8u* pCtrValue, int ctrNumBitSize)
-{
- /* test context */
- IPP_BAD_PTR1_RET(pCtx);
- /* use aligned AES context */
- pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtx, AES_ALIGNMENT) );
- /* test the context ID */
- IPP_BADARG_RET(!VALID_AES_ID(pCtx), ippStsContextMatchErr);
-
- /* test source, target and counter block pointers */
- IPP_BAD_PTR3_RET(pSrc, pDst, pCtrValue);
- /* test stream length */
- IPP_BADARG_RET((dataLen<1), ippStsLengthErr);
-
- /* test counter block size */
- IPP_BADARG_RET(((MBS_RIJ128*8)= MBS_RIJ128) {
- /* encrypt counter block */
- encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox);
-
- /* compute ciphertext block */
- if( !(IPP_UINT_PTR(pSrc) & 0x3) && !(IPP_UINT_PTR(pDst) & 0x3)) {
- ((Ipp32u*)pDst)[0] = output[0]^((Ipp32u*)pSrc)[0];
- ((Ipp32u*)pDst)[1] = output[1]^((Ipp32u*)pSrc)[1];
- ((Ipp32u*)pDst)[2] = output[2]^((Ipp32u*)pSrc)[2];
- ((Ipp32u*)pDst)[3] = output[3]^((Ipp32u*)pSrc)[3];
- }
- else
- XorBlock16(pSrc, output, pDst);
- /* encrement counter block */
- StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize);
-
- pSrc += MBS_RIJ128;
- pDst += MBS_RIJ128;
- dataLen -= MBS_RIJ128;
- }
- /*
- // encrypt last data block
- */
- if(dataLen) {
- /* encrypt counter block */
- encoder((Ipp8u*)counter, (Ipp8u*)output, RIJ_NR(pCtx), RIJ_EKEYS(pCtx), RijEncSbox);
-
- /* compute ciphertext block */
- XorBlock(pSrc, output, pDst,dataLen);
- /* encrement counter block */
- StdIncrement((Ipp8u*)counter,MBS_RIJ128*8, ctrNumBitSize);
- }
-
- /* update counter */
- CopyBlock16(counter, pCtrValue);
-
- return ippStsNoErr;
- }
-}
-
-IPPFUN(IppStatus, ippsAESEncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
- const IppsAESSpec* pCtx,
- Ipp8u* pCtrValue, int ctrNumBitSize))
-{
- return cpProcessAES_ctr(pSrc, pDst, dataLen, pCtx, pCtrValue, ctrNumBitSize);
-}
-
-IPPFUN(IppStatus, ippsAESDecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int dataLen,
- const IppsAESSpec* pCtx,
- Ipp8u* pCtrValue, int ctrNumBitSize))
-{
- return cpProcessAES_ctr(pSrc, pDst, dataLen, pCtx, pCtrValue, ctrNumBitSize);
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesminitca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesminitca.c
deleted file mode 100644
index 262fa85e90..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpaesminitca.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpaesm.h"
-#include "pcptool.h"
-
-#include "pcprijtables.h"
-
-/*F*
-// Name: ippsAESGetSize
-//
-// Purpose: Returns size of AES context (in bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSzie == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to AES size of context(in bytes)
-//
-*F*/
-IPPFUN(IppStatus, ippsAESGetSize,(int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = cpSizeofCtx_AES();
-
- return ippStsNoErr;
-}
-
-/* number of rounds (use [NK] for access) */
-static int rij128nRounds[3] = {NR128_128, NR128_192, NR128_256};
-
-/*
-// number of keys (estimation only!) (use [NK] for access)
-//
-// accurate number of keys necassary for encrypt/decrypt are:
-// nKeys = NB * (NR+1)
-// where NB - data block size (32-bit words)
-// NR - number of rounds (depend on NB and keyLen)
-//
-// but the estimation
-// estnKeys = (NK*n) >= nKeys
-// or
-// estnKeys = ( (NB*(NR+1) + (NK-1)) / NK) * NK
-// where NK - key length (words)
-// NB - data block size (word)
-// NR - number of rounds (depend on NB and keyLen)
-// nKeys - accurate numner of keys
-// is more convinient when calculates key extension
-*/
-static int rij128nKeys[3] = {44, 54, 64 };
-
-/*
-// helper for nRounds[] and estnKeys[] access
-// note: x is length in 32-bits words
-*/
-__INLINE int rij_index(int x)
-{ return (x-NB(128))>>1; }
-
-/*F*
-// Name: ippsAESInit
-//
-// Purpose: Init AES context for future usage
-// and setup secret key.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// ippStsMemAllocErr size of buffer is not match fro operation
-// ippStsLengthErr keyLen != 16
-// keyLen != 24
-// keyLen != 32
-//
-// Parameters:
-// pKey secret key
-// keyLen length of the secret key (in bytes)
-// pCtx pointer to buffer initialized as AES context
-// ctxSize available size (in bytes) of buffer above
-//
-// Note:
-// if pKey==NULL, then AES initialized by zero value key
-//
-*F*/
-IPPFUN(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen,
- IppsAESSpec* pCtxRaw, int rawCtxSize))
-{
- /* test context pointer */
- IPP_BAD_PTR1_RET(pCtxRaw);
-
- /* make sure in legal keyLen */
- IPP_BADARG_RET(keyLen!=16 && keyLen!=24 && keyLen!=32, ippStsLengthErr);
-
- {
- /* use aligned Rijndael context */
- IppsAESSpec* pCtx = (IppsAESSpec*)( IPP_ALIGNED_PTR(pCtxRaw, AES_ALIGNMENT) );
-
- /* test available size of context buffer */
- if(((Ipp8u*)pCtx+sizeof(IppsAESSpec)) > ((Ipp8u*)pCtxRaw+rawCtxSize))
- IPP_ERROR_RET(ippStsMemAllocErr);
-
- else {
- int keyWords = NK(keyLen*BITSIZE(Ipp8u));
- int nExpKeys = rij128nKeys [ rij_index(keyWords) ];
- int nRounds = rij128nRounds[ rij_index(keyWords) ];
-
- Ipp8u zeroKey[32] = {0};
- const Ipp8u* pActualKey = pKey? pKey : zeroKey;
-
- /* clear context */
- PaddBlock(0, pCtx, sizeof(IppsAESSpec));
-
- /* init spec */
- RIJ_ID(pCtx) = idCtxRijndael;
- RIJ_NB(pCtx) = NB(128);
- RIJ_NK(pCtx) = keyWords;
- RIJ_NR(pCtx) = nRounds;
- RIJ_SAFE_INIT(pCtx) = 1;
-
- /* set key expansion */
- ExpandRijndaelKey(pActualKey, keyWords, NB(128), nRounds, nExpKeys,
- RIJ_EKEYS(pCtx),
- RIJ_DKEYS(pCtx));
- {
- int nr;
- Ipp8u* pEnc_key = (Ipp8u*)(RIJ_EKEYS(pCtx));
- /* update key material: transpose inplace */
- for(nr=0; nr<(1+nRounds); nr++, pEnc_key+=16) {
- SWAP(pEnc_key[ 1], pEnc_key[ 4]);
- SWAP(pEnc_key[ 2], pEnc_key[ 8]);
- SWAP(pEnc_key[ 3], pEnc_key[12]);
- SWAP(pEnc_key[ 6], pEnc_key[ 9]);
- SWAP(pEnc_key[ 7], pEnc_key[13]);
- SWAP(pEnc_key[11], pEnc_key[14]);
- }
- }
- RIJ_ENCODER(pCtx) = Safe2Encrypt_RIJ128; /* safe encoder (compact Sbox)) */
- RIJ_DECODER(pCtx) = Safe2Decrypt_RIJ128; /* safe decoder (compact Sbox)) */
-
- return ippStsNoErr;
- }
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbn.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbn.h
deleted file mode 100644
index 180f59c5fd..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbn.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_BN_H)
-#define _CP_BN_H
-
-#include "pcpbnuimpl.h"
-#include "pcpbnuarith.h"
-#include "pcpbnumisc.h"
-#include "pcpbnu32arith.h"
-#include "pcpbnu32misc.h"
-
-/*
-// Big Number context
-*/
-struct _cpBigNum
-{
- IppCtxId idCtx; /* BigNum ctx id */
- IppsBigNumSGN sgn; /* sign */
- cpSize size; /* BigNum size (BNU_CHUNK_T) */
- cpSize room; /* BigNum max size (BNU_CHUNK_T) */
- BNU_CHUNK_T* number; /* BigNum value */
- BNU_CHUNK_T* buffer; /* temporary buffer */
-};
-
-/* BN accessory macros */
-#define BN_ID(pBN) ((pBN)->idCtx)
-#define BN_SIGN(pBN) ((pBN)->sgn)
-#define BN_POSITIVE(pBN) (BN_SIGN(pBN)==ippBigNumPOS)
-#define BN_NEGATIVE(pBN) (BN_SIGN(pBN)==ippBigNumNEG)
-#define BN_NUMBER(pBN) ((pBN)->number)
-#define BN_BUFFER(pBN) ((pBN)->buffer)
-#define BN_ROOM(pBN) ((pBN)->room)
-#define BN_SIZE(pBN) ((pBN)->size)
-#define BN_SIZE32(pBN) ((pBN)->size*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)))
-//#define BN_SIZE32(pBN) (BITS2WORD32_SIZE( BITSIZE_BNU(BN_NUMBER((pBN)),BN_SIZE((pBN)))))
-
-#define BN_VALID_ID(pBN) (BN_ID((pBN))==idCtxBigNum)
-
-#define INVERSE_SIGN(s) (((s)==ippBigNumPOS)? ippBigNumNEG : ippBigNumPOS)
-
-#define BN_ALIGNMENT ((int)sizeof(void*))
-
-
-/* pack-unpack context */
-void cpPackBigNumCtx(const IppsBigNumState* pBN, Ipp8u* pBuffer);
-void cpUnpackBigNumCtx(const Ipp8u* pBuffer, IppsBigNumState* pBN);
-
-/* copy BN */
-__INLINE IppsBigNumState* cpBN_copy(IppsBigNumState* pDst, const IppsBigNumState* pSrc)
-{
- BN_SIGN(pDst) = BN_SIGN(pSrc);
- BN_SIZE(pDst) = BN_SIZE(pSrc);
- ZEXPAND_COPY_BNU(BN_NUMBER(pDst), BN_ROOM(pDst), BN_NUMBER(pSrc), BN_SIZE(pSrc));
- return pDst;
-}
-/* set BN to zero */
-__INLINE IppsBigNumState* cpBN_zero(IppsBigNumState* pBN)
-{
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1;
- ZEXPAND_BNU(BN_NUMBER(pBN),0, (int)BN_ROOM(pBN));
- return pBN;
-}
-/* fixup BN */
-__INLINE IppsBigNumState* cpBN_fix(IppsBigNumState* pBN)
-{
- cpSize len = BN_SIZE(pBN);
- FIX_BNU(BN_NUMBER(pBN), len);
- BN_SIZE(pBN) = len;
- return pBN;
-}
-/* set BN to chunk */
-__INLINE IppsBigNumState* cpBN_chunk(IppsBigNumState* pBN, BNU_CHUNK_T a)
-{
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1;
- ZEXPAND_BNU(BN_NUMBER(pBN),0, (int)BN_ROOM(pBN));
- BN_NUMBER(pBN)[0] = a;
- return pBN;
-}
-/* set BN to 2^m */
-__INLINE IppsBigNumState* cpBN_power2(IppsBigNumState* pBN, int power)
-{
- cpSize size = BITS_BNU_CHUNK(power+1);
- if(BN_ROOM(pBN) >= size) {
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = size;
- ZEXPAND_BNU(BN_NUMBER(pBN),0, BN_ROOM(pBN));
- SET_BIT(BN_NUMBER(pBN), power);
- return pBN;
- }
- else return NULL;
-}
-
-/* bitsize of BN */
-__INLINE int cpBN_bitsize(const IppsBigNumState* pA)
-{
- int bitsize = BITSIZE_BNU(BN_NUMBER(pA), BN_SIZE(pA));
- return bitsize;
-}
-
-/* returns -1/0/+1 depemding on A~B comparison */
-__INLINE int cpBN_cmp(const IppsBigNumState* pA, const IppsBigNumState* pB)
-{
- IppsBigNumSGN signA = BN_SIGN(pA);
- IppsBigNumSGN signB = BN_SIGN(pB);
-
- if(signA==signB) {
- int result = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB));
- return (ippBigNumPOS==signA)? result : -result;
- }
- return (ippBigNumPOS==signA)? 1 : -1;
-}
-
-/* returns -1/0/+1 depemding on A comparison 0==0/>0 */
-__INLINE int cpBN_tst(const IppsBigNumState* pA)
-{
- if(1==BN_SIZE(pA) && 0==BN_NUMBER(pA)[0])
- return 0;
- else
- return BN_POSITIVE(pA)? 1 : -1;
-}
-
-
-// some addtition functions
-__INLINE int IsZero_BN(const IppsBigNumState* pA)
-{
- return ( BN_SIZE(pA)==1 ) && ( BN_NUMBER(pA)[0]==0 );
-}
-__INLINE int IsOdd_BN(const IppsBigNumState* pA)
-{
- return BN_NUMBER(pA)[0] & 1;
-}
-
-__INLINE IppsBigNumState* BN_Word(IppsBigNumState* pBN, BNU_CHUNK_T w)
-{
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1;
- ZEXPAND_BNU(BN_NUMBER(pBN),0, BN_ROOM(pBN));
- BN_NUMBER(pBN)[0] = w;
- return pBN;
-}
-__INLINE IppsBigNumState* BN_Set(const BNU_CHUNK_T* pData, cpSize len, IppsBigNumState* pBN)
-{
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = len;
- ZEXPAND_COPY_BNU(BN_NUMBER(pBN), BN_ROOM(pBN), pData, len);
- return pBN;
-}
-__INLINE IppsBigNumState* BN_Make(BNU_CHUNK_T* pData, BNU_CHUNK_T* pBuffer, cpSize len, IppsBigNumState* pBN)
-{
- BN_ID(pBN) = idCtxBigNum;
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1;
- BN_ROOM(pBN) = len;
- BN_NUMBER(pBN) = pData;
- BN_BUFFER(pBN) = pBuffer;
- return pBN;
-}
-
-
-
-/*
-// fixed single chunk BN
-*/
-typedef struct _ippcpBigNumChunk {
- IppsBigNumState bn;
- BNU_CHUNK_T value;
- BNU_CHUNK_T temporary;
-} IppsBigNumStateChunk;
-
-/* reference to BN(1) and BN(2) */
-IppsBigNumState* cpBN_OneRef(void);
-IppsBigNumState* cpBN_TwoRef(void);
-IppsBigNumState* cpBN_ThreeRef(void);
-
-#define BN_ONE_REF() cpBN_OneRef()
-#define BN_TWO_REF() cpBN_TwoRef()
-#define BN_THREE_REF() cpBN_ThreeRef()
-
-#endif /* _CP_BN_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnca.c
deleted file mode 100644
index 5e1e2a3d38..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnca.c
+++ /dev/null
@@ -1,1058 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcptool.h"
-
-/* BN(1) and reference */
-static IppsBigNumStateChunk cpChunk_BN1 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN1.value,&cpChunk_BN1.temporary
- },
- 1,0
-};
-IppsBigNumState* cpBN_OneRef(void)
-{ return &cpChunk_BN1.bn; };
-
-/* BN(2) and reference */
-static IppsBigNumStateChunk cpChunk_BN2 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN2.value,&cpChunk_BN2.temporary
- },
- 2,0
-};
-IppsBigNumState* cpBN_TwoRef(void)
-{ return &cpChunk_BN2.bn; };
-
-/* BN(3) and reference */
-static IppsBigNumStateChunk cpChunk_BN3 = {
- {
- idCtxBigNum,
- ippBigNumPOS,
- 1,1,
- &cpChunk_BN3.value,&cpChunk_BN3.temporary
- },
- 3,0
-};
-IppsBigNumState* cpBN_ThreeRef(void)
-{ return &cpChunk_BN3.bn; };
-
-
-
-/*F*
-// Name: ippsBigNumGetSize
-//
-// Purpose: Returns size of BigNum ctx (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtxSize == NULL
-// ippStsLengthErr len32 < 1
-// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtxSize pointer BigNum ctx size
-//
-*F*/
-IPPFUN(IppStatus, ippsBigNumGetSize, (cpSize len32, cpSize *pCtxSize))
-{
- IPP_BAD_PTR1_RET(pCtxSize);
- IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- {
- /* convert length to the number of BNU_CHUNK_T */
- cpSize len = INTERNAL_BNU_LENGTH(len32);
-
- /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
- mul, mont exp operations */
- len++;
-
- *pCtxSize = sizeof(IppsBigNumState)
- + len*sizeof(BNU_CHUNK_T)
- + len*sizeof(BNU_CHUNK_T)
- + BN_ALIGNMENT-1;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsBigNumInit
-//
-// Purpose: Init BigNum spec for future usage.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// ippStsLengthErr len32<1
-// len32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// len32 max BN length (32-bits segments)
-// pBN BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsBigNumInit, (cpSize len32, IppsBigNumState* pBN))
-{
- IPP_BADARG_RET(len32<1 || len32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
- IPP_BAD_PTR1_RET(pBN);
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
-
- {
- Ipp8u* ptr = (Ipp8u*)pBN;
-
- /* convert length to the number of BNU_CHUNK_T */
- cpSize len = INTERNAL_BNU_LENGTH(len32);
-
- BN_ID(pBN) = idCtxUnknown;
- BN_SIGN(pBN) = ippBigNumPOS;
- BN_SIZE(pBN) = 1; /* initial valie is zero */
- BN_ROOM(pBN) = len; /* close to what has been passed by user */
-
- /* reserve one BNU_CHUNK_T more for cpDiv_BNU,
- mul, mont exp operations */
- len++;
-
- /* allocate buffers */
- BN_NUMBER(pBN) = (BNU_CHUNK_T*)(ptr += sizeof(IppsBigNumState));
- BN_BUFFER(pBN) = (BNU_CHUNK_T*)(ptr += len*sizeof(BNU_CHUNK_T)); /* use expanded length here */
-
- /* set BN value and buffer to zero */
- ZEXPAND_BNU(BN_NUMBER(pBN), 0, len);
- ZEXPAND_BNU(BN_BUFFER(pBN), 0, len);
-
- BN_ID(pBN) = idCtxBigNum;
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsCmpZero_BN
-//
-// Purpose: Test BigNum value.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pResult == NULL
-// ippStsContextMatchErr BN_VALID_ID()
-// ippStsNoErr no errors
-//
-// Parameters:
-// pBN BigNum ctx
-// pResult result of comparison
-//
-*F*/
-IPPFUN(IppStatus, ippsCmpZero_BN, (const IppsBigNumState* pBN, Ipp32u* pResult))
-{
- IPP_BAD_PTR2_RET(pBN, pResult);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- if(BN_SIZE(pBN)==1 && BN_NUMBER(pBN)[0]==0)
- *pResult = IS_ZERO;
- else if (BN_SIGN(pBN)==ippBigNumPOS)
- *pResult = GREATER_THAN_ZERO;
- else if (BN_SIGN(pBN)==ippBigNumNEG)
- *pResult = LESS_THAN_ZERO;
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsCmp_BN
-//
-// Purpose: Compare two BigNums.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pResult == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA BigNum ctx
-// pB BigNum ctx
-// pResult result of comparison
-//
-*F*/
-IPPFUN(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u *pResult))
-{
- IPP_BAD_PTR3_RET(pA, pB, pResult);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
-
- {
- int res;
- if(BN_SIGN(pA)==BN_SIGN(pB)) {
- res = cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pB), BN_SIZE(pB));
- if(ippBigNumNEG==BN_SIGN(pA))
- res = -res;
- }
- else
- res = (ippBigNumPOS==BN_SIGN(pA))? 1 :-1;
-
- *pResult = (1==res)? IPP_IS_GT : (-1==res)? IPP_IS_LT : IPP_IS_EQ;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsSet_BN
-//
-// Purpose: Set BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// pData == NULL
-// ippStsContextMatchErr BN_VALID_ID(pBN)
-// ippStsLengthErr len32 < 1
-// ippStsOutOfRangeErr len32 > BN_ROOM()
-// ippStsNoErr no errors
-//
-// Parameters:
-// sgn sign
-// len32 data size (in Ipp32u chunks)
-// pData source data pointer
-// pBn BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsSet_BN, (IppsBigNumSGN sgn, cpSize len32, const Ipp32u* pData,
- IppsBigNumState* pBN))
-{
- IPP_BAD_PTR2_RET(pData, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- IPP_BADARG_RET(len32<1, ippStsLengthErr);
-
- /* compute real size */
- FIX_BNU(pData, len32);
-
- {
- cpSize len = INTERNAL_BNU_LENGTH(len32);
- IPP_BADARG_RET(len > BN_ROOM(pBN), ippStsOutOfRangeErr);
-
- ZEXPAND_COPY_BNU((Ipp32u*)BN_NUMBER(pBN), BN_ROOM(pBN)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pData, len32);
-
- BN_SIZE(pBN) = len;
-
- if(len32==1 && pData[0] == 0)
- sgn = ippBigNumPOS; /* consider zero value as positive */
- BN_SIGN(pBN) = sgn;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsRef_BN
-//
-// Purpose: Get BigNum info.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pBN == NULL
-// ippStsContextMatchErr BN_VALID_ID(pBN)
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSgn pointer to the sign
-// pBitSize pointer to the data size (in bits)
-// ppData pointer to the data buffer
-// pBN BigNum ctx
-//
-*F*/
-IPPFUN(IppStatus, ippsRef_BN, (IppsBigNumSGN* pSgn, cpSize* pBitSize, Ipp32u** const ppData,
- const IppsBigNumState *pBN))
-{
- IPP_BAD_PTR1_RET(pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- if(pSgn)
- *pSgn = BN_SIGN(pBN);
- if(pBitSize) {
- cpSize bitLen = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN));
- *pBitSize = bitLen? bitLen : 1;
- }
-
- if(ppData)
- *ppData = (Ipp32u*)BN_NUMBER(pBN);
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsAdd_BN
-//
-// Purpose: Add BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsAdd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
- IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- IppsBigNumSGN sgnA = BN_SIGN(pA);
- IppsBigNumSGN sgnB = BN_SIGN(pB);
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
-
- BNU_CHUNK_T carry;
-
- if(sgnA==sgnB) {
- if(nsA < nsB) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
- if(carry) {
- if(nsR>nsA)
- pDataR[nsA++] = carry;
- else
- IPP_ERROR_RET(ippStsOutOfRangeErr);
- }
- BN_SIGN(pR) = sgnA;
- }
-
- else {
- int cmpRes = cpCmp_BNU(pDataA, nsA, pDataB, nsB);
-
- if(0==cmpRes) {
- pDataR[0] = 0;
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = ippBigNumPOS;
- return ippStsNoErr;
- }
-
- if(0>cmpRes) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
-
- BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
- }
-
- FIX_BNU(pDataR, nsA);
- BN_SIZE(pR) = nsA;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsSub_BN
-//
-// Purpose: Subtcrac BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsSub_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
- IPP_BADARG_RET(nsR < IPP_MAX(nsA, nsB), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- IppsBigNumSGN sgnA = BN_SIGN(pA);
- IppsBigNumSGN sgnB = BN_SIGN(pB);
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
-
- BNU_CHUNK_T carry;
-
- if(sgnA!=sgnB) {
- if(nsA < nsB) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpAdd_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- carry = cpInc_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
- if(carry) {
- if(nsR > nsA)
- pDataR[nsA++] = carry;
- else
- IPP_ERROR_RET(ippStsOutOfRangeErr);
- }
- BN_SIGN(pR) = sgnA;
- }
-
- else {
- int cmpRes= cpCmp_BNU(pDataA, nsA, pDataB, nsB);
-
- if(0==cmpRes) {
- ZEXPAND_BNU(pDataR,0, nsR);
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = ippBigNumPOS;
- return ippStsNoErr;
- }
-
- if(0>cmpRes) {
- SWAP(nsA, nsB);
- SWAP_PTR(BNU_CHUNK_T, pDataA, pDataB);
- }
-
- carry = cpSub_BNU(pDataR, pDataA, pDataB, nsB);
- if(nsA>nsB)
- cpDec_BNU(pDataR+nsB, pDataA+nsB, nsA-nsB, carry);
-
- BN_SIGN(pR) = cmpRes>0? sgnA : INVERSE_SIGN(sgnA);
- }
-
- FIX_BNU(pDataR, nsA);
- BN_SIZE(pR) = nsA;
-
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsMul_BN
-//
-// Purpose: Multiply BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pR resultant BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR))
-{
- IPP_BAD_PTR3_RET(pA, pB, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- {
- BNU_CHUNK_T* pDataA = BN_NUMBER(pA);
- BNU_CHUNK_T* pDataB = BN_NUMBER(pB);
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
-
- cpSize nsA = BN_SIZE(pA);
- cpSize nsB = BN_SIZE(pB);
- cpSize nsR = BN_ROOM(pR);
-
- cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA);
- cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB);
-
- /* test if multiplicant/multiplier is zero */
- if(!bitSizeA || !bitSizeB) {
- BN_SIZE(pR) = 1;
- BN_SIGN(pR) = IppsBigNumPOS;
- pDataR[0] = 0;
- return ippStsNoErr;
- }
-
- /* test if even low estimation of product A*B exceeded */
- IPP_BADARG_RET(nsR*BNU_CHUNK_BITS < (bitSizeA+bitSizeB-1), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* aData = pDataA;
- BNU_CHUNK_T* bData = pDataB;
-
- if(pA == pR) {
- aData = BN_BUFFER(pR);
- COPY_BNU(aData, pDataA, nsA);
- }
- if((pB == pR) && (pA != pB)) {
- bData = BN_BUFFER(pR);
- COPY_BNU(bData, pDataB, nsB);
- }
-
- /* clear result */
- ZEXPAND_BNU(pDataR, 0, nsR+1);
-
- cpMul_BNU_school(pDataR, aData, nsA, bData, nsB);
-
- nsR = (bitSizeA + bitSizeB + BNU_CHUNK_BITS - 1) /BNU_CHUNK_BITS;
- FIX_BNU(pDataR, nsR);
- IPP_BADARG_RET(nsR>BN_ROOM(pR), ippStsOutOfRangeErr);
-
- BN_SIZE(pR) = nsR;
- BN_SIGN(pR) = (BN_SIGN(pA)==BN_SIGN(pB)? ippBigNumPOS : ippBigNumNEG);
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsDiv_BN
-//
-// Purpose: Divide BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pB == NULL
-// pQ == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pB)
-// BN_VALID_ID(pQ)
-// BN_VALID_ID(pR)
-// ippStsOutOfRangeErr pQ and/or pR can not hold result
-// ippStsNoErr no errors
-//
-// Parameters:
-// pA source BigNum
-// pB source BigNum
-// pQ quotient BigNum
-// pR reminder BigNum
-//
-// A = Q*B + R, 0 <= val(R) < val(B), sgn(A)==sgn(R)
-//
-*F*/
-IPPFUN(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR))
-{
- IPP_BAD_PTR4_RET(pA, pB, pQ, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- pQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pQ, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pQ), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_SIZE(pB)== 1 && BN_NUMBER(pB)[0]==0, ippStsDivByZeroErr);
-
- IPP_BADARG_RET(BN_ROOM(pR)cmpRes)
- SWAP_PTR(IppsBigNumState, x, y);
- if(0==cmpRes) {
- COPY_BNU(BN_NUMBER(g), BN_NUMBER(x), BN_SIZE(x));
- BN_SIGN(g) = ippBigNumPOS;
- BN_SIZE(g) = BN_SIZE(x);
- return ippStsNoErr;
- }
- if(BN_SIZE(x)==1) {
- BNU_CHUNK_T gcd = cpGcd_BNU(BN_NUMBER(x)[0], BN_NUMBER(y)[0]);
- BN_NUMBER(g)[0] = gcd;
- BN_SIZE(g) = 1;
- return ippStsNoErr;
- }
- }
-
- {
- Ipp32u* xBuffer = (Ipp32u*)BN_BUFFER(x);
- Ipp32u* yBuffer = (Ipp32u*)BN_BUFFER(y);
- Ipp32u* gBuffer = (Ipp32u*)BN_BUFFER(g);
- Ipp32u* xData = (Ipp32u*)BN_NUMBER(x);
- Ipp32u* yData = (Ipp32u*)BN_NUMBER(y);
- Ipp32u* gData = (Ipp32u*)BN_NUMBER(g);
- cpSize nsXmax = BN_ROOM(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsYmax = BN_ROOM(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsGmax = BN_ROOM(g)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsX = BN_SIZE(x)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
- cpSize nsY = BN_SIZE(y)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u));
-
- Ipp32u* T;
- Ipp32u* u;
-
- FIX_BNU(xData, nsX);
- FIX_BNU(yData, nsY);
-
- /* init buffers */
- ZEXPAND_COPY_BNU(xBuffer, nsX, xData, nsXmax);
- ZEXPAND_COPY_BNU(yBuffer, nsY, yData, nsYmax);
-
- T = gBuffer;
- u = gData;
- ZEXPAND_BNU(T, 0, nsGmax);
- ZEXPAND_BNU(u, 0, nsGmax);
-
- while(nsX > (cpSize)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))) {
- /* xx and yy is the high-order digits of x and y (yy could be 0) */
-
- Ipp64u xx = (Ipp64u)(xBuffer[nsX-1]);
- Ipp64u yy = (nsY < nsX)? 0 : (Ipp64u)(yBuffer[nsY-1]);
-
- Ipp64s AA = 1;
- Ipp64s BB = 0;
- Ipp64s CC = 0;
- Ipp64s DD = 1;
- Ipp64s t;
-
- while((yy+CC)!=0 && (yy+DD)!=0) {
- Ipp64u q = ( xx + AA ) / ( yy + CC );
- Ipp64u q1 = ( xx + BB ) / ( yy + DD );
- if(q!=q1)
- break;
- t = AA - q*CC;
- AA = CC;
- CC = t;
- t = BB - q*DD;
- BB = DD;
- DD = t;
- t = xx - q*yy;
- xx = yy;
- yy = t;
- }
-
- if(BB == 0) {
- /* T = x mod y */
- cpSize nsT = cpMod_BNU32(xBuffer, nsX, yBuffer, nsY);
- ZEXPAND_BNU(T, 0, nsGmax);
- COPY_BNU(T, xBuffer, nsT);
- /* a = b; b = T; */
- ZEXPAND_BNU(xBuffer, 0, nsXmax);
- COPY_BNU(xBuffer, yBuffer, nsY);
- ZEXPAND_BNU(yBuffer, 0, nsYmax);
- COPY_BNU(yBuffer, T, nsY);
- }
-
- else {
- Ipp32u carry;
- /*
- // T = AA*x + BB*y;
- // u = CC*x + DD*y;
- // b = u; a = T;
- */
- if((AA <= 0)&&(BB>=0)) {
- Ipp32u a1 = (Ipp32u)(-AA);
- carry = cpMulDgt_BNU32(T, yBuffer, nsY, (Ipp32u)BB);
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, a1);
- /* T = BB*y - AA*x; */
- carry = cpSub_BNU32(T, T, u, nsY);
- }
- else {
- if((AA >= 0)&&(BB<=0)) {
- Ipp32u b1 = (Ipp32u)(-BB);
- carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, b1);
- /* T = AA*x - BB*y; */
- carry = cpSub_BNU32(T, T, u, nsY);
- }
- else {
- /*AA*BB>=0 */
- carry = cpMulDgt_BNU32(T, xBuffer, nsY, (Ipp32u)AA);
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)BB);
- /* T = AA*x + BB*y; */
- carry = cpAdd_BNU32(T, T, u, nsY);
- }
- }
-
- /* Now T is reserved. We use only u for intermediate results. */
- if((CC <= 0)&&(DD>=0)){
- Ipp32u c1 = (Ipp32u)(-CC);
- /* u = x*CC; x = u; */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, c1);
- COPY_BNU(xBuffer, u, nsY);
- /* u = y*DD; */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
- /* u = DD*y - CC*x; */
- carry = cpSub_BNU32(u, u, xBuffer, nsY);
- }
- else {
- if((CC >= 0)&&(DD<=0)){
- Ipp32u d1 = (Ipp32u)(-DD);
- /* u = y*DD; y = u */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, d1);
- COPY_BNU(yBuffer, u, nsY);
- /* u = CC*x; */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
- /* u = CC*x - DD*y; */
- carry = cpSub_BNU32(u, u, yBuffer, nsY);
- }
- else {
- /*CC*DD>=0 */
- /* y = y*DD */
- carry = cpMulDgt_BNU32(u, yBuffer, nsY, (Ipp32u)DD);
- COPY_BNU(yBuffer, u, nsY);
- /* u = x*CC */
- carry = cpMulDgt_BNU32(u, xBuffer, nsY, (Ipp32u)CC);
- /* u = x*CC + y*DD */
- carry = cpAdd_BNU32(u, u, yBuffer, nsY);
- }
- }
-
- /* y = u; x = T; */
- COPY_BNU(yBuffer, u, nsY);
- COPY_BNU(xBuffer, T, nsY);
- }
-
- FIX_BNU(xBuffer, nsX);
- FIX_BNU(yBuffer, nsY);
-
- if (nsY > nsX) {
- SWAP_PTR(IppsBigNumState, x, y);
- SWAP(nsX, nsY);
- }
-
- if (nsY==1 && yBuffer[nsY-1]==0) {
- /* End evaluation */
- ZEXPAND_BNU(gData, 0, nsGmax);
- COPY_BNU(gData, xBuffer, nsX);
- BN_SIZE(g) = INTERNAL_BNU_LENGTH(nsX);
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
- }
-
- BN_NUMBER(g)[0] = cpGcd_BNU(((BNU_CHUNK_T*)xBuffer)[0], ((BNU_CHUNK_T*)yBuffer)[0]);
- BN_SIZE(g) = 1;
- BN_SIGN(g) = ippBigNumPOS;
- return ippStsNoErr;
- }
- }
-}
-
-
-/*F*
-// Name: ippsModInv_BN
-//
-// Purpose: Multiplicative Inversion BigNum.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pA == NULL
-// pM == NULL
-// pR == NULL
-// ippStsContextMatchErr BN_VALID_ID(pA)
-// BN_VALID_ID(pM)
-// BN_VALID_ID(pR)
-// ippStsBadArgErr A<=0
-// ippStsBadModulusErr M<=0
-// ippStsScaleRangeErr A>=M
-// ippStsOutOfRangeErr pR can not hold result
-// ippStsNoErr no errors
-// ippStsBadModulusErr inversion not found
-//
-// Parameters:
-// pA source (value) BigNum
-// pM source (modulus) BigNum
-// pR reminder BigNum
-//
-*F*/
-IPPFUN(IppStatus, ippsModInv_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR) )
-{
- IPP_BAD_PTR3_RET(pA, pM, pR);
-
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- pM = (IppsBigNumState*)( IPP_ALIGNED_PTR(pM, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pM), ippStsContextMatchErr);
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_ROOM(pR) < BN_SIZE(pM), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BN_NEGATIVE(pA) || (BN_SIZE(pA)==1 && BN_NUMBER(pA)[0]==0), ippStsBadArgErr);
- IPP_BADARG_RET(BN_NEGATIVE(pM) || (BN_SIZE(pM)==1 && BN_NUMBER(pM)[0]==0), ippStsBadModulusErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), BN_NUMBER(pM), BN_SIZE(pM)) >= 0, ippStsScaleRangeErr);
-
- {
- cpSize nsR = cpModInv_BNU(BN_NUMBER(pR),
- BN_NUMBER(pA), BN_SIZE(pA),
- BN_NUMBER(pM), BN_SIZE(pM),
- BN_BUFFER(pR), BN_BUFFER(pA), BN_BUFFER(pM));
- if(nsR) {
- BN_SIGN(pR) = ippBigNumPOS;
- BN_SIZE(pR) = nsR;
- return ippStsNoErr;
- }
- else
- return ippStsBadModulusErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresource.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresource.h
deleted file mode 100644
index 0358aaed4e..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresource.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_BNRESOURCE_H)
-#define _PCP_BNRESOURCE_H
-
-
-typedef struct {
- void* pNext;
- IppsBigNumState* pBN;
-} BigNumNode;
-
-
-/* size (byte) of BN resource */
-int cpBigNumListGetSize(int feBitSize, int nodes);
-
-/* init BN resource */
-void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList);
-
-/* get BN from resource */
-IppsBigNumState* cpBigNumListGet(BigNumNode** pList);
-
-#endif /* _PCP_BNRESOURCE_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c
deleted file mode 100644
index 63bdd6737f..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnresourceca.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbnresource.h"
-#include "pcpbn.h"
-
-/*
-// Size of BigNum List Buffer
-*/
-int cpBigNumListGetSize(int feBitSize, int nodes)
-{
- /* size of buffer per single big number */
- int bnSize;
- ippsBigNumGetSize(BITS2WORD32_SIZE(feBitSize), &bnSize);
-
- /* size of buffer for whole list */
- return (ALIGN_VAL-1) + (sizeof(BigNumNode) + bnSize) * nodes;
-}
-
-/*
-// Init list
-//
-// Note: buffer for BN list must have appropriate alignment
-*/
-void cpBigNumListInit(int feBitSize, int nodes, BigNumNode* pList)
-{
- int itemSize;
- /* length of Big Num */
- int bnLen = BITS2WORD32_SIZE(feBitSize);
- /* size of buffer per single big number */
- ippsBigNumGetSize(bnLen, &itemSize);
- /* size of list item */
- itemSize += sizeof(BigNumNode);
-
- {
- int n;
- /* init all nodes */
- BigNumNode* pNode = (BigNumNode*)( (Ipp8u*)pList + (nodes-1)*itemSize );
- BigNumNode* pNext = NULL;
- for(n=0; npNext = pNext;
- pNode->pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(tbnPtr, ALIGN_VAL) );
- ippsBigNumInit(bnLen, pNode->pBN);
- pNext = pNode;
- pNode = (BigNumNode*)( (Ipp8u*)pNode - itemSize);
- }
- }
-}
-
-/*
-// Get BigNum reference
-*/
-IppsBigNumState* cpBigNumListGet(BigNumNode** ppList)
-{
- if(*ppList) {
- IppsBigNumState* ret = (*ppList)->pBN;
- *ppList = (BigNumNode*)((*ppList)->pNext);
- return ret;
- }
- else
- return NULL;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnsetca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnsetca.c
deleted file mode 100644
index 728ec45c8d..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnsetca.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-
-
-/*F*
-// Name: ippsSetOctString_BN
-//
-// Purpose: Convert octet string into the BN value.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pOctStr
-// NULL == pBN
-//
-// ippStsLengthErr 0>strLen
-//
-// ippStsSizeErr BN_ROOM() is enough for keep actual strLen
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pOctStr pointer to the source octet string
-// strLen octet string length
-// pBN pointer to the target BN
-//
-*F*/
-IPPFUN(IppStatus, ippsSetOctString_BN,(const Ipp8u* pOctStr, cpSize strLen,
- IppsBigNumState* pBN))
-{
- IPP_BAD_PTR2_RET(pOctStr, pBN);
-
- pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr);
-
- IPP_BADARG_RET((0>strLen), ippStsLengthErr);
-
- /* remove leading zeros */
- while(strLen && (0==pOctStr[0])) {
- strLen--;
- pOctStr++;
- }
-
- /* test BN size */
- IPP_BADARG_RET((int)(sizeof(BNU_CHUNK_T)*BN_ROOM(pBN))strLen), ippStsLengthErr);
-
- return cpToOctStr_BNU(pOctStr,strLen, BN_NUMBER(pBN),BN_SIZE(pBN))? ippStsNoErr : ippStsLengthErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c
deleted file mode 100644
index 79779fd27c..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpbnumisc.h"
-#include "pcpbnu32misc.h"
-#include "pcpbnu32arith.h"
-
-
-/*
-// BNU32 addition
-*/
-Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, cpSize ns)
-{
- Ipp32u carry = 0;
- cpSize i;
- for(i=0; i>(32-1);
- }
- return borrow;
-}
-
-/*
-// BNU32 mul_by_digit
-*/
-Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val)
-{
- Ipp32u carry = 0;
- cpSize i;
- for(i=0; i0; nsA--) {
- Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry;
- *pR++ = LODWORD(r);
- carry = 0-HIDWORD(r);
- }
- return carry;
-}
-
-/*
-// BNU32 division
-*/
-int cpDiv_BNU32(Ipp32u* pQ, cpSize* sizeQ,
- Ipp32u* pX, cpSize sizeX,
- Ipp32u* pY, cpSize sizeY)
-{
- FIX_BNU(pY,sizeY);
- FIX_BNU(pX,sizeX);
-
- /* special case */
- if(sizeX < sizeY) {
-
- if(pQ) {
- pQ[0] = 0;
- *sizeQ = 1;
- }
-
- return sizeX;
- }
-
- /* special case */
- if(1 == sizeY) {
- int i;
- Ipp32u r = 0;
- for(i=(int)sizeX-1; i>=0; i--) {
- Ipp64u tmp = MAKEDWORD(pX[i],r);
- Ipp32u q = LODWORD(tmp / pY[0]);
- r = LODWORD(tmp - q*pY[0]);
- if(pQ) pQ[i] = q;
- }
-
- pX[0] = r;
-
- if(pQ) {
- FIX_BNU(pQ,sizeX);
- *sizeQ = sizeX;
- }
-
- return 1;
- }
-
-
- /* common case */
- {
- cpSize qs = sizeX-sizeY+1;
-
- cpSize nlz = cpNLZ_BNU32(pY[sizeY-1]);
-
- /* normalization */
- pX[sizeX] = 0;
- if(nlz) {
- cpSize ni;
-
- pX[sizeX] = pX[sizeX-1] >> (32-nlz);
- for(ni=sizeX-1; ni>0; ni--)
- pX[ni] = (pX[ni]<>(32-nlz));
- pX[0] <<= nlz;
-
- for(ni=sizeY-1; ni>0; ni--)
- pY[ni] = (pY[ni]<>(32-nlz));
- pY[0] <<= nlz;
- }
-
- /*
- // division
- */
- {
- Ipp32u yHi = pY[sizeY-1];
-
- int i;
- for(i=(int)qs-1; i>=0; i--) {
- Ipp32u extend;
-
- /* estimate digit of quotient */
- Ipp64u tmp = MAKEDWORD(pX[i+sizeY-1], pX[i+sizeY]);
- Ipp64u q = tmp / yHi;
- Ipp64u r = tmp - q*yHi;
-
- /* tune estimation above */
- for(; HIDWORD(q) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) {
- q -= 1;
- r += yHi;
- if( HIDWORD(r) )
- break;
- }
-
- /* multiply and subtract */
- extend = cpSubMulDgt_BNU32(pX+i, pY, sizeY, (Ipp32u)q);
- extend = (pX[i+sizeY] -= extend);
-
- if(extend) { /* subtracted too much */
- q -= 1;
- extend = cpAdd_BNU32(pX+i, pY, pX+i, sizeY);
- pX[i+sizeY] += extend;
- }
-
- /* store quotation digit */
- if(pQ) pQ[i] = LODWORD(q);
- }
- }
-
- /* de-normalization */
- if(nlz) {
- cpSize ni;
- for(ni=0; ni>nlz) | (pX[ni+1]<<(32-nlz));
- for(ni=0; ni>nlz) | (pY[ni+1]<<(32-nlz));
- pY[sizeY-1] >>= nlz;
- }
-
- FIX_BNU(pX,sizeX);
-
- if(pQ) {
- FIX_BNU(pQ,qs);
- *sizeQ = qs;
- }
-
- return sizeX;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h
deleted file mode 100644
index 96cfe24231..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32arith.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_BNU32_ARITH_H)
-#define _CP_BNU32_ARITH_H
-
-Ipp32u cpAdd_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
-Ipp32u cpSub_BNU32(Ipp32u* pR, const Ipp32u* pA, const Ipp32u* pB, int ns);
-Ipp32u cpInc_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
-Ipp32u cpDec_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize ns, Ipp32u val);
-
-Ipp32u cpMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int ns, Ipp32u val);
-Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int nsA, Ipp32u val);
-
-int cpDiv_BNU32(Ipp32u* pQ, int* nsQ, Ipp32u* pX, int nsX, Ipp32u* pY, int nsY);
-#define cpMod_BNU32(pX,sizeX, pM,sizeM) cpDiv_BNU32(NULL,NULL, (pX),(sizeX), (pM),(sizeM))
-
-#endif /* _CP_BNU32_ARITH_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c
deleted file mode 100644
index 6680a497d7..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpbnuimpl.h"
-#include "pcpbnumisc.h"
-#include "pcpbnu32misc.h"
-
-
-/*
-// number of leading zeros
-*/
-cpSize cpNLZ_BNU32(Ipp32u x)
-{
- cpSize nlz = BITSIZE(Ipp32u);
- if(x) {
- nlz = 0;
- if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x80000000) ) { nlz++; }
- }
- return nlz;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h
deleted file mode 100644
index cda2eca224..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnu32misc.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_BNU32_MISC_H)
-#define _CP_BNU32_MISC_H
-
-
-/* bit operations */
-#define BITSIZE_BNU32(p,ns) ((ns)*BNU_CHUNK_32BIT-cpNLZ_BNU32((p)[(ns)-1]))
-
-/* number of leading/trailing zeros */
-cpSize cpNLZ_BNU32(Ipp32u x);
-
-/* most significant BNU bit */
-__INLINE int cpMSBit_BNU32(const Ipp32u* pA, cpSize nsA)
-{
- FIX_BNU(pA, nsA);
- return nsA*BITSIZE(Ipp32u) - cpNLZ_BNU32(pA[nsA-1]) -1;
-}
-
-#endif /* _CP_BNU32_MISC_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnuarith.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnuarith.c
deleted file mode 100644
index 93822f3f67..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnuarith.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpbnuarith.h"
-#include "pcpbnumisc.h"
-
-
-/* Function cpAdd_BNU - addition of 2 BigNumbers */
-BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns)
-{
- BNU_CHUNK_T carry = 0;
- cpSize i;
- for(i=0; i b){
- gcd = a;
- t = b;
- } else {
- t = a;
- gcd = b;
- }
-
- while (t != 0) {
- r = gcd % t;
- gcd = t;
- t = r;
- }
- return gcd;
-}
-
-
-/*
-// cpMAC_BNU
-//
-// Multiply with ACcumulation
-// Computes r <- r + a * b, returns real size of the r in the size_r variable
-// Returns 0 if there are no enought buffer size to write to r[MAX(size_r + 1, size_a + size_b) - 1]
-// Returns 1 if no error
-//
-// Note:
-// DO NOT run in inplace mode
-// The minimum buffer size for the r must be (size_a + size_b - 1)
-// the maximum buffer size for the r is MAX(size_r + 1, size_a + size_b)
-*/
-static int cpMac_BNU(BNU_CHUNK_T* pR, cpSize nsR,
- const BNU_CHUNK_T* pA, cpSize nsA,
- const BNU_CHUNK_T* pB, cpSize nsB)
-{
- /* cleanup the rest of destination buffer */
- ZEXPAND_BNU(pR, nsR, nsA+nsB-1);
-
- {
- BNU_CHUNK_T expansion = 0;
- cpSize i;
- for(i=0; i> (BNU_CHUNK_BITS/2))
-
-/* (carry,R) = A+B */
-#define ADD_AB(CARRY,R, A,B) \
-do { \
- BNU_CHUNK_T __s = (A) + (B); \
- (CARRY) = __s < (A); \
- (R) = __s; \
-} while(0)
-
-/* (carry,R) = A+B+C */
-#define ADD_ABC(CARRY,R, A,B,C) \
-do { \
- BNU_CHUNK_T __s = (A) + (B); \
- BNU_CHUNK_T __t1= __s < (A); \
- BNU_CHUNK_T __r = __s + (C); \
- BNU_CHUNK_T __t2 = __r < __s; \
- (CARRY) = __t1 + __t2; \
- (R) = __r; \
-} while(0)
-
-/* (borrow,R) = A-B */
-#define SUB_AB(BORROW,R, A,B) \
-do { \
- (BORROW) = (A)<(B); \
- (R) = (A)-(B); \
-} while(0)
-
-/* (borrow,R) = A-B-C */
-#define SUB_ABC(BORROW,R, A,B,C) \
-do { \
- BNU_CHUNK_T __s = (A) -( B); \
- BNU_CHUNK_T __t1= __s > (A); \
- BNU_CHUNK_T __r = __s - (C); \
- BNU_CHUNK_T __t2 = __r > __s; \
- (BORROW) = __t1 + __t2; \
- (R) = __r; \
-} while(0)
-
-/* (RH,RL) = A*B */
-#define MUL_AB(RH, RL, A, B) \
- do { \
- BNU_CHUNK_T __aL = LO_CHUNK((A)); \
- BNU_CHUNK_T __aH = HI_CHUNK((A)); \
- BNU_CHUNK_T __bL = LO_CHUNK((B)); \
- BNU_CHUNK_T __bH = HI_CHUNK((B)); \
- \
- BNU_CHUNK_T __x0 = (BNU_CHUNK_T) __aL * __bL; \
- BNU_CHUNK_T __x1 = (BNU_CHUNK_T) __aL * __bH; \
- BNU_CHUNK_T __x2 = (BNU_CHUNK_T) __aH * __bL; \
- BNU_CHUNK_T __x3 = (BNU_CHUNK_T) __aH * __bH; \
- \
- __x1 += HI_CHUNK(__x0); \
- __x1 += __x2; \
- if(__x1 < __x2) \
- __x3 += BNU_CHUNK_2H; \
- \
- (RH) = __x3 + HI_CHUNK(__x1); \
- (RL) = (__x1 << BNU_CHUNK_BITS/2) + LO_CHUNK(__x0); \
- } while (0)
-
-#endif /* _CP_BNU_IMPL_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.c
deleted file mode 100644
index 3b0bb839fc..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpbnumisc.h"
-
-
-/*
-// number of leading zeros
-*/
-cpSize cpNLZ_BNU(BNU_CHUNK_T x)
-{
- cpSize nlz = BNU_CHUNK_BITS;
- if(x) {
- nlz = 0;
- #if (BNU_CHUNK_BITS == BNU_CHUNK_64BIT)
- if( 0==(x & 0xFFFFFFFF00000000) ) { nlz +=32; x<<=32; }
- if( 0==(x & 0xFFFF000000000000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF00000000000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF000000000000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC000000000000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x8000000000000000) ) { nlz++; }
- #else
- if( 0==(x & 0xFFFF0000) ) { nlz +=16; x<<=16; }
- if( 0==(x & 0xFF000000) ) { nlz += 8; x<<= 8; }
- if( 0==(x & 0xF0000000) ) { nlz += 4; x<<= 4; }
- if( 0==(x & 0xC0000000) ) { nlz += 2; x<<= 2; }
- if( 0==(x & 0x80000000) ) { nlz++; }
- #endif
- }
- return nlz;
-}
-
-/*
-// number of trailing zeros
-*/
-cpSize cpNTZ_BNU(BNU_CHUNK_T x)
-{
- cpSize ntz = BNU_CHUNK_BITS;
- if(x) {
- ntz = 0;
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- if( 0==(x & 0x00000000FFFFFFFF) ) { ntz+=32; x>>=32; }
- if( 0==(x & 0x000000000000FFFF) ) { ntz+=16; x>>=16; }
- if( 0==(x & 0x00000000000000FF) ) { ntz+= 8; x>>= 8; }
- if( 0==(x & 0x000000000000000F) ) { ntz+= 4; x>>= 4; }
- if( 0==(x & 0x0000000000000003) ) { ntz+= 2; x>>= 2; }
- if( 0==(x & 0x0000000000000001) ) { ntz++; }
- #else
- if( 0==(x & 0x0000FFFF) ) { ntz+=16; x>>=16; }
- if( 0==(x & 0x000000FF) ) { ntz+= 8; x>>= 8; }
- if( 0==(x & 0x0000000F) ) { ntz+= 4; x>>= 4; }
- if( 0==(x & 0x00000003) ) { ntz+= 2; x>>= 2; }
- if( 0==(x & 0x00000001) ) { ntz++; }
- #endif
- }
- return ntz;
-}
-
-
-/*
-// Logical shift right (including inplace)
-//
-// Returns new length
-//
-*/
-cpSize cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits)
-{
- cpSize nw = nBits/BNU_CHUNK_BITS;
- cpSize n;
-
- pA += nw;
- nsA -= nw;
-
- nBits %= BNU_CHUNK_BITS;
- if(nBits) {
- BNU_CHUNK_T hi;
- BNU_CHUNK_T lo = pA[0];
-
- for(n=0; n<(nsA-1); n++) {
- hi = pA[n+1];
- pR[n] = (lo>>nBits) | (hi<<(BNU_CHUNK_BITS-nBits));
- lo = hi;
- }
- pR[nsA-1] = (lo>>nBits);
- }
- else {
- for(n=0; n=(int)sizeof(BNU_CHUNK_T); nsA++,strLen-=(int)(sizeof(BNU_CHUNK_T))) {
- /* pack sizeof(BNU_CHUNK_T) bytes into single BNU_CHUNK_T value*/
- *pA++ =
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- +( (BNU_CHUNK_T)pStr[strLen-8]<<(8*7) )
- +( (BNU_CHUNK_T)pStr[strLen-7]<<(8*6) )
- +( (BNU_CHUNK_T)pStr[strLen-6]<<(8*5) )
- +( (BNU_CHUNK_T)pStr[strLen-5]<<(8*4) )
- #endif
- +( (BNU_CHUNK_T)pStr[strLen-4]<<(8*3) )
- +( (BNU_CHUNK_T)pStr[strLen-3]<<(8*2) )
- +( (BNU_CHUNK_T)pStr[strLen-2]<<(8*1) )
- + (BNU_CHUNK_T)pStr[strLen-1];
- }
-
- /* convert the beginning of the string */
- if(strLen) {
- BNU_CHUNK_T x = 0;
- for(x=0; strLen>0; strLen--) {
- BNU_CHUNK_T d = *pStr++;
- x = (x<<8) + d;
- }
- *pA++ = x;
- nsA++;
- }
-
- return nsA;
-}
-
-/*
-// Convert BNU into HexString representation
-//
-// Returns length of the string or 0 if no success
-*/
-cpSize cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA)
-{
- FIX_BNU(pA, nsA);
- {
- cpSize bnuBitSize = BITSIZE_BNU(pA, nsA);
- if(bnuBitSize <= strLen*BYTESIZE) {
- int cnvLen = 0;
- BNU_CHUNK_T x = pA[nsA-1];
-
- ZEXPAND_BNU(pStr, 0, strLen);
- pStr += strLen - BITS2WORD8_SIZE(bnuBitSize);
-
- if(x) {
- //int nb;
- cpSize nb;
- for(nb=cpNLZ_BNU(x)/BYTESIZE; nb<(cpSize)(sizeof(BNU_CHUNK_T)); cnvLen++, nb++)
- *pStr++ = EBYTE(x, sizeof(BNU_CHUNK_T)-1-nb);
-
- for(--nsA; nsA>0; cnvLen+=sizeof(BNU_CHUNK_T), nsA--) {
- x = pA[nsA-1];
- #if (BNU_CHUNK_BITS==BNU_CHUNK_64BIT)
- *pStr++ = EBYTE(x,7);
- *pStr++ = EBYTE(x,6);
- *pStr++ = EBYTE(x,5);
- *pStr++ = EBYTE(x,4);
- #endif
- *pStr++ = EBYTE(x,3);
- *pStr++ = EBYTE(x,2);
- *pStr++ = EBYTE(x,1);
- *pStr++ = EBYTE(x,0);
- }
- }
- return strLen;
- }
- else
- return 0;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.h
deleted file mode 100644
index cbb8d60dbc..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpbnumisc.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_BNUMISC_H)
-#define _PCP_BNUMISC_H
-
-#include "pcpbnuimpl.h"
-
-
-/* bit operations */
-#define BITSIZE_BNU(p,ns) ((ns)*BNU_CHUNK_BITS-cpNLZ_BNU((p)[(ns)-1]))
-#define BIT_BNU(bnu, ns,nbit) ((((nbit)>>BNU_CHUNK_LOG2) < (ns))? ((((bnu))[(nbit)>>BNU_CHUNK_LOG2] >>((nbit)&(BNU_CHUNK_BITS))) &1) : 0)
-#define TST_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) & ((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1))))
-#define SET_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) |= ((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1))))
-#define CLR_BIT(bnu, nbit) ((((bnu))[(nbit)>>BNU_CHUNK_LOG2]) &=~((BNU_CHUNK_T)1<<((nbit)&(BNU_CHUNK_BITS-1))))
-
-/* convert bitsize nbits into the number of BNU_CHUNK_T */
-#define BITS_BNU_CHUNK(nbits) (((nbits)+BNU_CHUNK_BITS-1)/BNU_CHUNK_BITS)
-
-/* mask for top BNU_CHUNK_T */
-#define MASK_BNU_CHUNK(nbits) ((BNU_CHUNK_T)(-1) >>((BNU_CHUNK_BITS- ((nbits)&(BNU_CHUNK_BITS-1))) &(BNU_CHUNK_BITS-1)))
-
-/* copy BNU content */
-#define COPY_BNU(dst, src, len) \
-{ \
- cpSize __idx; \
- for(__idx=0; __idx<(len); __idx++) (dst)[__idx] = (src)[__idx]; \
-}
-
-/* expand by zeros */
-#define ZEXPAND_BNU(srcdst,srcLen, dstLen) \
-{ \
- cpSize __idx; \
- for(__idx=(srcLen); __idx<(dstLen); __idx++) (srcdst)[__idx] = 0; \
-}
-
-/* copy and expand by zeros */
-#define ZEXPAND_COPY_BNU(dst,dstLen, src,srcLen) \
-{ \
- cpSize __idx; \
- for(__idx=0; __idx<(srcLen); __idx++) (dst)[__idx] = (src)[__idx]; \
- for(; __idx<(dstLen); __idx++) (dst)[__idx] = 0; \
-}
-
-/* fix actual length */
-#define FIX_BNU(src,srcLen) \
- for(; ((srcLen)>1) && (0==(src)[(srcLen)-1]); (srcLen)--)
-
-
-/* copy and set */
-__INLINE void cpCpy_BNU(BNU_CHUNK_T* pDst, const BNU_CHUNK_T* pSrc, cpSize ns)
-{ COPY_BNU(pDst, pSrc, ns); }
-
-__INLINE void cpSet_BNU(BNU_CHUNK_T* pDst, cpSize ns, BNU_CHUNK_T val)
-{
- ZEXPAND_BNU(pDst, 0, ns);
- pDst[0] = val;
-}
-
-/* fix up */
-__INLINE int cpFix_BNU(const BNU_CHUNK_T* pA, int nsA)
-{
- FIX_BNU(pA, nsA);
- return nsA;
-}
-
-/* comparison
-//
-// returns
-// negative, if A < B
-// 0, if A = B
-// positive, if A > B
-*/
-__INLINE int cpCmp_BNU(const BNU_CHUNK_T* pA, cpSize nsA, const BNU_CHUNK_T* pB, cpSize nsB)
-{
- if(nsA!=nsB)
- return nsA>nsB? 1 : -1;
- else {
- for(; nsA>0; nsA--) {
- if(pA[nsA-1] > pB[nsA-1])
- return 1;
- else if(pA[nsA-1] < pB[nsA-1])
- return -1;
- }
- return 0;
- }
-}
-__INLINE int cpEqu_BNU_CHUNK(const BNU_CHUNK_T* pA, cpSize nsA, BNU_CHUNK_T b)
-{
- return (pA[0]==b && 1==cpFix_BNU(pA, nsA));
-}
-
-/*
-// test
-//
-// returns
-// 0, if A = 0
-// >0, if A > 0
-// <0, looks like impossible (or error) case
-*/
-__INLINE int cpTst_BNU(const BNU_CHUNK_T* pA, int nsA)
-{
- for(; (nsA>0) && (0==pA[nsA-1]); nsA--) ;
- return nsA;
-}
-
-/* number of leading/trailing zeros */
-cpSize cpNLZ_BNU(BNU_CHUNK_T x);
-cpSize cpNTZ_BNU(BNU_CHUNK_T x);
-
-/* logical shift left/right */
-int cpLSR_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits);
-
-/* least and most significant BNU bit */
-int cpMSBit_BNU(const BNU_CHUNK_T* pA, cpSize nsA);
-
-/* BNU <-> hex-string conversion */
-int cpToOctStr_BNU(Ipp8u* pStr, cpSize strLen, const BNU_CHUNK_T* pA, cpSize nsA);
-int cpFromOctStr_BNU(BNU_CHUNK_T* pA, const Ipp8u* pStr, cpSize strLen);
-
-#endif /* _PCP_BNUMISC_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpcmac.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpcmac.h
deleted file mode 100644
index 47eee76e9c..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpcmac.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_CMAC_H)
-#define _PCP_CMAC_H
-
-#include "pcprij.h"
-
-
-/*
-// Rijndael128 based CMAC context
-*/
-struct _cpAES_CMAC {
- IppCtxId idCtx; /* CMAC identifier */
- int index; /* internal buffer entry (free) */
- int dummy[2]; /* align-16 */
- Ipp8u k1[MBS_RIJ128]; /* k1 subkey */
- Ipp8u k2[MBS_RIJ128]; /* k2 subkey */
- Ipp8u mBuffer[MBS_RIJ128];/* buffer */
- Ipp8u mMAC[MBS_RIJ128]; /* intermediate digest */
- __ALIGN16 /* aligned AES context */
- IppsAESSpec mCipherCtx;
-};
-
-/* alignment */
-#define AESCMAC_ALIGNMENT (RIJ_ALIGNMENT)
-
-/*
-// Useful macros
-*/
-#define CMAC_ID(stt) ((stt)->idCtx)
-#define CMAC_INDX(stt) ((stt)->index)
-#define CMAC_K1(stt) ((stt)->k1)
-#define CMAC_K2(stt) ((stt)->k2)
-#define CMAC_BUFF(stt) ((stt)->mBuffer)
-#define CMAC_MAC(stt) ((stt)->mMAC)
-#define CMAC_CIPHER(stt) ((stt)->mCipherCtx)
-
-/* valid context ID */
-#define VALID_AESCMAC_ID(ctx) (CMAC_ID((ctx))==idCtxCMAC)
-
-#endif /* _PCP_CMAC_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccp.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccp.h
deleted file mode 100644
index 34871a136f..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccp.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_ECCP_H)
-#define _PCP_ECCP_H
-
-#include "pcpbnresource.h"
-#include "pcppma.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpsscm.h"
-
-
-typedef struct eccp_method_st ECCP_METHOD;
-
-/*
-// ECC over prime GF(p) Context
-*/
-struct _cpECCP {
- IppCtxId idCtx; /* prime EC identifier */
-
- IppsBigNumState* pPrime; /* specify finite field GF(p) */
- IppsBigNumState* pA; /* scecify A & B of EC equation: */
- IppsBigNumState* pB; /* y^2 = x^3 + A*x + B (mod)p */
-
- IppsBigNumState* pGX; /* Base Point (X coordinate) */
- IppsBigNumState* pGY; /* Base Point (Y coordinate) */
- IppsBigNumState* pR; /* order (r) of Base Point */
- /* fields above mainly for ippsECCPSet()/ippsECCPGet() */
-
- Ipp32u eccStandard;/* generic/standard ecc */
-
- ECCP_METHOD* pMethod;
-
- int gfeBitSize; /* size (bits) of field element */
- int ordBitSize; /* size (bits) of BP order */
-
- int a_3; /* ==1 if A==-3 or A==P-3 */
- IppsBigNumState* pAenc; /* internal formatted pA value */
- IppsBigNumState* pBenc; /* internal formatted pB value */
- IppsMontState* pMontP; /* montromery engine (modulo p) */
-
- IppsECCPPointState* pGenc; /* internal formatted Base Point */
- IppsBigNumState* pCofactor; /* cofactor = #E/base_point_order*/
- IppsMontState* pMontR; /* montromery engine (modulo r) */
-
- IppsBigNumState* pPrivate; /* private key */
- IppsECCPPointState* pPublic; /* public key (affine) */
- IppsBigNumState* pPrivateE; /* ephemeral private key */
- IppsECCPPointState* pPublicE; /* ephemeral public key (affine) */
-
- IppsPrimeState* pPrimary; /* prime engine */
-
- Ipp8u* pSscmBuffer;/* pointer to sscm buffer */
-
- BigNumNode* pBnList; /* list of big numbers */
-};
-
-/* some useful constants */
-#define BNLISTSIZE (32) /* list size (probably less) */
-
-/*
-// Contetx Access Macros
-*/
-#define ECP_ID(ctx) ((ctx)->idCtx)
-
-#define ECP_PRIME(ctx) ((ctx)->pPrime)
-#define ECP_A(ctx) ((ctx)->pA)
-#define ECP_B(ctx) ((ctx)->pB)
-
-#define ECP_GX(ctx) ((ctx)->pGX)
-#define ECP_GY(ctx) ((ctx)->pGY)
-#define ECP_ORDER(ctx) ((ctx)->pR)
-
-#define ECP_TYPE(ctx) ((ctx)->eccStandard)
-
-#define ECP_METHOD(ctx) ((ctx)->pMethod)
-
-#define ECP_GFEBITS(ctx) ((ctx)->gfeBitSize)
-#define ECP_ORDBITS(ctx) ((ctx)->ordBitSize)
-
-#define ECP_AMI3(ctx) ((ctx)->a_3)
-#define ECP_AENC(ctx) ((ctx)->pAenc)
-#define ECP_BENC(ctx) ((ctx)->pBenc)
-#define ECP_PMONT(ctx) ((ctx)->pMontP)
-
-#define ECP_GENC(ctx) ((ctx)->pGenc)
-#define ECP_COFACTOR(ctx) ((ctx)->pCofactor)
-#define ECP_RMONT(ctx) ((ctx)->pMontR)
-
-#define ECP_PRIVATE(ctx) ((ctx)->pPrivate)
-#define ECP_PUBLIC(ctx) ((ctx)->pPublic)
-#define ECP_PRIVATE_E(ctx) ((ctx)->pPrivateE)
-#define ECP_PUBLIC_E(ctx) ((ctx)->pPublicE)
-
-#define ECP_PRIMARY(ctx) ((ctx)->pPrimary)
-#define ECP_SCCMBUFF(ctx) ((ctx)->pSscmBuffer)
-#define ECP_BNCTX(ctx) ((ctx)->pBnList)
-
-#define ECP_VALID_ID(ctx) (ECP_ID((ctx))==idCtxECCP)
-
-/*
-// Recommended (Standard) Domain Parameters
-*/
-extern const Ipp32u secp112r1_p[]; // (2^128 -3)/76439
-extern const Ipp32u secp112r1_a[];
-extern const Ipp32u secp112r1_b[];
-extern const Ipp32u secp112r1_gx[];
-extern const Ipp32u secp112r1_gy[];
-extern const Ipp32u secp112r1_r[];
-extern Ipp32u secp112r1_h;
-
-extern const Ipp32u secp112r2_p[]; // (2^128 -3)/76439
-extern const Ipp32u secp112r2_a[];
-extern const Ipp32u secp112r2_b[];
-extern const Ipp32u secp112r2_gx[];
-extern const Ipp32u secp112r2_gy[];
-extern const Ipp32u secp112r2_r[];
-extern Ipp32u secp112r2_h;
-
-extern const Ipp32u secp128r1_p[]; // 2^128 -2^97 -1
-extern const Ipp32u secp128r1_a[];
-extern const Ipp32u secp128r1_b[];
-extern const Ipp32u secp128r1_gx[];
-extern const Ipp32u secp128r1_gy[];
-extern const Ipp32u secp128r1_r[];
-extern Ipp32u secp128r1_h;
-
-extern const Ipp32u* secp128_mx[];
-
-extern const Ipp32u secp128r2_p[]; // 2^128 -2^97 -1
-extern const Ipp32u secp128r2_a[];
-extern const Ipp32u secp128r2_b[];
-extern const Ipp32u secp128r2_gx[];
-extern const Ipp32u secp128r2_gy[];
-extern const Ipp32u secp128r2_r[];
-extern Ipp32u secp128r2_h;
-
-extern const Ipp32u secp160r1_p[]; // 2^160 -2^31 -1
-extern const Ipp32u secp160r1_a[];
-extern const Ipp32u secp160r1_b[];
-extern const Ipp32u secp160r1_gx[];
-extern const Ipp32u secp160r1_gy[];
-extern const Ipp32u secp160r1_r[];
-extern Ipp32u secp160r1_h;
-
-extern const Ipp32u secp160r2_p[]; // 2^160 -2^32 -2^14 -2^12 -2^9 -2^8 -2^7 -2^2 -1
-extern const Ipp32u secp160r2_a[];
-extern const Ipp32u secp160r2_b[];
-extern const Ipp32u secp160r2_gx[];
-extern const Ipp32u secp160r2_gy[];
-extern const Ipp32u secp160r2_r[];
-extern Ipp32u secp160r2_h;
-
-extern const Ipp32u secp192r1_p[]; // 2^192 -2^64 -1
-extern const Ipp32u secp192r1_a[];
-extern const Ipp32u secp192r1_b[];
-extern const Ipp32u secp192r1_gx[];
-extern const Ipp32u secp192r1_gy[];
-extern const Ipp32u secp192r1_r[];
-extern Ipp32u secp192r1_h;
-
-extern const Ipp32u secp224r1_p[]; // 2^224 -2^96 +1
-extern const Ipp32u secp224r1_a[];
-extern const Ipp32u secp224r1_b[];
-extern const Ipp32u secp224r1_gx[];
-extern const Ipp32u secp224r1_gy[];
-extern const Ipp32u secp224r1_r[];
-extern Ipp32u secp224r1_h;
-
-extern const Ipp32u secp256r1_p[]; // 2^256 -2^224 +2^192 +2^96 -1
-extern const Ipp32u secp256r1_a[];
-extern const Ipp32u secp256r1_b[];
-extern const Ipp32u secp256r1_gx[];
-extern const Ipp32u secp256r1_gy[];
-extern const Ipp32u secp256r1_r[];
-extern Ipp32u secp256r1_h;
-
-extern const Ipp32u secp384r1_p[]; // 2^384 -2^128 -2^96 +2^32 -1
-extern const Ipp32u secp384r1_a[];
-extern const Ipp32u secp384r1_b[];
-extern const Ipp32u secp384r1_gx[];
-extern const Ipp32u secp384r1_gy[];
-extern const Ipp32u secp384r1_r[];
-extern Ipp32u secp384r1_h;
-
-extern const Ipp32u secp521r1_p[]; // 2^521 -1
-extern const Ipp32u secp521r1_a[];
-extern const Ipp32u secp521r1_b[];
-extern const Ipp32u secp521r1_gx[];
-extern const Ipp32u secp521r1_gy[];
-extern const Ipp32u secp521r1_r[];
-extern Ipp32u secp521r1_h;
-
-/* half of some std modulus */
-extern const Ipp32u h_secp128r1_p[];
-extern const Ipp32u h_secp192r1_p[];
-extern const Ipp32u h_secp224r1_p[];
-extern const Ipp32u h_secp256r1_p[];
-extern const Ipp32u h_secp384r1_p[];
-extern const Ipp32u h_secp521r1_p[];
-
-#endif /* _PCP_ECCP_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c
deleted file mode 100644
index e4c88689d4..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpdpca.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-#include "pcpeccppoint.h"
-#include "pcpbnresource.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-#include "pcppma.h"
-
-
-/*F*
-// Name: ippsECCPSet
-//
-// Purpose: Set EC Domain Parameters.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPrime
-// NULL == pA
-// NULL == pB
-// NULL == pGX
-// NULL == pGY
-// NULL == pOrder
-// NULL == pECC
-//
-// ippStsContextMatchErr illegal pPrime->idCtx
-// illegal pA->idCtx
-// illegal pB->idCtx
-// illegal pGX->idCtx
-// illegal pGY->idCtx
-// illegal pOrder->idCtx
-// illegal pECC->idCtx
-//
-// ippStsRangeErr not enough room for:
-// pPrime
-// pA, pB,
-// pGX,pGY
-// pOrder
-//
-// ippStsRangeErr 0>= cofactor
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrime pointer to the prime (specify FG(p))
-// pA pointer to the A coefficient of EC equation
-// pB pointer to the B coefficient of EC equation
-// pGX,pGY pointer to the Base Point (x and y coordinates) of EC
-// pOrder pointer to the Base Point order
-// cofactor cofactor value
-// pECC pointer to the ECC context
-//
-*F*/
-static
-void ECCPSetDP(IppECCType flag,
- int primeSize, const Ipp32u* pPrime,
- int aSize, const Ipp32u* pA,
- int bSize, const Ipp32u* pB,
- int gxSize, const Ipp32u* pGx,
- int gySize, const Ipp32u* pGy,
- int orderSize, const Ipp32u* pOrder,
- Ipp32u cofactor,
- IppsECCPState* pECC)
-{
- ECP_TYPE(pECC) = flag;
-
- /* reset size (bits) of field element */
- ECP_GFEBITS(pECC) = cpMSBit_BNU32(pPrime, primeSize) +1;
- /* reset size (bits) of Base Point order */
- ECP_ORDBITS(pECC) = cpMSBit_BNU32(pOrder, orderSize) +1;
-
- /* set up prime */
- ippsSet_BN(ippBigNumPOS, primeSize, pPrime, ECP_PRIME(pECC));
- /* set up A */
- ippsSet_BN(ippBigNumPOS, aSize, pA, ECP_A(pECC));
- /* test A */
- BN_Word(ECP_B(pECC), 3);
- PMA_add(ECP_B(pECC), ECP_A(pECC), ECP_B(pECC), ECP_PRIME(pECC));
- ECP_AMI3(pECC) = IsZero_BN(ECP_B(pECC));
- /* set up B */
- ippsSet_BN(ippBigNumPOS, bSize, pB, ECP_B(pECC));
-
- /* set up affine coordinates of Base Point and order */
- ippsSet_BN(ippBigNumPOS, gxSize, pGx, ECP_GX(pECC));
- ippsSet_BN(ippBigNumPOS, gySize, pGy, ECP_GY(pECC));
- ippsSet_BN(ippBigNumPOS, orderSize, pOrder, ECP_ORDER(pECC));
-
- /* set up cofactor */
- //ippsSet_BN(ippBigNumPOS, 1, &((Ipp32u)cofactor), ECP_COFACTOR(pECC));
- ippsSet_BN(ippBigNumPOS, 1, &cofactor, ECP_COFACTOR(pECC));
-
- /* montgomery engine (prime) */
- if( ippStsNoErr == ippsMontSet((Ipp32u*)BN_NUMBER(ECP_PRIME(pECC)), BN_SIZE32(ECP_PRIME(pECC)), ECP_PMONT(pECC)) ) {
- /* modulo reduction and montgomery form of A and B */
- PMA_mod(ECP_AENC(pECC), ECP_A(pECC), ECP_PRIME(pECC));
- PMA_enc(ECP_AENC(pECC), ECP_AENC(pECC), ECP_PMONT(pECC));
- PMA_mod(ECP_BENC(pECC), ECP_B(pECC), ECP_PRIME(pECC));
- PMA_enc(ECP_BENC(pECC), ECP_BENC(pECC), ECP_PMONT(pECC));
- /* projective coordinates and montgomery form of of Base Point */
- if( ( IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity1(ECP_GX(pECC), ECP_GY(pECC))) ||
- (!IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity0(ECP_GX(pECC), ECP_GY(pECC))) )
- ECCP_SetPointToInfinity(ECP_GENC(pECC));
- else {
- ECP_METHOD(pECC)->SetPointProjective(ECP_GX(pECC), ECP_GY(pECC), BN_ONE_REF(), ECP_GENC(pECC), pECC);
- }
- }
-
- /* montgomery engine (order) */
- if( ippStsNoErr == ippsMontSet((Ipp32u*)BN_NUMBER(ECP_ORDER(pECC)), BN_SIZE32(ECP_ORDER(pECC)), ECP_RMONT(pECC)) )
- PMA_enc(ECP_COFACTOR(pECC), ECP_COFACTOR(pECC), ECP_RMONT(pECC));
-
- /* set zero private keys */
- BN_Word(ECP_PRIVATE(pECC), 0);
- BN_Word(ECP_PRIVATE_E(pECC), 0);
-
- /* set infinity public keys */
- ECCP_SetPointToInfinity(ECP_PUBLIC(pECC));
- ECCP_SetPointToInfinity(ECP_PUBLIC_E(pECC));
-}
-
-
-IPPFUN(IppStatus, ippsECCPSet, (const IppsBigNumState* pPrime,
- const IppsBigNumState* pA, const IppsBigNumState* pB,
- const IppsBigNumState* pGX,const IppsBigNumState* pGY,const IppsBigNumState* pOrder,
- int cofactor,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test pPrime */
- IPP_BAD_PTR1_RET(pPrime);
- pPrime = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrime, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrime), ippStsContextMatchErr);
- IPP_BADARG_RET((cpBN_bitsize(pPrime)>ECP_GFEBITS(pECC)), ippStsRangeErr);
-
- /* test pA and pB */
- IPP_BAD_PTR2_RET(pA,pB);
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, ALIGN_VAL) );
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- IPP_BADARG_RET((cpBN_bitsize(pA)>ECP_GFEBITS(pECC)), ippStsRangeErr);
- IPP_BADARG_RET((cpBN_bitsize(pB)>ECP_GFEBITS(pECC)), ippStsRangeErr);
-
- /* test pG and pGorder pointers */
- IPP_BAD_PTR3_RET(pGX,pGY, pOrder);
- pGX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGX, ALIGN_VAL) );
- pGY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pGY, ALIGN_VAL) );
- pOrder = (IppsBigNumState*)( IPP_ALIGNED_PTR(pOrder, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pGX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pGY), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pOrder), ippStsContextMatchErr);
- IPP_BADARG_RET((cpBN_bitsize(pGX)>ECP_GFEBITS(pECC)), ippStsRangeErr);
- IPP_BADARG_RET((cpBN_bitsize(pGY)>ECP_GFEBITS(pECC)), ippStsRangeErr);
- IPP_BADARG_RET((cpBN_bitsize(pOrder)>ECP_ORDBITS(pECC)), ippStsRangeErr);
-
- /* test cofactor */
- IPP_BADARG_RET(!(0idCtx
-//
-// ippStsECCInvalidFlagErr invalid flag
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// flag specify standard ECC parameter(s) to be setup
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetStd, (IppECCType flag, IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- *(ECP_METHOD(pECC)) = *(ECCPcom_Methods());
-
- switch(flag) {
- case IppECCPStd112r1:
- ECCPSetDP(IppECCPStd112r1,
- BITS2WORD32_SIZE(112), secp112r1_p,
- BITS2WORD32_SIZE(112), secp112r1_a,
- BITS2WORD32_SIZE(112), secp112r1_b,
- BITS2WORD32_SIZE(112), secp112r1_gx,
- BITS2WORD32_SIZE(112), secp112r1_gy,
- BITS2WORD32_SIZE(112), secp112r1_r,
- secp112r1_h, pECC);
- break;
-
- case IppECCPStd112r2:
- ECCPSetDP(IppECCPStd112r2,
- BITS2WORD32_SIZE(112), secp112r2_p,
- BITS2WORD32_SIZE(112), secp112r2_a,
- BITS2WORD32_SIZE(112), secp112r2_b,
- BITS2WORD32_SIZE(112), secp112r2_gx,
- BITS2WORD32_SIZE(112), secp112r2_gy,
- BITS2WORD32_SIZE(112), secp112r2_r,
- secp112r2_h, pECC);
- break;
-
- case IppECCPStd128r1:
- ECCPSetDP(IppECCPStd128r1,
- BITS2WORD32_SIZE(128), secp128r1_p,
- BITS2WORD32_SIZE(128), secp128r1_a,
- BITS2WORD32_SIZE(128), secp128r1_b,
- BITS2WORD32_SIZE(128), secp128r1_gx,
- BITS2WORD32_SIZE(128), secp128r1_gy,
- BITS2WORD32_SIZE(128), secp128r1_r,
- secp128r1_h, pECC);
- break;
-
- case IppECCPStd128r2:
- ECCPSetDP(IppECCPStd128r2,
- BITS2WORD32_SIZE(128), secp128r2_p,
- BITS2WORD32_SIZE(128), secp128r2_a,
- BITS2WORD32_SIZE(128), secp128r2_b,
- BITS2WORD32_SIZE(128), secp128r2_gx,
- BITS2WORD32_SIZE(128), secp128r2_gy,
- BITS2WORD32_SIZE(128), secp128r2_r,
- secp128r2_h, pECC);
- break;
-
- case IppECCPStd160r1:
- ECCPSetDP(IppECCPStd160r1,
- BITS2WORD32_SIZE(160), secp160r1_p,
- BITS2WORD32_SIZE(160), secp160r1_a,
- BITS2WORD32_SIZE(160), secp160r1_b,
- BITS2WORD32_SIZE(160), secp160r1_gx,
- BITS2WORD32_SIZE(160), secp160r1_gy,
- BITS2WORD32_SIZE(161), secp160r1_r,
- secp160r1_h, pECC);
- break;
-
- case IppECCPStd160r2:
- ECCPSetDP(IppECCPStd160r2,
- BITS2WORD32_SIZE(160), secp160r2_p,
- BITS2WORD32_SIZE(160), secp160r2_a,
- BITS2WORD32_SIZE(160), secp160r2_b,
- BITS2WORD32_SIZE(160), secp160r2_gx,
- BITS2WORD32_SIZE(160), secp160r2_gy,
- BITS2WORD32_SIZE(161), secp160r2_r,
- secp160r2_h, pECC);
- break;
-
- case IppECCPStd192r1:
- ECCPSetDP(IppECCPStd192r1,
- BITS2WORD32_SIZE(192), secp192r1_p,
- BITS2WORD32_SIZE(192), secp192r1_a,
- BITS2WORD32_SIZE(192), secp192r1_b,
- BITS2WORD32_SIZE(192), secp192r1_gx,
- BITS2WORD32_SIZE(192), secp192r1_gy,
- BITS2WORD32_SIZE(192), secp192r1_r,
- secp192r1_h, pECC);
- break;
-
- case IppECCPStd224r1:
- ECCPSetDP(IppECCPStd224r1,
- BITS2WORD32_SIZE(224), secp224r1_p,
- BITS2WORD32_SIZE(224), secp224r1_a,
- BITS2WORD32_SIZE(224), secp224r1_b,
- BITS2WORD32_SIZE(224), secp224r1_gx,
- BITS2WORD32_SIZE(224), secp224r1_gy,
- BITS2WORD32_SIZE(224), secp224r1_r,
- secp224r1_h, pECC);
- break;
-
- case IppECCPStd256r1:
- ECCPSetDP(IppECCPStd256r1,
- BITS2WORD32_SIZE(256), secp256r1_p,
- BITS2WORD32_SIZE(256), secp256r1_a,
- BITS2WORD32_SIZE(256), secp256r1_b,
- BITS2WORD32_SIZE(256), secp256r1_gx,
- BITS2WORD32_SIZE(256), secp256r1_gy,
- BITS2WORD32_SIZE(256), secp256r1_r,
- secp256r1_h, pECC);
- break;
-
- case IppECCPStd384r1:
- ECCPSetDP(IppECCPStd384r1,
- BITS2WORD32_SIZE(384), secp384r1_p,
- BITS2WORD32_SIZE(384), secp384r1_a,
- BITS2WORD32_SIZE(384), secp384r1_b,
- BITS2WORD32_SIZE(384), secp384r1_gx,
- BITS2WORD32_SIZE(384), secp384r1_gy,
- BITS2WORD32_SIZE(384), secp384r1_r,
- secp384r1_h, pECC);
- break;
-
- case IppECCPStd521r1:
- ECCPSetDP(IppECCPStd521r1,
- BITS2WORD32_SIZE(521), secp521r1_p,
- BITS2WORD32_SIZE(521), secp521r1_a,
- BITS2WORD32_SIZE(521), secp521r1_b,
- BITS2WORD32_SIZE(521), secp521r1_gx,
- BITS2WORD32_SIZE(521), secp521r1_gy,
- BITS2WORD32_SIZE(521), secp521r1_r,
- secp521r1_h, pECC);
- break;
-
- default:
- return ippStsECCInvalidFlagErr;
- }
-
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c
deleted file mode 100644
index b152a7b82c..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpgenkeyca.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPGenKeyPair
-//
-// Purpose: Generate (private,public) Key Pair
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPrivate
-// NULL == pPublic
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPrivate->idCtx
-// illegal pPublic->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the resultant private key
-// pPublic pointer to the resultant public key
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGenKeyPair, (IppsBigNumState* pPrivate, IppsECCPPointState* pPublic,
- IppsECCPState* pECC,
- IppBitSupplier rndFunc, void* pRndParam))
-{
- IPP_BAD_PTR2_RET(pECC, rndFunc);
-
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test private/public keys */
- IPP_BAD_PTR2_RET(pPrivate,pPublic);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pPrivate)*BITSIZE(BNU_CHUNK_T)MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC));
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c
deleted file mode 100644
index ee54bb844b..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpinitca.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-#include "pcpeccppoint.h"
-#include "pcpbnresource.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpsscm.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsECCPGetSize
-//
-// Purpose: Returns size of ECC context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsSizeErr 2>feBitSize
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pSize pointer to the size of internal ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGetSize, (int feBitSize, int *pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
-
- {
- int bn1Size;
- int bn2Size;
- int pointSize;
- int mont1Size;
- int mont2Size;
- int primeSize;
- int listSize;
-
- /* size of field element */
- int gfeSize = BITS2WORD32_SIZE(feBitSize);
- /* size of order */
- int ordSize = BITS2WORD32_SIZE(feBitSize+1);
-
- /* size of sscm buffer */
- int w = cpECCP_OptimalWinSize(feBitSize+1);
- int nPrecomputed = 1<feBitSize
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pECC pointer to the ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPInit, (int feBitSize, IppsECCPState* pECC))
-{
- /* test pECC pointer */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize || feBitSize>EC_GFP_MAXBITSIZE), ippStsSizeErr);
-
- /* clear context */
- PaddBlock(0, pECC, sizeof(IppsECCPState));
-
- /* context ID */
- ECP_ID(pECC) = idCtxECCP;
-
- /* generic EC */
- ECP_TYPE(pECC) = IppECCArbitrary;
-
- /* size of field element & BP order */
- ECP_GFEBITS(pECC) = feBitSize;
- ECP_ORDBITS(pECC) = feBitSize+1;
-
- /*
- // init other context fields
- */
- {
- int bn1Size;
- int bn2Size;
- int pointSize;
- int mont1Size;
- int mont2Size;
- int primeSize;
-
- /* size of field element */
- int gfeSize = BITS2WORD32_SIZE(feBitSize);
- /* size of order */
- int ordSize = BITS2WORD32_SIZE(feBitSize+1);
-
- /* size of sscm buffer */
- int w = cpECCP_OptimalWinSize(feBitSize+1);
- int nPrecomputed = 1< pP==pQ (maybe both pP and pQ are at Infinity)
-// returns 1 => pP!=pQ
-//
-// Note
-// In general we check:
-// P_X*Q_Z^2 ~ Q_X*P_Z^2
-// P_Y*Q_Z^3 ~ Q_Y*P_Z^3
-*/
-int ECCP_ComparePoint(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- /* P or/and Q at Infinity */
- if( ECCP_IsPointAtInfinity(pP) )
- return ECCP_IsPointAtInfinity(pQ)? 0:1;
- if( ECCP_IsPointAtInfinity(pQ) )
- return ECCP_IsPointAtInfinity(pP)? 0:1;
-
- /* (P_Z==1) && (Q_Z==1) */
- if( ECP_POINT_AFFINE(pP) && ECP_POINT_AFFINE(pQ) )
- return ((0==cpBN_cmp(ECP_POINT_X(pP),ECP_POINT_X(pQ))) && (0==cpBN_cmp(ECP_POINT_Y(pP),ECP_POINT_Y(pQ))))? 0:1;
-
- {
- IppsMontState* pMont = ECP_PMONT(pECC);
-
- IppsBigNumState* pPtmp = cpBigNumListGet(&pList);
- IppsBigNumState* pQtmp = cpBigNumListGet(&pList);
- IppsBigNumState* pPZ = cpBigNumListGet(&pList);
- IppsBigNumState* pQZ = cpBigNumListGet(&pList);
-
- /* P_X*Q_Z^2 ~ Q_X*P_Z^2 */
- if( !ECP_POINT_AFFINE(pQ) ) {
- PMA_sqre(pQZ, ECP_POINT_Z(pQ), pMont); /* Ptmp = P_X*Q_Z^2 */
- PMA_mule(pPtmp, ECP_POINT_X(pP), pQZ, pMont);
- }
- else {
- PMA_set(pPtmp, ECP_POINT_X(pP));
- }
- if( !ECP_POINT_AFFINE(pP) ) {
- PMA_sqre(pPZ, ECP_POINT_Z(pP), pMont); /* Qtmp = Q_X*P_Z^2 */
- PMA_mule(pQtmp, ECP_POINT_X(pQ), pPZ, pMont);
- }
- else {
- PMA_set(pQtmp, ECP_POINT_X(pQ));
- }
- if ( cpBN_cmp(pPtmp, pQtmp) )
- return 1; /* points are different: (P_X*Q_Z^2) != (Q_X*P_Z^2) */
-
- /* P_Y*Q_Z^3 ~ Q_Y*P_Z^3 */
- if( !ECP_POINT_AFFINE(pQ) ) {
- PMA_mule(pQZ, pQZ, ECP_POINT_Z(pQ), pMont); /* Ptmp = P_Y*Q_Z^3 */
- PMA_mule(pPtmp, ECP_POINT_Y(pP), pQZ, pMont);
- }
- else {
- PMA_set(pPtmp, ECP_POINT_Y(pP));
- }
- if( !ECP_POINT_AFFINE(pP) ) {
- PMA_mule(pPZ, pPZ, ECP_POINT_Z(pP), pMont); /* Qtmp = Q_Y*P_Z^3 */
- PMA_mule(pQtmp, ECP_POINT_Y(pQ), pPZ, pMont);
- }
- else {
- PMA_set(pQtmp, ECP_POINT_Y(pQ));
- }
- return cpBN_cmp(pPtmp, pQtmp)? 1:0;
- }
-}
-
-/*
-// ECCP_NegPoint
-//
-// Negative point
-*/
-void ECCP_NegPoint(const IppsECCPPointState* pP,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC)
-{
- /* test point at Infinity */
- if( ECCP_IsPointAtInfinity(pP) )
- ECCP_SetPointToInfinity(pR);
-
- else {
- IppsBigNumState* pModulo = ECP_PRIME(pECC);
-
- if( pP!=pR ) {
- PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP));
- PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP));
- }
- PMA_sub(ECP_POINT_Y(pR), pModulo, ECP_POINT_Y(pP), pModulo);
- ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP);
- }
-}
-
-/*
-// ECCP_DblPoint
-//
-// Double point
-*/
-void ECCP_DblPoint(const IppsECCPPointState* pP,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- /* P at infinity */
- if( ECCP_IsPointAtInfinity(pP) )
- ECCP_SetPointToInfinity(pR);
-
- else {
- IppsMontState* pMont = ECP_PMONT(pECC);
-
- IppsBigNumState* bnV = cpBigNumListGet(&pList);
- IppsBigNumState* bnU = cpBigNumListGet(&pList);
- IppsBigNumState* bnM = cpBigNumListGet(&pList);
- IppsBigNumState* bnS = cpBigNumListGet(&pList);
- IppsBigNumState* bnT = cpBigNumListGet(&pList);
- IppsBigNumState* pModulo = ECP_PRIME(pECC);
-
- /* M = 3*X^2 + A*Z^4 */
- if( ECP_POINT_AFFINE(pP) ) {
- PMA_sqre(bnU, ECP_POINT_X(pP), pMont);
- PMA_add(bnM, bnU, bnU, pModulo);
- PMA_add(bnM, bnM, bnU, pModulo);
- PMA_add(bnM, bnM, ECP_AENC(pECC), pModulo);
- }
- else if( ECP_AMI3(pECC) ) {
- PMA_sqre(bnU, ECP_POINT_Z(pP), pMont);
- PMA_add(bnS, ECP_POINT_X(pP), bnU, pModulo);
- PMA_sub(bnT, ECP_POINT_X(pP), bnU, pModulo);
- PMA_mule(bnM, bnS, bnT, pMont);
- PMA_add(bnU, bnM, bnM, pModulo);
- PMA_add(bnM, bnU, bnM, pModulo);
- }
- else {
- PMA_sqre(bnU, ECP_POINT_X(pP), pMont);
- PMA_add(bnM, bnU, bnU, pModulo);
- PMA_add(bnM, bnM, bnU, pModulo);
- PMA_sqre(bnU, ECP_POINT_Z(pP), pMont);
- PMA_sqre(bnU, bnU, pMont);
- PMA_mule(bnU, bnU, ECP_AENC(pECC), pMont);
- PMA_add(bnM, bnM, bnU, pModulo);
- }
-
- PMA_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP), pModulo);
-
- /* R_Z = 2*Y*Z */
- if( ECP_POINT_AFFINE(pP) ) {
- PMA_set(ECP_POINT_Z(pR), bnV);
- }
- else {
- PMA_mule(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP), pMont);
- }
-
- /* S = 4*X*Y^2 */
- PMA_sqre(bnT, bnV, pMont);
- PMA_mule(bnS, bnT, ECP_POINT_X(pP), pMont);
-
- /* R_X = M^2 - 2*S */
- PMA_sqre(bnU, bnM, pMont);
- PMA_sub(bnU, bnU, bnS, pModulo);
- PMA_sub(ECP_POINT_X(pR), bnU, bnS, pModulo);
-
- /* T = 8*Y^4 */
- PMA_mule(bnV, bnV, ECP_POINT_Y(pP), pMont);
- PMA_mule(bnT, bnT, bnV, pMont);
-
- /* R_Y = M*(S - R_X) - T */
- PMA_sub(bnS, bnS, ECP_POINT_X(pR), pModulo);
- PMA_mule(bnS, bnS, bnM, pMont);
- PMA_sub(ECP_POINT_Y(pR), bnS, bnT, pModulo);
-
- ECP_POINT_AFFINE(pR) = 0;
- }
-}
-
-/*
-// ECCP_AddPoint
-//
-// Add points
-*/
-void ECCP_AddPoint(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- /* prevent operation with point at Infinity */
- if( ECCP_IsPointAtInfinity(pP) ) {
- ECCP_CopyPoint(pQ, pR);
- return;
- }
- if( ECCP_IsPointAtInfinity(pQ) ) {
- ECCP_CopyPoint(pP, pR);
- return;
- }
-
- /*
- // addition
- */
- {
- IppsMontState* pMont = ECP_PMONT(pECC);
-
- IppsBigNumState* bnU0 = cpBigNumListGet(&pList);
- IppsBigNumState* bnS0 = cpBigNumListGet(&pList);
- IppsBigNumState* bnU1 = cpBigNumListGet(&pList);
- IppsBigNumState* bnS1 = cpBigNumListGet(&pList);
- IppsBigNumState* bnW = cpBigNumListGet(&pList);
- IppsBigNumState* bnR = cpBigNumListGet(&pList);
- IppsBigNumState *bnT = bnU0;
- IppsBigNumState *bnM = bnS0;
- IppsBigNumState* pModulo = ECP_PRIME(pECC);
-
- /* U0 = P_X * Q_Z^2 */
- /* S0 = P_Y * Q_Z^3 */
- if( ECP_POINT_AFFINE(pQ) ) {
- PMA_set(bnU0, ECP_POINT_X(pP));
- PMA_set(bnS0, ECP_POINT_Y(pP));
- }
- else {
- PMA_sqre(bnW, ECP_POINT_Z(pQ), pMont);
- PMA_mule(bnU0,ECP_POINT_X(pP), bnW, pMont);
- PMA_mule(bnW, ECP_POINT_Z(pQ), bnW, pMont);
- PMA_mule(bnS0,ECP_POINT_Y(pP), bnW, pMont);
- }
-
- /* U1 = Q_X * P_Z^2 */
- /* S1 = Q_Y * P_Z^3 */
- if( ECP_POINT_AFFINE(pP) ) {
- PMA_set(bnU1, ECP_POINT_X(pQ));
- PMA_set(bnS1, ECP_POINT_Y(pQ));
- }
- else {
- PMA_sqre(bnW, ECP_POINT_Z(pP), pMont);
- PMA_mule(bnU1,ECP_POINT_X(pQ), bnW, pMont);
- PMA_mule(bnW, ECP_POINT_Z(pP), bnW, pMont);
- PMA_mule(bnS1,ECP_POINT_Y(pQ), bnW, pMont);
- }
-
- /* W = U0-U1 */
- /* R = S0-S1 */
- PMA_sub(bnW, bnU0, bnU1, pModulo);
- PMA_sub(bnR, bnS0, bnS1, pModulo);
-
- if( IsZero_BN(bnW) ) {
- if( IsZero_BN(bnR) ) {
- ECCP_DblPoint(pP, pR, pECC, pList);
- return;
- }
- else {
- ECCP_SetPointToInfinity(pR);
- return;
- }
- }
-
- /* T = U0+U1 */
- /* M = S0+S1 */
- PMA_add(bnT, bnU0, bnU1, pModulo);
- PMA_add(bnM, bnS0, bnS1, pModulo);
-
- /* R_Z = P_Z * Q_Z * W */
- if( ECP_POINT_AFFINE(pQ) && ECP_POINT_AFFINE(pP) ) {
- PMA_set(ECP_POINT_Z(pR), bnW);
- }
- else {
- if( ECP_POINT_AFFINE(pQ) ) {
- PMA_set(bnU1, ECP_POINT_Z(pP));
- }
- else if( ECP_POINT_AFFINE(pP) ) {
- PMA_set(bnU1, ECP_POINT_Z(pQ));
- }
- else {
- PMA_mule(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ), pMont);
- }
- PMA_mule(ECP_POINT_Z(pR), bnU1, bnW, pMont);
- }
-
- PMA_sqre(bnU1, bnW, pMont); /* U1 = W^2 */
- PMA_mule(bnS1, bnT, bnU1, pMont); /* S1 = T * W^2 */
-
- /* R_X = R^2 - T * W^2 */
- PMA_sqre(ECP_POINT_X(pR), bnR, pMont);
- PMA_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1, pModulo);
-
- /* V = T * W^2 - 2 * R_X (S1) */
- PMA_sub(bnS1, bnS1, ECP_POINT_X(pR), pModulo);
- PMA_sub(bnS1, bnS1, ECP_POINT_X(pR), pModulo);
-
- /* R_Y = (V * R - M * W^3) /2 */
- PMA_mule(ECP_POINT_Y(pR), bnS1, bnR, pMont);
- PMA_mule(bnU1, bnU1, bnW, pMont);
- PMA_mule(bnU1, bnU1, bnM, pMont);
- PMA_sub(bnU1, ECP_POINT_Y(pR), bnU1, pModulo);
- PMA_div2(ECP_POINT_Y(pR), bnU1, pModulo);
-
- ECP_POINT_AFFINE(pR) = 0;
- }
-}
-
-/*
-// ECCP_MulPoint
-//
-// Multiply point by scalar
-*/
-void ECCP_MulPoint(const IppsECCPPointState* pP,
- const IppsBigNumState* bnN,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- /* test zero scalar or input point at Infinity */
- if( IsZero_BN(bnN) || ECCP_IsPointAtInfinity(pP) ) {
- ECCP_SetPointToInfinity(pR);
- return;
- }
-
- /*
- // scalar multiplication
- */
- else {
- Ipp8u* pScratchAligned = ECP_SCCMBUFF(pECC);
-
- BNU_CHUNK_T* pN = BN_NUMBER(bnN);
- cpSize nsN = BN_SIZE(bnN);
- /* scalar bitsize */
- int scalarBitSize = BITSIZE_BNU(pN, nsN);
- /* optimal size of window */
- int w = cpECCP_OptimalWinSize(scalarBitSize);
- /* number of table entries */
- int nPrecomputed = 1<>shift) & dmask;
-
- /* initialize result (ECP_FINITE_POINT|ECP_PROJECTIVE) */
- cpECCP_ScrambleGet(pR, coordSize, pScratchAligned+windowVal, nPrecomputed);
- ECP_POINT_AFFINE(pR) = 0;
-
- /* initialize temporary T (ECP_PROJECTIVE) */
- ECP_POINT_AFFINE(&T) = 0;
-
- for(wPosition-=w; wPosition>=0; wPosition-=w) {
- /* w times doubling */
- int k;
- for(k=0; k>shift) & dmask;
-
- /* extract value from the pre-computed table */
- cpECCP_ScrambleGet(&T, coordSize, pScratchAligned+windowVal, nPrecomputed);
-
- /* and add it */
- ECCP_AddPoint(pR, &T, pR, pECC, pList);
- }
- }
- }
-}
-
-
-void ECCP_MulBasePoint(const IppsBigNumState* pK,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- ECCP_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList);
-}
-
-/*
-// ECCP_ProdPoint
-//
-// Point product
-*/
-void ECCP_ProdPoint(const IppsECCPPointState* pP,
- const IppsBigNumState* bnPscalar,
- const IppsECCPPointState* pQ,
- const IppsBigNumState* bnQscalar,
- IppsECCPPointState* pR,
- const IppsECCPState* pECC,
- BigNumNode* pList)
-{
- IppsECCPPointState T;
- IppsECCPPointState U;
-
- ECP_POINT_X(&T) = cpBigNumListGet(&pList);
- ECP_POINT_Y(&T) = cpBigNumListGet(&pList);
- ECP_POINT_Z(&T) = cpBigNumListGet(&pList);
-
- ECP_POINT_X(&U) = cpBigNumListGet(&pList);
- ECP_POINT_Y(&U) = cpBigNumListGet(&pList);
- ECP_POINT_Z(&U) = cpBigNumListGet(&pList);
-
- ECCP_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList);
- ECCP_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList);
- ECCP_AddPoint(&T, &U, pR, pECC, pList);
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppoint.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppoint.h
deleted file mode 100644
index a72b0ea1ef..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppoint.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_ECCPPOINT_H)
-#define _PCP_ECCPPOINT_H
-
-#include "pcpeccp.h"
-
-
-/*
-// EC Point context
-*/
-struct _cpECCPPoint {
- IppCtxId idCtx; /* EC Point identifier */
-
- IppsBigNumState* pX; /* projective X */
- IppsBigNumState* pY; /* Y */
- IppsBigNumState* pZ; /* Z coordinates */
- int affine; /* impotrant case Z=1 */
-};
-
-/*
-// Contetx Access Macros
-*/
-#define ECP_POINT_ID(ctx) ((ctx)->idCtx)
-#define ECP_POINT_X(ctx) ((ctx)->pX)
-#define ECP_POINT_Y(ctx) ((ctx)->pY)
-#define ECP_POINT_Z(ctx) ((ctx)->pZ)
-#define ECP_POINT_AFFINE(ctx) ((ctx)->affine)
-#define ECP_POINT_VALID_ID(ctx) (ECP_POINT_ID((ctx))==idCtxECCPPoint)
-
-#endif /* _PCP_ECCPPOINT_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointca.c
deleted file mode 100644
index 04dd7ca4a7..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointca.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccppoint.h"
-
-
-/*F*
-// Name: ippsECCPPointGetSize
-//
-// Purpose: Returns size of EC Point context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSzie
-// ippStsSizeErr 2>feBitSize
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pSize pointer to the size of EC Point context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPPointGetSize, (int feBitSize, int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
-
- {
- int bnSize;
- ippsBigNumGetSize(BITS2WORD32_SIZE(feBitSize), &bnSize);
- *pSize = sizeof(IppsECCPPointState)
- + bnSize /* X coodinate */
- + bnSize /* Y coodinate */
- + bnSize /* Z coodinate */
- +(ALIGN_VAL-1);
- }
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPPointInit
-//
-// Purpose: Init EC Point context.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPoint
-// ippStsSizeErr 2>feBitSize
-// ippStsNoErr no errors
-//
-// Parameters:
-// feBitSize size of field element (bits)
-// pECC pointer to ECC context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPPointInit, (int feBitSize, IppsECCPPointState* pPoint))
-{
- /* test pEC pointer */
- IPP_BAD_PTR1_RET(pPoint);
-
- /* use aligned context */
- pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) );
-
- /* test size of field element */
- IPP_BADARG_RET((2>feBitSize), ippStsSizeErr);
-
- /* context ID */
- ECP_POINT_ID(pPoint) = idCtxECCPPoint;
-
- /* meaning: point was not set */
- ECP_POINT_AFFINE(pPoint) =-1;
-
- /*
- // init other context fields
- */
- {
- Ipp8u* ptr = (Ipp8u*)pPoint;
- int bnLen = BITS2WORD32_SIZE(feBitSize);
- int bnSize;
- ippsBigNumGetSize(bnLen, &bnSize);
-
- /* allocate coordinate buffers */
- ptr += sizeof(IppsECCPPointState);
- ECP_POINT_X(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) );
- ptr += bnSize;
- ECP_POINT_Y(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) );
- ptr += bnSize;
- ECP_POINT_Z(pPoint) = (IppsBigNumState*)( IPP_ALIGNED_PTR(ptr,ALIGN_VAL) );
-
- /* init coordinate buffers */
- ippsBigNumInit(bnLen, ECP_POINT_X(pPoint));
- ippsBigNumInit(bnLen, ECP_POINT_Y(pPoint));
- ippsBigNumInit(bnLen, ECP_POINT_Z(pPoint));
- }
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c
deleted file mode 100644
index df81d08f93..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppointopca.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPSetPoint
-//
-// Purpose: Converts regular affine coordinates EC point (pX,pY)
-// into internal presentation - montgomery projective.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-// NULL == pX
-// NULL == pY
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pX->idCtx
-// illegal pY->idCtx
-// illegal pPoint->idCtx
-//
-// ippStsOutOfECErr point out-of EC
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pX pointer to the regular affine coordinate X
-// pY pointer to the regular affine coordinate Y
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-// Note:
-// if B==0 and (x,y)=(0,y) then point at Infinity will be set up
-// if B!=0 and (x,y)=(0,0) then point at Infinity will be set up
-// else point with requested coordinates (x,y) wil be set up
-// There are no check validation inside!
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetPoint,(const IppsBigNumState* pX,
- const IppsBigNumState* pY,
- IppsECCPPointState* pPoint,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test pX and pY */
- IPP_BAD_PTR2_RET(pX,pY);
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
-
- /* test pPoint */
- IPP_BAD_PTR1_RET(pPoint);
- pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr);
-
- /* set affine coordinates at Infinity */
- if( ( IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity1(pX,pY)) ||
- (!IsZero_BN(ECP_BENC(pECC)) && ECCP_IsPointAtAffineInfinity0(pX,pY)) )
- ECCP_SetPointToInfinity(pPoint);
- /* set point */
- else {
- ECP_METHOD(pECC)->SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC);
- }
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPSetPointAtInfinity
-//
-// Purpose: Set point at Infinity
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPoint->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetPointAtInfinity,(IppsECCPPointState* pPoint,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test pPoint */
- IPP_BAD_PTR1_RET(pPoint);
- pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr);
-
- ECCP_SetPointToInfinity(pPoint);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPGetPoint
-//
-// Purpose: Converts internal presentation EC point - montgomery projective
-// into regular affine coordinates EC point (pX,pY)
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPoint
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPoint->idCtx
-// NULL != pX, illegal pX->idCtx
-// NULL != pY, illegal pY->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pX pointer to the regular affine coordinate X
-// pY pointer to the regular affine coordinate Y
-// pLength pointer to the length of coordinates
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPGetPoint,(IppsBigNumState* pX,
- IppsBigNumState* pY,
- const IppsECCPPointState* pPoint,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test source point */
- IPP_BAD_PTR1_RET(pPoint);
- pPoint = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPoint, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPoint), ippStsContextMatchErr);
-
- /* test pX and pY */
- if(pX) {
- pX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pX, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pX), ippStsContextMatchErr);
- }
- if(pY) {
- pY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pY), ippStsContextMatchErr);
- }
-
- if( ECCP_IsPointAtInfinity(pPoint) ) {
- if( IsZero_BN(ECP_BENC(pECC)) )
- ECCP_SetPointToAffineInfinity1(pX, pY);
- else
- ECCP_SetPointToAffineInfinity0(pX, pY);
- }
- else
- ECP_METHOD(pECC)->GetPointAffine(pX, pY, pPoint, pECC, ECP_BNCTX(pECC));
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPCheckPoint
-//
-// Purpose: Check EC point:
-// - is point lie on EC
-// - is point at infinity
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pResult
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPoint pointer to the EC Point context
-// pECC pointer to the ECCP context
-// pResult pointer to the result:
-// ippECValid
-// ippECPointIsNotValid
-// ippECPointIsAtInfinite
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPCheckPoint,(const IppsECCPPointState* pP,
- IppECResult* pResult,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test point */
- IPP_BAD_PTR1_RET(pP);
- pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr);
-
- /* test pResult */
- IPP_BAD_PTR1_RET(pResult);
-
- if( ECCP_IsPointAtInfinity(pP) )
- *pResult = ippECPointIsAtInfinite;
- else if( ECP_METHOD(pECC)->IsPointOnCurve(pP, pECC, ECP_BNCTX(pECC)) )
- *pResult = ippECValid;
- else
- *pResult = ippECPointIsNotValid;
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPComparePoint
-//
-// Purpose: Compare two EC points
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pQ
-// NULL == pResult
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pQ->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the EC Point context
-// pQ pointer to the EC Point context
-// pECC pointer to the ECCP context
-// pResult pointer to the result:
-// ippECPointIsEqual
-// ippECPointIsNotEqual
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPComparePoint,(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- IppECResult* pResult,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test points */
- IPP_BAD_PTR2_RET(pP,pQ);
- pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) );
- pQ = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pQ, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr);
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pQ), ippStsContextMatchErr);
-
- /* test pResult */
- IPP_BAD_PTR1_RET(pResult);
-
- *pResult = ECP_METHOD(pECC)->ComparePoint(pP, pQ, pECC, ECP_BNCTX(pECC))? ippECPointIsNotEqual : ippECPointIsEqual;
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPNegativePoint
-//
-// Purpose: Perforn EC point operation: R = -P
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPNegativePoint, (const IppsECCPPointState* pP,
- IppsECCPPointState* pR,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test points */
- IPP_BAD_PTR2_RET(pP,pR);
- pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) );
- pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr);
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr);
-
- ECP_METHOD(pECC)->NegPoint(pP, pR, pECC);
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPAddPoint
-//
-// Purpose: Perforn EC point operation: R = P+Q
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pQ
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pQ->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pQ pointer to the source EC Point context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPAddPoint,(const IppsECCPPointState* pP,
- const IppsECCPPointState* pQ,
- IppsECCPPointState* pR,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test points */
- IPP_BAD_PTR3_RET(pP,pQ,pR);
- pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) );
- pQ = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pQ, ALIGN_VAL) );
- pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr);
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pQ), ippStsContextMatchErr);
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr);
-
- if(pP==pQ)
- ECP_METHOD(pECC)->DblPoint(pP, pR, pECC, ECP_BNCTX(pECC));
- else
- ECP_METHOD(pECC)->AddPoint(pP, pQ, pR, pECC, ECP_BNCTX(pECC));
-
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsECCPMulPointScalar
-//
-// Purpose: Perforn EC point operation: R = k*P
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pP
-// NULL == pK
-// NULL == pR
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pP->idCtx
-// illegal pK->idCtx
-// illegal pR->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pP pointer to the source EC Point context
-// pK pointer to the source BigNum multiplier context
-// pR pointer to the resultant EC Point context
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPMulPointScalar,(const IppsECCPPointState* pP,
- const IppsBigNumState* pK,
- IppsECCPPointState* pR,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test points */
- IPP_BAD_PTR2_RET(pP,pR);
- pP = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pP, ALIGN_VAL) );
- pR = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pR, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pP), ippStsContextMatchErr);
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pR), ippStsContextMatchErr);
-
- /* test scalar */
- IPP_BAD_PTR1_RET(pK);
- pK = (IppsBigNumState*)( IPP_ALIGNED_PTR(pK, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pK), ippStsContextMatchErr);
-
- ECP_METHOD(pECC)->MulPoint(pP, pK, pR, pECC, ECP_BNCTX(pECC));
-
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c
deleted file mode 100644
index 42b2515cf4..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccppublickeyca.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPPublicKey
-//
-// Purpose: Calculate Public Key
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPrivate
-// NULL == pPublic
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPrivate->idCtx
-// illegal pPublic->idCtx
-//
-// ippStsIvalidPrivateKey !(0 < pPrivate < order)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the private key
-// pPublic pointer to the resultant public key
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPPublicKey, (const IppsBigNumState* pPrivate,
- IppsECCPPointState* pPublic,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test public key */
- IPP_BAD_PTR1_RET(pPublic);
- pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublic), ippStsContextMatchErr);
-
- /* test private keys */
- IPP_BAD_PTR1_RET(pPrivate);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
- IPP_BADARG_RET(!((0cpBN_cmp(pPrivate, ECP_ORDER(pECC))) ), ippStsIvalidPrivateKey);
-
- /* calculates public key */
- ECP_METHOD(pECC)->MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC));
-
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c
deleted file mode 100644
index 3fec05a086..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsecretdhca.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPSharedSecretDH
-//
-// Purpose: Shared Secret Value Derivation
-// (Diffie-Hellman version).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPrivateA
-// NULL == pPublicB
-// NULL == pShare
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPrivateA->idCtx
-// illegal pPublicB->idCtx
-// illegal pShare->idCtx
-//
-// ippStsRangeErr not enough room for share key
-//
-// ippStsShareKeyErr (infinity) => z
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivateA pointer to own private key
-// pPublicB pointer to alien public key
-// pShare pointer to the shareds secret value
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA,
- const IppsECCPPointState* pPublicB,
- IppsBigNumState* pShare,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test private (own) key */
- IPP_BAD_PTR1_RET(pPrivateA);
- pPrivateA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateA, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivateA), ippStsContextMatchErr);
-
- /* test public (other party) key */
- IPP_BAD_PTR1_RET(pPublicB);
- pPublicB = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublicB, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublicB), ippStsContextMatchErr);
-
- /* test share secret value */
- IPP_BAD_PTR1_RET(pShare);
- pShare = (IppsBigNumState*)( IPP_ALIGNED_PTR(pShare, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pShare), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pShare)*BITSIZE(BNU_CHUNK_T)MulPoint(pPublicB, pPrivateA, &Tmp, pECC, pList);
-
- /* test: Tmp ~ point at Infinity */
- if( ECCP_IsPointAtInfinity(&Tmp) )
- return ippStsShareKeyErr;
- else {
- ECP_METHOD(pECC)->GetPointAffine(pShare, NULL, &Tmp, pECC, pList);
- return ippStsNoErr;
- }
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c
deleted file mode 100644
index c1644c06ae..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsetkeyca.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPSetKeyPair
-//
-// Purpose: Generate (private,public) Key Pair
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pPrivate
-// NULL == pPublic
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pPrivate->idCtx
-// illegal pPublic->idCtx
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pPrivate pointer to the private key
-// pPublic pointer to the public key
-// regular flag regular/ephemeral keys
-// pECC pointer to the ECCP context
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSetKeyPair, (const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic,
- IppBool regular,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- /* test ID */
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- {
- IppsBigNumState* targetPrivate;
- IppsECCPPointState* targetPublic;
-
- if( regular ) {
- targetPrivate = ECP_PRIVATE(pECC);
- targetPublic = ECP_PUBLIC(pECC);
- }
- else {
- targetPrivate = ECP_PRIVATE_E(pECC);
- targetPublic = ECP_PUBLIC_E(pECC);
- }
-
- /* set up private key request */
- if( pPrivate ) {
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
- ippsSet_BN(ippBigNumPOS, BN_SIZE32(pPrivate), (Ipp32u*)BN_NUMBER(pPrivate), targetPrivate);
- }
-
- /* set up public key request */
- if( pPublic ) {
- pPublic = (IppsECCPPointState*)( IPP_ALIGNED_PTR(pPublic, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_POINT_VALID_ID(pPublic), ippStsContextMatchErr);
-
- ECP_METHOD(pECC)->GetPointAffine(ECP_POINT_X(targetPublic), ECP_POINT_Y(targetPublic), pPublic, pECC, ECP_BNCTX(pECC));
- ECP_METHOD(pECC)->SetPointAffine(ECP_POINT_X(targetPublic), ECP_POINT_Y(targetPublic), targetPublic, pECC);
- }
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c
deleted file mode 100644
index bcda1d76ad..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsigndsaca.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpeccp.h"
-#include "pcpeccppoint.h"
-#include "pcpeccpmethod.h"
-#include "pcpeccpmethodcom.h"
-
-
-/*F*
-// Name: ippsECCPSignDSA
-//
-// Purpose: Signing of message representative.
-// (DSA version).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pECC
-// NULL == pMsgDigest
-// NULL == pPrivate
-// NULL == pSignX
-// NULL == pSignY
-//
-// ippStsContextMatchErr illegal pECC->idCtx
-// illegal pMsgDigest->idCtx
-// illegal pPrivate->idCtx
-// illegal pSignX->idCtx
-// illegal pSignY->idCtx
-//
-// ippStsMessageErr MsgDigest >= order
-//
-// ippStsRangeErr not enough room for:
-// signX
-// signY
-//
-// ippStsEphemeralKeyErr (0==signX) || (0==signY)
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsgDigest pointer to the message representative to be signed
-// pPrivate pointer to the regular private key
-// pSignX,pSignY pointer to the signature
-// pECC pointer to the ECCP context
-//
-// Note:
-// - ephemeral key pair extracted from pECC and
-// must be generated and before ippsECCPDSASign() usage
-// - ephemeral key pair destroy before exit
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPSignDSA,(const IppsBigNumState* pMsgDigest,
- const IppsBigNumState* pPrivate,
- IppsBigNumState* pSignX, IppsBigNumState* pSignY,
- IppsECCPState* pECC))
-{
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test private key*/
- IPP_BAD_PTR1_RET(pPrivate);
- pPrivate = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivate, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivate), ippStsContextMatchErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsgDigest);
- pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
- IPP_BADARG_RET((0<=cpBN_cmp(pMsgDigest, ECP_ORDER(pECC))), ippStsMessageErr);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignX,pSignY);
- pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) );
- pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
- IPP_BADARG_RET((BN_ROOM(pSignX)*BITSIZE(BNU_CHUNK_T)GetPointAffine(pTmp, NULL, ECP_PUBLIC_E(pECC), pECC, pList);
-
- /*
- // compute
- // signX = eph_pub_x (mod order)
- */
- PMA_mod(pSignX, pTmp, pOrder);
- if( !IsZero_BN(pSignX) ) {
-
- IppsBigNumState* pEncMsg = cpBigNumListGet(&pList);
- IppsBigNumState* pEncSignX = cpBigNumListGet(&pList);
- PMA_enc(pEncMsg, (IppsBigNumState*)pMsgDigest, rMont);
- PMA_enc(pEncSignX, pSignX, rMont);
-
- /*
- // compute
- // signY = (1/eph_private)*(pMsgDigest + private*signX) (mod order)
- */
- PMA_inv(pSignY, ECP_PRIVATE_E(pECC), pOrder);
- PMA_enc(ECP_PRIVATE_E(pECC), pPrivate, rMont);
- PMA_mule(pTmp, ECP_PRIVATE_E(pECC), pEncSignX, rMont);
- PMA_add(pTmp, pTmp, pEncMsg, pOrder);
- PMA_mule(pSignY, pSignY, pTmp, rMont);
- if( !IsZero_BN(pSignY) )
- return ippStsNoErr;
- }
-
- return ippStsEphemeralKeyErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c
deleted file mode 100644
index 32ab537cf1..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpeccpsscm.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpeccppoint.h"
-
-
-#define LOG2_CACHE_LINE_SIZE (LOG_CACHE_LINE_SIZE)
-
-static int div_upper(int a, int d)
-{ return (a+d-1)/d; }
-
-static int getNumOperations(int bitsize, int w)
-{
- int n_overhead = (1<=n_opt) break;
- w_opt = w_trial;
- n_opt = n_trial;
- }
- return w_opt;
-#undef LIMIT
-}
-
-int cpECCP_ConvertRepresentation(BNU_CHUNK_T* pInput, int inpBits, int w)
-{
- Ipp32u* pR = (Ipp32u*)pInput;
- Ipp16u* pR16 = (Ipp16u*)pInput;
-
- int outBits = 0;
- Ipp32u base = (BNU_CHUNK_T)1<>digitShift) &digitMask;
-
- Ipp32u delta = (base-digit) & ~digitMask;
- delta <<= digitShift;
- cpDec_BNU32((Ipp32u*)(pR16+chunkIdx), (Ipp32u*)(pR16+chunkIdx), (2*nsR-chunkIdx+1)/2, delta);
-
- inpBits = BITSIZE_BNU32(pR, nsR);
- outBits += w;
- }
-
- return outBits;
-}
-
-/*
-// cpsScramblePut/cpsScrambleGet
-// stores to/retrieves from pScrambleEntry position
-// pre-computed data if fixed window method is used
-*/
-void cpECCP_ScramblePut(Ipp8u* pScrambleEntry, int proposity,
- const IppsECCPPointState* pPoint, cpSize coordLen)
-{
- int i;
- Ipp8u* pCoord;
-
- BNU_CHUNK_T* pX = BN_NUMBER(ECP_POINT_X(pPoint));
- BNU_CHUNK_T* pY = BN_NUMBER(ECP_POINT_Y(pPoint));
- BNU_CHUNK_T* pZ = BN_NUMBER(ECP_POINT_Z(pPoint));
- int coordSize = coordLen*sizeof(BNU_CHUNK_T);
-
- ZEXPAND_BNU(pX, BN_SIZE(ECP_POINT_X(pPoint)), coordLen);
- ZEXPAND_BNU(pY, BN_SIZE(ECP_POINT_Y(pPoint)), coordLen);
- ZEXPAND_BNU(pZ, BN_SIZE(ECP_POINT_Z(pPoint)), coordLen);
-
- pCoord = (Ipp8u*)pX;
- for(i=0; iidCtx
-// illegal pMsgDigest->idCtx
-// illegal pSignX->idCtx
-// illegal pSignY->idCtx
-//
-// ippStsMessageErr MsgDigest >= order
-//
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsgDigest pointer to the message representative to be signed
-// pSignX,pSignY pointer to the signature
-// pResult pointer to the result: ippECValid/ippECInvalidSignature
-// pECC pointer to the ECCP context
-//
-// Note:
-// - signer's key must be set up in ECCP context
-// before ippsECCPVerifyDSA() usage
-//
-*F*/
-IPPFUN(IppStatus, ippsECCPVerifyDSA,(const IppsBigNumState* pMsgDigest,
- const IppsBigNumState* pSignX, const IppsBigNumState* pSignY,
- IppECResult* pResult,
- IppsECCPState* pECC))
-{
- IppsMontState* rMont;
-
- /* test pECC */
- IPP_BAD_PTR1_RET(pECC);
- /* use aligned EC context */
- pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, ALIGN_VAL) );
- IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr);
-
- /* test message representative */
- IPP_BAD_PTR1_RET(pMsgDigest);
- pMsgDigest = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMsgDigest, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pMsgDigest), ippStsContextMatchErr);
- rMont = ECP_RMONT(pECC);
- IPP_BADARG_RET((0<=cpBN_cmp(pMsgDigest, ECP_ORDER(pECC))), ippStsMessageErr);
-
- /* test result */
- IPP_BAD_PTR1_RET(pResult);
-
- /* test signature */
- IPP_BAD_PTR2_RET(pSignX,pSignY);
- pSignX = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignX, ALIGN_VAL) );
- pSignY = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSignY, ALIGN_VAL) );
- IPP_BADARG_RET(!BN_VALID_ID(pSignX), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pSignY), ippStsContextMatchErr);
-
- /* test signature value */
- if( (0>cpBN_tst(pSignX)) || (0>cpBN_tst(pSignY)) ||
- (0<=cpBN_cmp(pSignX, ECP_ORDER(pECC))) ||
- (0<=cpBN_cmp(pSignY, ECP_ORDER(pECC))) ) {
- *pResult = ippECInvalidSignature;
- return ippStsNoErr;
- }
-
- /* validate signature */
- else {
- IppsECCPPointState P1;
-
- BigNumNode* pList = ECP_BNCTX(pECC);
- IppsBigNumState* pH1 = cpBigNumListGet(&pList);
- IppsBigNumState* pH2 = cpBigNumListGet(&pList);
- IppsBigNumState* pOrder = cpBigNumListGet(&pList);
- BN_Set(MNT_MODULUS(rMont), MNT_SIZE(rMont), pOrder);
-
- ECP_POINT_X(&P1) = cpBigNumListGet(&pList);
- ECP_POINT_Y(&P1) = cpBigNumListGet(&pList);
- ECP_POINT_Z(&P1) = cpBigNumListGet(&pList);
-
- PMA_inv(pH1, (IppsBigNumState*)pSignY, pOrder);/* h = 1/signY (mod order) */
- PMA_enc(pH1, pH1, rMont);
- PMA_mule(pH2, (IppsBigNumState*)pSignX, pH1, rMont); /* h2 = pSignX * h (mod order) */
- PMA_mule(pH1, (IppsBigNumState*)pMsgDigest, pH1, rMont); /* h1 = pMsgDigest * h (mod order) */
-
- /* compute h1*BasePoint + h2*publicKey */
- ECP_METHOD(pECC)->ProdPoint(ECP_GENC(pECC), pH1,
- ECP_PUBLIC(pECC), pH2,
- &P1, pECC, pList);
-
- if( ECCP_IsPointAtInfinity(&P1) ) {
- *pResult = ippECInvalidSignature;
- return ippStsNoErr;
- }
- /* extract X component */
- ECP_METHOD(pECC)->GetPointAffine(pH1, NULL, &P1, pECC, pList);
- /* compare with signX */
- PMA_mod(pH1, pH1, pOrder);
- *pResult = (0==cpBN_cmp(pH1, pSignX))? ippECValid : ippECInvalidSignature;
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphash.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphash.h
deleted file mode 100644
index 669f3e3467..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphash.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_HASH_H)
-#define _PCP_HASH_H
-
-
-/* messge block size */
-#define MBS_SHA1 (64) /* SHA1 message block size (bytes) */
-#define MBS_SHA256 (64) /* SHA256 and SHA224 */
-#define MBS_SHA224 (64) /* SHA224 */
-#define MBS_SHA512 (128) /* SHA512 and SHA384 */
-#define MBS_SHA384 (128) /* SHA384 */
-#define MBS_MD5 (64) /* MD5 */
-#define MBS_HASH_MAX (MBS_SHA512) /* max message block size (bytes) */
-#define MAX_HASH_SIZE (IPP_SHA512_DIGEST_BITSIZE/8) /* hash of the max len (bytes) */
-
-/*
-// Useful macros
-*/
-#define SHS_ID(stt) ((stt)->idCtx)
-#define SHS_INDX(stt) ((stt)->index)
-#define SHS_LENL(stt) ((stt)->msgLenLo)
-#define SHS_LENH(stt) ((stt)->msgLenHi)
-#define SHS_BUFF(stt) ((stt)->msgBuffer)
-#define SHS_HASH(stt) ((stt)->msgHash)
-
-/* initial hash values */
-extern const Ipp32u SHA1_IV[];
-extern const Ipp32u SHA256_IV[];
-extern const Ipp32u SHA224_IV[];
-extern const Ipp64u SHA512_IV[];
-extern const Ipp64u SHA384_IV[];
-extern const Ipp32u MD5_IV[];
-extern const Ipp64u SHA512_224_IV[];
-extern const Ipp64u SHA512_256_IV[];
-
-/* hash alg additive constants */
-extern __ALIGN16 const Ipp32u SHA1_cnt[];
-extern __ALIGN16 const Ipp32u SHA256_cnt[];
-extern __ALIGN16 const Ipp64u SHA512_cnt[];
-extern __ALIGN16 const Ipp32u MD5_cnt[];
-
-
-/* hash alg attributes */
-typedef struct _cpHashAttr {
- int ivSize; /* attr: length (bytes) of initial value cpHashIV */
- int hashSize; /* attr: length (bytes) of hash */
- int msgBlkSize; /* attr: length (bytes) of message block */
- int msgLenRepSize; /* attr: length (bytes) in representation of processed message length */
- Ipp64u msgLenMax[2]; /* attr: max message length (bytes) (low high) */
-} cpHashAttr;
-
-
-/* hash value */
-typedef Ipp64u cpHash[IPP_SHA512_DIGEST_BITSIZE/BITSIZE(Ipp64u)]; /* hash value */
-
-/* hash update function */
-typedef void (*cpHashProc)(void* pHash, const Ipp8u* pMsg, int msgLen, const void* pParam);
-
-
-
-/* hash context */
-struct _cpHashCtx {
- IppCtxId idCtx; /* hash identifier */
- IppHashAlgId algID; /* hash algorithm ID */
- Ipp64u msgLenLo; /* length (bytes) of processed message: */
- Ipp64u msgLenHi; /* low and high parts */
- cpHashProc hashProc; /* hash update function */
- const void* pParam; /* optional hashProc's parameter */
- cpHash hashVal; /* intermadiate has value */
- int buffOffset; /* current buffer position */
- Ipp8u msgBuffer[MBS_HASH_MAX]; /* buffer */
-};
-
-/* accessors */
-#define HASH_CTX_ID(stt) ((stt)->idCtx)
-#define HASH_ALG_ID(stt) ((stt)->algID)
-#define HASH_LENLO(stt) ((stt)->msgLenLo)
-#define HASH_LENHI(stt) ((stt)->msgLenHi)
-#define HASH_FUNC(stt) ((stt)->hashProc)
-#define HASH_FUNC_PAR(stt) ((stt)->pParam)
-#define HASH_VALUE(stt) ((stt)->hashVal)
-#define HAHS_BUFFIDX(stt) ((stt)->buffOffset)
-#define HASH_BUFF(stt) ((stt)->msgBuffer)
-#define HASH_VALID_ID(pCtx) (HASH_CTX_ID((pCtx))==idCtxHash)
-
-
-/* hash alg opt argument */
-extern const void* cpHashProcFuncOpt[];
-
-/* enabled hash alg */
-extern const IppHashAlgId cpEnabledHashAlgID[];
-
-/* hash alg IV (init value) */
-extern const Ipp8u* cpHashIV[];
-
-/* hash alg attribute DB */
-extern const cpHashAttr cpHashAlgAttr[];
-
-/* IV size helper */
-__INLINE int cpHashIvSize(IppHashAlgId algID)
-{ return cpHashAlgAttr[algID].ivSize; }
-
-/* hash size helper */
-__INLINE int cpHashSize(IppHashAlgId algID)
-{ return cpHashAlgAttr[algID].hashSize; }
-
-/* message block size helper */
-__INLINE int cpHashMBS(IppHashAlgId algID)
-{ return cpHashAlgAttr[algID].msgBlkSize; }
-
-/* maps algID into enabled IppHashAlgId value */
-__INLINE IppHashAlgId cpValidHashAlg(IppHashAlgId algID)
-{
- /* maps algID into the valid range */
- algID = (((int)ippHashAlg_Unknown < (int)algID) && ((int)algID < (int)ippHashAlg_MaxNo))? algID : ippHashAlg_Unknown;
- return cpEnabledHashAlgID[algID];
-}
-
-
-/* processing functions */
-void UpdateSHA1 (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam);
-void UpdateSHA256(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam);
-void UpdateSHA512(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam);
-void UpdateMD5 (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam);
-
-/* general methods */
-int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID);
-
-#endif /* _PCP_HASH_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashca.c
deleted file mode 100644
index 47b2a8b670..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashca.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsHashGetSize
-//
-// Purpose: Returns size (bytes) of IppsHashState state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSize == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to state size
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetSize,(int* pSize))
-{
- /* test pointers */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsHashState);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashInit
-//
-// Purpose: Init Hash state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pState == NULL
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pCtx pointer to the Hash state
-// algID hash alg ID
-//
-*F*/
-int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID)
-{
- int hashIvSize = cpHashIvSize(algID);
- const Ipp8u* iv = cpHashIV[algID];
-
- HASH_LENLO(pCtx) = CONST_64(0);
- HASH_LENHI(pCtx) = CONST_64(0);
- HAHS_BUFFIDX(pCtx) = 0;
- CopyBlock(iv, HASH_VALUE(pCtx), hashIvSize);
-
- return hashIvSize;
-}
-
-/*
-// hash alg default processing functions and opt argument
-*/
-static cpHashProc cpHashProcFunc[] = {
- (cpHashProc)NULL,
- UpdateSHA1,
- UpdateSHA256,
- UpdateSHA256,
- UpdateSHA512,
- UpdateSHA512,
- UpdateMD5,
- UpdateSHA512,
- UpdateSHA512,
-};
-
-int cpInitHash(IppsHashState* pCtx, IppHashAlgId algID)
-{
- /* setup default processing function */
- HASH_FUNC(pCtx) = cpHashProcFunc[algID];
-
- /* setup optional agr of processing function */
- HASH_FUNC_PAR(pCtx) = cpHashProcFuncOpt[algID];
-
- return cpReInitHash(pCtx, algID);
-}
-
-IPPFUN(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId algID))
-{
- /* get algorithm id */
- algID = cpValidHashAlg(algID);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr);
-
- /* test ctx pointer */
- IPP_BAD_PTR1_RET(pCtx);
- /* test hash alg */
-
- /* set ctx ID */
- HASH_CTX_ID(pCtx) = idCtxHash;
- HASH_ALG_ID(pCtx) = algID;
-
- /* init context */
- cpInitHash(pCtx, algID);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsHashUpdate
-//
-// Purpose: Updates intermediate hash value based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtx == NULL
-// ippStsNullPtrErr pSrc==0 but len!=0
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pCtx pointer to the Hash context
-//
-*F*/
-__INLINE int IsExceedMsgLen(Ipp64u maxLo, Ipp64u maxHi, Ipp64u lenLo, Ipp64u lenHi)
-{
- int isExceed = lenLo > maxLo;
- isExceed = (lenHi+isExceed) > maxHi;
- return isExceed;
-}
-
-IPPFUN(IppStatus, ippsHashUpdate,(const Ipp8u* pSrc, int len, IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
- /* test input length */
- IPP_BADARG_RET((len<0 && pSrc), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- /* handle non empty input */
- if(len) {
- const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)];
-
- /* test if size of message is being processed not exceeded yet */
- Ipp64u lenLo = HASH_LENLO(pCtx);
- Ipp64u lenHi = HASH_LENHI(pCtx);
- lenLo += len;
- if(lenLo < HASH_LENLO(pCtx)) lenHi++;
- if(IsExceedMsgLen(pAttr->msgLenMax[0],pAttr->msgLenMax[1], lenLo,lenHi))
- IPP_ERROR_RET(ippStsLengthErr);
-
- else {
- cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */
- const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */
- int mbs = pAttr->msgBlkSize; /* data block size */
-
- /*
- // processing
- */
- {
- int procLen;
-
- /* test if internal buffer is not empty */
- int n = HAHS_BUFFIDX(pCtx);
- if(n) {
- procLen = IPP_MIN(len, (mbs-n));
- CopyBlock(pSrc, HASH_BUFF(pCtx)+n, procLen);
- HAHS_BUFFIDX(pCtx) = n += procLen;
-
- /* block processing */
- if(mbs==n) {
- hashFunc(HASH_VALUE(pCtx), HASH_BUFF(pCtx), mbs, pParam);
- HAHS_BUFFIDX(pCtx) = 0;
- }
-
- /* update message pointer and length */
- pSrc += procLen;
- len -= procLen;
- }
-
- /* main processing part */
- procLen = len & ~(mbs-1);
- if(procLen) {
- hashFunc(HASH_VALUE(pCtx), pSrc, procLen, pParam);
- pSrc += procLen;
- len -= procLen;
- }
-
- /* rest of input message */
- if(len) {
- CopyBlock(pSrc, HASH_BUFF(pCtx), len);
- HAHS_BUFFIDX(pCtx) += len;
- }
- }
-
- /* update length of processed message */
- HASH_LENLO(pCtx) = lenLo;
- HASH_LENHI(pCtx) = lenHi;
-
- return ippStsNoErr;
- }
- }
-
- return ippStsNoErr;
-}
-
-
-static void cpComputeDigest(Ipp8u* pHashTag, int hashTagLen, const IppsHashState* pCtx)
-{
- /* hash alg and parameters */
- cpHashProc hashFunc = HASH_FUNC(pCtx); /* processing function */
- const void* pParam = HASH_FUNC_PAR(pCtx); /* and it's addition params */
-
- /* attributes */
- const cpHashAttr* pAttr = &cpHashAlgAttr[HASH_ALG_ID(pCtx)];
- int mbs = pAttr->msgBlkSize; /* data block size */
- int ivSize = pAttr->ivSize; /* size of hash's IV */
- int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
-
- /* number of bytes in context buffer */
- int n = HAHS_BUFFIDX(pCtx);
- /* buffer and it actual length */
- Ipp8u buffer[MBS_HASH_MAX*2];
- int bufferLen = n < (mbs-msgLenRepSize)? mbs : mbs*2;
-
- /* copy current hash value */
- cpHash hash;
- CopyBlock(HASH_VALUE(pCtx), hash, ivSize);
-
- /* copy of state's buffer */
- CopyBlock(HASH_BUFF(pCtx), buffer, bufferLen);
- /* end of message bit */
- buffer[n++] = 0x80;
- /* padd buffer */
- PaddBlock(0, buffer+n, bufferLen-n-msgLenRepSize);
-
- /* message length representation in bits (remember about big endian) */
- {
- /* convert processed message length bytes ->bits */
- Ipp64u lo = HASH_LENLO(pCtx);
- Ipp64u hi = HASH_LENHI(pCtx);
- hi = LSL64(hi,3) | LSR64(lo,63-3);
- lo = LSL64(lo,3);
-
- if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-2] = hi;
- #else
- ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(hi);
- #endif
- }
-
- /* recall about MD5 specific */
- if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
- #else
- ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
- #endif
- }
- else {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo);
- #else
- ((Ipp64u*)(buffer+bufferLen))[-1] = lo;
- #endif
- }
- }
-
- /* copmplete hash computation */
- hashFunc(hash, buffer, bufferLen, pParam);
-
- /* store digest into the user buffer (remember digest in big endian) */
- if(msgLenRepSize>(int)(sizeof(Ipp64u))) {
- /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
- hash[0] = ENDIANNESS64(hash[0]);
- hash[1] = ENDIANNESS64(hash[1]);
- hash[2] = ENDIANNESS64(hash[2]);
- hash[3] = ENDIANNESS64(hash[3]);
- hash[4] = ENDIANNESS64(hash[4]);
- hash[5] = ENDIANNESS64(hash[5]);
- hash[6] = ENDIANNESS64(hash[6]);
- hash[7] = ENDIANNESS64(hash[7]);
- }
- else if(ippHashAlg_MD5!=HASH_ALG_ID(pCtx)) {
- ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
- ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
- ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
- ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
- ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
- if(ippHashAlg_SHA1!=HASH_ALG_ID(pCtx)) {
- ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
- ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
- ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
- }
- }
- CopyBlock(hash, pHashTag, hashTagLen);
-}
-
-
-/*F*
-// Name: ippsHashGetTag
-//
-// Purpose: Compute digest based on current state.
-// Note, that futher digest update is possible
-//
-// Returns: Reason:
-// ippStsNullPtrErr pTag == NULL
-// pCtx == NULL
-// ippStsContextMatchErr pCtx->idCtx != idCtxHash
-// ippStsLengthErr hashSize < tagLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pTag address of the output digest
-// tagLen length of digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashGetTag,(Ipp8u* pTag, int tagLen, const IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR2_RET(pTag, pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
-
- {
- /* size of hash */
- int hashSize = cpHashAlgAttr[HASH_ALG_ID(pCtx)].hashSize;
- if(tagLen<1||hashSizeidCtx != idCtxHash
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// pCtx pointer to the SHS state
-//
-*F*/
-IPPFUN(IppStatus, ippsHashFinal,(Ipp8u* pMD, IppsHashState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR2_RET(pMD, pCtx);
- /* test the context */
- IPP_BADARG_RET(!HASH_VALID_ID(pCtx), ippStsContextMatchErr);
-
- {
- IppHashAlgId algID = HASH_ALG_ID(pCtx);
- int hashSize = cpHashAlgAttr[algID].hashSize;
-
- cpComputeDigest(pMD, hashSize, pCtx);
- cpReInitHash(pCtx, algID);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsHashMessage
-//
-// Purpose: Hash of the whole message.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pMsg == NULL but msgLen!=0
-// ippStsLengthErr msgLen <0
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the input message
-// msgLen input message length
-// pMD address of the output digest
-// algID hash alg ID
-//
-*F*/
-IPPFUN(IppStatus, ippsHashMessage,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD, IppHashAlgId algID))
-{
- /* get algorithm id */
- algID = cpValidHashAlg(algID);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==algID, ippStsNotSupportedModeErr);
-
- /* test digest pointer */
- IPP_BAD_PTR1_RET(pMD);
- /* test message length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- /* test message pointer */
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- {
- /* processing function and parameter */
- cpHashProc hashFunc = cpHashProcFunc[algID];
- const void* pParam = cpHashProcFuncOpt[algID];
-
- /* attributes */
- const cpHashAttr* pAttr = &cpHashAlgAttr[algID];
- int mbs = pAttr->msgBlkSize; /* data block size */
- int ivSize = pAttr->ivSize; /* size of hash's IV */
- int hashSize = pAttr->hashSize; /* hash size */
- int msgLenRepSize = pAttr->msgLenRepSize; /* length of the message representation */
-
- /* message bitlength representation */
- Ipp64u msgLenBits = (Ipp64u)msgLen*8;
- /* length of main message part */
- int msgLenBlks = msgLen & (-mbs);
- /* rest of message length */
- int msgLenRest = msgLen - msgLenBlks;
-
- /* end of message buffer */
- Ipp8u buffer[MBS_HASH_MAX*2];
- int bufferLen = (msgLenRest < (mbs-msgLenRepSize))? mbs : mbs*2;
-
- /* init hash */
- cpHash hash;
- const Ipp8u* iv = cpHashIV[algID];
- CopyBlock(iv, hash, ivSize);
-
- /*construct last messge block(s) */
- #define MSG_LEN_REP (sizeof(Ipp64u))
-
- /* copy end of message */
- CopyBlock(pMsg+msgLen-msgLenRest, buffer, msgLenRest);
- /* end of message bit */
- buffer[msgLenRest++] = 0x80;
- /* padd buffer */
- PaddBlock(0, buffer+msgLenRest, bufferLen-msgLenRest-MSG_LEN_REP);
- /* copy message bitlength representation */
- if(ippHashAlg_MD5!=algID)
- msgLenBits = ENDIANNESS64(msgLenBits);
- ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits;
-
- #undef MSG_LEN_REP
-
- /* message processing */
- if(msgLenBlks)
- hashFunc(hash, pMsg, msgLenBlks, pParam);
- hashFunc(hash, buffer, bufferLen, pParam);
-
- /* store digest into the user buffer (remember digest in big endian) */
- if(msgLenRepSize > (int)(sizeof(Ipp64u))) {
- /* ippHashAlg_SHA384, ippHashAlg_SHA512, ippHashAlg_SHA512_224 and ippHashAlg_SHA512_256 */
- hash[0] = ENDIANNESS64(hash[0]);
- hash[1] = ENDIANNESS64(hash[1]);
- hash[2] = ENDIANNESS64(hash[2]);
- hash[3] = ENDIANNESS64(hash[3]);
- hash[4] = ENDIANNESS64(hash[4]);
- hash[5] = ENDIANNESS64(hash[5]);
- hash[6] = ENDIANNESS64(hash[6]);
- hash[7] = ENDIANNESS64(hash[7]);
- }
- else if(ippHashAlg_MD5!=algID) {
- /* ippHashAlg_SHA1, ippHashAlg_SHA224, ippHashAlg_SHA256 and ippHashAlg_SM3 */
- ((Ipp32u*)hash)[0] = ENDIANNESS32(((Ipp32u*)hash)[0]);
- ((Ipp32u*)hash)[1] = ENDIANNESS32(((Ipp32u*)hash)[1]);
- ((Ipp32u*)hash)[2] = ENDIANNESS32(((Ipp32u*)hash)[2]);
- ((Ipp32u*)hash)[3] = ENDIANNESS32(((Ipp32u*)hash)[3]);
- ((Ipp32u*)hash)[4] = ENDIANNESS32(((Ipp32u*)hash)[4]);
- ((Ipp32u*)hash)[5] = ENDIANNESS32(((Ipp32u*)hash)[5]);
- ((Ipp32u*)hash)[6] = ENDIANNESS32(((Ipp32u*)hash)[6]);
- ((Ipp32u*)hash)[7] = ENDIANNESS32(((Ipp32u*)hash)[7]);
- }
- CopyBlock(hash, pMD, hashSize);
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashcnt.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashcnt.c
deleted file mode 100644
index 37e0188172..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashcnt.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-
-/*
-// enabled hash alg IDs
-*/
-const IppHashAlgId cpEnabledHashAlgID[] = {
- IPP_ALG_HASH_UNKNOWN,
- IPP_ALG_HASH_SHA1,
- IPP_ALG_HASH_SHA256,
- IPP_ALG_HASH_SHA224,
- IPP_ALG_HASH_SHA512,
- IPP_ALG_HASH_SHA384,
- IPP_ALG_HASH_MD5,
- IPP_ALG_HASH_SHA512_224,
- IPP_ALG_HASH_SHA512_256
-};
-////////////////////////////////////////////////////////////
-
-/*
-// hash init values
-*/
-const Ipp32u UnknownHash_IV[] = {
- 0};
-
-const Ipp32u SHA1_IV[] = {
- 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};
-
-const Ipp32u SHA256_IV[] = {
- 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
- 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19};
-
-const Ipp32u SHA224_IV[] = {
- 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939,
- 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4};
-
-const Ipp64u SHA512_IV[] = {
- CONST_64(0x6A09E667F3BCC908), CONST_64(0xBB67AE8584CAA73B),
- CONST_64(0x3C6EF372FE94F82B), CONST_64(0xA54FF53A5F1D36F1),
- CONST_64(0x510E527FADE682D1), CONST_64(0x9B05688C2B3E6C1F),
- CONST_64(0x1F83D9ABFB41BD6B), CONST_64(0x5BE0CD19137E2179)};
-
-const Ipp64u SHA384_IV[] = {
- CONST_64(0xCBBB9D5DC1059ED8), CONST_64(0x629A292A367CD507),
- CONST_64(0x9159015A3070DD17), CONST_64(0x152FECD8F70E5939),
- CONST_64(0x67332667FFC00B31), CONST_64(0x8EB44A8768581511),
- CONST_64(0xDB0C2E0D64F98FA7), CONST_64(0x47B5481DBEFA4FA4)};
-
-const Ipp32u MD5_IV[] = {
- 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476};
-
-const Ipp64u SHA512_224_IV[] = {
- CONST_64(0x8C3D37C819544DA2), CONST_64(0x73E1996689DCD4D6),
- CONST_64(0x1DFAB7AE32FF9C82), CONST_64(0x679DD514582F9FCF),
- CONST_64(0x0F6D2B697BD44DA8), CONST_64(0x77E36F7304C48942),
- CONST_64(0x3F9D85A86A1D36C8), CONST_64(0x1112E6AD91D692A1)};
-
-const Ipp64u SHA512_256_IV[] = {
- CONST_64(0x22312194FC2BF72C), CONST_64(0x9F555FA3C84C64C2),
- CONST_64(0x2393B86B6F53B151), CONST_64(0x963877195940EABD),
- CONST_64(0x96283EE2A88EFFE3), CONST_64(0xBE5E1E2553863992),
- CONST_64(0x2B0199FC2C85B8AA), CONST_64(0x0EB72DDC81C52CA2)};
-
-const Ipp8u* cpHashIV[] = {
- (Ipp8u*)UnknownHash_IV,
- (Ipp8u*)SHA1_IV,
- (Ipp8u*)SHA256_IV,
- (Ipp8u*)SHA224_IV,
- (Ipp8u*)SHA512_IV,
- (Ipp8u*)SHA384_IV,
- (Ipp8u*)MD5_IV,
- (Ipp8u*)SHA512_224_IV,
- (Ipp8u*)SHA512_256_IV,
-};
-
-////////////////////////////////////////////////////////////
-
-/*
-// additive constatns
-*/
-__ALIGN16 const Ipp32u SHA1_cnt[] = {
- 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
-};
-
-__ALIGN16 const Ipp32u SHA256_cnt[] = {
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
-};
-
-__ALIGN16 const Ipp64u SHA512_cnt[] = {
- CONST_64(0x428A2F98D728AE22), CONST_64(0x7137449123EF65CD), CONST_64(0xB5C0FBCFEC4D3B2F), CONST_64(0xE9B5DBA58189DBBC),
- CONST_64(0x3956C25BF348B538), CONST_64(0x59F111F1B605D019), CONST_64(0x923F82A4AF194F9B), CONST_64(0xAB1C5ED5DA6D8118),
- CONST_64(0xD807AA98A3030242), CONST_64(0x12835B0145706FBE), CONST_64(0x243185BE4EE4B28C), CONST_64(0x550C7DC3D5FFB4E2),
- CONST_64(0x72BE5D74F27B896F), CONST_64(0x80DEB1FE3B1696B1), CONST_64(0x9BDC06A725C71235), CONST_64(0xC19BF174CF692694),
- CONST_64(0xE49B69C19EF14AD2), CONST_64(0xEFBE4786384F25E3), CONST_64(0x0FC19DC68B8CD5B5), CONST_64(0x240CA1CC77AC9C65),
- CONST_64(0x2DE92C6F592B0275), CONST_64(0x4A7484AA6EA6E483), CONST_64(0x5CB0A9DCBD41FBD4), CONST_64(0x76F988DA831153B5),
- CONST_64(0x983E5152EE66DFAB), CONST_64(0xA831C66D2DB43210), CONST_64(0xB00327C898FB213F), CONST_64(0xBF597FC7BEEF0EE4),
- CONST_64(0xC6E00BF33DA88FC2), CONST_64(0xD5A79147930AA725), CONST_64(0x06CA6351E003826F), CONST_64(0x142929670A0E6E70),
- CONST_64(0x27B70A8546D22FFC), CONST_64(0x2E1B21385C26C926), CONST_64(0x4D2C6DFC5AC42AED), CONST_64(0x53380D139D95B3DF),
- CONST_64(0x650A73548BAF63DE), CONST_64(0x766A0ABB3C77B2A8), CONST_64(0x81C2C92E47EDAEE6), CONST_64(0x92722C851482353B),
- CONST_64(0xA2BFE8A14CF10364), CONST_64(0xA81A664BBC423001), CONST_64(0xC24B8B70D0F89791), CONST_64(0xC76C51A30654BE30),
- CONST_64(0xD192E819D6EF5218), CONST_64(0xD69906245565A910), CONST_64(0xF40E35855771202A), CONST_64(0x106AA07032BBD1B8),
- CONST_64(0x19A4C116B8D2D0C8), CONST_64(0x1E376C085141AB53), CONST_64(0x2748774CDF8EEB99), CONST_64(0x34B0BCB5E19B48A8),
- CONST_64(0x391C0CB3C5C95A63), CONST_64(0x4ED8AA4AE3418ACB), CONST_64(0x5B9CCA4F7763E373), CONST_64(0x682E6FF3D6B2B8A3),
- CONST_64(0x748F82EE5DEFB2FC), CONST_64(0x78A5636F43172F60), CONST_64(0x84C87814A1F0AB72), CONST_64(0x8CC702081A6439EC),
- CONST_64(0x90BEFFFA23631E28), CONST_64(0xA4506CEBDE82BDE9), CONST_64(0xBEF9A3F7B2C67915), CONST_64(0xC67178F2E372532B),
- CONST_64(0xCA273ECEEA26619C), CONST_64(0xD186B8C721C0C207), CONST_64(0xEADA7DD6CDE0EB1E), CONST_64(0xF57D4F7FEE6ED178),
- CONST_64(0x06F067AA72176FBA), CONST_64(0x0A637DC5A2C898A6), CONST_64(0x113F9804BEF90DAE), CONST_64(0x1B710B35131C471B),
- CONST_64(0x28DB77F523047D84), CONST_64(0x32CAAB7B40C72493), CONST_64(0x3C9EBE0A15C9BEBC), CONST_64(0x431D67C49C100D4C),
- CONST_64(0x4CC5D4BECB3E42B6), CONST_64(0x597F299CFC657E2A), CONST_64(0x5FCB6FAB3AD6FAEC), CONST_64(0x6C44198C4A475817)
-};
-
-__ALIGN16 const Ipp32u MD5_cnt[] = {
- 0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE,
- 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
- 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE,
- 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821,
-
- 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA,
- 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8,
- 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED,
- 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A,
-
- 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C,
- 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70,
- 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05,
- 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665,
-
- 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039,
- 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1,
- 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1,
- 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391
-};
-
-/*
-// hash alg default processing opt argument
-*/
-const void* cpHashProcFuncOpt[] = {
- NULL,
- SHA1_cnt,
- SHA256_cnt,
- SHA256_cnt,
- SHA512_cnt,
- SHA512_cnt,
- MD5_cnt,
- SHA512_cnt,
- SHA512_cnt,
-};
-////////////////////////////////////////////////////////////
-
-/* hash alg attributes */
-const cpHashAttr cpHashAlgAttr[] = {
- {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, /* unknown */
-
- {IPP_SHA1_DIGEST_BITSIZE/8, IPP_SHA1_DIGEST_BITSIZE/8, MBS_SHA1, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}},
-
- {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA256_DIGEST_BITSIZE/8, MBS_SHA256, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}},
-
- {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA224_DIGEST_BITSIZE/8, MBS_SHA224, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}},
-
- {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}},
-
- {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA384_DIGEST_BITSIZE/8, MBS_SHA384, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}},
-
- {IPP_MD5_DIGEST_BITSIZE/8,IPP_MD5_DIGEST_BITSIZE/8, MBS_MD5, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}},
-
- {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_224_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}},
-
- {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_256_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}
-};
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashmd5px.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashmd5px.c
deleted file mode 100644
index d6a93dd22f..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashmd5px.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-#pragma message("IPP_ALG_HASH_MD5 enabled")
-
-
-/*
-// Magic functions defined in RFC 1321
-//
-*/
-#define F(X,Y,Z) ((Z) ^ ((X) & ((Y) ^ (Z)))) /* sightly optimized form of (((X) & (Y)) | ((~(X) & (Z)))*/
-#define G(X,Y,Z) F((Z),(X),(Y)) /* replace the original (((X) & (Z)) | ((Y) & ~(Z))) */
-#define H(X,Y,Z) ((X) ^ (Y) ^ (Z))
-#define I(X,Y,Z) ((Y) ^ ((X) | ~(Z)))
-
-/*
-// MD5 step
-*/
-#define MD5_STEP(MAGIC, A,B,C,D, data, constant, nrot) \
- (A = B +ROL32((A +MAGIC(B,C,D) +data +constant), nrot))
-
-/*
-// MD5 left rotations (number of bits)
-// depends on round type
-*/
-#define F1 7
-#define F2 12
-#define F3 17
-#define F4 22
-
-#define G1 5
-#define G2 9
-#define G3 14
-#define G4 20
-
-#define H1 4
-#define H2 11
-#define H3 16
-#define H4 23
-
-#define I1 6
-#define I2 10
-#define I3 15
-#define I4 21
-
-/*F*
-// Name: UpdateMD5
-//
-// Purpose: Update internal hash according to input message stream.
-//
-// Parameters:
-// uniHash pointer to in/out hash
-// mblk pointer to message stream
-// mlen message stream length (multiple by message block size)
-// uniParam pointer to the optional parameter
-//
-*F*/
-void UpdateMD5(void* uinHash, const Ipp8u* mblk, int mlen, const void* uniParam)
-{
- Ipp32u* digest = (Ipp32u*)uinHash;
- Ipp32u* MD5_cnt_loc = (Ipp32u*)uniParam;
-
- for(; mlen>=MBS_MD5; mblk += MBS_MD5, mlen -= MBS_MD5) {
-
- /* allocate data */
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- Ipp32u data[MBS_MD5/sizeof(Ipp32u)];
- #else
- /* or just word alias */
- Ipp32u* data = (Ipp32u*)mblk;
- #endif
-
- /* init variables */
- Ipp32u a = digest[0];
- Ipp32u b = digest[1];
- Ipp32u c = digest[2];
- Ipp32u d = digest[3];
-
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- int t;
- for(t=0; t<16; t++) {
- data[t] = ENDIANNESS(((Ipp32u*)mblk)[t]);
- }
- #endif
-
- /* rounds type F */
- MD5_STEP(F, a,b,c,d, data[ 0], MD5_cnt_loc[ 0], F1);
- MD5_STEP(F, d,a,b,c, data[ 1], MD5_cnt_loc[ 1], F2);
- MD5_STEP(F, c,d,a,b, data[ 2], MD5_cnt_loc[ 2], F3);
- MD5_STEP(F, b,c,d,a, data[ 3], MD5_cnt_loc[ 3], F4);
- MD5_STEP(F, a,b,c,d, data[ 4], MD5_cnt_loc[ 4], F1);
- MD5_STEP(F, d,a,b,c, data[ 5], MD5_cnt_loc[ 5], F2);
- MD5_STEP(F, c,d,a,b, data[ 6], MD5_cnt_loc[ 6], F3);
- MD5_STEP(F, b,c,d,a, data[ 7], MD5_cnt_loc[ 7], F4);
- MD5_STEP(F, a,b,c,d, data[ 8], MD5_cnt_loc[ 8], F1);
- MD5_STEP(F, d,a,b,c, data[ 9], MD5_cnt_loc[ 9], F2);
- MD5_STEP(F, c,d,a,b, data[10], MD5_cnt_loc[10], F3);
- MD5_STEP(F, b,c,d,a, data[11], MD5_cnt_loc[11], F4);
- MD5_STEP(F, a,b,c,d, data[12], MD5_cnt_loc[12], F1);
- MD5_STEP(F, d,a,b,c, data[13], MD5_cnt_loc[13], F2);
- MD5_STEP(F, c,d,a,b, data[14], MD5_cnt_loc[14], F3);
- MD5_STEP(F, b,c,d,a, data[15], MD5_cnt_loc[15], F4);
-
- /* rounds type G */
- MD5_STEP(G, a,b,c,d, data[ 1], MD5_cnt_loc[16], G1);
- MD5_STEP(G, d,a,b,c, data[ 6], MD5_cnt_loc[17], G2);
- MD5_STEP(G, c,d,a,b, data[11], MD5_cnt_loc[18], G3);
- MD5_STEP(G, b,c,d,a, data[ 0], MD5_cnt_loc[19], G4);
- MD5_STEP(G, a,b,c,d, data[ 5], MD5_cnt_loc[20], G1);
- MD5_STEP(G, d,a,b,c, data[10], MD5_cnt_loc[21], G2);
- MD5_STEP(G, c,d,a,b, data[15], MD5_cnt_loc[22], G3);
- MD5_STEP(G, b,c,d,a, data[ 4], MD5_cnt_loc[23], G4);
- MD5_STEP(G, a,b,c,d, data[ 9], MD5_cnt_loc[24], G1);
- MD5_STEP(G, d,a,b,c, data[14], MD5_cnt_loc[25], G2);
- MD5_STEP(G, c,d,a,b, data[ 3], MD5_cnt_loc[26], G3);
- MD5_STEP(G, b,c,d,a, data[ 8], MD5_cnt_loc[27], G4);
- MD5_STEP(G, a,b,c,d, data[13], MD5_cnt_loc[28], G1);
- MD5_STEP(G, d,a,b,c, data[ 2], MD5_cnt_loc[29], G2);
- MD5_STEP(G, c,d,a,b, data[ 7], MD5_cnt_loc[30], G3);
- MD5_STEP(G, b,c,d,a, data[12], MD5_cnt_loc[31], G4);
-
- /* rounds type H */
- MD5_STEP(H, a,b,c,d, data[ 5], MD5_cnt_loc[32], H1);
- MD5_STEP(H, d,a,b,c, data[ 8], MD5_cnt_loc[33], H2);
- MD5_STEP(H, c,d,a,b, data[11], MD5_cnt_loc[34], H3);
- MD5_STEP(H, b,c,d,a, data[14], MD5_cnt_loc[35], H4);
- MD5_STEP(H, a,b,c,d, data[ 1], MD5_cnt_loc[36], H1);
- MD5_STEP(H, d,a,b,c, data[ 4], MD5_cnt_loc[37], H2);
- MD5_STEP(H, c,d,a,b, data[ 7], MD5_cnt_loc[38], H3);
- MD5_STEP(H, b,c,d,a, data[10], MD5_cnt_loc[39], H4);
- MD5_STEP(H, a,b,c,d, data[13], MD5_cnt_loc[40], H1);
- MD5_STEP(H, d,a,b,c, data[ 0], MD5_cnt_loc[41], H2);
- MD5_STEP(H, c,d,a,b, data[ 3], MD5_cnt_loc[42], H3);
- MD5_STEP(H, b,c,d,a, data[ 6], MD5_cnt_loc[43], H4);
- MD5_STEP(H, a,b,c,d, data[ 9], MD5_cnt_loc[44], H1);
- MD5_STEP(H, d,a,b,c, data[12], MD5_cnt_loc[45], H2);
- MD5_STEP(H, c,d,a,b, data[15], MD5_cnt_loc[46], H3);
- MD5_STEP(H, b,c,d,a, data[ 2], MD5_cnt_loc[47], H4);
-
- /* rounds type I */
- MD5_STEP(I, a,b,c,d, data[ 0], MD5_cnt_loc[48], I1);
- MD5_STEP(I, d,a,b,c, data[ 7], MD5_cnt_loc[49], I2);
- MD5_STEP(I, c,d,a,b, data[14], MD5_cnt_loc[50], I3);
- MD5_STEP(I, b,c,d,a, data[ 5], MD5_cnt_loc[51], I4);
- MD5_STEP(I, a,b,c,d, data[12], MD5_cnt_loc[52], I1);
- MD5_STEP(I, d,a,b,c, data[ 3], MD5_cnt_loc[53], I2);
- MD5_STEP(I, c,d,a,b, data[10], MD5_cnt_loc[54], I3);
- MD5_STEP(I, b,c,d,a, data[ 1], MD5_cnt_loc[55], I4);
- MD5_STEP(I, a,b,c,d, data[ 8], MD5_cnt_loc[56], I1);
- MD5_STEP(I, d,a,b,c, data[15], MD5_cnt_loc[57], I2);
- MD5_STEP(I, c,d,a,b, data[ 6], MD5_cnt_loc[58], I3);
- MD5_STEP(I, b,c,d,a, data[13], MD5_cnt_loc[59], I4);
- MD5_STEP(I, a,b,c,d, data[ 4], MD5_cnt_loc[60], I1);
- MD5_STEP(I, d,a,b,c, data[11], MD5_cnt_loc[61], I2);
- MD5_STEP(I, c,d,a,b, data[ 2], MD5_cnt_loc[62], I3);
- MD5_STEP(I, b,c,d,a, data[ 9], MD5_cnt_loc[63], I4);
-
- /* update digest */
- digest[0] += a;
- digest[1] += b;
- digest[2] += c;
- digest[3] += d;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha1px.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha1px.c
deleted file mode 100644
index 77b7c184e1..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha1px.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*
-// Magic functions defined in FIPS 180-1
-//
-*/
-#define MAGIC_F0(B,C,D) (((B) & (C)) | ((~(B)) & (D)))
-#define MAGIC_F1(B,C,D) ((B) ^ (C) ^ (D))
-#define MAGIC_F2(B,C,D) (((B) & (C)) | ((B) & (D)) | ((C) & (D)))
-#define MAGIC_F3(B,C,D) ((B) ^ (C) ^ (D))
-
-#define SHA1_STEP(A,B,C,D,E, MAGIC_FUN, W,K) \
- (E)+= ROL32((A),5) + MAGIC_FUN((B),(C),(D)) + (W) + (K); \
- (B) = ROL32((B),30)
-
-#define COMPACT_SHA1_STEP(A,B,C,D,E, MAGIC_FUN, W,K, t) { \
- Ipp32u _T = ROL32((A),5) + MAGIC_FUN((t)/20, (B),(C),(D)) + (E) + (W)[(t)] + (K)[(t)/20]; \
- (E) = (D); \
- (D) = (C); \
- (C) = ROL32((B),30); \
- (B) = (A); \
- (A) = _T; \
-}
-
-#if defined(_ALG_SHA1_COMPACT_)
-__INLINE Ipp32u MagicFun(int s, Ipp32u b, Ipp32u c, Ipp32u d)
-{
- switch(s) {
- case 0: return MAGIC_F0(b,c,d);
- case 2: return MAGIC_F2(b,c,d);
- default:return MAGIC_F1(b,c,d);
- }
-}
-#endif
-
-
-/*F*
-// Name: UpdateSHA1
-//
-// Purpose: Update internal hash according to input message stream.
-//
-// Parameters:
-// uniHash pointer to in/out hash
-// mblk pointer to message stream
-// mlen message stream length (multiple by message block size)
-// uniParam pointer to the optional parameter
-//
-*F*/
-#if defined(_ALG_SHA1_COMPACT_)
-#pragma message("SHA1 compact")
-#endif
-
-void UpdateSHA1(void* uinHash, const Ipp8u* mblk, int mlen, const void *uniParam)
-{
- Ipp32u* data = (Ipp32u*)mblk;
-
- Ipp32u* digest = (Ipp32u*)uinHash;
- Ipp32u* SHA1_cnt_loc = (Ipp32u*)uniParam;
-
- for(; mlen>=MBS_SHA1; data += MBS_SHA1/sizeof(Ipp32u), mlen -= MBS_SHA1) {
- int t;
-
- /*
- // expand message block
- */
- Ipp32u W[80];
- /* initialize the first 16 words in the array W (remember about endian) */
- for(t=0; t<16; t++) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- W[t] = data[t];
- #else
- W[t] = ENDIANNESS(data[t]);
- #endif
- }
- /* schedule another 80-16 words in the array W */
- for(; t<80; t++) {
- W[t] = ROL32(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1);
- }
-
- /*
- // update hash
- */
- {
- /* init A, B, C, D, E by the the input hash */
- Ipp32u A = digest[0];
- Ipp32u B = digest[1];
- Ipp32u C = digest[2];
- Ipp32u D = digest[3];
- Ipp32u E = digest[4];
-
- #if defined(_ALG_SHA1_COMPACT_)
- /* steps 0-79 */
- for(t=0; t<80; t++)
- COMPACT_SHA1_STEP(A,B,C,D,E, MagicFun, W, SHA1_cnt_loc, t);
-
- #else
- /* perform 0-19 steps */
- for(t=0; t<20; t+=5) {
- SHA1_STEP(A,B,C,D,E, MAGIC_F0, W[t ],SHA1_cnt_loc[0]);
- SHA1_STEP(E,A,B,C,D, MAGIC_F0, W[t+1],SHA1_cnt_loc[0]);
- SHA1_STEP(D,E,A,B,C, MAGIC_F0, W[t+2],SHA1_cnt_loc[0]);
- SHA1_STEP(C,D,E,A,B, MAGIC_F0, W[t+3],SHA1_cnt_loc[0]);
- SHA1_STEP(B,C,D,E,A, MAGIC_F0, W[t+4],SHA1_cnt_loc[0]);
- }
- /* perform 20-39 steps */
- for(; t<40; t+=5) {
- SHA1_STEP(A,B,C,D,E, MAGIC_F1, W[t ],SHA1_cnt_loc[1]);
- SHA1_STEP(E,A,B,C,D, MAGIC_F1, W[t+1],SHA1_cnt_loc[1]);
- SHA1_STEP(D,E,A,B,C, MAGIC_F1, W[t+2],SHA1_cnt_loc[1]);
- SHA1_STEP(C,D,E,A,B, MAGIC_F1, W[t+3],SHA1_cnt_loc[1]);
- SHA1_STEP(B,C,D,E,A, MAGIC_F1, W[t+4],SHA1_cnt_loc[1]);
- }
- /* perform 40-59 steps */
- for(; t<60; t+=5) {
- SHA1_STEP(A,B,C,D,E, MAGIC_F2, W[t ],SHA1_cnt_loc[2]);
- SHA1_STEP(E,A,B,C,D, MAGIC_F2, W[t+1],SHA1_cnt_loc[2]);
- SHA1_STEP(D,E,A,B,C, MAGIC_F2, W[t+2],SHA1_cnt_loc[2]);
- SHA1_STEP(C,D,E,A,B, MAGIC_F2, W[t+3],SHA1_cnt_loc[2]);
- SHA1_STEP(B,C,D,E,A, MAGIC_F2, W[t+4],SHA1_cnt_loc[2]);
- }
- /* perform 60-79 steps */
- for(; t<80; t+=5) {
- SHA1_STEP(A,B,C,D,E, MAGIC_F3, W[t ],SHA1_cnt_loc[3]);
- SHA1_STEP(E,A,B,C,D, MAGIC_F3, W[t+1],SHA1_cnt_loc[3]);
- SHA1_STEP(D,E,A,B,C, MAGIC_F3, W[t+2],SHA1_cnt_loc[3]);
- SHA1_STEP(C,D,E,A,B, MAGIC_F3, W[t+3],SHA1_cnt_loc[3]);
- SHA1_STEP(B,C,D,E,A, MAGIC_F3, W[t+4],SHA1_cnt_loc[3]);
- }
- #endif
-
- /* update digest */
- digest[0] += A;
- digest[1] += B;
- digest[2] += C;
- digest[3] += D;
- digest[4] += E;
- }
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha256px.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha256px.c
deleted file mode 100644
index 932b9cb335..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha256px.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*
-// SHA256 Specific Macros (reference proposal 256-384-512)
-*/
-#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
-#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-
-#define SUM0(x) (ROR32((x), 2) ^ ROR32((x),13) ^ ROR32((x),22))
-#define SUM1(x) (ROR32((x), 6) ^ ROR32((x),11) ^ ROR32((x),25))
-
-#define SIG0(x) (ROR32((x), 7) ^ ROR32((x),18) ^ LSR32((x), 3))
-#define SIG1(x) (ROR32((x),17) ^ ROR32((x),19) ^ LSR32((x),10))
-
-#define SHA256_UPDATE(i) \
- wdat[i & 15] += SIG1(wdat[(i+14)&15]) + wdat[(i+9)&15] + SIG0(wdat[(i+1)&15])
-
-#define SHA256_STEP(i,j) \
- v[(7 - i) & 7] += (j ? SHA256_UPDATE(i) : wdat[i&15]) \
- + SHA256_cnt_loc[i + j] \
- + SUM1(v[(4-i)&7]) \
- + CH(v[(4-i)&7], v[(5-i)&7], v[(6-i)&7]); \
- v[(3-i)&7] += v[(7-i)&7]; \
- v[(7-i)&7] += SUM0(v[(0-i)&7]) + MAJ(v[(0-i)&7], v[(1-i)&7], v[(2-i)&7])
-
-#define COMPACT_SHA256_STEP(A,B,C,D,E,F,G,H, W,K, r) { \
- Ipp32u _T1 = (H) + SUM1((E)) + CH((E),(F),(G)) + (W)[(r)] + (K)[(r)]; \
- Ipp32u _T2 = SUM0((A)) + MAJ((A),(B),(C)); \
- (H) = (G); \
- (G) = (F); \
- (F) = (E); \
- (E) = (D)+_T1; \
- (D) = (C); \
- (C) = (B); \
- (B) = (A); \
- (A) = _T1+_T2; \
-}
-
-/*F*
-// Name: UpdateSHA256
-//
-// Purpose: Update internal hash according to input message stream.
-//
-// Parameters:
-// uniHash pointer to in/out hash
-// mblk pointer to message stream
-// mlen message stream length (multiple by message block size)
-// uniParam pointer to the optional parameter
-//
-*F*/
-#if defined(_ALG_SHA256_COMPACT_)
-#pragma message("SHA256 compact")
-
-void UpdateSHA256(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam)
-{
- Ipp32u* data = (Ipp32u*)mblk;
-
- Ipp32u* digest = (Ipp32u*)uniHash;
- Ipp32u* SHA256_cnt_loc = (Ipp32u*)uniParam;
-
- for(; mlen>=MBS_SHA256; data += MBS_SHA256/sizeof(Ipp32u), mlen -= MBS_SHA256) {
- int t;
-
- /*
- // expand message block
- */
- Ipp32u W[64];
- /* initialize the first 16 words in the array W (remember about endian) */
- for(t=0; t<16; t++) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- W[t] = data[t];
- #else
- W[t] = ENDIANNESS( data[t] );
- #endif
- }
- for(; t<64; t++)
- W[t] = SIG1(W[t-2]) + W[t-7] + SIG0(W[t-15]) + W[t-16];
-
- /*
- // update hash
- */
- {
- /* init A, B, C, D, E, F, G, H by the input hash */
- Ipp32u A = digest[0];
- Ipp32u B = digest[1];
- Ipp32u C = digest[2];
- Ipp32u D = digest[3];
- Ipp32u E = digest[4];
- Ipp32u F = digest[5];
- Ipp32u G = digest[6];
- Ipp32u H = digest[7];
-
- for(t=0; t<64; t++)
- COMPACT_SHA256_STEP(A,B,C,D,E,F,G,H, W,SHA256_cnt_loc, t);
-
- /* update hash*/
- digest[0] += A;
- digest[1] += B;
- digest[2] += C;
- digest[3] += D;
- digest[4] += E;
- digest[5] += F;
- digest[6] += G;
- digest[7] += H;
- }
- }
-}
-
-#else
-void UpdateSHA256(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniParam)
-{
- Ipp32u* data = (Ipp32u*)mblk;
-
- Ipp32u* digest = (Ipp32u*)uniHash;
- Ipp32u* SHA256_cnt_loc = (Ipp32u*)uniParam;
-
- for(; mlen>=MBS_SHA256; data += MBS_SHA256/sizeof(Ipp32u), mlen -= MBS_SHA256) {
- Ipp32u wdat[16];
- int j;
-
- /* copy digest */
- Ipp32u v[8];
- CopyBlock(digest, v, IPP_SHA256_DIGEST_BITSIZE/BYTESIZE);
-
- /* initialize the first 16 words in the array W (remember about endian) */
- for(j=0; j<16; j++) {
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- wdat[j] = data[j];
- #else
- wdat[j] = ENDIANNESS( data[j] );
- #endif
- }
-
- for(j=0; j<64; j+=16) {
- SHA256_STEP( 0, j);
- SHA256_STEP( 1, j);
- SHA256_STEP( 2, j);
- SHA256_STEP( 3, j);
- SHA256_STEP( 4, j);
- SHA256_STEP( 5, j);
- SHA256_STEP( 6, j);
- SHA256_STEP( 7, j);
- SHA256_STEP( 8, j);
- SHA256_STEP( 9, j);
- SHA256_STEP(10, j);
- SHA256_STEP(11, j);
- SHA256_STEP(12, j);
- SHA256_STEP(13, j);
- SHA256_STEP(14, j);
- SHA256_STEP(15, j);
- }
-
- /* update digest */
- digest[0] += v[0];
- digest[1] += v[1];
- digest[2] += v[2];
- digest[3] += v[3];
- digest[4] += v[4];
- digest[5] += v[5];
- digest[6] += v[6];
- digest[7] += v[7];
- }
-}
-#endif
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha512px.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha512px.c
deleted file mode 100644
index 6b8983d467..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphashsha512px.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*
-// SHA512 Specific Macros (reference proposal 256-384-512)
-//
-// Note: All operations act on DWORDs (64-bits)
-*/
-#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
-#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-
-#define SUM0(x) (ROR64((x),28) ^ ROR64((x),34) ^ ROR64((x),39))
-#define SUM1(x) (ROR64((x),14) ^ ROR64((x),18) ^ ROR64((x),41))
-
-#define SIG0(x) (ROR64((x), 1) ^ ROR64((x), 8) ^ LSR64((x), 7))
-#define SIG1(x) (ROR64((x),19) ^ ROR64((x),61) ^ LSR64((x), 6))
-
-#define SHA512_UPDATE(i) \
- wdat[i&15] += SIG1(wdat[(i+14)&15]) + wdat[(i+9)&15] + SIG0(wdat[(i+1)&15])
-
-#define SHA512_STEP(i,j) \
- v[(7-i)&7] += (j ? SHA512_UPDATE(i) : wdat[i&15]) \
- + SHA512_cnt_loc[i+j] \
- + SUM1(v[(4-i)&7]) \
- + CH(v[(4-i)&7], v[(5-i)&7], v[(6-i)&7]); \
- v[(3-i)&7] += v[(7-i)&7]; \
- v[(7-i)&7] += SUM0(v[(0-i)&7]) + MAJ(v[(0-i)&7], v[(1-i)&7], v[(2-i)&7])
-
-#define COMPACT_SHA512_STEP(A,B,C,D,E,F,G,H, W,K, r) { \
- Ipp64u _T1 = (H) + SUM1((E)) + CH((E),(F),(G)) + (W)[(r)] + (K)[(r)]; \
- Ipp64u _T2 = SUM0((A)) + MAJ((A),(B),(C)); \
- (H) = (G); \
- (G) = (F); \
- (F) = (E); \
- (E) = (D)+_T1; \
- (D) = (C); \
- (C) = (B); \
- (B) = (A); \
- (A) = _T1+_T2; \
-}
-
-/*F*
-// Name: UpdateSHA512
-//
-// Purpose: Update internal hash according to input message stream.
-//
-// Parameters:
-// uniHash pointer to in/out hash
-// mblk pointer to message stream
-// mlen message stream length (multiple by message block size)
-// uniParam pointer to the optional parameter
-//
-*F*/
-#if defined(_ALG_SHA512_COMPACT_)
-#pragma message("SHA512 compact")
-
-void UpdateSHA512(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniPraram)
-{
- Ipp32u* data = (Ipp32u*)mblk;
-
- Ipp64u* digest = (Ipp64u*)uniHash;
- Ipp64u* SHA512_cnt_loc = (Ipp64u*)uniPraram;
-
-
- for(; mlen>=MBS_SHA512; data += MBS_SHA512/sizeof(Ipp32u), mlen -= MBS_SHA512) {
- int t;
- Ipp64u W[80];
-
- /*
- // expand message block
- */
- /* initialize the first 16 words in the array W (remember about endian) */
- for(t=0; t<16; t++) {
- Ipp32u hiX = data[2*t];
- Ipp32u loX = data[2*t+1];
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- W[t] = MAKEDWORD(loX, hiX);
- #else
- W[t] = MAKEDWORD( ENDIANNESS(loX), ENDIANNESS(hiX) );
- #endif
- }
- for(; t<80; t++)
- W[t] = SIG1(W[t-2]) + W[t-7] + SIG0(W[t-15]) + W[t-16];
-
- /*
- // update hash
- */
- {
- /* init A, B, C, D, E, F, G, H by the input hash */
- Ipp64u A = digest[0];
- Ipp64u B = digest[1];
- Ipp64u C = digest[2];
- Ipp64u D = digest[3];
- Ipp64u E = digest[4];
- Ipp64u F = digest[5];
- Ipp64u G = digest[6];
- Ipp64u H = digest[7];
-
- for(t=0; t<80; t++)
- COMPACT_SHA512_STEP(A,B,C,D,E,F,G,H, W,SHA512_cnt_loc, t);
-
- /* update hash*/
- digest[0] += A;
- digest[1] += B;
- digest[2] += C;
- digest[3] += D;
- digest[4] += E;
- digest[5] += F;
- digest[6] += G;
- digest[7] += H;
- }
- }
-}
-
-#else
-void UpdateSHA512(void* uniHash, const Ipp8u* mblk, int mlen, const void* uniPraram)
-{
- Ipp32u* data = (Ipp32u*)mblk;
-
- Ipp64u* digest = (Ipp64u*)uniHash;
- Ipp64u* SHA512_cnt_loc = (Ipp64u*)uniPraram;
-
- for(; mlen>=MBS_SHA512; data += MBS_SHA512/sizeof(Ipp32u), mlen -= MBS_SHA512) {
- Ipp64u wdat[16];
- int j;
-
- Ipp64u v[8];
-
- /* initialize the first 16 words in the array W (remember about endian) */
- for(j=0; j<16; j++) {
- Ipp32u hiX = data[2*j];
- Ipp32u loX = data[2*j+1];
- #if (IPP_ENDIAN == IPP_BIG_ENDIAN)
- wdat[j] = MAKEDWORD(loX, hiX);
- #else
- wdat[j] = MAKEDWORD( ENDIANNESS(loX), ENDIANNESS(hiX) );
- #endif
- }
-
- /* copy digest */
- CopyBlock(digest, v, IPP_SHA512_DIGEST_BITSIZE/BYTESIZE);
-
- for(j=0; j<80; j+=16) {
- SHA512_STEP( 0, j);
- SHA512_STEP( 1, j);
- SHA512_STEP( 2, j);
- SHA512_STEP( 3, j);
- SHA512_STEP( 4, j);
- SHA512_STEP( 5, j);
- SHA512_STEP( 6, j);
- SHA512_STEP( 7, j);
- SHA512_STEP( 8, j);
- SHA512_STEP( 9, j);
- SHA512_STEP(10, j);
- SHA512_STEP(11, j);
- SHA512_STEP(12, j);
- SHA512_STEP(13, j);
- SHA512_STEP(14, j);
- SHA512_STEP(15, j);
- }
-
- /* update digest */
- digest[0] += v[0];
- digest[1] += v[1];
- digest[2] += v[2];
- digest[3] += v[3];
- digest[4] += v[4];
- digest[5] += v[5];
- digest[6] += v[6];
- digest[7] += v[7];
- }
-}
-#endif
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmac.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmac.h
deleted file mode 100644
index 65374dbb87..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmac.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_HMAC_H)
-#define _PCP_HMAC_H
-
-#include "pcphash.h"
-
-/*
-// HMAC context
-*/
-struct _cpHMAC {
- IppCtxId idCtx; /* HMAC identifier */
- Ipp8u ipadKey[MBS_HASH_MAX]; /* inner padding key */
- Ipp8u opadKey[MBS_HASH_MAX]; /* outer padding key */
- IppsHashState hashCtx; /* hash context */
-};
-
-/* accessors */
-#define HMAC_CTX_ID(stt) ((stt)->idCtx)
-#define HASH_CTX(stt) ((stt)->hashCtx)
-#define HMAC_VALID_ID(stt) (HMAC_CTX_ID((stt))==idCtxHMAC)
-
-#define IPAD (0x36) /* inner padding value */
-#define OPAD (0x5C) /* outer padding value */
-
-#endif /* _PCP_HMAC_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmacca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmacca.c
deleted file mode 100644
index 524d26f49b..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcphmacca.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphmac.h"
-#include "pcptool.h"
-
-/*F*
-// Name: ippsHMAC_GetSize
-//
-// Purpose: Returns size of HMAC state (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSzie == NULL
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSize pointer to the HMAC state size
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_GetSize,(int* pSize))
-{
- /* test size's pointer */
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsHMACState);
- return ippStsNoErr;
-}
-
-/*F*
-// Name: ippsHMAC_Init
-//
-// Purpose: Init HMAC state.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pKey == NULL
-// pState == NULL
-// ippStsLengthErr keyLen <0
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pKey pointer to the secret key
-// keyLen length (bytes) of the secret key
-// pState pointer to the HMAC state
-// hashAlg hash alg ID
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_Init,(const Ipp8u* pKey, int keyLen, IppsHMACState* pCtx, IppHashAlgId hashAlg))
-{
- //int mbs;
-
- /* get algorithm id */
- hashAlg = cpValidHashAlg(hashAlg);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
- //mbs = cpHashMBS(hashAlg);
-
- /* test pState pointer */
- IPP_BAD_PTR1_RET(pCtx);
-
- /* test key pointer and key length */
- IPP_BAD_PTR1_RET(pKey);
- IPP_BADARG_RET(0>keyLen, ippStsLengthErr);
-
- /* set state ID */
- HMAC_CTX_ID(pCtx) = idCtxHMAC;
-
- /* init hash context */
- ippsHashInit(&HASH_CTX(pCtx), hashAlg);
-
- {
- int n;
-
- /* hash specific */
- IppsHashState* pHashCtx = &HASH_CTX(pCtx);
- int mbs = cpHashMBS(hashAlg);
- int hashSize = cpHashSize(hashAlg);
-
- /* copyMask = keyLen>mbs? 0xFF : 0x00 */
- int copyMask = (mbs-keyLen) >>(BITSIZE(int)-1);
-
- /* actualKeyLen = keyLen>mbs? hashSize:keyLen */
- int actualKeyLen = (hashSize & copyMask) | (keyLen & ~copyMask);
-
- /* compute hash(key, keyLen) just in case */
- ippsHashUpdate(pKey, keyLen, pHashCtx);
- ippsHashFinal(HASH_BUFF(pHashCtx), pHashCtx);
-
- /* copy either key or hash(key) into ipad- and opad- buffers */
- MASKED_COPY_BNU(pCtx->ipadKey, (Ipp8u)copyMask, HASH_BUFF(pHashCtx), pKey, actualKeyLen);
- MASKED_COPY_BNU(pCtx->opadKey, (Ipp8u)copyMask, HASH_BUFF(pHashCtx), pKey, actualKeyLen);
-
- /* XOR-ing key */
- for(n=0; nipadKey[n] ^= (Ipp8u)IPAD;
- pCtx->opadKey[n] ^= (Ipp8u)OPAD;
- }
- for(; nipadKey[n] = (Ipp8u)IPAD;
- pCtx->opadKey[n] = (Ipp8u)OPAD;
- }
-
- /* ipad key processing */
- ippsHashUpdate(pCtx->ipadKey, mbs, pHashCtx);
-
- return ippStsNoErr;
- }
-}
-
-/*F*
-// Name: ippsHMAC_Update
-//
-// Purpose: Updates intermadiate MAC based on input stream.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pSrc == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxHMAC
-// ippStsLengthErr len <0
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSrc pointer to the input stream
-// len input stream length
-// pState pointer to the HMAC state
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_Update,(const Ipp8u* pSrc, int len, IppsHMACState* pCtx))
-{
- /* test state pointers */
- IPP_BAD_PTR1_RET(pCtx);
-
- /* test state ID */
- IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr);
- /* test input length */
- IPP_BADARG_RET((len<0), ippStsLengthErr);
- /* test source pointer */
- IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr);
-
- if(len)
- return ippsHashUpdate(pSrc, len, &HASH_CTX(pCtx));
- else
- return ippStsNoErr;
-}
-
-/*F*
-// Name: ippsHMAC_Final
-//
-// Purpose: Stop message digesting and return digest.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxHMAC
-// ippStsLengthErr sizeof(DigestMD5) < mdLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// pState pointer to the HMAC state
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_Final,(Ipp8u* pMD, int mdLen, IppsHMACState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr);
-
- /* test MD pointer and length */
- IPP_BAD_PTR1_RET(pMD);
- IPP_BADARG_RET(mdLen<=0, ippStsLengthErr);
-
- {
- /* hash specific */
- IppsHashState* pHashCtx = &HASH_CTX(pCtx);
- int mbs = cpHashMBS(HASH_ALG_ID(pHashCtx));
- int hashSize = cpHashSize(HASH_ALG_ID(pHashCtx));
- if(mdLen>hashSize)
- IPP_ERROR_RET(ippStsLengthErr);
-
- /*
- // finalize hmac
- */
- {
- /* finalize 1-st step */
- Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/8];
- IppStatus sts = ippsHashFinal(md, pHashCtx);
-
- if(ippStsNoErr==sts) {
- /* perform outer hash */
- ippsHashUpdate(pCtx->opadKey, mbs, pHashCtx);
- ippsHashUpdate(md, hashSize, pHashCtx);
-
- /* complete HMAC */
- ippsHashFinal(md, pHashCtx);
- CopyBlock(md, pMD, IPP_MIN(hashSize, mdLen));
-
- /* ready to the next HMAC computation */
- ippsHashUpdate(pCtx->ipadKey, mbs, pHashCtx);
- }
-
- return sts;
- }
- }
-}
-
-/*F*
-// Name: ippsHMAC_GetTag
-//
-// Purpose: Compute digest with further digesting ability.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMD == NULL
-// pState == NULL
-// ippStsContextMatchErr pState->idCtx != idCtxHMAC
-// ippStsLengthErr size_of_digest < mdLen <1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMD address of the output digest
-// mdLen length of the digest
-// pState pointer to the HMAC state
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_GetTag,(Ipp8u* pMD, int mdLen, const IppsHMACState* pCtx))
-{
- /* test state pointer and ID */
- IPP_BAD_PTR1_RET(pCtx);
- IPP_BADARG_RET(!HMAC_VALID_ID(pCtx), ippStsContextMatchErr);
-
- /* test MD pointer */
- IPP_BAD_PTR1_RET(pMD);
-
- {
- IppsHMACState tmpCtx;
- CopyBlock(pCtx, &tmpCtx, sizeof(IppsHMACState));
- return ippsHMAC_Final(pMD, mdLen, &tmpCtx);
- }
-}
-
-/*F*
-// Name: ippsHMAC_Message
-//
-// Purpose: MAC of the whole message.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMsg == NULL
-// pKey == NULL
-// pMD == NULL
-// ippStsLengthErr msgLen <0
-// keyLen <0
-// size_of_digest < mdLen <1
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pMsg pointer to the input message
-// msgLen input message length
-// pKey pointer to the secret key
-// keyLen secret key length
-// pMD pointer to message digest
-// mdLen MD length
-// hashAlg hash alg ID
-//
-*F*/
-IPPFUN(IppStatus, ippsHMAC_Message,(const Ipp8u* pMsg, int msgLen,
- const Ipp8u* pKey, int keyLen,
- Ipp8u* pMD, int mdLen,
- IppHashAlgId hashAlg))
-{
- /* get algorithm id */
- hashAlg = cpValidHashAlg(hashAlg);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
-
- /* test secret key pointer and length */
- IPP_BAD_PTR1_RET(pKey);
- IPP_BADARG_RET((keyLen<0), ippStsLengthErr);
-
- /* test input message pointer and length */
- IPP_BADARG_RET((msgLen<0), ippStsLengthErr);
- IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr);
-
- /* test MD pointer and length */
- IPP_BAD_PTR1_RET(pMD);
- IPP_BADARG_RET(0>=mdLen || mdLen>cpHashSize(hashAlg), ippStsLengthErr);
-
- {
- IppsHMACState ctx;
- IppStatus sts = ippsHMAC_Init(pKey, keyLen, &ctx, hashAlg);
- if(ippStsNoErr!=sts) goto exit;
-
- sts = ippsHashUpdate(pMsg,msgLen, &HASH_CTX(&ctx));
- if(ippStsNoErr!=sts) goto exit;
-
- sts = ippsHMAC_Final(pMD, mdLen, &ctx);
-
- exit:
- PurgeBlock(&ctx, sizeof(IppsHMACState));
- return sts;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c
deleted file mode 100644
index fdc43b5127..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontexpbinca.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-
-
-/*
-// Binary method of Exponentiation
-*/
-cpSize cpMontExpBin_BNU(BNU_CHUNK_T* dataY,
- const BNU_CHUNK_T* dataX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- IppsMontState* pMont)
-{
- cpSize nsM = MNT_SIZE(pMont);
-
- /*
- // test for special cases:
- // x^0 = 1
- // 0^e = 0
- */
- if( cpEqu_BNU_CHUNK(dataE, nsE, 0) ) {
- COPY_BNU(dataY, MNT_1(pMont), nsM);
- }
- else if( cpEqu_BNU_CHUNK(dataX, nsX, 0) ) {
- ZEXPAND_BNU(dataY, 0, nsM);
- }
-
- /* general case */
- else {
- BNU_CHUNK_T* dataM = MNT_MODULUS(pMont);
- BNU_CHUNK_T m0 = MNT_HELPER(pMont);
-
- /* Montgomery engine buffers */
- BNU_CHUNK_T* pKBuffer = MNT_KBUFFER(pMont);
- BNU_CHUNK_T* pProduct = MNT_PRODUCT(pMont);
-
- BNU_CHUNK_T* dataT = MNT_TBUFFER(pMont);
-
- /* execute most significant part pE */
- BNU_CHUNK_T eValue = dataE[nsE-1];
- int n = cpNLZ_BNU(eValue)+1;
-
- /* expand base and init result */
- ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX);
- COPY_BNU(dataY, dataT, nsM);
-
- eValue <<= n;
- for(; n0; nsE--) {
- eValue = dataE[nsE-1];
-
- for(n=0; nidCtx)
-#define MNT_ROOM(eng) ((eng)->maxLen)
-#define MNT_SIZE(eng) ((eng)->modLen)
-#define MNT_HELPER(eng) ((eng)->m0)
-#define MNT_MODULUS(eng) ((eng)->pModulus)
-#define MNT_1(eng) ((eng)->pIdentity)
-#define MNT_IDENT_R(eng) (MNT_1((eng)))
-#define MNT_SQUARE_R(eng) ((eng)->pSquare)
-#define MNT_CUBE_R(eng) ((eng)->pCube)
-#define MNT_TBUFFER(eng) ((eng)->pTBuffer)
-#define MNT_SBUFFER(eng) ((eng)->pSBuffer)
-#define MNT_PRODUCT(eng) ((eng)->pProduct)
-#define MNT_KBUFFER(eng) ((eng)->pKBuffer)
-
-#define MNT_VALID_ID(eng) (MNT_ID((eng))==idCtxMontgomery)
-
-/* default methos */
-#define EXPONENT_METHOD (ippBinaryMethod)
-
-/* alignment */
-#define MONT_ALIGNMENT ((int)(sizeof(void*)))
-
-
-/*
-// Pacp/unpack Montgomery context
-*/
-void cpPackMontCtx(const IppsMontState* pCtx, Ipp8u* pBuffer);
-void cpUnpackMontCtx(const Ipp8u* pBuffer, IppsMontState* pCtx);
-
-
-/*
-// Montgomery reduction, multiplication and squaring
-*/
-void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0);
-
-__INLINE void cpMontRed_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
-{
- cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0);
-}
-
-__INLINE void cpMontMul_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pX, cpSize nsX,
- const BNU_CHUNK_T* pY, cpSize nsY,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0,
- BNU_CHUNK_T* pProduct, BNU_CHUNK_T* pKBuffer)
-{
- cpMul_BNU(pProduct, pX,nsX, pY,nsY, pKBuffer);
- ZEXPAND_BNU(pProduct,nsX+nsY, 2*nsM);
- cpMontRed_BNU(pR, pProduct, pModulus, nsM, m0);
-}
-
-__INLINE void cpMontSqr_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pX, cpSize nsX,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0,
- BNU_CHUNK_T* pProduct, BNU_CHUNK_T* pKBuffer)
-{
- cpSqr_BNU(pProduct, pX,nsX, pKBuffer);
- ZEXPAND_BNU(pProduct, 2*nsX, 2*nsM);
- cpMontRed_BNU(pR, pProduct, pModulus, nsM, m0);
-}
-
-/*
-// Montgomery encoding/decoding
-*/
-__INLINE cpSize cpMontEnc_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pXreg, cpSize nsX,
- IppsMontState* pMont)
-{
- cpSize nsM = MNT_SIZE(pMont);
- cpMontMul_BNU(pR,
- pXreg, nsX, MNT_SQUARE_R(pMont), nsM,
- MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont),
- MNT_PRODUCT(pMont), MNT_KBUFFER(pMont));
-
- FIX_BNU(pR, nsM);
- return nsM;
-}
-
-__INLINE cpSize cpMontDec_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pXmont, cpSize nsX,
- IppsMontState* pMont)
-{
- cpSize nsM = MNT_SIZE(pMont);
- ZEXPAND_COPY_BNU(MNT_PRODUCT(pMont), 2*nsM, pXmont, nsX);
-
- cpMontRed_BNU(pR, MNT_PRODUCT(pMont), MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont));
-
- FIX_BNU(pR, nsM);
- return nsM;
-}
-
-__INLINE void cpMontEnc_BN(IppsBigNumState* pRbn,
- const IppsBigNumState* pXbn,
- IppsMontState* pMont)
-{
- BNU_CHUNK_T* pR = BN_NUMBER(pRbn);
- cpSize nsM = MNT_SIZE(pMont);
- cpMontMul_BNU(pR,
- BN_NUMBER(pXbn), BN_SIZE(pXbn),
- MNT_SQUARE_R(pMont), nsM,
- MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont),
- MNT_PRODUCT(pMont), MNT_KBUFFER(pMont));
-
- FIX_BNU(pR, nsM);
- BN_SIZE(pRbn) = nsM;
- BN_SIGN(pRbn) = ippBigNumPOS;
-}
-
-__INLINE void cpMontDec_BN(IppsBigNumState* pRbn,
- const IppsBigNumState* pXbn,
- IppsMontState* pMont)
-{
- BNU_CHUNK_T* pR = BN_NUMBER(pRbn);
- cpSize nsM = MNT_SIZE(pMont);
- ZEXPAND_COPY_BNU(MNT_PRODUCT(pMont), 2*nsM, BN_NUMBER(pXbn), BN_SIZE(pXbn));
-
- cpMontRed_BNU(pR, MNT_PRODUCT(pMont), MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont));
-
- FIX_BNU(pR, nsM);
- BN_SIZE(pRbn) = nsM;
- BN_SIGN(pRbn) = ippBigNumPOS;
-}
-
-/*
-// Montgomery exponentiation (binary)
-*/
-cpSize cpMontExpBin_BNU(BNU_CHUNK_T* pY,
- const BNU_CHUNK_T* pX, cpSize nsX,
- const BNU_CHUNK_T* pE, cpSize nsE,
- IppsMontState* pMont);
-
-#endif /* _CP_MONTGOMETRY_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c
deleted file mode 100644
index 8459fd0249..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontgomeryca.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-#include "pcptool.h"
-
-/*F*
-// Name: ippsMontGetSize
-//
-// Purpose: Specifies size of buffer in bytes.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pCtxSize==NULL
-// ippStsLengthErr maxLen32 < 1
-// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// method selected exponential method (unused parameter)
-// maxLen32 max modulus length (in Ipp32u chunks)
-// pCtxSize size of context
-//
-// Notes: Function always use method=ippBinaryMethod,
-// so this parameter is ignored
-*F*/
-IPPFUN(IppStatus, ippsMontGetSize, (IppsExpMethod method, cpSize maxLen32, cpSize* pCtxSize))
-{
- IPP_BAD_PTR1_RET(pCtxSize);
- IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- UNREFERENCED_PARAMETER(method);
-
- {
- /* convert modulus length to the number of BNU_CHUNK_T */
- cpSize modSize = INTERNAL_BNU_LENGTH(maxLen32);
-
- *pCtxSize= sizeof(IppsMontState)
- + modSize*sizeof(BNU_CHUNK_T) /* modulus */
- + modSize*sizeof(BNU_CHUNK_T) /* identity */
- + modSize*sizeof(BNU_CHUNK_T) /* square R */
- + modSize*sizeof(BNU_CHUNK_T) /* cube R */
- + modSize*sizeof(BNU_CHUNK_T) /* internal buffer */
- + modSize*sizeof(BNU_CHUNK_T) /* internal sscm buffer */
- + modSize*sizeof(BNU_CHUNK_T)*2 /* internal product */
- + MONT_ALIGNMENT-1;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsMontInit
-//
-// Purpose: Initializes the symbolic data structure and partitions the
-// specified buffer space.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// ippStsLengthErr maxLen32 < 1
-// maxLen32 > BITS2WORD32_SIZE(BN_MAXBITSIZE)
-// ippStsNoErr no errors
-//
-// Parameters:
-// method selected exponential method (unused parameter)
-// maxLen32 max modulus length (in Ipp32u chunks)
-// pMont pointer to Montgomery context
-*F*/
-IPPFUN(IppStatus, ippsMontInit,(IppsExpMethod method, int maxLen32, IppsMontState* pMont))
-{
- IPP_BADARG_RET(maxLen32<1 || maxLen32>BITS2WORD32_SIZE(BN_MAXBITSIZE), ippStsLengthErr);
-
- IPP_BAD_PTR1_RET(pMont);
- pMont = (IppsMontState*)( IPP_ALIGNED_PTR(pMont, MONT_ALIGNMENT) );
-
- UNREFERENCED_PARAMETER(method);
-
- MNT_ID(pMont) = idCtxUnknown;
- MNT_ROOM(pMont) = INTERNAL_BNU_LENGTH(maxLen32);
- MNT_SIZE(pMont) = 0;
- MNT_HELPER(pMont) = 0;
-
- {
- Ipp8u* ptr = (Ipp8u*)pMont;
-
- /* convert modulus length to the number of BNU_CHUNK_T */
- cpSize modSize = MNT_ROOM(pMont);
-
- /* assign internal buffers */
- MNT_MODULUS(pMont) = (BNU_CHUNK_T*)( ptr += sizeof(IppsMontState) );
-
- MNT_1(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
- MNT_SQUARE_R(pMont)= (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
- MNT_CUBE_R(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
-
- MNT_TBUFFER(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
- MNT_SBUFFER(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
- MNT_PRODUCT(pMont) = (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T) );
- MNT_KBUFFER(pMont) = (BNU_CHUNK_T*)NULL;
-
- /* init internal buffers */
- ZEXPAND_BNU(MNT_MODULUS(pMont), 0, modSize);
- ZEXPAND_BNU(MNT_1(pMont), 0, modSize);
- ZEXPAND_BNU(MNT_SQUARE_R(pMont), 0, modSize);
- ZEXPAND_BNU(MNT_CUBE_R(pMont), 0, modSize);
-
- MNT_ID(pMont) = idCtxMontgomery;
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsMontSet
-//
-// Purpose: Setup modulus value
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMont==NULL
-// pModulus==NULL
-// ippStsContextMatchErr !MNT_VALID_ID()
-// ippStsLengthErr len32<1
-// ippStsNoErr no errors
-//
-// Parameters:
-// pModulus pointer to the modulus buffer
-// len32 length of the modulus (in Ipp32u chunks).
-// pMont pointer to the context
-*F*/
-static BNU_CHUNK_T cpMontHelper(BNU_CHUNK_T m0)
-{
- BNU_CHUNK_T y = 1;
- BNU_CHUNK_T x = 2;
- BNU_CHUNK_T mask = 2*x-1;
-
- int i;
- for(i=2; i<=BNU_CHUNK_BITS; i++, x<<=1) {
- BNU_CHUNK_T rH, rL;
- MUL_AB(rH, rL, m0, y);
- if( x < (rL & mask) ) /* x < ((m0*y) mod (2*x)) */
- y+=x;
- mask += mask + 1;
- }
- return 0-y;
-}
-
-IPPFUN(IppStatus, ippsMontSet,(const Ipp32u* pModulus, cpSize len32, IppsMontState* pMont))
-{
- IPP_BAD_PTR2_RET(pModulus, pMont);
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
-
- IPP_BADARG_RET(len32<1, ippStsLengthErr);
-
- /* modulus is not an odd number */
- IPP_BADARG_RET((pModulus[0] & 1) == 0, ippStsBadModulusErr);
- IPP_BADARG_RET(MNT_ROOM(pMont)<(int)(INTERNAL_BNU_LENGTH(len32)), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T m0;
- cpSize len;
-
- /* fix input modulus */
- FIX_BNU(pModulus, len32);
-
- /* store modulus */
- ZEXPAND_BNU(MNT_MODULUS(pMont), 0, MNT_ROOM(pMont));
- COPY_BNU((Ipp32u*)(MNT_MODULUS(pMont)), pModulus, len32);
- /* store modulus length */
- len = INTERNAL_BNU_LENGTH(len32);
- MNT_SIZE(pMont) = len;
-
- /* pre-compute helper m0, m0*m = -1 mod R */
- m0 = cpMontHelper(MNT_MODULUS(pMont)[0]);
- MNT_HELPER(pMont) = m0;
-
- /* setup identity */
- ZEXPAND_BNU(MNT_1(pMont), 0, len);
- MNT_1(pMont)[len] = 1;
- cpMod_BNU(MNT_1(pMont), len+1, MNT_MODULUS(pMont), len);
-
- /* setup square */
- ZEXPAND_BNU(MNT_SQUARE_R(pMont), 0, len);
- COPY_BNU(MNT_SQUARE_R(pMont)+len, MNT_1(pMont), len);
- cpMod_BNU(MNT_SQUARE_R(pMont), 2*len, MNT_MODULUS(pMont), len);
-
- /* setup cube */
- ZEXPAND_BNU(MNT_CUBE_R(pMont), 0, len);
- COPY_BNU(MNT_CUBE_R(pMont)+len, MNT_SQUARE_R(pMont), len);
- cpMod_BNU(MNT_CUBE_R(pMont), 2*len, MNT_MODULUS(pMont), len);
-
- /* clear buffers */
- ZEXPAND_BNU(MNT_TBUFFER(pMont), 0, len);
- ZEXPAND_BNU(MNT_SBUFFER(pMont), 0, len);
- ZEXPAND_BNU(MNT_PRODUCT(pMont), 0, 2*len);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsMontMul
-//
-// Purpose: Computes Montgomery modular multiplication for positive big
-// number integers of Montgomery form. The following pseudocode
-// represents this function:
-// r <- ( a * b * R^(-1) ) mod m
-//
-// Returns: Reason:
-// ippStsNoErr Returns no error.
-// ippStsNullPtrErr Returns an error when pointers are null.
-// ippStsBadArgErr Returns an error when a or b is a negative integer.
-// ippStsScaleRangeErr Returns an error when a or b is more than m.
-// ippStsOutOfRangeErr Returns an error when IppsBigNumState *r is larger than
-// IppsMontState *m.
-// ippStsContextMatchErr Returns an error when the context parameter does
-// not match the operation.
-//
-// Parameters:
-// a Multiplicand within the range [0, m - 1].
-// b Multiplier within the range [0, m - 1].
-// m Modulus.
-// r Montgomery multiplication result.
-//
-// Notes: The size of IppsBigNumState *r should not be less than the data
-// length of the modulus m.
-*F*/
-IPPFUN(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* pMont, IppsBigNumState* pR))
-{
- IPP_BAD_PTR4_RET(pA, pB, pMont, pR);
-
- pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT));
- pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) );
- pB = (IppsBigNumState*)( IPP_ALIGNED_PTR(pB, BN_ALIGNMENT) );
- pR = (IppsBigNumState*)( IPP_ALIGNED_PTR(pR, BN_ALIGNMENT) );
-
- IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pA), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pB), ippStsContextMatchErr);
- IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr);
-
- IPP_BADARG_RET(BN_NEGATIVE(pA) || BN_NEGATIVE(pB), ippStsBadArgErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr);
- IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pB), BN_SIZE(pB), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr);
- IPP_BADARG_RET(BN_ROOM(pR) < MNT_SIZE(pMont), ippStsOutOfRangeErr);
-
- {
- BNU_CHUNK_T* pDataR = BN_NUMBER(pR);
- cpSize nsM = MNT_SIZE(pMont);
-
- cpMontMul_BNU(pDataR,
- BN_NUMBER(pA), BN_SIZE(pA),
- BN_NUMBER(pB), BN_SIZE(pB),
- MNT_MODULUS(pMont), nsM,
- MNT_HELPER(pMont),
- MNT_PRODUCT(pMont), MNT_KBUFFER(pMont));
-
- FIX_BNU(pDataR, nsM);
- BN_SIZE(pR) = nsM;
- BN_SIGN(pR) = ippBigNumPOS;
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontred.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontred.c
deleted file mode 100644
index a7851d6ec8..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpmontred.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpbnuarith.h"
-
-
-void cpMontRedAdc_BNU(BNU_CHUNK_T* pR,
- BNU_CHUNK_T* pProduct,
- const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0)
-{
- BNU_CHUNK_T carry;
- BNU_CHUNK_T extension;
-
- cpSize n;
- for(n=0, carry = 0; n<(nsM-1); n++) {
- BNU_CHUNK_T u = pProduct[n]*m0;
- BNU_CHUNK_T t = pProduct[nsM +n +1] + carry;
-
- extension = cpAddMulDgt_BNU(pProduct+n, pModulus, nsM, u);
- ADD_AB(carry, pProduct[nsM+n], pProduct[nsM+n], extension);
- t += carry;
-
- carry = tmaxbitSizeN)
-#define RSA_PUB_KEY_MAXSIZE_E(x) ((x)->maxbitSizeE)
-#define RSA_PUB_KEY_ID(x) ((x)->id)
-#define RSA_PUB_KEY_BITSIZE_N(x) ((x)->bitSizeN)
-#define RSA_PUB_KEY_BITSIZE_E(x) ((x)->bitSizeE)
-#define RSA_PUB_KEY_E(x) ((x)->pDataE)
-#define RSA_PUB_KEY_NMONT(x) ((x)->pMontN)
-#define RSA_PUB_KEY_VALID_ID(x) (RSA_PUB_KEY_ID((x))==idCtxRSA_PubKey)
-#define RSA_PUB_KEY_IS_SET(x) (RSA_PUB_KEY_BITSIZE_N((x))>0)
-
-/* alignment */
-#define RSA_PUBLIC_KEY_ALIGNMENT ((int)(sizeof(void*)))
-
-struct _cpRSA_private_key {
- IppCtxId id; /* key ID */
- int maxbitSizeN;
- int maxbitSizeD;
- int bitSizeN; /* RSA modulus bitsize */
- int bitSizeD; /* RSA private exp bitsize */
- int bitSizeP; /* RSA p-factor bitsize */
- int bitSizeQ; /* RSA q-factor bitsize */
-
- BNU_CHUNK_T* pDataD; /* private exp */
- BNU_CHUNK_T* pDataDp; /* dp private exp */
- BNU_CHUNK_T* pDataDq; /* dq private exp */
- BNU_CHUNK_T* pDataQinv; /* qinv coeff */
-
- IppsMontState* pMontP; /* montgomery engine (P) */
- IppsMontState* pMontQ; /* montgomery engine (Q) */
- IppsMontState* pMontN; /* montgomery engine (N) */
-};
-
-/* access */
-#define RSA_PRV_KEY_MAXSIZE_N(x) ((x)->maxbitSizeN)
-#define RSA_PRV_KEY_MAXSIZE_D(x) ((x)->maxbitSizeD)
-#define RSA_PRV_KEY_ID(x) ((x)->id)
-#define RSA_PRV_KEY_BITSIZE_N(x) ((x)->bitSizeN)
-#define RSA_PRV_KEY_BITSIZE_D(x) ((x)->bitSizeD)
-#define RSA_PRV_KEY_BITSIZE_P(x) ((x)->bitSizeP)
-#define RSA_PRV_KEY_BITSIZE_Q(x) ((x)->bitSizeQ)
-#define RSA_PRV_KEY_D(x) ((x)->pDataD)
-#define RSA_PRV_KEY_DP(x) ((x)->pDataDp)
-#define RSA_PRV_KEY_DQ(x) ((x)->pDataDq)
-#define RSA_PRV_KEY_INVQ(x) ((x)->pDataQinv)
-#define RSA_PRV_KEY_PMONT(x) ((x)->pMontP)
-#define RSA_PRV_KEY_QMONT(x) ((x)->pMontQ)
-#define RSA_PRV_KEY_NMONT(x) ((x)->pMontN)
-#define RSA_PRV_KEY1_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey1)
-#define RSA_PRV_KEY2_VALID_ID(x) (RSA_PRV_KEY_ID((x))==idCtxRSA_PrvKey2)
-#define RSA_PRV_KEY_VALID_ID(x) (RSA_PRV_KEY1_VALID_ID((x)) || RSA_PRV_KEY2_VALID_ID((x)))
-#define RSA_PRV_KEY_IS_SET(x) (RSA_PRV_KEY_BITSIZE_N((x))>0)
-
-/* alignment */
-#define RSA_PRIVATE_KEY_ALIGNMENT ((int)(sizeof(void*)))
-
-/* pubic and private key operations */
-void gsRSApub_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPublicKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
-void gsRSAprv_cipher(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
-void gsRSAprv_cipher_crt(IppsBigNumState* pY, const IppsBigNumState* pX, const IppsRSAPrivateKeyState* pKey, BNU_CHUNK_T* pScratchBuffer);
-
-#endif /* _CP_NG_RSA_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c
deleted file mode 100644
index 4d147ad395..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaencodec.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpngrsa.h"
-#include "pcpngrsamontstuff.h"
-
-
-/*F*
-// Name: ippsRSA_GetBufferSizePublicKey
-//
-// Purpose: Returns size of temporary buffer (in bytes) for public key operation
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-// NULL == pBufferSize
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID()
-//
-// ippStsIncompleteContextErr no ippsRSA_SetPublicKey() call
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pBufferSize pointer to size of temporary buffer
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_GetBufferSizePublicKey,(int* pBufferSize, const IppsRSAPublicKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- IPP_BAD_PTR1_RET(pBufferSize);
-
- {
- cpSize expBitSize = RSA_PUB_KEY_BITSIZE_E(pKey);
- cpSize w = gsMontExp_WinSize(expBitSize);
- cpSize precompLen = (1==w)? 0 : (1<1)
- // temporary product (2)
- */
- cpSize bufferLen = ((nsM+1)*2)*2
- +precompLen*nsM
- +nsM
- +nsM*2;
-
- *pBufferSize = bufferLen*sizeof(BNU_CHUNK_T)
- + sizeof(BNU_CHUNK_T)-1
- + (CACHE_LINE_SIZE-1);
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsRSA_GetBufferSizePublicKey
-//
-// Purpose: Returns size of temporary buffer (in bytes) for public key operation
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-// NULL == pBufferSize
-//
-// ippStsContextMatchErr !RSA_PRV_KEY_VALID_ID()
-//
-// ippStsIncompleteContextErr (type1) private key is not set up
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pBufferSize pointer to size of temporary buffer
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_GetBufferSizePrivateKey,(int* pBufferSize, const IppsRSAPrivateKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(RSA_PRV_KEY1_VALID_ID(pKey) && !RSA_PRV_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- IPP_BAD_PTR1_RET(pBufferSize);
-
- {
- cpSize bufferLen;
- if(RSA_PRV_KEY1_VALID_ID(pKey)) {
- cpSize expBitSize = RSA_PRV_KEY_BITSIZE_D(pKey);
- cpSize w = gsMontExp_WinSize(expBitSize);
- cpSize precompLen = (1==w)? 0 : (1<1)
- // temporary product (2)
- */
- bufferLen = ((nsN+1)*2)*2
- +gsPrecompResourcelen(precompLen,nsN) //+precompLen*nsN
- +nsN
- +nsN
- +nsN*2;
- }
- else {
- cpSize expBitSize = IPP_MAX(RSA_PRV_KEY_BITSIZE_P(pKey), RSA_PRV_KEY_BITSIZE_Q(pKey));
- cpSize w = gsMontExp_WinSize(expBitSize);
- cpSize precompLen = (1==w)? 0 : (1<1)
- // recoure to keep "masked" multipler (x|1) (1), (w=1)
- // or resource to keep zero-extended power e (1), (w>1)
- // temporary product (2)
- */
- bufferLen = ((nsP*2+1)*2)*2
- +gsPrecompResourcelen(precompLen, nsP) //+precompLen*nsP
- +nsP
- +nsP
- +nsP*2;
- bufferLen = IPP_MAX( IPP_MAX(validationBufferLen,generationBufferLen), bufferLen );
- }
- *pBufferSize = bufferLen*sizeof(BNU_CHUNK_T)
- + sizeof(BNU_CHUNK_T)-1
- + (CACHE_LINE_SIZE-1);
- return ippStsNoErr;
- }
-}
-
-
-
-void gsRSApub_cipher(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const IppsRSAPublicKeyState* pKey,
- BNU_CHUNK_T* pScratchBuffer)
-{
- IppsMontState* pMontN = RSA_PUB_KEY_NMONT(pKey);
- gsMontEnc_BN(pY, pX, pMontN, pScratchBuffer);
-
- {
- /* optimal size of window */
- BNU_CHUNK_T* pExp = RSA_PUB_KEY_E(pKey);
- cpSize nsExp = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_E(pKey));
- cpSize w = gsMontExp_WinSize(RSA_PUB_KEY_BITSIZE_E(pKey));
-
- if(1==w)
- gsMontExpBin_BN(pY, pY, pExp, nsExp, pMontN, pScratchBuffer);
- else
- gsMontExpWin_BN(pY, pY, pExp, nsExp, w, pMontN, pScratchBuffer);
- }
-
- gsMontDec_BN(pY, pY, pMontN, pScratchBuffer);
-}
-
-
-/*F*
-// Name: ippsRSA_Encrypt
-//
-// Purpose: Performs RSA Encryprion
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-// NULL == pPtxt
-// NULL == pCtxt
-// NULL == pBuffer
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID()
-// !BN_VALID_ID(pPtxt)
-// !BN_VALID_ID(pCtxt)
-//
-// ippStsIncompleteContextErr public key is not setup
-//
-// ippStsOutOfRangeErr pPtxt >= modulus
-// pPtxt <0
-//
-// ippStsSizeErr BN_ROOM(pCtxt) is not enough
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pPtxt pointer to the plaintext
-// pCtxt pointer to the ciphertext
-// pKey pointer to the key context
-// pScratchBuffer pointer to the temporary buffer
-*F*/
-IPPFUN(IppStatus, ippsRSA_Encrypt,(const IppsBigNumState* pPtxt,
- IppsBigNumState* pCtxt,
- const IppsRSAPublicKeyState* pKey,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR2_RET(pKey, pScratchBuffer);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- IPP_BAD_PTR1_RET(pPtxt);
- pPtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPtxt, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPtxt), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pPtxt), ippStsOutOfRangeErr);
- IPP_BADARG_RET(0 <= cpCmp_BNU(BN_NUMBER(pPtxt), BN_SIZE(pPtxt),
- MNT_MODULUS(RSA_PUB_KEY_NMONT(pKey)), MNT_SIZE(RSA_PUB_KEY_NMONT(pKey))), ippStsOutOfRangeErr);
-
- IPP_BAD_PTR1_RET(pCtxt);
- pCtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCtxt, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCtxt), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pCtxt) < BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_N(pKey)), ippStsSizeErr);
-
- gsRSApub_cipher(pCtxt,
- pPtxt,
- pKey,
- (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) );
- return ippStsNoErr;
-}
-
-
-
-void gsRSAprv_cipher(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const IppsRSAPrivateKeyState* pKey,
- BNU_CHUNK_T* pScratchBuffer)
-{
- IppsMontState* pMontN = RSA_PRV_KEY_NMONT(pKey);
- gsMontEnc_BN(pY, pX, pMontN, pScratchBuffer);
-
- {
- /* optimal size of window */
- BNU_CHUNK_T* pExp = RSA_PRV_KEY_D(pKey);
- cpSize nsExp = BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_D(pKey));
- cpSize w = gsMontExp_WinSize(RSA_PRV_KEY_BITSIZE_D(pKey));
-
- if(1==w)
- gsMontExpBin_BN_sscm(pY, pY, pExp, nsExp, pMontN, pScratchBuffer);
- else
- gsMontExpWin_BN_sscm(pY, pY, pExp, nsExp, w, pMontN, pScratchBuffer);
- }
-
- gsMontDec_BN(pY, pY, pMontN, pScratchBuffer);
-}
-
-void gsRSAprv_cipher_crt(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const IppsRSAPrivateKeyState* pKey,
- BNU_CHUNK_T* pScratchBuffer)
-{
- /* P- and Q- montgometry engines */
- IppsMontState* pMontP = RSA_PRV_KEY_PMONT(pKey);
- IppsMontState* pMontQ = RSA_PRV_KEY_QMONT(pKey);
- cpSize nsP = MNT_SIZE(pMontP);
- cpSize nsQ = MNT_SIZE(pMontQ);
-
- const BNU_CHUNK_T* dataX = BN_NUMBER(pX);
- cpSize nsX = BN_SIZE(pX);
- BNU_CHUNK_T* dataXp = BN_NUMBER(pY);
- BNU_CHUNK_T* dataXq = BN_BUFFER(pY);
-
- cpSize bitSizeDP = BITSIZE_BNU(RSA_PRV_KEY_DP(pKey), nsP);
- cpSize bitSizeDQ = BITSIZE_BNU(RSA_PRV_KEY_DQ(pKey), nsQ);
- cpSize w;
- BNU_CHUNK_T cf;
-
- /* compute xq = x^dQ mod Q */
- COPY_BNU(dataXq, dataX, nsX);
- cpMod_BNU(dataXq, nsX, MNT_MODULUS(pMontQ), nsQ);
- gsMontEnc_BNU(dataXq, dataXq, nsQ, pMontQ, pScratchBuffer);
- w = gsMontExp_WinSize(bitSizeDQ);
-
- if(1==w)
- gsMontExpBin_BNU_sscm(dataXq,
- dataXq, nsQ,
- RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(bitSizeDQ),
- pMontQ, pScratchBuffer);
- else
- gsMontExpWin_BNU_sscm(dataXq,
- dataXq, nsQ,
- RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(bitSizeDQ), w,
- pMontQ, pScratchBuffer);
-
- gsMontDec_BNU(dataXq, dataXq, nsQ, pMontQ, pScratchBuffer);
-
- /* compute xp = x^dP mod P */
- COPY_BNU(dataXp, dataX, nsX);
- cpMod_BNU(dataXp, nsX, MNT_MODULUS(pMontP), nsP);
- gsMontEnc_BNU(dataXp, dataXp, nsP, pMontP, pScratchBuffer);
- w = gsMontExp_WinSize(bitSizeDP);
-
- if(1==w)
- gsMontExpBin_BNU_sscm(dataXp,
- dataXp, nsP,
- RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(bitSizeDP),
- pMontP, pScratchBuffer);
- else
- gsMontExpWin_BNU_sscm(dataXp,
- dataXp, nsP,
- RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(bitSizeDP), w,
- pMontP, pScratchBuffer);
-
- gsMontDec_BNU(dataXp, dataXp, nsP, pMontP, pScratchBuffer);
-
- /* xp -= xq */
- cf = cpSub_BNU(dataXp, dataXp, dataXq, nsQ);
- if(nsP-nsQ)
- cf = cpDec_BNU(dataXp+nsQ, dataXp+nsQ, (nsP-nsQ), cf);
- if(cf)
- cpAdd_BNU(dataXp, dataXp, MNT_MODULUS(pMontP), nsP);
-
- /* xp = xp*qInv mod P */
- cpMontMul_BNU(dataXp,
- dataXp, nsP,
- RSA_PRV_KEY_INVQ(pKey), nsP,
- MNT_MODULUS(pMontP), nsP, MNT_HELPER(pMontP),
- pScratchBuffer, NULL);
-
- /* Y = xq + xp*Q */
- cpMul_BNU_school(pScratchBuffer,
- dataXp, nsP,
- MNT_MODULUS(pMontQ), nsQ);
- cf = cpAdd_BNU(BN_NUMBER(pY), pScratchBuffer, dataXq, nsQ);
- cpInc_BNU(BN_NUMBER(pY)+nsQ, pScratchBuffer+nsQ, nsP, cf);
-
- nsX = nsP+nsQ;
- FIX_BNU(BN_NUMBER(pY), nsX);
- BN_SIZE(pY) = nsX;
- BN_SIGN(pY) = ippBigNumPOS;
-}
-
-/*F*
-// Name: ippsRSA_Decrypt
-//
-// Purpose: Performs RSA Decryprion
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-// NULL == pCtxt
-// NULL == pPtxt
-// NULL == pBuffer
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID()
-// !BN_VALID_ID(pCtxt)
-// !BN_VALID_ID(pPtxt)
-//
-// ippStsIncompleteContextErr private key is not set up
-//
-// ippStsOutOfRangeErr pCtxt >= modulus
-// pCtxt <0
-//
-// ippStsSizeErr BN_ROOM(pPtxt) is not enough
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pCtxt pointer to the ciphertext
-// pPtxt pointer to the plaintext
-// pKey pointer to the key context
-// pScratchBuffer pointer to the temporary buffer
-*F*/
-IPPFUN(IppStatus, ippsRSA_Decrypt,(const IppsBigNumState* pCtxt,
- IppsBigNumState* pPtxt,
- const IppsRSAPrivateKeyState* pKey,
- Ipp8u* pScratchBuffer))
-{
- IPP_BAD_PTR2_RET(pKey, pScratchBuffer);
- pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- IPP_BAD_PTR1_RET(pCtxt);
- pCtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCtxt, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCtxt), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_NEGATIVE(pCtxt), ippStsOutOfRangeErr);
- IPP_BADARG_RET(0 <= cpCmp_BNU(BN_NUMBER(pCtxt), BN_SIZE(pCtxt),
- MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)), MNT_SIZE(RSA_PRV_KEY_NMONT(pKey))), ippStsOutOfRangeErr);
-
- IPP_BAD_PTR1_RET(pPtxt);
- pPtxt = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPtxt, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPtxt), ippStsContextMatchErr);
- IPP_BADARG_RET(BN_ROOM(pPtxt) < BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_N(pKey)), ippStsSizeErr);
-
- if(RSA_PRV_KEY1_VALID_ID(pKey))
- gsRSAprv_cipher(pPtxt,
- pCtxt,
- pKey,
- (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) );
- else
- gsRSAprv_cipher_crt(pPtxt,
- pCtxt,
- pKey,
- (BNU_CHUNK_T*)(IPP_ALIGNED_PTR((pScratchBuffer), (int)sizeof(BNU_CHUNK_T))) );
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c
deleted file mode 100644
index ac9ce14f14..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsaesoaepca.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcptool.h"
-#include "pcpngrsa.h"
-#include "pcphash.h"
-
-
-/*F*
-// Name: ippsRSAEncrypt_OAEP
-//
-// Purpose: Performs RSAES-OAEP encryprion scheme
-//
-// Returns: Reason:
-// ippStsNotSupportedModeErr unknown hashAlg
-//
-// ippStsNullPtrErr NULL == pKey
-// NULL == pSrc
-// NULL == pDst
-// NULL == pLabel
-// NULL == pSeed
-// NULL == pBuffer
-//
-// ippStsLengthErr srcLen <0
-// labLen <0
-// srcLen > RSAsize -2*hashLen -2
-// RSAsize < 2*hashLen +2
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID()
-//
-// ippStsIncompleteContextErr public key is not set up
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pSrc pointer to the plaintext
-// srcLen plaintext length (bytes)
-// pLabel (optional) pointer to the label associated with plaintext
-// labLen label length (bytes)
-// pSeed seed string of hashLen size
-// pDst pointer to the ciphertext (length of pdst is not less then size of RSA modulus)
-// pKey pointer to the RSA public key context
-// hashAlg hash alg ID
-// pBuffer pointer to scratch buffer
-*F*/
-IPPFUN(IppStatus, ippsRSAEncrypt_OAEP,(const Ipp8u* pSrc, int srcLen,
- const Ipp8u* pLabel, int labLen,
- const Ipp8u* pSeed,
- Ipp8u* pDst,
- const IppsRSAPublicKeyState* pKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-{
- int hashLen;
-
- /* test hash algorith ID */
- hashAlg = cpValidHashAlg(hashAlg);
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
-
- /* test data pointer */
- IPP_BAD_PTR3_RET(pSrc,pDst, pSeed);
-
- IPP_BADARG_RET(!pLabel && labLen, ippStsNullPtrErr);
-
- /* test public key context */
- IPP_BAD_PTR2_RET(pKey, pBuffer);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- /* test length */
- IPP_BADARG_RET(srcLen<0||labLen<0, ippStsLengthErr);
-
- hashLen = cpHashSize(hashAlg);
- /* test compatibility of RSA and hash length */
- IPP_BADARG_RET(BITS2WORD8_SIZE(RSA_PRV_KEY_BITSIZE_N(pKey)) < (2*hashLen +2), ippStsLengthErr);
- /* test compatibility of msg length and other (RSA and hash) lengths */
- IPP_BADARG_RET(BITS2WORD8_SIZE(RSA_PRV_KEY_BITSIZE_N(pKey))-(2*hashLen +2) < srcLen, ippStsLengthErr);
-
- {
- /* size of RSA modulus in bytes and chunks */
- int k = BITS2WORD8_SIZE(RSA_PUB_KEY_BITSIZE_N(pKey));
- cpSize nsN = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_N(pKey));
-
- /*
- // EME-OAEP encoding
- */
- {
- Ipp8u seedMask[BITS2WORD8_SIZE(IPP_SHA512_DIGEST_BITSIZE)];
-
- Ipp8u* pMaskedSeed = pDst+1;
- Ipp8u* pMaskedDB = pDst +hashLen +1;
-
- pDst[0] = 0;
-
- /* maskedDB = MGF(seed, k-1-hashLen)*/
- ippsMGF(pSeed, hashLen, pMaskedDB, k-1-hashLen, hashAlg);
-
- /* seedMask = HASH(pLab) */
- ippsHashMessage(pLabel, labLen, seedMask, hashAlg);
-
- /* maskedDB ^= concat(HASH(pLab),PS,0x01,pSc) */
- XorBlock(pMaskedDB, seedMask, pMaskedDB, hashLen);
- pMaskedDB[k-srcLen-hashLen-2] ^= 0x01;
- XorBlock(pMaskedDB+k-srcLen-hashLen-2+1, pSrc, pMaskedDB+k-srcLen-hashLen-2+1, srcLen);
-
- /* seedMask = MGF(maskedDB, hashLen) */
- ippsMGF(pMaskedDB, k-1-hashLen, seedMask, hashLen, hashAlg);
- /* maskedSeed = seed ^ seedMask */
- XorBlock(pSeed, seedMask, pMaskedSeed, hashLen);
- }
-
- /* RSA encryption */
- {
- /* align buffer */
- BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) );
-
- /* temporary BN */
- __ALIGN8 IppsBigNumState tmpBN;
- BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &tmpBN);
-
- /* updtae buffer pointer */
- pScratchBuffer += (nsN+1)*2;
-
- ippsSetOctString_BN(pDst, k, &tmpBN);
-
- gsRSApub_cipher(&tmpBN, &tmpBN, pKey, pScratchBuffer);
-
- ippsGetOctString_BN(pDst, k, &tmpBN);
- }
-
- return ippStsNoErr;
- }
-}
-
-
-IPPFUN(IppStatus, ippsRSA_OAEPEncrypt_SHA256,(const Ipp8u* pSrc, int srcLen,
- const Ipp8u* pLabel, int labLen,
- const Ipp8u* pSeed,
- Ipp8u* pDst,
- const IppsRSAPublicKeyState* pKey,
- Ipp8u* pBuffer))
-{ return ippsRSAEncrypt_OAEP(pSrc,srcLen, pLabel,labLen, pSeed,
- pDst, pKey,
- IPP_ALG_HASH_SHA256,
- pBuffer); }
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c
deleted file mode 100644
index 2896ffdc89..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsagenerate.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpprimeg.h"
-#include "pcpngrsa.h"
-#include "pcpngrsamontstuff.h"
-
-/*F*
-// Name: ippsRSA_ValidateKeys
-//
-// Purpose: Validate RSA keys
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pPublicKey
-// NULL == pPrivateKeyType2
-// NULL == pPrivateKeyType1
-// NULL == pBuffer
-// NULL == pPrimeGen
-// NULL == rndFunc
-// NULL == pResult
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID(pPublicKey)
-// !RSA_PRV_KEY2_VALID_ID(pPrivateKeyType2)
-// !RSA_PRV_KEY1_VALID_ID(pPrivateKeyType1)
-// !PRIME_VALID_ID(pPrimeGen)
-//
-// ippStsIncompleteContextErr public and.or private key is not set up
-//
-// ippStsSizeErr PRIME_MAXBITSIZE(pPrimeGen) < factorPbitSize
-//
-// ippStsBadArgErr nTrials < 1
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pResult pointer to the validation result
-// pPublicKey pointer to the public key context
-// pPrivateKeyType2 pointer to the private key type2 context
-// pPrivateKeyType1 (optional) pointer to the private key type1 context
-// pBuffer pointer to the temporary buffer
-// nTrials parameter of Miller-Rabin Test
-// pPrimeGen pointer to the Prime generator context
-// rndFunc external PRNG
-// pRndParam pointer to the external PRNG parameters
-*F*/
-/*
-// make sure D*E = 1 mod(phi(P,Q))
-// where phi(P,Q) = (P-1)*(Q-1)
-*/
-static
-int isValidPriv1_classic(const BNU_CHUNK_T* pN, int nsN,
- const BNU_CHUNK_T* pE, int nsE,
- const BNU_CHUNK_T* pD, int nsD,
- const BNU_CHUNK_T* pFactorP, int nsP,
- const BNU_CHUNK_T* pFactorQ, int nsQ,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* pPhi = pBuffer;
- BNU_CHUNK_T* pProduct = pPhi + nsN;
- BNU_CHUNK_T c = cpSub_BNU(pPhi, pN, pFactorP, nsP);
- int prodLen;
- if(nsN>1) cpDec_BNU(pPhi+nsP, pN+nsP, nsQ, c);
- c = cpSub_BNU(pPhi,pPhi, pFactorQ, nsQ);
- if(nsN>1) cpDec_BNU(pPhi+nsQ, pPhi+nsQ, nsP, c);
- cpInc_BNU(pPhi, pPhi, nsP+nsQ, 1);
-
- cpMul_BNU_school(pProduct, pE, nsE, pD, nsD);
- prodLen = cpMod_BNU(pProduct, nsE+nsD, pPhi, nsN);
-
- return 1==cpEqu_BNU_CHUNK(pProduct, prodLen, 1)? IPP_IS_VALID : IPP_IS_INVALID;
-}
-
-/*
-// make sure D*E = 1 mod(lcm(P-1,Q-1))
-// where lcm(P-1,Q-1) = (P-1)*(Q-1)/gcd(P-1,Q-1)
-*/
-static
-int isValidPriv1_rsa(const BNU_CHUNK_T* pN, int nsN,
- const BNU_CHUNK_T* pE, int nsE,
- const BNU_CHUNK_T* pD, int nsD,
- BNU_CHUNK_T* pFactorP, int nsP,
- BNU_CHUNK_T* pFactorQ, int nsQ,
- BNU_CHUNK_T* pBuffer)
-{
- __ALIGN8 IppsBigNumState tmpBN1;
- __ALIGN8 IppsBigNumState tmpBN2;
- __ALIGN8 IppsBigNumState tmpBN3;
-
- BNU_CHUNK_T* pProduct = pBuffer;
- BNU_CHUNK_T* pGcd = pProduct+(nsN+1);
- BNU_CHUNK_T* pLcm;
- int nsLcm;
- int prodLen;
- pBuffer = pGcd + (nsP+1)*2;
-
- /* P = P-1 and Q = Q-1 */
- pFactorP[0]--;
- pFactorQ[0]--;
-
- /* compute product (P-1)*(Q-1) = P*Q -P -Q +1 = N -(P-1) -(Q-1) -1 */
- {
- BNU_CHUNK_T c = cpSub_BNU(pProduct, pN, pFactorP, nsP);
- if(nsN>1) cpDec_BNU(pProduct+nsP, pN+nsP, nsQ, c);
- c = cpSub_BNU(pProduct, pProduct, pFactorQ, nsQ);
- if(nsN>1) cpDec_BNU(pProduct+nsQ, pProduct+nsQ, nsP, c);
- cpDec_BNU(pProduct, pProduct, nsN, 1);
- }
-
- /* compute gcd(p-1, q-1) */
- BN_Make(pGcd, pGcd+nsP+1, nsP, &tmpBN1); /* BN(gcd) */
- BN_SIZE(&tmpBN1) = nsP;
- BN_Make(pFactorP, pBuffer, nsP, &tmpBN2); /* BN(P-1) */
- BN_SIZE(&tmpBN2) = nsP;
- BN_Make(pFactorQ, pBuffer+nsP+1, nsQ, &tmpBN3); /* BN(Q-1) */
- BN_SIZE(&tmpBN3) = nsQ;
- ippsGcd_BN(&tmpBN2, &tmpBN3, &tmpBN1);
-
- /* compute lcm(p-1, q-1) = (p-1)(q-1)/gcd(p-1, q-1) */
- pLcm = pBuffer;
- cpDiv_BNU(pLcm, &nsLcm, pProduct, nsN, pGcd, BN_SIZE(&tmpBN1));
-
- /* test E*D = 1 mod lcm */
- cpMul_BNU_school(pProduct, pE, nsE, pD, nsD);
- prodLen = cpMod_BNU(pProduct, nsE+nsD, pLcm, nsLcm);
-
- /* restore P and Q */
- pFactorP[0]++;
- pFactorQ[0]++;
-
- return 1==cpEqu_BNU_CHUNK(pProduct, prodLen, 1)? IPP_IS_VALID : IPP_IS_INVALID;
-}
-
-IPPFUN(IppStatus, ippsRSA_ValidateKeys,(int* pResult,
- const IppsRSAPublicKeyState* pPublicKey,
- const IppsRSAPrivateKeyState* pPrivateKeyType2,
- const IppsRSAPrivateKeyState* pPrivateKeyType1, /*optional */
- Ipp8u* pBuffer,
- int nTrials,
- IppsPrimeState* pPrimeGen,
- IppBitSupplier rndFunc, void* pRndParam))
-{
- IPP_BAD_PTR1_RET(pPublicKey);
- pPublicKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pPublicKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pPublicKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pPublicKey), ippStsIncompleteContextErr);
-
- IPP_BAD_PTR1_RET(pPrivateKeyType2);
- pPrivateKeyType2 = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrivateKeyType2, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY2_VALID_ID(pPrivateKeyType2), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrivateKeyType2), ippStsIncompleteContextErr);
-
- if(pPrivateKeyType1) { /* pPrivateKeyType1 is optional */
- pPrivateKeyType1 = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrivateKeyType1, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY1_VALID_ID(pPrivateKeyType1), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrivateKeyType1), ippStsIncompleteContextErr);
- }
-
- IPP_BAD_PTR1_RET(pPrimeGen);
- pPrimeGen = (IppsPrimeState*)( IPP_ALIGNED_PTR(pPrimeGen, PRIME_ALIGNMENT) );
- IPP_BADARG_RET(!PRIME_VALID_ID(pPrimeGen), ippStsContextMatchErr);
- IPP_BADARG_RET(PRIME_MAXBITSIZE(pPrimeGen) < RSA_PRV_KEY_BITSIZE_P(pPrivateKeyType2), ippStsSizeErr);
-
- IPP_BAD_PTR3_RET(pResult, pBuffer, rndFunc);
-
- /* test security parameter parameter */
- IPP_BADARG_RET((1>nTrials), ippStsBadArgErr);
-
- {
- BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)));
-
- /* E key component */
- BNU_CHUNK_T* pExpE = RSA_PUB_KEY_E(pPublicKey);
- cpSize nsE = BITS_BNU_CHUNK(RSA_PUB_KEY_BITSIZE_E(pPublicKey));
- /* P, dP, invQ key components */
- BNU_CHUNK_T* pFactorP= MNT_MODULUS(RSA_PRV_KEY_PMONT(pPrivateKeyType2));
- BNU_CHUNK_T* pExpDp = RSA_PRV_KEY_DP(pPrivateKeyType2);
- BNU_CHUNK_T* pInvQ = RSA_PRV_KEY_INVQ(pPrivateKeyType2);
- cpSize nsP = MNT_SIZE(RSA_PRV_KEY_PMONT(pPrivateKeyType2));
- /* Q, dQ key components */
- BNU_CHUNK_T* pFactorQ= MNT_MODULUS(RSA_PRV_KEY_QMONT(pPrivateKeyType2));
- BNU_CHUNK_T* pExpDq = RSA_PRV_KEY_DQ(pPrivateKeyType2);
- cpSize nsQ = MNT_SIZE(RSA_PRV_KEY_QMONT(pPrivateKeyType2));
-
- /*const*/ BNU_CHUNK_T* pN0 = MNT_MODULUS(RSA_PUB_KEY_NMONT(pPublicKey));
- cpSize nsN = MNT_SIZE(RSA_PUB_KEY_NMONT(pPublicKey));
-
- *pResult = IPP_IS_VALID;
-
- /* make sure P is prime */
- if(!cpPrimeTest(pFactorP, nsP, nTrials, pPrimeGen, rndFunc, pRndParam)) {
- *pResult = IPP_IS_COMPOSITE;
- return ippStsNoErr;
- }
-
- /* make sure Q is prime */
- if(!cpPrimeTest(pFactorQ, nsQ, nTrials, pPrimeGen, rndFunc, pRndParam)) {
- *pResult = IPP_IS_COMPOSITE;
- return ippStsNoErr;
- }
-
- /* make sure PubKey(N)==PrivKeytype2(N) and PubKey(N)==PrivKeytype1(N) */
- if(cpCmp_BNU(pN0, nsN,
- MNT_MODULUS(RSA_PRV_KEY_NMONT(pPrivateKeyType2)), MNT_SIZE(RSA_PRV_KEY_NMONT(pPrivateKeyType2)))) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- if(pPrivateKeyType1) {
- if(cpCmp_BNU(pN0, nsN,
- MNT_MODULUS(RSA_PRV_KEY_NMONT(pPrivateKeyType1)), MNT_SIZE(RSA_PRV_KEY_NMONT(pPrivateKeyType1)))) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- }
-
- /* make sure 3 <= E < N */
- if(1==nsE && pExpE[0]<3) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- if(0 <= cpCmp_BNU(pExpE, nsE, pN0, nsN)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
-
- {
- BNU_CHUNK_T* pFactor1 = pScratchBuffer;
- BNU_CHUNK_T* pInv = pFactor1 +nsP+1;
- BNU_CHUNK_T* pBufInv = pInv +nsP+1;
- BNU_CHUNK_T* pBufE = pBufInv +nsP+1;
- BNU_CHUNK_T* pBufFact = pBufE +nsP+1;
- BNU_CHUNK_T* pProduct = pBufInv;
-
- /* make sure E*dP = 1 mod (P-1) */
- cpDec_BNU(pFactor1, pFactorP, nsP, 1);
- cpMul_BNU_school(pProduct, pExpDp, nsP, pExpE, nsE);
- cpMod_BNU(pProduct, nsP+nsE, pFactor1, nsP);
- if(!cpEqu_BNU_CHUNK(pProduct, nsP, 1)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- /* make sure 1==GCD(E,P-1) => exist Inv(E,P-1) */
- if(!cpModInv_BNU(pInv, pExpE, nsE, pFactor1, nsP, pBufInv, pBufE, pBufFact)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
-
- /* make sure E*dQ = 1 mod (Q-1) */
- cpDec_BNU(pFactor1, pFactorQ, nsQ, 1);
- cpMul_BNU_school(pProduct, pExpDq, nsQ, pExpE, nsE);
- cpMod_BNU(pProduct, nsQ+nsE, pFactor1, nsQ);
- if(!cpEqu_BNU_CHUNK(pProduct, nsQ, 1)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- /* make sure 1==GCD(E,Q-1) => exist Inv(E,Q-1) */
- if(!cpModInv_BNU(pInv, pExpE, nsE, pFactor1, nsQ, pBufInv, pBufE, pBufFact)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- }
-
- /* make sure Q*Qinv = 1 mod P */
- cpMontMul_BNU(pScratchBuffer,
- pFactorQ, nsQ,
- pInvQ, nsP,
- pFactorP, nsP, MNT_HELPER(RSA_PRV_KEY_PMONT(pPrivateKeyType2)),
- pScratchBuffer+nsP, NULL);
- if(!cpEqu_BNU_CHUNK(pScratchBuffer, nsP, 1)) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
-
- /* test priva exponent (optiobal) */
- if(pPrivateKeyType1) {
- const BNU_CHUNK_T* pExpD = RSA_PRV_KEY_D(pPrivateKeyType1);
- cpSize nsD = nsN;
-
- int resilt1 = isValidPriv1_classic(pN0,nsN, pExpE,nsE, pExpD,nsD,
- pFactorP,nsP, pFactorQ,nsQ,
- (BNU_CHUNK_T*)pScratchBuffer);
- int resilt2 = isValidPriv1_rsa(pN0,nsN, pExpE,nsE, pExpD,nsD,
- pFactorP,nsP, pFactorQ,nsQ,
- (BNU_CHUNK_T*)pScratchBuffer);
- if(IPP_IS_VALID!=resilt1 && IPP_IS_VALID!=resilt2) {
- *pResult = IPP_IS_INVALID;
- return ippStsNoErr;
- }
- }
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c
deleted file mode 100644
index 5c4c13e845..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeyprivate.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpngrsa.h"
-#include "pcpngrsamontstuff.h"
-
-/*F*
-// Name: ippsRSA_GetSizePrivateKeyType1
-//
-// Purpose: Returns context size (bytes) of RSA private key (type1) context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsNotSupportedModeErr MIN_RSA_SIZE > rsaModulusBitSize
-// MAX_RSA_SIZE < rsaModulusBitSize
-//
-// ippStsBadArgErr 0 >= privateExpBitSize
-// privateExpBitSize > rsaModulusBitSize
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// rsaModulusBitSize bitsize of RSA modulus (bitsize of N)
-// privateExpBitSize bitsize of private exponent (bitsize of D)
-// pSize pointer to the size of RSA key context (bytes)
-*F*/
-static int cpSizeof_RSA_privateKey1(int rsaModulusBitSize, int privateExpBitSize)
-{
- int prvExpLen = BITS_BNU_CHUNK(privateExpBitSize);
- int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize);
- int montNsize;
- gsMontGetSize(ippBinaryMethod, modulusLen32, &montNsize);
-
- return sizeof(IppsRSAPrivateKeyState)
- + prvExpLen*sizeof(BNU_CHUNK_T)
- + sizeof(BNU_CHUNK_T)-1
- + montNsize
- + (RSA_PRIVATE_KEY_ALIGNMENT-1);
-}
-
-IPPFUN(IppStatus, ippsRSA_GetSizePrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize, int* pKeySize))
-{
- IPP_BAD_PTR1_RET(pKeySize);
- IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
- IPP_BADARG_RET(!((0 rsaModulusBitSize
-// MAX_RSA_SIZE < rsaModulusBitSize
-//
-// ippStsBadArgErr 0 >= privateExpBitSize
-// privateExpBitSize > rsaModulusBitSize
-//
-// ippStsMemAllocErr keyCtxSize is not enough for operation
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// rsaModulusBitSize bitsize of RSA modulus (bitsize of N)
-// privateExpBitSize bitsize of private exponent (bitsize of D)
-// pKey pointer to the key context
-// keyCtxSize size of memmory accosizted with key comtext
-*F*/
-IPPFUN(IppStatus, ippsRSA_InitPrivateKeyType1,(int rsaModulusBitSize, int privateExpBitSize,
- IppsRSAPrivateKeyState* pKey, int keyCtxSize))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) );
-
- IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
- IPP_BADARG_RET(!((0= pModulus
-// 0 >= pPrivateExp
-//
-// ippStsSizeErr bitsize(pModulus) exceeds requested value
-// bitsize(pPrivateExp) exceeds requested value
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pModulus pointer to modulus (N)
-// pPrivateExp pointer to public exponent (D)
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_SetPrivateKeyType1,(const IppsBigNumState* pModulus,
- const IppsBigNumState* pPrivateExp,
- IppsRSAPrivateKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY1_VALID_ID(pKey), ippStsContextMatchErr);
-
- IPP_BAD_PTR1_RET(pModulus);
- pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pModulus)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pModulus), BN_SIZE(pModulus)) > RSA_PRV_KEY_MAXSIZE_N(pKey), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pPrivateExp);
- pPrivateExp = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPrivateExp, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPrivateExp), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pPrivateExp)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPrivateExp), BN_SIZE(pPrivateExp)) > RSA_PRV_KEY_MAXSIZE_D(pKey), ippStsSizeErr);
-
- {
- /* store D */
- ZEXPAND_COPY_BNU(RSA_PRV_KEY_D(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_MAXSIZE_D(pKey)), BN_NUMBER(pPrivateExp), BN_SIZE(pPrivateExp));
-
- /* setup montgomery engine */
- gsMontSet((Ipp32u*)BN_NUMBER(pModulus), BN_SIZE32(pModulus), RSA_PRV_KEY_NMONT(pKey));
-
- RSA_PRV_KEY_BITSIZE_N(pKey) = cpBN_bitsize(pModulus);
- RSA_PRV_KEY_BITSIZE_D(pKey) = cpBN_bitsize(pPrivateExp);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsRSA_GetSizePrivateKeyType2
-//
-// Purpose: Returns context size (bytes) of RSA private key (type2) context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsNotSupportedModeErr MIN_RSA_SIZE > (factorPbitSize+factorQbitSize)
-// MAX_RSA_SIZE < (factorPbitSize+factorQbitSize)
-//
-// ippStsBadArgErr 0 >= factorPbitSize
-// 0 >= factorQbitSize
-// factorQbitSize > factorPbitSize
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// factorPbitSize bitsize of RSA modulus (bitsize of P)
-// factorPbitSize bitsize of private exponent (bitsize of Q)
-// pSize pointer to the size of RSA key context (bytes)
-*F*/
-static int cpSizeof_RSA_privateKey2(int factorPbitSize, int factorQbitSize)
-{
- int factorPlen = BITS_BNU_CHUNK(factorPbitSize);
- int factorQlen = BITS_BNU_CHUNK(factorQbitSize);
- int factorPlen32 = BITS2WORD32_SIZE(factorPbitSize);
- int factorQlen32 = BITS2WORD32_SIZE(factorQbitSize);
- int rsaModulusLen32 = BITS2WORD32_SIZE(factorPbitSize+factorQbitSize);
- int montPsize;
- int montQsize;
- int montNsize;
- gsMontGetSize(ippBinaryMethod, factorPlen32, &montPsize);
- gsMontGetSize(ippBinaryMethod, factorQlen32, &montQsize);
- gsMontGetSize(ippBinaryMethod, rsaModulusLen32, &montNsize);
-
- return sizeof(IppsRSAPrivateKeyState)
- + factorPlen*sizeof(BNU_CHUNK_T) /* dp slot */
- + factorQlen*sizeof(BNU_CHUNK_T) /* dq slot */
- + factorPlen*sizeof(BNU_CHUNK_T) /* qinv slot */
- + sizeof(BNU_CHUNK_T)-1
- + montPsize
- + montQsize
- + montNsize
- + (RSA_PRIVATE_KEY_ALIGNMENT-1);
-}
-
-IPPFUN(IppStatus, ippsRSA_GetSizePrivateKeyType2,(int factorPbitSize, int factorQbitSize, int* pKeySize))
-{
- IPP_BAD_PTR1_RET(pKeySize);
- IPP_BADARG_RET((factorPbitSize<=0) || (factorQbitSize<=0), ippStsBadArgErr);
- IPP_BADARG_RET((factorPbitSize < factorQbitSize), ippStsBadArgErr);
- IPP_BADARG_RET((MIN_RSA_SIZE>(factorPbitSize+factorQbitSize) || (factorPbitSize+factorQbitSize)>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
-
- *pKeySize = cpSizeof_RSA_privateKey2(factorPbitSize, factorQbitSize);
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsRSA_InitPrivateKeyType2
-//
-// Purpose: Init RSA private key context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-//
-// ippStsNotSupportedModeErr MIN_RSA_SIZE > (factorPbitSize+factorQbitSize)
-// MAX_RSA_SIZE < (factorPbitSize+factorQbitSize)
-//
-// ippStsBadArgErr 0 >= factorPbitSize
-// 0 >= factorQbitSize
-// factorQbitSize > factorPbitSize
-//
-// ippStsMemAllocErr keyCtxSize is not enough for operation
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// factorPbitSize bitsize of RSA modulus (bitsize of P)
-// factorQbitSize bitsize of private exponent (bitsize of Q)
-// pKey pointer to the key context
-// keyCtxSize size of memmory accosizted with key comtext
-*F*/
-IPPFUN(IppStatus, ippsRSA_InitPrivateKeyType2,(int factorPbitSize, int factorQbitSize,
- IppsRSAPrivateKeyState* pKey, int keyCtxSize))
-{
- IPP_BAD_PTR1_RET(pKey);
- IPP_BADARG_RET((factorPbitSize<=0) || (factorQbitSize<=0), ippStsBadArgErr);
- IPP_BADARG_RET((factorPbitSize < factorQbitSize), ippStsBadArgErr);
- IPP_BADARG_RET((MIN_RSA_SIZE>(factorPbitSize+factorQbitSize) || (factorPbitSize+factorQbitSize)>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
-
- /* test available size of context buffer */
- IPP_BADARG_RET(keyCtxSize= pFactorP, 0 >= pFactorQ
-// 0 >= pCrtExpP, 0 >= pCrtExpQ
-// 0 >= pInverseQ
-//
-// ippStsSizeErr bitsize(pFactorP) exceeds requested value
-// bitsize(pFactorQ) exceeds requested value
-// bitsize(pCrtExpP) > bitsize(pFactorP)
-// bitsize(pCrtExpQ) > bitsize(pFactorQ)
-// bitsize(pInverseQ) > bitsize(pFactorP)
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pFactorP, pFactorQ pointer to the RSA modulus (N) prime factors
-// pCrtExpP, pCrtExpQ pointer to CTR's exponent
-// pInverseQ 1/Q mod P
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_SetPrivateKeyType2,(const IppsBigNumState* pFactorP,
- const IppsBigNumState* pFactorQ,
- const IppsBigNumState* pCrtExpP,
- const IppsBigNumState* pCrtExpQ,
- const IppsBigNumState* pInverseQ,
- IppsRSAPrivateKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY2_VALID_ID(pKey), ippStsContextMatchErr);
-
- IPP_BAD_PTR1_RET(pFactorP);
- pFactorP = (IppsBigNumState*)( IPP_ALIGNED_PTR(pFactorP, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pFactorP), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pFactorP)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pFactorP), BN_SIZE(pFactorP)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pFactorQ);
- pFactorQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pFactorQ, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pFactorQ), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pFactorQ)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pFactorQ), BN_SIZE(pFactorQ)) > RSA_PRV_KEY_BITSIZE_Q(pKey), ippStsSizeErr);
-
- /* let P>Q */
- IPP_BADARG_RET(0>=cpBN_cmp(pFactorP,pFactorQ), ippStsBadArgErr);
-
- IPP_BAD_PTR1_RET(pCrtExpP);
- pCrtExpP = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCrtExpP, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCrtExpP), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pCrtExpP)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pCrtExpP), BN_SIZE(pCrtExpP)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pCrtExpQ);
- pCrtExpQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pCrtExpQ, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pCrtExpQ), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pCrtExpQ)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pCrtExpQ), BN_SIZE(pCrtExpQ)) > RSA_PRV_KEY_BITSIZE_Q(pKey), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pInverseQ);
- pInverseQ = (IppsBigNumState*)( IPP_ALIGNED_PTR(pInverseQ, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pInverseQ), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pInverseQ)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pInverseQ), BN_SIZE(pInverseQ)) > RSA_PRV_KEY_BITSIZE_P(pKey), ippStsSizeErr);
-
- /* set bitsize(N) = 0, so the key contex is not ready */
- RSA_PRV_KEY_BITSIZE_N(pKey) = 0;
- RSA_PRV_KEY_BITSIZE_D(pKey) = 0;
-
- /* setup montgomery engine P */
- gsMontSet((Ipp32u*)BN_NUMBER(pFactorP), BN_SIZE32(pFactorP), RSA_PRV_KEY_PMONT(pKey));
- /* setup montgomery engine Q */
- gsMontSet((Ipp32u*)BN_NUMBER(pFactorQ), BN_SIZE32(pFactorQ), RSA_PRV_KEY_QMONT(pKey));
-
- /* actual size of key components */
- RSA_PRV_KEY_BITSIZE_P(pKey) = cpBN_bitsize(pFactorP);
- RSA_PRV_KEY_BITSIZE_Q(pKey) = cpBN_bitsize(pFactorQ);
-
- /* store CTR's exp dp */
- ZEXPAND_COPY_BNU(RSA_PRV_KEY_DP(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_P(pKey)), BN_NUMBER(pCrtExpP), BN_SIZE(pCrtExpP));
- /* store CTR's exp dq */
- ZEXPAND_COPY_BNU(RSA_PRV_KEY_DQ(pKey), BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_Q(pKey)), BN_NUMBER(pCrtExpQ), BN_SIZE(pCrtExpQ));
- /* store mont encoded CTR's coeff qinv */
- {
- IppsMontState* pMontP = RSA_PRV_KEY_PMONT(pKey);
- BNU_CHUNK_T* pTmpProduct = MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey));
- cpMontMul_BNU(RSA_PRV_KEY_INVQ(pKey),
- BN_NUMBER(pInverseQ), BN_SIZE(pInverseQ),
- MNT_SQUARE_R(pMontP), MNT_SIZE(pMontP),
- MNT_MODULUS(pMontP), MNT_SIZE(pMontP), MNT_HELPER(pMontP),
- pTmpProduct, NULL);
- }
-
- /* setup montgomery engine N = P*Q */
- {
- BNU_CHUNK_T* pN = MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey));
- cpSize nsN = BITS_BNU_CHUNK(RSA_PRV_KEY_BITSIZE_P(pKey) + RSA_PRV_KEY_BITSIZE_Q(pKey));
-
- cpMul_BNU_school(pN,
- BN_NUMBER(pFactorP), BN_SIZE(pFactorP),
- BN_NUMBER(pFactorQ), BN_SIZE(pFactorQ));
-
- gsMontSet((Ipp32u*)MNT_MODULUS(RSA_PRV_KEY_NMONT(pKey)), BITS2WORD32_SIZE(RSA_PRV_KEY_BITSIZE_P(pKey)+RSA_PRV_KEY_BITSIZE_Q(pKey)), RSA_PRV_KEY_NMONT(pKey));
-
- FIX_BNU(pN, nsN);
- RSA_PRV_KEY_BITSIZE_N(pKey) = BITSIZE_BNU(pN, nsN);
- }
-
- return ippStsNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c
deleted file mode 100644
index a76c955d2a..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsakeypublic.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpngrsa.h"
-#include "pcpngrsamontstuff.h"
-
-
-/*F*
-// Name: ippsRSA_GetSizePublicKey
-//
-// Purpose: Returns context size (bytes) of RSA public key context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsNotSupportedModeErr MIN_RSA_SIZE > rsaModulusBitSize
-// MAX_RSA_SIZE < rsaModulusBitSize
-//
-// ippStsBadArgErr 0 >= publicExpBitSize
-// publicExpBitSize > rsaModulusBitSize
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// rsaModulusBitSize bitsize of RSA modulus (bitsize of N)
-// publicExpBitSize bitsize of public exponent (bitsize of E)
-// pSize pointer to the size of RSA key context (bytes)
-*F*/
-static int cpSizeof_RSA_publicKey(int rsaModulusBitSize, int publicExpBitSize)
-{
- int pubExpLen = BITS_BNU_CHUNK(publicExpBitSize);
- int modulusLen32 = BITS2WORD32_SIZE(rsaModulusBitSize);
- int montNsize;
- gsMontGetSize(ippBinaryMethod, modulusLen32, &montNsize);
-
- return sizeof(IppsRSAPublicKeyState)
- + pubExpLen*sizeof(BNU_CHUNK_T)
- + sizeof(BNU_CHUNK_T)-1
- + montNsize
- + (RSA_PUBLIC_KEY_ALIGNMENT-1);
-}
-
-IPPFUN(IppStatus, ippsRSA_GetSizePublicKey,(int rsaModulusBitSize, int publicExpBitSize, int* pKeySize))
-{
- IPP_BAD_PTR1_RET(pKeySize);
- IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
- IPP_BADARG_RET(!((0 rsaModulusBitSize
-// MAX_RSA_SIZE < rsaModulusBitSize
-//
-// ippStsBadArgErr 0 >= publicExpBitSize
-// publicExpBitSize > rsaModulusBitSize
-//
-// ippStsMemAllocErr keyCtxSize is not enough for operation
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// rsaModulusBitSize bitsize of RSA modulus (bitsize of N)
-// publicExpBitSize bitsize of public exponent (bitsize of E)
-// pKey pointer to the key context
-// keyCtxSize size of memmory accosizted with key comtext
-*F*/
-IPPFUN(IppStatus, ippsRSA_InitPublicKey,(int rsaModulusBitSize, int publicExpBitSize,
- IppsRSAPublicKeyState* pKey, int keyCtxSize))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
-
- IPP_BADARG_RET((MIN_RSA_SIZE>rsaModulusBitSize) || (rsaModulusBitSize>MAX_RSA_SIZE), ippStsNotSupportedModeErr);
- IPP_BADARG_RET(!((0= pModulus
-// 0 >= pPublicExp
-//
-// ippStsSizeErr bitsize(pModulus) exceeds requested value
-// bitsize(pPublicExp) exceeds requested value
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pModulus pointer to modulus (N)
-// pPublicExp pointer to public exponent (E)
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_SetPublicKey,(const IppsBigNumState* pModulus,
- const IppsBigNumState* pPublicExp,
- IppsRSAPublicKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
-
- IPP_BAD_PTR1_RET(pModulus);
- pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pModulus)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pModulus), BN_SIZE(pModulus)) > RSA_PUB_KEY_MAXSIZE_N(pKey), ippStsSizeErr);
-
- IPP_BAD_PTR1_RET(pPublicExp);
- pPublicExp = (IppsBigNumState*)( IPP_ALIGNED_PTR(pPublicExp, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pPublicExp), ippStsContextMatchErr);
- IPP_BADARG_RET(!(0 < cpBN_tst(pPublicExp)), ippStsOutOfRangeErr);
- IPP_BADARG_RET(BITSIZE_BNU(BN_NUMBER(pPublicExp), BN_SIZE(pPublicExp)) > RSA_PUB_KEY_MAXSIZE_E(pKey), ippStsSizeErr);
-
- {
- RSA_PUB_KEY_BITSIZE_N(pKey) = 0;
- RSA_PUB_KEY_BITSIZE_E(pKey) = 0;
-
- /* store E */
- ZEXPAND_COPY_BNU(RSA_PUB_KEY_E(pKey), BITS_BNU_CHUNK(RSA_PUB_KEY_MAXSIZE_E(pKey)), BN_NUMBER(pPublicExp), BN_SIZE(pPublicExp));
-
- /* setup montgomery engine */
- gsMontSet((Ipp32u*)BN_NUMBER(pModulus), BN_SIZE32(pModulus), RSA_PUB_KEY_NMONT(pKey));
-
- RSA_PUB_KEY_BITSIZE_N(pKey) = cpBN_bitsize(pModulus);
- RSA_PUB_KEY_BITSIZE_E(pKey) = cpBN_bitsize(pPublicExp);
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsRSA_GetPublicKey
-//
-// Purpose: Extract key component from the key context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pKey
-//
-// ippStsContextMatchErr !RSA_PUB_KEY_VALID_ID()
-// !BN_VALID_ID(pModulus)
-// !BN_VALID_ID(pExp)
-//
-// ippStsIncompleteContextErr public key is not set up
-//
-// ippStsSizeErr BN_ROOM(pModulus), BN_ROOM(pExp) is not enough
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pModulus (optional) pointer to the modulus (N)
-// pExp (optional) pointer to the public exponent (E)
-// pKey pointer to the key context
-*F*/
-IPPFUN(IppStatus, ippsRSA_GetPublicKey,(IppsBigNumState* pModulus,
- IppsBigNumState* pExp,
- const IppsRSAPublicKeyState* pKey))
-{
- IPP_BAD_PTR1_RET(pKey);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
-
- if(pModulus) {
- pModulus = (IppsBigNumState*)( IPP_ALIGNED_PTR(pModulus, BN_ALIGNMENT) );
- IPP_BADARG_RET(!BN_VALID_ID(pModulus), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
- IPP_BADARG_RET(BN_ROOM(pModulus)0; nsE--) {
- eValue = dataE[nsE-1];
-
- for(n=0; n=0; j--) {
- mask_pattern = (BNU_CHUNK_T)(back_step-1);
-
- /* safeBuffer = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */
- for(i=0; i>j) & 0x1) & (back_step^1);
- j += back_step;
- }
-
- /* execute rest bits of E */
- for(--nsE; nsE>0; nsE--) {
- eValue = dataE[nsE-1];
-
- for(j=BNU_CHUNK_BITS-1; j>=0; j--) {
- mask_pattern = (BNU_CHUNK_T)(back_step-1);
-
- /* safeBuffer = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */
- for(i=0; i>j) & 0x1) & (back_step^1);
- j += back_step;
- }
- }
- }
-
- return nsM;
-}
-
-
-/*
-// "fast" fixed-size window montgomery exponentiation
-//
-// scratch buffer structure:
-// precomutation resource[(1<>shift) &mask;
-
- /* initialize result */
- COPY_BNU(dataY, pResource+windowVal*nsM, nsM);
-
- for(eBit-=wBitSize; eBit>=0; eBit-=wBitSize) {
- /* do square window times */
- for(n=0,windowVal=0; n>shift) &mask;
-
- if(windowVal) {
- /* extract precomputed value and muptiply */
- cpMul_BNU(pProduct, dataY, nsM, pResource+windowVal*nsM, nsM, pBufferMulK);
- cpMontRed_BNU(dataY, pProduct, dataM, nsM, m0);
- }
- }
- }
- }
-
- return nsM;
-}
-
-
-/*
-// "safe" fixed-size window montgomery exponentiation
-//
-// scratch buffer structure:
-// precomutation resource[(1<>shift) &mask;
-
- /* initialize result */
- cpScrambleGet((Ipp32u*)dataY, nsM*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), ((Ipp8u*)pResource)+windowVal*chunkSize, chunkSize);
-
- for(eBit-=bitsizeEwin; eBit>=0; eBit-=bitsizeEwin) {
- /* do square window times */
- for(n=0,windowVal=0; n>shift) &mask;
-
- /* exptact precomputed value and muptiply */
- cpScrambleGet((Ipp32u*)dataT, nsM*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u), ((Ipp8u*)pResource)+windowVal*chunkSize, chunkSize);
-
- cpMul_BNU(pProduct, dataY, nsM, dataT, nsM, pBufferMulK);
- cpMontRed_BNU(dataY, pProduct, dataM, nsM, m0);
- }
- }
- }
-
- return nsM;
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h
deleted file mode 100644
index 2c69c8f0b3..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsamontstuff.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_NG_RSA_MONT_STUFF_H)
-#define _CP_NG_RSA_MONT_STUFF_H
-
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-
-/*
-// Montgomery engine preparation (GetSize/init/Set)
-*/
-void gsMontGetSize(IppsExpMethod method, int length, int* pSize);
-void gsMontInit(IppsExpMethod method, int length, IppsMontState* pCtx);
-void gsMontSet(const Ipp32u* pModulo, int size, IppsMontState* pCtx);
-
-
-/*
-// optimal size of fixed window exponentiation
-*/
-__INLINE cpSize gsMontExp_WinSize(cpSize bitsize)
-{
- return
- bitsize> 4096? 6 : /* 4096- .. . */
- bitsize> 2666? 5 : /* 2666 - 4095 */
- bitsize> 717? 4 : /* 717 - 2665 */
- bitsize> 178? 3 : /* 178 - 716 */
- bitsize> 41? 2 : 1; /* 41 - 177 */
-}
-
-/*
-// Montgomery encoding/decoding
-*/
-__INLINE cpSize gsMontEnc_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pXreg, cpSize nsX,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- cpSize nsM = MNT_SIZE(pMont);
- BNU_CHUNK_T* pProduct = pBuffer;
- BNU_CHUNK_T* pBufferKmul = NULL;
-
- cpMontMul_BNU(pR,
- pXreg, nsX, MNT_SQUARE_R(pMont), nsM,
- MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont),
- pProduct, pBufferKmul);
- return nsM;
-}
-
-__INLINE cpSize gsMontDec_BNU(BNU_CHUNK_T* pR,
- const BNU_CHUNK_T* pXmont, cpSize nsX,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- cpSize nsM = MNT_SIZE(pMont);
- ZEXPAND_COPY_BNU(pBuffer, 2*nsM, pXmont, nsX);
-
- cpMontRed_BNU(pR, pBuffer, MNT_MODULUS(pMont), nsM, MNT_HELPER(pMont));
- return nsM;
-}
-
-__INLINE void gsMontEnc_BN(IppsBigNumState* pRbn,
- const IppsBigNumState* pXbn,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* pR = BN_NUMBER(pRbn);
- cpSize nsM = MNT_SIZE(pMont);
-
- gsMontEnc_BNU(pR, BN_NUMBER(pXbn), BN_SIZE(pXbn), pMont, pBuffer);
-
- FIX_BNU(pR, nsM);
- BN_SIZE(pRbn) = nsM;
- BN_SIGN(pRbn) = ippBigNumPOS;
-}
-
-__INLINE void gsMontDec_BN(IppsBigNumState* pRbn,
- const IppsBigNumState* pXbn,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* pR = BN_NUMBER(pRbn);
- cpSize nsM = MNT_SIZE(pMont);
-
- gsMontDec_BNU(pR, BN_NUMBER(pXbn), BN_SIZE(pXbn), pMont, pBuffer);
-
- FIX_BNU(pR, nsM);
- BN_SIZE(pRbn) = nsM;
- BN_SIGN(pRbn) = ippBigNumPOS;
-}
-
-
-/*
-// binary montgomery exponentiation ("fast" version)
-*/
-cpSize gsMontExpBin_BNU(BNU_CHUNK_T* dataY,
- const BNU_CHUNK_T* dataX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer);
-
-__INLINE void gsMontExpBin_BN(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* dataY = BN_NUMBER(pY);
- cpSize nsY = gsMontExpBin_BNU(dataY,
- BN_NUMBER(pX), BN_SIZE(pX),
- dataE, nsE,
- pMont, pBuffer);
- FIX_BNU(dataY, nsY);
- BN_SIZE(pY) = nsY;
- BN_SIGN(pY) = ippBigNumPOS;
-}
-
-/*
-// fixed-size window montgomery exponentiation ("fast" version)
-*/
-cpSize gsMontExpWin_BNU(BNU_CHUNK_T* pY,
- const BNU_CHUNK_T* pX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieW,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer);
-
-__INLINE void gsMontExpWin_BN(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieW,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* dataY = BN_NUMBER(pY);
- cpSize nsY = gsMontExpWin_BNU(dataY,
- BN_NUMBER(pX), BN_SIZE(pX),
- dataE, nsE, bitsieW,
- pMont, pBuffer);
- FIX_BNU(dataY, nsY);
- BN_SIZE(pY) = nsY;
- BN_SIGN(pY) = ippBigNumPOS;
-}
-
-/*
-// binary montgomery exponentiation ("safe" version)
-*/
-__INLINE cpSize gsPrecompResourcelen(int n, cpSize nsM)
-{
- cpSize nsR = sizeof(BNU_CHUNK_T)*nsM*n + (CACHE_LINE_SIZE-1);
- nsR /=CACHE_LINE_SIZE; /* num of cashe lines */
- nsR *= (CACHE_LINE_SIZE/sizeof(BNU_CHUNK_T));
- return nsR;
-}
-
-cpSize gsMontExpBin_BNU_sscm(BNU_CHUNK_T* pY,
- const BNU_CHUNK_T* pX, cpSize nsX,
- const BNU_CHUNK_T* pE, cpSize nsE,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer);
-
-__INLINE void gsMontExpBin_BN_sscm(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const BNU_CHUNK_T* dataE, cpSize nsE,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* dataY = BN_NUMBER(pY);
- cpSize nsY = gsMontExpBin_BNU_sscm(dataY,
- BN_NUMBER(pX), BN_SIZE(pX),
- dataE, nsE,
- pMont, pBuffer);
- FIX_BNU(dataY, nsY);
- BN_SIZE(pY) = nsY;
- BN_SIGN(pY) = ippBigNumPOS;
-}
-
-/*
-// fixed-size window montgomery exponentiation ("safe" version)
-*/
-cpSize gsMontExpWin_BNU_sscm(BNU_CHUNK_T* dataY,
- const BNU_CHUNK_T* dataX, cpSize nsX,
- const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieEwin,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer);
-
-__INLINE void gsMontExpWin_BN_sscm(IppsBigNumState* pY,
- const IppsBigNumState* pX,
- const BNU_CHUNK_T* dataE, cpSize nsE, cpSize bitsieEwin,
- const IppsMontState* pMont,
- BNU_CHUNK_T* pBuffer)
-{
- BNU_CHUNK_T* dataY = BN_NUMBER(pY);
- cpSize nsY = gsMontExpWin_BNU_sscm(dataY,
- BN_NUMBER(pX), BN_SIZE(pX),
- dataE, nsE, bitsieEwin,
- pMont, pBuffer);
- FIX_BNU(dataY, nsY);
- BN_SIZE(pY) = nsY;
- BN_SIGN(pY) = ippBigNumPOS;
-}
-
-#endif /* _CP_NG_RSA_MONT_STUFF_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c
deleted file mode 100644
index c16699fc14..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpngrsassapkcsv15ca.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-#include "pcpngrsa.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-static int EMSA_PKCSv15(const Ipp8u* msgDg, int lenMsgDg,
- const Ipp8u* fixPS, int lenFixPS,
- Ipp8u* pEM, int lenEM)
-{
- /*
- // encoded message format:
- // EM = 00 || 01 || PS=(FF..FF) || 00 || T
- // T = fixPS || msgDg
- // len(PS) >= 8
- */
- int tLen = lenFixPS + lenMsgDg;
-
- if(lenEM >= tLen+11) {
- int psLen = lenEM - 3 - tLen;
-
- PaddBlock(0xFF, pEM, lenEM);
- pEM[0] = 0x00;
- pEM[1] = 0x01;
- pEM[2+psLen] = 0x00;
- CopyBlock(fixPS, pEM+3+psLen, lenFixPS);
- CopyBlock(msgDg, pEM+3+psLen+lenFixPS, lenMsgDg);
- return 1;
- }
- else
- return 0; /* encoded message length too long */
-}
-
-/*
-// The DER encoding T of the DigestInfo value is equal to the following (see PKCS-1v2-2):
-*/
-static const Ipp8u SHA1_fixPS[] = "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14";
-static const Ipp8u SHA224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04\x05\x00\x04\x1c";
-static const Ipp8u SHA256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20";
-static const Ipp8u SHA384_fixPS[] = "\x30\x41\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02\x05\x00\x04\x30";
-static const Ipp8u SHA512_fixPS[] = "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40";
-static const Ipp8u MD5_fixPS[] = "\x30\x20\x30\x0c\x06\x08\x2a\x86\x48\x86\xf7\x0d\x02\x05\x05\x00\x04\x10";
-static const Ipp8u SHA512_224_fixPS[] = "\x30\x2d\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x05\x05\x00\x04\x1c";
-static const Ipp8u SHA512_256_fixPS[] = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20";
-
-typedef struct {
- const Ipp8u* pSalt;
- int saltLen;
-} SaltInfo;
-
-static SaltInfo pksc15_salt[] = {
- {NULL, 0},
- {SHA1_fixPS, sizeof(SHA1_fixPS)-1},
- {SHA256_fixPS, sizeof(SHA256_fixPS)-1},
- {SHA224_fixPS, sizeof(SHA224_fixPS)-1},
- {SHA512_fixPS, sizeof(SHA512_fixPS)-1},
- {SHA384_fixPS, sizeof(SHA384_fixPS)-1},
- { MD5_fixPS, sizeof(MD5_fixPS)-1},
- {NULL, 0},
- {SHA512_224_fixPS, sizeof(SHA512_224_fixPS)-1},
- {SHA512_256_fixPS, sizeof(SHA512_256_fixPS)-1},
-};
-/* //////////////////////////////////////////////////////////////////////////////////////////////// */
-
-static int GenerateSing(const Ipp8u* pMsg, int msgLen, /* message representation */
- const Ipp8u* pSalt, int saltLen, /* fied string */
- Ipp8u* pSign,
- const IppsRSAPrivateKeyState* pPrvKey,
- const IppsRSAPublicKeyState* pPubKey,
- Ipp8u* pBuffer)
-{
- /* size of RSA modulus in bytes and chunks */
- cpSize rsaBits = RSA_PRV_KEY_BITSIZE_N(pPrvKey);
- cpSize k = BITS2WORD8_SIZE(rsaBits);
- cpSize nsN = BITS_BNU_CHUNK(rsaBits);
-
- /* EMSA-PKCS-v1_5 encoding */
- int result = EMSA_PKCSv15(pMsg,msgLen, pSalt,saltLen, pSign, k);
-
- if(result) {
- /* align buffer */
- BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) );
-
- /* temporary BNs */
- __ALIGN8 IppsBigNumState bnC;
- __ALIGN8 IppsBigNumState bnP;
-
- /* make BNs */
- BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnC);
- pScratchBuffer += (nsN+1)*2;
- BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnP);
- pScratchBuffer += (nsN+1)*2;
-
- /*
- // private-key operation
- */
- ippsSetOctString_BN(pSign, k, &bnC);
-
- if(RSA_PRV_KEY1_VALID_ID(pPrvKey))
- gsRSAprv_cipher(&bnP, &bnC, pPrvKey, pScratchBuffer);
- else
- gsRSAprv_cipher_crt(&bnP, &bnC, pPrvKey, pScratchBuffer);
-
- ippsGetOctString_BN(pSign, k, &bnP);
-
- /* check the result before send it out (fault attack mitigatioin) */
- if(pPubKey) {
- gsRSApub_cipher(&bnP, &bnP, pPubKey, pScratchBuffer);
-
- /* check signature before send it out (fault attack mitigatioin) */
- if(0!=cpBN_cmp(&bnP, &bnC)) {
- PaddBlock(0, pSign, k);
- result = 0;
- }
- }
- }
-
- return result;
-}
-
-IPPFUN(IppStatus, ippsRSASign_PKCS1v15,(const Ipp8u* pMsg, int msgLen,
- Ipp8u* pSign,
- const IppsRSAPrivateKeyState* pPrvKey,
- const IppsRSAPublicKeyState* pPubKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-{
- /* test private key context */
- IPP_BAD_PTR2_RET(pPrvKey, pBuffer);
- pPrvKey = (IppsRSAPrivateKeyState*)( IPP_ALIGNED_PTR(pPrvKey, RSA_PRIVATE_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PRV_KEY_VALID_ID(pPrvKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PRV_KEY_IS_SET(pPrvKey), ippStsIncompleteContextErr);
-
- /* test hash algorith ID */
- hashAlg = cpValidHashAlg(hashAlg);
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
-
- /* use aligned public key context if defined */
- if(pPubKey) {
- pPubKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pPubKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pPubKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pPubKey), ippStsIncompleteContextErr);
- }
-
- /* test data pointer */
- IPP_BAD_PTR2_RET(pMsg, pSign);
- /* test length */
- IPP_BADARG_RET(msgLen<0, ippStsLengthErr);
-
- {
- Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
- int mdLen = cpHashSize(hashAlg);
- ippsHashMessage(pMsg, msgLen, md, hashAlg);
-
- {
- const Ipp8u* pSalt = pksc15_salt[hashAlg].pSalt;
- int saltLen = pksc15_salt[hashAlg].saltLen;
-
- int sts = GenerateSing(md, mdLen,
- pSalt, saltLen,
- pSign,
- pPrvKey, pPubKey, pBuffer);
-
- return (1==sts)? ippStsNoErr : ippStsSizeErr;
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int VerifySing(const Ipp8u* pMsg, int msgLen, /* message representation */
- const Ipp8u* pSalt, int saltLen, /* fied string */
- const Ipp8u* pSign,
- int* pIsValid,
- const IppsRSAPublicKeyState* pKey,
- Ipp8u* pBuffer)
-{
- /* size of RSA modulus in bytes and chunks */
- cpSize rsaBits = RSA_PUB_KEY_BITSIZE_N(pKey);
- cpSize k = BITS2WORD8_SIZE(rsaBits);
- cpSize nsN = BITS_BNU_CHUNK(rsaBits);
-
- /* align buffer */
- BNU_CHUNK_T* pScratchBuffer = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(pBuffer, (int)sizeof(BNU_CHUNK_T)) );
-
- /* temporary BNs */
- __ALIGN8 IppsBigNumState bnC;
- __ALIGN8 IppsBigNumState bnP;
-
- /* make BNs */
- BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnC);
- pScratchBuffer += (nsN+1)*2;
- BN_Make(pScratchBuffer, pScratchBuffer+nsN+1, nsN, &bnP);
- pScratchBuffer += (nsN+1)*2;
-
- /*
- // public-key operation
- */
- ippsSetOctString_BN(pSign, k, &bnP);
- gsRSApub_cipher(&bnC, &bnP, pKey, pScratchBuffer);
-
- /* convert EM into the string */
- ippsGetOctString_BN((Ipp8u*)(BN_BUFFER(&bnC)), k, &bnC);
-
- /* EMSA-PKCS-v1_5 encoding */
- if( EMSA_PKCSv15(pMsg,msgLen, pSalt,saltLen, (Ipp8u*)(BN_NUMBER(&bnC)), k) ) {
- *pIsValid = 1==EquBlock((Ipp8u*)(BN_BUFFER(&bnC)), (Ipp8u*)(BN_NUMBER(&bnC)), k);
- return 1;
- }
- else
- return 0;
-}
-
-IPPFUN(IppStatus, ippsRSAVerify_PKCS1v15,(const Ipp8u* pMsg, int msgLen,
- const Ipp8u* pSign, int* pIsValid,
- const IppsRSAPublicKeyState* pKey,
- IppHashAlgId hashAlg,
- Ipp8u* pBuffer))
-{
- /* test public key context */
- IPP_BAD_PTR2_RET(pKey, pBuffer);
- pKey = (IppsRSAPublicKeyState*)( IPP_ALIGNED_PTR(pKey, RSA_PUBLIC_KEY_ALIGNMENT) );
- IPP_BADARG_RET(!RSA_PUB_KEY_VALID_ID(pKey), ippStsContextMatchErr);
- IPP_BADARG_RET(!RSA_PUB_KEY_IS_SET(pKey), ippStsIncompleteContextErr);
-
- /* test hash algorith ID */
- hashAlg = cpValidHashAlg(hashAlg);
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
-
- /* test data pointer */
- IPP_BAD_PTR3_RET(pMsg, pSign, pIsValid);
- /* test length */
- IPP_BADARG_RET(msgLen<0, ippStsLengthErr);
-
- *pIsValid = 0;
- {
- Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE];
- int mdLen = cpHashSize(hashAlg);
- ippsHashMessage(pMsg, msgLen, md, hashAlg);
-
- return VerifySing(md, mdLen,
- pksc15_salt[hashAlg].pSalt, pksc15_salt[hashAlg].saltLen,
- pSign, pIsValid,
- pKey, pBuffer)? ippStsNoErr : ippStsSizeErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcppma.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcppma.h
deleted file mode 100644
index 66f5da33fe..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcppma.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_PMA_H)
-#define _PCP_PMA_H
-
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-
-
-/*
-// Prime Modulo Arithmetic
-*/
-#define PMA_set(r,a) \
- BN_SIGN((r)) = BN_SIGN((a)); \
- BN_SIZE((r)) = BN_SIZE((a)); \
- ZEXPAND_COPY_BNU(BN_NUMBER((r)),BN_ROOM((r)), BN_NUMBER((a)),BN_SIZE((a))) \
-
-#define PMA_mod(r,a,modulo) \
- ippsMod_BN((a),(modulo),(r))
-
-#define PMA_inv(r,a,modulo) \
- ippsModInv_BN((a),(modulo),(r))
-
-#define PMA_div2(r,a,modulo) { \
- if( IsOdd_BN((a)) ) { \
- ippsAdd_BN((a), (modulo), (a)); \
- } \
- BN_SIZE((r)) = cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), (int)BN_SIZE((a)), 1); \
- cpBN_fix((r)); \
-}
-
-#define PMA_add(r,a,b,modulo) \
- ippsAdd_BN((a),(b),(r)); \
- if( cpCmp_BNU(BN_NUMBER((r)),BN_SIZE((r)),BN_NUMBER((modulo)),BN_SIZE(modulo)) >= 0 ) \
- ippsSub_BN((r),(modulo),(r))
-
-#define PMA_sub(r,a,b,modulo) \
- ippsSub_BN((a),(b),(r)); \
- if( BN_NEGATIVE((r)) ) \
- ippsAdd_BN((r),(modulo),(r))
-
-#define PMA_enc(r,a,mont) \
- cpMontEnc_BN((r), (a), (mont))
-
-#define PMA_dec(r,a,mont) \
- cpMontDec_BN((r), (a), (mont))
-
-#define PMA_sqre(r,a,mont) \
- ippsMontMul((a),(a), (mont),(r))
-
-#define PMA_mule(r,a,b,mont) \
- ippsMontMul((a),(b), (mont),(r))
-
-#endif /* _PCP_PMA_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeg.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeg.h
deleted file mode 100644
index 7e54efbe61..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeg.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_PRIME_H)
-#define _CP_PRIME_H
-
-#include "pcpbn.h"
-#include "pcpmontgomery.h"
-
-
-/*
-// Prime context
-*/
-struct _cpPrime {
- IppCtxId idCtx; /* Prime context identifier */
- cpSize maxBitSize; /* max bit length */
- BNU_CHUNK_T* pPrime; /* prime value */
- BNU_CHUNK_T* pT1; /* temporary BNU */
- BNU_CHUNK_T* pT2; /* temporary BNU */
- BNU_CHUNK_T* pT3; /* temporary BNU */
- IppsMontState* pMont; /* montgomery engine */
-};
-
-/* alignment */
-#define PRIME_ALIGNMENT ((int)sizeof(void*))
-
-/* Prime accessory macros */
-#define PRIME_ID(ctx) ((ctx)->idCtx)
-#define PRIME_MAXBITSIZE(ctx) ((ctx)->maxBitSize)
-#define PRIME_NUMBER(ctx) ((ctx)->pPrime)
-#define PRIME_TEMP1(ctx) ((ctx)->pT1)
-#define PRIME_TEMP2(ctx) ((ctx)->pT2)
-#define PRIME_TEMP3(ctx) ((ctx)->pT3)
-#define PRIME_MONT(ctx) ((ctx)->pMont)
-
-#define PRIME_VALID_ID(ctx) (PRIME_ID((ctx))==idCtxPrimeNumber)
-
-/* easy prime test */
-int cpMimimalPrimeTest(const Ipp32u* pPrime, cpSize ns);
-
-/* prime test */
-int cpPrimeTest(const BNU_CHUNK_T* pPrime, cpSize primeLen,
- cpSize nTrials,
- IppsPrimeState* pCtx,
- IppBitSupplier rndFunc, void* pRndParam);
-
-void cpPackPrimeCtx(const IppsPrimeState* pCtx, Ipp8u* pBuffer);
-void cpUnpackPrimeCtx(const Ipp8u* pBuffer, IppsPrimeState* pCtx);
-
-#endif /* _CP_PRIME_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimegenca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimegenca.c
deleted file mode 100644
index 6b105e8c16..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimegenca.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpprimeg.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsPrimeTest
-//
-// Purpose: Tests the set BN for being a probable prime.
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pCtx
-// NULL == pResult
-// NULL == rndFunc
-// ippStsContextMatchErr illegal pCtx->idCtx
-// ippStsOutOfRangeErr zero value under the test
-// ippStsBadArgErr 1 > nTrials
-// ippStsNoErr no error
-//
-// Parameters:
-// nTrials parameter for the Miller-Rabin probable primality test
-// pResult pointer to the test result (IS_COMPOSITE / IS_PRIME)
-// pCtx pointer to the context
-// rndFunc external PRNG
-// pRndParam pointer to the external PRNG parameters
-*F*/
-
-/* minimal prime test */
-static Ipp32u PrimeList[] = {
- 2, 3, 5, 7, 11, 13, 17, 19,
- 23, 29, 31, 37, 41, 43, 47, 53,
- 59, 61, 67, 71, 73, 79, 83, 89,
- 97, 101, 103, 107, 109, 113, 127, 131,
- 137, 139, 149, 151, 157, 163, 167, 173,
- 179, 181, 191, 193, 197, 199, 211, 223,
- 227, 229, 233, 239, 241, 251, 257, 263,
- 269, 271, 277, 281, 283, 293, 307, 311,
- 313, 317, 331, 337, 347, 349, 353, 359,
- 367, 373, 379, 383, 389, 397, 401, 409,
- 419, 421, 431, 433, 439, 443, 449, 457,
- 461, 463, 467, 479, 487, 491, 499, 503,
- 509, 521, 523, 541, 547, 557, 563, 569,
- 571, 577, 587, 593, 599, 601, 607, 613,
- 617, 619, 631, 641, 643, 647, 653, 659,
- 661, 673, 677, 683, 691, 701, 709, 719,
- 727, 733, 739, 743, 751, 757, 761, 769,
- 773, 787, 797, 809, 811, 821, 823, 827,
- 829, 839, 853, 857, 859, 863, 877, 881,
- 883, 887, 907, 911, 919, 929, 937, 941,
- 947, 953, 967, 971, 977, 983, 991, 997,
- 1009,1013,1019,1021,1031,1033,1039,1049,
- 1051,1061,1063,1069,1087,1091,1093,1097,
- 1103,1109,1117,1123,1129,1151,1153,1163,
- 1171,1181,1187,1193,1201,1213,1217,1223,
- 1229,1231,1237,1249,1259,1277,1279,1283,
- 1289,1291,1297,1301,1303,1307,1319,1321,
- 1327,1361,1367,1373,1381,1399,1409,1423,
- 1427,1429,1433,1439,1447,1451,1453,1459,
- 1471,1481,1483,1487,1489,1493,1499,1511,
- 1523,1531,1543,1549,1553,1559,1567,1571,
- 1579,1583,1597,1601,1607,1609,1613,1619,
- 1621,1627,1637,1657,1663,1667,1669,1693,
- 1697,1699,1709,1721,1723,1733,1741,1747,
- 1753,1759,1777,1783,1787,1789,1801,1811,
- 1823,1831,1847,1861,1867,1871,1873,1877,
- 1879,1889,1901,1907,1913,1931,1933,1949,
- 1951,1973,1979,1987,1993,1997,1999,2003,
- 2011,2017,2027,2029,2039,2053,2063,2069,
- 2081,2083,2087,2089,2099,2111,2113,2129,
- 2131,2137,2141,2143,2153,2161,2179,2203,
- 2207,2213,2221,2237,2239,2243,2251,2267,
- 2269,2273,2281,2287,2293,2297,2309,2311,
- 2333,2339,2341,2347,2351,2357,2371,2377,
- 2381,2383,2389,2393,2399,2411,2417,2423,
- 2437,2441,2447,2459,2467,2473,2477,2503,
- 2521,2531,2539,2543,2549,2551,2557,2579,
- 2591,2593,2609,2617,2621,2633,2647,2657,
- 2659,2663,2671,2677,2683,2687,2689,2693,
- 2699,2707,2711,2713,2719,2729,2731,2741,
- 2749,2753,2767,2777,2789,2791,2797,2801,
- 2803,2819,2833,2837,2843,2851,2857,2861,
- 2879,2887,2897,2903,2909,2917,2927,2939,
- 2953,2957,2963,2969,2971,2999,3001,3011,
- 3019,3023,3037,3041,3049,3061,3067,3079,
- 3083,3089,3109,3119,3121,3137,3163,3167,
- 3169,3181,3187,3191,3203,3209,3217,3221,
- 3229,3251,3253,3257,3259,3271,3299,3301,
- 3307,3313,3319,3323,3329,3331,3343,3347,
- 3359,3361,3371,3373,3389,3391,3407,3413,
- 3433,3449,3457,3461,3463,3467,3469,3491,
- 3499,3511,3517,3527,3529,3533,3539,3541,
- 3547,3557,3559,3571,3581,3583,3593,3607,
- 3613,3617,3623,3631,3637,3643,3659,3671,
- 3673,3677,3691,3697,3701,3709,3719,3727,
- 3733,3739,3761,3767,3769,3779,3793,3797,
- 3803,3821,3823,3833,3847,3851,3853,3863,
- 3877,3881,3889,3907,3911,3917,3919,3923,
- 3929,3931,3943,3947,3967,3989,4001,4003,
- 4007,4013,4019,4021,4027,4049,4051,4057,
- 4073,4079,4091,4093,4099,4111,4127,4129,
- 4133,4139,4153,4157,4159,4177,4201,4211,
- 4217,4219,4229,4231,4241,4243,4253,4259,
- 4261,4271,4273,4283,4289,4297,4327,4337,
- 4339,4349,4357,4363,4373,4391,4397,4409,
- 4421,4423,4441,4447,4451,4457,4463,4481,
- 4483,4493,4507,4513,4517,4519,4523,4547,
- 4549,4561,4567,4583,4591,4597,4603,4621,
- 4637,4639,4643,4649,4651,4657,4663,4673,
- 4679,4691,4703,4721,4723,4729,4733,4751,
- 4759,4783,4787,4789,4793,4799,4801,4813,
- 4817,4831,4861,4871,4877,4889,4903,4909,
- 4919,4931,4933,4937,4943,4951,4957,4967,
- 4969,4973,4987,4993,4999,5003,5009,5011,
- 5021,5023,5039,5051,5059,5077,5081,5087,
- 5099,5101,5107,5113,5119,5147,5153,5167,
- 5171,5179,5189,5197,5209,5227,5231,5233,
- 5237,5261,5273,5279,5281,5297,5303,5309,
- 5323,5333,5347,5351,5381,5387,5393,5399,
- 5407,5413,5417,5419,5431,5437,5441,5443,
- 5449,5471,5477,5479,5483,5501,5503,5507,
- 5519,5521,5527,5531,5557,5563,5569,5573,
- 5581,5591,5623,5639,5641,5647,5651,5653,
- 5657,5659,5669,5683,5689,5693,5701,5711,
- 5717,5737,5741,5743,5749,5779,5783,5791,
- 5801,5807,5813,5821,5827,5839,5843,5849,
- 5851,5857,5861,5867,5869,5879,5881,5897,
- 5903,5923,5927,5939,5953,5981,5987,6007,
- 6011,6029,6037,6043,6047,6053,6067,6073,
- 6079,6089,6091,6101,6113,6121,6131,6133,
- 6143,6151,6163,6173,6197,6199,6203,6211,
- 6217,6221,6229,6247,6257,6263,6269,6271,
- 6277,6287,6299,6301,6311,6317,6323,6329,
- 6337,6343,6353,6359,6361,6367,6373,6379,
- 6389,6397,6421,6427,6449,6451,6469,6473,
- 6481,6491,6521,6529,6547,6551,6553,6563,
- 6569,6571,6577,6581,6599,6607,6619,6637,
- 6653,6659,6661,6673,6679,6689,6691,6701,
- 6703,6709,6719,6733,6737,6761,6763,6779,
- 6781,6791,6793,6803,6823,6827,6829,6833,
- 6841,6857,6863,6869,6871,6883,6899,6907,
- 6911,6917,6947,6949,6959,6961,6967,6971,
- 6977,6983,6991,6997,7001,7013,7019,7027,
- 7039,7043,7057,7069,7079,7103,7109,7121,
- 7127,7129,7151,7159,7177,7187,7193,7207,
- 7211,7213,7219,7229,7237,7243,7247,7253,
- 7283,7297,7307,7309,7321,7331,7333,7349,
- 7351,7369,7393,7411,7417,7433,7451,7457,
- 7459,7477,7481,7487,7489,7499,7507,7517,
- 7523,7529,7537,7541,7547,7549,7559,7561,
- 7573,7577,7583,7589,7591,7603,7607,7621,
- 7639,7643,7649,7669,7673,7681,7687,7691,
- 7699,7703,7717,7723,7727,7741,7753,7757,
- 7759,7789,7793,7817,7823,7829,7841,7853,
- 7867,7873,7877,7879,7883,7901,7907,7919,
- 7927,7933,7937,7949,7951,7963,7993,8009,
- 8011,8017,8039,8053,8059,8069,8081,8087,
- 8089,8093,8101,8111,8117,8123,8147,8161,
- 8167,8171,8179,8191,8209,8219,8221,8231,
- 8233,8237,8243,8263,8269,8273,8287,8291,
- 8293,8297,8311,8317,8329,8353,8363,8369,
- 8377,8387,8389,8419,8423,8429,8431,8443,
- 8447,8461,8467,8501,8513,8521,8527,8537,
- 8539,8543,8563,8573,8581,8597,8599,8609,
- 8623,8627,8629,8641,8647,8663,8669,8677,
- 8681,8689,8693,8699,8707,8713,8719,8731,
- 8737,8741,8747,8753,8761,8779,8783,8803,
- 8807,8819,8821,8831,8837,8839,8849,8861,
- 8863,8867,8887,8893,8923,8929,8933,8941,
- 8951,8963,8969,8971,8999,9001,9007,9011,
- 9013,9029,9041,9043,9049,9059,9067,9091,
- 9103,9109,9127,9133,9137,9151,9157,9161,
- 9173,9181,9187,9199,9203,9209,9221,9227,
- 9239,9241,9257,9277,9281,9283,9293,9311,
- 9319,9323,9337,9341,9343,9349,9371,9377,
- 9391,9397,9403,9413,9419,9421,9431,9433,
- 9437,9439,9461,9463,9467,9473,9479,9491,
- 9497,9511,9521,9533,9539,9547,9551,9587,
- 9601,9613,9619,9623,9629,9631,9643,9649,
- 9661,9677,9679,9689,9697,9719,9721,9733,
- 9739,9743,9749,9767,9769,9781,9787,9791,
- 9803,9811,9817,9829,9833,9839,9851,9857,
- 9859,9871,9883,9887,9901,9907,9923,9929,
- 9931,9941,9949,9967,9973,10007,10009,10037,
- 10039,10061,10067,10069,10079,10091,10093,10099,
- 10103,10111,10133,10139,10141,10151,10159,10163,
- 10169,10177,10181,10193,10211,10223,10243,10247,
- 10253,10259,10267,10271,10273,10289,10301,10303,
- 10313,10321,10331,10333,10337,10343,10357,10369,
- 10391,10399,10427,10429,10433,10453,10457,10459,
- 10463,10477,10487,10499,10501,10513,10529,10531,
- 10559,10567,10589,10597,10601,10607,10613,10627,
- 10631,10639,10651,10657,10663,10667,10687,10691,
- 10709,10711,10723,10729,10733,10739,10753,10771,
- 10781,10789,10799,10831,10837,10847,10853,10859,
- 10861,10867,10883,10889,10891,10903,10909,10937,
- 10939,10949,10957,10973,10979,10987,10993,11003,
- 11027,11047,11057,11059,11069,11071,11083,11087,
- 11093,11113,11117,11119,11131,11149,11159,11161,
- 11171,11173,11177,11197,11213,11239,11243,11251,
- 11257,11261,11273,11279,11287,11299,11311,11317,
- 11321,11329,11351,11353,11369,11383,11393,11399,
- 11411,11423,11437,11443,11447,11467,11471,11483,
- 11489,11491,11497,11503,11519,11527,11549,11551,
- 11579,11587,11593,11597,11617,11621,11633,11657,
- 11677,11681,11689,11699,11701,11717,11719,11731,
- 11743,11777,11779,11783,11789,11801,11807,11813,
- 11821,11827,11831,11833,11839,11863,11867,11887,
- 11897,11903,11909,11923,11927,11933,11939,11941,
- 11953,11959,11969,11971,11981,11987,12007,12011,
- 12037,12041,12043,12049,12071,12073,12097,12101,
- 12107,12109,12113,12119,12143,12149,12157,12161,
- 12163,12197,12203,12211,12227,12239,12241,12251,
- 12253,12263,12269,12277,12281,12289,12301,12323,
- 12329,12343,12347,12373,12377,12379,12391,12401,
- 12409,12413,12421,12433,12437,12451,12457,12473,
- 12479,12487,12491,12497,12503,12511,12517,12527,
- 12539,12541,12547,12553,12569,12577,12583,12589,
- 12601,12611,12613,12619,12637,12641,12647,12653,
- 12659,12671,12689,12697,12703,12713,12721,12739,
- 12743,12757,12763,12781,12791,12799,12809,12821,
- 12823,12829,12841,12853,12889,12893,12899,12907,
- 12911,12917,12919,12923,12941,12953,12959,12967,
- 12973,12979,12983,13001,13003,13007,13009,13033,
- 13037,13043,13049,13063,13093,13099,13103,13109,
- 13121,13127,13147,13151,13159,13163,13171,13177,
- 13183,13187,13217,13219,13229,13241,13249,13259,
- 13267,13291,13297,13309,13313,13327,13331,13337,
- 13339,13367,13381,13397,13399,13411,13417,13421,
- 13441,13451,13457,13463,13469,13477,13487,13499,
- 13513,13523,13537,13553,13567,13577,13591,13597,
- 13613,13619,13627,13633,13649,13669,13679,13681,
- 13687,13691,13693,13697,13709,13711,13721,13723,
- 13729,13751,13757,13759,13763,13781,13789,13799,
- 13807,13829,13831,13841,13859,13873,13877,13879,
- 13883,13901,13903,13907,13913,13921,13931,13933,
- 13963,13967,13997,13999,14009,14011,14029,14033,
- 14051,14057,14071,14081,14083,14087,14107,14143,
- 14149,14153,14159,14173,14177,14197,14207,14221,
- 14243,14249,14251,14281,14293,14303,14321,14323,
- 14327,14341,14347,14369,14387,14389,14401,14407,
- 14411,14419,14423,14431,14437,14447,14449,14461,
- 14479,14489,14503,14519,14533,14537,14543,14549,
- 14551,14557,14561,14563,14591,14593,14621,14627,
- 14629,14633,14639,14653,14657,14669,14683,14699,
- 14713,14717,14723,14731,14737,14741,14747,14753,
- 14759,14767,14771,14779,14783,14797,14813,14821,
- 14827,14831,14843,14851,14867,14869,14879,14887,
- 14891,14897,14923,14929,14939,14947,14951,14957,
- 14969,14983,15013,15017,15031,15053,15061,15073,
- 15077,15083,15091,15101,15107,15121,15131,15137,
- 15139,15149,15161,15173,15187,15193,15199,15217,
- 15227,15233,15241,15259,15263,15269,15271,15277,
- 15287,15289,15299,15307,15313,15319,15329,15331,
- 15349,15359,15361,15373,15377,15383,15391,15401,
- 15413,15427,15439,15443,15451,15461,15467,15473,
- 15493,15497,15511,15527,15541,15551,15559,15569,
- 15581,15583,15601,15607,15619,15629,15641,15643,
- 15647,15649,15661,15667,15671,15679,15683,15727,
- 15731,15733,15737,15739,15749,15761,15767,15773,
- 15787,15791,15797,15803,15809,15817,15823,15859,
- 15877,15881,15887,15889,15901,15907,15913,15919,
- 15923,15937,15959,15971,15973,15991,16001,16007,
- 16033,16057,16061,16063,16067,16069,16073,16087,
- 16091,16097,16103,16111,16127,16139,16141,16183,
- 16187,16189,16193,16217,16223,16229,16231,16249,
- 16253,16267,16273,16301,16319,16333,16339,16349,
- 16361,16363,16369,16381,16411,16417,16421,16427,
- 16433,16447,16451,16453,16477,16481,16487,16493,
- 16519,16529,16547,16553,16561,16567,16573,16603,
- 16607,16619,16631,16633,16649,16651,16657,16661,
- 16673,16691,16693,16699,16703,16729,16741,16747,
- 16759,16763,16787,16811,16823,16829,16831,16843,
- 16871,16879,16883,16889,16901,16903,16921,16927,
- 16931,16937,16943,16963,16979,16981,16987,16993,
- 17011,17021,17027,17029,17033,17041,17047,17053,
- 17077,17093,17099,17107,17117,17123,17137,17159,
- 17167,17183,17189,17191,17203,17207,17209,17231,
- 17239,17257,17291,17293,17299,17317,17321,17327,
- 17333,17341,17351,17359,17377,17383,17387,17389,
- 17393,17401,17417,17419,17431,17443,17449,17467,
- 17471,17477,17483,17489,17491,17497,17509,17519,
- 17539,17551,17569,17573,17579,17581,17597,17599,
- 17609,17623,17627,17657,17659,17669,17681,17683,
- 17707,17713,17729,17737,17747,17749,17761,17783,
- 17789,17791,17807,17827,17837,17839,17851,17863
-};
-
-static
-Ipp32u cpMod32(const Ipp32u* pX, cpSize sizeX, Ipp32u divider)
-{
- cpSize n;
- Ipp32u r;
- for(n=sizeX, r=0; n>0; n--) {
- Ipp64u tmp = MAKEDWORD(pX[n-1],r);
- r = (Ipp32u)(tmp%divider);
- }
- return r;
-}
-
-int cpMimimalPrimeTest(const Ipp32u* pPrime, cpSize len32)
-{
- cpSize i;
-
- FIX_BNU(pPrime, len32);
-
- /* take a look in the list */
- if(1==len32) {
- for(i=0; i<(cpSize)(sizeof(PrimeList)/sizeof(Ipp32u)); i++) {
- if(pPrime[0]==PrimeList[i])
- return 1;
- }
- }
-
- /* test if value under the test is divisible by first prime numbers 2,3,5, ... */
- for(i=0; i<(cpSize)(sizeof(PrimeList)/sizeof(Ipp32u)); i++) {
- if(0 == cpMod32(pPrime, len32, PrimeList[i]))
- return 0;
- }
-
- return 1;
-}
-
-/* Rabin-Miller test */
-static
-int RabinMiller(int a,
- BNU_CHUNK_T* pZ,
- BNU_CHUNK_T* pR, cpSize nsR,
- BNU_CHUNK_T* pM, cpSize nsM,
- IppsMontState* pMont)
-{
- /* modulus and it length and other parameters */
- const BNU_CHUNK_T* pModulus = MNT_MODULUS(pMont);
- cpSize modLen = MNT_SIZE(pMont);
- BNU_CHUNK_T m0 = MNT_HELPER(pMont);
- BNU_CHUNK_T* pProduct = MNT_PRODUCT(pMont);
- BNU_CHUNK_T* pKBuffer = MNT_KBUFFER(pMont);
-
- /* compute z = r^m mod prime */
- nsR = cpMontEnc_BNU(pR, pR, nsR, pMont);
- cpMontExpBin_BNU(pZ, pR, nsR, pM, nsM, pMont);
-
- /* if z==1 => probably prime */
- if(0==cpCmp_BNU(pZ, modLen, MNT_1(pMont), modLen))
- return 1;
-
- /* if z==prime-1 => probably prime */
- cpSub_BNU(MNT_PRODUCT(pMont), pModulus, MNT_1(pMont), modLen);
- if(0==cpCmp_BNU(pZ, modLen, MNT_PRODUCT(pMont), modLen))
- return 1;
-
- while(--a) {
-
- /* z = z^2 mod w */
- cpMontSqr_BNU(pZ, pZ, modLen, pModulus, modLen, m0, pProduct, pKBuffer);
-
- /* if z==1 => definitely composite */
- if(0==cpCmp_BNU(pZ, modLen, MNT_1(pMont), modLen))
- return 1;
-
- /* if z==w-1 => probably prime */
- cpSub_BNU(MNT_PRODUCT(pMont), pModulus, MNT_1(pMont), modLen);
- if(0==cpCmp_BNU(pZ, modLen, MNT_PRODUCT(pMont), modLen))
- return 1;
- }
-
- /* if we are here, then we deal with composize */
- return 0;
-}
-
-int cpPrimeTest(const BNU_CHUNK_T* pPrime, cpSize primeLen,
- cpSize nTrials,
- IppsPrimeState* pCtx,
- IppBitSupplier rndFunc, void* pRndParam)
-{
- FIX_BNU(pPrime, primeLen);
-
- /* 0 is composite number */
- if( primeLen==1 && pPrime[0]==0)
- return 0;
-
- /* 2 is prime number */
- else if( primeLen==1 && pPrime[0]==2)
- return 1;
-
- /*
- // test number
- */
- else {
- cpSize primeBitsize = BITSIZE_BNU(pPrime, primeLen);
- cpSize primeLen32 = BITS2WORD32_SIZE(primeBitsize);
-
- /* apply easy prime test */
- if( 0==cpMimimalPrimeTest((Ipp32u*)pPrime, primeLen32) )
- return 0;
-
- /* continue test */
- else {
- cpSize n, a;
-
- IppsMontState* pMont = PRIME_MONT(pCtx);
- BNU_CHUNK_T* pMdata = PRIME_TEMP1(pCtx);
- BNU_CHUNK_T* pRdata = PRIME_TEMP2(pCtx);
- BNU_CHUNK_T* pZdata = PRIME_TEMP3(pCtx);
- cpSize lenM, lenR;
-
- /* set up Montgomery engine (and save value being under the test) */
- ippsMontSet((Ipp32u*)pPrime, primeLen32, pMont);
-
- /* express w = m*2^a + 1 */
- cpDec_BNU(pMdata, pPrime, primeLen, 1);
- for(n=0,a=0; n=1 */
- if(!cpTst_BNU(pRdata, lenR))
- pRdata[0] |= 1;
- FIX_BNU(pRdata, lenR);
-
- /* Rabin-Miller test */
- if(0==RabinMiller(a, pZdata, pRdata,lenR, pMdata,lenM, pMont))
- return 0;
- }
-
- return 1;
- }
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c
deleted file mode 100644
index 2a8af24616..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprimeginitca.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-* Copyright (C) 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 "owncp.h"
-#include "pcpprimeg.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsPrimeGetSize
-//
-// Purpose: Returns size of Prime Number Generator context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-// ippStsLengthErr 1 > maxBits
-// ippStsNoErr no error
-//
-// Parameters:
-// maxBits max length of a prime number
-// pSize pointer to the size of internal context
-*F*/
-IPPFUN(IppStatus, ippsPrimeGetSize, (cpSize maxBits, cpSize* pSize))
-{
- IPP_BAD_PTR1_RET(pSize);
- IPP_BADARG_RET(maxBits<1, ippStsLengthErr);
-
- {
- cpSize len = BITS_BNU_CHUNK(maxBits);
- cpSize len32 = BITS2WORD32_SIZE(maxBits);
- cpSize montSize;
- ippsMontGetSize(ippBinaryMethod, len32, &montSize);
-
- *pSize = sizeof(IppsPrimeState)
- +len*sizeof(BNU_CHUNK_T)
- +len*sizeof(BNU_CHUNK_T)
- +len*sizeof(BNU_CHUNK_T)
- +len*sizeof(BNU_CHUNK_T)
- +montSize
- +PRIME_ALIGNMENT-1;
-
- return ippStsNoErr;
- }
-}
-
-
-/*F*
-// Name: ippsPrimeInit
-//
-// Purpose: Initializes Prime Number Generator context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pCtx
-// ippStsLengthErr 1 > maxBits
-// ippStsNoErr no error
-//
-// Parameters:
-// maxBits max length of a prime number
-// pCtx pointer to the context to be initialized
-*F*/
-IPPFUN(IppStatus, ippsPrimeInit, (cpSize maxBits, IppsPrimeState* pCtx))
-{
- IPP_BAD_PTR1_RET(pCtx);
- IPP_BADARG_RET(maxBits<1, ippStsLengthErr);
-
- /* use aligned PRNG context */
- pCtx = (IppsPrimeState*)( IPP_ALIGNED_PTR(pCtx, PRIME_ALIGNMENT) );
-
- {
- Ipp8u* ptr = (Ipp8u*)pCtx;
-
- cpSize len = BITS_BNU_CHUNK(maxBits);
- cpSize len32 = BITS2WORD32_SIZE(maxBits);
-
- PRIME_ID(pCtx) = idCtxPrimeNumber;
- PRIME_MAXBITSIZE(pCtx) = maxBits;
-
- ptr += sizeof(IppsPrimeState);
- PRIME_NUMBER(pCtx) = (BNU_CHUNK_T*)ptr;
-
- ptr += len*sizeof(BNU_CHUNK_T);
- PRIME_TEMP1(pCtx) = (BNU_CHUNK_T*)ptr;
-
- ptr += len*sizeof(BNU_CHUNK_T);
- PRIME_TEMP2(pCtx) = (BNU_CHUNK_T*)ptr;
-
- ptr += len*sizeof(BNU_CHUNK_T);
- PRIME_TEMP3(pCtx) = (BNU_CHUNK_T*)ptr;
-
- ptr += len*sizeof(BNU_CHUNK_T);
- PRIME_MONT(pCtx) = (IppsMontState*)( IPP_ALIGNED_PTR((ptr), MONT_ALIGNMENT) );
- ippsMontInit(ippBinaryMethod, len32, PRIME_MONT(pCtx));
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprng.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprng.h
deleted file mode 100644
index 2c0201df48..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprng.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_CP_PRNG_H)
-#define _CP_PRNG_H
-
-/*
-// Pseudo-random generation context
-*/
-
-#define MAX_XKEY_SIZE 512
-#define DEFAULT_XKEY_SIZE 512 /* must be >=160 || <=512 */
-
-struct _cpPRNG {
- IppCtxId idCtx; /* PRNG identifier */
- cpSize seedBits; /* secret seed-key bitsize */
- BNU_CHUNK_T Q[BITS_BNU_CHUNK(160)]; /* modulus */
- BNU_CHUNK_T T[BITS_BNU_CHUNK(160)]; /* parameter of SHA_G() funct */
- BNU_CHUNK_T xAug[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* optional entropy augment */
- BNU_CHUNK_T xKey[BITS_BNU_CHUNK(MAX_XKEY_SIZE)]; /* secret seed-key */
-};
-
-/* alignment */
-#define PRNG_ALIGNMENT ((int)(sizeof(void*)))
-
-#define RAND_ID(ctx) ((ctx)->idCtx)
-#define RAND_SEEDBITS(ctx) ((ctx)->seedBits)
-#define RAND_Q(ctx) ((ctx)->Q)
-#define RAND_T(ctx) ((ctx)->T)
-#define RAND_XAUGMENT(ctx) ((ctx)->xAug)
-#define RAND_XKEY(ctx) ((ctx)->xKey)
-
-#define RAND_VALID_ID(ctx) (RAND_ID((ctx))==idCtxPRNG)
-
-int cpPRNGen(Ipp32u* pBuffer, cpSize bitLen, IppsPRNGState* pCtx);
-
-#endif /* _CP_PRNG_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprngenca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprngenca.c
deleted file mode 100644
index 066c3caa54..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprngenca.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcphash.h"
-#include "pcpprng.h"
-#include "pcptool.h"
-
-/*
-// G() function based on SHA1
-//
-// Parameters:
-// T 160 bit parameter
-// pHexStr input hex string
-// hexStrLen size of hex string (Ipp8u segnments)
-// xBNU 160 bit BNU result
-//
-// Note 1:
-// must to be hexStrLen <= 64 (512 bits)
-*/
-static
-void SHA1_G(Ipp32u* xBNU, const Ipp32u* T, Ipp8u* pHexStr, int hexStrLen)
-{
- /* select processing function */
- cpHashProc updateFunc = UpdateSHA1;
-
- /* pad HexString zeros */
- PaddBlock(0, pHexStr+hexStrLen, BITS2WORD8_SIZE(MAX_XKEY_SIZE)-hexStrLen);
-
- /* reset initial HASH value */
- xBNU[0] = T[0];
- xBNU[1] = T[1];
- xBNU[2] = T[2];
- xBNU[3] = T[3];
- xBNU[4] = T[4];
-
- /* SHA1 */
- //UpdateSHA1(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
- updateFunc(xBNU, pHexStr, BITS2WORD8_SIZE(MAX_XKEY_SIZE), SHA1_cnt);
-
- /* swap back */
- SWAP(xBNU[0],xBNU[4]);
- SWAP(xBNU[1],xBNU[3]);
-}
-
-/*
-// Returns bitsize of the bitstring has beed added
-*/
-int cpPRNGen(Ipp32u* pRand, cpSize nBits, IppsPRNGState* pRnd)
-{
- BNU_CHUNK_T Xj [BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
- BNU_CHUNK_T XVAL[BITS_BNU_CHUNK(MAX_XKEY_SIZE)];
-
- Ipp8u TXVAL[BITS2WORD8_SIZE(MAX_XKEY_SIZE)];
-
- /* XKEY length in BNU_CHUNK_T */
- cpSize xKeyLen = BITS_BNU_CHUNK(RAND_SEEDBITS(pRnd));
- /* XKEY length in bytes */
- cpSize xKeySize= BITS2WORD8_SIZE(RAND_SEEDBITS(pRnd));
- /* XKEY word's mask */
- BNU_CHUNK_T xKeyMsk = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd));
-
- /* number of Ipp32u chunks to be generated */
- cpSize genlen = BITS2WORD32_SIZE(nBits);
-
- ZEXPAND_BNU(Xj, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
- ZEXPAND_BNU(XVAL, 0, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
-
- while(genlen) {
- cpSize len;
-
- /* Step 1: XVAL=(Xkey+Xseed) mod 2^b */
- BNU_CHUNK_T carry = cpAdd_BNU(XVAL, RAND_XKEY(pRnd), RAND_XAUGMENT(pRnd), xKeyLen);
- XVAL[xKeyLen-1] &= xKeyMsk;
-
- /* Step 2: xj=G(t, XVAL) mod Q */
- cpToOctStr_BNU(TXVAL, xKeySize, XVAL, xKeyLen);
- SHA1_G((Ipp32u*)Xj, (Ipp32u*)RAND_T(pRnd), TXVAL, xKeySize);
-
- {
- cpSize sizeXj = BITS_BNU_CHUNK(160);
- if(0 <= cpCmp_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd),BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE)) )
- sizeXj = cpMod_BNU(Xj, BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE), RAND_Q(pRnd), BITS_BNU_CHUNK(IPP_SHA1_DIGEST_BITSIZE));
- FIX_BNU(Xj, sizeXj);
- ZEXPAND_BNU(Xj, sizeXj, BITS_BNU_CHUNK(MAX_XKEY_SIZE));
- }
-
- /* Step 3: Xkey=(1+Xkey+Xj) mod 2^b */
- cpInc_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), xKeyLen, 1);
- carry = cpAdd_BNU(RAND_XKEY(pRnd), RAND_XKEY(pRnd), Xj, xKeyLen);
- RAND_XKEY(pRnd)[xKeyLen-1] &= xKeyMsk;
-
- /* fill out result */
- len = genlenidCtx
-//
-// ippStsLengthErr 1 > nBits
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pBuffer pointer to the buffer
-// nBits number of bits be requested
-// pRndCtx pointer to the context
-*F*/
-IPPFUN(IppStatus, ippsPRNGen,(Ipp32u* pBuffer, cpSize nBits, void* pRnd))
-{
- IppsPRNGState* pRndCtx = (IppsPRNGState*)pRnd;
-
- /* test PRNG context */
- IPP_BAD_PTR2_RET(pBuffer, pRnd);
-
- pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRndCtx, PRNG_ALIGNMENT) );
- IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr);
-
- /* test sizes */
- IPP_BADARG_RET(nBits< 1, ippStsLengthErr);
-
- {
- cpSize rndSize = BITS2WORD32_SIZE(nBits);
- Ipp32u rndMask = MAKEMASK32(nBits);
-
- cpPRNGen(pBuffer, nBits, pRndCtx);
- pBuffer[rndSize-1] &= rndMask;
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprnginitca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprnginitca.c
deleted file mode 100644
index 9f42b23ff8..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpprnginitca.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-
-#include "owncp.h"
-#include "pcpbn.h"
-#include "pcpprng.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsPRNGGetSize
-//
-// Purpose: Returns size of PRNG context (bytes).
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pSize
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// pSize pointer to the size of internal context
-*F*/
-IPPFUN(IppStatus, ippsPRNGGetSize, (int* pSize))
-{
- IPP_BAD_PTR1_RET(pSize);
-
- *pSize = sizeof(IppsPRNGState)
- +PRNG_ALIGNMENT-1;
- return ippStsNoErr;
-}
-
-
-/*F*
-// Name: ippsPRNGInit
-//
-// Purpose: Initializes PRNG context
-//
-// Returns: Reason:
-// ippStsNullPtrErr NULL == pRnd
-//
-// ippStsLengthErr seedBits < 1
-// seedBits < MAX_XKEY_SIZE
-// seedBits%8 !=0
-//
-// ippStsNoErr no error
-//
-// Parameters:
-// seedBits seed bitsize
-// pRnd pointer to the context to be initialized
-*F*/
-IPPFUN(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pRnd))
-{
- /* test PRNG context */
- IPP_BAD_PTR1_RET(pRnd);
- pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) );
-
- /* test sizes */
- IPP_BADARG_RET((1>seedBits) || (seedBits>MAX_XKEY_SIZE) ||(seedBits&7), ippStsLengthErr);
-
- {
- int hashIvSize = cpHashIvSize(ippHashAlg_SHA1);
- const Ipp8u* iv = cpHashIV[ippHashAlg_SHA1];
-
- /* cleanup context */
- ZEXPAND_BNU((Ipp8u*)pRnd, 0, (cpSize)(sizeof(IppsPRNGState)));
-
- RAND_ID(pRnd) = idCtxPRNG;
- RAND_SEEDBITS(pRnd) = seedBits;
-
- /* default Q parameter */
- ((Ipp32u*)RAND_Q(pRnd))[0] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[1] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[2] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[3] = 0xFFFFFFFF;
- ((Ipp32u*)RAND_Q(pRnd))[4] = 0xFFFFFFFF;
-
- /* default T parameter */
- CopyBlock(iv, RAND_T(pRnd), hashIvSize);
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij.h
deleted file mode 100644
index f2e59a558d..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_RIJ_H)
-#define _PCP_RIJ_H
-
-
-/*
-// The GF(256) modular polynomial and elements
-*/
-#define WPOLY 0x011B
-#define BPOLY 0x1B
-
-/*
-// Make WORD using 4 arbitrary bytes
-*/
-#define BYTES_TO_WORD(b0,b1,b2,b3) ( ( ((Ipp32u)((Ipp8u)(b3))) <<24 ) \
- |( ((Ipp32u)((Ipp8u)(b2))) <<16 ) \
- |( ((Ipp32u)((Ipp8u)(b1))) << 8 ) \
- |( ((Ipp32u)((Ipp8u)(b0))) ) )
-/*
-// Make WORD setting byte in specified position
-*/
-#define BYTE0_TO_WORD(b) BYTES_TO_WORD((b), 0, 0, 0)
-#define BYTE1_TO_WORD(b) BYTES_TO_WORD( 0, (b), 0, 0)
-#define BYTE2_TO_WORD(b) BYTES_TO_WORD( 0, 0, (b), 0)
-#define BYTE3_TO_WORD(b) BYTES_TO_WORD( 0, 0, 0, (b))
-
-/*
-// Extract byte from specified position n.
-// Sure, n=0,1,2 or 3 only
-*/
-#define EBYTE(w,n) ((Ipp8u)((w) >> (8 * (n))))
-
-
-/*
-// Rijndael's spec
-*/
-typedef void (*RijnCipher)(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
-
-struct _cpRijndael128 {
- IppCtxId idCtx; /* Rijndael spec identifier */
- int nk; /* security key length (words) */
- int nb; /* data block size (words) */
- int nr; /* number of rounds */
- RijnCipher encoder; /* encoder/decoder */
- RijnCipher decoder; /* entry point */
- Ipp32u* pEncTbl; /* expanded S-boxes for */
- Ipp32u* pDecTbl; /* encryption and decryption */
- Ipp32u enc_keys[64]; /* array of keys for encryprion */
- Ipp32u dec_keys[64]; /* array of keys for decryprion */
- Ipp32u aesNI; /* AES instruction available */
- Ipp32u safeInit; /* SafeInit performed */
-};
-
-/* alignment */
-#define RIJ_ALIGNMENT (16)
-
-#define MBS_RIJ128 (128/8) /* message block size (bytes) */
-#define MBS_RIJ192 (192/8)
-#define MBS_RIJ256 (256/8)
-
-#define SR (4) /* number of rows in STATE data */
-
-#define NB(msgBlks) ((msgBlks)/32) /* message block size (words) */
- /* 4-word for 128-bits data block */
- /* 6-word for 192-bits data block */
- /* 8-word for 256-bits data block */
-
-#define NK(keybits) ((keybits)/32) /* key length (words): */
-#define NK128 NK(ippRijndaelKey128)/* 4-word for 128-bits security key */
-#define NK192 NK(ippRijndaelKey192)/* 6-word for 192-bits security key */
-#define NK256 NK(ippRijndaelKey256)/* 8-word for 256-bits security key */
-
-#define NR128_128 (10) /* number of rounds data: 128 bits key: 128 bits are used */
-#define NR128_192 (12) /* number of rounds data: 128 bits key: 192 bits are used */
-#define NR128_256 (14) /* number of rounds data: 128 bits key: 256 bits are used */
-#define NR192_128 (12) /* number of rounds data: 192 bits key: 128 bits are used */
-#define NR192_192 (12) /* number of rounds data: 192 bits key: 192 bits are used */
-#define NR192_256 (14) /* number of rounds data: 192 bits key: 256 bits are used */
-#define NR256_128 (14) /* number of rounds data: 256 bits key: 128 bits are used */
-#define NR256_192 (14) /* number of rounds data: 256 bits key: 192 bits are used */
-#define NR256_256 (14) /* number of rounds data: 256 bits key: 256 bits are used */
-
-/*
-// Useful macros
-*/
-#define RIJ_ID(ctx) ((ctx)->idCtx)
-#define RIJ_NB(ctx) ((ctx)->nb)
-#define RIJ_NK(ctx) ((ctx)->nk)
-#define RIJ_NR(ctx) ((ctx)->nr)
-#define RIJ_ENCODER(ctx) ((ctx)->encoder)
-#define RIJ_DECODER(ctx) ((ctx)->decoder)
-#define RIJ_ENC_SBOX(ctx) ((ctx)->pEncTbl)
-#define RIJ_DEC_SBOX(ctx) ((ctx)->pDecTbl)
-#define RIJ_EKEYS(ctx) (Ipp8u*)((ctx)->enc_keys)
-#define RIJ_DKEYS(ctx) (Ipp8u*)((ctx)->dec_keys)
-#define RIJ_AESNI(ctx) ((ctx)->aesNI)
-#define RIJ_SAFE_INIT(ctx) ((ctx)->safeInit)
-
-#define RIJ_ID_TEST(ctx) (RIJ_ID((ctx))==idCtxRijndael)
-
-/*
-// Internal functions
-*/
-
-void Safe2Encrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
-void Safe2Decrypt_RIJ128(const Ipp8u* pInpBlk, Ipp8u* pOutBlk, int nr, const Ipp8u* pKeys, const void* pTbl);
-
-void ExpandRijndaelKey(const Ipp8u* pKey, int NK, int NB, int NR, int nKeys,
- Ipp8u* pEncKeys, Ipp8u* pDecKeys);
-
-#endif /* _PCP_RIJ_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safe2.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safe2.h
deleted file mode 100644
index c407edd470..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safe2.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PCP_RIJ_SAFE2_H)
-#define _PCP_RIJ_SAFE2_H
-
-// transpose 4x4 Ipp8u matrix
-#define TRANSPOSE(out, inp) \
- (out)[ 0] = (inp)[ 0]; \
- (out)[ 4] = (inp)[ 1]; \
- (out)[ 8] = (inp)[ 2]; \
- (out)[12] = (inp)[ 3]; \
- \
- (out)[ 1] = (inp)[ 4]; \
- (out)[ 5] = (inp)[ 5]; \
- (out)[ 9] = (inp)[ 6]; \
- (out)[13] = (inp)[ 7]; \
- \
- (out)[ 2] = (inp)[ 8]; \
- (out)[ 6] = (inp)[ 9]; \
- (out)[10] = (inp)[10]; \
- (out)[14] = (inp)[11]; \
- \
- (out)[ 3] = (inp)[12]; \
- (out)[ 7] = (inp)[13]; \
- (out)[11] = (inp)[14]; \
- (out)[15] = (inp)[15]
-
-__INLINE void XorRoundKey(Ipp32u* state, const Ipp32u* RoundKey)
-{
- state[0] ^= RoundKey[0];
- state[1] ^= RoundKey[1];
- state[2] ^= RoundKey[2];
- state[3] ^= RoundKey[3];
-}
-
-// xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b}
-__INLINE Ipp32u mask4(Ipp32u x)
-{
- x &= 0x80808080;
- return (Ipp32u)((x<<1) - (x>>7));
-}
-
-__INLINE Ipp32u xtime4(Ipp32u x)
-{
- Ipp32u t = (x+x) &0xFEFEFEFE;
- t ^= mask4(x) & 0x1B1B1B1B;
- return t;
-}
-
-#endif /* _PCP_RIJ_SAFE2_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c
deleted file mode 100644
index 8dbbb21ae4..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safedec2pxca.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-#include "pcprij128safe2.h"
-#include "pcprijtables.h"
-
-
-__INLINE Ipp8u getInvSboxValue(Ipp32u x)
-{
- Ipp32u t[sizeof(RijDecSbox)/CACHE_LINE_SIZE];
- const Ipp8u* SboxEntry = RijDecSbox +x%CACHE_LINE_SIZE;
- Ipp32u i;
- for(i=0; i0;round--) {
- invShiftRows(state);
- invSubBytes((Ipp8u*)state);
- XorRoundKey(state,(Ipp32u*)(RoundKey+round*16));
- invMixColumns(state);
- }
-
- // last round
- invShiftRows(state);
- invSubBytes((Ipp8u*)state);
- XorRoundKey(state,(Ipp32u*)(RoundKey+0*16));
-
- // copy from the state to output
- TRANSPOSE(out, (Ipp8u*)state);
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c
deleted file mode 100644
index c59006df7b..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcprij128safeenc2pxca.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-
-#include "pcprij128safe2.h"
-#include "pcprijtables.h"
-
-
-__INLINE Ipp8u getSboxValue(Ipp32u x)
-{
- Ipp32u t[sizeof(RijEncSbox)/CACHE_LINE_SIZE];
- const Ipp8u* SboxEntry = RijEncSbox +x%CACHE_LINE_SIZE;
- Ipp32u i;
- for(i=0; i>7) & 1) * WPOLY))
-#define gf_m4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))
-#define gf_m8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \
- ^ (((x>>5) & 4) * WPOLY))
-#define gf_m1(x) ((x))
-#define gf_m3(x) (gf_m2(x) ^ x)
-#define gf_m9(x) (gf_m8(x) ^ x)
-#define gf_mB(x) (gf_m8(x) ^ gf_m2(x) ^ x)
-#define gf_mD(x) (gf_m8(x) ^ gf_m4(x) ^ x)
-#define gf_mE(x) (gf_m8(x) ^ gf_m4(x) ^ gf_m2(x))
-
-/*
-// The following particular transformations
-// are used for create Encryption Tables
-*/
-#define fwd_t0(x) BYTES_TO_WORD(gf_m2(x), gf_m1(x), gf_m1(x), gf_m3(x))
-#define fwd_t1(x) BYTES_TO_WORD(gf_m3(x), gf_m2(x), gf_m1(x), gf_m1(x))
-#define fwd_t2(x) BYTES_TO_WORD(gf_m1(x), gf_m3(x), gf_m2(x), gf_m1(x))
-#define fwd_t3(x) BYTES_TO_WORD(gf_m1(x), gf_m1(x), gf_m3(x), gf_m2(x))
-
-/*
-// The following particular transformations
-// are used for create Decryption Tables
-*/
-#define inv_t0(x) BYTES_TO_WORD(gf_mE(x), gf_m9(x), gf_mD(x), gf_mB(x))
-#define inv_t1(x) BYTES_TO_WORD(gf_mB(x), gf_mE(x), gf_m9(x), gf_mD(x))
-#define inv_t2(x) BYTES_TO_WORD(gf_mD(x), gf_mB(x), gf_mE(x), gf_m9(x))
-#define inv_t3(x) BYTES_TO_WORD(gf_m9(x), gf_mD(x), gf_mB(x), gf_mE(x))
-
-#define exp_b3(x) BYTES_TO_WORD(0, 0, 0, (x))
-#define exp_b2(x) BYTES_TO_WORD(0, 0, (x),0)
-#define exp_b1(x) BYTES_TO_WORD(0, (x),0, 0)
-#define exp_b0(x) BYTES_TO_WORD((x),0, 0, 0)
-
-/*
-// The following particular transformations
-// are used for create pure Encryption/Decryption Sboxes
-*/
-#define none_t(x) (x)
-
-
-/*
-// Just sequence of byte, beginning 0x00 upto 0xff
-// (be parametrized by any transformation 't')
-*/
-#define LINE(t) \
- t(0x00), t(0x01), t(0x02), t(0x03), t(0x04), t(0x05), t(0x06), t(0x07),\
- t(0x08), t(0x09), t(0x0a), t(0x0b), t(0x0c), t(0x0d), t(0x0e), t(0x0f),\
- t(0x10), t(0x11), t(0x12), t(0x13), t(0x14), t(0x15), t(0x16), t(0x17),\
- t(0x18), t(0x19), t(0x1a), t(0x1b), t(0x1c), t(0x1d), t(0x1e), t(0x1f),\
- t(0x20), t(0x21), t(0x22), t(0x23), t(0x24), t(0x25), t(0x26), t(0x27),\
- t(0x28), t(0x29), t(0x2a), t(0x2b), t(0x2c), t(0x2d), t(0x2e), t(0x2f),\
- t(0x30), t(0x31), t(0x32), t(0x33), t(0x34), t(0x35), t(0x36), t(0x37),\
- t(0x38), t(0x39), t(0x3a), t(0x3b), t(0x3c), t(0x3d), t(0x3e), t(0x3f),\
- t(0x40), t(0x41), t(0x42), t(0x43), t(0x44), t(0x45), t(0x46), t(0x47),\
- t(0x48), t(0x49), t(0x4a), t(0x4b), t(0x4c), t(0x4d), t(0x4e), t(0x4f),\
- t(0x50), t(0x51), t(0x52), t(0x53), t(0x54), t(0x55), t(0x56), t(0x57),\
- t(0x58), t(0x59), t(0x5a), t(0x5b), t(0x5c), t(0x5d), t(0x5e), t(0x5f),\
- t(0x60), t(0x61), t(0x62), t(0x63), t(0x64), t(0x65), t(0x66), t(0x67),\
- t(0x68), t(0x69), t(0x6a), t(0x6b), t(0x6c), t(0x6d), t(0x6e), t(0x6f),\
- t(0x70), t(0x71), t(0x72), t(0x73), t(0x74), t(0x75), t(0x76), t(0x77),\
- t(0x78), t(0x79), t(0x7a), t(0x7b), t(0x7c), t(0x7d), t(0x7e), t(0x7f),\
- t(0x80), t(0x81), t(0x82), t(0x83), t(0x84), t(0x85), t(0x86), t(0x87),\
- t(0x88), t(0x89), t(0x8a), t(0x8b), t(0x8c), t(0x8d), t(0x8e), t(0x8f),\
- t(0x90), t(0x91), t(0x92), t(0x93), t(0x94), t(0x95), t(0x96), t(0x97),\
- t(0x98), t(0x99), t(0x9a), t(0x9b), t(0x9c), t(0x9d), t(0x9e), t(0x9f),\
- t(0xa0), t(0xa1), t(0xa2), t(0xa3), t(0xa4), t(0xa5), t(0xa6), t(0xa7),\
- t(0xa8), t(0xa9), t(0xaa), t(0xab), t(0xac), t(0xad), t(0xae), t(0xaf),\
- t(0xb0), t(0xb1), t(0xb2), t(0xb3), t(0xb4), t(0xb5), t(0xb6), t(0xb7),\
- t(0xb8), t(0xb9), t(0xba), t(0xbb), t(0xbc), t(0xbd), t(0xbe), t(0xbf),\
- t(0xc0), t(0xc1), t(0xc2), t(0xc3), t(0xc4), t(0xc5), t(0xc6), t(0xc7),\
- t(0xc8), t(0xc9), t(0xca), t(0xcb), t(0xcc), t(0xcd), t(0xce), t(0xcf),\
- t(0xd0), t(0xd1), t(0xd2), t(0xd3), t(0xd4), t(0xd5), t(0xd6), t(0xd7),\
- t(0xd8), t(0xd9), t(0xda), t(0xdb), t(0xdc), t(0xdd), t(0xde), t(0xdf),\
- t(0xe0), t(0xe1), t(0xe2), t(0xe3), t(0xe4), t(0xe5), t(0xe6), t(0xe7),\
- t(0xe8), t(0xe9), t(0xea), t(0xeb), t(0xec), t(0xed), t(0xee), t(0xef),\
- t(0xf0), t(0xf1), t(0xf2), t(0xf3), t(0xf4), t(0xf5), t(0xf6), t(0xf7),\
- t(0xf8), t(0xf9), t(0xfa), t(0xfb), t(0xfc), t(0xfd), t(0xfe), t(0xff)
-
-/*
-// Encrypt/Decrypt S-box data
-// (be parametrized by any transformation 't')
-*/
-#define ENC_SBOX(t) \
- t(0x63), t(0x7c), t(0x77), t(0x7b), t(0xf2), t(0x6b), t(0x6f), t(0xc5),\
- t(0x30), t(0x01), t(0x67), t(0x2b), t(0xfe), t(0xd7), t(0xab), t(0x76),\
- t(0xca), t(0x82), t(0xc9), t(0x7d), t(0xfa), t(0x59), t(0x47), t(0xf0),\
- t(0xad), t(0xd4), t(0xa2), t(0xaf), t(0x9c), t(0xa4), t(0x72), t(0xc0),\
- t(0xb7), t(0xfd), t(0x93), t(0x26), t(0x36), t(0x3f), t(0xf7), t(0xcc),\
- t(0x34), t(0xa5), t(0xe5), t(0xf1), t(0x71), t(0xd8), t(0x31), t(0x15),\
- t(0x04), t(0xc7), t(0x23), t(0xc3), t(0x18), t(0x96), t(0x05), t(0x9a),\
- t(0x07), t(0x12), t(0x80), t(0xe2), t(0xeb), t(0x27), t(0xb2), t(0x75),\
- t(0x09), t(0x83), t(0x2c), t(0x1a), t(0x1b), t(0x6e), t(0x5a), t(0xa0),\
- t(0x52), t(0x3b), t(0xd6), t(0xb3), t(0x29), t(0xe3), t(0x2f), t(0x84),\
- t(0x53), t(0xd1), t(0x00), t(0xed), t(0x20), t(0xfc), t(0xb1), t(0x5b),\
- t(0x6a), t(0xcb), t(0xbe), t(0x39), t(0x4a), t(0x4c), t(0x58), t(0xcf),\
- t(0xd0), t(0xef), t(0xaa), t(0xfb), t(0x43), t(0x4d), t(0x33), t(0x85),\
- t(0x45), t(0xf9), t(0x02), t(0x7f), t(0x50), t(0x3c), t(0x9f), t(0xa8),\
- t(0x51), t(0xa3), t(0x40), t(0x8f), t(0x92), t(0x9d), t(0x38), t(0xf5),\
- t(0xbc), t(0xb6), t(0xda), t(0x21), t(0x10), t(0xff), t(0xf3), t(0xd2),\
- t(0xcd), t(0x0c), t(0x13), t(0xec), t(0x5f), t(0x97), t(0x44), t(0x17),\
- t(0xc4), t(0xa7), t(0x7e), t(0x3d), t(0x64), t(0x5d), t(0x19), t(0x73),\
- t(0x60), t(0x81), t(0x4f), t(0xdc), t(0x22), t(0x2a), t(0x90), t(0x88),\
- t(0x46), t(0xee), t(0xb8), t(0x14), t(0xde), t(0x5e), t(0x0b), t(0xdb),\
- t(0xe0), t(0x32), t(0x3a), t(0x0a), t(0x49), t(0x06), t(0x24), t(0x5c),\
- t(0xc2), t(0xd3), t(0xac), t(0x62), t(0x91), t(0x95), t(0xe4), t(0x79),\
- t(0xe7), t(0xc8), t(0x37), t(0x6d), t(0x8d), t(0xd5), t(0x4e), t(0xa9),\
- t(0x6c), t(0x56), t(0xf4), t(0xea), t(0x65), t(0x7a), t(0xae), t(0x08),\
- t(0xba), t(0x78), t(0x25), t(0x2e), t(0x1c), t(0xa6), t(0xb4), t(0xc6),\
- t(0xe8), t(0xdd), t(0x74), t(0x1f), t(0x4b), t(0xbd), t(0x8b), t(0x8a),\
- t(0x70), t(0x3e), t(0xb5), t(0x66), t(0x48), t(0x03), t(0xf6), t(0x0e),\
- t(0x61), t(0x35), t(0x57), t(0xb9), t(0x86), t(0xc1), t(0x1d), t(0x9e),\
- t(0xe1), t(0xf8), t(0x98), t(0x11), t(0x69), t(0xd9), t(0x8e), t(0x94),\
- t(0x9b), t(0x1e), t(0x87), t(0xe9), t(0xce), t(0x55), t(0x28), t(0xdf),\
- t(0x8c), t(0xa1), t(0x89), t(0x0d), t(0xbf), t(0xe6), t(0x42), t(0x68),\
- t(0x41), t(0x99), t(0x2d), t(0x0f), t(0xb0), t(0x54), t(0xbb), t(0x16)
-
-#define DEC_SBOX(t) \
- t(0x52), t(0x09), t(0x6a), t(0xd5), t(0x30), t(0x36), t(0xa5), t(0x38),\
- t(0xbf), t(0x40), t(0xa3), t(0x9e), t(0x81), t(0xf3), t(0xd7), t(0xfb),\
- t(0x7c), t(0xe3), t(0x39), t(0x82), t(0x9b), t(0x2f), t(0xff), t(0x87),\
- t(0x34), t(0x8e), t(0x43), t(0x44), t(0xc4), t(0xde), t(0xe9), t(0xcb),\
- t(0x54), t(0x7b), t(0x94), t(0x32), t(0xa6), t(0xc2), t(0x23), t(0x3d),\
- t(0xee), t(0x4c), t(0x95), t(0x0b), t(0x42), t(0xfa), t(0xc3), t(0x4e),\
- t(0x08), t(0x2e), t(0xa1), t(0x66), t(0x28), t(0xd9), t(0x24), t(0xb2),\
- t(0x76), t(0x5b), t(0xa2), t(0x49), t(0x6d), t(0x8b), t(0xd1), t(0x25),\
- t(0x72), t(0xf8), t(0xf6), t(0x64), t(0x86), t(0x68), t(0x98), t(0x16),\
- t(0xd4), t(0xa4), t(0x5c), t(0xcc), t(0x5d), t(0x65), t(0xb6), t(0x92),\
- t(0x6c), t(0x70), t(0x48), t(0x50), t(0xfd), t(0xed), t(0xb9), t(0xda),\
- t(0x5e), t(0x15), t(0x46), t(0x57), t(0xa7), t(0x8d), t(0x9d), t(0x84),\
- t(0x90), t(0xd8), t(0xab), t(0x00), t(0x8c), t(0xbc), t(0xd3), t(0x0a),\
- t(0xf7), t(0xe4), t(0x58), t(0x05), t(0xb8), t(0xb3), t(0x45), t(0x06),\
- t(0xd0), t(0x2c), t(0x1e), t(0x8f), t(0xca), t(0x3f), t(0x0f), t(0x02),\
- t(0xc1), t(0xaf), t(0xbd), t(0x03), t(0x01), t(0x13), t(0x8a), t(0x6b),\
- t(0x3a), t(0x91), t(0x11), t(0x41), t(0x4f), t(0x67), t(0xdc), t(0xea),\
- t(0x97), t(0xf2), t(0xcf), t(0xce), t(0xf0), t(0xb4), t(0xe6), t(0x73),\
- t(0x96), t(0xac), t(0x74), t(0x22), t(0xe7), t(0xad), t(0x35), t(0x85),\
- t(0xe2), t(0xf9), t(0x37), t(0xe8), t(0x1c), t(0x75), t(0xdf), t(0x6e),\
- t(0x47), t(0xf1), t(0x1a), t(0x71), t(0x1d), t(0x29), t(0xc5), t(0x89),\
- t(0x6f), t(0xb7), t(0x62), t(0x0e), t(0xaa), t(0x18), t(0xbe), t(0x1b),\
- t(0xfc), t(0x56), t(0x3e), t(0x4b), t(0xc6), t(0xd2), t(0x79), t(0x20),\
- t(0x9a), t(0xdb), t(0xc0), t(0xfe), t(0x78), t(0xcd), t(0x5a), t(0xf4),\
- t(0x1f), t(0xdd), t(0xa8), t(0x33), t(0x88), t(0x07), t(0xc7), t(0x31),\
- t(0xb1), t(0x12), t(0x10), t(0x59), t(0x27), t(0x80), t(0xec), t(0x5f),\
- t(0x60), t(0x51), t(0x7f), t(0xa9), t(0x19), t(0xb5), t(0x4a), t(0x0d),\
- t(0x2d), t(0xe5), t(0x7a), t(0x9f), t(0x93), t(0xc9), t(0x9c), t(0xef),\
- t(0xa0), t(0xe0), t(0x3b), t(0x4d), t(0xae), t(0x2a), t(0xf5), t(0xb0),\
- t(0xc8), t(0xeb), t(0xbb), t(0x3c), t(0x83), t(0x53), t(0x99), t(0x61),\
- t(0x17), t(0x2b), t(0x04), t(0x7e), t(0xba), t(0x77), t(0xd6), t(0x26),\
- t(0xe1), t(0x69), t(0x14), t(0x63), t(0x55), t(0x21), t(0x0c), t(0x7d),
-
-/*
-// Internal cipher tables
-*/
-extern const __ALIGN64 Ipp8u RijEncSbox[256]; /* pure encryption S-box */
-extern const __ALIGN64 Ipp8u RijDecSbox[256]; /* pure decryption S-box */
-
-#endif /* _PCP_RIJTBLES_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpscramble.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpscramble.h
deleted file mode 100644
index 9518ef6ada..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpscramble.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PC_SCRAMBLE_H)
-#define _PC_SCRAMBLE_H
-
-/*
-// cpsScramblePut/cpsScrambleGet
-// stores to/retrieves from pScrambleEntry position
-// pre-computed data if fixed window method is used
-*/
-__INLINE void cpScramblePut(Ipp8u* pArray, cpSize colummSize,
- const Ipp32u* pData, cpSize dataSize)
-{
- int i;
- switch(colummSize) {
- case 1:
- dataSize *= sizeof(Ipp32u);
- for(i=0; i=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) {
- ((Ipp32u*)pArray)[0] = pData[0];
- ((Ipp32u*)pArray)[1] = pData[1];
- }
- if(dataSize)
- ((Ipp32u*)pArray)[0] = pData[0];
- break;
- case 16:
- for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) {
- ((Ipp32u*)pArray)[0] = pData[0];
- ((Ipp32u*)pArray)[1] = pData[1];
- ((Ipp32u*)pArray)[2] = pData[2];
- ((Ipp32u*)pArray)[3] = pData[3];
- }
- for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
- ((Ipp32u*)pArray)[0] = pData[0];
- break;
- case 32:
- for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) {
- ((Ipp32u*)pArray)[0] = pData[0];
- ((Ipp32u*)pArray)[1] = pData[1];
- ((Ipp32u*)pArray)[2] = pData[2];
- ((Ipp32u*)pArray)[3] = pData[3];
- ((Ipp32u*)pArray)[4] = pData[4];
- ((Ipp32u*)pArray)[5] = pData[5];
- ((Ipp32u*)pArray)[6] = pData[6];
- ((Ipp32u*)pArray)[7] = pData[7];
- }
- for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
- ((Ipp32u*)pArray)[0] = pData[0];
- break;
- default:
- break;
- }
-}
-
-
-/*
-// Retrieve data from pArray
-*/
-#define u8_to_u32(b0,b1,b2,b3, x) \
- ((x) = (b0), \
- (x)|=((b1)<<8), \
- (x)|=((b2)<<16), \
- (x)|=((b3)<<24))
-#define u16_to_u32(w0,w1, x) \
- ((x) = (w0), \
- (x)|=((w1)<<16))
-#define u32_to_u64(dw0,dw1, x) \
- ((x) = (Ipp64u)(dw0), \
- (x)|= (((Ipp64u)(dw1))<<32))
-
-__INLINE void cpScrambleGet(Ipp32u* pData, cpSize dataSize,
- const Ipp8u* pArray, cpSize colummSize)
-{
- int i;
- switch(colummSize) {
- case 1:
- for(i=0; i=2; dataSize-=2, pArray+=CACHE_LINE_SIZE, pData+=2) {
- pData[0] = ((Ipp32u*)pArray)[0];
- pData[1] = ((Ipp32u*)pArray)[1];
- }
- if(dataSize)
- pData[0] = ((Ipp32u*)pArray)[0];
- break;
- case 16:
- for(; dataSize>=4; dataSize-=4, pArray+=CACHE_LINE_SIZE, pData+=4) {
- pData[0] = ((Ipp32u*)pArray)[0];
- pData[1] = ((Ipp32u*)pArray)[1];
- pData[2] = ((Ipp32u*)pArray)[2];
- pData[3] = ((Ipp32u*)pArray)[3];
-
- }
- for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
- pData[0] = ((Ipp32u*)pArray)[0];
- break;
- case 32:
- for(; dataSize>=8; dataSize-=8, pArray+=CACHE_LINE_SIZE, pData+=8) {
- pData[0] = ((Ipp32u*)pArray)[0];
- pData[1] = ((Ipp32u*)pArray)[1];
- pData[2] = ((Ipp32u*)pArray)[2];
- pData[3] = ((Ipp32u*)pArray)[3];
- pData[4] = ((Ipp32u*)pArray)[4];
- pData[5] = ((Ipp32u*)pArray)[5];
- pData[6] = ((Ipp32u*)pArray)[6];
- pData[7] = ((Ipp32u*)pArray)[7];
- }
- for(; dataSize>0; dataSize--, pArray+=sizeof(Ipp32u), pData++)
- pData[0] = ((Ipp32u*)pArray)[0];
- break;
- default:
- break;
- }
-}
-
-#endif /* _PC_SCRAMBLE_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c
deleted file mode 100644
index 544d30eb89..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpshsmgfca.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-#include "owncp.h"
-#include "pcphash.h"
-#include "pcptool.h"
-
-
-/*F*
-// Name: ippsMGF_SHA1
-// ippsMGF_SHA224
-// ippsMGF_SHA256
-// ippsMGF_SHA384
-// ippsMGF_SHA512
-// ippsMGF_MD5
-//
-// Purpose: Mask Generation Functios.
-//
-// Returns: Reason:
-// ippStsNullPtrErr pMask == NULL
-// ippStsLengthErr seedLen <0
-// maskLen <0
-// ippStsNotSupportedModeErr if algID is not match to supported hash alg
-// ippStsNoErr no errors
-//
-// Parameters:
-// pSeed pointer to the input stream
-// seedLen input stream length (bytes)
-// pMaske pointer to the ouput mask
-// maskLen desired length of mask (bytes)
-//
-*F*/
-IPPFUN(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg))
-{
- /* get algorithm id */
- hashAlg = cpValidHashAlg(hashAlg);
- /* test hash alg */
- IPP_BADARG_RET(ippHashAlg_Unknown==hashAlg, ippStsNotSupportedModeErr);
-
- IPP_BAD_PTR1_RET(pMask);
- IPP_BADARG_RET((seedLen<0)||(maskLen<0), ippStsLengthErr);
-
- {
- /* hash specific */
- int hashSize = cpHashSize(hashAlg);
-
- int i, outLen;
-
- IppsHashState hashCtx;
- ippsHashInit(&hashCtx, hashAlg);
-
- if(!pSeed)
- seedLen = 0;
-
- for(i=0,outLen=0; outLen>24) & 0xFF);
- cnt[1] = (Ipp8u)((i>>16) & 0xFF);
- cnt[2] = (Ipp8u)((i>>8) & 0xFF);
- cnt[3] = (Ipp8u)(i & 0xFF);
-
- cpReInitHash(&hashCtx, hashAlg);
- ippsHashUpdate(pSeed, seedLen, &hashCtx);
- ippsHashUpdate(cnt, 4, &hashCtx);
-
- if((outLen + hashSize) <= maskLen) {
- ippsHashFinal(pMask+outLen, &hashCtx);
- outLen += hashSize;
- }
- else {
- Ipp8u md[BITS2WORD8_SIZE(IPP_SHA512_DIGEST_BITSIZE)];
- ippsHashFinal(md, &hashCtx);
- CopyBlock(md, pMask+outLen, maskLen-outLen);
- outLen = maskLen;
- }
- }
-
- return ippStsNoErr;
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcptool.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcptool.h
deleted file mode 100644
index 9d6b63e913..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcptool.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-* Copyright (C) 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.
-*
-*/
-
-#if !defined(_PC_TOOL_H)
-#define _CP_TOOL_H
-
-/* copy data block */
-__INLINE void CopyBlock(const void* pSrc, void* pDst, cpSize numBytes)
-{
- const Ipp8u* s = (Ipp8u*)pSrc;
- Ipp8u* d = (Ipp8u*)pDst;
- cpSize k;
- for(k=0; k> (blkSize-numSize)%8 );
-
- /* save crytical byte */
- Ipp8u save = (Ipp8u)( pCounter[maskPosition] & ~mask );
-
- int len = BITS2WORD8_SIZE(blkSize);
- Ipp32u carry = 1;
- for(; (len>maskPosition) && carry; len--) {
- Ipp32u x = pCounter[len-1] + carry;
- pCounter[len-1] = (Ipp8u)x;
- carry = (x>>8) & 0xFF;
- }
-
- /* update crytical byte */
- pCounter[maskPosition] &= mask;
- pCounter[maskPosition] |= save;
-}
-
-#endif /* _CP_TOOL_H */
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.c b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.c
deleted file mode 100644
index 18c70aa883..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* Copyright (C) 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 "owndefs.h"
-
-#ifndef __OWNCP_H__
- #include "owncp.h"
-#endif
-
-#include "pcpname.h"
-#include "pcpver.h"
-
-#include "ippver.gen"
diff --git a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.h b/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.h
deleted file mode 100644
index 30e6dc3a02..0000000000
--- a/sgx-jvm/linux-sgx/external/crypto_px/sources/ippcp/src/pcpver.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* Copyright (C) 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 "ippver.h"
-#define BUILD() 1043
-#define VERSION() BASE_VERSION(),BUILD()
-
-/* ////////////////////////// End of file "pcpver.h" ///////////////////////// */
diff --git a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/Makefile.in b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/Makefile.in
index 449d978ba7..ef815352b9 100644
--- a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/Makefile.in
+++ b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/Makefile.in
@@ -77,7 +77,6 @@ clean:
$(MAKE) -C ./example/util/ clean
$(MAKE) -C ./example/ clean
$(MAKE) -C ./tools/ clean
- $(MAKE) -C ./ext/gtest/ clean
$(MAKE) -C ./epid/common-testhelper/ clean
$(MAKE) -C ./ext/dropt/ clean
diff --git a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/member/api.h b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/member/api.h
index f888d92687..6b834f5537 100644
--- a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/member/api.h
+++ b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/member/api.h
@@ -22,6 +22,10 @@
#include "epid/common/errors.h"
#include "epid/common/bitsupplier.h"
+#ifdef __cplusplus
+extern "C"{
+#endif
+
/*!
* \file
* \brief Intel(R) EPID SDK member API.
@@ -479,4 +483,9 @@ EpidStatus EpidDecompressPrivKey(GroupPubKey const* pub_key,
PrivKey* priv_key);
/*! @} */
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // EPID_MEMBER_API_H_
diff --git a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/verifier/api.h b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/verifier/api.h
index a0fcbc01f3..7a8b790549 100644
--- a/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/verifier/api.h
+++ b/sgx-jvm/linux-sgx/external/epid-sdk-3.0.0/epid/verifier/api.h
@@ -21,6 +21,10 @@
#include "epid/common/types.h"
#include "epid/common/errors.h"
+#ifdef __cplusplus
+extern "C"{
+#endif
+
/*!
* \file
* \brief Intel(R) EPID SDK verifier API.
@@ -544,4 +548,8 @@ EpidStatus EpidBlacklistSig(VerifierCtx* ctx, EpidSignature const* sig,
/*! @} */
+#ifdef __cplusplus
+}
+#endif
+
#endif // EPID_VERIFIER_API_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/LICENSE.txt b/sgx-jvm/linux-sgx/external/epid/LICENSE.txt
deleted file mode 100644
index 2afcf387aa..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/LICENSE.txt
+++ /dev/null
@@ -1,249 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
-=======================================================================
-
-Intel(R) Enhanced Privacy ID (Intel(R) EPID) SDK Subcomponents:
-
-The Intel(R) EPID SDK contains subcomponents with separate copyright notices
-and license terms. Your use of the source code for these subcomponents
-is subject to the terms and conditions of the following licenses.
-
-
------------------------------------------------------------------------
-The BSD 3-Clause License
------------------------------------------------------------------------
-
-The Intel(R) EPID SDK bundles portions of the following under the BSD 3-Clause
-License:
-
- - Google Test (https://github.com/google/googletest)
- Copyright 2008, Google Inc.
-
-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 Google Inc. 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.
diff --git a/sgx-jvm/linux-sgx/external/epid/Makefile b/sgx-jvm/linux-sgx/external/epid/Makefile
deleted file mode 100644
index a542d977a3..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-include ../../buildenv.mk
-
-EPIDLIB := libepid.a
-TOP_DIR := $(LINUX_EXTERNAL_DIR)/epid
-
-CFLAGS += -fPIC
-DEFINES := -DIPPEPID_USE_MERGEDLIB -DASSUME_GETOCTSTRING_POINT_VALID
-
-ifdef DEBUG
- CFLAGS += -O0
- DEFINES += -DDEBUG
-else
- DEFINES += -DNDEBUG
-endif
-
-ifeq ($(ARCH), x86_64)
- DEFINES += -DUSE_Y8_HEADER
-else
- DEFINES += -DUSE_P8_HEADER
-endif
-
-vpath %.c epid/common epid/common/math epid/member epid/verifier ext/ipp/sources/ippcpepid/src
-
-INCLUDE += -I$(TOP_DIR)/ext/ipp/include \
- -I$(TOP_DIR)/ext/ipp/sources/include \
- -I$(TOP_DIR)/ext/ipp/sources/ippcp/src \
- -I$(TOP_DIR)/ext/ipp/sources/ippcpepid/src \
- -I$(TOP_DIR)
-
-SRC := commitment.c epid2params.c errors.c grouppubkey.c memory.c printutils.c sigrlvalid.c stack.c \
- bignum.c ecgroup.c finitefield.c pairing.c \
- context.c nr_prove.c privkey.c signbasic.c get_sigsize.c presig.c request_join.c sign.c \
- check_privrl_entry.c nrverify.c verifybasic.c context.c sigs_linked.c verify.c \
- pcpgfp.c pcpgfpec.c pcpgfpecpoint.c pcpgfpecpointstuff.c pcpgfpstuff.c pcpgfpx.c pcpgfpxstuff.c
-
-OBJ := $(SRC:.c=.o)
-
-.PHONY: all
-all: $(EPIDLIB)
-
-$(EPIDLIB): $(OBJ)
- $(AR) rcs $@ $^
-
-%.o: %.c
- $(CC) $(INCLUDE) $(filter-out -Werror, $(CFLAGS)) $(DEFINES) -c $< -o $@
-
-.PHONY: clean
-clean:
- @$(RM) $(OBJ) $(EPIDLIB)
-
-.PHONY: rebuild
-rebuild: clean all
diff --git a/sgx-jvm/linux-sgx/external/epid/NOTICE.txt b/sgx-jvm/linux-sgx/external/epid/NOTICE.txt
deleted file mode 100644
index 507280fed5..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/NOTICE.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-Intel(R) Enhanced Privacy ID (Intel(R) EPID) SDK
-Copyright 2016 Intel Corporation
-
-==========
-
-The Intel(R) EPID SDK contains subcomponents with separate copyright notices
-and license terms.
-
-Your use of the source code for the these subcomponents is subject to
-the terms and conditions of their respective licenses.
-
-See the LICENSE.txt file for a list of subcomponents and dependencies and
-their respective licenses.
-
-----------
-
-The source code used for math primitives in the Intel(R) EPID SDK is a
-subset of the Intel(R) IPP Cryptography library (v9.0.3) written in
-C. For higher performance, you can use the commercial version of the
-IPP Cryptography libraries, which are available at
-https://software.intel.com/articles/download-ipp-cryptography-libraries.
-
diff --git a/sgx-jvm/linux-sgx/external/epid/README.md b/sgx-jvm/linux-sgx/external/epid/README.md
deleted file mode 100644
index 332f72233e..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/README.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# Intel(R) EPID SDK
-
-The Intel(R) Enhanced Privacy ID Software Development Kit
-
-Intel(R) EPID SDK enables adding Intel(R) EPID support to applications
-and platforms.
-
-Intel(R) EPID is a cryptographic protocol which enables the remote
-authentication of a trusted platform whilst preserving the user's
-privacy.
-
-* For a given public key there are many (e.g., millions) of private
- keys. The key holders form a group.
-
-* Any key holder may sign against the one public key.
-
-* No one can tell which private key signed the data. This is the
- privacy property.
-
-You can use Intel(R) EPID as a foundational building block for a
-multitude of security solutions.
-
-
-## Prerequisites
-
-* [Python](http://www.python.org)
-
-* [SCons](http://www.scons.org/)
-
-* [Parts](https://bitbucket.org/sconsparts/parts)
-
-* A C/C++ compiler supported by Parts
-
-
-## Release Notes
-
-See [RELEASE_NOTES.md](RELEASE_NOTES.md).
-
-
-## Documentation
-
-See [doc/index.html](doc/index.html) to browse the html
-documentation.
-
-
-## License
-
-See [LICENSE.txt](LICENSE.txt).
-
-
-## Math Primitives
-
-The source code used for math primitives in the Intel(R) EPID SDK is a
-subset of the Intel(R) IPP Cryptography library (v9.0.3) written in
-C. For higher performance, you can use the commercial version of the
-IPP Cryptography libraries, which are available at
-https://software.intel.com/articles/download-ipp-cryptography-libraries.
diff --git a/sgx-jvm/linux-sgx/external/epid/RELEASE_NOTES.md b/sgx-jvm/linux-sgx/external/epid/RELEASE_NOTES.md
deleted file mode 100644
index 3eb9ab3fc5..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/RELEASE_NOTES.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Intel(R) EPID SDK Release Notes {#ChangeLog}
-
-# 2.0.0
-
-## New in This Release
-
-* Signed binary issuer material support.
-
- - Binary issuer material validation APIs.
-
- - Updated sample issuer material.
-
- - Updated samples that parse signed binary issuer material.
-
-* Compressed member private key support.
-
-* Validated on additional IoT platforms.
-
- - Windows 10 IoT Core
-
- - WindRiver IDP
-
-
-## Changes
-
-* The default hash algorithm has changed. It is now SHA-512.
-
-* Functions that returned `EpidNullPtrErr` now return `EpidBadArgErr`
- instead.
-
-
-## Fixes
-
-* Updated build flags to work around GCC 4.8.5 defect.
-
-
-## Known Issues
-
-* SHA-512/256 hash algorithm is not supported.
-
-* Compressed key sample material is not included in the package.
diff --git a/sgx-jvm/linux-sgx/external/epid/SConstruct b/sgx-jvm/linux-sgx/external/epid/SConstruct
deleted file mode 100644
index 296adced51..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/SConstruct
+++ /dev/null
@@ -1,210 +0,0 @@
-############################################################################
-# Copyright 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-############################################################################
-
-"""use scons -k to invoke all builds regardless of unit test failures
-"""
-import string
-import sys
-import SCons.Script
-import os.path
-from parts import *
-
-print "**************** TOOLS ****************"
-print '* Python Version:', string.split(sys.version, " ", 1)[0]
-print '* SCons Version:', SCons.__version__
-print '* Parts Version:', PartsExtensionVersion()
-print "***************************************"
-
-def PrintCompilerVersion(env):
- """
- Function to print version of compilers used for build
- Args:
- env: Environment to get compilers version
- """
- res = ''
- if 'INTELC_VERSION' in env:
- res += 'ICC ' + env['INTELC_VERSION'] + ';'
- if 'MSVC_VERSION' in env:
- res += 'MS ' + env['MSVC_VERSION'] + ';'
- if 'GXX_VERSION' in env:
- res += 'GXX ' + env['GXX_VERSION'] + ';'
- if 'GCC_VERSION' in env:
- res += 'GCC ' + env['GCC_VERSION'] + ';'
- print 'Compiler Version: ', res
-
-def include_parts(part_list, **kwargs):
- for parts_file in part_list:
- if os.path.isfile(DefaultEnvironment().subst(parts_file)):
- Part(parts_file=parts_file, **kwargs)
-
-######## Part groups ####################################################
-ipp_parts = ['ext/ipp/ippcp.parts',
- 'ext/ipp/ippcpepid.parts',
- 'ext/ipp/ippcommon.parts']
-utest_parts = ['ext/gtest/gtest.parts',
- 'epid/common-testhelper/common-testhelper.parts']
-common_parts = ['epid/common/common.parts']
-member_parts = ['epid/member/member.parts']
-verifier_parts = ['epid/verifier/verifier.parts']
-util_parts = ['example/util/util.parts']
-example_parts = ['example/verifysig/verifysig.parts',
- 'example/signmsg/signmsg.parts',
- 'example/data/data.parts']
-example_test_parts = ['test/testbot/testbot.parts',
- 'test/testbot/signmsg/signmsg_testbot.parts',
- 'test/testbot/verifysig/verifysig_testbot.parts',
- 'test/testbot/integration/integration_testbot.parts']
-package_parts = ['ext/gtest/gtest.parts',
- 'ext/ipp/ippcommon.parts',
- 'ext/ipp/ippcp.parts',
- 'ext/ipp/ippcpepid.parts',
- 'package.parts']
-internal_tools_parts = ['tools/ikgfwrapper/ikgfwrapper.parts',
- 'tools/revokegrp/revokegrp.parts',
- 'tools/revokekey/revokekey.parts',
- 'tools/revokesig/revokesig.parts',
- 'tools/extractkeys/extractkeys.parts',
- 'tools/extractgrps/extractgrps.parts']
-######## End Part groups ###############################################
-######## Commandline option setup #######################################
-product_variants = [
- 'production',
- 'internal-test',
- 'package-epid-sdk',
- 'internal-tools'
-]
-
-default_variant = 'production'
-
-def is_production():
- return GetOption("product-variant") == 'production'
-
-def is_internal_test():
- return GetOption("product-variant") == 'internal-test'
-
-def is_internal_tools():
- return GetOption("product-variant") == 'internal-tools'
-
-def is_package():
- return GetOption("product-variant") == 'package-epid-sdk'
-
-def variant_dirname():
- s = GetOption("product-variant")
- if s == 'production':
- return 'epid-sdk'
- elif s == 'package-epid-sdk':
- return 'epid-sdk'
- else:
- return s
-
-AddOption("--product-variant", "--prod-var", nargs=1,
- help=("Select product variant to build. Possible "
- "options are: {0}. The default is {1} if no option "
- "is specified").format(", ".join(product_variants),
- default_variant),
- action='store', dest='product-variant', type='choice',
- choices=product_variants, default=default_variant)
-
-SetOptionDefault("PRODUCT_VARIANT", variant_dirname())
-
-######## End Commandline option setup ###################################
-
-
-# fix for parts 0.10.8 until we get better logic to extract ${CC}
-SetOptionDefault('PARTS_USE_SHORT_TOOL_NAMES', 1)
-
-def set_default_production_options():
- SetOptionDefault('TARGET_PLATFORM', 'x86_64')
- SetOptionDefault('CONFIG', 'release')
-
- SetOptionDefault('TARGET_VARIANT', '${TARGET_OS}-${TARGET_ARCH}')
-
- SetOptionDefault('INSTALL_ROOT',
- '#_install/${PRODUCT_VARIANT}')
-
- SetOptionDefault('INSTALL_TOOLS_BIN',
- '$INSTALL_ROOT/tools')
-
- SetOptionDefault('INSTALL_SAMPLE_BIN',
- '$INSTALL_ROOT/example')
-
- SetOptionDefault('INSTALL_EPID_INCLUDE',
- '$INSTALL_ROOT/include/epid')
-
- SetOptionDefault('INSTALL_IPP_INCLUDE',
- '$INSTALL_ROOT/include/ext/ipp/include')
-
- SetOptionDefault('INSTALL_TEST_BIN',
- '$INSTALL_ROOT/test')
-
- SetOptionDefault('INSTALL_LIB',
- '$INSTALL_ROOT/lib/${TARGET_VARIANT}')
-
- SetOptionDefault('INSTALL_SAMPLE_DATA',
- '$INSTALL_ROOT/example')
-
- SetOptionDefault('PACKAGE_DIR',
- '#_package')
-
- SetOptionDefault('PACKAGE_ROOT',
- '#_package/${PRODUCT_VARIANT}')
-
- SetOptionDefault('ROOT',
- '#')
-
- SetOptionDefault('PACKAGE_NAME',
- '{PRODUCT_VARIANT}')
-
-if is_production():
- set_default_production_options()
- include_parts(ipp_parts, mode=['install_lib'],
- INSTALL_INCLUDE='${INSTALL_IPP_INCLUDE}')
- include_parts(utest_parts + common_parts +
- member_parts + verifier_parts,
- mode=['install_lib'],
- INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}')
- include_parts(util_parts + example_parts,
- INSTALL_INCLUDE='${INSTALL_EPID_INCLUDE}',
- INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
- INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
- PrintCompilerVersion(DefaultEnvironment())
- Default('all')
- Default('run_utest::')
-
-if is_internal_test():
- set_default_production_options()
- include_parts(ipp_parts)
- include_parts(utest_parts + common_parts +
- member_parts + verifier_parts)
- include_parts(util_parts + example_parts,
- INSTALL_BIN='${INSTALL_SAMPLE_BIN}',
- INSTALL_DATA='${INSTALL_SAMPLE_DATA}')
- include_parts(example_test_parts)
- Default('all')
-
-if is_internal_tools():
- set_default_production_options()
- include_parts(ipp_parts + utest_parts + common_parts + util_parts)
- include_parts(internal_tools_parts, INSTALL_BIN='${INSTALL_TOOLS_BIN}')
- Default('ikgfwrapper', 'revokegrp', 'revokekey', 'revokesig',
- 'extractkeys', 'extractgrps')
-
-if is_package():
- set_default_production_options()
- include_parts(package_parts,
- mode=['install_package'],
- INSTALL_TOP_LEVEL='${PACKAGE_ROOT}')
- Default('package')
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.cc
deleted file mode 100644
index 75585e2a38..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Bignum C++ wrapper implementation.
- */
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/bignum_wrapper-testhelper.h"
-#include "epid/common/math/bignum.h"
-
-/// bignum deleter type
-struct BigNumDeleter {
- /// bignum deleter
- void operator()(BigNum* bn) {
- if (bn) {
- DeleteBigNum(&bn);
- }
- }
-};
-
-/// bignum deleter singlton
-BigNumDeleter bignum_deleter;
-
-/// Internal state of the bignum wrapper
-struct BigNumObj::State {
- /// size of the stored BigNum
- size_t size;
-
- /// The stored BigNum
- std::shared_ptr bn_;
-
- /// Default initializing constructor
- State() : size(0), bn_() {}
-
- /// write a new value
- void write(unsigned char const* buf, size_t buflen, size_t len) {
- bool orig_has_data = (buf != nullptr) && (buflen > 0);
- std::shared_ptr bn;
- BigNum* bn_ptr = nullptr;
- THROW_ON_EPIDERR(NewBigNum(len, &bn_ptr));
- bn.reset(bn_ptr, bignum_deleter);
- size = len;
- if (orig_has_data) {
- THROW_ON_EPIDERR(ReadBigNum(buf, buflen, bn.get()));
- }
- bn_ = bn;
- }
-};
-
-BigNumObj::BigNumObj() : state_(new State) {
- state_->write(nullptr, 0, sizeof(BigNumStr));
-}
-
-BigNumObj::BigNumObj(BigNumObj const& other) : state_(new State) {
- bool orig_has_data = other.state_->bn_.get() != nullptr;
- std::vector buf;
- if (orig_has_data) {
- buf.resize(other.state_->size);
- THROW_ON_EPIDERR(WriteBigNum(other.state_->bn_.get(), buf.size(), &buf[0]));
- }
- state_->write(&buf[0], other.state_->size, buf.size());
-}
-
-BigNumObj& BigNumObj::operator=(BigNumObj const& other) {
- bool orig_has_data = other.state_->bn_.get() != nullptr;
- std::vector buf;
- if (orig_has_data) {
- buf.resize(other.state_->size);
- THROW_ON_EPIDERR(WriteBigNum(other.state_->bn_.get(), buf.size(), &buf[0]));
- }
- state_->write(&buf[0], other.state_->size, buf.size());
- return *this;
-}
-
-BigNumObj::BigNumObj(size_t data_size_bytes) : state_(new State) {
- state_->write(nullptr, 0, data_size_bytes);
-}
-
-BigNumObj::BigNumObj(size_t data_size_bytes,
- std::vector const& bytes)
- : state_(new State) {
- state_->write(&bytes[0], bytes.size(), data_size_bytes);
-}
-
-BigNumObj::BigNumObj(size_t data_size_bytes, BigNumStr const& bytes)
- : state_(new State) {
- state_->write((unsigned char const*)&bytes, sizeof(BigNumStr),
- data_size_bytes);
-}
-
-BigNumObj::BigNumObj(std::vector const& bytes)
- : state_(new State) {
- state_->write(&bytes[0], bytes.size(), bytes.size());
-}
-
-BigNumObj::BigNumObj(BigNumStr const& bytes) : state_(new State) {
- state_->write((unsigned char const*)&bytes, sizeof(BigNumStr),
- sizeof(BigNumStr));
-}
-
-BigNumObj::~BigNumObj() {}
-
-BigNumObj::operator BigNum*() { return state_->bn_.get(); }
-
-BigNumObj::operator const BigNum*() const { return state_->bn_.get(); }
-
-BigNum* BigNumObj::get() { return state_->bn_.get(); }
-
-BigNum const* BigNumObj::getc() const { return state_->bn_.get(); }
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.h
deleted file mode 100644
index 6008e65928..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/bignum_wrapper-testhelper.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Bignum C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_
-
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-}
-
-/*!
-Wrapper class to provide Resource Allocation is Initialization handling
-for BigNum
-*/
-class BigNumObj {
- public:
- /// Create a BigNum of default size ( sizeof(BigNumStr) )
- BigNumObj();
- /// copy constructor
- BigNumObj(BigNumObj const& other);
- /// assignment operator
- BigNumObj& operator=(BigNumObj const& other);
- /// Create a BigNum of specific size
- explicit BigNumObj(size_t data_size_bytes);
- /// Create a BigNum of specific size and initialize it to bytes
- BigNumObj(size_t data_size_bytes, std::vector const& bytes);
- /// Create a BigNum of specific size and initialize it to bytes
- BigNumObj(size_t data_size_bytes, BigNumStr const& bytes);
- /// Create a BigNum the same size as bytes and initialize it to bytes
- explicit BigNumObj(std::vector const& bytes);
- /// Create a BigNum the same size as bytes and initialize it to bytes
- explicit BigNumObj(BigNumStr const& bytes);
- /// Destroy the Bignum
- ~BigNumObj();
- /// cast operator to get the pointer to the stored BigNum
- operator BigNum*();
- /// const cast operator to get the pointer to the stored BigNum
- operator const BigNum*() const;
- /// Get the underlying pointer
- BigNum* get();
- /// Get the underlying pointer
- BigNum const* getc() const;
-
- private:
- struct State;
- std::unique_ptr state_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/common-testhelper.parts b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/common-testhelper.parts
deleted file mode 100644
index 2fdd7653fb..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/common-testhelper.parts
+++ /dev/null
@@ -1,66 +0,0 @@
-############################################################################
-# Copyright 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-############################################################################
-Import('*')
-env.PartName('common-testhelper')
-
-
-
-src_files = Pattern(src_dir='.',
- includes=['*-testhelper.cc'],
- excludes=[],
- recursive=True).files()
-inc_files = Pattern(src_dir='.',
- includes=['*-testhelper.h'],
- excludes=[],
- recursive=True).files()
-#unit tests
-utest_files = Pattern(src_dir='.',
- includes=['*-test.cc'],
- excludes=[],
- recursive=True).files()
-
-
-if 'install_package' in env['MODE']:
- env.InstallTopLevel(src_files,sub_dir='epid/${PART_SHORT_NAME}')
- env.InstallTopLevel(inc_files,sub_dir='epid/${PART_SHORT_NAME}')
- env.InstallTopLevel(utest_files, sub_dir='epid/${PART_SHORT_NAME}/unittests')
- parts_file = ['common-testhelper.parts']
- env.InstallTopLevel(parts_file, sub_dir='epid/${PART_SHORT_NAME}')
-else:
- env.DependsOn([
- Component('common'),
- ])
-
- env.Append(CPPPATH='#')
-
- testenv = env.Clone()
-
- outputs = env.Library('${PART_NAME}', src_files)
- env.Sdk(outputs)
-
- testenv['UNIT_TEST_TARGET_NAME'] = "${PART_NAME}-${UNIT_TEST_TARGET}"
- testenv.UnitTest("utest",
- utest_files,
- command_args=[
- '--gtest_color=yes',
- '--gtest_print_time=1',
- '--gtest_output=xml',
- '--gtest_filter=**',
- ],
- make_pdb=(env.isConfigBasedOn('debug')),
- depends=[Component('gtest'),
- Component('common-testhelper')],
- INSTALL_BIN='${INSTALL_TEST_BIN}')
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.cc
deleted file mode 100644
index 3ce5959515..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcGroup C++ wrapper implementation.
- */
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common/math/bignum.h"
-#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/bignum_wrapper-testhelper.h"
-
-/// ecgroup deleter type
-struct EcGroupDeleter {
- /// ecgroup deleter
- void operator()(EcGroup* ptr) {
- if (ptr) {
- DeleteEcGroup(&ptr);
- }
- }
-};
-
-/// ecgroup deleter singlton
-EcGroupDeleter ecgroup_deleter;
-
-/// Internal state of the ecgroup wrapper
-struct EcGroupObj::State {
- /// The stored EcGroup
- std::shared_ptr group_;
- FiniteFieldObj fintefield_;
-
- /// constructor
- State() : group_(nullptr, ecgroup_deleter) {}
-
- // State instances are not meant to be copied.
- // Explicitly delete copy constructor and assignment operator.
- State(const State&) = delete;
- State& operator=(const State&) = delete;
-
- /// destructor
- ~State() {}
-};
-
-EcGroupObj::EcGroupObj() : state_(new State()) {
- const BigNumStr q_str = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13}}};
- const FqElemStr b_str = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}};
- const BigNumStr p_str = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99, 0x92, 0x1A,
- 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D}}};
- const BigNumStr h1 = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
- const G1ElemStr g1_str = {
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
- FiniteFieldObj fq(q_str);
- EcGroup* temp = nullptr;
- NewEcGroup(fq, FfElementObj(&fq), FfElementObj(&fq, b_str),
- FfElementObj(&fq, g1_str.x), FfElementObj(&fq, g1_str.y),
- BigNumObj(p_str), BigNumObj(h1), &temp);
- state_->group_.reset(temp, ecgroup_deleter);
- state_->fintefield_ = fq;
-}
-
-EcGroupObj::EcGroupObj(EcGroupObj const& other) : state_(new State) {
- state_->group_ = other.state_->group_;
- state_->fintefield_ = other.state_->fintefield_;
-}
-
-EcGroupObj& EcGroupObj::operator=(EcGroupObj const& other) {
- state_->group_ = other.state_->group_;
- state_->fintefield_ = other.state_->fintefield_;
- return *this;
-}
-
-EcGroupObj::EcGroupObj(FiniteFieldObj* ff, FfElement const* a,
- FfElement const* b, FfElement const* x,
- FfElement const* y, BigNum const* order,
- BigNum const* cofactor)
- : state_(new State) {
- EcGroup* temp = nullptr;
- NewEcGroup(*ff, a, b, x, y, order, cofactor, &temp);
- state_->group_.reset(temp, ecgroup_deleter);
- state_->fintefield_ = *ff;
-}
-
-EcGroupObj::~EcGroupObj() {}
-
-EcGroupObj::operator EcGroup*() { return state_->group_.get(); }
-
-EcGroupObj::operator const EcGroup*() const { return state_->group_.get(); }
-
-EcGroup* EcGroupObj::get() { return state_->group_.get(); }
-
-EcGroup const* EcGroupObj::getc() const { return state_->group_.get(); }
-
-size_t EcGroupObj::GetElementMaxSize() const {
- return 2 * state_->fintefield_.GetElementMaxSize();
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.h
deleted file mode 100644
index 4969134eb8..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecgroup_wrapper-testhelper.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcGroup C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_
-
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/ecgroup.h"
-}
-
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-
-/*!
-Wrapper class to provide Resource Allocation is Initialization handling
-for EcGroup
-*/
-class EcGroupObj {
- public:
- /// constructor
- EcGroupObj();
- /// copy constructor
- EcGroupObj(EcGroupObj const& other);
- /// assignment operator
- EcGroupObj& operator=(EcGroupObj const& other);
- /// Create a EcGroup
- explicit EcGroupObj(FiniteFieldObj* ff, FfElement const* a,
- FfElement const* b, FfElement const* x,
- FfElement const* y, BigNum const* order,
- BigNum const* cofactor);
- /// Destroy the EcGroup
- ~EcGroupObj();
- /// cast operator to get the pointer to the stored EcGroup
- operator EcGroup*();
- /// const cast operator to get the pointer to the stored EcGroup
- operator const EcGroup*() const;
- /// Get the underlying pointer
- EcGroup* get();
- /// Get the underlying pointer
- EcGroup const* getc() const;
- /// Get maximum size of group element
- size_t GetElementMaxSize() const;
-
- private:
- struct State;
- std::unique_ptr state_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.cc
deleted file mode 100644
index 9aef5d78ca..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcPoint C++ wrapper implementation.
- */
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
-#include "epid/common/math/bignum.h"
-
-/// ecpoint deleter type
-struct EcPointDeleter {
- /// ecpoint deleter
- void operator()(EcPoint* ptr) {
- if (ptr) {
- DeleteEcPoint(&ptr);
- }
- }
-};
-
-/// ecpoint deleter singlton
-EcPointDeleter ecpoint_deleter;
-
-/// Internal state of the ecpoint wrapper
-struct EcPointObj::State {
- /// The containing field
- EcGroupObj group_;
- /// The stored EcPoint
- std::shared_ptr point_;
-
- State() : group_(), point_() {}
- /// write a new value
- void write(EcGroupObj* group, unsigned char const* buf, size_t buflen) {
- group_ = *group;
- bool orig_has_data = (buf != nullptr) && (buflen > 0);
- std::shared_ptr point;
- EcPoint* point_ptr;
- THROW_ON_EPIDERR(NewEcPoint(group_, &point_ptr));
- point.reset(point_ptr, ecpoint_deleter);
- if (orig_has_data) {
- THROW_ON_EPIDERR(ReadEcPoint(group_, buf, buflen, point.get()));
- }
- point_ = point;
- }
-};
-
-EcPointObj::EcPointObj() : state_(new State) {}
-
-EcPointObj::EcPointObj(EcPointObj const& other) : state_(new State) {
- std::vector buf = other.data();
- state_->write(&other.state_->group_, &buf[0], buf.size());
-}
-
-EcPointObj& EcPointObj::operator=(EcPointObj const& other) {
- std::vector buf = other.data();
- state_->write(&other.state_->group_, &buf[0], buf.size());
- return *this;
-}
-
-EcPointObj::EcPointObj(EcGroupObj* group) : state_(new State) {
- state_->write(group, nullptr, 0);
-}
-
-EcPointObj::EcPointObj(EcGroupObj* group, G1ElemStr const& bytes)
- : state_(new State) {
- init(group, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-EcPointObj::EcPointObj(EcGroupObj* group, G2ElemStr const& bytes)
- : state_(new State) {
- init(group, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-EcPointObj::EcPointObj(EcGroupObj* group,
- std::vector const& bytes)
- : state_(new State) {
- init(group, &bytes[0], bytes.size());
-}
-
-EcPointObj::EcPointObj(EcGroupObj* group, void const* bytes, size_t size)
- : state_(new State) {
- init(group, (unsigned char const*)bytes, size);
-}
-
-void EcPointObj::init(EcGroupObj* group, unsigned char const* bytes,
- size_t size) {
- state_->write(group, bytes, size);
-}
-
-EcPointObj::~EcPointObj() {}
-
-EcPointObj::operator EcPoint*() { return state_->point_.get(); }
-
-EcPointObj::operator const EcPoint*() const { return state_->point_.get(); }
-
-EcPoint* EcPointObj::get() { return state_->point_.get(); }
-
-EcPoint const* EcPointObj::getc() const { return state_->point_.get(); }
-
-std::vector EcPointObj::data() const {
- std::vector buf;
- if (state_->point_.get() != nullptr) {
- buf.resize(state_->group_.GetElementMaxSize());
- THROW_ON_EPIDERR(WriteEcPoint(state_->group_, state_->point_.get(), &buf[0],
- buf.size()));
- }
- return buf;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.h
deleted file mode 100644
index 0b2e1b7119..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ecpoint_wrapper-testhelper.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcPoint C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
-
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/ecgroup.h"
-}
-
-class EcGroupObj;
-
-/*!
-Wrapper class to provide Resource Allocation is Initialization handling
-for EcPoint
-*/
-class EcPointObj {
- public:
- /// constructor
- EcPointObj();
- /// copy constructor
- EcPointObj(EcPointObj const& other);
- /// assignment operator
- EcPointObj& operator=(EcPointObj const& other);
- /// Create an EcPoint
- explicit EcPointObj(EcGroupObj* group);
- /// Create an EcPoint
- EcPointObj(EcGroupObj* group, G1ElemStr const& bytes);
- /// Create an EcPoint
- EcPointObj(EcGroupObj* group, G2ElemStr const& bytes);
- /// Create an EcPoint
- EcPointObj(EcGroupObj* group, std::vector const& bytes);
- /// Create an EcPoint
- EcPointObj(EcGroupObj* group, void const* bytes, size_t size);
- /// Destroy the EcPoint
- ~EcPointObj();
- /// cast operator to get the pointer to the stored EcPoint
- operator EcPoint*();
- /// const cast operator to get the pointer to the stored EcPoint
- operator const EcPoint*() const;
- /// Get the underlying pointer
- EcPoint* get();
- /// Get the underlying pointer
- EcPoint const* getc() const;
- /// Get element bytes
- std::vector data() const;
-
- private:
- void init(EcGroupObj* group, unsigned char const* bytes, size_t size);
- struct State;
- std::unique_ptr state_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.cc
deleted file mode 100644
index e281ab9f06..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.cc
+++ /dev/null
@@ -1,164 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Intel(R) EPID parameters C++ wrapper implementation.
- */
-
-#include
-#include
-
-#include "epid/common-testhelper/epid_params-testhelper.h"
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/ecgroup-internal.h"
-#include "epid/common/math/finitefield-internal.h"
-#include "epid/common/math/pairing-internal.h"
-}
-
-Epid20Params::Epid20Params() {
- // construct Fq finite field
- fq = FiniteFieldObj(q_str_);
-
- // construct Fq^2 finite field
- FfElementObj neg_beta(&fq);
- THROW_ON_EPIDERR(FfNeg(fq, FfElementObj(&fq, beta_str_), neg_beta));
- fq2 = FiniteFieldObj(fq, neg_beta, 2);
-
- // construct Fq^6 finite field
- FfElementObj neg_xi(&fq2);
- THROW_ON_EPIDERR(FfNeg(fq2, FfElementObj(&fq2, xi_str_), neg_xi));
- fq6 = FiniteFieldObj(fq2, neg_xi, 3);
-
- // construct Fq^12 finite field
- FfElementObj neg_v(&fq6);
- THROW_ON_EPIDERR(FfNeg(fq6, FfElementObj(&fq6, v_str_), neg_v));
- GT = FiniteFieldObj(fq6, neg_v, 2);
-
- const BigNumStr h1 = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
-
- // Create G1
- // G1 is an elliptic curve group E(Fq).It can be initialized as follows :
- // Set G1 = E(Fq).init(p, q, n = p, h = 1, a = 0, b, g1.x, g1.y).
- G1 = EcGroupObj(&fq, FfElementObj(&fq), FfElementObj(&fq, b_str_),
- FfElementObj(&fq, g1_str_.x), FfElementObj(&fq, g1_str_.y),
- BigNumObj(p_str_), BigNumObj(h1));
-
- // set h = 2q - p, aka cofactor
- std::vector cofactor_str(
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xfc, 0xf0, 0xcd, 0x46, 0xe5, 0xf2, 0x5e, 0xee, 0x71, 0xa4, 0xa0,
- 0x0c, 0xdc, 0x65, 0xfb, 0x12, 0x96, 0x82, 0xea, 0xb0, 0x25, 0x08, 0x4a,
- 0x8c, 0x9b, 0x10, 0x19});
- // set n = p * h, AKA order
- std::vector order_str(
- {0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xe1, 0x9a, 0x8d, 0xcb, 0xe4, 0xc7,
- 0x38, 0xfa, 0x9b, 0x98, 0x4d, 0x1c, 0x12, 0x9f, 0x64, 0x97, 0xe8, 0x54,
- 0xa3, 0x0a, 0x81, 0xac, 0x42, 0xf9, 0x39, 0x16, 0xa7, 0x70, 0x21, 0xdc,
- 0xfb, 0xb6, 0xe7, 0x7e, 0x1f, 0x5b, 0x55, 0xcc, 0x4e, 0x84, 0xcd, 0x19,
- 0x4f, 0x49, 0x20, 0x94, 0xb5, 0xd8, 0x12, 0xa0, 0x2e, 0x7f, 0x40, 0x13,
- 0xb2, 0xfa, 0xa1, 0x45});
-
- // Compute xi' = Fq2.inverse(xi).
- FfElementObj inv_xi(&fq2);
- THROW_ON_EPIDERR(FfInv(fq2, FfElementObj(&fq2, xi_str_), inv_xi));
- // Compute b' = Fq2.mul(xi', b).
- FfElementObj b_dash(&fq2);
- THROW_ON_EPIDERR(FfMul(fq2, inv_xi.get(), FfElementObj(&fq, b_str_), b_dash));
-
- // Set G2 = E(Fq2).init(p, param(Fq2), n, h, 0, b', g2.x, g2.y)
- G2 = EcGroupObj(&fq2, FfElementObj(&fq2), b_dash,
- FfElementObj(&fq2, &g2_str_.x, sizeof(g2_str_.x)),
- FfElementObj(&fq2, &g2_str_.y, sizeof(g2_str_.y)),
- BigNumObj(order_str), BigNumObj(cofactor_str));
-}
-
-const BigNumStr Epid20Params::q_str_ = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13}}};
-const FqElemStr Epid20Params::beta_str_ = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12}}};
-const Fq6ElemStr Epid20Params::v_str_ = {
- {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}};
-
-const BigNumStr Epid20Params::p_str_ = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99, 0x92, 0x1A,
- 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D}}};
-const FqElemStr Epid20Params::b_str_ = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}};
-const FqElemStr Epid20Params::h_str_ = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
-const G1ElemStr Epid20Params::g1_str_ = {
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
-const Fq2ElemStr Epid20Params::xi_str_ = {
- {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}}};
-const G2ElemStr Epid20Params::g2_str_ = {
- {{{{0xE2, 0x01, 0x71, 0xC5, 0x4A, 0xA3, 0xDA, 0x05, 0x21, 0x67, 0x04, 0x13,
- 0x74, 0x3C, 0xCF, 0x22, 0xD2, 0x5D, 0x52, 0x68, 0x3D, 0x32, 0x47, 0x0E,
- 0xF6, 0x02, 0x13, 0x43, 0xBF, 0x28, 0x23, 0x94}}},
- {{{0x59, 0x2D, 0x1E, 0xF6, 0x53, 0xA8, 0x5A, 0x80, 0x46, 0xCC, 0xDC, 0x25,
- 0x4F, 0xBB, 0x56, 0x56, 0x43, 0x43, 0x3B, 0xF6, 0x28, 0x96, 0x53, 0xE2,
- 0x7D, 0xF7, 0xB2, 0x12, 0xBA, 0xA1, 0x89, 0xBE}}}},
- {{{{0xAE, 0x60, 0xA4, 0xE7, 0x51, 0xFF, 0xD3, 0x50, 0xC6, 0x21, 0xE7, 0x03,
- 0x31, 0x28, 0x26, 0xBD, 0x55, 0xE8, 0xB5, 0x9A, 0x4D, 0x91, 0x68, 0x38,
- 0x41, 0x4D, 0xB8, 0x22, 0xDD, 0x23, 0x35, 0xAE}}},
- {{{0x1A, 0xB4, 0x42, 0xF9, 0x89, 0xAF, 0xE5, 0xAD, 0xF8, 0x02, 0x74, 0xF8,
- 0x76, 0x45, 0xE2, 0x53, 0x2C, 0xDC, 0x61, 0x81, 0x90, 0x93, 0xD6, 0x13,
- 0x2C, 0x90, 0xFE, 0x89, 0x51, 0xB9, 0x24, 0x21}}}}};
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.h
deleted file mode 100644
index d3f0a5611d..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/epid_params-testhelper.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Intel(R) EPID parameters C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_EPID_PARAMS_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_EPID_PARAMS_TESTHELPER_H_
-
-#include
-#include "epid/common/types.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/finitefield.h"
-#include "epid/common/math/ecgroup.h"
-}
-
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h"
-#include "epid/common-testhelper/bignum_wrapper-testhelper.h"
-
-class Epid20Params {
- public:
- Epid20Params();
-
- // This class instances are not meant to be copied.
- // Explicitly delete copy constructor and assignment operator.
- Epid20Params(const Epid20Params&) = delete;
- Epid20Params& operator=(const Epid20Params&) = delete;
-
- virtual ~Epid20Params() {}
-
- FiniteFieldObj GT;
- EcGroupObj G1;
- EcGroupObj G2;
-
- private:
- static const BigNumStr q_str_;
- static const FqElemStr beta_str_;
- static const Fq6ElemStr v_str_;
-
- static const BigNumStr p_str_;
- static const FqElemStr b_str_;
- static const FqElemStr h_str_;
- static const G1ElemStr g1_str_;
-
- static const Fq2ElemStr xi_str_;
- static const G2ElemStr g2_str_;
-
- FiniteFieldObj fq;
- FiniteFieldObj fq2;
- FiniteFieldObj fq6;
-};
-
-#endif // EPID_COMMON_TESTHELPER_EPID_PARAMS_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/errors-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/errors-testhelper.h
deleted file mode 100644
index 8dcf4ef524..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/errors-testhelper.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Error handling C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_
-
-#include
-#include
-#include
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-}
-
-/// Macro used to indicate fatal error during unit test run
-#define THROW_ON_EPIDERR(actual) \
- if (kEpidNoErr != actual) { \
- printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:"); \
- throw std::logic_error(std::string("Failed to call: ") + #actual); \
- }
-
-#endif // EPID_COMMON_TESTHELPER_ERRORS_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.cc
deleted file mode 100644
index f7ce83422a..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FfElement C++ wrapper implementation.
- */
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common/math/bignum.h"
-
-/// ffelement deleter type
-struct FfElementDeleter {
- /// ffelement deleter
- void operator()(FfElement* ffe) {
- if (ffe) {
- DeleteFfElement(&ffe);
- }
- }
-};
-
-/// ffelement deleter singlton
-FfElementDeleter ff_element_deleter;
-
-/// Internal state of the ffelement wrapper
-struct FfElementObj::State {
- /// The containing field
- FiniteFieldObj ff_;
- /// size of the element data
- size_t size;
- /// The stored FfElement
- std::shared_ptr ffe_;
-
- State() : ff_(), size(0), ffe_() {}
- /// write a new value
- void write(FiniteFieldObj* ff, unsigned char const* buf, size_t buflen) {
- ff_ = *ff;
- bool orig_has_data = (buf != nullptr) && (buflen > 0);
- std::shared_ptr ffe;
- FfElement* ffe_ptr;
- THROW_ON_EPIDERR(NewFfElement(ff_, &ffe_ptr));
- ffe.reset(ffe_ptr, ff_element_deleter);
- size = buflen;
- if (orig_has_data) {
- THROW_ON_EPIDERR(ReadFfElement(ff_, buf, buflen, ffe.get()));
- }
- ffe_ = ffe;
- }
-};
-
-FfElementObj::FfElementObj() : state_(new State) {}
-
-FfElementObj::FfElementObj(FfElementObj const& other) : state_(new State) {
- std::vector buf = other.data();
- state_->write(&other.state_->ff_, &buf[0], buf.size());
-}
-
-FfElementObj& FfElementObj::operator=(FfElementObj const& other) {
- std::vector buf = other.data();
- state_->write(&other.state_->ff_, &buf[0], buf.size());
- return *this;
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff) : state_(new State) {
- state_->write(ff, nullptr, 0);
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, FpElemStr const& bytes)
- : state_(new State) {
- init(ff, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, FqElemStr const& bytes)
- : state_(new State) {
- init(ff, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, Fq2ElemStr const& bytes)
- : state_(new State) {
- init(ff, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, Fq6ElemStr const& bytes)
- : state_(new State) {
- init(ff, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, Fq12ElemStr const& bytes)
- : state_(new State) {
- init(ff, (unsigned char*)&bytes, sizeof(bytes));
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff,
- std::vector const& bytes)
- : state_(new State) {
- init(ff, &bytes[0], bytes.size());
-}
-
-FfElementObj::FfElementObj(FiniteFieldObj* ff, void const* bytes, size_t size)
- : state_(new State) {
- init(ff, (unsigned char const*)bytes, size);
-}
-
-void FfElementObj::init(FiniteFieldObj* ff, unsigned char const* bytes,
- size_t size) {
- state_->write(ff, bytes, size);
-}
-
-FfElementObj::~FfElementObj() {}
-
-FfElementObj::operator FfElement*() { return state_->ffe_.get(); }
-
-FfElementObj::operator const FfElement*() const { return state_->ffe_.get(); }
-
-FfElement* FfElementObj::get() { return state_->ffe_.get(); }
-
-FfElement const* FfElementObj::getc() const { return state_->ffe_.get(); }
-
-std::vector FfElementObj::data() const {
- std::vector buf;
- if (state_->ffe_.get() != nullptr) {
- buf.resize(state_->ff_.GetElementMaxSize());
- THROW_ON_EPIDERR(
- WriteFfElement(state_->ff_, state_->ffe_.get(), &buf[0], buf.size()));
- }
- return buf;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.h
deleted file mode 100644
index 4a0bc5b6d1..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/ffelement_wrapper-testhelper.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FfElement C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_
-
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/finitefield.h"
-}
-
-class FiniteFieldObj;
-
-/*!
-Wrapper class to provide Resource Allocation is Initialization handling
-for FfElement
-*/
-class FfElementObj {
- public:
- /// constructor
- FfElementObj();
- /// copy constructor
- FfElementObj(FfElementObj const& other);
- /// assignment operator
- FfElementObj& operator=(FfElementObj const& other);
- /// Create a FfElement
- explicit FfElementObj(FiniteFieldObj* ff);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, FpElemStr const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, FqElemStr const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, Fq2ElemStr const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, Fq6ElemStr const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, Fq12ElemStr const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, std::vector const& bytes);
- /// Create a FfElement
- FfElementObj(FiniteFieldObj* ff, void const* bytes, size_t size);
- /// Destroy the FfElement
- ~FfElementObj();
- /// cast operator to get the pointer to the stored FfElement
- operator FfElement*();
- /// const cast operator to get the pointer to the stored FfElement
- operator const FfElement*() const;
- /// Get the underlying pointer
- FfElement* get();
- /// Get the underlying pointer
- FfElement const* getc() const;
- /// Get element bytes
- std::vector data() const;
-
- private:
- void init(FiniteFieldObj* ff, unsigned char const* bytes, size_t size);
- struct State;
- std::unique_ptr state_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_FFELEMENT_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.cc
deleted file mode 100644
index 6240415f17..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FiniteField C++ wrapper implementation.
- */
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common/math/bignum.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-
-/// finite field deleter type
-struct FiniteFieldDeleter {
- /// finite field deleter
- void operator()(FiniteField* ff) {
- if (ff) {
- DeleteFiniteField(&ff);
- }
- }
-};
-
-/// finite field deleter singlton
-FiniteFieldDeleter finite_field_deleter;
-
-/// Internal state of the finite field wrapper
-struct FiniteFieldObj::State {
- /// Inner state of complex fields
- struct InnerState {
- /// The ground field
- FiniteFieldObj gf_;
- /// The ground element
- FfElementObj ge_;
- };
- /// Inner state
- /*!
- We store a pointer to InnerState so simple fields
- that are not composed from other fields do not result
- in an infinite series of fields.
-
- Instead simple fields have a NULL inner_state and
- complex fields have it set.
- */
- InnerState* inner_state;
-
- /// The stored FiniteField
- std::shared_ptr ff_;
-
- /// Maximum size of field element
- size_t size_;
-
- /// constructor
- State() : ff_(nullptr, finite_field_deleter), size_(0) {
- inner_state = nullptr;
- }
-
- // State instances are not meant to be copied.
- // Explicitly delete copy constructor and assignment operator.
- State(const State&) = delete;
- State& operator=(const State&) = delete;
-
- /// destructor
- ~State() {
- if (inner_state) {
- delete inner_state;
- inner_state = nullptr;
- }
- }
-
- /// setter for inner_state
- void SetInnerState(FiniteFieldObj const& gf, FfElementObj const& ge) {
- if (!inner_state) {
- inner_state = new InnerState;
- inner_state->gf_ = gf;
- inner_state->ge_ = ge;
- }
- }
-
- /// setter for inner_state
- void SetInnerState(InnerState* state) {
- if (state) {
- if (!inner_state) {
- inner_state = new InnerState;
- }
- if (!inner_state) {
- inner_state->gf_ = state->gf_;
- inner_state->ge_ = state->ge_;
- }
- } else {
- if (inner_state) {
- delete inner_state;
- inner_state = nullptr;
- }
- }
- }
-};
-
-FiniteFieldObj::FiniteFieldObj() : state_(new State()) {
- /*
- to avoid a bug in ipp this is one less than the
- actual max value we could take.
- */
- const BigNumStr max_prime = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFe};
- FiniteField* temp = nullptr;
- NewFiniteField(&max_prime, &temp);
- state_->ff_.reset(temp, finite_field_deleter);
- state_->size_ = sizeof(max_prime);
-}
-
-FiniteFieldObj::FiniteFieldObj(FiniteFieldObj const& other)
- : state_(new State) {
- state_->ff_ = other.state_->ff_;
- state_->size_ = other.state_->size_;
- state_->SetInnerState(other.state_->inner_state);
-}
-
-FiniteFieldObj& FiniteFieldObj::operator=(FiniteFieldObj const& other) {
- state_->ff_ = other.state_->ff_;
- state_->size_ = other.state_->size_;
- state_->SetInnerState(other.state_->inner_state);
- return *this;
-}
-
-FiniteFieldObj::FiniteFieldObj(BigNumStr const& prime) : state_(new State) {
- FiniteField* temp = nullptr;
- NewFiniteField(&prime, &temp);
- state_->ff_.reset(temp, finite_field_deleter);
- state_->size_ = sizeof(prime);
-}
-
-FiniteFieldObj::FiniteFieldObj(FiniteFieldObj const& ground_field,
- FfElementObj const& ground_element, int degree)
- : state_(new State) {
- FiniteField* temp = nullptr;
- state_->SetInnerState(ground_field, ground_element);
- NewFiniteFieldViaBinomalExtension(ground_field, ground_element, degree,
- &temp);
- state_->ff_.reset(temp, finite_field_deleter);
- state_->size_ = ground_field.GetElementMaxSize() * degree;
-}
-
-FiniteFieldObj::~FiniteFieldObj() {}
-
-FiniteFieldObj::operator FiniteField*() { return state_->ff_.get(); }
-
-FiniteFieldObj::operator const FiniteField*() const {
- return state_->ff_.get();
-}
-
-FiniteField* FiniteFieldObj::get() { return state_->ff_.get(); }
-
-FiniteField const* FiniteFieldObj::getc() const { return state_->ff_.get(); }
-
-size_t FiniteFieldObj::GetElementMaxSize() const { return state_->size_; }
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.h
deleted file mode 100644
index f293bc7287..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/finite_field_wrapper-testhelper.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FiniteField C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
-
-#include
-#include
-
-extern "C" {
-#include "epid/common/math/finitefield.h"
-}
-
-class FfElementObj;
-
-/*!
-Wrapper class to provide Resource Allocation is Initialization handling
-for FiniteField
-*/
-class FiniteFieldObj {
- public:
- /// constructor
- FiniteFieldObj();
- /// copy constructor
- FiniteFieldObj(FiniteFieldObj const& other);
- /// assignment operator
- FiniteFieldObj& operator=(FiniteFieldObj const& other);
- /// Create a FiniteField
- explicit FiniteFieldObj(BigNumStr const& prime);
- /// Create a FiniteField
- FiniteFieldObj(FiniteFieldObj const& ground_field,
- FfElementObj const& ground_element, int degree);
- /// Destroy the FiniteField
- ~FiniteFieldObj();
- /// cast operator to get the pointer to the stored FiniteField
- operator FiniteField*();
- /// const cast operator to get the pointer to the stored FiniteField
- operator const FiniteField*() const;
- /// Get the underlying pointer
- FiniteField* get();
- /// Get the underlying pointer
- FiniteField const* getc() const;
- /// Get maximum size of field element
- size_t GetElementMaxSize() const;
-
- private:
- struct State;
- std::unique_ptr state_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.cc
deleted file mode 100644
index 2555e662e0..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief OctString handling utility implementation.
- */
-#include "epid/common-testhelper/octstr-testhelper.h"
-extern "C" {
-#include "epid/common/memory.h"
-}
-#include "ext/ipp/include/ippcp.h"
-
-/// Internal function to delete BigNum
-void delete_BigNum(IppsBigNumState** bn) {
- if (*bn) {
- SAFE_FREE(*bn);
- }
-}
-/// Internal function to create BigNum from an OctStr256
-EpidStatus create_BigNum(IppsBigNumState** bn, const OctStr256* str) {
- EpidStatus result = kEpidErr;
- IppsBigNumState* ipp_bn_ctx = nullptr;
- do {
- IppStatus sts = ippStsNoErr;
- unsigned int byte_size = sizeof(OctStr256);
- unsigned int word_size =
- (unsigned int)((byte_size + sizeof(Ipp32u) - 1) / sizeof(Ipp32u));
- int bignum_ctx_size = 0;
-
- if (!bn || !str) {
- return kEpidBadArgErr;
- }
-
- sts = ippsBigNumGetSize(word_size, &bignum_ctx_size);
- if (ippStsNoErr != sts) {
- if (ippStsLengthErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- // Allocate space for ipp bignum context
- ipp_bn_ctx = (IppsBigNumState*)SAFE_ALLOC(bignum_ctx_size);
- if (!ipp_bn_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize ipp bignum context
- sts = ippsBigNumInit(word_size, ipp_bn_ctx);
- if (sts != ippStsNoErr) {
- if (sts == ippStsLengthErr) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
-
- sts = ippsSetOctString_BN((Ipp8u*)str, byte_size, ipp_bn_ctx);
- if (sts != ippStsNoErr) {
- if (sts == ippStsLengthErr) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- *bn = ipp_bn_ctx;
- result = kEpidNoErr;
- } while (0);
-
- if (result != kEpidNoErr) {
- SAFE_FREE(ipp_bn_ctx);
- }
- return result;
-}
-
-EpidStatus Cmp_OctStr256(const OctStr256* pA, const OctStr256* pB,
- unsigned int* pResult) {
- EpidStatus result = kEpidErr;
- IppsBigNumState* ipp_a_ctx = nullptr;
- IppsBigNumState* ipp_b_ctx = nullptr;
-
- do {
- IppStatus sts = ippStsNoErr;
- if (!pA || !pB || !pResult) {
- return kEpidBadArgErr;
- }
- result = create_BigNum(&ipp_a_ctx, pA);
- if (kEpidNoErr != result) {
- break;
- }
- result = create_BigNum(&ipp_b_ctx, pB);
- if (kEpidNoErr != result) {
- break;
- }
- sts = ippsCmp_BN(ipp_a_ctx, ipp_b_ctx, pResult);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts || ippStsOutOfRangeErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- }
- } while (0);
-
- delete_BigNum(&ipp_a_ctx);
- delete_BigNum(&ipp_b_ctx);
- return result;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.h
deleted file mode 100644
index 1d60062d75..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/octstr-testhelper.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief OctString handling utility interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_OCTSTR_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_OCTSTR_TESTHELPER_H_
-
-#include "epid/common/errors.h"
-#include "epid/common/types.h"
-
-/// Compares 2 OctStr256
-/*!
-
-if A==B, then pResult = 0
-if A > B, then pResult = 1
-if A < B, then pResult = 2
-
-\param[in] pA
-OctStr256 A
-\param[in] pB
-OctStr256 B
-\param[out] pResult
-Comparison Result
-
-\returns ::EpidStatus
-
-*/
-EpidStatus Cmp_OctStr256(const OctStr256* pA, const OctStr256* pB,
- unsigned int* pResult);
-
-#endif // EPID_COMMON_TESTHELPER_OCTSTR_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/prng-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/prng-testhelper.h
deleted file mode 100644
index c44ff0f832..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/prng-testhelper.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Pseudo random number generator interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_PRNG_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_PRNG_TESTHELPER_H_
-
-#if defined(_WIN32) || defined(_WIN64)
-#define __STDCALL __stdcall
-#else
-#define __STDCALL
-#endif
-#include // for CHAR_BIT
-#include
-
-/// Return status for Prng Generate function
-typedef enum {
- kPrngNoErr = 0, //!< no error
- kPrngErr = -999, //!< unspecified error
- kPrngNotImpl, //!< not implemented error
- kPrngBadArgErr //!< incorrect arg to function
-} PrngStatus;
-
-/// Pseudo random number generator (prng) class.
-class Prng {
- public:
- Prng() : seed_(1) { set_seed(seed_); }
- ~Prng() {}
- /// Retrieve seed
- unsigned int get_seed() const { return seed_; }
- /// Set seed for random number generator
- void set_seed(unsigned int val) {
- seed_ = val;
- generator_.seed(seed_);
- }
- /// Generates random number
- static int __STDCALL Generate(unsigned int* random_data, int num_bits,
- void* user_data) {
- unsigned int num_bytes = num_bits / CHAR_BIT;
- int num_words = num_bytes / sizeof(unsigned int);
- if (!random_data) {
- return kPrngBadArgErr;
- }
- if (num_bits <= 0) {
- return kPrngBadArgErr;
- }
- if (num_bytes < sizeof(unsigned int) ||
- num_bytes % sizeof(unsigned int) != 0) {
- return kPrngBadArgErr;
- }
- Prng* myprng = (Prng*)user_data;
- std::uniform_int_distribution<> dis(0x0, 0xffff);
- for (int n = 0; n < num_words; n++) {
- random_data[n] =
- (dis(myprng->generator_) << 16) + dis(myprng->generator_);
- }
- return kPrngNoErr;
- }
-
- private:
- unsigned int seed_;
- std::mt19937 generator_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_PRNG_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/bignum_wrapper-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/bignum_wrapper-test.cc
deleted file mode 100644
index b5aa34ca68..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/bignum_wrapper-test.cc
+++ /dev/null
@@ -1,173 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Bignum C++ wrapper unit tests.
- */
-
-#include "gtest/gtest.h"
-
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/bignum_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/memory.h"
-}
-
-namespace {
-
-// Use Test Fixture for SetUp and TearDown
-class BigNumObjTest : public ::testing::Test {
- public:
- static const BigNumStr str_0;
- static const std::vector vec_0;
-};
-
-const BigNumStr BigNumObjTest::str_0 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-const std::vector BigNumObjTest::vec_0 = {0, 0, 0, 0,
- 0, 0, 0, 0};
-
-TEST_F(BigNumObjTest, ObjDefaultConstructedIsNotNull) {
- BigNumObj bn;
- EXPECT_NE(nullptr, (BigNum*)bn);
-}
-
-TEST_F(BigNumObjTest, ObjConstructedWithSizeIsNotNull) {
- BigNumObj bn1(1);
- EXPECT_NE(nullptr, (BigNum*)bn1);
- BigNumObj bn32(32);
- EXPECT_NE(nullptr, (BigNum*)bn32);
-}
-
-TEST_F(BigNumObjTest, AssignmentDoesNotCopyPointer) {
- BigNumObj bn1;
- BigNumObj bn2;
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn2);
- bn1 = bn2;
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn2);
-}
-
-TEST_F(BigNumObjTest, CopyConstructorDoesNotCopyPointer) {
- BigNumObj bn1;
- BigNumObj bn2(bn1);
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn2);
-}
-
-TEST_F(BigNumObjTest, ConstructorDoesNotThrow) {
- BigNumObj bn1;
- BigNumObj bn2(32);
- BigNumObj bn3(32, this->str_0);
- BigNumObj bn4(32, this->vec_0);
- BigNumObj bn5(this->str_0);
- BigNumObj bn6(this->vec_0);
-
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn2);
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn3);
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn4);
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn5);
- EXPECT_NE((BigNum*)bn1, (BigNum*)bn6);
-
- EXPECT_NE((BigNum*)bn2, (BigNum*)bn1);
- EXPECT_NE((BigNum*)bn2, (BigNum*)bn3);
- EXPECT_NE((BigNum*)bn2, (BigNum*)bn4);
- EXPECT_NE((BigNum*)bn2, (BigNum*)bn5);
- EXPECT_NE((BigNum*)bn2, (BigNum*)bn6);
-
- EXPECT_NE((BigNum*)bn3, (BigNum*)bn1);
- EXPECT_NE((BigNum*)bn3, (BigNum*)bn2);
- EXPECT_NE((BigNum*)bn3, (BigNum*)bn4);
- EXPECT_NE((BigNum*)bn3, (BigNum*)bn5);
- EXPECT_NE((BigNum*)bn3, (BigNum*)bn6);
-
- EXPECT_NE((BigNum*)bn4, (BigNum*)bn1);
- EXPECT_NE((BigNum*)bn4, (BigNum*)bn2);
- EXPECT_NE((BigNum*)bn4, (BigNum*)bn3);
- EXPECT_NE((BigNum*)bn4, (BigNum*)bn5);
- EXPECT_NE((BigNum*)bn4, (BigNum*)bn6);
-
- EXPECT_NE((BigNum*)bn5, (BigNum*)bn1);
- EXPECT_NE((BigNum*)bn5, (BigNum*)bn2);
- EXPECT_NE((BigNum*)bn5, (BigNum*)bn3);
- EXPECT_NE((BigNum*)bn5, (BigNum*)bn4);
- EXPECT_NE((BigNum*)bn5, (BigNum*)bn6);
-
- EXPECT_NE((BigNum*)bn6, (BigNum*)bn1);
- EXPECT_NE((BigNum*)bn6, (BigNum*)bn2);
- EXPECT_NE((BigNum*)bn6, (BigNum*)bn3);
- EXPECT_NE((BigNum*)bn6, (BigNum*)bn4);
- EXPECT_NE((BigNum*)bn6, (BigNum*)bn5);
-}
-
-TEST_F(BigNumObjTest, CanCastConstToConstPointer) {
- BigNumObj const bn;
- BigNum const* bn_ptr = bn;
- (void)bn_ptr;
-}
-
-TEST_F(BigNumObjTest, CanGetConstPointerFromConst) {
- BigNumObj const bn;
- BigNum const* bn_ptr = bn.getc();
- (void)bn_ptr;
-}
-
-/*
-The following tests are expected to result in
-compile time errors (by design)
-*/
-/*
-TEST_F(BigNumObjTest, CannotCastConstToNonConstPointer) {
- BigNumObj const bn;
- BigNum * bn_ptr = bn;
- (void) bn_ptr;
-}
-
-TEST_F(BigNumObjTest, CannotGetNonConstPointerFromConst) {
- BigNumObj const bn;
- BigNum * bn_ptr = bn.get();
- (void) bn_ptr;
-}
-*/
-
-TEST_F(BigNumObjTest, CanCastNonConstToConstPointer) {
- BigNumObj bn;
- BigNum const* bn_ptr = bn;
- (void)bn_ptr;
-}
-
-TEST_F(BigNumObjTest, CanGetConstPointerFromNonConst) {
- BigNumObj bn;
- BigNum const* bn_ptr = bn.getc();
- (void)bn_ptr;
-}
-
-TEST_F(BigNumObjTest, CanCastNonConstToNonConstPointer) {
- BigNumObj bn;
- BigNum* bn_ptr = bn;
- (void)bn_ptr;
-}
-
-TEST_F(BigNumObjTest, CanGetNonConstPointerFromNonConst) {
- BigNumObj bn;
- BigNum* bn_ptr = bn.get();
- (void)bn_ptr;
-}
-
-} // namespace
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecgroup_wrapper-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecgroup_wrapper-test.cc
deleted file mode 100644
index ad496d4f40..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecgroup_wrapper-test.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcGroup C++ wrapper unit tests.
- */
-
-#include "gtest/gtest.h"
-
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/bignum_wrapper-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/memory.h"
-#include "epid/common/types.h"
-}
-
-namespace {
-
-// Use Test Fixture for SetUp and TearDown
-class EcGroupObjTest : public ::testing::Test {
- public:
- static const BigNumStr q_str;
- static const FqElemStr b_str;
- static const BigNumStr p_str;
- static const BigNumStr h1;
- static const G1ElemStr g1_str;
-};
-const BigNumStr EcGroupObjTest::q_str = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9F, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13}}};
-const FqElemStr EcGroupObjTest::b_str = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}};
-const BigNumStr EcGroupObjTest::p_str = {
- {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2, 0x5E,
- 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99, 0x92, 0x1A,
- 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D}}};
-const BigNumStr EcGroupObjTest::h1 = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
-const G1ElemStr EcGroupObjTest::g1_str = {
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}};
-
-TEST_F(EcGroupObjTest, ObjDefaultConstructedIsNotNull) {
- EcGroupObj group;
- EXPECT_NE(nullptr, (EcGroup*)group);
-}
-
-TEST_F(EcGroupObjTest, AssignmentCopiesPointer) {
- EcGroupObj group1;
- EcGroupObj group2;
- EXPECT_NE((EcGroup*)group1, (EcGroup*)group2);
- group1 = group2;
- EXPECT_EQ((EcGroup*)group1, (EcGroup*)group2);
-}
-
-TEST_F(EcGroupObjTest, CopyConstructorCopiesPointer) {
- EcGroupObj group1;
- EcGroupObj group2(group1);
- EXPECT_EQ((EcGroup*)group1, (EcGroup*)group2);
-}
-
-TEST_F(EcGroupObjTest, ConstructorDoesNotThrow) {
- EcGroupObj group1;
- FiniteFieldObj fq(this->q_str);
- EcGroupObj group2(&fq, FfElementObj(&fq), FfElementObj(&fq, this->b_str),
- FfElementObj(&fq, this->g1_str.x),
- FfElementObj(&fq, this->g1_str.y), BigNumObj(this->p_str),
- BigNumObj(this->h1));
-}
-
-TEST_F(EcGroupObjTest, CanCastConstToConstPointer) {
- EcGroupObj const group;
- EcGroup const* group_ptr = group;
- (void)group_ptr;
-}
-
-TEST_F(EcGroupObjTest, CanGetConstPointerFromConst) {
- EcGroupObj const group;
- EcGroup const* group_ptr = group.getc();
- (void)group_ptr;
-}
-
-/*
-The following tests are expected to result in
-compile time errors (by design)
-*/
-/*
-TEST_F(EcGroupObjTest, CannotCastConstToNonConstPointer) {
- EcGroupObj const group;
- EcGroup * group_ptr = group;
- (void) group_ptr;
-}
-
-TEST_F(EcGroupObjTest, CannotGetNonConstPointerFromConst) {
- EcGroupObj const group;
- EcGroup * group_ptr = group.get();
- (void) group_ptr;
-}
-*/
-
-TEST_F(EcGroupObjTest, CanCastNonConstToConstPointer) {
- EcGroupObj group;
- EcGroup const* group_ptr = group;
- (void)group_ptr;
-}
-
-TEST_F(EcGroupObjTest, CanGetConstPointerFromNonConst) {
- EcGroupObj group;
- EcGroup const* group_ptr = group.getc();
- (void)group_ptr;
-}
-
-TEST_F(EcGroupObjTest, CanCastNonConstToNonConstPointer) {
- EcGroupObj group;
- EcGroup* group_ptr = group;
- (void)group_ptr;
-}
-
-TEST_F(EcGroupObjTest, CanGetNonConstPointerFromNonConst) {
- EcGroupObj group;
- EcGroup* group_ptr = group.get();
- (void)group_ptr;
-}
-
-} // namespace
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecpoint_wrapper-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecpoint_wrapper-test.cc
deleted file mode 100644
index 840521bdc8..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ecpoint_wrapper-test.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcPoint C++ wrapper unit tests.
- */
-
-#include "gtest/gtest.h"
-
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h"
-#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/memory.h"
-}
-
-namespace {
-
-// Use Test Fixture for SetUp and TearDown
-class EcPointObjTest : public ::testing::Test {
- public:
- static EcGroupObj group;
- static const G1ElemStr group_str_1;
- static const G1ElemStr group_str_2;
-};
-
-const G1ElemStr EcPointObjTest::group_str_1 = {
- {{{0x12, 0xA6, 0x5B, 0xD6, 0x91, 0x8D, 0x50, 0xA7, 0x66, 0xEB, 0x7D, 0x52,
- 0xE3, 0x40, 0x17, 0x60, 0x7F, 0xDF, 0x6C, 0xA1, 0x2C, 0x1A, 0x37, 0xE0,
- 0x92, 0xC0, 0xF7, 0xB9, 0x76, 0xAB, 0xB1, 0x8A}}},
- {{{0x78, 0x65, 0x28, 0xCB, 0xAF, 0x07, 0x52, 0x50, 0x55, 0x7A, 0x5F, 0x30,
- 0x0A, 0xC0, 0xB4, 0x6B, 0xEA, 0x6F, 0xE2, 0xF6, 0x6D, 0x96, 0xF7, 0xCD,
- 0xC8, 0xD3, 0x12, 0x7F, 0x1F, 0x3A, 0x8B, 0x42}}}};
-
-const G1ElemStr EcPointObjTest::group_str_2 = {
- {{{0xE6, 0x65, 0x23, 0x9B, 0xD4, 0x07, 0x16, 0x83, 0x38, 0x23, 0xB2, 0x67,
- 0x57, 0xEB, 0x0F, 0x23, 0x3A, 0xF4, 0x8E, 0xDA, 0x71, 0x5E, 0xD9, 0x98,
- 0x63, 0x98, 0x2B, 0xBC, 0x78, 0xD1, 0x94, 0xF2}}},
- {{{0x63, 0xB0, 0xAD, 0xB8, 0x2C, 0xE8, 0x14, 0xFD, 0xA2, 0x39, 0x0E, 0x66,
- 0xB7, 0xD0, 0x6A, 0xAB, 0xEE, 0xFA, 0x2E, 0x24, 0x9B, 0xB5, 0x14, 0x35,
- 0xFE, 0xB6, 0xB0, 0xFF, 0xFD, 0x5F, 0x73, 0x19}}}};
-
-EcGroupObj EcPointObjTest::group;
-
-TEST_F(EcPointObjTest, ObjDefaultConstructedIsNotNull) {
- EcPointObj point(&group);
- EXPECT_NE(nullptr, (EcPoint*)point);
-}
-
-TEST_F(EcPointObjTest, AssignmentDoesNotCopyPointer) {
- EcPointObj point1(&group, group_str_1);
- EcPointObj point2(&group, group_str_2);
- EXPECT_NE((EcPoint*)point1, (EcPoint*)point2);
- point1 = point2;
- EXPECT_NE((EcPoint*)point1, (EcPoint*)point2);
-}
-
-TEST_F(EcPointObjTest, CopyConstructorDoesNotCopyPointer) {
- EcPointObj point1(&group, group_str_1);
- EcPointObj point2(point1);
- EXPECT_NE((EcPoint*)point1, (EcPoint*)point2);
-}
-
-TEST_F(EcPointObjTest, CanCastConstToConstPointer) {
- EcPointObj const point(&group);
- EcPoint const* point_ptr = point;
- (void)point_ptr;
-}
-
-TEST_F(EcPointObjTest, CanGetConstPointerFromConst) {
- EcPointObj const point(&group);
- EcPoint const* point_ptr = point.getc();
- (void)point_ptr;
-}
-
-/*
-The following tests are expected to result in
-compile time errors (by design)
-*/
-/*
-TEST_F(EcPointObjTest, CannotCastConstToNonConstPointer) {
- EcPointObj const point(&group);
- EcPoint * point_ptr = point;
- (void) point_ptr;
-}
-
-TEST_F(EcPointObjTest, CannotGetNonConstPointerFromConst) {
- EcPointObj const point(&group);
- EcPoint * point_ptr = point.get();
- (void) point_ptr;
-}
-*/
-
-TEST_F(EcPointObjTest, CanCastNonConstToConstPointer) {
- EcPointObj point(&group);
- EcPoint const* point_ptr = point;
- (void)point_ptr;
-}
-
-TEST_F(EcPointObjTest, CanGetConstPointerFromNonConst) {
- EcPointObj point(&group);
- EcPoint const* point_ptr = point.getc();
- (void)point_ptr;
-}
-
-TEST_F(EcPointObjTest, CanCastNonConstToNonConstPointer) {
- EcPointObj point(&group);
- EcPoint* point_ptr = point;
- (void)point_ptr;
-}
-
-TEST_F(EcPointObjTest, CanGetNonConstPointerFromNonConst) {
- EcPointObj point(&group);
- EcPoint* point_ptr = point.get();
- (void)point_ptr;
-}
-
-} // namespace
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ffelement_wrapper-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ffelement_wrapper-test.cc
deleted file mode 100644
index 2e7bda61c6..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/ffelement_wrapper-test.cc
+++ /dev/null
@@ -1,156 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FfElement C++ wrapper unit tests.
- */
-
-#include "gtest/gtest.h"
-
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/memory.h"
-}
-
-namespace {
-
-// Use Test Fixture for SetUp and TearDown
-class FfElementObjTest : public ::testing::Test {
- public:
- static FiniteFieldObj ff;
- static const BigNumStr prime_str;
-
- static const FpElemStr ff_str_1;
- static const FpElemStr ff_str_2;
- static const Fq2ElemStr ff_2_str;
-};
-
-/// Intel(R) EPID 2.0 parameter p
-const BigNumStr FfElementObjTest::prime_str = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
- 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
- 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D};
-
-const FpElemStr FfElementObjTest::ff_str_1 = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-};
-
-const FpElemStr FfElementObjTest::ff_str_2 = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-};
-
-const Fq2ElemStr FfElementObjTest::ff_2_str = {
- // 1
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
- // 2
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20};
-
-FiniteFieldObj FfElementObjTest::ff(prime_str);
-
-TEST_F(FfElementObjTest, ObjDefaultConstructedIsNotNull) {
- FfElementObj ffe(&ff);
- EXPECT_NE(nullptr, (FfElement*)ffe);
-}
-
-TEST_F(FfElementObjTest, AssignmentDoesNotCopyPointer) {
- FfElementObj ffe1(&ff, ff_str_1);
- FfElementObj ffe2(&ff, ff_str_2);
- EXPECT_NE((FfElement*)ffe1, (FfElement*)ffe2);
- ffe1 = ffe2;
- EXPECT_NE((FfElement*)ffe1, (FfElement*)ffe2);
-}
-
-TEST_F(FfElementObjTest, CopyConstructorDoesNotCopyPointer) {
- FfElementObj ffe1(&ff, ff_str_1);
- FfElementObj ffe2(ffe1);
- EXPECT_NE((FfElement*)ffe1, (FfElement*)ffe2);
-}
-
-TEST_F(FfElementObjTest, CanConstructBinomialElement) {
- FfElementObj ffe1(&ff, ff_str_1);
- FiniteFieldObj ff2(ff, ffe1, 2);
- FfElementObj ff2_e1(&ff2, ff_2_str);
- EXPECT_NE(nullptr, (FfElement*)ff2_e1);
-}
-
-TEST_F(FfElementObjTest, CanCastConstToConstPointer) {
- FfElementObj const ffe(&ff);
- FfElement const* ffe_ptr = ffe;
- (void)ffe_ptr;
-}
-
-TEST_F(FfElementObjTest, CanGetConstPointerFromConst) {
- FfElementObj const ffe(&ff);
- FfElement const* ffe_ptr = ffe.getc();
- (void)ffe_ptr;
-}
-
-/*
-The following tests are expected to result in
-compile time errors (by design)
-*/
-/*
-TEST_F(FfElementObjTest, CannotCastConstToNonConstPointer) {
- FfElementObj const ffe(&ff);
- FfElement * ffe_ptr = ffe;
- (void) ffe_ptr;
-}
-
-TEST_F(FfElementObjTest, CannotGetNonConstPointerFromConst) {
- FfElementObj const ffe(&ff);
- FfElement * ffe_ptr = ffe.get();
- (void) ffe_ptr;
-}
-*/
-
-TEST_F(FfElementObjTest, CanCastNonConstToConstPointer) {
- FfElementObj ffe(&ff);
- FfElement const* ffe_ptr = ffe;
- (void)ffe_ptr;
-}
-
-TEST_F(FfElementObjTest, CanGetConstPointerFromNonConst) {
- FfElementObj ffe(&ff);
- FfElement const* ffe_ptr = ffe.getc();
- (void)ffe_ptr;
-}
-
-TEST_F(FfElementObjTest, CanCastNonConstToNonConstPointer) {
- FfElementObj ffe(&ff);
- FfElement* ffe_ptr = ffe;
- (void)ffe_ptr;
-}
-
-TEST_F(FfElementObjTest, CanGetNonConstPointerFromNonConst) {
- FfElementObj ffe(&ff);
- FfElement* ffe_ptr = ffe.get();
- (void)ffe_ptr;
-}
-
-} // namespace
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/finite_field_wrapper-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/finite_field_wrapper-test.cc
deleted file mode 100644
index 1792e7247f..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/finite_field_wrapper-test.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief FiniteField C++ wrapper unit tests.
- */
-
-#include "gtest/gtest.h"
-
-#include "epid/common-testhelper/errors-testhelper.h"
-#include "epid/common-testhelper/finite_field_wrapper-testhelper.h"
-#include "epid/common-testhelper/ffelement_wrapper-testhelper.h"
-
-extern "C" {
-#include "epid/common/math/bignum.h"
-#include "epid/common/memory.h"
-#include "epid/common/types.h"
-}
-
-namespace {
-
-// Use Test Fixture for SetUp and TearDown
-class FiniteFieldObjTest : public ::testing::Test {
- public:
- static const BigNumStr prime_str;
- static const FpElemStr ground_str;
-};
-
-/// Intel(R) EPID 2.0 parameter p
-const BigNumStr FiniteFieldObjTest::prime_str = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD, 0x46, 0xE5, 0xF2,
- 0x5E, 0xEE, 0x71, 0xA4, 0x9E, 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99,
- 0x92, 0x1A, 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D};
-
-const FpElemStr FiniteFieldObjTest::ground_str = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-TEST_F(FiniteFieldObjTest, ObjDefaultConstructedIsNotNull) {
- FiniteFieldObj ff;
- EXPECT_NE(nullptr, (FiniteField*)ff);
-}
-
-TEST_F(FiniteFieldObjTest, AssignmentCopiesPointer) {
- FiniteFieldObj ff1;
- FiniteFieldObj ff2;
- EXPECT_NE((FiniteField*)ff1, (FiniteField*)ff2);
- ff1 = ff2;
- EXPECT_EQ((FiniteField*)ff1, (FiniteField*)ff2);
-}
-
-TEST_F(FiniteFieldObjTest, CopyConstructorCopiesPointer) {
- FiniteFieldObj ff1;
- FiniteFieldObj ff2(ff1);
- EXPECT_EQ((FiniteField*)ff1, (FiniteField*)ff2);
-}
-
-TEST_F(FiniteFieldObjTest, ConstructorDoesNotThrow) {
- FiniteFieldObj ff1;
- FiniteFieldObj ff2(this->prime_str);
- FfElementObj ffe(&ff2, this->ground_str);
- FiniteFieldObj ff3(ff2, ffe, 2);
-}
-
-TEST_F(FiniteFieldObjTest, CanCastConstToConstPointer) {
- FiniteFieldObj const ff;
- FiniteField const* ff_ptr = ff;
- (void)ff_ptr;
-}
-
-TEST_F(FiniteFieldObjTest, CanGetConstPointerFromConst) {
- FiniteFieldObj const ff;
- FiniteField const* ff_ptr = ff.getc();
- (void)ff_ptr;
-}
-
-/*
-The following tests are expected to result in
-compile time errors (by design)
-*/
-/*
-TEST_F(FiniteFieldObjTest, CannotCastConstToNonConstPointer) {
- FiniteFieldObj const ff;
- FiniteField * ff_ptr = ff;
- (void) ff_ptr;
-}
-
-TEST_F(FiniteFieldObjTest, CannotGetNonConstPointerFromConst) {
- FiniteFieldObj const ff;
- FiniteField * ff_ptr = ff.get();
- (void) ff_ptr;
-}
-*/
-
-TEST_F(FiniteFieldObjTest, CanCastNonConstToConstPointer) {
- FiniteFieldObj ff;
- FiniteField const* ff_ptr = ff;
- (void)ff_ptr;
-}
-
-TEST_F(FiniteFieldObjTest, CanGetConstPointerFromNonConst) {
- FiniteFieldObj ff;
- FiniteField const* ff_ptr = ff.getc();
- (void)ff_ptr;
-}
-
-TEST_F(FiniteFieldObjTest, CanCastNonConstToNonConstPointer) {
- FiniteFieldObj ff;
- FiniteField* ff_ptr = ff;
- (void)ff_ptr;
-}
-
-TEST_F(FiniteFieldObjTest, CanGetNonConstPointerFromNonConst) {
- FiniteFieldObj ff;
- FiniteField* ff_ptr = ff.get();
- (void)ff_ptr;
-}
-
-} // namespace
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/main-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/main-test.cc
deleted file mode 100644
index 70f2d3a182..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/unittests/main-test.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-/*!
- * \file
- * \brief Main entry point for unit tests.
- */
-
-#include "gtest/gtest.h"
-
-int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.cc
deleted file mode 100644
index 9afa2735f3..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcGroup C++ wrapper implementation.
- */
-#include
-#include
-#include
-
-#include "epid/common-testhelper/verifier_wrapper-testhelper.h"
-
-VerifierCtxObj::VerifierCtxObj(GroupPubKey const& pub_key) : ctx_(nullptr) {
- auto sts = EpidVerifierCreate(&pub_key, nullptr, &ctx_);
- if (kEpidNoErr != sts) {
- printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
- throw std::logic_error(std::string("Failed to call: ") +
- "EpidVerifierCreate()");
- }
-}
-
-VerifierCtxObj::VerifierCtxObj(GroupPubKey const& pub_key,
- VerifierPrecomp const& precomp)
- : ctx_(nullptr) {
- auto sts = EpidVerifierCreate(&pub_key, &precomp, &ctx_);
- if (kEpidNoErr != sts) {
- printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
- throw std::logic_error(std::string("Failed to call: ") +
- "EpidVerifierCreate()");
- }
-}
-
-VerifierCtxObj::~VerifierCtxObj() { EpidVerifierDelete(&ctx_); }
-
-VerifierCtx* VerifierCtxObj::ctx() const { return ctx_; }
-
-VerifierCtxObj::operator VerifierCtx*() const { return ctx_; }
-
-VerifierCtxObj::operator const VerifierCtx*() const { return ctx_; }
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.h
deleted file mode 100644
index 1a42f0f813..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common-testhelper/verifier_wrapper-testhelper.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Verifier C++ wrapper interface.
- */
-#ifndef EPID_COMMON_TESTHELPER_VERIFIER_WRAPPER_TESTHELPER_H_
-#define EPID_COMMON_TESTHELPER_VERIFIER_WRAPPER_TESTHELPER_H_
-
-extern "C" {
-#include "epid/verifier/api.h"
-}
-
-/// C++ Wrapper to manage memory for VerifierCtx via RAII
-class VerifierCtxObj {
- public:
- /// Create a VerifierCtx
- explicit VerifierCtxObj(GroupPubKey const& pub_key);
- /// Create a VerifierCtx given precomputation blob
- VerifierCtxObj(GroupPubKey const& pub_key, VerifierPrecomp const& precomp);
-
- // This class instances are not meant to be copied.
- // Explicitly delete copy constructor and assignment operator.
- VerifierCtxObj(const VerifierCtxObj&) = delete;
- VerifierCtxObj& operator=(const VerifierCtxObj&) = delete;
-
- /// Destroy the VerifierCtx
- ~VerifierCtxObj();
- /// get a pointer to the stored VerifierCtx
- VerifierCtx* ctx() const;
- /// cast operator to get the pointer to the stored VerifierCtx
- operator VerifierCtx*() const;
- /// const cast operator to get the pointer to the stored VerifierCtx
- operator const VerifierCtx*() const;
-
- private:
- /// The stored VerifierCtx
- VerifierCtx* ctx_;
-};
-
-#endif // EPID_COMMON_TESTHELPER_VERIFIER_WRAPPER_TESTHELPER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/bitsupplier.h b/sgx-jvm/linux-sgx/external/epid/epid/common/bitsupplier.h
deleted file mode 100644
index 7abee2d03d..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/bitsupplier.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_BITSUPPLIER_H_
-#define EPID_COMMON_BITSUPPLIER_H_
-/*!
- * \file
- * \brief Random data supplier interface.
- */
-
-#if defined(_WIN32) || defined(_WIN64)
-#define __STDCALL __stdcall
-#else
-#define __STDCALL
-#endif
-
-/// Generates random data.
-/*!
- It is the responsibility of the caller of the SDK interfaces to
- implement a function of this prototype and to then pass a pointer
- to this function into methods that require it.
-
- \param[out] rand_data destination buffer
- \param[in] num_bits size of rand_data in bits
- \param[in] user_data user data passed through from api call.
-
- \returns zero on success and non-zero value on error.
-
- \ingroup EpidCommon
- */
-typedef int(__STDCALL* BitSupplier)(unsigned int* rand_data, int num_bits,
- void* user_data);
-
-#endif // EPID_COMMON_BITSUPPLIER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.c b/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.c
deleted file mode 100644
index 7cb3f9cf97..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Commitment hash implementation.
- */
-#include
-#include "epid/common/commitment.h"
-#include "epid/common/memory.h"
-
-EpidStatus SetKeySpecificCommitValues(GroupPubKey const* pub_key,
- CommitValues* values) {
- static const Epid2Params params = {
-#include "epid/common/epid2params_ate.inc"
- };
-
- if (!pub_key || !values) return kEpidBadArgErr;
-
- values->p = params.p;
- values->g1 = params.g1;
- values->g2 = params.g2;
- values->h1 = pub_key->h1;
- values->h2 = pub_key->h2;
- values->w = pub_key->w;
-
- return kEpidNoErr;
-}
-
-EpidStatus SetCalculatedCommitValues(G1ElemStr const* B, G1ElemStr const* K,
- G1ElemStr const* T, EcPoint const* R1,
- EcGroup* G1, FfElement const* R2,
- FiniteField* GT, CommitValues* values) {
- EpidStatus sts;
-
- if (!B || !K || !T || !R1 || !G1 || !R2 || !GT || !values) {
- return kEpidBadArgErr;
- }
-
- values->B = *B;
- values->K = *K;
- values->T = *T;
-
- sts = WriteEcPoint(G1, R1, &values->R1, sizeof(values->R1));
- if (kEpidNoErr != sts) return sts;
- sts = WriteFfElement(GT, R2, &values->R2, sizeof(values->R2));
- if (kEpidNoErr != sts) return sts;
-
- return kEpidNoErr;
-}
-
-EpidStatus CalculateCommitmentHash(CommitValues const* values, FiniteField* Fp,
- HashAlg hash_alg, void const* msg,
- size_t msg_len, FfElement* c) {
- EpidStatus sts;
-
- FfElement* t3 = NULL;
- size_t t3mconcat_size = sizeof(FpElemStr) + msg_len;
- uint8_t* t3mconcat_buf = NULL;
-
- if (!values || !Fp || !c) return kEpidBadArgErr;
- if (!msg && (0 != msg_len)) {
- // if message is non-empty it must have both length and content
- return kEpidBadArgErr;
- }
- if (SIZE_MAX - sizeof(FpElemStr) < msg_len) {
- return kEpidBadArgErr;
- }
-
- do {
- sts = NewFfElement(Fp, &t3);
- if (kEpidNoErr != sts) break;
-
- // compute t3 = Fp.hash(p || g1 || g2 || h1 ||
- // h2 || w || B || K || T || R1 || R2).
- sts = FfHash(Fp, values, sizeof(*values), hash_alg, t3);
- if (kEpidNoErr != sts) break;
-
- // compute c = Fp.hash(t3 || m).
- t3mconcat_buf = SAFE_ALLOC(t3mconcat_size);
- if (!t3mconcat_buf) {
- sts = kEpidMemAllocErr;
- break;
- }
-
- // get t3 into buffer
- sts = WriteFfElement(Fp, t3, t3mconcat_buf, sizeof(FpElemStr));
- if (kEpidNoErr != sts) break;
- // get m into buffer
- if (msg) {
- if (0 != memcpy_S(t3mconcat_buf + sizeof(FpElemStr),
- t3mconcat_size - sizeof(FpElemStr), msg, msg_len)) {
- sts = kEpidBadArgErr;
- break;
- }
- }
-
- sts = FfHash(Fp, t3mconcat_buf, t3mconcat_size, hash_alg, c);
- if (kEpidNoErr != sts) break;
-
- sts = kEpidNoErr;
- } while (0);
-
- SAFE_FREE(t3mconcat_buf);
- DeleteFfElement(&t3);
-
- return sts;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.h b/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.h
deleted file mode 100644
index c607d58d05..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/commitment.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_COMMITMENT_H_
-#define EPID_COMMON_COMMITMENT_H_
-/*!
- * \file
- * \brief Commitment hash interface.
- * \addtogroup EpidCommon
- * @{
- */
-#include "epid/common/errors.h"
-#include "epid/common/types.h"
-#include "epid/common/math/ecgroup.h"
-#include "epid/common/math/finitefield.h"
-
-#pragma pack(1)
-/// Storage for values to create commitment in Sign and Verify algorithms
-typedef struct CommitValues {
- BigNumStr p; ///< Intel(R) EPID2.0 parameter p
- G1ElemStr g1; ///< Intel(R) EPID2.0 parameter g1
- G2ElemStr g2; ///< Intel(R) EPID2.0 parameter g2
- G1ElemStr h1; ///< Group public key value h1
- G1ElemStr h2; ///< Group public key value h2
- G2ElemStr w; ///< Group public key value w
- G1ElemStr B; ///< Variable B computed in algorithm
- G1ElemStr K; ///< Variable K computed in algorithm
- G1ElemStr T; ///< Variable T computed in algorithm
- G1ElemStr R1; ///< Variable R1 computed in algorithm
- Fq12ElemStr R2; ///< Variable R2 computed in algorithm
-} CommitValues;
-#pragma pack()
-
-/// Set group public key related fields from CommitValues structure
-/*!
- Set p, g1, g2, h1, h2 and w fields of values argument.
-
- \param[in] pub_key
- Group public key
- \param[out] values
- Pointer to CommitValues structure to fill.
-
- \returns ::EpidStatus
-
- \see CalculateCommitmentHash
-*/
-EpidStatus SetKeySpecificCommitValues(GroupPubKey const* pub_key,
- CommitValues* values);
-
-/// Set CommitValues structure fields calculated in algorithm
-/*!
- Set B, K, T, R1 and R2 fields of values argument.
-
- \param[in] B
- Value of B to set
- \param[in] K
- Value of K to set
- \param[in] T
- Value of T to set
- \param[in] R1
- Value of R1 to set
- \param[in] G1
- EcGroup containing element R1
- \param[in] R2
- Value of R2 to set
- \param[in] GT
- FiniteField containing element R2
- \param[out] values
- Pointer to CommitValues structure to fill.
-
- \returns ::EpidStatus
-
- \see CalculateCommitmentHash
-*/
-EpidStatus SetCalculatedCommitValues(G1ElemStr const* B, G1ElemStr const* K,
- G1ElemStr const* T, EcPoint const* R1,
- EcGroup* G1, FfElement const* R2,
- FiniteField* GT, CommitValues* values);
-
-/// Calculate Fp.hash(t3 || m) for Sign and Verfiy algorithms
-/*!
- Calculate c = Fp.hash(t3 || m) where t3 is
- Fp.hash(p || g1 || g2 || h1 || h2 || w || B || K || T || R1 || R2).
-
- \param[in] values
- Commit values to hash
- \param[in] Fp
- Finite field to perfom hash operation in
- \param[in] hash_alg
- Hash algorithm to use
- \param[in] msg
- Message to hash
- \param[in] msg_len
- Size of msg buffer in bytes
- \param[out] c
- Result of calculation
-
- \returns ::EpidStatus
-
- \see SetKeySpecificCommitValues
- \see SetCalculatedCommitValues
-*/
-EpidStatus CalculateCommitmentHash(CommitValues const* values, FiniteField* Fp,
- HashAlg hash_alg, void const* msg,
- size_t msg_len, FfElement* c);
-
-/*! @} */
-#endif // EPID_COMMON_COMMITMENT_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/common.parts b/sgx-jvm/linux-sgx/external/epid/epid/common/common.parts
deleted file mode 100644
index 10e90e7b81..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/common.parts
+++ /dev/null
@@ -1,139 +0,0 @@
-############################################################################
-# Copyright 2016 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-############################################################################
-Import('*')
-env.PartName('common')
-
-math_headers = Pattern(src_dir='math',
- includes=[
- 'bignum.h',
- 'ecgroup.h',
- 'finitefield.h',
- 'hash.h',
- 'pairing.h',
- 'printutils.h',
- 'ecdsa.h',
- ],
- excludes=[],
- recursive=False).files()
-math_internal_headers = Pattern(src_dir='math',
- includes=[
- 'bignum-internal.h',
- 'ecgroup-internal.h',
- 'finitefield-internal.h',
- 'pairing-internal.h',
- ],
- excludes=[],
- recursive=False).files()
-common_headers = Pattern(src_dir='.',
- includes=[
- 'bitsupplier.h',
- 'errors.h',
- 'file_parser.h',
- 'stdtypes.h',
- 'types.h',
- ],
- excludes=[],
- recursive=False).files()
-epid_common_headers = Pattern(src_dir='.',
- includes=[
- 'commitment.h',
- 'endian_convert.h',
- 'epid2params.h',
- 'grouppubkey.h',
- 'memory.h',
- 'sigrlvalid.h',
- 'stack.h',
- ],
- excludes=[],
- recursive=False).files()
-epid_params = Pattern(src_dir='.',
- includes=[
- 'epid2params_ate.inc',
- ],
- excludes=[],
- recursive=False).files()
-
-src_files = Pattern(src_dir='.',
- includes=['*.c'],
- excludes=['*-test.cc'],
- recursive=False).files()
-
-math_src_files = Pattern(src_dir='math',
- includes=['*.c'],
- excludes=['*-test.cc'],
- recursive=True).files()
-
-parts_file = Pattern(src_dir='.',
- includes=[
- 'common.parts',
- ],
- excludes=[],
- recursive=False).files()
-
-#unit tests
-utest_files = Pattern(src_dir='.',
- includes=['*-test.cc', '*-testhelper.cc'],
- excludes=[],
- recursive=True).files()
-
-if 'install_package' in env['MODE']:
- env.InstallTopLevel(common_headers, sub_dir='epid/${PART_SHORT_NAME}')
- env.InstallTopLevel(epid_common_headers, sub_dir='epid/${PART_SHORT_NAME}')
- env.InstallTopLevel(src_files, sub_dir='epid/${PART_SHORT_NAME}')
-
- env.InstallTopLevel(math_headers, sub_dir='epid/${PART_SHORT_NAME}/math')
- env.InstallTopLevel(math_src_files, sub_dir='epid/${PART_SHORT_NAME}/math')
- env.InstallTopLevel(math_internal_headers,
- sub_dir='epid/${PART_SHORT_NAME}/math')
-
- env.InstallTopLevel(utest_files,
- sub_dir='epid/${PART_SHORT_NAME}/math/unittests')
- env.InstallTopLevel(epid_params, sub_dir='epid/${PART_SHORT_NAME}')
- env.InstallTopLevel(parts_file, sub_dir='epid/${PART_SHORT_NAME}')
-
-else:
- env.DependsOn([
- Component('ippcp'),
- Component('ippcpepid'),
- ])
-
- env.Append(CPPPATH='#')
-
- testenv = env.Clone()
-
- env.SdkInclude(common_headers, sub_dir='epid/${PART_SHORT_NAME}')
-
- outputs = env.Library('${PART_NAME}', src_files + math_src_files)
- env.Sdk(outputs)
- if 'install_lib' in env['MODE']:
- env.InstallLib(outputs)
- env.InstallInclude(common_headers, sub_dir='${PART_SHORT_NAME}')
-
-#unit tests
- testenv['UNIT_TEST_TARGET_NAME'] = "${PART_NAME}-${UNIT_TEST_TARGET}"
- testenv.UnitTest("utest",
- utest_files,
- command_args=[
- '--gtest_color=yes',
- '--gtest_print_time=1',
- '--gtest_output=xml',
- '--gtest_filter=**',
- ],
- make_pdb=(env.isConfigBasedOn('debug')),
- depends=[Component('gtest'),
- Component('common'),
- Component('common-testhelper')],
- INSTALL_BIN='${INSTALL_TEST_BIN}')
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/endian_convert.h b/sgx-jvm/linux-sgx/external/epid/epid/common/endian_convert.h
deleted file mode 100644
index 432f2b461d..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/endian_convert.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_ENDIAN_CONVERT_H_
-#define EPID_COMMON_ENDIAN_CONVERT_H_
-
-#include
-
-/*!
- * \file
- * \brief Endianness conversion interface.
- * \addtogroup EpidCommon
- * @{
- */
-
-#if !defined(ntohl)
-/// Macros to transform oct str 32 into uint_32
-#define ntohl(u32) \
- ((uint32_t)(((((unsigned char*)&(u32))[0]) << 24) + \
- ((((unsigned char*)&(u32))[1]) << 16) + \
- ((((unsigned char*)&(u32))[2]) << 8) + \
- (((unsigned char*)&(u32))[3])))
-#endif
-
-/*! @} */
-#endif // EPID_COMMON_ENDIAN_CONVERT_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.c b/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.c
deleted file mode 100644
index 3530262887..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.c
+++ /dev/null
@@ -1,575 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Intel(R) EPID 2.0 constant parameters implementation.
- */
-#include "epid/common/epid2params.h"
-#include "epid/common/memory.h"
-
-/// create a new Finite Field Fp
-static EpidStatus NewFp(Epid2Params const* param, FiniteField** Fp);
-/// create a new Finite Field Fq
-static EpidStatus NewFq(Epid2Params const* param, FiniteField** Fq);
-/// create a new Finite Field Fq2
-static EpidStatus NewFq2(Epid2Params const* param, FiniteField* Fq,
- FiniteField** Fq2);
-/// create a new Finite Field Fq6
-EpidStatus NewFq6(Epid2Params const* param, FiniteField* Fq2, FfElement* xi,
- FiniteField** Fq6);
-/// create a new Elliptic curve group G1 over Fq
-static EpidStatus NewG1(Epid2Params const* param, FiniteField* Fq,
- EcGroup** G1);
-/// create a new Elliptic curve group G2 over Fq2
-static EpidStatus NewG2(Epid2Params const* param, BigNum* p, BigNum* q,
- FiniteField* Fq, FiniteField* Fq2, EcGroup** G2);
-/// create a new Finite Field Fq12
-static EpidStatus NewGT(FiniteField* Fq6, FiniteField** GT);
-/// create a new pairing state
-
-/// Deallocate Finite Field Fp
-static void DeleteFp(FiniteField** Fp);
-
-/// Deallocate Finite Field Fq
-static void DeleteFq(FiniteField** Fq);
-/// Deallocate Finite Field Fq2
-static void DeleteFq2(FiniteField** Fq2);
-/// Deallocate Finite Field Fq6
-static void DeleteFq6(FiniteField** Fq6);
-/// Deallocate Elliptic curve group G1 over Fq
-static void DeleteG1(EcGroup** G1);
-/// Deallocate Elliptic curve group G2 over Fq2
-static void DeleteG2(EcGroup** G2);
-/// Deallocate Finite Field Fq12
-static void DeleteGT(FiniteField** GT);
-
-EpidStatus CreateEpid2Params(Epid2Params_** params) {
- EpidStatus result = kEpidErr;
- Epid2Params_* internal_param = NULL;
- BigNumStr t_str = {0};
- Epid2Params params_str = {
-#include "epid/common/epid2params_ate.inc"
- };
- if (!params) {
- return kEpidBadArgErr;
- }
- do {
- internal_param = SAFE_ALLOC(sizeof(Epid2Params_));
- if (!internal_param) {
- result = kEpidMemAllocErr;
- break;
- }
- result = NewBigNum(sizeof(params_str.p), &internal_param->p);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadBigNum(¶ms_str.p, sizeof(params_str.p), internal_param->p);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewBigNum(sizeof(params_str.q), &internal_param->q);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadBigNum(¶ms_str.q, sizeof(params_str.q), internal_param->q);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewBigNum(sizeof(params_str.t), &internal_param->t);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadBigNum(¶ms_str.t, sizeof(params_str.t), internal_param->t);
- if (kEpidNoErr != result) {
- break;
- }
- internal_param->neg = (params_str.neg.data[0]) ? true : false;
-
- result = NewFp(¶ms_str, &internal_param->Fp);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFq(¶ms_str, &internal_param->Fq);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFq2(¶ms_str, internal_param->Fq, &internal_param->Fq2);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(internal_param->Fq2, &internal_param->xi);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(internal_param->Fq2, ¶ms_str.xi,
- sizeof(params_str.xi), internal_param->xi);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFq6(¶ms_str, internal_param->Fq2, internal_param->xi,
- &internal_param->Fq6);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewGT(internal_param->Fq6, &internal_param->GT);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewG1(¶ms_str, internal_param->Fq, &internal_param->G1);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewEcPoint(internal_param->G1, &internal_param->g1);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadEcPoint(internal_param->G1, ¶ms_str.g1,
- sizeof(params_str.g1), internal_param->g1);
- if (kEpidNoErr != result) {
- break;
- }
- result =
- NewG2(¶ms_str, internal_param->p, internal_param->q,
- internal_param->Fq, internal_param->Fq2, &internal_param->G2);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewEcPoint(internal_param->G2, &internal_param->g2);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadEcPoint(internal_param->G2, ¶ms_str.g2,
- sizeof(params_str.g2), internal_param->g2);
- if (kEpidNoErr != result) {
- break;
- }
- result = WriteBigNum(internal_param->t, sizeof(t_str), &t_str);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewPairingState(internal_param->G1, internal_param->G2,
- internal_param->GT, &t_str, internal_param->neg,
- &internal_param->pairing_state);
- if (kEpidNoErr != result) {
- break;
- }
- *params = internal_param;
- result = kEpidNoErr;
- } while (0);
- if (kEpidNoErr != result && internal_param) {
- DeletePairingState(&internal_param->pairing_state);
-
- DeleteEcPoint(&internal_param->g2);
- DeleteEcPoint(&internal_param->g1);
-
- DeleteBigNum(&internal_param->p);
- DeleteBigNum(&internal_param->q);
- DeleteBigNum(&internal_param->t);
-
- DeleteFp(&internal_param->Fp);
- DeleteFq(&internal_param->Fq);
- DeleteFq2(&internal_param->Fq2);
- DeleteFq6(&internal_param->Fq6);
- DeleteGT(&internal_param->GT);
-
- DeleteG1(&internal_param->G1);
- DeleteG2(&internal_param->G2);
-
- SAFE_FREE(internal_param);
- }
- return result;
-}
-
-void DeleteEpid2Params(Epid2Params_** epid_params) {
- if (epid_params && *epid_params) {
- DeletePairingState(&(*epid_params)->pairing_state);
-
- DeleteBigNum(&(*epid_params)->p);
- DeleteBigNum(&(*epid_params)->q);
- DeleteBigNum(&(*epid_params)->t);
- DeleteFfElement(&(*epid_params)->xi);
- DeleteEcPoint(&(*epid_params)->g1);
- DeleteEcPoint(&(*epid_params)->g2);
-
- DeleteFp(&(*epid_params)->Fp);
- DeleteFq(&(*epid_params)->Fq);
- DeleteFq2(&(*epid_params)->Fq2);
- DeleteFq6(&(*epid_params)->Fq6);
- DeleteGT(&(*epid_params)->GT);
-
- DeleteG1(&(*epid_params)->G1);
- DeleteG2(&(*epid_params)->G2);
-
- SAFE_FREE(*epid_params);
- }
-}
-
-static EpidStatus NewFp(Epid2Params const* param, FiniteField** Fp) {
- EpidStatus result = kEpidErr;
- if (!param || !Fp) {
- return kEpidBadArgErr;
- }
- result = NewFiniteField(¶m->p, Fp);
- if (kEpidNoErr != result) {
- return result;
- }
- return kEpidNoErr;
-}
-
-static EpidStatus NewFq(Epid2Params const* param, FiniteField** Fq) {
- EpidStatus result = kEpidErr;
- if (!param || !Fq) {
- return kEpidBadArgErr;
- }
- result = NewFiniteField(¶m->q, Fq);
- if (kEpidNoErr != result) {
- return result;
- }
- return kEpidNoErr;
-}
-EpidStatus NewFq2(Epid2Params const* param, FiniteField* Fq,
- FiniteField** Fq2) {
- EpidStatus result = kEpidErr;
- FiniteField* Ff = NULL;
- FfElement* beta = NULL;
- FfElement* neg_beta = NULL;
- if (!param || !Fq || !Fq2) {
- return kEpidBadArgErr;
- }
- do {
- result = NewFfElement(Fq, &beta);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(Fq, &neg_beta);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq, ¶m->beta, sizeof(param->beta), beta);
- if (kEpidNoErr != result) {
- break;
- }
- result = FfNeg(Fq, beta, neg_beta);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFiniteFieldViaBinomalExtension(Fq, neg_beta, 2, &Ff);
- if (kEpidNoErr != result) {
- break;
- }
- *Fq2 = Ff;
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&neg_beta);
- DeleteFfElement(&beta);
-
- return result;
-}
-EpidStatus NewFq6(Epid2Params const* param, FiniteField* Fq2, FfElement* xi,
- FiniteField** Fq6) {
- EpidStatus result = kEpidErr;
- FiniteField* Ff = NULL;
- FfElement* neg_xi = NULL;
- if (!param || !Fq2 || !Fq6) {
- return kEpidBadArgErr;
- }
- do {
- result = NewFfElement(Fq2, &neg_xi);
- if (kEpidNoErr != result) {
- break;
- }
- result = FfNeg(Fq2, xi, neg_xi);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFiniteFieldViaBinomalExtension(Fq2, neg_xi, 3, &Ff);
- if (kEpidNoErr != result) {
- break;
- }
- *Fq6 = Ff;
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&neg_xi);
-
- return result;
-}
-EpidStatus NewG1(Epid2Params const* param, FiniteField* Fq, EcGroup** G1) {
- EpidStatus result = kEpidErr;
- EcGroup* ec = NULL;
- FfElement* fq_a = NULL;
- FfElement* fq_b = NULL;
- FfElement* g1_x = NULL;
- FfElement* g1_y = NULL;
- BigNum* order = NULL;
- BigNum* cofactor = NULL;
- // h = 1;
- const BigNumStr h1 = {
- {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}};
-
- if (!param || !Fq || !G1) {
- return kEpidBadArgErr;
- }
- do {
- // Create G1
- // G1 is an elliptic curve group E(Fq).It can be initialized as follows :
- // 1. Set G1 = E(Fq).init(p, q, n = p, h = 1, a = 0, b, g1.x, g1.y).
- // a = 0
- // NewFfelement is Identidy
- result = NewFfElement(Fq, &fq_a);
- if (kEpidNoErr != result) {
- break;
- }
- // b
- result = NewFfElement(Fq, &fq_b);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq, ¶m->b, sizeof(param->b), fq_b);
- if (kEpidNoErr != result) {
- break;
- }
- // g1.x
- result = NewFfElement(Fq, &g1_x);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq, ¶m->g1.x, sizeof(param->g1.x), g1_x);
- if (kEpidNoErr != result) {
- break;
- }
- // g1.y
- result = NewFfElement(Fq, &g1_y);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq, ¶m->g1.y, sizeof(param->g1.y), g1_y);
- if (kEpidNoErr != result) {
- break;
- }
- // order
- result = NewBigNum(sizeof(BigNumStr), &order);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadBigNum(¶m->p, sizeof(param->p), order);
- if (kEpidNoErr != result) {
- break;
- }
- // cofactor
- result = NewBigNum(sizeof(BigNumStr), &cofactor);
- if (kEpidNoErr != result) {
- break;
- }
-
- result = ReadBigNum(&h1, sizeof(h1), cofactor);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewEcGroup(Fq, fq_a, fq_b, g1_x, g1_y, order, cofactor, &ec);
- if (kEpidNoErr != result) {
- break;
- }
- *G1 = ec;
- result = kEpidNoErr;
- } while (0);
-
- DeleteBigNum(&cofactor);
- DeleteBigNum(&order);
- DeleteFfElement(&g1_y);
- DeleteFfElement(&g1_x);
- DeleteFfElement(&fq_b);
- DeleteFfElement(&fq_a);
-
- return result;
-}
-EpidStatus NewG2(Epid2Params const* param, BigNum* p, BigNum* q,
- FiniteField* Fq, FiniteField* Fq2, EcGroup** G2) {
- EpidStatus result = kEpidErr;
- EcGroup* ec = NULL;
- FfElement* a = NULL;
- FfElement* b = NULL;
- FfElement* fq_param_b = NULL;
- FfElement* x = NULL;
- FfElement* y = NULL;
- BigNum* order = NULL;
- BigNum* cofactor = NULL;
- if (!param || !Fq || !Fq2 || !G2) {
- return kEpidBadArgErr;
- }
- do {
- // 2. Set xi = (xi0, xi1) an element of Fq2.
- // 3. Let b', xi' be a temporary variable in Fq2.
- // 4. Compute xi' = Fq2.inverse(xi).
- // 5. Compute b' = Fq2.mul(xi', b).
- result = NewFfElement(Fq2, &b);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq2, ¶m->xi, sizeof(param->xi), b);
- if (kEpidNoErr != result) {
- break;
- }
- result = FfInv(Fq2, b, b);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(Fq, &fq_param_b);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq, ¶m->b, sizeof(param->b), fq_param_b);
- if (kEpidNoErr != result) {
- break;
- }
- result = FfMul(Fq2, b, fq_param_b, b); // ??? overflow fq2*fq
- if (kEpidNoErr != result) {
- break;
- }
- // 6. Set g2.x = (g2.x[0], g2.x[1]) an element of Fq2.
- // 7. Set g2.y = (g2.y[0], g2.y[1]) an element of Fq2.
- result = NewFfElement(Fq2, &x);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq2, ¶m->g2.x, sizeof(param->g2.x), x);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(Fq2, &y);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq2, ¶m->g2.y, sizeof(param->g2.y), y);
- if (kEpidNoErr != result) {
- break;
- }
- // 8. set h = 2q - p, aka cofactor
- result = NewBigNum(2 * sizeof(param->q), &cofactor);
- if (kEpidNoErr != result) {
- break;
- }
- result = BigNumAdd(q, q, cofactor);
- if (kEpidNoErr != result) {
- break;
- }
- result = BigNumSub(cofactor, p, cofactor);
- if (kEpidNoErr != result) {
- break;
- }
- // 9. set n = p * h, AKA order
- result = NewBigNum(2 * sizeof(param->q), &order);
- if (kEpidNoErr != result) {
- break;
- }
- result = BigNumMul(p, cofactor, order);
- if (kEpidNoErr != result) {
- break;
- }
- // set a to identity, NewFfElement does it by default
- result = NewFfElement(Fq2, &a);
- if (kEpidNoErr != result) {
- break;
- }
- // 10. Set G2 = E(Fq2).init(p, param(Fq2), n, h, 0, b', g2.x, g2.y)
- result = NewEcGroup(Fq2, a, b, x, y, order, cofactor, &ec);
- if (kEpidNoErr != result) {
- break;
- }
- *G2 = ec;
- result = kEpidNoErr;
- } while (0);
-
- DeleteBigNum(&cofactor);
- DeleteBigNum(&order);
- DeleteFfElement(&y);
- DeleteFfElement(&x);
- DeleteFfElement(&b);
- DeleteFfElement(&a);
- DeleteFfElement(&fq_param_b);
-
- return result;
-}
-EpidStatus NewGT(FiniteField* Fq6, FiniteField** GT) {
- EpidStatus result = kEpidErr;
- FiniteField* Ff = NULL;
- FfElement* v = NULL;
- FfElement* neg_v = NULL;
-
- const Fq6ElemStr v_str = {
- {{{{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}},
- {{{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}},
- {{{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}},
- {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}}}}};
-
- if (!Fq6 || !GT) {
- return kEpidBadArgErr;
- }
- do {
- result = NewFfElement(Fq6, &v);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(Fq6, &neg_v);
- if (kEpidNoErr != result) {
- break;
- }
- result = ReadFfElement(Fq6, &v_str, sizeof(v_str), v);
- if (kEpidNoErr != result) {
- break;
- }
- result = FfNeg(Fq6, v, neg_v);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFiniteFieldViaBinomalExtension(Fq6, neg_v, 2, &Ff);
- if (kEpidNoErr != result) {
- break;
- }
- *GT = Ff;
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&v);
- DeleteFfElement(&neg_v);
-
- return result;
-}
-static void DeleteFp(FiniteField** Fp) { DeleteFiniteField(Fp); }
-static void DeleteFq(FiniteField** Fq) { DeleteFiniteField(Fq); }
-static void DeleteFq2(FiniteField** Fq2) { DeleteFiniteField(Fq2); }
-static void DeleteFq6(FiniteField** Fq6) { DeleteFiniteField(Fq6); }
-static void DeleteG1(EcGroup** G1) { DeleteEcGroup(G1); }
-static void DeleteG2(EcGroup** G2) { DeleteEcGroup(G2); }
-static void DeleteGT(FiniteField** GT) { DeleteFiniteField(GT); }
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.h b/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.h
deleted file mode 100644
index a079f2760e..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_EPID2PARAMS_H_
-#define EPID_COMMON_EPID2PARAMS_H_
-/*!
- * \file
- * \brief Intel(R) EPID 2.0 constant parameters interface.
- * \addtogroup EpidCommon
- * @{
- */
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/ecgroup.h"
-#include "epid/common/math/finitefield.h"
-#include "epid/common/math/pairing.h"
-
-/// Internal representation of Epid2Params
-typedef struct Epid2Params_ {
- BigNum* p; ///< a prime
- BigNum* q; ///< a prime
- BigNum* t; ///< an integer
- bool neg; ///< a boolean
- FfElement* xi; ///< array of integers between [0, q-1]
- EcPoint* g1; ///< a generator (an element) of G1
- EcPoint* g2; ///< a generator (an element) of G2
-
- FiniteField* Fp; ///< Finite field Fp
-
- FiniteField* Fq; ///< Finite field Fq
- FiniteField* Fq2; ///< Finite field Fq2
- FiniteField* Fq6; ///< Finite field Fq6
- FiniteField* GT; ///< Finite field GT(Fq12 )
-
- EcGroup* G1; ///< Elliptic curve group over finite field Fq
- EcGroup* G2; ///< Elliptic curve group over finite field Fq2
-
- PairingState* pairing_state; ///< Pairing state
-} Epid2Params_;
-
-/// Constructs the internal representation of Epid2Params
-/*!
- Allocates memory for the internal representation of Epid2Params. Initialize
- the Epid2Params. Use DeleteEpid2Params() to deallocate memory.
-
- \param[in,out] params
- Internal Epid2Params
-
- \returns ::EpidStatus
- \see DeleteEpid2Params
-*/
-EpidStatus CreateEpid2Params(Epid2Params_** params);
-/// Deallocates storage for internal representation of Epid2Params
-/*!
- Frees the memory and nulls the pointer.
-
- \param[in,out] epid_params
- params to be deallocated
-
- \see CreateEpid2Params
-*/
-void DeleteEpid2Params(Epid2Params_** epid_params);
-/*! @} */
-#endif // EPID_COMMON_EPID2PARAMS_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params_ate.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params_ate.inc
deleted file mode 100644
index c13c95de68..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/epid2params_ate.inc
+++ /dev/null
@@ -1,111 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- *
- * \brief Intel(R) EPID 2.0 constant parameters data.
- *
- */
-
- {{{ // p
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD,
- 0x46, 0xE5, 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9E,
- 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99, 0x92, 0x1A,
- 0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D,
- }}},
- {{{ // q
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD,
- 0x46, 0xE5, 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9F,
- 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13,
- }}},
- {{{ // b
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- }}},
- {{ // t
- 0x68, 0x82, 0xF5, 0xC0, 0x30, 0xB0, 0xA8, 0x01,
- }},
- {{ // neg
- 0x01,
- }},
- {{{ // beta
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD,
- 0x46, 0xE5, 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9F,
- 0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82,
- 0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x12,
- }}},
- {
- {{{ // xi0
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- }}},
- {{{ // xi1
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- }}}
- },
- { // g1 *********EPIDG1Element
- {{{ // x
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
- }}},
- {{{ // y
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- }}},
- },
- { // g2 *********EPIDG2Element
- {
- {{{ // x0
- 0xE2, 0x01, 0x71, 0xC5, 0x4A, 0xA3, 0xDA, 0x05,
- 0x21, 0x67, 0x04, 0x13, 0x74, 0x3C, 0xCF, 0x22,
- 0xD2, 0x5D, 0x52, 0x68, 0x3D, 0x32, 0x47, 0x0E,
- 0xF6, 0x02, 0x13, 0x43, 0xBF, 0x28, 0x23, 0x94,
- }}},
- {{{ // x1
- 0x59, 0x2D, 0x1E, 0xF6, 0x53, 0xA8, 0x5A, 0x80,
- 0x46, 0xCC, 0xDC, 0x25, 0x4F, 0xBB, 0x56, 0x56,
- 0x43, 0x43, 0x3B, 0xF6, 0x28, 0x96, 0x53, 0xE2,
- 0x7D, 0xF7, 0xB2, 0x12, 0xBA, 0xA1, 0x89, 0xBE,
- }}}
- },
- {
- {{{ // y0
- 0xAE, 0x60, 0xA4, 0xE7, 0x51, 0xFF, 0xD3, 0x50,
- 0xC6, 0x21, 0xE7, 0x03, 0x31, 0x28, 0x26, 0xBD,
- 0x55, 0xE8, 0xB5, 0x9A, 0x4D, 0x91, 0x68, 0x38,
- 0x41, 0x4D, 0xB8, 0x22, 0xDD, 0x23, 0x35, 0xAE,
- }}},
- {{{ // y1
- 0x1A, 0xB4, 0x42, 0xF9, 0x89, 0xAF, 0xE5, 0xAD,
- 0xF8, 0x02, 0x74, 0xF8, 0x76, 0x45, 0xE2, 0x53,
- 0x2C, 0xDC, 0x61, 0x81, 0x90, 0x93, 0xD6, 0x13,
- 0x2C, 0x90, 0xFE, 0x89, 0x51, 0xB9, 0x24, 0x21,
- }}}
- },
- }
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/errors.c b/sgx-jvm/linux-sgx/external/epid/epid/common/errors.c
deleted file mode 100644
index 8809074925..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/errors.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Error reporting implementation.
- */
-
-#include
-
-#include "epid/common/stdtypes.h"
-#include "epid/common/errors.h"
-
-/// Record mapping status code to string
-struct ErrorTextEntry {
- /// error code
- EpidStatus value;
- /// string associated with error code
- char const* text;
-};
-
-/// Mapping of status codes to strings
-static const struct ErrorTextEntry kEnumToText[] = {
- {kEpidNoErr, "no error"},
- {kEpidErr, "unspecified error"},
- {kEpidSigInvalid, "invalid signature"},
- {kEpidSigRevokedinGroupRl, "signature revoked in GroupRl"},
- {kEpidSigRevokedinPrivRl, "signature revoked in PrivRl"},
- {kEpidSigRevokedinSigRl, "signature revoked in SigRl"},
- {kEpidSigRevokedinVerifierRl, "signature revoked in VerifierRl"},
- {kEpidNotImpl, "not implemented"},
- {kEpidBadArgErr, "bad arguments"},
- {kEpidNoMemErr, "could not allocate memory"},
- {kEpidMemAllocErr, "insufficient memory provided"},
- {kEpidMathErr, "internal math error"},
- {kEpidDivByZeroErr, "attempt to divide by zero"},
- {kEpidUnderflowErr, "underflow"},
- {kEpidHashAlgorithmNotSupported, "unsupported hash algorithm type"},
- {kEpidRandMaxIterErr, "reached max iteration for random number generation"},
- {kEpidDuplicateErr, "argument would add duplicate entry"},
-};
-
-char const* EpidStatusToString(EpidStatus e) {
- size_t i = 0;
- const size_t num_entries = sizeof(kEnumToText) / sizeof(kEnumToText[0]);
- for (i = 0; i < num_entries; i++) {
- if (e == kEnumToText[i].value) {
- return kEnumToText[i].text;
- }
- }
- return "unknown error";
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/errors.h b/sgx-jvm/linux-sgx/external/epid/epid/common/errors.h
deleted file mode 100644
index f897381e4a..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/errors.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_ERRORS_H_
-#define EPID_COMMON_ERRORS_H_
-/*!
- * \file
- * \brief Error reporting.
-*/
-
-/// Error reporting interface.
-/*!
- \defgroup ErrorCodes errors
- This module defines the return status type. It also provides tools for
- interactions with status values, such as converting them to a string.
-
- \ingroup EpidCommon
- @{
-*/
-
-/// Return status for SDK functions.
-/*!
- Convention for status values is as follows:
- - Zero indicates "success"
- - Any positive number indicates "success with status"
- - Any negative number indicates "failure"
-*/
-typedef enum {
- kEpidNoErr = 0, //!< no error
- kEpidSigValid = 0, //!< Signature is valid
- kEpidSigInvalid = 1, //!< Signature is invalid
- kEpidSigRevokedinGroupRl = 2, //!< Signature revoked in GroupRl
- kEpidSigRevokedinPrivRl = 3, //!< Signature revoked in PrivRl
- kEpidSigRevokedinSigRl = 4, //!< Signature revoked in SigRl
- kEpidSigRevokedinVerifierRl = 5, //!< Signature revoked in VerifierRl
- kEpidErr = -999, //!< unspecified error
- kEpidNotImpl, //!< not implemented error
- kEpidBadArgErr, //!< incorrect arg to function
- kEpidNoMemErr, //!< not enough memory for the operation
- kEpidMemAllocErr, //!< insufficient memory allocated for operation
- kEpidMathErr, //!< internal math error
- kEpidDivByZeroErr, //!< an attempt to divide by zero
- kEpidUnderflowErr, //!< a value became less than minimum supported level
- kEpidHashAlgorithmNotSupported, //!< unsupported hash algorithm type
- kEpidRandMaxIterErr, //!< reached max iteration for random number generation
- kEpidDuplicateErr, //!< argument would add duplicate entry
-} EpidStatus;
-
-/// Returns string representation of error code.
-/*!
- \param e
- The status value.
-
- \returns The string describing the status.
-*/
-char const* EpidStatusToString(EpidStatus e);
-
-/*! @} */
-#endif // EPID_COMMON_ERRORS_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.c b/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.c
deleted file mode 100644
index 63c89bb8ab..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- *
- * \brief Implementation of issuer material file parsing utilities.
- *
- */
-#include "epid/common/file_parser.h"
-
-#include
-
-#include "epid/common/math/ecdsa.h"
-#include "epid/common/memory.h"
-
-const OctStr16 kEpidFileTypeCode[kNumFileTypes] = {
- {0x00, 0x11}, {0x00, 0x0C}, {0x00, 0x0D}, {0x00, 0x0E},
- {0x00, 0x0F}, {0x00, 0x03}, {0x00, 0x0B}, {0x00, 0x13},
-};
-
-/// Intel(R) EPID 2.0 Group Public Key binary format
-typedef struct EpidGroupPubKeyCertificate {
- EpidFileHeader header; ///< Intel(R) EPID binary file header
- GroupId gid; ///< group ID
- G1ElemStr h1; ///< an element in G1
- G1ElemStr h2; ///< an element in G1
- G2ElemStr w; ///< an element in G2
- EcdsaSignature signature; ///< ECDSA Signature on SHA-256 of above values
-} EpidGroupPubKeyCertificate;
-
-/// Intel(R) EPID version
-static const OctStr16 epid_version = {0x02, 0x00};
-
-/// Verify that certificate contains of EC secp256r1 parameters
-static EpidStatus EpidVerifyCaCertificate(EpidCaCertificate const* cert) {
- // Prime of GF(p) for secp256r1
- static const unsigned char secp256r1_p[] = {
- // 2^256 -2^224 +2^192 +2^96 -1
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- // Coefficient of E Curve secp256r1
- static const unsigned char secp256r1_a[] = {
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc};
-
- // Coefficient of E Curve secp256r1
- static const unsigned char secp256r1_b[] = {
- 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb, 0xbd,
- 0x55, 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53,
- 0xb0, 0xf6, 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b};
-
- // X coordinate of Base point G of secp256r1
- static const unsigned char secp256r1_gx[] = {
- 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc, 0xe6,
- 0xe5, 0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb,
- 0x33, 0xa0, 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96};
-
- // Y coordinate of Base point G of secp256r1
- static const unsigned char secp256r1_gy[] = {
- 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, 0xeb,
- 0x4a, 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31,
- 0x5e, 0xce, 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5};
-
- // Order of base point of secp256r1
- static const unsigned char secp256r1_r[] = {
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, 0xa7, 0x17,
- 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51,
- };
-
- if (!cert) return kEpidBadArgErr;
-
- // Verify that certificate contains of correct file header
- if (0 !=
- memcmp(&cert->header.epid_version, &epid_version, sizeof(epid_version))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->header.file_type,
- &kEpidFileTypeCode[kIssuingCaPubKeyFile],
- sizeof(cert->header.file_type))) {
- return kEpidBadArgErr;
- }
-
- // Verify that certificate contains of EC secp256r1 parameters
- if (0 != memcmp(&cert->prime, secp256r1_p, sizeof(secp256r1_p))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->a, secp256r1_a, sizeof(secp256r1_a))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->b, secp256r1_b, sizeof(secp256r1_b))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->x, secp256r1_gx, sizeof(secp256r1_gx))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->y, secp256r1_gy, sizeof(secp256r1_gy))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&cert->r, secp256r1_r, sizeof(secp256r1_r))) {
- return kEpidBadArgErr;
- }
-
- return kEpidNoErr;
-}
-
-/// Parse a file with a revocation list of any type
-static EpidStatus EpidParseRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, void* rl,
- size_t* rl_len, EpidFileType file_type) {
- size_t min_rl_file_size = 0;
- size_t empty_rl_size = 0;
- size_t rl_entry_size = 0;
- EpidStatus result = kEpidErr;
- EpidFileHeader const* file_header = (EpidFileHeader*)buf;
- void const* buf_rl =
- (void const*)((unsigned char*)buf + sizeof(EpidFileHeader));
- size_t buf_rl_len = 0;
- EcdsaSignature const* signature = NULL;
-
- if (!buf || !cert || !rl_len) return kEpidBadArgErr;
-
- switch (file_type) {
- case kPrivRlFile:
- empty_rl_size = sizeof(PrivRl) - sizeof(((PrivRl*)0)->f[0]);
- rl_entry_size = sizeof(((PrivRl*)0)->f[0]);
- min_rl_file_size = sizeof(EpidFileHeader) + sizeof(PrivRl) -
- sizeof(((PrivRl*)0)->f[0]) + sizeof(EcdsaSignature);
- break;
- case kSigRlFile:
- empty_rl_size = sizeof(SigRl) - sizeof(((SigRl*)0)->bk[0]);
- rl_entry_size = sizeof(((SigRl*)0)->bk[0]);
- min_rl_file_size = sizeof(EpidFileHeader) + sizeof(SigRl) -
- sizeof(((SigRl*)0)->bk[0]) + sizeof(EcdsaSignature);
- break;
- case kGroupRlFile:
- empty_rl_size = sizeof(GroupRl) - sizeof(((GroupRl*)0)->gid[0]);
- rl_entry_size = sizeof(((GroupRl*)0)->gid[0]);
- min_rl_file_size = sizeof(EpidFileHeader) + sizeof(GroupRl) -
- sizeof(((GroupRl*)0)->gid[0]) + sizeof(EcdsaSignature);
- break;
- default:
- return kEpidErr;
- }
-
- if (min_rl_file_size > len) return kEpidBadArgErr;
-
- // Verify that Intel(R) EPID file header in the buffer is correct
- if (0 !=
- memcmp(&file_header->epid_version, &epid_version, sizeof(epid_version))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&file_header->file_type, &kEpidFileTypeCode[file_type],
- sizeof(file_header->file_type))) {
- return kEpidBadArgErr;
- }
-
- // Verify that CA certificate is correct
- result = EpidVerifyCaCertificate(cert);
- if (kEpidNoErr != result) return result;
-
- // Verify that RL in file buffer contains of integer number of entries
- buf_rl_len = len - sizeof(EpidFileHeader) - sizeof(EcdsaSignature);
- if (0 != ((buf_rl_len - empty_rl_size) % rl_entry_size)) {
- return kEpidBadArgErr;
- }
-
- signature =
- (EcdsaSignature*)((unsigned char*)buf + len - sizeof(EcdsaSignature));
- // Authenticate signature for buffer
- result = EcdsaVerifyBuffer(buf, len - sizeof(EcdsaSignature),
- (EcdsaPublicKey*)&cert->pubkey, signature);
- if (kEpidSigValid != result) return result;
-
- buf_rl_len = len - sizeof(EpidFileHeader) - sizeof(EcdsaSignature);
-
- // If pointer to output buffer is NULL it should return required size of RL
- if (!rl) {
- *rl_len = buf_rl_len;
- return kEpidNoErr;
- }
-
- if (*rl_len < buf_rl_len) return kEpidBadArgErr;
- *rl_len = buf_rl_len;
-
- // Copy revocation list from file buffer to output
- if (0 != memcpy_S(rl, *rl_len, buf_rl, buf_rl_len)) return kEpidBadArgErr;
-
- return kEpidNoErr;
-}
-
-EpidStatus EpidParseGroupPubKeyFile(void const* buf, size_t len,
- EpidCaCertificate const* cert,
- GroupPubKey* pubkey) {
- EpidStatus result;
- EpidGroupPubKeyCertificate* buf_pubkey = (EpidGroupPubKeyCertificate*)buf;
-
- if (!buf || !cert || !pubkey) {
- return kEpidBadArgErr;
- }
-
- if (sizeof(EpidGroupPubKeyCertificate) > len) {
- return kEpidBadArgErr;
- }
-
- // Verify that Intel(R) EPID file header in the buffer is correct
- if (0 != memcmp(&buf_pubkey->header.epid_version, &epid_version,
- sizeof(epid_version))) {
- return kEpidBadArgErr;
- }
- if (0 != memcmp(&buf_pubkey->header.file_type,
- &kEpidFileTypeCode[kGroupPubKeyFile],
- sizeof(buf_pubkey->header.file_type))) {
- return kEpidBadArgErr;
- }
-
- // Verify that CA certificate is correct
- result = EpidVerifyCaCertificate(cert);
- if (kEpidNoErr != result) return result;
-
- // Authenticate signature for buffer
- result =
- EcdsaVerifyBuffer(buf, len - sizeof(EcdsaSignature),
- (EcdsaPublicKey*)&cert->pubkey, &buf_pubkey->signature);
- if (kEpidSigValid != result) return result;
-
- // Copy public from the buffer to output
- pubkey->gid = buf_pubkey->gid;
- pubkey->h1 = buf_pubkey->h1;
- pubkey->h2 = buf_pubkey->h2;
- pubkey->w = buf_pubkey->w;
-
- return kEpidNoErr;
-}
-
-EpidStatus EpidParsePrivRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, PrivRl* rl,
- size_t* rl_len) {
- return EpidParseRlFile(buf, len, cert, rl, rl_len, kPrivRlFile);
-}
-
-EpidStatus EpidParseSigRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, SigRl* rl,
- size_t* rl_len) {
- return EpidParseRlFile(buf, len, cert, rl, rl_len, kSigRlFile);
-}
-
-EpidStatus EpidParseGroupRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, GroupRl* rl,
- size_t* rl_len) {
- return EpidParseRlFile(buf, len, cert, rl, rl_len, kGroupRlFile);
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.h b/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.h
deleted file mode 100644
index a835531772..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/file_parser.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Epid issuer material parsing utilities.
- */
-#ifndef EPID_COMMON_FILE_PARSER_H_
-#define EPID_COMMON_FILE_PARSER_H_
-
-#include
-
-#include "epid/common/types.h"
-#include "epid/common/errors.h"
-
-/// Parser for issuer material
-/*!
- \defgroup FileParser fileparser
- Provides an API for parsing buffers formatted according to the
- various IoT Intel(R) EPID binary file formats.
-
- \ingroup EpidCommon
- @{
-*/
-
-/// Recognized Intel(R) EPID file types
-typedef enum EpidFileType {
- kIssuingCaPubKeyFile, ///< IoT Issuing CA public key file
- kGroupPubKeyFile, ///< Group Public Key Output File Format
- kPrivRlFile, ///< Binary Private Key Revocation List
- kSigRlFile, ///< Binary Signature Revocation List
- kGroupRlFile, ///< Binary Group Revocation List
- kPrivRlRequestFile, ///< Binary Private Key Revocation Request
- kSigRlRequestFile, ///< Binary Signature Revocation Request
- kGroupRlRequestFile, ///< Binary Group Revocation Request
- kNumFileTypes, ///< Maximum number of file types
-} EpidFileType;
-
-/// Encoding of issuer material file types
-extern const OctStr16 kEpidFileTypeCode[kNumFileTypes];
-
-#pragma pack(1)
-/// Intel(R) EPID binary file header
-typedef struct EpidFileHeader {
- OctStr16 epid_version; ///< Intel(R) EPID Version
- OctStr16 file_type; ///< File Type
-} EpidFileHeader;
-
-/// IoT CA Certificate binary format
-typedef struct EpidCaCertificate {
- EpidFileHeader header; ///< Intel(R) EPID binary file header
- OctStr512 pubkey; ///< Public Key (Qx, Qy)
- OctStr256 prime; ///< Prime of GF(p)
- OctStr256 a; ///< Coefficient of E Curve
- OctStr256 b; ///< Coefficient of E Curve
- OctStr256 x; ///< X coordinate of Base point G
- OctStr256 y; ///< Y coordinate of Base point G
- OctStr256 r; ///< Order of base point
- EcdsaSignature signature; ///< ECDSA Signature on SHA-256 of above values
-} EpidCaCertificate;
-#pragma pack()
-
-/// Extracts group public key from buffer in issuer binary format
-/*!
-
- Extracts the first group public key from a buffer with format of
- Intel(R) EPID 2.0 Group Public Key Certificate Binary File. The
- function validates that the first public key was signed by the
- private key corresponding to the provided CA certificate and the
- size of the input buffer is correct.
-
- \warning
- It is the responsibility of the caller to authenticate the
- EpidCaCertificate.
-
- \param[in] buf
- Pointer to buffer containing public key to extract.
-
- \param[in] len
- The size of buf in bytes.
-
- \param[in] cert
- The issuing CA public key certificate.
-
- \param[out] pubkey
- The extracted group public key.
-
- \returns ::EpidStatus
-
- \retval ::kEpidSigInvalid
- Parsing failed due to data authentication failure.
-
- */
-EpidStatus EpidParseGroupPubKeyFile(void const* buf, size_t len,
- EpidCaCertificate const* cert,
- GroupPubKey* pubkey);
-
-/// Extracts private key revocation list from buffer in issuer binary format
-/*!
-
- Extracts the private key revocation list from a buffer with format of
- Binary Private Key Revocation List File. The function
- validates that the revocation list was signed by the private
- key corresponding to the provided CA certificate and the size of the
- input buffer is correct.
-
- To determine the required size of the revocation list output buffer,
- provide a null pointer for the output buffer.
-
- \warning
- It is the responsibility of the caller to authenticate the
- EpidCaCertificate.
-
- \param[in] buf
- Pointer to buffer containing the revocation list to extract.
-
- \param[in] len
- The size of buf in bytes.
-
- \param[in] cert
- The issuing CA public key certificate.
-
- \param[out] rl
- The extracted revocation list. If Null, rl_len is filled with
- the required output buffer size.
-
- \param[in,out] rl_len
- The size of rl in bytes.
-
- \returns ::EpidStatus
-
- \retval ::kEpidSigInvalid
- Parsing failed due to data authentication failure.
-
- */
-EpidStatus EpidParsePrivRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, PrivRl* rl,
- size_t* rl_len);
-
-/// Extracts signature revocation list from buffer in issuer binary format
-/*!
-
- Extracts the signature based revocation list from a buffer with
- format of Binary Signature Revocation List File. The function
- validates that the revocation list was signed by the private key
- corresponding to the provided CA certificate and the size of the
- input buffer is correct.
-
- To determine the required size of the revocation list output buffer,
- provide a null pointer for the output buffer.
-
- \warning
- It is the responsibility of the caller to authenticate the
- EpidCaCertificate.
-
- \param[in] buf
- Pointer to buffer containing the revocation list to extract.
-
- \param[in] len
- The size of buf in bytes.
-
- \param[in] cert
- The issuing CA public key certificate.
-
- \param[out] rl
- The extracted revocation list. If Null, rl_len is filled with
- the required output buffer size.
-
- \param[in,out] rl_len
- The size of rl in bytes.
-
- \returns ::EpidStatus
-
- \retval ::kEpidSigInvalid
- Parsing failed due to data authentication failure.
-
- */
-EpidStatus EpidParseSigRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, SigRl* rl,
- size_t* rl_len);
-
-/// Extracts group revocation list from buffer in issuer binary format
-/*!
-
- Extracts the group revocation list from a buffer with format of
- Binary Group Certificate Revocation List File. The function
- validates that the revocation list was signed by the private key
- corresponding to the provided CA certificate and the size of the
- input buffer is correct.
-
- To determine the required size of the revocation list output buffer,
- provide a null pointer for the output buffer.
-
- \warning
- It is the responsibility of the caller to authenticate the
- EpidCaCertificate.
-
- \param[in] buf
- Pointer to buffer containing the revocation list to extract.
-
- \param[in] len
- The size of buf in bytes.
-
- \param[in] cert
- The issuing CA public key certificate.
-
- \param[out] rl
- The extracted revocation list. If Null, rl_len is filled with
- the required output buffer size.
-
- \param[in,out] rl_len
- The size of rl in bytes.
-
- \returns ::EpidStatus
-
- \retval ::kEpidSigInvalid
- Parsing failed due to data authentication failure.
-
- */
-EpidStatus EpidParseGroupRlFile(void const* buf, size_t len,
- EpidCaCertificate const* cert, GroupRl* rl,
- size_t* rl_len);
-
-/*!
- @}
-*/
-
-#endif // EPID_COMMON_FILE_PARSER_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.c b/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.c
deleted file mode 100644
index e25abecb41..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Group public key implementation.
- */
-#include "epid/common/grouppubkey.h"
-#include "epid/common/memory.h"
-
-EpidStatus CreateGroupPubKey(GroupPubKey const* pub_key_str, EcGroup* G1,
- EcGroup* G2, GroupPubKey_** pub_key) {
- EpidStatus result = kEpidErr;
- GroupPubKey_* pubkey = NULL;
- if (!pub_key_str || !G1 || !G2 || !pub_key) {
- return kEpidBadArgErr;
- }
- do {
- pubkey = SAFE_ALLOC(sizeof(GroupPubKey_));
- if (!pubkey) {
- result = kEpidMemAllocErr;
- break;
- }
- result = NewEcPoint(G1, &pubkey->h1);
- if (kEpidNoErr != result) {
- break;
- }
- result =
- ReadEcPoint(G1, &pub_key_str->h1, sizeof(pub_key_str->h1), pubkey->h1);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewEcPoint(G1, &pubkey->h2);
- if (kEpidNoErr != result) {
- break;
- }
- result =
- ReadEcPoint(G1, &pub_key_str->h2, sizeof(pub_key_str->h2), pubkey->h2);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewEcPoint(G2, &pubkey->w);
- if (kEpidNoErr != result) {
- break;
- }
- result =
- ReadEcPoint(G2, &pub_key_str->w, sizeof(pub_key_str->w), pubkey->w);
- if (kEpidNoErr != result) {
- break;
- }
- pubkey->gid = pub_key_str->gid;
- *pub_key = pubkey;
- result = kEpidNoErr;
- } while (0);
-
- if (kEpidNoErr != result && pubkey) {
- DeleteEcPoint(&pubkey->w);
- DeleteEcPoint(&pubkey->h2);
- DeleteEcPoint(&pubkey->h1);
- SAFE_FREE(pubkey);
- }
- return result;
-}
-
-void DeleteGroupPubKey(GroupPubKey_** pub_key) {
- if (pub_key && *pub_key) {
- DeleteEcPoint(&(*pub_key)->w);
- DeleteEcPoint(&(*pub_key)->h2);
- DeleteEcPoint(&(*pub_key)->h1);
-
- SAFE_FREE(*pub_key);
- }
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.h b/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.h
deleted file mode 100644
index 43f1172d16..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/grouppubkey.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-#ifndef EPID_COMMON_GROUPPUBKEY_H_
-#define EPID_COMMON_GROUPPUBKEY_H_
-/*!
- * \file
- * \brief Group public key interface.
- * \addtogroup EpidCommon
- * @{
- */
-#include "epid/common/errors.h"
-#include "epid/common/math/ecgroup.h"
-#include "epid/common/types.h"
-
-/// Internal representation of GroupPubKey
-typedef struct GroupPubKey_ {
- GroupId gid; ///< group ID
- EcPoint* h1; ///< an element in G1
- EcPoint* h2; ///< an element in G1
- EcPoint* w; ///< an element in G2
-} GroupPubKey_;
-
-/// Constructs internal representation of GroupPubKey
-/*!
- Allocates memory and initializes gid, h1, h2, w parameters. Use
- DeleteGroupPubKey() to deallocate memory
-
- \param[in] pub_key_str
- Oct string representation of group public key
- \param[in] G1
- EcGroup containing elements h1 and h2
- \param[in] G2
- EcGroup containing element w
- \param[out] pub_key
- Group public key: (gid, h1, h2, w)
-
- \returns ::EpidStatus
- \see DeleteGroupPubKey
-*/
-EpidStatus CreateGroupPubKey(GroupPubKey const* pub_key_str, EcGroup* G1,
- EcGroup* G2, GroupPubKey_** pub_key);
-
-/// Deallocates storage for internal representation of GroupPubKey
-/*!
- Frees memory pointed to by Group public key. Nulls the pointer.
-
- \param[in] pub_key
- Group public key to be freed
-
- \see CreateGroupPubKey
-*/
-void DeleteGroupPubKey(GroupPubKey_** pub_key);
-/*! @} */
-#endif // EPID_COMMON_GROUPPUBKEY_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum-internal.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum-internal.h
deleted file mode 100644
index bbd5d98403..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum-internal.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Big number private interface.
- */
-
-#ifndef EPID_COMMON_MATH_BIGNUM_INTERNAL_H_
-#define EPID_COMMON_MATH_BIGNUM_INTERNAL_H_
-
-#include "ext/ipp/include/ippcpepid.h"
-#include "epid/common/stdtypes.h"
-
-/// Big Number
-struct BigNum {
- /// Internal implementation of bignum
- IppsBigNumState* ipp_bn;
-};
-
-/// convert octet string into "big number unsigned" representation
-/*!
-
-This is an internal function, used to convert an octet string (uint8_t
-array) into a big number unsigned representation (uint32_t array).
-For example, octet string {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-0x08} is converted to {0x05060708, 0x01020304}
-
-\param[out] bnu_ptr
-Output big number unsigned array
-\param[in] octstr_ptr
-Input octal string
-\param[in] octstr_len
-Length of octet string, should be multiple of 4
-
-\returns length of big number unsigned in uint32_t chunks
-\returns -1 in case of any error
-*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-int OctStr2Bnu(uint32_t* bnu_ptr, void const* octstr_ptr, int octstr_len);
-#ifdef __cplusplus
-}
-#endif
-
-#endif // EPID_COMMON_MATH_BIGNUM_INTERNAL_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.c
deleted file mode 100644
index 996fe2cb0d..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Big number implementation.
- */
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-
-EpidStatus NewBigNum(size_t data_size_bytes, BigNum** bignum) {
- EpidStatus result = kEpidErr;
- IppsBigNumState* ipp_bn_ctx = NULL;
- BigNum* bn = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- unsigned int ctxsize;
- unsigned int wordsize =
- (unsigned int)((data_size_bytes + sizeof(Ipp32u) - 1) / sizeof(Ipp32u));
-
- if (!bignum) {
- result = kEpidBadArgErr;
- break;
- }
- // Determine the memory requirement for bignum context
- sts = ippsBigNumGetSize(wordsize, (int*)&ctxsize);
- if (ippStsNoErr != sts) {
- if (ippStsLengthErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- // Allocate space for ipp bignum context
- ipp_bn_ctx = (IppsBigNumState*)SAFE_ALLOC(ctxsize);
- if (!ipp_bn_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize ipp bignum context
- sts = ippsBigNumInit(wordsize, ipp_bn_ctx);
- if (ippStsNoErr != sts) {
- if (ippStsLengthErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
-
- bn = (BigNum*)SAFE_ALLOC(sizeof(BigNum));
- if (!bn) {
- result = kEpidMemAllocErr;
- break;
- }
-
- bn->ipp_bn = ipp_bn_ctx;
-
- *bignum = bn;
- result = kEpidNoErr;
- } while (0);
-
- if (kEpidNoErr != result) {
- SAFE_FREE(ipp_bn_ctx);
- SAFE_FREE(bn);
- }
- return result;
-}
-
-void DeleteBigNum(BigNum** bignum) {
- if (bignum) {
- if (*bignum) {
- SAFE_FREE((*bignum)->ipp_bn);
- }
- SAFE_FREE(*bignum);
- }
-}
-
-EpidStatus ReadBigNum(void const* bn_str, size_t strlen, BigNum* bn) {
- IppStatus sts;
- size_t i;
- bool is_zero = true;
- Ipp8u const* byte_str = (Ipp8u const*)bn_str;
- int ipp_strlen = (int)strlen;
-
- if (!bn || !bn_str) return kEpidBadArgErr;
-
- if (!bn->ipp_bn) return kEpidBadArgErr;
-
- if (INT_MAX < strlen || strlen <= 0) return kEpidBadArgErr;
-
- /*
- Some versions of ippsSetOctString_BN have bug:
- When called for octet string with all bits set to zero the resulted BigNumber
- state initialize incorrectly which leads to unpredictable behaviour
- if used.
-
- Workaround:
- Test the input string before ippsSetOctStringSet_BN() call.
- If length of the string is zero or it does not contain any significant
- bits, then set BN to zero. Keep in mind that ippsBigNumInit() set BN
- value to zero.
- */
- for (i = 0; i < strlen; ++i)
- if (0 != byte_str[i]) {
- is_zero = false;
- break;
- }
- if (is_zero) {
- Ipp32u zero32 = 0;
- sts = ippsSet_BN(IppsBigNumPOS, 1, &zero32, bn->ipp_bn);
- } else {
- sts = ippsSetOctString_BN(bn_str, ipp_strlen, bn->ipp_bn);
- }
- if (sts != ippStsNoErr) {
- if (ippStsContextMatchErr == sts || ippStsSizeErr == sts ||
- ippStsLengthErr == sts || ippStsOutOfRangeErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
-
- return kEpidNoErr;
-}
-
-EpidStatus WriteBigNum(BigNum const* bn, size_t strlen, void const* bn_str) {
- IppStatus sts;
- int ipp_strlen = (int)strlen;
- if (!bn || !bn_str) return kEpidBadArgErr;
-
- if (!bn->ipp_bn) return kEpidBadArgErr;
-
- sts = ippsGetOctString_BN((Ipp8u*)bn_str, ipp_strlen, bn->ipp_bn);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
-
- return kEpidNoErr;
-}
-
-/// convert octet string into "big number unsigned" representation
-int OctStr2Bnu(uint32_t* bnu_ptr, void const* octstr_ptr, int octstr_len) {
- int bnusize = 0;
- uint8_t const* byte_str = (uint8_t const*)octstr_ptr;
- if (!bnu_ptr || !octstr_ptr) {
- return -1;
- }
- if (octstr_len < 4 || octstr_len % 4 != 0) return -1;
-
- *bnu_ptr = 0;
- /* start from the end of string */
- for (; octstr_len >= 4; bnusize++, octstr_len -= 4) {
- /* pack 4 bytes into single Ipp32u value*/
- *bnu_ptr++ = (byte_str[octstr_len - 4] << (8 * 3)) +
- (byte_str[octstr_len - 3] << (8 * 2)) +
- (byte_str[octstr_len - 2] << (8 * 1)) +
- byte_str[octstr_len - 1];
- }
- return bnusize ? bnusize : -1;
-}
-
-EpidStatus BigNumAdd(BigNum const* a, BigNum const* b, BigNum* r) {
- IppStatus sts;
-
- if (!r || !a || !b) return kEpidBadArgErr;
-
- if (!r->ipp_bn || !a->ipp_bn || !b->ipp_bn) return kEpidBadArgErr;
-
- sts = ippsAdd_BN(a->ipp_bn, b->ipp_bn, r->ipp_bn);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
-
- return kEpidNoErr;
-}
-
-EpidStatus BigNumSub(BigNum const* a, BigNum const* b, BigNum* r) {
- IppStatus sts;
- Ipp32u sign = IS_ZERO;
- if (!r || !a || !b) return kEpidBadArgErr;
-
- if (!r->ipp_bn || !a->ipp_bn || !b->ipp_bn) return kEpidBadArgErr;
-
- sts = ippsSub_BN(a->ipp_bn, b->ipp_bn, r->ipp_bn);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- sts = ippsCmpZero_BN(r->ipp_bn, &sign);
- if (ippStsNoErr != sts) {
- return kEpidMathErr;
- }
- if (sign == LESS_THAN_ZERO) {
- return kEpidUnderflowErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus BigNumMul(BigNum const* a, BigNum const* b, BigNum* r) {
- IppStatus sts;
-
- if (!r || !a || !b) return kEpidBadArgErr;
-
- if (!r->ipp_bn || !a->ipp_bn || !b->ipp_bn) return kEpidBadArgErr;
-
- sts = ippsMul_BN(a->ipp_bn, b->ipp_bn, r->ipp_bn);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts || ippStsOutOfRangeErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
-
- return kEpidNoErr;
-}
-
-EpidStatus BigNumMod(BigNum const* a, BigNum const* b, BigNum* r) {
- IppStatus sts;
-
- if (!r || !a || !b) return kEpidBadArgErr;
-
- if (!r->ipp_bn || !a->ipp_bn || !b->ipp_bn) return kEpidBadArgErr;
-
- sts = ippsMod_BN(a->ipp_bn, b->ipp_bn, r->ipp_bn);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsLengthErr == sts || ippStsOutOfRangeErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
-
- return kEpidNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.h
deleted file mode 100644
index a3b1bc3c6f..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/bignum.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Big number interface.
- */
-
-#ifndef EPID_COMMON_MATH_BIGNUM_H_
-#define EPID_COMMON_MATH_BIGNUM_H_
-
-#include
-#include
-#include "epid/common/errors.h"
-#include "epid/common/types.h"
-
-/// Big number operations
-/*!
- \defgroup BigNumPrimitives bignum
- This module provides an API for working with large numbers. BigNums
- represent non-negative integers.
-
- Each BigNum variable represents a number of a byte-size set when the variable
- was created. BigNum variables cannot be re-sized after they are created.
-
-
- \ingroup EpidMath
- @{
-*/
-
-/// Internal representation of large numbers
-typedef struct BigNum BigNum;
-
-/// Constructs a new BigNum.
-/*!
- Allocates memory and creates a new BigNum.
-
- Use DeleteBigNum() to free memory.
-
- \param[in] data_size_bytes
- The size in bytes of the new number.
- \param[out] bignum
- The BigNum.
-
- \returns ::EpidStatus
-
- \see DeleteBigNum
-*/
-EpidStatus NewBigNum(size_t data_size_bytes, BigNum** bignum);
-
-/// Deletes a previously allocated BigNum.
-/*!
- Frees memory pointed to by bignum. Nulls the pointer.
-
- \param[in] bignum
- The BigNum. Can be NULL.
-
- \see NewBigNum
-*/
-void DeleteBigNum(BigNum** bignum);
-
-/// Deserializes a BigNum from a string.
-/*!
- \param[in] bn_str
- The serialized value.
- \param[in] strlen
- The size of bn_str in bytes.
- \param[out] bn
- The target BigNum.
-
- \returns ::EpidStatus
-*/
-EpidStatus ReadBigNum(void const* bn_str, size_t strlen, BigNum* bn);
-
-/// Serializes a BigNum to a string.
-/*!
- \param[in] bn
- The BigNum to be serialized.
- \param[in] strlen
- The size of bn_str in bytes.
- \param[out] bn_str
- The target string.
-
- \returns ::EpidStatus
-*/
-EpidStatus WriteBigNum(BigNum const* bn, size_t strlen, void const* bn_str);
-
-/// Adds two BigNum values.
-/*!
- \param[in] a
- The left hand parameter.
- \param[in] b
- The right hand parameter.
- \param[out] r
- The result of adding a and b.
-
- \returns ::EpidStatus
-*/
-EpidStatus BigNumAdd(BigNum const* a, BigNum const* b, BigNum* r);
-
-/// Subtracts two BigNum values.
-/*!
- \param[in] a
- The left hand parameter.
- \param[in] b
- The right hand parameter.
- \param[out] r
- The result of subtracting a and b.
-
- \returns ::EpidStatus
-*/
-EpidStatus BigNumSub(BigNum const* a, BigNum const* b, BigNum* r);
-
-/// Multiplies two BigNum values.
-/*!
- \param[in] a
- The left hand parameter.
- \param[in] b
- The right hand parameter.
- \param[out] r
- The result of multiplying a and b.
-
- \returns ::EpidStatus
-*/
-EpidStatus BigNumMul(BigNum const* a, BigNum const* b, BigNum* r);
-
-/// Computes modular reduction for BigNum value by specified modulus.
-/*!
-\param[in] a
-The BigNum value.
-\param[in] b
-The modulus.
-\param[out] r
-Modular reduction result.
-
-\returns ::EpidStatus
-*/
-EpidStatus BigNumMod(BigNum const* a, BigNum const* b, BigNum* r);
-
-/*!
- @}
-*/
-#endif // EPID_COMMON_MATH_BIGNUM_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa.h
deleted file mode 100644
index c5be15233c..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Ecdsa interface.
- */
-
-#ifndef EPID_COMMON_MATH_ECDSA_H_
-#define EPID_COMMON_MATH_ECDSA_H_
-
-#include
-
-#include "epid/common/errors.h"
-#include "epid/common/types.h"
-#include "epid/common/bitsupplier.h"
-
-/// Elliptic Curve Digital Signature Algorithm Primitives
-/*!
- \defgroup EcdsaPrimitives ecdsa
- Provides APIs for computing and checking buffer signatures using the
- Elliptic Curve Digital Signature Algorithm.
-
- \ingroup EpidMath
- @{
-*/
-
-/// Verifies authenticity of a digital signature over a buffer
-/*!
-
- Uses Elliptic Curve Digital Signature Algorithm (ECDSA) to verify
- that the SHA256 hash of the input buffer was signed with the
- private key corresponding to the provided public key.
-
- The operation is over the standard secp256r1 curve.
-
- \warning
- It is the responsibility of the caller to verify the identity of
- the public key.
-
- \param[in] buf
- Pointer to buffer containing message to verify.
- \param[in] buf_len
- The size of buf in bytes.
- \param[in] pubkey
- The ECDSA public key on secp256r1 curve.
- \param[in] sig
- The ECDSA signature to be verified.
-
- \returns ::EpidStatus
-
- \retval ::kEpidSigValid
- EcdsaSignature is valid for the given buffer.
- \retval ::kEpidSigInvalid
- EcdsaSignature is invalid for the given buffer.
-
- \see EcdsaSignBuffer
- */
-EpidStatus EcdsaVerifyBuffer(void const* buf, size_t buf_len,
- EcdsaPublicKey const* pubkey,
- EcdsaSignature const* sig);
-
-/// Creates ECDSA signature of buffer
-/*!
-
- Uses Elliptic Curve Digital Signature Algorithm (ECDSA) to generate
- a signature of the SHA256 hash of the input buffer with the provided
- private key.
-
- The operation is over the standard secp256r1 curve.
-
- \param[in] buf
- Pointer to buffer containing message to sign.
- \param[in] buf_len
- The size of buf in bytes.
- \param[in] privkey
- The ECDSA private key on secp256r1 curve.
- \param[in] rnd_func
- Random number generator.
- \param[in] rnd_param
- Pass through context data for rnd_func.
- \param[out] sig
- The resulting ECDSA signature.
-
- \returns ::EpidStatus
-
- \retval ::kEpidRandMaxIterErr
- Failed to sign after maximum number of iterations due to bad luck in
- random number generation.
-
- \see EcdsaSignBuffer
- */
-EpidStatus EcdsaSignBuffer(void const* buf, size_t buf_len,
- EcdsaPrivateKey const* privkey, BitSupplier rnd_func,
- void* rnd_param, EcdsaSignature* sig);
-
-/*!
- @}
-*/
-
-#endif // EPID_COMMON_MATH_ECDSA_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_sign.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_sign.c
deleted file mode 100644
index 37f2754a36..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_sign.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcdsaSignBuffer implementation.
- */
-
-#include "epid/common/math/ecdsa.h"
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/math/ecgroup.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-
-/// The number of attempts to generate ephemeral key pair
-#define EPHKEYGEN_WATCHDOG (10)
-
-EpidStatus EcdsaSignBuffer(void const* buf, size_t buf_len,
- EcdsaPrivateKey const* privkey, BitSupplier rnd_func,
- void* rnd_param, EcdsaSignature* sig) {
- EpidStatus result = kEpidMathErr;
-
- IppsECCPState* ec_ctx = NULL;
- BigNum* bn_ec_order = NULL;
-
- BigNum* bn_hash = NULL;
-
- BigNum* bn_reg_private = NULL;
- BigNum* bn_eph_private = NULL;
- IppsECCPPointState* ecp_eph_public = NULL;
-
- BigNum* bn_sig_x = NULL;
- BigNum* bn_sig_y = NULL;
-
- do {
- EpidStatus epid_status = kEpidNoErr;
- IppStatus sts = ippStsNoErr;
- int ctxsize = 0;
- // order of EC secp256r1
- const uint8_t secp256r1_r[32] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17,
- 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51};
- Ipp8u hash[IPP_SHA256_DIGEST_BITSIZE / 8] = {0};
- unsigned int gen_loop_count = EPHKEYGEN_WATCHDOG;
- Ipp32u cmp0 = IS_ZERO;
- Ipp32u cmp_order = IS_ZERO;
-
- if ((0 != buf_len && !buf) || !privkey || !rnd_func || !sig) {
- result = kEpidBadArgErr;
- break;
- }
- if (buf_len > INT_MAX) {
- result = kEpidBadArgErr;
- break;
- }
-
- // Define standard elliptic curve secp256r1
- sts = ippsECCPGetSizeStd256r1(&ctxsize);
- if (ippStsNoErr != sts) break;
- ec_ctx = (IppsECCPState*)SAFE_ALLOC(ctxsize);
- if (!ec_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
- sts = ippsECCPInitStd256r1(ec_ctx);
- if (ippStsNoErr != sts) break;
- sts = ippsECCPSetStd256r1(ec_ctx);
- if (ippStsNoErr != sts) break;
-
- // Create big number for order of elliptic curve secp256r1
- epid_status = NewBigNum(sizeof(secp256r1_r), &bn_ec_order);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
- epid_status = ReadBigNum(secp256r1_r, sizeof(secp256r1_r), bn_ec_order);
- if (kEpidNoErr != epid_status) break;
-
- // Calculate hash for input message
- sts = ippsSHA256MessageDigest(buf, (int)buf_len, hash);
- if (ippStsNoErr != sts) break;
-
- // Create big number for hash
- epid_status = NewBigNum(sizeof(hash), &bn_hash);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
- epid_status = ReadBigNum(hash, sizeof(hash), bn_hash);
- if (kEpidNoErr != epid_status) break;
- sts = ippsMod_BN(bn_hash->ipp_bn, bn_ec_order->ipp_bn, bn_hash->ipp_bn);
- if (ippStsNoErr != sts) break;
-
- // Create big number for regular private key
- epid_status = NewBigNum(sizeof(*privkey), &bn_reg_private);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
- epid_status = ReadBigNum(privkey, sizeof(*privkey), bn_reg_private);
- if (kEpidNoErr != epid_status) break;
-
- // Validate private key is in range [1, bn_ec_order-1]
- sts = ippsCmpZero_BN(bn_reg_private->ipp_bn, &cmp0);
- if (ippStsNoErr != sts) break;
- sts = ippsCmp_BN(bn_reg_private->ipp_bn, bn_ec_order->ipp_bn, &cmp_order);
- if (ippStsNoErr != sts) break;
- if (IS_ZERO == cmp0 || LESS_THAN_ZERO != cmp_order) {
- result = kEpidBadArgErr;
- break;
- }
-
- // Create big number for ephemeral private key
- epid_status = NewBigNum(sizeof(secp256r1_r), &bn_eph_private);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
-
- // Create EC point for ephemeral public key
- sts = ippsECCPPointGetSize(256, &ctxsize);
- if (ippStsNoErr != sts) break;
- ecp_eph_public = (IppsECCPPointState*)SAFE_ALLOC(ctxsize);
- if (!ecp_eph_public) {
- result = kEpidMemAllocErr;
- break;
- }
- sts = ippsECCPPointInit(256, ecp_eph_public);
- if (ippStsNoErr != sts) break;
-
- // Create big numbers for signature
- epid_status = NewBigNum(sizeof(secp256r1_r), &bn_sig_x);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
- epid_status = NewBigNum(sizeof(secp256r1_r), &bn_sig_y);
- if (kEpidMemAllocErr == epid_status) {
- result = kEpidMemAllocErr;
- break;
- }
- if (kEpidNoErr != epid_status) break;
-
- do {
- // Generate ephemeral key pair
- sts = ippsECCPGenKeyPair(bn_eph_private->ipp_bn, ecp_eph_public, ec_ctx,
- (IppBitSupplier)rnd_func, rnd_param);
- if (ippStsNoErr != sts) break;
-
- // Set ephemeral key pair
- sts = ippsECCPSetKeyPair(bn_eph_private->ipp_bn, ecp_eph_public, ippFalse,
- ec_ctx);
- if (ippStsNoErr != sts) break;
-
- // Compute signature
- sts = ippsECCPSignDSA(bn_hash->ipp_bn, bn_reg_private->ipp_bn,
- bn_sig_x->ipp_bn, bn_sig_y->ipp_bn, ec_ctx);
- if (ippStsEphemeralKeyErr != sts) break;
- } while (--gen_loop_count);
- if (ippStsEphemeralKeyErr == sts) {
- result = kEpidRandMaxIterErr;
- break;
- }
- if (ippStsNoErr != sts) break;
-
- sts = ippsGetOctString_BN(sig->x.data, sizeof(sig->x), bn_sig_x->ipp_bn);
- if (ippStsNoErr != sts) break;
- sts = ippsGetOctString_BN(sig->y.data, sizeof(sig->y), bn_sig_y->ipp_bn);
- if (ippStsNoErr != sts) break;
-
- result = kEpidNoErr;
- } while (0);
-
- DeleteBigNum(&bn_ec_order);
- DeleteBigNum(&bn_hash);
- DeleteBigNum(&bn_reg_private);
- DeleteBigNum(&bn_eph_private);
- DeleteBigNum(&bn_sig_x);
- DeleteBigNum(&bn_sig_y);
-
- SAFE_FREE(ec_ctx);
- SAFE_FREE(ecp_eph_public);
-
- return result;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_verify.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_verify.c
deleted file mode 100644
index 1b50811996..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecdsa_verify.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief EcdsaVerifyBuffer implementation.
- */
-
-#include "epid/common/math/ecdsa.h"
-
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-
-/// Handle Ipp Errors with Break
-#define BREAK_ON_IPP_ERROR(sts, ret) \
- { \
- IppStatus temp_sts = (sts); \
- if (ippStsNoErr != temp_sts) { \
- (ret) = kEpidMathErr; \
- break; \
- } \
- }
-
-static EpidStatus NewSecp256r1Curve(IppsECCPState** ec);
-
-static void DeleteSecp256r1Curve(IppsECCPState** ec);
-
-static EpidStatus NewCurvePoint(IppsECCPState const* ec,
- IppsECCPPointState** p);
-
-static EpidStatus ReadCurvePoint(IppsECCPState* ec,
- EcdsaPublicKey const* pubkey,
- IppsECCPPointState* p);
-
-static EpidStatus CalcHashBn(void const* buf, size_t buf_len,
- BigNum* bn_digest);
-
-static void DeleteCurvePoint(IppsECCPPointState** p);
-
-static EpidStatus ValidateSignature(BigNum const* bn_sig_x,
- BigNum const* bn_sig_y);
-
-EpidStatus EcdsaVerifyBuffer(void const* buf, size_t buf_len,
- EcdsaPublicKey const* pubkey,
- EcdsaSignature const* sig) {
- EpidStatus result = kEpidErr;
- IppsECCPState* ec_state = NULL;
- IppsECCPPointState* ecp_pubkey = NULL;
- BigNum* bn_sig_x = NULL;
- BigNum* bn_sig_y = NULL;
- BigNum* bn_digest = NULL;
-
- if (!pubkey || !sig || (!buf && (0 != buf_len))) return kEpidBadArgErr;
- if (INT_MAX < buf_len) return kEpidBadArgErr;
-
- do {
- EpidStatus epid_status = kEpidNoErr;
- IppStatus ipp_status = ippStsNoErr;
- IppECResult ec_result = ippECValid;
-
- epid_status = NewBigNum(sizeof(sig->x), &bn_sig_x);
- if (kEpidNoErr != epid_status) break;
-
- epid_status = ReadBigNum(&sig->x, sizeof(sig->x), bn_sig_x);
- if (kEpidNoErr != epid_status) break;
-
- epid_status = NewBigNum(sizeof(sig->y), &bn_sig_y);
- if (kEpidNoErr != epid_status) break;
-
- epid_status = ReadBigNum(&sig->y, sizeof(sig->y), bn_sig_y);
- if (kEpidNoErr != epid_status) break;
-
- // check for invalid signature
- epid_status = ValidateSignature(bn_sig_x, bn_sig_y);
- if (kEpidSigValid != epid_status) {
- if (kEpidSigInvalid == epid_status) {
- result = kEpidBadArgErr;
- } else {
- result = epid_status;
- }
- break;
- }
-
- // setup curve
- epid_status = NewSecp256r1Curve(&ec_state);
- if (kEpidNoErr != epid_status) break;
-
- // load pubkey
- epid_status = NewCurvePoint(ec_state, &ecp_pubkey);
- if (kEpidNoErr != epid_status) break;
- epid_status = ReadCurvePoint(ec_state, pubkey, ecp_pubkey);
- if (kEpidNoErr != epid_status) break;
-
- // check for invalid pubkey
- ipp_status = ippsECCPCheckPoint(ecp_pubkey, &ec_result, ec_state);
- BREAK_ON_IPP_ERROR(ipp_status, result);
- if (ippECValid != ec_result) {
- result = kEpidBadArgErr;
- break;
- }
-
- // hash message
- epid_status = NewBigNum(IPP_SHA256_DIGEST_BITSIZE / 8, &bn_digest);
- if (kEpidNoErr != epid_status) break;
- epid_status = CalcHashBn(buf, buf_len, bn_digest);
- if (kEpidNoErr != epid_status) break;
-
- // configure key
- ipp_status = ippsECCPSetKeyPair(NULL, ecp_pubkey, ippTrue, ec_state);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- // verify message
- ipp_status = ippsECCPVerifyDSA(bn_digest->ipp_bn, bn_sig_x->ipp_bn,
- bn_sig_y->ipp_bn, &ec_result, ec_state);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- if (ippECValid == ec_result)
- result = kEpidSigValid;
- else
- result = kEpidSigInvalid;
- } while (0);
-
- DeleteSecp256r1Curve(&ec_state);
- DeleteCurvePoint(&ecp_pubkey);
- DeleteBigNum(&bn_digest);
- DeleteBigNum(&bn_sig_x);
- DeleteBigNum(&bn_sig_y);
-
- return result;
-}
-
-static EpidStatus NewSecp256r1Curve(IppsECCPState** ec) {
- EpidStatus result = kEpidNoErr;
- IppsECCPState* ec_state = NULL;
-
- if (!ec) return kEpidBadArgErr;
-
- do {
- int size = 0;
- IppStatus ipp_status = ippStsNoErr;
- ipp_status = ippsECCPGetSizeStd256r1(&size);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- ec_state = (IppsECCPState*)SAFE_ALLOC(size);
- if (!ec_state) {
- result = kEpidMemAllocErr;
- break;
- }
-
- ipp_status = ippsECCPInitStd256r1(ec_state);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- ipp_status = ippsECCPSetStd256r1(ec_state);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- *ec = ec_state;
- } while (0);
- if (kEpidNoErr != result) {
- SAFE_FREE(ec_state);
- }
- return result;
-}
-
-static void DeleteSecp256r1Curve(IppsECCPState** ec) {
- if (!ec || !(*ec)) {
- return;
- }
- SAFE_FREE(*ec);
- *ec = NULL;
-}
-
-static EpidStatus NewCurvePoint(IppsECCPState const* ec,
- IppsECCPPointState** p) {
- EpidStatus result = kEpidNoErr;
- IppsECCPPointState* point = NULL;
-
- if (!ec || !p) return kEpidBadArgErr;
-
- do {
- const int kFeBitSize = 256;
- IppStatus ipp_status = ippStsNoErr;
- int size = 0;
-
- ipp_status = ippsECCPPointGetSize(kFeBitSize, &size);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- point = (IppsECCPPointState*)SAFE_ALLOC(size);
- if (!point) {
- result = kEpidMemAllocErr;
- break;
- }
-
- ipp_status = ippsECCPPointInit(kFeBitSize, point);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- *p = point;
- } while (0);
- if (kEpidNoErr != result) {
- SAFE_FREE(point);
- }
- return result;
-}
-static void DeleteCurvePoint(IppsECCPPointState** p) {
- if (!p || !(*p)) {
- return;
- }
- SAFE_FREE(*p);
- *p = NULL;
-}
-
-static EpidStatus ReadCurvePoint(IppsECCPState* ec,
- EcdsaPublicKey const* pubkey,
- IppsECCPPointState* p) {
- EpidStatus result = kEpidNoErr;
- BigNum* bn_pubkey_x = NULL;
- BigNum* bn_pubkey_y = NULL;
-
- if (!ec || !pubkey || !p) return kEpidBadArgErr;
-
- do {
- IppStatus ipp_status = ippStsNoErr;
-
- result = NewBigNum(sizeof(pubkey->x), &bn_pubkey_x);
- if (kEpidNoErr != result) break;
-
- result = ReadBigNum(&pubkey->x, sizeof(pubkey->x), bn_pubkey_x);
- if (kEpidNoErr != result) break;
-
- result = NewBigNum(sizeof(pubkey->y), &bn_pubkey_y);
- if (kEpidNoErr != result) break;
-
- result = ReadBigNum(&pubkey->y, sizeof(pubkey->y), bn_pubkey_y);
- if (kEpidNoErr != result) break;
-
- ipp_status =
- ippsECCPSetPoint(bn_pubkey_x->ipp_bn, bn_pubkey_y->ipp_bn, p, ec);
- BREAK_ON_IPP_ERROR(ipp_status, result);
- } while (0);
-
- DeleteBigNum(&bn_pubkey_x);
- DeleteBigNum(&bn_pubkey_y);
-
- return result;
-}
-
-static EpidStatus CalcHashBn(void const* buf, size_t buf_len,
- BigNum* bn_digest) {
- EpidStatus result = kEpidErr;
- BigNum* bn_ec_order = NULL;
-
- if (!bn_digest || (!buf && (0 != buf_len))) return kEpidBadArgErr;
-
- do {
- IppStatus ipp_status = ippStsNoErr;
- Ipp8u digest[IPP_SHA256_DIGEST_BITSIZE / 8] = {0};
-
- const uint8_t secp256r1_r[] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17,
- 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51};
-
- ipp_status = ippsSHA256MessageDigest(buf, (int)buf_len, digest);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- // convert hash to BigNum for use by ipp
- result = ReadBigNum(digest, sizeof(digest), bn_digest);
- if (kEpidNoErr != result) break;
-
- result = NewBigNum(sizeof(secp256r1_r), &bn_ec_order);
- if (kEpidNoErr != result) break;
-
- result = ReadBigNum(secp256r1_r, sizeof(secp256r1_r), bn_ec_order);
- if (kEpidNoErr != result) break;
-
- ipp_status =
- ippsMod_BN(bn_digest->ipp_bn, bn_ec_order->ipp_bn, bn_digest->ipp_bn);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- result = kEpidNoErr;
- } while (0);
-
- DeleteBigNum(&bn_ec_order);
-
- return result;
-}
-
-static EpidStatus ValidateSignature(BigNum const* bn_sig_x,
- BigNum const* bn_sig_y) {
- EpidStatus result = kEpidSigInvalid;
-
- BigNum* bn_ec_order = NULL;
-
- if (!bn_sig_x || !bn_sig_y) return kEpidBadArgErr;
-
- do {
- IppStatus ipp_status = ippStsNoErr;
- Ipp32u sig_x_cmp0 = IS_ZERO;
- Ipp32u sig_y_cmp0 = IS_ZERO;
- Ipp32u sig_x_cmp_order = IS_ZERO;
- Ipp32u sig_y_cmp_order = IS_ZERO;
- const uint8_t secp256r1_r[] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17,
- 0x9E, 0x84, 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51};
-
- result = NewBigNum(sizeof(secp256r1_r), &bn_ec_order);
- if (kEpidNoErr != result) break;
-
- result = ReadBigNum(secp256r1_r, sizeof(secp256r1_r), bn_ec_order);
- if (kEpidNoErr != result) break;
-
- ipp_status = ippsCmpZero_BN(bn_sig_x->ipp_bn, &sig_x_cmp0);
- BREAK_ON_IPP_ERROR(ipp_status, result);
- ipp_status = ippsCmpZero_BN(bn_sig_y->ipp_bn, &sig_y_cmp0);
- BREAK_ON_IPP_ERROR(ipp_status, result);
- ipp_status =
- ippsCmp_BN(bn_sig_x->ipp_bn, bn_ec_order->ipp_bn, &sig_x_cmp_order);
- BREAK_ON_IPP_ERROR(ipp_status, result);
- ipp_status =
- ippsCmp_BN(bn_sig_y->ipp_bn, bn_ec_order->ipp_bn, &sig_y_cmp_order);
- BREAK_ON_IPP_ERROR(ipp_status, result);
-
- if (IS_ZERO == sig_x_cmp0 || IS_ZERO == sig_y_cmp0 ||
- LESS_THAN_ZERO != sig_x_cmp_order ||
- LESS_THAN_ZERO != sig_y_cmp_order) {
- result = kEpidSigInvalid;
- break;
- } else {
- result = kEpidSigValid;
- }
- } while (0);
-
- DeleteBigNum(&bn_ec_order);
-
- return result;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup-internal.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup-internal.h
deleted file mode 100644
index 23c011f44d..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup-internal.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Elliptic curve group private interface.
- */
-
-#ifndef EPID_COMMON_MATH_ECGROUP_INTERNAL_H_
-#define EPID_COMMON_MATH_ECGROUP_INTERNAL_H_
-
-#include "ext/ipp/include/ippcpepid.h"
-
-/// Elpitic Curve Group
-struct EcGroup {
- /// Internal implementation of elliptic curve group
- IppsGFpECState* ipp_ec;
- /// Scratch buffer for operations over elliptic curve group
- Ipp8u* scratch_buffer;
- /// Information about finite field of elliptic curve group created
- IppsGFpInfo info;
-};
-
-/// Elpitic Curve Point
-struct EcPoint {
- /// Internal implementation of elliptic curve point
- IppsGFpECPoint* ipp_ec_pt;
- /// Information about finite field element of elliptic curve group created
- IppsGFpInfo info;
-};
-#endif // EPID_COMMON_MATH_ECGROUP_INTERNAL_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.c
deleted file mode 100644
index 42b02784b8..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.c
+++ /dev/null
@@ -1,945 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Elliptic curve group implementation.
- */
-
-#include
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/math/ecgroup-internal.h"
-#include "epid/common/math/ecgroup.h"
-#include "epid/common/math/finitefield-internal.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-#include "ext/ipp/include/ippcpepid.h"
-
-EpidStatus NewEcGroup(FiniteField const* ff, FfElement const* a,
- FfElement const* b, FfElement const* x,
- FfElement const* y, BigNum const* order,
- BigNum const* cofactor, EcGroup** g) {
- EpidStatus result = kEpidNoErr;
- IppsGFpECState* state = NULL;
- Ipp8u* scratch_buffer = NULL;
- EcGroup* grp = NULL;
- do {
- IppStatus ipp_status;
- int stateSize = 0;
- int scratch_size = 0;
- Ipp32u* order_bnu;
- Ipp32u* cofactor_bnu;
- int order_bnu_size;
- int cofactor_bnu_size;
- IppsBigNumSGN sgn;
- // validate input pointers
- if (!ff || !a || !b || !x || !y || !order || !cofactor || !g) {
- result = kEpidBadArgErr;
- break;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != b->info.elementLen ||
- ff->info.elementLen != x->info.elementLen ||
- ff->info.elementLen != y->info.elementLen ||
- a->info.elementLen != b->info.elementLen ||
- a->info.elementLen != x->info.elementLen ||
- a->info.elementLen != y->info.elementLen ||
- b->info.elementLen != x->info.elementLen ||
- b->info.elementLen != y->info.elementLen ||
- x->info.elementLen != y->info.elementLen) {
- result = kEpidBadArgErr;
- break;
- }
-
- // construct the ECPrimeField
- ipp_status = ippsGFpECGetSize(ff->ipp_ff, &stateSize);
- if (ippStsNoErr != ipp_status) {
- if (ippStsSizeErr == ipp_status) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
-
- grp = (EcGroup*)SAFE_ALLOC(sizeof(EcGroup));
- if (!grp) {
- result = kEpidMemAllocErr;
- break;
- }
-
- state = (IppsGFpECState*)SAFE_ALLOC(stateSize);
- if (!state) {
- result = kEpidMemAllocErr;
- break;
- }
-
- ipp_status = ippsRef_BN(&sgn, &order_bnu_size, &order_bnu, order->ipp_bn);
- order_bnu_size /= sizeof(CHAR_BIT) * 4;
- if (ippStsNoErr != ipp_status) {
- result = kEpidMathErr;
- break;
- }
-
- ipp_status =
- ippsRef_BN(&sgn, &cofactor_bnu_size, &cofactor_bnu, cofactor->ipp_bn);
- cofactor_bnu_size /= sizeof(CHAR_BIT) * 4;
- if (ippStsNoErr != ipp_status) {
- result = kEpidMathErr;
- break;
- }
-
- ipp_status =
- ippsGFpECInit(a->ipp_ff_elem, b->ipp_ff_elem, x->ipp_ff_elem,
- y->ipp_ff_elem, order_bnu, order_bnu_size, cofactor_bnu,
- cofactor_bnu_size, ff->ipp_ff, state);
- if (ippStsNoErr != ipp_status) {
- result = kEpidMathErr;
- break;
- }
-
- // allocate scratch buffer
- ipp_status = ippsGFpECScratchBufferSize(1, state, &scratch_size);
- // check return codes
- if (ippStsNoErr != ipp_status) {
- if (ippStsContextMatchErr == ipp_status)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // allocate scratch buffer
- scratch_buffer = (Ipp8u*)SAFE_ALLOC(scratch_size);
- if (!scratch_buffer) {
- result = kEpidMemAllocErr;
- break;
- }
-
- grp->info = ff->info;
- grp->ipp_ec = state;
- grp->scratch_buffer = scratch_buffer;
- *g = grp;
- } while (0);
-
- if (kEpidNoErr != result) {
- // we had a problem during init, free any allocated memory
- SAFE_FREE(state);
- SAFE_FREE(scratch_buffer);
- SAFE_FREE(grp);
- }
- return result;
-}
-
-void DeleteEcGroup(EcGroup** g) {
- if (!g || !(*g)) {
- return;
- }
- if ((*g)->ipp_ec) {
- SAFE_FREE((*g)->ipp_ec);
- (*g)->ipp_ec = NULL;
- }
- if ((*g)->scratch_buffer) {
- SAFE_FREE((*g)->scratch_buffer);
- (*g)->scratch_buffer = NULL;
- }
- SAFE_FREE(*g);
- *g = NULL;
-}
-
-EpidStatus NewEcPoint(EcGroup const* g, EcPoint** p) {
- EpidStatus result = kEpidErr;
- IppsGFpECPoint* ec_pt_context = NULL;
- EcPoint* ecpoint = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- int sizeInBytes = 0;
- // validate inputs
- if (!g || !p) {
- result = kEpidBadArgErr;
- break;
- } else if (!g->ipp_ec) {
- result = kEpidBadArgErr;
- break;
- }
- // get size
- sts = ippsGFpECPointGetSize(g->ipp_ec, &sizeInBytes);
- if (ippStsContextMatchErr == sts) {
- result = kEpidBadArgErr;
- break;
- } else if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- // allocate memory
- ec_pt_context = (IppsGFpECPoint*)SAFE_ALLOC(sizeInBytes);
- if (!ec_pt_context) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize
- sts = ippsGFpECPointInit(NULL, NULL, ec_pt_context, g->ipp_ec);
- if (ippStsContextMatchErr == sts) {
- result = kEpidBadArgErr;
- break;
- } else if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- ecpoint = SAFE_ALLOC(sizeof(EcPoint));
- if (!ecpoint) {
- result = kEpidMemAllocErr;
- break;
- }
- ecpoint->info = g->info;
- ecpoint->ipp_ec_pt = ec_pt_context;
- *p = ecpoint;
- result = kEpidNoErr;
- } while (0);
- if (kEpidNoErr != result) {
- SAFE_FREE(ec_pt_context);
- SAFE_FREE(ecpoint);
- }
- return result;
-}
-
-void DeleteEcPoint(EcPoint** p) {
- if (p) {
- if (*p) {
- SAFE_FREE((*p)->ipp_ec_pt);
- }
- SAFE_FREE(*p);
- }
-}
-
-/// Check and initialize element if it is in elliptic curve group.
-/*!
- This is internal function.
- Takes a value p as input. If p is indeed an element of g, it
- outputs true, otherwise, it outputs false.
-
- This is only used to check if input buffer are actually valid
- elements in group. If p is in g, this fills p and initializes it to
- internal FfElement format.
-
- \param[in] g
- The eliptic curve group in which to perform the check
- \param[in] p_str
- Serialized eliptic curve group element to check
- \param[in] strlen
- The size of p_str in bytes.
- \param[out] p
- Deserialized value of p_str
- \param[out] in_group
- Result of the check
-
- \returns ::EpidStatus
-
- \see NewEcPoint
-*/
-EpidStatus eccontains(EcGroup* g, void const* p_str, size_t strlen, EcPoint* p,
- bool* in_group) {
- EpidStatus result = kEpidErr;
- IppStatus sts = ippStsNoErr;
- FiniteField fp;
- FfElement* fp_x = NULL;
- FfElement* fp_y = NULL;
- Ipp8u const* byte_str = (Ipp8u const*)p_str;
- IppECResult ec_result = ippECPointIsNotValid;
- int ipp_half_strlen = (int)strlen / 2;
-
- if (!g || !p_str || !p || !in_group) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !p->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
-
- if (INT_MAX < strlen || strlen <= 0 || strlen & 0x1) {
- return kEpidBadArgErr;
- }
-
- do {
- size_t i = 0;
- // if the string is all zeros then we take it as point at infinity
- for (i = 0; i < strlen; i++) {
- if (0 != byte_str[i]) {
- break;
- }
- }
- if (i >= strlen) {
- // p_str is point at infinity! Set it and we are done
- sts = ippsGFpECSetPointAtInfinity(p->ipp_ec_pt, g->ipp_ec);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- *in_group = true;
- result = kEpidNoErr;
- break;
- }
- // get finite field
- sts = ippsGFpECGet(g->ipp_ec, (const IppsGFpState**)&(fp.ipp_ff), 0, 0, 0,
- 0, 0, 0, 0, 0);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // create element X
- result = NewFfElement(&fp, &fp_x);
- if (kEpidNoErr != result) {
- break;
- }
-
- // create element Y
- result = NewFfElement(&fp, &fp_y);
- if (kEpidNoErr != result) {
- break;
- }
-
- // set element X data
- sts = ippsGFpSetElementOctString(byte_str, ipp_half_strlen,
- fp_x->ipp_ff_elem, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsOutOfRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // set element Y data
- sts =
- ippsGFpSetElementOctString(byte_str + ipp_half_strlen, ipp_half_strlen,
- fp_y->ipp_ff_elem, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsOutOfRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // set point from elements
- sts = ippsGFpECSetPoint(fp_x->ipp_ff_elem, fp_y->ipp_ff_elem, p->ipp_ec_pt,
- g->ipp_ec);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // verify the point is actually on the curve
- sts = ippsGFpECTstPoint(p->ipp_ec_pt, &ec_result, g->ipp_ec,
- g->scratch_buffer);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- *in_group = (ippECValid == ec_result);
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&fp_x);
- DeleteFfElement(&fp_y);
- return result;
-}
-
-EpidStatus ReadEcPoint(EcGroup* g, void const* p_str, size_t strlen,
- EcPoint* p) {
- EpidStatus result;
- bool in_group = false;
-
- if (!g || !p_str || !p) {
- return kEpidBadArgErr;
- }
- if (0 == strlen) {
- return kEpidBadArgErr;
- }
-
- result = eccontains(g, p_str, strlen, p, &in_group);
- if (kEpidNoErr != result) {
- return result;
- }
- if (in_group == false) {
- IppStatus sts = ippsGFpECPointInit(NULL, NULL, p->ipp_ec_pt, g->ipp_ec);
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else if (ippStsNoErr != sts) {
- return kEpidMathErr;
- }
- return kEpidBadArgErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus WriteEcPoint(EcGroup* g, EcPoint const* p, void* p_str,
- size_t strlen) {
- EpidStatus result = kEpidErr;
- FiniteField fp;
- FfElement* fp_x = NULL;
- FfElement* fp_y = NULL;
- Ipp8u* byte_str = (Ipp8u*)p_str;
- IppStatus sts = ippStsNoErr;
- int ipp_half_strlen = (int)strlen / 2;
-
- if (!g || !p || !p_str) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !p->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (INT_MAX < strlen) {
- return kEpidBadArgErr;
- }
-
- if (INT_MAX < strlen || strlen <= 0 || strlen & 0x1) {
- return kEpidBadArgErr;
- }
-
- do {
- // get finite field
- sts = ippsGFpECGet(g->ipp_ec, (const IppsGFpState**)&(fp.ipp_ff), 0, 0, 0,
- 0, 0, 0, 0, 0);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // create element X
- result = NewFfElement(&fp, &fp_x);
- if (kEpidNoErr != result) {
- break;
- }
-
- // create element Y
- result = NewFfElement(&fp, &fp_y);
- if (kEpidNoErr != result) {
- break;
- }
-
- // get elements from point
- sts = ippsGFpECGetPoint(p->ipp_ec_pt, fp_x->ipp_ff_elem, fp_y->ipp_ff_elem,
- g->ipp_ec);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsPointAtInfinity == sts) {
- memset(p_str, 0, strlen);
- result = kEpidNoErr;
- } else if (ippStsContextMatchErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
-
- // get element X data
- sts = ippsGFpGetElementOctString(fp_x->ipp_ff_elem, byte_str,
- ipp_half_strlen, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
-
- // get element Y data
- sts = ippsGFpGetElementOctString(fp_y->ipp_ff_elem,
- byte_str + ipp_half_strlen,
- ipp_half_strlen, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&fp_x);
- DeleteFfElement(&fp_y);
-
- return result;
-}
-
-EpidStatus EcMul(EcGroup* g, EcPoint const* a, EcPoint const* b, EcPoint* r) {
- IppStatus sts = ippStsNoErr;
- if (!g || !a || !b || !r) {
- return kEpidBadArgErr;
- } else if (!g->ipp_ec || !a->ipp_ec_pt || !b->ipp_ec_pt || !r->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != a->info.elementLen ||
- g->info.elementLen != b->info.elementLen ||
- g->info.elementLen != r->info.elementLen ||
- a->info.elementLen != b->info.elementLen ||
- a->info.elementLen != r->info.elementLen ||
- b->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- // Multiplies elliptic curve points
- sts = ippsGFpECAddPoint(a->ipp_ec_pt, b->ipp_ec_pt, r->ipp_ec_pt, g->ipp_ec);
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus EcExp(EcGroup* g, EcPoint const* a, BigNumStr const* b, EcPoint* r) {
- EpidStatus result = kEpidErr;
- BigNum* b_bn = NULL;
- do {
- IppStatus sts = ippStsNoErr;
-
- // Check required parameters
- if (!g || !a || !b || !r) {
- result = kEpidBadArgErr;
- break;
- } else if (!g->ipp_ec || !a->ipp_ec_pt || !r->ipp_ec_pt) {
- result = kEpidBadArgErr;
- break;
- }
- if (g->info.elementLen != a->info.elementLen ||
- g->info.elementLen != r->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- result = kEpidBadArgErr;
- break;
- }
-
- // Create and initialize big number element for ipp call
- result = NewBigNum(sizeof(((BigNumStr*)0)->data.data), &b_bn);
- if (kEpidNoErr != result) break;
- result = ReadBigNum(b, sizeof(*b), b_bn);
- if (kEpidNoErr != result) break;
-
- sts = ippsGFpECMulPoint(a->ipp_ec_pt, b_bn->ipp_bn, r->ipp_ec_pt, g->ipp_ec,
- g->scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsOutOfRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- result = kEpidNoErr;
- } while (0);
- DeleteBigNum(&b_bn);
- return result;
-}
-
-EpidStatus EcSscmExp(EcGroup* g, EcPoint const* a, BigNumStr const* b,
- EcPoint* r) {
- // call EcExp directly because its implementation is side channel
- // mitigated already
- return EcExp(g, a, b, r);
-}
-
-EpidStatus EcMultiExp(EcGroup* g, EcPoint const** a, BigNumStr const** b,
- size_t m, EcPoint* r) {
- EpidStatus result = kEpidErr;
- BigNum* b_bn = NULL;
- EcPoint* ecp_t = NULL;
- int i = 0;
- int ii = 0;
- int ipp_m = 0;
-
- if (!g || !a || !b || !r) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || m <= 0) {
- return kEpidBadArgErr;
- }
- // because we use ipp function with number of items parameter
- // defined as "int" we need to verify that input length
- // do not exceed INT_MAX to avoid overflow
- if (m > INT_MAX) {
- return kEpidBadArgErr;
- }
- ipp_m = (int)m;
- // Verify that ec points are not NULL
- for (i = 0; i < ipp_m; i++) {
- if (!a[i]) {
- return kEpidBadArgErr;
- }
- if (!a[i]->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != a[i]->info.elementLen) {
- return kEpidBadArgErr;
- }
- for (ii = i + 1; ii < ipp_m; ii++) {
- if (a[i]->info.elementLen != a[ii]->info.elementLen) {
- return kEpidBadArgErr;
- }
- }
- }
- if (g->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- do {
- IppStatus sts = ippStsNoErr;
-
- // Create big number element for ipp call
- result = NewBigNum(sizeof(((BigNumStr*)0)->data.data), &b_bn);
- if (kEpidNoErr != result) break;
- // Create temporal EcPoint element
- result = NewEcPoint(g, &ecp_t);
- if (kEpidNoErr != result) break;
-
- for (i = 0; i < ipp_m; i++) {
- // Initialize big number element for ipp call
- result = ReadBigNum(b[i], sizeof(BigNumStr), b_bn);
- if (kEpidNoErr != result) break;
-
- sts = ippsGFpECMulPoint(a[i]->ipp_ec_pt, b_bn->ipp_bn, ecp_t->ipp_ec_pt,
- g->ipp_ec, g->scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts ||
- ippStsOutOfRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- if (1 == m) {
- sts = ippsGFpECCpyPoint(ecp_t->ipp_ec_pt, r->ipp_ec_pt, g->ipp_ec);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- } else {
- sts = ippsGFpECAddPoint(ecp_t->ipp_ec_pt, r->ipp_ec_pt, r->ipp_ec_pt,
- g->ipp_ec);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- }
- }
- if (kEpidNoErr != result) break;
-
- result = kEpidNoErr;
- } while (0);
- DeleteBigNum(&b_bn);
- DeleteEcPoint(&ecp_t);
-
- return result;
-}
-
-EpidStatus EcSscmMultiExp(EcGroup* g, EcPoint const** a, BigNumStr const** b,
- size_t m, EcPoint* r) {
- // call EcMultiExp directly because its implementation is side channel
- // mitigated already
- return EcMultiExp(g, a, b, m, r);
-}
-
-EpidStatus EcGetRandom(EcGroup* g, BitSupplier rnd_func, void* rnd_func_param,
- EcPoint* r) {
- IppStatus sts = ippStsNoErr;
- if (!g || !rnd_func || !r) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !g->scratch_buffer) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsGFpECSetPointRandom((IppBitSupplier)rnd_func, rnd_func_param,
- r->ipp_ec_pt, g->ipp_ec, g->scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- return kEpidNoErr;
-}
-
-EpidStatus EcInGroup(EcGroup* g, void const* p_str, size_t strlen,
- bool* in_group) {
- EpidStatus result = kEpidErr;
- EcPoint* p = NULL;
-
- if (!g || !p_str || !in_group) {
- return kEpidBadArgErr;
- }
- if (0 == strlen) {
- return kEpidBadArgErr;
- }
-
- if (strlen != sizeof(G1ElemStr) && strlen != sizeof(G2ElemStr)) {
- *in_group = false;
- return kEpidBadArgErr;
- } else {
- if (strlen == sizeof(G1ElemStr)) {
- // check info.elementlen with strlen
- // multiply by 2 for x,y and 4 multiply to convert dword to bytes
- size_t info_elementLen_in_byte = (g->info.elementLen) * 2 * 4;
- if (info_elementLen_in_byte != strlen) {
- *in_group = false;
- return kEpidBadArgErr;
- }
- // check Fq basic and ground degree
- if (g->info.basicGFdegree != 1 || g->info.groundGFdegree != 1) {
- *in_group = false;
- return kEpidBadArgErr;
- }
- }
- if (strlen == sizeof(G2ElemStr)) {
- // check info.elementlen with strlen
- // multiply by 2 for x,y and 4 multiply to convert dword to bytes
- size_t info_elementLen_in_byte = (g->info.elementLen) * 2 * 4;
- IppStatus sts = ippStsNoErr;
- IppsGFpInfo ground_info = {0};
- if (info_elementLen_in_byte != strlen) {
- *in_group = false;
- return kEpidBadArgErr;
- }
- // check Fq2 basic and ground degree
- if (g->info.basicGFdegree != 2 || g->info.groundGFdegree != 2) {
- *in_group = false;
- return kEpidBadArgErr;
- }
- // check Fq basic and ground degree
- sts = ippsGFpGetInfo(g->info.pGroundGF, &ground_info);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- *in_group = false;
- return kEpidMathErr;
- } else {
- *in_group = false;
- return kEpidBadArgErr;
- }
- }
-
- if (ground_info.basicGFdegree != 1 || ground_info.groundGFdegree != 1) {
- *in_group = false;
- return kEpidBadArgErr;
- }
- }
- }
-
- do {
- result = NewEcPoint(g, &p);
- if (kEpidNoErr != result) break;
-
- result = eccontains(g, p_str, strlen, p, in_group);
- if (kEpidNoErr != result) break;
-
- result = kEpidNoErr;
- } while (0);
-
- DeleteEcPoint(&p);
-
- return result;
-}
-
-/// The number of attempts to hash a message to an element
-#define EPID_ECHASH_WATCHDOG (50)
-
-EpidStatus EcHash(EcGroup* g, void const* msg, size_t msg_len, HashAlg hash_alg,
- EcPoint* r) {
- EpidStatus result = kEpidErr;
- IppStatus sts = ippStsNoErr;
- IppHashID hash_id;
- int ipp_msg_len = 0;
- Ipp32u i = 0;
- if (!g || !msg || !r) {
- return kEpidBadArgErr;
- } else if (!g->ipp_ec || !r->ipp_ec_pt || msg_len <= 0) {
- return kEpidBadArgErr;
- }
- // because we use ipp function with message length parameter
- // defined as "int" we need to verify that input length
- // do not exceed INT_MAX to avoid overflow
- if (msg_len > INT_MAX) {
- return kEpidBadArgErr;
- }
- ipp_msg_len = (int)msg_len;
- if (kSha256 == hash_alg) {
- hash_id = ippSHA256;
- } else if (kSha384 == hash_alg) {
- hash_id = ippSHA384;
- } else if (kSha512 == hash_alg) {
- hash_id = ippSHA512;
- } else {
- return kEpidHashAlgorithmNotSupported;
- }
- if (g->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- for (i = 0; i < EPID_ECHASH_WATCHDOG; i++) {
- sts = ippsGFpECSetPointHash(i, msg, ipp_msg_len, hash_id, r->ipp_ec_pt,
- g->ipp_ec, g->scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsQuadraticNonResidueErr == sts) {
- result = kEpidMathErr;
- continue;
- } else if (ippStsContextMatchErr == sts || ippStsBadArgErr == sts ||
- ippStsLengthErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- return kEpidNoErr;
- }
-
- return result;
-}
-
-EpidStatus EcMakePoint(EcGroup* g, FfElement const* x, EcPoint* r) {
- IppStatus sts = ippStsNoErr;
- if (!g || !x || !r) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !x->ipp_ff_elem || !r->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != x->info.elementLen ||
- g->info.elementLen != r->info.elementLen ||
- x->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- sts = ippsGFpECMakePoint(x->ipp_ff_elem, r->ipp_ec_pt, g->ipp_ec);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsQuadraticNonResidueErr == sts ||
- ippStsBadArgErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus EcInverse(EcGroup* g, EcPoint const* p, EcPoint* r) {
- IppStatus sts = ippStsNoErr;
- if (!g || !p || !r) {
- return kEpidBadArgErr;
- } else if (!g->ipp_ec || !p->ipp_ec_pt || !r->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != p->info.elementLen ||
- g->info.elementLen != r->info.elementLen ||
- p->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- // Inverses elliptic curve point
- sts = ippsGFpECNegPoint(p->ipp_ec_pt, r->ipp_ec_pt, g->ipp_ec);
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus EcIsEqual(EcGroup* g, EcPoint const* a, EcPoint const* b,
- bool* is_equal) {
- IppStatus sts;
- IppECResult result;
-
- if (!g || !a || !b || !is_equal) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !a->ipp_ec_pt || !b->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != a->info.elementLen ||
- g->info.elementLen != b->info.elementLen ||
- a->info.elementLen != b->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsGFpECCmpPoint(a->ipp_ec_pt, b->ipp_ec_pt, &result, g->ipp_ec);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- *is_equal = ippECPointIsEqual == result;
-
- return kEpidNoErr;
-}
-
-EpidStatus EcIsIdentity(EcGroup* g, EcPoint const* p, bool* is_identity) {
- IppStatus sts;
- IppECResult result;
-
- if (!g || !p || !is_identity) {
- return kEpidBadArgErr;
- }
- if (!g->ipp_ec || !p->ipp_ec_pt) {
- return kEpidBadArgErr;
- }
- if (g->info.elementLen != p->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsGFpECTstPoint(p->ipp_ec_pt, &result, g->ipp_ec, g->scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- *is_identity = ippECPointIsAtInfinite == result;
-
- return kEpidNoErr;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.h
deleted file mode 100644
index 2212434d06..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/ecgroup.h
+++ /dev/null
@@ -1,435 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Elliptic curve group interface.
- */
-
-#ifndef EPID_COMMON_MATH_ECGROUP_H_
-#define EPID_COMMON_MATH_ECGROUP_H_
-
-#include "epid/common/stdtypes.h"
-#include "epid/common/errors.h"
-#include "epid/common/math/bignum.h"
-#include "epid/common/math/finitefield.h"
-#include "epid/common/types.h"
-
-/// Elliptic curve group operations
-/*!
- \defgroup EcGroupPrimitives ecgroup
- Provides APIs for working with Elliptic curve groups.
- Elliptic curve groups allow simple mathematical operations based on points
- that lie on a defined elliptic curve. The results of these operations also
- lie on the same curve.
-
- Curves themselves are defined based on elements (::FfElement) of a finite
- field (::FiniteField).
-
- \ingroup EpidMath
-@{
-*/
-
-/// Elliptic curve group over finite field.
-typedef struct EcGroup EcGroup;
-
-/// Constructs a new EcGroup.
-/*!
-
- Allocates memory and creates a new elliptic curve group.
-
- Use DeleteFiniteField() to free memory.
-
- \param[in] ff
- The finite field on which the curve is based.
- \param[in] a
- The A value of the elliptic curve.
- \param[in] b
- The B value of the elliptic curve.
- \param[in] x
- The X co-ordinate of the base point of the elliptic curve.
- \param[in] y
- The Y co-ordinate of the base point of the elliptic curve.
- \param[in] order
- The order of the elliptic curve group.
- \param[in] cofactor
- The co-factor of the elliptic curve.
- \param[out] g
- The newly constructed elliptic curve group.
-
- \returns ::EpidStatus
-
- \see DeleteEcGroup
-*/
-EpidStatus NewEcGroup(FiniteField const* ff, FfElement const* a,
- FfElement const* b, FfElement const* x,
- FfElement const* y, BigNum const* order,
- BigNum const* cofactor, EcGroup** g);
-
-/// Deletes a previously allocated EcGroup.
-/*!
- Frees memory pointed to by elliptic curve group. Nulls the pointer.
-
- \param[in] g
- The elliptic curve group. Can be NULL.
-
- \see NewEcGroup
-*/
-void DeleteEcGroup(EcGroup** g);
-
-/// Point on elliptic curve over finite field.
-typedef struct EcPoint EcPoint;
-
-/// Creates a new EcPoint.
-/*!
- Allocates memory and creates a new point on elliptic curve group.
-
- Use DeleteEcPoint() to free memory.
-
- \param[in] g
- Elliptic curve group.
- \param[out] p
- Newly constructed point on the elliptic curve group g.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see DeleteEcPoint
-*/
-EpidStatus NewEcPoint(EcGroup const* g, EcPoint** p);
-
-/// Deletes a previously allocated EcPoint.
-/*!
-
- Frees memory used by a point on elliptic curve group. Nulls the pointer.
-
- \param[in] p
- The EcPoint. Can be NULL.
-
- \see NewEcPoint
-*/
-void DeleteEcPoint(EcPoint** p);
-
-/// Deserializes an EcPoint from a string.
-/*!
- \param[in] g
- The elliptic curve group.
- \param[in] p_str
- The serialized value.
- \param[in] strlen
- The size of p_str in bytes.
- \param[out] p
- The target EcPoint.
-
- \returns ::EpidStatus
-
- \see NewEcPoint
-*/
-EpidStatus ReadEcPoint(EcGroup* g, void const* p_str, size_t strlen,
- EcPoint* p);
-
-/// Serializes an EcPoint to a string.
-/*!
- \param[in] g
- The elliptic curve group.
- \param[in] p
- The EcPoint to be serialized.
- \param[out] p_str
- The target string.
- \param[in] strlen
- the size of p_str in bytes.
-
- \returns ::EpidStatus
-
- \see NewEcPoint
-*/
-EpidStatus WriteEcPoint(EcGroup* g, EcPoint const* p, void* p_str,
- size_t strlen);
-
-/// Multiplies two elements in an elliptic curve group.
-/*!
- This multiplication operation is also known as element addition for
- elliptic curve groups.
-
- \param[in] g
- The elliptic curve group.
- \param[in] a
- The left hand parameter.
- \param[in] b
- The right hand parameter.
- \param[out] r
- The result of multiplying a and b.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcMul(EcGroup* g, EcPoint const* a, EcPoint const* b, EcPoint* r);
-
-/// Raises a point in an elliptic curve group to a power.
-/*!
- This exponentiation operation is also known as element multiplication
- for elliptic curve groups.
- \param[in] g
- The elliptic curve group.
- \param[in] a
- The base.
- \param[in] b
- The power. Power must be less than the order of the elliptic curve
- group.
- \param[out] r
- The result of raising a to the power b.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcExp(EcGroup* g, EcPoint const* a, BigNumStr const* b, EcPoint* r);
-
-/// Software side-channel mitigated implementation of EcExp.
-/*!
- This exponentiation operation is also known as element multiplication
- for elliptic curve groups.
-
- \attention
- The reference implementation of EcSscmExp calls EcExp directly because
- the implementation of EcExp is already side channel mitigated. Implementers
- providing their own versions of this function are responsible for ensuring
- that EcSscmExp is side channel mitigated per section 8 of the
- Intel(R) EPID 2.0 spec.
-
- \param[in] g
- The elliptic curve group.
- \param[in] a
- The base.
- \param[in] b
- The power. Power must be less than the order of the elliptic curve
- group.
- \param[out] r
- The result of raising a to the power b.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcSscmExp(EcGroup* g, EcPoint const* a, BigNumStr const* b,
- EcPoint* r);
-
-/// Multi-exponentiates elements in elliptic curve group.
-/*!
- Takes a group elements a[0], ... , a[m-1] in G and positive
- integers b[0], ..., b[m-1], where m is a small positive integer.
- Outputs r (in G) = EcExp(a[0],b[0]) * ... * EcExp(a[m-1],b[m-1]).
-
- \param[in] g
- The elliptic curve group.
- \param[in] a
- The bases.
- \param[in] b
- The powers. Power must be less than the order of the elliptic curve
- group.
- \param[in] m
- Number of entries in a and b.
- \param[out] r
- The result of raising each a to the corresponding power b and multiplying
- the results.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcMultiExp(EcGroup* g, EcPoint const** a, BigNumStr const** b,
- size_t m, EcPoint* r);
-
-/// Software side-channel mitigated implementation of EcMultiExp.
-/*!
- Takes a group elements a[0], ... , a[m-1] in G and positive
- integers b[0], ..., b[m-1], where m is a small positive integer.
- Outputs r (in G) = EcExp(a[0],b[0]) * ... * EcExp(a[m-1],b[m-1]).
-
- \attention
- The reference implementation of EcSscmMultiExp calls EcMultiExp
- directly because the implementation of EcMultiExp is already side channel
- mitigated. Implementers providing their own versions of this function are
- responsible for ensuring that EcSscmMultiExp is side channel mitigated per
- section 8 of the Intel(R) EPID 2.0 spec.
-
- \param[in] g
- The elliptic curve group.
- \param[in] a
- The bases.
- \param[in] b
- The powers. Power must be less than the order of the elliptic curve
- group.
- \param[in] m
- Number of entries in a and b.
- \param[out] r
- The result of raising each a to the corresponding power b and
- multiplying the results.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcSscmMultiExp(EcGroup* g, EcPoint const** a, BigNumStr const** b,
- size_t m, EcPoint* r);
-
-/// Generates a random element from an elliptic curve group.
-/*!
- This function is only available for G1 and GT.
-
- \param[in] g
- The elliptic curve group.
- \param[in] rnd_func
- Random number generator.
- \param[in] rnd_func_param
- Pass through context data for rnd_func.
- \param[in,out] r
- Output random elliptic curve element.
-
- \returns ::EpidStatus
-
- \see NewEcPoint
- \see BitSupplier
-*/
-EpidStatus EcGetRandom(EcGroup* g, BitSupplier rnd_func, void* rnd_func_param,
- EcPoint* r);
-
-/// Checks if a point is in an elliptic curve group.
-/*!
- \param[in] g
- The elliptic curve group.
- \param[in] p_str
- A serialized point. Must be a G1ElemStr or G2ElemStr.
- \param[in] strlen
- The size of p_str in bytes.
- \param[out] in_group
- The result of the check.
-
- \returns ::EpidStatus
-
- \see NewEcPoint
-*/
-EpidStatus EcInGroup(EcGroup* g, void const* p_str, size_t strlen,
- bool* in_group);
-
-/// Hashes an arbitrary message to an element in an elliptic curve group.
-/*!
- \param[in] g
- The elliptic curve group.
- \param[in] msg
- The message.
- \param[in] msg_len
- The size of msg in bytes.
- \param[in] hash_alg
- The hash algorithm.
- \param[out] r
- The hashed value.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcHash(EcGroup* g, void const* msg, size_t msg_len, HashAlg hash_alg,
- EcPoint* r);
-
-/// Sets an EcPoint variable to a point on a curve.
-/*!
- This function is only available for G1.
-
- \param[in] g
- The elliptic curve group.
- \param[in] x
- The x coordinate.
- \param[out] r
- The point.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
- \see NewFfElement
-*/
-EpidStatus EcMakePoint(EcGroup* g, FfElement const* x, EcPoint* r);
-
-/// Computes the additive inverse of an EcPoint.
-/*!
- This inverse operation is also known as element negation
- for elliptic curve groups.
-
- \param[in] g
- The elliptic curve group.
- \param[in] p
- The point.
- \param[out] r
- The inverted point.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcInverse(EcGroup* g, EcPoint const* p, EcPoint* r);
-
-/// Checks if two EcPoints are equal.
-/*!
- \param[in] g
- The elliptic curve group.
- \param[in] a
- A point to check.
- \param[in] b
- Another point to check.
- \param[out] is_equal
- The result of the check.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
- */
-EpidStatus EcIsEqual(EcGroup* g, EcPoint const* a, EcPoint const* b,
- bool* is_equal);
-
-/// Checks if an EcPoint is the identity element.
-/*!
-
- Takes a group element P as input. It outputs true if P is the
- identity element of G. Otherwise, it outputs false.
-
- \param[in] g
- The elliptic curve group.
- \param[in] p
- The point to check.
- \param[out] is_identity
- The result of the check.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
-*/
-EpidStatus EcIsIdentity(EcGroup* g, EcPoint const* p, bool* is_identity);
-
-/*!
-@}
-*/
-#endif // EPID_COMMON_MATH_ECGROUP_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield-internal.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield-internal.h
deleted file mode 100644
index b9dcc65e33..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield-internal.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Finite field private interface.
- */
-
-#ifndef EPID_COMMON_MATH_FINITEFIELD_INTERNAL_H_
-#define EPID_COMMON_MATH_FINITEFIELD_INTERNAL_H_
-
-#include "ext/ipp/include/ippcpepid.h"
-
-/// Finite Field
-struct FiniteField {
- /// Internal implementation of finite field
- IppsGFpState* ipp_ff;
- /// Information about finite field created
- IppsGFpInfo info;
-};
-
-/// Finite Field Element
-struct FfElement {
- /// Internal implementation of finite field element
- IppsGFpElement* ipp_ff_elem;
- /// Information about finite field element was created for
- IppsGFpInfo info;
-};
-
-/// Initialize FiniteField structure
-EpidStatus InitFiniteFieldFromIpp(IppsGFpState* ipp_ff, FiniteField* ff);
-
-#endif // EPID_COMMON_MATH_FINITEFIELD_INTERNAL_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.c
deleted file mode 100644
index c496010295..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.c
+++ /dev/null
@@ -1,805 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Finite field implementation.
- */
-
-#include
-#include
-#include "epid/common/math/finitefield.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/math/finitefield-internal.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-#include "ext/ipp/include/ippcpepid.h"
-
-/// Initializes a FiniteField structure
-EpidStatus InitFiniteFieldFromIpp(IppsGFpState* ipp_ff, FiniteField* ff) {
- IppStatus sts = ippStsNoErr;
-
- if (!ipp_ff || !ff) return kEpidBadArgErr;
-
- memset(ff, 0, sizeof(*ff));
-
- sts = ippsGFpGetInfo(ipp_ff, &(ff->info));
- if (ippStsNoErr != sts) return kEpidMathErr;
-
- ff->ipp_ff = ipp_ff;
-
- return kEpidNoErr;
-}
-
-EpidStatus NewFiniteField(BigNumStr const* prime, FiniteField** ff) {
- EpidStatus result = kEpidErr;
- IppsGFpState* ipp_finitefield_ctx = NULL;
- FiniteField* finitefield_ptr = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- Ipp32u bnu[sizeof(BigNumStr) / sizeof(Ipp32u)];
- int bnu_size;
- int bit_size = CHAR_BIT * sizeof(BigNumStr);
- int state_size_in_bytes = 0;
-
- if (!prime || !ff) {
- result = kEpidBadArgErr;
- break;
- }
- bnu_size = OctStr2Bnu(bnu, prime, sizeof(*prime));
- if (bnu_size < 0) {
- result = kEpidMathErr;
- break;
- }
-
- // Determine the memory requirement for finite field context
- sts = ippsGFpGetSize(bit_size, &state_size_in_bytes);
- if (ippStsNoErr != sts) {
- if (ippStsSizeErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- // Allocate space for ipp bignum context
- ipp_finitefield_ctx = (IppsGFpState*)SAFE_ALLOC(state_size_in_bytes);
- if (!ipp_finitefield_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize ipp finite field context
- sts = ippsGFpInit(bnu, bit_size, ipp_finitefield_ctx);
- if (ippStsNoErr != sts) {
- if (ippStsSizeErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- finitefield_ptr = (FiniteField*)SAFE_ALLOC(sizeof(FiniteField));
- if (!finitefield_ptr) {
- result = kEpidMemAllocErr;
- break;
- }
- result = InitFiniteFieldFromIpp(ipp_finitefield_ctx, finitefield_ptr);
- if (kEpidNoErr != result) break;
-
- *ff = finitefield_ptr;
- result = kEpidNoErr;
- } while (0);
-
- if (kEpidNoErr != result) {
- SAFE_FREE(finitefield_ptr);
- SAFE_FREE(ipp_finitefield_ctx);
- }
- return result;
-}
-
-EpidStatus NewFiniteFieldViaBinomalExtension(FiniteField const* ground_field,
- FfElement const* ground_element,
- int degree, FiniteField** ff) {
- EpidStatus result = kEpidErr;
- IppsGFpState* ipp_finitefield_ctx = NULL;
- FiniteField* finitefield_ptr = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- int state_size_in_bytes = 0;
- if (!ground_field || !ground_element || !ff) {
- result = kEpidBadArgErr;
- break;
- } else if (degree < 2 || !ground_field->ipp_ff ||
- !ground_element->ipp_ff_elem) {
- result = kEpidBadArgErr;
- break;
- }
-
- // Determine the memory requirement for finite field context
- sts = ippsGFpxGetSize(ground_field->ipp_ff, degree, &state_size_in_bytes);
- if (ippStsNoErr != sts) {
- if (ippStsSizeErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
-
- // Allocate space for ipp finite field context
- ipp_finitefield_ctx = (IppsGFpState*)SAFE_ALLOC(state_size_in_bytes);
- if (!ipp_finitefield_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
-
- // Initialize ipp binomial extension finite field context
- sts =
- ippsGFpxInitBinomial(ground_field->ipp_ff, ground_element->ipp_ff_elem,
- degree, ipp_finitefield_ctx);
- if (ippStsNoErr != sts) {
- if (ippStsSizeErr == sts) {
- result = kEpidBadArgErr;
- } else {
- result = kEpidMathErr;
- }
- break;
- }
- finitefield_ptr = (FiniteField*)SAFE_ALLOC(sizeof(FiniteField));
- if (!finitefield_ptr) {
- result = kEpidMemAllocErr;
- break;
- }
- result = InitFiniteFieldFromIpp(ipp_finitefield_ctx, finitefield_ptr);
- if (kEpidNoErr != result) break;
-
- *ff = finitefield_ptr;
- result = kEpidNoErr;
- } while (0);
-
- if (kEpidNoErr != result) {
- SAFE_FREE(finitefield_ptr);
- SAFE_FREE(ipp_finitefield_ctx);
- }
- return result;
-}
-
-void DeleteFiniteField(FiniteField** ff) {
- if (ff) {
- if (*ff) {
- SAFE_FREE((*ff)->ipp_ff);
- }
- SAFE_FREE((*ff));
- }
-}
-
-EpidStatus NewFfElement(FiniteField const* ff, FfElement** new_ff_elem) {
- EpidStatus result = kEpidErr;
- IppsGFpElement* ipp_ff_elem = NULL;
- FfElement* ff_elem = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- unsigned int ctxsize = 0;
- Ipp32u zero = 0;
- // check parameters
- if (!ff || !new_ff_elem) {
- result = kEpidBadArgErr;
- break;
- } else if (!ff->ipp_ff) {
- result = kEpidBadArgErr;
- break;
- }
- // Determine the memory requirement for finite field element context
- sts = ippsGFpElementGetSize(ff->ipp_ff, (int*)&ctxsize);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- // Allocate space for ipp bignum context
- ipp_ff_elem = (IppsGFpElement*)SAFE_ALLOC(ctxsize);
- if (!ipp_ff_elem) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize ipp bignum context
- // initialize state
- sts = ippsGFpElementInit(&zero, 1, ipp_ff_elem, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
-
- ff_elem = (FfElement*)SAFE_ALLOC(sizeof(FfElement));
- if (!ff_elem) {
- result = kEpidMemAllocErr;
- break;
- }
-
- ff_elem->ipp_ff_elem = ipp_ff_elem;
-
- sts = ippsGFpGetInfo(ff->ipp_ff, &(ff_elem->info));
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
-
- *new_ff_elem = ff_elem;
- result = kEpidNoErr;
- } while (0);
-
- if (kEpidNoErr != result) {
- SAFE_FREE(ipp_ff_elem);
- SAFE_FREE(ff_elem);
- }
- return result;
-}
-
-void DeleteFfElement(FfElement** ff_elem) {
- if (ff_elem) {
- if (*ff_elem) {
- SAFE_FREE((*ff_elem)->ipp_ff_elem);
- }
- SAFE_FREE(*ff_elem);
- }
-}
-
-EpidStatus ReadFfElement(FiniteField* ff, void const* ff_elem_str,
- size_t strlen, FfElement* ff_elem) {
- IppStatus sts;
- int ipp_str_size = (int)strlen;
-
- if (!ff || !ff_elem_str || !ff_elem) {
- return kEpidBadArgErr;
- }
- if (!ff_elem->ipp_ff_elem || !ff->ipp_ff) {
- return kEpidBadArgErr;
- }
-
- if (ipp_str_size <= 0) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != ff_elem->info.elementLen) {
- return kEpidBadArgErr;
- }
- sts = ippsGFpSetElementOctString(ff_elem_str, ipp_str_size,
- ff_elem->ipp_ff_elem, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsOutOfRangeErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
-
- return kEpidNoErr;
-}
-
-EpidStatus WriteFfElement(FiniteField* ff, FfElement const* ff_elem,
- void* ff_elem_str, size_t strlen) {
- IppStatus sts;
- IppsGFpInfo info;
-
- if (!ff || !ff_elem_str || !ff_elem) {
- return kEpidBadArgErr;
- }
- if (!ff_elem->ipp_ff_elem || !ff->ipp_ff) {
- return kEpidBadArgErr;
- }
- if (INT_MAX < strlen) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != ff_elem->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- // check that ippsGFpGetElementOctString does not truncate to fit the
- // buffer
- sts = ippsGFpGetInfo(ff->ipp_ff, &info);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- if (info.elementLen * sizeof(Ipp32u) > strlen) return kEpidBadArgErr;
-
- // get the data
- sts = ippsGFpGetElementOctString(ff_elem->ipp_ff_elem, ff_elem_str,
- (int)strlen, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
-
- return kEpidNoErr;
-}
-
-EpidStatus FfNeg(FiniteField* ff, FfElement const* a, FfElement* r) {
- IppStatus sts = ippStsNoErr;
- if (!ff || !a || !r) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != r->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- sts = ippsGFpNeg(a->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- return kEpidNoErr;
-}
-
-EpidStatus FfInv(FiniteField* ff, FfElement const* a, FfElement* r) {
- IppStatus sts = ippStsNoErr;
- // Check required parametersWriteFfElement
- if (!ff || !a || !r) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != r->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- // Invert the element
- sts = ippsGFpInv(a->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff);
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- return kEpidBadArgErr;
- else if (ippStsDivByZeroErr == sts)
- return kEpidDivByZeroErr;
- else
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus FfAdd(FiniteField* ff, FfElement const* a, FfElement const* b,
- FfElement* r) {
- IppStatus sts = ippStsNoErr;
- if (!ff || !a || !b || !r) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem ||
- !r->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != b->info.elementLen ||
- ff->info.elementLen != r->info.elementLen ||
- a->info.elementLen != b->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsGFpAdd(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff);
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else if (ippStsNoErr != sts) {
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus FfMul(FiniteField* ff, FfElement const* a, FfElement const* b,
- FfElement* r) {
- IppStatus sts = ippStsNoErr;
- // Check required parametersWriteFfElement
- if (!ff || !a || !b || !r) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem ||
- !r->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- // Multiplies elements
- if (a->info.elementLen != b->info.elementLen &&
- a->info.elementLen == a->info.groundGFdegree * b->info.elementLen) {
- sts = ippsGFpMul_GFpE(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem,
- ff->ipp_ff);
- } else {
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != b->info.elementLen ||
- ff->info.elementLen != r->info.elementLen ||
- a->info.elementLen != b->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- sts =
- ippsGFpMul(a->ipp_ff_elem, b->ipp_ff_elem, r->ipp_ff_elem, ff->ipp_ff);
- }
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
- return kEpidNoErr;
-}
-
-EpidStatus FfIsZero(FiniteField* ff, FfElement const* a, bool* is_zero) {
- IppStatus sts = ippStsNoErr;
- int ipp_result = IPP_IS_NE;
- // Check required parameters
- if (!ff || !a || !is_zero) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != a->info.elementLen) {
- return kEpidBadArgErr;
- }
- // Check if the element is zero
- sts = ippsGFpIsZeroElement(a->ipp_ff_elem, &ipp_result, ff->ipp_ff);
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts)
- return kEpidBadArgErr;
- else
- return kEpidMathErr;
- }
- if (IPP_IS_EQ == ipp_result) {
- *is_zero = true;
- } else {
- *is_zero = false;
- }
- return kEpidNoErr;
-}
-
-EpidStatus FfExp(FiniteField* ff, FfElement const* a, BigNum const* b,
- FfElement* r) {
- EpidStatus result = kEpidErr;
- Ipp8u* scratch_buffer = NULL;
- int exp_bit_size = 0;
- int element_size = 0;
-
- do {
- IppStatus sts = ippStsNoErr;
- // Check required parameters
- if (!ff || !a || !b || !r) {
- result = kEpidBadArgErr;
- break;
- } else if (!ff->ipp_ff || !a->ipp_ff_elem || !r->ipp_ff_elem) {
- result = kEpidBadArgErr;
- break;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != r->info.elementLen ||
- a->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsRef_BN(0, &exp_bit_size, 0, b->ipp_bn);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
-
- sts = ippsGFpScratchBufferSize(1, exp_bit_size, ff->ipp_ff, &element_size);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
-
- scratch_buffer = (Ipp8u*)SAFE_ALLOC(element_size);
- if (!scratch_buffer) {
- result = kEpidMemAllocErr;
- break;
- }
-
- sts = ippsGFpExp(a->ipp_ff_elem, b->ipp_bn, r->ipp_ff_elem, ff->ipp_ff,
- scratch_buffer);
- // Check return codes
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- result = kEpidNoErr;
- } while (0);
- SAFE_FREE(scratch_buffer);
- return result;
-}
-
-EpidStatus FfMultiExp(FiniteField* ff, FfElement const** p, BigNumStr const** b,
- size_t m, FfElement* r) {
- EpidStatus result = kEpidErr;
- IppsGFpElement** ipp_p = NULL;
- IppsBigNumState** ipp_b = NULL;
- BigNum** bignums = NULL;
- Ipp8u* scratch_buffer = NULL;
- int i = 0;
- int ipp_m = 0;
-
- // Check required parameters
- if (!ff || !p || !b || !r) {
- return kEpidBadArgErr;
- } else if (!ff->ipp_ff || !r->ipp_ff_elem || m <= 0) {
- return kEpidBadArgErr;
- }
- // because we use ipp function with number of items parameter
- // defined as "int" we need to verify that input length
- // do not exceed INT_MAX to avoid overflow
- if (m > INT_MAX) {
- return kEpidBadArgErr;
- }
- ipp_m = (int)m;
-
- for (i = 0; i < ipp_m; i++) {
- if (!p[i]) {
- return kEpidBadArgErr;
- }
- if (!p[i]->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != p[i]->info.elementLen) {
- return kEpidBadArgErr;
- }
- }
- if (ff->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- do {
- IppStatus sts = ippStsNoErr;
- int scratch_buffer_size = 0;
- const int exp_bit_size = CHAR_BIT * sizeof(BigNumStr);
-
- // Allocate memory for finite field elements for ipp call
- ipp_p = (IppsGFpElement**)SAFE_ALLOC(ipp_m * sizeof(IppsGFpElement*));
- if (!ipp_p) {
- result = kEpidMemAllocErr;
- break;
- }
- for (i = 0; i < ipp_m; i++) {
- ipp_p[i] = p[i]->ipp_ff_elem;
- }
-
- // Create big number elements for ipp call
- // Allocate memory for finite field elements for ipp call
- bignums = (BigNum**)SAFE_ALLOC(ipp_m * sizeof(BigNum*));
- if (!bignums) {
- result = kEpidMemAllocErr;
- break;
- }
- ipp_b = (IppsBigNumState**)SAFE_ALLOC(ipp_m * sizeof(IppsBigNumState*));
- if (!ipp_b) {
- result = kEpidMemAllocErr;
- break;
- }
- // Initialize BigNum and fill ipp array for ipp call
- for (i = 0; i < ipp_m; i++) {
- result = NewBigNum(sizeof(BigNumStr), &bignums[i]);
- if (kEpidNoErr != result) break;
- result = ReadBigNum(b[i], sizeof(BigNumStr), bignums[i]);
- if (kEpidNoErr != result) break;
- ipp_b[i] = bignums[i]->ipp_bn;
- }
- if (kEpidNoErr != result) break;
-
- // calculate scratch buffer size
- sts = ippsGFpScratchBufferSize(ipp_m, exp_bit_size, ff->ipp_ff,
- &scratch_buffer_size);
- if (sts != ippStsNoErr) {
- result = kEpidMathErr;
- break;
- }
- // allocate memory for scratch buffer
- scratch_buffer = (Ipp8u*)SAFE_ALLOC(scratch_buffer_size);
- if (!scratch_buffer) {
- result = kEpidMemAllocErr;
- break;
- }
-
- sts = ippsGFpMultiExp((const IppsGFpElement* const*)ipp_p,
- (const IppsBigNumState* const*)ipp_b, ipp_m,
- r->ipp_ff_elem, ff->ipp_ff, scratch_buffer);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsRangeErr == sts)
- result = kEpidBadArgErr;
- else
- result = kEpidMathErr;
- break;
- }
- result = kEpidNoErr;
- } while (0);
- if (NULL != bignums) { // delete big nums only if it was really allocated
- for (i = 0; i < ipp_m; i++) {
- DeleteBigNum(&bignums[i]);
- }
- }
- SAFE_FREE(bignums);
- SAFE_FREE(ipp_p);
- SAFE_FREE(ipp_b);
- SAFE_FREE(scratch_buffer);
- return result;
-}
-
-EpidStatus FfSscmMultiExp(FiniteField* ff, FfElement const** p,
- BigNumStr const** b, size_t m, FfElement* r) {
- // call EcMultiExp directly because its implementation is side channel
- // mitigated already
- return FfMultiExp(ff, p, b, m, r);
-}
-
-EpidStatus FfIsEqual(FiniteField* ff, FfElement const* a, FfElement const* b,
- bool* is_equal) {
- IppStatus sts;
- int result;
-
- if (!ff || !a || !b || !is_equal) {
- return kEpidBadArgErr;
- }
- if (!ff->ipp_ff || !a->ipp_ff_elem || !b->ipp_ff_elem) {
- return kEpidBadArgErr;
- }
- if (ff->info.elementLen != a->info.elementLen ||
- ff->info.elementLen != b->info.elementLen ||
- a->info.elementLen != b->info.elementLen) {
- return kEpidBadArgErr;
- }
-
- sts = ippsGFpCmpElement(a->ipp_ff_elem, b->ipp_ff_elem, &result, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- *is_equal = IPP_IS_EQ == result;
-
- return kEpidNoErr;
-}
-
-EpidStatus FfHash(FiniteField* ff, void const* msg, size_t msg_len,
- HashAlg hash_alg, FfElement* r) {
- EpidStatus result = kEpidErr;
- do {
- IppStatus sts = ippStsNoErr;
- IppHashID hash_id;
- int ipp_msg_len = 0;
- if (!ff || !msg || !r) {
- result = kEpidBadArgErr;
- break;
- } else if (!ff->ipp_ff || !r->ipp_ff_elem || msg_len <= 0) {
- result = kEpidBadArgErr;
- break;
- }
- // because we use ipp function with message length parameter
- // defined as "int" we need to verify that input length
- // do not exceed INT_MAX to avoid overflow
- if (msg_len > INT_MAX) {
- result = kEpidBadArgErr;
- break;
- }
- ipp_msg_len = (int)msg_len;
-
- if (kSha256 == hash_alg) {
- hash_id = ippSHA256;
- } else if (kSha384 == hash_alg) {
- hash_id = ippSHA384;
- } else if (kSha512 == hash_alg) {
- hash_id = ippSHA512;
- } else {
- result = kEpidHashAlgorithmNotSupported;
- break;
- }
- if (ff->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- sts = ippsGFpSetElementHash(msg, ipp_msg_len, hash_id, r->ipp_ff_elem,
- ff->ipp_ff);
- if (ippStsNoErr != sts) {
- if (ippStsContextMatchErr == sts || ippStsBadArgErr == sts ||
- ippStsLengthErr == sts) {
- return kEpidBadArgErr;
- } else {
- return kEpidMathErr;
- }
- }
- result = kEpidNoErr;
- } while (0);
- return result;
-}
-
-/// Number of tries for RNG
-#define RNG_WATCHDOG (10)
-EpidStatus FfGetRandom(FiniteField* ff, BigNumStr const* low_bound,
- BitSupplier rnd_func, void* rnd_param, FfElement* r) {
- EpidStatus result = kEpidErr;
- IppsGFpElement* low = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- unsigned int ctxsize = 0;
- unsigned int rngloopCount = RNG_WATCHDOG;
- Ipp32u bnu_low_bound[sizeof(BigNumStr) / sizeof(Ipp32u)];
- int bnu_size;
- if (!ff || !low_bound || !rnd_func || !r) {
- result = kEpidBadArgErr;
- break;
- }
- if (!ff->ipp_ff || !r->ipp_ff_elem) {
- result = kEpidBadArgErr;
- break;
- }
- if (ff->info.elementLen != r->info.elementLen) {
- return kEpidBadArgErr;
- }
- // create a new FfElement to hold low_bound
- sts = ippsGFpElementGetSize(ff->ipp_ff, (int*)&ctxsize);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- // Allocate space for ipp Ff Element context
- low = (IppsGFpElement*)SAFE_ALLOC(ctxsize);
- if (!low) {
- result = kEpidMemAllocErr;
- break;
- }
- bnu_size = OctStr2Bnu(bnu_low_bound, low_bound, sizeof(*low_bound));
- if (bnu_size < 0) {
- result = kEpidMathErr;
- break;
- }
- // initialize state
- sts = ippsGFpElementInit(bnu_low_bound, bnu_size, low, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- do {
- int cmpResult = IPP_IS_NE;
- sts = ippsGFpSetElementRandom((IppBitSupplier)rnd_func, rnd_param,
- r->ipp_ff_elem, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- sts = ippsGFpCmpElement(r->ipp_ff_elem, low, &cmpResult, ff->ipp_ff);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
- if (IPP_IS_LT != cmpResult) {
- // we have a valid value, proceed
- result = kEpidNoErr;
- break;
- } else {
- result = kEpidRandMaxIterErr;
- continue;
- }
- } while (--rngloopCount);
- } while (0);
- SAFE_FREE(low);
- return result;
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.h
deleted file mode 100644
index 91871dabde..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/finitefield.h
+++ /dev/null
@@ -1,403 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Finite field interface.
- */
-
-#ifndef EPID_COMMON_MATH_FINITEFIELD_H_
-#define EPID_COMMON_MATH_FINITEFIELD_H_
-
-#include "epid/common/stdtypes.h"
-#include "epid/common/bitsupplier.h"
-#include "epid/common/errors.h"
-#include "epid/common/math/bignum.h"
-#include "epid/common/types.h"
-
-/// Finite field operations
-/*!
-\defgroup FiniteFieldPrimitives finitefield
-provides APIs for working with finite fields.
-Finite fields allow simple mathematical operations based on a finite set of
-discrete values. the results of these operations are also contained in the
-same set.
-
-A simple example of a finite field is all integers from zero that are less than
-a given value.
-
-The elements (::FfElement) of a finite field can be used in a variety of
-simple mathematical operations that result in elements of the same field.
-
-\ingroup EpidMath
-@{
-*/
-
-/// A finite field.
-typedef struct FiniteField FiniteField;
-
-/// An element in a finite field.
-typedef struct FfElement FfElement;
-
-/// Creates new finite field.
-/*!
- Allocates memory and creates a new finite field GF(prime).
-
- Use DeleteFiniteField() to free memory.
-
- \param[in] prime
- The order of finite field.
- \param[out] ff
- The Newly constructed finite field.
-
- \returns ::EpidStatus
-
- \see DeleteFiniteField
-*/
-EpidStatus NewFiniteField(BigNumStr const* prime, FiniteField** ff);
-
-/// Creates a new finite field using binomial extension.
-/*!
- Allocates memory and creates a finite field using binomial extension.
-
- Use DeleteFiniteField() to free memory.
-
- \param[in] ground_field
- The ground field.
- \param[in] ground_element
- The low-order term of the extension.
- \param[in] degree
- The degree of the extension.
- \param[out] ff
- The Newly constructed finite field.
-
- \returns ::EpidStatus
-
- \see DeleteFiniteField
-*/
-EpidStatus NewFiniteFieldViaBinomalExtension(FiniteField const* ground_field,
- FfElement const* ground_element,
- int degree, FiniteField** ff);
-
-/// Frees a previously allocated FiniteField.
-/*!
- Frees memory pointed to by finite field. Nulls the pointer.
-
- \param[in] ff
- The Finite field. Can be NULL.
-
- \see NewFiniteField
-*/
-void DeleteFiniteField(FiniteField** ff);
-
-/// Creates a new finite field element.
-/*!
- Allocates memory and creates a new finite field
- element.
-
- Use DeleteFfElement() to free memory.
-
- \param[in] ff
- The finite field.
- \param[out] new_ff_elem
-The Newly constructed finite field element.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see DeleteFfElement
- */
-EpidStatus NewFfElement(FiniteField const* ff, FfElement** new_ff_elem);
-
-/// Frees a previously allocated FfElement.
-/*!
- Frees memory pointed to by ff_elem. Nulls the pointer.
-
- \param[in] ff_elem
- The finite field element. Can be NULL.
-
- \see NewFfElement
-*/
-void DeleteFfElement(FfElement** ff_elem);
-
-/// Deserializes a FfElement from a string.
-/*!
- \param[in] ff
- The the finite field.
- \param[in] ff_elem_str
- The serialized value.
- \param[in] strlen
- The size of ff_elem_str in bytes.
- \param[out] ff_elem
- the target FfElement.
-
- \returns ::EpidStatus
-
- \see NewFfElement
- \see WriteFfElement
-*/
-EpidStatus ReadFfElement(FiniteField* ff, void const* ff_elem_str,
- size_t strlen, FfElement* ff_elem);
-
-/// Serializes a finite field element to a string.
-/*!
- \param[in] ff
- The finite field.
- \param[in] ff_elem
- The FfElement to be serialized.
- \param[out] ff_elem_str
- The target string.
- \param[in] strlen
- The size of ff_elem_str in bytes.
-
- \returns ::EpidStatus
-
- \see NewFfElement
- \see FpElemStr
- \see FqElemStr
- \see GtElemStr
-*/
-EpidStatus WriteFfElement(FiniteField* ff, FfElement const* ff_elem,
- void* ff_elem_str, size_t strlen);
-
-/// Calculates the additive inverse of a finite field element.
-/*!
- \param[in] ff
- The finite field.
- \param[in] a
- The element.
- \param[out] r
- The inverted element.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfNeg(FiniteField* ff, FfElement const* a, FfElement* r);
-
-/// Calculates the multiplicative inverse of a finite field element.
-/*!
- \param[in] ff
- The finite field.
- \param[in] a
- The element.
- \param[out] r
- The inverted element.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfInv(FiniteField* ff, FfElement const* a, FfElement* r);
-
-/// Adds two finite field elements.
-/*!
- \param[in] ff
- The finite field.
- \param[out] a
- The left hand parameter.
- \param[out] b
- The right hand parameter.
- \param[out] r
- The result of adding a and b.
-
- \returns ::EpidStatus
- */
-EpidStatus FfAdd(FiniteField* ff, FfElement const* a, FfElement const* b,
- FfElement* r);
-
-/// Multiplies two finite field elements.
-/*!
- \param[in] ff
- The finite field.
- \param[out] a
- The left hand parameter.
- \param[out] b
- The right hand parameter. If ff is an extension field of a field F then
- this parameter may be an element of either ff or F.
- \param[out] r
- The result of multiplying a and b.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfMul(FiniteField* ff, FfElement const* a, FfElement const* b,
- FfElement* r);
-
-/// Checks if given finite field element is the additive identity (zero).
-/*!
- \param[in] ff
- The finite field.
- \param[out] a
- The element.
- \param[out] is_zero
- The result of the check.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfIsZero(FiniteField* ff, FfElement const* a, bool* is_zero);
-
-/// Raises an element of a finite field to a power.
-/*!
- \param[in] ff
- The finite field in which to perform the operation
- \param[in] a
- The base.
- \param[in] b
- The power.
- \param[out] r
- The result of raising a to the power b.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfExp(FiniteField* ff, FfElement const* a, BigNum const* b,
- FfElement* r);
-
-/// Multi-exponentiates finite field elements.
-/*!
- Calculates FfExp(p[0],b[0]) * ... * FfExp(p[m-1],b[m-1]) for m > 1
-
- \param[in] ff
- The finite field in which to perform the operation
- \param[in] a
- The bases.
- \param[in] b
- The powers.
- \param[in] m
- Number of entries in a and b.
- \param[out] r
- The result of raising each a to the corresponding power b and multiplying
- the results.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
-*/
-EpidStatus FfMultiExp(FiniteField* ff, FfElement const** a, BigNumStr const** b,
- size_t m, FfElement* r);
-
-/// Software side-channel mitigated implementation of FfMultiExp.
-/*!
- Calculates FfExp(p[0],b[0]) * ... * FfExp(p[m-1],b[m-1]) for m > 1
-
- \attention
- The reference implementation of FfSscmMultiExp calls FfMultiExp
- directly because the implementation of FfMultiExp is already side channel
- mitigated. Implementers providing their own versions of this function are
- responsible for ensuring that FfSscmMultiExp is side channel mitigated per
- section 8 of the Intel(R) EPID 2.0 spec.
-
- \param[in] ff
- The finite field in which to perform the operation.
- \param[in] a
- The bases.
- \param[in] b
- The powers.
- \param[in] m
- Number of entries in a and b.
- \param[out] r
- The result of raising each a to the corresponding power b and multiplying
- the results.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
-*/
-
-EpidStatus FfSscmMultiExp(FiniteField* ff, FfElement const** a,
- BigNumStr const** b, size_t m, FfElement* r);
-
-/// Checks if two finite field elements are equal.
-/*!
- \param[in] ff
- The finite field.
- \param[in] a
- An element to check.
- \param[in] b
- Another element to check.
- \param[out] is_equal
- The result of the check.
-
- \returns ::EpidStatus
-
- \see NewEcGroup
- \see NewEcPoint
- */
-EpidStatus FfIsEqual(FiniteField* ff, FfElement const* a, FfElement const* b,
- bool* is_equal);
-
-/// Hashes an arbitrary message to an element in a finite field.
-/*!
- \param[in] ff
- The finite field.
- \param[in] msg
- The message.
- \param[in] msg_len
- The size of msg in bytes.
- \param[in] hash_alg
- The hash algorithm.
- \param[out] r
- The hashed value.
-
- \returns ::EpidStatus
-
- \see NewFiniteField
- \see NewFfElement
- */
-EpidStatus FfHash(FiniteField* ff, void const* msg, size_t msg_len,
- HashAlg hash_alg, FfElement* r);
-
-/// Generate random finite field element.
-/*!
- \param[in] ff
- The finite field associated with the random finite field element.
- \param[in] low_bound
- Lower bound of the random finite field to be generated.
- \param[in] rnd_func
- Random number generator.
- \param[in] rnd_param
- Pass through context data for rnd_func.
- \param[in,out] r
- The random finite field element.
-
- \returns ::EpidStatus
-
- \retval ::kEpidRandMaxIterErr the function should be called again with
- different random data.
-
- \see NewFfElement
- \see BitSupplier
- */
-EpidStatus FfGetRandom(FiniteField* ff, BigNumStr const* low_bound,
- BitSupplier rnd_func, void* rnd_param, FfElement* r);
-
-/*!
- @}
-*/
-
-#endif // EPID_COMMON_MATH_FINITEFIELD_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/hash.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/hash.h
deleted file mode 100644
index 30e8e2009f..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/hash.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Hash primitives.
- */
-
-#ifndef EPID_COMMON_MATH_HASH_H_
-#define EPID_COMMON_MATH_HASH_H_
-
-#include
-#include
-#include // for CHAR_BIT
-#include "epid/common/errors.h"
-
-/// Hash primitives
-/*!
- \defgroup HashPrimitives hash
- Provides APIs for computing digests of messages.
-
- \ingroup EpidMath
- @{
-*/
-
-#pragma pack(1)
-/// SHA256 digest
-typedef struct Sha256Digest {
- unsigned char data[256 / CHAR_BIT]; ///< 256 bit data
-} Sha256Digest;
-#pragma pack()
-
-/// Computes SHA256 digest of a message.
-/*!
- \param[in] msg
- Message to compute digest for.
- \param[in] len
- The size of msg in bytes.
- \param[out] digest
- The resulting message digest.
-
- \returns ::EpidStatus
-*/
-EpidStatus Sha256MessageDigest(void const* msg, size_t len,
- Sha256Digest* digest);
-
-/*!
- @}
-*/
-#endif // EPID_COMMON_MATH_HASH_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing-internal.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing-internal.h
deleted file mode 100644
index f48b19c892..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing-internal.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Pairing private interface.
- */
-
-#ifndef EPID_COMMON_MATH_PAIRING_INTERNAL_H_
-#define EPID_COMMON_MATH_PAIRING_INTERNAL_H_
-
-/// Pairing State
-struct PairingState {
- EcGroup* ga; ///< elliptic curve group G1
- EcGroup* gb; ///< elliptic curve group G1
- FiniteField* ff; ///< finite field Fq12 GT
- BigNum* t; ///< positive integer such that 6t^2 = p-q, where p and q are
- /// parameters of G1
- bool neg; ///< 8-bit integer representing a Boolean value
- FfElement* g[3][5]; ///< 15 elements in Fq2
- FiniteField Fq; ///< Fq
- FiniteField Fq2; ///< Fq2
- FiniteField Fq6; ///< Fq6
-};
-
-#endif // EPID_COMMON_MATH_PAIRING_INTERNAL_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.c
deleted file mode 100644
index 339d711910..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.c
+++ /dev/null
@@ -1,2381 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Pairing implementation.
- */
-
-#include
-#include "epid/common/math/pairing.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/math/finitefield-internal.h"
-#include "epid/common/math/ecgroup-internal.h"
-#include "epid/common/math/pairing-internal.h"
-#include "epid/common/memory.h"
-#include "ext/ipp/include/ippcp.h"
-#include "ext/ipp/include/ippcpepid.h"
-
-/// Handle Ipp Errors with Break
-#define BREAK_ON_IPP_ERROR(sts, ret) \
- { \
- IppStatus temp_sts = (sts); \
- if (ippStsNoErr != temp_sts) { \
- if (ippStsContextMatchErr == temp_sts) { \
- (ret) = kEpidMathErr; \
- } else { \
- (ret) = kEpidBadArgErr; \
- } \
- break; \
- } \
- }
-/// Handle Ipp Errors with Return
-#define RETURN_ON_IPP_ERROR(sts) \
- { \
- IppStatus temp_sts = (sts); \
- if (ippStsNoErr != temp_sts) { \
- if (ippStsContextMatchErr == temp_sts) { \
- return kEpidMathErr; \
- } else { \
- return kEpidBadArgErr; \
- } \
- } \
- }
-/// Handle SDK Error with Break
-#define BREAK_ON_EPID_ERROR(ret) \
- if (kEpidNoErr != (ret)) { \
- break; \
- }
-
-#pragma pack(1)
-/// Data for element in Fq
-typedef struct FqElemDat {
- Ipp32u x[sizeof(FqElemStr) / sizeof(Ipp32u)]; ///< element in Fq
-} FqElemDat;
-/// Data for element in Fq2
-typedef struct Fq2ElemDat {
- FqElemDat x[2]; ///< element in Fq2
-} Fq2ElemDat;
-/// Data for element in Fq2^3
-typedef struct Fq6ElemDat {
- Fq2ElemDat x[3]; ///< element in Fq6
-} Fq6ElemDat;
-/// Data for element in Fq2^3^2
-typedef struct Fq12ElemDat {
- Fq6ElemDat x[2]; ///< element in Fq12
-} Fq12ElemDat;
-#pragma pack()
-
-// Forward Declarations
-static EpidStatus FinalExp(PairingState* ps, FfElement* d, FfElement const* h);
-
-static EpidStatus PiOp(PairingState* ps, FfElement* x_out, FfElement* y_out,
- FfElement const* x, FfElement const* y, const int e);
-
-static EpidStatus FrobeniusOp(PairingState* ps, FfElement* d_out,
- FfElement const* a, const int e);
-
-static EpidStatus Line(FiniteField* gt, FfElement* f, FfElement* x_out,
- FfElement* y_out, FfElement* z_out, FfElement* z2_out,
- FfElement const* px, FfElement const* py,
- FfElement const* x, FfElement const* y,
- FfElement const* z, FfElement const* z2,
- FfElement const* qx, FfElement const* qy);
-
-static EpidStatus Tangent(FiniteField* gt, FfElement* f, FfElement* x_out,
- FfElement* y_out, FfElement* z_out, FfElement* z2_out,
- FfElement const* px, FfElement const* py,
- FfElement const* x, FfElement const* y,
- FfElement const* z, FfElement const* z2);
-
-static EpidStatus Ternary(int* s, int* n, int max_elements, BigNum const* x);
-
-static int Bit(Ipp32u const* num, Ipp32u bit_index);
-
-static EpidStatus MulXiFast(FfElement* e, FfElement const* a, PairingState* ps);
-
-static EpidStatus MulV(FfElement* e, FfElement* a, PairingState* ps);
-
-static EpidStatus Fq6MulGFpE2(FfElement* e, FfElement* a, FfElement* b0,
- FfElement* b1, PairingState* ps);
-
-static EpidStatus MulSpecial(FfElement* e, FfElement const* a,
- FfElement const* b, PairingState* ps);
-
-static EpidStatus SquareCyclotomic(PairingState* ps, FfElement* e_out,
- FfElement const* a_in);
-
-static EpidStatus ExpCyclotomic(PairingState* ps, FfElement* e,
- FfElement const* a, BigNum const* b);
-
-// Implementation
-
-EpidStatus NewPairingState(EcGroup const* ga, EcGroup const* gb,
- FiniteField* ff, BigNumStr const* t, bool neg,
- PairingState** ps) {
- EpidStatus result = kEpidErr;
- FfElement* xi = NULL;
- PairingState* paring_state_ctx = NULL;
- BigNum* e = NULL;
- BigNum* one = NULL;
- BigNum* q = NULL;
- BigNum* six = NULL;
- Ipp8u* scratch_buffer = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- IppsGFpState* Fq6 = NULL;
- IppsGFpState* Fq2 = NULL;
- IppsGFpState* Fq = NULL;
- FiniteField Ffq2;
- IppsGFpInfo info = {0};
- Fq2ElemDat Fq6IrrPolynomial[3 + 1] = {0};
- uint8_t one_str[] = {1};
- uint8_t six_str[] = {6};
- FqElemDat qDat = {0};
- int i = 0;
- int j = 0;
- int bufferSize = 0;
- int bitSize = 0;
- // validate inputs
- if (!ga || !gb || !ff || !t || !ps) {
- result = kEpidBadArgErr;
- break;
- }
- if (!ga->ipp_ec || !gb->ipp_ec || !ff->ipp_ff) {
- result = kEpidBadArgErr;
- break;
- }
- // get Fq6, Fq2, Fq
- sts = ippsGFpGetInfo(ff->ipp_ff, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq6 = (IppsGFpState*)info.pGroundGF;
- sts = ippsGFpGetInfo(Fq6, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq2 = (IppsGFpState*)info.pGroundGF;
- result = InitFiniteFieldFromIpp(Fq2, &Ffq2);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpGetInfo(Fq2, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq = (IppsGFpState*)info.pGroundGF;
- // now get ref to modulus of Fq
- sts = ippsGFpGetModulus(Fq, (Ipp32u*)&qDat);
- BREAK_ON_IPP_ERROR(sts, result);
- // extract xi from Fq6 irr poly
- result = NewFfElement(&Ffq2, &xi);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpGetModulus(Fq6, (Ipp32u*)&Fq6IrrPolynomial[0]);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u const*)&Fq6IrrPolynomial[0],
- sizeof(Fq6IrrPolynomial[0]) / sizeof(Ipp32u),
- xi->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // first coefficent is -xi
- sts = ippsGFpNeg(xi->ipp_ff_elem, xi->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
-
- paring_state_ctx = (PairingState*)SAFE_ALLOC(sizeof(PairingState));
- if (!paring_state_ctx) {
- result = kEpidMemAllocErr;
- break;
- }
-
- // 1. Set param(pairing) = (param(G1), param(G2), param(GT), t, neg)
- paring_state_ctx->ga = (EcGroup*)ga;
- paring_state_ctx->gb = (EcGroup*)gb;
- paring_state_ctx->ff = ff;
- result = NewBigNum(sizeof(BigNumStr), &paring_state_ctx->t);
- BREAK_ON_EPID_ERROR(result);
- result = ReadBigNum(t, sizeof(BigNumStr), paring_state_ctx->t);
- BREAK_ON_EPID_ERROR(result);
- paring_state_ctx->neg = neg;
- result = InitFiniteFieldFromIpp(Fq6, &(paring_state_ctx->Fq6));
- BREAK_ON_EPID_ERROR(result);
- result = InitFiniteFieldFromIpp(Fq2, &(paring_state_ctx->Fq2));
- BREAK_ON_EPID_ERROR(result);
- result = InitFiniteFieldFromIpp(Fq, &(paring_state_ctx->Fq));
- BREAK_ON_EPID_ERROR(result);
- // 2. Let g[0][0], ..., g[0][4], g[1][0], ..., g[1][4], g[2][0], ...,
- // g[2][4] be 15 elements in Fq2.
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 5; j++) {
- result = NewFfElement(&Ffq2, &paring_state_ctx->g[i][j]);
- BREAK_ON_EPID_ERROR(result);
- }
- }
- // 3. Compute a big integer e = (q - 1)/6.
- result = NewBigNum(sizeof(BigNumStr), &one);
- BREAK_ON_EPID_ERROR(result);
- result = ReadBigNum(one_str, sizeof(one_str), one);
- BREAK_ON_EPID_ERROR(result);
- result = NewBigNum(sizeof(BigNumStr), &q);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsSet_BN(IppsBigNumPOS, sizeof(qDat) / sizeof(Ipp32u),
- (Ipp32u*)&qDat, q->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- result = NewBigNum(sizeof(BigNumStr), &e);
- BREAK_ON_EPID_ERROR(result);
- // q - 1
- sts = ippsSub_BN(q->ipp_bn, one->ipp_bn, e->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- result = NewBigNum(sizeof(BigNumStr), &six);
- BREAK_ON_EPID_ERROR(result);
- result = ReadBigNum(six_str, sizeof(six_str), six);
- BREAK_ON_EPID_ERROR(result);
- // e = (q - 1)/6
- // reusing one as remainder here
- sts = ippsDiv_BN(e->ipp_bn, six->ipp_bn, e->ipp_bn, one->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Compute g[0][0] = Fq2.exp(xi, e).
- sts = ippsRef_BN(0, &bitSize, 0, e->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpScratchBufferSize(1, bitSize, Fq2, &bufferSize);
- BREAK_ON_IPP_ERROR(sts, result);
- scratch_buffer = (Ipp8u*)SAFE_ALLOC(bufferSize);
- if (!scratch_buffer) {
- result = kEpidMemAllocErr;
- break;
- }
- sts =
- ippsGFpExp(xi->ipp_ff_elem, e->ipp_bn,
- paring_state_ctx->g[0][0]->ipp_ff_elem, Fq2, scratch_buffer);
- BREAK_ON_IPP_ERROR(sts, result);
- // 5. For i = 0, ..., 4, compute
- for (i = 0; i < 5; i++) {
- // a. If i > 0, compute g[0][i] = Fq2.mul(g[0][i-1], g[0][0]).
- if (i > 0) {
- sts = ippsGFpMul(paring_state_ctx->g[0][i - 1]->ipp_ff_elem,
- paring_state_ctx->g[0][0]->ipp_ff_elem,
- paring_state_ctx->g[0][i]->ipp_ff_elem, Fq2);
- }
- // b. Compute g[1][i] = Fq2.conjugate(g[0][i]),
- sts = ippsGFpConj(paring_state_ctx->g[0][i]->ipp_ff_elem,
- paring_state_ctx->g[1][i]->ipp_ff_elem, Fq2);
- // c. Compute g[1][i] = Fq2.mul(g[0][i], g[1][i]),
- sts = ippsGFpMul(paring_state_ctx->g[0][i]->ipp_ff_elem,
- paring_state_ctx->g[1][i]->ipp_ff_elem,
- paring_state_ctx->g[1][i]->ipp_ff_elem, Fq2);
- // d. Compute g[2][i] = Fq2.mul(g[0][i], g[1][i]).
- sts = ippsGFpMul(paring_state_ctx->g[0][i]->ipp_ff_elem,
- paring_state_ctx->g[1][i]->ipp_ff_elem,
- paring_state_ctx->g[2][i]->ipp_ff_elem, Fq2);
- }
- // 6. Save g[0][0], ..., g[0][4], g[1][0], ..., g[1][4], g[2][0], ...,
- // g[2][4]
- // for the pairing operations.
- *ps = paring_state_ctx;
- result = kEpidNoErr;
- } while (0);
- SAFE_FREE(scratch_buffer)
- DeleteBigNum(&six);
- DeleteBigNum(&e);
- DeleteBigNum(&q);
- DeleteBigNum(&one);
- DeleteFfElement(&xi);
- if (kEpidNoErr != result) {
- if (paring_state_ctx) {
- int i = 0;
- int j = 0;
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 5; j++) {
- DeleteFfElement(&paring_state_ctx->g[i][j]);
- }
- }
- DeleteBigNum(&paring_state_ctx->t);
- SAFE_FREE(paring_state_ctx);
- }
- }
- return result;
-}
-
-void DeletePairingState(PairingState** ps) {
- if (!ps) {
- return;
- }
- if (!*ps) {
- return;
- }
- if (ps) {
- if (*ps) {
- int i = 0;
- int j = 0;
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 5; j++) {
- DeleteFfElement(&(*ps)->g[i][j]);
- }
- }
- DeleteBigNum(&(*ps)->t);
- (*ps)->ga = NULL;
- (*ps)->gb = NULL;
- (*ps)->ff = NULL;
- }
- SAFE_FREE(*ps);
- }
-}
-
-EpidStatus Pairing(PairingState* ps, FfElement* d, EcPoint const* a,
- EcPoint const* b) {
- EpidStatus result = kEpidErr;
- FfElement* ax = NULL;
- FfElement* ay = NULL;
- FfElement* bx = NULL;
- FfElement* by = NULL;
- FfElement* x = NULL;
- FfElement* y = NULL;
- FfElement* z = NULL;
- FfElement* z2 = NULL;
- FfElement* bx_ = NULL;
- FfElement* by_ = NULL;
- FfElement* f = NULL;
- BigNum* s = NULL;
- BigNum* two = NULL;
- BigNum* six = NULL;
- FfElement* neg_qy = NULL;
-
- do {
- IppStatus sts = ippStsNoErr;
- Ipp32u two_dat[] = {2};
- Ipp32u six_dat[] = {6};
- Ipp32u one_dat[] = {1};
- int s_ternary[sizeof(BigNumStr) * CHAR_BIT] = {0};
- int i = 0;
- int n = 0;
- // check parameters
- if (!ps || !d || !a || !b) {
- result = kEpidBadArgErr;
- break;
- }
- if (!d->ipp_ff_elem || !a->ipp_ec_pt || !b->ipp_ec_pt || !ps->ff ||
- !ps->ff->ipp_ff || !ps->Fq.ipp_ff || !ps->Fq2.ipp_ff || !ps->t ||
- !ps->t->ipp_bn || !ps->ga || !ps->ga->ipp_ec || !ps->gb ||
- !ps->gb->ipp_ec) {
- result = kEpidBadArgErr;
- break;
- }
- // Let ax, ay be elements in Fq. Let bx, by, x, y, z, z2, bx', by'
- // be elements in Fq2. Let f be a variable in GT.
- result = NewFfElement(&ps->Fq, &ax);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq, &ay);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &bx);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &by);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &x);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &y);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &z);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &z2);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &bx_);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &by_);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &f);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&ps->Fq2, &neg_qy);
- BREAK_ON_EPID_ERROR(result);
-
- // 1. If neg = 0, compute integer s = 6t + 2, otherwise, compute
- // s = 6t - 2
- result = NewBigNum(sizeof(BigNumStr), &s);
- BREAK_ON_EPID_ERROR(result);
- result = NewBigNum(sizeof(BigNumStr), &two);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsSet_BN(IppsBigNumPOS, sizeof(two_dat) / sizeof(Ipp32u), two_dat,
- two->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- result = NewBigNum(sizeof(BigNumStr), &six);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsSet_BN(IppsBigNumPOS, sizeof(six_dat) / sizeof(Ipp32u), six_dat,
- six->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsMul_BN(six->ipp_bn, ps->t->ipp_bn, s->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- if (ps->neg) {
- sts = ippsSub_BN(s->ipp_bn, two->ipp_bn, s->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- } else {
- sts = ippsAdd_BN(s->ipp_bn, two->ipp_bn, s->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 2. Let sn...s1s0 be the ternary representation of s, that is s =
- // s0 + 2*s1 + ... + 2^n*sn, where si is in {-1, 0, 1}.
- result =
- Ternary(s_ternary, &n, sizeof(s_ternary) / sizeof(s_ternary[0]), s);
- BREAK_ON_EPID_ERROR(result);
- // 3. Set (ax, ay) = E(Fq).outputPoint(a)
- sts = ippsGFpECGetPoint(a->ipp_ec_pt, ax->ipp_ff_elem, ay->ipp_ff_elem,
- ps->ga->ipp_ec);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Set (bx, by) = E(Fq2).outputPoint(b).
- sts = ippsGFpECGetPoint(b->ipp_ec_pt, bx->ipp_ff_elem, by->ipp_ff_elem,
- ps->gb->ipp_ec);
- BREAK_ON_IPP_ERROR(sts, result);
- // 5. Set X = bx, Y = by, Z = Z2 = 1.
- sts = ippsGFpCpyElement(bx->ipp_ff_elem, x->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpCpyElement(by->ipp_ff_elem, y->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement(one_dat, sizeof(one_dat) / sizeof(Ipp32u),
- z->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement(one_dat, sizeof(one_dat) / sizeof(Ipp32u),
- z2->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 6. Set d = 1.
- sts = ippsGFpSetElement(one_dat, sizeof(one_dat) / sizeof(Ipp32u),
- d->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 7. For i = n-1, ..., 0, do the following:
- for (i = n - 1; i >= 0; i--) {
- // a. Set (f, x, y, z, z2) = tangent(ax, ay, x, y, z, z2),
- result = Tangent(ps->ff, f, x, y, z, z2, ax, ay, x, y, z, z2);
- BREAK_ON_EPID_ERROR(result);
- // b. Set d = Fq12.square(d),
- sts = ippsGFpMul(d->ipp_ff_elem, d->ipp_ff_elem, d->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // c. Set d = Fq12.mulSpecial(d, f),
- result = MulSpecial(d, d, f, ps);
- BREAK_ON_EPID_ERROR(result);
- // d. If s[i] = -1 then
- if (-1 == s_ternary[i]) {
- // i. Set (f, x, y, z, z2) = line(ax, ay, x, y, z, z2, bx,
- // -by),
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpNeg(by->ipp_ff_elem, neg_qy->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- result = Line(ps->ff, f, x, y, z, z2, ax, ay, x, y, z, z2, bx, neg_qy);
- BREAK_ON_EPID_ERROR(result);
- // ii. Set d = Fq12.mulSpecial(d, f).
- result = MulSpecial(d, d, f, ps);
- BREAK_ON_EPID_ERROR(result);
- }
- // e. If s[i] = 1 then
- if (1 == s_ternary[i]) {
- // i. Set (f, x, y, z, z2) = line(ax, ay, x, y, z, z2, bx,
- // by),
- result = Line(ps->ff, f, x, y, z, z2, ax, ay, x, y, z, z2, bx, by);
- BREAK_ON_EPID_ERROR(result);
- // ii. Set d = Fq12.mulSpecial(d, f).
- result = MulSpecial(d, d, f, ps);
- BREAK_ON_EPID_ERROR(result);
- }
- }
-
- // 8. if neg = true,
- if (ps->neg) {
- // a. Set Y = Fq2.negate(y),
- sts = ippsGFpNeg(y->ipp_ff_elem, y->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // b. Set d = Fq12.conjugate(d).
- sts = ippsGFpConj(d->ipp_ff_elem, d->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 9. Set (bx', by') = Pi-op(bx, by, 1).
- result = PiOp(ps, bx_, by_, bx, by, 1);
- BREAK_ON_EPID_ERROR(result);
- // 10. Set (f, x, y, z, z2) = line(ax, ay, x, y, z, z2, bx', by').
- result = Line(ps->ff, f, x, y, z, z2, ax, ay, x, y, z, z2, bx_, by_);
- BREAK_ON_EPID_ERROR(result);
- // 11. Set d = Fq12.mulSpecial(d, f).
- result = MulSpecial(d, d, f, ps);
- BREAK_ON_EPID_ERROR(result);
- // 12. Set (bx', by') = piOp(bx, by, 2).
- result = PiOp(ps, bx_, by_, bx, by, 2);
- BREAK_ON_EPID_ERROR(result);
- // 13. Set by' = Fq2.negate(by').
- sts = ippsGFpNeg(by_->ipp_ff_elem, by_->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 14. Set (f, x, y, z, z2) = line(ax, ay, x, y, z, z2, bx', by').
- result = Line(ps->ff, f, x, y, z, z2, ax, ay, x, y, z, z2, bx_, by_);
- BREAK_ON_EPID_ERROR(result);
- // 15. Set d = Fq12.mulSpecial(d, f).
- result = MulSpecial(d, d, f, ps);
- BREAK_ON_EPID_ERROR(result);
- // 16. Set d = finalExp(d).
- result = FinalExp(ps, d, d);
- BREAK_ON_EPID_ERROR(result);
- // 17. Return d.
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&ax);
- DeleteFfElement(&ay);
- DeleteFfElement(&bx);
- DeleteFfElement(&by);
- DeleteFfElement(&x);
- DeleteFfElement(&y);
- DeleteFfElement(&z);
- DeleteFfElement(&z2);
- DeleteFfElement(&bx_);
- DeleteFfElement(&by_);
- DeleteFfElement(&f);
- DeleteFfElement(&neg_qy);
-
- DeleteBigNum(&s);
- DeleteBigNum(&two);
- DeleteBigNum(&six);
-
- return result;
-}
-
-/*
-d = finalExp(h)
-Input: h (an element in GT)
-Output: d (an element in GT) where d = GT.exp(h, (q^12-1)/p)
-*/
-static EpidStatus FinalExp(PairingState* ps, FfElement* d, FfElement const* h) {
- EpidStatus result = kEpidErr;
- FfElement* f = NULL;
- FfElement* f1 = NULL;
- FfElement* f2 = NULL;
- FfElement* f3 = NULL;
- FfElement* ft1 = NULL;
- FfElement* ft2 = NULL;
- FfElement* ft3 = NULL;
- FfElement* fp1 = NULL;
- FfElement* fp2 = NULL;
- FfElement* fp3 = NULL;
- FfElement* y0 = NULL;
- FfElement* y1 = NULL;
- FfElement* y2 = NULL;
- FfElement* y3 = NULL;
- FfElement* y4 = NULL;
- FfElement* y5 = NULL;
- FfElement* y6 = NULL;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- do {
- IppStatus sts = ippStsNoErr;
- // Check parameters
- if (!ps || !d || !h) {
- result = kEpidBadArgErr;
- break;
- }
- if (!d->ipp_ff_elem || !h->ipp_ff_elem || !ps->ff || !ps->ff->ipp_ff ||
- !ps->t || !ps->t->ipp_bn) {
- result = kEpidBadArgErr;
- break;
- }
- // Let f, f1, f2, f3, ft1, ft2, ft3, fp1, fp2, fp3, y0, y1, y2,
- // y3, y4, y5, y6, t0, t1 be temporary variables in GT. All the
- // following operations are computed in Fq12 unless explicitly
- // specified.
- result = NewFfElement(ps->ff, &f);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &f1);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &f2);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &f3);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &ft1);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &ft2);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &ft3);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &fp1);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &fp2);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &fp3);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y0);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y1);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y2);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y3);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y4);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y5);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &y6);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &t0);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(ps->ff, &t1);
- BREAK_ON_EPID_ERROR(result);
- // 1. Set f1 = Fq12.conjugate(h).
- sts = ippsGFpConj(h->ipp_ff_elem, f1->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Set f2 = Fq12.inverse(h).
- sts = ippsGFpInv(h->ipp_ff_elem, f2->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 3. Set f = f1 * f2.
- sts = ippsGFpMul(f1->ipp_ff_elem, f2->ipp_ff_elem, f->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Set f3 = frobeniusOp(f, 2).
- result = FrobeniusOp(ps, f3, f, 2);
- BREAK_ON_EPID_ERROR(result);
- // 5. Set f = f3 * f.
- sts = ippsGFpMul(f3->ipp_ff_elem, f->ipp_ff_elem, f->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 6. Set ft1 = Fq12.expCyclotomic (f, t).
- result = ExpCyclotomic(ps, ft1, f, ps->t);
- BREAK_ON_EPID_ERROR(result);
- // 7. If neg = true, ft1 = Fq12.conjugate(ft1).
- if (ps->neg) {
- sts = ippsGFpConj(ft1->ipp_ff_elem, ft1->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 8. Set ft2 = Fq12.expCyclotomic (ft1, t).
- result = ExpCyclotomic(ps, ft2, ft1, ps->t);
- BREAK_ON_EPID_ERROR(result);
- // 9. If neg = true, ft2 = Fq12.conjugate(ft2).
- if (ps->neg) {
- sts = ippsGFpConj(ft2->ipp_ff_elem, ft2->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 10. Set ft3 = Fq12.expCyclotomic (ft2, t).
- result = ExpCyclotomic(ps, ft3, ft2, ps->t);
- BREAK_ON_EPID_ERROR(result);
- // 11. If neg = true, ft3 = Fq12.conjugate(ft3).
- if (ps->neg) {
- sts = ippsGFpConj(ft3->ipp_ff_elem, ft3->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 12. Set fp1 = frobeniusOp(f, 1).
- result = FrobeniusOp(ps, fp1, f, 1);
- BREAK_ON_EPID_ERROR(result);
- // 13. Set fp2 = frobeniusOp(f, 2).
- result = FrobeniusOp(ps, fp2, f, 2);
- BREAK_ON_EPID_ERROR(result);
- // 14. Set fp3 = frobeniusOp(f, 3).
- result = FrobeniusOp(ps, fp3, f, 3);
- BREAK_ON_EPID_ERROR(result);
- // 15. Set y0 = fp1 * fp2 * fp3.
- sts = ippsGFpMul(fp1->ipp_ff_elem, fp2->ipp_ff_elem, y0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(y0->ipp_ff_elem, fp3->ipp_ff_elem, y0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 16. Set y1 = Fq12.conjugate(f).
- sts = ippsGFpConj(f->ipp_ff_elem, y1->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 17. Set y2 = frobeniusOp(ft2, 2).
- result = FrobeniusOp(ps, y2, ft2, 2);
- BREAK_ON_EPID_ERROR(result);
- // 18. Set y3 = frobeniusOp(ft1, 1).
- result = FrobeniusOp(ps, y3, ft1, 1);
- BREAK_ON_EPID_ERROR(result);
- // 19. Set y3 = Fq12.conjugate(y3).
- sts = ippsGFpConj(y3->ipp_ff_elem, y3->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 20. Set y4 = frobeniusOp(ft2, 1).
- result = FrobeniusOp(ps, y4, ft2, 1);
- BREAK_ON_EPID_ERROR(result);
- // 21. Set y4 = y4 * ft1.
- sts = ippsGFpMul(y4->ipp_ff_elem, ft1->ipp_ff_elem, y4->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 22. Set y4 = Fq12.conjugate(y4).
- sts = ippsGFpConj(y4->ipp_ff_elem, y4->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 23. Set y5 = Fq12.conjugate(ft2).
- sts = ippsGFpConj(ft2->ipp_ff_elem, y5->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 24. Set y6 = frobeniusOp(ft3, 1).
- result = FrobeniusOp(ps, y6, ft3, 1);
- BREAK_ON_EPID_ERROR(result);
- // 25. Set y6 = y6 * ft3.
- sts = ippsGFpMul(y6->ipp_ff_elem, ft3->ipp_ff_elem, y6->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 26. Set y6 = Fq12.conjugate(y6).
- sts = ippsGFpConj(y6->ipp_ff_elem, y6->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 27. Set t0 = Fq12.squareCyclotomic(y6).
- result = SquareCyclotomic(ps, t0, y6);
- BREAK_ON_EPID_ERROR(result);
- // 28. Set t0 = t0 * y4 * y5.
- sts = ippsGFpMul(t0->ipp_ff_elem, y4->ipp_ff_elem, t0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(t0->ipp_ff_elem, y5->ipp_ff_elem, t0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 29. Set t1 = y3 * y5 * t0.
- sts = ippsGFpMul(y3->ipp_ff_elem, y5->ipp_ff_elem, t1->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(t1->ipp_ff_elem, t0->ipp_ff_elem, t1->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 30. Set t0 = t0 * y2.
- sts = ippsGFpMul(t0->ipp_ff_elem, y2->ipp_ff_elem, t0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 31. Set t1 = Fq12.squareCyclotomic(t1).
- result = SquareCyclotomic(ps, t1, t1);
- BREAK_ON_EPID_ERROR(result);
- // 32. Set t1 = t1 * t0.
- sts = ippsGFpMul(t1->ipp_ff_elem, t0->ipp_ff_elem, t1->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 33. Set t1 = Fq12.squareCyclotomic(t1).
- result = SquareCyclotomic(ps, t1, t1);
- BREAK_ON_EPID_ERROR(result);
- // 34. Set t0 = t1 * y1.
- sts = ippsGFpMul(t1->ipp_ff_elem, y1->ipp_ff_elem, t0->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 35. Set t1 = t1 * y0.
- sts = ippsGFpMul(t1->ipp_ff_elem, y0->ipp_ff_elem, t1->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 36. Set t0 = Fq12.squareCyclotomic(t0).
- result = SquareCyclotomic(ps, t0, t0);
- BREAK_ON_EPID_ERROR(result);
- // 37. Set d = t1 * t0.
- sts = ippsGFpMul(t1->ipp_ff_elem, t0->ipp_ff_elem, d->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 38. Return d.
- result = kEpidNoErr;
- } while (0);
-
- DeleteFfElement(&f);
- DeleteFfElement(&f1);
- DeleteFfElement(&f2);
- DeleteFfElement(&f3);
- DeleteFfElement(&ft1);
- DeleteFfElement(&ft2);
- DeleteFfElement(&ft3);
- DeleteFfElement(&fp1);
- DeleteFfElement(&fp2);
- DeleteFfElement(&fp3);
- DeleteFfElement(&y0);
- DeleteFfElement(&y1);
- DeleteFfElement(&y2);
- DeleteFfElement(&y3);
- DeleteFfElement(&y4);
- DeleteFfElement(&y5);
- DeleteFfElement(&y6);
- DeleteFfElement(&t0);
- DeleteFfElement(&t1);
-
- return result;
-}
-
-/*
-(x', y') = piOp(x, y, e)
-Input: x, y (elements in Fq2), e (an integer of value 1 or 2)
-Output: x', y' (elements in Fq2)
-*/
-static EpidStatus PiOp(PairingState* ps, FfElement* x_out, FfElement* y_out,
- FfElement const* x, FfElement const* y, const int e) {
- IppStatus sts = ippStsNoErr;
- IppsGFpState* Fq2 = 0;
- IppsGFpState* Fq6 = 0;
- FiniteField* Fq12 = 0;
- IppsGFpInfo info = {0};
- // check parameters
- if (!ps || !x_out || !y_out || !x || !y) {
- return kEpidBadArgErr;
- }
- if (e < 1 || e > 3) {
- return kEpidBadArgErr;
- }
- Fq12 = ps->ff;
- // get Fq6, Fq2
- sts = ippsGFpGetInfo(Fq12->ipp_ff, &info);
- RETURN_ON_IPP_ERROR(sts);
- Fq6 = (IppsGFpState*)info.pGroundGF;
- sts = ippsGFpGetInfo(Fq6, &info);
- RETURN_ON_IPP_ERROR(sts);
- Fq2 = (IppsGFpState*)info.pGroundGF;
- // 1. Set x' = x and y' = y.
- sts = ippsGFpCpyElement(x->ipp_ff_elem, x_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- sts = ippsGFpCpyElement(y->ipp_ff_elem, y_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- if (1 == e) {
- // 2. If e = 1,
- // a. Compute x' = Fq2.conjugate(x').
- sts = ippsGFpConj(x_out->ipp_ff_elem, x_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- // b. Compute y' = Fq2.conjugate(y').
- sts = ippsGFpConj(y_out->ipp_ff_elem, y_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- }
- // 3. Compute x' = Fq2.mul(x', g[e-1][1]).
- sts = ippsGFpMul(x_out->ipp_ff_elem, ps->g[e - 1][1]->ipp_ff_elem,
- x_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- // 4. Compute y' = Fq2.mul(y', g[e-1][2]).
- sts = ippsGFpMul(y_out->ipp_ff_elem, ps->g[e - 1][2]->ipp_ff_elem,
- y_out->ipp_ff_elem, Fq2);
- RETURN_ON_IPP_ERROR(sts);
- // 5. Return (x', y').
- return kEpidNoErr;
-}
-
-/*
-d = frobeniusOp(a, e)
-Input: a (an element in GT), e (an integer of value 1, 2, or 3)
-Output: d (an element in GT) such that d = GT.exp(a, qe)
-
-*/
-static EpidStatus FrobeniusOp(PairingState* ps, FfElement* d_out,
- FfElement const* a, const int e) {
- EpidStatus result = kEpidErr;
- FfElement* d[6] = {0};
- size_t i = 0;
- Fq12ElemDat a_dat = {0};
- Fq12ElemDat d_dat = {0};
- do {
- IppStatus sts = ippStsNoErr;
- // check parameters
- if (!ps || !d_out || !a) {
- return kEpidBadArgErr;
- }
- if (e < 1 || e > 3 || !d_out->ipp_ff_elem || !a->ipp_ff_elem || !ps->ff ||
- !ps->ff->ipp_ff || !ps->Fq2.ipp_ff) {
- return kEpidBadArgErr;
- }
-
- for (i = 0; i < sizeof(d) / sizeof(FfElement*); i++) {
- result = NewFfElement(&ps->Fq2, &d[i]);
- BREAK_ON_EPID_ERROR(result);
- }
-
- // 1. Let a = ((a[0], a[2], a[4]), (a[1], a[3], a[5])).
- sts = ippsGFpGetElement(a->ipp_ff_elem, (Ipp32u*)&a_dat,
- sizeof(a_dat) / sizeof(Ipp32u), ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Let d = ((d[0], d[2], d[4]), (d[1], d[3], d[5])).
- // 3. For i = 0, ..., 5,
- // a. set d[i] = a[i].
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0].x[0],
- sizeof(a_dat.x[0].x[0]) / sizeof(Ipp32u),
- d[0]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0].x[1],
- sizeof(a_dat.x[0].x[1]) / sizeof(Ipp32u),
- d[2]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0].x[2],
- sizeof(a_dat.x[0].x[2]) / sizeof(Ipp32u),
- d[4]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1].x[0],
- sizeof(a_dat.x[1].x[0]) / sizeof(Ipp32u),
- d[1]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1].x[1],
- sizeof(a_dat.x[1].x[1]) / sizeof(Ipp32u),
- d[3]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1].x[2],
- sizeof(a_dat.x[1].x[2]) / sizeof(Ipp32u),
- d[5]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
-
- // b. If e = 1 or 3, set d[i] = Fq2.conjugate(d[i]).
- if (1 == e || 3 == e) {
- for (i = 0; i < sizeof(d) / sizeof(FfElement*); i++) {
- sts = ippsGFpConj(d[i]->ipp_ff_elem, d[i]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- }
- // 4. For i = 1, ..., 5, compute d[i] = Fq2.mul(d[i], g[e-1][i-1]).
- for (i = 1; i < sizeof(d) / sizeof(FfElement*); i++) {
- sts = ippsGFpMul(d[i]->ipp_ff_elem, ps->g[e - 1][i - 1]->ipp_ff_elem,
- d[i]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 5. Return d.
- sts = ippsGFpGetElement(d[0]->ipp_ff_elem, (Ipp32u*)&d_dat.x[0].x[0],
- sizeof(d_dat.x[0].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(d[2]->ipp_ff_elem, (Ipp32u*)&d_dat.x[0].x[1],
- sizeof(d_dat.x[0].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(d[4]->ipp_ff_elem, (Ipp32u*)&d_dat.x[0].x[2],
- sizeof(d_dat.x[0].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(d[1]->ipp_ff_elem, (Ipp32u*)&d_dat.x[1].x[0],
- sizeof(d_dat.x[1].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(d[3]->ipp_ff_elem, (Ipp32u*)&d_dat.x[1].x[1],
- sizeof(d_dat.x[1].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(d[5]->ipp_ff_elem, (Ipp32u*)&d_dat.x[1].x[2],
- sizeof(d_dat.x[1].x[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&d_dat, sizeof(d_dat) / sizeof(Ipp32u),
- d_out->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- result = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(&a_dat, sizeof(a_dat));
- EpidZeroMemory(&d_dat, sizeof(d_dat));
- for (i = 0; i < sizeof(d) / sizeof(FfElement*); i++) {
- DeleteFfElement(&d[i]);
- }
-
- return result;
-}
-
-/*
-(f, X', Y', Z', Z2') = line(Px, Py, X, Y, Z, Z2, Qx, Qy)
-Input: Px, Py (elements in Fq), X, Y, Z, Z2, Qx, Qy (elements in Fq2)
-Output: f (an element in GT), X', Y', Z', Z2' (elements in Fq2)
-*/
-static EpidStatus Line(FiniteField* gt, FfElement* f, FfElement* x_out,
- FfElement* y_out, FfElement* z_out, FfElement* z2_out,
- FfElement const* px, FfElement const* py,
- FfElement const* x, FfElement const* y,
- FfElement const* z, FfElement const* z2,
- FfElement const* qx, FfElement const* qy) {
- EpidStatus result = kEpidNotImpl;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- FfElement* t2 = NULL;
- FfElement* t3 = NULL;
- FfElement* t4 = NULL;
- FfElement* t5 = NULL;
- FfElement* t6 = NULL;
- FfElement* t7 = NULL;
- FfElement* t8 = NULL;
- FfElement* t9 = NULL;
- FfElement* t10 = NULL;
- FfElement* t = NULL;
- Fq12ElemDat fDat = {0};
- do {
- IppStatus sts = ippStsNoErr;
- IppsGFpState* Fq2 = 0;
- IppsGFpState* Fq6 = 0;
- IppsGFpInfo info = {0};
- FiniteField Ffq2;
-
- // check parameters
- if (!f || !x_out || !y_out || !z_out || !z2_out || !px || !py || !x || !y ||
- !z || !z2 || !qx || !qy || !gt) {
- result = kEpidBadArgErr;
- break;
- }
- if (!f->ipp_ff_elem || !x_out->ipp_ff_elem || !y_out->ipp_ff_elem ||
- !z_out->ipp_ff_elem || !z2_out->ipp_ff_elem || !px->ipp_ff_elem ||
- !py->ipp_ff_elem || !x->ipp_ff_elem || !y->ipp_ff_elem ||
- !z->ipp_ff_elem || !z2->ipp_ff_elem || !qx->ipp_ff_elem ||
- !qy->ipp_ff_elem || !gt->ipp_ff) {
- result = kEpidBadArgErr;
- break;
- }
- // get Fq6, Fq2
- sts = ippsGFpGetInfo(gt->ipp_ff, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq6 = (IppsGFpState*)info.pGroundGF;
- sts = ippsGFpGetInfo(Fq6, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq2 = (IppsGFpState*)info.pGroundGF;
- result = InitFiniteFieldFromIpp(Fq2, &Ffq2);
- BREAK_ON_EPID_ERROR(result);
- // Let t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 be temporary
- // elements in Fq2. All the following operations are computed in
- // Fq2 unless explicitly specified.
- result = NewFfElement(&Ffq2, &t0);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t1);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t2);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t3);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t4);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t5);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t6);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t7);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t8);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t9);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t10);
- if (kEpidNoErr != result) {
- break;
- }
- result = NewFfElement(&Ffq2, &t);
- if (kEpidNoErr != result) {
- break;
- }
- // 1. Set t0 = Qx * Z2.
- sts =
- ippsGFpMul(qx->ipp_ff_elem, z2_out->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Set t1 = (Qy + Z)^2 - Qy * Qy - Z2.
- sts = ippsGFpAdd(qy->ipp_ff_elem, z->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(t1->ipp_ff_elem, t1->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(qy->ipp_ff_elem, qy->ipp_ff_elem, t->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t1->ipp_ff_elem, t->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t1->ipp_ff_elem, z2->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 3. Set t1 = t1 * Z2.
- sts =
- ippsGFpMul(t1->ipp_ff_elem, z2_out->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Set t2 = t0 - X.
- sts = ippsGFpSub(t0->ipp_ff_elem, x->ipp_ff_elem, t2->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 5. Set t3 = t2 * t2.
- sts = ippsGFpMul(t2->ipp_ff_elem, t2->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 6. Set t4 = 4 * t3.
- sts = ippsGFpAdd(t3->ipp_ff_elem, t3->ipp_ff_elem, t4->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(t4->ipp_ff_elem, t4->ipp_ff_elem, t4->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 7. Set t5 = t4 * t2.
- sts = ippsGFpMul(t4->ipp_ff_elem, t2->ipp_ff_elem, t5->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 8. Set t6 = t1 - Y - Y.
- sts = ippsGFpSub(t1->ipp_ff_elem, y->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t6->ipp_ff_elem, y->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 9. Set t9 = t6 * Qx.
- sts = ippsGFpMul(t6->ipp_ff_elem, qx->ipp_ff_elem, t9->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 10. Set t7 = X * t4.
- sts = ippsGFpMul(x->ipp_ff_elem, t4->ipp_ff_elem, t7->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 11. X' = t6 * t6 - t5 - t7 - t7.
- sts = ippsGFpMul(t6->ipp_ff_elem, t6->ipp_ff_elem, x_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(x_out->ipp_ff_elem, t5->ipp_ff_elem, x_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(x_out->ipp_ff_elem, t7->ipp_ff_elem, x_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(x_out->ipp_ff_elem, t7->ipp_ff_elem, x_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 12. Set Z' = (Z + t2)^2 - Z2 - t3.
- sts = ippsGFpAdd(z->ipp_ff_elem, t2->ipp_ff_elem, z_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(z_out->ipp_ff_elem, z_out->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(z_out->ipp_ff_elem, z2->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(z_out->ipp_ff_elem, t3->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 13. Set t10 = Qy + Z'.
- sts =
- ippsGFpAdd(qy->ipp_ff_elem, z_out->ipp_ff_elem, t10->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 14. Set t8 = (t7 - X') * t6.
- sts = ippsGFpSub(t7->ipp_ff_elem, x_out->ipp_ff_elem, t8->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(t8->ipp_ff_elem, t6->ipp_ff_elem, t8->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 15. Set t0 = 2 * Y * t5.
- sts = ippsGFpMul(y->ipp_ff_elem, t5->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(t0->ipp_ff_elem, t0->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 16. Set Y' = t8 - t0.
- sts = ippsGFpSub(t8->ipp_ff_elem, t0->ipp_ff_elem, y_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 17. Set Z2' = Z' * Z'.
- sts = ippsGFpMul(z_out->ipp_ff_elem, z_out->ipp_ff_elem,
- z2_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 18. Set t10 = t10 * t10 - Qy * Qy - Z2'.
- sts = ippsGFpMul(t10->ipp_ff_elem, t10->ipp_ff_elem, t10->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t10->ipp_ff_elem, t->ipp_ff_elem, t10->ipp_ff_elem,
- Fq2); // t still Qy*Qy
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t10->ipp_ff_elem, z2_out->ipp_ff_elem, t10->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 19. Set t9 = t9 + t9 - t10.
- sts = ippsGFpAdd(t9->ipp_ff_elem, t9->ipp_ff_elem, t9->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t9->ipp_ff_elem, t10->ipp_ff_elem, t9->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 20. Set t10 = Fq2.mul(Z', Py).
- sts = ippsGFpMul_GFpE(z_out->ipp_ff_elem, py->ipp_ff_elem, t10->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 21. Set t10 = t10 + t10.
- sts = ippsGFpAdd(t10->ipp_ff_elem, t10->ipp_ff_elem, t10->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 22. Set t6 = -t6.
- sts = ippsGFpNeg(t6->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 23. Set t1 = Fq2.mul(t6, Px).
- sts =
- ippsGFpMul_GFpE(t6->ipp_ff_elem, px->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 24. Set t1 = t1 + t1.
- sts = ippsGFpAdd(t1->ipp_ff_elem, t1->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 25. Set f = ((t10, 0, 0), (t1, t9, 0)).
- sts = ippsGFpGetElement(t10->ipp_ff_elem, (Ipp32u*)&fDat.x[0].x[0],
- sizeof(fDat.x[0].x[0]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(t1->ipp_ff_elem, (Ipp32u*)&fDat.x[1].x[0],
- sizeof(fDat.x[1].x[0]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(t9->ipp_ff_elem, (Ipp32u*)&fDat.x[1].x[1],
- sizeof(fDat.x[1].x[1]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&fDat, sizeof(fDat) / sizeof(Ipp32u),
- f->ipp_ff_elem, gt->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 26. Return (f, X', Y', Z', Z2').
- } while (0);
- EpidZeroMemory(&fDat, sizeof(fDat));
- DeleteFfElement(&t);
- DeleteFfElement(&t10);
- DeleteFfElement(&t9);
- DeleteFfElement(&t8);
- DeleteFfElement(&t7);
- DeleteFfElement(&t6);
- DeleteFfElement(&t5);
- DeleteFfElement(&t4);
- DeleteFfElement(&t3);
- DeleteFfElement(&t2);
- DeleteFfElement(&t1);
- DeleteFfElement(&t0);
-
- return (result);
-}
-
-/*
-(f, X', Y', Z', Z2') = tangent(Px, Py, X, Y, Z, Z2)
-Input: Px, Py (elements in Fq), X, Y, Z, Z2 (elements in Fq2)
-Output: f (an element in GT), X', Y', Z', Z2' (elements in Fq2)
-Steps:
-*/
-static EpidStatus Tangent(FiniteField* gt, FfElement* f, FfElement* x_out,
- FfElement* y_out, FfElement* z_out, FfElement* z2_out,
- FfElement const* px, FfElement const* py,
- FfElement const* x, FfElement const* y,
- FfElement const* z, FfElement const* z2) {
- EpidStatus result = kEpidErr;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- FfElement* t2 = NULL;
- FfElement* t3 = NULL;
- FfElement* t4 = NULL;
- FfElement* t5 = NULL;
- FfElement* t6 = NULL;
- Fq12ElemDat fDat = {0};
- do {
- IppStatus sts = ippStsNoErr;
- IppsGFpState* Fq2 = NULL;
- IppsGFpState* Fq6 = NULL;
- FiniteField Ffq2;
- IppsGFpInfo info = {0};
- int i = 0;
- // validate input
- if (!gt || !f || !x_out || !y_out || !z_out || !z2_out || !px || !py ||
- !x || !y || !z || !z2) {
- result = kEpidBadArgErr;
- break;
- }
- if (!gt->ipp_ff || !f->ipp_ff_elem || !x_out->ipp_ff_elem ||
- !y_out->ipp_ff_elem || !z_out->ipp_ff_elem || !z2_out->ipp_ff_elem ||
- !px->ipp_ff_elem || !py->ipp_ff_elem || !x->ipp_ff_elem ||
- !y->ipp_ff_elem || !z->ipp_ff_elem || !z2->ipp_ff_elem) {
- result = kEpidBadArgErr;
- break;
- }
- // get Fq2, Fq6
- sts = ippsGFpGetInfo(gt->ipp_ff, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq6 = (IppsGFpState*)info.pGroundGF;
- sts = ippsGFpGetInfo(Fq6, &info);
- BREAK_ON_IPP_ERROR(sts, result);
- Fq2 = (IppsGFpState*)info.pGroundGF;
- result = InitFiniteFieldFromIpp(Fq2, &Ffq2);
- BREAK_ON_EPID_ERROR(result);
- // Let t0, t1, t2, t3, t4, t5, t6 be elements in Fq2. All the following
- // operations are computed in Fq2 unless explicitly specified.
- // 1. Set t0 = X * X.
- result = NewFfElement(&Ffq2, &t0);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpMul(x->ipp_ff_elem, x->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Set t1 = Y * Y.
- result = NewFfElement(&Ffq2, &t1);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpMul(y->ipp_ff_elem, y->ipp_ff_elem, t1->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 3. Set t2 = t1 * t1.
- result = NewFfElement(&Ffq2, &t2);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpMul(t1->ipp_ff_elem, t1->ipp_ff_elem, t2->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Set t3 = (t1 + X)^2 - t0 - t2.
- result = NewFfElement(&Ffq2, &t3);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpAdd(t1->ipp_ff_elem, x->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(t3->ipp_ff_elem, t3->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t3->ipp_ff_elem, t0->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t3->ipp_ff_elem, t2->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 5. Set t3 = t3 + t3.
- sts = ippsGFpAdd(t3->ipp_ff_elem, t3->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 6. Set t4 = 3 * t0.
- result = NewFfElement(&Ffq2, &t4);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpAdd(t0->ipp_ff_elem, t0->ipp_ff_elem, t4->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(t4->ipp_ff_elem, t0->ipp_ff_elem, t4->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 7. Set t6 = X + t4.
- result = NewFfElement(&Ffq2, &t6);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpAdd(x->ipp_ff_elem, t4->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 8. Set t5 = t4 * t4.
- result = NewFfElement(&Ffq2, &t5);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpMul(t4->ipp_ff_elem, t4->ipp_ff_elem, t5->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 9. Set X' = t5 - t3 - t3.
- sts = ippsGFpSub(t5->ipp_ff_elem, t3->ipp_ff_elem, x_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(x_out->ipp_ff_elem, t3->ipp_ff_elem, x_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 10.Set Z' = (Y + Z)^2 - t1 - Z2.
- sts = ippsGFpAdd(y->ipp_ff_elem, z->ipp_ff_elem, z_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(z_out->ipp_ff_elem, z_out->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(z_out->ipp_ff_elem, t1->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(z_out->ipp_ff_elem, z2->ipp_ff_elem, z_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 11.Set Y' = (t3 - X') * t4 - 8 * t2.
- sts = ippsGFpSub(t3->ipp_ff_elem, x_out->ipp_ff_elem, y_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpMul(y_out->ipp_ff_elem, t4->ipp_ff_elem, y_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- for (i = 0; i < 8; i++) {
- sts = ippsGFpSub(y_out->ipp_ff_elem, t2->ipp_ff_elem, y_out->ipp_ff_elem,
- Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 12.Set t3 = -2 * (t4 * Z2).
- sts = ippsGFpMul(t4->ipp_ff_elem, z2->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(t3->ipp_ff_elem, t3->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpNeg(t3->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 13.Set t3 = Fq2.mul(t3, Px).
- sts =
- ippsGFpMul_GFpE(t3->ipp_ff_elem, px->ipp_ff_elem, t3->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 14.Set t6 = t6 * t6 - t0 - t5 - 4 * t1.
- sts = ippsGFpMul(t6->ipp_ff_elem, t6->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t6->ipp_ff_elem, t0->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(t6->ipp_ff_elem, t5->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- for (i = 0; i < 4; i++) {
- sts = ippsGFpSub(t6->ipp_ff_elem, t1->ipp_ff_elem, t6->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 15.Set t0 = 2 * (Z' * Z2).
- sts = ippsGFpMul(z_out->ipp_ff_elem, z2->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(t0->ipp_ff_elem, t0->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 16.Set t0 = Fq2.mul(t0, Py).
- sts =
- ippsGFpMul_GFpE(t0->ipp_ff_elem, py->ipp_ff_elem, t0->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 17.Set f = ((t0, 0, 0), (t3, t6, 0)).
- sts = ippsGFpGetElement(t0->ipp_ff_elem, (Ipp32u*)&fDat.x[0].x[0],
- sizeof(fDat.x[0].x[0]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(t3->ipp_ff_elem, (Ipp32u*)&fDat.x[1].x[0],
- sizeof(fDat.x[1].x[0]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(t6->ipp_ff_elem, (Ipp32u*)&fDat.x[1].x[1],
- sizeof(fDat.x[1].x[1]) / sizeof(Ipp32u), Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&fDat, sizeof(fDat) / sizeof(Ipp32u),
- f->ipp_ff_elem, gt->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 18.Set Z2' = Z' * Z'.
- sts = ippsGFpMul(z_out->ipp_ff_elem, z_out->ipp_ff_elem,
- z2_out->ipp_ff_elem, Fq2);
- BREAK_ON_IPP_ERROR(sts, result);
- // 19.Return (f, X', Y', Z', Z2').
- } while (0);
- EpidZeroMemory(&fDat, sizeof(fDat));
- DeleteFfElement(&t6);
- DeleteFfElement(&t5);
- DeleteFfElement(&t4);
- DeleteFfElement(&t3);
- DeleteFfElement(&t2);
- DeleteFfElement(&t1);
- DeleteFfElement(&t0);
- return result;
-}
-
-/*
-(sn...s1s0) = ternary(s)
-Input: s (big integer)
-Output: sn...s1s0 (ternary representation of s)
-*/
-static EpidStatus Ternary(int* s, int* n, int max_elements, BigNum const* x) {
- /*
- Let xn...x1x0 be binary representation of s.
- Let flag be a Boolean variable.
- 1. Set flag = false.
- 2. For i = 0, ..., n, do the following:
- a. If xi = 1
- i. If flag = true, set si = 0,
- ii. Else
- 1. If xi+1 = 1, set si = -1 and set flag = true,
- 2. Else si = 1.
- b. Else
- i. If flag = true, set si = 1 and set flag = false,
- ii. Else set si = 0.
- 3. If flag is true
- a. Set n = n+1,
- b. Set sn = 1.
- 4. Return sn...s1s0.
- */
- EpidStatus result = kEpidErr;
-
- do {
- IppStatus sts = ippStsNoErr;
- int flag = 0;
- int i = 0;
- int num_bits = 0;
- Ipp32u* data = 0;
-
- // check parameters
- if (!s || !n || !x || !x->ipp_bn) {
- result = kEpidBadArgErr;
- break;
- }
-
- sts = ippsRef_BN(0, &num_bits, &data, x->ipp_bn);
- if (ippStsNoErr != sts) {
- result = kEpidMathErr;
- break;
- }
-
- if (num_bits + 1 > max_elements) {
- // not enough room for ternary representation
- result = kEpidBadArgErr;
- break;
- }
-
- // Let xn...x1x0 be binary representation of s. Let flag be a
- // Boolean variable.
- *n = num_bits - 1;
- // 1. Set flag = false.
- flag = 0;
- // 2. For i = 0, ..., n, do the following:
- for (i = 0; i < num_bits; i++) {
- if (1 == Bit(data, i)) {
- // a. If x[i] = 1
- if (flag) {
- // i. If flag = true, set si = 0,
- s[i] = 0;
- } else {
- // ii. Else
- if ((i < num_bits - 2) && Bit(data, i + 1)) {
- // 1. If x[i+1] = 1, set s[i] = -1 and set flag = true,
- s[i] = -1;
- flag = 1;
- } else {
- // 2. Else s[i] = 1.
- s[i] = 1;
- }
- }
- } else {
- // b. Else
- if (flag) {
- // i. If flag = true, set s[i] = 1 and set flag = false,
- s[i] = 1;
- flag = 0;
- } else {
- // ii. Else set s[i] = 0.
- s[i] = 0;
- }
- }
- }
- // 3. If flag is true
- if (flag) {
- // a. Set n = n+1,
- *n = *n + 1;
- // b. Set s[n] = 1.
- s[*n] = 1;
- }
- // 4. Return sn...s1s0.
- result = kEpidNoErr;
- } while (0);
-
- return (result);
-}
-
-static int Bit(Ipp32u const* num, Ipp32u bit_index) {
- return 0 != (num[bit_index >> 5] & (1 << (bit_index & 0x1F)));
-}
-
-/*
-e = Fq2.mulXi(a)
-Input: a (an element in Fq2)
-Output: e (an element in Fq2) where e = a * xi
-
-\note THIS IMPLEMENTATION ASSUMES xi[0] = 2, xi[1] = 1, beta = -1
-
-\note only should work with Fq2
-
-*/
-static EpidStatus MulXiFast(FfElement* e, FfElement const* a,
- PairingState* ps) {
- EpidStatus retvalue = kEpidNotImpl;
- FfElement* a0 = NULL;
- FfElement* a1 = NULL;
- FfElement* e0 = NULL;
- FfElement* e1 = NULL;
- Fq2ElemDat a_dat = {0};
- Fq2ElemDat e_dat = {0};
-
- do {
- IppStatus sts = ippStsNoErr;
- // check parameters
- if (!e || !a || !ps) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- if (!e->ipp_ff_elem || !a->ipp_ff_elem || !ps->Fq.ipp_ff ||
- !ps->Fq2.ipp_ff) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- // All the following arithmetic operations are in ps->Fq.
- // 1. Let a = (a[0], a[1]), xi = (xi[0], xi[1]), and e = (e[0], e[1]).
- retvalue = NewFfElement(&(ps->Fq), &a0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq), &a1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq), &e0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq), &e1);
- BREAK_ON_EPID_ERROR(retvalue);
-
- sts = ippsGFpGetElement(a->ipp_ff_elem, (Ipp32u*)&a_dat,
- sizeof(a_dat) / sizeof(Ipp32u), ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0],
- sizeof(a_dat.x[0]) / sizeof(Ipp32u),
- a0->ipp_ff_elem, ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1],
- sizeof(a_dat.x[1]) / sizeof(Ipp32u),
- a1->ipp_ff_elem, ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
-
- // 4. If xi[0] = 2, xi[1] = 1, beta = -1, then e[0] and e[1] can
- // be computed as
- // a. e[0] = a[0] + a[0] - a[1].
- sts = ippsGFpAdd(a0->ipp_ff_elem, a0->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSub(e0->ipp_ff_elem, a1->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // b. e[1] = a[0] + a[1] + a[1].
- sts = ippsGFpAdd(a0->ipp_ff_elem, a1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpAdd(e1->ipp_ff_elem, a1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 5. Return e = (e[0], e[1]).
- sts = ippsGFpGetElement(e0->ipp_ff_elem, (Ipp32u*)&e_dat.x[0],
- sizeof(e_dat.x[0]) / sizeof(Ipp32u), ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpGetElement(e1->ipp_ff_elem, (Ipp32u*)&e_dat.x[1],
- sizeof(e_dat.x[1]) / sizeof(Ipp32u), ps->Fq.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&e_dat, sizeof(e_dat) / sizeof(Ipp32u),
- e->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- retvalue = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(&a_dat, sizeof(a_dat));
- EpidZeroMemory(&e_dat, sizeof(e_dat));
- DeleteFfElement(&a0);
- DeleteFfElement(&a1);
- DeleteFfElement(&e0);
- DeleteFfElement(&e1);
-
- return (retvalue);
-}
-
-/*
-e = Fq6.MulV(a)
-Input: a (element in Fq6)
-Output: e (an element in Fq6) where e = a * V, where V = 0 * v2 + 1 * v + 0
-
-\note only should work with Fq6
-*/
-static EpidStatus MulV(FfElement* e, FfElement* a, PairingState* ps) {
- EpidStatus retvalue = kEpidNotImpl;
- FfElement* a2 = NULL;
- FfElement* e0 = NULL;
- FfElement* e1 = NULL;
- FfElement* e2 = NULL;
- Fq6ElemDat a_dat = {0};
- Fq6ElemDat e_dat = {0};
- do {
- IppStatus sts = ippStsNoErr;
- // check parameters
- if (!e || !a || !ps) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- if (!e->ipp_ff_elem || !a->ipp_ff_elem || !ps->Fq2.ipp_ff ||
- !ps->Fq6.ipp_ff) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- // 1. Let a = (a[0], a[1], a[2]) and e = (e[0], e[1], e[2]).
- retvalue = NewFfElement(&(ps->Fq2), &a2);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e2);
- BREAK_ON_EPID_ERROR(retvalue);
-
- sts = ippsGFpGetElement(a->ipp_ff_elem, (Ipp32u*)&a_dat,
- sizeof(a_dat) / sizeof(Ipp32u), ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[2],
- sizeof(a_dat.x[2]) / sizeof(Ipp32u),
- a2->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 2. e[0] = Fq2.mulXi(a[2]).
- retvalue = MulXiFast(e0, a2, ps);
- BREAK_ON_EPID_ERROR(retvalue);
- // 3. e[1] = a[0].
- if (0 != memcpy_S(&e_dat.x[1], sizeof(e_dat.x[1]), &a_dat.x[0],
- sizeof(a_dat.x[0]))) {
- retvalue = kEpidBadArgErr;
- break;
- }
- // 4. e[2] = a[1].
- if (0 != memcpy_S(&e_dat.x[2], sizeof(e_dat.x[2]), &a_dat.x[1],
- sizeof(a_dat.x[1]))) {
- retvalue = kEpidBadArgErr;
- break;
- }
-
- sts =
- ippsGFpGetElement(e0->ipp_ff_elem, (Ipp32u*)&e_dat.x[0],
- sizeof(e_dat.x[0]) / sizeof(Ipp32u), ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&e_dat, sizeof(e_dat) / sizeof(Ipp32u),
- e->ipp_ff_elem, ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- retvalue = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(&a_dat, sizeof(a_dat));
- EpidZeroMemory(&e_dat, sizeof(e_dat));
- DeleteFfElement(&a2);
- DeleteFfElement(&e0);
- DeleteFfElement(&e1);
- DeleteFfElement(&e2);
-
- return (retvalue);
-}
-
-/*
-helper for MulSpecial, special args form of Fq6Mul
-
-special args form of Fq6.mul(a,b[0],b[1])
-Input: a (elements in Fq6), b[0], b[1] (elements in Fq2)
-Output: e (an element in Fq6) where e = a * b, and b = b[1] * v + b[0]
-
-\note assumes a,e are Fq6 elements and b0,b1 are fq2 elements
-*/
-static EpidStatus Fq6MulGFpE2(FfElement* e, FfElement* a, FfElement* b0,
- FfElement* b1, PairingState* ps) {
- EpidStatus retvalue = kEpidNotImpl;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- FfElement* t2 = NULL;
- FfElement* t3 = NULL;
- FfElement* t4 = NULL;
- FfElement* a0 = NULL;
- FfElement* a1 = NULL;
- FfElement* a2 = NULL;
- FfElement* e0 = NULL;
- FfElement* e1 = NULL;
- FfElement* e2 = NULL;
- Fq6ElemDat a_dat = {0};
- Fq6ElemDat e_dat = {0};
- do {
- IppStatus sts = ippStsNoErr;
- // check parameters
- if (!e || !a || !b0 || !b1 || !ps) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- if (!e->ipp_ff_elem || !a->ipp_ff_elem || !b0->ipp_ff_elem ||
- !b1->ipp_ff_elem || !ps->Fq2.ipp_ff || !ps->Fq6.ipp_ff) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
-
- // Let t0, t1, t3, t4 be temporary variables in Fq2. All the
- // following arithmetic operations are in Fq2.
- retvalue = NewFfElement(&(ps->Fq2), &t0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &t1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &t2);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &t3);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &t4);
- BREAK_ON_EPID_ERROR(retvalue);
- // 1. Let a = (a[0], a[1], a[2]) and e = (e[0], e[1], e[2]).
- retvalue = NewFfElement(&(ps->Fq2), &a0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &a1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &a2);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &e2);
- BREAK_ON_EPID_ERROR(retvalue);
-
- sts = ippsGFpGetElement(a->ipp_ff_elem, (Ipp32u*)&a_dat,
- sizeof(a_dat) / sizeof(Ipp32u), ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0],
- sizeof(a_dat.x[0]) / sizeof(Ipp32u),
- a0->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1],
- sizeof(a_dat.x[1]) / sizeof(Ipp32u),
- a1->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[2],
- sizeof(a_dat.x[2]) / sizeof(Ipp32u),
- a2->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 2. t0 = a[0] * b[0].
- sts = ippsGFpMul(a0->ipp_ff_elem, b0->ipp_ff_elem, t0->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 3. t1 = a[1] * b[1].
- sts = ippsGFpMul(a1->ipp_ff_elem, b1->ipp_ff_elem, t1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 4. t3 = a[1] + a[2].
- sts = ippsGFpAdd(a1->ipp_ff_elem, a2->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 5. t3 = t3 * b[1].
- sts = ippsGFpMul(t3->ipp_ff_elem, b1->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 6. t3 = t3 - t1.
- sts = ippsGFpSub(t3->ipp_ff_elem, t1->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 7. e[0] = Fq2.mulXi(t3) + t0.
- retvalue = MulXiFast(e0, t3, ps);
- BREAK_ON_EPID_ERROR(retvalue);
- sts = ippsGFpAdd(e0->ipp_ff_elem, t0->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 8. t3 = a[0] + a[1].
- sts = ippsGFpAdd(a0->ipp_ff_elem, a1->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 9. t4 = b[0] + b[1].
- sts = ippsGFpAdd(b0->ipp_ff_elem, b1->ipp_ff_elem, t4->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 10. t3 = t3 * t4.
- sts = ippsGFpMul(t3->ipp_ff_elem, t4->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 11. e[1] = t3 - t0 - t1.
- sts = ippsGFpSub(t3->ipp_ff_elem, t0->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSub(e1->ipp_ff_elem, t1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 12. t3 = a[2] * b[0].
- sts = ippsGFpMul(a2->ipp_ff_elem, b0->ipp_ff_elem, t3->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 13. e[2] = t3 + t1.
- sts = ippsGFpAdd(t3->ipp_ff_elem, t1->ipp_ff_elem, e2->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 14. Return e.
- sts =
- ippsGFpGetElement(e0->ipp_ff_elem, (Ipp32u*)&e_dat.x[0],
- sizeof(e_dat.x[0]) / sizeof(Ipp32u), ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts =
- ippsGFpGetElement(e1->ipp_ff_elem, (Ipp32u*)&e_dat.x[1],
- sizeof(e_dat.x[1]) / sizeof(Ipp32u), ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts =
- ippsGFpGetElement(e2->ipp_ff_elem, (Ipp32u*)&e_dat.x[2],
- sizeof(e_dat.x[2]) / sizeof(Ipp32u), ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&e_dat, sizeof(e_dat) / sizeof(Ipp32u),
- e->ipp_ff_elem, ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- retvalue = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(&a_dat, sizeof(a_dat));
- EpidZeroMemory(&e_dat, sizeof(e_dat));
- DeleteFfElement(&t0);
- DeleteFfElement(&t1);
- DeleteFfElement(&t2);
- DeleteFfElement(&t3);
- DeleteFfElement(&t4);
- DeleteFfElement(&a0);
- DeleteFfElement(&a1);
- DeleteFfElement(&a2);
- DeleteFfElement(&e0);
- DeleteFfElement(&e1);
- DeleteFfElement(&e2);
-
- return (retvalue);
-}
-
-/*
-e = Fq12.MulSpecial(a, b)
-Input: a, b (elements in Fq12) where b = ((b[0], b[2], b[4]), (b[1], b[3],
-b[5])) and b[2] = b[4] = b[5] = 0
-Output: e (an element in Fq12) where e = a * b
-*/
-static EpidStatus MulSpecial(FfElement* e, FfElement const* a,
- FfElement const* b, PairingState* ps) {
- EpidStatus retvalue = kEpidNotImpl;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- FfElement* t2 = NULL;
- FfElement* a0 = NULL;
- FfElement* a1 = NULL;
- FfElement* b0 = NULL;
- FfElement* b1 = NULL;
- FfElement* b3 = NULL;
- FfElement* e0 = NULL;
- FfElement* e1 = NULL;
- FfElement* b0plusb1 = NULL;
- Fq12ElemDat a_dat = {0};
- Fq12ElemDat b_dat = {0};
- Fq12ElemDat e_dat = {0};
- do {
- IppStatus sts = ippStsNoErr;
-
- // check parameters
- if (!e || !a || !b || !ps) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
- if (!e->ipp_ff_elem || !a->ipp_ff_elem || !b->ipp_ff_elem ||
- !ps->Fq2.ipp_ff || !ps->Fq6.ipp_ff || !ps->ff || !ps->ff->ipp_ff) {
- retvalue = kEpidBadArgErr;
- BREAK_ON_EPID_ERROR(retvalue);
- }
-
- // Let t0, t1, t2 be temporary variables in ps->Fq6.
- retvalue = NewFfElement(&(ps->Fq6), &t0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq6), &t1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq6), &t2);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &b0plusb1);
- BREAK_ON_EPID_ERROR(retvalue);
-
- // 1. Let a = (a[0], a[1]) and e = (e[0], e[1]).
- retvalue = NewFfElement(&(ps->Fq6), &a0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq6), &a1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq6), &e0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq6), &e1);
- BREAK_ON_EPID_ERROR(retvalue);
-
- sts = ippsGFpGetElement(a->ipp_ff_elem, (Ipp32u*)&a_dat,
- sizeof(a_dat) / sizeof(Ipp32u), ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[0],
- sizeof(a_dat.x[0]) / sizeof(Ipp32u),
- a0->ipp_ff_elem, ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&a_dat.x[1],
- sizeof(a_dat.x[1]) / sizeof(Ipp32u),
- a1->ipp_ff_elem, ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
-
- // 2. Let b = ((b[0], b[2], b[4]), (b[1], b[3], b[5])) where
- // b[0], ..., b[5] are elements in ps->Fq2 and b[2] = b[4] = b[5]
- // = 0.
- retvalue = NewFfElement(&(ps->Fq2), &b0);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &b1);
- BREAK_ON_EPID_ERROR(retvalue);
- retvalue = NewFfElement(&(ps->Fq2), &b3);
- BREAK_ON_EPID_ERROR(retvalue);
-
- sts = ippsGFpGetElement(b->ipp_ff_elem, (Ipp32u*)&b_dat,
- sizeof(b_dat) / sizeof(Ipp32u), ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&b_dat.x[0].x[0],
- sizeof(a_dat.x[0].x[0]) / sizeof(Ipp32u),
- b0->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&b_dat.x[1].x[0],
- sizeof(a_dat.x[1].x[0]) / sizeof(Ipp32u),
- b1->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&b_dat.x[1].x[1],
- sizeof(a_dat.x[1].x[1]) / sizeof(Ipp32u),
- b3->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
-
- // 3. t0 = ps->Fq6.mul(a[0], b[0]).
- sts = ippsGFpMul_GFpE(a0->ipp_ff_elem, b0->ipp_ff_elem, t0->ipp_ff_elem,
- ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 4. t1 = ps->Fq6.mul(a[1], b[1], b[3]).
- retvalue = Fq6MulGFpE2(t1, a1, b1, b3, ps);
- BREAK_ON_EPID_ERROR(retvalue);
- // 5. e[0] = ps->Fq6.MulV(t1).
- retvalue = MulV(e0, t1, ps);
- BREAK_ON_EPID_ERROR(retvalue);
- // 6. e[0] = ps->Fq6.add(t0, e[0]).
- sts = ippsGFpAdd(t0->ipp_ff_elem, e0->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 7. t2 = ps->Fq6.add(a[0], a[1]).
- sts = ippsGFpAdd(a0->ipp_ff_elem, a1->ipp_ff_elem, t2->ipp_ff_elem,
- ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 8. e[1] = ps->Fq6.mul(t2, b[0] + b[1], b[3]).
- sts = ippsGFpAdd(b0->ipp_ff_elem, b1->ipp_ff_elem, b0plusb1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- retvalue = Fq6MulGFpE2(e1, t2, b0plusb1, b3, ps);
- BREAK_ON_EPID_ERROR(retvalue);
- // 9. e[1] = ps->Fq6.subtract(e[1], t0).
- sts = ippsGFpSub(e1->ipp_ff_elem, t0->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 10. e[1] = ps->Fq6.subtract(e[1], t1).
- sts = ippsGFpSub(e1->ipp_ff_elem, t1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- // 11. Return e.
- sts =
- ippsGFpGetElement(e0->ipp_ff_elem, (Ipp32u*)&e_dat.x[0],
- sizeof(e_dat.x[0]) / sizeof(Ipp32u), ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts =
- ippsGFpGetElement(e1->ipp_ff_elem, (Ipp32u*)&e_dat.x[1],
- sizeof(e_dat.x[1]) / sizeof(Ipp32u), ps->Fq6.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- sts = ippsGFpSetElement((Ipp32u*)&e_dat, sizeof(e_dat) / sizeof(Ipp32u),
- e->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, retvalue);
- retvalue = kEpidNoErr;
- } while (0);
- EpidZeroMemory(&a_dat, sizeof(a_dat));
- EpidZeroMemory(&b_dat, sizeof(b_dat));
- EpidZeroMemory(&e_dat, sizeof(e_dat));
- DeleteFfElement(&t0);
- DeleteFfElement(&t1);
- DeleteFfElement(&t2);
- DeleteFfElement(&a0);
- DeleteFfElement(&a1);
- DeleteFfElement(&b0);
- DeleteFfElement(&b1);
- DeleteFfElement(&b3);
- DeleteFfElement(&e0);
- DeleteFfElement(&e1);
- DeleteFfElement(&b0plusb1);
-
- return (retvalue);
-}
-
-/*
- (e0, e1) = Fq12.SquareForFq4(a0, a1)
- Input: a0, a1 (elements in Fq2)
- Output: e0, e1 (elements in Fq2) where e = a * a in Fq4
-*/
-static EpidStatus SquareForFq4(PairingState* ps, FfElement* e0, FfElement* e1,
- FfElement const* a0, FfElement const* a1) {
- EpidStatus result = kEpidErr;
- FfElement* t0 = NULL;
- FfElement* t1 = NULL;
- FfElement* xi = NULL;
- Fq2ElemStr Fq6IrrPolynomial[3 + 1] = {0};
-
- // check parameters
- if (!e0 || !e1 || !a0 || !a1 || !ps) return kEpidBadArgErr;
-
- if (!e0->ipp_ff_elem || !e1->ipp_ff_elem || !a0->ipp_ff_elem ||
- !a1->ipp_ff_elem || !ps->ff || !ps->ff->ipp_ff || !ps->Fq2.ipp_ff ||
- !ps->Fq6.ipp_ff)
- return kEpidBadArgErr;
-
- do {
- IppStatus sts = ippStsNoErr;
-
- // extract xi from Fq6 irr poly
- result = NewFfElement(&(ps->Fq2), &xi);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpGetModulus(ps->Fq6.ipp_ff, (Ipp32u*)&Fq6IrrPolynomial[0]);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u const*)&Fq6IrrPolynomial[0],
- sizeof(Fq6IrrPolynomial[0]) / sizeof(Ipp32u),
- xi->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // first coefficent is -xi
- sts = ippsGFpNeg(xi->ipp_ff_elem, xi->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
-
- // Let t0, t1 be temporary variables in Fq2. All the following
- // operations are computed in Fq2.
- result = NewFfElement(&(ps->Fq2), &t0);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t1);
- BREAK_ON_EPID_ERROR(result);
-
- // 1. Set t0 = a0 * a0.
- sts = ippsGFpMul(a0->ipp_ff_elem, a0->ipp_ff_elem, t0->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Set t1 = a1 * a1.
- sts = ippsGFpMul(a1->ipp_ff_elem, a1->ipp_ff_elem, t1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 3. Set e0 = t1 * xi.
- sts = ippsGFpMul(t1->ipp_ff_elem, xi->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 4. Set e0 = e0 + t0.
- sts = ippsGFpAdd(e0->ipp_ff_elem, t0->ipp_ff_elem, e0->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 5. Set e1 = a0 + a1.
- sts = ippsGFpAdd(a0->ipp_ff_elem, a1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 6. Set e1 = e1 * e1 - t0 - t1.
- sts = ippsGFpMul(e1->ipp_ff_elem, e1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e1->ipp_ff_elem, t0->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e1->ipp_ff_elem, t1->ipp_ff_elem, e1->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 7. Return (e0, e1).
- result = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(Fq6IrrPolynomial, sizeof(Fq6IrrPolynomial));
- DeleteFfElement(&t0);
- DeleteFfElement(&t1);
- DeleteFfElement(&xi);
-
- return (result);
-}
-
-/*
- e = Fq12.squareCyclotomic(a)
- Input: a (an element in Fq12)
- Output: e (an element in Fq12) where e = a * a
-*/
-static EpidStatus SquareCyclotomic(PairingState* ps, FfElement* e_out,
- FfElement const* a_in) {
- EpidStatus result = kEpidErr;
- FfElement* t00 = NULL;
- FfElement* t01 = NULL;
- FfElement* t02 = NULL;
- FfElement* t10 = NULL;
- FfElement* t11 = NULL;
- FfElement* t12 = NULL;
-
- FfElement* a[6] = {0};
- FfElement* e[6] = {0};
-
- FfElement* xi = NULL;
- int i = 0;
- Fq12ElemStr a_str = {0};
- Fq12ElemStr e_str = {0};
- Fq2ElemStr Fq6IrrPolynomial[3 + 1] = {0};
-
- // check parameters
- if (!e_out || !a_in || !ps) return kEpidBadArgErr;
-
- if (!e_out->ipp_ff_elem || !a_in->ipp_ff_elem || !ps->ff || !ps->ff->ipp_ff ||
- !ps->Fq.ipp_ff || !ps->Fq2.ipp_ff || !ps->Fq6.ipp_ff)
- return kEpidBadArgErr;
-
- do {
- IppStatus sts = ippStsNoErr;
-
- // extract xi from Fq6 irr poly
- result = NewFfElement(&(ps->Fq2), &xi);
- BREAK_ON_EPID_ERROR(result);
- sts = ippsGFpGetModulus(ps->Fq6.ipp_ff, (Ipp32u*)&Fq6IrrPolynomial);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u const*)&Fq6IrrPolynomial[0],
- sizeof(Fq6IrrPolynomial[0]) / sizeof(Ipp32u),
- xi->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // first coefficent is -xi
- sts = ippsGFpNeg(xi->ipp_ff_elem, xi->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
-
- // Let t00, t01, t02, t10, t11, t12 be temporary variables in
- // Fq2. All the following operations are computed in Fq2 unless
- // specified otherwise.
- result = NewFfElement(&(ps->Fq2), &t00);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t01);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t02);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t10);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t11);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &t12);
- BREAK_ON_EPID_ERROR(result);
- for (i = 0; i < 6; i++) {
- result = NewFfElement(&(ps->Fq2), &a[i]);
- BREAK_ON_EPID_ERROR(result);
- result = NewFfElement(&(ps->Fq2), &e[i]);
- BREAK_ON_EPID_ERROR(result);
- }
- BREAK_ON_EPID_ERROR(result);
- // 1. Let a = ((a[0], a[2], a[4]), (a[1], a[3], a[5])).
- sts = ippsGFpGetElement(a_in->ipp_ff_elem, (Ipp32u*)&a_str,
- sizeof(a_str) / sizeof(Ipp32u), ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[0].a[0],
- sizeof(a_str.a[0].a[0]) / sizeof(Ipp32u),
- a[0]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[0].a[1],
- sizeof(a_str.a[0].a[1]) / sizeof(Ipp32u),
- a[2]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[0].a[2],
- sizeof(a_str.a[0].a[2]) / sizeof(Ipp32u),
- a[4]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[1].a[0],
- sizeof(a_str.a[1].a[0]) / sizeof(Ipp32u),
- a[1]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[1].a[1],
- sizeof(a_str.a[1].a[1]) / sizeof(Ipp32u),
- a[3]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&a_str.a[1].a[2],
- sizeof(a_str.a[1].a[2]) / sizeof(Ipp32u),
- a[5]->ipp_ff_elem, ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Let e = ((e[0], e[2], e[4]), (e[1], e[3], e[5])).
-
- // 3. (t00, t11) = Fq12.SquareForFq4(a[0], a[3]).
- result = SquareForFq4(ps, t00, t11, a[0], a[3]);
- BREAK_ON_EPID_ERROR(result);
- // 4. (t01, t12) = Fq12.SquareForFq4(a[1], a[4]).
- result = SquareForFq4(ps, t01, t12, a[1], a[4]);
- BREAK_ON_EPID_ERROR(result);
- // 5. (t02, t10) = Fq12.SquareForFq4(a[2], a[5]).
- result = SquareForFq4(ps, t02, t10, a[2], a[5]);
- BREAK_ON_EPID_ERROR(result);
- // 6. Set t10 = t10 * xi.
- sts = ippsGFpMul(t10->ipp_ff_elem, xi->ipp_ff_elem, t10->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 7. Set e[0] = 3 * t00 - 2 * a[0].
- sts = ippsGFpAdd(t00->ipp_ff_elem, t00->ipp_ff_elem, e[0]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[0]->ipp_ff_elem, t00->ipp_ff_elem, e[0]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[0]->ipp_ff_elem, a[0]->ipp_ff_elem, e[0]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[0]->ipp_ff_elem, a[0]->ipp_ff_elem, e[0]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 8. Set e[2] = 3 * t01 - 2 * a[2].
- sts = ippsGFpAdd(t01->ipp_ff_elem, t01->ipp_ff_elem, e[2]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[2]->ipp_ff_elem, t01->ipp_ff_elem, e[2]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[2]->ipp_ff_elem, a[2]->ipp_ff_elem, e[2]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[2]->ipp_ff_elem, a[2]->ipp_ff_elem, e[2]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 9. Set e[4] = 3 * t02 - 2 * a[4].
- sts = ippsGFpAdd(t02->ipp_ff_elem, t02->ipp_ff_elem, e[4]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[4]->ipp_ff_elem, t02->ipp_ff_elem, e[4]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[4]->ipp_ff_elem, a[4]->ipp_ff_elem, e[4]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSub(e[4]->ipp_ff_elem, a[4]->ipp_ff_elem, e[4]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 10. Set e[1] = 3 * t10 + 2 * a[1].
- sts = ippsGFpAdd(t10->ipp_ff_elem, t10->ipp_ff_elem, e[1]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[1]->ipp_ff_elem, t10->ipp_ff_elem, e[1]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[1]->ipp_ff_elem, a[1]->ipp_ff_elem, e[1]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[1]->ipp_ff_elem, a[1]->ipp_ff_elem, e[1]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 11. Set e[3] = 3 * t11 + 2 * a[3].
- sts = ippsGFpAdd(t11->ipp_ff_elem, t11->ipp_ff_elem, e[3]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[3]->ipp_ff_elem, t11->ipp_ff_elem, e[3]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[3]->ipp_ff_elem, a[3]->ipp_ff_elem, e[3]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[3]->ipp_ff_elem, a[3]->ipp_ff_elem, e[3]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 12. Set e[5] = 3 * t12 + 2 * a[5].
- sts = ippsGFpAdd(t12->ipp_ff_elem, t12->ipp_ff_elem, e[5]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[5]->ipp_ff_elem, t12->ipp_ff_elem, e[5]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[5]->ipp_ff_elem, a[5]->ipp_ff_elem, e[5]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpAdd(e[5]->ipp_ff_elem, a[5]->ipp_ff_elem, e[5]->ipp_ff_elem,
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 13. Return e.
- sts = ippsGFpGetElement(e[0]->ipp_ff_elem, (Ipp32u*)&e_str.a[0].a[0],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(e[2]->ipp_ff_elem, (Ipp32u*)&e_str.a[0].a[1],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(e[4]->ipp_ff_elem, (Ipp32u*)&e_str.a[0].a[2],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(e[1]->ipp_ff_elem, (Ipp32u*)&e_str.a[1].a[0],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(e[3]->ipp_ff_elem, (Ipp32u*)&e_str.a[1].a[1],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpGetElement(e[5]->ipp_ff_elem, (Ipp32u*)&e_str.a[1].a[2],
- sizeof(e_str.a[0].a[0]) / sizeof(Ipp32u),
- ps->Fq2.ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- sts = ippsGFpSetElement((Ipp32u*)&e_str, sizeof(e_str) / sizeof(Ipp32u),
- e_out->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- result = kEpidNoErr;
- } while (0);
-
- EpidZeroMemory(&a_str, sizeof(a_str));
- EpidZeroMemory(&e_str, sizeof(e_str));
- EpidZeroMemory(Fq6IrrPolynomial, sizeof(Fq6IrrPolynomial));
- DeleteFfElement(&t00);
- DeleteFfElement(&t01);
- DeleteFfElement(&t02);
- DeleteFfElement(&t10);
- DeleteFfElement(&t11);
- DeleteFfElement(&t12);
-
- for (i = 0; i < 6; i++) {
- DeleteFfElement(&a[i]);
- DeleteFfElement(&e[i]);
- }
-
- DeleteFfElement(&xi);
-
- return (result);
-}
-
-/*
- e = Fq12.expCyclotomic(a, b)
- Input: a (an element in Fq12), b (a non-negative integer)
- Output: e (an element in Fq12) where e = a^b
- Steps:
-
- 2. Set e = a.
- 3. For i = n-1, ..., 0, do the following:
- e = Fq12.squareCyclotomic(e, e),
- If bi = 1, compute e = Fq12.mul(e, a).
- 4. Return e.
-*/
-static EpidStatus ExpCyclotomic(PairingState* ps, FfElement* e,
- FfElement const* a, BigNum const* b) {
- EpidStatus result = kEpidErr;
-
- // check parameters
- if (!e || !a || !b || !ps) return kEpidBadArgErr;
-
- if (!e->ipp_ff_elem || !a->ipp_ff_elem || !ps->Fq.ipp_ff || !ps->Fq2.ipp_ff ||
- !b->ipp_bn)
- return kEpidBadArgErr;
-
- do {
- IppStatus sts = ippStsNoErr;
- int num_bits = 0;
- Ipp32u* b_str = 0;
- int i = 0;
-
- // 1. Let bn...b1b0 be the binary representation of b.
- sts = ippsRef_BN(0, &num_bits, &b_str, b->ipp_bn);
- BREAK_ON_IPP_ERROR(sts, result);
- // 2. Set e = a.
- sts = ippsGFpCpyElement(a->ipp_ff_elem, e->ipp_ff_elem, ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- // 3. For i = n-1, ..., 0, do the following:
- for (i = num_bits - 2; i >= 0; i--) {
- // e = Fq12.squareCyclotomic(e, e),
- result = SquareCyclotomic(ps, e, e);
- BREAK_ON_EPID_ERROR(result);
- // If bi = 1, compute e = Fq12.mul(e, a).
- if (1 == Bit(b_str, i)) {
- sts = ippsGFpMul(e->ipp_ff_elem, a->ipp_ff_elem, e->ipp_ff_elem,
- ps->ff->ipp_ff);
- BREAK_ON_IPP_ERROR(sts, result);
- }
- // 4. Return e.
- }
- result = kEpidNoErr;
- } while (0);
-
- return (result);
-}
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.h
deleted file mode 100644
index a5a13255eb..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/pairing.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Pairing interface.
- */
-
-#ifndef EPID_COMMON_MATH_PAIRING_H_
-#define EPID_COMMON_MATH_PAIRING_H_
-
-#include "epid/common/errors.h"
-#include "epid/common/types.h"
-#include "epid/common/math/finitefield.h"
-#include "epid/common/math/ecgroup.h"
-
-/// Pairing operations
-/*!
- \defgroup PairingPrimitives pairing
- Provides APIs for defining and using a pairing relationship between two
- Elliptic Curve Groups.
-
- \ingroup EpidMath
- @{
-*/
-
-/// A pairing
-typedef struct PairingState PairingState;
-
-/// Constructs a new Pairing State.
-/*!
- Allocates memory and creates a new Pairing State for Optimal Ate Pairing.
-
- Use DeletePairingState() to free memory.
-
- \param[in] ga
- The EcGroup from which the first parameter of the pairing is taken.
- \param[in] gb
- The EcGroup from which the second parameter of the pairing is taken.
- \param[in] ff
- The result finite field. Must be a Fq12 field.
- \param[in] t
- A positive integer such that 6(t^2) == q - p, where p and q are parameters
- of G1.
- \param[in] neg
- Select the alternate "negate" processing path for Optimal Ate Pairing.
- \param[out] ps
- Newly constructed Pairing State.
-
- \returns ::EpidStatus
-
- \see DeletePairingState
-*/
-EpidStatus NewPairingState(EcGroup const* ga, EcGroup const* gb,
- FiniteField* ff, BigNumStr const* t, bool neg,
- PairingState** ps);
-
-/// Frees a previously allocated by PairingState.
-/*!
- Frees memory pointed to by pairing state. Nulls the pointer.
-
- \param[in] ps
- The Pairing state. Can be NULL.
-
- \see NewPairingState
-*/
-void DeletePairingState(PairingState** ps);
-
-/// Computes an Optimal Ate Pairing for two parameters.
-/*!
- \param[in] ps
- The pairing state.
- \param[out] d
- The result of the pairing. Will be in ff used to create the pairing state.
- \param[in] a
- The first value to pair. Must be in ga used to create ps.
- \param[in] b
- The second value to pair. Must be in gb used to create ps
-
- \returns ::EpidStatus
-*/
-EpidStatus Pairing(PairingState* ps, FfElement* d, EcPoint const* a,
- EcPoint const* b);
-
-/*!
- @}
-*/
-
-#endif // EPID_COMMON_MATH_PAIRING_H_
diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.c
deleted file mode 100644
index b349d630e7..0000000000
--- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/*############################################################################
- # Copyright 2016 Intel Corporation
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- ############################################################################*/
-
-/*!
- * \file
- * \brief Print helper implementation.
- */
-#ifndef EPID_ENABLE_DEBUG_PRINT
-#define EPID_ENABLE_DEBUG_PRINT
-#endif
-
-#include "epid/common/math/printutils.h"
-
-#include
-#include
-
-#include "ext/ipp/include/ippcp.h"
-#include "epid/common/math/bignum-internal.h"
-#include "epid/common/math/ecgroup-internal.h"
-#include "epid/common/math/finitefield-internal.h"
-#include "epid/common/memory.h"
-
-/// Allowed number of characters printed in one line
-#define WIDTH 49
-
-/// Amount of identation added in the beginning of each line
-#define INDENT 2
-
-/// Number of charaters used to represent one byte. For example, "ab" or "05".
-#define BYTE_LENGTH 2
-
-/// Separator
-#define SEPARATOR (" ")
-
-/// Make configured number of identation
-#define MAKE_INDENT() \
- { \
- uint8_t ind = 0; \
- for (ind = 0; ind < INDENT; ind++) { \
- PRINT(" "); \
- } \
- }
-
-/// Print to specified stream
-#define PRINT(...) fprintf(stdout, __VA_ARGS__)
-
-static int PrintBuf(void const* buf, size_t size) {
- size_t curr_column = 0;
- size_t i = 0;
- if (!buf || size == 0) {
- return -1;
- }
- for (i = 0; i < size; i++) {
- if (curr_column == 0) {
- MAKE_INDENT();
- curr_column += INDENT;
- }
- if (BYTE_LENGTH != PRINT("%.2x", ((unsigned char const*)buf)[i])) {
- return -1;
- }
- curr_column += BYTE_LENGTH;
- if (i < size - 1) {
- if ((curr_column + BYTE_LENGTH + strlen(SEPARATOR)) > WIDTH) {
- PRINT("\n");
- curr_column = 0;
- } else {
- PRINT("%s", SEPARATOR);
- curr_column += (uint8_t)strlen(SEPARATOR);
- }
- }
- }
- PRINT("\n");
- return 0;
-}
-
-void PrintBigNum(BigNum const* big_num, char const* var_name) {
- IppStatus sts = ippStsNoErr;
- unsigned char* buf = NULL;
- int ipp_word_buf_size;
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (BigNum):\n", var_name);
- if (!big_num) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (!big_num->ipp_bn) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- sts = ippsGetSize_BN(big_num->ipp_bn, &ipp_word_buf_size);
- if (ippStsNoErr != sts) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- do {
- buf = SAFE_ALLOC(ipp_word_buf_size * sizeof(Ipp32u));
- if (!buf) {
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- sts = ippsGetOctString_BN((Ipp8u*)buf, ipp_word_buf_size * sizeof(Ipp32u),
- big_num->ipp_bn);
- if (ippStsNoErr != sts) {
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- if (0 != PrintBuf((const void*)buf, ipp_word_buf_size * sizeof(Ipp32u))) {
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- } while (0);
-
- SAFE_FREE(buf);
-}
-
-void PrintFfElement(FiniteField const* ff, FfElement const* ff_element,
- char const* var_name, PrintUtilFormat format) {
- IppStatus sts;
- uint8_t ff_element_str[sizeof(Fq12ElemStr)];
- int ipp_ff_element_size;
- if (!var_name) {
- var_name = "";
- }
- if (!ff_element || !ff) {
- PRINT("%s (FfElement):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (!ff_element->ipp_ff_elem || !ff->ipp_ff ||
- (format != kPrintUtilUnannotated && format != kPrintUtilAnnotated)) {
- PRINT("%s (FfElement):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-
- // get the data
- ipp_ff_element_size = ff_element->info.elementLen * sizeof(Ipp32u);
- sts = ippsGFpGetElementOctString(ff_element->ipp_ff_elem,
- (Ipp8u*)&ff_element_str, ipp_ff_element_size,
- ff->ipp_ff);
- if (ippStsNoErr != sts) {
- PRINT("%s (FfElement):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-
- if (ipp_ff_element_size == sizeof(FqElemStr)) {
- PrintFqElemStr((const FqElemStr*)&ff_element_str, var_name);
- } else if (ipp_ff_element_size == sizeof(FpElemStr)) {
- PrintFpElemStr((const FpElemStr*)&ff_element_str, var_name);
- } else if (ipp_ff_element_size == sizeof(Fq2ElemStr)) {
- PrintFq2ElemStr((const Fq2ElemStr*)&ff_element_str, var_name, format);
- } else if (ipp_ff_element_size == sizeof(Fq6ElemStr)) {
- PrintFq6ElemStr((const Fq6ElemStr*)&ff_element_str, var_name, format);
- } else if (ipp_ff_element_size == sizeof(Fq6ElemStr)) {
- PrintFq12ElemStr((const Fq12ElemStr*)&ff_element_str, var_name, format);
- } else if (ipp_ff_element_size == sizeof(GtElemStr)) {
- PrintGtElemStr((const GtElemStr*)&ff_element_str, var_name, format);
- } else {
- PRINT("%s (FfElement):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- }
-}
-
-void PrintEcPoint(EcGroup const* g, EcPoint const* ec_point,
- char const* var_name, PrintUtilFormat format) {
- FiniteField fp;
- FfElement* fp_x = NULL;
- FfElement* fp_y = NULL;
- uint8_t ec_point_str[sizeof(G2ElemStr)];
- if (!var_name) {
- var_name = "";
- }
- if (!ec_point || !g) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (!ec_point->ipp_ec_pt || !g->ipp_ec) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- do {
- IppStatus sts = ippStsNoErr;
- int ipp_half_strlen;
- // get finite field
- sts = ippsGFpECGet(g->ipp_ec, (const IppsGFpState**)&(fp.ipp_ff), 0, 0, 0,
- 0, 0, 0, 0, 0);
- if (ippStsNoErr != sts) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
-
- // create element X
- if (kEpidNoErr != NewFfElement(&fp, &fp_x)) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- // create element Y
- if (kEpidNoErr != NewFfElement(&fp, &fp_y)) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
-
- ipp_half_strlen = fp_x->info.elementLen * sizeof(Ipp32u);
-
- // get elements from point
- sts = ippsGFpECGetPoint(ec_point->ipp_ec_pt, fp_x->ipp_ff_elem,
- fp_y->ipp_ff_elem, g->ipp_ec);
- // check return codes
- if (ippStsNoErr != sts) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
-
- // get element X data
- sts = ippsGFpGetElementOctString(fp_x->ipp_ff_elem, (Ipp8u*)&ec_point_str,
- ipp_half_strlen, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- // get element Y data
- sts = ippsGFpGetElementOctString(fp_y->ipp_ff_elem,
- (Ipp8u*)&ec_point_str + ipp_half_strlen,
- ipp_half_strlen, fp.ipp_ff);
- // check return codes
- if (ippStsNoErr != sts) {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
-
- if (2 * ipp_half_strlen == sizeof(G1ElemStr)) {
- PrintG1ElemStr((const G1ElemStr*)&ec_point_str, var_name, format);
- } else if (2 * ipp_half_strlen == sizeof(G2ElemStr)) {
- PrintG2ElemStr((const G2ElemStr*)&ec_point_str, var_name, format);
- } else {
- PRINT("%s (EcPoint):\n", var_name);
- MAKE_INDENT();
- PRINT("\n");
- break;
- }
- } while (0);
-
- DeleteFfElement(&fp_x);
- DeleteFfElement(&fp_y);
-}
-
-void PrintBigNumStr(BigNumStr const* big_num_str, char const* var_name) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (BigNumStr):\n", var_name);
- if (!big_num_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (0 != PrintBuf((const void*)big_num_str, sizeof(*big_num_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintFpElemStr(FpElemStr const* fp_elem_str, char const* var_name) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (FpElemStr):\n", var_name);
- if (!fp_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (0 != PrintBuf((const void*)fp_elem_str, sizeof(*fp_elem_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintFqElemStr(FqElemStr const* fq_elem_str, char const* var_name) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (FqElemStr):\n", var_name);
- if (!fq_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (0 != PrintBuf((const void*)fq_elem_str, sizeof(*fq_elem_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintFq2ElemStr(Fq2ElemStr const* fq2_elem_str, char const* var_name,
- PrintUtilFormat format) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (Fq2ElemStr):\n", var_name);
- if (!fq2_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (format == kPrintUtilAnnotated) {
- MAKE_INDENT();
- PRINT("a0:\n");
- if (0 != PrintBuf((const void*)&fq2_elem_str->a[0],
- sizeof(fq2_elem_str->a[0]))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- MAKE_INDENT();
- PRINT("a1:\n");
- if (0 != PrintBuf((const void*)&fq2_elem_str->a[1],
- sizeof(fq2_elem_str->a[1]))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- } else if (format == kPrintUtilUnannotated) {
- if (0 != PrintBuf((const void*)fq2_elem_str, sizeof(*fq2_elem_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- } else {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintFq6ElemStr(Fq6ElemStr const* fq6_elem_str, char const* var_name,
- PrintUtilFormat format) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (Fq6ElemStr):\n", var_name);
- if (!fq6_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (format == kPrintUtilAnnotated) {
- unsigned int i = 0;
- unsigned int j = 0;
- for (i = 0; i < sizeof(fq6_elem_str->a) / sizeof(fq6_elem_str->a[0]); i++) {
- for (j = 0;
- j < sizeof(fq6_elem_str->a[0]) / sizeof(fq6_elem_str->a[0].a[0]);
- j++) {
- MAKE_INDENT();
- PRINT("a%u.%u:\n", i, j);
- if (0 != PrintBuf((const void*)&fq6_elem_str->a[i].a[j],
- sizeof(fq6_elem_str->a[i].a[j]))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- }
- }
- } else if (format == kPrintUtilUnannotated) {
- if (0 != PrintBuf((const void*)fq6_elem_str, sizeof(*fq6_elem_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- } else {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintFq12ElemStr(Fq12ElemStr const* fq12_elem_str, char const* var_name,
- PrintUtilFormat format) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (Fq12ElemStr):\n", var_name);
- if (!fq12_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (format == kPrintUtilAnnotated) {
- unsigned int i = 0;
- unsigned int j = 0;
- unsigned int k = 0;
- for (i = 0; i < sizeof(fq12_elem_str->a) / sizeof(fq12_elem_str->a[0]);
- i++) {
- for (j = 0;
- j < sizeof(fq12_elem_str->a[0]) / sizeof(fq12_elem_str->a[0].a[0]);
- j++) {
- for (k = 0; k < sizeof(fq12_elem_str->a[0].a[0]) /
- sizeof(fq12_elem_str->a[0].a[0].a[0]);
- k++) {
- MAKE_INDENT();
- PRINT("a%u.%u.%u:\n", i, j, k);
- if (0 != PrintBuf((const void*)&fq12_elem_str->a[i].a[j].a[k],
- sizeof(fq12_elem_str->a[i].a[j].a[k]))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- }
- }
- }
- } else if (format == kPrintUtilUnannotated) {
- if (0 != PrintBuf((const void*)fq12_elem_str, sizeof(*fq12_elem_str))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- } else {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
-}
-
-void PrintG1ElemStr(G1ElemStr const* g1_elem_str, char const* var_name,
- PrintUtilFormat format) {
- if (!var_name) {
- var_name = "";
- }
- PRINT("%s (G1ElemStr):\n", var_name);
- if (!g1_elem_str) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- if (format == kPrintUtilAnnotated) {
- MAKE_INDENT();
- PRINT("x:\n");
- if (0 != PrintBuf((const void*)&g1_elem_str->x, sizeof(g1_elem_str->x))) {
- MAKE_INDENT();
- PRINT("\n");
- return;
- }
- MAKE_INDENT();
- PRINT("y:\n");
- if (0 != PrintBuf((const void*)&g1_elem_str->y, sizeof(g1_elem_str->y))) {
- MAKE_INDENT();
- PRINT("