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 00 */ -__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("\n"); - return; - } - } else if (format == kPrintUtilUnannotated) { - if (0 != PrintBuf((const void*)g1_elem_str, sizeof(*g1_elem_str))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - } else { - MAKE_INDENT(); - PRINT("\n"); - return; - } -} - -void PrintG2ElemStr(G2ElemStr const* g2_elem_str, char const* var_name, - PrintUtilFormat format) { - if (!var_name) { - var_name = ""; - } - PRINT("%s (G2ElemStr):\n", var_name); - if (!g2_elem_str) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - if (format == kPrintUtilAnnotated) { - MAKE_INDENT(); - PRINT("x0:\n"); - if (0 != - PrintBuf((const void*)&g2_elem_str->x[0], sizeof(g2_elem_str->x[0]))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - MAKE_INDENT(); - PRINT("x1:\n"); - if (0 != - PrintBuf((const void*)&g2_elem_str->x[1], sizeof(g2_elem_str->x[1]))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - MAKE_INDENT(); - PRINT("y0:\n"); - if (0 != - PrintBuf((const void*)&g2_elem_str->y[0], sizeof(g2_elem_str->y[0]))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - MAKE_INDENT(); - PRINT("y1:\n"); - if (0 != - PrintBuf((const void*)&g2_elem_str->y[1], sizeof(g2_elem_str->y[1]))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - } else if (format == kPrintUtilUnannotated) { - if (0 != PrintBuf((const void*)g2_elem_str, sizeof(*g2_elem_str))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - } else { - MAKE_INDENT(); - PRINT("\n"); - return; - } -} - -void PrintGtElemStr(GtElemStr const* gt_elem_str, char const* var_name, - PrintUtilFormat format) { - if (!var_name) { - var_name = ""; - } - PRINT("%s (GtElemStr):\n", var_name); - if (!gt_elem_str) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - if (format == kPrintUtilAnnotated) { - unsigned int i = 0; - for (i = 0; i < sizeof(gt_elem_str->x) / sizeof(gt_elem_str->x[0]); i++) { - MAKE_INDENT(); - PRINT("x%u:\n", i); - if (0 != PrintBuf((const void*)>_elem_str->x[i], - sizeof(gt_elem_str->x[i]))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - } - } else if (format == kPrintUtilUnannotated) { - if (0 != PrintBuf((const void*)gt_elem_str, sizeof(*gt_elem_str))) { - MAKE_INDENT(); - PRINT("\n"); - return; - } - } else { - MAKE_INDENT(); - PRINT("\n"); - return; - } -} - -#ifdef EPID_ENABLE_DEBUG_PRINT -#undef EPID_ENABLE_DEBUG_PRINT -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.h b/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.h deleted file mode 100644 index 463f4651cd..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/printutils.h +++ /dev/null @@ -1,287 +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 interface. - */ -#ifndef EPID_COMMON_MATH_PRINTUTILS_H_ -#define EPID_COMMON_MATH_PRINTUTILS_H_ - -#include "epid/common/types.h" -#include "epid/common/math/bignum.h" -#include "epid/common/math/finitefield.h" -#include "epid/common/math/ecgroup.h" - -/// Debug print routines -/*! - \defgroup EpidPrint print_utils - Defines an API to print formatted versions of the types used for - mathematical operations. - - If the symbol EPID_ENABLE_DEBUG_PRINT is not defined, all calls to the - functions in this module are ignored. - - \ingroup EpidCommon - @{ -*/ - -#if !defined(EPID_ENABLE_DEBUG_PRINT) - -/// Do not print bignum if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintBigNum(...) - -/// Do not print ff element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFfElement(...) - -/// Do not print ec point if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintEcPoint(...) - -/// Do not print serialized bignum if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintBigNumStr(...) - -/// Do not print Fp element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFpElemStr(...) - -/// Do not print Fq element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFqElemStr(...) - -/// Do not print Fq2 element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFq2ElemStr(...) - -/// Do not print Fq6 element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFq6ElemStr(...) - -/// Do not print Fq12 element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintFq12ElemStr(...) - -/// Do not print G1 element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintG1ElemStr(...) - -/// Do not print G2 element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintG2ElemStr(...) - -/// Do not print Gt element if EPID_ENABLE_DEBUG_PRINT is undefined -#define PrintGtElemStr(...) - -#else - -/// Print format -typedef enum { - kPrintUtilUnannotated = 0, //!< Unannotated output format - kPrintUtilAnnotated = 1, //!< Annotated output format -} PrintUtilFormat; - -/// Prints BigNum -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] big_num - BigNum to be printed - \param[in] var_name - Result variable name - -*/ -void PrintBigNum(BigNum const* big_num, char const* var_name); - -/// Prints finite field element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] ff - Finite field that element to be printed belongs to - \param[in] ff_element - Finite field element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintFfElement(FiniteField const* ff, FfElement const* ff_element, - char const* var_name, PrintUtilFormat format); - -/// Prints elliptic curve group element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] g - Elliptic curve group that element to be printed belongs to - \param[in] ec_point - Elliptic curve group element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintEcPoint(EcGroup const* g, EcPoint const* ec_point, - char const* var_name, PrintUtilFormat format); - -/// Prints serialized BigNum -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] big_num_str - Serialized BigNum to be printed - \param[in] var_name - Result variable name - -*/ -void PrintBigNumStr(BigNumStr const* big_num_str, char const* var_name); - -/// Prints serialized Fp element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] fp_elem_str - Serialized Fp element to be printed - \param[in] var_name - Result variable name - -*/ -void PrintFpElemStr(FpElemStr const* fp_elem_str, char const* var_name); - -/// Prints serialized Fq element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] fq_elem_str - Serialized Fq element to be printed - \param[in] var_name - Result variable name - -*/ -void PrintFqElemStr(FqElemStr const* fq_elem_str, char const* var_name); - -/// Prints serialized Fq2 element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] fq2_elem_str - Serialized Fq2 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintFq2ElemStr(Fq2ElemStr const* fq2_elem_str, char const* var_name, - PrintUtilFormat format); - -/// Prints serialized Fq6 element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] fq6_elem_str - Serialized Fq6 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintFq6ElemStr(Fq6ElemStr const* fq6_elem_str, char const* var_name, - PrintUtilFormat format); - -/// Prints serialized Fq12 element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] fq12_elem_str - Serialized Intel(R) EPID Fq12 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintFq12ElemStr(Fq12ElemStr const* fq12_elem_str, char const* var_name, - PrintUtilFormat format); - -/// Prints serialized G1 element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] g1_elem_str - Serialized G1 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintG1ElemStr(G1ElemStr const* g1_elem_str, char const* var_name, - PrintUtilFormat format); - -/// Prints serialized G2 element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] g2_elem_str - Serialized G2 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintG2ElemStr(G2ElemStr const* g2_elem_str, char const* var_name, - PrintUtilFormat format); - -/// Prints serialized Gt element -/*! - Macro EPID_ENABLE_DEBUG_PRINT needs to be defined - in order to activate this routine; otherwise, - it prints nothing. - - \param[in] gt_elem_str - Serialized G2 element to be printed - \param[in] var_name - Result variable name - \param[in] format - Output format - -*/ -void PrintGtElemStr(GtElemStr const* gt_elem_str, char const* var_name, - PrintUtilFormat format); - -#endif // !defined( EPID_ENABLE_DEBUG_PRINT ) -/*! @} */ - -#endif // EPID_COMMON_MATH_PRINTUTILS_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/sha256.c b/sgx-jvm/linux-sgx/external/epid/epid/common/math/sha256.c deleted file mode 100644 index 7f1b3f3101..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/sha256.c +++ /dev/null @@ -1,43 +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 SHA256 implementation. -*/ -#include "epid/common/math/hash.h" -#include "ext/ipp/include/ippcp.h" - -EpidStatus Sha256MessageDigest(void const* msg, size_t len, - Sha256Digest* digest) { - IppStatus sts; - int ipp_len = (int)len; - - if ((len && !msg) || !digest) return kEpidBadArgErr; - - if (INT_MAX < len) return kEpidBadArgErr; - - sts = ippsSHA256MessageDigest(msg, ipp_len, (Ipp8u*)digest); - if (ippStsNoErr != sts) { - if (ippStsLengthErr == sts) { - return kEpidBadArgErr; - } else { - return kEpidMathErr; - } - } - - return kEpidNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/bignum-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/bignum-test.cc deleted file mode 100644 index 3f34b44cda..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/bignum-test.cc +++ /dev/null @@ -1,394 +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 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 BigNumTest : public ::testing::Test { - public: - static const BigNumStr str_0; - static const BigNumStr str_1; - static const BigNumStr str_2; - static const BigNumStr str_big; - static const BigNumStr str_2big; - static const BigNumStr str_large_m1; - static const BigNumStr str_large; - static const BigNumStr str_large_p1; - static const BigNumStr str_32byte_high_bit_set; - static const BigNumStr str_32byte_high; - static const std::vector vec_33byte_low; - virtual void SetUp() {} - - virtual void TearDown() {} - - ::testing::AssertionResult CompareBigNumStr(const BigNumStr* expected, - const BigNumStr* actual); - - ::testing::AssertionResult CompareBigNum(const BigNum* expected, - const BigNum* actual); -}; - -const BigNumStr BigNumTest::str_0{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 BigNumTest::str_1{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 BigNumStr BigNumTest::str_2{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 BigNumStr BigNumTest::str_big{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const BigNumStr BigNumTest::str_2big{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const BigNumStr BigNumTest::str_large_m1{ - 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, 0x0C}; - -/// Intel(R) EPID 2.0 parameter p -const BigNumStr BigNumTest::str_large{ - 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 BigNumTest::str_large_p1{ - 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, 0x0E}; -const BigNumStr BigNumTest::str_32byte_high{ - 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, 0xFF}; -const BigNumStr BigNumTest::str_32byte_high_bit_set{ - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 std::vector BigNumTest::vec_33byte_low{ - 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}; - -::testing::AssertionResult BigNumTest::CompareBigNumStr( - const BigNumStr* expected, const BigNumStr* actual) { - int size = sizeof(BigNumStr); - unsigned char* expected_str = (unsigned char*)expected; - unsigned char* actual_str = (unsigned char*)actual; - for (int i = 0; i < size; ++i) { - if (expected_str[i] != actual_str[i]) { - return ::testing::AssertionFailure() - << "Mismatch at " << i << " : Expected " << std::hex - << expected_str[i] << " Found " << std::hex << actual_str[i]; - } - } - - return ::testing::AssertionSuccess(); -} - -::testing::AssertionResult BigNumTest::CompareBigNum(const BigNum* expected_bn, - const BigNum* actual_bn) { - size_t size = 0; - std::vector expected_str; - std::vector actual_str; - // Use an extra huge size so we have plenty of room to check - // overflow tests. This assumes no tests try to create a number - // bigger than 64 bytes. - size = sizeof(BigNumStr) * 2; - expected_str.resize(size, 0); - actual_str.resize(size, 0); - - THROW_ON_EPIDERR(WriteBigNum(expected_bn, size, &expected_str[0])); - THROW_ON_EPIDERR(WriteBigNum(actual_bn, size, &actual_str[0])); - - for (size_t i = 0; i < size; ++i) { - if (expected_str[i] != actual_str[i]) { - return ::testing::AssertionFailure() << "Numbers do not match"; - } - } - - return ::testing::AssertionSuccess(); -} - -/////////////////////////////////////////////////////////////////////// -// Create / Destroy - -TEST_F(BigNumTest, NewCanCreate256BitBigNum) { - BigNum* bn = nullptr; - EXPECT_EQ(kEpidNoErr, NewBigNum(32, &bn)); - DeleteBigNum(&bn); -} - -TEST_F(BigNumTest, NewFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, NewBigNum(sizeof(BigNumStr), NULL)); -} - -TEST_F(BigNumTest, NewFailsGivenSizeZero) { - BigNum* bn = nullptr; - EXPECT_EQ(kEpidBadArgErr, NewBigNum(0, &bn)); - DeleteBigNum(&bn); -} - -TEST_F(BigNumTest, DeleteBigNumNullsPointer) { - BigNum* bn = nullptr; - THROW_ON_EPIDERR(NewBigNum(sizeof(BigNumStr), &bn)); - DeleteBigNum(&bn); - EXPECT_EQ(nullptr, bn); -} - -TEST_F(BigNumTest, DeleteWorksGivenNullPointer) { - BigNum* bn = nullptr; - DeleteBigNum(nullptr); - EXPECT_EQ(nullptr, bn); -} - -/////////////////////////////////////////////////////////////////////// -// Serialization - -TEST_F(BigNumTest, ReadFailsGivenNullPtr) { - BigNum* bn = nullptr; - THROW_ON_EPIDERR(NewBigNum(sizeof(BigNumStr), &bn)); - EXPECT_EQ(kEpidBadArgErr, ReadBigNum(NULL, sizeof(BigNumStr), bn)); - EXPECT_EQ(kEpidBadArgErr, - ReadBigNum(&this->str_large, sizeof(BigNumStr), NULL)); - DeleteBigNum(&bn); -} - -TEST_F(BigNumTest, ReadFailsGivenInvalidBufferSize) { - BigNumObj bn(32); - EXPECT_EQ(kEpidBadArgErr, ReadBigNum(&this->str_0, 0, bn)); - EXPECT_EQ(kEpidBadArgErr, - ReadBigNum(&this->str_0, std::numeric_limits::max(), bn)); -#if (SIZE_MAX >= 0x100000001) // When size_t value allowed to be 0x100000001 - EXPECT_EQ(kEpidBadArgErr, ReadBigNum(&this->str_0, 0x100000001, bn)); -#endif -} - -TEST_F(BigNumTest, ReadFailsGivenTooBigBuffer) { - BigNum* bn = nullptr; - THROW_ON_EPIDERR(NewBigNum(sizeof(BigNumStr), &bn)); - EXPECT_NE(kEpidNoErr, ReadBigNum(&this->vec_33byte_low[0], - this->vec_33byte_low.size(), bn)); - DeleteBigNum(&bn); -} - -TEST_F(BigNumTest, WriteFailsGivenNullPtr) { - BigNum* bn = nullptr; - BigNumStr str = {0}; - THROW_ON_EPIDERR(NewBigNum(sizeof(BigNumStr), &bn)); - EXPECT_EQ(kEpidBadArgErr, WriteBigNum(NULL, sizeof(str), &str)); - EXPECT_EQ(kEpidBadArgErr, WriteBigNum(bn, 0, NULL)); - DeleteBigNum(&bn); -} - -TEST_F(BigNumTest, WriteFailsGivenTooSmallBuffer) { - BigNumStr str; - BigNumObj bn(this->vec_33byte_low); - EXPECT_NE(kEpidNoErr, WriteBigNum(bn, sizeof(str), &str)); -} - -TEST_F(BigNumTest, ReadCanDeSerializeBigNumStrZero) { - BigNumObj bn_ref; - BigNumObj bn; - EXPECT_EQ(kEpidNoErr, ReadBigNum(&this->str_0, sizeof(this->str_0), bn)); - // No way to check this yet -} - -TEST_F(BigNumTest, ReadCanDeSerializeBigNum) { - BigNumObj bn; - EXPECT_EQ(kEpidNoErr, - ReadBigNum(&this->str_large, sizeof(this->str_large), bn)); - // No way to check this yet -} - -TEST_F(BigNumTest, WriteCanSerializeBigNumZero) { - BigNumObj bn; // defaults to 0 - BigNumStr str; - EXPECT_EQ(kEpidNoErr, WriteBigNum(bn, sizeof(str), &str)); - EXPECT_TRUE(CompareBigNumStr(&str, &this->str_0)); -} - -TEST_F(BigNumTest, DeSerializeFollowedBySerializeHasSameValue) { - BigNumStr str; - BigNumObj bn; - EXPECT_EQ(kEpidNoErr, - ReadBigNum(&this->str_large, sizeof(this->str_large), bn)); - EXPECT_EQ(kEpidNoErr, WriteBigNum(bn, sizeof(str), &str)); - EXPECT_TRUE(CompareBigNumStr(&this->str_large, &str)); -} - -/////////////////////////////////////////////////////////////////////// -// Addition - -TEST_F(BigNumTest, AddBadArgumentsFail) { - BigNumObj bn; - EXPECT_NE(kEpidNoErr, BigNumAdd(nullptr, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumAdd(bn, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumAdd(nullptr, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumAdd(nullptr, nullptr, bn)); - EXPECT_NE(kEpidNoErr, BigNumAdd(bn, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumAdd(nullptr, bn, bn)); - EXPECT_NE(kEpidNoErr, BigNumAdd(bn, nullptr, bn)); -} - -TEST_F(BigNumTest, AddZeroIsIdentity) { - BigNumObj bn; - BigNumObj bn_0(this->str_0); - BigNumObj bn_large(this->str_large); - EXPECT_EQ(kEpidNoErr, BigNumAdd(bn_large, bn_0, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_large)); -} - -TEST_F(BigNumTest, AddOneIncrements) { - BigNumObj bn; - BigNumObj bn_1(this->str_1); - BigNumObj bn_large(this->str_large); - BigNumObj bn_large_p1(this->str_large_p1); - EXPECT_EQ(kEpidNoErr, BigNumAdd(bn_large, bn_1, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_large_p1)); -} - -TEST_F(BigNumTest, AddOneTo32ByteInTo32BytesFails) { - BigNumObj bn(32); - BigNumObj bn_1(this->str_1); - BigNumObj bn_32high(this->str_32byte_high); - EXPECT_NE(kEpidNoErr, BigNumAdd(bn_32high, bn_1, bn)); -} - -TEST_F(BigNumTest, AddOneTo32ByteInTo33BytesIncrements) { - BigNumObj bn(33); - BigNumObj bn_1(this->str_1); - BigNumObj bn_32high(this->str_32byte_high); - BigNumObj bn_33low(this->vec_33byte_low); - EXPECT_EQ(kEpidNoErr, BigNumAdd(bn_32high, bn_1, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_33low)); -} - -/////////////////////////////////////////////////////////////////////// -// Subtraction - -TEST_F(BigNumTest, SubBadArgumentsFail) { - BigNumObj bn; - EXPECT_NE(kEpidNoErr, BigNumSub(nullptr, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumSub(bn, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumSub(nullptr, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumSub(nullptr, nullptr, bn)); - EXPECT_NE(kEpidNoErr, BigNumSub(bn, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumSub(nullptr, bn, bn)); - EXPECT_NE(kEpidNoErr, BigNumSub(bn, nullptr, bn)); -} - -TEST_F(BigNumTest, SubOneFromZeroFails) { - BigNumObj bn; - BigNumObj bn_0(this->str_0); - BigNumObj bn_1(this->str_1); - EXPECT_EQ(kEpidUnderflowErr, BigNumSub(bn_0, bn_1, bn)); -} - -TEST_F(BigNumTest, SubZeroIsIdentity) { - BigNumObj bn; - BigNumObj bn_0(this->str_0); - BigNumObj bn_large(this->str_large); - EXPECT_EQ(kEpidNoErr, BigNumSub(bn_large, bn_0, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_large)); -} - -TEST_F(BigNumTest, SubOneDecrements) { - BigNumObj bn; - BigNumObj bn_1(this->str_1); - BigNumObj bn_large(this->str_large); - BigNumObj bn_large_m1(this->str_large_m1); - EXPECT_EQ(kEpidNoErr, BigNumSub(bn_large, bn_1, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_large_m1)); -} - -/////////////////////////////////////////////////////////////////////// -// Multiplication - -TEST_F(BigNumTest, MulBadArgumentsFail) { - BigNumObj bn; - EXPECT_NE(kEpidNoErr, BigNumMul(nullptr, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumMul(bn, nullptr, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumMul(nullptr, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumMul(nullptr, nullptr, bn)); - EXPECT_NE(kEpidNoErr, BigNumMul(bn, bn, nullptr)); - EXPECT_NE(kEpidNoErr, BigNumMul(nullptr, bn, bn)); - EXPECT_NE(kEpidNoErr, BigNumMul(bn, nullptr, bn)); -} - -TEST_F(BigNumTest, MulOneIsIdentity) { - BigNumObj bn; - BigNumObj bn_1(this->str_1); - BigNumObj bn_large(this->str_large); - EXPECT_EQ(kEpidNoErr, BigNumMul(bn_large, bn_1, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_large)); -} - -TEST_F(BigNumTest, MulTwoIsDouble) { - BigNumObj bn; - BigNumObj bn_2(this->str_2); - BigNumObj bn_big(this->str_big); - BigNumObj bn_2big(this->str_2big); - EXPECT_EQ(kEpidNoErr, BigNumMul(bn_big, bn_2, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_2big)); -} - -TEST_F(BigNumTest, MulZeroIsZero) { - BigNumObj bn; - BigNumObj bn_0(this->str_0); - BigNumObj bn_large(this->str_large); - EXPECT_EQ(kEpidNoErr, BigNumMul(bn_large, bn_0, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_0)); -} - -TEST_F(BigNumTest, MulReportsErrorGivenOverflow) { - BigNumObj bn(32); - BigNumObj bn_2(this->str_2); - BigNumObj bn_high_bit_set(this->str_32byte_high_bit_set); - EXPECT_EQ(kEpidBadArgErr, BigNumMul(bn_high_bit_set, bn_2, bn)); -} - -TEST_F(BigNumTest, MulWorksWith264BitValue) { - BigNumObj bn(33); - BigNumObj bn_2(this->str_2); - BigNumObj bn_high_bit_set(this->str_32byte_high_bit_set); - BigNumObj bn_33low(this->vec_33byte_low); - EXPECT_EQ(kEpidNoErr, BigNumMul(bn_high_bit_set, bn_2, bn)); - EXPECT_TRUE(CompareBigNum(bn, bn_33low)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_sign-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_sign-test.cc deleted file mode 100644 index ce47b5b377..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_sign-test.cc +++ /dev/null @@ -1,229 +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 unit tests. - */ - -#include -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/common/math/ecdsa.h" -#include "epid/common/memory.h" -} - -#include "epid/common-testhelper/prng-testhelper.h" - -bool operator==(EcdsaSignature const& lhs, EcdsaSignature const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -namespace { -/// Fill message buffer -/*! - - Fill a message buffer - - \param[in] buf - pointer to buffer to be filled - \param[in] buf_len - size of buffer in bytes - - \returns ::EpidStatus -*/ -static EpidStatus FillMessage(uint8_t* buf, size_t buf_len) { - if (!buf) return kEpidBadArgErr; - if (buf_len <= 0) return kEpidBadArgErr; - for (size_t n = 0; n < buf_len; n++) { - buf[n] = (uint8_t)n; - } - return kEpidNoErr; -} -class EcdsaSignBufferTest : public ::testing::Test { - public: - /// Signer's static private key (ECDSA-256 RFC 4754 Test Vector) - static const EcdsaPrivateKey kPrivkey0; - /// Signer's static public key (ECDSA-256 RFC 4754 Test Vector) - static const EcdsaPublicKey kPubkey0; - /// Signer's ephemeral private key (ECDSA-256 RFC 4754 Test Vector) - static const EcdsaPrivateKey kEphPrivkey0; - /// Message (ECDSA-256 RFC 4754 Test Vector) - static const std::vector kMsg0; - /// Signature of msg0 with privkey0 and kEphPrivkey0 - static const EcdsaSignature kSig_msg0_key0; - /// Signature of empty msg with privkey0 and kEphPrivkey0 - static const EcdsaSignature kSig_emptymsg_key0; - /// Signature of 1M msg with privkey0 and kEphPrivkey0 - static const EcdsaSignature kSig_1Mmsg_key0; -}; - -const EcdsaPrivateKey EcdsaSignBufferTest::kPrivkey0 = { - 0xDC, 0x51, 0xD3, 0x86, 0x6A, 0x15, 0xBA, 0xCD, 0xE3, 0x3D, 0x96, - 0xF9, 0x92, 0xFC, 0xA9, 0x9D, 0xA7, 0xE6, 0xEF, 0x09, 0x34, 0xE7, - 0x09, 0x75, 0x59, 0xC2, 0x7F, 0x16, 0x14, 0xC8, 0x8A, 0x7F}; -const EcdsaPublicKey EcdsaSignBufferTest::kPubkey0 = { - 0x24, 0x42, 0xA5, 0xCC, 0x0E, 0xCD, 0x01, 0x5F, 0xA3, 0xCA, 0x31, - 0xDC, 0x8E, 0x2B, 0xBC, 0x70, 0xBF, 0x42, 0xD6, 0x0C, 0xBC, 0xA2, - 0x00, 0x85, 0xE0, 0x82, 0x2C, 0xB0, 0x42, 0x35, 0xE9, 0x70, 0x6F, - 0xC9, 0x8B, 0xD7, 0xE5, 0x02, 0x11, 0xA4, 0xA2, 0x71, 0x02, 0xFA, - 0x35, 0x49, 0xDF, 0x79, 0xEB, 0xCB, 0x4B, 0xF2, 0x46, 0xB8, 0x09, - 0x45, 0xCD, 0xDF, 0xE7, 0xD5, 0x09, 0xBB, 0xFD, 0x7D}; -const EcdsaPrivateKey EcdsaSignBufferTest::kEphPrivkey0 = { - 0x9E, 0x56, 0xF5, 0x09, 0x19, 0x67, 0x84, 0xD9, 0x63, 0xD1, 0xC0, - 0xA4, 0x01, 0x51, 0x0E, 0xE7, 0xAD, 0xA3, 0xDC, 0xC5, 0xDE, 0xE0, - 0x4B, 0x15, 0x4B, 0xF6, 0x1A, 0xF1, 0xD5, 0xA6, 0xDE, 0xCE}; -/* - -Ephemeral public key expected to be generated for kEphPrivkey0: -gkx: ephemeral public key: -CB28E099 9B9C7715 FD0A80D8 E47A7707 9716CBBF 917DD72E 97566EA1 C066957C -gky: ephemeral public key: -2B57C023 5FB74897 68D058FF 4911C20F DBE71E36 99D91339 AFBB903E E17255DC -*/ - -const std::vector EcdsaSignBufferTest::kMsg0 = {'a', 'b', 'c'}; - -const EcdsaSignature EcdsaSignBufferTest::kSig_msg0_key0 = { - 0xCB, 0x28, 0xE0, 0x99, 0x9B, 0x9C, 0x77, 0x15, 0xFD, 0x0A, 0x80, - 0xD8, 0xE4, 0x7A, 0x77, 0x07, 0x97, 0x16, 0xCB, 0xBF, 0x91, 0x7D, - 0xD7, 0x2E, 0x97, 0x56, 0x6E, 0xA1, 0xC0, 0x66, 0x95, 0x7C, 0x86, - 0xFA, 0x3B, 0xB4, 0xE2, 0x6C, 0xAD, 0x5B, 0xF9, 0x0B, 0x7F, 0x81, - 0x89, 0x92, 0x56, 0xCE, 0x75, 0x94, 0xBB, 0x1E, 0xA0, 0xC8, 0x92, - 0x12, 0x74, 0x8B, 0xFF, 0x3B, 0x3D, 0x5B, 0x03, 0x15, -}; -const EcdsaSignature EcdsaSignBufferTest::kSig_emptymsg_key0 = { - 0xCB, 0x28, 0xE0, 0x99, 0x9B, 0x9C, 0x77, 0x15, 0xFD, 0x0A, 0x80, - 0xD8, 0xE4, 0x7A, 0x77, 0x07, 0x97, 0x16, 0xCB, 0xBF, 0x91, 0x7D, - 0xD7, 0x2E, 0x97, 0x56, 0x6E, 0xA1, 0xC0, 0x66, 0x95, 0x7C, 0x8c, - 0x09, 0x5c, 0xec, 0xd5, 0xcf, 0xec, 0x1e, 0xa5, 0xb6, 0xa6, 0x44, - 0x1e, 0x12, 0x3d, 0x30, 0xff, 0x97, 0xdd, 0x4b, 0x44, 0xc1, 0x70, - 0x7c, 0x95, 0x9d, 0x7f, 0x46, 0x86, 0x73, 0x55, 0xae, -}; -const EcdsaSignature EcdsaSignBufferTest::kSig_1Mmsg_key0 = { - 0xCB, 0x28, 0xE0, 0x99, 0x9B, 0x9C, 0x77, 0x15, 0xFD, 0x0A, 0x80, - 0xD8, 0xE4, 0x7A, 0x77, 0x07, 0x97, 0x16, 0xCB, 0xBF, 0x91, 0x7D, - 0xD7, 0x2E, 0x97, 0x56, 0x6E, 0xA1, 0xC0, 0x66, 0x95, 0x7C, 0xf9, - 0xa5, 0x3a, 0xbf, 0x22, 0xe7, 0xf3, 0x97, 0x5a, 0x8c, 0xce, 0xb8, - 0xca, 0x7b, 0xae, 0x9d, 0xd8, 0x7f, 0x43, 0xa9, 0xef, 0x40, 0x78, - 0x56, 0x37, 0xcc, 0xb2, 0xda, 0x1e, 0x04, 0x31, 0x03, -}; - -static int __STDCALL constant_32byte_endianswap_prng(unsigned int* random_data, - int num_bits, - void* user_data) { - if (256 != num_bits) return -1; - for (int i = 0; i < 32; i++) { - ((uint8_t*)random_data)[i] = ((uint8_t*)user_data)[31 - i]; - } - return 0; -} - -static int __STDCALL contextless_kEphPrivkey0_prng(unsigned int* random_data, - int num_bits, - void* user_data) { - (void)user_data; - return constant_32byte_endianswap_prng( - random_data, num_bits, - (void*)(EcdsaSignBufferTest::kEphPrivkey0.data.data)); -} - -TEST_F(EcdsaSignBufferTest, FailsGivenNullPtr) { - uint8_t msg[1]; - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - EcdsaSignature signature; - - EXPECT_EQ(kEpidBadArgErr, - EcdsaSignBuffer(nullptr, sizeof(msg), &this->kPrivkey0, rnd_func, - rnd_param, &signature)); - EXPECT_EQ(kEpidBadArgErr, EcdsaSignBuffer(msg, sizeof(msg), nullptr, rnd_func, - rnd_param, &signature)); - EXPECT_EQ(kEpidBadArgErr, EcdsaSignBuffer(msg, sizeof(msg), &this->kPrivkey0, - nullptr, rnd_param, &signature)); - EXPECT_EQ(kEpidBadArgErr, EcdsaSignBuffer(msg, sizeof(msg), &this->kPrivkey0, - rnd_func, rnd_param, nullptr)); -} - -TEST_F(EcdsaSignBufferTest, SignsEmptyMessage) { - uint8_t msg[1]; - EcdsaSignature signature; - - EXPECT_EQ( - kEpidNoErr, - EcdsaSignBuffer(msg, 0, &this->kPrivkey0, constant_32byte_endianswap_prng, - (void*)&(this->kEphPrivkey0), &signature)); - EXPECT_EQ(this->kSig_emptymsg_key0, signature); - EXPECT_EQ(kEpidNoErr, - EcdsaSignBuffer(nullptr, 0, &this->kPrivkey0, - constant_32byte_endianswap_prng, - (void*)&(this->kEphPrivkey0), &signature)); - EXPECT_EQ(this->kSig_emptymsg_key0, signature); -} - -TEST_F(EcdsaSignBufferTest, WorksGivenNoRndParam) { - EcdsaSignature signature; - - EXPECT_EQ( - kEpidNoErr, - EcdsaSignBuffer(this->kMsg0.data(), this->kMsg0.size(), &this->kPrivkey0, - contextless_kEphPrivkey0_prng, nullptr, &signature)); - EXPECT_EQ(this->kSig_msg0_key0, signature); -} - -TEST_F(EcdsaSignBufferTest, SignsShortMessage) { - EcdsaSignature signature; - - EXPECT_EQ(kEpidNoErr, - EcdsaSignBuffer(this->kMsg0.data(), this->kMsg0.size(), - &this->kPrivkey0, constant_32byte_endianswap_prng, - (void*)&(this->kEphPrivkey0), &signature)); - EXPECT_EQ(this->kSig_msg0_key0, signature); -} - -TEST_F(EcdsaSignBufferTest, SignsLongMessage) { - std::vector msg_1mb(0x100000); - FillMessage(msg_1mb.data(), msg_1mb.size()); - - EcdsaSignature signature; - - EXPECT_EQ(kEpidNoErr, - EcdsaSignBuffer(msg_1mb.data(), msg_1mb.size(), &this->kPrivkey0, - constant_32byte_endianswap_prng, - (void*)&(this->kEphPrivkey0), &signature)); - EXPECT_EQ(this->kSig_1Mmsg_key0, signature); -} - -TEST_F(EcdsaSignBufferTest, FailsGivenInvalidPrivateKey) { - uint8_t msg[1] = {0x00}; - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - EcdsaSignature signature; - - EcdsaPrivateKey invalid_prikey; - memset(&invalid_prikey, 0xff, sizeof(invalid_prikey)); - - EXPECT_EQ(kEpidBadArgErr, EcdsaSignBuffer(msg, sizeof(msg), &invalid_prikey, - rnd_func, rnd_param, &signature)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_verify-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_verify-test.cc deleted file mode 100644 index 7f28330343..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecdsa_verify-test.cc +++ /dev/null @@ -1,278 +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 unit tests. - */ - -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/common/math/ecdsa.h" -} - -namespace { - -/// Fill message buffer -/*! - - Fill a message buffer - - \param[in] buf - pointer to buffer to be filled - \param[in] buf_len - size of buffer in bytes - - \returns ::EpidStatus -*/ -static EpidStatus fill_message(uint8_t* buf, size_t buf_len) { - if (!buf) return kEpidBadArgErr; - if (buf_len <= 0) return kEpidBadArgErr; - for (size_t n = 0; n < buf_len; n++) { - buf[n] = (uint8_t)n; - } - return kEpidNoErr; -} -class EcdsaVerifyBufferTest : public ::testing::Test { - public: - /// an Ecdsa key pair - /// Regular - static const EcdsaPrivateKey kPrivkey0; - static const EcdsaPublicKey kPubkey0; - /// an Ecdsa key pair - // Regular - static const EcdsaPrivateKey kPrivkey1; - static const EcdsaPublicKey kPubkey1; - /// a message - static const std::vector kMsg0; - /// a message - static const std::vector kMsg1; - /// signature of msg0 with privkey0 - static const EcdsaSignature kSig_msg0_key0; - /// signature of msg0 with privkey1 - static const EcdsaSignature kSig_msg0_key1; - /// signature of msg1 with privkey0 - static const EcdsaSignature kSig_msg1_key0; - /// signature of msg1 with privkey1 - static const EcdsaSignature kSig_msg1_key1; - /// signature of empty msg with privkey0 - static const EcdsaSignature kSig_emptymsg_key0; - /// signature of empty msg with privkey1 - static const EcdsaSignature kSig_emptymsg_key1; - /// signature of 1M msg with privkey0 - static const EcdsaSignature kSig_1Mmsg_key0; - /// signature of 1M msg with privkey1 - static const EcdsaSignature kSig_1Mmsg_key1; -}; - -const EcdsaPrivateKey EcdsaVerifyBufferTest::kPrivkey0 = { - 0xfc, 0x0e, 0x32, 0x3b, 0x5d, 0xf6, 0x95, 0x43, 0x99, 0x0f, 0x46, - 0x37, 0xb0, 0x19, 0xb3, 0xbb, 0xba, 0xd5, 0x91, 0x63, 0x2d, 0x4a, - 0x5a, 0x1e, 0xd8, 0x09, 0x4f, 0x44, 0xa9, 0x5c, 0xd8, 0x87, -}; -const EcdsaPublicKey EcdsaVerifyBufferTest::kPubkey0 = { - 0x32, 0x05, 0x28, 0x50, 0x53, 0x0c, 0x62, 0xdf, 0x17, 0xc7, 0xcb, - 0x8c, 0xd3, 0x6f, 0x05, 0xe8, 0xbb, 0xbb, 0x6a, 0xf4, 0x43, 0x82, - 0x59, 0xad, 0xd2, 0x56, 0x6c, 0x63, 0xde, 0x06, 0x37, 0x69, 0x7b, - 0x42, 0x9a, 0xda, 0x3c, 0x91, 0xf3, 0xc0, 0xdd, 0xc1, 0xd4, 0x9e, - 0xc2, 0x24, 0x32, 0x09, 0x07, 0x8c, 0xb9, 0xfc, 0xd8, 0x7b, 0x69, - 0xf9, 0x17, 0x1e, 0x35, 0xb4, 0x20, 0x23, 0x45, 0x94, -}; - -const EcdsaPrivateKey EcdsaVerifyBufferTest::kPrivkey1 = { - 0xd6, 0x5a, 0x82, 0x5d, 0xd4, 0xad, 0x28, 0x6f, 0x09, 0x2c, 0x96, - 0x07, 0x0a, 0x96, 0xac, 0x13, 0xc9, 0xfd, 0xcf, 0xf0, 0xbe, 0x08, - 0xcb, 0xbb, 0x4b, 0xba, 0x7e, 0x9e, 0xac, 0x02, 0xe9, 0x7c, -}; -const EcdsaPublicKey EcdsaVerifyBufferTest::kPubkey1 = { - 0x34, 0xb0, 0x88, 0xcc, 0xb7, 0xf3, 0x56, 0xe0, 0x5c, 0x7c, 0xfc, - 0x03, 0x5d, 0x62, 0x72, 0xe4, 0x70, 0x08, 0xcd, 0x6f, 0x4b, 0x29, - 0x0e, 0x2d, 0x86, 0x26, 0x93, 0x52, 0x55, 0xef, 0xb4, 0x45, 0x11, - 0x07, 0xe9, 0xbe, 0x1e, 0x5d, 0xdb, 0x92, 0x64, 0xb6, 0xbf, 0x67, - 0x83, 0x1f, 0xde, 0xaa, 0x72, 0x84, 0xe9, 0x27, 0x5c, 0xd5, 0xbc, - 0x82, 0x07, 0xc9, 0x81, 0xd1, 0x70, 0x07, 0xaa, 0xd5, -}; - -const std::vector EcdsaVerifyBufferTest::kMsg0 = {'m', 's', 'g', '0'}; -const std::vector EcdsaVerifyBufferTest::kMsg1 = {'m', 's', 'g', '1'}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_msg0_key0 = { - 0x81, 0xDD, 0x1A, 0x18, 0x35, 0x1E, 0x22, 0x99, 0x85, 0xC5, 0xAA, - 0xE4, 0x78, 0x02, 0xC5, 0x65, 0xF1, 0x39, 0x80, 0x45, 0xF5, 0xFC, - 0xBD, 0xC6, 0x67, 0xBD, 0xC1, 0x93, 0x42, 0xF6, 0x17, 0x0E, 0x45, - 0x19, 0x39, 0xD3, 0x27, 0x1F, 0xA9, 0x2A, 0x14, 0xDD, 0xF1, 0x5A, - 0x81, 0xA8, 0xEC, 0x3B, 0xB4, 0x0B, 0xF8, 0xC9, 0x9A, 0x06, 0xEB, - 0x04, 0x77, 0x19, 0xCB, 0x57, 0x9C, 0xB9, 0xE9, 0x2F, -}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_msg0_key1 = { - 0xA9, 0xFC, 0x44, 0x2D, 0x09, 0x9E, 0x15, 0x6C, 0x25, 0xD9, 0x74, - 0x9D, 0xD9, 0xAD, 0xC2, 0x7A, 0xFB, 0xC0, 0xD4, 0xFE, 0xC2, 0x48, - 0x41, 0x80, 0x47, 0x4A, 0x74, 0x8A, 0x62, 0x71, 0x68, 0xFF, 0x51, - 0xDF, 0x47, 0x76, 0xAB, 0xD7, 0xE2, 0xA0, 0x97, 0x6B, 0x04, 0x51, - 0x2B, 0x8F, 0x4D, 0x7E, 0xDB, 0x7B, 0x60, 0x08, 0xC6, 0x51, 0x81, - 0x5E, 0x92, 0x9E, 0x11, 0xDB, 0x9C, 0x16, 0x64, 0x79, -}; -const EcdsaSignature EcdsaVerifyBufferTest::kSig_msg1_key0 = { - 0xA4, 0xD7, 0xF9, 0x80, 0xBA, 0x93, 0x25, 0xA4, 0x43, 0xD4, 0xCE, - 0x6F, 0x7C, 0xD9, 0xA9, 0xD2, 0x24, 0x1B, 0xB8, 0x32, 0xDE, 0xE0, - 0x26, 0x01, 0xA6, 0xC8, 0x57, 0x21, 0xD7, 0x1E, 0xBC, 0x88, 0xA2, - 0x27, 0x8B, 0x51, 0x93, 0x90, 0xC0, 0x0A, 0x3B, 0xA4, 0x7A, 0x9B, - 0x8C, 0x5E, 0xC8, 0x8B, 0x39, 0x5F, 0x3D, 0x82, 0xCE, 0x57, 0x9F, - 0xF7, 0x9A, 0x32, 0x82, 0xEF, 0xF8, 0xC5, 0x8B, 0x22, -}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_msg1_key1 = { - 0xC1, 0x0A, 0x01, 0xB3, 0x81, 0x47, 0x02, 0xA4, 0xD2, 0xB1, 0xD6, - 0xF9, 0x25, 0x1F, 0xDF, 0x16, 0x7F, 0x28, 0x7F, 0x04, 0x38, 0xAE, - 0x6D, 0x6E, 0xE7, 0xFC, 0xCB, 0x9E, 0xB6, 0xA4, 0xF6, 0x41, 0x2B, - 0xEA, 0x6B, 0x53, 0x32, 0x7B, 0xB0, 0xB6, 0x8F, 0x21, 0x07, 0x0A, - 0x4C, 0xB7, 0xA9, 0xDE, 0x9F, 0x27, 0x3A, 0xEE, 0x4F, 0xE2, 0xF4, - 0xE3, 0x1E, 0xC3, 0x3F, 0xAA, 0x41, 0xD4, 0xFA, 0xA2, -}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_emptymsg_key0 = { - 0xB7, 0xDC, 0x55, 0x35, 0x12, 0xB9, 0xAE, 0x59, 0xAE, 0xE1, 0xB5, - 0x50, 0x20, 0x65, 0x18, 0x84, 0x3B, 0x1E, 0x54, 0xF4, 0x11, 0x4B, - 0x71, 0xBD, 0x12, 0x5E, 0x05, 0x41, 0xAB, 0x6A, 0xF9, 0x20, 0x26, - 0xC9, 0x2B, 0x21, 0x56, 0x62, 0x3F, 0xC3, 0x62, 0xA0, 0xD2, 0x9D, - 0x27, 0x97, 0xF8, 0xE2, 0x59, 0xE7, 0x0E, 0x7E, 0xEE, 0xA7, 0xB5, - 0x11, 0x66, 0xD0, 0xF3, 0x6E, 0x41, 0x76, 0x3C, 0xFE, -}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_emptymsg_key1 = { - 0xCB, 0xED, 0xEF, 0xEE, 0x11, 0x68, 0x21, 0x7D, 0x57, 0x4A, 0x37, - 0xB1, 0x96, 0xF0, 0xF8, 0x42, 0x46, 0x00, 0x64, 0xEF, 0x19, 0xA7, - 0xFF, 0x38, 0x8F, 0x3A, 0x25, 0xD5, 0xC4, 0xF3, 0xD0, 0xC4, 0xB0, - 0xC4, 0xC5, 0xB0, 0x58, 0xAD, 0x74, 0xF2, 0x19, 0xEE, 0x0C, 0x98, - 0x6D, 0x5F, 0x4F, 0xB7, 0x9A, 0xE8, 0x25, 0x1B, 0xAD, 0x9E, 0x26, - 0x22, 0xF2, 0xED, 0xB1, 0x8D, 0x3B, 0x02, 0x7F, 0xB1, -}; -const EcdsaSignature EcdsaVerifyBufferTest::kSig_1Mmsg_key0 = { - 0x4A, 0x45, 0xE3, 0xA5, 0xFC, 0x73, 0x86, 0xAF, 0xD8, 0x21, 0x25, - 0x35, 0x13, 0xEB, 0x1B, 0xA7, 0x39, 0x08, 0x21, 0x2A, 0x2A, 0x09, - 0x79, 0x3C, 0xEA, 0x17, 0x67, 0x53, 0x6C, 0xE4, 0xA0, 0x97, 0x36, - 0x98, 0x79, 0x69, 0x1C, 0xF1, 0x21, 0x42, 0x56, 0x48, 0x38, 0x35, - 0x3C, 0xC1, 0x30, 0x7C, 0x49, 0x4F, 0xC9, 0xFA, 0xE1, 0x69, 0xF9, - 0x42, 0x3D, 0x7D, 0x4B, 0x6D, 0xB1, 0xEE, 0x9D, 0x4B, -}; - -const EcdsaSignature EcdsaVerifyBufferTest::kSig_1Mmsg_key1 = { - 0x87, 0xE0, 0x27, 0x51, 0xC1, 0x16, 0x79, 0x8F, 0xCF, 0x82, 0x60, - 0x48, 0x72, 0x04, 0xE1, 0xC4, 0xDA, 0xEE, 0x31, 0x4D, 0x12, 0xF9, - 0xCA, 0x19, 0x1B, 0xDC, 0xA4, 0xCA, 0x8C, 0xCC, 0xBD, 0x2A, 0xD4, - 0x73, 0x2B, 0x6B, 0xE4, 0x9B, 0xA1, 0x56, 0xF2, 0x28, 0x4A, 0xBD, - 0x41, 0x69, 0x98, 0xAB, 0x62, 0x3D, 0x8D, 0xC9, 0x77, 0xE1, 0x98, - 0xF1, 0x53, 0xF5, 0xD0, 0x97, 0x80, 0x89, 0xCB, 0x97, -}; -TEST_F(EcdsaVerifyBufferTest, FailsGivenNullParameters) { - // tests using a trivial message - EXPECT_EQ(kEpidBadArgErr, - EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), &kPubkey0, nullptr)); - EXPECT_EQ(kEpidBadArgErr, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - nullptr, &kSig_msg0_key0)); - // tests using a null message - EXPECT_EQ(kEpidBadArgErr, EcdsaVerifyBuffer(nullptr, 0, &kPubkey0, nullptr)); - EXPECT_EQ(kEpidBadArgErr, - EcdsaVerifyBuffer(nullptr, 0, nullptr, &kSig_msg0_key0)); -} - -TEST_F(EcdsaVerifyBufferTest, VerifiesZeroLengthMsg) { - // tests using a non-null message buffer - EXPECT_EQ(kEpidSigValid, - EcdsaVerifyBuffer(kMsg0.data(), 0, &kPubkey0, &kSig_emptymsg_key0)); - EXPECT_EQ(kEpidSigValid, - EcdsaVerifyBuffer(kMsg0.data(), 0, &kPubkey1, &kSig_emptymsg_key1)); - // tests using a null message buffer - EXPECT_EQ(kEpidSigValid, - EcdsaVerifyBuffer(nullptr, 0, &kPubkey0, &kSig_emptymsg_key0)); - EXPECT_EQ(kEpidSigValid, - EcdsaVerifyBuffer(nullptr, 0, &kPubkey1, &kSig_emptymsg_key1)); -} - -TEST_F(EcdsaVerifyBufferTest, VerifiesShortMessage) { - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey0, &kSig_msg0_key0)); - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey1, &kSig_msg0_key1)); - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey0, &kSig_msg1_key0)); - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey1, &kSig_msg1_key1)); -} - -TEST_F(EcdsaVerifyBufferTest, VerifiesLongMessage) { - std::vector msg_1mb(0x100000); - fill_message(msg_1mb.data(), msg_1mb.size()); - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(msg_1mb.data(), msg_1mb.size(), - &kPubkey0, &kSig_1Mmsg_key0)); - EXPECT_EQ(kEpidSigValid, EcdsaVerifyBuffer(msg_1mb.data(), msg_1mb.size(), - &kPubkey1, &kSig_1Mmsg_key1)); -} - -TEST_F(EcdsaVerifyBufferTest, FailsGivenWrongKey) { - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey1, &kSig_msg0_key0)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey0, &kSig_msg0_key1)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey1, &kSig_msg1_key0)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey0, &kSig_msg1_key1)); -} - -TEST_F(EcdsaVerifyBufferTest, FailsGivenWrongMsg) { - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey0, &kSig_msg0_key0)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), - &kPubkey1, &kSig_msg0_key1)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey0, &kSig_msg1_key0)); - EXPECT_EQ(kEpidSigInvalid, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey1, &kSig_msg1_key1)); -} - -TEST_F(EcdsaVerifyBufferTest, FailsGivenInvalidKey) { - // define a public key with the high half set to all FF. This will - // not be on the curve specified for this API - EcdsaPublicKey invalid_pubkey = kPubkey0; - for (size_t i = 0; i < sizeof(invalid_pubkey.x); i++) { - invalid_pubkey.x.data[i] = 0xff; - } - EXPECT_EQ(kEpidBadArgErr, - EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), &invalid_pubkey, - &kSig_msg0_key0)); - EXPECT_EQ(kEpidBadArgErr, - EcdsaVerifyBuffer(kMsg1.data(), kMsg1.size(), &invalid_pubkey, - &kSig_msg1_key0)); -} - -TEST_F(EcdsaVerifyBufferTest, FailsGivenInvalidSignature) { - // define a signature with the high half set to all FF. This will - // not be on the curve specified for this API - EcdsaSignature invalid_sig = kSig_msg0_key0; - for (size_t i = 0; i < sizeof(invalid_sig.x); i++) { - invalid_sig.x.data[i] = 0xff; - } - EXPECT_EQ(kEpidBadArgErr, EcdsaVerifyBuffer(kMsg0.data(), kMsg0.size(), - &kPubkey0, &invalid_sig)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecgroup-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecgroup-test.cc deleted file mode 100644 index 9c2ce85641..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ecgroup-test.cc +++ /dev/null @@ -1,1690 +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 unit tests. - */ - -#include -#include -#include -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/common/math/ecgroup.h" -#include "epid/common/math/finitefield.h" -} -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/common-testhelper/bignum_wrapper-testhelper.h" -#include "epid/common-testhelper/finite_field_wrapper-testhelper.h" -#include "epid/common-testhelper/ffelement_wrapper-testhelper.h" -#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h" -#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h" - -/// compares G1ElemStr values -bool operator==(G1ElemStr const& lhs, G1ElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -/// compares G2ElemStr values -bool operator==(G2ElemStr const& lhs, G2ElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -namespace { - -class EFq2Params { - public: - FiniteFieldObj fq2; - FfElementObj a; - FfElementObj b; - FfElementObj x; - FfElementObj y; - BigNumObj order; - BigNumObj cofactor; - - explicit EFq2Params(FiniteFieldObj* fq) { - // Intel(R) EPID 2.0 parameters for EC(Fq2) - static const FqElemStr param_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}}}; - static const G2ElemStr param_g2 = { - {{{{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}}}}}; - static const Fq2ElemStr param_xi0xi1 = { - {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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}}}}}; - static const FqElemStr param_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}}; - - // Setup Fq2 with parameters (q, beta) - // Fq^2 = Fq[u] / (u^2 - beta) - FfElementObj neg_beta(fq); - THROW_ON_EPIDERR(FfNeg(*fq, FfElementObj(fq, param_beta), neg_beta)); - fq2 = FiniteFieldObj(*fq, neg_beta, 2); - - // set x to (g2.x[0], g2.x[1]) and y to (g2.y[0], g2.y[1]) - x = FfElementObj(&fq2, ¶m_g2.x, sizeof(param_g2.x)); - y = FfElementObj(&fq2, ¶m_g2.y, sizeof(param_g2.y)); - - // set a to identity, NewFfElement does it by default - a = FfElementObj(&fq2); - - // set b to inv(xi)*param_b, where xi is (xi0, xi1) element in Fq2 - FfElementObj neg_xi(&fq2); - THROW_ON_EPIDERR(FfInv(fq2, FfElementObj(&fq2, param_xi0xi1), neg_xi)); - b = FfElementObj(&fq2); - THROW_ON_EPIDERR(FfMul(fq2, neg_xi.get(), FfElementObj(fq, param_b), b)); - - // 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}); - cofactor = BigNumObj(cofactor_str); - - // 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}); - order = BigNumObj(order_str); - } - - virtual ~EFq2Params() {} - - private: - // This class is not meant to be copied or assigned - EFq2Params(const EFq2Params&); - EFq2Params& operator=(const EFq2Params&); -}; - -class EcGroupTest : public ::testing::Test { - public: - static const G1ElemStr g1_str; - static const G2ElemStr g2_str; - - static const FqElemStr a1; - static const FqElemStr b1; - static const BigNumStr h1; - static const BigNumStr p; - static const BigNumStr q; - - static const G1ElemStr efq_a_str; - static const G1ElemStr efq_b_str; - static const BigNumStr x_str; - static const BigNumStr y_str; - static const G1ElemStr efq_mul_ab_str; - static const G1ElemStr efq_exp_ax_str; - static const G1ElemStr efq_multiexp_abxy_str; - static const G1ElemStr efq_inv_a_str; - static const G1ElemStr efq_identity_str; - static const G1ElemStr efq_r_sha256_str; - static const G1ElemStr efq_r_sha384_str; - static const G1ElemStr efq_r_sha512_str; - static const uint8_t sha_msg[]; - - static const G2ElemStr efq2_a_str; - static const G2ElemStr efq2_b_str; - static const G2ElemStr efq2_mul_ab_str; - static const G2ElemStr efq2_exp_ax_str; - static const G2ElemStr efq2_multiexp_abxy_str; - static const G2ElemStr efq2_inv_a_str; - static const G2ElemStr efq2_identity_str; - - virtual void SetUp() { - fq = FiniteFieldObj(q); - fq_a = FfElementObj(&fq, a1); - fq_b = FfElementObj(&fq, b1); - g1_x = FfElementObj(&fq, g1_str.x); - g1_y = FfElementObj(&fq, g1_str.y); - - bn_p = BigNumObj(p); - bn_h = BigNumObj(h1); - - efq = EcGroupObj(&fq, fq_a, fq_b, g1_x, g1_y, bn_p, bn_h); - - efq_a = EcPointObj(&efq, efq_a_str); - efq_b = EcPointObj(&efq, efq_b_str); - efq_r = EcPointObj(&efq); - efq_identity = EcPointObj(&efq, efq_identity_str); - - efq2_par.reset(new EFq2Params(&fq)); - - efq2 = EcGroupObj(&efq2_par->fq2, efq2_par->a, efq2_par->b, efq2_par->x, - efq2_par->y, efq2_par->order, efq2_par->cofactor); - - efq2_a = EcPointObj(&efq2, efq2_a_str); - efq2_b = EcPointObj(&efq2, efq2_b_str); - efq2_r = EcPointObj(&efq2); - efq2_identity = EcPointObj(&efq2, efq_identity_str); - } - - FiniteFieldObj fq; - FfElementObj fq_a; - FfElementObj fq_b; - FfElementObj g1_x; - FfElementObj g1_y; - - BigNumObj bn_p; - BigNumObj bn_h; - - EcGroupObj efq; - EcPointObj efq_a; - EcPointObj efq_b; - EcPointObj efq_r; - EcPointObj efq_identity; - - std::unique_ptr efq2_par; - EcGroupObj efq2; - EcPointObj efq2_a; - EcPointObj efq2_b; - EcPointObj efq2_r; - EcPointObj efq2_identity; -}; - -const G1ElemStr EcGroupTest::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 G2ElemStr EcGroupTest::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}}}}}; - -const FqElemStr EcGroupTest::a1 = { - {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 FqElemStr EcGroupTest::b1 = { - {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 EcGroupTest::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 BigNumStr EcGroupTest::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}}}; -const BigNumStr EcGroupTest::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}}}; - -const G1ElemStr EcGroupTest::efq_a_str = { - {{{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 EcGroupTest::efq_b_str = { - {{{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}}}}; - -const BigNumStr EcGroupTest::x_str = { - {{0xFF, 0xFB, 0x3E, 0x5D, 0xFF, 0x9A, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0xFF, - 0xF2, 0xE1, 0x85, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x81, - 0xFF, 0xFD, 0xFF, 0xEB, 0xFF, 0x29, 0xA7, 0xFF}}}; - -const BigNumStr EcGroupTest::y_str = { - {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, 0x08, 0xFF, 0xFF, - 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, - 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}}; - -const G1ElemStr EcGroupTest::efq_mul_ab_str = { - {{{0x30, 0xF8, 0x33, 0xB7, 0x1C, 0x85, 0x94, 0x6D, 0x6F, 0x3C, 0x97, 0x77, - 0x81, 0xA5, 0xC2, 0x98, 0x93, 0x5C, 0x8C, 0xC1, 0xFF, 0x35, 0x9E, 0x68, - 0xF6, 0x4D, 0x18, 0xDD, 0x65, 0xA9, 0xC0, 0x60}}}, - {{{0x89, 0xE5, 0x08, 0x2D, 0xD1, 0xD8, 0xC7, 0xBF, 0xDE, 0x16, 0x24, 0xA7, - 0x2F, 0xF1, 0x48, 0x00, 0x26, 0xAF, 0x89, 0xEA, 0xC9, 0x94, 0x78, 0xFF, - 0x2A, 0xB0, 0x20, 0xED, 0x33, 0x0C, 0x4E, 0x88}}}}; - -const G1ElemStr EcGroupTest::efq_exp_ax_str = { - {{{0x44, 0x45, 0xFA, 0x16, 0x23, 0x66, 0x26, 0x9D, 0x44, 0xB9, 0x43, 0xAB, - 0x87, 0xE3, 0x56, 0xCA, 0x9C, 0x89, 0x44, 0x8E, 0xE8, 0x19, 0x29, 0x4D, - 0x4D, 0x59, 0x7D, 0xBE, 0x46, 0x3F, 0x55, 0x0D}}}, - {{{0x98, 0x09, 0xCF, 0x43, 0x46, 0x75, 0xB8, 0x71, 0xFF, 0x37, 0xBA, 0xA0, - 0x63, 0xE2, 0xAC, 0x09, 0x38, 0x10, 0x70, 0xAC, 0x15, 0x52, 0x28, 0xF4, - 0x77, 0x68, 0x32, 0x7B, 0x6E, 0xFB, 0xC1, 0x43}}}}; - -const G1ElemStr EcGroupTest::efq_multiexp_abxy_str = { - {{{0x63, 0x4A, 0xD4, 0xC1, 0x6B, 0x90, 0x67, 0xA2, 0x0B, 0xE2, 0xB3, 0xE9, - 0x95, 0x3F, 0x82, 0x7E, 0x21, 0xBF, 0x9F, 0xCD, 0xA0, 0x16, 0x56, 0x6B, - 0x31, 0x66, 0x68, 0xBB, 0x25, 0xF8, 0xBD, 0xF3}}}, - {{{0xBD, 0x5F, 0xF8, 0x48, 0xD4, 0xBF, 0x35, 0x2D, 0xDC, 0xD1, 0x78, 0x74, - 0xFF, 0xB1, 0x47, 0xD5, 0x6B, 0x21, 0xE5, 0x15, 0x01, 0xA8, 0xDC, 0x8B, - 0x3C, 0x9D, 0x96, 0xC7, 0xC6, 0xB0, 0x05, 0x20}}}}; - -const G1ElemStr EcGroupTest::efq_inv_a_str = { - {{{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}}}, - {{{0x87, 0x9A, 0xD7, 0x34, 0x50, 0xF5, 0x9E, 0x7C, 0xF1, 0x6B, 0x93, 0x2E, - 0xE3, 0xB0, 0xF0, 0x33, 0x22, 0x6C, 0x83, 0x04, 0xA5, 0x01, 0x12, 0xB5, - 0x0A, 0x56, 0x1B, 0x5C, 0x8F, 0x98, 0xA4, 0xD1}}}}; - -const G1ElemStr EcGroupTest::efq_identity_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}}}}; - -const uint8_t EcGroupTest::sha_msg[] = {'a', 'b', 'c'}; - -const G1ElemStr EcGroupTest::efq_r_sha256_str = { - {{{0x2E, 0xBB, 0x50, 0x4D, 0x88, 0xFF, 0x25, 0x62, 0xF3, 0x71, 0x65, 0x81, - 0xAD, 0xBE, 0x83, 0x6E, 0x54, 0xF5, 0xA6, 0x2A, 0x70, 0xE6, 0x18, 0x6B, - 0xD5, 0x4A, 0x10, 0x3C, 0x80, 0x08, 0x95, 0x3D}}}, - {{{0x8A, 0x43, 0xA1, 0x04, 0xB1, 0x3F, 0x3C, 0xB4, 0xBD, 0x67, 0x38, 0xB1, - 0x07, 0xF0, 0x7A, 0x32, 0x7E, 0xCD, 0xF0, 0x2E, 0x62, 0x3E, 0x2C, 0x1F, - 0x48, 0xAA, 0x0D, 0x6C, 0xDC, 0x48, 0xF9, 0xF7}}}}; - -const G1ElemStr EcGroupTest::efq_r_sha384_str = { - {{{0xE1, 0xC8, 0x28, 0xB1, 0x9A, 0xDF, 0x5D, 0x4B, 0xC4, 0x25, 0x90, 0xFB, - 0x38, 0x20, 0xD4, 0x8B, 0x30, 0x8F, 0x95, 0x76, 0xC3, 0x7F, 0x9D, 0xAD, - 0x94, 0xC4, 0x31, 0x80, 0xD7, 0xDF, 0xD5, 0xFE}}}, - {{{0x0E, 0x86, 0x11, 0x90, 0xAF, 0xEF, 0xEB, 0x79, 0x4B, 0x3E, 0x80, 0x92, - 0x94, 0x3B, 0x2F, 0x5E, 0x72, 0x21, 0xEF, 0xF8, 0xBC, 0xE3, 0x48, 0xA9, - 0xD0, 0x31, 0x19, 0xAC, 0xD1, 0xD7, 0x49, 0x87}}}}; - -const G1ElemStr EcGroupTest::efq_r_sha512_str = { - {{{0x8C, 0x62, 0xA0, 0x2D, 0x55, 0x55, 0x55, 0x86, 0xBC, 0x82, 0xA6, 0xA2, - 0x21, 0x97, 0x9B, 0x9B, 0xB4, 0x03, 0x3D, 0x83, 0xF3, 0xBA, 0xDA, 0x9C, - 0x42, 0xF7, 0xB3, 0x94, 0x99, 0x2A, 0x96, 0xE4}}}, - {{{0x4C, 0x0E, 0xA7, 0x62, 0x17, 0xB9, 0xFB, 0xE5, 0x21, 0x7D, 0x54, 0x24, - 0xE0, 0x2B, 0x87, 0xF7, 0x69, 0x54, 0x0C, 0xC6, 0xAD, 0xF2, 0xF2, 0x7B, - 0xE6, 0x91, 0xD8, 0xF3, 0x40, 0x6C, 0x8F, 0x03}}}}; - -const G2ElemStr EcGroupTest::efq2_a_str = { - { - {0x2F, 0x8C, 0xC7, 0xD7, 0xD4, 0x1E, 0x4A, 0xCB, 0x82, 0x92, 0xC7, 0x9C, - 0x0F, 0xA2, 0xF2, 0x1B, 0xDF, 0xEA, 0x96, 0x64, 0x8B, 0xA2, 0x32, 0x7C, - 0xDF, 0xD8, 0x89, 0x10, 0xFD, 0xBB, 0x38, 0xCD}, - {0xB1, 0x23, 0x46, 0x13, 0x4D, 0x9B, 0x8E, 0x8A, 0x95, 0x64, 0xDD, 0x37, - 0x29, 0x44, 0x1F, 0x76, 0xB5, 0x3A, 0x47, 0xD3, 0xE0, 0x18, 0x1E, 0x60, - 0xE9, 0x94, 0x13, 0xA4, 0x47, 0xCD, 0xBE, 0x03}, - }, - { - {0xD3, 0x67, 0xA5, 0xCC, 0xEF, 0x7B, 0xD1, 0x8D, 0x4A, 0x7F, 0xF1, 0x8F, - 0x66, 0xCB, 0x5E, 0x86, 0xAC, 0xCB, 0x36, 0x5F, 0x29, 0x90, 0x28, 0x55, - 0xF0, 0xDC, 0x6E, 0x8B, 0x87, 0xB5, 0xD8, 0x32}, - {0x6C, 0x0A, 0xC5, 0x58, 0xB1, 0x4E, 0xCA, 0x85, 0x44, 0x3E, 0xDE, 0x71, - 0x9B, 0xC7, 0x90, 0x19, 0x06, 0xD2, 0xA0, 0x4E, 0xC7, 0x33, 0xF4, 0x5C, - 0xE8, 0x16, 0xE2, 0x67, 0xDB, 0xBF, 0x64, 0x84}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_b_str = { - { - {0x16, 0xF1, 0x61, 0x76, 0x06, 0x3E, 0xE9, 0xC0, 0xB9, 0xB1, 0x3A, 0x75, - 0xFC, 0xDB, 0x90, 0xCD, 0x01, 0xF4, 0x9F, 0xCC, 0xAA, 0x24, 0x69, 0x83, - 0xBE, 0x20, 0x44, 0x87, 0x58, 0x90, 0x0F, 0x4F}, - {0xC7, 0x50, 0x37, 0xC1, 0xB9, 0x2D, 0xE1, 0xE3, 0x79, 0x20, 0x7B, 0x62, - 0x90, 0xF8, 0xC7, 0xF0, 0xD7, 0x5A, 0xE7, 0xAD, 0x65, 0xE1, 0xC7, 0x50, - 0x59, 0xA1, 0xFC, 0x49, 0xBC, 0x2A, 0xE5, 0xD7}, - }, - { - {0x12, 0x73, 0x3B, 0xA4, 0xDD, 0x0F, 0xBB, 0x35, 0x38, 0x4A, 0xE0, 0x3D, - 0x79, 0x63, 0x66, 0x73, 0x9C, 0x07, 0xE1, 0xEC, 0x71, 0x16, 0x50, 0x75, - 0xA1, 0xBA, 0xE5, 0x37, 0x45, 0x1A, 0x0C, 0x59}, - {0xC9, 0x49, 0xB9, 0xDB, 0x7E, 0x76, 0xC5, 0xC5, 0x0A, 0x87, 0xB7, 0x56, - 0x88, 0x09, 0x21, 0xC6, 0xF6, 0x6C, 0xCC, 0x5E, 0x80, 0xFD, 0x05, 0xD0, - 0x5F, 0xC6, 0x2E, 0x06, 0xA1, 0xBE, 0x5B, 0xA0}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_mul_ab_str = { - { - {0x25, 0xCC, 0x11, 0x80, 0x8F, 0x08, 0x1D, 0x66, 0xF8, 0xDB, 0xBC, 0x98, - 0x26, 0x24, 0x26, 0xCF, 0x04, 0x02, 0xB6, 0x99, 0x1B, 0x52, 0xA8, 0xE3, - 0x4E, 0x9A, 0x85, 0xB0, 0x5C, 0xCE, 0xDD, 0xC5}, - {0xFC, 0x3C, 0xC2, 0x2C, 0x4B, 0x63, 0x72, 0x5F, 0xA9, 0xF9, 0x8C, 0x62, - 0xF4, 0xE7, 0x30, 0x71, 0x6F, 0x78, 0xF5, 0xFE, 0xF6, 0xDF, 0xF7, 0xB5, - 0x21, 0x69, 0x7C, 0x50, 0xAC, 0x56, 0xD9, 0xB5}, - }, - { - {0xA5, 0xD6, 0xAB, 0x2D, 0xED, 0x8E, 0xFE, 0x43, 0xCB, 0xC9, 0xEF, 0x09, - 0xC8, 0x2D, 0xE8, 0xD0, 0x3B, 0xC0, 0x5C, 0x7F, 0xE5, 0x3A, 0x1D, 0x72, - 0xF2, 0xF5, 0x03, 0xBD, 0xE5, 0xEB, 0x08, 0xA0}, - {0xE6, 0xF3, 0x59, 0xE4, 0xD2, 0x52, 0xFD, 0x4F, 0xEC, 0xCE, 0x49, 0x9F, - 0x86, 0x50, 0x2D, 0x4A, 0x59, 0x2C, 0xA2, 0x4E, 0xE3, 0xFE, 0xF2, 0xFC, - 0xB9, 0xF4, 0x22, 0x88, 0xBC, 0x79, 0x21, 0xD0}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_exp_ax_str = { - { - {0xC0, 0x5A, 0x37, 0xAD, 0x08, 0xAB, 0x22, 0xCF, 0xF7, 0xF9, 0xCC, 0xD4, - 0x5A, 0x47, 0x38, 0x82, 0xE1, 0xC2, 0x06, 0x35, 0x4D, 0x5B, 0x95, 0xA1, - 0xA3, 0xC1, 0x83, 0x6C, 0x0F, 0x31, 0x24, 0xD2}, - {0xC7, 0x86, 0xE1, 0x59, 0x63, 0xCE, 0x21, 0x2A, 0x57, 0x77, 0xE5, 0x48, - 0xF7, 0x60, 0x21, 0x00, 0x40, 0x2F, 0x09, 0x18, 0x5C, 0x32, 0x32, 0x75, - 0xD7, 0xB9, 0xE7, 0xB1, 0x95, 0xD5, 0xDF, 0x02}, - }, - { - {0xE5, 0xDE, 0xC6, 0x3E, 0x05, 0xFC, 0x6F, 0x7A, 0xE3, 0x2D, 0x7D, 0x90, - 0x5F, 0x43, 0xE2, 0xB0, 0x9E, 0xCD, 0xEC, 0x7B, 0x37, 0x4C, 0x0A, 0x3E, - 0x87, 0x4E, 0xE6, 0xDA, 0xD1, 0x90, 0xC0, 0xD1}, - {0x70, 0x90, 0x54, 0x7F, 0x78, 0x93, 0xFA, 0xC4, 0xF7, 0x3A, 0x4D, 0xBC, - 0x03, 0x5E, 0x83, 0xDF, 0xEF, 0xF7, 0x52, 0xF9, 0x64, 0x7F, 0x17, 0xC1, - 0x69, 0xD6, 0xD7, 0x96, 0x18, 0x62, 0x46, 0xD1}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_multiexp_abxy_str = { - { - {0xE8, 0x6E, 0x02, 0x7A, 0xEC, 0xEA, 0xBA, 0x7E, 0xE5, 0x7C, 0xAD, 0x98, - 0x37, 0x54, 0xB2, 0x15, 0x64, 0x9C, 0x81, 0xFF, 0x69, 0xCC, 0xD6, 0xA6, - 0xAA, 0xA7, 0x10, 0x4F, 0x9B, 0x0C, 0x50, 0x14}, - {0x7C, 0xAF, 0xC0, 0x6F, 0xC8, 0x87, 0xFF, 0x4A, 0x6F, 0xB5, 0x9E, 0x63, - 0x74, 0x20, 0xB5, 0xC6, 0x4F, 0x14, 0x0B, 0x6C, 0xBF, 0x00, 0x71, 0xE2, - 0x6D, 0x6C, 0x41, 0x6A, 0x0B, 0xA5, 0x5B, 0xCF}, - }, - { - {0x16, 0xCC, 0x9B, 0x37, 0xE7, 0xCB, 0x16, 0x5C, 0x39, 0x7C, 0x10, 0x7E, - 0xE0, 0xDD, 0x34, 0x90, 0xBE, 0x56, 0x28, 0x76, 0x27, 0x59, 0xCE, 0xB3, - 0xD7, 0xB4, 0x56, 0xD4, 0x0D, 0xD1, 0xB8, 0xFB}, - {0x5E, 0x9E, 0x27, 0x30, 0x60, 0x87, 0x3B, 0xA4, 0x9B, 0x15, 0xEE, 0x86, - 0x15, 0x1D, 0xF4, 0xF3, 0x07, 0x31, 0x46, 0xFD, 0xB7, 0x51, 0xFF, 0xC0, - 0x42, 0x94, 0x38, 0xB7, 0x84, 0x5F, 0x86, 0x3A}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_inv_a_str = { - { - {0x2F, 0x8C, 0xC7, 0xD7, 0xD4, 0x1E, 0x4A, 0xCB, 0x82, 0x92, 0xC7, 0x9C, - 0x0F, 0xA2, 0xF2, 0x1B, 0xDF, 0xEA, 0x96, 0x64, 0x8B, 0xA2, 0x32, 0x7C, - 0xDF, 0xD8, 0x89, 0x10, 0xFD, 0xBB, 0x38, 0xCD}, - {0xB1, 0x23, 0x46, 0x13, 0x4D, 0x9B, 0x8E, 0x8A, 0x95, 0x64, 0xDD, 0x37, - 0x29, 0x44, 0x1F, 0x76, 0xB5, 0x3A, 0x47, 0xD3, 0xE0, 0x18, 0x1E, 0x60, - 0xE9, 0x94, 0x13, 0xA4, 0x47, 0xCD, 0xBE, 0x03}, - }, - { - {0x2C, 0x98, 0x5A, 0x33, 0x10, 0x81, 0x1F, 0x3F, 0xFC, 0x66, 0x00, 0xCF, - 0x87, 0xA6, 0x46, 0x18, 0x60, 0x11, 0x2F, 0x9B, 0xE9, 0x07, 0xE2, 0x2C, - 0xE2, 0x4C, 0xBF, 0x50, 0x27, 0x1D, 0x57, 0xE1}, - {0x93, 0xF5, 0x3A, 0xA7, 0x4E, 0xAE, 0x26, 0x48, 0x02, 0xA7, 0x13, 0xED, - 0x52, 0xAA, 0x14, 0x86, 0x06, 0x09, 0xC5, 0xAC, 0x4B, 0x64, 0x16, 0x25, - 0xEB, 0x12, 0x4B, 0x73, 0xD3, 0x13, 0xCB, 0x8F}, - }, -}; - -const G2ElemStr EcGroupTest::efq2_identity_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, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - }, -}; -/////////////////////////////////////////////////////////////////////// -// NewEcGroup -TEST_F(EcGroupTest, NewFailsGivenArgumentsMismatch) { - // construct Fq^2 finite field - FqElemStr 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}}; - FfElementObj neg_beta(&fq); - THROW_ON_EPIDERR(FfNeg(fq, FfElementObj(&fq, beta_str), neg_beta)); - FiniteFieldObj fq2(fq, neg_beta, 2); - - FfElementObj fq2_a(&fq2); - FfElementObj fq2_b(&fq2); - FfElementObj g2_x(&fq2); - FfElementObj g2_y(&fq2); - - EcGroup* g = nullptr; - EXPECT_EQ(kEpidBadArgErr, NewEcGroup(fq2, this->fq_a, this->fq_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - DeleteEcGroup(&g); - EXPECT_EQ(kEpidBadArgErr, NewEcGroup(this->fq, fq2_a, this->fq_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - DeleteEcGroup(&g); - EXPECT_EQ(kEpidBadArgErr, NewEcGroup(this->fq, this->fq_a, fq2_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - DeleteEcGroup(&g); - EXPECT_EQ(kEpidBadArgErr, NewEcGroup(this->fq, this->fq_a, this->fq_b, g2_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - DeleteEcGroup(&g); - EXPECT_EQ(kEpidBadArgErr, - NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, g2_y, - this->bn_p, this->bn_h, &g)); - DeleteEcGroup(&g); -} -TEST_F(EcGroupTest, NewFailsGivenNullParameters) { - EcGroup* g; - EpidStatus sts; - sts = NewEcGroup(this->fq, nullptr, this->fq_b, this->g1_x, this->g1_y, - this->bn_p, this->bn_h, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, nullptr, this->g1_x, this->g1_y, - this->bn_p, this->bn_h, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, nullptr, this->g1_y, - this->bn_p, this->bn_h, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, nullptr, - this->bn_p, this->bn_h, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, this->g1_y, - nullptr, this->bn_h, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, this->g1_y, - this->bn_p, nullptr, &g); - EXPECT_EQ(kEpidBadArgErr, sts); - sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, this->g1_y, - this->bn_p, this->bn_h, nullptr); - EXPECT_EQ(kEpidBadArgErr, sts); -} -TEST_F(EcGroupTest, CanCreateEcGroupBasedOnFq) { - EcGroup* g; - EpidStatus sts = NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g); - EXPECT_EQ(kEpidNoErr, sts); - - DeleteEcGroup(&g); -} -TEST_F(EcGroupTest, CanCreateEcGroupBasedOnFq2) { - EcGroup* g; - EXPECT_EQ(kEpidNoErr, - NewEcGroup(efq2_par->fq2, efq2_par->a, efq2_par->b, efq2_par->x, - efq2_par->y, efq2_par->order, efq2_par->cofactor, &g)); - - DeleteEcGroup(&g); -} - -/////////////////////////////////////////////////////////////////////// -// DeleteEcGroup -TEST_F(EcGroupTest, DeleteWorksGivenNewlyCreatedEcGroup) { - EcGroup* g; - THROW_ON_EPIDERR(NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - EXPECT_NO_THROW(DeleteEcGroup(&g)); -} -TEST_F(EcGroupTest, DeleteWorksGivenNewlyCreatedEcGroupFq2) { - EcGroup* g; - THROW_ON_EPIDERR(NewEcGroup(efq2_par->fq2, efq2_par->a, efq2_par->b, - efq2_par->x, efq2_par->y, efq2_par->order, - efq2_par->cofactor, &g)); - EXPECT_NO_THROW(DeleteEcGroup(&g)); -} -TEST_F(EcGroupTest, DeleteNullsPointer) { - EcGroup* g = nullptr; - THROW_ON_EPIDERR(NewEcGroup(this->fq, this->fq_a, this->fq_b, this->g1_x, - this->g1_y, this->bn_p, this->bn_h, &g)); - - EXPECT_NO_THROW(DeleteEcGroup(&g)); - EXPECT_EQ(nullptr, g); -} -TEST_F(EcGroupTest, DeleteWorksGivenNullPointer) { - EXPECT_NO_THROW(DeleteEcGroup(nullptr)); - EcGroup* g = nullptr; - EXPECT_NO_THROW(DeleteEcGroup(&g)); -} -/////////////////////////////////////////////////////////////////////// -// NewEcPoint -TEST_F(EcGroupTest, NewEcPointSucceedsGivenEcGroupBasedOnFq) { - EcPoint* point = nullptr; - EXPECT_EQ(kEpidNoErr, NewEcPoint(this->efq, &point)); - DeleteEcPoint(&point); -} -TEST_F(EcGroupTest, NewEcPointFailsGivenNullPointer) { - EcPoint* point = nullptr; - EXPECT_EQ(kEpidBadArgErr, NewEcPoint(nullptr, &point)); - EXPECT_EQ(kEpidBadArgErr, NewEcPoint(this->efq, nullptr)); - DeleteEcPoint(&point); -} -TEST_F(EcGroupTest, NewEcPointSucceedsGivenEcGroupBasedOnFq2) { - EcPoint* point = nullptr; - EXPECT_EQ(kEpidNoErr, NewEcPoint(this->efq2, &point)); - DeleteEcPoint(&point); -} -TEST_F(EcGroupTest, DefaultEcPointIsIdentity) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EcPoint* point = nullptr; - EXPECT_EQ(kEpidNoErr, NewEcPoint(this->efq, &point)); - EpidStatus sts = - WriteEcPoint(this->efq, point, &g1_elem_str, sizeof(g1_elem_str)); - EXPECT_EQ(this->efq_identity_str, g1_elem_str); - DeleteEcPoint(&point); - THROW_ON_EPIDERR(sts); - - G2ElemStr g2_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, NewEcPoint(this->efq2, &point)); - sts = WriteEcPoint(this->efq2, point, &g2_elem_str, sizeof(g2_elem_str)); - EXPECT_EQ(this->efq2_identity_str, g2_elem_str); - DeleteEcPoint(&point); - THROW_ON_EPIDERR(sts); -} -/////////////////////////////////////////////////////////////////////// -// DeleteEcPoint -TEST_F(EcGroupTest, DeleteEcPointNullsPointer) { - EcPoint* point = nullptr; - THROW_ON_EPIDERR(NewEcPoint(this->efq, &point)); - EXPECT_NO_THROW(DeleteEcPoint(&point)); - EXPECT_EQ(nullptr, point); -} -TEST_F(EcGroupTest, DeleteEcPointWorksGivenNullPointer) { - EXPECT_NO_THROW(DeleteEcPoint(nullptr)); - EcPoint* point = nullptr; - EXPECT_NO_THROW(DeleteEcPoint(&point)); - EXPECT_EQ(nullptr, point); -} -/////////////////////////////////////////////////////////////////////// -// ReadEcPoint -TEST_F(EcGroupTest, ReadFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, ReadEcPoint(nullptr, &(this->efq_a_str), - sizeof(this->efq_a_str), this->efq_a)); - EXPECT_EQ(kEpidBadArgErr, ReadEcPoint(this->efq, nullptr, - sizeof(this->efq_a_str), this->efq_a)); - EXPECT_EQ(kEpidBadArgErr, ReadEcPoint(this->efq, &(this->efq_a_str), - sizeof(this->efq_a_str), nullptr)); -} -TEST_F(EcGroupTest, ReadFailsGivenInvalidBufferSize) { - EXPECT_EQ(kEpidBadArgErr, - ReadEcPoint(this->efq, &(this->efq_a_str), 0, this->efq_a)); - EXPECT_EQ(kEpidBadArgErr, - ReadEcPoint(this->efq, &(this->efq_a_str), - sizeof(this->efq_a_str) - 1, this->efq_a)); - EXPECT_EQ(kEpidBadArgErr, - ReadEcPoint(this->efq, &(this->efq_a_str), - std::numeric_limits::max(), this->efq_a)); -} -TEST_F(EcGroupTest, ReadEcPointReadsG1PointCorrectly) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, ReadEcPoint(this->efq, &this->efq_a_str, - sizeof(this->efq_a_str), this->efq_a)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, sizeof(g1_elem_str))); - EXPECT_EQ(this->efq_a_str, g1_elem_str); -} -TEST_F(EcGroupTest, ReadEcPointReadsG1IdentityPointCorrectly) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(this->efq, &this->efq_identity_str, - sizeof(this->efq_identity_str), this->efq_a)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, sizeof(g1_elem_str))); - EXPECT_EQ(this->efq_identity_str, g1_elem_str); -} -TEST_F(EcGroupTest, ReadEcPointReadsG2IdentityPointCorrectly) { - G2ElemStr g2_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(this->efq2, &this->efq2_identity_str, - sizeof(this->efq2_identity_str), this->efq2_r)); - THROW_ON_EPIDERR(WriteEcPoint(this->efq2, this->efq2_r, &g2_elem_str, - sizeof(g2_elem_str))); - EXPECT_EQ(this->efq2_identity_str, g2_elem_str); -} -TEST_F(EcGroupTest, ReadEcPointReadsG2PointCorrectly) { - G2ElemStr g2_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, ReadEcPoint(this->efq2, &this->efq2_a_str, - sizeof(this->efq2_a_str), this->efq2_r)); - THROW_ON_EPIDERR(WriteEcPoint(this->efq2, this->efq2_r, &g2_elem_str, - sizeof(g2_elem_str))); - EXPECT_EQ(this->efq2_a_str, g2_elem_str); -} - -TEST_F(EcGroupTest, ReadFailsGivenPointDoesNotBelongToEcGroup) { - G1ElemStr bad_g1_point = this->efq_a_str; - bad_g1_point.x.data.data[31]++; // make point not belong to the group - EXPECT_EQ(kEpidBadArgErr, ReadEcPoint(this->efq, &bad_g1_point, - sizeof(bad_g1_point), this->efq_a)); - - G2ElemStr bad_g2_point = this->efq2_a_str; - bad_g2_point.x[0].data.data[31]++; // make point not belong to the group - EXPECT_EQ(kEpidBadArgErr, ReadEcPoint(this->efq2, &bad_g2_point, - sizeof(bad_g2_point), this->efq2_a)); -} -/////////////////////////////////////////////////////////////////////// -// WriteEcPoint -TEST_F(EcGroupTest, WriteFailsGivenNullPointer) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidBadArgErr, WriteEcPoint(nullptr, this->efq_a, &g1_elem_str, - sizeof(g1_elem_str))); - EXPECT_EQ(kEpidBadArgErr, WriteEcPoint(this->efq, nullptr, &g1_elem_str, - sizeof(g1_elem_str))); - EXPECT_EQ(kEpidBadArgErr, - WriteEcPoint(this->efq, this->efq_a, nullptr, sizeof(g1_elem_str))); -} -TEST_F(EcGroupTest, WriteFailsGivenInvalidBufferSize) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidBadArgErr, - WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, 0)); - EXPECT_EQ(kEpidBadArgErr, WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, - sizeof(g1_elem_str) - 1)); - EXPECT_EQ(kEpidBadArgErr, WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, - std::numeric_limits::max())); -} -TEST_F(EcGroupTest, WriteEcPointWritesG1PointCorrectly) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, WriteEcPoint(this->efq, this->efq_a, &g1_elem_str, - sizeof(g1_elem_str))); - EXPECT_EQ(this->efq_a_str, g1_elem_str); -} -TEST_F(EcGroupTest, WriteEcPointWritesG1IdentityPointCorrectly) { - G1ElemStr g1_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, WriteEcPoint(this->efq, this->efq_identity, - &g1_elem_str, sizeof(g1_elem_str))); - EXPECT_EQ(this->efq_identity_str, g1_elem_str); -} -TEST_F(EcGroupTest, WriteEcPointWritesG2IdentityPointCorrectly) { - G2ElemStr g2_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, WriteEcPoint(this->efq2, this->efq2_identity, - &g2_elem_str, sizeof(g2_elem_str))); - EXPECT_EQ(this->efq2_identity_str, g2_elem_str); -} -TEST_F(EcGroupTest, WriteEcPointWritesG2PointCorrectly) { - G2ElemStr g2_elem_str = {{{{0}}}, {{{0}}}}; - EXPECT_EQ(kEpidNoErr, WriteEcPoint(this->efq2, this->efq2_a, &g2_elem_str, - sizeof(g2_elem_str))); - EXPECT_EQ(this->efq2_a_str, g2_elem_str); -} -/////////////////////////////////////////////////////////////////////// -// EcMul -TEST_F(EcGroupTest, MulFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq2, this->efq_a, this->efq_b, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, this->efq2_a, this->efq_b, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, this->efq_a, this->efq2_b, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, this->efq_a, this->efq_b, this->efq2_r)); -} -TEST_F(EcGroupTest, MulFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, - EcMul(nullptr, this->efq_a, this->efq_b, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, nullptr, this->efq_b, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, this->efq_a, nullptr, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMul(this->efq, this->efq_a, this->efq_b, nullptr)); -} -TEST_F(EcGroupTest, MulSucceedsGivenIdentityElement) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq, this->efq_a, this->efq_identity, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_a_str, efq_r_str); - - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq, this->efq_identity, this->efq_a, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_a_str, efq_r_str); -} - -TEST_F(EcGroupTest, MulSucceedsGivenTwoElements) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq, this->efq_a, this->efq_b, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_mul_ab_str, efq_r_str); -} -TEST_F(EcGroupTest, MulSucceedsGivenG2IdentityElement) { - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq2, this->efq2_a, this->efq2_identity, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_a_str, efq2_r_str); - - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq2, this->efq2_identity, this->efq2_a, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_a_str, efq2_r_str); -} -TEST_F(EcGroupTest, MulSucceedsGivenTwoG2Elements) { - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, - EcMul(this->efq2, this->efq2_a, this->efq2_b, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_mul_ab_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcExp -TEST_F(EcGroupTest, ExpFailsGivenArgumentsMismatch) { - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq2, this->efq_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, this->efq2_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, this->efq_a, &zero_bn_str, this->efq2_r)); -} -TEST_F(EcGroupTest, ExpFailsGivenNullPointer) { - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcExp(nullptr, this->efq_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, nullptr, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, this->efq_a, nullptr, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, this->efq_a, &zero_bn_str, nullptr)); -} -TEST_F(EcGroupTest, ExpSucceedsGivenZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidNoErr, - EcExp(this->efq, this->efq_a, &zero_bn_str, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, ExpResultIsCorrect) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcExp(this->efq, this->efq_a, &this->x_str, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_exp_ax_str, efq_r_str); -} -TEST_F(EcGroupTest, ExpFailsGivenOutOfRangeExponent) { - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, - EcExp(this->efq, this->efq_a, &this->p, this->efq_r)); -} -TEST_F(EcGroupTest, ExpSucceedsGivenG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidNoErr, - EcExp(this->efq2, this->efq2_a, &zero_bn_str, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, ExpResultIsCorrectForG2) { - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, - EcExp(this->efq2, this->efq2_a, &this->x_str, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_exp_ax_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcSscmExp -TEST_F(EcGroupTest, SscmExpFailsGivenArgumentsMismatch) { - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq2, this->efq_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, this->efq2_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, this->efq_a, &zero_bn_str, this->efq2_r)); -} -TEST_F(EcGroupTest, SscmExpFailsGivenNullPointer) { - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(nullptr, this->efq_a, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, nullptr, &zero_bn_str, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, this->efq_a, nullptr, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, this->efq_a, &zero_bn_str, nullptr)); -} -TEST_F(EcGroupTest, SscmExpSucceedsGivenZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidNoErr, - EcSscmExp(this->efq, this->efq_a, &zero_bn_str, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmExpResultIsCorrect) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcSscmExp(this->efq, this->efq_a, &this->x_str, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_exp_ax_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmExpFailsGivenOutOfRangeExponent) { - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, - EcSscmExp(this->efq, this->efq_a, &this->p, this->efq_r)); -} -TEST_F(EcGroupTest, SscmExpSucceedsGivenG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EXPECT_EQ(kEpidNoErr, - EcSscmExp(this->efq2, this->efq2_a, &zero_bn_str, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, SscmExpResultIsCorrectForG2) { - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, - EcSscmExp(this->efq2, this->efq2_a, &this->x_str, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_exp_ax_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcMultiExp -TEST_F(EcGroupTest, MultiExpFailsGivenArgumentsMismatch) { - EcPoint const* pts_ec1[] = {this->efq_a, this->efq_b}; - EcPoint const* pts_ec2[] = {this->efq2_a, this->efq2_b}; - EcPoint const* pts_ec1_ec2[] = {this->efq_a, this->efq2_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - size_t m = 2; - - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq2, pts_ec1, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts_ec2, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts_ec1, b, m, this->efq2_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts_ec1_ec2, b, m, this->efq_r)); -} -TEST_F(EcGroupTest, MultiExpFailsGivenNullPointer) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - EcPoint const* pts_withnull[] = {nullptr, this->efq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - BigNumStr const* b_withnull[] = {nullptr, &bnm1}; - size_t m = 2; - - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(nullptr, pts, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, nullptr, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts, nullptr, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts, b, m, nullptr)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts_withnull, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts, b_withnull, m, this->efq_r)); -} -TEST_F(EcGroupTest, MultiExpFailsGivenIncorrectMLen) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts, b, 0, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts, b, std::numeric_limits::max(), - this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcMultiExp(this->efq, pts, b, (size_t)INT_MAX + 1, this->efq_r)); -} -TEST_F(EcGroupTest, MultiExpFailsGivenOutOfRangeExponent) { - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b_1[] = {&this->p}; - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts, b_1, 1, this->efq_r)); -} -TEST_F(EcGroupTest, MultiExpFailsGivenOutOfRangeExponents) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - const BigNumStr bnm_1 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, - 0x6B, 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, - 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, - 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - BigNumStr const* b_1[] = {&bnm_1, &this->p}; - BigNumStr const* b_2[] = {&this->p, &bnm_1}; - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts, b_1, 2, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMultiExp(this->efq, pts, b_2, 2, this->efq_r)); -} -TEST_F(EcGroupTest, MultiExpWorksGivenOneZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenTwoZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a, this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenSixZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a, this->efq_a, this->efq_a, - this->efq_a, this->efq_a, this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str, &zero_bn_str, - &zero_bn_str, &zero_bn_str, &zero_bn_str}; - size_t m = 6; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenOneG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenTwoG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a, this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenSixG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a, this->efq2_a, this->efq2_a, - this->efq2_a, this->efq2_a, this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str, &zero_bn_str, - &zero_bn_str, &zero_bn_str, &zero_bn_str}; - size_t m = 6; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenOneExponent) { - G1ElemStr efq_r_str; - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b[] = {&this->x_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_exp_ax_str, efq_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenTwoExponents) { - G1ElemStr efq_r_str; - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - BigNumStr const* b[] = {&this->x_str, &this->y_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_multiexp_abxy_str, efq_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenOneG2Exponent) { - G2ElemStr efq2_r_str; - EcPoint const* pts[] = {this->efq2_a}; - BigNumStr const* b[] = {&this->x_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_exp_ax_str, efq2_r_str); -} -TEST_F(EcGroupTest, MultiExpWorksGivenTwoG2Exponents) { - G2ElemStr efq2_r_str; - EcPoint const* pts[] = {this->efq2_a, this->efq2_b}; - BigNumStr const* b[] = {&this->x_str, &this->y_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_multiexp_abxy_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcSscmMultiExp -TEST_F(EcGroupTest, SscmMultiExpFailsGivenArgumentsMismatch) { - EcPoint const* pts_ec1[] = {this->efq_a, this->efq_b}; - EcPoint const* pts_ec2[] = {this->efq2_a, this->efq2_b}; - EcPoint const* pts_ec1_ec2[] = {this->efq_a, this->efq2_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - size_t m = 2; - - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq2, pts_ec1, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts_ec2, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts_ec1, b, m, this->efq2_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts_ec1_ec2, b, m, this->efq_r)); -} -TEST_F(EcGroupTest, SscmMultiExpFailsGivenNullPointer) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - EcPoint const* pts_withnull[] = {nullptr, this->efq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - BigNumStr const* b_withnull[] = {nullptr, &bnm1}; - size_t m = 2; - - EXPECT_EQ(kEpidBadArgErr, EcSscmMultiExp(nullptr, pts, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, nullptr, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, nullptr, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcSscmMultiExp(this->efq, pts, b, m, nullptr)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts_withnull, b, m, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, b_withnull, m, this->efq_r)); -} -TEST_F(EcGroupTest, SscmMultiExpFailsGivenIncorrectMLen) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - EXPECT_EQ(kEpidBadArgErr, EcSscmMultiExp(this->efq, pts, b, 0, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, b, - std::numeric_limits::max(), this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcSscmMultiExp(this->efq, pts, b, - (size_t)INT_MAX + 1, this->efq_r)); -} -TEST_F(EcGroupTest, SscmMultiExpFailsGivenOutOfRangeExponent) { - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b_1[] = {&this->p}; - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, b_1, 1, this->efq_r)); -} -TEST_F(EcGroupTest, SscmMultiExpFailsGivenOutOfRangeExponents) { - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - const BigNumStr bnm_1 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, - 0x6B, 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, - 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, - 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - BigNumStr const* b_1[] = {&bnm_1, &this->p}; - BigNumStr const* b_2[] = {&this->p, &bnm_1}; - // The exponent should be less than elliptic curve group order - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, b_1, 2, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcSscmMultiExp(this->efq, pts, b_2, 2, this->efq_r)); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenOneZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenTwoZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a, this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenSixZeroExponent) { - G1ElemStr efq_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq_a, this->efq_a, this->efq_a, - this->efq_a, this->efq_a, this->efq_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str, &zero_bn_str, - &zero_bn_str, &zero_bn_str, &zero_bn_str}; - size_t m = 6; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenOneG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenTwoG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a, this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenSixG2ZeroExponent) { - G2ElemStr efq2_r_str; - BigNumStr zero_bn_str = {0}; - EcPoint const* pts[] = {this->efq2_a, this->efq2_a, this->efq2_a, - this->efq2_a, this->efq2_a, this->efq2_a}; - BigNumStr const* b[] = {&zero_bn_str, &zero_bn_str, &zero_bn_str, - &zero_bn_str, &zero_bn_str, &zero_bn_str}; - size_t m = 6; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenOneExponent) { - G1ElemStr efq_r_str; - EcPoint const* pts[] = {this->efq_a}; - BigNumStr const* b[] = {&this->x_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_exp_ax_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenTwoExponents) { - G1ElemStr efq_r_str; - EcPoint const* pts[] = {this->efq_a, this->efq_b}; - BigNumStr const* b[] = {&this->x_str, &this->y_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq, pts, b, m, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_multiexp_abxy_str, efq_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenOneG2Exponent) { - G2ElemStr efq2_r_str; - EcPoint const* pts[] = {this->efq2_a}; - BigNumStr const* b[] = {&this->x_str}; - size_t m = 1; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_exp_ax_str, efq2_r_str); -} -TEST_F(EcGroupTest, SscmMultiExpWorksGivenTwoG2Exponents) { - G2ElemStr efq2_r_str; - EcPoint const* pts[] = {this->efq2_a, this->efq2_b}; - BigNumStr const* b[] = {&this->x_str, &this->y_str}; - size_t m = 2; - EXPECT_EQ(kEpidNoErr, EcSscmMultiExp(this->efq2, pts, b, m, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_multiexp_abxy_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcGetRandom -TEST_F(EcGroupTest, GetRandomFailsGivenArgumentsMismatch) { - Prng my_prng; - EXPECT_EQ(kEpidBadArgErr, - EcGetRandom(this->efq2, &Prng::Generate, &my_prng, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcGetRandom(this->efq, &Prng::Generate, &my_prng, this->efq2_r)); -} -TEST_F(EcGroupTest, GetRandomFailsGivenNullPointer) { - Prng my_prng; - EXPECT_EQ(kEpidBadArgErr, - EcGetRandom(nullptr, &Prng::Generate, &my_prng, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcGetRandom(this->efq, nullptr, &my_prng, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcGetRandom(this->efq, &Prng::Generate, &my_prng, nullptr)); -} -TEST_F(EcGroupTest, GetRandomGeneratesDifferentECPoints) { - Prng my_prng; - EcPointObj r1(&this->efq); - EcPointObj r2(&this->efq); - bool result; - // __LINE__ makes sure that r1 and r2 are generated using distinct seeds - my_prng.set_seed(__LINE__); - EXPECT_EQ(kEpidNoErr, EcGetRandom(this->efq, &Prng::Generate, &my_prng, r1)); - my_prng.set_seed(__LINE__); - EXPECT_EQ(kEpidNoErr, EcGetRandom(this->efq, &Prng::Generate, &my_prng, r2)); - THROW_ON_EPIDERR(EcIsEqual(this->efq, r1, r2, &result)); - EXPECT_FALSE(result); -} -/////////////////////////////////////////////////////////////////////// -// EcInGroup -TEST_F(EcGroupTest, InGroupFailsGivenNullPointer) { - bool in_group; - EXPECT_EQ(kEpidBadArgErr, EcInGroup(nullptr, &(this->efq_a_str), - sizeof(this->efq_a_str), &in_group)); - EXPECT_EQ(kEpidBadArgErr, - EcInGroup(this->efq, nullptr, sizeof(this->efq_a_str), &in_group)); - EXPECT_EQ(kEpidBadArgErr, EcInGroup(this->efq, &(this->efq_a_str), - sizeof(this->efq_a_str), nullptr)); -} -TEST_F(EcGroupTest, InGroupFailsGivenInvalidBufferSize) { - bool in_group; - EXPECT_EQ(kEpidBadArgErr, - EcInGroup(this->efq, &(this->efq_a_str), 0, &in_group)); - EXPECT_EQ(kEpidBadArgErr, - EcInGroup(this->efq, &(this->efq_a_str), - std::numeric_limits::max(), &in_group)); -#if (SIZE_MAX >= 0x100000001) // When size_t value allowed to be 0x100000001 - EXPECT_EQ(kEpidBadArgErr, - EcInGroup(this->efq, &(this->efq_a_str), 0x100000001, &in_group)); -#endif -} -TEST_F(EcGroupTest, InGroupDetectsElementNotInGroup) { - // element be not in group if Y coordinate increased by 1 - G1ElemStr p_str = this->efq_a_str; - p_str.y.data.data[31] -= 1; - - bool in_group; - EXPECT_EQ(kEpidNoErr, EcInGroup(this->efq, &p_str, sizeof(p_str), &in_group)); - EXPECT_FALSE(in_group); - - G2ElemStr p2_str = this->efq2_a_str; - p2_str.y[0].data.data[31] -= 1; - - EXPECT_EQ(kEpidNoErr, - EcInGroup(this->efq2, &p2_str, sizeof(p2_str), &in_group)); - EXPECT_FALSE(in_group); -} -TEST_F(EcGroupTest, InGroupDetectsIdentityElementInGroup) { - bool in_group; - EXPECT_EQ(kEpidNoErr, EcInGroup(this->efq, &(this->efq_identity_str), - sizeof(this->efq_identity_str), &in_group)); - EXPECT_TRUE(in_group); - - EXPECT_EQ(kEpidNoErr, EcInGroup(this->efq2, &(this->efq2_identity_str), - sizeof(this->efq2_identity_str), &in_group)); - EXPECT_TRUE(in_group); -} -TEST_F(EcGroupTest, InGroupFailsGivenContextMismatch) { - bool in_group; - EXPECT_EQ(kEpidBadArgErr, EcInGroup(this->efq2, &(this->efq_a_str), - sizeof(this->efq_a_str), &in_group)); - EXPECT_FALSE(in_group); - - EXPECT_EQ(kEpidBadArgErr, EcInGroup(this->efq, &(this->efq2_a_str), - sizeof(this->efq2_a_str), &in_group)); - EXPECT_FALSE(in_group); -} -/////////////////////////////////////////////////////////////////////// -// EcHash -TEST_F(EcGroupTest, HashFailsGivenArgumentsMismatch) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq2, msg, sizeof(msg), kSha256, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, msg, sizeof(msg), kSha256, this->efq2_r)); -} -TEST_F(EcGroupTest, HashFailsGivenNullPointer) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidBadArgErr, - EcHash(nullptr, msg, sizeof(msg), kSha256, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, nullptr, sizeof(msg), kSha256, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, msg, sizeof(msg), kSha256, nullptr)); -} -TEST_F(EcGroupTest, HashFailsGivenUnsupportedHashAlg) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - EcHash(this->efq, msg, sizeof(msg), kSha512_256, this->efq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - EcHash(this->efq, msg, sizeof(msg), kSha3_256, this->efq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - EcHash(this->efq, msg, sizeof(msg), kSha3_384, this->efq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - EcHash(this->efq, msg, sizeof(msg), kSha3_512, this->efq_r)); -} -TEST_F(EcGroupTest, HashFailsGivenIncorrectMsgLen) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidBadArgErr, EcHash(this->efq, msg, 0, kSha256, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, msg, std::numeric_limits::max(), kSha256, - this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, msg, (size_t)INT_MAX + 1, kSha256, this->efq_r)); -#if (SIZE_MAX >= 0x100000001) // When size_t value allowed to be 0x100000001 - EXPECT_EQ(kEpidBadArgErr, - EcHash(this->efq, msg, (size_t)0x100000001, kSha256, this->efq_r)); -#endif -} -TEST_F(EcGroupTest, HashWorksGivenSHA256HashAlg) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcHash(this->efq, sha_msg, sizeof(sha_msg), kSha256, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_r_sha256_str, efq_r_str); -} -TEST_F(EcGroupTest, HashWorksGivenSHA384HashAlg) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcHash(this->efq, sha_msg, sizeof(sha_msg), kSha384, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_r_sha384_str, efq_r_str); -} -TEST_F(EcGroupTest, HashWorksGivenSHA512HashAlg) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, - EcHash(this->efq, sha_msg, sizeof(sha_msg), kSha512, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_r_sha512_str, efq_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcMakePoint -TEST_F(EcGroupTest, MakePointFailsGivenArgumentsMismatch) { - FfElementObj fq2_a(&this->efq2_par->fq2); - - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(this->efq2, this->fq_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(this->efq, fq2_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(this->efq2, this->fq_a, this->efq2_r)); -} -TEST_F(EcGroupTest, MakePointFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(nullptr, this->fq_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(this->efq, nullptr, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcMakePoint(this->efq, this->fq_a, nullptr)); -} -TEST_F(EcGroupTest, MakePointSucceedsGivenElement) { - Prng my_prng; - G1ElemStr efq_r_str; - - // a pre-computed point in eqf - G1ElemStr efq_ref_str = { - {{0X1C, 0X53, 0X40, 0X69, 0X8B, 0X77, 0X75, 0XAA, 0X2B, 0X7D, 0X91, 0XD6, - 0X29, 0X49, 0X05, 0X7F, 0XF6, 0X4C, 0X63, 0X90, 0X58, 0X22, 0X06, 0XF5, - 0X1F, 0X3B, 0X9F, 0XA2, 0X04, 0X39, 0XA9, 0X67}}, - {{0X3B, 0X65, 0X58, 0XAC, 0X97, 0X46, 0X47, 0XC9, 0X84, 0X57, 0X3F, 0XFA, - 0X4F, 0XB0, 0X64, 0X8D, 0X48, 0XC8, 0X14, 0XEB, 0XF1, 0X94, 0X87, 0XDC, - 0XB3, 0X73, 0X90, 0X1D, 0X75, 0XAD, 0XD5, 0X56}}}; - - // create a point with x == ref.x - FfElementObj elem(&this->fq, efq_ref_str.x); - EXPECT_EQ(kEpidNoErr, EcMakePoint(this->efq, elem, this->efq_r)); - - // check that the point matches ref - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(efq_ref_str, efq_r_str); -} -TEST_F(EcGroupTest, MakePointFailsGivenZeroElement) { - EXPECT_EQ(kEpidBadArgErr, - EcMakePoint(this->efq, FfElementObj(&this->fq), this->efq_r)); - // EcMakePoint is only defined for G1 - EXPECT_EQ(kEpidBadArgErr, - EcMakePoint(this->efq2, FfElementObj(&this->efq2_par->fq2), - this->efq2_r)); -} -/////////////////////////////////////////////////////////////////////// -// EcInverse -TEST_F(EcGroupTest, InverseFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, EcInverse(this->efq2, this->efq_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcInverse(this->efq, this->efq2_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcInverse(this->efq, this->efq_a, this->efq2_r)); -} - -TEST_F(EcGroupTest, InverseFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, EcInverse(nullptr, this->efq_a, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcInverse(this->efq, nullptr, this->efq_r)); - EXPECT_EQ(kEpidBadArgErr, EcInverse(this->efq, this->efq_a, nullptr)); -} - -TEST_F(EcGroupTest, InverseSucceedsGivenIdentity) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, EcInverse(this->efq, this->efq_identity, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_identity_str, efq_r_str); - - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, - EcInverse(this->efq2, this->efq2_identity, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_identity_str, efq2_r_str); -} - -TEST_F(EcGroupTest, InverseSucceedsGivenElement) { - G1ElemStr efq_r_str; - EXPECT_EQ(kEpidNoErr, EcInverse(this->efq, this->efq_a, this->efq_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq, this->efq_r, &efq_r_str, sizeof(efq_r_str))); - EXPECT_EQ(this->efq_inv_a_str, efq_r_str); - - G2ElemStr efq2_r_str; - EXPECT_EQ(kEpidNoErr, EcInverse(this->efq2, this->efq2_a, this->efq2_r)); - THROW_ON_EPIDERR( - WriteEcPoint(this->efq2, this->efq2_r, &efq2_r_str, sizeof(efq2_r_str))); - EXPECT_EQ(this->efq2_inv_a_str, efq2_r_str); -} -/////////////////////////////////////////////////////////////////////// -// EcIsEqual -TEST_F(EcGroupTest, IsEqualFailsGivenArgumentsMismatch) { - bool result; - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq2, this->efq_a, this->efq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq, this->efq2_a, this->efq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq, this->efq_a, this->efq2_a, &result)); -} -TEST_F(EcGroupTest, IsEqualFailsGivenNullPointer) { - bool result; - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(nullptr, this->efq_a, this->efq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq, nullptr, this->efq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq, this->efq_a, nullptr, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsEqual(this->efq, this->efq_a, this->efq_a, nullptr)); -} -TEST_F(EcGroupTest, IsEqualCanCompareElementWithItself) { - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq, this->efq_a, this->efq_a, &result)); - EXPECT_TRUE(result); - - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq2, this->efq2_a, this->efq2_a, &result)); - EXPECT_TRUE(result); -} -TEST_F(EcGroupTest, DifferentEFqElementsAreNotEqual) { - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq, this->efq_a, this->efq_b, &result)); - EXPECT_FALSE(result); -} -TEST_F(EcGroupTest, SameEFqElementsAreEqual) { - THROW_ON_EPIDERR(ReadEcPoint(this->efq, &(this->efq_a_str), - sizeof(this->efq_a_str), this->efq_b)); - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq, this->efq_a, this->efq_b, &result)); - EXPECT_TRUE(result); -} -TEST_F(EcGroupTest, IsEqualCanCompareIdentityEFqElements) { - THROW_ON_EPIDERR(ReadEcPoint(this->efq, &(this->efq_identity_str), - sizeof(this->efq_identity_str), this->efq_b)); - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq, this->efq_identity, this->efq_b, &result)); - EXPECT_TRUE(result); -} - -TEST_F(EcGroupTest, DifferentEFq2ElementsAreNotEqual) { - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq2, this->efq2_a, this->efq2_b, &result)); - EXPECT_FALSE(result); -} -TEST_F(EcGroupTest, SameEFq2ElementsAreEqual) { - THROW_ON_EPIDERR(ReadEcPoint(this->efq2, &(this->efq2_a_str), - sizeof(this->efq2_a_str), this->efq2_b)); - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq2, this->efq2_a, this->efq2_b, &result)); - EXPECT_TRUE(result); -} -TEST_F(EcGroupTest, IsEqualCanCompareIdentityEFq2Elements) { - THROW_ON_EPIDERR(ReadEcPoint(this->efq2, &(this->efq2_identity_str), - sizeof(this->efq2_identity_str), this->efq2_b)); - bool result; - ASSERT_EQ(kEpidNoErr, - EcIsEqual(this->efq2, this->efq2_identity, this->efq2_b, &result)); - EXPECT_TRUE(result); -} -/////////////////////////////////////////////////////////////////////// -// EcIsIdentity -TEST_F(EcGroupTest, IsIdentityFailsGivenArgumentsMismatch) { - bool result; - EXPECT_EQ(kEpidBadArgErr, - EcIsIdentity(this->efq2, this->efq_identity, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsIdentity(this->efq, this->efq2_identity, &result)); -} -TEST_F(EcGroupTest, IsIdentityFailsGivenNullPointer) { - bool result; - EXPECT_EQ(kEpidBadArgErr, EcIsIdentity(nullptr, this->efq_identity, &result)); - EXPECT_EQ(kEpidBadArgErr, EcIsIdentity(this->efq, nullptr, &result)); - EXPECT_EQ(kEpidBadArgErr, - EcIsIdentity(this->efq, this->efq_identity, nullptr)); -} -TEST_F(EcGroupTest, IsIdentityDetectsIdentityElement) { - bool result; - EXPECT_EQ(kEpidNoErr, EcIsIdentity(this->efq, this->efq_identity, &result)); - EXPECT_TRUE(result); - EXPECT_EQ(kEpidNoErr, EcIsIdentity(this->efq2, this->efq2_identity, &result)); - EXPECT_TRUE(result); -} -TEST_F(EcGroupTest, IsIdentityDetectsNonIdentityElement) { - bool result; - EXPECT_EQ(kEpidNoErr, EcIsIdentity(this->efq, this->efq_a, &result)); - EXPECT_FALSE(result); - EXPECT_EQ(kEpidNoErr, EcIsIdentity(this->efq2, this->efq2_a, &result)); - EXPECT_FALSE(result); -} -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ffelement-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ffelement-test.cc deleted file mode 100644 index c80b3b7bb4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/ffelement-test.cc +++ /dev/null @@ -1,2543 +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 unit tests. - */ - -#include -#include -#include - -#include "gtest/gtest.h" - -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/common-testhelper/octstr-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" - -extern "C" { -#include "epid/common/math/finitefield.h" -} - -#include "epid/common/types.h" - -/// compares FqElemStr values -bool operator==(FqElemStr const& lhs, FqElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -bool operator==(Fq2ElemStr const& lhs, Fq2ElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -bool operator==(Fq6ElemStr const& lhs, Fq6ElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -/// compares Fq12ElemStr values -bool operator==(Fq12ElemStr const& lhs, Fq12ElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -/// compares FpElemStr values -bool operator==(FpElemStr const& lhs, FpElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -bool operator==(FfElementObj const& lhs, FfElementObj const& rhs) { - auto lhs_data = lhs.data(); - auto rhs_data = rhs.data(); - return lhs_data.size() == rhs_data.size() && - std::equal(lhs_data.begin(), lhs_data.end(), lhs_data.begin()); -} - -namespace { - -class FfElementTest : public ::testing::Test { - public: - virtual void SetUp() { - FqElemStr 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}}; - Fq2ElemStr 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}}}}}; - 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}}}}}; - - fq = FiniteFieldObj(epid20_q); - - // 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)); - fq12 = FiniteFieldObj(fq6, neg_v, 2); - - fq_zero = FfElementObj(&fq, &bn_zero_data, sizeof((bn_zero_data))); - fq_one = FfElementObj(&fq, &bn_one_data, sizeof(bn_one_data)); - fq_a = FfElementObj(&fq, &bn_a_data, sizeof(bn_a_data)); - fq_b = FfElementObj(&fq, &bn_b_data, sizeof(bn_b_data)); - fq_r = FfElementObj(&fq); - - fp = FiniteFieldObj(epid20_p); - fp_elem = FfElementObj(&fp, fp_p_data); - - exponent_zero = BigNumObj(bn_zero_data); - exponent_one = BigNumObj(bn_one_data); - exponent_b = BigNumObj(bn_a_data); - - fq2_a = FfElementObj(&fq2); - fq2_b = FfElementObj(&fq2); - fq2_r = FfElementObj(&fq2); - - fq12_a = FfElementObj(&fq12); - fq12_b = FfElementObj(&fq12); - fq12_r = FfElementObj(&fq12); - } - - FiniteFieldObj fq; - FiniteFieldObj fq2; - FiniteFieldObj fq6; - FiniteFieldObj fq12; - - FfElementObj fq_zero; - FfElementObj fq_one; - FfElementObj fq_a; - FfElementObj fq_b; - FfElementObj fq_r; - - FfElementObj fq2_a; - FfElementObj fq2_b; - FfElementObj fq2_r; - - FfElementObj fq12_a; - FfElementObj fq12_b; - FfElementObj fq12_r; - - FiniteFieldObj fp; - FfElementObj fp_elem; - - BigNumObj exponent_zero; - BigNumObj exponent_one; - BigNumObj exponent_b; - - /// Intel(R) EPID 2.0 parameter q - static const BigNumStr epid20_q; - static const BigNumStr epid20_p; - static const BigNumStr bn_zero_data; - static const FqElemStr fq_zero_data; - static const BigNumStr bn_one_data; - static const FqElemStr fq_one_data; - static const BigNumStr bn_two_data; - static const BigNumStr bn_a_data; - static const FqElemStr fq_a_data; - static const BigNumStr bn_b_data; - static const FqElemStr fq_b_data; - static const FqElemStr fq_mul_ab_data; - static const FqElemStr fq_inv_a_data; - static const FqElemStr fq_neg_a_data; - static const FqElemStr fq_exp_ab_data; - static const FqElemStr fq_sum_ab_data; - static const FpElemStr fp_p_data; - static const uint8_t sha_msg[3]; /// predefined message for tests "abc" - static const FqElemStr fq_r_sha256; - static const FqElemStr fq_r_sha384; - static const FqElemStr fq_r_sha512; -}; - -/// Intel(R) EPID 2.0 parameter q -const BigNumStr FfElementTest::epid20_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}; - -const BigNumStr FfElementTest::epid20_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}; - -const BigNumStr FfElementTest::bn_zero_data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 FqElemStr FfElementTest::fq_zero_data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 FfElementTest::bn_one_data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 BigNumStr FfElementTest::bn_two_data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 FqElemStr FfElementTest::fq_one_data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 BigNumStr FfElementTest::bn_a_data = { - 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}; - -const FqElemStr FfElementTest::fq_a_data = { - 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}; - -const BigNumStr FfElementTest::bn_b_data = { - 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}; - -const FqElemStr FfElementTest::fq_b_data = { - 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}; - -const FqElemStr FfElementTest::fq_mul_ab_data = { - 0xE4, 0xAB, 0xE3, 0xE4, 0x08, 0xC3, 0x8A, 0x00, 0x78, 0x50, 0x01, - 0xA9, 0x4A, 0xFC, 0x43, 0x15, 0xA2, 0x99, 0x51, 0x20, 0x6B, 0x9C, - 0x00, 0xCF, 0x82, 0x88, 0xBD, 0x39, 0x0B, 0xA2, 0x0B, 0x58}; - -const FqElemStr FfElementTest::fq_inv_a_data = { - 0x15, 0x17, 0x1A, 0x1E, 0x93, 0x71, 0x1B, 0x39, 0xC5, 0x97, 0xEF, - 0x78, 0xA5, 0x51, 0x34, 0x62, 0x44, 0xAD, 0x8D, 0x51, 0xDF, 0x90, - 0x7C, 0x6F, 0x56, 0xB6, 0xAB, 0x63, 0x5A, 0x68, 0x6D, 0xF6}; - -const FqElemStr FfElementTest::fq_neg_a_data = { - 0xED, 0x59, 0xA4, 0x29, 0x6E, 0x6F, 0xA0, 0x25, 0xDF, 0xFA, 0x75, - 0x0C, 0x0B, 0x31, 0x8D, 0x3E, 0x8C, 0xFC, 0xF9, 0x59, 0xE6, 0x7D, - 0xD2, 0xA2, 0x40, 0x68, 0x36, 0x22, 0x38, 0x27, 0x7E, 0x89}; - -const FqElemStr FfElementTest::fq_exp_ab_data = { - 0x29, 0x65, 0x68, 0x0E, 0x56, 0xB9, 0x8F, 0xBA, 0xA6, 0xEA, 0x8F, - 0xE1, 0x13, 0x44, 0x3B, 0x12, 0x5C, 0xB9, 0xF8, 0x76, 0x42, 0x12, - 0xCB, 0xB2, 0xED, 0xC0, 0x23, 0xA3, 0x5C, 0xAD, 0x38, 0xD1}; - -const FqElemStr FfElementTest::fq_sum_ab_data = { - 0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F, - 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79, - 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C}; - -const FpElemStr FfElementTest::fp_p_data = { - 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, 0x00}; -const uint8_t FfElementTest::sha_msg[] = {'a', 'b', 'c'}; -const FqElemStr FfElementTest::fq_r_sha256 = { - 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40, - 0xDE, 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, - 0x7A, 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD, -}; -const FqElemStr FfElementTest::fq_r_sha384 = { - 0x10, 0xAC, 0xE4, 0xE8, 0x8F, 0xBB, 0x96, 0xBF, 0x53, 0xB6, 0xAF, - 0xE4, 0x4E, 0x95, 0xDE, 0xA5, 0x98, 0x8F, 0x10, 0xBF, 0x59, 0xC4, - 0x11, 0xFE, 0x1F, 0x7A, 0xA6, 0x1E, 0x57, 0x3E, 0xE3, 0x3C, -}; -const FqElemStr FfElementTest::fq_r_sha512 = { - 0x14, 0xB4, 0x28, 0x89, 0xD2, 0x86, 0xA4, 0x79, 0xE3, 0x5B, 0xC4, - 0x50, 0xD1, 0x3B, 0xF2, 0x35, 0xF7, 0x97, 0x91, 0x05, 0x3D, 0x64, - 0xC0, 0x06, 0x45, 0x9F, 0xEC, 0xD8, 0xDB, 0x53, 0x3E, 0xC3, -}; - -/////////////////////////////////////////////////////////////////////// -// NewFfElement - -TEST_F(FfElementTest, NewFailsGivenNullPointer) { - FfElement* ff_elem = nullptr; - EXPECT_EQ(kEpidBadArgErr, NewFfElement(nullptr, &ff_elem)); - EXPECT_EQ(kEpidBadArgErr, NewFfElement(this->fq, nullptr)); - DeleteFfElement(&ff_elem); -} - -TEST_F(FfElementTest, NewSucceedsGiven256BitFiniteField) { - FfElement* ff_elem = nullptr; - EXPECT_EQ(kEpidNoErr, NewFfElement(this->fq, &ff_elem)); - DeleteFfElement(&ff_elem); -} - -TEST_F(FfElementTest, Default256BitElementIsZero) { - FfElement* ff_elem = nullptr; - THROW_ON_EPIDERR(NewFfElement(this->fq, &ff_elem)); - FqElemStr ff_elem_str; - EpidStatus sts = - WriteFfElement(this->fq, ff_elem, &ff_elem_str, sizeof(ff_elem_str)); - DeleteFfElement(&ff_elem); - THROW_ON_EPIDERR(sts); - - FqElemStr fq_zero_str = {0}; - EXPECT_EQ(fq_zero_str, ff_elem_str); -} - -/////////////////////////////////////////////////////////////////////// -// DeleteFfElement - -TEST_F(FfElementTest, DeleteNullsPointer) { - FfElement* ff_elem = nullptr; - EpidStatus sts = NewFfElement(this->fq, &ff_elem); - DeleteFfElement(&ff_elem); - THROW_ON_EPIDERR(sts); - EXPECT_EQ(nullptr, ff_elem); -} - -TEST_F(FfElementTest, DeleteWorksGivenNullPointer) { - EXPECT_NO_THROW(DeleteFfElement(nullptr)); - FfElement* ff_elem = nullptr; - EXPECT_NO_THROW(DeleteFfElement(&ff_elem)); -} - -/////////////////////////////////////////////////////////////////////// -// ReadFfElement - -TEST_F(FfElementTest, ReadFailsGivenArgumentsMismatch) { - uint8_t buf[sizeof(Fq12ElemStr)] = {0}; - EXPECT_EQ(kEpidBadArgErr, - ReadFfElement(this->fq12, buf, sizeof(Fq12ElemStr), this->fq_a)); - EXPECT_EQ(kEpidBadArgErr, - ReadFfElement(this->fq, buf, sizeof(FqElemStr), this->fq12_a)); -} - -TEST_F(FfElementTest, ReadFailsGivenNullPointer) { - FqElemStr ff_elem_str; - EXPECT_EQ(kEpidBadArgErr, ReadFfElement(nullptr, &ff_elem_str, - sizeof(ff_elem_str), this->fq_a)); - EXPECT_EQ(kEpidBadArgErr, - ReadFfElement(this->fq, nullptr, sizeof(ff_elem_str), this->fq_a)); - EXPECT_EQ(kEpidBadArgErr, ReadFfElement(this->fq, &ff_elem_str, - sizeof(ff_elem_str), nullptr)); -} - -TEST_F(FfElementTest, ReadFailsGivenInvalidBufferSize) { - FqElemStr ff_elem_str; - EXPECT_EQ(kEpidBadArgErr, - ReadFfElement(this->fq, &ff_elem_str, 0, this->fq_a)); - EXPECT_EQ(kEpidBadArgErr, - ReadFfElement(this->fq, &ff_elem_str, - std::numeric_limits::max(), this->fq_a)); -} - -TEST_F(FfElementTest, ReadFailsGivenElementDoesNotBelongToFF) { - // q does not belong to Fq - FqElemStr ff_elem_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}; - EXPECT_EQ(kEpidBadArgErr, ReadFfElement(this->fq, &ff_elem_str, - sizeof(ff_elem_str), this->fq_a)); -} - -TEST_F(FfElementTest, Read256BitElementCorrectly) { - // q-1 is valid element of Fq - FqElemStr ff_elem_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}; - ASSERT_EQ(kEpidNoErr, ReadFfElement(this->fq, &ff_elem_str, - sizeof(ff_elem_str), this->fq_a)); - - FqElemStr buf; - EXPECT_EQ(kEpidNoErr, - WriteFfElement(this->fq, this->fq_a, &buf, sizeof(buf))); - EXPECT_EQ(ff_elem_str, buf); -} - -/////////////////////////////////////////////////////////////////////// -// FfIsEqual - -TEST_F(FfElementTest, FfIsEqualFailsGivenArgumentsMismatch) { - bool result; - EXPECT_EQ(kEpidBadArgErr, - FfIsEqual(this->fq12, this->fq_a, this->fq_b, &result)); - EXPECT_EQ(kEpidBadArgErr, - FfIsEqual(this->fq, this->fq12_a, this->fq_b, &result)); - EXPECT_EQ(kEpidBadArgErr, - FfIsEqual(this->fq, this->fq_a, this->fq12_b, &result)); -} - -TEST_F(FfElementTest, FfIsEqualFailsGivenNullPointer) { - bool result; - EXPECT_EQ(kEpidBadArgErr, - FfIsEqual(nullptr, this->fq_a, this->fq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, FfIsEqual(this->fq, nullptr, this->fq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, FfIsEqual(this->fq, this->fq_a, nullptr, &result)); - EXPECT_EQ(kEpidBadArgErr, - FfIsEqual(this->fq, this->fq_a, this->fq_a, nullptr)); -} - -TEST_F(FfElementTest, FfIsEqualCanCompareElementWithItself) { - bool result; - EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, this->fq_a, &result)); - EXPECT_TRUE(result); -} - -TEST_F(FfElementTest, Different256BitFiniteFieldElementsAreNotEqual) { - bool result; - EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, this->fq_b, &result)); - EXPECT_FALSE(result); -} - -TEST_F(FfElementTest, Same256BitFiniteFieldElementsAreEqual) { - THROW_ON_EPIDERR(ReadFfElement(this->fq, &(this->bn_a_data), - sizeof(this->bn_a_data), this->fq_b)); - bool result; - EXPECT_EQ(kEpidNoErr, FfIsEqual(this->fq, this->fq_a, this->fq_b, &result)); - EXPECT_TRUE(result); -} - -TEST_F(FfElementTest, DifferentFq12ElementsAreNotEqual) { - const Fq12ElemStr a_str = { - 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01, - 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1, - 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4, - 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2, - 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84, - 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7, - 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c, - 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19, - 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00, - 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e, - 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29, - 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6, - 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a, - 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5, - 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73, - 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03, - 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51, - 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41, - 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc, - 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4, - 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31, - 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8, - 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03, - 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e, - 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e, - 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda, - 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed, - 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8, - 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19, - 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76, - 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26, - 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e, - }; - const Fq12ElemStr b_str = { - 0x41, 0xfb, 0xbe, 0xd2, 0x20, 0x95, 0xe5, 0xba, 0x87, 0x54, 0x23, 0xcc, - 0x04, 0x97, 0x38, 0x4b, 0x69, 0x28, 0x18, 0x6d, 0xae, 0x19, 0xe3, 0x3d, - 0xfe, 0x39, 0xe2, 0x1c, 0xc2, 0x53, 0x17, 0xf6, 0xea, 0xa3, 0x0f, 0x62, - 0x6e, 0xbf, 0x6f, 0x8f, 0xbc, 0xfa, 0x6e, 0x07, 0xd3, 0xd3, 0xae, 0x5c, - 0xaa, 0xb5, 0x9c, 0xd7, 0xb8, 0x5b, 0x1b, 0x69, 0x52, 0x93, 0xbf, 0xdb, - 0x87, 0x5c, 0x19, 0x07, 0x1b, 0x03, 0xe1, 0x79, 0x3c, 0x10, 0x0b, 0x65, - 0xbf, 0xd7, 0xf3, 0x45, 0x1a, 0xd4, 0xdd, 0xb8, 0x67, 0x1a, 0x8f, 0x41, - 0x1a, 0xd4, 0x04, 0x3c, 0xd2, 0xa4, 0x3b, 0x47, 0xfe, 0xbd, 0xea, 0x87, - 0xdf, 0x7f, 0x94, 0x9c, 0xb8, 0x65, 0x54, 0x8d, 0xd7, 0x0b, 0x33, 0x26, - 0x25, 0x89, 0xd4, 0x60, 0x0c, 0x89, 0x5f, 0x2c, 0x00, 0x7f, 0xaf, 0x89, - 0x35, 0xe5, 0xb9, 0x23, 0x7f, 0x79, 0x1a, 0x86, 0xce, 0x01, 0x4f, 0x24, - 0x3c, 0x3a, 0xc3, 0x61, 0x5b, 0xd9, 0x2d, 0x87, 0x94, 0xa3, 0xd2, 0x8b, - 0x57, 0xc4, 0x07, 0xf8, 0x29, 0x5e, 0x09, 0x23, 0xca, 0xe9, 0x85, 0xa1, - 0xdb, 0xf2, 0x0c, 0x8f, 0xc2, 0xfb, 0x9a, 0xcc, 0xd9, 0x82, 0x63, 0x28, - 0x83, 0xb7, 0x4f, 0x99, 0x3a, 0x19, 0x11, 0xb0, 0xb4, 0xe7, 0x73, 0x94, - 0x35, 0x19, 0x6b, 0xc2, 0x5d, 0x2e, 0x8c, 0x33, 0xff, 0x13, 0xcd, 0xbe, - 0x29, 0x43, 0xf6, 0xa0, 0xe9, 0xdc, 0x27, 0x27, 0x9b, 0x0a, 0x33, 0xbc, - 0x85, 0x6a, 0xbf, 0x8b, 0xc5, 0x89, 0x10, 0x92, 0xae, 0x73, 0xc9, 0x32, - 0x46, 0x8d, 0x24, 0x1f, 0x32, 0x96, 0xed, 0x0b, 0x44, 0x8c, 0x6d, 0xf6, - 0x1a, 0x2f, 0xca, 0x18, 0x8e, 0x84, 0xff, 0x5f, 0x5f, 0xaf, 0xc0, 0x52, - 0x35, 0xa1, 0xb3, 0xa0, 0xde, 0xee, 0x97, 0xbf, 0xb8, 0xfa, 0x8b, 0x9e, - 0x00, 0x13, 0xe7, 0x26, 0xfb, 0x78, 0xa1, 0x6d, 0x41, 0x92, 0xa6, 0xc6, - 0x7f, 0xad, 0xb7, 0xfc, 0x4f, 0x5f, 0x48, 0x94, 0x7d, 0xb7, 0xf5, 0xcc, - 0xb5, 0x7e, 0x08, 0xcd, 0xbf, 0x58, 0xc9, 0x30, 0xeb, 0xe4, 0xa0, 0xbf, - 0x0c, 0x6a, 0x89, 0x18, 0x97, 0x37, 0x54, 0x76, 0x79, 0x3e, 0x8e, 0xa6, - 0x5b, 0x77, 0xce, 0x4a, 0xcb, 0xd9, 0x8b, 0x7b, 0x32, 0x1a, 0x30, 0x40, - 0x49, 0xff, 0x84, 0xe7, 0xbe, 0xd8, 0xcf, 0xfd, 0x2d, 0x23, 0x54, 0xb5, - 0x2e, 0x29, 0xe9, 0xc7, 0x62, 0x1b, 0x03, 0x34, 0x3a, 0xeb, 0xc9, 0x69, - 0x38, 0x9f, 0xd1, 0x2b, 0xda, 0x8b, 0x07, 0x58, 0x30, 0xf8, 0x38, 0x08, - 0x09, 0x07, 0xca, 0x5b, 0x3a, 0x13, 0xed, 0xf4, 0x5d, 0xc9, 0x23, 0x66, - 0x85, 0x8c, 0x6a, 0x7d, 0xe9, 0x11, 0x17, 0xe6, 0x43, 0x2f, 0x12, 0xc5, - 0x07, 0x63, 0x84, 0x98, 0xa0, 0x1c, 0xdc, 0xf3, 0x91, 0x91, 0x11, 0x55, - }; - - THROW_ON_EPIDERR( - ReadFfElement(this->fq12, &(a_str), sizeof(a_str), this->fq12_a)); - THROW_ON_EPIDERR( - ReadFfElement(this->fq12, &(b_str), sizeof(b_str), this->fq12_b)); - bool result; - EXPECT_EQ(kEpidNoErr, - FfIsEqual(this->fq12, this->fq12_a, this->fq12_b, &result)); - EXPECT_FALSE(result); -} - -TEST_F(FfElementTest, SameFq12ElementsAreEqual) { - const Fq12ElemStr a_str = { - 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01, - 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1, - 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4, - 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2, - 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84, - 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7, - 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c, - 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19, - 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00, - 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e, - 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29, - 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6, - 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a, - 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5, - 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73, - 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03, - 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51, - 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41, - 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc, - 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4, - 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31, - 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8, - 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03, - 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e, - 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e, - 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda, - 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed, - 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8, - 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19, - 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76, - 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26, - 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e, - }; - const Fq12ElemStr b_str = { - 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01, - 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1, - 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4, - 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2, - 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84, - 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7, - 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c, - 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19, - 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00, - 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e, - 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29, - 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6, - 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a, - 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5, - 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73, - 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03, - 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51, - 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41, - 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc, - 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4, - 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31, - 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8, - 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03, - 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e, - 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e, - 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda, - 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed, - 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8, - 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19, - 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76, - 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26, - 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e, - }; - - THROW_ON_EPIDERR( - ReadFfElement(this->fq12, &(a_str), sizeof(a_str), this->fq12_a)); - THROW_ON_EPIDERR( - ReadFfElement(this->fq12, &(b_str), sizeof(b_str), this->fq12_b)); - bool result; - EXPECT_EQ(kEpidNoErr, - FfIsEqual(this->fq12, this->fq12_a, this->fq12_b, &result)); - EXPECT_TRUE(result); -} - -/////////////////////////////////////////////////////////////////////// -// WriteFfElement - -TEST_F(FfElementTest, WriteFailsGivenArgumentsMismatch) { - uint8_t buf[sizeof(Fq12ElemStr)] = {0}; - EXPECT_EQ(kEpidBadArgErr, - WriteFfElement(this->fq12, this->fq_a, buf, sizeof(Fq12ElemStr))); - EXPECT_EQ(kEpidBadArgErr, - WriteFfElement(this->fq, this->fq12_a, buf, sizeof(Fq12ElemStr))); -} - -TEST_F(FfElementTest, WriteFailsGivenNullPointer) { - FqElemStr ff_elem_str; - EXPECT_EQ(kEpidBadArgErr, WriteFfElement(nullptr, this->fq_a, &ff_elem_str, - sizeof(ff_elem_str))); - EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, nullptr, &ff_elem_str, - sizeof(ff_elem_str))); - EXPECT_EQ(kEpidBadArgErr, - WriteFfElement(this->fq, this->fq_a, nullptr, sizeof(ff_elem_str))); -} - -TEST_F(FfElementTest, WriteFailsGivenInvalidBufferSize) { - FqElemStr ff_elem_str; - EXPECT_EQ(kEpidBadArgErr, - WriteFfElement(this->fq, this->fq_a, &ff_elem_str, 0)); - EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str, - sizeof(ff_elem_str) - 1)); - EXPECT_EQ(kEpidBadArgErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str, - std::numeric_limits::max())); -} - -TEST_F(FfElementTest, WriteWorksGiven256BitElement) { - FqElemStr ff_elem_str; - EXPECT_EQ(kEpidNoErr, WriteFfElement(this->fq, this->fq_a, &ff_elem_str, - sizeof(ff_elem_str))); - EXPECT_EQ(this->fq_a_data, ff_elem_str); -} - -/////////////////////////////////////////////////////////////////////// -// FfNeg - -TEST_F(FfElementTest, FfNegFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq12, this->fq_a, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq12_a, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq_a, this->fq12_r)); -} - -TEST_F(FfElementTest, FfNegFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, FfNeg(nullptr, this->fq_a, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, nullptr, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfNeg(this->fq, this->fq_a, nullptr)); -} - -TEST_F(FfElementTest, FfNegSucceedsGivenElementZero) { - FqElemStr fq_r_data; - EXPECT_EQ(kEpidNoErr, FfNeg(this->fq, this->fq_zero, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_zero_data, fq_r_data) - << "FfNeg: Negate element does not match to reference neg zero value"; -} - -TEST_F(FfElementTest, FfNegSucceedsGivenNonZeroElement) { - FqElemStr fq_r_data; - EXPECT_EQ(kEpidNoErr, FfNeg(this->fq, this->fq_a, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_neg_a_data, fq_r_data) - << "FfNeg: Negate element does not match to reference neg value"; -} - -/////////////////////////////////////////////////////////////////////// -// FfIsZero - -TEST_F(FfElementTest, FfIsZeroFailsGivenNullPointer) { - bool result = false; - EXPECT_EQ(kEpidBadArgErr, FfIsZero(nullptr, this->fq_zero, &result)); - EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, nullptr, &result)); - EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, this->fq_zero, nullptr)); -} - -TEST_F(FfElementTest, FfIsZeroFailsGivenArgumentsMismatch) { - bool result; - EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq12, this->fq_a, &result)); - EXPECT_EQ(kEpidBadArgErr, FfIsZero(this->fq, this->fq12_a, &result)); -} - -TEST_F(FfElementTest, FfIsZeroSucceedsGivenZeroElement) { - bool result = false; - EXPECT_EQ(kEpidNoErr, FfIsZero(this->fq, this->fq_zero, &result)); - EXPECT_TRUE(result); -} - -TEST_F(FfElementTest, FfIsZeroSucceedsGivenNonZeroElement) { - bool result = false; - EXPECT_EQ(kEpidNoErr, FfIsZero(this->fq, this->fq_one, &result)); - EXPECT_FALSE(result); -} - -/////////////////////////////////////////////////////////////////////// -// FfMul - -TEST_F(FfElementTest, FfMulFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, FfMul(nullptr, this->fq_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMul(this->fq, nullptr, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMul(this->fq, this->fq_a, nullptr, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMul(this->fq, this->fq_a, this->fq_b, nullptr)); -} - -TEST_F(FfElementTest, FfMulFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, - FfMul(this->fq12, this->fq_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMul(this->fq, this->fq12_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMul(this->fq, this->fq_a, this->fq12_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMul(this->fq, this->fq_a, this->fq_b, this->fq12_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMul(this->fq2, this->fq_a, this->fq2_b, this->fq2_r)); -} - -TEST_F(FfElementTest, FfMulSucceedsGivenElementZero) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, FfMul(this->fq, this->fq_zero, this->fq_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_zero_data, fq_r_data); - - EXPECT_EQ(kEpidNoErr, FfMul(this->fq, this->fq_a, this->fq_zero, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_zero_data, fq_r_data); -} - -TEST_F(FfElementTest, FfMulSucceedsGivenElementOne) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, FfMul(this->fq, this->fq_one, this->fq_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_b_data, fq_r_data); - - EXPECT_EQ(kEpidNoErr, FfMul(this->fq, this->fq_a, this->fq_one, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_a_data, fq_r_data); -} - -TEST_F(FfElementTest, FfMulSucceedsGivenTwoElements) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, FfMul(this->fq, this->fq_a, this->fq_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_mul_ab_data, fq_r_data); - - Fq2ElemStr fq2_r_str; - - const Fq2ElemStr fq2_a_str = { - 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, 0xDD, - 0x2B, 0xE9, 0x59, 0x24, 0xA5, 0xB3, 0xFD, 0xEB, 0xE1, 0x3C, 0xC0, - 0x73, 0x4E, 0x99, 0xEE, 0x36, 0xF6, 0xC0, 0x1A, 0x76, 0x01, 0x0A, - 0xF0, 0xCB, 0xB4, 0x71, 0x88, 0x95, 0xCB, 0x35, 0xBA}; - - const Fq2ElemStr fq2_mul_ab_str = { - 0xE4, 0xAB, 0xE3, 0xE4, 0x08, 0xC3, 0x8A, 0x00, 0x78, 0x50, 0x01, - 0xA9, 0x4A, 0xFC, 0x43, 0x15, 0xA2, 0x99, 0x51, 0x20, 0x6B, 0x9C, - 0x00, 0xCF, 0x82, 0x88, 0xBD, 0x39, 0x0B, 0xA2, 0x0B, 0x58, 0xB4, - 0xE4, 0x39, 0xEA, 0x70, 0xDE, 0x15, 0xC3, 0xC6, 0x91, 0xFD, 0x7F, - 0xBE, 0x2B, 0xF5, 0xD2, 0xC0, 0xB7, 0x20, 0xFC, 0x1F, 0x02, 0x33, - 0xC9, 0x39, 0x93, 0xB9, 0x5E, 0x55, 0x51, 0xB6, 0x46}; - - THROW_ON_EPIDERR( - ReadFfElement(this->fq2, &(fq2_a_str), sizeof(fq2_a_str), this->fq2_a)); - THROW_ON_EPIDERR( - ReadFfElement(this->fq, &(fq_b_data), sizeof(fq_b_data), this->fq_b)); - EXPECT_EQ(kEpidNoErr, FfMul(this->fq2, this->fq2_a, this->fq_b, this->fq2_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq2, this->fq2_r, &fq2_r_str, sizeof(fq2_r_str))); - EXPECT_EQ(fq2_mul_ab_str, fq2_r_str); - - Fq12ElemStr fq12_r_str; - const Fq12ElemStr fq12_a_str = { - 0x0f, 0xd0, 0x1c, 0x59, 0x98, 0x52, 0x5a, 0x40, 0xff, 0x26, 0x0a, 0xfd, - 0x70, 0xec, 0x23, 0x48, 0x1b, 0x4b, 0x70, 0xa0, 0x15, 0xc5, 0xb1, 0x8b, - 0xa5, 0x75, 0xac, 0xce, 0xf3, 0x6c, 0xe8, 0xba, 0xa7, 0xfb, 0xf9, 0xea, - 0x18, 0x70, 0xd8, 0x9b, 0x3c, 0xc3, 0x66, 0x10, 0x38, 0xac, 0x16, 0x32, - 0xdc, 0x9d, 0xf0, 0xd4, 0x2c, 0xe7, 0xf6, 0x69, 0x47, 0x69, 0x84, 0xee, - 0x39, 0x5f, 0xd8, 0xcc, 0x1b, 0xef, 0x81, 0x13, 0x81, 0xb9, 0x56, 0xae, - 0xd0, 0xd4, 0xae, 0xcb, 0x24, 0x7c, 0x7b, 0x7f, 0xc0, 0x41, 0x42, 0x0a, - 0x9d, 0x90, 0x6b, 0x1e, 0x3a, 0xad, 0x39, 0x7a, 0x1f, 0xef, 0x56, 0x9e, - 0xbd, 0x84, 0x48, 0xaf, 0x65, 0x66, 0x33, 0xe5, 0x67, 0xf1, 0xc4, 0x48, - 0xf0, 0xb6, 0x61, 0x06, 0xc7, 0x78, 0xb3, 0xc1, 0x12, 0xb8, 0x31, 0xd4, - 0x69, 0x2e, 0x0e, 0xd3, 0xd4, 0x91, 0x81, 0x9a, 0x23, 0x62, 0x9b, 0x83, - 0x95, 0xf6, 0x7f, 0xf6, 0xcc, 0x6b, 0xee, 0x84, 0xf0, 0x5b, 0x93, 0xa6, - 0x90, 0x48, 0x1a, 0xa7, 0xa8, 0xe8, 0x10, 0xa5, 0x53, 0x7e, 0x4f, 0xd5, - 0x0d, 0xb0, 0x86, 0xf7, 0x1f, 0xb8, 0xb7, 0xd4, 0x2e, 0x41, 0x83, 0x2c, - 0xfc, 0x62, 0x14, 0xb8, 0xc2, 0xf6, 0xc1, 0x5e, 0xc1, 0xc1, 0x40, 0x8b, - 0x28, 0xb5, 0x1b, 0x85, 0xee, 0x71, 0xc8, 0x14, 0x56, 0xb9, 0x3b, 0x90, - 0x4a, 0xfe, 0x73, 0xfa, 0xcf, 0x20, 0x67, 0x0e, 0x89, 0x1d, 0xcb, 0x05, - 0x38, 0x27, 0x1c, 0xd5, 0x7a, 0x0c, 0xac, 0x92, 0x17, 0x94, 0x7f, 0x10, - 0x3e, 0xff, 0x97, 0x23, 0x66, 0x8d, 0x70, 0xae, 0x80, 0x97, 0xff, 0x88, - 0xf8, 0x01, 0x2b, 0x99, 0x81, 0xeb, 0xf8, 0x19, 0xef, 0xda, 0xe3, 0xae, - 0xd9, 0x9b, 0x4c, 0x13, 0xfc, 0x9e, 0x18, 0xd6, 0xb0, 0xcf, 0x4e, 0x29, - 0xa8, 0xcf, 0x01, 0xfa, 0xda, 0x22, 0x85, 0x18, 0x9a, 0x51, 0x17, 0xac, - 0x26, 0x57, 0xf6, 0x73, 0x59, 0x24, 0xd5, 0xc9, 0x4d, 0xac, 0xb6, 0xe4, - 0x51, 0xf7, 0x5e, 0x30, 0x5b, 0x25, 0x3d, 0x52, 0xa3, 0xe0, 0x4b, 0xa2, - 0xc3, 0x4c, 0x2f, 0x53, 0xd5, 0x92, 0x33, 0x7e, 0x8b, 0x66, 0x5f, 0x48, - 0x48, 0xca, 0xa8, 0x98, 0x0f, 0x73, 0xd3, 0x60, 0xaf, 0x25, 0x02, 0xee, - 0x64, 0xe7, 0x02, 0x89, 0x9a, 0xd2, 0x96, 0x45, 0x04, 0xe1, 0x30, 0x9b, - 0xd8, 0x85, 0xf0, 0x99, 0x7c, 0x01, 0xd5, 0x58, 0x5a, 0x74, 0x0b, 0xd4, - 0xf2, 0xfa, 0xc7, 0x59, 0x36, 0xfd, 0x91, 0x07, 0x60, 0xf7, 0xdc, 0x11, - 0x3e, 0x8a, 0xc6, 0x48, 0x0d, 0x02, 0x30, 0x18, 0xd0, 0xb9, 0x6b, 0xd6, - 0x39, 0x6a, 0x41, 0x82, 0xdd, 0xe3, 0xce, 0xb8, 0xb6, 0xf5, 0x61, 0x80, - 0x61, 0x16, 0xf4, 0x9a, 0xb8, 0x58, 0x1d, 0x3f, 0x4d, 0xc2, 0xca, 0xcf, - }; - const Fq12ElemStr fq12_b_str = { - 0x3a, 0x30, 0x33, 0xa2, 0x14, 0xdf, 0xdc, 0x70, 0x48, 0xf3, 0xba, 0x3f, - 0xce, 0xfc, 0x69, 0x24, 0xae, 0xa1, 0xf3, 0xcf, 0xd8, 0x77, 0x69, 0x38, - 0x38, 0xf4, 0x8e, 0xfb, 0x51, 0xfb, 0x10, 0x7c, 0x73, 0xb4, 0xee, 0xf9, - 0x76, 0xbb, 0x45, 0xec, 0x07, 0x24, 0x23, 0xa3, 0x38, 0x64, 0x39, 0x4c, - 0x03, 0x94, 0xf5, 0xee, 0x5f, 0xc9, 0x83, 0x4f, 0xd1, 0xa6, 0x4a, 0x05, - 0x25, 0x0c, 0x46, 0x33, 0xd4, 0x40, 0x47, 0xae, 0xec, 0xda, 0x30, 0xf9, - 0xe1, 0x28, 0xfb, 0xb1, 0x4c, 0x62, 0xfb, 0x6c, 0x90, 0x0d, 0xb1, 0xec, - 0xaf, 0x2d, 0x95, 0x64, 0x11, 0x93, 0xda, 0x8e, 0xb8, 0x7d, 0xe4, 0xa3, - 0x8e, 0xa6, 0x9b, 0xaa, 0x58, 0xd5, 0xdc, 0x59, 0x1a, 0x51, 0x53, 0x47, - 0x30, 0x1c, 0x2b, 0xb0, 0xbb, 0x57, 0x57, 0x0a, 0x8c, 0x5f, 0x62, 0x9c, - 0x52, 0x28, 0xc0, 0x25, 0x27, 0xae, 0xcd, 0x36, 0xbf, 0x2d, 0x03, 0xb1, - 0x33, 0xfd, 0x24, 0x81, 0x3c, 0x91, 0x43, 0x90, 0x0c, 0x20, 0xc4, 0xe3, - 0x69, 0x3f, 0xa9, 0xa2, 0x7c, 0xc2, 0x48, 0x28, 0x1b, 0xf0, 0x81, 0x1f, - 0x2b, 0x8f, 0x8d, 0x43, 0x38, 0x18, 0x12, 0xa3, 0x89, 0xf1, 0xd7, 0x60, - 0x89, 0x68, 0x6a, 0xc4, 0xcc, 0x5d, 0xf4, 0xce, 0x43, 0x95, 0x84, 0xcd, - 0x01, 0x55, 0xb8, 0x5d, 0x24, 0x50, 0xcd, 0xe3, 0x68, 0x1c, 0xff, 0x59, - 0x0d, 0xac, 0xcb, 0xe7, 0x9d, 0x68, 0x0f, 0x4a, 0xaf, 0xeb, 0xb5, 0xfb, - 0xf9, 0xb1, 0x58, 0x80, 0xd5, 0x71, 0x53, 0x26, 0x2e, 0x9c, 0xce, 0x10, - 0xac, 0xd2, 0x0a, 0xeb, 0xb4, 0x5c, 0xc8, 0xd7, 0x16, 0x26, 0x66, 0x71, - 0xdd, 0x67, 0xba, 0xdb, 0x35, 0x76, 0x64, 0xc6, 0x0b, 0x0b, 0x07, 0x4b, - 0x65, 0xa2, 0xf7, 0x68, 0x9e, 0xfe, 0xe8, 0xe3, 0xa7, 0x09, 0x79, 0xc5, - 0xdf, 0x5e, 0x9c, 0xec, 0xee, 0x83, 0x59, 0xb5, 0x89, 0x81, 0xa2, 0x87, - 0xd7, 0x75, 0x65, 0x90, 0xde, 0x78, 0x37, 0x59, 0x04, 0x9b, 0x50, 0xc3, - 0xba, 0x90, 0x09, 0x15, 0xab, 0x17, 0xc5, 0xbf, 0x5b, 0xb9, 0xe4, 0x6c, - 0xa9, 0xb1, 0x49, 0x76, 0x25, 0x74, 0x5d, 0x9c, 0x78, 0xc5, 0x09, 0xee, - 0xeb, 0xeb, 0x9d, 0x1c, 0x6c, 0xc0, 0x27, 0x9d, 0x66, 0xe6, 0x7f, 0x31, - 0xcd, 0xb0, 0x8a, 0xe4, 0x9e, 0xbd, 0x70, 0x18, 0x88, 0xa1, 0x08, 0x39, - 0xa2, 0x48, 0xa5, 0x98, 0xb6, 0xad, 0x10, 0x54, 0x07, 0xcd, 0xfc, 0x6d, - 0xb1, 0x02, 0xff, 0xe3, 0x92, 0xd7, 0x9d, 0x48, 0xfb, 0xce, 0x88, 0x46, - 0x92, 0x07, 0x02, 0xba, 0xee, 0xeb, 0xae, 0x88, 0xb1, 0x4e, 0xd0, 0xf2, - 0xce, 0xd7, 0x57, 0x07, 0xd4, 0x39, 0xd2, 0x7d, 0x1a, 0x0c, 0xef, 0xf2, - 0x84, 0x84, 0x22, 0x8a, 0xb1, 0x80, 0x0d, 0xdc, 0x64, 0x86, 0xfd, 0x70, - }; - const Fq12ElemStr fq12_mul_ab_str = { - 0x4a, 0x0e, 0x83, 0x4f, 0x62, 0xca, 0x56, 0x0b, 0x0f, 0x2e, 0xf3, 0x1a, - 0xc6, 0xfc, 0x76, 0x4f, 0x4b, 0x85, 0x78, 0x6f, 0x9d, 0xb9, 0xbd, 0xc8, - 0xbb, 0x7c, 0x73, 0x12, 0x28, 0xff, 0xbc, 0x8f, 0x18, 0x8e, 0x5e, 0x4b, - 0x72, 0xa5, 0x4a, 0x99, 0xfc, 0xe7, 0x05, 0xe5, 0xd2, 0x2c, 0x06, 0x95, - 0xf5, 0xe4, 0xa5, 0x87, 0xcb, 0x85, 0x25, 0xf8, 0xda, 0x71, 0x7b, 0x9a, - 0xf1, 0x52, 0xf9, 0x33, 0x05, 0x5f, 0x15, 0x72, 0xa3, 0x61, 0xa6, 0x6c, - 0xb8, 0x43, 0xbb, 0xca, 0x33, 0xb2, 0xdb, 0x59, 0xca, 0xab, 0xad, 0xa0, - 0x4d, 0xe3, 0xb8, 0xf5, 0xc9, 0x8c, 0x06, 0x91, 0xe5, 0xe4, 0x5a, 0xad, - 0xe7, 0x66, 0xcc, 0x2b, 0x2c, 0x11, 0x88, 0x29, 0xb1, 0x3c, 0x52, 0xfe, - 0x50, 0xdf, 0x8f, 0x15, 0x6a, 0x6b, 0xb8, 0x32, 0x96, 0x90, 0x85, 0x03, - 0x78, 0x88, 0x97, 0x7b, 0x5b, 0x50, 0x2e, 0xde, 0xe7, 0x53, 0x22, 0x11, - 0xeb, 0xff, 0x1b, 0x19, 0xae, 0x5f, 0x58, 0x3a, 0x4f, 0x6f, 0x34, 0xfb, - 0x2a, 0x49, 0xca, 0x4b, 0x9c, 0x31, 0xfc, 0x74, 0x0f, 0x11, 0xcc, 0x45, - 0xcd, 0xa2, 0x12, 0xca, 0xf4, 0x2f, 0x30, 0x9a, 0x6a, 0xcb, 0xee, 0x88, - 0x15, 0x56, 0x29, 0x2a, 0xbf, 0x33, 0x7b, 0xdb, 0x59, 0x74, 0x4d, 0xc0, - 0x64, 0xf0, 0x0b, 0x9f, 0xf2, 0x65, 0xb7, 0x3a, 0xda, 0xe2, 0xb5, 0x63, - 0x3a, 0x3e, 0x06, 0xef, 0x73, 0xa3, 0xbc, 0xea, 0xcc, 0x68, 0xd9, 0xf5, - 0x6e, 0x94, 0x1c, 0x54, 0x47, 0xf1, 0x99, 0x2c, 0x44, 0x64, 0x45, 0x84, - 0x50, 0x10, 0xfd, 0xc5, 0x16, 0x65, 0x89, 0xec, 0x72, 0xa6, 0x7e, 0x82, - 0x7f, 0xe2, 0xe3, 0xea, 0x82, 0xa3, 0x18, 0xf4, 0x9b, 0x93, 0x4d, 0x79, - 0xa0, 0x2c, 0xbf, 0x90, 0x0e, 0xdb, 0x41, 0x09, 0x27, 0x44, 0x19, 0xd1, - 0xb4, 0xe5, 0xc6, 0x8c, 0xa5, 0xc7, 0x82, 0xbf, 0x00, 0x7b, 0x8d, 0x7a, - 0x05, 0x7b, 0x7e, 0x33, 0x60, 0x28, 0x34, 0x9c, 0x86, 0x5a, 0x6b, 0xce, - 0xa5, 0xed, 0x26, 0x22, 0x63, 0x4a, 0xe9, 0x57, 0xcd, 0x55, 0xd2, 0xd3, - 0x0e, 0x73, 0x14, 0xe4, 0xee, 0xe7, 0x3c, 0x43, 0xfc, 0xae, 0x84, 0x59, - 0x2f, 0xea, 0x35, 0x84, 0xa5, 0x77, 0xce, 0xa8, 0xc5, 0xaa, 0xb8, 0xdc, - 0xb9, 0xd6, 0x71, 0x11, 0xe2, 0x95, 0x00, 0x97, 0xbd, 0x50, 0xda, 0x58, - 0x1b, 0xda, 0xb3, 0x25, 0x19, 0x2f, 0x9d, 0xfa, 0x2c, 0xfb, 0x96, 0x26, - 0xbb, 0x4a, 0x41, 0x82, 0xa9, 0x45, 0x24, 0xee, 0xee, 0xea, 0xd3, 0xc5, - 0x94, 0xfc, 0x2a, 0x37, 0x6a, 0x43, 0xb8, 0x6c, 0xbb, 0x98, 0xb7, 0x17, - 0x03, 0xc0, 0x3d, 0x6d, 0x59, 0x56, 0x3d, 0x23, 0x42, 0x94, 0x25, 0x64, - 0xb9, 0x62, 0xad, 0x4d, 0x84, 0x9b, 0x3c, 0x05, 0x8c, 0xf0, 0xd3, 0xd3, - }; - THROW_ON_EPIDERR(ReadFfElement(this->fq12, &(fq12_a_str), sizeof(fq12_a_str), - this->fq12_a)); - THROW_ON_EPIDERR(ReadFfElement(this->fq12, &(fq12_b_str), sizeof(fq12_b_str), - this->fq12_b)); - EXPECT_EQ(kEpidNoErr, - FfMul(this->fq12, this->fq12_a, this->fq12_b, this->fq12_r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq12, this->fq12_r, &fq12_r_str, - sizeof(fq12_r_str))); - EXPECT_EQ(fq12_mul_ab_str, fq12_r_str); -} - -/////////////////////////////////////////////////////////////////////// -// FfAdd -TEST_F(FfElementTest, FfAddFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, - FfAdd(this->fq12, this->fq_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfAdd(this->fq, this->fq12_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfAdd(this->fq, this->fq_a, this->fq12_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfAdd(this->fq, this->fq_a, this->fq_b, this->fq12_r)); -} - -TEST_F(FfElementTest, FfAddFailsGivenNullPtr) { - EXPECT_EQ(kEpidBadArgErr, FfAdd(nullptr, this->fq_a, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfAdd(this->fq, nullptr, this->fq_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfAdd(this->fq, this->fq_a, nullptr, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfAdd(this->fq, this->fq_a, this->fq_b, nullptr)); -} - -TEST_F(FfElementTest, FfAddSucceedsGivenElementZero) { - FqElemStr fq_r_data = {0x0}; - - // additive identity - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq, this->fq_a, this->fq_zero, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_a_data, fq_r_data); - - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq, this->fq_zero, this->fq_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_b_data, fq_r_data); - - EXPECT_EQ(kEpidNoErr, - FfAdd(this->fq, this->fq_zero, this->fq_zero, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_zero_data, fq_r_data); -} - -TEST_F(FfElementTest, FfAddSucceedsGivenTwoElements) { - FqElemStr fq_r_data = {0x0}; - - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq, this->fq_a, this->fq_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_sum_ab_data, fq_r_data); -} - -TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq2) { - const Fq2ElemStr sum_ab_data = { - 0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F, - 0xBA, 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79, - 0x11, 0x78, 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - FfElementObj a(&this->fq2, &this->bn_a_data, sizeof(this->bn_a_data)); - FfElementObj b(&this->fq2, &this->bn_b_data, sizeof(this->bn_b_data)); - FfElementObj r(&this->fq2); - - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq2, a, b, r)); - EXPECT_EQ(FfElementObj(&this->fq2, sum_ab_data), r); -} -TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq6) { - const Fq6ElemStr sum_ab_data = { - 0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F, 0xBA, - 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79, 0x11, 0x78, - 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - FfElementObj a(&this->fq6, &this->bn_a_data, sizeof(this->bn_a_data)); - FfElementObj b(&this->fq6, &this->bn_b_data, sizeof(this->bn_b_data)); - FfElementObj r(&this->fq6); - - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq6, a, b, r)); - EXPECT_EQ(FfElementObj(&this->fq6, sum_ab_data), r); -} -TEST_F(FfElementTest, FfAddSucceedsGivenTwoElementsFq12) { - const Fq12ElemStr sum_ab_data = { - 0xF9, 0x0B, 0x7F, 0x72, 0x65, 0x94, 0x67, 0x2A, 0x9F, 0x0F, 0x2F, 0xBA, - 0x3B, 0x2B, 0x26, 0x83, 0xBA, 0xD3, 0xFB, 0x7B, 0x9D, 0x79, 0x11, 0x78, - 0xF6, 0x59, 0x23, 0x75, 0xEF, 0x7D, 0x46, 0x7C, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - FfElementObj a(&this->fq12, &this->bn_a_data, sizeof(this->bn_a_data)); - FfElementObj b(&this->fq12, &this->bn_b_data, sizeof(this->bn_b_data)); - FfElementObj r(&this->fq12); - - EXPECT_EQ(kEpidNoErr, FfAdd(this->fq12, a, b, r)); - EXPECT_EQ(FfElementObj(&this->fq12, sum_ab_data), r); -} - -/////////////////////////////////////////////////////////////////////// -// FfInv - -TEST_F(FfElementTest, FfInvFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, FfInv(nullptr, (this->fq_a), this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, nullptr, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq_a, nullptr)); -} - -TEST_F(FfElementTest, FfInvFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq12, this->fq_a, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq12_a, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfInv(this->fq, this->fq_a, this->fq12_r)); -} - -TEST_F(FfElementTest, FfInvFailsGivenElementZero) { - EXPECT_EQ(kEpidDivByZeroErr, FfInv(this->fq, this->fq_zero, this->fq_r)); -} - -TEST_F(FfElementTest, FfInvSucceedsGivenElementOne) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, FfInv(this->fq, this->fq_one, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_one_data, fq_r_data); -} - -TEST_F(FfElementTest, FfInvSucceedsGivenAnElement) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, FfInv(this->fq, this->fq_a, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_inv_a_data, fq_r_data); -} - -/////////////////////////////////////////////////////////////////////// -// FfExp - -TEST_F(FfElementTest, FfExpFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, - FfExp(nullptr, this->fq_a, this->exponent_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfExp(this->fq, nullptr, this->exponent_b, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfExp(this->fq, this->fq_a, nullptr, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfExp(this->fq, this->fq_a, this->exponent_b, nullptr)); -} - -TEST_F(FfElementTest, FfExpFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, - FfExp(this->fq12, this->fq_a, this->exponent_zero, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfExp(this->fq, this->fq12_a, this->exponent_zero, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfExp(this->fq, this->fq_a, this->exponent_zero, this->fq12_r)); -} - -TEST_F(FfElementTest, FfExpSucceedsGivenElementZero) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq, this->fq_zero, this->exponent_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_zero_data, fq_r_data); -} - -TEST_F(FfElementTest, FfExpSucceedsGivenExponentZero) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq, this->fq_a, this->exponent_zero, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_one_data, fq_r_data); -} - -TEST_F(FfElementTest, FfExpSucceedsGivenElementOne) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq, this->fq_one, this->exponent_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_one_data, fq_r_data); -} - -TEST_F(FfElementTest, FfExpSucceedsGivenExponentOne) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq, this->fq_a, this->exponent_one, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_a_data, fq_r_data); -} - -TEST_F(FfElementTest, FfExpSucceedsGivenAnElement) { - FqElemStr fq_r_data; - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq, this->fq_a, this->exponent_b, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_exp_ab_data, fq_r_data); - - Fq12ElemStr fq12_r_str; - const Fq12ElemStr fq12_a_str = { - 0xe4, 0xca, 0x0b, 0xa8, 0x9c, 0x70, 0xe2, 0x20, 0x24, 0xd9, 0x8f, 0x09, - 0x12, 0x79, 0x55, 0x44, 0x8c, 0x58, 0x42, 0x8f, 0x18, 0x97, 0x0a, 0xc3, - 0x0a, 0x40, 0x68, 0x0e, 0x1e, 0x21, 0x7f, 0xb4, 0x73, 0xcf, 0x8d, 0x54, - 0x68, 0xae, 0x1c, 0xc4, 0x95, 0x01, 0xe3, 0x52, 0x33, 0xfe, 0x69, 0xb5, - 0x23, 0x45, 0xef, 0xff, 0x79, 0x14, 0xef, 0x98, 0xa8, 0x4e, 0xb1, 0x2e, - 0xe1, 0x15, 0x81, 0x0c, 0x9f, 0x65, 0x90, 0x6a, 0x53, 0xd7, 0xf6, 0x73, - 0x08, 0xda, 0x45, 0x11, 0xde, 0xcf, 0xed, 0x4c, 0x8c, 0x21, 0x02, 0xf5, - 0x3f, 0x97, 0xb6, 0xb2, 0xf5, 0xc6, 0x58, 0xfc, 0x9a, 0xa6, 0xbb, 0xf9, - 0x3c, 0xd8, 0xfc, 0x86, 0x09, 0x1c, 0x16, 0xa4, 0x6f, 0x5e, 0x7a, 0x81, - 0x01, 0xf9, 0x8a, 0x6d, 0x38, 0xb5, 0xc9, 0x5f, 0xe9, 0x7d, 0x6f, 0x46, - 0x92, 0x49, 0x5b, 0xb8, 0x61, 0x03, 0x6f, 0x5e, 0xda, 0x53, 0xcb, 0x62, - 0xcd, 0x82, 0x63, 0x96, 0xc7, 0xc0, 0x39, 0xa4, 0x31, 0xee, 0x15, 0x26, - 0x1c, 0xe6, 0x4e, 0xe4, 0xb4, 0x40, 0xfa, 0x65, 0xa3, 0xf4, 0x73, 0x03, - 0x85, 0x84, 0x41, 0xf9, 0x77, 0xf3, 0x90, 0xdc, 0x88, 0x26, 0xbd, 0x27, - 0x9a, 0x9d, 0x37, 0xf0, 0x80, 0xee, 0x02, 0x1d, 0x3e, 0x4f, 0x88, 0xed, - 0x8f, 0x89, 0x90, 0xf1, 0x6d, 0x5d, 0x70, 0x49, 0x99, 0x07, 0x61, 0x22, - 0x43, 0x52, 0xba, 0xee, 0xa8, 0xe9, 0x8e, 0x2e, 0x83, 0x30, 0x41, 0x85, - 0xe3, 0x51, 0xb0, 0x8c, 0x86, 0x31, 0xec, 0x02, 0x76, 0xe8, 0x41, 0x1f, - 0x88, 0xbc, 0x39, 0xa2, 0xe4, 0xc1, 0x34, 0xa7, 0x1d, 0x5f, 0x8c, 0x23, - 0x0f, 0xf0, 0xdc, 0xcd, 0xba, 0x67, 0xd5, 0x78, 0xd6, 0x8d, 0x32, 0x6a, - 0xc1, 0x7f, 0x6f, 0x97, 0xcf, 0x46, 0xf0, 0x04, 0x7b, 0xe3, 0x5a, 0xee, - 0x31, 0xc4, 0xc0, 0x79, 0x96, 0xbc, 0x01, 0x78, 0x9f, 0xbe, 0x8b, 0xba, - 0x59, 0x22, 0xfb, 0x64, 0x1b, 0x37, 0x5c, 0x33, 0x57, 0xaf, 0x83, 0x5a, - 0x96, 0xea, 0x56, 0xaa, 0x6e, 0x9c, 0xfa, 0xe6, 0xf9, 0xdf, 0xd8, 0x44, - 0xbb, 0x4e, 0xbf, 0xa8, 0xec, 0x0f, 0x16, 0xa8, 0x59, 0x1f, 0x49, 0xf4, - 0x8c, 0x80, 0x6c, 0x52, 0x7f, 0x74, 0x94, 0xc2, 0xe3, 0x29, 0x34, 0x9c, - 0x97, 0xb9, 0x5e, 0xed, 0xfd, 0x59, 0x9d, 0xd4, 0x83, 0xfb, 0xc2, 0xad, - 0x72, 0xe8, 0xf3, 0x68, 0x43, 0xd0, 0xd4, 0xdc, 0xb2, 0x36, 0xc1, 0xdb, - 0x03, 0x29, 0xee, 0x8c, 0x1a, 0x10, 0xd7, 0xfb, 0xc2, 0xea, 0xda, 0xba, - 0x42, 0x18, 0xe6, 0xe4, 0x63, 0x41, 0x6e, 0x8c, 0xb3, 0x14, 0x68, 0x9a, - 0x0f, 0x64, 0x87, 0x16, 0x02, 0xa3, 0x59, 0xf4, 0x60, 0x80, 0x04, 0x2b, - 0xa4, 0xe6, 0x10, 0x2d, 0x61, 0x59, 0x14, 0xfe, 0xaf, 0x84, 0xa0, 0x67, - }; - BigNumStr exponent_b_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, 0x0c, - }; - const Fq12ElemStr fq12_exp_ab_str = { - 0xe4, 0xca, 0x0b, 0xa8, 0x9c, 0x70, 0xe2, 0x20, 0x24, 0xd9, 0x8f, 0x09, - 0x12, 0x79, 0x55, 0x44, 0x8c, 0x58, 0x42, 0x8f, 0x18, 0x97, 0x0a, 0xc3, - 0x0a, 0x40, 0x68, 0x0e, 0x1e, 0x21, 0x7f, 0xb4, 0x73, 0xcf, 0x8d, 0x54, - 0x68, 0xae, 0x1c, 0xc4, 0x95, 0x01, 0xe3, 0x52, 0x33, 0xfe, 0x69, 0xb5, - 0x23, 0x45, 0xef, 0xff, 0x79, 0x14, 0xef, 0x98, 0xa8, 0x4e, 0xb1, 0x2e, - 0xe1, 0x15, 0x81, 0x0c, 0x9f, 0x65, 0x90, 0x6a, 0x53, 0xd7, 0xf6, 0x73, - 0x08, 0xda, 0x45, 0x11, 0xde, 0xcf, 0xed, 0x4c, 0x8c, 0x21, 0x02, 0xf5, - 0x3f, 0x97, 0xb6, 0xb2, 0xf5, 0xc6, 0x58, 0xfc, 0x9a, 0xa6, 0xbb, 0xf9, - 0x3c, 0xd8, 0xfc, 0x86, 0x09, 0x1c, 0x16, 0xa4, 0x6f, 0x5e, 0x7a, 0x81, - 0x01, 0xf9, 0x8a, 0x6d, 0x38, 0xb5, 0xc9, 0x5f, 0xe9, 0x7d, 0x6f, 0x46, - 0x92, 0x49, 0x5b, 0xb8, 0x61, 0x03, 0x6f, 0x5e, 0xda, 0x53, 0xcb, 0x62, - 0xcd, 0x82, 0x63, 0x96, 0xc7, 0xc0, 0x39, 0xa4, 0x31, 0xee, 0x15, 0x26, - 0x1c, 0xe6, 0x4e, 0xe4, 0xb4, 0x40, 0xfa, 0x65, 0xa3, 0xf4, 0x73, 0x03, - 0x85, 0x84, 0x41, 0xf9, 0x77, 0xf3, 0x90, 0xdc, 0x88, 0x26, 0xbd, 0x27, - 0x9a, 0x9d, 0x37, 0xf0, 0x80, 0xee, 0x02, 0x1d, 0x3e, 0x4f, 0x88, 0xed, - 0x8f, 0x89, 0x90, 0xf1, 0x6d, 0x5d, 0x70, 0x49, 0x99, 0x07, 0x61, 0x22, - 0xbc, 0xad, 0x45, 0x11, 0x57, 0x13, 0x62, 0x9e, 0xc3, 0xb5, 0xb0, 0xd9, - 0x0b, 0x1f, 0xf4, 0x12, 0x86, 0xaa, 0x79, 0xf8, 0x9b, 0xaf, 0xc9, 0x63, - 0x4a, 0x6c, 0xf4, 0x38, 0xca, 0x11, 0xfb, 0x6c, 0xe2, 0xa0, 0x73, 0xdc, - 0xf0, 0x0c, 0x13, 0xff, 0x8c, 0x7e, 0x1c, 0xe6, 0x17, 0xe4, 0x72, 0x34, - 0x4b, 0x5c, 0xf6, 0x63, 0x43, 0x51, 0x1a, 0x7e, 0x57, 0x45, 0xd2, 0xed, - 0x7d, 0x0e, 0x6f, 0x9a, 0x69, 0x43, 0xfe, 0x87, 0x60, 0x3e, 0x65, 0x12, - 0xed, 0xc2, 0xf6, 0xfa, 0xd3, 0x3a, 0x48, 0x6b, 0xb5, 0x2c, 0xe2, 0xa0, - 0x7b, 0xad, 0xb3, 0xd8, 0x64, 0x8c, 0x32, 0xf4, 0xb4, 0xf3, 0x57, 0xcf, - 0x44, 0xb1, 0x40, 0x57, 0x13, 0xed, 0xda, 0x24, 0xed, 0xc6, 0xa8, 0x6a, - 0x61, 0xf1, 0x38, 0x4c, 0x8d, 0x67, 0xd1, 0x38, 0x2f, 0x6e, 0xd5, 0xe6, - 0x3b, 0x6f, 0xce, 0xed, 0xb1, 0x79, 0x92, 0x3f, 0x7c, 0x04, 0x3d, 0x52, - 0x8d, 0x13, 0xfd, 0x65, 0x03, 0x15, 0x1d, 0x82, 0x3c, 0x3a, 0xe2, 0xc4, - 0x09, 0xb2, 0x77, 0x6e, 0xf8, 0x87, 0x32, 0x87, 0x10, 0x3e, 0x53, 0x21, - 0x6c, 0xba, 0x49, 0x2f, 0x9c, 0xbe, 0x91, 0x73, 0x4c, 0xe8, 0x88, 0x33, - 0x37, 0x81, 0x6b, 0x48, 0xeb, 0xce, 0x4a, 0xaa, 0xac, 0x5c, 0x61, 0xcf, - 0x6d, 0xb1, 0xfa, 0x55, 0x71, 0xd0, 0x18, 0xdc, 0xff, 0x4e, 0x8f, 0xac, - }; - - THROW_ON_EPIDERR(ReadFfElement(this->fq12, &(fq12_a_str), sizeof(fq12_a_str), - this->fq12_a)); - THROW_ON_EPIDERR( - ReadBigNum(&exponent_b_str, sizeof(exponent_b_str), this->exponent_b)); - - EXPECT_EQ(kEpidNoErr, - FfExp(this->fq12, this->fq12_a, this->exponent_b, this->fq12_r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq12, this->fq12_r, &fq12_r_str, - sizeof(fq12_r_str))); - EXPECT_EQ(fq12_exp_ab_str, fq12_r_str); -} - -/////////////////////////////////////////////////////////////////////// -// FfHash - -TEST_F(FfElementTest, FfHashFailsGivenArgumentsMismatch) { - EXPECT_EQ(kEpidBadArgErr, FfHash(this->fq12, this->sha_msg, - sizeof(this->sha_msg), kSha256, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfHash(this->fq, this->sha_msg, sizeof(this->sha_msg), kSha256, - this->fq12_r)); -} - -TEST_F(FfElementTest, FfHashFailsGivenNullPointer) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidBadArgErr, - FfHash(nullptr, msg, sizeof(msg), kSha256, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfHash(this->fq, nullptr, sizeof(msg), kSha256, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfHash(this->fq, msg, sizeof(msg), kSha256, nullptr)); -} - -TEST_F(FfElementTest, FfHashFailsGivenUnsupportedHashAlg) { - uint8_t const msg[] = {0}; - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - FfHash(this->fq, msg, sizeof(msg), kSha512_256, this->fq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - FfHash(this->fq, msg, sizeof(msg), kSha3_256, this->fq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - FfHash(this->fq, msg, sizeof(msg), kSha3_384, this->fq_r)); - EXPECT_EQ(kEpidHashAlgorithmNotSupported, - FfHash(this->fq, msg, sizeof(msg), kSha3_512, this->fq_r)); -} - -TEST_F(FfElementTest, FfHashFailsGivenIncorrectMsgLen) { - uint8_t const msg[] = {0}; - size_t len_greater_int_max = (size_t)INT_MAX + 1; - EXPECT_EQ(kEpidBadArgErr, FfHash(this->fq, msg, 0, kSha256, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfHash(this->fq, msg, std::numeric_limits::max(), kSha256, - this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfHash(this->fq, msg, len_greater_int_max, kSha256, this->fq_r)); -} - -TEST_F(FfElementTest, FfHashWorksGivenSHA256HashAlg) { - FqElemStr fq_r_data; - EXPECT_EQ(kEpidNoErr, - FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha256, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_r_sha256, fq_r_data) - << "FfHash: Hash element does not match to reference value"; -} - -TEST_F(FfElementTest, FfHashWorksGivenSHA384HashAlg) { - FqElemStr fq_r_data; - EXPECT_EQ(kEpidNoErr, - FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha384, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_r_sha384, fq_r_data) - << "FfHash: Hash element does not match to reference value"; -} - -TEST_F(FfElementTest, FfHashWorksGivenSHA512HashAlg) { - FqElemStr fq_r_data; - EXPECT_EQ(kEpidNoErr, - FfHash(this->fq, sha_msg, sizeof(sha_msg), kSha512, this->fq_r)); - THROW_ON_EPIDERR( - WriteFfElement(this->fq, this->fq_r, &fq_r_data, sizeof(fq_r_data))); - EXPECT_EQ(this->fq_r_sha512, fq_r_data) - << "FfHash: Hash element does not match to reference value"; -} - -/////////////////////////////////////////////////////////////////////// -// FfMultiExp - -TEST_F(FfElementTest, FfMultiExpFailsGivenArgumentsMismatch) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - FfElement const* p12[] = {this->fq12_a, this->fq12_b}; - const BigNumStr bnm0 = {0}; - const BigNumStr bnm1 = {0}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq12, p, b, 2, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p12, b, 2, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, 2, this->fq12_r)); -} - -TEST_F(FfElementTest, FfMultiExpFailsGivenNullPointer) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - FfElement const* p_withnull[] = {nullptr, this->fq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - BigNumStr const* b_withnull[] = {nullptr, &bnm1}; - size_t m = 2; - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(nullptr, p, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, nullptr, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, nullptr, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, m, nullptr)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p_withnull, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b_withnull, m, this->fq_r)); -} - -TEST_F(FfElementTest, FfMultiExpFailsGivenIncorrectMLen) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - size_t len_greater_int_max = (size_t)INT_MAX + 1; - EXPECT_EQ(kEpidBadArgErr, FfMultiExp(this->fq, p, b, 0, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMultiExp(this->fq, p, b, std::numeric_limits::max(), - this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfMultiExp(this->fq, p, b, len_greater_int_max, this->fq_r)); -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenOneExponent) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[1]; - FfElement const* p[1]; - BigNumStr const* b[1]; - int m = 0; - const FqElemStr ffe[] = {{ - 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, - }}; - const BigNumStr bnm[] = {{ - 0xFF, 0xFB, 0x3E, 0x5D, 0xFF, 0x9A, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0xFF, - 0xF2, 0xE1, 0x85, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x81, - 0xFF, 0xFD, 0xFF, 0xEB, 0xFF, 0x29, 0xA7, 0xFF, - }}; - const FqElemStr res = { - 0x6A, 0x21, 0xEC, 0x89, 0xCC, 0x13, 0x2F, 0x6F, 0x29, 0x1B, 0x3A, - 0x94, 0xF6, 0xE6, 0xA8, 0xBD, 0x98, 0x25, 0x43, 0x7A, 0xDC, 0xC1, - 0x20, 0xBA, 0x30, 0xD8, 0x1C, 0x8E, 0x79, 0xFC, 0xDA, 0x67, - }; - // prepare data for test - for (m = 0; m < 1; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 1, r)); - // verify calculation is correct - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenTwoExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[2]; - FfElement const* p[2]; - BigNumStr const* b[2]; - int m = 0; - const FqElemStr ffe[] = { - {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}, - {0xDD, 0x2B, 0xE9, 0x59, 0x24, 0xA5, 0xB3, 0xFD, 0xEB, 0xE1, 0x3C, 0xC0, - 0x73, 0x4E, 0x99, 0xEE, 0x36, 0xF6, 0xC0, 0x1A, 0x76, 0x01, 0x0A, 0xF0, - 0xCB, 0xB4, 0x71, 0x88, 0x95, 0xCB, 0x35, 0xBA}}; - const BigNumStr bnm[] = { - {0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, 0x08, 0xFF, 0xFF, - 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, - 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF}, - {0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, 0xFF, 0x6B, 0xD5, - 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, - 0x84, 0xFF, 0xFF, 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - const FqElemStr res = { - 0x8A, 0xF7, 0x96, 0x53, 0x9C, 0xC3, 0x57, 0x89, 0x50, 0xE3, 0xAB, - 0x12, 0x62, 0xEA, 0x0C, 0xE4, 0x65, 0xA6, 0x91, 0x09, 0x93, 0x81, - 0xFC, 0xBB, 0x0E, 0xFA, 0xC1, 0xC4, 0xDC, 0x3F, 0x0A, 0xD1, - }; - // prepare data for test - for (m = 0; m < 2; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 2, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenThreeExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[3]; - FfElement const* p[3]; - BigNumStr const* b[3]; - int m = 0; - const FqElemStr ffe[] = { - {0x24, 0x9D, 0xDD, 0x1A, 0xC0, 0x07, 0x1F, 0x65, 0xDF, 0xBB, 0xC7, 0x39, - 0x99, 0x44, 0x63, 0x8E, 0x7E, 0xB2, 0x85, 0x82, 0xC6, 0x4E, 0x2D, 0x39, - 0xA8, 0x3F, 0x12, 0xB4, 0xE9, 0x9D, 0x67, 0x28}, - {0x6B, 0x51, 0x6B, 0x33, 0x0B, 0x2E, 0x2A, 0x94, 0x34, 0xCC, 0x7E, 0x97, - 0xFA, 0x85, 0x51, 0x44, 0x30, 0xE5, 0xF2, 0x68, 0x23, 0x31, 0x84, 0xFF, - 0xBB, 0x95, 0x9A, 0xB2, 0x80, 0x95, 0xC4, 0x91}, - {0x77, 0xED, 0xA2, 0x53, 0xA3, 0xBF, 0x6C, 0x58, 0x16, 0x7D, 0xEF, 0x8A, - 0x7D, 0x38, 0x65, 0x3F, 0x92, 0xA6, 0x85, 0xD7, 0x9F, 0x80, 0xA4, 0xA1, - 0x70, 0x02, 0xE5, 0x66, 0xF2, 0xD8, 0xD7, 0xD2}}; - const BigNumStr bnm[] = { - {0xFF, 0xFF, 0xFF, 0xB4, 0x48, 0xFF, 0xFF, 0xFF, 0xA3, 0xFF, 0xE3, 0xFF, - 0x61, 0xFF, 0xA2, 0x97, 0x9A, 0xFF, 0x6F, 0x04, 0xC6, 0xB9, 0xFF, 0x22, - 0xFF, 0x20, 0x9E, 0xFF, 0x43, 0xFF, 0xFF, 0xFF}, - {0xB1, 0x19, 0xBF, 0xFF, 0x74, 0x7F, 0xCC, 0x34, 0x1E, 0x30, 0x7D, 0xC5, - 0xC4, 0xFF, 0xE7, 0xF8, 0xFF, 0x5F, 0xFF, 0x73, 0xFF, 0x58, 0xFF, 0xD6, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF}, - {0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0xA8, 0xFF, 0xFF, 0xFF, - 0x3E, 0xFF, 0xFF, 0xFF, 0xE0, 0x4F, 0xFF, 0xE3, 0xFF, 0xFF, 0xEB, 0x04, - 0x4B, 0xFF, 0x5D, 0x55, 0xFF, 0x2D, 0xFF, 0xFF}}; - const FqElemStr res = { - 0x04, 0x22, 0x21, 0xE7, 0x9F, 0xE3, 0x07, 0x2F, 0xA4, 0xBB, 0x56, - 0x84, 0xD5, 0x93, 0x4A, 0xDA, 0x5B, 0x89, 0x07, 0xBE, 0xC5, 0x5F, - 0xE6, 0x5C, 0x18, 0xF0, 0xF8, 0x8E, 0x8E, 0x00, 0xB9, 0x87, - }; - // prepare data for test - for (m = 0; m < 3; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 3, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenFourExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[4]; - FfElement const* p[4]; - BigNumStr const* b[4]; - int m = 0; - const FqElemStr ffe[] = { - {0x81, 0xEE, 0x78, 0x31, 0x4C, 0xC0, 0x3C, 0xDD, 0x16, 0x52, 0xC6, 0x7E, - 0x07, 0x4C, 0xFE, 0xC4, 0x50, 0x63, 0x5A, 0x40, 0xC8, 0xDF, 0x94, 0x23, - 0x1A, 0x90, 0xDD, 0x24, 0x61, 0x23, 0xDD, 0x87}, - {0x76, 0xBB, 0x2C, 0x1C, 0xB3, 0x78, 0x93, 0x7E, 0x10, 0x29, 0xC3, 0xEC, - 0xBD, 0xA3, 0x75, 0x3A, 0xF1, 0x0B, 0xE1, 0xCA, 0xEE, 0x02, 0x58, 0x74, - 0xC7, 0xDC, 0xB8, 0x4F, 0x3F, 0x7B, 0xA2, 0xFC}, - {0x3A, 0xD3, 0x04, 0xAA, 0x9D, 0x2A, 0xDE, 0x86, 0x56, 0x84, 0x80, 0x42, - 0xA5, 0x68, 0xD8, 0x6E, 0x65, 0xC4, 0x08, 0x07, 0x87, 0x4B, 0xC1, 0x92, - 0xCB, 0x68, 0x52, 0x6C, 0x5A, 0x4F, 0x7C, 0xFB}, - {0x56, 0xE7, 0xBD, 0x59, 0x54, 0xCC, 0x20, 0x16, 0xAE, 0x36, 0xD1, 0xB0, - 0xE4, 0x82, 0x47, 0x27, 0x32, 0xD1, 0x38, 0x7C, 0x53, 0x7F, 0xDD, 0xF4, - 0xDE, 0xFA, 0xF7, 0x0F, 0xDD, 0xDF, 0x48, 0xA9}}; - const BigNumStr bnm[] = { - {0xFF, 0xA5, 0xC3, 0xFF, 0xFF, 0x09, 0x18, 0x18, 0x95, 0x40, 0xFF, 0xFF, - 0xDB, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0xFF, 0x25, 0xFF, 0xFF, 0x42, 0x07, - 0xB5, 0xFF, 0x26, 0xE0, 0x4F, 0xB5, 0xB4, 0xFF}, - {0x1F, 0xFF, 0xAA, 0xF1, 0xFF, 0xFF, 0x7E, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, - 0xE7, 0xDF, 0xFF, 0xEE, 0xFF, 0x57, 0xFF, 0xFF, 0xFF, 0xB8, 0xB3, 0x9C, - 0xFF, 0x8A, 0x89, 0xFF, 0xFE, 0x32, 0xFF, 0xC1}, - {0x9A, 0xFF, 0xFF, 0x9B, 0xFF, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x36, 0xF0, 0xC5, 0xAE, 0x87, 0x41, 0xFF, 0x5C, 0xDD, 0xFF, 0xFF, - 0xFF, 0xFF, 0x59, 0xC9, 0xFF, 0x44, 0x5C, 0x58}, - {0x00, 0xFF, 0x95, 0xFF, 0x21, 0xFF, 0xFF, 0x1D, 0x1A, 0x06, 0xD3, 0xFF, - 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xB0, 0x31, 0xFF, 0xFF, 0x1F, - 0x61, 0x48, 0xFF, 0xFF, 0xFF, 0x17, 0xC9, 0x79}}; - const FqElemStr res = { - 0x26, 0x2C, 0x23, 0x55, 0xD5, 0xBD, 0x7B, 0x67, 0x60, 0xFE, 0x06, - 0x7B, 0xCC, 0xB8, 0x6B, 0xC9, 0x00, 0x81, 0xAE, 0xCB, 0xEC, 0x91, - 0x6D, 0x1B, 0x9E, 0x1C, 0xD8, 0xC0, 0x8D, 0x3F, 0x1B, 0x20, - }; - // prepare data for test - for (m = 0; m < 4; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 4, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; - - const Fq12ElemStr ff12e[] = { - { - 0x2c, 0x86, 0xee, 0x80, 0x61, 0x45, 0x8f, 0xfd, 0x96, 0xc2, 0x81, - 0x11, 0xe8, 0x96, 0xe2, 0xca, 0x21, 0x78, 0xf7, 0xa3, 0x4b, 0xba, - 0xdc, 0x0d, 0x34, 0x8a, 0x56, 0x12, 0x67, 0x8d, 0x72, 0x37, 0xa8, - 0xeb, 0x5f, 0x1a, 0x1b, 0xf0, 0x5c, 0xc6, 0x6f, 0xc2, 0xc5, 0x03, - 0xc4, 0x19, 0x85, 0xa6, 0xe0, 0x64, 0xfe, 0x71, 0x51, 0x46, 0xdf, - 0xc2, 0xd6, 0xf9, 0xa0, 0xd6, 0x84, 0xc1, 0x4a, 0x11, 0xe0, 0x33, - 0xa3, 0x1c, 0x73, 0x71, 0x62, 0x17, 0x10, 0x4c, 0xd8, 0x3e, 0xee, - 0xa1, 0x38, 0x9f, 0xa5, 0xfb, 0x1d, 0xc4, 0x9d, 0x2f, 0x08, 0x4a, - 0xd3, 0x61, 0x37, 0x79, 0xab, 0xc1, 0x37, 0x7e, 0x90, 0xfd, 0xa3, - 0x9d, 0x0c, 0x81, 0x52, 0xf4, 0x58, 0x24, 0x89, 0xc4, 0xf4, 0xd4, - 0x82, 0x33, 0xca, 0x5d, 0xb4, 0x58, 0xa6, 0x1e, 0xe6, 0x2b, 0x86, - 0xef, 0x56, 0xc4, 0x4f, 0x9b, 0x27, 0x3c, 0x96, 0x54, 0xda, 0xb5, - 0x32, 0x23, 0x8a, 0x93, 0xcc, 0xa5, 0x7d, 0x28, 0x4a, 0x97, 0xa4, - 0x30, 0xa8, 0x11, 0xbc, 0x43, 0x22, 0x7f, 0x02, 0x73, 0x0e, 0x5c, - 0x63, 0x52, 0x2f, 0x4b, 0x5f, 0x7d, 0xc3, 0x1e, 0x30, 0xae, 0xac, - 0x8c, 0xe8, 0x93, 0xd6, 0xce, 0x05, 0x4b, 0x6b, 0x21, 0x01, 0x14, - 0x4a, 0x1d, 0xd9, 0x08, 0x0c, 0xa1, 0x4c, 0x0b, 0x44, 0x28, 0x9c, - 0xb6, 0xd1, 0x96, 0xbd, 0x07, 0x8b, 0x3d, 0x77, 0x4e, 0xbd, 0x7b, - 0x9f, 0x65, 0x20, 0xdb, 0xa0, 0x95, 0x25, 0x44, 0x44, 0x7a, 0xe3, - 0xdc, 0xdd, 0x2f, 0xba, 0x75, 0x16, 0x19, 0xcb, 0x90, 0x31, 0x79, - 0x38, 0xb6, 0x1a, 0x82, 0xbc, 0xb6, 0x85, 0xcd, 0xeb, 0xb9, 0x13, - 0x43, 0xea, 0xc2, 0x78, 0xbe, 0x25, 0x97, 0x1c, 0x6e, 0x18, 0x55, - 0xfd, 0xcb, 0xe6, 0x7e, 0x1e, 0x92, 0xad, 0x48, 0xe7, 0xa7, 0x02, - 0x87, 0x0b, 0x8f, 0x16, 0xd7, 0x8e, 0x95, 0x8e, 0x62, 0x0a, 0xad, - 0x20, 0x2d, 0x6a, 0x2b, 0x4e, 0x6f, 0xc1, 0xc2, 0x63, 0xba, 0x82, - 0xf3, 0x8c, 0xd0, 0xa2, 0x09, 0xd3, 0xe5, 0xba, 0x1f, 0x65, 0x35, - 0xd0, 0x1c, 0x09, 0x98, 0x47, 0x65, 0xf2, 0x90, 0xd4, 0xe2, 0xd0, - 0x6f, 0x9e, 0xdb, 0xa2, 0x14, 0x9b, 0x4b, 0x3d, 0xaa, 0x75, 0x25, - 0x67, 0xf4, 0x7d, 0x77, 0xe9, 0x24, 0xed, 0xee, 0x1b, 0x07, 0x7f, - 0xe0, 0x7a, 0x34, 0xb7, 0x3c, 0x36, 0x0d, 0xce, 0xf9, 0xbf, 0xf9, - 0xe5, 0x09, 0x86, 0xeb, 0xb9, 0xd8, 0xc4, 0x67, 0xc5, 0xcd, 0xd4, - 0xbc, 0xee, 0x45, 0xf7, 0x11, 0x68, 0xd9, 0x23, 0x6d, 0xd6, 0x24, - 0x6e, 0x97, 0x83, 0x13, 0x76, 0x9f, 0x35, 0xea, 0xb8, 0x47, 0x57, - 0x9b, 0x74, 0x47, 0x1f, 0x19, 0xe7, 0x97, 0x74, 0x1b, 0xb1, 0xa0, - 0xf3, 0x92, 0xdc, 0x35, 0xfd, 0x7f, 0x4f, 0x07, 0x22, 0xac, - }, - { - 0xfd, 0x05, 0x41, 0x27, 0x00, 0x7a, 0xad, 0x17, 0xbc, 0xbf, 0x22, - 0x5e, 0xda, 0xeb, 0x7d, 0xaa, 0xb5, 0x2d, 0xc8, 0x61, 0xfe, 0x2c, - 0xba, 0x9e, 0x54, 0x43, 0x94, 0xdc, 0xfd, 0x0e, 0x6d, 0x6d, 0xa1, - 0x5e, 0x05, 0xa5, 0x05, 0x55, 0xe7, 0x2a, 0xf7, 0x53, 0x37, 0x2c, - 0xef, 0x44, 0x95, 0xca, 0x2c, 0xe8, 0xeb, 0xae, 0x61, 0x05, 0x33, - 0xe7, 0x0f, 0x30, 0x67, 0xbe, 0xcd, 0xb2, 0x93, 0x44, 0x44, 0x31, - 0x96, 0x4d, 0x72, 0x61, 0xcd, 0x23, 0x1f, 0x7b, 0x57, 0x33, 0x39, - 0xac, 0x57, 0x53, 0x3d, 0x70, 0x57, 0xb3, 0x6d, 0xd5, 0x8a, 0x89, - 0x30, 0xbc, 0xed, 0x29, 0x19, 0x39, 0x6e, 0x6a, 0x80, 0x21, 0x1e, - 0xb7, 0x84, 0xb1, 0x0a, 0xa4, 0xd0, 0xff, 0x59, 0x31, 0xe9, 0xba, - 0x39, 0xf7, 0x81, 0xdf, 0x1b, 0x7b, 0xd9, 0xdb, 0x02, 0x17, 0xbe, - 0x97, 0x63, 0xbd, 0x37, 0x14, 0xb8, 0x8b, 0x6c, 0xcc, 0x5b, 0xa3, - 0xee, 0xc8, 0x0b, 0x7b, 0xf5, 0xde, 0xbc, 0xb7, 0xa8, 0x25, 0x35, - 0xae, 0x0b, 0x30, 0x96, 0x33, 0x52, 0x13, 0xa3, 0x89, 0x3a, 0x2e, - 0xa4, 0x7e, 0x5f, 0x4e, 0xb1, 0xf7, 0x87, 0xba, 0x08, 0xb0, 0xfb, - 0xcb, 0x31, 0xa6, 0x2b, 0x3e, 0xe7, 0xc4, 0xcc, 0xa5, 0x14, 0x61, - 0xc9, 0x18, 0xfc, 0x74, 0x59, 0x06, 0xf4, 0xad, 0xfc, 0x2d, 0x0c, - 0x7d, 0xdb, 0x2a, 0xec, 0xd4, 0xe9, 0x31, 0x31, 0x50, 0x25, 0xb7, - 0x0c, 0x48, 0x30, 0xd5, 0x78, 0xb1, 0x10, 0xea, 0x5d, 0xaa, 0xaa, - 0x03, 0xec, 0xe3, 0x0f, 0x36, 0xa6, 0xbc, 0x18, 0x3a, 0x76, 0x87, - 0xa3, 0xe9, 0x33, 0xda, 0x48, 0x78, 0x93, 0x64, 0x72, 0x9b, 0x2a, - 0x1e, 0x0d, 0x50, 0x9f, 0x6f, 0xbd, 0xa5, 0x18, 0xb1, 0xa8, 0x14, - 0x9a, 0x1b, 0xb9, 0xb4, 0x2c, 0x1f, 0x46, 0xb8, 0x9b, 0x7a, 0xc7, - 0x84, 0xae, 0x27, 0xd1, 0xec, 0x1c, 0xec, 0x69, 0xf0, 0x35, 0x40, - 0x77, 0x7e, 0x27, 0x22, 0x36, 0x38, 0xdf, 0x15, 0xc2, 0xb3, 0xb8, - 0x63, 0x4a, 0x6e, 0x68, 0x8c, 0xc1, 0x39, 0x3c, 0x02, 0x4c, 0x2a, - 0x31, 0x18, 0x2e, 0x35, 0xf5, 0xca, 0xa2, 0xe9, 0x24, 0x92, 0xd5, - 0xe5, 0x2e, 0x5d, 0x1c, 0x94, 0xd9, 0xc7, 0xf0, 0x22, 0x16, 0x20, - 0xa8, 0x37, 0xdd, 0x0e, 0xab, 0x1b, 0x5e, 0x8b, 0xee, 0x81, 0xc6, - 0x17, 0xf1, 0x29, 0x5d, 0x1d, 0x6f, 0x53, 0x5a, 0xb2, 0x20, 0x88, - 0x3d, 0xa4, 0x98, 0x81, 0xa4, 0xef, 0x11, 0x1b, 0x64, 0x9e, 0x2c, - 0x95, 0xdd, 0xd7, 0x57, 0xb3, 0x95, 0xca, 0x40, 0xb9, 0x0d, 0x62, - 0xdc, 0x86, 0x8b, 0xe6, 0xd3, 0x7b, 0x33, 0xea, 0x50, 0x25, 0xe2, - 0x77, 0xe3, 0x0b, 0x5a, 0xc8, 0x81, 0xfc, 0xae, 0x74, 0x38, 0x69, - 0x07, 0xf8, 0x4e, 0xd7, 0x85, 0xa6, 0x2f, 0x13, 0xb7, 0x0a, - }, - { - 0xf4, 0xdc, 0xac, 0x02, 0xc0, 0x95, 0x07, 0xdc, 0x12, 0x4f, 0x3a, - 0x01, 0xa9, 0xee, 0xf3, 0x07, 0x46, 0x94, 0x47, 0x15, 0x63, 0xa6, - 0x8e, 0x0a, 0xc4, 0xc4, 0xe4, 0x23, 0x85, 0x63, 0xe4, 0x4e, 0x9a, - 0x9e, 0x9f, 0xc1, 0xed, 0x4e, 0x94, 0x10, 0xfe, 0x7d, 0x90, 0xef, - 0x82, 0x21, 0xac, 0x67, 0x24, 0x99, 0x86, 0xc6, 0x85, 0x8b, 0x19, - 0x9a, 0x9b, 0x90, 0x0b, 0xa4, 0x90, 0x78, 0x34, 0x53, 0xb1, 0x4c, - 0xba, 0xb8, 0xc6, 0x40, 0x71, 0xc2, 0x17, 0x51, 0x05, 0xc2, 0xc9, - 0xbc, 0x03, 0x10, 0x4e, 0xfe, 0x2f, 0x94, 0xed, 0x13, 0x35, 0x7b, - 0x20, 0xa6, 0x59, 0x44, 0x81, 0xd0, 0xec, 0x12, 0x74, 0xa2, 0x4a, - 0xfb, 0xd7, 0x28, 0x70, 0xad, 0xde, 0x86, 0x2f, 0xef, 0xf9, 0x50, - 0x5d, 0x1e, 0x46, 0x3b, 0x82, 0x1c, 0x6a, 0xc9, 0x3f, 0x32, 0xae, - 0xcd, 0x93, 0x2c, 0xa5, 0x70, 0x45, 0x24, 0x38, 0x19, 0x79, 0xbf, - 0x35, 0xf5, 0xc1, 0x53, 0x06, 0x42, 0xaa, 0x6b, 0xf3, 0xb7, 0x8f, - 0xfb, 0xfc, 0x28, 0x46, 0x9a, 0x65, 0x2a, 0x45, 0x3d, 0x4c, 0x3c, - 0x6b, 0x9c, 0x44, 0xc5, 0x82, 0xb8, 0x80, 0xf9, 0xb3, 0x44, 0x95, - 0x17, 0x39, 0x01, 0x6b, 0xd6, 0x1d, 0x73, 0x22, 0x94, 0xff, 0x6f, - 0x7b, 0x4e, 0xb6, 0xa4, 0xe4, 0x6c, 0xa8, 0xdb, 0x38, 0x74, 0x0b, - 0xdb, 0xfa, 0x14, 0x99, 0x39, 0x28, 0xee, 0xfc, 0x62, 0xe5, 0x33, - 0x9c, 0x63, 0xd5, 0x7f, 0x2c, 0x4c, 0xf4, 0x76, 0x4c, 0xf7, 0x7b, - 0x27, 0x2c, 0xa9, 0xb9, 0x01, 0x3c, 0x58, 0xf7, 0xce, 0xaa, 0x0a, - 0x21, 0xc0, 0xa3, 0xa7, 0xa1, 0x85, 0xbc, 0xfe, 0x55, 0xfc, 0x3b, - 0x9b, 0x3d, 0xef, 0x14, 0x85, 0x8a, 0x4e, 0x5e, 0x1f, 0x4f, 0xc9, - 0x86, 0xb8, 0xf2, 0xb2, 0xe3, 0xe7, 0x7e, 0x87, 0xe2, 0x20, 0xd7, - 0x85, 0x2c, 0xd1, 0x13, 0xcb, 0x46, 0xad, 0xd7, 0xec, 0x66, 0xd5, - 0x2b, 0x6e, 0x87, 0x92, 0x13, 0xb2, 0x7d, 0x18, 0x69, 0x35, 0xcb, - 0xf1, 0xbe, 0xc2, 0x9d, 0xeb, 0xf5, 0x00, 0x0b, 0x73, 0xa3, 0xfd, - 0x51, 0xdc, 0x91, 0x0e, 0xe4, 0x46, 0x41, 0x23, 0xdd, 0x85, 0x53, - 0x0c, 0xae, 0xf9, 0x74, 0xcf, 0x1c, 0x32, 0x22, 0xda, 0x4a, 0x14, - 0x80, 0x71, 0x51, 0x23, 0xc3, 0xab, 0x7e, 0xec, 0x77, 0xcc, 0x59, - 0x12, 0x1c, 0x0f, 0x65, 0x6b, 0xd8, 0x41, 0xe0, 0x1b, 0x51, 0x9c, - 0x89, 0x26, 0xab, 0x88, 0x63, 0x5d, 0xbb, 0x95, 0x92, 0x5b, 0x2c, - 0x1d, 0xde, 0xc1, 0x88, 0xd6, 0xf1, 0x02, 0x48, 0xe0, 0xe2, 0xd1, - 0x40, 0x7f, 0xf1, 0x23, 0x4a, 0xcf, 0x36, 0xd5, 0xcf, 0x76, 0x0d, - 0x00, 0x2a, 0xf7, 0x5f, 0x31, 0xbb, 0xcc, 0x46, 0x84, 0x07, 0x04, - 0x98, 0x9c, 0xb4, 0x31, 0x15, 0x2d, 0x91, 0xf6, 0x29, 0x33, - }, - { - 0xa8, 0x8e, 0x9a, 0xf9, 0x25, 0x12, 0x98, 0xe2, 0xc3, 0x61, 0x2e, - 0xe8, 0xd6, 0xa6, 0x77, 0x16, 0x49, 0x04, 0x75, 0x69, 0xd1, 0x83, - 0x2d, 0x3f, 0x2a, 0x79, 0xb6, 0x9b, 0xc9, 0x1d, 0x03, 0x90, 0x2a, - 0xd8, 0x11, 0x9f, 0x26, 0x36, 0xe7, 0xe9, 0x3a, 0x05, 0x4c, 0x15, - 0x49, 0x93, 0xda, 0xe9, 0xd0, 0x5a, 0xe4, 0x8d, 0x8a, 0xfa, 0x04, - 0xf1, 0x20, 0x84, 0x56, 0xec, 0x3c, 0x27, 0x19, 0x5c, 0xf1, 0xaf, - 0xbf, 0xf6, 0x0e, 0x58, 0x84, 0x2d, 0x94, 0x11, 0xf4, 0xb5, 0xf4, - 0x14, 0x51, 0xb0, 0x90, 0x46, 0x1a, 0x81, 0xed, 0xcf, 0x91, 0x66, - 0x58, 0xa6, 0x36, 0x3a, 0x52, 0x18, 0x5a, 0xc1, 0x08, 0x4c, 0x99, - 0xd3, 0xdc, 0xce, 0x7f, 0xce, 0x78, 0xe0, 0x38, 0x87, 0x32, 0xf1, - 0x80, 0x3c, 0x7b, 0x67, 0xaa, 0x6f, 0xdd, 0xe0, 0xfc, 0xcb, 0xd0, - 0xb0, 0x3a, 0x59, 0x52, 0x2a, 0x84, 0xe4, 0xf8, 0x4a, 0xff, 0x50, - 0xa0, 0x65, 0xc4, 0xee, 0xf4, 0x9c, 0xaa, 0x34, 0x46, 0xf9, 0xd2, - 0x6c, 0xa1, 0x61, 0x71, 0x49, 0x32, 0x25, 0x84, 0x54, 0x90, 0x44, - 0xbe, 0xa4, 0x0b, 0xf7, 0xfe, 0x26, 0x81, 0x63, 0x73, 0xf7, 0x2f, - 0xf2, 0xfa, 0x24, 0x52, 0xa4, 0xd9, 0x4c, 0xc1, 0xa7, 0xa5, 0xc3, - 0x03, 0x36, 0x13, 0x9b, 0x16, 0x45, 0x16, 0xcb, 0x4b, 0x99, 0x38, - 0xf3, 0x6d, 0xc8, 0x7e, 0xab, 0xb3, 0x53, 0xdf, 0xb6, 0x82, 0x60, - 0x12, 0x11, 0x36, 0x69, 0x0e, 0x05, 0x31, 0x8e, 0xcf, 0xd7, 0x3f, - 0x32, 0xe7, 0x95, 0x84, 0x1d, 0xc8, 0xb5, 0xbe, 0x49, 0x17, 0x9d, - 0xcf, 0xa9, 0x5a, 0x2a, 0xc4, 0x11, 0x86, 0xe8, 0x6c, 0x02, 0x56, - 0xb0, 0x25, 0x2f, 0xa0, 0x06, 0xb3, 0x62, 0xb2, 0x11, 0xaf, 0xbe, - 0xa4, 0xe8, 0x61, 0x64, 0x85, 0xfb, 0xeb, 0x1c, 0xf1, 0xbc, 0x2c, - 0xae, 0x10, 0x51, 0x16, 0xa6, 0xc0, 0xb3, 0x86, 0x8e, 0x6d, 0x79, - 0xb6, 0xbd, 0xde, 0x1e, 0x26, 0x06, 0x46, 0x65, 0x82, 0x84, 0x5a, - 0x97, 0xd3, 0xb7, 0x93, 0x78, 0x6b, 0x9d, 0x14, 0x33, 0x94, 0x43, - 0x34, 0x04, 0x45, 0xd1, 0x47, 0xd4, 0x2f, 0x17, 0xcf, 0xf1, 0xdd, - 0xea, 0x11, 0x52, 0xae, 0x01, 0x88, 0x3a, 0x10, 0xee, 0x5c, 0x16, - 0xcd, 0xb5, 0x48, 0xe9, 0x16, 0x2c, 0x70, 0xb4, 0x1e, 0x19, 0x38, - 0xe0, 0x18, 0xe9, 0xae, 0xc5, 0xda, 0x74, 0x41, 0x2d, 0x70, 0x07, - 0x60, 0x37, 0x27, 0x66, 0xf7, 0x00, 0xbb, 0x79, 0x51, 0xf3, 0x7c, - 0x8a, 0x2b, 0xb5, 0x69, 0x6e, 0x10, 0x1f, 0xe0, 0x0a, 0x5e, 0xbe, - 0xb4, 0x4e, 0x0e, 0x02, 0x59, 0xb5, 0xcb, 0x4a, 0x6a, 0x86, 0x8b, - 0xcc, 0xa2, 0x13, 0xa0, 0xe9, 0xf2, 0x5c, 0xb0, 0x23, 0xb2, 0x15, - 0xf9, 0xbb, 0x43, 0xc1, 0x54, 0xf4, 0xc8, 0xab, 0x16, 0xa6, - }, - }; - const BigNumStr bnm12[] = { - { - 0x14, 0x92, 0xd1, 0x1f, 0xac, 0x90, 0x4d, 0xc3, 0x3e, 0xb8, 0xa7, - 0xfe, 0x35, 0x98, 0xda, 0x94, 0xd6, 0xf3, 0x27, 0x29, 0x4b, 0x70, - 0xcf, 0x0f, 0xda, 0x14, 0x97, 0xa1, 0x9b, 0x6b, 0x24, 0x08, - }, - { - 0x76, 0x8d, 0xe5, 0xc2, 0xab, 0x78, 0xd9, 0x76, 0x98, 0xff, 0x92, - 0xea, 0x95, 0x58, 0xc5, 0x0c, 0x6f, 0x1b, 0x35, 0xc4, 0xbf, 0x4a, - 0x9e, 0xc2, 0x6a, 0xec, 0xe2, 0xf6, 0xaf, 0xeb, 0xac, 0x06, - }, - { - 0x50, 0x38, 0x60, 0x31, 0xab, 0x05, 0xcc, 0xb1, 0xc2, 0x06, 0xa0, - 0xd7, 0x92, 0x12, 0xbd, 0x17, 0x81, 0xb9, 0x7e, 0x07, 0x9b, 0xd4, - 0x3b, 0x2d, 0x3c, 0x15, 0x3a, 0x5a, 0xf1, 0xc0, 0xc4, 0x75, - }, - { - 0xa1, 0x3f, 0xea, 0x99, 0x7e, 0xc7, 0x65, 0xf5, 0x41, 0xa6, 0xd6, - 0xd3, 0x77, 0xec, 0x27, 0xf8, 0x6c, 0x18, 0x28, 0x69, 0x97, 0x08, - 0x0e, 0x63, 0x5a, 0xda, 0xfe, 0x9f, 0xd1, 0x4a, 0x61, 0x4f, - }, - }; - const Fq12ElemStr fq12_expected_result_str = { - 0x3a, 0x30, 0x33, 0xa2, 0x14, 0xdf, 0xdc, 0x70, 0x48, 0xf3, 0xba, 0x3f, - 0xce, 0xfc, 0x69, 0x24, 0xae, 0xa1, 0xf3, 0xcf, 0xd8, 0x77, 0x69, 0x38, - 0x38, 0xf4, 0x8e, 0xfb, 0x51, 0xfb, 0x10, 0x7c, 0x73, 0xb4, 0xee, 0xf9, - 0x76, 0xbb, 0x45, 0xec, 0x07, 0x24, 0x23, 0xa3, 0x38, 0x64, 0x39, 0x4c, - 0x03, 0x94, 0xf5, 0xee, 0x5f, 0xc9, 0x83, 0x4f, 0xd1, 0xa6, 0x4a, 0x05, - 0x25, 0x0c, 0x46, 0x33, 0xd4, 0x40, 0x47, 0xae, 0xec, 0xda, 0x30, 0xf9, - 0xe1, 0x28, 0xfb, 0xb1, 0x4c, 0x62, 0xfb, 0x6c, 0x90, 0x0d, 0xb1, 0xec, - 0xaf, 0x2d, 0x95, 0x64, 0x11, 0x93, 0xda, 0x8e, 0xb8, 0x7d, 0xe4, 0xa3, - 0x8e, 0xa6, 0x9b, 0xaa, 0x58, 0xd5, 0xdc, 0x59, 0x1a, 0x51, 0x53, 0x47, - 0x30, 0x1c, 0x2b, 0xb0, 0xbb, 0x57, 0x57, 0x0a, 0x8c, 0x5f, 0x62, 0x9c, - 0x52, 0x28, 0xc0, 0x25, 0x27, 0xae, 0xcd, 0x36, 0xbf, 0x2d, 0x03, 0xb1, - 0x33, 0xfd, 0x24, 0x81, 0x3c, 0x91, 0x43, 0x90, 0x0c, 0x20, 0xc4, 0xe3, - 0x69, 0x3f, 0xa9, 0xa2, 0x7c, 0xc2, 0x48, 0x28, 0x1b, 0xf0, 0x81, 0x1f, - 0x2b, 0x8f, 0x8d, 0x43, 0x38, 0x18, 0x12, 0xa3, 0x89, 0xf1, 0xd7, 0x60, - 0x89, 0x68, 0x6a, 0xc4, 0xcc, 0x5d, 0xf4, 0xce, 0x43, 0x95, 0x84, 0xcd, - 0x01, 0x55, 0xb8, 0x5d, 0x24, 0x50, 0xcd, 0xe3, 0x68, 0x1c, 0xff, 0x59, - 0x0d, 0xac, 0xcb, 0xe7, 0x9d, 0x68, 0x0f, 0x4a, 0xaf, 0xeb, 0xb5, 0xfb, - 0xf9, 0xb1, 0x58, 0x80, 0xd5, 0x71, 0x53, 0x26, 0x2e, 0x9c, 0xce, 0x10, - 0xac, 0xd2, 0x0a, 0xeb, 0xb4, 0x5c, 0xc8, 0xd7, 0x16, 0x26, 0x66, 0x71, - 0xdd, 0x67, 0xba, 0xdb, 0x35, 0x76, 0x64, 0xc6, 0x0b, 0x0b, 0x07, 0x4b, - 0x65, 0xa2, 0xf7, 0x68, 0x9e, 0xfe, 0xe8, 0xe3, 0xa7, 0x09, 0x79, 0xc5, - 0xdf, 0x5e, 0x9c, 0xec, 0xee, 0x83, 0x59, 0xb5, 0x89, 0x81, 0xa2, 0x87, - 0xd7, 0x75, 0x65, 0x90, 0xde, 0x78, 0x37, 0x59, 0x04, 0x9b, 0x50, 0xc3, - 0xba, 0x90, 0x09, 0x15, 0xab, 0x17, 0xc5, 0xbf, 0x5b, 0xb9, 0xe4, 0x6c, - 0xa9, 0xb1, 0x49, 0x76, 0x25, 0x74, 0x5d, 0x9c, 0x78, 0xc5, 0x09, 0xee, - 0xeb, 0xeb, 0x9d, 0x1c, 0x6c, 0xc0, 0x27, 0x9d, 0x66, 0xe6, 0x7f, 0x31, - 0xcd, 0xb0, 0x8a, 0xe4, 0x9e, 0xbd, 0x70, 0x18, 0x88, 0xa1, 0x08, 0x39, - 0xa2, 0x48, 0xa5, 0x98, 0xb6, 0xad, 0x10, 0x54, 0x07, 0xcd, 0xfc, 0x6d, - 0xb1, 0x02, 0xff, 0xe3, 0x92, 0xd7, 0x9d, 0x48, 0xfb, 0xce, 0x88, 0x46, - 0x92, 0x07, 0x02, 0xba, 0xee, 0xeb, 0xae, 0x88, 0xb1, 0x4e, 0xd0, 0xf2, - 0xce, 0xd7, 0x57, 0x07, 0xd4, 0x39, 0xd2, 0x7d, 0x1a, 0x0c, 0xef, 0xf2, - 0x84, 0x84, 0x22, 0x8a, 0xb1, 0x80, 0x0d, 0xdc, 0x64, 0x86, 0xfd, 0x70, - }; - - FfElementObj r12(&this->fq12); - FfElementObj fq12_exp[4]; - - // prepare data for test - for (m = 0; m < 4; m++) { - fq12_exp[m] = FfElementObj(&this->fq12, ff12e[m]); - // initialize data for test - p[m] = fq12_exp[m]; - b[m] = &bnm12[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq12, p, b, 4, r12)); - EXPECT_EQ(FfElementObj(&this->fq12, fq12_expected_result_str), r12) - << "FfMultiExp: Finite field element does not match with reference value"; -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenFiveExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[5]; - FfElement const* p[5]; - BigNumStr const* b[5]; - int m = 0; - const FqElemStr ffe[] = { - {0x7B, 0x26, 0x96, 0x84, 0x04, 0x0D, 0x6F, 0x10, 0xAA, 0x7F, 0xD0, 0x0C, - 0x41, 0x3A, 0x68, 0x48, 0xBF, 0x3D, 0xB5, 0xCE, 0x3A, 0x9C, 0xA9, 0x10, - 0xA4, 0x67, 0x7C, 0xC0, 0x41, 0x52, 0xCA, 0xE7}, - {0x2E, 0xD9, 0xEF, 0x86, 0xB6, 0x32, 0x72, 0x89, 0x37, 0xCF, 0x16, 0xCE, - 0x27, 0x15, 0x7A, 0x95, 0xCF, 0x94, 0x1B, 0xF3, 0xCE, 0x49, 0x20, 0x29, - 0x9A, 0x61, 0x2E, 0x0A, 0xF5, 0xE1, 0xDC, 0x9F}, - {0xE0, 0x19, 0x37, 0x44, 0xA7, 0x45, 0x49, 0x7E, 0x19, 0x02, 0x09, 0x78, - 0xBE, 0xA4, 0x65, 0x60, 0x7A, 0xF5, 0xC8, 0xAF, 0x97, 0x5E, 0xDA, 0x3A, - 0xB4, 0x16, 0x70, 0x31, 0xE3, 0xB4, 0x18, 0xA8}, - {0xBC, 0x92, 0x29, 0x92, 0x14, 0xD3, 0x3F, 0xB8, 0xB8, 0x8C, 0x41, 0xDF, - 0xC5, 0xA1, 0xCA, 0x77, 0xE5, 0x73, 0xFE, 0xA7, 0xAC, 0x81, 0x66, 0x11, - 0x5A, 0x6D, 0x7D, 0x97, 0x13, 0x92, 0x8D, 0x1D}, - {0xE1, 0xA0, 0x0D, 0xDC, 0x8F, 0x20, 0xF5, 0x2D, 0x1D, 0x1F, 0xBD, 0x24, - 0x8C, 0xC2, 0x26, 0x06, 0x89, 0xE9, 0x46, 0xA9, 0xD2, 0x44, 0x8F, 0x1A, - 0x8D, 0xAF, 0x20, 0x73, 0x60, 0x0B, 0x66, 0x9C}}; - - const BigNumStr bnm[] = { - {0x78, 0xE6, 0x3F, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7, 0x6E, - 0xE9, 0xFF, 0x4F, 0xFF, 0x23, 0xFF, 0x67, 0xB4, 0xED, 0xEE, 0xD7, 0xC6, - 0xFF, 0x4B, 0x0B, 0x6F, 0x1F, 0xD6, 0xFD, 0x7F}, - {0xA1, 0x87, 0xFF, 0x1B, 0xFF, 0x85, 0x68, 0xFF, 0x1C, 0xFF, 0xD5, 0xFF, - 0x95, 0x73, 0xFF, 0xFF, 0xFF, 0x9E, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x5E, - 0x9E, 0x62, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0xF3}, - {0x2E, 0xE8, 0x1E, 0x35, 0xFF, 0x82, 0x0B, 0x99, 0xEC, 0x30, 0x2B, 0xCE, - 0xEC, 0x83, 0x05, 0xFF, 0x9E, 0x3C, 0xFF, 0xFF, 0xA1, 0xFF, 0xFF, 0xFF, - 0x57, 0x26, 0x5B, 0x6C, 0xFF, 0xE6, 0x94, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0x79, 0xFC, 0xFF, 0x83, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xA9, 0xFF, 0x2F, 0x6B, 0xD1, 0xE7, 0xFF, 0xFF, - 0xFF, 0x7C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {0x63, 0x53, 0x53, 0xFF, 0xFF, 0xFF, 0x4F, 0xFF, 0xFF, 0xFF, 0x09, 0xFF, - 0xC0, 0xD8, 0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x45, - 0xFF, 0x3A, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x06}}; - - const FqElemStr res = { - 0x8F, 0x6D, 0x54, 0xCA, 0x00, 0x85, 0xD8, 0x78, 0xA4, 0x45, 0x36, - 0x7C, 0x23, 0xD0, 0x3C, 0x2D, 0x20, 0x78, 0xD9, 0xD7, 0xF1, 0xC3, - 0x99, 0xD9, 0xD3, 0x0A, 0x0E, 0x86, 0x98, 0xC2, 0xA7, 0x97, - }; - // prepare data for test - for (m = 0; m < 5; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 5, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; -} - -TEST_F(FfElementTest, FfMultiExpWorksGivenSixExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[6]; - FfElement const* p[6]; - BigNumStr const* b[6]; - int m = 0; - const FqElemStr ffe[] = { - {0x75, 0x18, 0x6A, 0x3D, 0xCC, 0x76, 0x33, 0x92, 0xD0, 0x57, 0xDA, 0xE0, - 0x37, 0x6F, 0x71, 0xD5, 0x9E, 0x7E, 0x65, 0xED, 0xD7, 0xFD, 0x82, 0xC0, - 0x6C, 0x83, 0x60, 0x30, 0xC1, 0xD3, 0x3D, 0x4D}, - {0xF5, 0x3A, 0x20, 0xAB, 0x22, 0x47, 0x07, 0xAE, 0x71, 0xC1, 0x91, 0x73, - 0xEF, 0x1F, 0x1D, 0x76, 0x2E, 0xEE, 0x0D, 0xDE, 0xD9, 0xF8, 0x5C, 0x85, - 0xC7, 0x5B, 0x93, 0x88, 0xF6, 0xFF, 0x4C, 0xA5}, - {0x21, 0xB3, 0x5E, 0xE8, 0xD2, 0xDA, 0x14, 0x1C, 0xB5, 0x2C, 0xFC, 0x61, - 0x9D, 0xEB, 0x65, 0x87, 0xBB, 0x5B, 0xBC, 0xFD, 0x37, 0x54, 0x6B, 0xDC, - 0xD9, 0xFA, 0x7A, 0xCD, 0x18, 0x7E, 0x8B, 0x89}, - {0x70, 0xB7, 0x19, 0x42, 0xB4, 0x41, 0x2C, 0x1B, 0xBD, 0x7B, 0x25, 0x06, - 0xA2, 0x95, 0xB5, 0xB6, 0x70, 0xDF, 0x58, 0x71, 0xCA, 0x09, 0x12, 0x66, - 0x5A, 0x7B, 0xF0, 0x5F, 0x43, 0x69, 0x32, 0xF6}, - {0x3D, 0x57, 0xE8, 0x3F, 0x1E, 0x39, 0x2B, 0xE5, 0xD0, 0xCF, 0xA9, 0xC8, - 0x72, 0x10, 0x7F, 0xC5, 0x4F, 0xAE, 0xE9, 0x73, 0x28, 0x4C, 0xFC, 0x3F, - 0xD5, 0xFF, 0xE8, 0xCF, 0x2C, 0xEB, 0x33, 0xD3}, - {0x51, 0x80, 0x15, 0x1C, 0xE6, 0x9C, 0x4B, 0x80, 0x40, 0xBA, 0x40, 0x29, - 0x3A, 0x86, 0xA8, 0xB2, 0x66, 0x08, 0x97, 0x8D, 0xEB, 0x8B, 0xA7, 0x93, - 0xE3, 0x49, 0xC6, 0xC0, 0x46, 0x93, 0xC1, 0x75}}; - const BigNumStr bnm[] = { - {0xFF, 0xFF, 0xFF, 0x49, 0x50, 0xFF, 0x19, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, - 0xFF, 0x28, 0x4A, 0x0E, 0xFF, 0x74, 0xFF, 0xC7, 0xFF, 0xD9, 0x81, 0xFF, - 0xFF, 0xFF, 0xD5, 0x2C, 0xFF, 0xFF, 0xFF, 0xAE}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x0C, 0x03, 0xFF, 0x95, 0xFF, 0x11, 0x9D, 0xFF, 0x9B, 0xFF, 0xFF, - 0x68, 0x44, 0xFF, 0xC9, 0xFF, 0x10, 0xC7, 0xBF}, - {0x64, 0xFF, 0x89, 0x4A, 0xFF, 0x20, 0xFF, 0xE7, 0xFF, 0x36, 0x23, 0xDD, - 0xFF, 0xFF, 0xFC, 0xFF, 0x6B, 0xFF, 0xFF, 0xFF, 0xFF, 0x48, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xD3, 0x59, 0xBE}, - {0x0F, 0xFF, 0x76, 0xA5, 0x9E, 0x02, 0x9B, 0xFF, 0xA1, 0xFF, 0xC2, 0xFF, - 0x9D, 0xFF, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0x6B, 0x81, 0x2A, 0xFF, 0x98, - 0xFF, 0xFF, 0xB9, 0xFF, 0xB7, 0x78, 0xE6, 0xFF}, - {0xAF, 0xF3, 0xFF, 0x3C, 0xA8, 0xFF, 0xB9, 0x3A, 0xFF, 0xFF, 0xFF, 0x70, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, 0x52, - 0xFF, 0x41, 0x10, 0x62, 0xFF, 0x51, 0x35, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0xC3, 0xD9, 0xFF, 0xFF, 0x3A, 0x44, 0x88, - 0x04, 0xFF, 0x0B, 0xFF, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0x52, 0xFF, 0x7D, - 0x6B, 0x24, 0x6E, 0xFF, 0xFF, 0xFF, 0xA7, 0x71}}; - const FqElemStr res = { - 0xFB, 0x89, 0x4F, 0xBB, 0x91, 0xEE, 0xD6, 0x57, 0x2D, 0x34, 0xF9, - 0x0B, 0xE3, 0xEB, 0x71, 0x1D, 0x63, 0x74, 0x96, 0x3B, 0xD4, 0x02, - 0x2F, 0x08, 0xDB, 0x95, 0x6A, 0x40, 0x68, 0xD4, 0x55, 0x76, - }; - // prepare data for test - for (m = 0; m < 6; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfMultiExp(this->fq, p, b, 6, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfMultiExp: Finite field element does not match with reference value"; -} -/////////////////////////////////////////////////////////////////////// -// FfSscmMultiExp - -TEST_F(FfElementTest, SscmFfMultiExpFailsGivenArgumentsMismatch) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - FfElement const* p12[] = {this->fq12_a, this->fq12_b}; - const BigNumStr bnm0 = {0}; - const BigNumStr bnm1 = {0}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq12, p, b, 2, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p12, b, 2, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, 2, this->fq12_r)); -} - -TEST_F(FfElementTest, SscmFfMultiExpFailsGivenNullPointer) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - FfElement const* p_withnull[] = {nullptr, this->fq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - BigNumStr const* b_withnull[] = {nullptr, &bnm1}; - size_t m = 2; - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(nullptr, p, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, nullptr, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, p, nullptr, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, m, nullptr)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, p_withnull, b, m, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, p, b_withnull, m, this->fq_r)); -} - -TEST_F(FfElementTest, SscmFfMultiExpFailsGivenIncorrectMLen) { - FfElement const* p[] = {this->fq_a, this->fq_b}; - const BigNumStr bnm0 = {{0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, - 0x08, 0xFF, 0xFF, 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, - 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, 0xF2, 0x6A, 0xFF, - 0xFF, 0xEA, 0x31, 0xFF, 0xFF}}; - const BigNumStr bnm1 = {{0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, - 0xFF, 0x6B, 0xD5, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, - 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, 0x84, 0xFF, 0xFF, - 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - BigNumStr const* b[] = {&bnm0, &bnm1}; - size_t len_greater_int_max = (size_t)INT_MAX + 1; - EXPECT_EQ(kEpidBadArgErr, FfSscmMultiExp(this->fq, p, b, 0, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, p, b, std::numeric_limits::max(), - this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfSscmMultiExp(this->fq, p, b, len_greater_int_max, this->fq_r)); -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenOneExponent) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[1]; - FfElement const* p[1]; - BigNumStr const* b[1]; - int m = 0; - const FqElemStr ffe[] = {{ - 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, - }}; - const BigNumStr bnm[] = {{ - 0xFF, 0xFB, 0x3E, 0x5D, 0xFF, 0x9A, 0xFF, 0x02, 0x00, 0xFF, 0xFF, 0xFF, - 0xF2, 0xE1, 0x85, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x81, - 0xFF, 0xFD, 0xFF, 0xEB, 0xFF, 0x29, 0xA7, 0xFF, - }}; - const FqElemStr res = { - 0x6A, 0x21, 0xEC, 0x89, 0xCC, 0x13, 0x2F, 0x6F, 0x29, 0x1B, 0x3A, - 0x94, 0xF6, 0xE6, 0xA8, 0xBD, 0x98, 0x25, 0x43, 0x7A, 0xDC, 0xC1, - 0x20, 0xBA, 0x30, 0xD8, 0x1C, 0x8E, 0x79, 0xFC, 0xDA, 0x67, - }; - // prepare data for test - for (m = 0; m < 1; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 1, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenTwoExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[2]; - FfElement const* p[2]; - BigNumStr const* b[2]; - int m = 0; - const FqElemStr ffe[] = { - {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}, - {0xDD, 0x2B, 0xE9, 0x59, 0x24, 0xA5, 0xB3, 0xFD, 0xEB, 0xE1, 0x3C, 0xC0, - 0x73, 0x4E, 0x99, 0xEE, 0x36, 0xF6, 0xC0, 0x1A, 0x76, 0x01, 0x0A, 0xF0, - 0xCB, 0xB4, 0x71, 0x88, 0x95, 0xCB, 0x35, 0xBA}}; - const BigNumStr bnm[] = { - {0x11, 0xFF, 0xFF, 0xFF, 0x4F, 0x59, 0xB1, 0xD3, 0x6B, 0x08, 0xFF, 0xFF, - 0x0B, 0xF3, 0xAF, 0x27, 0xFF, 0xB8, 0xFF, 0xFF, 0x98, 0xFF, 0xEB, 0xFF, - 0xF2, 0x6A, 0xFF, 0xFF, 0xEA, 0x31, 0xFF, 0xFF}, - {0xE2, 0xFF, 0x03, 0x1D, 0xFF, 0x19, 0x81, 0xCB, 0xFF, 0xFF, 0x6B, 0xD5, - 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xBD, 0xFF, 0x5A, 0xFF, 0x5C, 0x7C, 0xFF, - 0x84, 0xFF, 0xFF, 0x8C, 0x03, 0xB2, 0x26, 0xFF}}; - const FqElemStr res = { - 0x8A, 0xF7, 0x96, 0x53, 0x9C, 0xC3, 0x57, 0x89, 0x50, 0xE3, 0xAB, - 0x12, 0x62, 0xEA, 0x0C, 0xE4, 0x65, 0xA6, 0x91, 0x09, 0x93, 0x81, - 0xFC, 0xBB, 0x0E, 0xFA, 0xC1, 0xC4, 0xDC, 0x3F, 0x0A, 0xD1, - }; - // prepare data for test - for (m = 0; m < 2; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 2, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenThreeExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[3]; - FfElement const* p[3]; - BigNumStr const* b[3]; - int m = 0; - const FqElemStr ffe[] = { - {0x24, 0x9D, 0xDD, 0x1A, 0xC0, 0x07, 0x1F, 0x65, 0xDF, 0xBB, 0xC7, 0x39, - 0x99, 0x44, 0x63, 0x8E, 0x7E, 0xB2, 0x85, 0x82, 0xC6, 0x4E, 0x2D, 0x39, - 0xA8, 0x3F, 0x12, 0xB4, 0xE9, 0x9D, 0x67, 0x28}, - {0x6B, 0x51, 0x6B, 0x33, 0x0B, 0x2E, 0x2A, 0x94, 0x34, 0xCC, 0x7E, 0x97, - 0xFA, 0x85, 0x51, 0x44, 0x30, 0xE5, 0xF2, 0x68, 0x23, 0x31, 0x84, 0xFF, - 0xBB, 0x95, 0x9A, 0xB2, 0x80, 0x95, 0xC4, 0x91}, - {0x77, 0xED, 0xA2, 0x53, 0xA3, 0xBF, 0x6C, 0x58, 0x16, 0x7D, 0xEF, 0x8A, - 0x7D, 0x38, 0x65, 0x3F, 0x92, 0xA6, 0x85, 0xD7, 0x9F, 0x80, 0xA4, 0xA1, - 0x70, 0x02, 0xE5, 0x66, 0xF2, 0xD8, 0xD7, 0xD2}}; - const BigNumStr bnm[] = { - {0xFF, 0xFF, 0xFF, 0xB4, 0x48, 0xFF, 0xFF, 0xFF, 0xA3, 0xFF, 0xE3, 0xFF, - 0x61, 0xFF, 0xA2, 0x97, 0x9A, 0xFF, 0x6F, 0x04, 0xC6, 0xB9, 0xFF, 0x22, - 0xFF, 0x20, 0x9E, 0xFF, 0x43, 0xFF, 0xFF, 0xFF}, - {0xB1, 0x19, 0xBF, 0xFF, 0x74, 0x7F, 0xCC, 0x34, 0x1E, 0x30, 0x7D, 0xC5, - 0xC4, 0xFF, 0xE7, 0xF8, 0xFF, 0x5F, 0xFF, 0x73, 0xFF, 0x58, 0xFF, 0xD6, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF}, - {0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0xA8, 0xFF, 0xFF, 0xFF, - 0x3E, 0xFF, 0xFF, 0xFF, 0xE0, 0x4F, 0xFF, 0xE3, 0xFF, 0xFF, 0xEB, 0x04, - 0x4B, 0xFF, 0x5D, 0x55, 0xFF, 0x2D, 0xFF, 0xFF}}; - const FqElemStr res = { - 0x04, 0x22, 0x21, 0xE7, 0x9F, 0xE3, 0x07, 0x2F, 0xA4, 0xBB, 0x56, - 0x84, 0xD5, 0x93, 0x4A, 0xDA, 0x5B, 0x89, 0x07, 0xBE, 0xC5, 0x5F, - 0xE6, 0x5C, 0x18, 0xF0, 0xF8, 0x8E, 0x8E, 0x00, 0xB9, 0x87, - }; - // prepare data for test - for (m = 0; m < 3; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 3, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenFourExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[4]; - FfElement const* p[4]; - BigNumStr const* b[4]; - int m = 0; - const FqElemStr ffe[] = { - {0x81, 0xEE, 0x78, 0x31, 0x4C, 0xC0, 0x3C, 0xDD, 0x16, 0x52, 0xC6, 0x7E, - 0x07, 0x4C, 0xFE, 0xC4, 0x50, 0x63, 0x5A, 0x40, 0xC8, 0xDF, 0x94, 0x23, - 0x1A, 0x90, 0xDD, 0x24, 0x61, 0x23, 0xDD, 0x87}, - {0x76, 0xBB, 0x2C, 0x1C, 0xB3, 0x78, 0x93, 0x7E, 0x10, 0x29, 0xC3, 0xEC, - 0xBD, 0xA3, 0x75, 0x3A, 0xF1, 0x0B, 0xE1, 0xCA, 0xEE, 0x02, 0x58, 0x74, - 0xC7, 0xDC, 0xB8, 0x4F, 0x3F, 0x7B, 0xA2, 0xFC}, - {0x3A, 0xD3, 0x04, 0xAA, 0x9D, 0x2A, 0xDE, 0x86, 0x56, 0x84, 0x80, 0x42, - 0xA5, 0x68, 0xD8, 0x6E, 0x65, 0xC4, 0x08, 0x07, 0x87, 0x4B, 0xC1, 0x92, - 0xCB, 0x68, 0x52, 0x6C, 0x5A, 0x4F, 0x7C, 0xFB}, - {0x56, 0xE7, 0xBD, 0x59, 0x54, 0xCC, 0x20, 0x16, 0xAE, 0x36, 0xD1, 0xB0, - 0xE4, 0x82, 0x47, 0x27, 0x32, 0xD1, 0x38, 0x7C, 0x53, 0x7F, 0xDD, 0xF4, - 0xDE, 0xFA, 0xF7, 0x0F, 0xDD, 0xDF, 0x48, 0xA9}}; - const BigNumStr bnm[] = { - {0xFF, 0xA5, 0xC3, 0xFF, 0xFF, 0x09, 0x18, 0x18, 0x95, 0x40, 0xFF, 0xFF, - 0xDB, 0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0xFF, 0x25, 0xFF, 0xFF, 0x42, 0x07, - 0xB5, 0xFF, 0x26, 0xE0, 0x4F, 0xB5, 0xB4, 0xFF}, - {0x1F, 0xFF, 0xAA, 0xF1, 0xFF, 0xFF, 0x7E, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, - 0xE7, 0xDF, 0xFF, 0xEE, 0xFF, 0x57, 0xFF, 0xFF, 0xFF, 0xB8, 0xB3, 0x9C, - 0xFF, 0x8A, 0x89, 0xFF, 0xFE, 0x32, 0xFF, 0xC1}, - {0x9A, 0xFF, 0xFF, 0x9B, 0xFF, 0xAB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x36, 0xF0, 0xC5, 0xAE, 0x87, 0x41, 0xFF, 0x5C, 0xDD, 0xFF, 0xFF, - 0xFF, 0xFF, 0x59, 0xC9, 0xFF, 0x44, 0x5C, 0x58}, - {0x00, 0xFF, 0x95, 0xFF, 0x21, 0xFF, 0xFF, 0x1D, 0x1A, 0x06, 0xD3, 0xFF, - 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xB0, 0x31, 0xFF, 0xFF, 0x1F, - 0x61, 0x48, 0xFF, 0xFF, 0xFF, 0x17, 0xC9, 0x79}}; - const FqElemStr res = { - 0x26, 0x2C, 0x23, 0x55, 0xD5, 0xBD, 0x7B, 0x67, 0x60, 0xFE, 0x06, - 0x7B, 0xCC, 0xB8, 0x6B, 0xC9, 0x00, 0x81, 0xAE, 0xCB, 0xEC, 0x91, - 0x6D, 0x1B, 0x9E, 0x1C, 0xD8, 0xC0, 0x8D, 0x3F, 0x1B, 0x20, - }; - // prepare data for test - for (m = 0; m < 4; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 4, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; - - const Fq12ElemStr ff12e[] = { - { - 0x2c, 0x86, 0xee, 0x80, 0x61, 0x45, 0x8f, 0xfd, 0x96, 0xc2, 0x81, - 0x11, 0xe8, 0x96, 0xe2, 0xca, 0x21, 0x78, 0xf7, 0xa3, 0x4b, 0xba, - 0xdc, 0x0d, 0x34, 0x8a, 0x56, 0x12, 0x67, 0x8d, 0x72, 0x37, 0xa8, - 0xeb, 0x5f, 0x1a, 0x1b, 0xf0, 0x5c, 0xc6, 0x6f, 0xc2, 0xc5, 0x03, - 0xc4, 0x19, 0x85, 0xa6, 0xe0, 0x64, 0xfe, 0x71, 0x51, 0x46, 0xdf, - 0xc2, 0xd6, 0xf9, 0xa0, 0xd6, 0x84, 0xc1, 0x4a, 0x11, 0xe0, 0x33, - 0xa3, 0x1c, 0x73, 0x71, 0x62, 0x17, 0x10, 0x4c, 0xd8, 0x3e, 0xee, - 0xa1, 0x38, 0x9f, 0xa5, 0xfb, 0x1d, 0xc4, 0x9d, 0x2f, 0x08, 0x4a, - 0xd3, 0x61, 0x37, 0x79, 0xab, 0xc1, 0x37, 0x7e, 0x90, 0xfd, 0xa3, - 0x9d, 0x0c, 0x81, 0x52, 0xf4, 0x58, 0x24, 0x89, 0xc4, 0xf4, 0xd4, - 0x82, 0x33, 0xca, 0x5d, 0xb4, 0x58, 0xa6, 0x1e, 0xe6, 0x2b, 0x86, - 0xef, 0x56, 0xc4, 0x4f, 0x9b, 0x27, 0x3c, 0x96, 0x54, 0xda, 0xb5, - 0x32, 0x23, 0x8a, 0x93, 0xcc, 0xa5, 0x7d, 0x28, 0x4a, 0x97, 0xa4, - 0x30, 0xa8, 0x11, 0xbc, 0x43, 0x22, 0x7f, 0x02, 0x73, 0x0e, 0x5c, - 0x63, 0x52, 0x2f, 0x4b, 0x5f, 0x7d, 0xc3, 0x1e, 0x30, 0xae, 0xac, - 0x8c, 0xe8, 0x93, 0xd6, 0xce, 0x05, 0x4b, 0x6b, 0x21, 0x01, 0x14, - 0x4a, 0x1d, 0xd9, 0x08, 0x0c, 0xa1, 0x4c, 0x0b, 0x44, 0x28, 0x9c, - 0xb6, 0xd1, 0x96, 0xbd, 0x07, 0x8b, 0x3d, 0x77, 0x4e, 0xbd, 0x7b, - 0x9f, 0x65, 0x20, 0xdb, 0xa0, 0x95, 0x25, 0x44, 0x44, 0x7a, 0xe3, - 0xdc, 0xdd, 0x2f, 0xba, 0x75, 0x16, 0x19, 0xcb, 0x90, 0x31, 0x79, - 0x38, 0xb6, 0x1a, 0x82, 0xbc, 0xb6, 0x85, 0xcd, 0xeb, 0xb9, 0x13, - 0x43, 0xea, 0xc2, 0x78, 0xbe, 0x25, 0x97, 0x1c, 0x6e, 0x18, 0x55, - 0xfd, 0xcb, 0xe6, 0x7e, 0x1e, 0x92, 0xad, 0x48, 0xe7, 0xa7, 0x02, - 0x87, 0x0b, 0x8f, 0x16, 0xd7, 0x8e, 0x95, 0x8e, 0x62, 0x0a, 0xad, - 0x20, 0x2d, 0x6a, 0x2b, 0x4e, 0x6f, 0xc1, 0xc2, 0x63, 0xba, 0x82, - 0xf3, 0x8c, 0xd0, 0xa2, 0x09, 0xd3, 0xe5, 0xba, 0x1f, 0x65, 0x35, - 0xd0, 0x1c, 0x09, 0x98, 0x47, 0x65, 0xf2, 0x90, 0xd4, 0xe2, 0xd0, - 0x6f, 0x9e, 0xdb, 0xa2, 0x14, 0x9b, 0x4b, 0x3d, 0xaa, 0x75, 0x25, - 0x67, 0xf4, 0x7d, 0x77, 0xe9, 0x24, 0xed, 0xee, 0x1b, 0x07, 0x7f, - 0xe0, 0x7a, 0x34, 0xb7, 0x3c, 0x36, 0x0d, 0xce, 0xf9, 0xbf, 0xf9, - 0xe5, 0x09, 0x86, 0xeb, 0xb9, 0xd8, 0xc4, 0x67, 0xc5, 0xcd, 0xd4, - 0xbc, 0xee, 0x45, 0xf7, 0x11, 0x68, 0xd9, 0x23, 0x6d, 0xd6, 0x24, - 0x6e, 0x97, 0x83, 0x13, 0x76, 0x9f, 0x35, 0xea, 0xb8, 0x47, 0x57, - 0x9b, 0x74, 0x47, 0x1f, 0x19, 0xe7, 0x97, 0x74, 0x1b, 0xb1, 0xa0, - 0xf3, 0x92, 0xdc, 0x35, 0xfd, 0x7f, 0x4f, 0x07, 0x22, 0xac, - }, - { - 0xfd, 0x05, 0x41, 0x27, 0x00, 0x7a, 0xad, 0x17, 0xbc, 0xbf, 0x22, - 0x5e, 0xda, 0xeb, 0x7d, 0xaa, 0xb5, 0x2d, 0xc8, 0x61, 0xfe, 0x2c, - 0xba, 0x9e, 0x54, 0x43, 0x94, 0xdc, 0xfd, 0x0e, 0x6d, 0x6d, 0xa1, - 0x5e, 0x05, 0xa5, 0x05, 0x55, 0xe7, 0x2a, 0xf7, 0x53, 0x37, 0x2c, - 0xef, 0x44, 0x95, 0xca, 0x2c, 0xe8, 0xeb, 0xae, 0x61, 0x05, 0x33, - 0xe7, 0x0f, 0x30, 0x67, 0xbe, 0xcd, 0xb2, 0x93, 0x44, 0x44, 0x31, - 0x96, 0x4d, 0x72, 0x61, 0xcd, 0x23, 0x1f, 0x7b, 0x57, 0x33, 0x39, - 0xac, 0x57, 0x53, 0x3d, 0x70, 0x57, 0xb3, 0x6d, 0xd5, 0x8a, 0x89, - 0x30, 0xbc, 0xed, 0x29, 0x19, 0x39, 0x6e, 0x6a, 0x80, 0x21, 0x1e, - 0xb7, 0x84, 0xb1, 0x0a, 0xa4, 0xd0, 0xff, 0x59, 0x31, 0xe9, 0xba, - 0x39, 0xf7, 0x81, 0xdf, 0x1b, 0x7b, 0xd9, 0xdb, 0x02, 0x17, 0xbe, - 0x97, 0x63, 0xbd, 0x37, 0x14, 0xb8, 0x8b, 0x6c, 0xcc, 0x5b, 0xa3, - 0xee, 0xc8, 0x0b, 0x7b, 0xf5, 0xde, 0xbc, 0xb7, 0xa8, 0x25, 0x35, - 0xae, 0x0b, 0x30, 0x96, 0x33, 0x52, 0x13, 0xa3, 0x89, 0x3a, 0x2e, - 0xa4, 0x7e, 0x5f, 0x4e, 0xb1, 0xf7, 0x87, 0xba, 0x08, 0xb0, 0xfb, - 0xcb, 0x31, 0xa6, 0x2b, 0x3e, 0xe7, 0xc4, 0xcc, 0xa5, 0x14, 0x61, - 0xc9, 0x18, 0xfc, 0x74, 0x59, 0x06, 0xf4, 0xad, 0xfc, 0x2d, 0x0c, - 0x7d, 0xdb, 0x2a, 0xec, 0xd4, 0xe9, 0x31, 0x31, 0x50, 0x25, 0xb7, - 0x0c, 0x48, 0x30, 0xd5, 0x78, 0xb1, 0x10, 0xea, 0x5d, 0xaa, 0xaa, - 0x03, 0xec, 0xe3, 0x0f, 0x36, 0xa6, 0xbc, 0x18, 0x3a, 0x76, 0x87, - 0xa3, 0xe9, 0x33, 0xda, 0x48, 0x78, 0x93, 0x64, 0x72, 0x9b, 0x2a, - 0x1e, 0x0d, 0x50, 0x9f, 0x6f, 0xbd, 0xa5, 0x18, 0xb1, 0xa8, 0x14, - 0x9a, 0x1b, 0xb9, 0xb4, 0x2c, 0x1f, 0x46, 0xb8, 0x9b, 0x7a, 0xc7, - 0x84, 0xae, 0x27, 0xd1, 0xec, 0x1c, 0xec, 0x69, 0xf0, 0x35, 0x40, - 0x77, 0x7e, 0x27, 0x22, 0x36, 0x38, 0xdf, 0x15, 0xc2, 0xb3, 0xb8, - 0x63, 0x4a, 0x6e, 0x68, 0x8c, 0xc1, 0x39, 0x3c, 0x02, 0x4c, 0x2a, - 0x31, 0x18, 0x2e, 0x35, 0xf5, 0xca, 0xa2, 0xe9, 0x24, 0x92, 0xd5, - 0xe5, 0x2e, 0x5d, 0x1c, 0x94, 0xd9, 0xc7, 0xf0, 0x22, 0x16, 0x20, - 0xa8, 0x37, 0xdd, 0x0e, 0xab, 0x1b, 0x5e, 0x8b, 0xee, 0x81, 0xc6, - 0x17, 0xf1, 0x29, 0x5d, 0x1d, 0x6f, 0x53, 0x5a, 0xb2, 0x20, 0x88, - 0x3d, 0xa4, 0x98, 0x81, 0xa4, 0xef, 0x11, 0x1b, 0x64, 0x9e, 0x2c, - 0x95, 0xdd, 0xd7, 0x57, 0xb3, 0x95, 0xca, 0x40, 0xb9, 0x0d, 0x62, - 0xdc, 0x86, 0x8b, 0xe6, 0xd3, 0x7b, 0x33, 0xea, 0x50, 0x25, 0xe2, - 0x77, 0xe3, 0x0b, 0x5a, 0xc8, 0x81, 0xfc, 0xae, 0x74, 0x38, 0x69, - 0x07, 0xf8, 0x4e, 0xd7, 0x85, 0xa6, 0x2f, 0x13, 0xb7, 0x0a, - }, - { - 0xf4, 0xdc, 0xac, 0x02, 0xc0, 0x95, 0x07, 0xdc, 0x12, 0x4f, 0x3a, - 0x01, 0xa9, 0xee, 0xf3, 0x07, 0x46, 0x94, 0x47, 0x15, 0x63, 0xa6, - 0x8e, 0x0a, 0xc4, 0xc4, 0xe4, 0x23, 0x85, 0x63, 0xe4, 0x4e, 0x9a, - 0x9e, 0x9f, 0xc1, 0xed, 0x4e, 0x94, 0x10, 0xfe, 0x7d, 0x90, 0xef, - 0x82, 0x21, 0xac, 0x67, 0x24, 0x99, 0x86, 0xc6, 0x85, 0x8b, 0x19, - 0x9a, 0x9b, 0x90, 0x0b, 0xa4, 0x90, 0x78, 0x34, 0x53, 0xb1, 0x4c, - 0xba, 0xb8, 0xc6, 0x40, 0x71, 0xc2, 0x17, 0x51, 0x05, 0xc2, 0xc9, - 0xbc, 0x03, 0x10, 0x4e, 0xfe, 0x2f, 0x94, 0xed, 0x13, 0x35, 0x7b, - 0x20, 0xa6, 0x59, 0x44, 0x81, 0xd0, 0xec, 0x12, 0x74, 0xa2, 0x4a, - 0xfb, 0xd7, 0x28, 0x70, 0xad, 0xde, 0x86, 0x2f, 0xef, 0xf9, 0x50, - 0x5d, 0x1e, 0x46, 0x3b, 0x82, 0x1c, 0x6a, 0xc9, 0x3f, 0x32, 0xae, - 0xcd, 0x93, 0x2c, 0xa5, 0x70, 0x45, 0x24, 0x38, 0x19, 0x79, 0xbf, - 0x35, 0xf5, 0xc1, 0x53, 0x06, 0x42, 0xaa, 0x6b, 0xf3, 0xb7, 0x8f, - 0xfb, 0xfc, 0x28, 0x46, 0x9a, 0x65, 0x2a, 0x45, 0x3d, 0x4c, 0x3c, - 0x6b, 0x9c, 0x44, 0xc5, 0x82, 0xb8, 0x80, 0xf9, 0xb3, 0x44, 0x95, - 0x17, 0x39, 0x01, 0x6b, 0xd6, 0x1d, 0x73, 0x22, 0x94, 0xff, 0x6f, - 0x7b, 0x4e, 0xb6, 0xa4, 0xe4, 0x6c, 0xa8, 0xdb, 0x38, 0x74, 0x0b, - 0xdb, 0xfa, 0x14, 0x99, 0x39, 0x28, 0xee, 0xfc, 0x62, 0xe5, 0x33, - 0x9c, 0x63, 0xd5, 0x7f, 0x2c, 0x4c, 0xf4, 0x76, 0x4c, 0xf7, 0x7b, - 0x27, 0x2c, 0xa9, 0xb9, 0x01, 0x3c, 0x58, 0xf7, 0xce, 0xaa, 0x0a, - 0x21, 0xc0, 0xa3, 0xa7, 0xa1, 0x85, 0xbc, 0xfe, 0x55, 0xfc, 0x3b, - 0x9b, 0x3d, 0xef, 0x14, 0x85, 0x8a, 0x4e, 0x5e, 0x1f, 0x4f, 0xc9, - 0x86, 0xb8, 0xf2, 0xb2, 0xe3, 0xe7, 0x7e, 0x87, 0xe2, 0x20, 0xd7, - 0x85, 0x2c, 0xd1, 0x13, 0xcb, 0x46, 0xad, 0xd7, 0xec, 0x66, 0xd5, - 0x2b, 0x6e, 0x87, 0x92, 0x13, 0xb2, 0x7d, 0x18, 0x69, 0x35, 0xcb, - 0xf1, 0xbe, 0xc2, 0x9d, 0xeb, 0xf5, 0x00, 0x0b, 0x73, 0xa3, 0xfd, - 0x51, 0xdc, 0x91, 0x0e, 0xe4, 0x46, 0x41, 0x23, 0xdd, 0x85, 0x53, - 0x0c, 0xae, 0xf9, 0x74, 0xcf, 0x1c, 0x32, 0x22, 0xda, 0x4a, 0x14, - 0x80, 0x71, 0x51, 0x23, 0xc3, 0xab, 0x7e, 0xec, 0x77, 0xcc, 0x59, - 0x12, 0x1c, 0x0f, 0x65, 0x6b, 0xd8, 0x41, 0xe0, 0x1b, 0x51, 0x9c, - 0x89, 0x26, 0xab, 0x88, 0x63, 0x5d, 0xbb, 0x95, 0x92, 0x5b, 0x2c, - 0x1d, 0xde, 0xc1, 0x88, 0xd6, 0xf1, 0x02, 0x48, 0xe0, 0xe2, 0xd1, - 0x40, 0x7f, 0xf1, 0x23, 0x4a, 0xcf, 0x36, 0xd5, 0xcf, 0x76, 0x0d, - 0x00, 0x2a, 0xf7, 0x5f, 0x31, 0xbb, 0xcc, 0x46, 0x84, 0x07, 0x04, - 0x98, 0x9c, 0xb4, 0x31, 0x15, 0x2d, 0x91, 0xf6, 0x29, 0x33, - }, - { - 0xa8, 0x8e, 0x9a, 0xf9, 0x25, 0x12, 0x98, 0xe2, 0xc3, 0x61, 0x2e, - 0xe8, 0xd6, 0xa6, 0x77, 0x16, 0x49, 0x04, 0x75, 0x69, 0xd1, 0x83, - 0x2d, 0x3f, 0x2a, 0x79, 0xb6, 0x9b, 0xc9, 0x1d, 0x03, 0x90, 0x2a, - 0xd8, 0x11, 0x9f, 0x26, 0x36, 0xe7, 0xe9, 0x3a, 0x05, 0x4c, 0x15, - 0x49, 0x93, 0xda, 0xe9, 0xd0, 0x5a, 0xe4, 0x8d, 0x8a, 0xfa, 0x04, - 0xf1, 0x20, 0x84, 0x56, 0xec, 0x3c, 0x27, 0x19, 0x5c, 0xf1, 0xaf, - 0xbf, 0xf6, 0x0e, 0x58, 0x84, 0x2d, 0x94, 0x11, 0xf4, 0xb5, 0xf4, - 0x14, 0x51, 0xb0, 0x90, 0x46, 0x1a, 0x81, 0xed, 0xcf, 0x91, 0x66, - 0x58, 0xa6, 0x36, 0x3a, 0x52, 0x18, 0x5a, 0xc1, 0x08, 0x4c, 0x99, - 0xd3, 0xdc, 0xce, 0x7f, 0xce, 0x78, 0xe0, 0x38, 0x87, 0x32, 0xf1, - 0x80, 0x3c, 0x7b, 0x67, 0xaa, 0x6f, 0xdd, 0xe0, 0xfc, 0xcb, 0xd0, - 0xb0, 0x3a, 0x59, 0x52, 0x2a, 0x84, 0xe4, 0xf8, 0x4a, 0xff, 0x50, - 0xa0, 0x65, 0xc4, 0xee, 0xf4, 0x9c, 0xaa, 0x34, 0x46, 0xf9, 0xd2, - 0x6c, 0xa1, 0x61, 0x71, 0x49, 0x32, 0x25, 0x84, 0x54, 0x90, 0x44, - 0xbe, 0xa4, 0x0b, 0xf7, 0xfe, 0x26, 0x81, 0x63, 0x73, 0xf7, 0x2f, - 0xf2, 0xfa, 0x24, 0x52, 0xa4, 0xd9, 0x4c, 0xc1, 0xa7, 0xa5, 0xc3, - 0x03, 0x36, 0x13, 0x9b, 0x16, 0x45, 0x16, 0xcb, 0x4b, 0x99, 0x38, - 0xf3, 0x6d, 0xc8, 0x7e, 0xab, 0xb3, 0x53, 0xdf, 0xb6, 0x82, 0x60, - 0x12, 0x11, 0x36, 0x69, 0x0e, 0x05, 0x31, 0x8e, 0xcf, 0xd7, 0x3f, - 0x32, 0xe7, 0x95, 0x84, 0x1d, 0xc8, 0xb5, 0xbe, 0x49, 0x17, 0x9d, - 0xcf, 0xa9, 0x5a, 0x2a, 0xc4, 0x11, 0x86, 0xe8, 0x6c, 0x02, 0x56, - 0xb0, 0x25, 0x2f, 0xa0, 0x06, 0xb3, 0x62, 0xb2, 0x11, 0xaf, 0xbe, - 0xa4, 0xe8, 0x61, 0x64, 0x85, 0xfb, 0xeb, 0x1c, 0xf1, 0xbc, 0x2c, - 0xae, 0x10, 0x51, 0x16, 0xa6, 0xc0, 0xb3, 0x86, 0x8e, 0x6d, 0x79, - 0xb6, 0xbd, 0xde, 0x1e, 0x26, 0x06, 0x46, 0x65, 0x82, 0x84, 0x5a, - 0x97, 0xd3, 0xb7, 0x93, 0x78, 0x6b, 0x9d, 0x14, 0x33, 0x94, 0x43, - 0x34, 0x04, 0x45, 0xd1, 0x47, 0xd4, 0x2f, 0x17, 0xcf, 0xf1, 0xdd, - 0xea, 0x11, 0x52, 0xae, 0x01, 0x88, 0x3a, 0x10, 0xee, 0x5c, 0x16, - 0xcd, 0xb5, 0x48, 0xe9, 0x16, 0x2c, 0x70, 0xb4, 0x1e, 0x19, 0x38, - 0xe0, 0x18, 0xe9, 0xae, 0xc5, 0xda, 0x74, 0x41, 0x2d, 0x70, 0x07, - 0x60, 0x37, 0x27, 0x66, 0xf7, 0x00, 0xbb, 0x79, 0x51, 0xf3, 0x7c, - 0x8a, 0x2b, 0xb5, 0x69, 0x6e, 0x10, 0x1f, 0xe0, 0x0a, 0x5e, 0xbe, - 0xb4, 0x4e, 0x0e, 0x02, 0x59, 0xb5, 0xcb, 0x4a, 0x6a, 0x86, 0x8b, - 0xcc, 0xa2, 0x13, 0xa0, 0xe9, 0xf2, 0x5c, 0xb0, 0x23, 0xb2, 0x15, - 0xf9, 0xbb, 0x43, 0xc1, 0x54, 0xf4, 0xc8, 0xab, 0x16, 0xa6, - }, - }; - const BigNumStr bnm12[] = { - { - 0x14, 0x92, 0xd1, 0x1f, 0xac, 0x90, 0x4d, 0xc3, 0x3e, 0xb8, 0xa7, - 0xfe, 0x35, 0x98, 0xda, 0x94, 0xd6, 0xf3, 0x27, 0x29, 0x4b, 0x70, - 0xcf, 0x0f, 0xda, 0x14, 0x97, 0xa1, 0x9b, 0x6b, 0x24, 0x08, - }, - { - 0x76, 0x8d, 0xe5, 0xc2, 0xab, 0x78, 0xd9, 0x76, 0x98, 0xff, 0x92, - 0xea, 0x95, 0x58, 0xc5, 0x0c, 0x6f, 0x1b, 0x35, 0xc4, 0xbf, 0x4a, - 0x9e, 0xc2, 0x6a, 0xec, 0xe2, 0xf6, 0xaf, 0xeb, 0xac, 0x06, - }, - { - 0x50, 0x38, 0x60, 0x31, 0xab, 0x05, 0xcc, 0xb1, 0xc2, 0x06, 0xa0, - 0xd7, 0x92, 0x12, 0xbd, 0x17, 0x81, 0xb9, 0x7e, 0x07, 0x9b, 0xd4, - 0x3b, 0x2d, 0x3c, 0x15, 0x3a, 0x5a, 0xf1, 0xc0, 0xc4, 0x75, - }, - { - 0xa1, 0x3f, 0xea, 0x99, 0x7e, 0xc7, 0x65, 0xf5, 0x41, 0xa6, 0xd6, - 0xd3, 0x77, 0xec, 0x27, 0xf8, 0x6c, 0x18, 0x28, 0x69, 0x97, 0x08, - 0x0e, 0x63, 0x5a, 0xda, 0xfe, 0x9f, 0xd1, 0x4a, 0x61, 0x4f, - }, - }; - const Fq12ElemStr fq12_expected_result_str = { - 0x3a, 0x30, 0x33, 0xa2, 0x14, 0xdf, 0xdc, 0x70, 0x48, 0xf3, 0xba, 0x3f, - 0xce, 0xfc, 0x69, 0x24, 0xae, 0xa1, 0xf3, 0xcf, 0xd8, 0x77, 0x69, 0x38, - 0x38, 0xf4, 0x8e, 0xfb, 0x51, 0xfb, 0x10, 0x7c, 0x73, 0xb4, 0xee, 0xf9, - 0x76, 0xbb, 0x45, 0xec, 0x07, 0x24, 0x23, 0xa3, 0x38, 0x64, 0x39, 0x4c, - 0x03, 0x94, 0xf5, 0xee, 0x5f, 0xc9, 0x83, 0x4f, 0xd1, 0xa6, 0x4a, 0x05, - 0x25, 0x0c, 0x46, 0x33, 0xd4, 0x40, 0x47, 0xae, 0xec, 0xda, 0x30, 0xf9, - 0xe1, 0x28, 0xfb, 0xb1, 0x4c, 0x62, 0xfb, 0x6c, 0x90, 0x0d, 0xb1, 0xec, - 0xaf, 0x2d, 0x95, 0x64, 0x11, 0x93, 0xda, 0x8e, 0xb8, 0x7d, 0xe4, 0xa3, - 0x8e, 0xa6, 0x9b, 0xaa, 0x58, 0xd5, 0xdc, 0x59, 0x1a, 0x51, 0x53, 0x47, - 0x30, 0x1c, 0x2b, 0xb0, 0xbb, 0x57, 0x57, 0x0a, 0x8c, 0x5f, 0x62, 0x9c, - 0x52, 0x28, 0xc0, 0x25, 0x27, 0xae, 0xcd, 0x36, 0xbf, 0x2d, 0x03, 0xb1, - 0x33, 0xfd, 0x24, 0x81, 0x3c, 0x91, 0x43, 0x90, 0x0c, 0x20, 0xc4, 0xe3, - 0x69, 0x3f, 0xa9, 0xa2, 0x7c, 0xc2, 0x48, 0x28, 0x1b, 0xf0, 0x81, 0x1f, - 0x2b, 0x8f, 0x8d, 0x43, 0x38, 0x18, 0x12, 0xa3, 0x89, 0xf1, 0xd7, 0x60, - 0x89, 0x68, 0x6a, 0xc4, 0xcc, 0x5d, 0xf4, 0xce, 0x43, 0x95, 0x84, 0xcd, - 0x01, 0x55, 0xb8, 0x5d, 0x24, 0x50, 0xcd, 0xe3, 0x68, 0x1c, 0xff, 0x59, - 0x0d, 0xac, 0xcb, 0xe7, 0x9d, 0x68, 0x0f, 0x4a, 0xaf, 0xeb, 0xb5, 0xfb, - 0xf9, 0xb1, 0x58, 0x80, 0xd5, 0x71, 0x53, 0x26, 0x2e, 0x9c, 0xce, 0x10, - 0xac, 0xd2, 0x0a, 0xeb, 0xb4, 0x5c, 0xc8, 0xd7, 0x16, 0x26, 0x66, 0x71, - 0xdd, 0x67, 0xba, 0xdb, 0x35, 0x76, 0x64, 0xc6, 0x0b, 0x0b, 0x07, 0x4b, - 0x65, 0xa2, 0xf7, 0x68, 0x9e, 0xfe, 0xe8, 0xe3, 0xa7, 0x09, 0x79, 0xc5, - 0xdf, 0x5e, 0x9c, 0xec, 0xee, 0x83, 0x59, 0xb5, 0x89, 0x81, 0xa2, 0x87, - 0xd7, 0x75, 0x65, 0x90, 0xde, 0x78, 0x37, 0x59, 0x04, 0x9b, 0x50, 0xc3, - 0xba, 0x90, 0x09, 0x15, 0xab, 0x17, 0xc5, 0xbf, 0x5b, 0xb9, 0xe4, 0x6c, - 0xa9, 0xb1, 0x49, 0x76, 0x25, 0x74, 0x5d, 0x9c, 0x78, 0xc5, 0x09, 0xee, - 0xeb, 0xeb, 0x9d, 0x1c, 0x6c, 0xc0, 0x27, 0x9d, 0x66, 0xe6, 0x7f, 0x31, - 0xcd, 0xb0, 0x8a, 0xe4, 0x9e, 0xbd, 0x70, 0x18, 0x88, 0xa1, 0x08, 0x39, - 0xa2, 0x48, 0xa5, 0x98, 0xb6, 0xad, 0x10, 0x54, 0x07, 0xcd, 0xfc, 0x6d, - 0xb1, 0x02, 0xff, 0xe3, 0x92, 0xd7, 0x9d, 0x48, 0xfb, 0xce, 0x88, 0x46, - 0x92, 0x07, 0x02, 0xba, 0xee, 0xeb, 0xae, 0x88, 0xb1, 0x4e, 0xd0, 0xf2, - 0xce, 0xd7, 0x57, 0x07, 0xd4, 0x39, 0xd2, 0x7d, 0x1a, 0x0c, 0xef, 0xf2, - 0x84, 0x84, 0x22, 0x8a, 0xb1, 0x80, 0x0d, 0xdc, 0x64, 0x86, 0xfd, 0x70, - }; - - FfElementObj r12(&this->fq12); - FfElementObj fq12_exp[4]; - - // prepare data for test - for (m = 0; m < 4; m++) { - fq12_exp[m] = FfElementObj(&this->fq12, ff12e[m]); - // initialize data for test - p[m] = fq12_exp[m]; - b[m] = &bnm12[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq12, p, b, 4, r12)); - EXPECT_EQ(FfElementObj(&this->fq12, fq12_expected_result_str), r12) - << "FfSscmMultiExp: Finite field element does not match with reference " - "value"; -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenFiveExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[5]; - FfElement const* p[5]; - BigNumStr const* b[5]; - int m = 0; - const FqElemStr ffe[] = { - {0x7B, 0x26, 0x96, 0x84, 0x04, 0x0D, 0x6F, 0x10, 0xAA, 0x7F, 0xD0, 0x0C, - 0x41, 0x3A, 0x68, 0x48, 0xBF, 0x3D, 0xB5, 0xCE, 0x3A, 0x9C, 0xA9, 0x10, - 0xA4, 0x67, 0x7C, 0xC0, 0x41, 0x52, 0xCA, 0xE7}, - {0x2E, 0xD9, 0xEF, 0x86, 0xB6, 0x32, 0x72, 0x89, 0x37, 0xCF, 0x16, 0xCE, - 0x27, 0x15, 0x7A, 0x95, 0xCF, 0x94, 0x1B, 0xF3, 0xCE, 0x49, 0x20, 0x29, - 0x9A, 0x61, 0x2E, 0x0A, 0xF5, 0xE1, 0xDC, 0x9F}, - {0xE0, 0x19, 0x37, 0x44, 0xA7, 0x45, 0x49, 0x7E, 0x19, 0x02, 0x09, 0x78, - 0xBE, 0xA4, 0x65, 0x60, 0x7A, 0xF5, 0xC8, 0xAF, 0x97, 0x5E, 0xDA, 0x3A, - 0xB4, 0x16, 0x70, 0x31, 0xE3, 0xB4, 0x18, 0xA8}, - {0xBC, 0x92, 0x29, 0x92, 0x14, 0xD3, 0x3F, 0xB8, 0xB8, 0x8C, 0x41, 0xDF, - 0xC5, 0xA1, 0xCA, 0x77, 0xE5, 0x73, 0xFE, 0xA7, 0xAC, 0x81, 0x66, 0x11, - 0x5A, 0x6D, 0x7D, 0x97, 0x13, 0x92, 0x8D, 0x1D}, - {0xE1, 0xA0, 0x0D, 0xDC, 0x8F, 0x20, 0xF5, 0x2D, 0x1D, 0x1F, 0xBD, 0x24, - 0x8C, 0xC2, 0x26, 0x06, 0x89, 0xE9, 0x46, 0xA9, 0xD2, 0x44, 0x8F, 0x1A, - 0x8D, 0xAF, 0x20, 0x73, 0x60, 0x0B, 0x66, 0x9C}}; - - const BigNumStr bnm[] = { - {0x78, 0xE6, 0x3F, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD7, 0x6E, - 0xE9, 0xFF, 0x4F, 0xFF, 0x23, 0xFF, 0x67, 0xB4, 0xED, 0xEE, 0xD7, 0xC6, - 0xFF, 0x4B, 0x0B, 0x6F, 0x1F, 0xD6, 0xFD, 0x7F}, - {0xA1, 0x87, 0xFF, 0x1B, 0xFF, 0x85, 0x68, 0xFF, 0x1C, 0xFF, 0xD5, 0xFF, - 0x95, 0x73, 0xFF, 0xFF, 0xFF, 0x9E, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x5E, - 0x9E, 0x62, 0xFF, 0xFF, 0x97, 0xFF, 0xFF, 0xF3}, - {0x2E, 0xE8, 0x1E, 0x35, 0xFF, 0x82, 0x0B, 0x99, 0xEC, 0x30, 0x2B, 0xCE, - 0xEC, 0x83, 0x05, 0xFF, 0x9E, 0x3C, 0xFF, 0xFF, 0xA1, 0xFF, 0xFF, 0xFF, - 0x57, 0x26, 0x5B, 0x6C, 0xFF, 0xE6, 0x94, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0x79, 0xFC, 0xFF, 0x83, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xA9, 0xFF, 0x2F, 0x6B, 0xD1, 0xE7, 0xFF, 0xFF, - 0xFF, 0x7C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {0x63, 0x53, 0x53, 0xFF, 0xFF, 0xFF, 0x4F, 0xFF, 0xFF, 0xFF, 0x09, 0xFF, - 0xC0, 0xD8, 0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x45, - 0xFF, 0x3A, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x06}}; - - const FqElemStr res = { - 0x8F, 0x6D, 0x54, 0xCA, 0x00, 0x85, 0xD8, 0x78, 0xA4, 0x45, 0x36, - 0x7C, 0x23, 0xD0, 0x3C, 0x2D, 0x20, 0x78, 0xD9, 0xD7, 0xF1, 0xC3, - 0x99, 0xD9, 0xD3, 0x0A, 0x0E, 0x86, 0x98, 0xC2, 0xA7, 0x97, - }; - // prepare data for test - for (m = 0; m < 5; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 5, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; -} - -TEST_F(FfElementTest, SscmFfMultiExpWorksGivenSixExponents) { - FfElementObj r(&this->fq); - FfElementObj fq_exp[6]; - FfElement const* p[6]; - BigNumStr const* b[6]; - int m = 0; - const FqElemStr ffe[] = { - {0x75, 0x18, 0x6A, 0x3D, 0xCC, 0x76, 0x33, 0x92, 0xD0, 0x57, 0xDA, 0xE0, - 0x37, 0x6F, 0x71, 0xD5, 0x9E, 0x7E, 0x65, 0xED, 0xD7, 0xFD, 0x82, 0xC0, - 0x6C, 0x83, 0x60, 0x30, 0xC1, 0xD3, 0x3D, 0x4D}, - {0xF5, 0x3A, 0x20, 0xAB, 0x22, 0x47, 0x07, 0xAE, 0x71, 0xC1, 0x91, 0x73, - 0xEF, 0x1F, 0x1D, 0x76, 0x2E, 0xEE, 0x0D, 0xDE, 0xD9, 0xF8, 0x5C, 0x85, - 0xC7, 0x5B, 0x93, 0x88, 0xF6, 0xFF, 0x4C, 0xA5}, - {0x21, 0xB3, 0x5E, 0xE8, 0xD2, 0xDA, 0x14, 0x1C, 0xB5, 0x2C, 0xFC, 0x61, - 0x9D, 0xEB, 0x65, 0x87, 0xBB, 0x5B, 0xBC, 0xFD, 0x37, 0x54, 0x6B, 0xDC, - 0xD9, 0xFA, 0x7A, 0xCD, 0x18, 0x7E, 0x8B, 0x89}, - {0x70, 0xB7, 0x19, 0x42, 0xB4, 0x41, 0x2C, 0x1B, 0xBD, 0x7B, 0x25, 0x06, - 0xA2, 0x95, 0xB5, 0xB6, 0x70, 0xDF, 0x58, 0x71, 0xCA, 0x09, 0x12, 0x66, - 0x5A, 0x7B, 0xF0, 0x5F, 0x43, 0x69, 0x32, 0xF6}, - {0x3D, 0x57, 0xE8, 0x3F, 0x1E, 0x39, 0x2B, 0xE5, 0xD0, 0xCF, 0xA9, 0xC8, - 0x72, 0x10, 0x7F, 0xC5, 0x4F, 0xAE, 0xE9, 0x73, 0x28, 0x4C, 0xFC, 0x3F, - 0xD5, 0xFF, 0xE8, 0xCF, 0x2C, 0xEB, 0x33, 0xD3}, - {0x51, 0x80, 0x15, 0x1C, 0xE6, 0x9C, 0x4B, 0x80, 0x40, 0xBA, 0x40, 0x29, - 0x3A, 0x86, 0xA8, 0xB2, 0x66, 0x08, 0x97, 0x8D, 0xEB, 0x8B, 0xA7, 0x93, - 0xE3, 0x49, 0xC6, 0xC0, 0x46, 0x93, 0xC1, 0x75}}; - const BigNumStr bnm[] = { - {0xFF, 0xFF, 0xFF, 0x49, 0x50, 0xFF, 0x19, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, - 0xFF, 0x28, 0x4A, 0x0E, 0xFF, 0x74, 0xFF, 0xC7, 0xFF, 0xD9, 0x81, 0xFF, - 0xFF, 0xFF, 0xD5, 0x2C, 0xFF, 0xFF, 0xFF, 0xAE}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x0C, 0x03, 0xFF, 0x95, 0xFF, 0x11, 0x9D, 0xFF, 0x9B, 0xFF, 0xFF, - 0x68, 0x44, 0xFF, 0xC9, 0xFF, 0x10, 0xC7, 0xBF}, - {0x64, 0xFF, 0x89, 0x4A, 0xFF, 0x20, 0xFF, 0xE7, 0xFF, 0x36, 0x23, 0xDD, - 0xFF, 0xFF, 0xFC, 0xFF, 0x6B, 0xFF, 0xFF, 0xFF, 0xFF, 0x48, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xD3, 0x59, 0xBE}, - {0x0F, 0xFF, 0x76, 0xA5, 0x9E, 0x02, 0x9B, 0xFF, 0xA1, 0xFF, 0xC2, 0xFF, - 0x9D, 0xFF, 0x23, 0xFF, 0xFF, 0xFF, 0xFF, 0x6B, 0x81, 0x2A, 0xFF, 0x98, - 0xFF, 0xFF, 0xB9, 0xFF, 0xB7, 0x78, 0xE6, 0xFF}, - {0xAF, 0xF3, 0xFF, 0x3C, 0xA8, 0xFF, 0xB9, 0x3A, 0xFF, 0xFF, 0xFF, 0x70, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, 0x52, - 0xFF, 0x41, 0x10, 0x62, 0xFF, 0x51, 0x35, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xD3, 0xC3, 0xD9, 0xFF, 0xFF, 0x3A, 0x44, 0x88, - 0x04, 0xFF, 0x0B, 0xFF, 0xFF, 0xFF, 0x64, 0xFF, 0xFF, 0x52, 0xFF, 0x7D, - 0x6B, 0x24, 0x6E, 0xFF, 0xFF, 0xFF, 0xA7, 0x71}}; - const FqElemStr res = { - 0xFB, 0x89, 0x4F, 0xBB, 0x91, 0xEE, 0xD6, 0x57, 0x2D, 0x34, 0xF9, - 0x0B, 0xE3, 0xEB, 0x71, 0x1D, 0x63, 0x74, 0x96, 0x3B, 0xD4, 0x02, - 0x2F, 0x08, 0xDB, 0x95, 0x6A, 0x40, 0x68, 0xD4, 0x55, 0x76, - }; - // prepare data for test - for (m = 0; m < 6; m++) { - fq_exp[m] = FfElementObj(&this->fq, ffe[m]); - // initialize data for test - p[m] = fq_exp[m]; - b[m] = &bnm[m]; - } - // do test - EXPECT_EQ(kEpidNoErr, FfSscmMultiExp(this->fq, p, b, 6, r)); - EXPECT_EQ(FfElementObj(&this->fq, res), r) - << "FfSscmMultiExp: Finite field element does not " - "match with reference value"; -} -/////////////////////////////////////////////////////////////////////// -// FfGetRandom - -TEST_F(FfElementTest, FfGetRandomFailsGivenArgumentsMismatch) { - Prng my_prng; - EXPECT_EQ(kEpidBadArgErr, FfGetRandom(this->fq12, &this->bn_one_data, - &Prng::Generate, &my_prng, this->fq_r)); - EXPECT_EQ(kEpidBadArgErr, - FfGetRandom(this->fq, &this->bn_one_data, &Prng::Generate, &my_prng, - this->fq12_r)); -} - -TEST_F(FfElementTest, FfGetRandomFailsGivenNullPtr) { - Prng my_prng; - FfElementObj r(&this->fq); - EXPECT_EQ(kEpidBadArgErr, FfGetRandom(nullptr, &this->bn_one_data, - &Prng::Generate, &my_prng, r)); - EXPECT_EQ(kEpidBadArgErr, - FfGetRandom(this->fq, nullptr, &Prng::Generate, &my_prng, r)); - EXPECT_EQ(kEpidBadArgErr, - FfGetRandom(this->fq, &this->bn_one_data, nullptr, &my_prng, r)); - EXPECT_EQ(kEpidBadArgErr, FfGetRandom(this->fq, &this->bn_one_data, - &Prng::Generate, &my_prng, nullptr)); -} -TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq2) { - Prng my_prng; - FfElementObj r(&this->fq2); - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq2, &this->bn_one_data, - &Prng::Generate, &my_prng, r)); -} -TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq6) { - Prng my_prng; - FfElementObj r(&this->fq6); - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq6, &this->bn_one_data, - &Prng::Generate, &my_prng, r)); -} -TEST_F(FfElementTest, FfGetRandomSucceedsGivenFq12) { - Prng my_prng; - FfElementObj r(&this->fq12); - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq12, &this->bn_one_data, - &Prng::Generate, &my_prng, r)); -} - -TEST_F(FfElementTest, FfGetRandomSuccedsGivenLowBound) { - Prng my_prng; - FfElementObj r(&this->fq); - const BigNumStr bn_low_data1 = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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}; - const BigNumStr bn_low_data2 = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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}; - FqElemStr buf; - unsigned int result; - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_one_data, - &Prng::Generate, &my_prng, r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf))); - THROW_ON_EPIDERR(Cmp_OctStr256(&this->bn_one_data.data, &buf.data, &result)); - EXPECT_EQ(result, (unsigned int)2); - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_two_data, - &Prng::Generate, &my_prng, r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf))); - THROW_ON_EPIDERR(Cmp_OctStr256(&this->bn_two_data.data, &buf.data, &result)); - EXPECT_EQ(result, (unsigned int)2); - EXPECT_EQ(kEpidNoErr, - FfGetRandom(this->fq, &bn_low_data1, &Prng::Generate, &my_prng, r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf))); - THROW_ON_EPIDERR(Cmp_OctStr256(&bn_low_data1.data, &buf.data, &result)); - EXPECT_EQ(result, (unsigned int)2); - EXPECT_EQ(kEpidNoErr, - FfGetRandom(this->fq, &bn_low_data2, &Prng::Generate, &my_prng, r)); - THROW_ON_EPIDERR(WriteFfElement(this->fq, r, &buf, sizeof(buf))); - THROW_ON_EPIDERR(Cmp_OctStr256(&bn_low_data2.data, &buf.data, &result)); - EXPECT_EQ(result, (unsigned int)2); -} - -TEST_F(FfElementTest, FfGetRandomGeneratesDifferentNumbers) { - Prng my_prng; - FfElementObj r1(&this->fq); - FfElementObj r2(&this->fq); - bool result; - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_one_data, - &Prng::Generate, &my_prng, r1)); - EXPECT_EQ(kEpidNoErr, FfGetRandom(this->fq, &this->bn_one_data, - &Prng::Generate, &my_prng, r2)); - THROW_ON_EPIDERR(FfIsEqual(this->fq, r1, r2, &result)); - EXPECT_FALSE(result); -} -TEST_F(FfElementTest, FfGetRandomFailsOnMaxIterGivenLargeLowBound) { - Prng my_prng; - FfElementObj r(&this->fq); - // FfGetRandom generates random data between [low_bound, modulus-1] - // modulus in this case is Intel(R) EPID 2.0 parameter q - // giving low_bound = modulus - {0x30, 0x13} should get kEpidRandMaxIterErr - const BigNumStr bn_low_data = { - 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, 0x00, 0x00}; - EXPECT_EQ(kEpidRandMaxIterErr, - FfGetRandom(this->fq, &bn_low_data, &Prng::Generate, &my_prng, r)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/file_parser-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/file_parser-test.cc deleted file mode 100644 index 2291412239..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/file_parser-test.cc +++ /dev/null @@ -1,1199 +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 Issuer material file parsing unit tests. - */ -#include -#include - -#include "gtest/gtest.h" -extern "C" { -#include "epid/common/file_parser.h" -} - -namespace { - -/// Test fixture class for EpidFileParser -class EpidFileParser : public ::testing::Test { - public: - /// Cert used to sign legitimate test data - static const EpidCaCertificate kCert; - - /// A file with short GroupPublicKey signed with kCert - static const std::vector kGroupPublicKeyFile; - /// Expected short GroupPublicKey - static const std::vector kGroupPublicKey; - - /// A file with short privrl signed with cert - static const std::vector kShortPrivRlFile; - /// Expected short privrl - static const std::vector kShortPrivRl; - - /// A file with empty privrl signed with cert - static const std::vector kEmptyPrivRlFile; - - /// Expected empty privrl - static const std::vector kEmptyPrivRl; - - /// A file with empty SigRl signed with kCert - static const std::vector kEmptySigRlFile; - /// Expected empty SigRl - static const std::vector kEmptySigRl; - /// A file with short SigRl signed with kCert - static const std::vector kShortSigRlFile; - /// Expected short SigRl - static const std::vector kShortSigRl; - - /// A file with empty GroupRl signed with kCert - static const std::vector kEmptyGroupRlFile; - /// Expected empty GroupRl - static const std::vector kEmptyGroupRl; - /// A file with short GroupRl signed with kCert - static const std::vector kShortGroupRlFile; - /// Expected short GroupRl - static const std::vector kShortGroupRl; -}; - -const EpidCaCertificate EpidFileParser::kCert = { - 0x02, 0x00, 0x00, 0x11, 0x24, 0x42, 0xa5, 0xcc, 0x0e, 0xcd, 0x01, 0x5f, - 0xa3, 0xca, 0x31, 0xdc, 0x8e, 0x2b, 0xbc, 0x70, 0xbf, 0x42, 0xd6, 0x0c, - 0xbc, 0xa2, 0x00, 0x85, 0xe0, 0x82, 0x2c, 0xb0, 0x42, 0x35, 0xe9, 0x70, - 0x6f, 0xc9, 0x8b, 0xd7, 0xe5, 0x02, 0x11, 0xa4, 0xa2, 0x71, 0x02, 0xfa, - 0x35, 0x49, 0xdf, 0x79, 0xeb, 0xcb, 0x4b, 0xf2, 0x46, 0xb8, 0x09, 0x45, - 0xcd, 0xdf, 0xe7, 0xd5, 0x09, 0xbb, 0xfd, 0x7d, 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, 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, - 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, 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, 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, - 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, 0xfb, 0x57, 0x6f, 0x15, - 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, - 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, - 0xb9, 0x3a, 0x76, 0xe7, 0x94, 0x03, 0x1d, 0x90, 0x6b, 0x6f, 0xcd, 0x99, - 0xef, 0x2c, 0xdb, 0x8b, 0xa9, 0x8a, 0xef, 0x7e, 0xf0, 0x77, 0xba, 0xb5, - 0x11, 0x43, 0x0d, 0x28, 0x1c, 0x01, 0x5b, 0xc9, 0x08, 0xce, 0x3e, 0x68}; - -const std::vector EpidFileParser::kEmptySigRlFile = { - 0x02, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, - 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, - 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0x7d, 0x04, 0xa1, 0x29, 0x28, 0xc3, 0x4d, 0x30, 0x8d, 0x67, 0xe4, 0xe8, - 0x62, 0x71, 0xe8, 0x4f, 0x0d, 0x45, 0x46, 0xc9, 0xde, 0x67, 0x30, 0x47, - 0xb5, 0xfb, 0xb5, 0x66, 0xf5, 0x8f, 0x0d, 0xfb}; -const std::vector EpidFileParser::kEmptySigRl = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const std::vector EpidFileParser::kShortSigRlFile = { - 0x02, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x03, 0x92, 0xb0, 0x8b, 0x6d, 0x6b, 0xa4, 0x32, 0x4e, - 0xd1, 0x83, 0x26, 0x24, 0x73, 0x70, 0x80, 0xd3, 0x72, 0xe3, 0xab, 0xfe, - 0xbc, 0x86, 0x9f, 0x55, 0x9e, 0x56, 0x57, 0xa5, 0x1f, 0x06, 0x6c, 0x1b, - 0x2a, 0x55, 0xb6, 0xb2, 0x13, 0xe9, 0xe8, 0x88, 0x6c, 0xbd, 0xe7, 0xca, - 0x81, 0xcb, 0x92, 0x10, 0xa7, 0xef, 0xdc, 0x88, 0xf1, 0x7c, 0x91, 0x07, - 0xcc, 0xf0, 0x63, 0x39, 0xae, 0x5c, 0xb9, 0x78, 0xcd, 0x54, 0xdd, 0x98, - 0x3e, 0xa6, 0xc9, 0x2f, 0x83, 0x78, 0xc8, 0x64, 0xc9, 0x92, 0x41, 0x52, - 0xb9, 0xf9, 0x59, 0x91, 0x46, 0x89, 0x78, 0xda, 0xc3, 0x26, 0xdd, 0x9d, - 0x1f, 0x0c, 0x8e, 0xea, 0xba, 0xa8, 0xde, 0xa5, 0x33, 0x8c, 0x2e, 0xaa, - 0x0e, 0x2c, 0x13, 0x36, 0xb3, 0x7b, 0xa6, 0x12, 0x98, 0x0a, 0x13, 0x35, - 0xa3, 0x9e, 0x52, 0xaf, 0x43, 0xf4, 0x1c, 0x79, 0xcf, 0x46, 0xc6, 0xcd, - 0xc4, 0xc4, 0x0d, 0x19, 0xac, 0x77, 0xc7, 0x12, 0xcb, 0x22, 0x4a, 0x65, - 0xdb, 0x26, 0xcb, 0x1b, 0x27, 0xbf, 0x25, 0x6f, 0x47, 0xff, 0x2e, 0x59, - 0x11, 0x72, 0x0f, 0x42, 0x70, 0x64, 0xd0, 0x78, 0x6c, 0x09, 0xe6, 0xce, - 0xd4, 0xd9, 0x7b, 0x80, 0x9a, 0xe9, 0x3e, 0x8f, 0x73, 0x77, 0x84, 0x67, - 0x1f, 0xf2, 0x74, 0xbc, 0xcf, 0x9c, 0xb4, 0x58, 0xaa, 0xe2, 0x7b, 0x6f, - 0xb6, 0xfe, 0x9a, 0x40, 0x1e, 0x84, 0xab, 0x5f, 0xe8, 0x73, 0xc6, 0x87, - 0xcc, 0x9b, 0xb4, 0xf4, 0xd9, 0x5a, 0x9c, 0x2d, 0xea, 0xf3, 0x04, 0x9f, - 0xc3, 0xbf, 0x2a, 0xf2, 0x9d, 0xe5, 0x38, 0x2c, 0xf2, 0xcc, 0x46, 0xd9, - 0x3e, 0x52, 0xb2, 0x3e, 0x49, 0xf4, 0x08, 0x14, 0x10, 0x31, 0x9c, 0xeb, - 0x10, 0xe5, 0x26, 0xaa, 0x4d, 0x76, 0x12, 0xb2, 0xc3, 0x8e, 0x15, 0x4b, - 0x28, 0x51, 0xe9, 0x30, 0x00, 0x2c, 0x74, 0xb1, 0x33, 0x71, 0x1c, 0x19, - 0xb8, 0x6b, 0x5c, 0xde, 0x30, 0x4f, 0x36, 0x29, 0x29, 0xaf, 0x1d, 0x41, - 0xd1, 0xcd, 0xa0, 0x4f, 0xb2, 0x8c, 0xb7, 0x76, 0xc2, 0x60, 0xc8, 0xf7, - 0x72, 0x98, 0xe1, 0x75, 0x3c, 0xfb, 0xd7, 0x3c, 0x7c, 0x3a, 0x91, 0x92, - 0xb8, 0x83, 0x25, 0xf3, 0x3b, 0xa6, 0x64, 0x4f, 0xa7, 0x70, 0x68, 0x7c, - 0xcc, 0x47, 0xdb, 0xbc, 0x0f, 0x54, 0x36, 0x2d, 0xea, 0xde, 0x6f, 0x96, - 0xdc, 0xa9, 0xca, 0xa1, 0xb0, 0x80, 0x2e, 0xf8, 0x84, 0x12, 0x84, 0xf6, - 0xf7, 0x8c, 0xa3, 0x45, 0xee, 0x87, 0x59, 0xd9, 0x88, 0xa4, 0xbd, 0x1f, - 0x0a, 0x41, 0xd7, 0x17, 0x42, 0xc2, 0x8f, 0x46, 0x40, 0xa9, 0x3d, 0x00, - 0x99, 0xb4, 0x1d, 0x8f, 0xea, 0xac, 0x86, 0xc1, 0x06, 0x03, 0x02, 0x74, - 0x85, 0x78, 0xe6, 0xc3, 0x4b, 0xc1, 0x60, 0x1b, 0xf5, 0xb1, 0xda, 0xd6, - 0x03, 0x75, 0xad, 0xd1, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, - 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, - 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0xcb, 0x1d, 0x80, 0xda, 0x3d, 0xd1, 0x68, 0x14, 0x90, 0xa6, 0x4a, 0x33, - 0x16, 0x7c, 0x82, 0x86, 0xfb, 0xfa, 0x46, 0x14, 0x51, 0xef, 0xa5, 0x80, - 0x1d, 0x97, 0x0a, 0xb6, 0x9d, 0x77, 0x69, 0x6c}; -const std::vector EpidFileParser::kShortSigRl = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x92, 0xb0, 0x8b, 0x6d, 0x6b, 0xa4, 0x32, 0x4e, 0xd1, 0x83, 0x26, 0x24, - 0x73, 0x70, 0x80, 0xd3, 0x72, 0xe3, 0xab, 0xfe, 0xbc, 0x86, 0x9f, 0x55, - 0x9e, 0x56, 0x57, 0xa5, 0x1f, 0x06, 0x6c, 0x1b, 0x2a, 0x55, 0xb6, 0xb2, - 0x13, 0xe9, 0xe8, 0x88, 0x6c, 0xbd, 0xe7, 0xca, 0x81, 0xcb, 0x92, 0x10, - 0xa7, 0xef, 0xdc, 0x88, 0xf1, 0x7c, 0x91, 0x07, 0xcc, 0xf0, 0x63, 0x39, - 0xae, 0x5c, 0xb9, 0x78, 0xcd, 0x54, 0xdd, 0x98, 0x3e, 0xa6, 0xc9, 0x2f, - 0x83, 0x78, 0xc8, 0x64, 0xc9, 0x92, 0x41, 0x52, 0xb9, 0xf9, 0x59, 0x91, - 0x46, 0x89, 0x78, 0xda, 0xc3, 0x26, 0xdd, 0x9d, 0x1f, 0x0c, 0x8e, 0xea, - 0xba, 0xa8, 0xde, 0xa5, 0x33, 0x8c, 0x2e, 0xaa, 0x0e, 0x2c, 0x13, 0x36, - 0xb3, 0x7b, 0xa6, 0x12, 0x98, 0x0a, 0x13, 0x35, 0xa3, 0x9e, 0x52, 0xaf, - 0x43, 0xf4, 0x1c, 0x79, 0xcf, 0x46, 0xc6, 0xcd, 0xc4, 0xc4, 0x0d, 0x19, - 0xac, 0x77, 0xc7, 0x12, 0xcb, 0x22, 0x4a, 0x65, 0xdb, 0x26, 0xcb, 0x1b, - 0x27, 0xbf, 0x25, 0x6f, 0x47, 0xff, 0x2e, 0x59, 0x11, 0x72, 0x0f, 0x42, - 0x70, 0x64, 0xd0, 0x78, 0x6c, 0x09, 0xe6, 0xce, 0xd4, 0xd9, 0x7b, 0x80, - 0x9a, 0xe9, 0x3e, 0x8f, 0x73, 0x77, 0x84, 0x67, 0x1f, 0xf2, 0x74, 0xbc, - 0xcf, 0x9c, 0xb4, 0x58, 0xaa, 0xe2, 0x7b, 0x6f, 0xb6, 0xfe, 0x9a, 0x40, - 0x1e, 0x84, 0xab, 0x5f, 0xe8, 0x73, 0xc6, 0x87, 0xcc, 0x9b, 0xb4, 0xf4, - 0xd9, 0x5a, 0x9c, 0x2d, 0xea, 0xf3, 0x04, 0x9f, 0xc3, 0xbf, 0x2a, 0xf2, - 0x9d, 0xe5, 0x38, 0x2c, 0xf2, 0xcc, 0x46, 0xd9, 0x3e, 0x52, 0xb2, 0x3e, - 0x49, 0xf4, 0x08, 0x14, 0x10, 0x31, 0x9c, 0xeb, 0x10, 0xe5, 0x26, 0xaa, - 0x4d, 0x76, 0x12, 0xb2, 0xc3, 0x8e, 0x15, 0x4b, 0x28, 0x51, 0xe9, 0x30, - 0x00, 0x2c, 0x74, 0xb1, 0x33, 0x71, 0x1c, 0x19, 0xb8, 0x6b, 0x5c, 0xde, - 0x30, 0x4f, 0x36, 0x29, 0x29, 0xaf, 0x1d, 0x41, 0xd1, 0xcd, 0xa0, 0x4f, - 0xb2, 0x8c, 0xb7, 0x76, 0xc2, 0x60, 0xc8, 0xf7, 0x72, 0x98, 0xe1, 0x75, - 0x3c, 0xfb, 0xd7, 0x3c, 0x7c, 0x3a, 0x91, 0x92, 0xb8, 0x83, 0x25, 0xf3, - 0x3b, 0xa6, 0x64, 0x4f, 0xa7, 0x70, 0x68, 0x7c, 0xcc, 0x47, 0xdb, 0xbc, - 0x0f, 0x54, 0x36, 0x2d, 0xea, 0xde, 0x6f, 0x96, 0xdc, 0xa9, 0xca, 0xa1, - 0xb0, 0x80, 0x2e, 0xf8, 0x84, 0x12, 0x84, 0xf6, 0xf7, 0x8c, 0xa3, 0x45, - 0xee, 0x87, 0x59, 0xd9, 0x88, 0xa4, 0xbd, 0x1f, 0x0a, 0x41, 0xd7, 0x17, - 0x42, 0xc2, 0x8f, 0x46, 0x40, 0xa9, 0x3d, 0x00, 0x99, 0xb4, 0x1d, 0x8f, - 0xea, 0xac, 0x86, 0xc1, 0x06, 0x03, 0x02, 0x74, 0x85, 0x78, 0xe6, 0xc3, - 0x4b, 0xc1, 0x60, 0x1b, 0xf5, 0xb1, 0xda, 0xd6, 0x03, 0x75, 0xad, 0xd1}; - -const std::vector EpidFileParser::kEmptyPrivRlFile = { - 0x02, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, - 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, - 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0x47, 0x18, 0x86, 0x03, 0xfe, 0x8a, 0xb8, 0x4a, 0x9c, 0xb6, 0xcd, 0x8b, - 0x1f, 0x68, 0x1c, 0x61, 0x4c, 0xa2, 0x30, 0x95, 0xec, 0x76, 0xc4, 0xa7, - 0x00, 0x6c, 0x6e, 0x3c, 0xc6, 0xf9, 0x32, 0xfc}; - -const std::vector EpidFileParser::kEmptyPrivRl = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -const std::vector EpidFileParser::kShortPrivRlFile = { - 0x02, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x03, 0x3a, 0x03, 0xb4, 0x95, 0xd3, 0x86, 0xf7, 0xb9, - 0x7e, 0x88, 0x79, 0xd8, 0xce, 0x30, 0x44, 0xf3, 0x35, 0xed, 0x0c, 0xb1, - 0x80, 0x67, 0xeb, 0x1b, 0x24, 0x7f, 0xe0, 0x0c, 0xc7, 0xe8, 0xae, 0x54, - 0xd1, 0xcd, 0x66, 0x2b, 0x11, 0x4e, 0x04, 0x9c, 0xe9, 0x1f, 0xac, 0xb5, - 0xdd, 0x74, 0xa4, 0x9f, 0x8e, 0x66, 0x31, 0x4c, 0xde, 0xb2, 0x11, 0x25, - 0xcc, 0x8e, 0xee, 0x1e, 0xa2, 0x89, 0x1a, 0xae, 0x7a, 0x98, 0x8e, 0x0a, - 0xd7, 0x01, 0xc4, 0xd3, 0x49, 0xb8, 0x56, 0x9a, 0x7b, 0xf4, 0xab, 0x52, - 0xb1, 0x1a, 0x84, 0xbd, 0x96, 0xd9, 0x17, 0xb0, 0xe9, 0x38, 0xff, 0xc7, - 0x7a, 0x50, 0x0c, 0x8a, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, - 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, - 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0x1c, 0xfb, 0xad, 0x9f, 0x47, 0x4d, 0x46, 0x53, 0x18, 0x05, 0x51, 0x04, - 0x31, 0x90, 0x95, 0x33, 0x57, 0xc0, 0x19, 0x64, 0x80, 0xbf, 0x23, 0x4c, - 0x92, 0xb6, 0x52, 0xd2, 0xd0, 0x05, 0xbe, 0x58}; - -const std::vector EpidFileParser::kShortPrivRl = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x3a, 0x03, 0xb4, 0x95, 0xd3, 0x86, 0xf7, 0xb9, 0x7e, 0x88, 0x79, 0xd8, - 0xce, 0x30, 0x44, 0xf3, 0x35, 0xed, 0x0c, 0xb1, 0x80, 0x67, 0xeb, 0x1b, - 0x24, 0x7f, 0xe0, 0x0c, 0xc7, 0xe8, 0xae, 0x54, 0xd1, 0xcd, 0x66, 0x2b, - 0x11, 0x4e, 0x04, 0x9c, 0xe9, 0x1f, 0xac, 0xb5, 0xdd, 0x74, 0xa4, 0x9f, - 0x8e, 0x66, 0x31, 0x4c, 0xde, 0xb2, 0x11, 0x25, 0xcc, 0x8e, 0xee, 0x1e, - 0xa2, 0x89, 0x1a, 0xae, 0x7a, 0x98, 0x8e, 0x0a, 0xd7, 0x01, 0xc4, 0xd3, - 0x49, 0xb8, 0x56, 0x9a, 0x7b, 0xf4, 0xab, 0x52, 0xb1, 0x1a, 0x84, 0xbd, - 0x96, 0xd9, 0x17, 0xb0, 0xe9, 0x38, 0xff, 0xc7, 0x7a, 0x50, 0x0c, 0x8a}; - -const std::vector EpidFileParser::kGroupPublicKeyFile = { - 0x02, 0x00, 0x00, 0x0c, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x89, 0x33, 0xa7, 0x86, - 0xd7, 0x71, 0xcc, 0x80, 0x46, 0x4b, 0x42, 0xc3, 0xe7, 0xba, 0x1a, 0x54, - 0x85, 0x8a, 0x21, 0x8e, 0x29, 0x91, 0xa9, 0x60, 0x41, 0xf9, 0xa5, 0xd9, - 0x7b, 0x5f, 0x54, 0x49, 0x2a, 0x89, 0x8c, 0x10, 0x0e, 0x26, 0x0d, 0xe8, - 0x36, 0x6a, 0x9e, 0x6f, 0x79, 0xff, 0xf1, 0xcd, 0xa7, 0xcd, 0xac, 0x1f, - 0x92, 0x33, 0x3a, 0xd9, 0x7c, 0xf5, 0xcd, 0x38, 0x48, 0x01, 0x4f, 0xc5, - 0x6f, 0xea, 0x50, 0x60, 0x59, 0x09, 0xda, 0x44, 0x21, 0xc2, 0xd0, 0x86, - 0xe6, 0x00, 0x63, 0x59, 0xa9, 0xfb, 0x35, 0x13, 0x4e, 0x13, 0xb1, 0x47, - 0x36, 0xd7, 0xbd, 0xf6, 0x0a, 0x35, 0x74, 0x7d, 0x36, 0xc5, 0x67, 0xa2, - 0x03, 0xb7, 0x38, 0x31, 0x16, 0xa8, 0x5d, 0x64, 0x3f, 0xe6, 0xf1, 0x94, - 0x37, 0x09, 0x8c, 0x20, 0x17, 0xac, 0x2f, 0x55, 0x9e, 0xed, 0xb3, 0xc7, - 0x73, 0xc0, 0x1c, 0xbb, 0xbf, 0xf7, 0x18, 0xce, 0x4f, 0xd4, 0xe3, 0x67, - 0x75, 0xe4, 0xd9, 0x51, 0xfb, 0x1b, 0x22, 0xf9, 0x72, 0x2e, 0xc1, 0x76, - 0x2a, 0xe1, 0x4a, 0x6e, 0x88, 0xd6, 0x2d, 0x71, 0xf4, 0xc4, 0x6d, 0xac, - 0x8c, 0xbd, 0xe7, 0x2b, 0xb1, 0x40, 0x15, 0x93, 0xbd, 0x97, 0xd4, 0x84, - 0x90, 0xef, 0x4e, 0xfd, 0x78, 0x25, 0xab, 0xdf, 0x16, 0xf3, 0x46, 0x52, - 0x16, 0x96, 0xae, 0x50, 0x88, 0x96, 0x18, 0x73, 0xc1, 0xd1, 0x73, 0xf0, - 0x67, 0xc8, 0x8d, 0xbb, 0x4e, 0xbc, 0x6a, 0x40, 0xe6, 0x1e, 0x7d, 0x36, - 0x8c, 0xf4, 0xb1, 0xf1, 0x5f, 0x26, 0x4f, 0x43, 0x0a, 0x36, 0xd4, 0x67, - 0xd4, 0x79, 0x3f, 0xb8, 0x69, 0x6f, 0x9c, 0x33, 0xd3, 0xdb, 0xc6, 0xce, - 0x42, 0xe3, 0x46, 0x87, 0xd6, 0x65, 0xac, 0xc9, 0x71, 0xf1, 0xa9, 0x8f, - 0x78, 0x45, 0x9a, 0xef, 0x1c, 0xe4, 0x45, 0x84, 0x3d, 0x8a, 0x27, 0x51, - 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a, - 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06, - 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x58, 0x2a, 0xf6, 0x06, - 0xed, 0x55, 0xd6, 0x86, 0x4f, 0x99, 0x57, 0x9e, 0x8c, 0xfc, 0xea, 0x5e, - 0x7d, 0xc3, 0x41, 0xa2, 0x51, 0x19, 0x47, 0x4b, 0x56, 0x4e, 0x46, 0x3e, - 0xca, 0xd3, 0xb5, 0x89}; -const std::vector EpidFileParser::kGroupPublicKey = { - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff, 0xee, 0xdd, 0xcc, - 0xbb, 0xaa, 0x99, 0x88, 0x89, 0x33, 0xa7, 0x86, 0xd7, 0x71, 0xcc, 0x80, - 0x46, 0x4b, 0x42, 0xc3, 0xe7, 0xba, 0x1a, 0x54, 0x85, 0x8a, 0x21, 0x8e, - 0x29, 0x91, 0xa9, 0x60, 0x41, 0xf9, 0xa5, 0xd9, 0x7b, 0x5f, 0x54, 0x49, - 0x2a, 0x89, 0x8c, 0x10, 0x0e, 0x26, 0x0d, 0xe8, 0x36, 0x6a, 0x9e, 0x6f, - 0x79, 0xff, 0xf1, 0xcd, 0xa7, 0xcd, 0xac, 0x1f, 0x92, 0x33, 0x3a, 0xd9, - 0x7c, 0xf5, 0xcd, 0x38, 0x48, 0x01, 0x4f, 0xc5, 0x6f, 0xea, 0x50, 0x60, - 0x59, 0x09, 0xda, 0x44, 0x21, 0xc2, 0xd0, 0x86, 0xe6, 0x00, 0x63, 0x59, - 0xa9, 0xfb, 0x35, 0x13, 0x4e, 0x13, 0xb1, 0x47, 0x36, 0xd7, 0xbd, 0xf6, - 0x0a, 0x35, 0x74, 0x7d, 0x36, 0xc5, 0x67, 0xa2, 0x03, 0xb7, 0x38, 0x31, - 0x16, 0xa8, 0x5d, 0x64, 0x3f, 0xe6, 0xf1, 0x94, 0x37, 0x09, 0x8c, 0x20, - 0x17, 0xac, 0x2f, 0x55, 0x9e, 0xed, 0xb3, 0xc7, 0x73, 0xc0, 0x1c, 0xbb, - 0xbf, 0xf7, 0x18, 0xce, 0x4f, 0xd4, 0xe3, 0x67, 0x75, 0xe4, 0xd9, 0x51, - 0xfb, 0x1b, 0x22, 0xf9, 0x72, 0x2e, 0xc1, 0x76, 0x2a, 0xe1, 0x4a, 0x6e, - 0x88, 0xd6, 0x2d, 0x71, 0xf4, 0xc4, 0x6d, 0xac, 0x8c, 0xbd, 0xe7, 0x2b, - 0xb1, 0x40, 0x15, 0x93, 0xbd, 0x97, 0xd4, 0x84, 0x90, 0xef, 0x4e, 0xfd, - 0x78, 0x25, 0xab, 0xdf, 0x16, 0xf3, 0x46, 0x52, 0x16, 0x96, 0xae, 0x50, - 0x88, 0x96, 0x18, 0x73, 0xc1, 0xd1, 0x73, 0xf0, 0x67, 0xc8, 0x8d, 0xbb, - 0x4e, 0xbc, 0x6a, 0x40, 0xe6, 0x1e, 0x7d, 0x36, 0x8c, 0xf4, 0xb1, 0xf1, - 0x5f, 0x26, 0x4f, 0x43, 0x0a, 0x36, 0xd4, 0x67, 0xd4, 0x79, 0x3f, 0xb8, - 0x69, 0x6f, 0x9c, 0x33, 0xd3, 0xdb, 0xc6, 0xce, 0x42, 0xe3, 0x46, 0x87, - 0xd6, 0x65, 0xac, 0xc9, 0x71, 0xf1, 0xa9, 0x8f, 0x78, 0x45, 0x9a, 0xef, - 0x1c, 0xe4, 0x45, 0x84, 0x3d, 0x8a, 0x27, 0x51}; -const std::vector EpidFileParser::kEmptyGroupRlFile = { - 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, - 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, - 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0x30, 0x9f, 0x8c, 0xae, 0x9b, 0x2a, 0xab, 0xcf, 0xb9, 0x85, 0x6f, - 0x16, 0x21, 0x92, 0xb8, 0x9a, 0x31, 0x2c, 0xb8, 0x04, 0x20, 0xc8, - 0x2a, 0x98, 0x8f, 0xd5, 0xaf, 0xc7, 0x27, 0xe5, 0x04, 0x0c}; -const std::vector EpidFileParser::kEmptyGroupRl = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const std::vector EpidFileParser::kShortGroupRlFile = { - 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9a, 0xbc, 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, - 0x51, 0x71, 0xed, 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, - 0x70, 0x2a, 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, - 0x09, 0x15, 0x86, 0xd7, 0x24, 0x47, 0xfc, 0x1e, 0x44, 0xc0, 0xfb, 0x9e, - 0x4f, 0xe4, 0x92, 0x85, 0x79, 0x94, 0x9c, 0x80, 0xd1, 0xa1, 0x66, 0x34, - 0x79, 0xb6, 0xb3, 0x3b, 0x66, 0xad, 0x2e, 0x40}; -const std::vector EpidFileParser::kShortGroupRl = { - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xbc}; - -////////////////////////////////////////////////////////////////////////// -// EpidParseGroupPubKeyFile Tests -TEST_F(EpidFileParser, GroupPubKeyParseFailsGivenNullParameters) { - GroupPubKey pubkey; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile(nullptr, this->kGroupPublicKeyFile.size(), - &this->kCert, &pubkey)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), nullptr, - &pubkey)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &this->kCert, nullptr)); -} - -TEST_F(EpidFileParser, GroupPubKeyParseFailsGivenUnsupportedCurve) { - GroupPubKey pubkey; - EpidCaCertificate unsupported_curve1(this->kCert); - unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve1, &pubkey)); - EpidCaCertificate unsupported_curve2(this->kCert); - unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve2, &pubkey)); - EpidCaCertificate unsupported_curve3(this->kCert); - unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve3, &pubkey)); - EpidCaCertificate unsupported_curve4(this->kCert); - unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve4, &pubkey)); - EpidCaCertificate unsupported_curve5(this->kCert); - unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve5, &pubkey)); - EpidCaCertificate unsupported_curve6(this->kCert); - unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &unsupported_curve6, &pubkey)); -} - -TEST_F(EpidFileParser, GroupPubKeyParseFailsGivenInvalidKeyInCertificate) { - GroupPubKey pubkey; - EpidCaCertificate invalid_key_qx(this->kCert); - invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &invalid_key_qx, &pubkey)); - EpidCaCertificate invalid_key_qy(this->kCert); - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] = - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &invalid_key_qy, &pubkey)); - EpidCaCertificate invalid_key_qx_qy(this->kCert); - invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF; - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] = - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^ - 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), - &invalid_key_qx_qy, &pubkey)); -} - -TEST_F(EpidFileParser, RejectsGroupPubKeyFileWithInvalidSize) { - GroupPubKey pubkey; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), 0, - &this->kCert, &pubkey)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size() - 1, - &this->kCert, &pubkey)); -} - -TEST_F(EpidFileParser, RejectsInvalidGroupPubKeyFileType) { - GroupPubKey pubkey; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)this->kShortPrivRlFile.data(), - this->kGroupPublicKeyFile.size(), - &this->kCert, &pubkey)); -} - -TEST_F(EpidFileParser, RejectsGroupPubKeyFileWithUnsupportedEpidVersion) { - GroupPubKey pubkey; - - std::vector unsupported_epidver_file(this->kGroupPublicKeyFile); - unsupported_epidver_file[0] = {0x01}; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupPubKeyFile((void*)unsupported_epidver_file.data(), - unsupported_epidver_file.size(), - &this->kCert, &pubkey)); -} - -TEST_F(EpidFileParser, ParsesValidPubKeyFile) { - std::vector pubkey(sizeof(GroupPubKey), 0); - EXPECT_EQ(kEpidNoErr, EpidParseGroupPubKeyFile( - (void*)this->kGroupPublicKeyFile.data(), - this->kGroupPublicKeyFile.size(), &this->kCert, - (GroupPubKey*)pubkey.data())); - EXPECT_EQ(this->kGroupPublicKey, pubkey); -} - -TEST_F(EpidFileParser, RejectsGroupPubKeyFileWithInvalidSignature) { - GroupPubKey pubkey; - std::vector pubkey_inv_sign(this->kGroupPublicKeyFile); - pubkey_inv_sign[pubkey_inv_sign.size() - 1] = - pubkey_inv_sign[pubkey_inv_sign.size() - 1] ^ 0xFF; - EXPECT_EQ( - kEpidSigInvalid, - EpidParseGroupPubKeyFile((void*)pubkey_inv_sign.data(), - pubkey_inv_sign.size(), &this->kCert, &pubkey)); -} - -////////////////////////////////////////////////////////////////////////// -// EpidParsePrivRlFile Tests -TEST_F(EpidFileParser, PrivRlParseProvidesRequiredLenWithNullDest) { - size_t rl_len = 0; - EXPECT_EQ(kEpidNoErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - nullptr, &rl_len)); - EXPECT_EQ(this->kShortPrivRl.size(), rl_len); -} - -TEST_F(EpidFileParser, PrivRlParseFailsGivenNullParameters) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - - // null input buffer - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile(nullptr, this->kShortPrivRlFile.size(), - &this->kCert, (PrivRl*)rl.data(), &rl_len)); - // null cert - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), nullptr, - (PrivRl*)rl.data(), &rl_len)); - // null rl_length - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (PrivRl*)rl.data(), nullptr)); -} - -TEST_F(EpidFileParser, PrivRlParseFailsGivenUnsupportedCurve) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - EpidCaCertificate unsupported_curve(kCert); - unsupported_curve.a.data[0] = unsupported_curve.a.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve, - (PrivRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve2(kCert); - unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve2, - (PrivRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve3(kCert); - unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve3, - (PrivRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve4(kCert); - unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve4, - (PrivRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve5(kCert); - unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve5, - (PrivRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve6(kCert); - unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF; - - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &unsupported_curve6, - (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, PrivRlParseFailsGivenInvalidKeyInCertificate) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - EpidCaCertificate invalid_key_qx(kCert); - invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF; - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &invalid_key_qx, - (PrivRl*)rl.data(), &rl_len)); - - EpidCaCertificate invalid_key_qy(kCert); - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] = - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF; - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &invalid_key_qy, - (PrivRl*)rl.data(), &rl_len)); - - EpidCaCertificate invalid_key_qx_qy(kCert); - invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF; - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] = - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &invalid_key_qx_qy, - (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsPrivRlFileWithInvalidSize) { - size_t rl_len = this->kEmptyPrivRl.size(); - std::vector rl(rl_len); - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kEmptyPrivRlFile.data(), - this->kEmptyPrivRlFile.size() - 1, &this->kCert, - (PrivRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kEmptyPrivRlFile.data(), 0, - &this->kCert, (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsInvalidPrivRlFileType) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsPrivRlFileWithUnsupportedEpidVersion) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - - std::vector unsupported_epidver_file(this->kShortPrivRlFile); - unsupported_epidver_file[0] = {0x01}; - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)unsupported_epidver_file.data(), - unsupported_epidver_file.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ParsesEmptyPrivRl) { - size_t rl_len = this->kEmptyPrivRl.size(); - std::vector rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParsePrivRlFile((void*)this->kEmptyPrivRlFile.data(), - this->kEmptyPrivRlFile.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); - EXPECT_EQ(this->kEmptyPrivRl, rl); -} - -TEST_F(EpidFileParser, ParsesShortPrivRl) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); - EXPECT_EQ(this->kShortPrivRl, rl); -} - -TEST_F(EpidFileParser, ParsesLongPrivRl) { - EcdsaSignature signature = { - 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, - 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, - 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x02, - 0xd7, 0x14, 0x3e, 0xce, 0x36, 0x24, 0xb2, 0xe5, 0x14, 0x94, 0x17, - 0xdf, 0x8d, 0x0f, 0xda, 0xff, 0x8c, 0xb9, 0x7f, 0xb6, 0x05, 0x09, - 0x08, 0x80, 0xb0, 0xb8, 0x45, 0x92, 0x15, 0xb6, 0x08, - }; - - std::vector long_privrl_file = {// Intel(R) EPID Version - 0x02, 0x00, - // File Type - 0x00, 0x0d, - // Group ID - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2a, - // Revocation list version number - 0x00, 0x00, 0x00, 0x00, - // Number of entries - 0x00, 0x00, 0x00, 0x32}; - const std::vector FToCreateLongRl = { - 0x8a, 0xdc, 0xc0, 0xc8, 0xcd, 0x29, 0x9e, 0x08, 0x9e, 0x4e, 0x0d, - 0xa7, 0xf6, 0x46, 0xee, 0x80, 0xca, 0x91, 0x86, 0x54, 0x3c, 0x7f, - 0x8d, 0xb5, 0x49, 0xf9, 0x6d, 0x00, 0x39, 0x39, 0x62, 0xc7, - }; - for (int i = 0; i < 50; ++i) { - for (auto it : FToCreateLongRl) { - long_privrl_file.push_back(it); - } - } - for (auto it : signature.x.data) { - long_privrl_file.push_back(it); - } - for (auto it : signature.y.data) { - long_privrl_file.push_back(it); - } - size_t rl_len = long_privrl_file.size() - 68; - std::vector rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParsePrivRlFile((void*)long_privrl_file.data(), - long_privrl_file.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); - EXPECT_EQ( - std::vector(&long_privrl_file[4], - &long_privrl_file[long_privrl_file.size() - 64]), - rl); -} - -TEST_F(EpidFileParser, RejectsPrivRlFileWithInvalidSignature) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - std::vector privrl_inv_sign(kShortPrivRlFile); - privrl_inv_sign[privrl_inv_sign.size() - 1] = - privrl_inv_sign[privrl_inv_sign.size() - 1] ^ 0xFF; - - EXPECT_EQ(kEpidSigInvalid, - EpidParsePrivRlFile(privrl_inv_sign.data(), privrl_inv_sign.size(), - &this->kCert, (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, PrivRlParseRejectsBufWithInsufficientSize) { - size_t rl_len = this->kShortPrivRl.size() - 1; - std::vector rl(rl_len); - - EXPECT_EQ(kEpidBadArgErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (PrivRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ReturnsProperSizeGivenOversizedPrivRlBuf) { - size_t rl_len = this->kShortPrivRl.size() + 1; - std::vector oversized_rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParsePrivRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (PrivRl*)oversized_rl.data(), &rl_len)); - std::vector rl(oversized_rl.begin(), oversized_rl.end() - 1); - EXPECT_EQ(this->kShortPrivRl, rl); - EXPECT_EQ(this->kShortPrivRl.size(), rl_len); -} - -////////////////////////////////////////////////////////////////////////// -// EpidParseSigRlFile Tests -TEST_F(EpidFileParser, SigRlParseProvidesRequiredLenWithNullDest) { - size_t rl_len = 0; - EXPECT_EQ(kEpidNoErr, EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &kCert, - nullptr, &rl_len)); - EXPECT_EQ(rl_len, this->kShortSigRl.size()); -} - -TEST_F(EpidFileParser, SigRlParseFailsGivenNullParameters) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile(nullptr, this->kShortSigRlFile.size(), &kCert, - (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), nullptr, - (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &kCert, - (SigRl*)rl.data(), nullptr)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &kCert, nullptr, - nullptr)); -} - -TEST_F(EpidFileParser, SigRlParseFailsGivenUnsupportedCurve) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - EpidCaCertificate unsupported_curve1(kCert); - unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve1, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve2(kCert); - unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve2, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve3(kCert); - unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve3, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve4(kCert); - unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve4, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve5(kCert); - unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve5, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve6(kCert); - unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &unsupported_curve6, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, SigRlParseFailsGivenInvalidKeyInCertificate) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - EpidCaCertificate invalid_key_qx(kCert); - invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &invalid_key_qx, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate invalid_key_qy(kCert); - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] = - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &invalid_key_qy, - (SigRl*)rl.data(), &rl_len)); - EpidCaCertificate invalid_key_qx_qy(kCert); - invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF; - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] = - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^ - 0xFF; - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &invalid_key_qx_qy, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsSigRlFileWithInvalidSize) { - size_t rl_len = this->kEmptySigRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kEmptySigRlFile.data(), 0, - &this->kCert, (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kEmptySigRlFile.data(), - this->kEmptySigRlFile.size() - 1, &this->kCert, - (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kEmptySigRlFile.size() + 1, &this->kCert, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, SigRlParseRejectsInvalidSigRlFileType) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsSigRlFileWithUnsupportedEpidVersion) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - std::vector unsupported_epidver_file(this->kShortSigRlFile); - unsupported_epidver_file[0] = {0x01}; - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)unsupported_epidver_file.data(), - unsupported_epidver_file.size(), &this->kCert, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ParsesEmptySigRl) { - size_t rl_len = this->kEmptySigRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, - EpidParseSigRlFile(this->kEmptySigRlFile.data(), - this->kEmptySigRlFile.size(), &this->kCert, - (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(rl, this->kEmptySigRl); -} - -TEST_F(EpidFileParser, ParsesShortSigRl) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, - EpidParseSigRlFile(this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &this->kCert, - (SigRl*)rl.data(), &rl_len)); - EXPECT_EQ(rl, this->kShortSigRl); -} - -TEST_F(EpidFileParser, ParsesLongSigRl) { - std::vector b = { - 0x92, 0xb0, 0x8b, 0x6d, 0x6b, 0xa4, 0x32, 0x4e, 0xd1, 0x83, 0x26, 0x24, - 0x73, 0x70, 0x80, 0xd3, 0x72, 0xe3, 0xab, 0xfe, 0xbc, 0x86, 0x9f, 0x55, - 0x9e, 0x56, 0x57, 0xa5, 0x1f, 0x06, 0x6c, 0x1b, 0x2a, 0x55, 0xb6, 0xb2, - 0x13, 0xe9, 0xe8, 0x88, 0x6c, 0xbd, 0xe7, 0xca, 0x81, 0xcb, 0x92, 0x10, - 0xa7, 0xef, 0xdc, 0x88, 0xf1, 0x7c, 0x91, 0x07, 0xcc, 0xf0, 0x63, 0x39, - 0xae, 0x5c, 0xb9, 0x78, 0xcd, 0x54, 0xdd, 0x98, 0x3e, 0xa6, 0xc9, 0x2f, - 0x83, 0x78, 0xc8, 0x64, 0xc9, 0x92, 0x41, 0x52, 0xb9, 0xf9, 0x59, 0x91, - 0x46, 0x89, 0x78, 0xda, 0xc3, 0x26, 0xdd, 0x9d, 0x1f, 0x0c, 0x8e, 0xea, - 0xba, 0xa8, 0xde, 0xa5, 0x33, 0x8c, 0x2e, 0xaa, 0x0e, 0x2c, 0x13, 0x36, - 0xb3, 0x7b, 0xa6, 0x12, 0x98, 0x0a, 0x13, 0x35, 0xa3, 0x9e, 0x52, 0xaf, - 0x43, 0xf4, 0x1c, 0x79, 0xcf, 0x46, 0xc6, 0xcd}; - EcdsaSignature signature = { - 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, - 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, - 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x35, - 0xb4, 0x20, 0x07, 0x4e, 0xed, 0xc3, 0xb1, 0x60, 0xd8, 0x78, 0x32, - 0xb3, 0xa0, 0x8e, 0xc2, 0xab, 0xdb, 0x46, 0x6b, 0x03, 0x94, 0xd7, - 0x90, 0xd3, 0xfd, 0xd3, 0x5a, 0x9a, 0xc3, 0x66, 0xab, - }; - std::vector long_sigrl_file = { - // Intel(R) EPID Version - 0x02, 0x00, - // File Type - 0x00, 0x0e, - // Group ID - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x34, - // Revocation list version number - 0x00, 0x00, 0x00, 0x03, - // Number of revocation list entries N - 0x00, 0x00, 0x00, 0x32, - }; - for (int i = 0; i < 50; ++i) { - for (auto it : b) { - long_sigrl_file.push_back(it); - } - } - for (auto it : signature.x.data) { - long_sigrl_file.push_back(it); - } - for (auto it : signature.y.data) { - long_sigrl_file.push_back(it); - } - size_t rl_len = long_sigrl_file.size() - sizeof(signature) - 4; - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, - EpidParseSigRlFile(long_sigrl_file.data(), long_sigrl_file.size(), - &this->kCert, (SigRl*)rl.data(), &rl_len)); - - std::vector expected_long_sig_rl(std::vector( - &long_sigrl_file[4], - &long_sigrl_file[long_sigrl_file.size() - sizeof(signature)])); - - EXPECT_EQ(expected_long_sig_rl, rl); -} - -TEST_F(EpidFileParser, RejectsSigRlFileWithInvalidSignature) { - size_t rl_len = this->kShortSigRl.size(); - std::vector rl(rl_len); - std::vector sigrl_inv_sign(kShortSigRlFile); - sigrl_inv_sign[sigrl_inv_sign.size() - 1] = - sigrl_inv_sign[sigrl_inv_sign.size() - 1] ^ 0xFF; - EXPECT_EQ( - kEpidSigInvalid, - EpidParseSigRlFile((void*)sigrl_inv_sign.data(), sigrl_inv_sign.size(), - &this->kCert, (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, SigRlParseRejectsBufWithInsufficientSize) { - size_t rl_len = this->kShortSigRl.size() - 1; - std::vector rl(rl_len); - - EXPECT_EQ(kEpidBadArgErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &this->kCert, - (SigRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ReturnsProperSizeGivenOversizedSigRlBuf) { - size_t rl_len = this->kShortSigRl.size() + 1; - std::vector oversized_rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParseSigRlFile((void*)this->kShortSigRlFile.data(), - this->kShortSigRlFile.size(), &this->kCert, - (SigRl*)oversized_rl.data(), &rl_len)); - std::vector rl(oversized_rl.begin(), oversized_rl.end() - 1); - EXPECT_EQ(this->kShortSigRl, rl); - EXPECT_EQ(this->kShortSigRl.size(), rl_len); -} - -////////////////////////////////////////////////////////////////////////// -// EpidParseGroupRlFile Tests -TEST_F(EpidFileParser, GroupRlParseProvidesRequiredLenWithNullDest) { - size_t rl_len = 0; - EXPECT_EQ(kEpidNoErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &kCert, - nullptr, &rl_len)); - EXPECT_EQ(rl_len, this->kShortGroupRl.size()); -} - -TEST_F(EpidFileParser, GroupRlParseFailsGivenNullParameters) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile(nullptr, this->kShortGroupRlFile.size(), - &kCert, (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), nullptr, - (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &kCert, - (GroupRl*)rl.data(), nullptr)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &kCert, - nullptr, nullptr)); -} - -TEST_F(EpidFileParser, GroupRlParseFailsGivenUnsupportedCurve) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - EpidCaCertificate unsupported_curve1(kCert); - unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve1, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve2(kCert); - unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve2, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve3(kCert); - unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve3, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve4(kCert); - unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve4, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve5(kCert); - unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve5, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate unsupported_curve6(kCert); - unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &unsupported_curve6, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, GroupRlParseFailsGivenInvalidKeyInCertificate) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - EpidCaCertificate invalid_key_qx(kCert); - invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, EpidParseGroupRlFile( - (void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &invalid_key_qx, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate invalid_key_qy(kCert); - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] = - invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF; - EXPECT_EQ(kEpidBadArgErr, EpidParseGroupRlFile( - (void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &invalid_key_qy, - (GroupRl*)rl.data(), &rl_len)); - EpidCaCertificate invalid_key_qx_qy(kCert); - invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF; - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] = - invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^ - 0xFF; - EXPECT_EQ( - kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &invalid_key_qx_qy, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsGroupRlFileWithInvalidSize) { - size_t rl_len = this->kEmptyGroupRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kEmptyGroupRlFile.data(), 0, - &this->kCert, (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kEmptyGroupRlFile.data(), - this->kEmptyGroupRlFile.size() - 1, - &this->kCert, (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kEmptyGroupRlFile.size() + 1, - &this->kCert, (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsInvalidGroupRlFileType) { - size_t rl_len = this->kShortPrivRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortPrivRlFile.data(), - this->kShortPrivRlFile.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, RejectsGroupRlFileWithUnsupportedEpidVersion) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - std::vector unsupported_epidver_file(this->kShortGroupRlFile); - unsupported_epidver_file[0] = {0x01}; - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)unsupported_epidver_file.data(), - unsupported_epidver_file.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ParsesEmptyGroupRl) { - size_t rl_len = this->kEmptyGroupRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, - EpidParseGroupRlFile(this->kEmptyGroupRlFile.data(), - this->kEmptyGroupRlFile.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(rl, this->kEmptyGroupRl); -} - -TEST_F(EpidFileParser, ParsesShortGroupRl) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, - EpidParseGroupRlFile(this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); - EXPECT_EQ(rl, this->kShortGroupRl); -} - -TEST_F(EpidFileParser, ParsesLongGroupRl) { - std::vector gid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xbc}; - EcdsaSignature signature = { - 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, - 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, - 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0xa4, - 0xaa, 0x8c, 0x1c, 0x91, 0xa2, 0x57, 0x07, 0x67, 0x0e, 0x58, 0xae, - 0xc7, 0x25, 0x15, 0x36, 0xda, 0xa0, 0xea, 0xc1, 0x15, 0x2b, 0xf2, - 0xc2, 0x33, 0x43, 0x3f, 0xc6, 0x56, 0xc1, 0x57, 0xbd, - }; - std::vector long_grouprl_file = { - /// Intel(R) EPID Version - 0x02, 0x00, - // File type - 0x00, 0x0f, - // RLver: revocation list version number - 0x00, 0x00, 0x00, 0x01, - // n3: number of entries in GroupRL - 0x00, 0x00, 0x00, 0x32, - }; - for (int i = 0; i < 50; ++i) { - for (auto it : gid) { - long_grouprl_file.push_back(it); - } - } - for (auto it : signature.x.data) { - long_grouprl_file.push_back(it); - } - for (auto it : signature.y.data) { - long_grouprl_file.push_back(it); - } - - size_t rl_len = long_grouprl_file.size() - sizeof(signature) - 4; - std::vector rl(rl_len); - EXPECT_EQ(kEpidNoErr, EpidParseGroupRlFile( - long_grouprl_file.data(), long_grouprl_file.size(), - &this->kCert, (GroupRl*)rl.data(), &rl_len)); - - std::vector expected_long_gr_rl(std::vector( - &long_grouprl_file[4], - &long_grouprl_file[long_grouprl_file.size() - sizeof(signature)])); - - EXPECT_EQ(expected_long_gr_rl, rl); -} - -TEST_F(EpidFileParser, RejectsGroupRlFileWithInvalidSignature) { - size_t rl_len = this->kShortGroupRl.size(); - std::vector rl(rl_len); - std::vector grouprl_inv_sign(this->kShortGroupRlFile); - grouprl_inv_sign[grouprl_inv_sign.size() - 1] = - grouprl_inv_sign[grouprl_inv_sign.size() - 1] ^ 0xFF; - EXPECT_EQ(kEpidSigInvalid, - EpidParseGroupRlFile((void*)grouprl_inv_sign.data(), - grouprl_inv_sign.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, GroupRlParseRejectsBufWithInsufficientSize) { - size_t rl_len = this->kShortGroupRl.size() - 1; - std::vector rl(rl_len); - - EXPECT_EQ(kEpidBadArgErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &this->kCert, - (GroupRl*)rl.data(), &rl_len)); -} - -TEST_F(EpidFileParser, ReturnsProperSizeGivenOversizedGroupRlBuf) { - size_t rl_len = this->kShortGroupRl.size() + 1; - std::vector oversized_rl(rl_len); - - EXPECT_EQ(kEpidNoErr, - EpidParseGroupRlFile((void*)this->kShortGroupRlFile.data(), - this->kShortGroupRlFile.size(), &this->kCert, - (GroupRl*)oversized_rl.data(), &rl_len)); - std::vector rl(oversized_rl.begin(), oversized_rl.end() - 1); - EXPECT_EQ(this->kShortGroupRl, rl); - EXPECT_EQ(this->kShortGroupRl.size(), rl_len); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/finitefield-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/finitefield-test.cc deleted file mode 100644 index 78b18e903a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/finitefield-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 FiniteField 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/finitefield.h" -} - -namespace { -/// Intel(R) EPID 2.0 parameters q, beta, xi and v -BigNumStr 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}}; -FqElemStr 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}}; -Fq2ElemStr xi = { - {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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}}}}}; -Fq6ElemStr v = { - {{{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, - {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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}}}}}; -TEST(FiniteField, DeleteWorksGivenNewlyCreatedFiniteField) { - FiniteField* finitefield = nullptr; - EpidStatus sts = NewFiniteField(&q, &finitefield); - EXPECT_EQ(kEpidNoErr, sts); - EXPECT_NO_THROW(DeleteFiniteField(&finitefield)); -} -TEST(FiniteField, DeleteWorksGivenNullPointer) { - EXPECT_NO_THROW(DeleteFiniteField(nullptr)); - FiniteField* finitefield = nullptr; - EXPECT_NO_THROW(DeleteFiniteField(&finitefield)); -} -TEST(FiniteField, NewFailsGivenNullBigNumStr) { - FiniteField* finitefield = nullptr; - EpidStatus sts = NewFiniteField(nullptr, &finitefield); - EXPECT_EQ(kEpidBadArgErr, sts); - DeleteFiniteField(&finitefield); -} - -TEST(FiniteField, NewFailsGivenNullFiniteField) { - EpidStatus sts = NewFiniteField(&q, nullptr); - EXPECT_EQ(kEpidBadArgErr, sts); -} - -TEST(FiniteField, NewSucceedsGivenNewlyCreatedBigNumStr) { - FiniteField* finitefield = nullptr; - EpidStatus sts = NewFiniteField(&q, &finitefield); - EXPECT_EQ(kEpidNoErr, sts); - DeleteFiniteField(&finitefield); -} - -// the following test reproduces a bug in IPP. -TEST(FiniteField, DISABLED_NewSucceedsGivenAllFFBigNumStr) { - const BigNumStr test_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, 0xFF}; - FiniteField* finitefield = nullptr; - EpidStatus sts = NewFiniteField(&test_prime, &finitefield); - EXPECT_EQ(kEpidNoErr, sts); - DeleteFiniteField(&finitefield); -} - -TEST(FiniteField, BinomialExtensionFailsGivenNullPointer) { - FiniteField* binom_ext_finite_field_ptr = nullptr; - FiniteFieldObj ground_field(q); - FfElementObj ground_element(&ground_field, beta); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(nullptr, ground_element, 2, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(ground_field, nullptr, 2, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); - EXPECT_EQ(kEpidBadArgErr, NewFiniteFieldViaBinomalExtension( - ground_field, ground_element, 2, nullptr)); -} - -TEST(FiniteField, BinomialExtensionFailsGivenBadDegree) { - FiniteField* binom_ext_finite_field_ptr = nullptr; - FiniteFieldObj ground_field(q); - FfElementObj ground_element(&ground_field, beta); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(ground_field, ground_element, 1, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(ground_field, ground_element, 0, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(ground_field, ground_element, -1, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); - EXPECT_EQ(kEpidBadArgErr, - NewFiniteFieldViaBinomalExtension(ground_field, ground_element, -99, - &binom_ext_finite_field_ptr)); - DeleteFiniteField(&binom_ext_finite_field_ptr); -} - -TEST(FiniteField, BinomialExtensionCanBuildEpid2GtField) { - // construct Fq finite field - FiniteFieldObj fq(q); - - // construct Fq^2 finite field - FfElementObj neg_beta(&fq); - THROW_ON_EPIDERR(FfNeg(fq, FfElementObj(&fq, beta), neg_beta)); - FiniteFieldObj fq2(fq, neg_beta, 2); - - // construct Fq^6 finite field - FfElementObj neg_xi(&fq2); - THROW_ON_EPIDERR(FfNeg(fq2, FfElementObj(&fq2, xi), neg_xi)); - FiniteFieldObj fq6(fq2, neg_xi, 3); - - // construct Fq^12 finite field - FfElementObj neg_v(&fq6); - THROW_ON_EPIDERR(FfNeg(fq6, FfElementObj(&fq6, v), neg_v)); - FiniteFieldObj fq12(fq6, neg_v, 2); - - FiniteField* binom_ext_fq12_ptr = nullptr; - EXPECT_EQ(kEpidNoErr, NewFiniteFieldViaBinomalExtension(fq6, neg_v, 2, - &binom_ext_fq12_ptr)); - DeleteFiniteField(&binom_ext_fq12_ptr); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/hash-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/hash-test.cc deleted file mode 100644 index eea7d08912..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/hash-test.cc +++ /dev/null @@ -1,87 +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 unit tests. - */ - -#include -#include -#include "gtest/gtest.h" - -#include "epid/common-testhelper/errors-testhelper.h" - -extern "C" { -#include "epid/common/math/hash.h" -} - -/// compares Sha256Digest values -bool operator==(Sha256Digest const& lhs, Sha256Digest const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -namespace { - -/////////////////////////////////////////////////////////////////////// -// SHA256 -TEST(Hash, Sha256MessageDigestFailsGivenNullPtr) { - char msg[] = "abc"; - Sha256Digest digest; - - EXPECT_EQ(kEpidBadArgErr, - Sha256MessageDigest(nullptr, sizeof(msg) - 1, &digest)); - EXPECT_EQ(kEpidBadArgErr, Sha256MessageDigest(msg, sizeof(msg) - 1, nullptr)); -} - -TEST(Hash, Sha256MessageDigestFailsGivenInvalidBufferSize) { - char msg[] = "abc"; - Sha256Digest digest; - - EXPECT_EQ( - kEpidBadArgErr, - Sha256MessageDigest(msg, std::numeric_limits::max(), &digest)); -#if (SIZE_MAX >= 0x100000001) // When size_t value allowed to be 0x100000001 - EXPECT_EQ(kEpidBadArgErr, Sha256MessageDigest(msg, 0x100000001, &digest)); -#endif -} - -TEST(Hash, Sha256MessageDigestComputesCorrectDigest) { - // Test vectors here are taken from - // http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA256.pdf - - Sha256Digest digest; - - char msg_abc[] = "abc"; - Sha256Digest digest_abc = {{0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, - 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, - 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, - 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD}}; - EXPECT_EQ(kEpidNoErr, - Sha256MessageDigest(msg_abc, sizeof(msg_abc) - 1, &digest)); - EXPECT_EQ(digest_abc, digest); - - char msg_long[] = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - Sha256Digest digest_long = {{0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, - 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, - 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, - 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1}}; - EXPECT_EQ(kEpidNoErr, - Sha256MessageDigest(msg_long, sizeof(msg_long) - 1, &digest)); - EXPECT_EQ(digest_long, digest); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/main-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/main-test.cc deleted file mode 100644 index 70f2d3a182..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/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/math/unittests/octstrconvert-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/octstrconvert-test.cc deleted file mode 100644 index 5813429849..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/octstrconvert-test.cc +++ /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 OctStr2Bnu unit tests. - * - * OctStr2Bnu is an internal function used in the IPP implementation of the - * math libraries. These tests can be omitted if you do not use this function. - */ - -#include "epid/common/stdtypes.h" -#include "gtest/gtest.h" -#include "epid/common/math/bignum-internal.h" - -namespace { - -const uint8_t bnstr1[] = {0x01, 0x02, 0x03, 0x04}; -const uint8_t bnstr2[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; -uint32_t bnustr1[sizeof(bnstr1) / sizeof(uint32_t)] = {0x01020304}; -uint32_t bnustr2[sizeof(bnstr2) / sizeof(uint32_t)] = {0x05060708, 0x01020304}; - -TEST(OctStr2Bnu, octstr2bnuFailsGivenNullBnu) { - int len = OctStr2Bnu(nullptr, bnstr1, sizeof(bnstr1) / sizeof(uint8_t)); - EXPECT_EQ(-1, len); -} -TEST(OctStr2Bnu, octstr2bnuFailsGivenNullOctstr) { - uint32_t bnustr_res[sizeof(bnstr1) / sizeof(uint32_t)] = {0}; - int len = OctStr2Bnu(bnustr_res, nullptr, sizeof(bnstr1) / sizeof(uint8_t)); - EXPECT_EQ(-1, len); -} -TEST(OctStr2Bnu, octstr2bnuFailsGivenInvalidOctsrtLen) { - uint32_t bnustr_res[sizeof(bnstr1) / sizeof(uint32_t)] = {0}; - int len = OctStr2Bnu(bnustr_res, bnstr1, -1); - EXPECT_EQ(-1, len); - len = OctStr2Bnu(bnustr_res, bnstr1, 0); - EXPECT_EQ(-1, len); - len = OctStr2Bnu(bnustr_res, bnstr1, 3); - EXPECT_EQ(-1, len); - len = OctStr2Bnu(bnustr_res, bnstr1, 5); - EXPECT_EQ(-1, len); -} -TEST(OctStr2Bnu, octstr2bnuWorksGivenOctstr1) { - uint32_t bnustr_res[sizeof(bnstr1) / sizeof(uint32_t)] = {0}; - int len = OctStr2Bnu(bnustr_res, bnstr1, sizeof(bnstr1) / sizeof(uint8_t)); - EXPECT_EQ(1, len); - EXPECT_EQ(0, - memcmp(bnustr1, bnustr_res, sizeof(bnustr_res) / sizeof(uint32_t))) - << "OctStr2Bnu: bnu string result does not match with predefined value\n"; -} -TEST(OctStr2Bnu, octstr2bnuWorksGivenOctstr2) { - uint32_t bnustr_res[sizeof(bnstr2) / sizeof(uint32_t)] = {0}; - int len = OctStr2Bnu(bnustr_res, bnstr2, sizeof(bnstr2) / sizeof(uint8_t)); - EXPECT_EQ(2, len); - EXPECT_EQ(0, - memcmp(bnustr2, bnustr_res, sizeof(bnustr_res) / sizeof(uint32_t))) - << "OctStr2Bnu: bnu string result does not match with predefined value\n"; -} -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/pairing-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/pairing-test.cc deleted file mode 100644 index aab5deac5e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/pairing-test.cc +++ /dev/null @@ -1,225 +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 unit tests. - */ - -#include - -#include "gtest/gtest.h" - -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/epid_params-testhelper.h" -#include "epid/common-testhelper/finite_field_wrapper-testhelper.h" -#include "epid/common-testhelper/ffelement_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/pairing.h" -#include "epid/common/math/ecgroup-internal.h" -#include "epid/common/math/finitefield-internal.h" -#include "epid/common/math/pairing-internal.h" -} - -/// compares Fq12ElemStr values -bool operator==(GtElemStr const& lhs, GtElemStr const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -namespace { - -class PairingTest : public Epid20Params, public ::testing::Test { - public: - static const BigNumStr t_str; - - virtual void SetUp() { params = new Epid20Params(); } - virtual void TearDown() { delete params; } - - Epid20Params* params; -}; - -const BigNumStr PairingTest::t_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, 0x68, 0x82, 0xF5, 0xC0, 0x30, 0xB0, 0xA8, 0x01}; - -/////////////////////////////////////////////////////////////////////// -// NewPairingState / DeletePairingState - -// test that delete works in a "normal" valid case. -TEST_F(PairingTest, DeleteWorksGivenNewlyCreatedPairingState) { - PairingState* ps = nullptr; - EpidStatus sts = kEpidNoErr; - EXPECT_EQ(kEpidNoErr, - NewPairingState(this->params->G1, this->params->G2, - this->params->GT, &this->t_str, true, &ps)); - EXPECT_EQ(kEpidNoErr, sts); - EXPECT_NO_THROW(DeletePairingState(&ps)); -} - -// test that delete works if there is nothing to do -TEST_F(PairingTest, DeleteWorksGivenNullPointer) { - EXPECT_NO_THROW(DeletePairingState(nullptr)); - PairingState* ps = nullptr; - EXPECT_NO_THROW(DeletePairingState(&ps)); -} - -// test that new succeeds with valid parameters -TEST_F(PairingTest, NewSucceedsGivenValidParameters) { - PairingState* ps = nullptr; - EXPECT_EQ(kEpidNoErr, - NewPairingState(this->params->G1, this->params->G2, - this->params->GT, &this->t_str, true, &ps)); - DeletePairingState(&ps); -} - -// test that new fails if any options are NULL -TEST_F(PairingTest, NewFailsGivenNullParameters) { - PairingState* ps = nullptr; - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(nullptr, this->params->G2, this->params->GT, - &this->t_str, true, &ps)); - DeletePairingState(&ps); - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(this->params->G1, nullptr, this->params->GT, - &this->t_str, true, &ps)); - DeletePairingState(&ps); - EXPECT_EQ(kEpidBadArgErr, NewPairingState(this->params->G1, this->params->G2, - nullptr, &this->t_str, true, &ps)); - DeletePairingState(&ps); - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(this->params->G1, this->params->G2, - this->params->GT, nullptr, true, &ps)); - DeletePairingState(&ps); - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(this->params->G1, this->params->G2, - this->params->GT, &this->t_str, true, nullptr)); -} - -// test that new checks that G1 is valid -TEST_F(PairingTest, NewFailsGivenInvalidG1) { - PairingState* ps = nullptr; - EcGroup ga; - ga.ipp_ec = nullptr; - ga.scratch_buffer = nullptr; - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(&ga, this->params->G2, this->params->GT, - &this->t_str, true, &ps)); - DeletePairingState(&ps); -} - -// test that new checks that G2 is valid -TEST_F(PairingTest, NewFailsGivenInvalidG2) { - PairingState* ps = nullptr; - EcGroup gb; - gb.ipp_ec = nullptr; - gb.scratch_buffer = nullptr; - EXPECT_EQ(kEpidBadArgErr, - NewPairingState(this->params->G1, &gb, this->params->GT, - &this->t_str, true, &ps)); - DeletePairingState(&ps); -} - -// test that new checks that GT is valid -TEST_F(PairingTest, NewFailsGivenInvalidGT) { - PairingState* ps = nullptr; - FiniteField ff; - ff.ipp_ff = nullptr; - EXPECT_EQ(kEpidBadArgErr, NewPairingState(this->params->G1, this->params->G2, - &ff, &this->t_str, true, &ps)); - DeletePairingState(&ps); -} -/////////////////////////////////////////////////////////////////////// -// Pairing -TEST_F(PairingTest, PairingWorksFromG1AndG2ToGt) { - const bool neg = true; - - GtElemStr r_expected_str = { - 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01, - 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1, - 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4, - 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2, - 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84, - 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7, - 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c, - 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19, - 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00, - 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e, - 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29, - 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6, - 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a, - 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5, - 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73, - 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03, - 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51, - 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41, - 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc, - 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4, - 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31, - 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8, - 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03, - 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e, - 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e, - 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda, - 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed, - 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8, - 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19, - 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76, - 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26, - 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e, - }; - G1ElemStr ga_elem_str = { - 0xd7, 0xe2, 0xf9, 0x37, 0x21, 0x0f, 0x09, 0x97, 0x0f, 0xca, 0xa6, - 0x03, 0x7d, 0x91, 0xc3, 0x75, 0x8a, 0xc9, 0x44, 0x11, 0xfc, 0xaa, - 0x55, 0x67, 0xba, 0xce, 0xaf, 0x8d, 0xf6, 0x7c, 0x84, 0x83, 0x04, - 0xb7, 0xa6, 0xff, 0x9f, 0x0d, 0x26, 0x73, 0xaf, 0x6c, 0xd0, 0x0a, - 0xf6, 0x13, 0xc9, 0x44, 0x3f, 0xf0, 0x82, 0x58, 0x48, 0x59, 0x03, - 0x3f, 0x88, 0xe2, 0x46, 0xd6, 0x0f, 0x93, 0x42, 0x4b, - }; - G2ElemStr gb_elem_str = { - 0x3f, 0x4c, 0xb5, 0x2d, 0xbc, 0x72, 0xb0, 0x9c, 0x6f, 0xb2, 0xb5, 0xc1, - 0xdc, 0xfb, 0xda, 0x35, 0x91, 0xa6, 0x8d, 0x51, 0x37, 0x70, 0xe2, 0x17, - 0xad, 0x53, 0x23, 0xdc, 0xa3, 0xc3, 0xfd, 0x4c, 0x90, 0xfa, 0x4f, 0xa2, - 0xcb, 0x35, 0xf3, 0x50, 0x5e, 0x8e, 0xf4, 0xce, 0x7f, 0xb0, 0x8a, 0x69, - 0x49, 0xdf, 0xf5, 0x4f, 0xb0, 0xc1, 0xd7, 0xf9, 0xb8, 0xfb, 0x89, 0xd1, - 0xb6, 0xf8, 0x74, 0x04, 0xef, 0xc6, 0x60, 0x05, 0x62, 0xf3, 0x17, 0x5a, - 0x80, 0xf4, 0x4b, 0x97, 0x08, 0x3e, 0x43, 0xa1, 0x44, 0x4c, 0x54, 0x86, - 0x16, 0x20, 0xb9, 0xcc, 0xfb, 0xbd, 0x00, 0x5f, 0xc8, 0x01, 0xfb, 0x5b, - 0xc1, 0x6e, 0x2b, 0x46, 0xe2, 0x04, 0x70, 0xeb, 0xa2, 0xaa, 0x86, 0x5a, - 0x35, 0x14, 0x0e, 0xc9, 0xdf, 0xba, 0x9b, 0x6f, 0x3a, 0xca, 0x94, 0x9c, - 0x44, 0x89, 0x94, 0xa3, 0xeb, 0x61, 0x8b, 0x01, - }; - - GtElemStr r_str = {0}; - - FfElementObj r(&this->params->GT); - EcPointObj ga_elem(&this->params->G1, ga_elem_str); - EcPointObj gb_elem(&this->params->G2, gb_elem_str); - - PairingState* ps = nullptr; - THROW_ON_EPIDERR(NewPairingState(this->params->G1, this->params->G2, - this->params->GT, &this->t_str, neg, &ps)); - EXPECT_EQ(kEpidNoErr, Pairing(ps, r, ga_elem, gb_elem)); - DeletePairingState(&ps); - - THROW_ON_EPIDERR(WriteFfElement(this->params->GT, r, &r_str, sizeof(r_str))); - EXPECT_EQ(r_expected_str, r_str); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/printutils-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/printutils-test.cc deleted file mode 100644 index 14e4c8227f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/math/unittests/printutils-test.cc +++ /dev/null @@ -1,379 +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 Printutils unit tests. - */ - -#ifndef EPID_ENABLE_DEBUG_PRINT -#define EPID_ENABLE_DEBUG_PRINT -#endif - -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/common/math/bignum.h" -#include "epid/common/math/printutils.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" -#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h" -#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h" -#include "epid/common-testhelper/bignum_wrapper-testhelper.h" - -namespace { - -class PrintutilsTest : public ::testing::Test { - public: - /// Intel(R) EPID 2.0 parameter q - static const BigNumStr epid20_q; - static const BigNumStr epid20_p; - static const FpElemStr p_str; - static const FqElemStr beta_str; - static const Fq2ElemStr xi_str; - static const Fq6ElemStr v_str; - static const Fq12ElemStr a_str; - static const G1ElemStr g1_str; - static const G2ElemStr g2_str; - static const FqElemStr a1; - static const FqElemStr b1; - static const BigNumStr h1; - static const G1ElemStr efq_a_str; - static const G2ElemStr efq2_a_str; - - BigNumObj q; - - FiniteFieldObj fp; - FiniteFieldObj fq; - FiniteFieldObj fq2; - FiniteFieldObj fq6; - FiniteFieldObj fq12; - - FfElementObj fp_elem; - FfElementObj fq_beta; - FfElementObj fq2_xi; - FfElementObj fq6_v; - FfElementObj fq12_a; - - EcGroupObj efq; - EcPointObj efq_a; - - EcGroupObj efq2; - EcPointObj efq2_a; - - public: - virtual void SetUp() { - q = BigNumObj(epid20_q); - - ConstructFiniteFields(); - ConstructEllipticCurveGroups(); - } - - private: - void ConstructFiniteFields() { - // construct Fp finite field - fp = FiniteFieldObj(epid20_p); - fp_elem = FfElementObj(&fp, p_str); - - // construct Fq finite field - fq = FiniteFieldObj(epid20_q); - fq_beta = FfElementObj(&fq, beta_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); - fq2_xi = FfElementObj(&fq2, xi_str); - - // 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); - fq6_v = FfElementObj(&fq6, v_str); - - // construct Fq^12 finite field - FfElementObj neg_v(&fq6); - THROW_ON_EPIDERR(FfNeg(fq6, FfElementObj(&fq6, v_str), neg_v)); - fq12 = FiniteFieldObj(fq6, neg_v, 2); - fq12_a = FfElementObj(&fq12, a_str); - } - - void ConstructEllipticCurveGroups() { - // 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). - efq = EcGroupObj(&fq, FfElementObj(&fq), FfElementObj(&fq, b1), - FfElementObj(&fq, g1_str.x), FfElementObj(&fq, g1_str.y), - BigNumObj(epid20_p), 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, b1), b_dash)); - - // Set G2 = E(Fq2).init(p, param(Fq2), n, h, 0, b', g2.x, g2.y) - efq2 = 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)); - - efq_a = EcPointObj(&efq, efq_a_str); - efq2_a = EcPointObj(&efq2, efq2_a_str); - } -}; -/// Intel(R) EPID 2.0 parameter q -const BigNumStr PrintutilsTest::epid20_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}; -const BigNumStr PrintutilsTest::epid20_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}; -const FpElemStr PrintutilsTest::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, 0x00}; -const FqElemStr PrintutilsTest::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 Fq2ElemStr PrintutilsTest::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 Fq6ElemStr PrintutilsTest::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 Fq12ElemStr PrintutilsTest::a_str = { - 0xba, 0x10, 0x1f, 0xf6, 0x46, 0x8b, 0xe9, 0x32, 0x4f, 0xc0, 0xa5, 0x01, - 0xad, 0x5e, 0xe2, 0x31, 0x16, 0x29, 0x96, 0xed, 0xa7, 0xde, 0x4c, 0xe1, - 0xd2, 0x8d, 0x33, 0xca, 0x50, 0xab, 0x7b, 0xc6, 0x15, 0xeb, 0x79, 0xf4, - 0xeb, 0xde, 0x30, 0xb6, 0xc4, 0x07, 0x7c, 0x42, 0xcb, 0x04, 0x54, 0xf2, - 0x1f, 0x4d, 0x1f, 0xc0, 0xdf, 0xa2, 0x2b, 0x9e, 0x34, 0xc4, 0x4c, 0x84, - 0x14, 0xd3, 0x62, 0x07, 0xf1, 0x8b, 0x84, 0xd1, 0x46, 0x57, 0xb6, 0xe7, - 0x80, 0xe1, 0x46, 0x49, 0x1c, 0x0d, 0xef, 0x81, 0x31, 0xb0, 0xbe, 0x8c, - 0xb9, 0x08, 0xd0, 0xd3, 0xc4, 0x56, 0xca, 0xad, 0xf9, 0x1d, 0x75, 0x19, - 0x3f, 0xee, 0x7c, 0x43, 0xc1, 0xfa, 0x4e, 0x50, 0xb7, 0x19, 0x01, 0x00, - 0x6f, 0xd5, 0x16, 0xb6, 0xf4, 0x85, 0xe0, 0xeb, 0x2e, 0x5f, 0x0a, 0x7e, - 0xf8, 0xac, 0xbc, 0x05, 0xec, 0x73, 0xb5, 0x57, 0xe3, 0xb3, 0x18, 0x29, - 0xbb, 0xef, 0x86, 0x50, 0x87, 0xcf, 0x70, 0xba, 0x13, 0x8b, 0xb1, 0xb6, - 0x2d, 0x6f, 0x65, 0x3d, 0xa1, 0x0b, 0xe3, 0x92, 0xc5, 0x72, 0x86, 0x6a, - 0xb3, 0xeb, 0xe0, 0xe5, 0xda, 0x0e, 0x57, 0x87, 0xd5, 0xa9, 0x61, 0xa5, - 0x1e, 0xcb, 0x04, 0x86, 0xcd, 0xc3, 0x18, 0x2a, 0x36, 0xa0, 0x81, 0x73, - 0xe7, 0x13, 0x87, 0x80, 0x8d, 0x1a, 0xfe, 0x6e, 0x4b, 0xa3, 0x13, 0x03, - 0x66, 0x9e, 0x80, 0x4d, 0x8a, 0xaa, 0x00, 0x95, 0x72, 0xce, 0xbb, 0x51, - 0xe8, 0x01, 0x09, 0x41, 0xd3, 0x63, 0x28, 0x05, 0xa4, 0xbe, 0xd6, 0x41, - 0xa6, 0x2f, 0x5f, 0xbf, 0x0b, 0x13, 0xb4, 0x54, 0x5b, 0x50, 0x65, 0xdc, - 0x6f, 0x29, 0xd6, 0xda, 0xbf, 0xc2, 0x06, 0xea, 0x3b, 0xb2, 0xf1, 0xd4, - 0x26, 0x5c, 0x92, 0x6b, 0x95, 0x6d, 0x88, 0xab, 0x8f, 0xc6, 0x9d, 0x31, - 0xe4, 0x9b, 0x71, 0x49, 0xe0, 0xce, 0x97, 0x8f, 0xc9, 0x9f, 0xbc, 0xa8, - 0x4a, 0xc6, 0xaa, 0x4a, 0xc8, 0x0d, 0x2a, 0x60, 0x1a, 0x43, 0x40, 0x03, - 0xb3, 0x53, 0x30, 0x98, 0x1f, 0x3f, 0xdf, 0x5c, 0x0f, 0xf0, 0x84, 0x8e, - 0x5a, 0x5d, 0x41, 0xd2, 0x47, 0x78, 0x6d, 0x9f, 0x89, 0xce, 0xf5, 0x8e, - 0xb6, 0x54, 0xa2, 0x26, 0xe5, 0x40, 0x39, 0x5c, 0x59, 0x08, 0xb3, 0xda, - 0xf5, 0xf8, 0xa0, 0x18, 0x33, 0x57, 0xd1, 0x72, 0xbb, 0xba, 0x6c, 0xed, - 0xe8, 0xa0, 0x5e, 0xc8, 0x81, 0xc5, 0xac, 0x15, 0x1b, 0xd0, 0xe6, 0xc8, - 0x92, 0xf9, 0x43, 0x03, 0x5a, 0x00, 0x42, 0xe3, 0x49, 0xa5, 0xf7, 0x19, - 0x78, 0x8a, 0x39, 0x89, 0x32, 0xae, 0xbf, 0x4d, 0x4b, 0xb3, 0x33, 0x76, - 0x16, 0xfd, 0x0b, 0xfe, 0x42, 0x1e, 0x17, 0x37, 0x2a, 0x04, 0xea, 0x26, - 0xba, 0x6e, 0x2c, 0x36, 0xaf, 0x35, 0x1b, 0x75, 0x6d, 0x17, 0xdc, 0x8e, -}; -const FqElemStr PrintutilsTest::a1 = { - {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 FqElemStr PrintutilsTest::b1 = { - {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 PrintutilsTest::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 PrintutilsTest::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 G2ElemStr PrintutilsTest::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}}}}}; -const G1ElemStr PrintutilsTest::efq_a_str = { - {{{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 G2ElemStr PrintutilsTest::efq2_a_str = { - { - {0x2F, 0x8C, 0xC7, 0xD7, 0xD4, 0x1E, 0x4A, 0xCB, 0x82, 0x92, 0xC7, 0x9C, - 0x0F, 0xA2, 0xF2, 0x1B, 0xDF, 0xEA, 0x96, 0x64, 0x8B, 0xA2, 0x32, 0x7C, - 0xDF, 0xD8, 0x89, 0x10, 0xFD, 0xBB, 0x38, 0xCD}, - {0xB1, 0x23, 0x46, 0x13, 0x4D, 0x9B, 0x8E, 0x8A, 0x95, 0x64, 0xDD, 0x37, - 0x29, 0x44, 0x1F, 0x76, 0xB5, 0x3A, 0x47, 0xD3, 0xE0, 0x18, 0x1E, 0x60, - 0xE9, 0x94, 0x13, 0xA4, 0x47, 0xCD, 0xBE, 0x03}, - }, - { - {0xD3, 0x67, 0xA5, 0xCC, 0xEF, 0x7B, 0xD1, 0x8D, 0x4A, 0x7F, 0xF1, 0x8F, - 0x66, 0xCB, 0x5E, 0x86, 0xAC, 0xCB, 0x36, 0x5F, 0x29, 0x90, 0x28, 0x55, - 0xF0, 0xDC, 0x6E, 0x8B, 0x87, 0xB5, 0xD8, 0x32}, - {0x6C, 0x0A, 0xC5, 0x58, 0xB1, 0x4E, 0xCA, 0x85, 0x44, 0x3E, 0xDE, 0x71, - 0x9B, 0xC7, 0x90, 0x19, 0x06, 0xD2, 0xA0, 0x4E, 0xC7, 0x33, 0xF4, 0x5C, - 0xE8, 0x16, 0xE2, 0x67, 0xDB, 0xBF, 0x64, 0x84}, - }, -}; - -TEST_F(PrintutilsTest, DISABLED_PrintutilsWorkWithAnnotatedFormat) { - // Test intentionally disabled and has no predicate. - // Enable for manual output inspection. - - PrintBigNum(q, "q"); - PrintFfElement(fp, fp_elem, "fp_elem", kPrintUtilAnnotated); - PrintFfElement(fq, fq_beta, "fq_beta", kPrintUtilAnnotated); - PrintFfElement(fq2, fq2_xi, "fq2_xi", kPrintUtilAnnotated); - PrintFfElement(fq6, fq6_v, "fq6_v", kPrintUtilAnnotated); - PrintFfElement(fq12, fq12_a, "fq12_a", kPrintUtilAnnotated); - PrintEcPoint(efq, efq_a, "efq_a", kPrintUtilAnnotated); - PrintEcPoint(efq2, efq2_a, "efq2_a", kPrintUtilAnnotated); - - PrintBigNumStr(&epid20_q, "q_str"); - PrintFqElemStr(&beta_str, "fq_beta_str"); - PrintFq2ElemStr(&xi_str, "fq2_xi_str", kPrintUtilAnnotated); - PrintFq6ElemStr(&v_str, "fq6_v_str", kPrintUtilAnnotated); - PrintFq12ElemStr(&a_str, "fq12_a_str", kPrintUtilAnnotated); - PrintG1ElemStr(&efq_a_str, "efq_a_str", kPrintUtilAnnotated); - PrintG2ElemStr(&efq2_a_str, "efq_a_str", kPrintUtilAnnotated); -} - -TEST_F(PrintutilsTest, DISABLED_PrintutilsWorkWithUnannotatedFormat) { - // Test intentionally disabled and has no predicate. - // Enable for manual output inspection. - - PrintFfElement(fp, fp_elem, "fp_elem", kPrintUtilUnannotated); - PrintFfElement(fq, fq_beta, "fq_beta", kPrintUtilUnannotated); - PrintFfElement(fq2, fq2_xi, "fq2_xi", kPrintUtilUnannotated); - PrintFfElement(fq6, fq6_v, "fq6_v", kPrintUtilUnannotated); - PrintFfElement(fq12, fq12_a, "fq12_a", kPrintUtilUnannotated); - PrintEcPoint(efq, efq_a, "efq_a", kPrintUtilUnannotated); - PrintEcPoint(efq2, efq2_a, "efq2_a", kPrintUtilUnannotated); - - PrintFq2ElemStr(&xi_str, "fq2_xi_str", kPrintUtilUnannotated); - PrintFq6ElemStr(&v_str, "fq6_v_str", kPrintUtilUnannotated); - PrintFq12ElemStr(&a_str, "fq12_a_str", kPrintUtilUnannotated); - PrintG1ElemStr(&efq_a_str, "efq_a_str", kPrintUtilUnannotated); - PrintG2ElemStr(&efq2_a_str, "efq_a_str", kPrintUtilUnannotated); -} - -TEST_F(PrintutilsTest, DISABLED_PrintutilsReportNullPtr) { - // Test intentionally disabled and has no predicate. - // Enable for manual output inspection. - - PrintBigNum(nullptr, "q"); - - PrintFfElement(nullptr, fp_elem, "fp_elem", kPrintUtilUnannotated); - PrintFfElement(fp, nullptr, "fp_elem", kPrintUtilUnannotated); - - PrintFfElement(nullptr, fq_beta, "fq_beta", kPrintUtilUnannotated); - PrintFfElement(fq, nullptr, "fq_beta", kPrintUtilUnannotated); - - PrintEcPoint(nullptr, efq_a, "efq_a", kPrintUtilUnannotated); - PrintEcPoint(efq, nullptr, "efq_a", kPrintUtilUnannotated); - - PrintBigNumStr(nullptr, "q_str"); - PrintFqElemStr(nullptr, "fq_beta_str"); - PrintFq2ElemStr(nullptr, "fq2_xi_str", kPrintUtilAnnotated); - PrintFq6ElemStr(nullptr, "fq6_v_str", kPrintUtilAnnotated); - PrintFq12ElemStr(nullptr, "fq12_a_str", kPrintUtilAnnotated); - PrintG1ElemStr(nullptr, "efq_a_str", kPrintUtilAnnotated); - PrintG2ElemStr(nullptr, "efq_a_str", kPrintUtilAnnotated); -} - -TEST_F(PrintutilsTest, DISABLED_PrintutilsReportInvalidArgument) { - // Test intentionally disabled and has no predicate. - // Enable for manual output inspection. - - PrintFfElement(fp, fp_elem, "fp_elem", (PrintUtilFormat)100); - PrintFfElement(fq, fq_beta, "fq_beta", (PrintUtilFormat)100); - PrintFfElement(fq2, fq2_xi, "fq2_xi", (PrintUtilFormat)100); - PrintFfElement(fq6, fq6_v, "fq6_v", (PrintUtilFormat)100); - PrintFfElement(fq12, fq12_a, "fq12_a", (PrintUtilFormat)100); - PrintEcPoint(efq, efq_a, "efq_a", (PrintUtilFormat)100); - PrintEcPoint(efq2, efq2_a, "efq2_a", (PrintUtilFormat)100); - - PrintFq2ElemStr(&xi_str, "fq2_xi_str", (PrintUtilFormat)100); - PrintFq6ElemStr(&v_str, "fq6_v_str", (PrintUtilFormat)100); - PrintFq12ElemStr(&a_str, "fq12_a_str", (PrintUtilFormat)100); - PrintG1ElemStr(&efq_a_str, "efq_a_str", (PrintUtilFormat)100); - PrintG2ElemStr(&efq2_a_str, "efq_a_str", (PrintUtilFormat)100); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/memory.c b/sgx-jvm/linux-sgx/external/epid/epid/common/memory.c deleted file mode 100644 index b425c9ddbd..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/memory.c +++ /dev/null @@ -1,122 +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 Memory access implementation. - */ - -#include "epid/common/memory.h" - -#include -#include - -/// Maximum size of the destination buffer -#ifndef RSIZE_MAX -#define RSIZE_MAX ((SIZE_MAX) >> 1) -#endif - -#ifndef MIN -/// Evaluate to minimum of two values -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif // MIN - -/// Copies count of character from dest to src -/*! \note Implementation follows C11 memcpy_s but with checks always enabled - */ -int memcpy_S(void* dest, size_t destsz, void const* src, size_t count) { - size_t i; - if (!dest || destsz > RSIZE_MAX) return -1; - if (!src || count > RSIZE_MAX || count > destsz || - count > (dest > src ? ((uintptr_t)dest - (uintptr_t)src) - : ((uintptr_t)src - (uintptr_t)dest))) { - // zero out dest if error detected - memset(dest, 0, destsz); - return -1; - } - - for (i = 0; i < count; i++) ((uint8_t*)dest)[i] = ((uint8_t*)src)[i]; - return 0; -} - -void EpidZeroMemory(void* ptr, size_t size) { memset(ptr, 0, size); } - -#if defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - -#if !defined(EPID_ALLOC_ALIGN) -/// Alignment constant for EpidAlloc, must be a power of two -#define EPID_ALLOC_ALIGN sizeof(size_t) -#endif // !defined(EPID_ALLOC_ALIGN) - -#pragma pack(1) -/// Allocated memory block information -typedef struct EpidAllocHeader { - size_t length; ///< number of bytes memory block is allocated for - void* ptr; ///< pointer to whole memory block including EpidAllocHeader -} EpidAllocHeader; -#pragma pack() - -#endif // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - -void* EpidAlloc(size_t size) { -#if defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - void* ptr = NULL; - if (size <= 0) return NULL; - // Allocate memory enough to store size bytes and EpidAllocHeader - ptr = calloc(1, size + EPID_ALLOC_ALIGN - 1 + sizeof(EpidAllocHeader)); - if (ptr) { - void* aligned_pointer = (void*)(((uintptr_t)ptr + EPID_ALLOC_ALIGN + - sizeof(EpidAllocHeader) - 1) & - (~(EPID_ALLOC_ALIGN - 1))); - ((EpidAllocHeader*)aligned_pointer)[-1].length = size; - ((EpidAllocHeader*)aligned_pointer)[-1].ptr = ptr; - return aligned_pointer; - } - return NULL; -#else // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - return calloc(1, size); -#endif // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) -} - -void* EpidRealloc(void* ptr, size_t new_size) { -#if defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - void* new_ptr = EpidAlloc(new_size); - if (!new_ptr) return NULL; - if (ptr) { - if (0 != memcpy_S(new_ptr, ((EpidAllocHeader*)new_ptr)[-1].length, ptr, - MIN(((EpidAllocHeader*)ptr)[-1].length, - ((EpidAllocHeader*)new_ptr)[-1].length))) { - EpidFree(new_ptr); - return NULL; - } - EpidFree(ptr); - } - return new_ptr; -#else // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - return realloc(ptr, new_size); -#endif // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) -} - -void EpidFree(void* ptr) { -#if defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - if (ptr) { - EpidZeroMemory(ptr, ((EpidAllocHeader*)ptr)[-1].length); - free(((EpidAllocHeader*)ptr)[-1].ptr); - } -#else // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) - free(ptr); -#endif // defined(EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE) -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/memory.h b/sgx-jvm/linux-sgx/external/epid/epid/common/memory.h deleted file mode 100644 index 9fa57e072b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/memory.h +++ /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. - ############################################################################*/ -#ifndef EPID_COMMON_MEMORY_H_ -#define EPID_COMMON_MEMORY_H_ - -#include -#include - -/*! - * \file - * \brief Memory access interface. - * \addtogroup EpidCommon - * @{ - */ - -/// When enabled secrets are wiped out from the memory by EpidFree -#define EPID_ENABLE_EPID_ZERO_MEMORY_ON_FREE - -/// Clear information stored in block of memory pointer to by ptr -/*! - - \warning - This function may be optimized away by some compilers. If it is, you - should consider using a compiler or operating system specific memory - sanitization function (e.g. memcpy_s or SecureZeroMemory). - - \param[in] ptr - pointer to memory block - \param[in] size - number of bytes to clear - */ -void EpidZeroMemory(void* ptr, size_t size); - -/// Allocates memory of size bytes -/*! - The content of memory is initialized with zeros. - Memory must be freed with EpidFree function. - - \param[in] size - number of bytes to allocate - - \returns pointer to allocated memory. - */ -void* EpidAlloc(size_t size); - -/// Reallocates memory allocated by EpidAlloc -/*! - In case of error NULL pointer is returned and input memory block - is not changed. - Memory must be freed with EpidFree function. - - \param[in] ptr - pointer to memory block to reallocate - \param[in] new_size - number of bytes to reallocate for - - \returns pointer to allocated memory. - */ -void* EpidRealloc(void* ptr, size_t new_size); - -/// Frees memory allocated by EpidAlloc -/*! - Clears information stored in the block of memory. - - \param[in] ptr - pointer to allocated memory block - */ -void EpidFree(void* ptr); - -#if !defined(SAFE_ALLOC) -/// Allocates zero initalized block of memory -#define SAFE_ALLOC(size) EpidAlloc(size); -#endif // !defined(SAFE_ALLOC) -#if !defined(SAFE_FREE) -/// Deallocates space allocated by SAFE_ALLOC() and nulls pointer -#define SAFE_FREE(ptr) \ - { \ - if (NULL != (ptr)) { \ - EpidFree(ptr); \ - (ptr) = NULL; \ - } \ - } -#endif // !defined(SAFE_FREE) - -#if !defined(SAFE_REALLOC) -/// Changes the size of the memory block pointed to by ptr -#define SAFE_REALLOC(ptr, size) EpidRealloc((ptr), (size)) -#endif // !defined(SAFE_REALLOC) - -/// Copies bytes between buffers with security ehancements -/*! - Copies count bytes from src to dest. If the source and destination - overlap, the behavior is undefined. - - \param[out] dest - pointer to the object to copy to - \param[in] destsz - max number of bytes to modify in the destination (typically the size - of the destination object) - \param[in] src - pointer to the object to copy from - \param[in] count - number of bytes to copy - - \returns zero on success and non-zero value on error. - */ -int memcpy_S(void* dest, size_t destsz, void const* src, size_t count); - -/*! @} */ -#endif // EPID_COMMON_MEMORY_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.c b/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.c deleted file mode 100644 index b67b1f848c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.c +++ /dev/null @@ -1,49 +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 SigRl validity checking implementation. - */ - -#include - -#include "epid/common/endian_convert.h" -#include "epid/common/sigrlvalid.h" - -bool IsSigRlValid(GroupId const* gid, SigRl const* sig_rl, size_t sig_rl_size) { - const size_t kMinSigRlSize = sizeof(SigRl) - sizeof(SigRlEntry); - size_t input_sig_rl_size = 0; - if (!gid || !sig_rl) { - return false; - } - if (kMinSigRlSize > sig_rl_size) { - return false; - } - if (ntohl(sig_rl->n2) > (SIZE_MAX - kMinSigRlSize) / sizeof(sig_rl->bk[0])) { - return false; - } - // sanity check of intput SigRl size - input_sig_rl_size = kMinSigRlSize + ntohl(sig_rl->n2) * sizeof(sig_rl->bk[0]); - if (input_sig_rl_size != sig_rl_size) { - return false; - } - // verify that gid given and gid in SigRl match - if (0 != memcmp(gid, &sig_rl->gid, sizeof(*gid))) { - return false; - } - return true; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.h b/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.h deleted file mode 100644 index c510ea8d6d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/sigrlvalid.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_SIGRLVALID_H_ -#define EPID_COMMON_SIGRLVALID_H_ -/*! - * \file - * \brief SigRl validity checking interface. - * \addtogroup EpidCommon - * @{ - */ - -#include - -#include "epid/common/stdtypes.h" -#include "epid/common/types.h" - -/// Function to verify if signature based revocation list is valid -/*! - - \param[in] gid - Group id - \param[in] sig_rl - Signature based revocation list - \param[in] sig_rl_size - Size of signature based revocation list - - \returns true if revocation list is valid - \returns false if revocation list is invalid -*/ -bool IsSigRlValid(GroupId const* gid, SigRl const* sig_rl, size_t sig_rl_size); - -/*! @} */ -#endif // EPID_COMMON_SIGRLVALID_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/stack.c b/sgx-jvm/linux-sgx/external/epid/epid/common/stack.c deleted file mode 100644 index 8af5a9dc32..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/stack.c +++ /dev/null @@ -1,91 +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 Stack container implementation. - */ -#include -#include "epid/common/stack.h" -#include "epid/common/memory.h" - -/// Internal representation of a Stack -struct Stack { - size_t element_size; ///< Size of element in bytes - void* buf; ///< Buffer to store elements - size_t max_size; ///< Numbers of elements buffer was allocated to - size_t top; ///< Stack top, the number of elements in the stack -}; - -bool CreateStack(size_t element_size, Stack** stack) { - if (!stack || 0 == element_size) return false; - *stack = SAFE_ALLOC(sizeof(Stack)); - if (!*stack) return false; - (*stack)->element_size = element_size; - return true; -} - -void* StackPushN(Stack* stack, size_t n, void* elements) { - if (!stack) return 0; - if (n > 0) { - size_t max_size_required = stack->top + n; - if (n > (SIZE_MAX / stack->element_size) - stack->top) - return 0; // integer overflow - if (max_size_required > stack->max_size) { - void* reallocated = - SAFE_REALLOC(stack->buf, max_size_required * stack->element_size); - if (!reallocated) return 0; - stack->buf = reallocated; - stack->max_size = max_size_required; - } - if (elements) { - if (0 != memcpy_S((uint8_t*)stack->buf + stack->top * stack->element_size, - (stack->max_size - stack->top) * stack->element_size, - elements, n * stack->element_size)) { - return 0; - } - } - stack->top += n; - } - return (uint8_t*)stack->buf + (stack->top - n) * stack->element_size; -} - -bool StackPopN(Stack* stack, size_t n, void* elements) { - if (!stack) return false; - if (n > 0) { - if (n > stack->top) return false; - if (elements) { - if (0 != memcpy_S(elements, n * stack->element_size, - (uint8_t*)stack->buf + - (stack->top - n) * stack->element_size, - n * stack->element_size)) { - return false; - } - stack->top -= n; - } - } - return true; -} - -size_t StackGetSize(Stack const* stack) { - return stack ? stack->top : (size_t)0; -} - -void DeleteStack(Stack** stack) { - if (stack && *stack) { - SAFE_FREE((*stack)->buf); - SAFE_FREE(*stack); - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/stack.h b/sgx-jvm/linux-sgx/external/epid/epid/common/stack.h deleted file mode 100644 index fbb05aeb5e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/stack.h +++ /dev/null @@ -1,95 +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_STACK_H_ -#define EPID_COMMON_STACK_H_ -/*! - * \file - * \brief Stack container interface. - * \addtogroup EpidCommon - * @{ - */ -#include -#include "epid/common/stdtypes.h" - -/// A stack -typedef struct Stack Stack; - -/// Create stack -/*! - \param[in] element_size - Size of stack element - \param[out] stack - Stack context to be created - - \returns true is operation succeed, false if stack were failed to allocate - - \see DeleteStack -*/ -bool CreateStack(size_t element_size, Stack** stack); - -/// Push multiple elements to the stack -/*! - \param[in,out] stack - Stack context - \param[in] n - Number of elements to push to the stack - \param[in] elements - Array of elements to push to the stack. Can be NULL - - \returns A pointer to an array of new elements in the stack or NULL if - stack is empty or push operation were failed. - - \see CreateStack -*/ -void* StackPushN(Stack* stack, size_t n, void* elements); - -/// Pop multiple elements from the stack -/*! - \param[in,out] stack - Stack context - \param[in] n - Number of elements to pop from the stack - \param[out] elements - Pointer to a buffer to store elements removed from the stack - - \returns true is operation succeed, false otherwise - - \see CreateStack -*/ -bool StackPopN(Stack* stack, size_t n, void* elements); - -/// Get number of elements in the stack -/*! - \param[in] stack - Stack context - - \returns Number of elements in the stack or 0 if stack is NULL - - \see CreateStack -*/ -size_t StackGetSize(Stack const* stack); - -/// Deallocates memory used for the stack. -/*! - \param[in,out] stack - Stack context - - \see CreateStack -*/ -void DeleteStack(Stack** stack); - -/*! @} */ -#endif // EPID_COMMON_STACK_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/stdtypes.h b/sgx-jvm/linux-sgx/external/epid/epid/common/stdtypes.h deleted file mode 100644 index 8d15f3da7d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/stdtypes.h +++ /dev/null @@ -1,37 +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_STDTYPES_H_ -#define EPID_COMMON_STDTYPES_H_ - -/*! - * \file - * \brief C99 standard data types. - */ - -#include // Fixed-width integer types - -#ifndef __cplusplus -#ifndef _Bool -/// Boolean type -typedef char bool; -/// integer constant 1 -#define true 1 -/// integer constant 0 -#define false 0 -#endif // -#endif // ifndef __cplusplus - -#endif // EPID_COMMON_STDTYPES_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/gpubkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/gpubkey.inc deleted file mode 100644 index 0ed0ded412..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/gpubkey.inc +++ /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. - ############################################################################*/ - -// gpubkey -0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, -0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, - -0x89, 0x33, 0xA7, 0x86, 0xD7, 0x71, 0xCC, 0x80, -0x46, 0x4B, 0x42, 0xC3, 0xE7, 0xBA, 0x1A, 0x54, -0x85, 0x8A, 0x21, 0x8E, 0x29, 0x91, 0xA9, 0x60, -0x41, 0xF9, 0xA5, 0xD9, 0x7B, 0x5F, 0x54, 0x49, -0x2A, 0x89, 0x8C, 0x10, 0x0E, 0x26, 0x0D, 0xE8, -0x36, 0x6A, 0x9E, 0x6F, 0x79, 0xFF, 0xF1, 0xCD, -0xA7, 0xCD, 0xAC, 0x1F, 0x92, 0x33, 0x3A, 0xD9, -0x7C, 0xF5, 0xCD, 0x38, 0x48, 0x01, 0x4F, 0xC5, -0x6F, 0xEA, 0x50, 0x60, 0x59, 0x09, 0xDA, 0x44, -0x21, 0xC2, 0xD0, 0x86, 0xE6, 0x00, 0x63, 0x59, -0xA9, 0xFB, 0x35, 0x13, 0x4E, 0x13, 0xB1, 0x47, -0x36, 0xD7, 0xBD, 0xF6, 0x0A, 0x35, 0x74, 0x7D, -0x36, 0xC5, 0x67, 0xA2, 0x03, 0xB7, 0x38, 0x31, -0x16, 0xA8, 0x5D, 0x64, 0x3F, 0xE6, 0xF1, 0x94, -0x37, 0x09, 0x8C, 0x20, 0x17, 0xAC, 0x2F, 0x55, -0x9E, 0xED, 0xB3, 0xC7, 0x73, 0xC0, 0x1C, 0xBB, -0xBF, 0xF7, 0x18, 0xCE, 0x4F, 0xD4, 0xE3, 0x67, -0x75, 0xE4, 0xD9, 0x51, 0xFB, 0x1B, 0x22, 0xF9, -0x72, 0x2E, 0xC1, 0x76, 0x2A, 0xE1, 0x4A, 0x6E, -0x88, 0xD6, 0x2D, 0x71, 0xF4, 0xC4, 0x6D, 0xAC, -0x8C, 0xBD, 0xE7, 0x2B, 0xB1, 0x40, 0x15, 0x93, -0xBD, 0x97, 0xD4, 0x84, 0x90, 0xEF, 0x4E, 0xFD, -0x78, 0x25, 0xAB, 0xDF, 0x16, 0xF3, 0x46, 0x52, -0x16, 0x96, 0xAE, 0x50, 0x88, 0x96, 0x18, 0x73, -0xC1, 0xD1, 0x73, 0xF0, 0x67, 0xC8, 0x8D, 0xBB, -0x4E, 0xBC, 0x6A, 0x40, 0xE6, 0x1E, 0x7D, 0x36, -0x8C, 0xF4, 0xB1, 0xF1, 0x5F, 0x26, 0x4F, 0x43, -0x0A, 0x36, 0xD4, 0x67, 0xD4, 0x79, 0x3F, 0xB8, -0x69, 0x6F, 0x9C, 0x33, 0xD3, 0xDB, 0xC6, 0xCE, -0x42, 0xE3, 0x46, 0x87, 0xD6, 0x65, 0xAC, 0xC9, -0x71, 0xF1, 0xA9, 0x8F, 0x78, 0x45, 0x9A, 0xEF, -0x1C, 0xE4, 0x45, 0x84, 0x3D, 0x8A, 0x27, 0x51, - diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha256_sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha256_sigrl.inc deleted file mode 100644 index c009b344a9..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha256_sigrl.inc +++ /dev/null @@ -1,1222 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha256 - * Message: "test message" - * Basename: None (random base) - * SigRl: SigRl of group - */ -0xb3, 0x6f, 0xff, 0x81, 0xe2, 0x1b, 0x17, -0xeb, 0x3d, 0x75, 0x3d, 0x61, 0x7e, 0x27, -0xb0, 0xcb, 0xd0, 0x6d, 0x8f, 0x9d, 0x64, -0xce, 0xe3, 0xce, 0x43, 0x4c, 0x62, 0xfd, -0xb5, 0x80, 0xe0, 0x99, 0x3a, 0x7, 0x56, -0x80, 0xe0, 0x88, 0x59, 0xa4, 0xfd, 0xb5, -0xb7, 0x9d, 0xe9, 0x4d, 0xae, 0x9c, 0xee, -0x3d, 0x66, 0x42, 0x82, 0x45, 0x7e, 0x7f, -0xd8, 0x69, 0x3e, 0xa1, 0x74, 0xf4, 0x59, -0xee, 0x50, 0xda, 0xbf, 0xc4, 0x59, 0xcc, -0x11, 0xf3, 0x49, 0xd8, 0xbb, 0x51, 0xfc, -0xa7, 0x15, 0xf9, 0x4d, 0xbb, 0x7c, 0x27, -0xaa, 0x0, 0x2c, 0xa2, 0x91, 0x7b, 0x36, -0xa3, 0x2c, 0x60, 0x96, 0x16, 0x38, 0xff, -0xe4, 0x4a, 0x42, 0x13, 0x3, 0xdb, 0x88, -0x6f, 0xe3, 0x4f, 0xd6, 0xf2, 0x47, 0x10, -0xed, 0xeb, 0xa0, 0xaf, 0x71, 0xc3, 0x6, -0x10, 0x30, 0x55, 0x91, 0xf0, 0xf2, 0x70, -0xe0, 0x10, 0x1b, 0x7f, 0xb4, 0x3, 0xc2, -0x0, 0x70, 0xb2, 0x77, 0x20, 0xbf, 0x6c, -0x49, 0xee, 0xfa, 0xf2, 0xca, 0x6, 0x99, -0x9c, 0x54, 0xe3, 0x29, 0x1b, 0x17, 0x6a, -0xb1, 0x5e, 0x92, 0xa0, 0x27, 0xac, 0x81, -0x91, 0x33, 0x39, 0x6a, 0xf9, 0x60, 0xb, -0xe4, 0xcd, 0xa2, 0xe8, 0xde, 0x74, 0xb2, -0xbe, 0x58, 0xaa, 0x96, 0x3e, 0xdd, 0x5f, -0xc0, 0x3c, 0xe5, 0x94, 0x1b, 0xfd, 0x78, -0xa8, 0x44, 0x48, 0x32, 0x91, 0x89, 0xb0, -0xf0, 0x9e, 0x56, 0x87, 0x76, 0xee, 0x24, -0xfe, 0xf5, 0xf, 0x69, 0x95, 0xc, 0xfe, -0xcc, 0xce, 0x22, 0xd7, 0x33, 0xe3, 0xe5, -0x86, 0xa3, 0xb9, 0x42, 0x6f, 0x7b, 0xe4, -0x86, 0x95, 0xec, 0xc3, 0x8, 0x43, 0xf6, -0xba, 0x26, 0x1c, 0xbd, 0x8b, 0x21, 0xa7, -0x82, 0x91, 0x22, 0xdb, 0x62, 0x4c, 0xff, -0x85, 0x8f, 0x10, 0xb7, 0xb1, 0x40, 0xa7, -0x44, 0x80, 0x20, 0xb4, 0x61, 0xf9, 0xf4, -0x98, 0xad, 0xb4, 0x35, 0xf7, 0x1e, 0x11, -0xa1, 0x77, 0xe4, 0xf2, 0x60, 0x68, 0x96, -0x9, 0x62, 0x6c, 0x35, 0xd2, 0x73, 0x43, -0x6a, 0x12, 0xc3, 0x2b, 0x5d, 0xe3, 0xc4, -0x68, 0x2f, 0x5a, 0x69, 0x56, 0xb6, 0x40, -0x26, 0x11, 0xb9, 0xff, 0x67, 0xb, 0xec, -0xdc, 0x53, 0x86, 0xe2, 0x83, 0xfb, 0x75, -0xa1, 0x48, 0xd1, 0x3a, 0xaf, 0xaf, 0x29, -0x53, 0xce, 0xd1, 0x24, 0xb5, 0xf8, 0x6e, -0x9, 0xab, 0x2b, 0xe4, 0xf0, 0xfe, 0x19, -0x66, 0x65, 0xc1, 0x73, 0x91, 0x9d, 0xe5, -0xe1, 0x89, 0x24, 0x17, 0xa8, 0xba, 0x73, -0x10, 0xbe, 0x6b, 0xf6, 0x45, 0xbc, 0xe5, -0x3e, 0x97, 0x0, 0x0, 0x0, 0x0, 0x0, -0x0, 0x0, 0x32, 0x27, 0xce, 0xbd, 0x3d, -0xe0, 0xa, 0x5a, 0x61, 0x29, 0xaa, 0xe0, -0xda, 0x63, 0x27, 0x6f, 0x7a, 0xae, 0x85, -0xf9, 0x9a, 0x4d, 0x38, 0xe, 0x7, 0x7d, -0xc4, 0xbc, 0x3e, 0xef, 0x50, 0xc5, 0x39, -0x43, 0x3d, 0x1f, 0xb1, 0xd3, 0x86, 0x5a, -0x47, 0x4c, 0x19, 0xf6, 0xf3, 0x13, 0x22, -0x92, 0x6c, 0x3d, 0xe2, 0x29, 0x6a, 0xe6, -0xb7, 0xf1, 0x26, 0xd8, 0x31, 0xa1, 0xe9, -0x8f, 0x97, 0xd7, 0xc8, 0x2e, 0x80, 0x1d, -0x98, 0xc, 0x1a, 0xbe, 0x7b, 0xef, 0xd5, -0x7c, 0x1, 0x86, 0xcd, 0x4d, 0xe0, 0xcd, -0xc9, 0x75, 0xe8, 0x43, 0x11, 0x2, 0x5c, -0x12, 0x54, 0xe6, 0x79, 0xbd, 0x81, 0x75, -0xd, 0x7e, 0xd, 0x2, 0xc3, 0x73, 0x85, -0xee, 0x9e, 0x41, 0x81, 0x6a, 0xf9, 0x7, -0x95, 0x21, 0x2f, 0x45, 0x60, 0xb2, 0x1a, -0x3b, 0x83, 0x1, 0x76, 0x9e, 0xf6, 0x4, -0x5c, 0x52, 0xa1, 0x53, 0x4c, 0x0, 0xfc, -0x4f, 0x2c, 0xe, 0x70, 0xd9, 0x9, 0x6c, -0x2b, 0x5b, 0x8c, 0xed, 0xc3, 0xfe, 0xbb, -0xbc, 0xa4, 0x2d, 0x51, 0x9f, 0xa8, 0x69, -0x43, 0x7c, 0xe3, 0x82, 0x49, 0x1a, 0x90, -0xc0, 0xfd, 0x9c, 0x69, 0xe0, 0x20, 0xdb, -0x40, 0x5c, 0xf7, 0x16, 0x15, 0x24, 0xaa, -0x6, 0x5e, 0xb5, 0x39, 0xb8, 0x0, 0x79, -0x5d, 0xc1, 0x72, 0x89, 0xa2, 0x14, 0xdf, -0xdc, 0x2b, 0x6b, 0x70, 0x66, 0xd9, 0xd, -0x23, 0x47, 0x67, 0xb3, 0x8c, 0x9c, 0x8a, -0xea, 0xa5, 0x5c, 0x79, 0x4b, 0xaa, 0x16, -0x82, 0xb7, 0x4f, 0xdf, 0x55, 0x24, 0xf7, -0x72, 0x4e, 0x4b, 0xaf, 0xc2, 0x8c, 0xfe, -0x82, 0x70, 0x49, 0x30, 0xa6, 0xd4, 0x97, -0xa5, 0x7c, 0xec, 0x42, 0xd6, 0x1, 0xbe, -0x66, 0x35, 0xf7, 0x28, 0xce, 0xe0, 0xab, -0x6a, 0xfc, 0x69, 0xf3, 0x6b, 0xea, 0xd5, -0xa5, 0xbf, 0xd, 0x6d, 0xc3, 0xbf, 0xaa, -0xb2, 0x69, 0x35, 0xe7, 0xdb, 0x51, 0x3a, -0x59, 0x8, 0x1, 0xb7, 0xd8, 0x7a, 0x95, -0xa8, 0xa5, 0xc8, 0x6a, 0xaa, 0x30, 0x25, -0x4f, 0x59, 0x45, 0x70, 0xce, 0x95, 0x70, -0x70, 0xec, 0xf2, 0xaa, 0x3c, 0xa2, 0x3, -0xcb, 0xb8, 0x3f, 0x1d, 0x64, 0x66, 0x26, -0xc2, 0x2d, 0xa, 0xfc, 0x1a, 0x1e, 0x89, -0xfd, 0xfd, 0xaa, 0x51, 0xb7, 0x72, 0xad, -0xb3, 0x98, 0xe1, 0x8, 0x58, 0x10, 0x56, -0x87, 0xaf, 0x5a, 0x71, 0x68, 0x94, 0x11, -0x50, 0x3b, 0xae, 0x96, 0xfe, 0x34, 0x73, -0x41, 0xcd, 0x9f, 0xf3, 0x70, 0xbc, 0xad, -0xb, 0xb5, 0x76, 0x6a, 0x7d, 0x9c, 0x64, -0x5d, 0x0, 0xed, 0xf1, 0xfa, 0xd4, 0xed, -0x73, 0xdf, 0x25, 0xe, 0x74, 0xd1, 0x5d, -0x5f, 0xf3, 0x86, 0x69, 0x61, 0x4a, 0xda, -0x39, 0xd5, 0x4b, 0xf, 0x94, 0xd, 0x14, -0xc8, 0x43, 0x33, 0xf9, 0xfd, 0x92, 0x46, -0x77, 0x8f, 0xef, 0xc8, 0xb8, 0x35, 0xa3, -0x6b, 0x3b, 0xf4, 0x29, 0x6e, 0x58, 0xa8, -0xe4, 0x9a, 0xbd, 0xe6, 0x17, 0x18, 0x12, -0x5f, 0x78, 0xde, 0xf9, 0xa9, 0x54, 0x83, -0xd1, 0xa3, 0xbe, 0xf9, 0xe7, 0x3, 0xab, -0xe1, 0x7, 0xe4, 0xa9, 0x4, 0x9f, 0x86, -0xff, 0xf7, 0x88, 0x2, 0x3, 0xe8, 0xe9, -0xa, 0xf2, 0x8a, 0xf8, 0x70, 0xbb, 0xc9, -0xc1, 0xb9, 0x6, 0x29, 0x25, 0x94, 0x70, -0xc4, 0x3, 0xdd, 0x9a, 0x51, 0x3a, 0xfc, -0x45, 0x1a, 0xc6, 0xac, 0x56, 0x80, 0x18, -0x3c, 0x4b, 0x1d, 0xb, 0x6c, 0x1a, 0x73, -0xd1, 0xdd, 0xae, 0x7f, 0xe2, 0x48, 0x3a, -0xe5, 0xb6, 0xf5, 0x1a, 0xf3, 0xc5, 0x2a, -0x79, 0x93, 0x3, 0x41, 0x88, 0x5d, 0x86, -0x2, 0x26, 0xbd, 0x93, 0x7f, 0xdf, 0xc9, -0x49, 0xaa, 0x79, 0x66, 0x62, 0x50, 0x81, -0xf5, 0xef, 0x1, 0xeb, 0x61, 0xd1, 0x64, -0x6c, 0xe0, 0xa8, 0x2, 0xb8, 0xff, 0x3e, -0x6e, 0x3c, 0xf5, 0xd2, 0x81, 0xbe, 0x9c, -0x45, 0x7a, 0x77, 0x83, 0x38, 0x76, 0x7f, -0x28, 0x25, 0x47, 0xc7, 0xe1, 0x8c, 0xae, -0x99, 0x81, 0x79, 0xa9, 0xd1, 0x3d, 0x9e, -0x6a, 0xfc, 0x40, 0x8b, 0xc5, 0xbd, 0x2d, -0xf7, 0x91, 0x8f, 0x5, 0x83, 0x13, 0x10, -0x2, 0x84, 0xc2, 0xc6, 0x8d, 0x18, 0x5f, -0x23, 0x7e, 0x1b, 0x60, 0xc6, 0x66, 0x24, -0xba, 0xd8, 0xf4, 0x3d, 0x76, 0xc6, 0xd2, -0x1, 0xe9, 0x85, 0xb7, 0x44, 0x1c, 0xd4, -0x59, 0xe8, 0xa4, 0xe0, 0x88, 0x8b, 0xad, -0x34, 0xd5, 0x36, 0x2e, 0xc2, 0x16, 0x82, -0x1, 0x2f, 0x92, 0x75, 0x98, 0x88, 0xb2, -0xcb, 0x34, 0xcd, 0xb8, 0x6, 0x40, 0x84, -0xbb, 0x99, 0xd, 0x79, 0x5f, 0xca, 0xca, -0x9c, 0xbf, 0x2f, 0xd3, 0x2a, 0x1, 0x8f, -0xea, 0xff, 0xcd, 0x24, 0x2b, 0x4b, 0xfd, -0xef, 0xeb, 0x96, 0xc3, 0xca, 0xa5, 0x39, -0x91, 0x3, 0x6f, 0x73, 0xc5, 0x72, 0x41, -0x42, 0x17, 0xd, 0x4a, 0x2f, 0xa, 0x7e, -0x12, 0x1f, 0x73, 0xd6, 0x80, 0x64, 0x69, -0xf0, 0xe1, 0xd3, 0x74, 0x31, 0xa8, 0x8a, -0x24, 0xaa, 0xd6, 0x8f, 0x39, 0x95, 0xbd, -0x13, 0x39, 0x99, 0xa5, 0xa4, 0x7b, 0x78, -0x80, 0x3f, 0xad, 0x19, 0x18, 0x28, 0x37, -0x54, 0xd3, 0x42, 0x43, 0x95, 0x9d, 0x22, -0xc3, 0x1b, 0x63, 0x9a, 0x2f, 0xea, 0xa7, -0x94, 0x88, 0x62, 0x34, 0x5b, 0xae, 0x44, -0xf1, 0xda, 0xd8, 0x55, 0x8b, 0xe6, 0x24, -0xd5, 0xce, 0x77, 0x75, 0xd9, 0x71, 0x2b, -0xb7, 0xb7, 0x62, 0x2d, 0xb8, 0xa2, 0xd8, -0x2c, 0x38, 0xc4, 0x3a, 0x6, 0x34, 0xd0, -0xe9, 0x74, 0xb9, 0xba, 0xe7, 0xb9, 0xe8, -0x97, 0x80, 0xdd, 0x65, 0xd6, 0x5b, 0xeb, -0x7f, 0xdf, 0x38, 0xe9, 0x30, 0x43, 0x3e, -0xc5, 0x28, 0xb4, 0xb7, 0x47, 0xae, 0xfa, -0xf9, 0x53, 0xa7, 0xd, 0x3e, 0x82, 0xd4, -0x60, 0xf8, 0xa9, 0xa4, 0x16, 0x6d, 0xfb, -0x84, 0x57, 0x7a, 0xeb, 0x80, 0x71, 0xff, -0x55, 0xbd, 0x42, 0xe8, 0xd0, 0x1c, 0xf, -0xd, 0xe1, 0x38, 0xac, 0x69, 0xd0, 0xb1, -0x4c, 0x8f, 0x26, 0x5b, 0xe0, 0x4, 0xa2, -0xe8, 0xd1, 0x72, 0x15, 0x24, 0x97, 0x51, -0x7, 0x85, 0x54, 0xed, 0x6f, 0xc4, 0xa0, -0xac, 0xed, 0x67, 0x6, 0x7d, 0x92, 0x5, -0x79, 0x4, 0x2f, 0x5e, 0x4e, 0x9e, 0x69, -0x33, 0xc3, 0x43, 0xc9, 0x89, 0x8, 0xfa, -0x7a, 0x8d, 0x86, 0x2d, 0x27, 0x37, 0x32, -0xdf, 0x9, 0x94, 0x86, 0x5f, 0x21, 0x97, -0x25, 0xc, 0xb3, 0xbd, 0xe, 0x61, 0xf4, -0x53, 0xfd, 0xac, 0xbb, 0xd2, 0x4d, 0x9a, -0xd1, 0x6e, 0xfc, 0x99, 0x3, 0xc1, 0x3f, -0x4c, 0x1a, 0xcb, 0x0, 0x4a, 0x54, 0xd2, -0xa9, 0x26, 0x32, 0x46, 0xe0, 0x5a, 0x60, -0x1, 0x58, 0x59, 0xca, 0x2d, 0x19, 0xf4, -0xc0, 0x18, 0x4b, 0x7a, 0xc6, 0x83, 0xab, -0xf0, 0xbf, 0xb2, 0x82, 0x49, 0x9b, 0x15, -0x31, 0xa0, 0x65, 0x4, 0x72, 0xc, 0xbe, -0x1b, 0x70, 0x34, 0x7d, 0xe4, 0x44, 0xbf, -0x78, 0x5e, 0xca, 0x41, 0x27, 0x8b, 0x8c, -0xba, 0x53, 0xa7, 0x7b, 0xb7, 0x77, 0xe2, -0xa3, 0x2e, 0x69, 0x6, 0x12, 0xcc, 0x5f, -0x8, 0xea, 0x7a, 0x72, 0x23, 0xc9, 0x66, -0xa6, 0x3a, 0x56, 0x23, 0x3d, 0xee, 0x93, -0x57, 0x2a, 0xca, 0x63, 0x6a, 0xb3, 0x77, -0x82, 0xac, 0xe0, 0xe4, 0x23, 0xd0, 0x16, -0x3, 0x7c, 0x3a, 0x74, 0x7b, 0xc3, 0xa6, -0xbe, 0x72, 0xe1, 0x9a, 0xe7, 0x73, 0x6e, -0xcb, 0x70, 0x74, 0x7e, 0xab, 0xac, 0xec, -0x80, 0x57, 0xa6, 0x38, 0x68, 0x8f, 0x54, -0x41, 0xa9, 0xb, 0x0, 0x77, 0x2, 0xa8, -0xad, 0x92, 0x64, 0x6d, 0xd2, 0xee, 0x2f, -0x2c, 0x42, 0x40, 0xec, 0x4a, 0x45, 0x33, -0x4f, 0x55, 0xc, 0x4b, 0x51, 0x3c, 0x10, -0x22, 0x27, 0xa4, 0xe1, 0x89, 0x3a, 0x90, -0xe5, 0xe0, 0x97, 0x10, 0xe2, 0x89, 0x63, -0x16, 0xb9, 0x59, 0x1e, 0xcb, 0xf2, 0xb0, -0xe8, 0xbf, 0x7b, 0x5a, 0x8f, 0x67, 0xec, -0xb0, 0x98, 0xb0, 0x4b, 0xed, 0x5b, 0xd8, -0xbe, 0x4f, 0x33, 0xb9, 0x5, 0xb4, 0x4d, -0x40, 0x91, 0x83, 0x5d, 0xc, 0x9b, 0x56, -0x60, 0xa8, 0xdc, 0xf9, 0xdd, 0xfb, 0xb5, -0x6, 0xcd, 0x6d, 0xc2, 0x44, 0x9a, 0xdd, -0xf, 0x1a, 0xe0, 0x18, 0x62, 0xb0, 0x90, -0xb1, 0xed, 0xa9, 0x11, 0xcb, 0x8c, 0x1, -0xb2, 0x78, 0x62, 0x9a, 0x8f, 0x37, 0x2, -0xac, 0xbc, 0xc5, 0x23, 0x36, 0xfd, 0xe, -0x73, 0x15, 0x27, 0x1, 0x17, 0xc9, 0xc6, -0xf5, 0x79, 0x80, 0xee, 0x68, 0x47, 0xb4, -0x8f, 0xfd, 0xdb, 0x11, 0x1c, 0x7f, 0x3e, -0xcd, 0x78, 0xdd, 0x7, 0x80, 0x55, 0xe7, -0xbc, 0xfb, 0x11, 0xe1, 0xca, 0xcf, 0x65, -0x75, 0x5c, 0x73, 0xf2, 0x28, 0x9b, 0x7a, -0x24, 0xd0, 0x9f, 0x43, 0x85, 0xe4, 0x62, -0x8d, 0x90, 0x53, 0xec, 0xcd, 0xba, 0xdc, -0xc3, 0x96, 0x3e, 0x12, 0x22, 0xc, 0x52, -0x59, 0x8c, 0xa3, 0x18, 0x86, 0x6b, 0xbe, -0xc8, 0x65, 0x66, 0xe2, 0x6e, 0x1c, 0xfc, -0x7b, 0x8c, 0xd5, 0xaa, 0xcc, 0xc2, 0xb9, -0x3, 0x1e, 0xf2, 0x10, 0x92, 0x45, 0xf1, -0xf0, 0xe0, 0xf, 0x68, 0x4a, 0x92, 0xf8, -0x6d, 0x19, 0x83, 0xf9, 0xe7, 0xe9, 0xb2, -0x47, 0x17, 0xd6, 0x39, 0x59, 0x55, 0xd3, -0x96, 0xd0, 0xfd, 0xe7, 0xdc, 0xb7, 0x12, -0x35, 0xbe, 0xaa, 0xb0, 0xc4, 0xe8, 0x83, -0x25, 0xc0, 0x42, 0xc4, 0x42, 0xd9, 0x41, -0x38, 0xcd, 0xcb, 0x86, 0x58, 0x83, 0x2c, -0xef, 0xf4, 0x90, 0x95, 0x56, 0x6, 0x24, -0x1, 0x5, 0x4c, 0xdc, 0xcd, 0x80, 0xa6, -0xd6, 0x4, 0xc0, 0xd4, 0xc3, 0x42, 0x99, -0x8c, 0xa4, 0x97, 0x98, 0x4f, 0xaf, 0x98, -0x27, 0x47, 0x62, 0x9b, 0x25, 0x94, 0xaf, -0x27, 0x61, 0x6c, 0x13, 0x7d, 0x5f, 0x1a, -0x3d, 0x43, 0x3d, 0x49, 0x3e, 0x96, 0x1f, -0x8d, 0xc3, 0x5c, 0x17, 0x3, 0x3c, 0xe, -0xd, 0xc5, 0xf7, 0x21, 0x5c, 0xcc, 0x81, -0x3c, 0x49, 0xfa, 0xfd, 0x1c, 0xc5, 0x7d, -0x51, 0x34, 0x5d, 0xcd, 0x6a, 0x67, 0x7e, -0x63, 0x9a, 0x57, 0xd3, 0x49, 0x94, 0xda, -0x7b, 0xb1, 0xa7, 0xf, 0xc0, 0xcb, 0xe6, -0x8a, 0x94, 0x2e, 0x6e, 0xc7, 0x49, 0xf8, -0x7f, 0xea, 0xe2, 0xe3, 0xb3, 0x46, 0x19, -0x5, 0xaf, 0x9f, 0x7e, 0x65, 0x42, 0xd8, -0x18, 0xa4, 0xf2, 0x31, 0xa3, 0x1f, 0xb3, -0x93, 0x8b, 0xe5, 0x5c, 0x5e, 0x44, 0xd3, -0xc5, 0xce, 0xd0, 0xe, 0x4d, 0xe9, 0x70, -0x4f, 0x57, 0xa4, 0x18, 0x5f, 0x26, 0xc, -0x46, 0x74, 0x7e, 0xf4, 0x55, 0x5d, 0xc, -0x16, 0xc9, 0xcc, 0xc5, 0xe9, 0x42, 0xfa, -0x60, 0xbf, 0x62, 0x4f, 0x46, 0x38, 0x9c, -0x2a, 0x26, 0x86, 0x73, 0xab, 0x24, 0x29, -0x23, 0x49, 0x72, 0x9e, 0x8c, 0x97, 0xf2, -0x5b, 0x54, 0xbe, 0xf8, 0x4, 0x1d, 0xa5, -0xe7, 0x21, 0x9d, 0xa0, 0x5e, 0xf7, 0xbf, -0x1c, 0xfe, 0xec, 0xee, 0x28, 0xac, 0x6, -0x6e, 0xc6, 0x3a, 0x4f, 0xe4, 0xf3, 0xb5, -0x27, 0x98, 0x28, 0x84, 0xef, 0x62, 0xf, -0xc0, 0x14, 0x1c, 0xf6, 0x63, 0x88, 0xdf, -0x2, 0xfb, 0x84, 0x76, 0x6a, 0x1f, 0x30, -0x3e, 0x77, 0x79, 0x46, 0x9b, 0x24, 0x5b, -0x63, 0x5e, 0x82, 0x7f, 0x43, 0x0, 0xdd, -0x41, 0xc9, 0x61, 0xf6, 0x25, 0x38, 0xee, -0x6b, 0xf, 0xcd, 0xa2, 0x19, 0xcd, 0x21, -0x8e, 0x57, 0x94, 0xcb, 0xda, 0x87, 0x3a, -0xe1, 0xf4, 0xc6, 0x91, 0xce, 0xf6, 0x85, -0x92, 0xf6, 0xf9, 0x55, 0x84, 0x16, 0x7e, -0x88, 0x69, 0x43, 0xbf, 0x9b, 0xd5, 0x14, -0xc6, 0xf2, 0x86, 0xf2, 0x79, 0xae, 0xb8, -0x1d, 0xf, 0xde, 0xcd, 0xf, 0xbf, 0x5f, -0x18, 0x11, 0xd2, 0x83, 0xc1, 0x55, 0x77, -0x6b, 0xdc, 0x13, 0x6d, 0x6e, 0x6, 0x76, -0x9, 0xdc, 0xa2, 0xe5, 0x13, 0xe0, 0xa5, -0x40, 0x30, 0xa7, 0x67, 0x85, 0x82, 0x92, -0xec, 0xaa, 0xa1, 0x1, 0x32, 0x76, 0xd9, -0x20, 0x21, 0xef, 0xe, 0xb, 0x51, 0xee, -0xbd, 0xf1, 0xca, 0x7, 0x8b, 0x3d, 0xb0, -0xca, 0xc1, 0x23, 0x4b, 0x2e, 0x4b, 0x55, -0x1e, 0x82, 0xea, 0x5d, 0x9f, 0x4b, 0x77, -0xc9, 0x7e, 0xb6, 0xe, 0x4b, 0xc6, 0x45, -0x53, 0xa8, 0xfd, 0xcf, 0x8f, 0x66, 0x41, -0x4a, 0x1, 0x79, 0x4f, 0x41, 0x53, 0x67, -0xc2, 0x50, 0xc5, 0xfe, 0xea, 0x66, 0xab, -0x63, 0xe4, 0xed, 0xaa, 0x78, 0xba, 0x59, -0xef, 0x91, 0x15, 0xe7, 0xc1, 0xcf, 0x6b, -0x0, 0xc3, 0x9, 0xba, 0x66, 0x7d, 0x3f, -0x1a, 0x5c, 0x39, 0x89, 0xaf, 0x44, 0x7e, -0x37, 0xe6, 0x8e, 0x5, 0x75, 0xd9, 0xcb, -0xe8, 0x3c, 0x6, 0xc0, 0xca, 0xce, 0xba, -0x27, 0x13, 0x58, 0x5e, 0x17, 0x86, 0x22, -0xfd, 0x57, 0x29, 0xb5, 0x55, 0xb, 0xf7, -0xdc, 0x7d, 0x6b, 0x4e, 0xd6, 0x4c, 0x39, -0x10, 0x71, 0x1f, 0x55, 0xcd, 0x58, 0x5d, -0x4e, 0x4e, 0x5a, 0xee, 0x80, 0x66, 0xae, -0x6e, 0xe6, 0x4e, 0x8f, 0x97, 0xfd, 0x88, -0xba, 0x92, 0xc4, 0x2e, 0x9a, 0xe, 0x15, -0xff, 0xad, 0x1c, 0x21, 0xda, 0x5, 0x8d, -0x6, 0x61, 0x54, 0x2e, 0x6, 0xb1, 0xd1, -0xa1, 0xb, 0x87, 0xe, 0xf6, 0x95, 0x7f, -0xa5, 0xf7, 0x1c, 0x24, 0xa7, 0x5f, 0xab, -0xf7, 0x33, 0x26, 0x6e, 0xb3, 0x53, 0x3, -0xd7, 0x8b, 0x24, 0x8a, 0x83, 0xfe, 0x21, -0x7d, 0xcb, 0x55, 0x37, 0x34, 0x58, 0xdc, -0x7a, 0x1d, 0x62, 0x2a, 0x79, 0xaf, 0x1d, -0xe1, 0x97, 0xfb, 0xbe, 0x37, 0x1d, 0xa7, -0xcd, 0x7f, 0x65, 0x9a, 0x5, 0x8d, 0x4e, -0xe, 0x83, 0x66, 0x9d, 0xb8, 0xbf, 0x30, -0x57, 0xe8, 0xbf, 0x8, 0x8d, 0x91, 0xa3, -0x9b, 0xe4, 0xf6, 0x7, 0xd2, 0xc5, 0x14, -0x0, 0x42, 0x6, 0xaa, 0xe8, 0x32, 0x8e, -0x63, 0x99, 0x5c, 0x88, 0x6a, 0x3a, 0x50, -0xb6, 0x40, 0xf9, 0x0, 0x63, 0xbc, 0x1b, -0x9d, 0xcf, 0xa7, 0x39, 0x18, 0xab, 0x76, -0x87, 0xa1, 0xad, 0x4b, 0xeb, 0x7d, 0x0, -0xab, 0x45, 0x79, 0xb9, 0x17, 0x8b, 0x2a, -0xf8, 0x1c, 0x1, 0x1a, 0x11, 0xda, 0xf2, -0x8, 0x7e, 0x4, 0x66, 0x67, 0xc0, 0xb8, -0xa3, 0x12, 0x4f, 0x57, 0xb2, 0x45, 0xda, -0xbb, 0x93, 0x54, 0x5b, 0xc5, 0xaf, 0x2f, -0xe5, 0x6a, 0x2c, 0xcc, 0x6a, 0x44, 0x9c, -0xe5, 0x10, 0xba, 0x6, 0x27, 0x25, 0xe7, -0x24, 0x31, 0x3a, 0xaf, 0x7d, 0xb1, 0x86, -0x1e, 0xb1, 0xa9, 0x3c, 0xc8, 0xea, 0x9c, -0xa6, 0x93, 0xf2, 0x45, 0x6a, 0xde, 0x13, -0xfb, 0x6, 0x32, 0xd3, 0x4b, 0x4d, 0x83, -0x76, 0x9, 0x12, 0xf2, 0x1e, 0xdc, 0xb2, -0xae, 0x5d, 0x6a, 0x87, 0x5d, 0xbc, 0xd1, -0x94, 0x8, 0xec, 0x1c, 0xf4, 0x61, 0x82, -0x67, 0xa1, 0x33, 0x7c, 0x98, 0x3c, 0xfc, -0x14, 0xdb, 0x4e, 0x0, 0x3f, 0x16, 0x5f, -0x4b, 0x72, 0xe4, 0x89, 0xbc, 0xf4, 0x4c, -0x99, 0x5f, 0x51, 0x4e, 0xfb, 0xb0, 0xaf, -0x29, 0xf4, 0xe2, 0x30, 0x8e, 0x74, 0x5, -0xc0, 0x45, 0xc1, 0xc2, 0xe, 0xde, 0x70, -0x58, 0x9e, 0x80, 0x6d, 0x87, 0x49, 0x83, -0xc2, 0xaa, 0x25, 0x46, 0x94, 0x8e, 0x23, -0x21, 0x0, 0x3a, 0x43, 0xcf, 0x34, 0x34, -0x1c, 0x42, 0x13, 0x3e, 0x10, 0xd4, 0x1d, -0x35, 0xf3, 0x60, 0x26, 0xe5, 0x69, 0xbd, -0x2c, 0x3c, 0xc6, 0xb, 0xb6, 0xa4, 0xd1, -0x51, 0x22, 0x1, 0xac, 0xb2, 0xab, 0x84, -0x21, 0xdd, 0x7e, 0x50, 0x8b, 0x11, 0x77, -0x1, 0x32, 0x6, 0xd0, 0xf3, 0x7f, 0x28, -0x2c, 0xb5, 0x7e, 0x83, 0x84, 0xc7, 0x41, -0x5e, 0xc1, 0xd6, 0x14, 0x21, 0xcf, 0x84, -0x69, 0xff, 0x1a, 0xf4, 0x3d, 0xca, 0x53, -0x8b, 0x30, 0x83, 0x96, 0xc9, 0xef, 0xa1, -0xc6, 0x9e, 0xc6, 0x7d, 0x55, 0x5d, 0xb7, -0x7, 0x16, 0x4, 0x77, 0x12, 0xb2, 0xc5, -0x55, 0xa0, 0x32, 0xc0, 0x1, 0xae, 0xdb, -0x1, 0x9b, 0x8f, 0x81, 0xf2, 0xc7, 0xb1, -0xef, 0x75, 0x87, 0x1, 0x5e, 0x8c, 0x75, -0x7f, 0x42, 0x3, 0x45, 0x2f, 0x45, 0x15, -0x69, 0xa6, 0x81, 0xd0, 0x31, 0x69, 0x30, -0x7c, 0xc0, 0xc0, 0xa6, 0x24, 0xd5, 0xca, -0xc2, 0xe0, 0x26, 0xee, 0xc7, 0xa0, 0x6b, -0x83, 0xe0, 0x83, 0x6b, 0xee, 0xab, 0xa8, -0xe4, 0x1e, 0x5f, 0x48, 0x54, 0xd4, 0x40, -0x5c, 0xd, 0x2e, 0x63, 0xf4, 0xde, 0x9a, -0x76, 0xb, 0xc1, 0x26, 0x73, 0x53, 0xfd, -0x1b, 0xac, 0xf1, 0x60, 0x5a, 0x9d, 0xb6, -0x7a, 0x54, 0x81, 0xcd, 0x31, 0xb5, 0xd9, -0x66, 0x40, 0xae, 0x11, 0xc6, 0xf3, 0x93, -0x8f, 0xfe, 0x28, 0x3, 0x8e, 0x20, 0x36, -0xb7, 0x1f, 0xab, 0xd3, 0x99, 0xb9, 0x4c, -0x5, 0x72, 0xfc, 0x16, 0xe1, 0x78, 0xb8, -0xa4, 0x1b, 0x8c, 0xe2, 0xf7, 0x1e, 0x62, -0x9e, 0x4b, 0x57, 0x2d, 0x47, 0x87, 0x34, -0x55, 0xaa, 0x7f, 0xfd, 0x6b, 0x5e, 0x3a, -0x3f, 0xc0, 0xb3, 0x69, 0xe8, 0x58, 0x11, -0x3d, 0x7, 0xb, 0x79, 0x4c, 0xae, 0xc9, -0x39, 0x87, 0x27, 0xba, 0x67, 0x79, 0xcd, -0x2a, 0x78, 0x81, 0x47, 0x24, 0xaf, 0x83, -0xc, 0xd, 0xfb, 0xe1, 0xc5, 0x1a, 0xc2, -0x38, 0x36, 0xe6, 0xfa, 0x4f, 0xb3, 0xe4, -0xa3, 0x1a, 0xc5, 0x9b, 0x16, 0x87, 0xb4, -0x7f, 0xd2, 0x9d, 0xf5, 0xde, 0xba, 0x9d, -0x13, 0xc, 0x75, 0x30, 0x48, 0xe6, 0x91, -0x11, 0x98, 0x30, 0x6d, 0xa8, 0x9, 0xc5, -0x76, 0x45, 0x64, 0x54, 0x8a, 0xa1, 0xd6, -0xa0, 0xdd, 0x5f, 0x9e, 0x6b, 0x86, 0x49, -0xbe, 0xf8, 0x99, 0xdf, 0x40, 0x5a, 0x18, -0x2e, 0xe8, 0x98, 0x68, 0x2, 0xbc, 0xa6, -0xfe, 0x15, 0xe9, 0x4a, 0x7, 0x9f, 0x18, -0x34, 0x41, 0x9, 0x73, 0x47, 0xd7, 0x0, -0x5, 0x99, 0x80, 0x4, 0x58, 0x3, 0x24, -0x12, 0x59, 0x69, 0xcf, 0x2b, 0xb4, 0x11, -0xd7, 0x8, 0xa6, 0xfa, 0x86, 0xb4, 0xe0, -0x32, 0x5e, 0x9f, 0x8d, 0xbb, 0x91, 0xe3, -0x83, 0x83, 0x8c, 0x26, 0x9e, 0x71, 0x26, -0x8c, 0xbc, 0x3a, 0x84, 0x2a, 0xba, 0xe2, -0x55, 0x75, 0xa8, 0x52, 0x9, 0x91, 0xeb, -0xef, 0x8f, 0x6c, 0x2a, 0xa8, 0x88, 0x8a, -0xc5, 0xd1, 0x5d, 0x4a, 0x5f, 0xe, 0xac, -0xe2, 0xc9, 0xd3, 0x36, 0xf4, 0xa9, 0x1a, -0x37, 0xbd, 0x1, 0xb9, 0x4, 0x4d, 0x86, -0x8c, 0x4d, 0x6b, 0xce, 0x6a, 0x6c, 0xba, -0x6c, 0x4d, 0xc5, 0x34, 0x54, 0x1d, 0xe5, -0x61, 0x85, 0x6d, 0x53, 0xc3, 0xf8, 0x75, -0x17, 0xad, 0xbc, 0xd4, 0x66, 0x76, 0x8a, -0x84, 0xb6, 0xd7, 0x42, 0xaf, 0x9b, 0xaf, -0xbd, 0xee, 0xaf, 0x51, 0xe5, 0x1c, 0x17, -0x57, 0x66, 0x6e, 0xac, 0x93, 0x8d, 0xef, -0xaf, 0xaf, 0xb4, 0xa1, 0x3, 0xfe, 0x82, -0x86, 0xa6, 0xa6, 0xc4, 0x30, 0x17, 0x5c, -0x90, 0x8e, 0xa1, 0x17, 0xa8, 0x92, 0x23, -0x1d, 0xc, 0x57, 0xbc, 0x24, 0xcb, 0x7b, -0x7c, 0x72, 0x93, 0x2a, 0xf0, 0x78, 0xf6, -0xa6, 0x71, 0xb, 0x81, 0x2a, 0x41, 0x37, -0xda, 0xfd, 0xc1, 0xc1, 0xc3, 0x5d, 0x29, -0x59, 0x99, 0xe1, 0x78, 0x9d, 0x7e, 0x2c, -0xba, 0xf7, 0xf5, 0x99, 0xb1, 0x2b, 0x51, -0x26, 0xb5, 0x93, 0xae, 0x1e, 0xd1, 0x94, -0xdf, 0x30, 0x55, 0x10, 0xa4, 0xe6, 0xb9, -0x33, 0x74, 0xb2, 0x4c, 0x5e, 0xdf, 0x83, -0xf1, 0xd4, 0x2c, 0x3e, 0x46, 0x55, 0xed, -0xb, 0x16, 0x71, 0xb2, 0xf7, 0xac, 0x69, -0x3d, 0x7b, 0x31, 0x70, 0xf9, 0xc3, 0x38, -0xdc, 0x8d, 0xaa, 0x56, 0x81, 0x2c, 0x21, -0x3c, 0xb5, 0x16, 0x5c, 0x98, 0xfe, 0x53, -0x6c, 0x7d, 0x8b, 0x3c, 0xc9, 0x35, 0x1f, -0x8, 0xd2, 0x41, 0x4e, 0x2b, 0x7, 0xaa, -0xde, 0x85, 0xc4, 0x77, 0xe5, 0xfb, 0xec, -0x7f, 0x48, 0x6a, 0x94, 0x73, 0xbf, 0xa3, -0x77, 0x34, 0xb7, 0xe3, 0x90, 0xa6, 0x99, -0xb8, 0x2f, 0x7d, 0x0, 0xef, 0x5f, 0xd7, -0xa7, 0x10, 0x16, 0xf9, 0xd5, 0x98, 0x79, -0xd4, 0x49, 0x57, 0xf0, 0x4b, 0x70, 0xed, -0x2f, 0x81, 0x53, 0x35, 0x1d, 0xef, 0x82, -0xa7, 0x15, 0xcb, 0x69, 0x59, 0x90, 0x1d, -0x5c, 0x58, 0xc2, 0x1c, 0x73, 0x2a, 0x5a, -0xd4, 0x13, 0x6e, 0xa, 0x15, 0xc0, 0xc5, -0x64, 0xea, 0xd1, 0xf1, 0x14, 0x62, 0x97, -0xb1, 0x7e, 0x8c, 0xa0, 0x8c, 0xbd, 0xe3, -0x6b, 0x11, 0x71, 0xb0, 0xff, 0xf7, 0xe0, -0xa, 0x2d, 0xaa, 0x8, 0x64, 0x65, 0x6b, -0x32, 0xe5, 0x87, 0x40, 0x4d, 0x87, 0xa7, -0xb3, 0x8b, 0x26, 0x79, 0xd, 0xed, 0x99, -0x5c, 0xae, 0x4e, 0x2b, 0x5d, 0x21, 0xb6, -0xc4, 0xf0, 0x1b, 0x47, 0xc4, 0xcc, 0xc3, -0x62, 0xc3, 0x77, 0x54, 0x45, 0x4, 0x66, -0x99, 0xeb, 0x51, 0x44, 0x6e, 0xb9, 0x7c, -0xd5, 0x90, 0x68, 0xa8, 0x77, 0xcf, 0x3e, -0xe6, 0x20, 0xc9, 0xbc, 0x2f, 0xf1, 0x91, -0x11, 0xc, 0x36, 0x12, 0xec, 0xd6, 0xcb, -0xfe, 0xcf, 0x38, 0x5, 0x39, 0x9e, 0x9, -0xae, 0x54, 0x25, 0x78, 0xa9, 0x64, 0xc4, -0xd1, 0x83, 0x45, 0xac, 0x73, 0xdd, 0x96, -0x88, 0x52, 0x7, 0xf, 0x6e, 0x2d, 0xa4, -0x0, 0xc3, 0xbd, 0xd2, 0xcc, 0xd1, 0xb0, -0xd2, 0x9d, 0xf4, 0xc6, 0xbe, 0xcd, 0x95, -0x11, 0xed, 0x62, 0x4, 0x8, 0x23, 0x5, -0x88, 0xc7, 0x3d, 0x76, 0x81, 0x5, 0x9a, -0x6f, 0x5a, 0x2a, 0xd6, 0xbb, 0x7c, 0x3, -0x34, 0xea, 0x35, 0x9b, 0x75, 0x6c, 0x44, -0x18, 0xb0, 0x61, 0xd6, 0x6c, 0x6e, 0xf9, -0xfd, 0x12, 0x9c, 0x17, 0xc3, 0x89, 0x16, -0x3d, 0x8d, 0x6, 0x47, 0x5d, 0x99, 0xc9, -0x9a, 0x7c, 0xdf, 0xb3, 0xc2, 0x5f, 0x4, -0xf2, 0xf3, 0xb7, 0x72, 0xf8, 0x3, 0x4c, -0xe1, 0x53, 0x18, 0x13, 0x5f, 0xbd, 0x74, -0x9f, 0xa1, 0xc9, 0xa8, 0x5, 0x4c, 0xb6, -0x9d, 0xa1, 0xd5, 0x29, 0xec, 0x44, 0x7a, -0x61, 0xe8, 0x74, 0x12, 0x30, 0x32, 0xa4, -0x1f, 0x32, 0xaf, 0x44, 0x4, 0xe3, 0x8, -0x94, 0xbd, 0x13, 0x9f, 0x19, 0x12, 0x68, -0x87, 0x2e, 0x9c, 0xa0, 0xe5, 0x5a, 0xd, -0x4d, 0x88, 0x8f, 0x3b, 0xfb, 0x7c, 0xd6, -0xf7, 0x76, 0x7c, 0x69, 0x9c, 0x41, 0x8c, -0xa0, 0xeb, 0x3c, 0x2a, 0xdd, 0xbd, 0x26, -0x85, 0x61, 0xd2, 0x80, 0x25, 0xa1, 0xdc, -0xc7, 0x92, 0xd7, 0xe6, 0xa9, 0xdf, 0x6c, -0xf3, 0x64, 0xc3, 0x93, 0xaf, 0xef, 0xe8, -0xd1, 0xc4, 0x23, 0x1a, 0xe1, 0xa0, 0xac, -0xc2, 0x9c, 0x3e, 0x54, 0xaf, 0x7a, 0xe1, -0x67, 0xe1, 0x2b, 0x9d, 0xa, 0xa4, 0xe9, -0x6, 0x2, 0xfa, 0x98, 0xd, 0xd8, 0xdf, -0x37, 0xa6, 0x21, 0xe2, 0x8b, 0xd0, 0xe0, -0x27, 0xee, 0xa0, 0x9b, 0xf0, 0xc9, 0xe, -0xfc, 0xad, 0x8, 0x9f, 0x5e, 0x8b, 0x2d, -0xf0, 0x45, 0x45, 0x55, 0x29, 0xd1, 0xe3, -0xb3, 0x95, 0x81, 0x0, 0x86, 0x44, 0x36, -0x99, 0x78, 0x3e, 0x76, 0xb7, 0xa, 0x88, -0xda, 0xb6, 0x6f, 0xb6, 0xd2, 0xcd, 0xe0, -0x41, 0x8d, 0x49, 0x49, 0x7b, 0x36, 0xa0, -0x52, 0x22, 0x51, 0xa8, 0xb7, 0xd0, 0x4f, -0x20, 0xef, 0xb, 0xf6, 0x7d, 0x6b, 0x10, -0xde, 0x6e, 0xaf, 0xe8, 0x4a, 0xe6, 0x91, -0xea, 0x2b, 0x7f, 0x7d, 0x97, 0x98, 0xb6, -0xcb, 0x9a, 0x31, 0x76, 0x78, 0xeb, 0x9, -0x10, 0xed, 0x27, 0x29, 0xcd, 0xe6, 0x34, -0x48, 0x9e, 0xb9, 0x3f, 0x89, 0xc, 0x93, -0x65, 0xc0, 0x5, 0x8, 0x2b, 0x5c, 0x82, -0x77, 0x4e, 0x46, 0xdd, 0x7e, 0x5e, 0x42, -0xe0, 0x43, 0xb8, 0x30, 0xd8, 0xb, 0xfc, -0xab, 0xb2, 0x35, 0x55, 0x50, 0x1c, 0xfa, -0xc6, 0x6, 0xaf, 0xff, 0xfe, 0xeb, 0x64, -0x3, 0x5, 0x6e, 0x33, 0x19, 0x57, 0xb0, -0x4f, 0xc6, 0x86, 0x99, 0x1b, 0x3e, 0x9c, -0xb2, 0xb3, 0xf9, 0x2c, 0xba, 0xaf, 0xbb, -0xe6, 0x87, 0x63, 0x2b, 0xd7, 0x22, 0xa0, -0x79, 0xce, 0x17, 0x9f, 0x45, 0x68, 0x3b, -0xd6, 0x55, 0xf1, 0xe0, 0x22, 0x9c, 0x25, -0x9a, 0x5b, 0xa5, 0xd1, 0xcd, 0x8f, 0x2c, -0x3c, 0x35, 0x93, 0x36, 0x66, 0x3a, 0x32, -0xa1, 0x43, 0x3, 0xd4, 0xe3, 0xf3, 0xbe, -0xdd, 0x36, 0xd7, 0x1c, 0xdb, 0xf9, 0x33, -0xab, 0x59, 0x3c, 0x18, 0xb1, 0x79, 0xd5, -0x24, 0x7, 0x70, 0xd0, 0x43, 0xf6, 0xf7, -0x61, 0x72, 0xef, 0xc5, 0x8e, 0x7b, 0xd0, -0x92, 0x7b, 0x6a, 0x4d, 0x98, 0x43, 0xf6, -0xfa, 0xb2, 0x4d, 0xde, 0x1f, 0xbf, 0xe2, -0x69, 0x75, 0x9d, 0x3a, 0x12, 0x24, 0xe6, -0xf2, 0xd0, 0xb2, 0x6e, 0x35, 0x43, 0x1c, -0x14, 0xc6, 0x7f, 0xa4, 0x5d, 0x6f, 0x80, -0xfe, 0x64, 0x60, 0x88, 0xbe, 0x74, 0x85, -0x88, 0x24, 0x6, 0xe2, 0xe5, 0xb5, 0xdc, -0xc7, 0x4b, 0x16, 0xcc, 0x11, 0xec, 0xb5, -0xbc, 0x31, 0xc8, 0xa3, 0x24, 0x13, 0x16, -0xe6, 0xa5, 0xdb, 0x14, 0x9b, 0x75, 0x25, -0x9, 0xc8, 0x28, 0x68, 0xa6, 0x8c, 0x7f, -0x80, 0x5c, 0x48, 0x70, 0x47, 0x1e, 0x6a, -0x14, 0x17, 0xbc, 0x84, 0x16, 0xb7, 0x7, -0x5f, 0x25, 0x3a, 0x7d, 0x6f, 0x3, 0x8f, -0xe8, 0xb7, 0x1c, 0x14, 0xff, 0x73, 0xc8, -0xd4, 0x94, 0x3c, 0x37, 0x77, 0xec, 0x8f, -0x95, 0xf4, 0xf3, 0x8a, 0x0, 0x4, 0x8a, -0x3e, 0xb5, 0x77, 0xc0, 0x7b, 0x5f, 0x7b, -0xb3, 0xe0, 0xe8, 0xd4, 0x9a, 0xfd, 0x90, -0xb6, 0x61, 0xe7, 0x61, 0x9, 0x80, 0xfd, -0x47, 0x68, 0xb0, 0x28, 0x92, 0x94, 0x3a, -0x3e, 0xcd, 0x1b, 0x3e, 0xed, 0xc0, 0xc0, -0x24, 0x14, 0x9a, 0xce, 0x32, 0x46, 0xe3, -0x6d, 0xef, 0x29, 0xa0, 0x8b, 0x14, 0xc, -0x8a, 0x7b, 0x2f, 0xde, 0xba, 0xb6, 0x4e, -0xf4, 0x46, 0x39, 0xe5, 0x2c, 0x76, 0xa1, -0x9d, 0xf2, 0x64, 0xfa, 0xbc, 0xac, 0x7a, -0x9d, 0xef, 0x8, 0x38, 0xc, 0xaf, 0xc, -0xff, 0xd3, 0x3a, 0x58, 0x9c, 0xdb, 0xae, -0x7c, 0x16, 0x36, 0x45, 0xba, 0x4f, 0xd1, -0xcf, 0xbf, 0x3a, 0x5a, 0x99, 0xf8, 0x66, -0x65, 0x7a, 0xcb, 0x93, 0xad, 0xba, 0x40, -0x66, 0x60, 0xb5, 0x32, 0x10, 0x88, 0xe5, -0xd5, 0xc5, 0xfe, 0xf3, 0x18, 0xa4, 0x62, -0xff, 0x3, 0x9, 0x9a, 0xf6, 0x13, 0x1d, -0x1d, 0x6f, 0xa1, 0xf9, 0xa9, 0xe0, 0x21, -0x40, 0x57, 0x59, 0x4f, 0x52, 0xa5, 0x22, -0xb1, 0x30, 0xa8, 0xa1, 0x55, 0x5f, 0x82, -0x2d, 0xf4, 0x58, 0x94, 0x77, 0x3f, 0x7b, -0xaf, 0x30, 0xaf, 0x91, 0xcd, 0xb0, 0x63, -0x60, 0x80, 0x9f, 0xf3, 0xd9, 0xb2, 0xd, -0x15, 0xc5, 0xab, 0xa4, 0x18, 0xa5, 0x5c, -0x9b, 0x2a, 0x3e, 0x5f, 0x52, 0x26, 0xa2, -0x71, 0xe, 0x64, 0xcb, 0xb0, 0x59, 0x9d, -0x1a, 0x65, 0xa4, 0x8a, 0x7, 0xcd, 0x6a, -0x31, 0xe8, 0xf9, 0x1, 0x41, 0x7e, 0x69, -0x98, 0x55, 0x4a, 0xee, 0xcc, 0x28, 0x35, -0x23, 0x38, 0xd7, 0xeb, 0xe6, 0x41, 0x91, -0x5e, 0xf8, 0xa8, 0x25, 0x67, 0x44, 0x75, -0xd, 0xaf, 0x0, 0xff, 0x83, 0xd2, 0xd2, -0xc2, 0xd4, 0xf7, 0xbb, 0xcd, 0x87, 0x84, -0xe1, 0x90, 0x0, 0xfb, 0x85, 0xd1, 0x12, -0xac, 0x36, 0x72, 0xb6, 0x57, 0xae, 0x41, -0x47, 0x1e, 0x1, 0x5d, 0x38, 0x48, 0xb2, -0x6e, 0xd9, 0xe4, 0xda, 0x9b, 0xba, 0xcc, -0xf5, 0x7, 0x91, 0xf6, 0xb0, 0xe8, 0x1d, -0x4c, 0x88, 0x6e, 0x28, 0xf2, 0x1b, 0x3d, -0xe0, 0x33, 0xd1, 0xdd, 0x4b, 0x68, 0xd7, -0x8f, 0xcd, 0xc9, 0x43, 0x74, 0x36, 0x69, -0xa7, 0xe9, 0x2d, 0xa6, 0x75, 0x59, 0xb, -0x49, 0x24, 0x27, 0xb6, 0x1d, 0xc9, 0xa, -0x4, 0x61, 0xce, 0x6e, 0x8b, 0x0, 0x88, -0x72, 0x46, 0x40, 0xaa, 0xc5, 0x92, 0xf2, -0x2e, 0xf, 0x29, 0x9d, 0xc9, 0xa3, 0x5b, -0x39, 0xe5, 0xde, 0xf1, 0x26, 0x2a, 0xd4, -0x1a, 0x1e, 0x1c, 0x33, 0x20, 0x58, 0x6e, -0x2b, 0xd9, 0xf4, 0x81, 0x77, 0xcd, 0x47, -0xba, 0x98, 0x2c, 0x2f, 0xf5, 0x9, 0x8d, -0xe5, 0xd0, 0xa2, 0x9f, 0x11, 0x4, 0xf9, -0xc2, 0x5e, 0xe8, 0x66, 0xa9, 0x66, 0xb5, -0xee, 0x12, 0x2d, 0x43, 0x85, 0xa3, 0x57, -0x9a, 0x7a, 0x29, 0xc3, 0x6a, 0x65, 0xca, -0xa2, 0x3b, 0x34, 0x84, 0x35, 0xd8, 0x39, -0xda, 0x71, 0xb6, 0xd0, 0xda, 0xe9, 0x4, -0x3e, 0x95, 0x3, 0x72, 0x6e, 0x4b, 0x4d, -0x58, 0x97, 0x1b, 0x4c, 0x31, 0xb2, 0x5d, -0xf, 0x3b, 0x44, 0x4, 0x0, 0x8c, 0x9f, -0xfa, 0x40, 0x3d, 0x8f, 0xa4, 0x70, 0x4b, -0x38, 0x69, 0xcf, 0x4f, 0xc, 0xd5, 0xc7, -0x2a, 0x24, 0xec, 0xb6, 0x5d, 0x6, 0xcd, -0x69, 0x88, 0x41, 0x27, 0x37, 0xc3, 0x23, -0x43, 0x87, 0x28, 0x70, 0x31, 0x74, 0x77, -0x8b, 0xca, 0x4b, 0x73, 0x4a, 0x33, 0xbb, -0xb7, 0xa0, 0x68, 0xe6, 0x27, 0x1e, 0x6d, -0xc5, 0xf5, 0x49, 0x74, 0x5e, 0x7c, 0xbe, -0xb1, 0x25, 0x5b, 0x2, 0x91, 0x8f, 0xde, -0x35, 0x5d, 0x5b, 0xfd, 0xc0, 0xe0, 0x3d, -0x7e, 0x5b, 0x56, 0x1a, 0x15, 0x77, 0x69, -0x1, 0x7b, 0x2d, 0x4e, 0x86, 0xb9, 0x1b, -0x5a, 0x1d, 0xc4, 0x4e, 0x7f, 0x5, 0x31, -0x58, 0x2c, 0xf5, 0xdd, 0xeb, 0xb8, 0x2d, -0x4e, 0x5c, 0xa2, 0xc0, 0x94, 0x60, 0xde, -0xc0, 0x2c, 0xb7, 0x1b, 0x9d, 0xff, 0x15, -0x99, 0x9d, 0x34, 0x84, 0x8e, 0xf8, 0x32, -0xa, 0xb4, 0xc3, 0xe4, 0x8c, 0xf6, 0x9e, -0x5f, 0xc1, 0xde, 0x71, 0x85, 0xe7, 0xc8, -0x8f, 0x77, 0x5b, 0xf4, 0x69, 0x50, 0xcf, -0x86, 0xda, 0x9a, 0x52, 0x11, 0x1e, 0x9d, -0x93, 0xb2, 0xb7, 0x5, 0x4a, 0x3b, 0xf3, -0x30, 0xd9, 0x6d, 0xe0, 0x6f, 0x50, 0x28, -0xcd, 0x8, 0x1a, 0x99, 0x3e, 0x7e, 0xd3, -0x90, 0x97, 0x66, 0xb9, 0x3a, 0x97, 0xb2, -0xb5, 0xea, 0x6d, 0x28, 0xa9, 0x35, 0x50, -0x0, 0x12, 0x94, 0xc5, 0xd3, 0xcc, 0x4b, -0x52, 0x7d, 0x2a, 0x2e, 0x92, 0x19, 0xde, -0x61, 0xf8, 0x21, 0x33, 0x13, 0xc5, 0x3, -0x7f, 0x33, 0x3, 0x13, 0x2e, 0xa7, 0x9f, -0x38, 0xe9, 0x5c, 0xd, 0xa3, 0xda, 0x4f, -0xd9, 0xb3, 0x5f, 0x9, 0xdd, 0x58, 0xa2, -0x80, 0x20, 0x89, 0x30, 0x14, 0x34, 0xb5, -0x5, 0x71, 0x84, 0x25, 0x68, 0x24, 0x37, -0x30, 0x53, 0x19, 0xa1, 0xe0, 0xac, 0x52, -0x65, 0x49, 0x5e, 0x3b, 0xca, 0xcc, 0xb7, -0xc3, 0xe2, 0xce, 0xfb, 0x90, 0x42, 0x1e, -0xbe, 0x94, 0xb0, 0xa1, 0x19, 0x8f, 0xde, -0x5, 0xde, 0x69, 0x16, 0x39, 0x72, 0x4e, -0x94, 0x45, 0x6a, 0xe4, 0xf1, 0x30, 0x25, -0xc1, 0xd5, 0xf, 0xcb, 0xe7, 0xa1, 0x31, -0x66, 0x4b, 0xae, 0x36, 0x7b, 0xfd, 0x88, -0x48, 0x25, 0x44, 0xd7, 0x85, 0xeb, 0xce, -0xcd, 0x2b, 0xec, 0x63, 0x82, 0xbf, 0xc5, -0x17, 0xb9, 0x5, 0xb, 0x14, 0x9, 0x1f, -0x98, 0xb6, 0x6, 0x38, 0xc8, 0x20, 0x58, -0x4, 0xc7, 0xf8, 0x95, 0xc8, 0xaa, 0xee, -0x1f, 0x88, 0x2f, 0xc1, 0x3f, 0x4f, 0x3d, -0x7b, 0x4a, 0xdd, 0xfc, 0x11, 0x2a, 0xaf, -0x11, 0xd, 0xbf, 0xe6, 0xd3, 0xa3, 0x2c, -0xd1, 0x2b, 0xb9, 0x7a, 0xaa, 0xad, 0xc6, -0x2d, 0xbb, 0x22, 0x84, 0x98, 0x2, 0x4d, -0x1f, 0x37, 0x6b, 0x86, 0xd7, 0xdd, 0xbc, -0x1f, 0x69, 0x44, 0x87, 0x70, 0xe, 0x3f, -0x4e, 0xe, 0x76, 0xdb, 0x18, 0x4a, 0x8e, -0x3d, 0x65, 0x3b, 0xae, 0x7e, 0xca, 0x6c, -0x8d, 0x7f, 0x6a, 0xf9, 0x38, 0xf6, 0x25, -0x55, 0xc1, 0xd8, 0x4c, 0xd0, 0xb6, 0x2c, -0x8e, 0x15, 0xa, 0x88, 0x63, 0xd3, 0xda, -0xda, 0xab, 0xf3, 0x22, 0x9d, 0xd1, 0x26, -0x1b, 0x13, 0x3d, 0x9d, 0x90, 0x3b, 0xd6, -0xb9, 0x92, 0xfd, 0x21, 0x5f, 0xb2, 0xb8, -0xe6, 0xa6, 0xd7, 0xb9, 0x29, 0x13, 0x5e, -0xa3, 0x22, 0x1c, 0x31, 0xc2, 0xd6, 0xd7, -0xa9, 0x5a, 0x14, 0xf6, 0x4, 0x7f, 0xba, -0x92, 0x49, 0x41, 0x4c, 0x14, 0xb1, 0xe, -0x26, 0xc0, 0x6c, 0xa9, 0xe3, 0x8c, 0xf7, -0xd3, 0xa8, 0x1f, 0x2, 0xd6, 0xc0, 0x1a, -0xf1, 0x5f, 0x7e, 0xd2, 0x13, 0xb5, 0xd2, -0xb1, 0xf9, 0x44, 0x57, 0x9d, 0xd1, 0x1d, -0xb6, 0x55, 0x20, 0x2a, 0x68, 0x52, 0xaf, -0xa9, 0x6e, 0x28, 0x41, 0x9, 0x2b, 0xe8, -0x49, 0x6d, 0x13, 0x32, 0x83, 0xd8, 0x1d, -0x86, 0xf2, 0x73, 0x53, 0xcb, 0x89, 0x92, -0xf1, 0xd8, 0x8e, 0xab, 0xab, 0xce, 0x32, -0xe5, 0x8e, 0xda, 0xab, 0xbe, 0xcd, 0x8b, -0x9c, 0xe0, 0xd0, 0x23, 0xfc, 0x1e, 0x1f, -0xf9, 0x94, 0x4f, 0x26, 0xa2, 0x86, 0xfe, -0x26, 0x50, 0x51, 0xf6, 0xdd, 0x1b, 0x7f, -0x7c, 0x13, 0xe8, 0xcc, 0x91, 0x77, 0x1f, -0xe7, 0xc0, 0x54, 0x2a, 0xe9, 0x60, 0xf3, -0x8b, 0x8e, 0x58, 0x2a, 0x24, 0x15, 0x0, -0x48, 0xa3, 0x9c, 0x68, 0xa3, 0x6a, 0x21, -0x89, 0xf1, 0x62, 0x92, 0xa8, 0x78, 0x18, -0x3e, 0x95, 0x62, 0x2b, 0xfa, 0x76, 0xa1, -0xa1, 0xfb, 0xed, 0x16, 0x89, 0xef, 0x74, -0xbb, 0x16, 0xef, 0x78, 0x9c, 0x4, 0xb2, -0x51, 0xe1, 0x15, 0x5f, 0xf3, 0xd5, 0x21, -0xf8, 0x54, 0x76, 0xfd, 0xda, 0xd9, 0x70, -0x81, 0xd2, 0x45, 0x29, 0x8, 0xf8, 0xfd, -0x21, 0x56, 0x82, 0x59, 0x5, 0x70, 0x29, -0xe9, 0x1, 0x55, 0xb6, 0xc5, 0x53, 0xee, -0x30, 0x18, 0xa7, 0xae, 0x9f, 0xc4, 0x2c, -0xd, 0x4d, 0x13, 0x9, 0x48, 0xde, 0x91, -0xcf, 0x3, 0xdd, 0xf5, 0xe8, 0xb3, 0x50, -0x82, 0x99, 0x75, 0x83, 0x72, 0x55, 0xb2, -0x6b, 0x95, 0x1e, 0xeb, 0x5a, 0x2c, 0xd1, -0xc3, 0x38, 0xc8, 0xd5, 0x5f, 0x2d, 0x3e, -0xd9, 0xc, 0xea, 0xc7, 0xb8, 0x5c, 0x9, -0x24, 0x21, 0xbd, 0x2a, 0x31, 0x75, 0x94, -0xe7, 0x8, 0x35, 0x25, 0x5a, 0xf, 0x25, -0x59, 0xfe, 0xf7, 0x96, 0x75, 0x5b, 0xd1, -0xd6, 0x91, 0x3b, 0xcf, 0x6d, 0x5f, 0xbd, -0x40, 0x59, 0x5e, 0xbe, 0xde, 0xf, 0x36, -0x97, 0x85, 0x9e, 0xa6, 0x95, 0xf6, 0xa0, -0x18, 0x44, 0xaf, 0x56, 0x8c, 0x65, 0x48, -0x81, 0x91, 0xfe, 0x87, 0x60, 0x7, 0xa9, -0x91, 0xb7, 0xed, 0xb5, 0x7c, 0x63, 0x1d, -0x84, 0x51, 0xd7, 0x15, 0x0, 0xda, 0xa0, -0x39, 0x96, 0xb6, 0x4d, 0x3a, 0x3c, 0x7b, -0xd9, 0xe3, 0x7a, 0x6, 0x31, 0x62, 0x17, -0xfe, 0x84, 0x5f, 0x59, 0xed, 0xa2, 0x45, -0x6, 0xda, 0x41, 0xa9, 0x0, 0xca, 0x60, -0x62, 0x77, 0x27, 0xdf, 0x9a, 0xa, 0x64, -0xc4, 0x7d, 0xbe, 0x8, 0x98, 0x6b, 0xd7, -0x67, 0xe1, 0xca, 0x90, 0x24, 0xc4, 0x34, -0xa5, 0x84, 0x9f, 0xc9, 0xa, 0xdd, 0x36, -0xd1, 0x58, 0x94, 0xcf, 0x68, 0xf7, 0x4b, -0xfd, 0x1f, 0x9a, 0x7f, 0xc0, 0x9c, 0xa0, -0x63, 0x5d, 0x3f, 0x27, 0x60, 0x33, 0x13, -0xef, 0x6d, 0x58, 0xd8, 0x9d, 0x75, 0xfc, -0x9d, 0x73, 0x89, 0xb3, 0x4, 0x8, 0xe, -0x79, 0x8f, 0xe8, 0xfa, 0xde, 0xd8, 0x94, -0x21, 0x97, 0x22, 0x37, 0x2b, 0xdb, 0xe9, -0x2, 0x9f, 0x7, 0xa7, 0xe4, 0xad, 0x79, -0x51, 0xe3, 0xcd, 0x92, 0xeb, 0x72, 0x1b, -0xf1, 0x3d, 0x3f, 0xf4, 0x16, 0xa3, 0x40, -0x50, 0x2, 0x8f, 0xcf, 0x2, 0xfc, 0x33, -0x61, 0x11, 0xea, 0xfb, 0x37, 0x1, 0xbe, -0xa1, 0xc6, 0xee, 0xe8, 0x37, 0x84, 0xd1, -0x9c, 0xfe, 0xbf, 0x23, 0x98, 0x60, 0xb3, -0x49, 0x71, 0x1e, 0xfa, 0xbf, 0x90, 0x73, -0x8f, 0x41, 0xc0, 0xef, 0x70, 0x46, 0xa2, -0x9d, 0x4c, 0x22, 0x92, 0x90, 0xae, 0xd8, -0xee, 0x2a, 0xe2, 0x24, 0xfa, 0x75, 0xe7, -0x63, 0x1a, 0xaa, 0xfa, 0xcf, 0xdc, 0x54, -0x1f, 0x73, 0x63, 0xe3, 0xf9, 0x5e, 0x73, -0xff, 0x11, 0xd2, 0x39, 0x1a, 0xa, 0x38, -0x56, 0x3e, 0xa0, 0xaa, 0xf6, 0x72, 0x4c, -0x36, 0x1a, 0xf, 0xd7, 0xe2, 0x91, 0x46, -0xe6, 0xaa, 0xe2, 0xdc, 0x3f, 0xf0, 0xac, -0x0, 0x98, 0x32, 0xcc, 0x3a, 0x4a, 0xa8, -0xab, 0x8b, 0xa6, 0xfd, 0x59, 0xd, 0xed, -0x1, 0xc7, 0xee, 0x38, 0x80, 0xb3, 0x52, -0x9e, 0x8, 0x69, 0x44, 0xf9, 0x7, 0x4b, -0xf6, 0xf7, 0xb4, 0x34, 0xa8, 0xa1, 0xfa, -0x36, 0xf2, 0x96, 0xf0, 0xf5, 0xc4, 0x8f, -0x29, 0x80, 0x8c, 0x3e, 0xa1, 0x15, 0x6a, -0xb6, 0x33, 0xfe, 0x91, 0x4a, 0x4d, 0x8c, -0x5f, 0x8, 0xdf, 0x5c, 0xb3, 0xda, 0x4b, -0xb3, 0xa5, 0xad, 0xcb, 0xec, 0x19, 0xc9, -0xf0, 0xe2, 0x93, 0xc9, 0x1f, 0x5f, 0xc3, -0xed, 0x9d, 0x3f, 0x52, 0x20, 0x4a, 0x5a, -0x10, 0x46, 0x72, 0xc8, 0x1, 0xa7, 0x43, -0xed, 0x58, 0x87, 0xd4, 0x96, 0xf1, 0x61, -0xea, 0xce, 0xbd, 0x42, 0xa3, 0x1c, 0xf, -0x67, 0xb6, 0xb5, 0x75, 0xe6, 0x7a, 0xad, -0x70, 0x9f, 0x25, 0x99, 0x0, 0xd3, 0x19, -0x15, 0xc4, 0x17, 0xe0, 0xe6, 0xb1, 0x81, -0xbc, 0xd9, 0x34, 0xc4, 0x96, 0x9e, 0x6, -0xf4, 0x89, 0xfe, 0x28, 0xac, 0x51, 0x8, -0x1c, 0x60, 0x1b, 0x5, 0x8b, 0x1b, 0x79, -0x2, 0x74, 0xb9, 0xa7, 0x55, 0x6f, 0x7a, -0x94, 0xc7, 0x5a, 0x84, 0x6d, 0x6a, 0x3e, -0x19, 0xe, 0xd1, 0xe9, 0x76, 0xf5, 0x5d, -0x6a, 0x7e, 0x3c, 0x3c, 0x3b, 0xb3, 0x73, -0x28, 0x5a, 0x89, 0xa2, 0x33, 0x42, 0x67, -0xf, 0xd, 0x33, 0x1a, 0x1a, 0xf6, 0xfe, -0x3c, 0x3a, 0xf2, 0xd7, 0x6d, 0x67, 0x40, -0xfc, 0x70, 0xde, 0xc1, 0xf6, 0x46, 0xa2, -0x36, 0xde, 0xb1, 0x19, 0x2a, 0x3e, 0x39, -0xb, 0xa7, 0xf9, 0x42, 0x69, 0xc0, 0xd9, -0xfc, 0xfb, 0x56, 0xe7, 0x73, 0x3e, 0xf8, -0xd8, 0x92, 0xe7, 0xfa, 0xe, 0x6c, 0x9d, -0x81, 0x2, 0x7f, 0xe6, 0x2f, 0x1e, 0x6f, -0x59, 0x81, 0x7c, 0xe8, 0x10, 0x34, 0x76, -0x4, 0x57, 0x56, 0xed, 0x15, 0x20, 0x4b, -0x4e, 0x16, 0x2c, 0x99, 0x57, 0xdb, 0xd, -0x18, 0xf7, 0xaa, 0xd3, 0x89, 0x24, 0x50, -0x18, 0x32, 0xf, 0x75, 0xea, 0x10, 0x5, -0xe9, 0x1b, 0xfb, 0x6c, 0x6c, 0xf, 0xf1, -0x27, 0x83, 0x1f, 0x13, 0x91, 0x69, 0xe7, -0x9f, 0x60, 0xc4, 0x93, 0x7c, 0xe0, 0x37, -0x30, 0x8b, 0x4b, 0xb1, 0xd9, 0x4f, 0x82, -0x4c, 0xa9, 0xce, 0x1d, 0xc9, 0x48, 0x2f, -0xcc, 0x21, 0x1b, 0x8c, 0x6a, 0xc1, 0xa, -0xa5, 0x44, 0x57, 0x98, 0xec, 0x10, 0x1d, -0xd7, 0x5f, 0xf3, 0x53, 0x76, 0x96, 0x6c, -0xe2, 0x46, 0x38, 0xac, 0x47, 0xb7, 0x77, -0xc9, 0x49, 0xaa, 0xae, 0xe7, 0xab, 0x20, -0xaa, 0x8e, 0x2a, 0x58, 0x5a, 0x80, 0xe3, -0x88, 0xde, 0x7, 0x1c, 0x3, 0xfd, 0xe6, -0x69, 0x29, 0x16, 0xc6, 0x2d, 0xa7, 0x12, -0x66, 0xb2, 0x3f, 0x8a, 0xb0, 0x74, 0xb1, -0x0, 0x3c, 0x4d, 0xd9, 0x6b, 0x12, 0xf9, -0xbf, 0x4e, 0xda, 0x29, 0x32, 0x27, 0xd5, -0x5b, 0x9a, 0xb9, 0xc5, 0x2b, 0x58, 0x78, -0x6c, 0x4, 0x5a, 0xb, 0xa1, 0x16, 0xb9, -0xc1, 0x27, 0xb6, 0x93, 0x7c, 0x74, 0x52, -0x53, 0xa, 0xec, 0x63, 0x67, 0x62, 0x8a, -0x3a, 0xf1, 0x6d, 0x73, 0x32, 0x4e, 0x93, -0x2a, 0xce, 0x1f, 0x32, 0x9e, 0xa6, 0x5e, -0xa9, 0xcc, 0xd3, 0xe0, 0x30, 0x29, 0x85, -0x36, 0x13, 0xe9, 0xdd, 0x8a, 0x26, 0x78, -0xe8, 0xa2, 0x8d, 0xd3, 0xf9, 0xf2, 0x14, -0xf4, 0xb0, 0x55, 0x8f, 0x6e, 0x93, 0x90, -0x70, 0x42, 0xaa, 0x93, 0x7c, 0xaa, 0x3c, -0x14, 0xee, 0x2c, 0xa6, 0x4c, 0x79, 0x5d, -0xd1, 0x15, 0xcb, 0x18, 0x45, 0x2c, 0x15, -0x4d, 0x96, 0x9a, 0x8, 0xec, 0xde, 0xfb, -0xa6, 0x26, 0x64, 0xcd, 0x3f, 0x85, 0x46, -0xa6, 0x20, 0xe7, 0x1b, 0xc4, 0xa1, 0xe4, -0xbf, 0x57, 0x40, 0x8d, 0x12, 0x2b, 0x8, -0x88, 0xa3, 0x7a, 0x7d, 0x82, 0xfa, 0xc4, -0xe3, 0x5b, 0xa6, 0x55, 0x63, 0xec, 0x7c, -0x23, 0xd0, 0xbc, 0x9a, 0xbb, 0x1b, 0xce, -0x21, 0x6a, 0x92, 0xf, 0xa3, 0xd2, 0xcd, -0x93, 0x74, 0x81, 0x2a, 0xa0, 0x26, 0xde, -0xf1, 0x70, 0x5b, 0x7e, 0xbf, 0x2b, 0xc3, -0x91, 0x8a, 0xbf, 0xfb, 0xa0, 0xf, 0x10, -0x4, 0x9e, 0xa5, 0xad, 0xdd, 0xbd, 0x90, -0xe, 0x3f, 0xbb, 0xc4, 0xc0, 0xb3, 0xc6, -0x15, 0x8a, 0xb2, 0x0, 0x6a, 0xcc, 0x4e, -0x7c, 0xca, 0x21, 0x51, 0x63, 0xb6, 0xc2, -0x71, 0x38, 0xf6, 0x5f, 0x50, 0x91, 0xab, -0x87, 0xd3, 0xb9, 0xad, 0x44, 0x37, 0x3d, -0x2e, 0x93, 0x43, 0xd2, 0x5b, 0xcd, 0xa9, -0x8c, 0xec, 0xfb, 0xcc, 0x49, 0xb0, 0xa9, -0x77, 0x66, 0x12, 0x15, 0x6, 0xbd, 0x43, -0x86, 0x6c, 0x2a, 0xeb, 0x62, 0x58, 0x25, -0xa5, 0x23, 0xaf, 0xe2, 0x4, 0x7a, 0x61, -0xb8, 0x25, 0x3a, 0x4, 0x39, 0xe3, 0x15, -0x10, 0x1e, 0x8d, 0x4a, 0x42, 0x5f, 0x81, -0xe2, 0xac, 0x28, 0x4a, 0x25, 0x35, 0x5, -0xb7, 0x20, 0xab, 0xbb, 0xc4, 0x45, 0xef, -0xc4, 0xf7, 0xf1, 0x41, 0xf9, 0x58, 0x3a, -0x67, 0x14, 0xba, 0xc3, 0x76, 0x41, 0x58, -0x8, 0x6f, 0x90, 0x6e, 0xe0, 0x51, 0x19, -0xf, 0x94, 0x60, 0x7c, 0x8, 0x81, 0xd4, -0xc9, 0xbc, 0x7, 0xfd, 0x2b, 0xf2, 0xa8, -0x1b, 0xfa, 0x4a, 0xe5, 0x3d, 0xf3, 0xe7, -0x84, 0xff, 0x9e, 0xee, 0x44, 0xb8, 0xee, -0xbb, 0xd0, 0xd5, 0xfb, 0xc9, 0xd7, 0x7c, -0xc8, 0x28, 0xd2, 0x2c, 0x46, 0x3f, 0xee, -0xd3, 0x7, 0x5c, 0xed, 0x50, 0x3a, 0x92, -0x6e, 0xd, 0xdf, 0x75, 0x55, 0x2f, 0xf8, -0x46, 0x58, 0x17, 0x0, 0x94, 0xc9, 0x1d, -0xc, 0x96, 0xee, 0x44, 0x33, 0xcc, 0x7d, -0xf7, 0xd3, 0x52, 0x4d, 0x92, 0x66, 0x4e, -0xdd, 0xe1, 0x18, 0xa3, 0x94, 0xae, 0x82, -0x6d, 0x80, 0x75, 0xc1, 0x65, 0x42, 0x3f, -0xc8, 0x96, 0x2c, 0xb, 0xb, 0x7b, 0x18, -0x65, 0x90, 0x57, 0xc6, 0x22, 0x38, 0xf2, -0xce, 0x5, 0x9e, 0xd6, 0xcc, 0x7d, 0x7b, -0x75, 0x90, 0x4e, 0xda, 0xd, 0x28, 0x63, -0xea, 0x8c, 0xd6, 0x8a, 0x8a, 0x74, 0x38, -0x61, 0xf7, 0xbd, 0xd, 0x5b, 0x5f, 0x50, -0x70, 0x23, 0x78, 0x2b, 0xc5, 0xb1, 0x2c, -0xac, 0x26, 0x37, 0xf9, 0xf1, 0xa8, 0x95, -0x74, 0xb7, 0x2d, 0xf3, 0xeb, 0xb4, 0x78, -0x9e, 0xfe, 0xd5, 0x7c, 0xad, 0xd1, 0x18, -0x26, 0xb5, 0x84, 0x64, 0x6f, 0x80, 0xc, -0x9a, 0xe9, 0x9, 0xbc, 0x47, 0x26, 0x88, -0x52, 0x95, 0x3c, 0xab, 0x4d, 0x8, 0x42, -0x81, 0x69, 0x3, 0xd8, 0xf4, 0x31, 0x9a, -0x2f, 0x3, 0xa3, 0xcc, 0x1f, 0xb4, 0x11, -0xd1, 0x82, 0x7, 0xa7, 0x93, 0xac, 0xb2, -0x8b, 0x7, 0xba, 0x46, 0x67, 0x6a, 0x2c, -0xde, 0x62, 0x53, 0x15, 0xd1, 0x70, 0x6d, -0x9, 0x30, 0xa9, 0xf, 0xb3, 0x3d, 0x8b, -0xb1, 0xc, 0xd6, 0x88, 0xcd, 0xa6, 0xf4, -0xee, 0x22, 0xc0, 0x1a, 0x18, 0x1b, 0x42, -0xbc, 0x34, 0xb1, 0x57, 0x48, 0x9, 0x5b, -0x5b, 0xb1, 0x7, 0xfb, 0x45, 0x97, 0x8e, -0x25, 0x40, 0x2, 0xd8, 0xaa, 0x64, 0x6f, -0x8c, 0xa, 0xd7, 0xfd, 0x4c, 0xad, 0x35, -0x97, 0xc5, 0xbe, 0xf9, 0x3d, 0x86, 0x15, -0x3c, 0x7c, 0xd9, 0x72, 0x8, 0x6b, 0xdf, -0xff, 0x30, 0x32, 0x94, 0x23, 0xa7, 0x71, -0x27, 0x39, 0xa6, 0x16, 0x75, 0x4f, 0x6a, -0x45, 0x51, 0x74, 0xcc, 0xe7, 0xfe, 0xa2, -0x7d, 0xf8, 0xe8, 0x2e, 0x1d, 0x8c, 0xe9, -0xba, 0xca, 0x89, 0xc4, 0x29, 0x1c, 0x9a, -0x24, 0x4f, 0x50, 0xe5, 0x2c, 0x55, 0x12, -0x9, 0x17, 0xae, 0x75, 0x31, 0xac, 0x2, -0x86, 0x1f, 0x85, 0xf4, 0x1d, 0x5c, 0x3, -0x13, 0x3f, 0xe0, 0x12, 0xdb, 0xfc, 0x6d, -0x7c, 0x30, 0xfd, 0x53, 0x56, 0xbe, 0x14, -0xce, 0x19, 0x19, 0xab, 0x43, 0x62, 0xcd, -0xd7, 0x4b, 0x24, 0x11, 0xc7, 0x6a, 0x80, -0xe7, 0xcb, 0x98, 0x47, 0x79, 0x8a, 0xf, -0x72, 0x5b, 0xd2, 0xf8, 0xf7, 0x10, 0x3e, -0x21, 0xfa, 0x37, 0xdf, 0xe3, 0xa6, 0xfb, -0x21, 0x47, 0xf4, 0x95, 0x9a, 0x88, 0xe3, -0x51, 0x82, 0x5c, 0xa6, 0xe0, 0x24, 0xf4, -0x5f, 0x74, 0x25, 0x24, 0x78, 0x81, 0xe7, -0x3d, 0x37, 0x1c, 0xda, 0xbc, 0x0, 0x46, -0x86, 0x3a, 0x7d, 0x36, 0xe5, 0x35, 0x6d, -0xdc, 0x6d, 0x64, 0xbf, 0xe1, 0x26, 0x7b, -0x5c, 0xb0, 0xe5, 0x75, 0xd3, 0xcd, 0x4c, -0x12, 0xf, 0x0, 0x3e, 0x2d, 0x8a, 0x9e, -0xc, 0xa6, 0xb1, 0xf1, 0x18, 0xc3, 0x74, -0xc5, 0xc2, 0xf7, 0xdb, 0xc4, 0x70, 0xf, -0x21, 0x41, 0xa5, 0xb7, 0x67, 0x16, 0x2f, -0xef, 0xd6, 0x3c, 0xa5, 0x96, 0xa7, 0xb8, -0x5c, 0x87, 0x39, 0x4e, 0x85, 0xbc, 0x80, -0xdd, 0x66, 0x5b, 0xa7, 0xfc, 0x53, 0xb3, -0x1c, 0x14, 0xae, 0xb9, 0xd4, 0xef, 0xce, -0x7b, 0xb5, 0x10, 0x89, 0x7e, 0xd2, 0xc9, -0xb4, 0x6b, 0xfe, 0xb5, 0x9d, 0x35, 0xf2, -0x6f, 0xb6, 0x79, 0xfb, 0x5, 0x7, 0x6e, -0xdc, 0x8e, 0xa8, 0x2f, 0xdf, 0x73, 0x87, -0xed, 0x33, 0x14, 0x4e, 0xbb, 0x88, 0x68, -0x3c, 0x82, 0x44, 0x3b, 0xce, 0xba, 0xa8, -0x72, 0xf5, 0x3e, 0xdd, 0xcc, 0x48, 0x9, -0xe, 0xfe, 0xb3, 0x3, 0x1f, 0xd9, 0x4, -0x85, 0xbc, 0x2, 0xa7, 0x84, 0x3d, 0xc2, -0x4d, 0xf0, 0x1d, 0x14, 0x6b, 0xd0, 0x99, -0xb3, 0xe, 0x7b, 0xdd, 0xdd, 0x82, 0xd6, -0x9b, 0xf8, 0x8c, 0xf8, 0x9e, 0xf8, 0x3, -0x10, 0x49, 0xfb, 0x24, 0x5d, 0xe2, 0x35, -0xc3, 0xb1, 0x50, 0xdc, 0x53, 0xd2, 0xa3, -0xce, 0xa1, 0xc5, 0x75, 0x4b, 0x9e, 0x63, -0x7a, 0xd3, 0x1f, 0x6d, 0x4c, 0xb0, 0xee, -0x16, 0x90, 0x1a, 0x51, 0x59, 0x8, 0x9a, -0xd8, 0x3, 0xac, 0x6b, 0x0, 0xb8, 0x71, -0xb7, 0x26, 0xc8, 0x14, 0x35, 0xe, 0x99, -0x27, 0xd5, 0x36, 0xd2, 0xee, 0x6c, 0xf, -0xed, 0x7a, 0x29, 0x89, 0xeb, 0x1c, 0x60, -0x73, 0xd8, 0x50, 0x4d, 0x4a, 0x74, 0x30, -0xa0, 0x85, 0xe4, 0x52, 0x59, 0x56, 0xca, -0xcf, 0xa4, 0xad, 0x80, 0x59, 0x57, 0x13, -0xae, 0xd7, 0x99, 0x26, 0x7a, 0x7d, 0xbe, -0xbf, 0xf7, 0xf2, 0x30, 0xc9, 0xc2, 0x12, -0xd6, 0x54, 0x53, 0x9d, 0x2e, 0xca, 0x56, -0x4d, 0xc0, 0xff, 0x8d, 0x24, 0xe8, 0x5e, -0x4b, 0x97, 0xb, 0x27, 0x77, 0x5a, 0x60, -0x2e, 0x72, 0x36, 0xdb, 0xde, 0x48, 0x27, -0x7c, 0xe4, 0xb2, 0xed, 0x38, 0xf8, 0x13, -0x9e, 0xfd, 0x5c, 0x48, 0xf, 0x6f, 0x6e, -0x74, 0xd6, 0x69, 0x2, 0x9b, 0x54, 0xec, -0xda, 0xc9, 0x8f, 0x77, 0xa0, 0x49, 0x42, -0x1, 0x74, 0x2, 0x6, 0x17, 0x5e, 0x85, -0x9e, 0x85, 0x13, 0x5f, 0x12, 0x2e, 0xf4, -0xd, 0xcc, 0x7f, 0x41, 0xdc, 0xd5, 0xa2, -0xd6, 0x4a, 0x1e, 0x16, 0xd5, 0xdf, 0x39, -0xd2, 0x36, 0x43, 0x1d, 0x8f, 0xb5, 0xc5, -0x90, 0x71, 0xec, 0xb1, 0x9e, 0x32, 0x54, -0xb2, 0x2e, 0x10, 0xe4, 0x92, 0x21, 0x79, -0x3b, 0xa2, 0x25, 0xf0, 0x49, 0x19, 0xb5, -0xf4, 0x8c, 0xff, 0xf2, 0x85, 0x81, 0xc0, -0x53, 0xc8, 0xa8, 0x8e, 0x61, 0x7d, 0x50, -0xd4, 0x3a, 0x6a, 0x7b, 0x9f, 0xb2, 0xd9, -0x7b, 0xf6, 0x8a, 0xe4, 0x6, 0x70, 0xe6, -0x6e, 0xb9, 0x78, 0x26, 0x9b, 0x9c, 0xcd, -0x90, 0x27, 0xdc, 0xed, 0xc4, 0xd6, 0x93, -0xd0, 0x89, 0xe4, 0xd0, 0x15, 0x77, 0x24, -0x4d, 0x64, 0x81, 0x60, 0xa8, 0x8a, 0xd7, -0xfd, 0xd6, 0x4c, 0x47, 0x27, 0xf7, 0x9, -0xea, 0xa1, 0xfa, 0x1c, 0x75, 0x6f, 0xe5, -0xf4, 0xdb, 0xa6, 0xa6, 0xc4, 0xa1, 0xc0, -0x40, 0x4d, 0x46, 0xa5, 0xc1, 0x66, 0xc1, -0x1b, 0x1, 0x2b, 0x9e, 0x91, 0xd4, 0xb8, -0x68, 0xa0, 0x24, 0x2a, 0x1c, 0x37, 0x42, -0x4b, 0xd8, 0x3b, 0x7f, 0x4e, 0x1d, 0x4e, -0xb, 0x5f, 0x6a, 0x17, 0xfa, 0xb8, 0x21, -0x88, 0x87, 0x58, 0x42, 0x77, 0x86, 0xea, -0x3, 0xf, 0xf2, 0x15, 0x95, 0xf3, 0x16, -0xf1, 0x8e, 0xee, 0x95, 0xba, 0x7d, 0x75, -0x8c, 0xd0, 0x4e, 0x63, 0x2, 0x1a, 0xc6, -0x5e, 0x1, 0x20, 0x44, 0xd7, 0x21, 0x43, -0x40, 0xd9, 0xd1, 0x82, 0xa9, 0x23, 0x4c, -0x68, 0x88, 0x94, 0xfa, 0x47, 0x56, 0x45, -0x31, 0x58, 0x2c, 0x1c, 0x6e, 0x56, 0x31, -0x37, 0x10, 0x6b, 0x2e, 0xda, 0xac, 0x69, -0x8c, 0xd2, 0x7a, 0x66, 0x8d, 0xa5, 0x26, -0x1f, 0xf6, 0x3e, 0xe0, 0x1, 0xb0, 0x7, -0xe1, 0xd9, 0xff, 0x8c, 0x4b, 0x8e, 0x17, -0x1b, 0xcc, 0x47, 0x76, 0xed, 0xbd, 0xd6, -0x94, 0x21, 0xb7, 0x8f, 0x5e, 0xb4, 0x1c, -0xd1, 0x49, 0x83, 0x25, 0x6f, 0x63, 0xe8, -0x28, 0xa5, 0x51, 0xd7, 0xdb, 0x82, 0x9f, -0xd9, 0xb1, 0x32, 0x38, 0xa5, 0xd0, 0x59, -0x2d, 0x97, 0xd, 0xb5, 0x14, 0xe5, 0x2f, -0xb9, 0xb2, 0x2a, 0xb, 0x96, 0xf6, 0x77, -0x86, 0xf3, 0xa9, 0xe0, 0x96, 0x76, 0x1f, -0x66, 0xc0, 0x78, 0xff, 0xd1, 0x26, 0xfb, -0xe7, 0x94, 0x81, 0x72, 0xe9, 0xdd, 0xa4, -0x1a, 0x7a, 0xdc, 0x95, 0x9e, 0x2c, 0x6d, -0x41, 0xfb, 0x3c, 0x67, 0x66, 0xa5, 0xa, -0x84, 0x43, 0xb8, 0x80, 0x45, 0x54, 0xd9, -0x69, 0x70, 0x93, 0x52, 0xaf, 0xbb, 0xe7, -0xd4, 0x39, 0x22, 0xd5, 0x40, 0xa2, 0xf7, -0xee, 0x21, 0xe8, 0x8e, 0x81, 0xb6, 0x33, -0x12, 0x72, 0x7, 0x70, 0x7c, 0x52, 0x9a, -0x62, 0xd1, 0x52, 0x33, 0x51, 0x11, 0x7f, -0x1c, 0x9f, 0x43, 0xe6, 0xa0, 0xc2, 0x99, -0xea, 0xc4, 0xd6, 0x92, 0xb8, 0x75, 0x64, -0x42, 0x83, 0x4, 0x9d, 0x42, 0xd4, 0x4b, -0x55, 0x4e, 0xef, 0xd9, 0x10, 0x7e, 0xe4, -0x5e, 0xa0, 0x4f, 0x47, 0x16, 0xc2, 0x54, -0x22, 0x3f, 0x37, 0x1, 0x31, 0x90, 0x34, -0xc5, 0x15, 0x5a, 0x4a, 0x88, 0x9, 0xdb, -0x49, 0x9, 0xd7, 0xd2, 0x34, 0x54, 0xd7, -0xb4, 0xdc, 0xa5, 0x6d, 0x10, 0x3b, 0x19, -0x4c, 0x81, 0x5f, 0x2f, 0x5a, 0xe2, 0x54, -0xc5, 0xd0, 0x2, 0xf0, 0x6c, 0xc5, 0x3a, -0x1d, 0x59, 0x41, 0xf3, 0x30, 0x33, 0xf7, -0xfc, 0x1, 0x69, 0xba, 0x87, 0xbc, 0x9f, -0x30, 0x3b, 0x68, 0xb7, 0xb1, 0xf5, 0x19, -0x33, 0xdb, 0xd2, 0xf5, 0x3a, 0x8b, 0xb0, -0xdf, 0x8, 0x63, 0xce, 0x7a, 0x8, 0xcc, -0x81, 0x97, 0x9b, 0x3f, 0xc, 0x91, 0x46, -0x8d, 0x3c, 0x9d, 0x7b, 0xea, 0x27, 0x3b, -0x3f, 0xa5, 0x16, 0x27, 0xe9, 0x54, 0x87, -0xda, 0x84, 0xfd, 0x16, 0x24, 0x71, 0xd3, -0xce, 0x9d, 0xa3, 0x4d, 0x34, 0xeb, 0x92, -0xf8, 0x5f, 0xa9, 0x1a, 0x47, 0x6d, 0xc, -0x44, 0x7b, 0xd3, 0x4d, 0xe7, 0xfe, 0x7, -0xa4, 0x25, 0xfe, 0x9d, 0x9a, 0x94, 0x9a, -0x34, 0x6a, 0x3b, 0x50, 0xcc, 0x41, 0xdc, -0x5f, 0x28, 0x4, 0x3d, 0x3a, 0xc2, 0x58, -0x40, 0xc0, 0xa, 0x63, 0x1, 0x6e, 0xb, -0x9, 0xc1, 0xc7, 0x42, 0x0, 0x72, 0xa0, -0x45, 0xa6, 0x11, 0x53, 0x23, 0x7b, 0x42, -0x0, 0x46, 0x9b, 0x1e, 0x7a, 0xde, 0x96, -0x7b, 0x48, 0x40, 0xda, 0x5b, 0x20, 0xf, -0xb6, 0x79, 0xc6, 0x5c, 0x4b, 0xb0, 0x4f, -0xf7, 0xa1, 0x93, 0x34, 0x6, 0x73, 0xb5, -0x9d, 0x94, 0xc0, 0xd, 0x11, 0x4e, 0xfa, -0xc2, 0x71, 0xb4, 0x2d, 0x68, 0xf6, 0x72, -0x4a, 0xe4, 0x40, 0xa3, 0xc5, 0x3c, 0x2f, -0x5e, 0x70, 0x1d, 0xfb, 0x66, 0xff, 0xed, -0x9a, 0x22, 0x85, 0x96, 0x41, 0xf, 0x7c, -0xc, 0xc7, 0x86, 0x6a, 0xc4, 0xd8, 0xa9, -0x59, 0x55, 0x69, 0xa3, 0xd0, 0x85, 0x6c, -0xae, 0xd2, 0x97, 0xf1, 0x54, 0xeb, 0xf1, -0x59, 0x29, 0xa6, 0x89, 0xb5, 0xfa, 0xd, -0x10, 0xe7, 0xd6, 0xb5, 0xfe, 0xb0, 0xc7, -0x1a, 0x65, 0x62, 0xfa, 0xce, 0x31, 0xb7, -0x8d, 0x64, 0x93, 0x5b, 0xfb, 0x6, 0x31, -0x19, 0xee, 0xb2, 0x54, 0xc9, 0x3c, 0xdb, -0xbe, 0xb0, 0xc1, 0xc3, 0x95, 0xb, 0x9f, -0xcd, 0xa2, 0x35, 0x29, 0xcf, 0x2b, 0xa0, -0xf2, 0x9b, 0x21, 0x5a, 0xa, 0xbe, 0x2a, -0x99, 0xfa, 0x60, 0xa1, 0x4c, 0x15, 0x2a, -0x6d, 0xec, 0xc6, 0x86, 0x49, 0x6, 0xcc, -0x50, 0xe6, 0xf9, 0xe4, 0xa9, 0xa2, 0x39, -0x24, 0x8e, 0xcb, 0xa0, 0xb7, 0x32, 0x2b, -0xab, 0x2f, 0xfb, 0x8f, 0xdf, 0x31, 0x9f, -0xfe, 0x5b, 0x55, 0xbd, 0xb4, 0x61, 0xb4, -0xfe, 0xe1, 0x26, 0xd5, 0x6e, 0x61, 0xde, -0xd9, 0x7a, 0x56, 0xa8, 0x57, 0x56, 0x74, -0xf2, 0xcb, 0xd3, 0xc2, 0xf8, 0xe8, 0x4, -0x49, 0x4c, 0x22, 0x45, 0x6d, 0x46, 0x30, -0x92, 0xf2, 0xdd, 0x45, 0x98, 0xe3, 0x8e, -0x71, 0xaf, 0x7d, 0x1b, 0x3, 0xa6, 0x7c, -0x42, 0x88, 0xae, 0xc8, 0xe1, 0x11, 0x55, -0x1a, 0x10, 0x42, 0x9a, 0x7a, 0x11, 0x4a, -0xe, 0x53, 0x36, 0xcc, 0x6b, 0x4b, 0x86, -0x7, 0x38, 0xe9, 0xf9, 0x66, 0xcc, 0x71, -0xa1, 0xf, 0x16, 0xd7, 0x92, 0x16, 0x9, -0x9d, 0xc0, 0xc3, 0x38, 0xdb, 0xcb, 0xb5, -0xd4, 0x42, 0xf0, 0xc, 0x90, 0xb, 0xad, -0x93, 0x1e, 0x50, 0x23, 0xe8, 0x9a, 0xe1, -0xd0, 0xf9, 0x67, 0xc4, 0x89, 0xc9, 0x7, -0xdc, 0x96, 0xfd, 0xa6, 0x9a, 0x2a, 0x6, -0xff, 0x12, 0x44, 0x30, 0xa3, 0x62, 0xe2, -0x82, 0x8a, 0x62, 0x61, 0xa5, 0x22, 0x2d, -0x65, 0xcf, 0x2c, 0x39, 0x32, 0x65, 0x94, -0x8b, 0xb5, 0x14, 0xbb, 0xbe, 0xfb, 0x83, -0xe4, 0x83, 0x4c, 0x84, 0x38, 0x35, 0xa4, -0xbc, 0x11, 0x13, 0x2b, 0xc6, 0x45, 0x67, -0x48, 0x42, 0x79, 0xf4, 0xbe, 0x65, 0xe9, -0x38, 0xdc, 0xea, 0x96, 0xc1, 0xb5, 0x35, -0xd3, 0xa5, 0x7d, 0x52, 0x16, 0xf2, 0x3c, -0xbd, 0x2d, 0x9c, 0x67, 0xb0, 0x5c, 0x69, -0x21, 0x7a, 0x22, 0xdd, 0xc6, 0x80, 0x4, -0x9e, 0xcd, 0x1a, 0xfd, 0x77, 0xa9, 0xa0, -0x40, 0x1f, 0xd9, 0xfb, 0x17, 0x99, 0xec, -0x4e, 0x69, 0x86, 0x7f, 0xf, 0x32, 0xea, -0x1e, 0xe9, 0x12, 0x64, 0xe, 0xef, 0x30, -0x9b, 0xfd, 0xf7, 0xfb, 0x9c, 0x24, 0x2f, -0x5f, 0x79, 0x83, 0x7c, 0x41, 0x57, 0x85, -0xa1, 0xcf, 0x55, 0xda, 0xf, 0xce, 0xd7, -0x43, 0xa1, 0x3c, 0xe3, 0x17, 0xa7, 0x66, -0x44, 0xac, 0x51, 0xc2, 0x46, 0x2e, 0x2d, -0x88, 0x61, 0xc5, 0xea, 0xc9, 0x9d, 0x3, -0xdc, 0xc2, 0x9f, 0x21, 0x6, 0xfe, 0xed, -0xb1, 0x38, 0xef, 0x7a, 0x88, 0xfd, 0x9, -0xfe, 0x2b, 0x50, 0xd8, 0xcc, 0x2b, 0xb, -0xb1, 0x2b, 0x8c, 0x7e, 0xd7, 0x7d, 0x54, -0x1, 0xb8, 0xd7, 0x2b, 0xf7, 0xfd, 0xdf, -0x3f, 0xe6, 0xde, 0x5a, 0xa2, 0x9e, 0x45, -0xc, 0x37, 0xf1, 0x1a, 0xa0, 0xd1, 0x87, -0x7c, 0xd9, 0x16, 0x7e, 0x66, 0x97, 0xd2, -0x7e, 0x4a, 0xb3, 0x2f, 0x53, 0x24, 0xd5, -0xd6, 0x22, 0xa2, 0x2e, 0xf9, 0x22, 0x43, -0x8d, 0x65, 0x6b, 0x6a, 0xb7, 0xdf, 0xb4, -0x60, 0x3d, 0x4b, 0x10, 0x72, 0xc, 0x82, -0x3a, 0x72, 0x13, 0xe5, 0x76, 0x1e, 0x6d, -0x21, 0xce, 0xec, 0x6, 0x8b, 0x98, 0x73, -0xb7, 0x6b, 0x9d, 0xed, 0x52, 0x42, 0x10, -0x38, 0xf1, 0x6d, 0xeb, 0xd2, 0x77, 0x9c, -0xc9, 0x8d, 0x44, 0x9e, 0xf1, 0x26, 0x5, -0xc7, 0x94, 0xdd, 0x8e, 0xe0, 0xc7, 0x7b, -0xe2, 0x98, 0x8b, 0xd, 0x36, 0x92, 0x74, -0xf7, 0x7c, 0xf2, 0x98, 0xd5, 0x19, 0x34, -0xab, 0x59, 0xd, 0xcb, 0x7a, 0x2b, 0x71, -0x3f, 0xfc, 0x73, 0xa0, 0x51, 0x8a, 0xe6, -0xd8, 0xa1, 0x76, 0x25, 0xe3, 0x7, 0xd1, -0xc2, 0xf6, 0x4f, 0x84, 0x50, 0xd6, 0xdd, -0x92, 0xeb, 0x8c, 0x45, 0xfe, 0xbf, 0xdd, -0x40, 0x1a, 0x4b, 0xff, 0x84, 0x47, 0x44, -0xad, 0x78, 0x75, 0x42, 0x20, 0xae, 0xa7, -0x91, 0x23, 0xda, 0xde, 0xc6, 0x68, 0x9f, -0xb3, 0x10, 0xc4, 0x3, 0xf, 0xa8, 0x5, -0x5d, 0xb0, 0xec, 0x33, 0x1f, 0xf5, 0xd3, -0x57, 0x9b, 0xab, 0xcd, 0xb3, 0xe2, 0xdc, -0x2d, 0xf7, 0xa3, 0xd3, 0x78, 0x56, 0xb1, -0xcf, 0x82, 0x8d, 0x2c, 0x65, 0x4a, 0xde, -0x17, 0xe7, 0xcc, 0xb8, 0xf2, 0xe, 0x9b, -0x67, 0xf4, 0x3a, 0x76, 0xeb, 0x66, 0xd5, -0x15, 0x2a, 0xc, 0xa0, 0x5b, 0xc, 0xfb, -0xcd, 0x7f, 0x65, 0x7d, 0xee, 0x12, 0xba, -0x2b, 0xd7, 0x2a, 0x5f, 0xc, 0x1c, 0x8d, -0x89, 0x51, 0x60, 0x9c, 0x17, 0x24, 0xe1, -0x48, 0xa2, 0x9c, 0xd5, 0x72, 0xa1, 0x25, -0x95, 0x9a, 0xa6, 0x4a, 0x2, 0x54, 0x68, -0x53, 0xe1, 0x5c, 0xea, 0x6a, 0xc2, 0xcd, -0x63, 0x86, 0x96, 0xaa, 0xbf, 0xd0, 0x52, -0x92, 0x3d, 0x5d, 0x3, 0x76, 0x67, 0xe8, -0x4c, 0xf5, 0x33, 0xc0, 0x7, 0xcd, 0xa6, -0x75, 0x8f, 0x5c, 0x82, 0x8e, 0x8e, 0xbf, -0x1f, 0xdb, 0x91, 0x94, 0x41, 0x51, 0x11, -0x78, 0x9a, 0x53, 0x40, 0x99, 0x74, 0x1c, -0x2f, 0x46, 0x37, 0x2b, 0x26, 0x2a, 0xcf, -0x1e, 0x4f, 0x43, 0x7b, 0x72, 0x61, 0x94, -0x9d, 0xd9, 0xf5, 0xb7, 0x37, 0x4e, 0x6f, -0x63, 0x25, 0xfc, 0x0, 0xc0, 0x72, 0x17, -0x6a, 0xec, 0x15, 0x37, 0x2, 0x3e, 0xc8, -0x78, 0xd0, 0xf3, 0xe4, 0x32, 0xa6, 0x60, -0xcf, 0xf8, 0xe8, 0xb8, 0x23, 0x37, 0x43, -0x94, 0xff, 0xbe, 0xfd, 0xa7, 0x3b, 0x54, -0x4d, 0x40, 0x3f, 0x8, 0x3a, 0x7d, 0x57, -0x7e, 0x7b, 0x79, 0xe8, 0x91, 0x1c, 0x47, -0x50, 0xe6, 0xde, 0xa3, 0x27, 0x50, 0x21, -0x8, 0xef, 0x89, 0x64, 0xec, 0x77, 0x0, -0x49, 0xd5, 0xab, 0xcf, 0xc0, 0xd6, 0xbe, -0x3c, 0x3f, 0x8, 0xae, 0x6, 0x73, 0x24, -0x56, 0x91, 0xff, 0xb, 0xe0, 0xa5, 0xe7, -0x2d, 0x69, 0x7, 0xa5, 0xb5, 0xe3, 0x4e, -0xa9, 0xc7, 0x19, 0x7e, 0xc4, 0xa1, 0x8a, -0xc1, 0xc1, 0x9f, 0x22, 0xbf, 0x76, 0xf2, -0x10, 0x8d, 0x78, 0xd8, 0xad, 0x4f, 0xef, -0xd8, 0x90, 0x97, 0x37, 0x13, 0x38, 0x99, -0x36, 0xab, 0x2b, 0x7d, 0x77, 0xe4, 0x34, -0x43, 0x17, 0x5a, 0x4e, 0x3c, 0xc7, 0xcd, -0xb7, 0xbb, 0x69, 0x79, 0x75, 0x43, 0x3d, -0xc2, 0x79, 0x7b, 0xfb, 0xff, 0xf5, 0x1, -0x2f, 0xb2, 0x79, 0x82, 0x6, 0x28, 0x74, -0xd9, 0x4d, 0x79, 0x23, 0xb4, 0xb2, 0xfb, -0x26, 0x12, 0x8e, 0x42, 0x2f, 0x5e, 0xf9, -0x62, 0xb2, 0x5e, 0x57, 0x13, 0x29, 0x75, -0x49, 0x35, 0x7e, 0x11, 0x46, 0xdd, 0xf6, -0x8d, 0x38, 0x6d, 0xea, 0x2d, 0x29, 0xce, -0x22, 0x14, 0x77, 0xe0, 0xd3, 0x4f, 0x91, -0x45, 0x7a, 0xb9, 0x43, 0x5d, 0xbf, 0xdc, -0x9f, 0x71, 0xaf, 0x48, 0x52, 0xe6, 0x15, -0x9f, 0xdb, 0xd9, 0xb2, 0x1b, 0x78, 0x6, -0x4e, 0x7f, 0xfa, 0x13, 0x54, 0xf9, 0x82, -0x4c, 0x21, 0x17, 0xe4, 0x53, 0x3, 0xdb, -0x2f, 0x8, 0x7a, 0x29, 0xb6, 0x2e, 0xde, -0x11, 0xce, 0xf7, 0x57, 0x5, 0x5, 0xdc, -0xb5, 0xcf, 0x3, 0xe1, 0x98, 0x77, 0xe7, -0xd5, 0x8b, 0x63, 0x74, 0x26, 0xea, 0xdd, -0xfe, 0x5c, 0x59, 0x90, 0x44, 0x31, 0x73, -0x51, 0x4e, 0x62, 0xcd, 0x5, 0x23, 0xed, -0x24, 0x79, 0x52, 0x4a, 0x69, 0x64, 0x6b, -0x2b, 0x7e, 0xf8, 0x51, 0x6e, 0xd1, 0x56, -0x5b, 0x5a, 0xa3, 0x48, 0xcd, 0x5b, 0xc9, -0x1b, 0xf7, 0x5e, 0x5f, 0x84, 0xf7, 0x3d, -0x8a, 0xf7, 0x25, 0xbf, 0xc8, 0x80, 0x6, -0x44, 0x96, 0x3e, 0x9c, 0x85, 0xbf, 0xad, -0x64, 0xd4, 0x6e, 0xab, 0x2e, 0x4e, 0x8d, -0x1b, 0xaa, 0x8a, 0x6a, 0xb9, 0x4e, 0x2a, -0x73, 0xad, 0x2c, 0x14, 0xb2, 0xa2, 0xd4, -0x4a, 0x75, 0x5c, 0x62, 0xa3, 0xf2, 0x53, -0xef, 0xf2, 0x5b, 0x5a, 0x4a, 0xeb, 0x1b, -0xba, 0x34, 0x5f, 0x66, 0x73, 0xd2, 0x19, -0x55, 0x3d, 0x8c, 0x18, 0x32, 0x4c, 0x8, -0x99, 0xf5, 0x4a, 0x52, 0xbd, 0x78, 0xbe, -0x1f, 0x29, 0x91, 0xf0, 0x26, 0x25, 0xb5, -0xb2, 0x6d, 0x2f, 0x22, 0xd8, 0x4d, 0x4, -0xe1, 0x5e, 0x4d, 0x55, 0xec, 0x6f, 0x29, -0x99, 0x1b, 0xe6, 0x4e, 0x8, 0xc1, 0x35, -0x11, 0x28, 0x59, 0xdc, 0xd4, 0xa4, 0x3e, -0x72, 0xdc, 0x31, 0x7a, 0x2b, 0x64, 0x83, -0xa9, 0xdb, 0xd5, 0xfa, 0x46, 0x29, 0xaa, -0x27, 0x34, 0x98, 0x36, 0xcc, 0x72, 0xa6, -0xe2, 0x1c, 0x86, 0x7a, 0x94, 0xa4, 0x50, -0xd8, 0x23, 0x3, 0x33, 0x7b, 0x14, 0xe, -0xa2, 0x16, 0x77, 0x4d, 0x8b, 0x7c, 0x3c, -0xda, 0xe2 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha384_sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha384_sigrl.inc deleted file mode 100644 index c3e1b0a84e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha384_sigrl.inc +++ /dev/null @@ -1,1222 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha384 - * Message: "test message" - * Basename: None (random base) - * SigRl: SigRl of group - */ -0x36, 0x19, 0x27, 0x2c, 0xcf, 0xa0, 0x7a, -0x44, 0x9c, 0xea, 0xe5, 0x77, 0x7e, 0x7d, -0x12, 0x33, 0xd9, 0x21, 0x41, 0x58, 0x9b, -0xaf, 0xcc, 0xa2, 0x2e, 0xe1, 0xe1, 0x27, -0x70, 0xe6, 0x2f, 0x8e, 0x70, 0x9d, 0x7c, -0x2b, 0x65, 0xf0, 0xd6, 0xe3, 0x89, 0x5b, -0x8a, 0x82, 0x68, 0x2a, 0x2f, 0x44, 0xbb, -0xba, 0xbe, 0xbf, 0xed, 0x94, 0x87, 0x5b, -0xf4, 0x2a, 0xde, 0xb2, 0xe6, 0xee, 0x57, -0x17, 0x71, 0xec, 0xf4, 0x3d, 0x7c, 0x44, -0x2d, 0x77, 0x42, 0xc6, 0x22, 0x88, 0xc4, -0x80, 0xe3, 0x99, 0x79, 0x7d, 0xe8, 0xf0, -0xaf, 0x37, 0x67, 0x66, 0xe8, 0xa8, 0x63, -0xd7, 0x88, 0xd6, 0xf7, 0x2e, 0x2b, 0x98, -0xcc, 0x0a, 0x96, 0xef, 0x72, 0xfe, 0x47, -0xf7, 0x46, 0x4c, 0x0b, 0x79, 0x94, 0x8c, -0x6a, 0x1f, 0x09, 0x30, 0x31, 0x29, 0xd2, -0x86, 0xed, 0x93, 0xd9, 0xed, 0x9e, 0x88, -0xd2, 0x9b, 0x44, 0x15, 0x36, 0x91, 0x33, -0x62, 0x44, 0xcf, 0xab, 0x0d, 0xf0, 0x24, -0x86, 0x3f, 0x10, 0x74, 0x42, 0x37, 0xbb, -0x1a, 0x67, 0xf4, 0x16, 0x61, 0xc7, 0x5e, -0x30, 0x18, 0x86, 0x28, 0xa2, 0x3a, 0x68, -0xe2, 0xec, 0x6e, 0xa4, 0x5f, 0x1e, 0x81, -0xf1, 0x09, 0xcc, 0x8c, 0xde, 0xe5, 0x3f, -0xc3, 0x6e, 0xfe, 0x19, 0x4f, 0x51, 0xa6, -0x66, 0x69, 0xf2, 0x38, 0xac, 0xad, 0xd9, -0xe8, 0xe2, 0x81, 0xdd, 0x0c, 0x74, 0x9a, -0x76, 0x49, 0x7e, 0x33, 0x7a, 0xa8, 0x15, -0xc0, 0x49, 0xee, 0xd5, 0xff, 0x6f, 0x53, -0x27, 0x69, 0xcc, 0xb6, 0x4b, 0x55, 0xf7, -0x64, 0xa1, 0x08, 0x46, 0x09, 0xb9, 0x18, -0x0e, 0x97, 0x87, 0x2a, 0x41, 0x48, 0x5d, -0x45, 0x3b, 0xea, 0xc5, 0x15, 0x7a, 0xe2, -0x91, 0xee, 0x35, 0xea, 0x34, 0xd4, 0x89, -0x96, 0xf1, 0x74, 0x63, 0x06, 0xc7, 0x43, -0x69, 0xc6, 0x9a, 0x75, 0x30, 0x45, 0x87, -0x8a, 0x3b, 0x64, 0x60, 0xa0, 0xfb, 0x73, -0xc3, 0x77, 0xde, 0x9d, 0xfb, 0x2d, 0x1a, -0x03, 0xc2, 0xc6, 0x2d, 0x72, 0x31, 0x93, -0xd9, 0xb1, 0x26, 0xd3, 0xb7, 0x51, 0xcb, -0x4c, 0x95, 0x42, 0x55, 0xfc, 0x30, 0xa4, -0x13, 0x4b, 0x2b, 0xe2, 0x99, 0x10, 0x3c, -0x5c, 0x4d, 0xf6, 0xe5, 0x1b, 0x7a, 0x5a, -0xbe, 0xb4, 0x23, 0x4b, 0x99, 0x3c, 0x93, -0x63, 0x38, 0x84, 0x2b, 0xfe, 0xc1, 0x01, -0xdd, 0x0b, 0xc7, 0x6f, 0x3c, 0x06, 0xbc, -0x6f, 0x17, 0xb4, 0x95, 0x9d, 0xd3, 0xd1, -0xfd, 0xea, 0xf3, 0x15, 0x47, 0xec, 0x07, -0xa1, 0x22, 0xd0, 0x2d, 0xe8, 0xb8, 0xfb, -0x33, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x32, 0x97, 0x36, 0xc2, 0x28, -0x13, 0xa6, 0xce, 0x2a, 0x82, 0xf5, 0x7e, -0xce, 0xdb, 0x7e, 0x95, 0x97, 0x71, 0xce, -0xf0, 0xa6, 0xbd, 0x9a, 0x09, 0x6c, 0x4b, -0x5c, 0x64, 0xbc, 0xb6, 0x56, 0xfb, 0x5c, -0xec, 0x0e, 0xc6, 0x33, 0x54, 0xa0, 0x4d, -0x21, 0xdf, 0x03, 0xc4, 0xc8, 0x6a, 0x28, -0xa3, 0xde, 0x94, 0x2c, 0x1b, 0x81, 0x47, -0x71, 0xe9, 0xe0, 0xe7, 0x2a, 0x2e, 0x37, -0x04, 0x0a, 0x86, 0x0f, 0x57, 0x49, 0xfc, -0x58, 0xc2, 0x79, 0xfa, 0x8f, 0x4a, 0xfa, -0x41, 0x7a, 0x8e, 0xb1, 0xe0, 0x57, 0x41, -0xe6, 0x7b, 0xad, 0xa9, 0x2f, 0x66, 0x89, -0x76, 0x88, 0x72, 0x5f, 0xd7, 0xf8, 0xc9, -0xdd, 0x64, 0x6d, 0x92, 0xe8, 0x5e, 0xce, -0x15, 0xb3, 0xa0, 0xf1, 0x2a, 0x24, 0xe0, -0x09, 0xf7, 0xb5, 0x77, 0x27, 0xff, 0x15, -0xd3, 0xaf, 0x33, 0x45, 0xe0, 0x33, 0x15, -0xef, 0xb7, 0x38, 0x23, 0xf2, 0x20, 0x1d, -0xd6, 0xc1, 0x6a, 0x37, 0x1d, 0xda, 0xfb, -0xf4, 0xa7, 0x29, 0x60, 0xf7, 0x45, 0x50, -0x0a, 0x9f, 0xcb, 0xa7, 0xc4, 0x17, 0x8d, -0x7d, 0x91, 0x3f, 0xb8, 0xa9, 0xcb, 0x0f, -0x89, 0x16, 0x2a, 0x1d, 0xc6, 0xef, 0xc7, -0x53, 0xe6, 0x53, 0xbf, 0x7c, 0x3d, 0xed, -0x79, 0x88, 0xd6, 0xbb, 0xf8, 0x2d, 0xeb, -0x1a, 0x87, 0xd4, 0xee, 0xc4, 0x30, 0xbd, -0xa0, 0x36, 0x98, 0xe5, 0x0a, 0xa5, 0x04, -0xb5, 0xaa, 0x25, 0x00, 0xc8, 0x0b, 0xee, -0x66, 0xe8, 0xc4, 0x6e, 0x9f, 0xb9, 0xea, -0x29, 0xdb, 0xb2, 0x70, 0xfc, 0x75, 0xc8, -0xef, 0x52, 0xd7, 0x4b, 0xa0, 0x15, 0x9c, -0xf0, 0x4a, 0xc5, 0xbe, 0xe0, 0xbd, 0x4f, -0xe7, 0x07, 0x61, 0x69, 0xa4, 0xd8, 0xf0, -0x6a, 0x2e, 0x8e, 0x7f, 0xf2, 0x1f, 0x98, -0x77, 0x9f, 0x19, 0xed, 0x1b, 0x39, 0x5a, -0xa1, 0xec, 0x26, 0xcd, 0xae, 0xe9, 0x13, -0xd5, 0x33, 0x86, 0xc7, 0x68, 0xc7, 0x18, -0xcf, 0xb0, 0x58, 0x11, 0x08, 0xe1, 0xe3, -0x79, 0x91, 0x29, 0x60, 0xc6, 0x3a, 0x31, -0x20, 0xc5, 0x82, 0xbb, 0x63, 0x7f, 0x57, -0x31, 0xef, 0x91, 0xf5, 0xe7, 0x68, 0x19, -0x29, 0x99, 0x01, 0x22, 0x53, 0x86, 0x41, -0x34, 0xf9, 0xb6, 0x46, 0x03, 0x78, 0xfb, -0xf3, 0x67, 0x33, 0x8a, 0x18, 0x7e, 0x0e, -0x18, 0x6e, 0xa0, 0x93, 0xfe, 0x3c, 0xa8, -0x47, 0xb0, 0xe9, 0xee, 0x27, 0x4f, 0x25, -0x29, 0x0f, 0x96, 0xa0, 0x26, 0xe7, 0xa6, -0xd6, 0xf2, 0x03, 0x85, 0x3b, 0x2e, 0xc6, -0x78, 0xe7, 0x77, 0x8d, 0x4f, 0xba, 0x03, -0x55, 0xeb, 0xdb, 0xac, 0x3d, 0x77, 0xdf, -0xdc, 0x27, 0xad, 0x71, 0x6c, 0xb9, 0xee, -0x87, 0xc8, 0x51, 0x3f, 0xe5, 0xe1, 0xa0, -0x3d, 0x42, 0xc9, 0xf2, 0x87, 0x7b, 0x0b, -0xe3, 0x68, 0xbc, 0xbc, 0xea, 0x79, 0xd2, -0x99, 0x0a, 0x9c, 0x29, 0x38, 0xb9, 0x96, -0x3a, 0xaa, 0xd5, 0x0f, 0xdf, 0xf8, 0xb7, -0x3b, 0xab, 0x35, 0x51, 0xbf, 0xa4, 0x60, -0xd2, 0xc8, 0xeb, 0x22, 0x9d, 0xc6, 0x51, -0x85, 0xc9, 0xc1, 0xd7, 0xe3, 0xd5, 0xa4, -0x2b, 0x76, 0x6f, 0xd1, 0x2a, 0x9a, 0xd3, -0x73, 0xca, 0xe7, 0x48, 0xc4, 0xa4, 0xa6, -0x11, 0xa9, 0x91, 0x03, 0xb8, 0xaa, 0xaf, -0xb0, 0xf7, 0x51, 0x7b, 0x4b, 0xed, 0x49, -0x65, 0x39, 0x76, 0xf4, 0x60, 0xbf, 0x01, -0x2f, 0xeb, 0x80, 0x9b, 0x4e, 0x51, 0xf2, -0x7d, 0xd4, 0x99, 0xab, 0x78, 0x49, 0x43, -0x05, 0x88, 0x8d, 0xee, 0xcc, 0x39, 0x32, -0xf8, 0xc2, 0x51, 0x7e, 0xd3, 0x58, 0x26, -0x01, 0xb2, 0x41, 0xc1, 0x9e, 0x38, 0x7e, -0xab, 0x05, 0x48, 0xbe, 0x95, 0x09, 0x9f, -0x02, 0x01, 0x15, 0xa6, 0x3d, 0xfa, 0xa7, -0xf9, 0xac, 0xe4, 0xc0, 0xb1, 0x22, 0x82, -0xfc, 0x37, 0x9b, 0xbd, 0xdb, 0xec, 0x23, -0x3e, 0xec, 0xd8, 0x64, 0x35, 0xe9, 0x81, -0xab, 0x15, 0x54, 0x28, 0x65, 0xf3, 0x2b, -0xe1, 0x3e, 0x9e, 0x6c, 0x45, 0x43, 0xdf, -0x76, 0x00, 0x37, 0xf4, 0x52, 0x8b, 0x68, -0xce, 0xb4, 0xe6, 0x24, 0x0f, 0x39, 0x03, -0x8a, 0x75, 0x78, 0x62, 0x68, 0xa6, 0x4d, -0x37, 0x32, 0x8e, 0xf6, 0x8c, 0x3e, 0xa3, -0xc8, 0xb2, 0xbf, 0x43, 0x03, 0x29, 0x2c, -0x1c, 0xa4, 0xde, 0x60, 0x54, 0xaa, 0x0e, -0x7a, 0xe2, 0x4e, 0xf0, 0x8f, 0x46, 0x95, -0xdf, 0x00, 0xbc, 0x53, 0xf2, 0x64, 0x96, -0xa2, 0x20, 0x7e, 0x45, 0xfa, 0x81, 0xa9, -0x93, 0x3a, 0x69, 0xa8, 0x5a, 0x17, 0xd8, -0xf0, 0x49, 0x3d, 0x1d, 0x82, 0x88, 0x5f, -0x37, 0x83, 0x7b, 0x08, 0xa9, 0x22, 0xc3, -0xa4, 0x2f, 0x2c, 0x21, 0x9f, 0x01, 0x9c, -0x61, 0xc4, 0x6a, 0x3a, 0x45, 0x59, 0xc0, -0x0e, 0x8b, 0x5d, 0xf8, 0xc6, 0xbf, 0x30, -0xc3, 0xec, 0xa0, 0xff, 0xdb, 0xda, 0xd3, -0x3e, 0x7d, 0x72, 0x04, 0x8f, 0x68, 0x76, -0xe6, 0x30, 0xb2, 0x13, 0xde, 0x8c, 0xe9, -0x07, 0xc2, 0xbf, 0x3a, 0x78, 0xf0, 0xf0, -0xd4, 0xc1, 0xdb, 0x64, 0x69, 0x26, 0x5d, -0x4f, 0xac, 0x98, 0x66, 0x4d, 0x20, 0x0d, -0xc0, 0x9c, 0x56, 0x94, 0xd8, 0xe2, 0x84, -0xa9, 0x32, 0x4c, 0x10, 0x47, 0x68, 0x2b, -0x33, 0x8c, 0x16, 0xb0, 0xf9, 0x35, 0x36, -0x2f, 0xcd, 0x3b, 0xbd, 0x31, 0x03, 0x70, -0xcf, 0x5b, 0x4c, 0x50, 0xdf, 0xd7, 0x54, -0xc0, 0x2f, 0x85, 0x7f, 0xee, 0xd1, 0x9a, -0xde, 0xfe, 0x9f, 0x3d, 0xce, 0x08, 0xc4, -0xd0, 0x8d, 0x96, 0x0f, 0x30, 0xdd, 0x60, -0x4f, 0x37, 0xf8, 0xf1, 0x10, 0x5e, 0x10, -0x3f, 0xfc, 0xbb, 0x6b, 0x7b, 0x7d, 0x9c, -0xe3, 0xf0, 0x27, 0xab, 0xa6, 0x9a, 0x70, -0xae, 0x18, 0xa0, 0x9a, 0xa7, 0x48, 0xb2, -0xf8, 0x28, 0xe3, 0x20, 0x76, 0x67, 0xaf, -0x3f, 0xb2, 0x5e, 0x59, 0x4c, 0x84, 0x9c, -0xc7, 0x6e, 0x41, 0x30, 0xbf, 0xfe, 0x9b, -0xb8, 0x9b, 0xab, 0x40, 0x09, 0xfd, 0x02, -0x99, 0x79, 0x9f, 0x39, 0xb4, 0x40, 0x73, -0xb3, 0x3e, 0xa0, 0x5e, 0xa0, 0x5c, 0x74, -0x5d, 0x21, 0xfc, 0x00, 0x57, 0xbf, 0x23, -0xda, 0xae, 0x49, 0xac, 0x6a, 0x10, 0xe6, -0x1e, 0x1b, 0x19, 0xe6, 0xce, 0x41, 0x6c, -0x3c, 0xe7, 0x45, 0x3c, 0xcb, 0x75, 0xa9, -0xd7, 0x60, 0x0d, 0x43, 0x69, 0x1e, 0xc2, -0x47, 0xea, 0x07, 0x46, 0x2c, 0x58, 0x25, -0x1e, 0x10, 0xe9, 0xc8, 0x8a, 0x14, 0x85, -0x6f, 0x49, 0x37, 0xd7, 0xfb, 0x07, 0xbb, -0xfa, 0xc2, 0x4e, 0x9d, 0xaf, 0x4c, 0xe6, -0xb8, 0xad, 0x1b, 0x70, 0x8c, 0x74, 0xda, -0xb4, 0x38, 0x57, 0xa7, 0x42, 0x4e, 0xe2, -0x84, 0xfb, 0x97, 0x4e, 0x46, 0x2c, 0xad, -0x37, 0xc0, 0x10, 0x62, 0x6c, 0x07, 0xea, -0x06, 0xc4, 0x5a, 0x29, 0xfb, 0x4c, 0x0f, -0xc6, 0x9e, 0x5f, 0xcd, 0xd6, 0x33, 0xc6, -0x1b, 0x92, 0x76, 0x99, 0xa3, 0xe7, 0x13, -0x92, 0x0b, 0x27, 0x3b, 0x75, 0xb2, 0x3f, -0x9c, 0x6b, 0x4e, 0x96, 0x9f, 0xfc, 0xed, -0x36, 0xb7, 0x69, 0x3d, 0xe2, 0x64, 0xa9, -0xb8, 0xdf, 0x46, 0x67, 0x6e, 0xc2, 0x2f, -0x5e, 0xf9, 0x24, 0x2b, 0xea, 0x6c, 0xde, -0x00, 0x14, 0x4a, 0xe0, 0x8e, 0x43, 0x0b, -0x2b, 0xcb, 0xf4, 0x93, 0x76, 0x97, 0x74, -0x61, 0xaf, 0x2e, 0x7d, 0xfe, 0x11, 0x74, -0x03, 0x8f, 0x38, 0x32, 0x7c, 0x1f, 0xf6, -0x46, 0x68, 0xac, 0x29, 0x48, 0x3e, 0x63, -0xac, 0x64, 0x10, 0x97, 0x1a, 0x22, 0x67, -0x09, 0x51, 0x0c, 0x46, 0x7e, 0xab, 0x21, -0x72, 0xbf, 0x12, 0x69, 0x99, 0x7c, 0xef, -0x07, 0x39, 0x33, 0x63, 0xf8, 0x16, 0x70, -0xe8, 0x25, 0x62, 0x90, 0xa4, 0xa4, 0x37, -0x0e, 0xcc, 0x8b, 0xc4, 0x6b, 0x77, 0x3f, -0xbd, 0xe7, 0xe8, 0xaa, 0xf1, 0x2c, 0x70, -0x00, 0xb3, 0x13, 0x91, 0xa9, 0x01, 0x2e, -0x8b, 0xc4, 0xf7, 0x4b, 0xe9, 0xc8, 0x6c, -0x3f, 0xfe, 0x3d, 0x99, 0x71, 0x95, 0x04, -0x01, 0x58, 0x62, 0x43, 0x2b, 0x38, 0xdc, -0x11, 0x03, 0x08, 0x98, 0x14, 0x7e, 0x71, -0xf4, 0xa6, 0x3d, 0xac, 0x02, 0x05, 0x97, -0xfe, 0xf0, 0x54, 0xd8, 0x4c, 0xd3, 0x11, -0xbc, 0x9f, 0x6a, 0x4b, 0x40, 0xd0, 0x5c, -0x53, 0xd5, 0x5c, 0x8d, 0xfa, 0x90, 0x95, -0x73, 0x7e, 0xb6, 0xba, 0x4d, 0x08, 0xf5, -0xb7, 0x46, 0x89, 0xf6, 0x9d, 0x82, 0x72, -0xce, 0x0d, 0xfc, 0x0e, 0x01, 0x07, 0x5a, -0xd8, 0xee, 0x8d, 0x20, 0x09, 0xfe, 0x2b, -0x08, 0x63, 0x62, 0xc6, 0xdb, 0x1d, 0xac, -0x9b, 0xbc, 0x97, 0x15, 0xba, 0x45, 0x1f, -0x05, 0x1a, 0xe4, 0xbb, 0x1a, 0xeb, 0x2a, -0xc6, 0x3a, 0xd5, 0xdc, 0x14, 0x90, 0x90, -0x29, 0x8d, 0xe1, 0x2b, 0x37, 0x50, 0x63, -0x1f, 0xcc, 0x73, 0xbe, 0x46, 0x69, 0xeb, -0x67, 0x75, 0xd6, 0x18, 0xc7, 0xde, 0x39, -0xd3, 0x26, 0x1f, 0xd3, 0xca, 0x39, 0x5f, -0x93, 0xf2, 0x5d, 0x94, 0x69, 0x3b, 0xbc, -0x68, 0x2e, 0x02, 0x6c, 0x07, 0x7d, 0xa9, -0x2a, 0xc7, 0xf7, 0xf9, 0x5c, 0xfd, 0x05, -0xb5, 0x5b, 0x5c, 0x07, 0xab, 0x26, 0xf5, -0xd5, 0xbd, 0x34, 0xdc, 0xf7, 0x73, 0x6e, -0x07, 0xc4, 0xca, 0x72, 0xe9, 0x82, 0x3f, -0x6f, 0x79, 0xff, 0xd7, 0xb6, 0xbe, 0x7a, -0xf7, 0xab, 0x49, 0x8c, 0xd5, 0xa2, 0x34, -0xb8, 0x9b, 0xe7, 0xca, 0x1f, 0x6e, 0x29, -0x08, 0x7e, 0xd9, 0x44, 0x7f, 0xda, 0x23, -0x0e, 0x99, 0xf7, 0xd0, 0x2f, 0x12, 0x68, -0xac, 0xbc, 0x41, 0xe0, 0x40, 0x5a, 0x3b, -0xee, 0x85, 0xb2, 0x49, 0x67, 0xd3, 0xee, -0xe2, 0x24, 0x5f, 0xb8, 0x89, 0x45, 0xad, -0xeb, 0x92, 0xf1, 0x86, 0x43, 0x15, 0x7e, -0x21, 0xbc, 0x06, 0xba, 0xe3, 0x78, 0xf8, -0x85, 0xc0, 0x90, 0x71, 0x16, 0xdb, 0x6f, -0x21, 0x0b, 0xd4, 0x69, 0x34, 0x35, 0x4e, -0x1c, 0xc1, 0x83, 0x2b, 0x4e, 0x2f, 0x2f, -0xb4, 0xf5, 0x2b, 0x94, 0x91, 0xdf, 0x97, -0x65, 0xd0, 0x79, 0x74, 0xd7, 0x61, 0x12, -0x3e, 0xf8, 0xaa, 0xfe, 0x74, 0x54, 0x09, -0x38, 0x0c, 0xdf, 0x0f, 0x2c, 0x21, 0xb7, -0x75, 0xf7, 0xb7, 0x39, 0x48, 0xdb, 0xbe, -0xee, 0x88, 0x61, 0xb9, 0x46, 0x2a, 0x5e, -0x34, 0xf9, 0x27, 0x9b, 0xeb, 0x9a, 0x68, -0xba, 0xc6, 0x9f, 0x5d, 0xc7, 0xf3, 0x02, -0x93, 0x9a, 0xf5, 0x2f, 0xa8, 0xe0, 0xac, -0x9d, 0xb8, 0x2d, 0x2e, 0xd2, 0x2e, 0x19, -0x40, 0x31, 0xa2, 0xe9, 0x40, 0x8d, 0xb5, -0x0c, 0xda, 0x09, 0xe2, 0x70, 0x5a, 0x57, -0x78, 0x50, 0x26, 0xfe, 0xa1, 0x75, 0x37, -0x74, 0xa3, 0x19, 0xd9, 0xf3, 0x9b, 0xf5, -0x66, 0x12, 0x1e, 0xb9, 0x1a, 0x25, 0xad, -0x94, 0x64, 0x5e, 0x82, 0x93, 0xc6, 0x66, -0xd6, 0xeb, 0x48, 0xff, 0x8f, 0x7d, 0xa1, -0x9d, 0x24, 0xd2, 0xf5, 0x84, 0xf9, 0x1b, -0xa5, 0xaa, 0xed, 0xec, 0xb5, 0xc4, 0x9e, -0xaf, 0xda, 0x54, 0x5d, 0x32, 0xfd, 0xe1, -0x4f, 0x77, 0xa9, 0xdb, 0x77, 0x50, 0x54, -0x75, 0xcd, 0x4e, 0x9a, 0xd9, 0x87, 0x25, -0xae, 0x5a, 0x73, 0x36, 0x5d, 0x80, 0xa8, -0x70, 0x76, 0x8a, 0xc5, 0x42, 0xb2, 0xc1, -0xed, 0x8e, 0x3b, 0xf8, 0x1c, 0xbf, 0x99, -0x8a, 0x9b, 0x5d, 0x83, 0xf8, 0x55, 0x91, -0xd9, 0xd9, 0xc0, 0xa8, 0xfc, 0x42, 0xdb, -0xd8, 0x42, 0xcf, 0x65, 0x45, 0x14, 0xac, -0x06, 0x65, 0x93, 0x74, 0x3c, 0xa0, 0x61, -0x24, 0xb1, 0x17, 0x4c, 0xab, 0xb4, 0x67, -0xd5, 0xbc, 0x0a, 0x2d, 0x42, 0xea, 0x87, -0xad, 0x56, 0xb4, 0xf7, 0xb0, 0xed, 0x44, -0xff, 0xe6, 0x10, 0xec, 0x19, 0x22, 0xb6, -0xfc, 0x1f, 0xc4, 0x3c, 0x6c, 0x43, 0x7f, -0x0a, 0xb6, 0x9c, 0xed, 0x3d, 0x66, 0xd3, -0x43, 0xc8, 0xe5, 0x33, 0x13, 0x1d, 0xd1, -0xaa, 0x0b, 0xa6, 0x59, 0xed, 0x60, 0xb2, -0xa8, 0x5e, 0xee, 0x00, 0x2f, 0x73, 0xf3, -0xa3, 0xdc, 0x8d, 0x9a, 0xb6, 0xa3, 0x6f, -0x9a, 0x20, 0x9f, 0xfe, 0xb9, 0xb8, 0xe8, -0x49, 0x22, 0x93, 0xe2, 0xc0, 0xf1, 0x66, -0xe0, 0xbe, 0x32, 0x94, 0x13, 0x4b, 0x4a, -0x70, 0xa0, 0xfe, 0xfb, 0xa3, 0xe7, 0x99, -0xd0, 0x9d, 0xc1, 0x89, 0x91, 0xe4, 0x78, -0xc3, 0xf0, 0xb2, 0xae, 0x27, 0x71, 0xc8, -0x87, 0x1d, 0xaa, 0x40, 0x44, 0x23, 0x68, -0x9f, 0x51, 0xd5, 0x8b, 0x88, 0xf3, 0x29, -0x2f, 0xf5, 0xdf, 0x31, 0xa5, 0xcd, 0x8e, -0xc2, 0x16, 0x2f, 0x0f, 0x69, 0x45, 0xb8, -0x9b, 0x23, 0xda, 0x29, 0xa6, 0x3c, 0xb8, -0xc4, 0x81, 0x5c, 0x25, 0x1e, 0x88, 0x7e, -0x30, 0x47, 0xe4, 0x4b, 0xea, 0x6a, 0xb2, -0xe7, 0x78, 0x21, 0xe0, 0xec, 0x4f, 0x36, -0xad, 0x1a, 0xe1, 0x1c, 0x9c, 0x83, 0xfb, -0x51, 0xb1, 0x0b, 0x92, 0x1d, 0x04, 0xb2, -0xe3, 0xf8, 0xf9, 0xb0, 0x67, 0x7a, 0x55, -0x11, 0xb9, 0x24, 0xc5, 0x8d, 0x25, 0x74, -0x49, 0x47, 0xb8, 0x6b, 0xc2, 0xe3, 0x84, -0xef, 0x3a, 0x32, 0x46, 0x60, 0x1f, 0x5e, -0xa4, 0x5f, 0x9e, 0x20, 0x3a, 0x6e, 0xc5, -0x7e, 0x4b, 0xa5, 0x05, 0x46, 0xa4, 0x15, -0xdd, 0x60, 0x3c, 0xda, 0xd9, 0x52, 0x20, -0x59, 0xa3, 0x12, 0x6d, 0x03, 0xda, 0x88, -0x60, 0xd6, 0xeb, 0x6b, 0x2a, 0x38, 0x35, -0xe6, 0x4a, 0xbf, 0x57, 0xe9, 0x1d, 0x50, -0x40, 0xd9, 0x74, 0xe9, 0xc5, 0x03, 0x2a, -0xde, 0x1e, 0x95, 0xc7, 0xd4, 0xd2, 0x58, -0x70, 0xdb, 0x20, 0xaa, 0x46, 0x94, 0x55, -0xd8, 0x19, 0xc7, 0xe6, 0xd4, 0x9b, 0x25, -0x4f, 0x5d, 0xf9, 0x57, 0x9d, 0xb3, 0x21, -0x31, 0x95, 0x7c, 0xb6, 0xcb, 0x67, 0x4d, -0x2f, 0xd7, 0xa7, 0xdd, 0xe5, 0x08, 0xf7, -0x2e, 0xab, 0x37, 0xee, 0xb0, 0x78, 0x51, -0x9b, 0xfd, 0xda, 0x9f, 0xe2, 0x8f, 0xc0, -0x7d, 0xfd, 0x72, 0xd6, 0xa1, 0x5f, 0x05, -0x73, 0x9b, 0x8d, 0xbf, 0xb1, 0x21, 0xd1, -0x6f, 0x9b, 0x6d, 0x40, 0x68, 0x0e, 0x68, -0x5c, 0x56, 0xfe, 0xae, 0xf1, 0xa6, 0x19, -0x18, 0x16, 0xb9, 0xa5, 0xc3, 0x3b, 0x2c, -0xcc, 0x15, 0x6d, 0xad, 0x01, 0xc3, 0x9c, -0xcd, 0xce, 0xd2, 0xdb, 0x17, 0x07, 0x54, -0x44, 0x2b, 0xa5, 0xaf, 0xe7, 0x65, 0xe8, -0x2e, 0x71, 0xf3, 0xe3, 0x0d, 0xb1, 0xe4, -0x07, 0x57, 0xb9, 0x83, 0x9f, 0xae, 0x98, -0x1f, 0xc0, 0x1a, 0xc9, 0x94, 0x22, 0xe1, -0x4c, 0xad, 0x1e, 0xc8, 0x6b, 0x34, 0x9a, -0x0a, 0xeb, 0xd4, 0x83, 0x0e, 0xb1, 0x34, -0x56, 0xdb, 0x9a, 0xca, 0xbb, 0x0d, 0x34, -0x9c, 0x38, 0x74, 0x6b, 0xee, 0x67, 0x65, -0xb4, 0xee, 0xb3, 0x65, 0xc4, 0x22, 0xeb, -0x4b, 0x7d, 0x67, 0xe5, 0x83, 0x8d, 0xf4, -0x92, 0x02, 0x88, 0xad, 0x85, 0xe7, 0xbd, -0xfd, 0x9f, 0xd8, 0x55, 0x86, 0x8e, 0x0d, -0x1a, 0xff, 0x1a, 0x0a, 0x5d, 0xf9, 0x0a, -0xc3, 0xa3, 0x66, 0x35, 0xab, 0x09, 0x3c, -0xfc, 0x3e, 0x81, 0xe7, 0xd2, 0xa2, 0x7c, -0xf2, 0xb3, 0x0a, 0x18, 0x1b, 0xcb, 0xfa, -0x3f, 0x6c, 0x2a, 0x9c, 0x56, 0x54, 0x6c, -0xf6, 0xf6, 0xb8, 0xae, 0x63, 0xd0, 0x3b, -0x03, 0xad, 0xc2, 0xb5, 0xe3, 0x17, 0x7e, -0x60, 0x04, 0x76, 0x12, 0x2b, 0x86, 0x6a, -0x9e, 0x7d, 0xa4, 0x92, 0x14, 0x61, 0x47, -0x76, 0xb4, 0x8c, 0x27, 0x4e, 0x4b, 0xc6, -0x52, 0x63, 0x8f, 0xa0, 0x17, 0xf6, 0x32, -0x2c, 0x91, 0x5c, 0x14, 0x20, 0xb5, 0xf7, -0x5a, 0xf2, 0x4e, 0xcf, 0xd3, 0x7b, 0x04, -0xe6, 0xb9, 0xe5, 0x09, 0xa0, 0x53, 0xfd, -0x60, 0x0c, 0x83, 0xb2, 0xb9, 0xcb, 0xd2, -0xfb, 0xc3, 0x16, 0x48, 0x8d, 0xcf, 0xec, -0xd8, 0xf2, 0x68, 0x46, 0x8f, 0x5a, 0x26, -0x1c, 0x4e, 0x31, 0x7e, 0x65, 0x4b, 0xc7, -0xd6, 0x4e, 0x9d, 0xe4, 0x06, 0x98, 0x1e, -0xef, 0x79, 0x41, 0xfe, 0x9d, 0xe1, 0x68, -0xbf, 0x45, 0x17, 0xb7, 0x34, 0x90, 0x7c, -0xa6, 0xf2, 0xe7, 0xa7, 0x59, 0xc0, 0x12, -0xb0, 0xce, 0x62, 0x1c, 0x22, 0x31, 0x52, -0x8d, 0x3f, 0x55, 0x41, 0x92, 0x0a, 0xa5, -0x1e, 0x1d, 0x3c, 0x84, 0xd2, 0x51, 0xe7, -0x6b, 0x4a, 0xb5, 0x10, 0x01, 0xec, 0x76, -0x5b, 0xda, 0x57, 0xe4, 0x11, 0xcd, 0x6f, -0x40, 0x3e, 0xe6, 0x48, 0x22, 0x86, 0xd6, -0xb6, 0x7c, 0x43, 0x84, 0x82, 0x70, 0x3e, -0x35, 0x24, 0xaf, 0x79, 0x55, 0xe5, 0x36, -0xcf, 0x3e, 0x02, 0xcf, 0x25, 0x02, 0xb6, -0xd4, 0xc3, 0x17, 0x68, 0xba, 0x60, 0x94, -0xf4, 0x3d, 0x7a, 0x0b, 0x48, 0xc1, 0xc6, -0xd6, 0xf3, 0x1a, 0x08, 0x05, 0x20, 0x3e, -0x88, 0x59, 0x83, 0x75, 0xa9, 0x1f, 0xd3, -0x79, 0x81, 0x81, 0xac, 0xb3, 0x94, 0xd1, -0x67, 0x5b, 0x6e, 0xcd, 0x04, 0x79, 0x91, -0x8e, 0x6e, 0xa5, 0x2a, 0x06, 0x9d, 0x49, -0x7c, 0x58, 0x91, 0xcf, 0xae, 0x88, 0xc0, -0xc9, 0x19, 0xb4, 0xcc, 0x4e, 0x6e, 0x06, -0x50, 0xf6, 0x3c, 0x3e, 0xc7, 0x48, 0xb1, -0x9e, 0x32, 0xe3, 0x54, 0x05, 0xac, 0x41, -0xd8, 0x31, 0xb6, 0xb3, 0x6e, 0xf1, 0x4d, -0xfe, 0xd4, 0x38, 0x2e, 0xff, 0x2f, 0x3a, -0x61, 0xa3, 0xe7, 0x77, 0x99, 0xcb, 0x27, -0xb8, 0x26, 0xab, 0xc4, 0x10, 0xe3, 0xdf, -0x93, 0x05, 0x2b, 0x95, 0x7e, 0xca, 0x2e, -0x6c, 0xe2, 0x9b, 0x29, 0x67, 0xfd, 0x73, -0x91, 0x61, 0x2b, 0xa4, 0x5d, 0xea, 0x95, -0xe2, 0x63, 0xae, 0xe8, 0x43, 0x98, 0x2e, -0x15, 0x09, 0xf4, 0x98, 0x5d, 0x9c, 0x98, -0x4f, 0x74, 0x63, 0x9d, 0x5d, 0x93, 0xda, -0x26, 0x36, 0xb7, 0xb0, 0xf9, 0xe5, 0x04, -0x9c, 0xeb, 0xaf, 0x94, 0x72, 0xa1, 0xf5, -0xf1, 0x7f, 0xa1, 0xeb, 0x32, 0x0a, 0x9a, -0x90, 0xc5, 0xbb, 0xb8, 0x55, 0x05, 0x91, -0xe0, 0x0c, 0xd6, 0x1e, 0x8f, 0xfd, 0xd8, -0xe7, 0xf5, 0xb4, 0x2f, 0xf3, 0xa4, 0xe1, -0x1b, 0x95, 0x30, 0xcf, 0x1f, 0x72, 0xfc, -0xbb, 0x6d, 0x4d, 0x06, 0x80, 0x68, 0xe0, -0x98, 0x77, 0x97, 0x66, 0x2c, 0x48, 0x3b, -0xa6, 0xb9, 0x1d, 0x76, 0x02, 0x6c, 0x7a, -0x9e, 0x3e, 0xf9, 0x2f, 0x4b, 0x1a, 0xae, -0x34, 0x03, 0x39, 0xe2, 0x7f, 0x1e, 0x5a, -0x29, 0x8d, 0x45, 0xac, 0x2e, 0x85, 0x91, -0xd0, 0x37, 0xcf, 0xe0, 0x84, 0x02, 0x13, -0x13, 0x69, 0xd7, 0x8a, 0xc6, 0xbc, 0x07, -0xb4, 0x1c, 0xa0, 0xa7, 0x18, 0x73, 0x26, -0x8d, 0xad, 0xae, 0x67, 0xc3, 0x83, 0x88, -0x46, 0x52, 0x90, 0x23, 0x40, 0xd1, 0x04, -0x50, 0xbe, 0x57, 0x0c, 0x37, 0x13, 0x8f, -0x29, 0x8a, 0xcd, 0xc0, 0x67, 0xb7, 0x97, -0xfa, 0x41, 0xf5, 0x88, 0x2f, 0x63, 0x4a, -0x5b, 0xd2, 0x60, 0xc0, 0x76, 0xfa, 0xa8, -0xbb, 0xfc, 0x8a, 0xc1, 0x07, 0x2a, 0x31, -0x01, 0xf8, 0x31, 0x43, 0xdc, 0x13, 0x86, -0xb1, 0x46, 0x6d, 0xb8, 0xd5, 0xc7, 0x14, -0xa8, 0xab, 0x99, 0xd6, 0x54, 0x48, 0x9e, -0x60, 0xf9, 0xf5, 0x74, 0xd9, 0xa9, 0xcc, -0xbd, 0x1c, 0xa9, 0xce, 0xc2, 0xa6, 0x18, -0x21, 0xad, 0x44, 0x72, 0x71, 0x8d, 0xd7, -0x91, 0xcd, 0x4f, 0x9d, 0x98, 0x39, 0x2e, -0x62, 0xe2, 0xbf, 0x8b, 0xab, 0xb0, 0x8c, -0xda, 0xa7, 0x44, 0x45, 0xcf, 0xff, 0xfd, -0x0e, 0xee, 0xd7, 0xcb, 0xbb, 0x09, 0x6d, -0x86, 0xb2, 0x31, 0x54, 0xcd, 0xca, 0x49, -0x67, 0x5c, 0x7f, 0x49, 0x90, 0xf3, 0xb3, -0x95, 0x8d, 0x25, 0xed, 0x4e, 0x84, 0x28, -0xb3, 0xbf, 0x68, 0xc1, 0xc6, 0x32, 0xa0, -0x66, 0xb0, 0x07, 0x25, 0xc5, 0x26, 0xfb, -0x76, 0x9e, 0x73, 0xed, 0x63, 0x19, 0x2f, -0xb1, 0x3e, 0xb0, 0xc7, 0x8c, 0xd8, 0x7d, -0x60, 0xb5, 0x0a, 0x0c, 0x57, 0x0d, 0xac, -0xa5, 0xa3, 0xa4, 0x94, 0x4b, 0x07, 0x7d, -0xc3, 0x4e, 0x99, 0x32, 0x34, 0x95, 0x7b, -0x99, 0xea, 0x30, 0x93, 0x16, 0x81, 0x61, -0x86, 0x6b, 0xa7, 0x28, 0xd9, 0x62, 0xf0, -0x0e, 0x48, 0x5f, 0xad, 0x97, 0x1b, 0x8b, -0x14, 0x4e, 0x10, 0xa7, 0xac, 0xf7, 0xa1, -0x86, 0x43, 0x53, 0x73, 0x90, 0xc4, 0x4b, -0xb9, 0xcb, 0x56, 0x8a, 0x54, 0xd0, 0xbb, -0xa5, 0xcb, 0xbb, 0x7b, 0xb1, 0xb0, 0x22, -0x82, 0x58, 0x85, 0xdd, 0x80, 0x78, 0xfb, -0x2d, 0x67, 0x23, 0x38, 0xdb, 0x96, 0xe1, -0x98, 0xc6, 0x07, 0xed, 0xd0, 0x8a, 0xeb, -0x29, 0xda, 0xdd, 0xc9, 0x14, 0xea, 0xe9, -0xeb, 0x3b, 0x5e, 0xd1, 0x06, 0x80, 0xb8, -0x3e, 0x87, 0x49, 0x23, 0x5c, 0xcf, 0x47, -0x20, 0xd4, 0x84, 0x2c, 0xba, 0xc7, 0x4b, -0x0c, 0xf5, 0xfd, 0xa9, 0x36, 0xdd, 0x32, -0x97, 0x78, 0x6b, 0x52, 0x4a, 0xac, 0x73, -0xb6, 0x38, 0x58, 0x6c, 0xc4, 0x2c, 0xbe, -0x57, 0xbc, 0xd2, 0x29, 0xad, 0xb0, 0xfc, -0xd9, 0xcf, 0x0d, 0x4d, 0x8d, 0x85, 0x80, -0x50, 0x8e, 0x35, 0xf1, 0x9a, 0x9f, 0x19, -0x05, 0xb8, 0x65, 0x0f, 0x1b, 0xc5, 0xca, -0xb9, 0xbb, 0x66, 0xf9, 0x18, 0x6a, 0x2b, -0x45, 0x6f, 0x98, 0xe5, 0x09, 0xd4, 0x7b, -0x84, 0x50, 0x3d, 0x44, 0x58, 0xf7, 0xa7, -0xc8, 0xf3, 0xef, 0xa1, 0x5c, 0x0e, 0x9c, -0x7f, 0xbf, 0x6d, 0xfd, 0x54, 0xcc, 0xe0, -0xf8, 0xa9, 0x41, 0x85, 0x55, 0xfa, 0x0e, -0xa2, 0x89, 0xc8, 0xcf, 0xd8, 0x6e, 0x6b, -0x1d, 0x96, 0x9f, 0x48, 0xf9, 0xa2, 0x67, -0xff, 0xf0, 0x86, 0x3d, 0x03, 0xc5, 0x73, -0x5c, 0xeb, 0x9f, 0xe1, 0x1e, 0x5d, 0x06, -0x59, 0x2e, 0xfa, 0x69, 0x41, 0x6f, 0x8b, -0x5a, 0x51, 0x9a, 0x75, 0x0d, 0x6a, 0x94, -0x51, 0xac, 0xb9, 0xb4, 0x31, 0xe1, 0xea, -0x38, 0xe4, 0x91, 0x1a, 0x59, 0xb1, 0xd5, -0x94, 0x3a, 0x7a, 0x9f, 0x5d, 0xb6, 0xe0, -0x46, 0x33, 0x5c, 0x2d, 0xb4, 0x5e, 0x5d, -0xaf, 0x0a, 0x24, 0x0a, 0xae, 0x39, 0xe5, -0xef, 0xc4, 0xb1, 0x26, 0xad, 0x42, 0x1f, -0xc3, 0x12, 0x79, 0xb8, 0x60, 0xcc, 0x23, -0x28, 0x6d, 0x11, 0x41, 0x27, 0x08, 0x8f, -0xbd, 0x12, 0xbe, 0x71, 0x5f, 0x48, 0x99, -0x88, 0xa0, 0xa0, 0x34, 0xb5, 0x0e, 0x72, -0xe3, 0x99, 0x7d, 0x88, 0x14, 0x1c, 0x3e, -0x3d, 0x9b, 0x1e, 0xe0, 0x6b, 0x2b, 0xb6, -0xd6, 0x3d, 0xe3, 0x86, 0xdf, 0x31, 0x61, -0x5e, 0x4a, 0xba, 0xf6, 0x9d, 0xd4, 0xf9, -0x8c, 0xdf, 0x59, 0x8a, 0x47, 0x2d, 0x04, -0x95, 0x64, 0x2c, 0x0f, 0x9e, 0xcb, 0xf9, -0x08, 0x37, 0x47, 0x43, 0x23, 0xe5, 0x16, -0x5b, 0x73, 0xbe, 0xc1, 0x8f, 0x24, 0x59, -0x36, 0xa7, 0xa9, 0xa8, 0x63, 0xd5, 0x25, -0xfc, 0xf7, 0x64, 0x6a, 0x16, 0x2d, 0x03, -0xe3, 0x44, 0x2a, 0xc8, 0xa9, 0x0a, 0xe4, -0xb8, 0x11, 0xc0, 0xd8, 0x7f, 0x82, 0x96, -0x79, 0x79, 0x0c, 0xdb, 0xe0, 0x09, 0xfb, -0x0b, 0x84, 0x7a, 0x44, 0x91, 0x68, 0x15, -0xec, 0x7d, 0x20, 0x43, 0x87, 0xd8, 0x99, -0x4c, 0xda, 0xa5, 0xf1, 0xe1, 0xa8, 0xfb, -0x7e, 0x07, 0x2a, 0x98, 0x43, 0x87, 0x69, -0xa3, 0xb0, 0x68, 0xce, 0xdd, 0xad, 0xb0, -0x1f, 0x26, 0x1e, 0x60, 0x4f, 0x92, 0xc8, -0x74, 0xb3, 0xee, 0xee, 0x53, 0x73, 0x97, -0x03, 0xa0, 0x5a, 0x84, 0x9f, 0x9b, 0x79, -0x2b, 0x6b, 0xbb, 0xec, 0x95, 0xa6, 0x97, -0x01, 0x47, 0x45, 0xd7, 0x07, 0x77, 0x86, -0x19, 0x43, 0x8d, 0x9a, 0x44, 0x7c, 0xb5, -0xfc, 0xa3, 0x47, 0x2b, 0xaf, 0x60, 0x26, -0x6e, 0x7e, 0x85, 0xb6, 0x72, 0x26, 0xec, -0x11, 0xe4, 0xf9, 0x11, 0xea, 0x0f, 0xba, -0xe1, 0x17, 0x3c, 0xe6, 0x73, 0x4d, 0x03, -0x25, 0x1d, 0xcf, 0x45, 0x07, 0x78, 0x01, -0xfa, 0x31, 0x88, 0xc9, 0xe1, 0x23, 0x72, -0x0f, 0x29, 0x19, 0x54, 0xa9, 0x81, 0xaa, -0x0e, 0xa5, 0x76, 0x1a, 0xb9, 0x38, 0xbd, -0xae, 0x53, 0xf8, 0xa6, 0x53, 0x4b, 0xc9, -0xa8, 0x80, 0xeb, 0xbc, 0x24, 0xf6, 0xf3, -0xb9, 0x3d, 0x53, 0x53, 0xf0, 0x13, 0xfe, -0x3b, 0x5a, 0x60, 0xb9, 0x8a, 0x32, 0x7e, -0x7a, 0x6f, 0xd2, 0xe5, 0x1b, 0x23, 0x66, -0xb4, 0x3b, 0xc3, 0xf6, 0x1f, 0x62, 0xd5, -0xe4, 0x26, 0x62, 0x38, 0xc0, 0x7f, 0xce, -0xa4, 0x14, 0x11, 0xe9, 0xfa, 0x97, 0x64, -0x4e, 0x0f, 0x82, 0x6f, 0x82, 0x82, 0x2d, -0x2a, 0xd0, 0xc0, 0xd3, 0x66, 0x37, 0x87, -0x1b, 0x9d, 0xaf, 0x2c, 0xbd, 0xe3, 0xb2, -0x15, 0x36, 0x75, 0x65, 0x1c, 0x68, 0xbc, -0x4d, 0x64, 0xe6, 0x50, 0x82, 0x0a, 0x4f, -0x4b, 0x0d, 0x2c, 0x89, 0x63, 0x50, 0x18, -0x48, 0x3c, 0xcf, 0xa8, 0xa8, 0xd8, 0x03, -0xb8, 0xab, 0xed, 0x3a, 0x81, 0x1e, 0x90, -0x00, 0x37, 0xd6, 0x45, 0xb5, 0x3b, 0xaf, -0x3f, 0xa2, 0x65, 0xed, 0x94, 0xcf, 0x64, -0xb7, 0xa5, 0x8c, 0xc5, 0xed, 0x82, 0xac, -0x80, 0x08, 0x7e, 0xd2, 0x5b, 0x80, 0xfd, -0xf3, 0xc7, 0x7c, 0x1b, 0xb0, 0x94, 0xb3, -0xd4, 0x75, 0x3c, 0xf6, 0x66, 0x84, 0xb1, -0xc5, 0x3c, 0x16, 0x9c, 0x02, 0x65, 0xb6, -0x32, 0x7c, 0xd6, 0xbf, 0xf7, 0x38, 0xab, -0xc3, 0x66, 0xa3, 0x2f, 0x19, 0x00, 0x40, -0xd3, 0xd0, 0x97, 0xf2, 0x77, 0x09, 0x57, -0x68, 0xcf, 0xce, 0x25, 0x7e, 0x7c, 0xec, -0x31, 0xf6, 0xed, 0x1d, 0xdc, 0xbb, 0xa3, -0x4b, 0x24, 0xb3, 0x94, 0x56, 0xed, 0xd8, -0x59, 0x01, 0x4c, 0x45, 0xff, 0x9d, 0x8c, -0xbf, 0xa1, 0x40, 0x19, 0xdc, 0x17, 0x04, -0x8d, 0xd4, 0x43, 0x9e, 0xa0, 0x0a, 0xca, -0x9d, 0x1e, 0xc7, 0xf5, 0x50, 0xad, 0x6b, -0x99, 0x75, 0xda, 0x4b, 0xfc, 0x4f, 0x92, -0x5e, 0x3c, 0x49, 0xb7, 0x0e, 0xf6, 0xda, -0x35, 0xa7, 0x17, 0xd3, 0xb7, 0x30, 0xc9, -0x7b, 0x50, 0xcc, 0x09, 0x29, 0xa4, 0xfa, -0xc0, 0x63, 0xaf, 0xee, 0x0e, 0xfb, 0x06, -0x69, 0x4a, 0x2f, 0x38, 0xf9, 0x3e, 0x42, -0x22, 0xd1, 0x08, 0xe6, 0x75, 0xd1, 0x07, -0xb6, 0x76, 0x11, 0x60, 0xe7, 0x03, 0x07, -0x11, 0x3a, 0x2f, 0x38, 0x5e, 0x2b, 0xc7, -0x65, 0xb6, 0x2c, 0x62, 0xf6, 0x4c, 0xb7, -0xb6, 0xae, 0x56, 0x4c, 0x6d, 0xfe, 0x86, -0xd6, 0x8b, 0x25, 0x04, 0xc1, 0x9c, 0x8c, -0x87, 0x66, 0x1a, 0x7b, 0xe9, 0xf4, 0x0c, -0xc0, 0xdb, 0xca, 0xf2, 0x8a, 0x8f, 0x0b, -0xdb, 0x9d, 0xfe, 0xf5, 0x38, 0x09, 0x74, -0xac, 0xd8, 0x7e, 0x7c, 0x1b, 0xc4, 0xda, -0x71, 0x73, 0x00, 0x0b, 0x3f, 0x1b, 0xb0, -0xbc, 0xd4, 0xe4, 0xf3, 0x14, 0x43, 0xb7, -0x51, 0xd0, 0x38, 0x82, 0x77, 0x39, 0xa2, -0x16, 0x0e, 0xc5, 0xd5, 0x90, 0x70, 0xb2, -0x92, 0x4b, 0xb7, 0xb3, 0x7c, 0xad, 0x3a, -0xf9, 0xd6, 0x53, 0x3f, 0xf8, 0xdb, 0x03, -0x10, 0x14, 0x4f, 0x7c, 0x47, 0x64, 0x24, -0xd2, 0xd8, 0xec, 0x72, 0x73, 0xc8, 0x21, -0x81, 0xcc, 0xb5, 0x11, 0xd2, 0x8c, 0xbc, -0xe1, 0x27, 0xa7, 0xe5, 0x76, 0xae, 0x92, -0x19, 0x23, 0x99, 0x43, 0x8f, 0x3b, 0xee, -0xd5, 0x62, 0xf8, 0x5c, 0xbf, 0x9f, 0xb9, -0xa8, 0x65, 0xdb, 0xf6, 0x86, 0xff, 0x9b, -0x2c, 0xe6, 0x80, 0x0b, 0x80, 0x17, 0x12, -0x48, 0x81, 0x81, 0x79, 0x7d, 0xae, 0xc9, -0x15, 0x79, 0x45, 0xa7, 0x45, 0x3a, 0x97, -0xf5, 0x9a, 0x67, 0xaf, 0x07, 0x35, 0x28, -0x61, 0xf1, 0x16, 0x0b, 0x89, 0x5e, 0xa8, -0x63, 0x38, 0x24, 0xd9, 0x21, 0x7b, 0xa4, -0x4e, 0x63, 0x4e, 0x26, 0xc5, 0x31, 0xcf, -0x9e, 0x9b, 0x7e, 0xce, 0x94, 0x58, 0x95, -0x63, 0x36, 0x88, 0xa8, 0x96, 0x1b, 0xd5, -0xfd, 0x24, 0xfc, 0xc3, 0xaf, 0x39, 0xb2, -0x12, 0x18, 0xb7, 0xe4, 0x93, 0xb3, 0x7c, -0x73, 0x38, 0x2d, 0x63, 0xb6, 0x3b, 0xce, -0xa9, 0x0e, 0xb8, 0xa5, 0x4b, 0x97, 0x63, -0x92, 0xcf, 0xd9, 0xd9, 0x67, 0x40, 0x17, -0x42, 0x4b, 0xc8, 0xdf, 0x4c, 0x14, 0x3b, -0x3c, 0x23, 0x91, 0xf2, 0x57, 0x38, 0x23, -0x8e, 0x66, 0xf0, 0xfd, 0x3b, 0x9e, 0x4d, -0x93, 0x23, 0x49, 0xed, 0x96, 0xf7, 0x1b, -0x11, 0x55, 0x55, 0x86, 0x2f, 0x09, 0xe1, -0x57, 0xa8, 0xc2, 0x54, 0x1a, 0x81, 0x85, -0x50, 0x64, 0xfc, 0x16, 0x0b, 0x0c, 0x20, -0x24, 0xb5, 0x62, 0x8f, 0x21, 0xc1, 0xe8, -0x14, 0x7e, 0xec, 0x8c, 0xa4, 0x82, 0x3b, -0xb9, 0xfc, 0x3e, 0xfd, 0x96, 0x17, 0xe0, -0xcf, 0x6f, 0x21, 0x67, 0xb5, 0x76, 0x39, -0x8b, 0xf6, 0x98, 0xff, 0xbb, 0x7f, 0xd6, -0x8c, 0xdb, 0x4a, 0xba, 0xdf, 0xd6, 0x52, -0xfa, 0x53, 0x2e, 0x82, 0x7e, 0x1c, 0x1e, -0x63, 0x7c, 0x35, 0x39, 0xde, 0x9f, 0x5f, -0xc4, 0xbe, 0xe2, 0xcd, 0xcf, 0x43, 0x40, -0x55, 0x98, 0x6a, 0x21, 0x8e, 0xac, 0x93, -0x90, 0x98, 0x6f, 0xcf, 0xe5, 0x88, 0x13, -0x27, 0x5c, 0x88, 0xad, 0x16, 0x9a, 0x2f, -0x5f, 0x8b, 0x88, 0xfd, 0x01, 0x9a, 0x75, -0x56, 0x5f, 0xd4, 0x6f, 0xc7, 0x20, 0x30, -0xe2, 0xf6, 0x97, 0x77, 0xee, 0xa1, 0xd4, -0x50, 0x26, 0x3a, 0x3f, 0x9e, 0x5a, 0x75, -0xa8, 0xce, 0xf5, 0x4f, 0x2e, 0xfc, 0xee, -0x87, 0xb2, 0xe9, 0x92, 0x5e, 0xce, 0x09, -0x12, 0x1b, 0x56, 0x3e, 0x28, 0xb1, 0x2c, -0x1f, 0xe4, 0x59, 0x09, 0x75, 0x1a, 0xdf, -0x3e, 0x91, 0x79, 0x0f, 0x71, 0x36, 0x6d, -0xb2, 0xcd, 0x82, 0x0c, 0x9d, 0x3d, 0xfa, -0x0f, 0x8c, 0xf8, 0xc2, 0x65, 0xa6, 0xae, -0x42, 0xe5, 0x73, 0x0d, 0x6e, 0x26, 0x92, -0x8e, 0x1d, 0x88, 0x2f, 0x2c, 0xa5, 0x92, -0x8b, 0xac, 0xa8, 0x60, 0x1d, 0xbc, 0xbe, -0x03, 0x04, 0x53, 0x5d, 0xf9, 0x33, 0x12, -0x8b, 0xc2, 0x6c, 0x5a, 0xf4, 0x68, 0x4d, -0x94, 0x65, 0x06, 0xa5, 0xa3, 0x06, 0x62, -0x82, 0xb6, 0x4d, 0xf3, 0x76, 0x9d, 0xdc, -0x69, 0xb8, 0xef, 0xf5, 0x80, 0xa5, 0xc6, -0xfe, 0xe1, 0xcc, 0xb3, 0x5a, 0xa9, 0x8a, -0x70, 0x33, 0xc6, 0x9f, 0x33, 0xdb, 0x51, -0xc1, 0x10, 0x00, 0xea, 0x2d, 0x37, 0x51, -0x63, 0x55, 0xe7, 0x7f, 0x75, 0x41, 0x9f, -0x7a, 0x79, 0xb7, 0x05, 0xfa, 0xf4, 0x11, -0x05, 0xf2, 0x8b, 0x5e, 0xc0, 0x34, 0x26, -0x25, 0xa0, 0x00, 0xe5, 0xf5, 0x7a, 0x82, -0xec, 0x11, 0xdf, 0xd4, 0x68, 0x87, 0x69, -0x81, 0x40, 0xff, 0x1a, 0x3d, 0xc7, 0x37, -0xe1, 0x94, 0x42, 0xa5, 0xdf, 0xc0, 0xeb, -0x38, 0x82, 0x2d, 0x33, 0xf7, 0x9d, 0x6c, -0x7c, 0xee, 0xa4, 0x3e, 0x37, 0x73, 0xfc, -0x3b, 0x2c, 0xd9, 0x0c, 0x5b, 0x7a, 0x18, -0x9c, 0xe3, 0x53, 0xc5, 0xbb, 0x02, 0xc2, -0x4a, 0x03, 0xb3, 0xeb, 0xe9, 0x74, 0xc3, -0xf6, 0xeb, 0xab, 0xe9, 0x24, 0xbf, 0x7a, -0x0f, 0xfd, 0x35, 0xe1, 0x7f, 0xb2, 0x38, -0x60, 0xb9, 0x4d, 0x24, 0x15, 0x5d, 0x74, -0x27, 0x16, 0xe9, 0x57, 0x63, 0x2d, 0x62, -0x82, 0x7e, 0x41, 0xc4, 0xe9, 0xc7, 0x64, -0x91, 0x6e, 0x41, 0xbe, 0x01, 0x19, 0xce, -0x0f, 0x14, 0x42, 0xd5, 0x7f, 0xbb, 0x8b, -0x28, 0x7f, 0x79, 0xa8, 0xf7, 0xdc, 0x70, -0xe2, 0x09, 0xc9, 0x93, 0x23, 0xae, 0x13, -0x96, 0x7d, 0xb2, 0x75, 0x18, 0xbd, 0xee, -0x88, 0x76, 0xb1, 0x97, 0xb5, 0xf7, 0x7b, -0x85, 0x32, 0x43, 0xb8, 0xec, 0xf7, 0x2b, -0x77, 0x99, 0x59, 0xbd, 0xc5, 0x15, 0x3c, -0x3f, 0x6f, 0xa2, 0x16, 0x1e, 0x47, 0x1c, -0x9c, 0x80, 0x3a, 0x7e, 0xcd, 0xb8, 0xad, -0x53, 0xf5, 0x04, 0xcc, 0x7e, 0x8b, 0x4e, -0x6c, 0x65, 0x52, 0x1c, 0x8a, 0x7a, 0xa6, -0x30, 0x6a, 0x6f, 0xc2, 0xf5, 0x26, 0xf8, -0xc9, 0xa6, 0xb1, 0x47, 0x18, 0x16, 0x3d, -0x38, 0x47, 0x95, 0xa5, 0x16, 0xb2, 0x95, -0x77, 0xad, 0x2b, 0xdf, 0xf8, 0x27, 0xc8, -0x7c, 0xf7, 0xa0, 0x12, 0x13, 0xa1, 0xcb, -0xd0, 0xd3, 0x01, 0x7f, 0x51, 0x89, 0x88, -0x55, 0x73, 0x66, 0x18, 0x4b, 0xa5, 0xfa, -0xd9, 0xde, 0xb5, 0xde, 0x2d, 0x4f, 0xe5, -0x99, 0xda, 0x1c, 0x0d, 0xaf, 0x8d, 0xaf, -0xaa, 0x33, 0x37, 0x97, 0xd9, 0xca, 0x53, -0x1a, 0x9f, 0x8c, 0xd0, 0x56, 0xb9, 0x5b, -0xb2, 0x99, 0xad, 0x8e, 0x85, 0x00, 0x97, -0xf1, 0x23, 0xb0, 0x2c, 0xd7, 0x6c, 0x22, -0xb8, 0x55, 0xcf, 0xb9, 0x96, 0x49, 0xbb, -0xe2, 0x02, 0x58, 0x07, 0xd1, 0xb0, 0x05, -0xc5, 0xe5, 0x9a, 0xd9, 0xce, 0x3e, 0xa9, -0xd0, 0x27, 0x32, 0x8a, 0x59, 0xd4, 0xde, -0xde, 0x7a, 0x9a, 0x7e, 0x34, 0x08, 0xfc, -0xbc, 0xbe, 0x32, 0x96, 0xd0, 0x4d, 0x70, -0x16, 0xac, 0x9f, 0xa9, 0xca, 0x0d, 0xe8, -0x50, 0xcd, 0x0c, 0x41, 0xfe, 0x43, 0xe0, -0x97, 0x75, 0xb9, 0x11, 0xc3, 0x48, 0xe7, -0xfa, 0x5b, 0xf3, 0x92, 0x7f, 0x3a, 0x50, -0xe4, 0xd7, 0x49, 0xe0, 0x22, 0x79, 0x2a, -0x19, 0x7e, 0x21, 0x08, 0xf9, 0x5b, 0x87, -0x13, 0x8d, 0xf1, 0x02, 0x10, 0x14, 0xe9, -0x11, 0xfa, 0xb2, 0xd5, 0x08, 0xdb, 0xbc, -0x95, 0x79, 0x8d, 0xce, 0x53, 0x41, 0xd7, -0xf9, 0x72, 0x6d, 0xe3, 0x95, 0x0e, 0x51, -0x18, 0x30, 0x2a, 0xe5, 0x3c, 0x57, 0xb1, -0x3a, 0x5a, 0xbb, 0x3c, 0x8e, 0x90, 0x20, -0x1e, 0x70, 0x2c, 0x97, 0x17, 0x5b, 0x02, -0x0b, 0x4f, 0x78, 0x9c, 0x91, 0x9a, 0x77, -0x87, 0xbc, 0x40, 0x9d, 0x15, 0xbe, 0xf4, -0x19, 0x1f, 0xb3, 0x60, 0x6b, 0x31, 0x2c, -0xd2, 0xdf, 0xf5, 0xae, 0xaa, 0x2d, 0xb1, -0x52, 0xb5, 0x2b, 0x0d, 0x44, 0x79, 0x30, -0x3e, 0x60, 0x5b, 0x35, 0xd5, 0x21, 0xaf, -0xec, 0xed, 0xbb, 0x94, 0xf9, 0xf4, 0x76, -0x05, 0x16, 0x50, 0x1e, 0x57, 0x7f, 0xfc, -0x76, 0xf1, 0x30, 0x95, 0xae, 0xa2, 0xad, -0xce, 0x24, 0x4a, 0x08, 0xc6, 0xf8, 0xd8, -0x8d, 0x88, 0xb7, 0x5d, 0x59, 0x27, 0x93, -0xe1, 0x74, 0xbe, 0xa2, 0x48, 0x15, 0x1f, -0x44, 0x88, 0x4f, 0x72, 0xd8, 0x51, 0x3b, -0xdf, 0x74, 0x4c, 0xd7, 0x60, 0x6c, 0x99, -0x79, 0xf3, 0xdc, 0xd5, 0xbc, 0xf8, 0x57, -0x13, 0x4d, 0x2b, 0x91, 0xbe, 0x94, 0xa8, -0x31, 0x74, 0x49, 0x7e, 0x40, 0xca, 0x8b, -0xe9, 0xf5, 0x83, 0x90, 0x86, 0x8f, 0xa3, -0x46, 0xcf, 0x4a, 0xbc, 0xf5, 0xc9, 0x03, -0xb4, 0x25, 0xaa, 0xe6, 0xd5, 0xeb, 0xcc, -0x20, 0x0d, 0x58, 0x05, 0x2c, 0x6d, 0xd5, -0xbe, 0x38, 0xd5, 0x97, 0x40, 0x1b, 0x9e, -0xfc, 0x5f, 0x56, 0xe5, 0x3c, 0xb3, 0x99, -0x7a, 0x44, 0x62, 0x2f, 0xef, 0x5a, 0x1b, -0x36, 0x3e, 0x84, 0xf1, 0xde, 0x24, 0xf6, -0x48, 0x24, 0xc0, 0x20, 0xf3, 0xb3, 0x8c, -0x77, 0xd0, 0xb4, 0xa3, 0xba, 0xad, 0x1d, -0xf9, 0x27, 0xc4, 0x79, 0x4c, 0x2a, 0x8a, -0x05, 0xfc, 0x84, 0x9c, 0x11, 0x71, 0xce, -0x12, 0x00, 0xdf, 0x5c, 0xaa, 0xc2, 0x4e, -0xdf, 0x7b, 0xdb, 0x2f, 0x22, 0x19, 0x9e, -0xb2, 0xf6, 0x34, 0x35, 0xc5, 0x22, 0xcf, -0x07, 0x4b, 0x99, 0xc6, 0x39, 0x3b, 0x9d, -0x5e, 0xd0, 0x4f, 0x06, 0x41, 0xb4, 0x2e, -0xd1, 0x8d, 0x22, 0x41, 0x45, 0x58, 0x46, -0x29, 0xe0, 0x26, 0x38, 0x45, 0x00, 0xdb, -0x6c, 0xfc, 0xc4, 0x9f, 0xe5, 0xb3, 0x3b, -0xba, 0x57, 0x82, 0x51, 0x2d, 0xef, 0x3e, -0xc1, 0x65, 0x89, 0x3d, 0x85, 0x62, 0xe9, -0x58, 0x1c, 0x27, 0x77, 0xa0, 0xcb, 0x2d, -0x33, 0x88, 0x2c, 0xb7, 0x32, 0xa5, 0x55, -0xdb, 0xe5, 0x33, 0x88, 0x5f, 0x72, 0xb1, -0x91, 0x9b, 0xe0, 0xab, 0x41, 0x59, 0x85, -0x8e, 0xd1, 0x4f, 0xb9, 0x64, 0x43, 0x82, -0x31, 0x1e, 0x39, 0x43, 0x9c, 0x78, 0xfd, -0x1c, 0x77, 0xa5, 0x87, 0x09, 0x9e, 0x13, -0x22, 0x45, 0x0c, 0x9a, 0xf7, 0xa9, 0x57, -0x19, 0x7a, 0x40, 0xfa, 0x81, 0x66, 0xd6, -0x89, 0x41, 0x92, 0xb4, 0x97, 0x13, 0xf9, -0xf4, 0x84, 0xde, 0xe3, 0x37, 0x6e, 0xce, -0x49, 0xd8, 0xa7, 0x1a, 0x27, 0xad, 0xb5, -0xe1, 0x06, 0x8e, 0x3d, 0xf5, 0xa0, 0x79, -0xd8, 0x91, 0xca, 0x15, 0x0b, 0xca, 0x80, -0x82, 0xbc, 0xf8, 0x68, 0x9b, 0xa5, 0x3f, -0x68, 0x1c, 0x9f, 0x68, 0xd1, 0x25, 0xc3, -0x2c, 0xb3, 0xe9, 0x45, 0x2d, 0x01, 0x81, -0x75, 0x2f, 0xf2, 0x50, 0x7b, 0xca, 0x7c, -0xe2, 0x1e, 0x17, 0x47, 0x34, 0x25, 0x8e, -0x5a, 0x04, 0xe4, 0x6c, 0xd2, 0xad, 0x7f, -0xaa, 0xaa, 0xc8, 0x1d, 0x2a, 0xaa, 0x62, -0x16, 0x31, 0x4b, 0x88, 0x1d, 0x2d, 0xd5, -0x31, 0x96, 0x15, 0xa7, 0xb0, 0xa6, 0x0c, -0xc4, 0xef, 0xcb, 0xb9, 0x86, 0x8a, 0xfe, -0xb9, 0x99, 0xc8, 0x73, 0xd5, 0x3a, 0xa0, -0x24, 0x06, 0x1b, 0x89, 0x45, 0xc0, 0x38, -0x33, 0xcc, 0xae, 0xab, 0x10, 0x31, 0xed, -0x68, 0x0d, 0x9b, 0x3c, 0xa7, 0xde, 0xac, -0x3f, 0x97, 0x0c, 0x3e, 0xca, 0x02, 0xaa, -0xe2, 0x87, 0x7c, 0x61, 0xfe, 0x7e, 0x82, -0x32, 0x20, 0xcf, 0x84, 0x12, 0x78, 0x37, -0x1e, 0x4c, 0xb0, 0xe6, 0x4e, 0x54, 0x84, -0x5e, 0xa0, 0x93, 0x6b, 0xa3, 0x59, 0x71, -0xcf, 0x40, 0x7a, 0xda, 0x28, 0x19, 0xf1, -0x6a, 0x6f, 0xb7, 0x1e, 0xe0, 0xcd, 0xbc, -0x99, 0xb7, 0x6e, 0x2d, 0x2b, 0xdd, 0xf7, -0xea, 0x81, 0x65, 0x39, 0xd2, 0x90, 0xd3, -0xbc, 0x64, 0xb5, 0x2c, 0xeb, 0xb4, 0xaf, -0x4e, 0x9c, 0x50, 0x67, 0x60, 0xc3, 0xd2, -0x56, 0xb3, 0x34, 0x94, 0xbb, 0x4d, 0xeb, -0x4c, 0x8f, 0x7f, 0x31, 0x8a, 0xe1, 0xd8, -0xf9, 0x18, 0x62, 0x4d, 0xa4, 0xb6, 0x4a, -0x80, 0xa8, 0x09, 0x85, 0x2c, 0x1a, 0x14, -0x3c, 0xa9, 0xab, 0x28, 0xef, 0x35, 0x37, -0x7c, 0xdc, 0x69, 0x0e, 0x8f, 0x82, 0xa0, -0xfb, 0xb4, 0x86, 0xcc, 0xd9, 0x07, 0x1a, -0x2d, 0x53, 0xa9, 0x5b, 0x46, 0xf7, 0xf2, -0xcb, 0x7a, 0x85, 0x62, 0x89, 0xc8, 0x53, -0x08, 0x24, 0xfc, 0x11, 0x10, 0xfb, 0x4f, -0x31, 0xa3, 0xcd, 0xd5, 0x75, 0x91, 0xbd, -0x18, 0xb3, 0xaa, 0x40, 0xed, 0xda, 0xe9, -0x83, 0xcc, 0x46, 0xb4, 0x1f, 0xb8, 0xd8, -0x11, 0xbf, 0xa6, 0x83, 0x58, 0x93, 0xfc, -0xe2, 0xc7, 0x0d, 0xa0, 0x13, 0xd0, 0x6d, -0xe2, 0xb7, 0x50, 0xc9, 0xcb, 0x41, 0x8b, -0xfd, 0xa6, 0xf7, 0x25, 0xe1, 0xb6, 0x40, -0x69, 0xbc, 0xd5, 0x80, 0x3d, 0xbb, 0x7b, -0x30, 0xf7, 0x84, 0x2f, 0x04, 0xb8, 0x22, -0xc8, 0x33, 0xc4, 0x26, 0x30, 0xd1, 0x50, -0x53, 0x13, 0xd1, 0x45, 0xfc, 0x0c, 0x33, -0xb9, 0xa8, 0xc2, 0x41, 0x29, 0x0c, 0x4e, -0x98, 0xb9, 0x43, 0xc2, 0x7b, 0x24, 0x68, -0x77, 0xcc, 0xad, 0x7e, 0x62, 0x51, 0x7d, -0x1d, 0x34, 0xaf, 0x08, 0xa8, 0x15, 0x24, -0x2d, 0xbe, 0x9c, 0x9f, 0xb3, 0xb8, 0x6b, -0x29, 0x68, 0x4e, 0x07, 0x6f, 0xfb, 0xe1, -0xc8, 0x27, 0x5b, 0x3c, 0xef, 0x8f, 0x85, -0x79, 0x75, 0x42, 0xfb, 0xab, 0x59, 0x9c, -0x8c, 0x18, 0x10, 0x0f, 0xc4, 0x74, 0x24, -0xfe, 0x82, 0x7f, 0xb6, 0x6c, 0xfd, 0xc0, -0xc5, 0xd6, 0xa6, 0x23, 0x7c, 0x26, 0xf1, -0x28, 0x09, 0x32, 0xa3, 0x59, 0x5f, 0x98, -0x52, 0x70, 0x40, 0x1e, 0x75, 0xfc, 0x3f, -0xad, 0xa2, 0xa6, 0xc2, 0xea, 0xf9, 0x1d, -0xbc, 0xd9, 0x6a, 0xa3, 0x48, 0x18, 0x15, -0x01, 0x99, 0x5c, 0xe1, 0x23, 0x76, 0xeb, -0x35, 0x1a, 0xfb, 0xdb, 0xcc, 0xc8, 0x49, -0xf0, 0x4a, 0xfd, 0xf6, 0x5d, 0x20, 0x42, -0x78, 0xf5, 0xf5, 0x44, 0x0b, 0x11, 0x77, -0xc4, 0xd4, 0x0f, 0x60, 0xb3, 0xc9, 0xe1, -0x04, 0xa0, 0xe6, 0xc1, 0x2e, 0xb6, 0x1d, -0x9d, 0x1d, 0xeb, 0x1c, 0xa2, 0x85, 0x0c, -0x1b, 0x8d, 0xb0, 0xa8, 0xea, 0x4c, 0x12, -0x2d, 0xf6, 0x85, 0xf0, 0xe9, 0x3f, 0x17, -0x2f, 0x3d, 0xe4, 0x03, 0x29, 0x5a, 0xe7, -0x95, 0x1e, 0x6c, 0xea, 0x8e, 0x92, 0x15, -0x98, 0x83, 0xcb, 0xec, 0x4a, 0x84, 0x39, -0x7a, 0xc0, 0xc7, 0xd8, 0x97, 0x79, 0xcc, -0x6a, 0x9a, 0x4a, 0x3e, 0xfb, 0x4f, 0xd1, -0x64, 0xd9, 0xf7, 0xb2, 0xc4, 0xcc, 0xd3, -0x9c, 0x22, 0x55, 0xc3, 0xbc, 0xf8, 0xf8, -0x2e, 0x35, 0x37, 0x05, 0x47, 0x43, 0x26, -0x43, 0xb3, 0x96, 0x1c, 0xd4, 0x1a, 0xc7, -0x2b, 0xdd, 0x5a, 0x9c, 0xb4, 0x58, 0x3a, -0x9f, 0x24, 0x9d, 0x82, 0x31, 0x21, 0x44, -0x81, 0x44, 0x67, 0x78, 0xcb, 0x57, 0x20, -0xd3, 0xdc, 0x54, 0x4b, 0x2b, 0xd6, 0xa7, -0xff, 0x83, 0x8e, 0x6b, 0xa9, 0xac, 0xb1, -0x25, 0xf7, 0x33, 0xad, 0xbe, 0xc6, 0x83, -0xd1, 0x9c, 0x72, 0x12, 0x61, 0xc9, 0xf2, -0xc2, 0x4a, 0xe0, 0x7f, 0x5d, 0xab, 0xb8, -0x6f, 0x94, 0xad, 0x78, 0x8c, 0x98, 0x58, -0xa0, 0x31, 0xf8, 0x73, 0xec, 0x61, 0x54, -0xd1, 0x3f, 0x46, 0xd1, 0xa2, 0xe9, 0x9a, -0x99, 0x8f, 0x32, 0xa2, 0x23, 0x9f, 0xf3, -0xc0, 0xa2, 0xfd, 0x23, 0x5c, 0x93, 0x82, -0xfa, 0xfe, 0xce, 0x28, 0xdf, 0xa2, 0x32, -0xf6, 0x2c, 0x67, 0xeb, 0x0f, 0x7c, 0x43, -0xab, 0xd9, 0xbd, 0x1c, 0x38, 0xf4, 0x80, -0x12, 0xb8, 0x14, 0x05, 0x8e, 0xab, 0x62, -0x47, 0x6a, 0xa8, 0xa4, 0x89, 0xfd, 0xf5, -0x85, 0x8a, 0xea, 0x2c, 0x58, 0x3e, 0x95, -0xe5, 0x6a, 0x6f, 0xd3, 0x63, 0x47, 0x3c, -0xfb, 0xdb, 0x6c, 0x94, 0xb0, 0xcf, 0x97, -0xdd, 0xfc, 0xde, 0xa9, 0x5e, 0x67, 0x49, -0x37, 0x55, 0xe5, 0xd4, 0x25, 0xbc, 0x95, -0x58, 0x9d, 0xf7, 0x08, 0x05, 0x34, 0x32, -0xbf, 0x4f, 0xf1, 0xf5, 0x3a, 0x59, 0x1c, -0x55, 0x6b, 0xbd, 0x14, 0x83, 0x29, 0xbe, -0x4f, 0xab, 0xe2, 0xc0, 0xc7, 0x52, 0xf6, -0x6e, 0x73, 0x60, 0x35, 0x35, 0x27, 0x73, -0x9f, 0xcc, 0x07, 0xee, 0xbd, 0x2c, 0xbb, -0x47, 0x46, 0x1f, 0xdf, 0x05, 0xd8, 0xcf, -0x5e, 0xc9, 0x5a, 0xa7, 0x46, 0xdb, 0xcd, -0x98, 0xb4, 0xf1, 0x2a, 0x90, 0xbf, 0xad, -0x39, 0x73, 0x9e, 0x78, 0xf7, 0x40, 0xda, -0x1b, 0xc9, 0xe0, 0x1f, 0x24, 0xd4, 0x4f, -0xee, 0x3c, 0x97, 0x15, 0xa9, 0x05, 0xd0, -0xa1, 0x8b, 0x81, 0x57, 0xb1, 0xe8, 0x55, -0x25, 0xa2, 0x2b, 0x2c, 0x10, 0xf2, 0x3e, -0x0e, 0xb2, 0xea, 0x7c, 0x63, 0x9b, 0x01, -0x54, 0x26, 0x20, 0xd3, 0xc5, 0x2b, 0x76, -0xe6, 0xc9, 0x34, 0x84, 0xf0, 0xf5, 0xb5, -0x50, 0xb9, 0xd9, 0x9a, 0xba, 0x2a, 0x7a, -0xd6, 0xea, 0xec, 0x1a, 0xee, 0xbe, 0x5a, -0x6b, 0x9e, 0xa7, 0x7a, 0x34, 0xe6, 0xf7, -0xb7, 0x97, 0x57, 0xba, 0x6f, 0x56, 0xe8, -0xc7, 0xc0, 0xa1, 0xfe, 0x5d, 0xf0, 0x0f, -0x06, 0xf5, 0xbc, 0x4d, 0x68, 0x75, 0x39, -0x3d, 0x93, 0x4e, 0x1f, 0xb7, 0xcd, 0xc6, -0x3f, 0x5a, 0xf2, 0x71, 0x79, 0xbe, 0x8a, -0x44, 0xe4, 0x8f, 0xad, 0x1b, 0xaf, 0x6d, -0x2e, 0x27, 0xd2, 0xd3, 0x0e, 0xfb, 0x1c, -0x62, 0x75, 0x7d, 0xaf, 0x0d, 0xf0, 0x45, -0x77, 0xf0, 0xfc, 0xbd, 0x4b, 0xae, 0xe9, -0x0e, 0xb4, 0xed, 0x4a, 0xf9, 0x6c, 0x34, -0xbf, 0x94, 0x94, 0x0c, 0xf9, 0xd1, 0x66, -0x37, 0x90, 0xba, 0x1e, 0x62, 0x61, 0xbf, -0xc8, 0xed, 0x9f, 0xf0, 0x9d, 0xf5, 0xa2, -0x5f, 0x22, 0x5b, 0xcf, 0x22, 0xb0, 0x91, -0xe8, 0x17, 0x56, 0x0d, 0xf4, 0x60, 0x5e, -0x77, 0x97, 0x42, 0xb6, 0x33, 0xdb, 0xcd, -0x5f, 0x04, 0xa2, 0x7c, 0x1e, 0xb2, 0xd7, -0xc9, 0xf5, 0x4d, 0xdf, 0x76, 0xe7, 0xb1, -0x83, 0xa5, 0x72, 0x13, 0xf1, 0x27, 0x65, -0x49, 0x7f, 0x05, 0x6e, 0x35, 0xab, 0x73, -0xcb, 0x09, 0x49, 0x14, 0x1f, 0xf1, 0xa6, -0x85, 0x8b, 0x61, 0x3a, 0xb7, 0xe0, 0x1d, -0x87, 0xeb, 0x34, 0x44, 0xd8, 0xd4, 0x12, -0x7b, 0x82, 0xa1, 0xb6, 0x77, 0x53, 0xd7, -0x36, 0x39, 0x64, 0x49, 0xbd, 0xd1, 0xb4, -0x3d, 0xea, 0x4d, 0x0b, 0x50, 0x5d, 0x0a, -0x5d, 0x64, 0xa2, 0xac, 0x7d, 0x6c, 0x6a, -0x2c, 0x01, 0x75, 0x1b, 0xbd, 0x19, 0xf6, -0x4a, 0xe6, 0x83, 0x0b, 0x23, 0x5f, 0xe2, -0xe8, 0x15, 0x70, 0x2c, 0x63, 0x68, 0xde, -0x1c, 0xf8, 0xd4, 0x41, 0xab, 0x0e, 0xf0, -0x39, 0xbe, 0x3c, 0x46, 0xfd, 0x2b, 0xcb, -0x21, 0x88, 0x4c, 0xdf, 0xf8, 0x91, 0x3b, -0x83, 0xa1, 0x3e, 0xaa, 0xc6, 0xc0, 0xd9, -0x1d, 0xac, 0x0c, 0x79, 0xec, 0x23, 0xed, -0xde, 0x4a, 0xcc, 0x33, 0xdb, 0x5a, 0x81, -0x3b, 0xee, 0xa6, 0x22, 0x4d, 0x87, 0x43, -0x29, 0x1a, 0x3f, 0xdd, 0xe3, 0xc5, 0x1a, -0x3b, 0x8f, 0x22, 0x42, 0xa9, 0x43, 0xdf, -0x07, 0x2e, 0x0c, 0xc0, 0x6f, 0x69, 0x9d, -0x1f, 0x03, 0x4a, 0xc2, 0x8f, 0x2e, 0x07, -0x09, 0x20, 0xa8, 0xbb, 0xb4, 0x63, 0xd1, -0x12, 0x09, 0xf6, 0xd6, 0x01, 0xa4, 0x25, -0x74, 0xa8, 0xb9, 0x56, 0x82, 0xdb, 0x78, -0xe8, 0x41, 0xbb, 0xc6, 0x18, 0xc5, 0x86, -0xa3, 0xea, 0xbf, 0x90, 0x2c, 0xdd, 0x15, -0xe0, 0x4a, 0x21, 0xd4, 0x42, 0x94, 0x94, -0xf4, 0x48, 0x62, 0x97, 0x25, 0xc7, 0xcd, -0x44, 0x88, 0x20, 0xd6, 0x05, 0x4b, 0x96, -0x89, 0xd0, 0x3e, 0x0d, 0x9f, 0xa3, 0x24, -0xf8, 0xf8, 0xed, 0x7e, 0xe1, 0x64, 0xa9, -0x03, 0x04, 0x07, 0x19, 0x5f, 0x1c, 0x08, -0x59, 0xef, 0x5e, 0xa6, 0xe0, 0xe4, 0x79, -0xd7, 0xd9, 0x15, 0x83, 0xc8, 0x67, 0xf4, -0xaa, 0x89, 0xaf, 0xa1, 0x85, 0x09, 0x6d, -0xc5, 0x4c, 0x09, 0xd2, 0xf9, 0x91, 0x37, -0x73, 0xa1, 0x87, 0x5e, 0x2e, 0x00, 0x81, -0x1b, 0xea, 0xf2, 0x01, 0xf0, 0x30, 0x36, -0xdd, 0x69, 0x9d, 0xf5, 0x30, 0x3d, 0x25, -0x9f, 0xef, 0xd9, 0xf3, 0x18, 0x23, 0x1a, -0x49, 0x72, 0x66, 0x7f, 0xda, 0x95, 0xea, -0x50, 0x7c, 0xe8, 0x98, 0x1a, 0x11, 0xdc, -0xec, 0xb8, 0x0b, 0x10, 0x65, 0x9c, 0xfe, -0xdd, 0xf1, 0x09, 0x13, 0xfb, 0xc4, 0xea, -0x49, 0x12, 0x30, 0x07, 0x6a, 0x0c, 0x52, -0x2f, 0x63, 0xf8, 0x53, 0xe5, 0x9e, 0x66, -0xaf, 0x6d, 0xe3, 0xc3, 0xbd, 0x1f, 0xf7, -0x9b, 0x1f, 0x52, 0xb8, 0x9b, 0x8e, 0x63, -0x4c, 0x95, 0xb4, 0x92, 0x7c, 0x7f, 0x23, -0x76, 0x07, 0x3a, 0x48, 0xdc, 0x88, 0x4b, -0x43, 0xf2, 0xea, 0x57, 0x07, 0xf6, 0xcc, -0x8a, 0x9c, 0x0e, 0x7f, 0x9e, 0x75, 0x98, -0xf5, 0x25, 0x9e, 0x19, 0x41, 0x4f, 0x5b, -0xb1, 0xee, 0x70, 0x69, 0xf4, 0x23, 0xb5, -0xba, 0x59, 0x5f, 0x7c, 0x1e, 0x76, 0x6b, -0xb4, 0xd6, 0x77, 0x51, 0xf8, 0xd7, 0xdf, -0x55, 0x5c, 0x85, 0x50, 0x5c, 0xd0, 0x12, -0xd0, 0x38, 0x4e, 0x7b, 0xee, 0xa8, 0x6c, -0xd8, 0x33, 0x04, 0xf1, 0x9d, 0x90, 0xd3, -0xf1, 0x78, 0x88, 0x79, 0xce, 0x72, 0xc1, -0x0c, 0xad, 0x9b, 0xae, 0x50, 0x1b, 0x9e, -0xfd, 0xb4, 0x44, 0x31, 0x85, 0x82, 0xe6, -0x9e, 0xe4, 0xe8, 0x5f, 0x14, 0xe2, 0x37, -0x87, 0x2f, 0x79, 0x8e, 0xb0, 0xd8, 0x6d, -0xae, 0x2d, 0xa5, 0xcc, 0x9c, 0xeb, 0xd0, -0x49, 0x8b, 0xa1, 0xa7, 0xc1, 0x5e, 0x2c, -0xfe, 0x61, 0x6b, 0x3b, 0x39, 0xd3, 0x20, -0x6a, 0x77, 0x4c, 0xa0, 0x13, 0xa7, 0x68, -0xc8, 0x34, 0x95, 0x71, 0x26, 0x31, 0x02, -0x7e, 0x26, 0x87, 0x5a, 0x2c, 0x8b, 0xd3, -0x3b, 0x30, 0x94, 0xa6, 0x04, 0x03, 0xcd, -0xbf, 0x4b, 0x53, 0x46, 0xe5, 0x37, 0xf1, -0xa7, 0x16, 0xad, 0x23, 0x3a, 0x7f, 0x5d, -0x43, 0x22, 0x5c, 0xdb, 0xfd, 0x6c, 0xd1, -0x41, 0x69, 0xc1, 0x2a, 0x63, 0x6c, 0x02, -0xe9, 0x9c, 0xa1, 0x26, 0xa6, 0x4a, 0xa5, -0xaa, 0x18, 0xa9, 0xb7, 0x71, 0x6f, 0x4b, -0x52, 0x06, 0xc7, 0x52, 0xfd, 0x33, 0xe3, -0x1d, 0x48, 0x16, 0x3b, 0x76, 0x96, 0x83, -0xd8, 0xc1, 0xb6, 0x8e, 0xdb, 0xf9, 0x19, -0xb0, 0xc3, 0xae, 0xf8, 0x73, 0xa3, 0x90, -0x56, 0xba, 0x83, 0x60, 0xaa, 0x56, 0x5b, -0xbd, 0xa7, 0x2d, 0x38, 0xc0, 0xc4, 0xac, -0xe9, 0x13, 0xdf, 0x29, 0xd8, 0xf7, 0x9e, -0xc4, 0xf0, 0x9b, 0x7b, 0x15, 0xbf, 0xd7, -0x50, 0x8f, 0xf6, 0x61, 0xd9, 0x30, 0x59, -0xb6, 0x05, 0xd5, 0xfe, 0x9e, 0xf5, 0x5c, -0x5b, 0x54, 0x3a, 0x18, 0x7a, 0xd2, 0x68, -0x47, 0x42, 0x82, 0x39, 0xf0, 0xdd, 0x9a, -0x1b, 0x90, 0x1c, 0x52, 0xe7, 0xed, 0xac, -0xb3, 0x52, 0xbd, 0x6b, 0x19, 0x90, 0x8f, -0xc4, 0xe4, 0x80, 0x2a, 0x86, 0xb4, 0x9c, -0x8c, 0x83, 0x45, 0x6b, 0x3b, 0x03, 0x99, -0xa7, 0xe8, 0x7b, 0x34, 0xda, 0x8a, 0x0c, -0xc7, 0x1d, 0xcd, 0x31, 0x41, 0xe6, 0x44, -0xd9, 0xcf, 0xea, 0x58, 0x2f, 0x0f, 0x56, -0x6e, 0xe1, 0xc1, 0x8b, 0x53, 0xa6, 0xdb, -0xf2, 0xad, 0x68, 0x13, 0x54, 0x43, 0xb5, -0x2d, 0xb8, 0x0d, 0x77, 0xbd, 0x48, 0xae, -0xbc, 0x80, 0x27, 0x61, 0xdc, 0x20, 0xca, -0x8c, 0x41, 0xb0, 0x51, 0xd6, 0xfb, 0xd2, -0x93, 0x39, 0xb7, 0x59, 0x41, 0x91, 0xd5, -0x5d, 0xdc, 0xbd, 0xd7, 0x3a, 0xad, 0xaa, -0x41, 0xe2, 0xcb, 0x6b, 0xbe, 0xd1, 0x97, -0x50, 0x6b, 0x38, 0xaa, 0x64, 0x38, 0x3f, -0x08, 0xe2, 0xf8, 0xa8, 0x64, 0x3c, 0xc4, -0x33, 0xdc, 0x19, 0x00, 0xbb, 0x19, 0x63, -0xc0, 0xd1, 0x74, 0x9c, 0x2a, 0x4e, 0x82, -0x17, 0x12, 0xda, 0x0e, 0x7f, 0x30, 0x86, -0x3d, 0x49, 0x6a, 0xce, 0xbd, 0xbc, 0x2f, -0xc8, 0xc5, 0x3d, 0xaa, 0xf0, 0x31, 0xa4, -0xe8, 0x50, 0x7e, 0xb6, 0xf0, 0xfd, 0xe9, -0x8c, 0x00, 0x7f, 0xfa, 0x56, 0xba, 0x29, -0x82, 0xc1, 0x2a, 0xfa, 0x70, 0x2b, 0x8f, -0x42, 0xc2, 0x54, 0x61, 0xd2, 0xec, 0xe4, -0x9c, 0x8a, 0xe3, 0x28, 0xa1, 0x88, 0x3d, -0x96, 0xfd, 0x36, 0x64, 0x5e, 0x63, 0xa9, -0xc8, 0x6c, 0x65, 0x69, 0x46, 0x74, 0x23, -0x7a, 0x30, 0x08, 0xe3, 0x37, 0x01, 0xe8, -0xe5, 0x2d, 0xed, 0xd9, 0xb9, 0x14, 0x53, -0x76, 0x87, 0x0e, 0x9f, 0xf3, 0x36, 0xc4, -0xec, 0xef, 0x3b, 0xee, 0xd2, 0x04, 0x8f, -0xb1, 0xca, 0x5f, 0xbd, 0xbf, 0xd2, 0xa4, -0xbb, 0x63, 0x2f, 0x00, 0x59, 0xb6, 0x78, -0x03, 0x56, 0x74, 0x42, 0x14, 0x27, 0x21, -0x09, 0x05, 0xa5, 0xfd, 0x61, 0x03, 0x39, -0xff, 0x23, 0x51, 0xa4, 0x45, 0x40, 0x9c, -0x0e, 0x1e, 0xaa, 0x93, 0xdc, 0x28, 0xe0, -0xd4, 0xfc, 0x7d, 0x4d, 0x80, 0x6a, 0x1a, -0x0e, 0xfc, 0xe5, 0xdb, 0x3a, 0x05, 0x49, -0xed, 0x56, 0x9d, 0x4f, 0x17, 0x79, 0x9b, -0x6d, 0x0f, 0x1e, 0xd0, 0x10, 0x5a, 0xfa, -0xd7, 0x08, 0x25, 0x2f, 0x1d, 0xef, 0x5e, -0x9a, 0xc4, 0x44, 0xff, 0x41, 0x50, 0xfb, -0x5a, 0x5f, 0x14, 0x60, 0x49, 0xbc, 0x52, -0x68, 0xf2, 0xf0, 0x44, 0xc9, 0x20, 0x72, -0xc5, 0xbf, 0x91, 0xc6, 0x93, 0x7d, 0x9f, -0xde, 0x0f, 0x66, 0x90, 0xa6, 0x0b, 0x66, -0x74, 0xc8, 0x71, 0x54, 0xc3, 0x42, 0xd8, -0xa5, 0xe0, 0xba, 0xf1, 0x50, 0x1d, 0x39, -0x33, 0x0b, 0xa1, 0x9d, 0xfa, 0xf7, 0xe7, -0xa0, 0xf9, 0xf6, 0xe6, 0xb7, 0xe0, 0x20, -0xe6, 0x95, 0xcc, 0xe1, 0x84, 0x9c, 0xce, -0xab, 0x61, 0x14, 0xdc, 0xa6, 0x22, 0xda, -0xf7, 0x14, 0xc5, 0x58, 0x4b, 0xae, 0x1c, -0xd6, 0xcf, 0xce, 0x32, 0x4d, 0x20, 0x1d, -0x1c, 0xae, 0x26, 0xf5, 0xa8, 0x47, 0x18, -0x28, 0x05, 0x83, 0xcd, 0xd7, 0x11, 0xc5, -0x4c, 0xf4, 0x39, 0xe6, 0x1b, 0x54, 0xf9, -0x6c, 0x1a, 0x43, 0xc4, 0x02, 0xf4, 0xb7, -0x06, 0xaa, 0xca, 0xda, 0x13, 0x64, 0xee, -0xf4, 0xfc, 0xc7, 0x28, 0x13, 0x57, 0xeb, -0x9c, 0x2c, 0xa0, 0x2e, 0x1d, 0x3c, 0xd4, -0x8f, 0xcd, 0x15, 0x9d, 0x3d, 0x5a, 0x0b, -0xe8, 0xce, 0x70, 0x70, 0xe1, 0x8f, 0x46, -0x0b, 0xeb, 0x63, 0x7c, 0xd1, 0x2c, 0x7e, -0xe5, 0x6b, 0x4b, 0x1d, 0x4e, 0x22, 0xd1, -0x1a, 0x10, 0xc4, 0x00, 0x04, 0xf6, 0x37, -0x9f, 0x67, 0xe4, 0x37, 0xef, 0x3a, 0xa6, -0x28, 0x09, 0x9d, 0x2b, 0xd2, 0x6b, 0xf8, -0x95, 0xe1, 0xf7, 0x19, 0x22, 0x34, 0xd0, -0xca, 0x8a, 0x05, 0x2d, 0x1f, 0x4d, 0x8a, -0x02, 0x59, 0x8e, 0x06, 0x3b, 0x36, 0xd8, -0x7d, 0x70, 0x52, 0xcd, 0x55, 0xd3, 0x94, -0x5c, 0x7b, 0xb4, 0x84, 0x91, 0x29, 0x4b, -0xb2, 0x86, 0xba, 0xdd, 0xc7, 0xb5, 0x48, -0xd5, 0xde, 0x6f, 0x9c, 0x2c, 0xcf, 0xd8, -0xd8, 0xcc, 0x34, 0xcf, 0x54, 0x0a, 0xc4, -0xb5, 0xb0, 0x79, 0x87, 0x50, 0xdb, 0xdf, -0x39, 0xa7, 0x8a, 0x38, 0x9e, 0x97, 0xa9, -0xac, 0x5e, 0x42, 0xaa, 0xc0, 0xfb, 0xe4, -0xf5, 0x08, 0xfb, 0xd7, 0xa9, 0x80, 0x1e, -0x13, 0x22, 0xa3, 0x44, 0x46, 0x99, 0x96, -0xc9, 0x77, 0xa1, 0xc1, 0xdf, 0xdf, 0x93, -0x8f, 0xf2, 0xd0, 0xda, 0x1f, 0x0f, 0xfb, -0xb1, 0x8e, 0x06, 0x17, 0x4a, 0x10, 0xb2, -0x73, 0xa5, 0x2a, 0x26, 0x59, 0x81, 0x33, -0xba, 0xd7, 0x26, 0x5a, 0x60, 0x1f, 0x02, -0x42, 0xd9, 0xca, 0xde, 0x01, 0x85, 0xb3, -0xb6, 0x4d, 0x38, 0x00, 0x98, 0xbd, 0xab, -0xd1, 0xc3, 0x9c, 0x18, 0x67, 0x76, 0x73, -0xc6, 0x55, 0x3a, 0xbf, 0x5d, 0x3d, 0x65, -0x1e, 0x50, 0x74, 0x31, 0x4f, 0x2d, 0x2a, -0x81, 0x91, 0x98, 0x91, 0xfb, 0x67, 0x5d, -0xdb, 0x13, 0x5d, 0xaf, 0xdc, 0x90, 0x87, -0x9d, 0x55, 0xb4, 0xbc, 0xa9, 0x3a, 0x73, -0xca, 0x2e, 0x22, 0xad, 0x64, 0xb2, 0xdf, -0x61, 0xbe, 0x85, 0x3b, 0xee, 0x50, 0xda, -0x90, 0x80, 0xb4, 0xaf, 0x13, 0xcb, 0xb6, -0x5c, 0xd0, 0x68, 0xc2, 0x21, 0x8e, 0x26, -0x34, 0xd1, 0xd6, 0x1b, 0x67, 0x3b, 0xce, -0xc3, 0x22, 0x45, 0x00, 0x1c, 0x2e, 0xe5, -0xbc, 0x10, 0x6f, 0x8d, 0x45, 0x0f, 0x1e, -0x8e, 0x77, 0x3d, 0xee, 0x8f, 0x7d, 0x94, -0x34, 0x24, 0xf9, 0xca, 0x55, 0xaa, 0x99, -0x63, 0x24, 0x55, 0x22, 0x3c, 0x3a, 0xee, -0x42, 0x9f, 0x2e, 0xfd, 0xb2, 0xad, 0x10, -0xe7, 0x34, 0xec, 0x9f, 0x1b, 0x06, 0x88, -0x7a, 0xba, 0x5d, 0xf8, 0xb7, 0x62, 0x0e, -0x6a, 0x84, 0x23, 0x1c, 0xfa, 0x15, 0xba, -0xe1, 0xcf, 0xa1, 0xb8, 0x88, 0xe2, 0x16, -0x5c, 0xdf, 0x15, 0x18, 0x42, 0xd5, 0x9c, -0xc7, 0x08, 0xfe, 0x9d, 0x50, 0x56, 0x72, -0x53, 0x99, 0x19, 0xb5, 0x67, 0x40, 0x96, -0x5f, 0x0c, 0x94, 0xcf, 0xa8, 0xc9, 0xbe, -0xcf, 0xb1, 0x7d, 0xf4, 0x55, 0xa4, 0x5e, -0xc0, 0xae, 0x03, 0x91, 0x98, 0x6e, 0x29, -0x56, 0xbb, 0xa3, 0xb2, 0xea, 0x45, 0xfb, -0xcb, 0x45, 0x33, 0x84, 0x0c, 0x14, 0x2d, -0x9d, 0x09, 0x72, 0x4f, 0x01, 0x58, 0x86, -0x07, 0x83, 0x3e, 0xfc, 0xa5, 0x89, 0x4e, -0xa7, 0xe4, 0xfd, 0x5e, 0x61, 0x47, 0x98, -0xa8, 0xec, 0x05, 0xdc, 0xe4, 0x92, 0x85, -0x5f, 0xd5, 0xeb, 0x26, 0x4f, 0x19, 0xde, -0xa1, 0xf6, 0xcd, 0xd4, 0xfa, 0x5e, 0x45, -0x25, 0x13, 0x39, 0x93, 0x80, 0x59, 0x90, -0xbf, 0xee, 0x0e, 0x74, 0x41, 0xdd, 0x41, -0xe2, 0x85, 0x9d, 0x39, 0xa1, 0xa1, 0xdf, -0xa0, 0x89, 0x7e, 0x79, 0x7c, 0xb9, 0x78, -0x12, 0x6b, 0x3f, 0x11, 0x59, 0x47, 0x34, -0x5b, 0x14, 0xb9, 0x98, 0x4e, 0x73, 0x46, -0x5a, 0xdf, 0xeb, 0x2f, 0x24, 0x22, 0x6a, -0x1c, 0x26, 0xe5, 0x07, 0x51, 0xee, 0x43, -0x95, 0xdd, 0xb0, 0xb2, 0x7a, 0x10, 0x0a, -0xcd, 0xdb, 0x8f, 0x62, 0x0c, 0xca, 0xb9, -0xd5, 0x07, 0x87, 0xde, 0x94, 0xb0, 0xc8, -0xa8, 0xa4, 0x32, 0xb6, 0x48, 0xb7, 0xbe, -0xce, 0x02, 0x43, 0x7e, 0x1f, 0x67, 0xbe, -0x60, 0x26, 0xa3, 0xb8, 0xa8, 0xb0, 0x89, -0xca, 0xd3, 0x92, 0x1f, 0xbb, 0xf8, 0x6a, -0xcb, 0xb3, 0x65, 0x44, 0x9e, 0x8b, 0xaa, -0x94, 0x77, 0x68, 0x1b, 0x38, 0xa1, 0x41, -0x9f, 0x54, 0xae, 0xd4, 0x4e, 0x61, 0x71, -0x8e, 0x78, 0x59, 0x93, 0x9c, 0xc5, 0x00, -0xa6, 0xd1, 0x0c, 0x69, 0x09, 0xbe, 0x59, -0x7c, 0xd7, 0x82, 0x30, 0x8b, 0xa2, 0x4a, -0xba, 0x7f, 0xb7, 0xe5, 0x5e, 0x91, 0x72, -0x5f, 0xb9, 0x06, 0xfe, 0x72, 0x06, 0xd9, -0xd3, 0xa4, 0xd3, 0xfa, 0xa2, 0xdb, 0xdb, -0xfc, 0x5c, 0x41, 0xcf, 0x3f, 0x84, 0xc4, -0x18, 0x9d, 0xe6, 0x93, 0x00, 0xe9, 0x19, -0x4b, 0x99, 0x4a, 0xf6, 0x56, 0xd8, 0x89, -0xd9, 0xbe, 0x7b, 0x75, 0xfd, 0x9b, 0x76, -0xa0, 0xa7, 0x62, 0x27, 0xe1, 0xca, 0xd2, -0x77, 0x06, 0x94, 0xd5, 0xc9, 0x0f, 0x32, -0xaf, 0x46, 0x9e, 0xc9, 0xd1, 0x0d, 0xc2, -0xfa, 0x62, 0x34, 0x9d, 0xe9, 0x67, 0x17, -0xf3, 0x49, 0x8e, 0x10, 0x12, 0x69, 0x8b, -0xe3, 0x3b, 0xfc, 0x73, 0x16, 0xf9, 0x81, -0xea, 0xa1, 0x5a, 0x11, 0xa5, 0xfe, 0x7a, -0x1b, 0xf4, 0x6c, 0xc1, 0xc0, 0xf9, 0x56, -0x1b, 0xad, 0xe5, 0xc6, 0xf2, 0xfe, 0x44, -0x5d, 0x5d, 0x16, 0x15, 0x5e, 0xe3, 0xdf, -0x30, 0x21, 0x13, 0x7b, 0x3d, 0x84, 0x09, -0x8c, 0x1c, 0x59, 0xa5, 0x22, 0x56, 0x28, -0xa6, 0xac, 0x36, 0xf1, 0x9f, 0x76, 0x21, -0x42, 0xc6, 0xf7, 0xb3, 0x12, 0xd6, 0x63, -0x2c, 0x89, 0xf3, 0x96, 0xf8, 0x9f, 0x66, -0xf2, 0x5c, 0xc8, 0x08, 0x59, 0xdd, 0x5d, -0xe8, 0x1e, 0xee, 0x1b, 0xaa, 0xb5, 0x47, -0x14, 0x77, 0xf0, 0x1f, 0x48, 0x59, 0x8a, -0x59, 0x6b, 0x6e, 0x06, 0xfe, 0x10, 0x03, -0x74, 0xef, 0xa1, 0xef, 0xed, 0x46, 0x78, -0xac, 0x62, 0x9c, 0xf2, 0xd3, 0x77, 0x1d, -0x40, 0xad, 0xdb, 0xab, 0xc7, 0x22, 0xf4, -0xd1, 0x34, 0x71, 0xfc, 0x7e, 0xb1, 0xc5, -0x4d, 0x85, 0x65, 0xb5, 0x3a, 0xba, 0xe4, -0xe3, 0xa9, 0xe6, 0xd4, 0xd6, 0x68, 0xe5, -0x5f, 0x06, 0x1b, 0x36, 0xdf, 0x86, 0x97, -0xa0, 0x08, 0x4a, 0x40, 0x74, 0x75, 0x5c, -0x21, 0x14, 0xe3, 0x2b, 0xb7, 0x88, 0x73, -0x52, 0x10, 0x70, 0x94, 0x99, 0x85, 0x8f, -0x08, 0xba, 0xac, 0xba, 0x73, 0x2e, 0x94, -0x9b, 0xc4, 0xcf, 0xa6, 0x09, 0x9d, 0x46, -0xcb, 0x71, 0x75, 0x42, 0x85, 0xba, 0xdf, -0x94, 0xb4, 0x3c, 0xff, 0xcb, 0x57, 0x27, -0xd2, 0x7c, 0xec, 0xd5, 0x24, 0x8c, 0xa6, -0x5a, 0x04, 0x5d, 0x98, 0x65, 0x57, 0x1c, -0xcb, 0x11, 0x1e, 0xfa, 0xe4, 0xfc, 0x53, -0xb3, 0x4b, 0x62, 0x10, 0xb7, 0x64, 0xf0, -0x54, 0x1a, 0x39, 0xf7, 0xcc, 0x15, 0x03, -0x8d, 0xf6, 0xaf, 0x34, 0x05, 0x50, 0xce, -0xc0, 0xc1, 0xd1, 0x14, 0x5d, 0x80, 0x37, -0xd4, 0x51, 0x54, 0x3d, 0xdc, 0xa9, 0x8c, -0x5e, 0xe2, 0xc2, 0x01, 0x86, 0x8c, 0x4b, -0x71, 0xf5, 0xf2, 0x3a, 0xfa, 0xb9, 0x2c, -0xec, 0x1b, 0xf8, 0xce, 0xce, 0xcf, 0xb5, -0x63, 0x31, 0x66, 0xa3, 0x21, 0xe6, 0xfd, -0x8b, 0x15, 0xd2, 0xff, 0xa5, 0x16, 0xab, -0x93, 0x23, 0xf5, 0xf4, 0x33, 0x92, 0xd3, -0x52, 0x05, 0x01, 0x42, 0x33, 0x36, 0x37, -0x6c, 0x58, 0xa2, 0x21, 0x3d, 0x86, 0xbb, -0x1e, 0x20, 0xc2, 0x6c, 0x50, 0x17, 0xc0, -0x31, 0xcc, 0x55, 0xdc, 0x76, 0x5e, 0x32, -0x9e, 0x5d, 0x54, 0x9d, 0xd3, 0xc9, 0xd9, -0x2d, 0x1c, 0xbf, 0x2d, 0x27, 0x8c, 0xf2, -0xf5, 0x22, 0x75, 0xbb, 0x8d, 0x27, 0x43, -0xd6, 0xc2, 0x84, 0x28, 0x63, 0x95, 0x4d, -0x13, 0x42, 0x80, 0x0a, 0x69, 0xaa, 0xef, -0xa2, 0x79, 0x56, 0xb9, 0x9f, 0x35, 0x75, -0x67, 0xaf, 0x13, 0x84, 0x68, 0xcb, 0xf5, -0x1f, 0x35, 0x6f, 0xe1, 0x45, 0x9b, 0x22, -0x69, 0x0a, 0x8f, 0x90, 0x7d, 0x37, 0x8e, -0x7e, 0xaa, 0x8e, 0xef, 0x25, 0x22, 0xf5, -0xe2, 0xa6, 0x69, 0xfb, 0x56, 0x79, 0xdc, -0xcb, 0x9c, 0xcb, 0xf2, 0xc5, 0x8b, 0xbe, -0x28, 0xc7, 0x75, 0x2f, 0x95, 0xf8, 0x36, -0xac, 0x3c, 0x52, 0x4d, 0x96, 0x95, 0xc3, -0xda, 0xb6, 0x0d, 0x45, 0x20, 0x1a, 0x25, -0x80, 0x1e, 0x7b, 0xa5, 0x33, 0x62, 0xbf, -0xb5, 0x66, 0xb5, 0x39, 0x0a, 0x86, 0xfb, -0xcf, 0xb5, 0xfe, 0x66, 0x81, 0xc8, 0x87, -0x0c, 0x69, 0x60, 0xbb, 0xc0, 0x39, 0xad, -0x21, 0x04, 0xbe, 0x57, 0xea, 0xa2, 0x8b, -0xf4, 0xde, 0x12, 0xbd, 0x58, 0x84, 0x21, -0xe3, 0x95, 0x4f, 0x1c, 0x5f, 0x35, 0xea, -0x2f, 0xed, 0x84, 0x43, 0x31, 0x88, 0x12, -0x98, 0x4a, 0x68, 0xe1, 0x66, 0x7c, 0x81, -0xc6, 0x57, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha512_sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha512_sigrl.inc deleted file mode 100644 index 265b16633c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test0_sha512_sigrl.inc +++ /dev/null @@ -1,1222 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha512 - * Message: "test message" - * Basename: None (random base) - * SigRl: SigRl of group - */ -0x36, 0x19, 0x27, 0x2c, 0xcf, 0xa0, 0x7a, -0x44, 0x9c, 0xea, 0xe5, 0x77, 0x7e, 0x7d, -0x12, 0x33, 0xd9, 0x21, 0x41, 0x58, 0x9b, -0xaf, 0xcc, 0xa2, 0x2e, 0xe1, 0xe1, 0x27, -0x70, 0xe6, 0x2f, 0x8e, 0x70, 0x9d, 0x7c, -0x2b, 0x65, 0xf0, 0xd6, 0xe3, 0x89, 0x5b, -0x8a, 0x82, 0x68, 0x2a, 0x2f, 0x44, 0xbb, -0xba, 0xbe, 0xbf, 0xed, 0x94, 0x87, 0x5b, -0xf4, 0x2a, 0xde, 0xb2, 0xe6, 0xee, 0x57, -0x17, 0x71, 0xec, 0xf4, 0x3d, 0x7c, 0x44, -0x2d, 0x77, 0x42, 0xc6, 0x22, 0x88, 0xc4, -0x80, 0xe3, 0x99, 0x79, 0x7d, 0xe8, 0xf0, -0xaf, 0x37, 0x67, 0x66, 0xe8, 0xa8, 0x63, -0xd7, 0x88, 0xd6, 0xf7, 0x2e, 0x2b, 0x98, -0xcc, 0x0a, 0x96, 0xef, 0x72, 0xfe, 0x47, -0xf7, 0x46, 0x4c, 0x0b, 0x79, 0x94, 0x8c, -0x6a, 0x1f, 0x09, 0x30, 0x31, 0x29, 0xd2, -0x86, 0xed, 0x93, 0xd9, 0xed, 0x9e, 0x88, -0xd2, 0x9b, 0x44, 0x15, 0x36, 0x91, 0x33, -0x62, 0x44, 0xcf, 0xab, 0x0d, 0xf0, 0x24, -0x86, 0x3f, 0x10, 0x74, 0x42, 0x37, 0xbb, -0x1a, 0x67, 0xf4, 0x16, 0x61, 0xc7, 0x5e, -0x30, 0x18, 0x86, 0x28, 0xa2, 0x3a, 0x68, -0xe2, 0xec, 0x6e, 0xa4, 0x5f, 0x1e, 0x81, -0xf1, 0x09, 0xcc, 0x8c, 0xde, 0xe5, 0x3f, -0xc3, 0x6e, 0xfe, 0x19, 0x4f, 0x51, 0xa6, -0x66, 0x69, 0xf2, 0x38, 0xac, 0xad, 0xd9, -0xe8, 0xe2, 0x81, 0x5d, 0xde, 0x68, 0xa8, -0x7e, 0x87, 0xfc, 0x67, 0xda, 0x14, 0xab, -0x14, 0xf0, 0x42, 0x73, 0x8b, 0x2f, 0x82, -0x3b, 0xce, 0x2e, 0x1f, 0x8d, 0xc8, 0x6e, -0x3a, 0x6a, 0x0e, 0x8b, 0x9f, 0x8d, 0x58, -0xbc, 0x32, 0x42, 0x14, 0x07, 0x5c, 0x4c, -0x51, 0xd8, 0xb6, 0x59, 0x29, 0xf7, 0xe7, -0x68, 0xa7, 0x27, 0x43, 0x75, 0x2d, 0x6b, -0x0b, 0x0a, 0x4f, 0x9e, 0x85, 0xe0, 0x84, -0xf2, 0x65, 0x25, 0xbd, 0x33, 0x76, 0xb7, -0xee, 0x5d, 0xab, 0x4d, 0x2e, 0x33, 0xfd, -0x93, 0xff, 0x74, 0x4d, 0x23, 0x99, 0xb4, -0xaa, 0x10, 0x3a, 0xa5, 0x41, 0xb4, 0x18, -0x38, 0xfc, 0x20, 0x04, 0x69, 0xb9, 0x8e, -0xae, 0x5f, 0x77, 0xd8, 0x92, 0x15, 0xa4, -0x5b, 0x4b, 0x46, 0x75, 0xdc, 0x77, 0xf8, -0xdb, 0x58, 0x7a, 0xf8, 0xd3, 0x50, 0xa6, -0x3b, 0x52, 0x10, 0x8b, 0x0f, 0x5c, 0x3d, -0xeb, 0xb9, 0xf0, 0x11, 0xe7, 0xab, 0x1d, -0x24, 0xc6, 0x99, 0x13, 0xbf, 0xc6, 0x41, -0xbd, 0xf8, 0x13, 0xe1, 0x06, 0xb8, 0xb5, -0xb3, 0x94, 0xcb, 0xc1, 0x65, 0xf2, 0x9a, -0x47, 0x05, 0x87, 0xb6, 0x81, 0x8d, 0xd9, -0x19, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x32, 0x97, 0x36, 0xc2, 0x28, -0x13, 0xa6, 0xce, 0x2a, 0x82, 0xf5, 0x7e, -0xce, 0xdb, 0x7e, 0x95, 0x97, 0x71, 0xce, -0xf0, 0xa6, 0xbd, 0x9a, 0x09, 0x6c, 0x4b, -0x5c, 0x64, 0xbc, 0xb6, 0x56, 0xfb, 0x5c, -0xec, 0x0e, 0xc6, 0x33, 0x54, 0xa0, 0x4d, -0x21, 0xdf, 0x03, 0xc4, 0xc8, 0x6a, 0x28, -0xa3, 0xde, 0x94, 0x2c, 0x1b, 0x81, 0x47, -0x71, 0xe9, 0xe0, 0xe7, 0x2a, 0x2e, 0x37, -0x04, 0x0a, 0x86, 0x0f, 0x9f, 0xa4, 0x25, -0x70, 0xd8, 0x52, 0xf4, 0x03, 0xdc, 0x10, -0x93, 0x37, 0x9e, 0x23, 0xd9, 0x95, 0x59, -0x66, 0xa0, 0x65, 0x00, 0x10, 0x27, 0xb3, -0x78, 0xf2, 0x4a, 0xef, 0xab, 0x60, 0xed, -0x21, 0x22, 0xb6, 0x5d, 0x1e, 0x90, 0x16, -0xdf, 0xcc, 0x94, 0x54, 0x01, 0x3f, 0x06, -0xfa, 0xdc, 0x59, 0xb9, 0x68, 0x95, 0xd1, -0x71, 0x59, 0x06, 0x1d, 0xfe, 0xf4, 0x16, -0x57, 0x19, 0x01, 0xc1, 0xd0, 0x7d, 0x6d, -0x41, 0xee, 0x8e, 0xe0, 0x11, 0xd1, 0x95, -0xde, 0xb5, 0x11, 0xa5, 0x61, 0xc6, 0xbf, -0xb4, 0x4c, 0x9b, 0xb2, 0xc1, 0xb7, 0x32, -0xb0, 0x45, 0x1c, 0xd5, 0x9d, 0x4e, 0x50, -0x52, 0xa6, 0x2a, 0x1d, 0xc6, 0xef, 0xc7, -0x53, 0xe6, 0x53, 0xbf, 0x7c, 0x3d, 0xed, -0x79, 0x88, 0xd6, 0xbb, 0xf8, 0x2d, 0xeb, -0x1a, 0x87, 0xd4, 0xee, 0xc4, 0x30, 0xbd, -0xa0, 0x36, 0x98, 0xe5, 0x0a, 0xa5, 0x04, -0xb5, 0xaa, 0x25, 0x00, 0xc8, 0x0b, 0xee, -0x66, 0xe8, 0xc4, 0x6e, 0x9f, 0xb9, 0xea, -0x29, 0xdb, 0xb2, 0x70, 0xfc, 0x75, 0xc8, -0xef, 0x52, 0xd7, 0x4b, 0xa0, 0x15, 0x9c, -0xf0, 0x4a, 0xc5, 0x1a, 0x8f, 0x1e, 0xb3, -0xf3, 0xdc, 0xe0, 0x95, 0x5a, 0x07, 0x7d, -0x8c, 0xfd, 0x2d, 0xeb, 0x20, 0x3e, 0xce, -0x59, 0x63, 0x65, 0x59, 0x41, 0xf5, 0xde, -0x3b, 0xb9, 0xd3, 0x0d, 0x88, 0xbc, 0xf4, -0xf2, 0x95, 0x89, 0x29, 0x75, 0xeb, 0xbc, -0xc3, 0x80, 0xe3, 0x5e, 0x06, 0x84, 0x10, -0xc6, 0xb2, 0xd4, 0x61, 0x99, 0x4f, 0xe8, -0x34, 0xcc, 0xfb, 0x22, 0x61, 0x9f, 0x24, -0xe1, 0x5f, 0xf2, 0x56, 0x54, 0x01, 0x05, -0xde, 0x2c, 0x21, 0xb4, 0x20, 0xbf, 0x86, -0x1e, 0xef, 0x88, 0x35, 0xfb, 0xac, 0xcf, -0x94, 0xcf, 0xb3, 0x66, 0x58, 0x2c, 0x53, -0xdf, 0x87, 0xc9, 0xa2, 0x27, 0xa8, 0xe4, -0x10, 0xb0, 0xe9, 0xee, 0x27, 0x4f, 0x25, -0x29, 0x0f, 0x96, 0xa0, 0x26, 0xe7, 0xa6, -0xd6, 0xf2, 0x03, 0x85, 0x3b, 0x2e, 0xc6, -0x78, 0xe7, 0x77, 0x8d, 0x4f, 0xba, 0x03, -0x55, 0xeb, 0xdb, 0xac, 0x3d, 0x77, 0xdf, -0xdc, 0x27, 0xad, 0x71, 0x6c, 0xb9, 0xee, -0x87, 0xc8, 0x51, 0x3f, 0xe5, 0xe1, 0xa0, -0x3d, 0x42, 0xc9, 0xf2, 0x87, 0x7b, 0x0b, -0xe3, 0x68, 0xbc, 0xbc, 0xea, 0x79, 0xd2, -0x99, 0x0a, 0xdc, 0x37, 0x39, 0x68, 0xf2, -0x5d, 0x09, 0xe4, 0xba, 0xc6, 0xf6, 0xd9, -0xfa, 0xab, 0x90, 0x2c, 0x0f, 0x08, 0x8d, -0xca, 0x14, 0xe1, 0xd8, 0xe9, 0xc8, 0x38, -0x63, 0x00, 0x5f, 0x87, 0xba, 0x7e, 0x83, -0x1b, 0x7d, 0x31, 0xcb, 0x54, 0x50, 0xca, -0xe0, 0x96, 0x34, 0x4b, 0xdc, 0x71, 0x17, -0xcb, 0x79, 0x1b, 0xa2, 0xae, 0x6f, 0xf2, -0x1f, 0x62, 0xc1, 0x24, 0xc2, 0x30, 0x77, -0x6c, 0x51, 0x23, 0x62, 0x1c, 0x4b, 0x0f, -0xb5, 0x63, 0xc1, 0xd6, 0x12, 0x10, 0x77, -0x11, 0x35, 0x01, 0xd9, 0xbd, 0x90, 0x02, -0x39, 0x8c, 0x2d, 0x12, 0xbe, 0x77, 0x02, -0x65, 0x9c, 0x66, 0xa5, 0x5d, 0xbe, 0x18, -0x01, 0xb2, 0x41, 0xc1, 0x9e, 0x38, 0x7e, -0xab, 0x05, 0x48, 0xbe, 0x95, 0x09, 0x9f, -0x02, 0x01, 0x15, 0xa6, 0x3d, 0xfa, 0xa7, -0xf9, 0xac, 0xe4, 0xc0, 0xb1, 0x22, 0x82, -0xfc, 0x37, 0x9b, 0xbd, 0xdb, 0xec, 0x23, -0x3e, 0xec, 0xd8, 0x64, 0x35, 0xe9, 0x81, -0xab, 0x15, 0x54, 0x28, 0x65, 0xf3, 0x2b, -0xe1, 0x3e, 0x9e, 0x6c, 0x45, 0x43, 0xdf, -0x76, 0x00, 0x37, 0xf4, 0x52, 0x8b, 0x68, -0xce, 0xdb, 0x29, 0x71, 0x1d, 0x5e, 0x1f, -0x94, 0x7f, 0x46, 0xfc, 0x2b, 0x34, 0x1b, -0xbb, 0xee, 0x0e, 0xa5, 0x57, 0x8e, 0xe1, -0x51, 0x4d, 0x54, 0xbc, 0x62, 0x19, 0xe3, -0xec, 0x5d, 0x10, 0xa0, 0x94, 0x8d, 0x8d, -0xb2, 0xca, 0x19, 0xac, 0x49, 0xa9, 0x4e, -0x9a, 0x9f, 0xcc, 0x77, 0x1d, 0x3e, 0x14, -0xe2, 0x99, 0xac, 0x58, 0x1d, 0xe0, 0xd0, -0x7e, 0x01, 0xe2, 0x46, 0x4b, 0x22, 0x10, -0x66, 0x04, 0x6a, 0x18, 0x3d, 0x60, 0x3c, -0xc7, 0x13, 0x65, 0xb9, 0xba, 0x8e, 0xfe, -0xf8, 0x2a, 0x37, 0x06, 0xf1, 0xd2, 0x84, -0xc7, 0x80, 0xfc, 0x51, 0x8b, 0xbf, 0x7d, -0xe1, 0x70, 0xd1, 0xc4, 0xf8, 0xa9, 0x30, -0xc3, 0xec, 0xa0, 0xff, 0xdb, 0xda, 0xd3, -0x3e, 0x7d, 0x72, 0x04, 0x8f, 0x68, 0x76, -0xe6, 0x30, 0xb2, 0x13, 0xde, 0x8c, 0xe9, -0x07, 0xc2, 0xbf, 0x3a, 0x78, 0xf0, 0xf0, -0xd4, 0xc1, 0xdb, 0x64, 0x69, 0x26, 0x5d, -0x4f, 0xac, 0x98, 0x66, 0x4d, 0x20, 0x0d, -0xc0, 0x9c, 0x56, 0x94, 0xd8, 0xe2, 0x84, -0xa9, 0x32, 0x4c, 0x10, 0x47, 0x68, 0x2b, -0x33, 0x8c, 0x16, 0xb0, 0xf9, 0x35, 0x36, -0x65, 0x53, 0xc8, 0x23, 0x7e, 0x6b, 0x07, -0x2d, 0x2d, 0x32, 0x20, 0x1a, 0x4c, 0xe9, -0xe9, 0x84, 0x25, 0x4d, 0xc3, 0x8e, 0x70, -0xa6, 0x47, 0xd1, 0xe5, 0xfd, 0x72, 0xa6, -0xf5, 0x7c, 0x9a, 0x93, 0x0e, 0x23, 0xe0, -0x98, 0xb9, 0x64, 0x1f, 0x9a, 0x64, 0xc0, -0xd4, 0x0a, 0xe5, 0xbb, 0x17, 0x3e, 0x3a, -0x94, 0xe3, 0x81, 0xd6, 0x75, 0x5c, 0x8e, -0xf3, 0xf6, 0x9f, 0x80, 0xb5, 0x1e, 0xef, -0xd6, 0x58, 0x31, 0x8b, 0x94, 0xe0, 0xed, -0x3a, 0x5b, 0xcf, 0xca, 0x26, 0x34, 0xe8, -0xa1, 0x70, 0xc3, 0xbe, 0x23, 0x0a, 0x47, -0x36, 0xeb, 0xc8, 0xfc, 0x8a, 0x26, 0xf7, -0x60, 0x44, 0x48, 0x4e, 0x08, 0x40, 0x73, -0xb3, 0x3e, 0xa0, 0x5e, 0xa0, 0x5c, 0x74, -0x5d, 0x21, 0xfc, 0x00, 0x57, 0xbf, 0x23, -0xda, 0xae, 0x49, 0xac, 0x6a, 0x10, 0xe6, -0x1e, 0x1b, 0x19, 0xe6, 0xce, 0x41, 0x6c, -0x3c, 0xe7, 0x45, 0x3c, 0xcb, 0x75, 0xa9, -0xd7, 0x60, 0x0d, 0x43, 0x69, 0x1e, 0xc2, -0x47, 0xea, 0x07, 0x46, 0x2c, 0x58, 0x25, -0x1e, 0x10, 0xe9, 0xc8, 0x8a, 0x14, 0x85, -0x6f, 0x49, 0x37, 0xd7, 0xfb, 0x07, 0x82, -0x4a, 0x6a, 0x5a, 0x3e, 0x95, 0x7c, 0x2c, -0x05, 0xc4, 0x50, 0x82, 0xaa, 0x9e, 0x6b, -0x27, 0x35, 0x48, 0x42, 0x8e, 0x5a, 0x5f, -0x4c, 0x7e, 0xd4, 0x7c, 0x08, 0x77, 0x1e, -0x91, 0x42, 0xd8, 0x3f, 0xbe, 0xed, 0x3b, -0x64, 0x58, 0x57, 0x95, 0xc7, 0x92, 0x94, -0xcf, 0xce, 0x22, 0x73, 0xe3, 0x32, 0xe5, -0x15, 0xa9, 0xbb, 0x6f, 0x27, 0xb9, 0xf3, -0xf1, 0xe4, 0xfd, 0xaf, 0xf5, 0x02, 0x86, -0xb2, 0x4e, 0x50, 0x5b, 0xef, 0xa0, 0xac, -0x0c, 0xa9, 0xba, 0x78, 0xe1, 0xbe, 0x4d, -0x1b, 0x74, 0x9f, 0x36, 0xa4, 0x58, 0x4b, -0xcf, 0x7b, 0xc2, 0xac, 0x3f, 0x1d, 0x8a, -0x9f, 0x81, 0x15, 0x70, 0x8e, 0x43, 0x0b, -0x2b, 0xcb, 0xf4, 0x93, 0x76, 0x97, 0x74, -0x61, 0xaf, 0x2e, 0x7d, 0xfe, 0x11, 0x74, -0x03, 0x8f, 0x38, 0x32, 0x7c, 0x1f, 0xf6, -0x46, 0x68, 0xac, 0x29, 0x48, 0x3e, 0x63, -0xac, 0x64, 0x10, 0x97, 0x1a, 0x22, 0x67, -0x09, 0x51, 0x0c, 0x46, 0x7e, 0xab, 0x21, -0x72, 0xbf, 0x12, 0x69, 0x99, 0x7c, 0xef, -0x07, 0x39, 0x33, 0x63, 0xf8, 0x16, 0x70, -0xe8, 0x25, 0x62, 0x90, 0xa4, 0xd4, 0x10, -0x77, 0xbf, 0x20, 0xac, 0x00, 0xc8, 0x85, -0x12, 0x34, 0x52, 0x1a, 0x77, 0x2a, 0xb7, -0x42, 0x27, 0xcf, 0x2d, 0x1b, 0x15, 0x29, -0x60, 0xdc, 0x61, 0xdf, 0x0d, 0x97, 0xac, -0x71, 0x86, 0xae, 0x93, 0x78, 0xdf, 0xc4, -0xa2, 0x1a, 0xb9, 0x30, 0x23, 0xd0, 0x37, -0xd4, 0x3a, 0x14, 0x67, 0x80, 0xb7, 0xfd, -0x41, 0x89, 0xc3, 0x5b, 0x72, 0xa7, 0x55, -0x76, 0xdf, 0x73, 0x43, 0x9d, 0x40, 0xd6, -0xd8, 0x93, 0xee, 0x39, 0x54, 0xf3, 0x65, -0x15, 0x76, 0xa9, 0x90, 0xe3, 0x5a, 0xea, -0xda, 0xc9, 0x19, 0x9e, 0x4e, 0x30, 0x43, -0x07, 0xcc, 0x24, 0x40, 0x73, 0x91, 0xaf, -0x8d, 0x42, 0x65, 0x0e, 0x01, 0x07, 0x5a, -0xd8, 0xee, 0x8d, 0x20, 0x09, 0xfe, 0x2b, -0x08, 0x63, 0x62, 0xc6, 0xdb, 0x1d, 0xac, -0x9b, 0xbc, 0x97, 0x15, 0xba, 0x45, 0x1f, -0x05, 0x1a, 0xe4, 0xbb, 0x1a, 0xeb, 0x2a, -0xc6, 0x3a, 0xd5, 0xdc, 0x14, 0x90, 0x90, -0x29, 0x8d, 0xe1, 0x2b, 0x37, 0x50, 0x63, -0x1f, 0xcc, 0x73, 0xbe, 0x46, 0x69, 0xeb, -0x67, 0x75, 0xd6, 0x18, 0xc7, 0xde, 0x39, -0xd3, 0x26, 0x1f, 0xd3, 0x92, 0x27, 0x65, -0xec, 0xd0, 0x6a, 0xb3, 0xca, 0x84, 0x47, -0x97, 0xb9, 0x07, 0x70, 0xc5, 0xcf, 0xa1, -0xf0, 0x54, 0x99, 0x32, 0x1b, 0x1a, 0x15, -0xd7, 0x49, 0xd3, 0x50, 0x36, 0x20, 0x99, -0xde, 0xf8, 0xc3, 0x06, 0xa9, 0x99, 0x29, -0x91, 0x9c, 0xed, 0xf5, 0xad, 0x30, 0x78, -0x6f, 0xdb, 0xca, 0x37, 0x10, 0xf1, 0x8c, -0xf5, 0x23, 0x0b, 0x08, 0x81, 0xf3, 0x89, -0x1d, 0x82, 0xc2, 0x5c, 0x52, 0x69, 0x28, -0x5e, 0x63, 0x82, 0x85, 0xc6, 0xc3, 0x7d, -0x31, 0x64, 0x09, 0x7d, 0xac, 0xbc, 0x03, -0x1e, 0xe0, 0xe9, 0xba, 0xf3, 0xc3, 0xfd, -0xdd, 0xd2, 0x6d, 0x21, 0xd7, 0xa3, 0x9d, -0x2c, 0x80, 0x5f, 0xb8, 0x89, 0x45, 0xad, -0xeb, 0x92, 0xf1, 0x86, 0x43, 0x15, 0x7e, -0x21, 0xbc, 0x06, 0xba, 0xe3, 0x78, 0xf8, -0x85, 0xc0, 0x90, 0x71, 0x16, 0xdb, 0x6f, -0x21, 0x0b, 0xd4, 0x69, 0x34, 0x35, 0x4e, -0x1c, 0xc1, 0x83, 0x2b, 0x4e, 0x2f, 0x2f, -0xb4, 0xf5, 0x2b, 0x94, 0x91, 0xdf, 0x97, -0x65, 0xd0, 0x79, 0x74, 0xd7, 0x61, 0x12, -0x3e, 0xf8, 0xaa, 0xfe, 0x74, 0x54, 0x09, -0x38, 0x0c, 0xdf, 0xb7, 0x50, 0x9e, 0x03, -0xab, 0x6d, 0xe4, 0x7c, 0x62, 0xe0, 0xc7, -0x9d, 0x80, 0xa4, 0x02, 0x64, 0x1f, 0x4f, -0x4b, 0x22, 0x5c, 0xf9, 0x10, 0xc1, 0xc8, -0x5e, 0x73, 0x65, 0xd8, 0xd7, 0xf3, 0x5f, -0xb4, 0xc9, 0x25, 0xbf, 0x55, 0xea, 0x09, -0x14, 0x42, 0x69, 0x19, 0x5c, 0x2b, 0xfa, -0x3d, 0x79, 0x2c, 0x66, 0xa4, 0x99, 0x63, -0x96, 0x1c, 0xe0, 0xbb, 0x5a, 0x52, 0x65, -0x56, 0x77, 0x2e, 0x47, 0x94, 0xc6, 0x4d, -0x12, 0x03, 0xb0, 0x23, 0x89, 0x25, 0xc8, -0x59, 0xdf, 0x1a, 0xb6, 0x01, 0x42, 0x45, -0x12, 0x3a, 0xbd, 0xb6, 0x22, 0xbe, 0x7c, -0x64, 0x04, 0x07, 0xe4, 0x90, 0xca, 0x55, -0x94, 0x24, 0xd2, 0xf5, 0x84, 0xf9, 0x1b, -0xa5, 0xaa, 0xed, 0xec, 0xb5, 0xc4, 0x9e, -0xaf, 0xda, 0x54, 0x5d, 0x32, 0xfd, 0xe1, -0x4f, 0x77, 0xa9, 0xdb, 0x77, 0x50, 0x54, -0x75, 0xcd, 0x4e, 0x9a, 0xd9, 0x87, 0x25, -0xae, 0x5a, 0x73, 0x36, 0x5d, 0x80, 0xa8, -0x70, 0x76, 0x8a, 0xc5, 0x42, 0xb2, 0xc1, -0xed, 0x8e, 0x3b, 0xf8, 0x1c, 0xbf, 0x99, -0x8a, 0x9b, 0x5d, 0x83, 0xf8, 0x55, 0x91, -0xd9, 0xd9, 0x80, 0x17, 0xde, 0xea, 0xa1, -0xf2, 0x47, 0xc2, 0xbd, 0xfa, 0x3b, 0x47, -0x1b, 0x57, 0xe0, 0xbd, 0x7d, 0xa5, 0x67, -0x7a, 0x86, 0xae, 0x64, 0x74, 0x57, 0xd6, -0x9d, 0x34, 0xe8, 0x48, 0xf8, 0x1d, 0xce, -0x40, 0x32, 0x6e, 0xb4, 0x80, 0xaa, 0xae, -0xb8, 0x10, 0x23, 0x1c, 0x03, 0x2d, 0x68, -0x7c, 0x17, 0xb2, 0x10, 0xec, 0x22, 0xa4, -0x11, 0x0a, 0xcb, 0xe8, 0xcc, 0x56, 0x11, -0xe4, 0x61, 0xf2, 0x13, 0xf7, 0x9a, 0x67, -0x3f, 0x82, 0x92, 0xcc, 0x56, 0xd7, 0xc4, -0x2a, 0xd1, 0x49, 0x22, 0x9a, 0xa1, 0xcf, -0x2a, 0xea, 0xe8, 0xd6, 0xac, 0x49, 0x3d, -0x8a, 0x77, 0xc7, 0x3f, 0x29, 0xbf, 0x93, -0x49, 0x22, 0x93, 0xe2, 0xc0, 0xf1, 0x66, -0xe0, 0xbe, 0x32, 0x94, 0x13, 0x4b, 0x4a, -0x70, 0xa0, 0xfe, 0xfb, 0xa3, 0xe7, 0x99, -0xd0, 0x9d, 0xc1, 0x89, 0x91, 0xe4, 0x78, -0xc3, 0xf0, 0xb2, 0xae, 0x27, 0x71, 0xc8, -0x87, 0x1d, 0xaa, 0x40, 0x44, 0x23, 0x68, -0x9f, 0x51, 0xd5, 0x8b, 0x88, 0xf3, 0x29, -0x2f, 0xf5, 0xdf, 0x31, 0xa5, 0xcd, 0x8e, -0xc2, 0x16, 0x2f, 0x0f, 0x69, 0x45, 0xb8, -0x9b, 0xa5, 0x6f, 0x06, 0x43, 0x15, 0xbb, -0xaa, 0xf0, 0xa1, 0xd4, 0x5e, 0xf8, 0xbb, -0xe5, 0x8c, 0x83, 0x6a, 0x4b, 0x87, 0xf2, -0xa9, 0x61, 0x48, 0xe2, 0xcb, 0x8a, 0xcf, -0x0c, 0x77, 0x7d, 0x0b, 0xb9, 0x29, 0x80, -0x69, 0x90, 0x41, 0x31, 0x6b, 0x02, 0x49, -0xb7, 0xb6, 0x27, 0xca, 0x64, 0x2a, 0x1e, -0xa4, 0x3c, 0xda, 0x95, 0xa1, 0xb0, 0xa2, -0x81, 0x90, 0xce, 0xcd, 0x93, 0xc2, 0x88, -0xac, 0xb2, 0x5f, 0x2c, 0x0e, 0x72, 0x05, -0x9d, 0x93, 0xb3, 0x46, 0x30, 0x1f, 0xef, -0xf4, 0xe9, 0xaf, 0x92, 0xb9, 0x92, 0x89, -0xfc, 0xa6, 0x2e, 0xb4, 0x2a, 0xee, 0x34, -0x27, 0xcf, 0xb7, 0xdb, 0x36, 0xf4, 0x88, -0x60, 0xd6, 0xeb, 0x6b, 0x2a, 0x38, 0x35, -0xe6, 0x4a, 0xbf, 0x57, 0xe9, 0x1d, 0x50, -0x40, 0xd9, 0x74, 0xe9, 0xc5, 0x03, 0x2a, -0xde, 0x1e, 0x95, 0xc7, 0xd4, 0xd2, 0x58, -0x70, 0xdb, 0x20, 0xaa, 0x46, 0x94, 0x55, -0xd8, 0x19, 0xc7, 0xe6, 0xd4, 0x9b, 0x25, -0x4f, 0x5d, 0xf9, 0x57, 0x9d, 0xb3, 0x21, -0x31, 0x95, 0x7c, 0xb6, 0xcb, 0x67, 0x4d, -0x2f, 0xd7, 0xa7, 0xdd, 0xe5, 0x08, 0xf7, -0xf2, 0x13, 0x99, 0x98, 0x84, 0x8d, 0xef, -0x7d, 0xed, 0x17, 0xa1, 0x8c, 0x78, 0x45, -0x36, 0x54, 0x78, 0xf3, 0xcb, 0x3d, 0x23, -0x34, 0xcd, 0x94, 0xd8, 0x79, 0x88, 0x7d, -0xca, 0x3b, 0x0b, 0x69, 0x21, 0xe0, 0x4b, -0x5f, 0x5f, 0x56, 0x34, 0xba, 0x73, 0xb3, -0xe5, 0x04, 0xf2, 0x76, 0xaf, 0x19, 0x8c, -0x4b, 0x3c, 0xf2, 0xd7, 0x9d, 0x5e, 0x3e, -0x0e, 0x0b, 0x74, 0xb1, 0xf4, 0x51, 0x5b, -0x5f, 0x9f, 0xdc, 0xa5, 0x4f, 0x95, 0x05, -0x3a, 0xb9, 0x60, 0x87, 0xc2, 0xda, 0xb1, -0xa9, 0xc0, 0x85, 0xf6, 0xf4, 0x3c, 0xd9, -0x3a, 0x39, 0x5d, 0x80, 0xfa, 0x93, 0x56, -0xbc, 0x4c, 0x7e, 0xb1, 0x8a, 0x34, 0x9a, -0x0a, 0xeb, 0xd4, 0x83, 0x0e, 0xb1, 0x34, -0x56, 0xdb, 0x9a, 0xca, 0xbb, 0x0d, 0x34, -0x9c, 0x38, 0x74, 0x6b, 0xee, 0x67, 0x65, -0xb4, 0xee, 0xb3, 0x65, 0xc4, 0x22, 0xeb, -0x4b, 0x7d, 0x67, 0xe5, 0x83, 0x8d, 0xf4, -0x92, 0x02, 0x88, 0xad, 0x85, 0xe7, 0xbd, -0xfd, 0x9f, 0xd8, 0x55, 0x86, 0x8e, 0x0d, -0x1a, 0xff, 0x1a, 0x0a, 0x5d, 0xf9, 0x0a, -0xc3, 0xa3, 0x66, 0x35, 0xab, 0x09, 0xe2, -0x64, 0x25, 0x02, 0x6e, 0xbb, 0xca, 0x62, -0xd2, 0xbe, 0x1e, 0xb1, 0x8f, 0x16, 0xb5, -0x40, 0x56, 0x86, 0x97, 0x57, 0x35, 0xbf, -0x1d, 0xdd, 0x70, 0x28, 0x1d, 0xd5, 0x0a, -0x92, 0x9e, 0x94, 0x35, 0xcb, 0xdc, 0xe2, -0x56, 0xc3, 0x6f, 0x46, 0x35, 0x73, 0xee, -0xfd, 0x02, 0x6e, 0x63, 0xad, 0x46, 0x26, -0xb8, 0x71, 0x6f, 0x4a, 0x67, 0x0d, 0x70, -0x33, 0x82, 0x90, 0x90, 0x16, 0x00, 0xcd, -0x54, 0x93, 0xb3, 0xc2, 0x67, 0xdf, 0x6f, -0x23, 0x34, 0x29, 0x19, 0x02, 0xad, 0x0b, -0xd0, 0x8e, 0xd9, 0xc8, 0x3d, 0x17, 0x10, -0xc8, 0x0a, 0x6c, 0x1f, 0x62, 0x3e, 0xed, -0x72, 0xde, 0x5c, 0x1b, 0x8d, 0xcf, 0xec, -0xd8, 0xf2, 0x68, 0x46, 0x8f, 0x5a, 0x26, -0x1c, 0x4e, 0x31, 0x7e, 0x65, 0x4b, 0xc7, -0xd6, 0x4e, 0x9d, 0xe4, 0x06, 0x98, 0x1e, -0xef, 0x79, 0x41, 0xfe, 0x9d, 0xe1, 0x68, -0xbf, 0x45, 0x17, 0xb7, 0x34, 0x90, 0x7c, -0xa6, 0xf2, 0xe7, 0xa7, 0x59, 0xc0, 0x12, -0xb0, 0xce, 0x62, 0x1c, 0x22, 0x31, 0x52, -0x8d, 0x3f, 0x55, 0x41, 0x92, 0x0a, 0xa5, -0x1e, 0x1d, 0x3c, 0x84, 0xd2, 0xba, 0x5d, -0x83, 0x83, 0xe9, 0x8e, 0xca, 0xbc, 0xb4, -0x44, 0xc7, 0x9b, 0x7c, 0xdd, 0x3b, 0xcf, -0xe2, 0xe3, 0x82, 0x3b, 0x05, 0x12, 0x2f, -0xf1, 0x7a, 0x62, 0x72, 0xcb, 0xce, 0x3f, -0xc4, 0xbc, 0xe9, 0x22, 0x34, 0x2f, 0x76, -0xe7, 0x0f, 0xa3, 0xda, 0x73, 0x1c, 0xe9, -0xe6, 0x51, 0x39, 0x85, 0xb0, 0xf2, 0xab, -0xc3, 0x65, 0xd3, 0x18, 0xe5, 0xd7, 0xc4, -0x64, 0x90, 0xee, 0xe4, 0x9c, 0xc3, 0x69, -0xe7, 0x9a, 0x1a, 0x7d, 0x1e, 0x43, 0xc8, -0xe2, 0x31, 0x50, 0x07, 0xd1, 0xb5, 0xb6, -0x25, 0x56, 0x90, 0x19, 0x38, 0xb9, 0x3e, -0x2b, 0x3e, 0xcd, 0xcd, 0x74, 0xc1, 0x40, -0x61, 0xdb, 0xd4, 0xcf, 0xae, 0x88, 0xc0, -0xc9, 0x19, 0xb4, 0xcc, 0x4e, 0x6e, 0x06, -0x50, 0xf6, 0x3c, 0x3e, 0xc7, 0x48, 0xb1, -0x9e, 0x32, 0xe3, 0x54, 0x05, 0xac, 0x41, -0xd8, 0x31, 0xb6, 0xb3, 0x6e, 0xf1, 0x4d, -0xfe, 0xd4, 0x38, 0x2e, 0xff, 0x2f, 0x3a, -0x61, 0xa3, 0xe7, 0x77, 0x99, 0xcb, 0x27, -0xb8, 0x26, 0xab, 0xc4, 0x10, 0xe3, 0xdf, -0x93, 0x05, 0x2b, 0x95, 0x7e, 0xca, 0x2e, -0x6c, 0xe2, 0x9b, 0x29, 0x84, 0xca, 0x6c, -0xad, 0x9b, 0x59, 0xc6, 0x69, 0x03, 0x78, -0x34, 0x13, 0xd6, 0x7f, 0xf9, 0x94, 0xcd, -0xce, 0x79, 0x2b, 0x98, 0x2d, 0xc6, 0xb7, -0xbe, 0xe2, 0x05, 0x2d, 0xdd, 0xae, 0x62, -0x4c, 0xb9, 0x12, 0xc9, 0xfe, 0x0d, 0x8b, -0x90, 0x19, 0xd1, 0x75, 0xfc, 0x5f, 0x6d, -0x21, 0x86, 0x0b, 0x2d, 0x5f, 0xd1, 0x1c, -0xde, 0xb4, 0x32, 0x69, 0x6b, 0x41, 0x6d, -0xbe, 0xfe, 0xb9, 0x62, 0xba, 0x5d, 0x5b, -0x28, 0x73, 0xd5, 0xdb, 0x7b, 0x71, 0x88, -0x28, 0x86, 0xb2, 0x1a, 0x6c, 0xa7, 0x52, -0x79, 0x84, 0x74, 0xd7, 0x40, 0xcf, 0x45, -0xd7, 0x5a, 0xf3, 0x16, 0xa6, 0x32, 0x5c, -0x82, 0x6d, 0x1d, 0x76, 0x02, 0x6c, 0x7a, -0x9e, 0x3e, 0xf9, 0x2f, 0x4b, 0x1a, 0xae, -0x34, 0x03, 0x39, 0xe2, 0x7f, 0x1e, 0x5a, -0x29, 0x8d, 0x45, 0xac, 0x2e, 0x85, 0x91, -0xd0, 0x37, 0xcf, 0xe0, 0x84, 0x02, 0x13, -0x13, 0x69, 0xd7, 0x8a, 0xc6, 0xbc, 0x07, -0xb4, 0x1c, 0xa0, 0xa7, 0x18, 0x73, 0x26, -0x8d, 0xad, 0xae, 0x67, 0xc3, 0x83, 0x88, -0x46, 0x52, 0x90, 0x23, 0x40, 0xd1, 0x04, -0x50, 0xbe, 0x57, 0x2a, 0xb5, 0x53, 0x39, -0x9e, 0x53, 0xb5, 0xcc, 0x15, 0xf2, 0xa7, -0xae, 0xb1, 0x82, 0x64, 0xa1, 0x05, 0xfe, -0xd5, 0xf7, 0x39, 0x8b, 0xbe, 0xe5, 0xbb, -0xae, 0xab, 0xce, 0x4f, 0x60, 0x7b, 0x4c, -0x2e, 0xc4, 0x3c, 0x32, 0x2c, 0xb1, 0x95, -0x36, 0xb4, 0x10, 0xd6, 0xfc, 0xf3, 0xcc, -0x03, 0x69, 0x82, 0xfa, 0xdd, 0x02, 0xfb, -0xf6, 0xed, 0x44, 0x90, 0xec, 0x7a, 0xfa, -0x74, 0xd4, 0xd9, 0x97, 0x1c, 0xd1, 0x69, -0x5f, 0x87, 0xa9, 0x51, 0x1b, 0x00, 0x5d, -0xf7, 0x12, 0xe0, 0xf1, 0xb0, 0xae, 0x33, -0x09, 0xbc, 0xe9, 0xd0, 0x50, 0xac, 0x80, -0x80, 0xb8, 0xe1, 0xa5, 0x7a, 0xd5, 0x65, -0x1c, 0xee, 0xd7, 0xcb, 0xbb, 0x09, 0x6d, -0x86, 0xb2, 0x31, 0x54, 0xcd, 0xca, 0x49, -0x67, 0x5c, 0x7f, 0x49, 0x90, 0xf3, 0xb3, -0x95, 0x8d, 0x25, 0xed, 0x4e, 0x84, 0x28, -0xb3, 0xbf, 0x68, 0xc1, 0xc6, 0x32, 0xa0, -0x66, 0xb0, 0x07, 0x25, 0xc5, 0x26, 0xfb, -0x76, 0x9e, 0x73, 0xed, 0x63, 0x19, 0x2f, -0xb1, 0x3e, 0xb0, 0xc7, 0x8c, 0xd8, 0x7d, -0x60, 0xb5, 0x0a, 0x0c, 0x57, 0x0d, 0xac, -0xa5, 0xa3, 0x12, 0x1e, 0x3a, 0xa3, 0x82, -0xeb, 0xfb, 0x0d, 0x1a, 0x26, 0x22, 0xd6, -0x25, 0x14, 0xa7, 0x4e, 0x72, 0x87, 0x62, -0x8d, 0x7a, 0x25, 0x31, 0xbb, 0xb8, 0x89, -0x62, 0x69, 0xf1, 0xff, 0xb4, 0xb7, 0x26, -0x45, 0x80, 0x59, 0xce, 0x1b, 0x19, 0x22, -0x4b, 0x6d, 0x31, 0x8f, 0xf7, 0x9c, 0xf2, -0xf7, 0xe0, 0x1e, 0x4a, 0x7d, 0x5e, 0x6c, -0xc2, 0x3e, 0x2d, 0x42, 0x96, 0xe6, 0xe8, -0x7d, 0x3d, 0xdf, 0x8b, 0xbb, 0x8c, 0x64, -0xc3, 0x45, 0x91, 0x67, 0x39, 0x6c, 0xcb, -0x9b, 0x58, 0x4b, 0xde, 0x32, 0x6c, 0xc4, -0xf2, 0x19, 0x5e, 0x27, 0x7e, 0xdc, 0xee, -0x14, 0x69, 0x14, 0x83, 0x62, 0xa6, 0xb5, -0x3e, 0x87, 0x49, 0x23, 0x5c, 0xcf, 0x47, -0x20, 0xd4, 0x84, 0x2c, 0xba, 0xc7, 0x4b, -0x0c, 0xf5, 0xfd, 0xa9, 0x36, 0xdd, 0x32, -0x97, 0x78, 0x6b, 0x52, 0x4a, 0xac, 0x73, -0xb6, 0x38, 0x58, 0x6c, 0xc4, 0x2c, 0xbe, -0x57, 0xbc, 0xd2, 0x29, 0xad, 0xb0, 0xfc, -0xd9, 0xcf, 0x0d, 0x4d, 0x8d, 0x85, 0x80, -0x50, 0x8e, 0x35, 0xf1, 0x9a, 0x9f, 0x19, -0x05, 0xb8, 0x65, 0x0f, 0x1b, 0xc5, 0xca, -0xb9, 0x77, 0xb1, 0x00, 0xa1, 0x9a, 0x95, -0xd7, 0x11, 0xcd, 0x8f, 0x56, 0xe3, 0x62, -0xc9, 0xc5, 0x47, 0xf1, 0x2c, 0x0c, 0xd1, -0xc2, 0x49, 0x17, 0xc0, 0xe4, 0xeb, 0xe4, -0xa9, 0x1f, 0x34, 0x10, 0x0a, 0xc5, 0x54, -0x8d, 0xb1, 0xb9, 0x4d, 0xf6, 0x89, 0xc2, -0x86, 0x2c, 0xde, 0x32, 0xdd, 0x67, 0x01, -0x0a, 0x37, 0xad, 0x0a, 0xa7, 0xa9, 0x6a, -0x75, 0xdf, 0x18, 0x53, 0xf8, 0x54, 0xee, -0x4e, 0x2a, 0x0b, 0x94, 0x09, 0x92, 0x54, -0x20, 0x92, 0x93, 0x5a, 0x22, 0xb5, 0xc6, -0x1a, 0x94, 0xed, 0xd5, 0x2b, 0xe7, 0xb6, -0xe2, 0xdf, 0xc5, 0x4f, 0x17, 0xce, 0xfc, -0xc2, 0x5a, 0xdb, 0x3b, 0xf9, 0x9d, 0xd5, -0x94, 0x3a, 0x7a, 0x9f, 0x5d, 0xb6, 0xe0, -0x46, 0x33, 0x5c, 0x2d, 0xb4, 0x5e, 0x5d, -0xaf, 0x0a, 0x24, 0x0a, 0xae, 0x39, 0xe5, -0xef, 0xc4, 0xb1, 0x26, 0xad, 0x42, 0x1f, -0xc3, 0x12, 0x79, 0xb8, 0x60, 0xcc, 0x23, -0x28, 0x6d, 0x11, 0x41, 0x27, 0x08, 0x8f, -0xbd, 0x12, 0xbe, 0x71, 0x5f, 0x48, 0x99, -0x88, 0xa0, 0xa0, 0x34, 0xb5, 0x0e, 0x72, -0xe3, 0x99, 0x7d, 0x88, 0x14, 0x1c, 0x3e, -0x13, 0xd6, 0xcd, 0x56, 0xb5, 0x46, 0xc6, -0xed, 0x80, 0x78, 0x23, 0xb5, 0xfb, 0x53, -0x7c, 0x5f, 0x9f, 0xb4, 0x21, 0x2c, 0xb7, -0x4b, 0xbf, 0x5a, 0x67, 0xc7, 0x9a, 0x4f, -0x59, 0x2f, 0x8f, 0x3b, 0x8a, 0x11, 0xde, -0x5a, 0xa7, 0x66, 0xc5, 0x2b, 0xa7, 0x2d, -0xde, 0xad, 0x85, 0x0c, 0x5d, 0x80, 0xf6, -0x41, 0x38, 0x99, 0xdf, 0x1f, 0x27, 0x64, -0x5c, 0xe5, 0x26, 0x6f, 0x2e, 0xbc, 0xb3, -0x5e, 0x00, 0xf7, 0x9d, 0x1e, 0xdb, 0x35, -0x7e, 0x70, 0x9d, 0xaf, 0x33, 0x5f, 0x01, -0x79, 0xe2, 0x08, 0x4f, 0x50, 0x7b, 0xf0, -0x10, 0xa5, 0xe8, 0x63, 0x36, 0x34, 0xe5, -0x2e, 0x25, 0x1b, 0xfa, 0x1d, 0xd8, 0x99, -0x4c, 0xda, 0xa5, 0xf1, 0xe1, 0xa8, 0xfb, -0x7e, 0x07, 0x2a, 0x98, 0x43, 0x87, 0x69, -0xa3, 0xb0, 0x68, 0xce, 0xdd, 0xad, 0xb0, -0x1f, 0x26, 0x1e, 0x60, 0x4f, 0x92, 0xc8, -0x74, 0xb3, 0xee, 0xee, 0x53, 0x73, 0x97, -0x03, 0xa0, 0x5a, 0x84, 0x9f, 0x9b, 0x79, -0x2b, 0x6b, 0xbb, 0xec, 0x95, 0xa6, 0x97, -0x01, 0x47, 0x45, 0xd7, 0x07, 0x77, 0x86, -0x19, 0x43, 0x8d, 0x9a, 0x44, 0x7c, 0xb4, -0x85, 0x48, 0xcd, 0xa0, 0x9e, 0x94, 0xc3, -0x41, 0x46, 0x40, 0xd5, 0x51, 0x75, 0x64, -0x58, 0x36, 0x5a, 0xc9, 0x52, 0x48, 0x08, -0xa4, 0xd3, 0xd9, 0x7e, 0x07, 0x74, 0x22, -0xd9, 0xf3, 0x2d, 0x4d, 0x93, 0x8b, 0xad, -0x79, 0xc1, 0x6a, 0x6d, 0xd6, 0x57, 0xc4, -0xbf, 0x37, 0x03, 0xb1, 0x78, 0xf2, 0xf3, -0x1c, 0x01, 0xd6, 0x09, 0x53, 0xb8, 0xb4, -0x23, 0x54, 0xaf, 0x39, 0x8c, 0xa6, 0xf7, -0x54, 0x19, 0x99, 0x53, 0xd1, 0x3a, 0x14, -0x68, 0xf2, 0x00, 0x69, 0x03, 0xa3, 0xae, -0x75, 0x46, 0x2e, 0x70, 0xe5, 0xde, 0x4c, -0xe0, 0xec, 0x46, 0x94, 0xa6, 0x6d, 0x7b, -0x9c, 0x96, 0x65, 0xeb, 0x1f, 0x62, 0xd5, -0xe4, 0x26, 0x62, 0x38, 0xc0, 0x7f, 0xce, -0xa4, 0x14, 0x11, 0xe9, 0xfa, 0x97, 0x64, -0x4e, 0x0f, 0x82, 0x6f, 0x82, 0x82, 0x2d, -0x2a, 0xd0, 0xc0, 0xd3, 0x66, 0x37, 0x87, -0x1b, 0x9d, 0xaf, 0x2c, 0xbd, 0xe3, 0xb2, -0x15, 0x36, 0x75, 0x65, 0x1c, 0x68, 0xbc, -0x4d, 0x64, 0xe6, 0x50, 0x82, 0x0a, 0x4f, -0x4b, 0x0d, 0x2c, 0x89, 0x63, 0x50, 0x18, -0x48, 0x3c, 0xcf, 0xa8, 0xa8, 0x1b, 0xaa, -0x62, 0x38, 0x79, 0x4d, 0x93, 0x79, 0xeb, -0xcb, 0x54, 0x17, 0x76, 0xc2, 0x29, 0xf5, -0x54, 0x34, 0x36, 0xe8, 0xfb, 0x87, 0x30, -0xec, 0x67, 0xf1, 0x16, 0x26, 0x10, 0x6f, -0xab, 0x0a, 0x9b, 0xea, 0x38, 0x16, 0x42, -0x9f, 0x45, 0xbb, 0xbc, 0x88, 0x5c, 0x2d, -0x03, 0xe0, 0xc0, 0xd9, 0xc9, 0x99, 0x8e, -0xab, 0x5e, 0x6f, 0x57, 0xff, 0xe4, 0xe2, -0xc4, 0x5a, 0xf8, 0x3d, 0x59, 0x12, 0x82, -0x35, 0x2d, 0x92, 0x0f, 0x5b, 0xa3, 0xd0, -0x25, 0xd7, 0xe5, 0xa9, 0xd1, 0xde, 0x73, -0x78, 0x0b, 0x17, 0x6e, 0xa1, 0xf2, 0xfe, -0x68, 0xba, 0xe0, 0x24, 0x26, 0x75, 0x58, -0x18, 0x07, 0xa1, 0x94, 0x56, 0xed, 0xd8, -0x59, 0x01, 0x4c, 0x45, 0xff, 0x9d, 0x8c, -0xbf, 0xa1, 0x40, 0x19, 0xdc, 0x17, 0x04, -0x8d, 0xd4, 0x43, 0x9e, 0xa0, 0x0a, 0xca, -0x9d, 0x1e, 0xc7, 0xf5, 0x50, 0xad, 0x6b, -0x99, 0x75, 0xda, 0x4b, 0xfc, 0x4f, 0x92, -0x5e, 0x3c, 0x49, 0xb7, 0x0e, 0xf6, 0xda, -0x35, 0xa7, 0x17, 0xd3, 0xb7, 0x30, 0xc9, -0x7b, 0x50, 0xcc, 0x09, 0x29, 0xa4, 0xfa, -0xc0, 0x63, 0xaf, 0xee, 0x71, 0x1d, 0x57, -0xdf, 0x64, 0xfd, 0x32, 0x18, 0x7d, 0x28, -0xb8, 0xca, 0xbe, 0x81, 0x5e, 0x89, 0x70, -0xfe, 0x5f, 0xae, 0x82, 0x79, 0xf6, 0xf5, -0x8f, 0x54, 0xfe, 0xe0, 0xc4, 0x12, 0x07, -0x5e, 0x80, 0x4e, 0x74, 0x7b, 0x74, 0x1c, -0xe2, 0x81, 0x77, 0xf8, 0x13, 0xae, 0xd9, -0xf7, 0x2c, 0xc0, 0xc1, 0x0f, 0xbb, 0xcb, -0xe1, 0xb3, 0x27, 0x2f, 0x08, 0x9d, 0x4a, -0xc8, 0xdc, 0x09, 0xc3, 0x78, 0xba, 0x85, -0x17, 0xb0, 0xa9, 0x2c, 0xaa, 0x1a, 0x0a, -0x67, 0xea, 0x33, 0x3e, 0x03, 0x5f, 0xc6, -0xd3, 0x0d, 0x50, 0xfd, 0x22, 0xb6, 0x12, -0x35, 0x24, 0x82, 0xd7, 0x55, 0xc4, 0x6d, -0x0e, 0xac, 0x38, 0x82, 0x77, 0x39, 0xa2, -0x16, 0x0e, 0xc5, 0xd5, 0x90, 0x70, 0xb2, -0x92, 0x4b, 0xb7, 0xb3, 0x7c, 0xad, 0x3a, -0xf9, 0xd6, 0x53, 0x3f, 0xf8, 0xdb, 0x03, -0x10, 0x14, 0x4f, 0x7c, 0x47, 0x64, 0x24, -0xd2, 0xd8, 0xec, 0x72, 0x73, 0xc8, 0x21, -0x81, 0xcc, 0xb5, 0x11, 0xd2, 0x8c, 0xbc, -0xe1, 0x27, 0xa7, 0xe5, 0x76, 0xae, 0x92, -0x19, 0x23, 0x99, 0x43, 0x8f, 0x3b, 0xee, -0xd5, 0x62, 0xf8, 0xb5, 0x66, 0xc9, 0x66, -0xee, 0xdc, 0x99, 0x49, 0xcc, 0x7f, 0x24, -0xce, 0x25, 0xbc, 0xe1, 0x4e, 0xa4, 0x07, -0x1c, 0xe8, 0x60, 0xe8, 0x2d, 0xdd, 0x0a, -0x4f, 0x3f, 0x09, 0xf4, 0x28, 0xe6, 0x1b, -0x74, 0xb0, 0xfa, 0xa8, 0xa9, 0x7d, 0xed, -0xae, 0x9f, 0x3c, 0x5b, 0x32, 0xb6, 0x7f, -0xfa, 0x3a, 0xc3, 0xbc, 0xb4, 0xe5, 0x81, -0x63, 0x08, 0xc4, 0x4e, 0xa0, 0xaf, 0xd7, -0x6e, 0xa1, 0x2d, 0x7f, 0xf1, 0x49, 0x97, -0xde, 0xf0, 0xca, 0xe2, 0x94, 0xf5, 0x7f, -0xd5, 0xf3, 0x96, 0x15, 0xb9, 0xc1, 0x1d, -0x49, 0x0a, 0x05, 0xcb, 0xfd, 0x6a, 0xfd, -0x3c, 0xc5, 0xcb, 0x0a, 0xaf, 0xde, 0x15, -0x34, 0x0e, 0xb8, 0xa5, 0x4b, 0x97, 0x63, -0x92, 0xcf, 0xd9, 0xd9, 0x67, 0x40, 0x17, -0x42, 0x4b, 0xc8, 0xdf, 0x4c, 0x14, 0x3b, -0x3c, 0x23, 0x91, 0xf2, 0x57, 0x38, 0x23, -0x8e, 0x66, 0xf0, 0xfd, 0x3b, 0x9e, 0x4d, -0x93, 0x23, 0x49, 0xed, 0x96, 0xf7, 0x1b, -0x11, 0x55, 0x55, 0x86, 0x2f, 0x09, 0xe1, -0x57, 0xa8, 0xc2, 0x54, 0x1a, 0x81, 0x85, -0x50, 0x64, 0xfc, 0x16, 0x0b, 0x0c, 0x20, -0x24, 0xb5, 0xce, 0x38, 0x21, 0xf4, 0xb1, -0x84, 0xc4, 0xcb, 0x5a, 0x37, 0x47, 0xfc, -0x24, 0x07, 0x00, 0x24, 0x6c, 0x94, 0xdf, -0xa8, 0xaf, 0xd0, 0x3c, 0x80, 0xe7, 0x19, -0xb1, 0xe2, 0xaa, 0x1c, 0xfb, 0xfc, 0xce, -0xe0, 0x6b, 0x5c, 0xbe, 0x4a, 0xb0, 0xad, -0x17, 0xf2, 0x47, 0xb3, 0x97, 0x70, 0x78, -0x5d, 0x89, 0xe0, 0x7f, 0x8e, 0x8e, 0x19, -0xe2, 0xc0, 0x11, 0x4e, 0x10, 0x0d, 0x67, -0x4d, 0x21, 0x8e, 0x97, 0x90, 0xbb, 0xac, -0xc0, 0x4a, 0x85, 0xdb, 0x5b, 0x9a, 0x91, -0x62, 0x76, 0x39, 0x67, 0xb6, 0xe0, 0xfc, -0x3f, 0xa4, 0x71, 0x1f, 0xa7, 0xae, 0x84, -0x5b, 0xad, 0x84, 0x56, 0xae, 0x90, 0xe2, -0xe2, 0xf6, 0x97, 0x77, 0xee, 0xa1, 0xd4, -0x50, 0x26, 0x3a, 0x3f, 0x9e, 0x5a, 0x75, -0xa8, 0xce, 0xf5, 0x4f, 0x2e, 0xfc, 0xee, -0x87, 0xb2, 0xe9, 0x92, 0x5e, 0xce, 0x09, -0x12, 0x1b, 0x56, 0x3e, 0x28, 0xb1, 0x2c, -0x1f, 0xe4, 0x59, 0x09, 0x75, 0x1a, 0xdf, -0x3e, 0x91, 0x79, 0x0f, 0x71, 0x36, 0x6d, -0xb2, 0xcd, 0x82, 0x0c, 0x9d, 0x3d, 0xfa, -0x0f, 0x8c, 0xf8, 0xc2, 0x65, 0xa6, 0xae, -0x42, 0x93, 0x2c, 0xcd, 0x8b, 0x76, 0x4d, -0x0e, 0xec, 0xd2, 0xd5, 0x43, 0xe3, 0xd6, -0x61, 0xcc, 0xd9, 0x7e, 0x42, 0x09, 0xbd, -0x0b, 0xaa, 0x95, 0xb0, 0x03, 0x5d, 0x87, -0xd6, 0x15, 0xe8, 0x3e, 0x65, 0x1f, 0xc6, -0xd8, 0x79, 0xfe, 0xa9, 0xc4, 0xbc, 0xc8, -0x81, 0xf5, 0x0b, 0x75, 0xab, 0xc4, 0x12, -0x1a, 0x6e, 0x76, 0xd9, 0xea, 0x58, 0xea, -0x81, 0x99, 0x72, 0x8b, 0x3c, 0x2b, 0xca, -0xff, 0xfd, 0xff, 0xb4, 0x07, 0xb5, 0x1d, -0x0c, 0x7a, 0x55, 0x76, 0xf9, 0xb6, 0x7e, -0xbd, 0xd7, 0x46, 0x07, 0x3e, 0x17, 0x96, -0x24, 0xba, 0x94, 0xdf, 0xe4, 0x10, 0xeb, -0xed, 0x37, 0xd0, 0xe2, 0xc2, 0x33, 0x26, -0x25, 0xa0, 0x00, 0xe5, 0xf5, 0x7a, 0x82, -0xec, 0x11, 0xdf, 0xd4, 0x68, 0x87, 0x69, -0x81, 0x40, 0xff, 0x1a, 0x3d, 0xc7, 0x37, -0xe1, 0x94, 0x42, 0xa5, 0xdf, 0xc0, 0xeb, -0x38, 0x82, 0x2d, 0x33, 0xf7, 0x9d, 0x6c, -0x7c, 0xee, 0xa4, 0x3e, 0x37, 0x73, 0xfc, -0x3b, 0x2c, 0xd9, 0x0c, 0x5b, 0x7a, 0x18, -0x9c, 0xe3, 0x53, 0xc5, 0xbb, 0x02, 0xc2, -0x4a, 0x03, 0xb3, 0xeb, 0xe9, 0x74, 0xc3, -0xb4, 0x2f, 0xfa, 0xc1, 0xf9, 0xa9, 0x22, -0xf0, 0x53, 0xc4, 0x2a, 0x33, 0x24, 0x3c, -0xbe, 0xb2, 0xf4, 0x72, 0xdf, 0x71, 0xf6, -0x8c, 0x85, 0xb8, 0xb4, 0xef, 0xd3, 0x17, -0x52, 0x68, 0xdc, 0xcd, 0xb8, 0x0d, 0x09, -0xb5, 0x40, 0xdf, 0x0b, 0x4a, 0xbd, 0xee, -0xd3, 0x92, 0x03, 0xbd, 0xff, 0x1f, 0x5c, -0x6f, 0xb0, 0x4d, 0x94, 0x01, 0xf4, 0xca, -0xdd, 0x86, 0xdc, 0x4e, 0x41, 0xe9, 0x49, -0x08, 0x55, 0x01, 0x03, 0x49, 0x89, 0x9b, -0xc1, 0x0b, 0x23, 0x52, 0xf8, 0xea, 0x2d, -0x75, 0xdd, 0xb1, 0xb1, 0x2e, 0xa1, 0x91, -0x10, 0x7c, 0x13, 0xe6, 0xe4, 0x47, 0x2c, -0x08, 0x6e, 0xfc, 0xca, 0xf9, 0x47, 0x1c, -0x9c, 0x80, 0x3a, 0x7e, 0xcd, 0xb8, 0xad, -0x53, 0xf5, 0x04, 0xcc, 0x7e, 0x8b, 0x4e, -0x6c, 0x65, 0x52, 0x1c, 0x8a, 0x7a, 0xa6, -0x30, 0x6a, 0x6f, 0xc2, 0xf5, 0x26, 0xf8, -0xc9, 0xa6, 0xb1, 0x47, 0x18, 0x16, 0x3d, -0x38, 0x47, 0x95, 0xa5, 0x16, 0xb2, 0x95, -0x77, 0xad, 0x2b, 0xdf, 0xf8, 0x27, 0xc8, -0x7c, 0xf7, 0xa0, 0x12, 0x13, 0xa1, 0xcb, -0xd0, 0xd3, 0x01, 0x7f, 0x51, 0x89, 0x0e, -0xb1, 0x72, 0x5c, 0x08, 0x15, 0xa0, 0x20, -0xd6, 0x10, 0x3e, 0xbe, 0xcb, 0x45, 0x30, -0x92, 0x3d, 0xb7, 0xca, 0x4d, 0xff, 0xe0, -0x0c, 0x17, 0x77, 0xbc, 0x92, 0x84, 0xf0, -0x63, 0x39, 0xde, 0xb3, 0x31, 0x4b, 0x0b, -0xe6, 0x4d, 0x8b, 0x8d, 0x81, 0xf7, 0xfb, -0x51, 0xbf, 0x53, 0xeb, 0x23, 0x12, 0x6e, -0x48, 0x28, 0xbe, 0xaa, 0x18, 0xff, 0x70, -0x9f, 0x81, 0x87, 0x7e, 0xb3, 0x21, 0xba, -0x44, 0x5a, 0x63, 0x60, 0x31, 0xf2, 0x62, -0x2a, 0x92, 0x74, 0x31, 0x6a, 0x98, 0x4c, -0xbd, 0x90, 0xe4, 0xd7, 0xbc, 0xab, 0xe7, -0x51, 0xde, 0x08, 0x68, 0xa7, 0xcc, 0x28, -0xdf, 0xac, 0xb1, 0x05, 0xca, 0x0d, 0xe8, -0x50, 0xcd, 0x0c, 0x41, 0xfe, 0x43, 0xe0, -0x97, 0x75, 0xb9, 0x11, 0xc3, 0x48, 0xe7, -0xfa, 0x5b, 0xf3, 0x92, 0x7f, 0x3a, 0x50, -0xe4, 0xd7, 0x49, 0xe0, 0x22, 0x79, 0x2a, -0x19, 0x7e, 0x21, 0x08, 0xf9, 0x5b, 0x87, -0x13, 0x8d, 0xf1, 0x02, 0x10, 0x14, 0xe9, -0x11, 0xfa, 0xb2, 0xd5, 0x08, 0xdb, 0xbc, -0x95, 0x79, 0x8d, 0xce, 0x53, 0x41, 0xd7, -0xf9, 0x72, 0x6d, 0xe3, 0x95, 0x56, 0xb6, -0xbb, 0x71, 0x77, 0xab, 0x07, 0xbd, 0xdd, -0xeb, 0xc9, 0xb7, 0x26, 0xcd, 0x15, 0xbd, -0x19, 0x88, 0xe9, 0x7c, 0xa0, 0xaa, 0x3e, -0x64, 0xd1, 0xd9, 0x66, 0x91, 0xdd, 0x89, -0x5d, 0xfc, 0x26, 0x2e, 0x0a, 0x9c, 0x87, -0x88, 0x44, 0x2e, 0x54, 0x68, 0x98, 0x8b, -0xa7, 0x23, 0xd6, 0xe2, 0x3a, 0x17, 0x2f, -0xd9, 0x71, 0x89, 0xa6, 0xcb, 0x1d, 0xb8, -0x21, 0xe6, 0x8d, 0x37, 0x30, 0xca, 0xcb, -0xc5, 0x87, 0x61, 0x1b, 0x39, 0xca, 0xf5, -0xe8, 0xd4, 0x3b, 0xa6, 0x3f, 0xdf, 0x19, -0x34, 0x70, 0xeb, 0xb0, 0x5b, 0xb5, 0x2c, -0x3f, 0x6f, 0x99, 0x4e, 0x21, 0x64, 0x64, -0x3f, 0xb7, 0x01, 0x5d, 0x59, 0x27, 0x93, -0xe1, 0x74, 0xbe, 0xa2, 0x48, 0x15, 0x1f, -0x44, 0x88, 0x4f, 0x72, 0xd8, 0x51, 0x3b, -0xdf, 0x74, 0x4c, 0xd7, 0x60, 0x6c, 0x99, -0x79, 0xf3, 0xdc, 0xd5, 0xbc, 0xf8, 0x57, -0x13, 0x4d, 0x2b, 0x91, 0xbe, 0x94, 0xa8, -0x31, 0x74, 0x49, 0x7e, 0x40, 0xca, 0x8b, -0xe9, 0xf5, 0x83, 0x90, 0x86, 0x8f, 0xa3, -0x46, 0xcf, 0x4a, 0xbc, 0xf5, 0xc9, 0x03, -0xb4, 0x25, 0xaa, 0xe6, 0x6c, 0xcf, 0xc6, -0xbf, 0x90, 0x74, 0xf2, 0x6f, 0xa9, 0x5e, -0xba, 0xee, 0x5f, 0x90, 0x07, 0x19, 0x75, -0x41, 0xf4, 0x35, 0xe6, 0xd5, 0x05, 0xbe, -0xdb, 0xc4, 0xc8, 0xc8, 0xce, 0x21, 0xe6, -0xbf, 0xd9, 0xa3, 0x5f, 0xce, 0x63, 0x89, -0xa0, 0xd4, 0x30, 0x5e, 0x48, 0xca, 0xb1, -0x04, 0x5e, 0x78, 0xfa, 0xac, 0x9f, 0x98, -0x2f, 0xb2, 0xe1, 0xfc, 0x2e, 0x76, 0xda, -0xc5, 0x55, 0x7c, 0xcc, 0x40, 0x9e, 0xf0, -0x42, 0x84, 0xb3, 0x69, 0x5a, 0x3c, 0x78, -0xe7, 0x34, 0x7b, 0xf1, 0x6b, 0x8f, 0xc3, -0x34, 0xfc, 0x4b, 0x56, 0xfc, 0x33, 0x93, -0xb6, 0x01, 0x35, 0xbb, 0x94, 0xcd, 0xb3, -0xef, 0x00, 0x4f, 0x06, 0x41, 0xb4, 0x2e, -0xd1, 0x8d, 0x22, 0x41, 0x45, 0x58, 0x46, -0x29, 0xe0, 0x26, 0x38, 0x45, 0x00, 0xdb, -0x6c, 0xfc, 0xc4, 0x9f, 0xe5, 0xb3, 0x3b, -0xba, 0x57, 0x82, 0x51, 0x2d, 0xef, 0x3e, -0xc1, 0x65, 0x89, 0x3d, 0x85, 0x62, 0xe9, -0x58, 0x1c, 0x27, 0x77, 0xa0, 0xcb, 0x2d, -0x33, 0x88, 0x2c, 0xb7, 0x32, 0xa5, 0x55, -0xdb, 0xe5, 0x33, 0x88, 0x5f, 0x72, 0xb1, -0x91, 0x9b, 0xe0, 0x25, 0x31, 0x3b, 0x35, -0x67, 0x27, 0x30, 0xda, 0x75, 0xcd, 0x78, -0xa3, 0x2a, 0x6f, 0x0e, 0x80, 0xc9, 0xa7, -0x69, 0x00, 0xed, 0x5d, 0x3f, 0x87, 0xa3, -0x87, 0x11, 0xf5, 0x65, 0x07, 0xcb, 0xcd, -0xb7, 0x31, 0x2b, 0x5a, 0x52, 0x19, 0x1e, -0xa4, 0x7e, 0x93, 0x9e, 0xf5, 0x60, 0x7b, -0xea, 0x8b, 0x0b, 0x6e, 0xbb, 0xe3, 0x85, -0x04, 0xe6, 0x5b, 0xb9, 0x78, 0x61, 0x7f, -0xe1, 0x1c, 0x6c, 0xff, 0x5d, 0x25, 0x8c, -0x12, 0x86, 0xa6, 0xec, 0x30, 0x5d, 0x57, -0x29, 0x6a, 0x3e, 0x8f, 0x96, 0xaf, 0xca, -0x88, 0xf0, 0x17, 0xeb, 0xf1, 0x2f, 0xe0, -0x07, 0x41, 0xe1, 0x47, 0x81, 0x48, 0x28, -0x09, 0x2f, 0xf2, 0x50, 0x7b, 0xca, 0x7c, -0xe2, 0x1e, 0x17, 0x47, 0x34, 0x25, 0x8e, -0x5a, 0x04, 0xe4, 0x6c, 0xd2, 0xad, 0x7f, -0xaa, 0xaa, 0xc8, 0x1d, 0x2a, 0xaa, 0x62, -0x16, 0x31, 0x4b, 0x88, 0x1d, 0x2d, 0xd5, -0x31, 0x96, 0x15, 0xa7, 0xb0, 0xa6, 0x0c, -0xc4, 0xef, 0xcb, 0xb9, 0x86, 0x8a, 0xfe, -0xb9, 0x99, 0xc8, 0x73, 0xd5, 0x3a, 0xa0, -0x24, 0x06, 0x1b, 0x89, 0x45, 0xc0, 0x38, -0x33, 0xcc, 0x25, 0xb0, 0xc9, 0xeb, 0xee, -0x0b, 0xd3, 0xfe, 0xa6, 0x51, 0x84, 0xef, -0xd4, 0x1c, 0x42, 0xc6, 0x04, 0x15, 0x33, -0x98, 0xd6, 0xd7, 0x01, 0xf8, 0xc3, 0x29, -0xe0, 0xeb, 0x5f, 0x28, 0x5a, 0xd1, 0xa6, -0x90, 0x26, 0xac, 0x0a, 0x58, 0xed, 0x08, -0x41, 0xe8, 0x5f, 0x84, 0x8f, 0xaf, 0x04, -0x82, 0x1f, 0xa1, 0xf7, 0x3b, 0xbf, 0xd9, -0x69, 0x98, 0xcc, 0x59, 0xb3, 0x7f, 0xde, -0xa2, 0x55, 0x81, 0x8b, 0x88, 0xb2, 0x98, -0xfd, 0x77, 0x7a, 0x32, 0x7b, 0x42, 0xe1, -0x14, 0x94, 0xbf, 0x7c, 0xcf, 0x43, 0x73, -0x51, 0x97, 0xda, 0xc3, 0x96, 0x79, 0x3a, -0x0a, 0xf5, 0x0b, 0x5a, 0x9d, 0x60, 0x5d, -0x4c, 0x8f, 0x7f, 0x31, 0x8a, 0xe1, 0xd8, -0xf9, 0x18, 0x62, 0x4d, 0xa4, 0xb6, 0x4a, -0x80, 0xa8, 0x09, 0x85, 0x2c, 0x1a, 0x14, -0x3c, 0xa9, 0xab, 0x28, 0xef, 0x35, 0x37, -0x7c, 0xdc, 0x69, 0x0e, 0x8f, 0x82, 0xa0, -0xfb, 0xb4, 0x86, 0xcc, 0xd9, 0x07, 0x1a, -0x2d, 0x53, 0xa9, 0x5b, 0x46, 0xf7, 0xf2, -0xcb, 0x7a, 0x85, 0x62, 0x89, 0xc8, 0x53, -0x08, 0x24, 0xfc, 0x11, 0x10, 0xfb, 0x4f, -0x31, 0x21, 0x6f, 0x01, 0x10, 0xff, 0x2f, -0x21, 0x48, 0x8e, 0x91, 0xa0, 0x91, 0xc7, -0xaf, 0x0a, 0xf9, 0xb2, 0x3f, 0xe4, 0x61, -0x83, 0x1b, 0x03, 0xb8, 0x66, 0x96, 0xd1, -0x54, 0x85, 0xfc, 0xf1, 0x7d, 0x10, 0x3e, -0xec, 0xcf, 0x2d, 0xe5, 0xaa, 0xe0, 0xde, -0xa7, 0x20, 0x8a, 0x22, 0xca, 0x1a, 0x56, -0x98, 0xb2, 0x7c, 0xe7, 0x6c, 0xf5, 0x2f, -0x9e, 0x9e, 0x95, 0x43, 0xbc, 0x8a, 0x3d, -0xcc, 0xa0, 0xdb, 0x49, 0x78, 0x36, 0x84, -0x2e, 0x55, 0x49, 0x02, 0xb2, 0xdf, 0x5f, -0x21, 0x1c, 0x2b, 0x97, 0xca, 0xc1, 0x8f, -0xc1, 0x5d, 0xf2, 0xa4, 0x3c, 0xb7, 0x69, -0xd0, 0x19, 0x5d, 0xea, 0xe6, 0x95, 0x7d, -0x1d, 0x34, 0xaf, 0x08, 0xa8, 0x15, 0x24, -0x2d, 0xbe, 0x9c, 0x9f, 0xb3, 0xb8, 0x6b, -0x29, 0x68, 0x4e, 0x07, 0x6f, 0xfb, 0xe1, -0xc8, 0x27, 0x5b, 0x3c, 0xef, 0x8f, 0x85, -0x79, 0x75, 0x42, 0xfb, 0xab, 0x59, 0x9c, -0x8c, 0x18, 0x10, 0x0f, 0xc4, 0x74, 0x24, -0xfe, 0x82, 0x7f, 0xb6, 0x6c, 0xfd, 0xc0, -0xc5, 0xd6, 0xa6, 0x23, 0x7c, 0x26, 0xf1, -0x28, 0x09, 0x32, 0xa3, 0x59, 0x5f, 0x98, -0x89, 0x6c, 0x22, 0xd6, 0x6b, 0x7d, 0x52, -0x1c, 0xce, 0xbd, 0xbb, 0xf5, 0x1b, 0x8d, -0x8d, 0xa2, 0xd4, 0x98, 0x30, 0x14, 0x69, -0xd8, 0xae, 0x66, 0x36, 0x6e, 0x7c, 0xd8, -0x82, 0x97, 0xa3, 0xac, 0x84, 0x35, 0xe3, -0xeb, 0x09, 0x4b, 0x72, 0x43, 0xd7, 0x2b, -0xc9, 0xc4, 0x72, 0xbe, 0x84, 0x2b, 0xfa, -0x23, 0x95, 0x9c, 0x2f, 0x18, 0x45, 0x03, -0xeb, 0x92, 0x9e, 0x0a, 0x46, 0xad, 0x01, -0xc6, 0xea, 0xe1, 0xd3, 0xd8, 0x25, 0x50, -0x1f, 0x8a, 0xb8, 0x19, 0xdb, 0x05, 0x17, -0x74, 0x6d, 0x28, 0x1d, 0x8c, 0x4c, 0x29, -0xde, 0xc2, 0x64, 0x96, 0x0a, 0x07, 0xf8, -0xc5, 0xad, 0xcd, 0x5c, 0x1a, 0x92, 0x15, -0x98, 0x83, 0xcb, 0xec, 0x4a, 0x84, 0x39, -0x7a, 0xc0, 0xc7, 0xd8, 0x97, 0x79, 0xcc, -0x6a, 0x9a, 0x4a, 0x3e, 0xfb, 0x4f, 0xd1, -0x64, 0xd9, 0xf7, 0xb2, 0xc4, 0xcc, 0xd3, -0x9c, 0x22, 0x55, 0xc3, 0xbc, 0xf8, 0xf8, -0x2e, 0x35, 0x37, 0x05, 0x47, 0x43, 0x26, -0x43, 0xb3, 0x96, 0x1c, 0xd4, 0x1a, 0xc7, -0x2b, 0xdd, 0x5a, 0x9c, 0xb4, 0x58, 0x3a, -0x9f, 0x24, 0x9d, 0x82, 0x31, 0x21, 0x43, -0xa7, 0xc7, 0xb0, 0xe8, 0xf5, 0xf0, 0xd1, -0xcd, 0x86, 0xe4, 0xf8, 0x98, 0x5e, 0x50, -0x10, 0x87, 0xac, 0x79, 0x6f, 0x56, 0x3f, -0xf6, 0x27, 0x87, 0x83, 0xa7, 0xc4, 0x45, -0x10, 0x20, 0xca, 0x77, 0xca, 0x65, 0x04, -0x6f, 0xd5, 0x54, 0x8f, 0xf8, 0xf3, 0x3c, -0xd2, 0x4d, 0x6f, 0x46, 0xaa, 0xa8, 0x3d, -0xb6, 0xdf, 0x24, 0xc3, 0xf8, 0xfe, 0x59, -0x88, 0x47, 0x2c, 0x2d, 0xed, 0x76, 0x08, -0x89, 0x55, 0x10, 0x42, 0xfc, 0xa4, 0x74, -0x2b, 0xbf, 0x26, 0xe9, 0x9c, 0x52, 0x6b, -0xa4, 0x3c, 0xad, 0x31, 0x76, 0x1d, 0x9f, -0x09, 0xbf, 0xda, 0xde, 0xb1, 0x12, 0x3b, -0xcb, 0x34, 0x6b, 0x44, 0x38, 0xf4, 0x80, -0x12, 0xb8, 0x14, 0x05, 0x8e, 0xab, 0x62, -0x47, 0x6a, 0xa8, 0xa4, 0x89, 0xfd, 0xf5, -0x85, 0x8a, 0xea, 0x2c, 0x58, 0x3e, 0x95, -0xe5, 0x6a, 0x6f, 0xd3, 0x63, 0x47, 0x3c, -0xfb, 0xdb, 0x6c, 0x94, 0xb0, 0xcf, 0x97, -0xdd, 0xfc, 0xde, 0xa9, 0x5e, 0x67, 0x49, -0x37, 0x55, 0xe5, 0xd4, 0x25, 0xbc, 0x95, -0x58, 0x9d, 0xf7, 0x08, 0x05, 0x34, 0x32, -0xbf, 0x4f, 0xf1, 0xf5, 0x3a, 0x96, 0x7c, -0xe5, 0xb7, 0xe3, 0x71, 0xac, 0x9e, 0x89, -0xb6, 0x1c, 0xce, 0x7d, 0x10, 0x33, 0xc3, -0x41, 0x5e, 0x9d, 0xa0, 0xff, 0x67, 0xcc, -0xe6, 0xdb, 0x27, 0xa4, 0xe8, 0xe1, 0x80, -0xf7, 0x67, 0x76, 0x42, 0xef, 0xd2, 0x48, -0x65, 0x45, 0xd6, 0xea, 0x69, 0xd5, 0xb4, -0x6f, 0xc7, 0x3c, 0xe7, 0xe3, 0x71, 0x88, -0x23, 0x27, 0x77, 0x23, 0xb3, 0x65, 0x89, -0x19, 0x52, 0x31, 0x7e, 0xe3, 0x78, 0x78, -0xa5, 0x38, 0x4f, 0xff, 0x64, 0x18, 0x87, -0x09, 0x5d, 0xc5, 0x82, 0x5f, 0xd4, 0xa4, -0x28, 0x3a, 0x69, 0xb3, 0x80, 0xb1, 0x9f, -0x04, 0xa1, 0x24, 0x9a, 0x6f, 0x15, 0xe2, -0x09, 0xd6, 0xe2, 0xd3, 0xc5, 0x2b, 0x76, -0xe6, 0xc9, 0x34, 0x84, 0xf0, 0xf5, 0xb5, -0x50, 0xb9, 0xd9, 0x9a, 0xba, 0x2a, 0x7a, -0xd6, 0xea, 0xec, 0x1a, 0xee, 0xbe, 0x5a, -0x6b, 0x9e, 0xa7, 0x7a, 0x34, 0xe6, 0xf7, -0xb7, 0x97, 0x57, 0xba, 0x6f, 0x56, 0xe8, -0xc7, 0xc0, 0xa1, 0xfe, 0x5d, 0xf0, 0x0f, -0x06, 0xf5, 0xbc, 0x4d, 0x68, 0x75, 0x39, -0x3d, 0x93, 0x4e, 0x1f, 0xb7, 0xcd, 0xc6, -0x3f, 0x5a, 0xf2, 0x71, 0xa3, 0x44, 0x5e, -0x15, 0xd3, 0x84, 0x6c, 0xf8, 0xc8, 0xe8, -0xb5, 0x31, 0xa3, 0x45, 0x58, 0xdd, 0xa6, -0x63, 0x43, 0x73, 0xe2, 0x06, 0x52, 0x40, -0x34, 0x0e, 0xb4, 0xea, 0x59, 0x5b, 0x9f, -0xcb, 0xed, 0xd9, 0x41, 0x9d, 0xd4, 0x92, -0x46, 0xa4, 0x47, 0x0a, 0x38, 0xde, 0x19, -0xab, 0xdd, 0x98, 0x25, 0x2a, 0x46, 0xc9, -0xb4, 0xb0, 0x15, 0xa2, 0xcf, 0x34, 0xff, -0x82, 0x39, 0xa7, 0x17, 0xa3, 0x62, 0xe3, -0xed, 0xa7, 0x7b, 0x62, 0x32, 0x0c, 0x46, -0x96, 0xfd, 0x6c, 0x1b, 0x6d, 0x47, 0xb9, -0x73, 0xb0, 0x65, 0x39, 0xea, 0x25, 0x71, -0xd7, 0x77, 0x8a, 0x43, 0x58, 0x2b, 0x8c, -0xa3, 0x1b, 0x72, 0x13, 0xf1, 0x27, 0x65, -0x49, 0x7f, 0x05, 0x6e, 0x35, 0xab, 0x73, -0xcb, 0x09, 0x49, 0x14, 0x1f, 0xf1, 0xa6, -0x85, 0x8b, 0x61, 0x3a, 0xb7, 0xe0, 0x1d, -0x87, 0xeb, 0x34, 0x44, 0xd8, 0xd4, 0x12, -0x7b, 0x82, 0xa1, 0xb6, 0x77, 0x53, 0xd7, -0x36, 0x39, 0x64, 0x49, 0xbd, 0xd1, 0xb4, -0x3d, 0xea, 0x4d, 0x0b, 0x50, 0x5d, 0x0a, -0x5d, 0x64, 0xa2, 0xac, 0x7d, 0x6c, 0x6a, -0x2c, 0x01, 0x75, 0x04, 0xf8, 0x50, 0xfe, -0x58, 0xb2, 0xe5, 0xaa, 0x7a, 0x30, 0x96, -0x82, 0x98, 0x8b, 0x4c, 0xd5, 0x97, 0x5c, -0xf8, 0xb6, 0xf0, 0x7d, 0xdd, 0xba, 0xdd, -0xfd, 0xf2, 0xd6, 0xea, 0x6b, 0xbd, 0x9d, -0xcd, 0x63, 0x33, 0x9b, 0x4f, 0xf2, 0x3c, -0x3b, 0x17, 0x2e, 0x46, 0xbf, 0xaf, 0xc5, -0x97, 0x32, 0x14, 0x34, 0x99, 0x94, 0xc9, -0xa9, 0x10, 0x91, 0xe7, 0x51, 0x3b, 0x42, -0x8d, 0x74, 0x8b, 0x57, 0x28, 0x20, 0x3f, -0xd1, 0xdc, 0xf9, 0xd4, 0x0f, 0x87, 0x5b, -0xd5, 0x2f, 0x74, 0x44, 0xc3, 0xc7, 0xbe, -0xcd, 0x17, 0x0c, 0xbf, 0xe4, 0x62, 0xa1, -0x43, 0x34, 0x17, 0x08, 0x46, 0x30, 0xa0, -0x85, 0x20, 0xa8, 0xbb, 0xb4, 0x63, 0xd1, -0x12, 0x09, 0xf6, 0xd6, 0x01, 0xa4, 0x25, -0x74, 0xa8, 0xb9, 0x56, 0x82, 0xdb, 0x78, -0xe8, 0x41, 0xbb, 0xc6, 0x18, 0xc5, 0x86, -0xa3, 0xea, 0xbf, 0x90, 0x2c, 0xdd, 0x15, -0xe0, 0x4a, 0x21, 0xd4, 0x42, 0x94, 0x94, -0xf4, 0x48, 0x62, 0x97, 0x25, 0xc7, 0xcd, -0x44, 0x88, 0x20, 0xd6, 0x05, 0x4b, 0x96, -0x89, 0xd0, 0x3e, 0x0d, 0x9f, 0xa3, 0x24, -0xf8, 0xf8, 0xb1, 0x44, 0xa9, 0x37, 0x55, -0xdb, 0x2c, 0x51, 0xb8, 0x8c, 0x6b, 0x4e, -0x36, 0xaa, 0xb9, 0x56, 0x0b, 0xda, 0x62, -0x49, 0x97, 0xac, 0x9b, 0x62, 0xaa, 0x90, -0x4e, 0xe3, 0xce, 0xa9, 0x04, 0x5f, 0x7f, -0xcc, 0x3d, 0x97, 0xaf, 0x73, 0xb8, 0x4a, -0x2f, 0xdc, 0x5b, 0xd8, 0x3a, 0xc3, 0xb4, -0x98, 0x7a, 0x2b, 0xd5, 0x24, 0x6b, 0x50, -0xe1, 0xbe, 0x1f, 0x24, 0x1d, 0xff, 0xb6, -0xfb, 0x93, 0xe3, 0xb5, 0x06, 0x75, 0x07, -0x64, 0xb1, 0xb0, 0x78, 0x0d, 0xf7, 0xa9, -0x06, 0x1f, 0x9f, 0x80, 0x57, 0xb1, 0x25, -0xca, 0xdb, 0x58, 0xc7, 0x79, 0xfd, 0x18, -0xac, 0x71, 0xc2, 0x3b, 0x54, 0xd7, 0x38, -0x49, 0x12, 0x30, 0x07, 0x6a, 0x0c, 0x52, -0x2f, 0x63, 0xf8, 0x53, 0xe5, 0x9e, 0x66, -0xaf, 0x6d, 0xe3, 0xc3, 0xbd, 0x1f, 0xf7, -0x9b, 0x1f, 0x52, 0xb8, 0x9b, 0x8e, 0x63, -0x4c, 0x95, 0xb4, 0x92, 0x7c, 0x7f, 0x23, -0x76, 0x07, 0x3a, 0x48, 0xdc, 0x88, 0x4b, -0x43, 0xf2, 0xea, 0x57, 0x07, 0xf6, 0xcc, -0x8a, 0x9c, 0x0e, 0x7f, 0x9e, 0x75, 0x98, -0xf5, 0x25, 0x9e, 0x19, 0x41, 0x4f, 0x5b, -0xb1, 0x86, 0x94, 0x7a, 0x52, 0xf6, 0xdc, -0x0f, 0x8f, 0x2f, 0x29, 0x52, 0x9f, 0x0a, -0x50, 0x3a, 0xac, 0xe4, 0x59, 0xbb, 0x6d, -0xae, 0x3a, 0x89, 0xf8, 0x5d, 0x9a, 0xd5, -0x1f, 0x6b, 0x58, 0x1e, 0xc9, 0xe9, 0x1a, -0xdf, 0x63, 0xd1, 0xea, 0xb6, 0x51, 0x10, -0x91, 0xe2, 0x9c, 0xa0, 0x48, 0xc3, 0x39, -0xa2, 0x80, 0xfc, 0x3f, 0x21, 0x74, 0xe5, -0xd4, 0x4f, 0x83, 0x95, 0x09, 0x00, 0x82, -0x59, 0x94, 0x78, 0xad, 0x63, 0x7f, 0x97, -0xbf, 0x27, 0x7d, 0x93, 0x4f, 0x4f, 0x8e, -0x98, 0x74, 0x76, 0xa1, 0x8a, 0x91, 0xb5, -0x22, 0xf0, 0x81, 0x03, 0x53, 0xc9, 0xc0, -0xd0, 0x5a, 0x30, 0xe5, 0x63, 0x66, 0x20, -0x6a, 0x77, 0x4c, 0xa0, 0x13, 0xa7, 0x68, -0xc8, 0x34, 0x95, 0x71, 0x26, 0x31, 0x02, -0x7e, 0x26, 0x87, 0x5a, 0x2c, 0x8b, 0xd3, -0x3b, 0x30, 0x94, 0xa6, 0x04, 0x03, 0xcd, -0xbf, 0x4b, 0x53, 0x46, 0xe5, 0x37, 0xf1, -0xa7, 0x16, 0xad, 0x23, 0x3a, 0x7f, 0x5d, -0x43, 0x22, 0x5c, 0xdb, 0xfd, 0x6c, 0xd1, -0x41, 0x69, 0xc1, 0x2a, 0x63, 0x6c, 0x02, -0xe9, 0x9c, 0xa1, 0x26, 0xa6, 0x4a, 0xa5, -0xe3, 0xd1, 0xd3, 0x75, 0x73, 0x0b, 0x6b, -0x7c, 0x52, 0x84, 0x0d, 0x1e, 0x7c, 0xdc, -0xb2, 0xf8, 0x61, 0x74, 0x83, 0x26, 0x91, -0x59, 0xf2, 0x6d, 0x6f, 0x08, 0x0e, 0x31, -0xd8, 0xc6, 0xdd, 0x4c, 0xb5, 0x4a, 0x16, -0x62, 0x83, 0x21, 0xf2, 0x93, 0xe2, 0x4e, -0x32, 0x22, 0x0b, 0x29, 0x79, 0xcc, 0x9f, -0x7e, 0xaf, 0x39, 0x5f, 0x5f, 0x70, 0xf3, -0x60, 0x3c, 0xc2, 0x52, 0x03, 0x4b, 0x7c, -0xef, 0x98, 0x95, 0xd2, 0xb1, 0xf0, 0x33, -0xdf, 0xa9, 0x82, 0x2e, 0x17, 0x9d, 0x89, -0xe2, 0xa9, 0xd8, 0x61, 0x62, 0x30, 0x7b, -0x1c, 0x07, 0x2b, 0xc3, 0xe1, 0x29, 0x80, -0x4e, 0x36, 0x98, 0x14, 0x75, 0xed, 0xac, -0xb3, 0x52, 0xbd, 0x6b, 0x19, 0x90, 0x8f, -0xc4, 0xe4, 0x80, 0x2a, 0x86, 0xb4, 0x9c, -0x8c, 0x83, 0x45, 0x6b, 0x3b, 0x03, 0x99, -0xa7, 0xe8, 0x7b, 0x34, 0xda, 0x8a, 0x0c, -0xc7, 0x1d, 0xcd, 0x31, 0x41, 0xe6, 0x44, -0xd9, 0xcf, 0xea, 0x58, 0x2f, 0x0f, 0x56, -0x6e, 0xe1, 0xc1, 0x8b, 0x53, 0xa6, 0xdb, -0xf2, 0xad, 0x68, 0x13, 0x54, 0x43, 0xb5, -0x2d, 0xb8, 0x0d, 0x77, 0xbd, 0x48, 0x2a, -0x50, 0xe8, 0x47, 0xac, 0xbc, 0xb5, 0x15, -0x58, 0x45, 0xa9, 0x6d, 0xfb, 0x62, 0x13, -0xe1, 0x77, 0xb7, 0x21, 0x17, 0x18, 0x8a, -0xd8, 0xf8, 0x96, 0xdb, 0xdf, 0x33, 0x92, -0x0b, 0xea, 0x18, 0x66, 0x08, 0x28, 0x47, -0xbd, 0xa1, 0xd7, 0x3b, 0x00, 0x50, 0x84, -0xa0, 0xd6, 0xc9, 0xf9, 0x9a, 0x9e, 0x25, -0xab, 0x43, 0x07, 0x4d, 0x89, 0x11, 0xe4, -0xaf, 0x01, 0xf1, 0xf3, 0x2a, 0x42, 0xa8, -0xbe, 0xea, 0xcd, 0x17, 0x5b, 0x99, 0x5d, -0xdf, 0xf4, 0x2e, 0xe8, 0x1d, 0xee, 0x1b, -0x3a, 0x91, 0x70, 0x50, 0x82, 0xa7, 0xb5, -0x17, 0x7c, 0xe1, 0x35, 0x8b, 0xe4, 0x43, -0x29, 0x8d, 0x52, 0xb9, 0x56, 0xba, 0x29, -0x82, 0xc1, 0x2a, 0xfa, 0x70, 0x2b, 0x8f, -0x42, 0xc2, 0x54, 0x61, 0xd2, 0xec, 0xe4, -0x9c, 0x8a, 0xe3, 0x28, 0xa1, 0x88, 0x3d, -0x96, 0xfd, 0x36, 0x64, 0x5e, 0x63, 0xa9, -0xc8, 0x6c, 0x65, 0x69, 0x46, 0x74, 0x23, -0x7a, 0x30, 0x08, 0xe3, 0x37, 0x01, 0xe8, -0xe5, 0x2d, 0xed, 0xd9, 0xb9, 0x14, 0x53, -0x76, 0x87, 0x0e, 0x9f, 0xf3, 0x36, 0xc4, -0xec, 0xef, 0x3b, 0xee, 0xd2, 0x2d, 0x97, -0x94, 0x1d, 0xe7, 0x94, 0xe7, 0xe0, 0xb3, -0x03, 0x52, 0xb1, 0x65, 0xdd, 0x9e, 0xe3, -0x44, 0xaf, 0xba, 0x77, 0x09, 0x1e, 0x70, -0xc8, 0xc2, 0xc5, 0x32, 0x52, 0xcf, 0xa3, -0x0b, 0x74, 0x50, 0xda, 0x9e, 0xfa, 0xa7, -0x66, 0x02, 0x1d, 0xac, 0xd5, 0xc5, 0x0c, -0x87, 0xbd, 0x48, 0xd5, 0x43, 0x8c, 0xbc, -0xd7, 0x93, 0x54, 0x76, 0x9e, 0xbe, 0x99, -0x24, 0x18, 0xb2, 0xc0, 0xcb, 0x51, 0x38, -0x08, 0xd0, 0x2b, 0x72, 0x4b, 0xa5, 0xeb, -0xc2, 0x3f, 0x08, 0x5e, 0x0a, 0x75, 0x0c, -0x96, 0xdb, 0xe0, 0xf0, 0x40, 0x0d, 0x9d, -0xf0, 0xcb, 0x20, 0x38, 0xf3, 0x7e, 0xce, -0x5a, 0x73, 0x7e, 0x44, 0xc9, 0x20, 0x72, -0xc5, 0xbf, 0x91, 0xc6, 0x93, 0x7d, 0x9f, -0xde, 0x0f, 0x66, 0x90, 0xa6, 0x0b, 0x66, -0x74, 0xc8, 0x71, 0x54, 0xc3, 0x42, 0xd8, -0xa5, 0xe0, 0xba, 0xf1, 0x50, 0x1d, 0x39, -0x33, 0x0b, 0xa1, 0x9d, 0xfa, 0xf7, 0xe7, -0xa0, 0xf9, 0xf6, 0xe6, 0xb7, 0xe0, 0x20, -0xe6, 0x95, 0xcc, 0xe1, 0x84, 0x9c, 0xce, -0xab, 0x61, 0x14, 0xdc, 0xa6, 0x22, 0xda, -0xf7, 0x14, 0xc5, 0x58, 0x90, 0x20, 0xa0, -0x8b, 0x0b, 0x0f, 0xb3, 0x70, 0xcd, 0xbc, -0xe0, 0xc9, 0xa5, 0x33, 0x1e, 0xfd, 0x94, -0xe8, 0x7c, 0xe4, 0x0b, 0xc9, 0x65, 0x25, -0xa1, 0xed, 0x44, 0x87, 0xb5, 0xb0, 0x23, -0x85, 0xad, 0x67, 0xcb, 0xf4, 0x3b, 0xeb, -0xd5, 0x6c, 0xfb, 0x9e, 0xe2, 0x3f, 0xed, -0x99, 0x48, 0x99, 0xf4, 0xbe, 0x9a, 0x88, -0x72, 0x82, 0x71, 0x6c, 0x07, 0x3b, 0x77, -0x9b, 0xd7, 0xd9, 0xb1, 0x89, 0x0c, 0x62, -0x07, 0x67, 0xeb, 0xca, 0x1d, 0xf4, 0x1b, -0x39, 0x03, 0x7c, 0xd7, 0xf9, 0x07, 0x89, -0xc1, 0x80, 0xca, 0xfd, 0xf2, 0x19, 0xa2, -0x58, 0xef, 0x8f, 0xea, 0x93, 0x15, 0x4a, -0xfd, 0x90, 0xe4, 0x37, 0xef, 0x3a, 0xa6, -0x28, 0x09, 0x9d, 0x2b, 0xd2, 0x6b, 0xf8, -0x95, 0xe1, 0xf7, 0x19, 0x22, 0x34, 0xd0, -0xca, 0x8a, 0x05, 0x2d, 0x1f, 0x4d, 0x8a, -0x02, 0x59, 0x8e, 0x06, 0x3b, 0x36, 0xd8, -0x7d, 0x70, 0x52, 0xcd, 0x55, 0xd3, 0x94, -0x5c, 0x7b, 0xb4, 0x84, 0x91, 0x29, 0x4b, -0xb2, 0x86, 0xba, 0xdd, 0xc7, 0xb5, 0x48, -0xd5, 0xde, 0x6f, 0x9c, 0x2c, 0xcf, 0xd8, -0xd8, 0xcc, 0x34, 0xb0, 0x6a, 0x59, 0xc7, -0x3e, 0x3d, 0xe7, 0xe6, 0x89, 0x98, 0x83, -0xa4, 0x5d, 0xa9, 0x8d, 0x54, 0xa0, 0xb8, -0x9a, 0x32, 0xe3, 0x49, 0xc0, 0x25, 0x4e, -0x29, 0x1b, 0xb9, 0x49, 0x8b, 0x65, 0x16, -0x1f, 0xaa, 0x90, 0xbf, 0x2a, 0x64, 0x0f, -0x7a, 0x86, 0x57, 0x84, 0x47, 0xd6, 0x0e, -0xf2, 0x52, 0xaa, 0xe2, 0x0a, 0xc9, 0xb3, -0xdd, 0x5e, 0xda, 0xf1, 0xca, 0x81, 0x5c, -0x11, 0xed, 0x03, 0xdc, 0xc6, 0xff, 0x82, -0x8a, 0xa8, 0xac, 0x93, 0x9a, 0x77, 0xd7, -0xdf, 0x22, 0x33, 0xf8, 0xb6, 0xf5, 0x04, -0xb5, 0x25, 0x96, 0x1a, 0x78, 0x28, 0x75, -0x75, 0xaf, 0xc7, 0xbf, 0x14, 0xe3, 0x48, -0xb2, 0x55, 0x3a, 0xbf, 0x5d, 0x3d, 0x65, -0x1e, 0x50, 0x74, 0x31, 0x4f, 0x2d, 0x2a, -0x81, 0x91, 0x98, 0x91, 0xfb, 0x67, 0x5d, -0xdb, 0x13, 0x5d, 0xaf, 0xdc, 0x90, 0x87, -0x9d, 0x55, 0xb4, 0xbc, 0xa9, 0x3a, 0x73, -0xca, 0x2e, 0x22, 0xad, 0x64, 0xb2, 0xdf, -0x61, 0xbe, 0x85, 0x3b, 0xee, 0x50, 0xda, -0x90, 0x80, 0xb4, 0xaf, 0x13, 0xcb, 0xb6, -0x5c, 0xd0, 0x68, 0xc2, 0x21, 0x8e, 0x26, -0x34, 0xd1, 0x6f, 0xf6, 0xe2, 0x3e, 0x25, -0xdd, 0x38, 0x3e, 0xc7, 0xa4, 0x8f, 0x95, -0xb6, 0xc9, 0x1d, 0xe4, 0xc7, 0x46, 0x59, -0x9e, 0xf8, 0x46, 0xcd, 0x60, 0x59, 0x66, -0x0c, 0x7c, 0xf8, 0xe3, 0x61, 0xd4, 0x3f, -0xcd, 0x5d, 0xf7, 0xb9, 0x7c, 0x7d, 0x44, -0x1a, 0x86, 0x58, 0x62, 0xfd, 0x0b, 0x7c, -0x42, 0x78, 0x4e, 0x20, 0xe0, 0x81, 0x74, -0x15, 0xe4, 0xb9, 0x45, 0x85, 0x5f, 0x22, -0x79, 0x05, 0x4d, 0x35, 0xbb, 0x4b, 0xd7, -0x04, 0x55, 0xf9, 0x3f, 0x72, 0xb5, 0xfa, -0x2f, 0xbb, 0xcf, 0xce, 0xb6, 0x39, 0x2e, -0xf6, 0xbe, 0x76, 0x77, 0x34, 0x72, 0xc2, -0x1d, 0x38, 0x31, 0x25, 0x45, 0x74, 0x95, -0x5f, 0x0c, 0x94, 0xcf, 0xa8, 0xc9, 0xbe, -0xcf, 0xb1, 0x7d, 0xf4, 0x55, 0xa4, 0x5e, -0xc0, 0xae, 0x03, 0x91, 0x98, 0x6e, 0x29, -0x56, 0xbb, 0xa3, 0xb2, 0xea, 0x45, 0xfb, -0xcb, 0x45, 0x33, 0x84, 0x0c, 0x14, 0x2d, -0x9d, 0x09, 0x72, 0x4f, 0x01, 0x58, 0x86, -0x07, 0x83, 0x3e, 0xfc, 0xa5, 0x89, 0x4e, -0xa7, 0xe4, 0xfd, 0x5e, 0x61, 0x47, 0x98, -0xa8, 0xec, 0x05, 0xdc, 0xe4, 0x92, 0x85, -0x5f, 0x53, 0xa5, 0xeb, 0x5f, 0x06, 0x46, -0x23, 0xfd, 0xad, 0x25, 0x9c, 0xd4, 0xe5, -0xbe, 0x8c, 0x74, 0x5f, 0xc6, 0xbe, 0x62, -0x81, 0x13, 0xb5, 0xa0, 0x71, 0x90, 0x71, -0x56, 0x0b, 0x35, 0xef, 0x12, 0x9c, 0x8e, -0x45, 0xdf, 0xd8, 0x89, 0xbe, 0x35, 0x92, -0x2b, 0x46, 0x9e, 0xab, 0x62, 0x74, 0x0d, -0xa7, 0x51, 0x1b, 0x75, 0x4e, 0x67, 0x84, -0xa8, 0xc2, 0x06, 0x00, 0xc9, 0x6a, 0xdd, -0xa7, 0x17, 0xc6, 0xb0, 0xf1, 0x24, 0xcd, -0x42, 0x7a, 0xbe, 0x4f, 0x24, 0xa2, 0x3e, -0xf7, 0x54, 0x5b, 0xba, 0xd3, 0xfc, 0xc8, -0x4d, 0x37, 0x8f, 0xc5, 0x6f, 0x96, 0xd8, -0x2e, 0xab, 0x66, 0xfa, 0xba, 0x64, 0xbe, -0xce, 0x02, 0x43, 0x7e, 0x1f, 0x67, 0xbe, -0x60, 0x26, 0xa3, 0xb8, 0xa8, 0xb0, 0x89, -0xca, 0xd3, 0x92, 0x1f, 0xbb, 0xf8, 0x6a, -0xcb, 0xb3, 0x65, 0x44, 0x9e, 0x8b, 0xaa, -0x94, 0x77, 0x68, 0x1b, 0x38, 0xa1, 0x41, -0x9f, 0x54, 0xae, 0xd4, 0x4e, 0x61, 0x71, -0x8e, 0x78, 0x59, 0x93, 0x9c, 0xc5, 0x00, -0xa6, 0xd1, 0x0c, 0x69, 0x09, 0xbe, 0x59, -0x7c, 0xd7, 0x82, 0x30, 0x8b, 0xa2, 0x4a, -0x5c, 0x91, 0x8d, 0xe8, 0x6d, 0x8d, 0xe0, -0x77, 0x14, 0x91, 0x12, 0x4f, 0xda, 0x0d, -0x0e, 0x7d, 0x9e, 0xdf, 0x1a, 0x24, 0x48, -0x01, 0x47, 0x67, 0xba, 0x5a, 0x03, 0xec, -0x71, 0xa6, 0xde, 0x85, 0x86, 0xff, 0x0f, -0xbc, 0x6e, 0xc6, 0x1b, 0x13, 0xf3, 0x92, -0x7f, 0x38, 0x67, 0x61, 0x92, 0xfa, 0x6d, -0xe8, 0x43, 0x89, 0x75, 0x2d, 0xd5, 0xa9, -0xda, 0x44, 0x74, 0x43, 0xbd, 0xee, 0x16, -0x76, 0xa0, 0xc4, 0x42, 0xed, 0x77, 0xe2, -0x9b, 0x59, 0x11, 0x73, 0x16, 0x11, 0x1d, -0x36, 0xfc, 0x1c, 0xfd, 0x4b, 0xd3, 0x03, -0xa5, 0xad, 0xca, 0x9e, 0x9f, 0x92, 0x5d, -0x42, 0xb5, 0x62, 0xae, 0xdd, 0xfe, 0x7a, -0x1b, 0xf4, 0x6c, 0xc1, 0xc0, 0xf9, 0x56, -0x1b, 0xad, 0xe5, 0xc6, 0xf2, 0xfe, 0x44, -0x5d, 0x5d, 0x16, 0x15, 0x5e, 0xe3, 0xdf, -0x30, 0x21, 0x13, 0x7b, 0x3d, 0x84, 0x09, -0x8c, 0x1c, 0x59, 0xa5, 0x22, 0x56, 0x28, -0xa6, 0xac, 0x36, 0xf1, 0x9f, 0x76, 0x21, -0x42, 0xc6, 0xf7, 0xb3, 0x12, 0xd6, 0x63, -0x2c, 0x89, 0xf3, 0x96, 0xf8, 0x9f, 0x66, -0xf2, 0x5c, 0xc8, 0x08, 0x59, 0xdd, 0x7e, -0x79, 0xde, 0x0d, 0x3c, 0x41, 0xa9, 0x7e, -0xcc, 0xc1, 0x35, 0x6c, 0x60, 0x65, 0x02, -0xdc, 0xd1, 0x9e, 0x71, 0xc0, 0x99, 0x1e, -0x77, 0x63, 0x18, 0xa6, 0x42, 0x6a, 0x23, -0x51, 0x9c, 0xc3, 0xd3, 0xfd, 0x0f, 0x6b, -0xc9, 0x88, 0xb5, 0x7e, 0x7a, 0x9c, 0xf6, -0xd5, 0xdc, 0x53, 0xdb, 0x2e, 0x42, 0xdb, -0xd7, 0xcf, 0xe0, 0x8b, 0x80, 0x3f, 0x70, -0x53, 0x1e, 0xf5, 0x89, 0x6c, 0xa4, 0x23, -0x6e, 0x48, 0x5e, 0xd8, 0x34, 0xac, 0xf4, -0x69, 0x6b, 0x29, 0x45, 0x7d, 0xee, 0xbc, -0x90, 0xe7, 0x00, 0x99, 0xe1, 0x75, 0x4c, -0xe6, 0x42, 0x3f, 0xda, 0xc1, 0xe9, 0x26, -0x73, 0x38, 0xe7, 0xe9, 0x73, 0x2e, 0x94, -0x9b, 0xc4, 0xcf, 0xa6, 0x09, 0x9d, 0x46, -0xcb, 0x71, 0x75, 0x42, 0x85, 0xba, 0xdf, -0x94, 0xb4, 0x3c, 0xff, 0xcb, 0x57, 0x27, -0xd2, 0x7c, 0xec, 0xd5, 0x24, 0x8c, 0xa6, -0x5a, 0x04, 0x5d, 0x98, 0x65, 0x57, 0x1c, -0xcb, 0x11, 0x1e, 0xfa, 0xe4, 0xfc, 0x53, -0xb3, 0x4b, 0x62, 0x10, 0xb7, 0x64, 0xf0, -0x54, 0x1a, 0x39, 0xf7, 0xcc, 0x15, 0x03, -0x8d, 0xf6, 0xaf, 0x34, 0x05, 0x44, 0xaa, -0xa8, 0xe7, 0x51, 0xe0, 0x0a, 0xe9, 0xaa, -0xc6, 0x85, 0x5f, 0x73, 0x8e, 0xa6, 0xd4, -0xe6, 0x5d, 0x45, 0xab, 0x7d, 0xbf, 0x6f, -0x0b, 0xf9, 0x52, 0x17, 0x32, 0x54, 0x43, -0x29, 0x1b, 0x97, 0x6a, 0x6c, 0x68, 0x77, -0x31, 0x76, 0x72, 0x27, 0x04, 0x40, 0x16, -0x41, 0xb1, 0xfa, 0xc9, 0xb9, 0xa7, 0xaf, -0xce, 0xf4, 0xe5, 0x70, 0x19, 0x55, 0x19, -0xf2, 0x53, 0x19, 0x2d, 0x6f, 0x3f, 0x10, -0x81, 0xc4, 0x6c, 0xa6, 0x42, 0xa5, 0x86, -0x48, 0xce, 0x94, 0xd4, 0x3f, 0xcd, 0xc6, -0x87, 0x3d, 0xa9, 0x7c, 0xcb, 0x68, 0x30, -0x0d, 0xb1, 0x8f, 0x15, 0xb6, 0xeb, 0x67, -0x9e, 0x03, 0x25, 0x2d, 0x27, 0x8c, 0xf2, -0xf5, 0x22, 0x75, 0xbb, 0x8d, 0x27, 0x43, -0xd6, 0xc2, 0x84, 0x28, 0x63, 0x95, 0x4d, -0x13, 0x42, 0x80, 0x0a, 0x69, 0xaa, 0xef, -0xa2, 0x79, 0x56, 0xb9, 0x9f, 0x35, 0x75, -0x67, 0xaf, 0x13, 0x84, 0x68, 0xcb, 0xf5, -0x1f, 0x35, 0x6f, 0xe1, 0x45, 0x9b, 0x22, -0x69, 0x0a, 0x8f, 0x90, 0x7d, 0x37, 0x8e, -0x7e, 0xaa, 0x8e, 0xef, 0x25, 0x22, 0xf5, -0xe2, 0xa6, 0x69, 0xfb, 0xcd, 0xab, 0x02, -0xfe, 0xcc, 0x09, 0xc1, 0x59, 0x6c, 0x4b, -0xc4, 0xb9, 0xf0, 0xa1, 0x25, 0x3a, 0xec, -0x58, 0x76, 0xa4, 0xec, 0x27, 0x86, 0x05, -0xf3, 0x3e, 0x02, 0x05, 0x47, 0xfa, 0xb4, -0xf0, 0xde, 0xd3, 0xd1, 0x2a, 0x88, 0xf4, -0x47, 0x35, 0xd6, 0xba, 0x59, 0xe4, 0x7e, -0x42, 0x3c, 0x77, 0x1e, 0xf6, 0x00, 0xc4, -0x7c, 0x2c, 0x2e, 0x60, 0xdd, 0x5d, 0xcf, -0xc4, 0x25, 0x1f, 0x5d, 0x37, 0xf2, 0x37, -0x63, 0x7b, 0x88, 0x84, 0x64, 0x06, 0x07, -0xfa, 0x90, 0x66, 0x9b, 0x9a, 0x3e, 0x5a, -0x1f, 0x91, 0x62, 0xaf, 0x4d, 0xcb, 0x24, -0x39, 0x7f, 0x9e, 0x57, 0xf8, 0xc1, 0x97, -0xb9, 0x2e, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1.inc deleted file mode 100644 index ee582e3b8a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1.inc +++ /dev/null @@ -1,74 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha256 - * Message: "test1" - * Basename: None (random base) - * SigRl: Empty - */ - 0xF7, 0xEE, 0x2C, 0x94, 0x30, 0x89, 0xA3, 0x9D, 0x6F, 0x1B, 0xF4, - 0xC9, 0xEA, 0xFA, 0x17, 0xF0, 0x01, 0x3F, 0x48, 0xA0, 0x90, 0xB9, - 0x73, 0xA6, 0x52, 0xC4, 0xF0, 0xDD, 0xDD, 0xFF, 0xFC, 0x72, - - 0x15, 0x08, 0x6C, 0x6B, 0xE7, 0x8B, 0xFE, 0x27, 0x7B, 0x51, 0x39, - 0x7D, 0xE1, 0xB2, 0x2A, 0x17, 0xDF, 0x80, 0xF5, 0xC9, 0x55, 0x6A, - 0x30, 0xF2, 0xA9, 0xE7, 0x0E, 0xF9, 0x4F, 0x50, 0x32, 0xDB, - - 0xE0, 0x46, 0xF9, 0xFA, 0x48, 0xD1, 0xE9, 0xA4, 0x6E, 0xC1, 0x47, - 0xDE, 0x95, 0xD6, 0x03, 0x0B, 0x92, 0x38, 0xD2, 0x86, 0xE0, 0x0E, - 0x97, 0x9C, 0x4B, 0x74, 0x9E, 0x3E, 0xCE, 0x08, 0xA3, 0x97, - - 0xEB, 0x08, 0x67, 0x0F, 0x88, 0x9C, 0xB3, 0xCE, 0x5B, 0x13, 0x45, - 0x97, 0xFA, 0xA5, 0xE8, 0xC9, 0xEF, 0xEA, 0xD5, 0xFC, 0x4D, 0xE2, - 0x33, 0xC8, 0x43, 0x90, 0x40, 0x13, 0xFC, 0xA5, 0x7B, 0xDF, - - 0xA6, 0x1F, 0xE5, 0x33, 0x84, 0x9B, 0x59, 0x7B, 0x34, 0x13, 0x8E, - 0x87, 0x78, 0x53, 0xC2, 0x50, 0x83, 0x81, 0x8B, 0xE2, 0x16, 0x52, - 0x22, 0x89, 0x9C, 0xA6, 0xDA, 0xF5, 0x04, 0x4B, 0x76, 0x64, - - 0xBB, 0xBB, 0x2E, 0x80, 0x00, 0x80, 0xF0, 0xBF, 0x3F, 0xC0, 0x1A, - 0x8F, 0x6A, 0x76, 0xBB, 0x91, 0x36, 0xC7, 0x3B, 0x35, 0xFE, 0x1C, - 0x3E, 0x2A, 0x77, 0x11, 0xE4, 0x43, 0xBB, 0x98, 0xBF, 0xB4, - - 0xA1, 0x3F, 0xEA, 0x99, 0x7E, 0xC7, 0x65, 0xF5, 0x41, 0xA6, 0xD6, - 0xD3, 0x77, 0xEC, 0x27, 0xF8, 0x6C, 0x18, 0x28, 0x69, 0x97, 0x08, - 0x0E, 0x63, 0x5A, 0xDA, 0xFE, 0x9F, 0xD1, 0x4A, 0x61, 0x4F, - - 0xE2, 0x21, 0xD1, 0xBC, 0x14, 0x8A, 0xCB, 0xF5, 0xB4, 0xE0, 0x24, - 0xB8, 0xB7, 0x6B, 0xDD, 0x2A, 0xC5, 0xF8, 0x10, 0x3B, 0xD3, 0x77, - 0xC8, 0x8B, 0x19, 0xBF, 0x5E, 0xFB, 0x2B, 0xB1, 0xC9, 0xE1, - - 0x14, 0x92, 0xD1, 0x1F, 0xAC, 0x90, 0x4D, 0xC3, 0x3E, 0xB8, 0xA7, - 0xFE, 0x35, 0x98, 0xDA, 0x94, 0xD6, 0xF3, 0x27, 0x29, 0x4B, 0x70, - 0xCF, 0x0F, 0xDA, 0x14, 0x97, 0xA1, 0x9B, 0x6B, 0x24, 0x08, - - 0x50, 0x38, 0x60, 0x31, 0xAB, 0x05, 0xCC, 0xB1, 0xC2, 0x06, 0xA0, - 0xD7, 0x92, 0x12, 0xBD, 0x17, 0x81, 0xB9, 0x7E, 0x07, 0x9B, 0xD4, - 0x3B, 0x2D, 0x3C, 0x15, 0x3A, 0x5A, 0xF1, 0xC0, 0xC4, 0x75, - - 0x76, 0x8D, 0xE5, 0xC2, 0xAB, 0x78, 0xD9, 0x76, 0x98, 0xFF, 0x92, - 0xEA, 0x95, 0x58, 0xC5, 0x0C, 0x6F, 0x1B, 0x35, 0xC4, 0xBF, 0x4A, - 0x9E, 0xC2, 0x6A, 0xEC, 0xE2, 0xF6, 0xAF, 0xEB, 0xAC, 0x06, - - 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_basename1_sha256.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_basename1_sha256.inc deleted file mode 100644 index 9d2680fe08..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_basename1_sha256.inc +++ /dev/null @@ -1,85 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha256 - * Message: "test1" - * Basename: "basename1" - * SigRl: Empty - */ - 0xa6, 0x13, 0x29, 0xb6, 0x61, 0xa2, 0xb8, 0xd7, - 0x49, 0x86, 0xcb, 0xaf, 0x94, 0x4d, 0x9e, 0x51, - 0xcf, 0xd3, 0x5d, 0x0f, 0x33, 0x9a, 0x59, 0x0d, - 0xe7, 0xc9, 0xb9, 0x7f, 0x83, 0xae, 0x27, 0xe6, - - 0x40, 0xf0, 0x88, 0x13, 0xe2, 0xb6, 0x6a, 0x43, - 0x26, 0xa3, 0x21, 0xea, 0x00, 0x78, 0xcd, 0xce, - 0x0e, 0x14, 0x7a, 0xde, 0xcf, 0xaa, 0x7b, 0xc5, - 0x7e, 0x7c, 0xaf, 0xe4, 0x5e, 0x8a, 0xdd, 0xc7, - - 0x0b, 0x5e, 0x4e, 0xc6, 0x94, 0xf0, 0xef, 0xf3, - 0xbe, 0xd6, 0x12, 0x28, 0x01, 0xa5, 0xf0, 0x4d, - 0xcc, 0xbe, 0xeb, 0x0e, 0xb9, 0xa1, 0x39, 0x4a, - 0x7e, 0xb3, 0x46, 0x74, 0xc3, 0xb1, 0xdf, 0x91, - - 0x74, 0x3b, 0xa1, 0x5b, 0x29, 0xae, 0x57, 0xf1, - 0x9d, 0xfa, 0xda, 0x57, 0x06, 0x90, 0x4a, 0xa6, - 0x30, 0x16, 0x1a, 0xe9, 0x47, 0xad, 0xd1, 0xc2, - 0xda, 0x8d, 0xbb, 0x5b, 0x46, 0x17, 0x48, 0x58, - - 0x2d, 0xd2, 0x44, 0xc4, 0x7e, 0xd7, 0xb2, 0x73, - 0x91, 0x8c, 0xb2, 0xa7, 0xff, 0xb0, 0xd3, 0xab, - 0x6f, 0x10, 0x14, 0xeb, 0x30, 0x33, 0x90, 0x14, - 0x5b, 0x3b, 0x83, 0x6c, 0xe1, 0xa5, 0x0f, 0x8b, - - 0x6f, 0x9f, 0xf1, 0x1a, 0xbe, 0xc3, 0x75, 0xd2, - 0x0b, 0xb9, 0xa1, 0x1a, 0x2b, 0x01, 0x86, 0xc3, - 0xc2, 0xf8, 0xd7, 0x14, 0x1d, 0xc1, 0x8b, 0x97, - 0x0c, 0x20, 0xce, 0xce, 0xf4, 0x9a, 0xee, 0xc9, - - 0x77, 0x3b, 0x42, 0x0d, 0xe4, 0x87, 0xb2, 0x4a, - 0x44, 0x4e, 0x3e, 0xed, 0x39, 0xaa, 0xad, 0xe4, - 0xe8, 0x4d, 0xa3, 0x5d, 0x6f, 0xa4, 0xb7, 0x22, - 0x32, 0xae, 0xa5, 0xfb, 0x85, 0x71, 0x42, 0xc7, - - 0x02, 0x70, 0xa1, 0xae, 0x70, 0x4f, 0xfe, 0xfc, - 0x1e, 0x52, 0x0f, 0xc0, 0xbe, 0x0a, 0xaf, 0xbc, - 0x1a, 0x4a, 0xd6, 0x25, 0x91, 0x1f, 0xca, 0x0d, - 0x83, 0x89, 0x18, 0xd3, 0xbd, 0x35, 0xbd, 0x58, - - 0x5d, 0xda, 0x73, 0x4f, 0x82, 0xa4, 0xdc, 0x58, - 0x9a, 0x66, 0x02, 0x16, 0xa0, 0x85, 0x77, 0x8f, - 0x38, 0x84, 0x68, 0xcf, 0x08, 0xcd, 0x88, 0x7f, - 0x75, 0xe5, 0x6c, 0x16, 0x96, 0xd1, 0x0b, 0xea, - - 0x97, 0x74, 0xaa, 0x93, 0xcb, 0xe6, 0x6c, 0xab, - 0x9f, 0x62, 0x68, 0x8a, 0x07, 0x93, 0x5c, 0x67, - 0xb3, 0xa8, 0x7a, 0x5a, 0x1c, 0xc3, 0xc3, 0xbe, - 0x44, 0x73, 0x79, 0x65, 0xa5, 0x5a, 0x62, 0x9e, - - 0xc1, 0x52, 0xd9, 0xd1, 0xb2, 0x40, 0x0f, 0x95, - 0x4e, 0x53, 0x95, 0xc0, 0x3e, 0x5b, 0xba, 0x5f, - 0x54, 0x25, 0x05, 0xde, 0xea, 0x5a, 0x4c, 0xa1, - 0x25, 0xa6, 0x2c, 0x05, 0x0c, 0x79, 0x53, 0x15, - - 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha256.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha256.inc deleted file mode 100644 index b14d51849e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha256.inc +++ /dev/null @@ -1,85 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha256 - * Message: "test1" - * Basename: None (random base) - * SigRl: Empty - */ - 0x04, 0x16, 0x79, 0x8e, 0xf9, 0xff, 0x2b, 0xc3, - 0x63, 0x0a, 0x40, 0x68, 0x87, 0x4a, 0x5b, 0xb5, - 0xba, 0x0f, 0xe4, 0x23, 0x05, 0xca, 0xd1, 0xf8, - 0x4e, 0xa6, 0x40, 0x18, 0xed, 0xb5, 0xb3, 0x0d, - - 0x16, 0x58, 0x87, 0x51, 0xd1, 0x83, 0xb6, 0x9a, - 0x41, 0x03, 0xd9, 0xdc, 0xb3, 0xca, 0xc7, 0x0e, - 0xbe, 0xbc, 0xf5, 0xc7, 0x31, 0xe3, 0x8d, 0x0b, - 0x14, 0x0c, 0xe4, 0x2d, 0x2b, 0xcb, 0x3c, 0xf5, - - 0xc0, 0x23, 0x82, 0xe0, 0x69, 0xe7, 0x41, 0x78, - 0x7f, 0x50, 0xc6, 0x61, 0x5c, 0x1b, 0x07, 0x3a, - 0xf6, 0x83, 0xbc, 0xb0, 0x46, 0xae, 0x5c, 0x4f, - 0x13, 0xf3, 0xef, 0x0c, 0xe6, 0x24, 0xe5, 0xdf, - - 0x5e, 0x62, 0xa1, 0x09, 0x1a, 0xe3, 0xa1, 0xda, - 0x72, 0x34, 0x51, 0x18, 0xbc, 0x91, 0x7d, 0x11, - 0x0d, 0x4d, 0x9a, 0xd9, 0x47, 0x40, 0x69, 0xbf, - 0xc6, 0xaf, 0x06, 0xb2, 0xf6, 0xee, 0x76, 0xde, - - 0x1f, 0xb6, 0xb9, 0x55, 0xab, 0xe7, 0x7b, 0xb1, - 0xe7, 0x9e, 0xaf, 0xe4, 0x60, 0x9f, 0x6d, 0x1b, - 0xd9, 0xc8, 0xee, 0xcc, 0x49, 0xea, 0x52, 0x41, - 0x26, 0x06, 0x0b, 0x75, 0x13, 0x63, 0x4a, 0x15, - - 0x18, 0x50, 0xb4, 0x49, 0x35, 0xf8, 0xc7, 0xf7, - 0x77, 0xc3, 0xa7, 0x69, 0xc3, 0xb3, 0xaa, 0x19, - 0xc1, 0x57, 0x21, 0x44, 0x00, 0x95, 0x99, 0xef, - 0x09, 0xbe, 0x9b, 0xc5, 0x82, 0xbd, 0x3b, 0xc2, - - 0x0d, 0x85, 0xbb, 0x4a, 0x12, 0x0f, 0xd0, 0xfc, - 0x2d, 0x66, 0x8f, 0xda, 0x79, 0xb4, 0x28, 0x8e, - 0x3c, 0x74, 0xa8, 0xf8, 0x55, 0xe4, 0x6d, 0xc6, - 0x67, 0xa2, 0x7d, 0x1c, 0xfa, 0xcb, 0x59, 0x2d, - - 0x41, 0x4c, 0xd6, 0x9b, 0x89, 0xd3, 0xef, 0x3b, - 0x87, 0xae, 0x3c, 0x11, 0x6b, 0xc6, 0x6c, 0xab, - 0xe0, 0x9b, 0x68, 0x89, 0xa5, 0xcb, 0x9f, 0x87, - 0x49, 0x9f, 0xe6, 0x6b, 0xf7, 0xbb, 0x11, 0x70, - - 0x13, 0xee, 0x94, 0x8e, 0x35, 0x6a, 0xa5, 0x0c, - 0x8f, 0x71, 0x16, 0x65, 0xe4, 0x83, 0x8b, 0x15, - 0xc9, 0xa7, 0x27, 0x0c, 0x07, 0x86, 0x6c, 0x8b, - 0x5f, 0x4f, 0x69, 0xf3, 0x12, 0x7e, 0x4b, 0x27, - - 0x5c, 0x0f, 0x22, 0x26, 0xe4, 0x4a, 0x96, 0xe7, - 0x5b, 0x5a, 0xaf, 0x9e, 0xb4, 0xc8, 0xc5, 0x5e, - 0x12, 0xa7, 0x66, 0x50, 0xe4, 0x2a, 0x24, 0xb4, - 0x06, 0x93, 0x80, 0x1b, 0x39, 0xc2, 0x07, 0x20, - - 0x32, 0x82, 0xe5, 0xde, 0x81, 0xb6, 0x7c, 0x3a, - 0x55, 0x88, 0xa8, 0x4f, 0x12, 0xdb, 0xd4, 0x0c, - 0x75, 0x02, 0x9d, 0xdb, 0x0b, 0x8b, 0xf7, 0xc8, - 0x7e, 0xbc, 0x34, 0x66, 0x5e, 0x9a, 0xb2, 0x8f, - - 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha384.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha384.inc deleted file mode 100644 index 6191f5db47..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha384.inc +++ /dev/null @@ -1,85 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha384 - * Message: "test1" - * Basename: None (random base) - * SigRl: Empty - */ - 0x79, 0xb5, 0x73, 0xf5, 0xb2, 0x63, 0x6e, 0x0c, - 0xbb, 0x99, 0x14, 0xa8, 0x86, 0xbf, 0x23, 0xd6, - 0xc8, 0x03, 0x5f, 0x5e, 0x0b, 0xd9, 0xc6, 0x74, - 0x23, 0xc0, 0x4d, 0x0d, 0xa3, 0xdf, 0x88, 0x17, - - 0x67, 0x31, 0x05, 0xb8, 0x29, 0x9e, 0x58, 0x06, - 0xaa, 0x1f, 0xf1, 0x9f, 0xe7, 0x65, 0x7a, 0xda, - 0x9a, 0x45, 0x93, 0x27, 0xb2, 0x61, 0x51, 0x94, - 0xa4, 0x8c, 0x4a, 0x4e, 0xcd, 0xf4, 0x5c, 0x7c, - - 0xf7, 0xa4, 0x67, 0x40, 0x4e, 0xf4, 0x20, 0x90, - 0x77, 0x91, 0x37, 0x09, 0xfe, 0xe7, 0x4b, 0x9e, - 0x2e, 0xa9, 0x80, 0xfe, 0xda, 0x19, 0x4c, 0xe0, - 0x29, 0xab, 0x8e, 0xa8, 0x60, 0x59, 0x8b, 0x8e, - - 0xe1, 0x11, 0x52, 0x83, 0xdb, 0xbb, 0xff, 0x1b, - 0xc6, 0x94, 0xc2, 0xc9, 0xc9, 0x3d, 0x1f, 0xd9, - 0x3b, 0x9a, 0x14, 0x0c, 0x5e, 0x98, 0xae, 0x66, - 0x2a, 0xe1, 0x75, 0xd7, 0x19, 0x08, 0x5f, 0xf5, - - 0x01, 0xed, 0x5f, 0x18, 0xc1, 0x7e, 0xde, 0xb6, - 0x4f, 0x9c, 0xb2, 0xe7, 0x21, 0xeb, 0x94, 0xdc, - 0xaf, 0x2c, 0xf1, 0x4a, 0xef, 0x98, 0x9a, 0x8c, - 0x8d, 0xb2, 0xb5, 0x72, 0xab, 0x31, 0xf5, 0x10, - - 0xe5, 0x9c, 0x32, 0x35, 0xa7, 0x41, 0x56, 0x71, - 0xc2, 0x16, 0xcd, 0x05, 0x68, 0x2e, 0xc6, 0x00, - 0xc9, 0x3b, 0x0d, 0x43, 0x04, 0x7a, 0x6c, 0x32, - 0x96, 0x44, 0xeb, 0x75, 0xb2, 0xd9, 0xd5, 0xb1, - - 0x28, 0x91, 0x45, 0x6c, 0x28, 0x85, 0xae, 0x68, - 0xb0, 0xa6, 0x5e, 0x35, 0x1b, 0x46, 0xcf, 0x86, - 0x7a, 0xd1, 0x3a, 0xf0, 0xc6, 0x6c, 0x4a, 0x07, - 0x7a, 0xcb, 0x40, 0x90, 0x55, 0xb7, 0xdc, 0x63, - - 0xa9, 0x58, 0xae, 0x04, 0xe7, 0x65, 0x63, 0x4a, - 0x94, 0xcc, 0x32, 0x6f, 0xe3, 0xef, 0xac, 0x41, - 0x09, 0x1b, 0x06, 0x55, 0x27, 0x3a, 0x26, 0x87, - 0xb7, 0x4a, 0x1d, 0x76, 0x27, 0x2c, 0xab, 0x8a, - - 0x18, 0x64, 0x25, 0x70, 0x8b, 0x4f, 0xab, 0x0f, - 0x4b, 0x20, 0x14, 0xbf, 0x25, 0x49, 0xcc, 0x98, - 0xbd, 0x2d, 0xee, 0x33, 0x90, 0xd8, 0x37, 0x12, - 0x15, 0x7e, 0x0e, 0x39, 0x5e, 0xf1, 0x0f, 0xbd, - - 0xaf, 0x38, 0xb3, 0x0b, 0x9d, 0x98, 0x28, 0xa0, - 0xc3, 0x3f, 0x70, 0xc8, 0xe4, 0xc2, 0xa9, 0xac, - 0xeb, 0x24, 0xe1, 0x0a, 0xfa, 0xd4, 0xe3, 0x2e, - 0xdd, 0x8d, 0x15, 0xc9, 0x32, 0x01, 0x77, 0xcb, - - 0xdc, 0x99, 0x4c, 0xba, 0x99, 0xd3, 0xd0, 0xf1, - 0x22, 0x1a, 0xd7, 0x6e, 0x93, 0xe4, 0xd6, 0x46, - 0x41, 0x88, 0x7f, 0x5c, 0xda, 0x21, 0xa6, 0x1f, - 0x12, 0x9f, 0x77, 0x98, 0xae, 0x4a, 0x50, 0xc9, - - 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha512.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha512.inc deleted file mode 100644 index fe9eff17ff..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/member0/sig_test1_sha512.inc +++ /dev/null @@ -1,85 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: grp01 - * Signer: member0 - * HashAlg: Sha512 - * Message: "test1" - * Basename: None (random base) - * SigRl: Empty - */ - 0xb8, 0x56, 0xe4, 0xb3, 0x1a, 0xba, 0xcf, 0xaa, - 0xee, 0x6a, 0xc6, 0xaa, 0xc6, 0x43, 0xcf, 0x24, - 0x38, 0xb5, 0x95, 0xd9, 0x60, 0x40, 0xfd, 0xb1, - 0xa5, 0x0b, 0x49, 0x72, 0x8c, 0x1a, 0x32, 0x8b, - - 0x50, 0x9f, 0xed, 0xc0, 0x90, 0x46, 0x0f, 0xe5, - 0x26, 0x72, 0xb1, 0x7a, 0xf9, 0xfe, 0x67, 0xa2, - 0x81, 0xab, 0x7a, 0x6f, 0x8e, 0xc6, 0x26, 0x8b, - 0x9f, 0x5a, 0x07, 0xd7, 0xc1, 0x8a, 0x94, 0x53, - - 0x0b, 0x0a, 0xd3, 0xd9, 0xa2, 0x10, 0xc5, 0xc2, - 0x14, 0x13, 0xe2, 0xc0, 0x53, 0x5a, 0xa3, 0x13, - 0x25, 0xfd, 0xd7, 0x4c, 0xec, 0xc4, 0x57, 0x36, - 0xfc, 0x34, 0xb0, 0x7c, 0xcc, 0x17, 0x9c, 0xf4, - - 0x68, 0x9d, 0xd0, 0x8c, 0xb9, 0xb4, 0xb2, 0x35, - 0x7c, 0x9b, 0xeb, 0x24, 0x00, 0x05, 0x96, 0x0b, - 0xa2, 0xf2, 0xe4, 0x87, 0x38, 0x80, 0xcb, 0xd5, - 0x0c, 0x01, 0xc1, 0xb1, 0xe4, 0x21, 0x63, 0x41, - - 0x73, 0x44, 0xf4, 0xe4, 0x20, 0xb0, 0x0c, 0xb7, - 0x6b, 0x49, 0x4b, 0xe8, 0xb3, 0x09, 0x5f, 0x16, - 0x35, 0x08, 0x5e, 0x97, 0x5b, 0xe1, 0x77, 0x94, - 0x2c, 0x47, 0xba, 0x1b, 0x3b, 0x37, 0x71, 0x1b, - - 0x28, 0xb7, 0x7d, 0x9b, 0x61, 0x50, 0xc0, 0x85, - 0x38, 0xb7, 0xb4, 0xd7, 0x27, 0x22, 0x5b, 0xf1, - 0x72, 0xb6, 0x0d, 0x19, 0x60, 0xdc, 0x70, 0x38, - 0xe5, 0x01, 0x31, 0x04, 0x8a, 0xee, 0x1f, 0xd8, - - 0x45, 0x1d, 0x0c, 0x4c, 0xe3, 0x5f, 0xbc, 0xb0, - 0x6e, 0x9b, 0x7b, 0x01, 0x42, 0xcf, 0xb5, 0x56, - 0x32, 0xdc, 0xf2, 0xea, 0xb5, 0x66, 0xdc, 0x10, - 0xea, 0xb8, 0x2b, 0xa0, 0xb7, 0xbb, 0x55, 0x45, - - 0xf7, 0x50, 0xf5, 0x14, 0x02, 0x91, 0xf4, 0x2f, - 0x10, 0xa8, 0x94, 0xaf, 0x6a, 0x4a, 0xab, 0x87, - 0xdf, 0xd5, 0xeb, 0xc3, 0x22, 0x38, 0xaf, 0xef, - 0x79, 0xf4, 0xed, 0x1c, 0xe8, 0x5d, 0xd0, 0x19, - - 0x7a, 0x9c, 0x7c, 0x05, 0x23, 0x24, 0xb3, 0xfb, - 0x2c, 0x54, 0x4d, 0xee, 0x55, 0x51, 0xab, 0xff, - 0x52, 0xc6, 0x79, 0xe8, 0xd4, 0x64, 0x5b, 0xc5, - 0x3b, 0x65, 0xee, 0xaf, 0x69, 0xb5, 0x81, 0x51, - - 0x3a, 0x23, 0x0b, 0x6c, 0xf8, 0x0c, 0xe5, 0x72, - 0xd7, 0x16, 0x61, 0x3b, 0x73, 0x4c, 0x2b, 0x23, - 0x51, 0x64, 0x02, 0xa2, 0x60, 0xac, 0xda, 0x17, - 0x4d, 0x49, 0x38, 0xaf, 0x9c, 0xcd, 0x83, 0x3a, - - 0x88, 0x73, 0xb4, 0x5b, 0x86, 0x2c, 0xa7, 0x7f, - 0x95, 0xf1, 0x9f, 0xa9, 0x9b, 0x49, 0xca, 0xef, - 0xd7, 0x07, 0xdf, 0x06, 0x3e, 0xb9, 0xa8, 0x7f, - 0x45, 0x9d, 0x6e, 0x24, 0xf8, 0xf3, 0xee, 0x5e, - - 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/privrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/privrl.inc deleted file mode 100644 index 3c373a1e3f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/privrl.inc +++ /dev/null @@ -1,277 +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. - ############################################################################*/ - -// privRL -// gid -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, - -// version -0x00, 0x00, 0x00, 0x00, - -// n1 -0x00, 0x00, 0x00, 0x32, - -// f's -0x8a, 0xdc, 0xc0, 0xc8, 0xcd, 0x29, 0x9e, 0x8, -0x9e, 0x4e, 0xd, 0xa7, 0xf6, 0x46, 0xee, 0x80, -0xca, 0x91, 0x86, 0x54, 0x3c, 0x7f, 0x8d, 0xb5, -0x49, 0xf9, 0x6d, 0x00, 0x39, 0x39, 0x62, 0xc7, - -0xe9, 0xa2, 0x59, 0x31, 0xbc, 0xc6, 0x6, 0xe1, -0xf5, 0x45, 0xc6, 0xe1, 0x1a, 0x8e, 0xd6, 0xc6, -0xc7, 0x25, 0x94, 0x7f, 0x82, 0x99, 0x3d, 0x1d, -0x32, 0x39, 0xd9, 0x37, 0x2a, 0x12, 0x89, 0x03, - -0x83, 0xe7, 0x53, 0xa9, 0x99, 0xba, 0x3f, 0xae, -0x3e, 0xa0, 0x86, 0x91, 0x1c, 0xee, 0xe3, 0x76, -0x4b, 0xf0, 0x7a, 0x11, 0xb3, 0x9d, 0x35, 0x42, -0x00, 0xcf, 0x40, 0x5e, 0x36, 0x74, 0x2a, 0x94, - -0xb9, 0x2f, 0x96, 0xa7, 0xbf, 0x5d, 0x8c, 0x5b, -0x47, 0xc4, 0xac, 0xe9, 0x9a, 0x8a, 0x2d, 0x38, -0x4, 0xb5, 0xe6, 0x56, 0x30, 0xa7, 0xe4, 0x9a, -0xcc, 0x73, 0x81, 0x9a, 0x4f, 0x75, 0x6c, 0xef, - -0x91, 0x52, 0xb2, 0x6, 0x20, 0x83, 0x7c, 0x22, -0x27, 0x83, 0xd, 0x77, 0x5c, 0xff, 0x20, 0xf5, -0x53, 0xad, 0x9e, 0xd9, 0x9c, 0x76, 0x6f, 0xc, -0x4b, 0xa9, 0xb9, 0xc0, 0x51, 0xe7, 0x32, 0xd5, - -0x10, 0x01, 0xa7, 0xbf, 0xc5, 0xad, 0x96, 0xb9, -0x40, 0xdc, 0x6f, 0xdb, 0xca, 0xd5, 0xf8, 0x03, -0xe, 0x47, 0x6e, 0xe8, 0x76, 0x4b, 0x87, 0x1e, -0x59, 0x17, 0x99, 0x88, 0x15, 0xe4, 0xc5, 0x4d, - -0xf2, 0x38, 0xb7, 0x1d, 0x30, 0x89, 0xa5, 0xbe, -0x15, 0xb6, 0x9d, 0x8e, 0x8e, 0x85, 0x33, 0x99, -0xe3, 0x6a, 0x8, 0x3f, 0xba, 0xeb, 0x40, 0x8b, -0x17, 0xfc, 0xa8, 0x2e, 0xe0, 0x34, 0x94, 0x4e, - -0x50, 0xb6, 0x8d, 0x45, 0xac, 0x8, 0x10, 0xb1, -0xb7, 0xa4, 0xbe, 0xd6, 0x00, 0xd0, 0x96, 0xc, -0xa3, 0xb5, 0x74, 0xc6, 0xe9, 0xa7, 0xe1, 0x80, -0x6f, 0x5d, 0x71, 0x37, 0x4d, 0xf4, 0xee, 0x9a, - -0xc5, 0x46, 0xa4, 0x21, 0xff, 0xd2, 0x73, 0x47, -0x40, 0xe3, 0xa2, 0xf0, 0xe2, 0x4a, 0xed, 0xde, -0x35, 0xca, 0x92, 0xba, 0xfa, 0x92, 0xa4, 0x21, -0x03, 0x46, 0xb5, 0x28, 0x88, 0xea, 0xcc, 0xd2, - -0x38, 0x95, 0x8d, 0x4a, 0x3a, 0xcf, 0xc2, 0x8c, -0xc3, 0x88, 0x81, 0x5, 0x8d, 0x94, 0x7c, 0xd2, -0xf9, 0x7d, 0x6c, 0x68, 0x6f, 0x69, 0x54, 0xc4, -0x9d, 0xf5, 0x38, 0x9b, 0x40, 0xb6, 0xee, 0xe6, - -0xb, 0x50, 0x76, 0x23, 0x1b, 0x19, 0xf6, 0xf9, -0x1b, 0xf7, 0x63, 0xe4, 0x38, 0xd0, 0x1c, 0xff, -0x32, 0x6, 0x86, 0xa8, 0x89, 0x87, 0x5c, 0xc, -0x23, 0x2c, 0xaa, 0xe, 0x6, 0xa8, 0xfa, 0x91, - -0xfa, 0x93, 0xea, 0xdc, 0x3d, 0xc, 0x4d, 0x84, -0x89, 0x21, 0xc1, 0x3e, 0xb4, 0xa1, 0x30, 0x8e, -0x7e, 0xb, 0xa5, 0x4c, 0x51, 0x11, 0xff, 0x00, -0x95, 0x5a, 0xa4, 0x47, 0x94, 0x2f, 0x43, 0x56, - -0x2c, 0x53, 0xb8, 0x93, 0xf4, 0x38, 0xd7, 0x30, -0x15, 0x73, 0x53, 0xfa, 0xd9, 0x75, 0x4a, 0xda, -0xe5, 0xb, 0xdc, 0xc, 0x01, 0x73, 0x2e, 0x57, -0x1c, 0xdd, 0xf9, 0x9, 0x9e, 0x22, 0xf6, 0x4b, - -0xfd, 0xcd, 0x91, 0x57, 0x7f, 0xb9, 0x3d, 0xd1, -0xb6, 0xc9, 0x25, 0xe5, 0x18, 0x1a, 0x94, 0xe8, -0xe0, 0x52, 0x7d, 0xbe, 0x93, 0x28, 0xf, 0xa1, -0x69, 0x86, 0xc1, 0xb0, 0x47, 0xa4, 0x48, 0xa4, - -0x7d, 0xee, 0x16, 0x67, 0xe8, 0x23, 0x9d, 0xf9, -0xc4, 0xc6, 0x2f, 0xc1, 0x6f, 0x8, 0xa, 0x52, -0x2b, 0xd7, 0x33, 0x40, 0x3a, 0xf7, 0xc0, 0x60, -0x72, 0xa9, 0xf1, 0x34, 0x9e, 0xd8, 0x3b, 0x9c, - -0x7a, 0xc0, 0x2f, 0x2f, 0xe9, 0xae, 0xb2, 0xe1, -0x10, 0x8d, 0x30, 0xd7, 0xb5, 0x4e, 0x49, 0x1c, -0xac, 0xfc, 0x1d, 0x39, 0xc4, 0x36, 0x46, 0xd9, -0x82, 0x2d, 0xc1, 0xec, 0x27, 0xba, 0xe2, 0xea, - -0x3d, 0x9e, 0xfd, 0xe0, 0x81, 0x33, 0xe1, 0x17, -0xda, 0x5a, 0x29, 0x13, 0x03, 0xf0, 0xb5, 0xf, -0xf5, 0x78, 0x37, 0x64, 0xda, 0x20, 0x87, 0xf9, -0xf5, 0xbb, 0xff, 0x9e, 0x9c, 0xf4, 0xcc, 0xb0, - -0xeb, 0x30, 0xcf, 0x10, 0x34, 0xd0, 0xc2, 0x6b, -0x2b, 0xae, 0xc5, 0x8c, 0x1a, 0xf2, 0x1e, 0x19, -0x16, 0xe1, 0x31, 0xc0, 0x77, 0x32, 0x4e, 0x2a, -0x1a, 0x54, 0xb3, 0xbf, 0x52, 0x87, 0xa5, 0xb6, - -0x9e, 0x10, 0xba, 0x1a, 0x2f, 0x49, 0xe9, 0x6, -0xf4, 0x00, 0x84, 0xb8, 0x13, 0x94, 0x91, 0xfb, -0xaf, 0x43, 0x8f, 0x4a, 0xa3, 0x42, 0xce, 0xb7, -0x01, 0xf5, 0x2a, 0xde, 0xad, 0x36, 0x7f, 0xde, - -0x4e, 0xea, 0x64, 0x98, 0x8e, 0x13, 0x95, 0xae, -0xdf, 0xca, 0xa, 0x3f, 0x39, 0x65, 0xda, 0xe4, -0x4c, 0xa4, 0x1d, 0x80, 0x16, 0x25, 0x8b, 0x1e, -0xf4, 0x9e, 0x92, 0x7d, 0xe2, 0xb4, 0x5, 0xd3, - -0x18, 0x11, 0x18, 0x4c, 0xab, 0x71, 0x23, 0xf4, -0xeb, 0x2c, 0xc, 0x82, 0x15, 0x1c, 0x8c, 0xde, -0x24, 0x8d, 0xa1, 0x74, 0xf1, 0xe7, 0x54, 0x7a, -0x10, 0x3c, 0xd3, 0x39, 0x7a, 0x2e, 0x3e, 0x30, - -0x37, 0xc8, 0x39, 0x90, 0xf5, 0xca, 0x5e, 0x4c, -0xc1, 0x79, 0x40, 0x65, 0x97, 0x5d, 0x1a, 0x27, -0xb7, 0x7c, 0x10, 0xb3, 0x50, 0x61, 0x51, 0xc0, -0xe8, 0xac, 0x78, 0x1e, 0xcb, 0x88, 0x01, 0xbd, - -0x7, 0xb0, 0x2e, 0xd4, 0xe8, 0x6, 0xd, 0xb8, -0xb5, 0xa3, 0xe1, 0x54, 0xb6, 0xe7, 0xaf, 0x3a, -0x65, 0xdb, 0x3b, 0x76, 0x5c, 0xdd, 0x83, 0x15, -0xc0, 0x84, 0xf4, 0xda, 0xff, 0xf3, 0x40, 0xc5, - -0x2e, 0xe5, 0xab, 0x73, 0x4b, 0x14, 0xde, 0xb6, -0x5a, 0xfc, 0x3d, 0x77, 0x03, 0x5a, 0xa3, 0x9f, -0x88, 0x69, 0x58, 0xa6, 0x8, 0x87, 0x28, 0x33, -0xa3, 0x34, 0x4b, 0x83, 0x14, 0x8b, 0x1e, 0x50, - -0x9c, 0x6, 0x6b, 0x6a, 0xc1, 0x62, 0x82, 0xab, -0x8f, 0x82, 0xae, 0x3d, 0x91, 0xd7, 0xfd, 0xd5, -0xd2, 0x19, 0x3f, 0x4f, 0xae, 0x1f, 0x01, 0xcc, -0x50, 0x96, 0xfc, 0x79, 0x2f, 0x67, 0xa3, 0xdd, - -0x9b, 0x86, 0x6b, 0xd7, 0xd6, 0x8e, 0x62, 0x26, -0x59, 0x28, 0xd1, 0x9f, 0x25, 0x12, 0xe7, 0xbd, -0x16, 0x7b, 0x22, 0xd3, 0x7c, 0xfe, 0xcd, 0x7e, -0x60, 0x93, 0x59, 0xc9, 0x48, 0xd4, 0xab, 0xd8, - -0x95, 0x29, 0x50, 0xe4, 0x98, 0xe6, 0xb4, 0x4b, -0x41, 0x78, 0xb7, 0x01, 0x5d, 0x88, 0x3e, 0x3d, -0xd4, 0x4a, 0x59, 0x5, 0xc7, 0x8, 0xb9, 0x5c, -0xff, 0xcb, 0x6e, 0x3e, 0x1b, 0xe6, 0xf3, 0x9b, - -0xae, 0x75, 0x86, 0xc, 0x12, 0xb8, 0x5b, 0xb3, -0x62, 0x53, 0xb3, 0xf6, 0xa8, 0xdd, 0xa2, 0xc3, -0x6a, 0xc1, 0x54, 0x19, 0xfb, 0xd8, 0x51, 0x5b, -0x4c, 0x31, 0xc4, 0x58, 0xc6, 0x11, 0x89, 0x18, - -0x73, 0x93, 0xc, 0xda, 0x48, 0x73, 0x3a, 0x5e, -0x67, 0xa, 0xd1, 0x3c, 0x8e, 0xb7, 0xbe, 0x18, -0x1b, 0x84, 0xe5, 0x72, 0x59, 0x19, 0x5f, 0x44, -0x84, 0x41, 0x8a, 0xf5, 0xac, 0xa0, 0xa2, 0x85, - -0xcf, 0x50, 0xb0, 0x73, 0x9a, 0x2b, 0x6, 0x93, -0xaa, 0x26, 0xc4, 0xc7, 0xca, 0x30, 0xb, 0x2e, -0x3e, 0xca, 0xa9, 0xa4, 0x47, 0xe7, 0x44, 0x9f, -0xae, 0x7e, 0xda, 0xc0, 0x4b, 0xb7, 0xa1, 0x74, - -0x78, 0x86, 0xe6, 0xc4, 0x59, 0xbd, 0xb5, 0x41, -0xc0, 0x48, 0x57, 0x4f, 0x5b, 0x6a, 0xda, 0x9d, -0x27, 0xf6, 0xb6, 0x4f, 0xc5, 0x30, 0x94, 0x8e, -0xe3, 0x5d, 0x84, 0x67, 0xd7, 0xd4, 0x79, 0x37, - -0x31, 0x41, 0x4, 0xb0, 0xf0, 0xa8, 0xe3, 0x80, -0xf3, 0x3a, 0x6b, 0x5b, 0x03, 0x9d, 0x41, 0x37, -0x98, 0x3b, 0x03, 0xac, 0x1b, 0xca, 0xe9, 0xe1, -0x91, 0xc, 0x2b, 0x8b, 0x52, 0x7a, 0xf7, 0x6, - -0x4f, 0xdc, 0x6f, 0x6b, 0x9a, 0x2a, 0x88, 0x52, -0xf5, 0x65, 0x11, 0xc9, 0x27, 0x14, 0x90, 0xf6, -0xab, 0x73, 0xe0, 0x71, 0x50, 0x52, 0xb3, 0xb7, -0x27, 0x6e, 0xe7, 0xa, 0x17, 0x7a, 0x7e, 0xb3, - -0xc5, 0x67, 0x79, 0x19, 0xb9, 0xf1, 0x2b, 0x4b, -0x4e, 0x2f, 0xc6, 0xda, 0xee, 0x76, 0x1d, 0xb7, -0x91, 0x66, 0x30, 0x61, 0xa4, 0xca, 0xc3, 0x47, -0x68, 0xba, 0x5b, 0xe8, 0x1c, 0xd9, 0x7c, 0xb8, - -0x22, 0xfd, 0x1a, 0xe0, 0x39, 0x84, 0x8c, 0x9e, -0xb2, 0x1e, 0x5d, 0xbe, 0x86, 0x8d, 0xbb, 0x76, -0x12, 0xd3, 0x9d, 0x7c, 0xa9, 0x2a, 0xa5, 0xae, -0x11, 0xdd, 0x01, 0x96, 0xc6, 0x01, 0x5d, 0x5a, - -0x98, 0x55, 0x5e, 0x5a, 0xd3, 0xc9, 0x10, 0x11, -0x01, 0x62, 0xa7, 0x82, 0x01, 0xd3, 0xea, 0x5e, -0x49, 0x21, 0x54, 0x8e, 0x99, 0x35, 0x95, 0x15, -0x26, 0xfb, 0xbd, 0x82, 0x41, 0x2e, 0x66, 0x03, - -0xd9, 0x2b, 0xed, 0xd9, 0xb4, 0x44, 0x62, 0x4a, -0x11, 0x73, 0x6e, 0x54, 0xab, 0xdd, 0x5c, 0x24, -0x46, 0xdc, 0x47, 0xf, 0x2c, 0xbb, 0x4b, 0x71, -0x6a, 0xbd, 0xd2, 0xf9, 0xbf, 0x6b, 0x23, 0xb1, - -0xdb, 0xe8, 0xd0, 0x45, 0xbf, 0x20, 0x90, 0x9f, -0x89, 0xea, 0x8b, 0x8a, 0xbe, 0x52, 0xd5, 0xe4, -0xb0, 0x68, 0xf5, 0x80, 0x74, 0xad, 0xc, 0xe3, -0x9f, 0xa, 0xee, 0xec, 0x1b, 0x4, 0x7c, 0xf0, - -0x35, 0xf7, 0x80, 0xd7, 0xd8, 0xf3, 0x88, 0xee, -0xfb, 0x9, 0xc9, 0xd3, 0x5, 0x92, 0x77, 0xe3, -0xe3, 0x80, 0xe6, 0x6d, 0x7b, 0xc6, 0xc2, 0xe1, -0xfe, 0x5f, 0x5d, 0x53, 0xc7, 0x94, 0xf8, 0x9c, - -0x5f, 0xad, 0x9c, 0x1a, 0xf5, 0x2, 0xe5, 0xcf, -0x01, 0xe4, 0x87, 0x29, 0xaf, 0xb9, 0xa7, 0x2, -0xcb, 0xe0, 0x57, 0x00, 0xfd, 0x56, 0x35, 0x54, -0xb, 0xb5, 0x71, 0xa0, 0xf3, 0xdc, 0x34, 0x5a, - -0xbd, 0x7c, 0xe0, 0xc6, 0x99, 0x50, 0x58, 0x72, -0x53, 0x5d, 0x90, 0x70, 0x7d, 0x27, 0x6f, 0x99, -0x28, 0x6, 0x80, 0x20, 0x15, 0xd4, 0xcb, 0x7a, -0xb2, 0x6b, 0xd0, 0xe5, 0x14, 0xcf, 0x80, 0x79, - -0x6, 0x81, 0x62, 0x5f, 0x5, 0x2, 0xe6, 0x71, -0x77, 0xcc, 0xaf, 0x29, 0x46, 0x35, 0xe2, 0x20, -0x18, 0xb8, 0x47, 0x7d, 0x72, 0x34, 0x74, 0x3d, -0x19, 0x10, 0x6c, 0x11, 0x73, 0xe9, 0x3b, 0x48, - -0xec, 0xe9, 0x54, 0xc3, 0x4, 0xba, 0xa6, 0x78, -0xa2, 0xeb, 0x54, 0x6d, 0xf, 0x8f, 0xb2, 0x5f, -0x9a, 0xc3, 0x3a, 0xb8, 0x7e, 0x5b, 0x01, 0xac, -0x6b, 0x45, 0x65, 0xf5, 0x9a, 0x43, 0x4a, 0x46, - -0xef, 0x99, 0x9, 0x46, 0xa5, 0xa7, 0x6, 0xa5, -0xc3, 0x54, 0x7, 0xbe, 0x3b, 0x35, 0x4d, 0xdc, -0xc8, 0x8e, 0xa4, 0x44, 0x4a, 0x81, 0xdf, 0xdd, -0x92, 0xa8, 0xee, 0xcf, 0x1a, 0x5b, 0x2c, 0x6d, - -0x2e, 0x3e, 0xce, 0x64, 0xe7, 0x9, 0x9b, 0x23, -0xf6, 0xd8, 0x92, 0xca, 0x60, 0x6b, 0xf0, 0x21, -0xf9, 0x76, 0x4f, 0xf7, 0x56, 0x5, 0xe1, 0x89, -0xd1, 0x83, 0xe9, 0xd3, 0xc3, 0x4a, 0x8f, 0xd8, - -0x3e, 0xd6, 0x1c, 0xda, 0xdf, 0x9, 0x25, 0x7b, -0xf9, 0xc, 0x61, 0x93, 0x21, 0x12, 0x6b, 0xbb, -0x83, 0x2d, 0xfe, 0x3f, 0x81, 0x40, 0x34, 0x1c, -0x3c, 0xb6, 0x93, 0xe6, 0x27, 0x80, 0xfe, 0xde, - -0xbd, 0x53, 0xfb, 0x7c, 0x1c, 0xe5, 0x1e, 0xaa, -0xa0, 0x77, 0xe0, 0x60, 0xcd, 0xb6, 0x81, 0x30, -0xbe, 0x27, 0x59, 0x6a, 0x33, 0x8, 0x58, 0xa1, -0x23, 0x9d, 0x7f, 0x6e, 0x47, 0xf5, 0x45, 0xd9, - -0xa8, 0x7a, 0xc7, 0x01, 0x8, 0x40, 0x4a, 0x66, -0xbe, 0x6d, 0x12, 0xe9, 0xf, 0xc6, 0xca, 0xa5, -0x83, 0xd8, 0xda, 0x3e, 0xe5, 0xb5, 0x3d, 0x78, -0x60, 0x86, 0xdc, 0xfc, 0x9b, 0xd6, 0xb6, 0x33, - -0xd8, 0x2a, 0xa1, 0x5d, 0x1e, 0xc9, 0xab, 0xde, -0x6e, 0x10, 0x00, 0x74, 0x51, 0xa8, 0x5e, 0x94, -0x84, 0x6c, 0xf6, 0x73, 0xfd, 0x7, 0x38, 0xdc, -0x7e, 0x6a, 0x6d, 0xc, 0x50, 0x3f, 0x4, 0x13, - -0x55, 0xdd, 0x03, 0xd3, 0xdc, 0x5f, 0x11, 0x18, -0x97, 0xe9, 0x4a, 0xb5, 0x2b, 0xd, 0x88, 0x69, -0x18, 0x99, 0xc4, 0xe, 0x24, 0x5c, 0xac, 0x7f, -0x49, 0xc9, 0x33, 0xb9, 0xa9, 0xba, 0x6e, 0xc1 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/sigrl.inc deleted file mode 100644 index 52de07b8f1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/sigrl.inc +++ /dev/null @@ -1,878 +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. - ############################################################################*/ - -// sigRL - -// gid -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, - -// version -0x00, 0x00, 0x00, 0x00, - -// n2 -0x00, 0x00, 0x00, 0x32, - -// bk's -0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, -0x33, 0x35, 0x27, 0xd, 0x8, 0xb1, 0xbe, 0x5d, -0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, -0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, -0x56, 0x43, 0xc6, 0x94, 0x67, 0xa6, 0x72, 0xf6, -0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, -0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, -0x90, 0x23, 0x18, 0x8, 0xad, 0x7d, 0xfe, 0xf5, -0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, -0xc2, 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, -0x87, 0x98, 0xbd, 0x72, 0xf9, 0xcf, 0xd, 0x40, -0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, -0x61, 0x9d, 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, -0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, 0x33, 0xad, -0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, -0x98, 0x37, 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b, - -0x71, 0x8a, 0xb5, 0x1, 0x7f, 0x7c, 0x92, 0x9a, -0xa2, 0xc9, 0x81, 0x10, 0xfe, 0xbf, 0xc, 0x53, -0xa4, 0x43, 0xaf, 0x31, 0x74, 0x12, 0x25, 0x60, -0x3e, 0xc0, 0x21, 0xe6, 0x63, 0x9a, 0xd2, 0x67, -0x2d, 0xb5, 0xd5, 0x82, 0xc4, 0x49, 0x29, 0x51, -0x42, 0x8f, 0xe0, 0xe, 0xd1, 0x73, 0x27, 0xf5, -0x77, 0x16, 0x4, 0x40, 0x8a, 0x0, 0xe, 0x3a, -0x5d, 0x37, 0x42, 0xd3, 0x8, 0x40, 0xbd, 0x69, -0xf7, 0x5f, 0x74, 0x21, 0x50, 0xf4, 0xce, 0xfe, -0xd9, 0xdd, 0x97, 0x6c, 0xa8, 0xa5, 0x60, 0x6b, -0xf8, 0x1b, 0xba, 0x2, 0xb2, 0xca, 0x5, 0x44, -0x9b, 0xb1, 0x5e, 0x3a, 0xa4, 0x35, 0x7a, 0x51, -0xfa, 0xcf, 0xa4, 0x4, 0xe9, 0xf3, 0xbf, 0x38, -0xd4, 0x24, 0x9, 0x52, 0xf3, 0x58, 0x3d, 0x9d, -0x4b, 0xb3, 0x37, 0x4b, 0xec, 0x87, 0xe1, 0x64, -0x60, 0x3c, 0xb6, 0xf7, 0x7b, 0xff, 0x40, 0x11, - -0x6e, 0x22, 0xaa, 0x10, 0x84, 0x58, 0x8b, 0xff, -0xd8, 0x37, 0x8, 0xa9, 0xe9, 0xdb, 0xf6, 0x1f, -0x69, 0x10, 0x95, 0x6c, 0xbf, 0xd, 0x11, 0x48, -0x6f, 0x1b, 0x3c, 0x62, 0x46, 0x13, 0x89, 0x13, -0x5f, 0xa1, 0x3, 0x62, 0xed, 0x62, 0xdf, 0x3d, -0xbf, 0xcd, 0xb7, 0x41, 0x48, 0x81, 0x3, 0x9f, -0x54, 0xa, 0xe, 0xb3, 0x35, 0xf9, 0xde, 0x24, -0xba, 0x6d, 0x4c, 0x7f, 0xfc, 0xc1, 0xb4, 0xce, -0x6d, 0xa1, 0x73, 0x7c, 0xaa, 0xb, 0xad, 0x2, -0xd6, 0x37, 0x85, 0xe, 0xbb, 0x48, 0x11, 0x38, -0xc4, 0xaa, 0x1b, 0xf, 0xcf, 0xc1, 0x9c, 0x26, -0xcc, 0x95, 0xc2, 0x5b, 0x49, 0x9, 0x3d, 0xe9, -0x7d, 0xce, 0xc7, 0xa6, 0x4, 0x3e, 0x7c, 0x9e, -0x28, 0xde, 0x8, 0x11, 0xe, 0x61, 0x3b, 0xc0, -0x9c, 0x6b, 0x58, 0x23, 0xe6, 0x40, 0x7b, 0xbd, -0xb8, 0x72, 0xf, 0xe0, 0xee, 0xcf, 0xba, 0xb4, - -0xc4, 0xff, 0xaf, 0x48, 0x15, 0xda, 0x60, 0x40, -0xcc, 0xd7, 0xf2, 0x68, 0xf7, 0xe2, 0x70, 0x12, -0x8d, 0x15, 0xa5, 0xb7, 0xe6, 0x4c, 0x23, 0xea, -0x4d, 0x8a, 0x51, 0x6, 0x67, 0x3, 0x4c, 0x83, -0x6f, 0x28, 0x67, 0xcf, 0x63, 0x46, 0x3e, 0x8a, -0x45, 0x9f, 0xed, 0x1a, 0xde, 0xa7, 0xad, 0xb2, -0x2b, 0xf, 0x8b, 0xab, 0x7c, 0x70, 0xff, 0xc3, -0xa8, 0x6e, 0x8c, 0xaa, 0xb1, 0xf6, 0x20, 0xe3, -0xb9, 0xf1, 0xc3, 0x3d, 0x5, 0x6a, 0x1e, 0x26, -0x2d, 0xf4, 0xd, 0xe4, 0x53, 0x63, 0x67, 0x23, -0x48, 0xa8, 0x1, 0xa8, 0xee, 0xe1, 0x5f, 0x64, -0xe3, 0x2c, 0x71, 0xe2, 0x10, 0x82, 0x0, 0x52, -0xd7, 0x74, 0x87, 0xff, 0x1c, 0x0, 0x19, 0xe6, -0x4d, 0x15, 0x91, 0x6d, 0xf3, 0x38, 0x3b, 0xee, -0xf3, 0xd5, 0xd1, 0xc7, 0x6d, 0xd9, 0x8e, 0x55, -0x70, 0x90, 0xb0, 0xb, 0x3c, 0x4a, 0x67, 0x19, - -0x4f, 0x98, 0x92, 0xf9, 0x18, 0x38, 0xf5, 0xb4, -0xf7, 0x2f, 0xa7, 0x21, 0x71, 0x52, 0x27, 0xd0, -0x57, 0x4f, 0x9c, 0x30, 0xe, 0xb2, 0x27, 0xce, -0xd7, 0xb2, 0x9f, 0xc0, 0xf6, 0xc3, 0xb0, 0x7c, -0x40, 0x18, 0x75, 0x4a, 0xde, 0xb0, 0x9f, 0x46, -0x8a, 0x5a, 0xeb, 0x4f, 0xcb, 0x5e, 0x60, 0xf5, -0xca, 0xf4, 0x98, 0xaf, 0x62, 0x9b, 0x7e, 0x10, -0xda, 0xba, 0x2f, 0x47, 0x64, 0xf2, 0xc0, 0x84, -0x19, 0x75, 0xe0, 0xe4, 0xff, 0x20, 0xda, 0x7d, -0xe5, 0xd, 0xc8, 0xf8, 0xe3, 0x83, 0x61, 0x19, -0x17, 0xf1, 0xa9, 0x1b, 0xff, 0x39, 0x79, 0x88, -0x1, 0xfb, 0xe7, 0x23, 0xd2, 0xac, 0xe0, 0x49, -0x12, 0x2a, 0x38, 0xb4, 0x7c, 0xc2, 0x1b, 0x88, -0x5f, 0x68, 0x32, 0x11, 0xd9, 0xfd, 0xdc, 0x65, -0x2, 0xb3, 0x74, 0x2c, 0x13, 0xf2, 0xd8, 0xf1, -0x45, 0xc5, 0xd1, 0xf4, 0xa3, 0x38, 0x81, 0x92, - -0x4f, 0xde, 0x62, 0x9d, 0xde, 0xfb, 0x23, 0x29, -0x9c, 0x4, 0xed, 0x19, 0xa8, 0x86, 0x5f, 0xed, -0x99, 0x5d, 0xc0, 0xe, 0xcf, 0x2c, 0x2e, 0x27, -0x93, 0x91, 0x47, 0x75, 0xa5, 0xf3, 0x87, 0x99, -0x15, 0x47, 0xb4, 0xee, 0x79, 0xda, 0xf9, 0x7a, -0xd9, 0x8d, 0x67, 0xf2, 0xac, 0xe5, 0xc8, 0x30, -0xbe, 0xa2, 0xee, 0xe1, 0x85, 0x35, 0x93, 0xab, -0xf1, 0x46, 0xe, 0xb4, 0x4c, 0xa3, 0xe0, 0x9b, -0xb0, 0x8d, 0x54, 0x5b, 0xa8, 0x53, 0xbb, 0xd5, -0x9e, 0xc0, 0xa9, 0xd4, 0xae, 0x46, 0x4c, 0x1a, -0x1, 0xac, 0x80, 0x92, 0xee, 0x46, 0x39, 0xad, -0x69, 0x9b, 0x8b, 0x15, 0xc9, 0xa3, 0x88, 0x24, -0x96, 0x32, 0x2b, 0xae, 0xc8, 0xdb, 0x98, 0xc6, -0xbd, 0x32, 0xe9, 0x12, 0xbb, 0xb9, 0x5d, 0xa5, -0xfc, 0x4f, 0x2, 0xde, 0x64, 0xc5, 0x94, 0x15, -0x25, 0x19, 0x44, 0xc0, 0xa, 0xfe, 0xb3, 0x40, - -0xf, 0x8, 0xd2, 0x35, 0x1a, 0xca, 0x75, 0xb0, -0xdf, 0x4a, 0xc1, 0x5f, 0x93, 0x1f, 0x86, 0x7, -0x78, 0x4b, 0x31, 0x2, 0xb6, 0xe6, 0x9e, 0x93, -0x30, 0x19, 0x7e, 0x2f, 0x67, 0x40, 0xde, 0x3b, -0x71, 0x32, 0x71, 0x1a, 0x35, 0x2c, 0xe4, 0xb8, -0xeb, 0xf4, 0x9, 0xf1, 0xd2, 0x8, 0xcd, 0x15, -0xb3, 0xdf, 0xd, 0xf5, 0xe8, 0x3a, 0x65, 0x3e, -0xd6, 0x46, 0x87, 0xd8, 0x91, 0x70, 0xe, 0x73, -0x62, 0x11, 0xd6, 0x99, 0x36, 0xa5, 0xb7, 0x40, -0x98, 0xb1, 0x74, 0xfb, 0xbd, 0x99, 0xae, 0xfb, -0x5f, 0xac, 0xe5, 0x46, 0xb7, 0x71, 0x22, 0xd, -0xfa, 0xe2, 0x20, 0x8c, 0x1, 0x58, 0x61, 0x13, -0xd, 0xc, 0x33, 0x49, 0x64, 0xd4, 0x51, 0xe0, -0x13, 0xea, 0xa5, 0xe5, 0xc3, 0x2a, 0x7, 0x8d, -0x6f, 0x6e, 0x35, 0x28, 0x55, 0x82, 0xdd, 0x75, -0x5b, 0xab, 0x8e, 0xfe, 0x2a, 0x42, 0x3f, 0xd2, - -0x15, 0x50, 0xd8, 0xf6, 0x51, 0xc2, 0xf3, 0x9f, -0x4, 0xca, 0xb5, 0x5e, 0x8b, 0x4f, 0xc1, 0x2b, -0x6a, 0x19, 0x99, 0x32, 0x57, 0x88, 0xf5, 0xbf, -0x9c, 0x20, 0x37, 0x70, 0x29, 0x35, 0x8a, 0x5c, -0x74, 0x3c, 0x72, 0xe9, 0x47, 0x31, 0x2d, 0xd2, -0x23, 0xa5, 0x5b, 0xbb, 0x5, 0x36, 0x62, 0x57, -0x60, 0x98, 0xb6, 0x75, 0xc, 0x5a, 0xa8, 0x9b, -0x32, 0x47, 0xe6, 0x7e, 0x18, 0x67, 0xe6, 0x35, -0x8, 0x96, 0x14, 0x94, 0xd3, 0x86, 0xae, 0x25, -0x13, 0x66, 0xf0, 0xee, 0x6, 0x1b, 0x6e, 0x37, -0xba, 0xcd, 0x96, 0xa7, 0x35, 0x5c, 0x5b, 0xdd, -0x83, 0xdc, 0xb8, 0xa1, 0x22, 0x38, 0x66, 0x8c, -0xeb, 0xcd, 0x62, 0x9a, 0xc4, 0xf1, 0xc2, 0x4e, -0x2a, 0xf6, 0x5, 0x94, 0xfe, 0xa5, 0x33, 0xd7, -0xca, 0x59, 0x95, 0x72, 0xf1, 0x77, 0xe9, 0x48, -0x11, 0xe5, 0x78, 0x7a, 0x89, 0x98, 0xab, 0x1d, - -0x9d, 0x9e, 0xb0, 0x78, 0x78, 0xa4, 0xf, 0x23, -0xe9, 0x68, 0xb5, 0x63, 0xa, 0x59, 0x9e, 0xb7, -0xed, 0x92, 0x46, 0xf3, 0x52, 0x4b, 0x3b, 0x38, -0xec, 0xeb, 0x4a, 0xcd, 0xb5, 0x61, 0xf1, 0xc0, -0xe, 0xc8, 0x99, 0xc6, 0x8f, 0xfa, 0x7b, 0xcf, -0x4a, 0x58, 0xa5, 0x58, 0x51, 0x88, 0xe9, 0xe2, -0xb9, 0xbe, 0x2f, 0x9b, 0xa4, 0x4c, 0x16, 0x1b, -0xbe, 0x9e, 0xc6, 0x55, 0xd9, 0xe9, 0x2c, 0x77, -0x28, 0xdc, 0x7c, 0x35, 0x19, 0x3c, 0x19, 0x40, -0x6c, 0x6b, 0x28, 0x77, 0x37, 0x98, 0x15, 0x7f, -0xa8, 0xe9, 0x3e, 0x99, 0x66, 0xed, 0x7a, 0xe6, -0x79, 0x7c, 0xf9, 0x27, 0x75, 0x9, 0xb9, 0xc0, -0xd8, 0x88, 0xc2, 0xff, 0x79, 0x90, 0x4e, 0x1d, -0x61, 0x5c, 0x88, 0x81, 0x2, 0xbf, 0x4b, 0x2d, -0x2f, 0x18, 0x2a, 0xfb, 0x4, 0x5c, 0x1c, 0x17, -0xae, 0xd4, 0x6e, 0x97, 0x44, 0x61, 0xfd, 0x95, - -0x23, 0x91, 0x6e, 0xe5, 0x8a, 0xc4, 0x97, 0x21, -0xc9, 0x21, 0x6, 0x8d, 0xa3, 0xbe, 0x7f, 0x7a, -0xf5, 0xf8, 0x68, 0x86, 0xa, 0xc6, 0xf4, 0x57, -0x3e, 0x3f, 0xed, 0x48, 0xa1, 0xdf, 0xec, 0x77, -0x78, 0x82, 0x82, 0x7, 0xf4, 0x58, 0xd8, 0x9a, -0x8a, 0x52, 0x57, 0x69, 0x69, 0x2b, 0x9c, 0xf9, -0x85, 0x94, 0x53, 0x78, 0x2c, 0xa2, 0x21, 0x12, -0xc4, 0x50, 0xfe, 0xd3, 0x7d, 0x89, 0xf, 0x5f, -0x4c, 0xa5, 0xbc, 0x1d, 0x74, 0x99, 0xc7, 0x86, -0xc5, 0xbd, 0x25, 0xc0, 0xa1, 0x2, 0x99, 0xa4, -0xa8, 0xdf, 0x41, 0x9e, 0xed, 0xa9, 0x71, 0x0, -0x7f, 0xc7, 0x81, 0xd4, 0xbf, 0x70, 0xf6, 0x59, -0x77, 0x29, 0x44, 0x86, 0xae, 0xa9, 0xa, 0x3f, -0xc6, 0x7a, 0x4e, 0xe6, 0x5, 0x8c, 0x0, 0x6d, -0x4d, 0xc4, 0x82, 0xfc, 0x41, 0x3f, 0x11, 0xcb, -0x90, 0x9c, 0xee, 0xdf, 0x2, 0xc3, 0x26, 0xa2, - -0x32, 0x2e, 0xff, 0x9d, 0xa5, 0x5a, 0xee, 0xff, -0x5d, 0x42, 0xf2, 0x8b, 0xf1, 0xb6, 0x46, 0xe8, -0x93, 0x21, 0x8a, 0x1f, 0xc, 0x1d, 0x5e, 0x63, -0x36, 0xd0, 0x45, 0x22, 0x24, 0x74, 0x38, 0x5b, -0x5e, 0x22, 0xcd, 0xe4, 0x37, 0xa1, 0x9c, 0xe0, -0x34, 0xf7, 0x78, 0x5e, 0x79, 0x98, 0x56, 0xe8, -0xe5, 0xd5, 0x49, 0x1f, 0x1b, 0x3c, 0xf5, 0x8f, -0xd4, 0xa1, 0x8d, 0x4a, 0x4b, 0x71, 0xa, 0xb4, -0x4e, 0xde, 0x7e, 0x45, 0xa2, 0x59, 0xb3, 0x5, -0x82, 0xfb, 0x2, 0x23, 0xfe, 0x60, 0xf8, 0xec, -0xb7, 0xc7, 0xff, 0x23, 0x7e, 0xee, 0xc5, 0x60, -0xf, 0x7b, 0xc6, 0xb6, 0x90, 0x9c, 0x90, 0x67, -0xf9, 0x8c, 0x3, 0xf, 0x2a, 0x91, 0xfc, 0x57, -0x91, 0x1c, 0x77, 0xf4, 0xdd, 0xe7, 0x83, 0x68, -0x3, 0xf, 0x9b, 0xfd, 0x7a, 0xf0, 0x9a, 0xfc, -0x13, 0xe0, 0xae, 0x11, 0x26, 0xfe, 0x5f, 0xab, - -0xb0, 0xe, 0x1a, 0xa7, 0x1, 0x3d, 0xfa, 0xd4, -0xc2, 0x96, 0xce, 0x18, 0x53, 0x5f, 0x82, 0xe4, -0x30, 0x91, 0x9, 0x6, 0x68, 0xf, 0x94, 0x20, -0xb0, 0x58, 0x65, 0x8, 0xb5, 0xce, 0x69, 0x34, -0x5, 0x6c, 0x3, 0xea, 0x92, 0x96, 0xa9, 0xf0, -0x23, 0xb4, 0x93, 0xbc, 0xf8, 0x99, 0xd6, 0xda, -0x97, 0x3e, 0xea, 0x92, 0x70, 0x9b, 0x7a, 0xc6, -0x8c, 0xaf, 0x69, 0x3e, 0x5b, 0x5a, 0xd9, 0x59, -0x4a, 0x59, 0xa5, 0xbe, 0x29, 0xf1, 0x79, 0x79, -0x56, 0x2d, 0x92, 0x7e, 0x56, 0xe9, 0x56, 0x8b, -0x71, 0xac, 0xf7, 0xe9, 0xc1, 0x59, 0x28, 0xe1, -0x3f, 0x96, 0x4d, 0x28, 0xc6, 0x83, 0xbf, 0xf3, -0xb, 0x8, 0x26, 0x39, 0x90, 0x22, 0x1e, 0x93, -0xb2, 0x50, 0xa4, 0x4e, 0xa6, 0xcb, 0xa, 0x28, -0xa7, 0xb9, 0xe5, 0x1a, 0x84, 0x8d, 0x98, 0xc1, -0x8f, 0x7d, 0xc5, 0xe3, 0xea, 0xe6, 0x16, 0x83, - -0xed, 0xfc, 0x46, 0x11, 0x79, 0x69, 0xbe, 0x73, -0x6e, 0x86, 0xa0, 0x58, 0x7, 0x14, 0x8, 0x92, -0x9e, 0x26, 0x3, 0x72, 0xb1, 0x5b, 0x85, 0x5c, -0x1f, 0x96, 0xfb, 0x59, 0x52, 0x48, 0x99, 0x7d, -0x34, 0xd6, 0x68, 0x62, 0x3, 0xf3, 0x65, 0xcf, -0x64, 0x78, 0x50, 0xc3, 0xe5, 0xbb, 0x57, 0x4e, -0xc1, 0xce, 0xdf, 0x0, 0x63, 0x57, 0xd2, 0x6, -0x75, 0x3d, 0x7b, 0x0, 0xa6, 0x7f, 0x88, 0x1c, -0x96, 0x47, 0x7, 0xa3, 0x9, 0x61, 0x79, 0xed, -0x86, 0x1e, 0xd9, 0xc2, 0xf0, 0x73, 0x6, 0x2b, -0x74, 0x57, 0x5f, 0x5c, 0xea, 0xfc, 0x1a, 0xdf, -0x67, 0x98, 0xa4, 0x72, 0x3f, 0x73, 0x10, 0x8a, -0x9b, 0xd1, 0xbf, 0x8e, 0x22, 0x5b, 0x7d, 0x1e, -0xc6, 0x8a, 0x9b, 0x6b, 0xbd, 0xdb, 0x43, 0x33, -0xfb, 0x30, 0xf2, 0x24, 0xda, 0x2f, 0x54, 0xea, -0xfc, 0xcc, 0x9, 0x98, 0x31, 0xc7, 0xfd, 0x3a, - -0xf1, 0xea, 0x2c, 0xbc, 0x2d, 0xfe, 0xfd, 0xb1, -0x86, 0x1c, 0x3, 0x10, 0x59, 0xa5, 0x66, 0x5c, -0xc2, 0x5e, 0x94, 0x23, 0x12, 0x3d, 0x52, 0x75, -0x95, 0x5b, 0xa2, 0xaf, 0xf0, 0x11, 0x83, 0x9a, -0x4, 0x96, 0xba, 0xaa, 0x6f, 0x5c, 0x26, 0x15, -0x43, 0xd4, 0xc5, 0xbc, 0x74, 0xa9, 0xbf, 0xd8, -0x5e, 0x92, 0x55, 0xa, 0x2e, 0xb6, 0xcf, 0xe6, -0x6f, 0x11, 0x44, 0xf3, 0x39, 0x32, 0x69, 0xc8, -0xe1, 0x74, 0x50, 0x34, 0x62, 0x14, 0x20, 0xd3, -0xc2, 0xc8, 0x9c, 0x4e, 0x58, 0xb, 0xad, 0x7c, -0xc0, 0xf5, 0xe8, 0xfe, 0x35, 0xd5, 0x2b, 0xb0, -0x24, 0x83, 0x77, 0x1d, 0x69, 0x7a, 0x29, 0xd8, -0x3c, 0x4d, 0xdf, 0xe5, 0x5b, 0x4c, 0xc5, 0x86, -0xf2, 0xf8, 0x6b, 0x4e, 0x44, 0xad, 0xae, 0x92, -0xa5, 0x24, 0xdd, 0x54, 0x66, 0x75, 0x83, 0x4a, -0x89, 0xea, 0xc6, 0xef, 0xc6, 0xfb, 0xbd, 0x85, - -0xf8, 0x5b, 0xa, 0xc1, 0xf2, 0x3d, 0xbc, 0x3c, -0xb7, 0x59, 0x5d, 0xbf, 0xac, 0x28, 0xd7, 0x99, -0xbb, 0x95, 0x18, 0x98, 0x3d, 0xf6, 0xbd, 0x5a, -0x35, 0xb2, 0x60, 0x97, 0x12, 0x8, 0xfd, 0x48, -0xc, 0xfb, 0xf3, 0x9e, 0x6, 0x8, 0x22, 0xa5, -0xa4, 0x92, 0xdb, 0xd4, 0x67, 0x85, 0xb2, 0x84, -0x32, 0x6a, 0x45, 0xed, 0x5c, 0x63, 0x16, 0xe2, -0xb1, 0x9b, 0xb9, 0x6a, 0x15, 0xd4, 0x53, 0x65, -0xda, 0x4d, 0xac, 0xe7, 0xb7, 0x43, 0x2b, 0x1a, -0x0, 0xaa, 0x62, 0xfd, 0xc, 0x3e, 0xed, 0xcc, -0xb8, 0x25, 0x4d, 0x61, 0x12, 0xe5, 0xf6, 0x4c, -0x79, 0xe, 0x7e, 0xe4, 0x88, 0x32, 0xf9, 0x88, -0xd2, 0xd0, 0xd2, 0xf7, 0x83, 0xb0, 0xa3, 0xc1, -0xf0, 0x1e, 0x43, 0x8c, 0x1b, 0xc5, 0xc0, 0xf7, -0x39, 0x5d, 0x8, 0x79, 0xf6, 0xb1, 0x59, 0x33, -0x94, 0xcd, 0xee, 0xcd, 0xd, 0x13, 0x11, 0xbd, - -0xba, 0x7b, 0x86, 0x3d, 0x31, 0x42, 0x89, 0xe1, -0xde, 0xf9, 0xc0, 0x79, 0x94, 0x8, 0x93, 0xc3, -0x45, 0xd5, 0xba, 0x55, 0x77, 0x66, 0x56, 0xce, -0xdc, 0xbc, 0x50, 0x96, 0x49, 0xe2, 0xd1, 0xf9, -0x20, 0xc1, 0x88, 0x8f, 0xe0, 0xd3, 0xaf, 0xc1, -0xe4, 0xdf, 0x7c, 0xa2, 0xce, 0x92, 0xd1, 0x1e, -0xd1, 0xbb, 0xe0, 0x26, 0xaf, 0x1f, 0x36, 0x40, -0x8c, 0x22, 0xca, 0xe1, 0xe, 0x2f, 0x5d, 0x90, -0x5a, 0x9b, 0x88, 0x91, 0x1f, 0x35, 0x74, 0xd6, -0x13, 0x6f, 0xd1, 0xfe, 0xf6, 0x4, 0x80, 0xba, -0x15, 0x27, 0x12, 0x27, 0x6a, 0x6, 0xf2, 0x94, -0xeb, 0xd6, 0xf3, 0x1d, 0x89, 0x2f, 0xac, 0xb0, -0x68, 0x2e, 0x8a, 0x51, 0x3d, 0x4e, 0xfc, 0xf6, -0x6f, 0xc2, 0x24, 0x36, 0x0, 0x1, 0x34, 0xd6, -0xa6, 0x35, 0x7b, 0x4b, 0xd1, 0x4a, 0x3f, 0xd1, -0x8b, 0x44, 0xb, 0xe1, 0xe6, 0x35, 0x22, 0xdf, - -0x80, 0x71, 0xf1, 0xef, 0x8d, 0x26, 0x7e, 0x30, -0x4e, 0x47, 0xde, 0xcf, 0x64, 0xdd, 0x28, 0xbe, -0x1b, 0xbf, 0x95, 0x1b, 0x54, 0xda, 0x36, 0xad, -0xf0, 0x9b, 0x92, 0x9e, 0x35, 0x74, 0x93, 0xd0, -0x14, 0x8, 0x82, 0xfe, 0x29, 0xd7, 0xa1, 0x50, -0x3, 0xc2, 0x21, 0xf3, 0x20, 0xa8, 0x53, 0x32, -0xd9, 0x23, 0x6d, 0x9e, 0x9c, 0xb8, 0x93, 0x9a, -0x8c, 0xb3, 0xa3, 0x69, 0xa6, 0x33, 0xba, 0x92, -0x8, 0x96, 0xc5, 0x84, 0x89, 0x94, 0x2c, 0x81, -0x3e, 0xe2, 0xd9, 0x57, 0x63, 0x8a, 0x89, 0x78, -0x14, 0x17, 0x46, 0xac, 0x26, 0x21, 0x8f, 0xb, -0x7, 0x4d, 0x5f, 0xff, 0xc1, 0xa5, 0xad, 0xbd, -0xf2, 0x62, 0x79, 0x59, 0x56, 0x9a, 0x94, 0xd5, -0xfe, 0x50, 0xba, 0xba, 0x6f, 0xd7, 0xb, 0xf, -0xea, 0x9e, 0x49, 0xbb, 0x4, 0x5f, 0x2b, 0x3c, -0x81, 0xe0, 0xab, 0xcb, 0xa6, 0x64, 0x7a, 0x2b, - -0x89, 0xfd, 0x2b, 0x3e, 0x3b, 0xc4, 0x15, 0x91, -0x6c, 0x10, 0x47, 0x4a, 0xd4, 0x8d, 0xde, 0x36, -0x3f, 0xbf, 0x3e, 0x70, 0xb3, 0x83, 0xb, 0x13, -0xf2, 0x73, 0xa7, 0xe6, 0xfb, 0xc5, 0x4f, 0xbc, -0xe, 0xc8, 0xc, 0xee, 0x61, 0x7b, 0x71, 0xce, -0x29, 0xb9, 0xa6, 0xb8, 0xee, 0xbc, 0x27, 0x76, -0x4a, 0x60, 0x2d, 0x11, 0xf, 0x64, 0x8c, 0x7, -0x27, 0x6, 0xd8, 0x4e, 0x75, 0xeb, 0x98, 0x10, -0x86, 0x49, 0x6c, 0x2d, 0x5f, 0xc, 0x15, 0xb0, -0x35, 0x37, 0x29, 0xe5, 0xbd, 0xa9, 0xba, 0xea, -0x3e, 0x4d, 0xc7, 0xd0, 0xdd, 0x1c, 0x57, 0x17, -0xe5, 0xb7, 0x16, 0x46, 0x70, 0x1e, 0x47, 0x75, -0x29, 0x2c, 0xd, 0x39, 0x85, 0xe8, 0xdf, 0xad, -0x74, 0x2e, 0xf1, 0xda, 0x63, 0x9, 0xdc, 0x32, -0xb8, 0x99, 0x66, 0xb1, 0x0, 0xc, 0x81, 0x5d, -0x6f, 0x2b, 0xd4, 0xb4, 0xbf, 0xbc, 0x70, 0x3e, - -0x2c, 0xef, 0xd7, 0x19, 0xac, 0x86, 0x1e, 0xbc, -0x99, 0xf9, 0xe, 0x18, 0xb1, 0x5b, 0x6, 0x22, -0x67, 0xcb, 0x1a, 0x81, 0xb6, 0x96, 0x53, 0xf, -0x31, 0xb5, 0x1d, 0x6c, 0xd2, 0x4a, 0xf8, 0x4b, -0x3b, 0x8a, 0x4c, 0x30, 0x4e, 0x3c, 0xde, 0xc9, -0x14, 0x63, 0x5a, 0xe1, 0x32, 0x4a, 0x66, 0x88, -0x67, 0x93, 0x7c, 0xf9, 0xbe, 0x5d, 0x84, 0x4, -0x28, 0x56, 0x21, 0xd4, 0x33, 0x6, 0x79, 0x30, -0xd5, 0x17, 0xd5, 0x30, 0x63, 0x7c, 0x23, 0x67, -0x3d, 0x30, 0x66, 0x63, 0x5d, 0xd9, 0xde, 0x20, -0xd9, 0xfa, 0xcc, 0x13, 0x5c, 0x45, 0xef, 0xd8, -0x83, 0xdd, 0xeb, 0x7e, 0xe2, 0x13, 0x1a, 0x74, -0xe4, 0xad, 0x46, 0xfa, 0x33, 0x7, 0xe2, 0xa7, -0x57, 0xf5, 0x86, 0xa1, 0xe6, 0xce, 0x12, 0x5b, -0x21, 0xff, 0x43, 0x3d, 0x70, 0xf1, 0x59, 0x4b, -0x53, 0x1c, 0xf, 0x56, 0x5e, 0xc0, 0x78, 0xd7, - -0x30, 0x32, 0xbe, 0xcb, 0xdf, 0x3c, 0xce, 0xb5, -0xbe, 0x2e, 0x6c, 0x52, 0xd2, 0x74, 0x7e, 0x2e, -0x84, 0x65, 0xcb, 0xfd, 0x90, 0x43, 0x60, 0x10, -0x88, 0xa1, 0x4f, 0x63, 0xa1, 0x54, 0x7d, 0xbe, -0x5e, 0x40, 0xbf, 0x7a, 0x77, 0x6d, 0xa, 0xca, -0xa4, 0xaf, 0xbc, 0xe7, 0xe3, 0x85, 0xa7, 0x9c, -0xcd, 0x2a, 0xde, 0xdc, 0xce, 0x29, 0x61, 0x0, -0x9e, 0x89, 0x5, 0xf4, 0xf3, 0x6f, 0xb8, 0x3b, -0xf6, 0x8c, 0x58, 0xd3, 0x43, 0x96, 0x10, 0x23, -0x5a, 0xff, 0x3b, 0xc7, 0x7, 0x81, 0xdf, 0x53, -0xda, 0x5e, 0x26, 0x82, 0xe3, 0xe7, 0xb0, 0xd9, -0xca, 0x56, 0x71, 0xc6, 0x5, 0x1c, 0x9b, 0x7a, -0x8e, 0x11, 0x16, 0xfd, 0x5e, 0x22, 0x9a, 0xd7, -0x9e, 0x5e, 0x43, 0x8f, 0x8f, 0xe0, 0x2a, 0x7d, -0xc0, 0x21, 0xc4, 0xf3, 0x3b, 0x42, 0xb, 0x44, -0x7b, 0xac, 0x24, 0xf, 0x8b, 0x4c, 0x65, 0xd5, - -0xdf, 0x8f, 0x1, 0xec, 0xe, 0xa9, 0x96, 0x5f, -0x91, 0x94, 0x83, 0x69, 0x8f, 0x9, 0xfb, 0x59, -0x6, 0xa9, 0xd6, 0xa0, 0xa3, 0x8b, 0xb2, 0xb1, -0xc8, 0xcd, 0xc1, 0xb1, 0xdf, 0xb0, 0x50, 0x80, -0x6b, 0xed, 0x99, 0x37, 0x3b, 0x69, 0x36, 0x9c, -0xd2, 0xc6, 0xb0, 0x44, 0x3f, 0x89, 0x4, 0x15, -0x6a, 0xe1, 0xde, 0xd, 0x8c, 0x27, 0x81, 0x9b, -0xb9, 0xcf, 0xdc, 0x8c, 0x9a, 0xdd, 0xf0, 0x8e, -0xed, 0x6c, 0xe4, 0xfa, 0x11, 0xbf, 0xef, 0x54, -0x83, 0xed, 0x8, 0xf1, 0x9a, 0x5a, 0x1f, 0xf, -0xf6, 0xa0, 0xd4, 0xd6, 0x1d, 0x0, 0xca, 0x93, -0x8d, 0x33, 0x15, 0x93, 0x38, 0x2f, 0x24, 0xed, -0xd0, 0xe7, 0x16, 0x50, 0x9c, 0xf, 0x82, 0x6f, -0xf1, 0xd1, 0x10, 0x24, 0xbc, 0x21, 0x41, 0x26, -0x2d, 0x2b, 0xa8, 0xce, 0x34, 0xe4, 0x7c, 0x55, -0x2c, 0x8b, 0x30, 0xa2, 0xbe, 0x5b, 0x47, 0xa3, - -0x1d, 0xa0, 0xf4, 0xc, 0xa4, 0xf8, 0x4c, 0x5f, -0x9a, 0x97, 0xda, 0xca, 0x11, 0x5d, 0x78, 0xef, -0x4e, 0x97, 0x71, 0xc5, 0xd7, 0x48, 0xa8, 0x68, -0x3e, 0xfc, 0x6f, 0xc2, 0x29, 0x2f, 0x62, 0x80, -0x72, 0x58, 0xbf, 0x54, 0xc1, 0x86, 0x23, 0x11, -0xa2, 0x49, 0xa3, 0xf7, 0x19, 0x1b, 0xd6, 0xb1, -0x50, 0xca, 0x1c, 0x1a, 0x7f, 0xb7, 0xd4, 0x15, -0xc8, 0x88, 0x11, 0xf2, 0xc1, 0x53, 0x3b, 0xac, -0x2, 0xef, 0x3, 0x67, 0xea, 0x3d, 0x69, 0x40, -0xa6, 0x76, 0xd7, 0x20, 0x8d, 0x9b, 0x94, 0x54, -0x5f, 0x72, 0x32, 0xd9, 0x79, 0x22, 0xe, 0x63, -0x0, 0x86, 0x5f, 0xba, 0x4, 0xf4, 0xd2, 0xb3, -0xa, 0xbe, 0x23, 0x30, 0x9d, 0x44, 0x97, 0x50, -0x83, 0x74, 0x45, 0x33, 0x12, 0x60, 0x1, 0xe2, -0x95, 0x1b, 0x7e, 0xd, 0x78, 0x3f, 0xa0, 0x9d, -0xe0, 0x72, 0xfa, 0x9a, 0x6a, 0xc3, 0x7e, 0x47, - -0x5f, 0x32, 0x87, 0x6c, 0x2d, 0x88, 0xd8, 0x57, -0x9, 0x43, 0x81, 0xc5, 0x76, 0xe7, 0x67, 0x44, -0x19, 0x41, 0xea, 0x76, 0xdc, 0xd5, 0xd6, 0x38, -0x43, 0x59, 0xa4, 0xda, 0x13, 0xd1, 0x8f, 0xa0, -0x42, 0x8f, 0xf9, 0x64, 0x2f, 0x5a, 0x3e, 0x9c, -0xee, 0x22, 0x2d, 0xe0, 0xcf, 0x20, 0x89, 0x6, -0x57, 0x1, 0x17, 0x51, 0x19, 0x7a, 0x1c, 0xb4, -0x18, 0x21, 0xec, 0x88, 0xad, 0x96, 0xe4, 0xfa, -0xa, 0x98, 0x94, 0xaa, 0x76, 0xe7, 0x8, 0x68, -0x45, 0xdb, 0xa5, 0xc0, 0xb2, 0xab, 0xc1, 0x14, -0x38, 0xf1, 0x3b, 0x43, 0xec, 0x7d, 0x5e, 0xe3, -0xfa, 0x82, 0x2b, 0x23, 0xfe, 0x50, 0x3e, 0x7b, -0x27, 0xed, 0x24, 0x5e, 0x9d, 0xa0, 0xf7, 0x67, -0x3f, 0x3a, 0xc1, 0xdd, 0x9b, 0x79, 0xf4, 0x86, -0xab, 0xac, 0x27, 0xb0, 0xbf, 0x6b, 0xa5, 0xd7, -0x7a, 0x7, 0xc6, 0xb0, 0xfc, 0xa6, 0xf9, 0xbf, - -0x47, 0x3, 0xfc, 0x4, 0xc3, 0x71, 0xd5, 0xb0, -0xaa, 0xe4, 0x3e, 0xe8, 0x5c, 0x36, 0xfa, 0x89, -0x21, 0x94, 0xba, 0x7c, 0x16, 0xbf, 0x1e, 0xff, -0xd0, 0x47, 0xd5, 0x2a, 0x98, 0x46, 0x2a, 0x60, -0x42, 0x13, 0xdb, 0xca, 0xe1, 0x3a, 0xd, 0xaf, -0x89, 0xf2, 0x7c, 0x99, 0x6b, 0xbe, 0xb4, 0xd6, -0x58, 0x8a, 0xf2, 0x99, 0x2, 0x81, 0xc4, 0x1f, -0x10, 0x8f, 0x7c, 0x81, 0xe4, 0x23, 0x9f, 0x25, -0x96, 0x1, 0x26, 0x44, 0x4, 0xa3, 0xef, 0x45, -0x8, 0x8b, 0x1e, 0x20, 0x67, 0x89, 0x9b, 0xea, -0xd8, 0x59, 0x22, 0xa6, 0xe0, 0x5f, 0x5c, 0xde, -0x45, 0x97, 0x52, 0xb5, 0x45, 0x76, 0xe2, 0x13, -0xdd, 0x29, 0x9a, 0x77, 0x2f, 0xb8, 0xf, 0x83, -0xb0, 0x73, 0x3d, 0x96, 0x1c, 0xe5, 0xfc, 0xc2, -0x31, 0x24, 0x6f, 0xa5, 0x9, 0x1f, 0x9b, 0xc7, -0x58, 0x80, 0x32, 0xd, 0x25, 0xd7, 0x42, 0x7f, - -0x8a, 0x55, 0x23, 0x5, 0x68, 0xe5, 0x4c, 0xb3, -0x8d, 0x17, 0xb8, 0x4f, 0xe5, 0xaa, 0x91, 0x15, -0x46, 0xb5, 0x96, 0x6c, 0x4, 0xac, 0x93, 0x93, -0xe4, 0xa5, 0x48, 0x42, 0x50, 0x18, 0x1d, 0x84, -0x5b, 0xd2, 0x79, 0xb1, 0x44, 0x7f, 0x92, 0x7, -0x14, 0xc3, 0x87, 0x7c, 0x1a, 0x32, 0xa0, 0x32, -0xd3, 0x79, 0xc1, 0x1d, 0xec, 0x86, 0x98, 0x4, -0xd, 0x65, 0xb6, 0x40, 0x1d, 0x31, 0x73, 0xdd, -0x8c, 0x91, 0x23, 0x99, 0x9a, 0xa6, 0x82, 0xad, -0xf6, 0xd4, 0x74, 0x6, 0x46, 0x46, 0x97, 0x5, -0x42, 0xcf, 0x82, 0x7e, 0xc8, 0x8c, 0x4, 0xdc, -0xff, 0x99, 0x8b, 0xa0, 0x18, 0x8f, 0xff, 0x44, -0xdf, 0x2f, 0x8c, 0xd3, 0x67, 0x7b, 0x87, 0x8a, -0xf4, 0xd, 0xe1, 0x5d, 0x70, 0xcc, 0x42, 0x69, -0xa9, 0xb5, 0xff, 0x33, 0xac, 0xfe, 0xf6, 0x69, -0xc1, 0x1f, 0xa5, 0x8d, 0x76, 0x0, 0xc7, 0xee, - -0xd7, 0xa5, 0x87, 0x51, 0xe0, 0x70, 0xf, 0x6d, -0xf7, 0x3c, 0x72, 0x1e, 0x7, 0xd, 0xa, 0xa1, -0x64, 0xce, 0xd7, 0x1c, 0xfb, 0xc, 0xd1, 0x53, -0xb2, 0x39, 0xeb, 0x50, 0x59, 0x64, 0x8, 0x76, -0x73, 0x56, 0x31, 0xf8, 0x24, 0xfd, 0x64, 0x8, -0xbf, 0xb3, 0x3, 0xcf, 0x86, 0x80, 0xf1, 0x5a, -0xa0, 0x79, 0x12, 0xe4, 0x80, 0x85, 0x52, 0x76, -0x2f, 0xd9, 0x52, 0x16, 0x1a, 0xbb, 0x7e, 0x65, -0x52, 0x65, 0x5e, 0xd, 0x85, 0x17, 0x2f, 0x2e, -0x41, 0xc, 0x48, 0xe7, 0x19, 0x51, 0x3e, 0x6e, -0x88, 0x22, 0xf, 0xb4, 0xfb, 0x30, 0x70, 0xf7, -0x77, 0xa9, 0xd6, 0x90, 0xcd, 0x1b, 0x9b, 0x6b, -0x28, 0x35, 0x9c, 0x36, 0xbf, 0xd4, 0x6f, 0xb7, -0xd0, 0xc2, 0x29, 0x14, 0x22, 0xdf, 0x72, 0xc7, -0x6e, 0x60, 0x34, 0xca, 0xe, 0x46, 0x14, 0xf1, -0x54, 0x3e, 0x25, 0x49, 0x7c, 0x42, 0x3e, 0x38, - -0x7b, 0x17, 0x81, 0xf6, 0x4c, 0xf3, 0x84, 0x2, -0x8e, 0x2c, 0xe7, 0x62, 0xa, 0x82, 0xbc, 0xb6, -0x8f, 0x77, 0x3a, 0x1, 0x30, 0x77, 0xc5, 0xbf, -0x58, 0x43, 0xcd, 0xfc, 0xfd, 0xba, 0x9, 0xe1, -0x65, 0x5, 0xe5, 0x8f, 0xad, 0x64, 0x9f, 0xe7, -0x5d, 0xa9, 0xb2, 0x6a, 0x7d, 0xca, 0xbd, 0x29, -0xd0, 0xfe, 0xba, 0xac, 0xad, 0x46, 0xca, 0xa5, -0xfe, 0xf0, 0x38, 0xef, 0x73, 0x0, 0x3a, 0x94, -0xbb, 0x69, 0xcc, 0x7c, 0xdb, 0x4d, 0x83, 0xe8, -0x7b, 0x4b, 0x2e, 0xd1, 0x37, 0xe3, 0x5b, 0x79, -0xd, 0x1, 0x9c, 0x17, 0xe5, 0x88, 0x48, 0x65, -0x1f, 0x9d, 0xc0, 0x2d, 0xe5, 0xcf, 0x56, 0x2f, -0xac, 0x74, 0xf3, 0x23, 0xd, 0x51, 0x4e, 0x66, -0x22, 0x3e, 0xa7, 0x39, 0xcc, 0xe2, 0xef, 0x1d, -0xd2, 0x80, 0x35, 0x5b, 0xec, 0x5c, 0xe9, 0xf8, -0xb7, 0x70, 0x5c, 0xf1, 0x9a, 0x6e, 0xfa, 0xda, - -0x0, 0xeb, 0x6a, 0x69, 0xfd, 0x26, 0x7d, 0xbb, -0xcd, 0xc, 0x62, 0xa, 0x90, 0x3d, 0x9c, 0x37, -0xfa, 0x9a, 0x84, 0x9e, 0x93, 0xac, 0xc4, 0xb9, -0x32, 0x2d, 0xf5, 0x69, 0x27, 0x35, 0x86, 0x2, -0x56, 0xbd, 0x85, 0x22, 0x54, 0x87, 0xf6, 0x77, -0xfa, 0xc9, 0x62, 0xfb, 0xd3, 0x6f, 0x8f, 0x3, -0x0, 0x56, 0x30, 0x6e, 0xc7, 0xd7, 0xd1, 0xd0, -0x45, 0x6f, 0xe8, 0xcd, 0x8b, 0xbc, 0x81, 0xd0, -0x3a, 0x1, 0x7, 0x85, 0x6d, 0x3b, 0xb0, 0x42, -0x6c, 0xa2, 0x54, 0xeb, 0x5b, 0x60, 0x59, 0xa1, -0x70, 0x34, 0x86, 0x1d, 0xb1, 0xba, 0xfb, 0x28, -0x29, 0x73, 0xb, 0xa8, 0xb3, 0x31, 0x42, 0x4e, -0xa6, 0x23, 0xee, 0x1e, 0x34, 0x8d, 0x8f, 0xc8, -0xf3, 0x5b, 0xcd, 0x8e, 0x64, 0x15, 0x2e, 0xa1, -0x81, 0x12, 0xad, 0x13, 0x8d, 0x8, 0x68, 0xe8, -0xe2, 0xf2, 0xf4, 0xc4, 0x2a, 0x73, 0x30, 0x9b, - -0xb0, 0x12, 0x3b, 0x5e, 0xd0, 0x7a, 0x6c, 0x93, -0x6f, 0x7c, 0x3f, 0xe4, 0x2c, 0xb2, 0x61, 0xb1, -0xe1, 0xc4, 0x61, 0xfa, 0x9b, 0x92, 0xe, 0xe3, -0x27, 0x85, 0x9c, 0xb6, 0xa2, 0x54, 0x62, 0x38, -0x4a, 0xb8, 0x72, 0x8, 0xa3, 0xd8, 0x8d, 0xa1, -0xef, 0x20, 0x75, 0x46, 0x76, 0xba, 0xae, 0x40, -0x68, 0x14, 0x49, 0xd9, 0xfc, 0x2, 0x42, 0xca, -0x83, 0xb2, 0x2b, 0xb6, 0x34, 0x58, 0x80, 0x26, -0x82, 0xe8, 0xbe, 0x17, 0xe7, 0x26, 0xab, 0x11, -0xc0, 0xea, 0xb0, 0x5b, 0x19, 0xef, 0xea, 0x61, -0x9d, 0xe6, 0xa9, 0x82, 0xf1, 0xa0, 0xe6, 0xb3, -0xda, 0xaf, 0xd2, 0xcf, 0x41, 0x8c, 0x32, 0xd4, -0xa, 0xf0, 0xd2, 0xca, 0xe6, 0x41, 0x3d, 0x41, -0x29, 0x93, 0x96, 0x39, 0x87, 0x5b, 0x85, 0x1f, -0x61, 0xd8, 0x63, 0x45, 0xee, 0x4c, 0x2e, 0x42, -0x4b, 0x7c, 0xa7, 0xe4, 0x20, 0xf6, 0x37, 0x63, - -0xfe, 0xb1, 0x28, 0xb9, 0xf0, 0x76, 0x30, 0xe7, -0xce, 0x9e, 0xf6, 0xe9, 0x65, 0x5d, 0xcc, 0x20, -0x70, 0xd8, 0x70, 0x3d, 0x87, 0x24, 0xa2, 0x56, -0xc4, 0x93, 0xd3, 0xaa, 0xd0, 0xd6, 0x5c, 0x3d, -0xd, 0xfc, 0x49, 0x61, 0x23, 0x94, 0x2c, 0x22, -0xc3, 0x7e, 0xdc, 0xf7, 0x3f, 0x2, 0xcc, 0x2c, -0xd2, 0xe0, 0x77, 0xc4, 0xda, 0xd2, 0x99, 0xe6, -0x9, 0x6b, 0x60, 0x65, 0x82, 0x38, 0x7b, 0x60, -0x53, 0x30, 0xc2, 0xb7, 0xd4, 0xe3, 0xec, 0xb0, -0xc4, 0x50, 0x41, 0xcc, 0xe7, 0xa4, 0x3f, 0xed, -0xc0, 0x27, 0x2b, 0xc4, 0x17, 0xb7, 0x98, 0x7f, -0xcc, 0xe9, 0xb0, 0xfd, 0x1e, 0x9, 0x49, 0x20, -0x88, 0x9e, 0x2d, 0xa6, 0x9, 0x32, 0x42, 0xc7, -0x21, 0x2a, 0x85, 0x84, 0x42, 0xd8, 0x2d, 0x94, -0x6b, 0x18, 0x45, 0x46, 0xd8, 0x69, 0xee, 0xff, -0x15, 0xfb, 0x20, 0x4d, 0x6, 0xce, 0xf, 0x14, - -0x6c, 0x8d, 0xf3, 0xd, 0x53, 0x39, 0x80, 0x8, -0x4f, 0x41, 0xe9, 0xe9, 0xae, 0x97, 0x1c, 0x53, -0xae, 0x21, 0x1e, 0x99, 0xf8, 0x98, 0xe9, 0x6a, -0xa0, 0x1f, 0x93, 0xd1, 0xd2, 0x5f, 0xb8, 0x26, -0x25, 0x82, 0x34, 0xa9, 0x2a, 0xa7, 0xe7, 0x53, -0x48, 0x37, 0x3e, 0x4f, 0x3d, 0xa9, 0x11, 0x28, -0x4f, 0xa6, 0x1f, 0x34, 0xf4, 0x62, 0x44, 0x3c, -0xf6, 0xe6, 0x84, 0xf9, 0xd, 0x59, 0x82, 0xc3, -0xb1, 0x7f, 0x36, 0x6c, 0x95, 0x1a, 0x8e, 0x55, -0x5c, 0x95, 0x53, 0xfe, 0xb0, 0x2c, 0xc7, 0xd, -0xfe, 0x1c, 0x4a, 0xc5, 0x85, 0xe4, 0x23, 0xb3, -0x46, 0xaa, 0x17, 0xd9, 0x24, 0x6e, 0xf6, 0x6b, -0x8e, 0x5d, 0x6c, 0x48, 0x1c, 0x61, 0x16, 0x6d, -0x94, 0xf7, 0xc6, 0xf3, 0xb6, 0xde, 0xb2, 0x4d, -0xee, 0x25, 0x1a, 0x45, 0xb8, 0xd5, 0xdf, 0x46, -0xcd, 0xc7, 0x93, 0xfe, 0x49, 0xd0, 0xc9, 0x63, - -0xd3, 0x9a, 0x16, 0xee, 0x5a, 0x93, 0xd7, 0x63, -0x89, 0x9a, 0x6a, 0x68, 0x45, 0xb0, 0x2, 0x49, -0xac, 0xb2, 0x8e, 0x1e, 0xb5, 0x8d, 0x4e, 0x61, -0xb, 0xab, 0x35, 0x9c, 0x84, 0x51, 0xca, 0x2, -0x15, 0x7c, 0x2b, 0x8d, 0x34, 0x92, 0xc2, 0x29, -0x6c, 0xa7, 0x64, 0x1b, 0xbe, 0x6e, 0x8c, 0x7c, -0x8d, 0x16, 0x31, 0x3f, 0x66, 0x65, 0xf7, 0xf1, -0x56, 0x7b, 0x89, 0x5e, 0x21, 0x6f, 0xd9, 0x64, -0x5e, 0x87, 0x20, 0x18, 0xb0, 0x94, 0x28, 0x78, -0x42, 0x3, 0x5f, 0x34, 0x59, 0xd8, 0x96, 0x53, -0xd1, 0xef, 0x4, 0xbc, 0xfb, 0x3b, 0xce, 0x65, -0x7d, 0x16, 0xad, 0x60, 0x7e, 0xf, 0x5a, 0x57, -0x76, 0xfa, 0x5, 0x79, 0x85, 0xba, 0x96, 0xab, -0x50, 0xd4, 0x1f, 0x49, 0x8, 0xdd, 0xfc, 0x8e, -0xa9, 0xa1, 0x46, 0x96, 0x47, 0xbe, 0x94, 0x5b, -0x78, 0xb1, 0x29, 0x35, 0x6e, 0x42, 0x62, 0xb7, - -0x39, 0xcc, 0xbd, 0x7d, 0xfa, 0xc5, 0xcf, 0x4b, -0x17, 0x1, 0x9a, 0xaf, 0xca, 0xd, 0xb2, 0xe8, -0x21, 0x6f, 0x15, 0xa5, 0x74, 0x47, 0xea, 0x19, -0xe4, 0x5d, 0x95, 0x4b, 0x6c, 0xc3, 0x78, 0xad, -0x2, 0x2b, 0xed, 0xb4, 0xc3, 0x4e, 0xd5, 0x8, -0x9, 0xde, 0xf9, 0x59, 0x1, 0xf3, 0x4e, 0xf6, -0xac, 0x6f, 0xb2, 0x44, 0xa4, 0xd6, 0x3f, 0x8c, -0x48, 0xb7, 0xf0, 0xbb, 0xd7, 0xa5, 0xd5, 0xc9, -0xfe, 0x6b, 0x77, 0xdd, 0x2d, 0xda, 0x97, 0xff, -0x8e, 0xbc, 0xd6, 0x43, 0x40, 0xa2, 0x69, 0x6b, -0x38, 0x13, 0x8d, 0x53, 0xd2, 0xe0, 0xc1, 0x5a, -0xe1, 0x97, 0xdc, 0x6c, 0x6d, 0x46, 0xce, 0x5a, -0x71, 0xa7, 0x98, 0xf2, 0x38, 0xa, 0x82, 0x9d, -0xe4, 0x5, 0xa2, 0xe5, 0x16, 0xcc, 0xb1, 0x0, -0x73, 0x7, 0x73, 0x21, 0xf2, 0x46, 0xf7, 0xb6, -0xed, 0x9a, 0x81, 0x1c, 0xae, 0x19, 0x59, 0x76, - -0x79, 0xdc, 0x3b, 0x6f, 0x6b, 0x96, 0xfc, 0x1a, -0x9, 0x6, 0x55, 0x8a, 0x8, 0xa2, 0x6, 0x8a, -0x32, 0x6, 0x38, 0x3a, 0xba, 0xc9, 0x40, 0xc, -0xb0, 0x9c, 0x9, 0x29, 0xe1, 0x7b, 0x9, 0xae, -0x30, 0xb8, 0x21, 0xbf, 0x8a, 0x64, 0x89, 0x43, -0x47, 0xd, 0xc4, 0xee, 0xfd, 0xec, 0x75, 0x61, -0xe8, 0xf7, 0x4c, 0xd2, 0x4b, 0xdb, 0x58, 0x2d, -0x8a, 0xd9, 0x4c, 0xe4, 0xc8, 0xf5, 0xe, 0x42, -0x4b, 0x7d, 0xdd, 0xa1, 0xdb, 0xe3, 0x97, 0x4e, -0x34, 0x19, 0xed, 0xab, 0xfa, 0x4f, 0xb3, 0x32, -0xd9, 0x3a, 0x6, 0x44, 0x30, 0x70, 0xa8, 0x94, -0x11, 0x37, 0xc2, 0x18, 0x1f, 0xb3, 0x38, 0x7f, -0xf, 0xc5, 0xad, 0xfa, 0xfd, 0x76, 0x2e, 0x34, -0xa9, 0x6d, 0x50, 0x80, 0xf3, 0x84, 0xd4, 0x6f, -0xd6, 0x1c, 0x4d, 0x70, 0xcb, 0xe, 0xf6, 0x36, -0x6a, 0xf3, 0xbb, 0x83, 0xc5, 0x4c, 0x9c, 0x6b, - -0x32, 0x41, 0x4d, 0x3e, 0xf, 0x84, 0x41, 0xe8, -0xbe, 0x7e, 0x23, 0x4c, 0x5a, 0x71, 0x48, 0xe7, -0xe7, 0x4a, 0xb3, 0x88, 0xee, 0xe4, 0x47, 0xd5, -0xde, 0x56, 0x89, 0x1d, 0x2b, 0xc2, 0xcc, 0xb5, -0x3, 0x4d, 0xcc, 0x9a, 0xa4, 0x3, 0x40, 0xce, -0x1f, 0xbc, 0xb8, 0x9d, 0x2b, 0x88, 0x11, 0xda, -0xe2, 0x6f, 0x66, 0x86, 0xeb, 0x68, 0x91, 0x2b, -0xf9, 0x18, 0xc7, 0x67, 0x81, 0xfa, 0xf5, 0xee, -0xf0, 0x21, 0x1a, 0x6b, 0xcb, 0x5d, 0xfc, 0x9a, -0x64, 0xd3, 0x12, 0xe, 0xa1, 0x81, 0xfd, 0xec, -0xe9, 0x6a, 0xb1, 0x20, 0x23, 0xd6, 0xfe, 0x77, -0xc8, 0x99, 0x1b, 0x21, 0x1e, 0x8b, 0xc, 0x57, -0x11, 0x6, 0xc9, 0x88, 0xbc, 0x92, 0xff, 0xa0, -0xa4, 0x54, 0x45, 0xc5, 0x47, 0x2c, 0x81, 0x2a, -0x32, 0x69, 0xfb, 0x2c, 0xa7, 0x99, 0x6f, 0x79, -0x41, 0xf2, 0x22, 0xe9, 0x3b, 0x59, 0xa, 0x41, - -0xb7, 0x85, 0x32, 0xa9, 0xe0, 0x96, 0xcd, 0x1c, -0xf7, 0x10, 0x94, 0xa0, 0xa6, 0x1, 0x66, 0x2b, -0xf3, 0x9a, 0x82, 0x3d, 0x34, 0x20, 0xa9, 0x7a, -0x1, 0xcb, 0x10, 0x91, 0x6b, 0xb0, 0x2a, 0xec, -0x77, 0xb1, 0x35, 0x53, 0xe6, 0xc9, 0x42, 0xe9, -0x59, 0xc2, 0xd8, 0x6, 0x3e, 0x50, 0xba, 0xe2, -0xcf, 0xe0, 0x65, 0x5f, 0xde, 0x58, 0xc6, 0x22, -0x6c, 0x16, 0x70, 0x96, 0x4c, 0x8c, 0xd1, 0xe2, -0x4f, 0x82, 0x3a, 0x98, 0x6, 0x4e, 0x67, 0xae, -0x9c, 0x0, 0x9f, 0x3f, 0x20, 0xa2, 0x7a, 0x69, -0xc3, 0x7a, 0xd6, 0x73, 0xef, 0x5f, 0xf3, 0xb9, -0xbd, 0x68, 0xe5, 0x9b, 0xeb, 0xdb, 0x1c, 0x1, -0x83, 0x5, 0x48, 0x94, 0x63, 0x8e, 0xfb, 0x23, -0x17, 0x66, 0xfc, 0xa0, 0x66, 0x26, 0x9d, 0x69, -0xdb, 0xca, 0xef, 0x20, 0x3b, 0x41, 0x4e, 0x10, -0x8d, 0x5c, 0x1a, 0x46, 0xef, 0x48, 0x13, 0xb7, - -0xfc, 0x1c, 0x63, 0xaf, 0x63, 0x54, 0x72, 0x88, -0x46, 0xf0, 0xe6, 0x2d, 0x14, 0x7f, 0x3b, 0x8b, -0xd0, 0x2c, 0xb0, 0x5d, 0x8f, 0x82, 0x33, 0x36, -0x76, 0xa0, 0xa8, 0x2d, 0x8, 0x1a, 0x4e, 0xd1, -0x34, 0xb8, 0xac, 0x3c, 0xe9, 0x75, 0x97, 0xa1, -0x96, 0x36, 0xfe, 0xad, 0xcd, 0x9d, 0x7d, 0xc9, -0xb6, 0x58, 0xbc, 0xa3, 0x1b, 0x47, 0xb, 0x87, -0x4c, 0x3a, 0xae, 0x85, 0xb7, 0xd5, 0xb7, 0x94, -0xc1, 0x2e, 0x39, 0x85, 0x74, 0x2e, 0xc1, 0x7f, -0x7c, 0x81, 0xd6, 0x17, 0xbd, 0x7a, 0x4d, 0xb8, -0x95, 0x8c, 0x4b, 0x9c, 0x8c, 0x33, 0x30, 0xc1, -0x45, 0xf6, 0x2f, 0x74, 0xc6, 0x89, 0x24, 0x87, -0x3a, 0xb6, 0x7d, 0x89, 0x13, 0x40, 0x1e, 0xf9, -0x8a, 0xf8, 0xf1, 0xcd, 0x7, 0xc3, 0x29, 0x4e, -0x1, 0xc4, 0x1f, 0xf9, 0x81, 0xca, 0x5e, 0x1, -0xc8, 0xb3, 0xb7, 0xf6, 0x6d, 0x38, 0x31, 0x18, - -0x4f, 0xd, 0x10, 0x96, 0x61, 0xfc, 0x72, 0xce, -0xc2, 0xbb, 0xfe, 0x11, 0xfa, 0xf4, 0x26, 0x54, -0xf, 0x40, 0x26, 0xe0, 0x5, 0x93, 0xf8, 0xe9, -0x7f, 0x7b, 0x44, 0x75, 0xeb, 0x30, 0xa7, 0xde, -0x2f, 0xb3, 0x29, 0x93, 0x17, 0x8b, 0x19, 0x1a, -0xcf, 0xf, 0xb9, 0xee, 0xb2, 0xbb, 0xc1, 0xf3, -0x4, 0x7b, 0xb0, 0xd, 0xf5, 0x4a, 0x57, 0xdd, -0xf5, 0xac, 0x9e, 0xf5, 0x97, 0x7e, 0x87, 0xbb, -0x3b, 0xb5, 0x8e, 0x53, 0xc7, 0x81, 0x9, 0xa3, -0x12, 0x8a, 0x42, 0x2b, 0xa, 0x7a, 0xfc, 0x1f, -0xba, 0x4b, 0xab, 0xe9, 0xe8, 0x21, 0xda, 0xae, -0x33, 0x47, 0xd9, 0x1b, 0x44, 0x7a, 0x2f, 0xdc, -0x53, 0xf7, 0xf2, 0xa8, 0xab, 0x76, 0x3f, 0x7b, -0xaa, 0xa2, 0x6a, 0xd0, 0x88, 0xc1, 0x1b, 0x47, -0x16, 0x66, 0x69, 0xe, 0x75, 0x97, 0x9c, 0x17, -0xe, 0x60, 0x2a, 0x68, 0xc3, 0x11, 0xdf, 0x4, - -0xc8, 0xc4, 0xce, 0x61, 0x25, 0xf6, 0x34, 0x2b, -0x61, 0x50, 0x91, 0x1d, 0x35, 0xcb, 0x6b, 0x91, -0x2f, 0x8e, 0x9c, 0x69, 0xce, 0xfe, 0x1f, 0x62, -0x22, 0x3f, 0x8f, 0xb4, 0x5f, 0x29, 0x5a, 0x8f, -0x1e, 0x8a, 0xbd, 0x6, 0x5d, 0xe, 0xb, 0xd9, -0xd6, 0x53, 0x68, 0xd0, 0x14, 0xb4, 0xb5, 0xf5, -0xa0, 0x5e, 0x4e, 0x2e, 0x91, 0x5b, 0xd4, 0xfc, -0xcf, 0x58, 0x38, 0x10, 0xa5, 0x78, 0x8a, 0xdb, -0xa5, 0xa, 0xad, 0x7a, 0xa, 0x72, 0xc0, 0xe2, -0xe2, 0xf5, 0x40, 0xb9, 0x7b, 0x47, 0xad, 0xa3, -0xfe, 0x11, 0x9d, 0x3f, 0x37, 0xc4, 0x82, 0x44, -0x3, 0xa4, 0x29, 0xf1, 0xe4, 0x29, 0x29, 0x27, -0xb6, 0x30, 0x85, 0x95, 0x2b, 0x82, 0xb2, 0x55, -0x4b, 0x69, 0x5a, 0x4, 0x89, 0x84, 0x1f, 0x96, -0xa8, 0x5b, 0x59, 0x83, 0x6e, 0x62, 0xeb, 0x9c, -0xfe, 0x97, 0x30, 0x1d, 0x9c, 0x16, 0x26, 0x7d, - -0x7d, 0x9c, 0x59, 0x60, 0x81, 0x8b, 0x65, 0x29, -0xb1, 0x2f, 0xb3, 0x34, 0x11, 0xa8, 0x19, 0x5f, -0xde, 0xf5, 0x65, 0xea, 0xb8, 0x55, 0xc3, 0xe1, -0x1c, 0xac, 0x3a, 0x7, 0xd8, 0xeb, 0x91, 0x51, -0x3e, 0x4e, 0x24, 0xb, 0xa3, 0x7f, 0x59, 0x86, -0xeb, 0x7d, 0x33, 0xe9, 0x3e, 0x58, 0xa9, 0x68, -0x6d, 0x70, 0x12, 0xb3, 0xbb, 0xf7, 0x21, 0x2d, -0x30, 0xca, 0x83, 0x2, 0x11, 0xb9, 0xc2, 0x52, -0xb8, 0xd4, 0xc1, 0x52, 0xdc, 0x8c, 0xd, 0x2e, -0x95, 0x84, 0x58, 0x54, 0xa0, 0x22, 0xe4, 0xa4, -0xf1, 0xa3, 0xa4, 0xd4, 0x5d, 0x27, 0x6c, 0x83, -0x3d, 0xfe, 0x90, 0xd9, 0x61, 0x43, 0x40, 0x2, -0x4d, 0x64, 0x6f, 0xd6, 0x74, 0xc, 0x58, 0x38, -0x7c, 0x3, 0xf3, 0x77, 0x30, 0xcc, 0x29, 0x8d, -0x9d, 0xf9, 0x56, 0xea, 0x6b, 0xa8, 0x1a, 0x7, -0xd0, 0xa0, 0xe8, 0x48, 0x93, 0xa3, 0x19, 0x9b, - -0xc4, 0x4, 0x57, 0x5, 0xec, 0x63, 0xd6, 0x6f, -0xb2, 0xf7, 0x48, 0x65, 0x24, 0x19, 0xcb, 0x20, -0x78, 0xb4, 0xaf, 0xe8, 0x6c, 0x92, 0x7d, 0x86, -0x49, 0xab, 0x5, 0x7, 0xfc, 0x11, 0xc6, 0x70, -0x66, 0xac, 0xbc, 0x70, 0x7e, 0x9d, 0x34, 0xb0, -0x50, 0x41, 0x35, 0xf9, 0xc2, 0x6c, 0xf4, 0xf, -0x17, 0xe0, 0xa7, 0xc2, 0x7a, 0xbf, 0xf4, 0xa1, -0x11, 0xb, 0xe4, 0x52, 0xbf, 0x7c, 0x38, 0x29, -0xfa, 0x34, 0x32, 0x44, 0x14, 0x99, 0x79, 0x6b, -0xb3, 0x5b, 0xd, 0x1, 0x5f, 0xc3, 0x33, 0x57, -0xb0, 0x4b, 0xe, 0x28, 0x36, 0xcf, 0xff, 0xf4, -0x19, 0xf, 0x91, 0x4b, 0xcb, 0x93, 0xcc, 0x6c, -0xc7, 0xfd, 0x2b, 0x57, 0x38, 0x15, 0x7b, 0x6e, -0xda, 0x83, 0xed, 0xcf, 0x28, 0x32, 0x2b, 0xda, -0x82, 0x55, 0x49, 0x68, 0xf8, 0x66, 0xb1, 0x13, -0x11, 0xa9, 0xe0, 0xef, 0xb0, 0x87, 0xec, 0x2, - -0xe7, 0x64, 0x49, 0x58, 0x93, 0xd9, 0x87, 0xb3, -0xfa, 0x50, 0x39, 0x3e, 0xe8, 0x3c, 0xdc, 0x7c, -0x41, 0x21, 0x95, 0xf7, 0xae, 0xa8, 0xa6, 0xc2, -0xab, 0x1b, 0xec, 0x67, 0xd9, 0xd5, 0xca, 0xac, -0x2, 0xe5, 0x72, 0x59, 0xab, 0x29, 0x74, 0x52, -0xc8, 0xf8, 0x1b, 0x10, 0xd4, 0xe9, 0xc2, 0x1a, -0x25, 0xfc, 0xa8, 0xca, 0x41, 0x4b, 0x16, 0x2c, -0x4d, 0x11, 0x20, 0xa5, 0x4a, 0xa9, 0xbc, 0x55, -0xbc, 0x8, 0x79, 0x92, 0x4b, 0xe2, 0x4e, 0x30, -0x26, 0x76, 0xf4, 0xd3, 0x37, 0x68, 0x17, 0xca, -0xcc, 0xd0, 0x71, 0x38, 0x5, 0x44, 0x7e, 0xd4, -0x69, 0xbe, 0xd7, 0xdd, 0xd4, 0x2f, 0x76, 0x8f, -0x41, 0x13, 0x51, 0x5, 0x15, 0x4e, 0x56, 0x75, -0x1a, 0x4f, 0x93, 0x4e, 0x89, 0x1f, 0xef, 0x77, -0x59, 0xe2, 0xbf, 0x4a, 0x86, 0xcc, 0x76, 0x20, -0x9a, 0xfe, 0x3a, 0xbb, 0x7f, 0xb5, 0xed, 0x27, - -0x7a, 0xee, 0x1, 0xca, 0xda, 0x8a, 0xd6, 0x6, -0xe4, 0xdc, 0xe, 0xb4, 0x43, 0xa7, 0x21, 0x55, -0x71, 0x38, 0xc4, 0x44, 0xf, 0x9d, 0x77, 0xad, -0x32, 0xea, 0x41, 0x9a, 0xa8, 0x99, 0x39, 0xb2, -0xc, 0x28, 0xf3, 0x89, 0x7b, 0xee, 0x2a, 0x76, -0x23, 0xc8, 0xc4, 0xa, 0x8e, 0x2, 0xc0, 0xa6, -0x96, 0xe, 0x4e, 0xf6, 0x91, 0xb1, 0x1a, 0x38, -0x46, 0x62, 0x24, 0x37, 0x60, 0xf8, 0x3e, 0x8d, -0xe9, 0x7, 0x1f, 0x88, 0xcf, 0xab, 0xae, 0x3e, -0x80, 0x74, 0xc9, 0x1, 0x8c, 0x81, 0xc1, 0xa, -0x7, 0x10, 0x7c, 0x72, 0xf5, 0xb7, 0x0, 0x3f, -0x7b, 0xfa, 0xe4, 0x4, 0xf4, 0x6d, 0x87, 0x6e, -0xbb, 0x55, 0xce, 0xaf, 0xd9, 0x8e, 0xbd, 0xfc, -0x67, 0x8c, 0x1d, 0x9, 0x98, 0x65, 0x84, 0xda, -0xc6, 0xb8, 0x6f, 0xba, 0x9c, 0x20, 0x83, 0xeb, -0x6e, 0xa1, 0x92, 0x29, 0xb3, 0xe7, 0x35, 0xf3, - -0x7e, 0xaa, 0xc6, 0xcb, 0xb7, 0x7b, 0x73, 0xbd, -0xd2, 0xca, 0x8, 0xa3, 0xb4, 0x12, 0x94, 0x8c, -0xe9, 0xf4, 0x20, 0xa2, 0xbb, 0x22, 0xc, 0x7e, -0x83, 0x1a, 0x58, 0xe9, 0xd2, 0x5, 0x49, 0x5, -0x53, 0xe6, 0x44, 0x81, 0x5c, 0x4d, 0x67, 0x7d, -0x81, 0xcd, 0xb0, 0x69, 0xf6, 0x46, 0x11, 0xf5, -0x42, 0x9c, 0xa3, 0xce, 0x8e, 0x3b, 0x81, 0x53, -0x1d, 0x34, 0x29, 0xcc, 0x50, 0x38, 0x8, 0x5c, -0x71, 0xf4, 0xbe, 0x48, 0x44, 0x8f, 0x9, 0x1f, -0xa1, 0x3e, 0xfc, 0xa8, 0x4c, 0x3, 0x4, 0x5e, -0x7f, 0xed, 0x8f, 0xc8, 0x26, 0x45, 0x8, 0xaf, -0x83, 0xa8, 0xa7, 0x96, 0xb5, 0xd5, 0x53, 0x9c, -0xc2, 0x82, 0x9, 0xe3, 0x77, 0x5, 0x48, 0xf6, -0x87, 0x98, 0x74, 0x32, 0x93, 0x56, 0x7e, 0xb, -0x7e, 0x59, 0x5, 0xfe, 0x77, 0x5f, 0xa1, 0x2a, -0x28, 0x16, 0xf0, 0xb9, 0x85, 0x9c, 0x19, 0xc2, - -0x21, 0x97, 0x11, 0x13, 0xb5, 0x8, 0x6, 0xe8, -0x10, 0xe8, 0xdc, 0x87, 0xc3, 0x2c, 0x26, 0xa8, -0x3f, 0xdd, 0x20, 0x60, 0x58, 0x5c, 0x56, 0x34, -0xb8, 0x5c, 0xb6, 0x57, 0xe0, 0xf1, 0x9b, 0x3f, -0x41, 0x16, 0xac, 0x18, 0x9c, 0x83, 0xcf, 0xa2, -0x81, 0xdd, 0xc8, 0xf3, 0x5e, 0xda, 0x3a, 0x91, -0xb1, 0x77, 0xb9, 0x49, 0x4a, 0x83, 0x89, 0x79, -0x47, 0x8a, 0xb8, 0xa8, 0x42, 0xa6, 0x3, 0x31, -0x1b, 0xe6, 0xc0, 0xed, 0x41, 0x51, 0xf8, 0x7a, -0x40, 0x1, 0x93, 0x45, 0x9, 0x53, 0x2b, 0x5c, -0x8d, 0xf6, 0x42, 0x42, 0xd3, 0xfe, 0xef, 0x5, -0x87, 0x6e, 0x16, 0x43, 0xe5, 0xcf, 0x49, 0x7d, -0xc6, 0xc7, 0x1, 0xc3, 0x4f, 0x44, 0xa2, 0x51, -0x8, 0xe8, 0xd4, 0x7a, 0x4c, 0x7f, 0xae, 0x89, -0xd8, 0x37, 0xd2, 0x33, 0xcc, 0xb7, 0x9a, 0xc3, -0x59, 0x83, 0xe0, 0xc9, 0xa7, 0xe4, 0x83, 0x13, - -0xa1, 0xd7, 0xd7, 0x18, 0x5, 0x55, 0x43, 0x5a, -0xbc, 0x5e, 0x7c, 0x95, 0x59, 0x4e, 0x77, 0xe6, -0x15, 0x44, 0xf5, 0x4c, 0x65, 0x8f, 0x2, 0xdc, -0xa, 0x15, 0x83, 0x9f, 0x95, 0x5b, 0x18, 0x4e, -0x6e, 0x4d, 0x6f, 0x6c, 0xce, 0x99, 0x7e, 0xa5, -0x34, 0x3e, 0x1b, 0xb4, 0xb4, 0x1c, 0xa1, 0x70, -0x35, 0xb9, 0x3b, 0xe4, 0x86, 0xcb, 0xfe, 0xc8, -0x67, 0x86, 0xd6, 0x5a, 0x8a, 0x2, 0x9e, 0xc9, -0x23, 0xfc, 0xe3, 0x50, 0x5a, 0xaa, 0xb4, 0xd, -0xb9, 0xb6, 0x6f, 0xc2, 0xdf, 0xc8, 0x9, 0x5a, -0x9, 0xf, 0xf9, 0x5f, 0xaf, 0xd7, 0x26, 0x7e, -0xb7, 0x15, 0xbf, 0x6d, 0xb9, 0xc8, 0x10, 0x61, -0x1a, 0x8f, 0xaf, 0xcb, 0x82, 0xe1, 0xc0, 0x3e, -0xce, 0x43, 0x44, 0x82, 0x22, 0xcb, 0x64, 0x5f, -0xa8, 0xd0, 0xfc, 0x9e, 0x5f, 0x6c, 0x3f, 0x78, -0xe9, 0x67, 0xa, 0xac, 0x22, 0x66, 0x57, 0x95, - -0xa, 0x95, 0xf0, 0xa7, 0xae, 0x1, 0x32, 0x8, -0xb3, 0xe1, 0x5c, 0x3d, 0xa4, 0x65, 0xac, 0xa0, -0x0, 0x3f, 0xad, 0xbd, 0xbb, 0xce, 0xfc, 0xb4, -0x37, 0xf1, 0xd, 0xfa, 0x6c, 0x22, 0x75, 0xea, -0x70, 0x7b, 0x6, 0x18, 0xcf, 0x50, 0x33, 0xc2, -0xe2, 0x7f, 0x35, 0xd1, 0x47, 0xd8, 0x74, 0x83, -0x5a, 0x8e, 0xe2, 0xf6, 0x2d, 0xa3, 0xa5, 0x90, -0xc2, 0x52, 0xf4, 0xd2, 0xbd, 0xa6, 0xde, 0xc2, -0x5b, 0xc6, 0xaf, 0xdc, 0xc4, 0xec, 0xd2, 0xb1, -0x17, 0xb9, 0x50, 0x8d, 0xc7, 0x57, 0xa5, 0x31, -0xa8, 0x50, 0xe6, 0xa, 0xcd, 0xe1, 0x93, 0xa1, -0xd8, 0x84, 0xf6, 0x4, 0xa5, 0x4, 0xf3, 0x4e, -0x16, 0xea, 0x91, 0x22, 0xd2, 0xeb, 0xd7, 0x82, -0xe3, 0xdb, 0x4e, 0x55, 0x5, 0xd7, 0xfd, 0x74, -0xaa, 0x87, 0xa7, 0x87, 0xb3, 0xf3, 0x9, 0x4b, -0xfe, 0x69, 0x27, 0xa, 0x1a, 0x5e, 0x67, 0xcb, - -0xe9, 0x23, 0xb, 0x62, 0xe3, 0xd9, 0xb7, 0xc4, -0x1c, 0x7a, 0xe9, 0x78, 0x3f, 0x98, 0x25, 0xef, -0x2, 0x2c, 0x2a, 0xa4, 0x71, 0x5, 0xa6, 0xa0, -0x5e, 0x1c, 0x5d, 0x4e, 0x48, 0x97, 0x9b, 0x12, -0x71, 0xe1, 0x2f, 0xf9, 0x14, 0xfd, 0xa4, 0x9d, -0x93, 0xd0, 0x64, 0x93, 0xda, 0xda, 0x8, 0x4, -0x16, 0x9b, 0xbc, 0xa7, 0xd1, 0x2, 0xbf, 0x1f, -0xed, 0x5a, 0x4c, 0x4a, 0x94, 0x29, 0xc, 0x77, -0x8b, 0xcd, 0x10, 0x37, 0xca, 0x92, 0x98, 0x1b, -0x30, 0x2f, 0x83, 0x4d, 0x53, 0x35, 0x29, 0x53, -0x87, 0x90, 0xb9, 0x38, 0x41, 0x68, 0xd0, 0x79, -0xf9, 0xf4, 0xb, 0x2e, 0x76, 0x5e, 0x39, 0xc3, -0x99, 0xa3, 0x91, 0x90, 0xf9, 0x9, 0x85, 0x9, -0x20, 0xca, 0xa1, 0x49, 0xd7, 0xd2, 0xc6, 0x8f, -0xe0, 0x15, 0x61, 0xc, 0xd6, 0xa1, 0x88, 0xdd, -0x49, 0x72, 0xa2, 0x50, 0xd2, 0xf4, 0x71, 0x3, - -0xc4, 0x7e, 0xa4, 0x9b, 0x7c, 0xf2, 0x78, 0x3f, -0x3e, 0xcc, 0x67, 0xda, 0xa9, 0x5e, 0x19, 0x27, -0x48, 0x7b, 0xbd, 0x36, 0xb9, 0xc1, 0x55, 0x34, -0x99, 0xaf, 0xb6, 0xe6, 0x29, 0xc9, 0xcc, 0x62, -0x5a, 0x5f, 0xfd, 0xa0, 0x92, 0xab, 0x61, 0x75, -0x3b, 0x17, 0x2c, 0x9, 0x3a, 0xed, 0xfd, 0x14, -0x35, 0xc0, 0xcb, 0xb9, 0x4d, 0xa2, 0x64, 0x60, -0x7, 0xe, 0x61, 0x78, 0xe1, 0x1a, 0xdd, 0xda, -0x57, 0xe9, 0xff, 0xf2, 0x6c, 0x22, 0x37, 0xa5, -0x3d, 0xfb, 0xb, 0x67, 0x40, 0x34, 0xf1, 0x8e, -0x7, 0xe4, 0x2a, 0xe4, 0x85, 0x5e, 0xa7, 0x9d, -0x9f, 0xed, 0x88, 0xc2, 0xcf, 0x0, 0xed, 0xd3, -0x77, 0x6a, 0xfc, 0x3e, 0x87, 0x56, 0x39, 0xa3, -0xa6, 0x79, 0xa7, 0xf1, 0xad, 0x98, 0x94, 0x86, -0x41, 0x68, 0x4c, 0xc6, 0xf5, 0xc3, 0xeb, 0x80, -0xc5, 0x68, 0x5f, 0x1f, 0x83, 0x20, 0x5c, 0xa3, - -0x45, 0xde, 0xf9, 0x2, 0xcf, 0xe0, 0x57, 0xc8, -0x76, 0x43, 0x75, 0x4e, 0x21, 0xa4, 0x75, 0x42, -0x81, 0xa0, 0x18, 0xe2, 0xee, 0x4, 0xed, 0x88, -0x50, 0xcc, 0xde, 0xd8, 0xa4, 0x58, 0x13, 0xe7, -0x7d, 0x88, 0x54, 0x71, 0x2c, 0x5d, 0x9a, 0xe0, -0x91, 0xf9, 0x83, 0x84, 0x1c, 0x73, 0xff, 0x6a, -0x79, 0x8b, 0x54, 0x25, 0x2f, 0x7f, 0x2f, 0xae, -0x4b, 0x9c, 0x95, 0xc8, 0x88, 0xb1, 0x75, 0xc6, -0xb6, 0xdc, 0xcf, 0x84, 0x91, 0x44, 0xb7, 0x73, -0x22, 0x30, 0x38, 0x49, 0xda, 0x1d, 0xe3, 0x19, -0xdd, 0xf1, 0x32, 0xb6, 0xaf, 0xed, 0x36, 0xde, -0xf2, 0x3e, 0xfb, 0x42, 0x11, 0x8c, 0xdc, 0x3d, -0x8c, 0xd0, 0x71, 0xdc, 0x8a, 0xe3, 0x22, 0xfb, -0xca, 0x87, 0xfb, 0x9c, 0x9a, 0xa1, 0xfb, 0xbb, -0x5b, 0x4b, 0x6b, 0xd0, 0xf5, 0x67, 0x8b, 0xd7, -0x85, 0x43, 0xb2, 0x4f, 0x9d, 0x34, 0x46, 0x23 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/verrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/verrl.inc deleted file mode 100644 index 36c5f922f9..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp01/verrl.inc +++ /dev/null @@ -1,151 +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. - ############################################################################*/ - -// VerRl - -// gid -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x2A, -// B -0x41, 0x63, 0xfd, 0x06, 0xb8, 0xb1, 0xa6, 0x32, 0xa5, 0xe3, 0xeb, 0xc4, -0x40, 0x11, 0x37, 0xc0, 0x62, 0x0d, 0xe1, 0xca, 0xe9, 0x79, 0xad, 0xff, -0x1d, 0x13, 0xb3, 0xda, 0xa0, 0x10, 0x8a, 0xa8, 0x30, 0x72, 0xa4, 0xe8, -0x27, 0xb5, 0xad, 0xdb, 0xac, 0x89, 0xd8, 0x37, 0x79, 0xd9, 0x8c, 0xd0, -0xb3, 0xef, 0x94, 0x17, 0x4f, 0x05, 0x53, 0x4c, 0x4d, 0xf0, 0x77, 0xf7, -0xb6, 0xaf, 0xb8, 0xfa, -// version -0x00, 0x00, 0x00, 0x00, -// n4 -0x00, 0x00, 0x00, 0x11, -// k's -0xdc, 0x41, 0x24, 0xe7, 0xb8, 0xf2, 0x6d, 0xc4, 0x01, 0xf9, 0x5d, 0xf8, -0xd9, 0x23, 0x32, 0x29, 0x0a, 0xe1, 0xf6, 0xdc, 0xa1, 0xef, 0x52, 0xf7, -0x3a, 0x3c, 0xe6, 0x7e, 0x3d, 0x0e, 0xe8, 0x86, 0xa9, 0x58, 0xf4, 0xfe, -0xfa, 0x8b, 0xe4, 0x1c, 0xad, 0x58, 0x5b, 0x1c, 0xc7, 0x54, 0xee, 0x7e, -0xe7, 0x12, 0x6a, 0x4b, 0x01, 0x63, 0xb4, 0xdb, 0x6e, 0xe7, 0x7a, 0xe9, -0x62, 0xa5, 0xb4, 0xe3, - -0xc3, 0x22, 0x1c, 0x3c, 0x75, 0x2e, 0x7a, 0xe2, 0xc6, 0x86, 0xf7, 0x0b, -0xba, 0x1f, 0x2d, 0xe8, 0xfa, 0xd8, 0x21, 0x59, 0xe1, 0x41, 0xd1, 0xbd, -0x78, 0xfe, 0xcd, 0x10, 0x70, 0xb9, 0xe3, 0x46, 0x9c, 0x62, 0x13, 0x53, -0x93, 0xd5, 0xf0, 0x3f, 0xfe, 0x00, 0x4c, 0x78, 0xc4, 0x4c, 0x24, 0x70, -0x56, 0xde, 0x40, 0x1a, 0x47, 0xea, 0x2b, 0xcc, 0xc7, 0x18, 0xdc, 0xa2, -0x91, 0x97, 0x0c, 0xec, - -0x64, 0x87, 0x4a, 0x72, 0x28, 0x6e, 0x35, 0xa7, 0x38, 0x21, 0x8c, 0x44, -0x74, 0xde, 0x34, 0x2c, 0x64, 0xba, 0x9e, 0xf1, 0x53, 0x09, 0xa8, 0x75, -0x85, 0xcc, 0x29, 0x8c, 0x58, 0x1f, 0xf9, 0xde, 0x2d, 0xab, 0xca, 0xc3, -0x46, 0xf4, 0xb9, 0x21, 0x63, 0x19, 0xbc, 0xf4, 0x1a, 0x18, 0xb3, 0xc5, -0x1e, 0xbc, 0x37, 0xde, 0x99, 0xef, 0xa7, 0x32, 0x2b, 0x4d, 0xb1, 0xe9, -0xe8, 0xb7, 0x8c, 0xff, - -0xdd, 0x77, 0x59, 0x88, 0xd7, 0x91, 0xee, 0x4c, 0x30, 0x8b, 0x8e, 0x81, -0x6f, 0x83, 0x4f, 0x82, 0x76, 0xca, 0xfa, 0xbc, 0x34, 0xa2, 0x48, 0xe4, -0xde, 0x4b, 0x55, 0x18, 0xcc, 0xf6, 0xdd, 0x11, 0x97, 0x6a, 0xf7, 0x3a, -0x25, 0x4c, 0x84, 0x06, 0xd9, 0xc4, 0x58, 0x1d, 0xc5, 0xac, 0xf9, 0x47, -0x33, 0x48, 0x14, 0x61, 0xcb, 0xba, 0x10, 0x83, 0x6b, 0x20, 0xb3, 0x72, -0x8e, 0xee, 0x72, 0x26, - -0x9e, 0x5e, 0xb2, 0x19, 0x23, 0x86, 0x14, 0x5a, 0x5c, 0xb0, 0x0a, 0x41, -0x71, 0x6c, 0x88, 0xde, 0xd1, 0x1c, 0xa5, 0xa4, 0x80, 0xba, 0x41, 0x9c, -0xd3, 0xd8, 0xa6, 0x8f, 0x6f, 0x3e, 0xd8, 0x04, 0x8f, 0x8b, 0x78, 0x13, -0x7b, 0xd4, 0x9d, 0x92, 0xe4, 0xda, 0x0e, 0xfe, 0xa3, 0xd1, 0xda, 0x8f, -0x6a, 0x62, 0x8d, 0x7c, 0x7c, 0x00, 0x33, 0x2e, 0x68, 0xa8, 0x39, 0x3c, -0x86, 0x7b, 0x02, 0x20, - -0x6d, 0x53, 0x62, 0x9e, 0xd3, 0x2a, 0x14, 0x3c, 0xec, 0x3f, 0x2c, 0x22, -0x37, 0xe4, 0xb7, 0xf4, 0x4b, 0x44, 0xad, 0xcb, 0xa4, 0xf0, 0xb6, 0x4a, -0x5a, 0x1c, 0x74, 0x41, 0x7c, 0x57, 0xe5, 0xbc, 0xa9, 0x60, 0xfc, 0xf6, -0x45, 0x53, 0xa1, 0x6f, 0x9f, 0x76, 0xf3, 0x15, 0x00, 0x8f, 0xae, 0xd8, -0xf6, 0x5e, 0x3d, 0x39, 0x85, 0xa2, 0xbe, 0xc2, 0xc0, 0x53, 0xaf, 0xd5, -0xa6, 0x5f, 0x57, 0xf3, - -0x24, 0x4d, 0x10, 0x98, 0xde, 0xbc, 0x37, 0x64, 0x60, 0xf5, 0x9d, 0x92, -0x65, 0x03, 0x36, 0xbb, 0x40, 0x03, 0x64, 0x12, 0x5f, 0xca, 0x63, 0x2d, -0x53, 0xe8, 0xa5, 0xa5, 0x7b, 0x5f, 0x82, 0x76, 0xbb, 0xd6, 0xb2, 0xf8, -0x26, 0xc3, 0x9d, 0xfa, 0x2a, 0xb2, 0x73, 0xe3, 0xab, 0x6c, 0x9e, 0xbd, -0x6a, 0xa4, 0x3c, 0x29, 0x4b, 0x70, 0xf8, 0x22, 0x0d, 0xde, 0x78, 0xe1, -0x05, 0x50, 0x76, 0xba, - -0x08, 0xf1, 0x64, 0xbc, 0x00, 0x43, 0xac, 0x2e, 0x11, 0x46, 0xad, 0xb9, -0x02, 0x48, 0x05, 0xd1, 0xfd, 0x9f, 0x63, 0x65, 0x1c, 0xcc, 0x62, 0x33, -0x12, 0x95, 0xdb, 0xd2, 0xff, 0xd7, 0x0e, 0x8b, 0x64, 0x92, 0xd5, 0x44, -0x3e, 0x30, 0xf8, 0xfc, 0x49, 0xe3, 0x4b, 0x27, 0x82, 0xa8, 0x90, 0x4b, -0xca, 0xa1, 0x0b, 0xfd, 0x1e, 0xe1, 0x9b, 0xad, 0xcc, 0x08, 0x7e, 0x6a, -0x03, 0xef, 0xec, 0x07, - -0x03, 0xf8, 0x09, 0xa5, 0x9e, 0xd3, 0x5e, 0x75, 0x0c, 0x80, 0x8b, 0x13, -0x54, 0xa2, 0x25, 0x05, 0x5a, 0xa8, 0x82, 0xb4, 0xa2, 0x33, 0xc4, 0xb3, -0xb5, 0xf7, 0xa8, 0x78, 0x33, 0x6a, 0xef, 0x50, 0x14, 0xf1, 0x17, 0xff, -0x30, 0x59, 0x87, 0xe4, 0x2c, 0xb7, 0x20, 0x9f, 0x17, 0xb8, 0x7b, 0x32, -0xe1, 0x6a, 0x3c, 0xda, 0x51, 0x09, 0x79, 0x33, 0x0b, 0x8d, 0x9c, 0x11, -0xbe, 0x0c, 0xcb, 0x98, - -0xd7, 0x9f, 0xa6, 0x0b, 0x21, 0xab, 0x8b, 0x56, 0xc1, 0xae, 0xca, 0x76, -0xa9, 0x4e, 0x41, 0xcd, 0x9d, 0xfd, 0xa1, 0x15, 0xc0, 0x3a, 0x51, 0xd7, -0x1d, 0x12, 0x7c, 0x9a, 0xe4, 0x11, 0x0b, 0xee, 0x1f, 0x5f, 0x2b, 0x1c, -0x39, 0xca, 0x6a, 0x87, 0x37, 0xe0, 0xd4, 0xa2, 0xef, 0x05, 0xc1, 0x92, -0xcd, 0x2a, 0x5a, 0x7d, 0x1b, 0xc6, 0xde, 0xf7, 0x57, 0xa2, 0xea, 0x17, -0x63, 0x94, 0x00, 0x81, - -0xd6, 0xf7, 0x2d, 0x50, 0x48, 0x25, 0x69, 0xed, 0x4f, 0x19, 0x42, 0x19, -0x72, 0xcd, 0x57, 0x83, 0xde, 0x1b, 0x3f, 0x46, 0xa6, 0x95, 0x50, 0x60, -0x48, 0xbc, 0xb9, 0xe3, 0xe6, 0x05, 0x08, 0x58, 0xa5, 0x15, 0x80, 0x35, -0xcd, 0x27, 0x2d, 0xd0, 0xc5, 0xe5, 0x29, 0x7f, 0x43, 0x02, 0xc1, 0x0a, -0xe4, 0x47, 0x0e, 0x55, 0x7a, 0xbd, 0x44, 0xb0, 0x31, 0x90, 0x55, 0xa0, -0x38, 0x16, 0x0e, 0x2a, - -0xb5, 0x12, 0xe8, 0x99, 0x4e, 0xaf, 0x15, 0xa7, 0x39, 0xa2, 0xf2, 0x50, -0x88, 0xc4, 0x48, 0x70, 0xb4, 0xf1, 0x54, 0xd0, 0x58, 0xdb, 0x91, 0x43, -0xc1, 0x64, 0x49, 0x0b, 0xc6, 0x06, 0xb6, 0x4a, 0x25, 0x78, 0x9d, 0xa9, -0x8b, 0x4e, 0x1b, 0x33, 0xa9, 0x6f, 0xa3, 0x5c, 0x53, 0xd5, 0xab, 0x0a, -0xf4, 0x49, 0x9d, 0x67, 0xc5, 0x6a, 0x4b, 0x81, 0x84, 0x4d, 0x6c, 0xd8, -0x8f, 0xe4, 0xca, 0x1f, - -0x80, 0xe6, 0x23, 0x82, 0xf5, 0x0c, 0x24, 0x37, 0x4e, 0xd6, 0x2d, 0x29, -0x80, 0x69, 0x8d, 0x04, 0x72, 0x82, 0x7f, 0xe5, 0x81, 0x50, 0xfd, 0x53, -0x7c, 0xc3, 0xd6, 0xc8, 0x80, 0xea, 0x67, 0x76, 0xe4, 0x17, 0x98, 0xac, -0x3c, 0x4a, 0x01, 0x86, 0xb6, 0xb7, 0x07, 0x20, 0x31, 0x0a, 0x4d, 0x08, -0xf0, 0xe0, 0xc0, 0xea, 0xb8, 0x82, 0xfa, 0x91, 0x76, 0x01, 0xe6, 0xe4, -0x45, 0x54, 0xdf, 0x75, - -0x32, 0xdb, 0x43, 0x97, 0x5e, 0x3b, 0x23, 0x42, 0x9d, 0xc7, 0xbc, 0x2a, -0x05, 0x8f, 0xc0, 0xfb, 0x8b, 0xd6, 0xd7, 0x4b, 0xbf, 0x51, 0x34, 0x11, -0xcf, 0xaa, 0x15, 0x6b, 0x0c, 0x4e, 0xf1, 0x05, 0xff, 0x2e, 0x1e, 0x09, -0x4a, 0xa0, 0xfa, 0xf4, 0x59, 0x61, 0x2a, 0x0f, 0x62, 0x09, 0x75, 0x55, -0x87, 0x21, 0x7d, 0xc1, 0x97, 0xef, 0x89, 0x5d, 0xb8, 0x45, 0x63, 0xc6, -0x28, 0x4f, 0x84, 0x22, - -0x42, 0x71, 0xbc, 0xc5, 0x4c, 0xf2, 0x5e, 0xe8, 0x91, 0xda, 0x0c, 0x86, -0xb7, 0x81, 0x66, 0xad, 0xef, 0xcd, 0x89, 0x35, 0xb8, 0xdc, 0x8f, 0x24, -0x38, 0x17, 0x91, 0x65, 0xf4, 0x45, 0x71, 0xf9, 0x89, 0xcf, 0x54, 0x0b, -0x8c, 0x35, 0xa5, 0x74, 0x89, 0x41, 0x9f, 0x1e, 0xc1, 0xef, 0x5d, 0xc3, -0xba, 0x46, 0x27, 0xc3, 0xe6, 0x88, 0x4b, 0xc7, 0xfe, 0x8b, 0x8f, 0x0e, -0x7c, 0xcd, 0xdc, 0xce, - -0x0c, 0x81, 0x66, 0xa5, 0x23, 0xa8, 0x87, 0x81, 0x03, 0x09, 0x36, 0x04, -0x88, 0xd7, 0xbf, 0x33, 0xb5, 0x40, 0x65, 0xf6, 0x65, 0xcc, 0x05, 0x6c, -0xa1, 0x3c, 0xfa, 0x5d, 0x0c, 0x2a, 0x28, 0x53, 0x03, 0xae, 0x59, 0xdd, -0x99, 0x80, 0xb7, 0x81, 0x68, 0xaf, 0xf0, 0xf4, 0xcb, 0xd0, 0xa3, 0xde, -0x7d, 0x1f, 0x5c, 0x53, 0x20, 0x25, 0xe2, 0x0f, 0x08, 0x40, 0xb2, 0xca, -0xc5, 0x81, 0x02, 0xf4, - -0x40, 0xcf, 0x75, 0xb0, 0x18, 0x9c, 0x82, 0x40, 0xea, 0x98, 0x2d, 0x24, -0x97, 0xb3, 0x1a, 0x2d, 0x78, 0x56, 0x2a, 0x21, 0x51, 0x38, 0x19, 0x1a, -0x47, 0x58, 0x16, 0xa9, 0xf8, 0x9c, 0xe9, 0x16, 0xad, 0xa4, 0x9c, 0x11, -0xce, 0xcf, 0x19, 0x8a, 0x37, 0x64, 0xab, 0x81, 0xe9, 0x35, 0x9e, 0x18, -0x3e, 0x06, 0x6f, 0xb8, 0x89, 0xf0, 0x67, 0x75, 0xeb, 0xbc, 0x4e, 0xff, -0x95, 0xea, 0x12, 0x40, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/cmpprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/cmpprivkey.inc deleted file mode 100644 index 902ee73a63..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/cmpprivkey.inc +++ /dev/null @@ -1,36 +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 Test data. - * - * Type : Intel(R) EPID 2.0 compressed private key - * Group : grpX - * Signer : member9 - */ -//unsigned char cmpprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xaf, 0x49, 0xd9, 0xba, 0x72, 0x81, 0xa7, 0x2f, - 0xcc, 0x5a, 0xe3, 0x13, 0xed, 0x5c, 0xf2, 0x5b, - 0xf9, 0x56, 0x23, 0x39, 0x4b, 0xc2, 0xf6, 0x29, - 0xb7, 0x14, 0x61, 0x4c, 0x4e, 0x46, 0x9c, 0x35, - 0xaf, 0x5a, 0x70, 0xdd, 0x2d, 0x06, 0x13, 0x55, - 0xc9, 0x70, 0xb6, 0xa9, 0x90, 0xd6, 0x2f, 0x98, - 0x69, 0x92, 0x82, 0x7c, 0x44, 0x77, 0x81, 0x9e, - 0xe9, 0x35, 0x57, 0x87, 0x5b, 0x3a, 0xd3, 0xbf -//}; -//unsigned int cmpprivkey_dat_len = 80; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/mprivkey.inc deleted file mode 100644 index 58db4cdc0e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/cmember9/mprivkey.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : member9 - */ -//unsigned char mprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xaf, 0x49, 0xd9, 0xba, 0x72, 0x81, 0xa7, 0x2f, - 0xcc, 0x5a, 0xe3, 0x13, 0xed, 0x5c, 0xf2, 0x5b, - 0xf9, 0x56, 0x23, 0x39, 0x4b, 0xc2, 0xf6, 0x29, - 0xb7, 0x14, 0x61, 0x4c, 0x4e, 0x46, 0x9c, 0x35, - 0xae, 0x8d, 0xc4, 0x20, 0xb1, 0x9a, 0x2f, 0x21, - 0x66, 0xae, 0x93, 0xd9, 0xe3, 0xfb, 0x65, 0xd6, - 0xbf, 0x3c, 0x97, 0x59, 0x43, 0x37, 0x51, 0x5e, - 0x94, 0x9f, 0xb7, 0xcd, 0x49, 0x71, 0xee, 0xef, - 0x92, 0x9c, 0xdc, 0xfc, 0x54, 0x9d, 0xa5, 0x42, - 0x51, 0x5e, 0xec, 0x41, 0x1a, 0x4c, 0xb7, 0xf1, - 0x5f, 0x34, 0x8d, 0x3a, 0x4c, 0x75, 0x0e, 0xc9, - 0x3f, 0xc6, 0x46, 0x08, 0x8d, 0xbb, 0xbf, 0xe1, - 0xc1, 0xb0, 0xb5, 0x16, 0x13, 0xaa, 0x45, 0x66, - 0xaa, 0x57, 0x3f, 0x96, 0x0f, 0x54, 0x62, 0xd9, - 0x90, 0x13, 0x5e, 0x5b, 0xdd, 0x2a, 0xb1, 0xfd, - 0x51, 0xef, 0x85, 0xa9, 0x8b, 0xf8, 0x3d, 0x78 -//}; -//unsigned int mprivkey_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/iprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/iprivkey.inc deleted file mode 100644 index b3adabd4f8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/iprivkey.inc +++ /dev/null @@ -1,31 +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 Test data. - * - * Type : Intel(R) EPID 2.0 issuing private key - * Group : grpX - */ -//unsigned char iprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xb5, 0xd4, 0xfe, 0x09, 0x91, 0x97, 0xd0, 0x9c, - 0x39, 0x20, 0x94, 0x7f, 0xe2, 0x30, 0xbb, 0x5a, - 0xea, 0x00, 0x35, 0xfe, 0x8d, 0x49, 0x3c, 0x86, - 0x56, 0xd8, 0xec, 0x55, 0xc8, 0x86, 0xe5, 0xb5 -//}; -//unsigned int iprivkey_dat_len = 48; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/mprivkey.inc deleted file mode 100644 index 67f52a093b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/mprivkey.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : member0 - */ -//unsigned char mprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x63, 0xd3, 0x48, 0x19, 0x93, 0x92, 0x3d, 0xfc, - 0x78, 0xcc, 0x01, 0x3f, 0x2a, 0x29, 0x73, 0xd8, - 0x1b, 0x9a, 0xbe, 0x70, 0x66, 0x71, 0xfa, 0x47, - 0x66, 0xc5, 0xd4, 0xe5, 0x07, 0xcb, 0xe2, 0x51, - 0x47, 0x4a, 0x06, 0x9a, 0x29, 0xeb, 0x99, 0x0e, - 0x1b, 0x6b, 0x24, 0x88, 0x8f, 0x11, 0x4b, 0x9d, - 0xb4, 0x82, 0xf6, 0x04, 0x79, 0xde, 0x9b, 0xe7, - 0x83, 0x63, 0x27, 0x91, 0x46, 0xa8, 0x52, 0x27, - 0xb2, 0xed, 0xf0, 0x3b, 0x61, 0x78, 0x50, 0x20, - 0x61, 0x97, 0x3f, 0x4d, 0xba, 0x17, 0xfc, 0x50, - 0x65, 0x0a, 0xff, 0xec, 0x64, 0x14, 0xa2, 0x53, - 0xee, 0x2d, 0xff, 0xc9, 0x2d, 0xb3, 0xbe, 0xa0, - 0xc4, 0x80, 0xd8, 0xd9, 0xfa, 0xa9, 0xb6, 0x1a, - 0xa0, 0x24, 0xcc, 0xfa, 0x4f, 0x03, 0x37, 0xe2, - 0xdf, 0xff, 0x35, 0x2e, 0x87, 0xd3, 0x3a, 0x2b, - 0x58, 0x00, 0x54, 0x32, 0x8b, 0xe4, 0x83, 0xb5 -//}; -//unsigned int mprivkey_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0.inc deleted file mode 100644 index 3b033accc6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59, - 0x15, 0xdb, 0xf7, 0x26, 0xde, 0xc4, 0x1f, 0x31, - 0xe8, 0x4c, 0x11, 0xe6, 0x60, 0xdf, 0xc4, 0xde, - 0xa1, 0x42, 0xbb, 0x55, 0x22, 0x0e, 0xea, 0x5f, - 0xc0, 0xf7, 0x78, 0x8a, 0x15, 0xcd, 0xf4, 0x03, - 0x97, 0x1b, 0x88, 0xd7, 0xcc, 0x86, 0xaf, 0x54, - 0x65, 0xa1, 0x18, 0x10, 0x39, 0x53, 0x95, 0x1f, - 0x93, 0x74, 0x9b, 0xb7, 0x39, 0xc7, 0x9a, 0x81, - 0x72, 0x2b, 0x67, 0x12, 0xe3, 0x42, 0xbc, 0x76, - 0xb6, 0x03, 0xbe, 0xc2, 0x13, 0x7f, 0xb2, 0x86, - 0xc7, 0x20, 0x27, 0xcc, 0x30, 0x1e, 0xa7, 0xf2, - 0xfe, 0x96, 0x5b, 0x85, 0xa6, 0xac, 0xef, 0x41, - 0x1f, 0x12, 0xe7, 0x6f, 0x22, 0xea, 0xf1, 0xac, - 0xb3, 0x48, 0xef, 0xdf, 0x39, 0x11, 0xe3, 0x2f, - 0x16, 0x98, 0x77, 0x4f, 0x6f, 0x71, 0x40, 0x03, - 0xdf, 0xb7, 0xa3, 0x10, 0x08, 0xc7, 0xae, 0x77, - 0x87, 0x3d, 0xd6, 0x8b, 0xc8, 0xd4, 0x00, 0x05, - 0x4f, 0xd3, 0xb2, 0x21, 0x71, 0x28, 0x97, 0x2b, - 0xda, 0x05, 0x07, 0x87, 0x9e, 0x32, 0x24, 0xe7, - 0x0c, 0xa2, 0x37, 0x32, 0xf0, 0xfa, 0xec, 0x07, - 0x5e, 0x5e, 0xec, 0x45, 0xdd, 0xa3, 0x68, 0x4d, - 0x8a, 0x8b, 0xd5, 0xc3, 0x0d, 0x91, 0xd2, 0xc4, - 0x3d, 0x04, 0x24, 0xe9, 0xbc, 0x65, 0xb9, 0xee, - 0x2d, 0x52, 0xf7, 0x97, 0xe5, 0xa0, 0x84, 0x16, - 0x57, 0x53, 0xd5, 0x7b, 0xee, 0xb2, 0xa6, 0x9c, - 0x77, 0xad, 0x9d, 0x73, 0x0b, 0x53, 0xd8, 0x33, - 0x83, 0x8f, 0xb2, 0x7c, 0x2e, 0x4b, 0x12, 0xf2, - 0xbd, 0xbb, 0x7c, 0x25, 0x80, 0xa8, 0x04, 0x24, - 0x39, 0x90, 0x61, 0xdf, 0x72, 0x21, 0x05, 0xd3, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x5b, 0x9f, 0xd9, 0x96, 0x82, 0x57, 0x4c, 0xa7, - 0xd8, 0x66, 0xe6, 0x2f, 0x56, 0x46, 0x7a, 0xa4, - 0xa6, 0x74, 0x28, 0x38, 0xa2, 0x38, 0x28, 0xb3, - 0xb6, 0x5b, 0x95, 0xf5, 0xd6, 0x6c, 0x37, 0xb1, - 0x14, 0x59, 0xf6, 0x42, 0xe9, 0x5c, 0xee, 0x45, - 0x51, 0x5b, 0xe7, 0x3b, 0xd9, 0x0c, 0x44, 0x40, - 0x3a, 0x9b, 0x2d, 0x9a, 0xfb, 0x07, 0xdf, 0xe3, - 0x58, 0xdc, 0x3d, 0x62, 0xc0, 0x7c, 0x8f, 0xa9, - 0x32, 0x48, 0x7d, 0x8f, 0x4d, 0xe0, 0x26, 0x72, - 0xe9, 0x1e, 0xcb, 0x7f, 0x10, 0x93, 0x00, 0xf8, - 0xca, 0x02, 0x3e, 0x21, 0x99, 0xee, 0xae, 0x57, - 0x8d, 0xef, 0xa3, 0x29, 0xef, 0xb7, 0xfc, 0x11, - 0xf5, 0x8b, 0x19, 0xc7, 0xfb, 0x9c, 0xc7, 0xc1, - 0x7e, 0x35, 0x2c, 0x78, 0xd8, 0x15, 0x60, 0xe6, - 0xbf, 0xf5, 0xba, 0x21, 0xeb, 0x60, 0x94, 0x2e, - 0x37, 0xe2, 0xa8, 0x11, 0xab, 0xfd, 0xea, 0x26, - 0xab, 0x82, 0x6c, 0x24, 0x38, 0xbb, 0x56, 0x10, - 0x5b, 0xb9, 0xcb, 0xe7, 0xc2, 0xbe, 0x4c, 0xf7, - 0x43, 0xe8, 0xca, 0xeb, 0x6c, 0x57, 0xcb, 0x01, - 0xb7, 0x54, 0x84, 0x6a, 0x61, 0xe0, 0x37, 0x3a, - 0xe1, 0xfa, 0xae, 0x67, 0x06, 0x81, 0xbe, 0x4c, - 0x2a, 0xc8, 0xf1, 0x17, 0x75, 0xd3, 0xa9, 0x75, - 0xa7, 0xa9, 0x72, 0x6b, 0xe9, 0xd2, 0x32, 0x63, - 0x8b, 0x37, 0xf7, 0x45, 0xa4, 0x43, 0x9c, 0x2d, - 0x12, 0x40, 0x05, 0x9f, 0xe1, 0x97, 0xee, 0xdb, - 0x92, 0x6a, 0x98, 0xe4, 0x66, 0x83, 0xdb, 0x6e, - 0xdf, 0xbe, 0x53, 0x36, 0x68, 0x38, 0xb2, 0x6b, - 0x1c, 0x66, 0xe6, 0xc8, 0xfc, 0x1c, 0x25, 0x39, - 0xbf, 0xd7, 0x0e, 0x4c, 0x2d, 0x36, 0x78, 0xfe, - 0xdf, 0x47, 0x51, 0x19, 0xb1, 0xf2, 0x4b, 0xd8, - 0x55, 0xed, 0xab, 0x3d, 0x2e, 0x4a, 0x18, 0x78, - 0xb1, 0x29, 0x4a, 0xe9, 0xad, 0xab, 0xe8, 0xcf, - 0xa2, 0x8f, 0xf4, 0xc3, 0x70, 0x6b, 0x4d, 0x18, - 0xfa, 0x0d, 0xea, 0x9d, 0xf1, 0x81, 0x51, 0x05, - 0x85, 0x8f, 0x00, 0xb2, 0x6b, 0xfe, 0x64, 0xfe, - 0xbc, 0x65, 0xcd, 0x14, 0xcd, 0x65, 0xe8, 0xc6, - 0xe2, 0x21, 0xb8, 0x95, 0x5e, 0x62, 0xb5, 0x4d, - 0x98, 0x0e, 0x8e, 0xb2, 0xba, 0x9b, 0x07, 0xd4, - 0xa8, 0xb6, 0x01, 0xe4, 0xe6, 0x8f, 0xdc, 0x69, - 0x06, 0xe0, 0x0a, 0x53, 0x94, 0xef, 0x07, 0x05, - 0xb2, 0x33, 0x1d, 0xb4, 0x5a, 0x8f, 0x88, 0x24, - 0xee, 0x28, 0x61, 0x80, 0x58, 0x95, 0xc6, 0x1c, - 0x8d, 0xb3, 0xb1, 0x9c, 0x9c, 0x7a, 0x5e, 0xc6, - 0x75, 0xe1, 0x0a, 0x75, 0xce, 0xb6, 0xb2, 0x60, - 0x7b, 0xf8, 0x48, 0xb9, 0xd3, 0x62, 0x44, 0xa4, - 0x32, 0x00, 0xd7, 0xf5, 0xc9, 0x4e, 0xc4, 0xba, - 0x76, 0xf3, 0x6c, 0x25, 0x55, 0xd0, 0x69, 0x92, - 0x19, 0x10, 0xb5, 0xf6, 0x27, 0x50, 0xaa, 0x99, - 0x61, 0xfe, 0x6e, 0x6b, 0x94, 0xb2, 0x55, 0x69, - 0x9b, 0xd1, 0x93, 0x92, 0xdc, 0x68, 0xe3, 0x26, - 0x6a, 0xc7, 0xf4, 0xdf, 0x50, 0xcb, 0x94, 0x82, - 0x57, 0xe8, 0xc0, 0x50, 0xee, 0x21, 0xd0, 0x11, - 0xcc, 0x17, 0x9a, 0x40, 0xb9, 0x11, 0x54, 0xe9, - 0x20, 0x43, 0x97, 0x33, 0xfb, 0xda, 0x25, 0x67, - 0x94, 0x0d, 0x6e, 0x08, 0x59, 0x54, 0x75, 0xb5, - 0x3c, 0x85, 0x4f, 0xfe, 0x21, 0x1a, 0xc4, 0x74, - 0xdc, 0x1f, 0x3c, 0x1b, 0x6e, 0x8d, 0x66, 0xc2, - 0xdb, 0x6f, 0x02, 0x1a, 0x3d, 0x23, 0xc5, 0x14, - 0xbf, 0x9c, 0xb1, 0x87, 0x3f, 0x14, 0x82, 0x8b, - 0xe2, 0x20, 0x2a, 0x64, 0xe5, 0xb3, 0x1d, 0x2e -//}; -//unsigned int sig_grpx_member0_sha256_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0_rl_singleentry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0_rl_singleentry.inc deleted file mode 100644 index ba9b3f4470..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0_rl_singleentry.inc +++ /dev/null @@ -1,95 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59, - 0x15, 0xdb, 0xf7, 0x26, 0xde, 0xc4, 0x1f, 0x31, - 0xe8, 0x4c, 0x11, 0xe6, 0x60, 0xdf, 0xc4, 0xde, - 0xa1, 0x42, 0xbb, 0x55, 0x22, 0x0e, 0xea, 0x5f, - 0xc0, 0xf7, 0x78, 0x8a, 0x15, 0xcd, 0xf4, 0x03, - 0x97, 0x1b, 0x88, 0xd7, 0xcc, 0x86, 0xaf, 0x54, - 0x65, 0xa1, 0x18, 0x10, 0x39, 0x53, 0x95, 0x1f, - 0x93, 0x74, 0x9b, 0xb7, 0x39, 0xc7, 0x9a, 0x81, - 0x72, 0x2b, 0x67, 0x12, 0xe3, 0x42, 0xbc, 0x76, - 0xb6, 0x03, 0xbe, 0xc2, 0x13, 0x7f, 0xb2, 0x86, - 0xc7, 0x20, 0x27, 0xcc, 0x30, 0x1e, 0xa7, 0xf2, - 0xfe, 0x96, 0x5b, 0x85, 0xa6, 0xac, 0xef, 0x41, - 0x1f, 0x12, 0xe7, 0x6f, 0x22, 0xea, 0xf1, 0xac, - 0xb3, 0x48, 0xef, 0xdf, 0x39, 0x11, 0xe3, 0x2f, - 0x16, 0x98, 0x77, 0x4f, 0x6f, 0x71, 0x40, 0x03, - 0xdf, 0xb7, 0xa3, 0x10, 0x08, 0xc7, 0xae, 0x77, - 0x87, 0x3d, 0xd6, 0x8b, 0xc8, 0xd4, 0x00, 0x05, - 0x4f, 0xd3, 0xb2, 0x21, 0x71, 0x28, 0x97, 0x2b, - 0xda, 0x05, 0x07, 0x87, 0x9e, 0x32, 0x24, 0xe7, - 0x0c, 0xa2, 0x37, 0x32, 0xf0, 0xfa, 0xec, 0x07, - 0x5e, 0x5e, 0xec, 0x45, 0xdd, 0xa3, 0x68, 0x4d, - 0x8a, 0x8b, 0xd5, 0xc3, 0x0d, 0x91, 0xd2, 0xc4, - 0x3d, 0x04, 0x24, 0xe9, 0xbc, 0x65, 0xb9, 0xee, - 0x2d, 0x52, 0xf7, 0x97, 0xe5, 0xa0, 0x84, 0x16, - 0x57, 0x53, 0xd5, 0x7b, 0xee, 0xb2, 0xa6, 0x9c, - 0x77, 0xad, 0x9d, 0x73, 0x0b, 0x53, 0xd8, 0x33, - 0x83, 0x8f, 0xb2, 0x7c, 0x2e, 0x4b, 0x12, 0xf2, - 0xbd, 0xbb, 0x7c, 0x25, 0x80, 0xa8, 0x04, 0x24, - 0x39, 0x90, 0x61, 0xdf, 0x72, 0x21, 0x05, 0xd3, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x5b, 0x9f, 0xd9, 0x96, 0x82, 0x57, 0x4c, 0xa7, - 0xd8, 0x66, 0xe6, 0x2f, 0x56, 0x46, 0x7a, 0xa4, - 0xa6, 0x74, 0x28, 0x38, 0xa2, 0x38, 0x28, 0xb3, - 0xb6, 0x5b, 0x95, 0xf5, 0xd6, 0x6c, 0x37, 0xb1, - 0x14, 0x59, 0xf6, 0x42, 0xe9, 0x5c, 0xee, 0x45, - 0x51, 0x5b, 0xe7, 0x3b, 0xd9, 0x0c, 0x44, 0x40, - 0x3a, 0x9b, 0x2d, 0x9a, 0xfb, 0x07, 0xdf, 0xe3, - 0x58, 0xdc, 0x3d, 0x62, 0xc0, 0x7c, 0x8f, 0xa9, - 0x32, 0x48, 0x7d, 0x8f, 0x4d, 0xe0, 0x26, 0x72, - 0xe9, 0x1e, 0xcb, 0x7f, 0x10, 0x93, 0x00, 0xf8, - 0xca, 0x02, 0x3e, 0x21, 0x99, 0xee, 0xae, 0x57, - 0x8d, 0xef, 0xa3, 0x29, 0xef, 0xb7, 0xfc, 0x11, - 0xf5, 0x8b, 0x19, 0xc7, 0xfb, 0x9c, 0xc7, 0xc1, - 0x7e, 0x35, 0x2c, 0x78, 0xd8, 0x15, 0x60, 0xe6, - 0xbf, 0xf5, 0xba, 0x21, 0xeb, 0x60, 0x94, 0x2e, - 0x37, 0xe2, 0xa8, 0x11, 0xab, 0xfd, 0xea, 0x26, - 0xab, 0x82, 0x6c, 0x24, 0x38, 0xbb, 0x56, 0x10, - 0x5b, 0xb9, 0xcb, 0xe7, 0xc2, 0xbe, 0x4c, 0xf7, - 0x43, 0xe8, 0xca, 0xeb, 0x6c, 0x57, 0xcb, 0x01, - 0xb7, 0x54, 0x84, 0x6a, 0x61, 0xe0, 0x37, 0x3a -//}; -//unsigned int sig_grpx_member0_sha256_bsn0_msg0_dat_len = 520; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg1.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg1.inc deleted file mode 100644 index 28a6a45def..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg1.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg1" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_sha256_bsn0_msg1_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59, - 0x52, 0xbb, 0x68, 0x9d, 0x22, 0x68, 0x8c, 0xc4, - 0x51, 0x27, 0x21, 0x02, 0x87, 0x4a, 0xb0, 0x39, - 0x7e, 0xdc, 0xb8, 0xbb, 0x39, 0x08, 0x76, 0xac, - 0xbb, 0x39, 0xc7, 0x46, 0xed, 0xfa, 0xb2, 0x43, - 0xb2, 0xdb, 0xf9, 0xd5, 0x46, 0x9a, 0xc7, 0x6c, - 0xbd, 0xb3, 0x0b, 0x70, 0x4f, 0xcd, 0xf0, 0x12, - 0x15, 0x5f, 0x42, 0x56, 0x8c, 0xd9, 0x04, 0xef, - 0x67, 0xa0, 0x21, 0xe1, 0x97, 0x99, 0x50, 0x11, - 0x38, 0x67, 0x95, 0x92, 0x63, 0x14, 0xed, 0xa2, - 0x34, 0xdb, 0x2f, 0x70, 0x01, 0x3e, 0xf2, 0x68, - 0x86, 0x44, 0x76, 0x31, 0xd2, 0x82, 0xaa, 0x82, - 0x4f, 0x63, 0x86, 0xdb, 0xed, 0xa4, 0x9c, 0xff, - 0x3d, 0xeb, 0x80, 0xfe, 0x39, 0xf9, 0x27, 0xd0, - 0x27, 0x63, 0x25, 0xb0, 0x3f, 0x27, 0x6d, 0x53, - 0x74, 0xc7, 0x4c, 0xae, 0x75, 0x4e, 0x1c, 0xd0, - 0xb4, 0x0a, 0xd0, 0x15, 0x24, 0x40, 0x87, 0x17, - 0x56, 0x5d, 0xa6, 0xfb, 0x4d, 0x12, 0xc7, 0x2a, - 0x1c, 0x11, 0x5c, 0x81, 0x1d, 0x80, 0x82, 0x01, - 0xa5, 0x9b, 0x2b, 0x8a, 0xe5, 0x1a, 0x77, 0x36, - 0xcb, 0x40, 0xb1, 0xbd, 0x60, 0x1c, 0x92, 0x0c, - 0xbf, 0xa6, 0xe5, 0xd4, 0x2b, 0x26, 0xa9, 0x99, - 0xf4, 0x64, 0x8e, 0x35, 0xaa, 0xab, 0x3f, 0x5f, - 0x8c, 0x35, 0x09, 0xb6, 0x96, 0x09, 0x93, 0x35, - 0xe3, 0x77, 0xfb, 0xb0, 0x2f, 0xa0, 0xd2, 0x69, - 0x8f, 0x13, 0xe1, 0x03, 0x87, 0x4e, 0xdf, 0xdd, - 0x67, 0x14, 0x3b, 0xb0, 0x1e, 0x43, 0xbe, 0x75, - 0x38, 0x1a, 0x06, 0xee, 0xab, 0xa8, 0x67, 0xf2, - 0x67, 0x97, 0x2c, 0x36, 0x24, 0x62, 0x48, 0x61, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x69, 0x60, 0x39, 0xdb, 0xa7, 0x11, 0xf4, 0xa3, - 0xee, 0x42, 0x45, 0xcf, 0x2a, 0x2b, 0xfc, 0xe0, - 0x95, 0x0c, 0x30, 0x14, 0xee, 0x49, 0xdc, 0x75, - 0xf1, 0xcc, 0xeb, 0xec, 0x6e, 0xdc, 0xd2, 0xf3, - 0x89, 0x9f, 0xfc, 0xd3, 0x18, 0xfe, 0xb1, 0x49, - 0x0f, 0x97, 0xea, 0xa1, 0x43, 0xb4, 0xef, 0xac, - 0xd8, 0x5f, 0x29, 0x87, 0x00, 0x7a, 0x81, 0xdc, - 0x89, 0xb1, 0x74, 0x18, 0x93, 0xa0, 0x19, 0x3b, - 0x22, 0x27, 0xe3, 0x8c, 0x3f, 0x09, 0x20, 0x4d, - 0x23, 0x8b, 0xab, 0x97, 0xa3, 0xfa, 0xc5, 0x03, - 0x7e, 0x62, 0xa0, 0xcc, 0x8b, 0x0e, 0x3a, 0x17, - 0xb7, 0x5d, 0xcd, 0x51, 0xf2, 0x52, 0x1a, 0x0f, - 0x6d, 0xb2, 0xd8, 0xf6, 0xc4, 0x2b, 0xbd, 0xcb, - 0xe8, 0x80, 0x6d, 0xe8, 0x29, 0x64, 0xdb, 0xb9, - 0x7f, 0x63, 0xb0, 0x42, 0x12, 0xdd, 0x57, 0x89, - 0x3b, 0x65, 0xee, 0xc0, 0x5a, 0x53, 0x83, 0x81, - 0xf6, 0xe1, 0x96, 0x33, 0xc0, 0x59, 0x7d, 0x65, - 0x20, 0x37, 0xd6, 0xd0, 0xcf, 0xae, 0xbb, 0x00, - 0x19, 0x29, 0xbc, 0x03, 0xe1, 0xb4, 0x97, 0x8a, - 0x00, 0xde, 0xd3, 0xce, 0x52, 0x52, 0xd4, 0x48, - 0x16, 0xed, 0xe6, 0xee, 0x09, 0x83, 0x12, 0xc8, - 0x70, 0xc9, 0x4a, 0x0c, 0x11, 0x3a, 0xa1, 0x2a, - 0x4a, 0xd4, 0xf4, 0x22, 0xa6, 0x6d, 0x3e, 0xb8, - 0x35, 0x6b, 0x1e, 0x75, 0xa0, 0xb4, 0x43, 0xcd, - 0x65, 0xe7, 0x62, 0x17, 0x3d, 0x2e, 0x83, 0xda, - 0x79, 0xea, 0x23, 0x5f, 0xba, 0x73, 0x2c, 0x15, - 0x0b, 0x38, 0x0a, 0x9b, 0x28, 0x66, 0x5f, 0x4e, - 0x2e, 0x0d, 0x41, 0x21, 0x83, 0x4a, 0x8d, 0xa1, - 0x0e, 0xf6, 0xc4, 0xf5, 0x7d, 0x77, 0x65, 0x75, - 0xba, 0xcd, 0xc9, 0x97, 0xc7, 0x45, 0xd1, 0x84, - 0xcb, 0xac, 0xe6, 0x75, 0x60, 0xd0, 0x1f, 0xff, - 0x07, 0xe1, 0x81, 0x50, 0x76, 0x64, 0x62, 0x2a, - 0x82, 0xc3, 0x85, 0x08, 0x0c, 0xe1, 0x96, 0xbd, - 0xf3, 0x92, 0x4d, 0x24, 0x58, 0x0f, 0x02, 0x45, - 0x23, 0x92, 0x6d, 0xab, 0x30, 0x2e, 0x91, 0x7a, - 0xab, 0x99, 0xb6, 0xc8, 0xe4, 0xea, 0x51, 0x84, - 0x54, 0xc7, 0xe3, 0x37, 0x8f, 0x90, 0xd0, 0x71, - 0x4b, 0x34, 0xfc, 0xaf, 0x41, 0xcf, 0x78, 0xe7, - 0x0a, 0xe8, 0x83, 0xf5, 0xa6, 0x5c, 0x6d, 0x83, - 0x24, 0xed, 0x52, 0xb5, 0x0f, 0x65, 0xf8, 0x9c, - 0x3b, 0xa3, 0x15, 0xd6, 0xa5, 0xf4, 0x00, 0xd4, - 0xf4, 0xdb, 0x43, 0xc2, 0x02, 0x40, 0x14, 0x75, - 0x13, 0x7e, 0xdb, 0xc5, 0xf2, 0x9c, 0xea, 0x44, - 0x9b, 0x0a, 0x56, 0xfd, 0x97, 0xa5, 0xc5, 0x14, - 0xc4, 0xe2, 0x0d, 0x79, 0xe3, 0xd3, 0x7a, 0x64, - 0x83, 0x7c, 0x82, 0xba, 0x94, 0x0e, 0xba, 0xef, - 0x9a, 0x8a, 0x87, 0xf7, 0x8b, 0x53, 0x62, 0xae, - 0xa4, 0x9f, 0xff, 0xe4, 0xdf, 0x30, 0x71, 0x8f, - 0x72, 0x3d, 0xd1, 0xfa, 0xff, 0x5f, 0x8f, 0x13, - 0x8f, 0xf8, 0x65, 0xe9, 0xa2, 0xd9, 0x07, 0x2a, - 0x5b, 0x87, 0x2b, 0x3c, 0x43, 0x33, 0xdd, 0xf6, - 0x95, 0x0d, 0x43, 0x77, 0xc6, 0x65, 0x74, 0xe4, - 0xbc, 0xcf, 0x6a, 0x88, 0xcc, 0xda, 0x16, 0xe0, - 0xd7, 0xab, 0xe7, 0x46, 0xbe, 0x08, 0x0f, 0x6a, - 0x4b, 0x8d, 0xa3, 0xf4, 0xee, 0xc5, 0x83, 0xff, - 0x98, 0xee, 0x19, 0x2c, 0x7b, 0x81, 0xd4, 0x2e, - 0xb8, 0x04, 0x3c, 0x4f, 0xdb, 0xc7, 0x9c, 0x9c, - 0x8e, 0x2f, 0x77, 0x86, 0x6e, 0x7c, 0xbe, 0xc6, - 0x5e, 0x70, 0xc1, 0x4b, 0x0b, 0x2d, 0x07, 0x2a, - 0xa1, 0xfd, 0x63, 0x2d, 0xc5, 0x4c, 0x63, 0x36 -//}; -//unsigned int sig_sha256_bsn0_msg1_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn1_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn1_msg0.inc deleted file mode 100644 index fd1131e6d1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_bsn1_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn1" - * SigRl : group x sigrl - */ -//unsigned char sig_sha256_bsn1_msg0_dat[] = { - 0x4b, 0xb3, 0x62, 0x6c, 0xa5, 0x12, 0xaa, 0x7a, - 0x22, 0x7f, 0xde, 0xf0, 0x8f, 0x1e, 0x3c, 0xc8, - 0xda, 0x5f, 0x2f, 0x6d, 0x3b, 0xd0, 0x42, 0xec, - 0x62, 0xbf, 0x3c, 0x0f, 0xae, 0xd4, 0xf9, 0xa0, - 0x56, 0xc9, 0xd5, 0x33, 0xaa, 0x60, 0xab, 0x86, - 0x15, 0x48, 0xc2, 0xbb, 0xda, 0x3f, 0x37, 0x71, - 0x3e, 0xf2, 0xd5, 0x3c, 0xd3, 0xb9, 0x08, 0xa0, - 0x63, 0x26, 0x6e, 0x26, 0xca, 0x93, 0xc1, 0xe1, - 0x03, 0x2e, 0xff, 0xad, 0xc8, 0xb1, 0x8f, 0x26, - 0x16, 0x61, 0x4f, 0x33, 0x19, 0x45, 0xb8, 0x0c, - 0xb3, 0x0e, 0x19, 0x98, 0xfc, 0x32, 0x83, 0xc2, - 0x58, 0x60, 0x12, 0x5c, 0xc6, 0xa8, 0x36, 0xc2, - 0xf6, 0xd4, 0x99, 0xb2, 0x44, 0x19, 0xef, 0xf0, - 0x75, 0x76, 0x6e, 0x63, 0xc4, 0x3f, 0x21, 0x5d, - 0x47, 0xa4, 0xf6, 0x90, 0x16, 0xa6, 0x18, 0xa4, - 0xe7, 0xc6, 0xff, 0x47, 0xb9, 0x9d, 0x99, 0x8a, - 0x12, 0x4d, 0xb7, 0xe4, 0xf1, 0x42, 0x1d, 0x8b, - 0x0f, 0x71, 0xac, 0xc7, 0xd4, 0xe0, 0x46, 0x7e, - 0x71, 0x36, 0x6c, 0x10, 0xa5, 0x93, 0xdc, 0x17, - 0xb6, 0x40, 0x7d, 0xa4, 0x8a, 0xf7, 0xf1, 0x9d, - 0x48, 0x41, 0xd3, 0xd1, 0x01, 0xbe, 0x28, 0xdf, - 0x50, 0x56, 0x1e, 0xf2, 0x0d, 0x47, 0x4e, 0x8d, - 0x11, 0x57, 0xe1, 0x5f, 0x41, 0xb2, 0x8e, 0x05, - 0xa2, 0xac, 0xb9, 0x05, 0x5a, 0xc4, 0x71, 0xb8, - 0x8a, 0xf2, 0xf1, 0xb0, 0x9e, 0x5e, 0xcf, 0xa9, - 0x83, 0xb4, 0x57, 0x1d, 0xe9, 0x6c, 0xda, 0xf5, - 0x3c, 0x90, 0xc0, 0x0e, 0xc2, 0xc3, 0x60, 0xd7, - 0x19, 0x61, 0xf7, 0x9b, 0x95, 0x3d, 0x16, 0xed, - 0x01, 0x60, 0xd0, 0xe2, 0x3b, 0x83, 0xd9, 0x3b, - 0xda, 0xe7, 0x8a, 0x4b, 0xdd, 0xfa, 0xcd, 0x4e, - 0xbf, 0xd1, 0x70, 0x57, 0xd0, 0x63, 0x56, 0xee, - 0xea, 0x76, 0x33, 0x59, 0xcc, 0xfb, 0x25, 0xc7, - 0x20, 0x9d, 0x74, 0x8f, 0x13, 0x68, 0xdb, 0x64, - 0x02, 0x20, 0x5b, 0x3a, 0xd2, 0x59, 0x78, 0xd4, - 0xf3, 0x53, 0x43, 0x9f, 0xcc, 0x3f, 0x4d, 0x9a, - 0x23, 0x2d, 0xdb, 0x71, 0xda, 0x25, 0x94, 0x0c, - 0xaa, 0xd9, 0x9a, 0x6a, 0x1c, 0x5d, 0xd1, 0xfe, - 0xf5, 0x19, 0xf7, 0x03, 0xe7, 0x74, 0x1b, 0x6f, - 0x37, 0x93, 0x3a, 0xc4, 0x4e, 0xdb, 0x72, 0xfb, - 0xfc, 0x81, 0xcc, 0xf9, 0x0e, 0x27, 0x55, 0x0d, - 0xb5, 0x48, 0xe9, 0xb7, 0x26, 0xa7, 0xf4, 0x2a, - 0x74, 0x93, 0xb8, 0x0d, 0x2b, 0xf8, 0x48, 0x18, - 0xde, 0x13, 0x7b, 0x5a, 0x33, 0xda, 0x46, 0x5b, - 0x10, 0xce, 0xe9, 0x94, 0x98, 0x97, 0xaf, 0x67, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xa2, 0xa8, 0xe1, 0x74, 0xe4, 0x4e, 0x10, 0xcc, - 0xbe, 0x17, 0x43, 0xb0, 0x5f, 0xd5, 0x66, 0x1c, - 0xbe, 0xf8, 0xfe, 0x35, 0xa0, 0x99, 0x9b, 0x24, - 0x16, 0x73, 0xd3, 0xcb, 0x31, 0x96, 0x2f, 0xab, - 0xd1, 0x7c, 0xdb, 0xf9, 0x82, 0xfc, 0xd5, 0x38, - 0x2d, 0x76, 0x3e, 0x9a, 0x13, 0x39, 0x63, 0x71, - 0xe8, 0x1a, 0xea, 0x20, 0xbf, 0xcb, 0x81, 0x4d, - 0xe7, 0xc6, 0xb9, 0xbb, 0x9f, 0x9e, 0x97, 0x93, - 0xc9, 0xe3, 0x6a, 0xca, 0xc0, 0x3b, 0xd6, 0x23, - 0xb3, 0x66, 0xf5, 0x6a, 0x02, 0x63, 0x46, 0xbf, - 0xa0, 0xbd, 0x94, 0x92, 0x59, 0x2b, 0x06, 0x71, - 0xb7, 0xcc, 0x00, 0xc0, 0xb1, 0x12, 0x21, 0x34, - 0xb7, 0xdb, 0x08, 0x1e, 0x57, 0x12, 0x72, 0x5b, - 0x9c, 0xee, 0x22, 0x73, 0x7a, 0xf8, 0x75, 0x31, - 0x2f, 0xa3, 0x1f, 0xea, 0x3d, 0x45, 0x3e, 0xfd, - 0xf6, 0x13, 0xcf, 0xa9, 0x16, 0xc6, 0xe5, 0xb7, - 0x7c, 0xf7, 0x87, 0x95, 0x6a, 0xc7, 0xc9, 0x79, - 0x09, 0x17, 0x9e, 0xe6, 0xb1, 0x8f, 0x96, 0x14, - 0x86, 0xc6, 0xa2, 0xbe, 0xb0, 0x4a, 0x54, 0x65, - 0xb3, 0x80, 0xef, 0xf5, 0xc0, 0x40, 0xa3, 0xde, - 0x6b, 0x31, 0xaa, 0x49, 0x21, 0xfa, 0x0c, 0x83, - 0x54, 0xdf, 0xe3, 0x17, 0xf1, 0x2a, 0xa4, 0x73, - 0x6d, 0x1f, 0x97, 0xcb, 0x23, 0x29, 0x1d, 0x7e, - 0xf3, 0x9f, 0x7b, 0xcc, 0x3c, 0x48, 0xc1, 0x18, - 0xe3, 0x07, 0xb6, 0x7d, 0x32, 0x32, 0xce, 0xfa, - 0x8d, 0x9d, 0xba, 0x42, 0x4a, 0x45, 0xe6, 0x7b, - 0x02, 0x7c, 0x53, 0x7d, 0x21, 0x8e, 0x6f, 0x35, - 0x4f, 0xb2, 0x1b, 0xe2, 0x2d, 0xdb, 0x9c, 0xef, - 0x3e, 0x58, 0x58, 0x8d, 0x11, 0xc2, 0xec, 0xfa, - 0x99, 0x13, 0x86, 0x1a, 0xe6, 0x14, 0x95, 0x70, - 0x4d, 0xf4, 0xe4, 0x7f, 0xde, 0x95, 0x29, 0xcf, - 0x93, 0x4c, 0xac, 0x79, 0x99, 0xcf, 0xbe, 0x1f, - 0x1c, 0x4b, 0x29, 0x29, 0x24, 0xf6, 0xbe, 0x9f, - 0xf2, 0x0f, 0x67, 0xae, 0x4d, 0x0d, 0xe3, 0x17, - 0x79, 0xcf, 0x65, 0xfd, 0x6f, 0x12, 0x64, 0xc6, - 0x9e, 0x2d, 0xcc, 0x3b, 0x2c, 0x94, 0x42, 0x63, - 0x86, 0x06, 0x00, 0xa7, 0x37, 0x06, 0x92, 0x15, - 0x02, 0xc6, 0x34, 0xeb, 0xa6, 0x17, 0xfe, 0x90, - 0x0d, 0xd1, 0x85, 0x5c, 0x77, 0x3a, 0x2b, 0x96, - 0xf1, 0x21, 0x07, 0xb5, 0x7c, 0x38, 0xb1, 0x4d, - 0x02, 0x43, 0xa9, 0x11, 0x65, 0x4d, 0x34, 0x64, - 0x72, 0x6a, 0x41, 0xb3, 0x8f, 0xf5, 0x2c, 0x9c, - 0xec, 0x3b, 0x48, 0xd0, 0xd5, 0xa9, 0x37, 0xf5, - 0x1f, 0x3e, 0x54, 0x62, 0xde, 0xed, 0x9e, 0x8a, - 0x0e, 0x22, 0x36, 0x2c, 0xc8, 0x2c, 0xf5, 0xc0, - 0xf6, 0xc9, 0x08, 0x73, 0x4a, 0xaf, 0x83, 0x8f, - 0xd6, 0x17, 0xe9, 0xf3, 0x01, 0xe3, 0xa3, 0x55, - 0xfd, 0x2d, 0x9d, 0xa7, 0x04, 0xa8, 0x09, 0x23, - 0xc0, 0x22, 0x74, 0x8e, 0xd4, 0xd4, 0x78, 0x75, - 0x6f, 0x33, 0xe8, 0xb9, 0xd7, 0x3c, 0x72, 0xb5, - 0x73, 0x78, 0x60, 0x4b, 0xcf, 0x2e, 0x22, 0x60, - 0x28, 0xa1, 0x8e, 0xcc, 0x1d, 0x20, 0xfa, 0x32, - 0x16, 0xce, 0x2b, 0x90, 0x62, 0xf3, 0x4d, 0x52, - 0x26, 0x05, 0x7d, 0xad, 0x07, 0x6d, 0x21, 0x55, - 0x34, 0x24, 0x21, 0xb2, 0x79, 0x14, 0x1c, 0x64, - 0x16, 0x1c, 0x14, 0x8b, 0x19, 0xf7, 0x03, 0x87, - 0xde, 0xe1, 0xdf, 0x9b, 0xa9, 0x86, 0x79, 0xdf, - 0x0f, 0x99, 0x09, 0x93, 0x96, 0x15, 0x79, 0x27, - 0x40, 0x53, 0x06, 0x73, 0x59, 0x19, 0x8d, 0x4f, - 0xd0, 0x09, 0xd3, 0x09, 0x23, 0x4f, 0x12, 0xec -//}; -//unsigned int sig_sha256_bsn1_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg0.inc deleted file mode 100644 index 824f0ef856..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: None (random base) - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_rndbase_msg0_dat[] = { - 0x69, 0x77, 0x85, 0xee, 0xf5, 0x5f, 0x69, 0xd7, - 0x6f, 0x22, 0x49, 0x4f, 0xbb, 0x83, 0x73, 0x2e, - 0x91, 0xf1, 0x94, 0x48, 0x1b, 0x06, 0x4a, 0xf7, - 0x90, 0x07, 0x07, 0x2e, 0xb5, 0x65, 0xc8, 0xed, - 0x3e, 0x48, 0xb8, 0xc1, 0x7e, 0x20, 0x79, 0xd3, - 0xe0, 0x49, 0x3f, 0x10, 0x40, 0x41, 0x39, 0x59, - 0xa6, 0xfe, 0xe7, 0xcf, 0x21, 0x29, 0x37, 0x1b, - 0xef, 0xc0, 0xf0, 0x37, 0x49, 0x75, 0x6d, 0x66, - 0x4f, 0x31, 0x71, 0x23, 0x0e, 0x3a, 0x03, 0x00, - 0x9e, 0xcd, 0xc4, 0x70, 0xaa, 0x97, 0x02, 0xf7, - 0x1c, 0x49, 0x45, 0xac, 0xd9, 0xe7, 0x46, 0x20, - 0x36, 0xe8, 0x23, 0x57, 0xee, 0x5e, 0x6b, 0x6d, - 0x1a, 0xf4, 0x04, 0x1d, 0xd5, 0xb0, 0x81, 0x0c, - 0xe4, 0xd6, 0x01, 0x39, 0x35, 0xe2, 0x38, 0xb9, - 0xea, 0xc1, 0x35, 0xc0, 0x91, 0x39, 0x0e, 0xe6, - 0x6a, 0x45, 0x5e, 0xe1, 0x06, 0xa3, 0x5b, 0x09, - 0x6a, 0xd8, 0xe4, 0x61, 0x35, 0x72, 0x8d, 0x22, - 0x53, 0xd0, 0x96, 0xc3, 0xd9, 0x32, 0x21, 0x87, - 0x6f, 0xaa, 0x41, 0x4f, 0x90, 0x75, 0x01, 0x57, - 0x2a, 0xab, 0x38, 0xc7, 0x5d, 0xd5, 0xdd, 0x6b, - 0xfb, 0xde, 0xd8, 0x25, 0xa4, 0x14, 0x7f, 0x87, - 0x55, 0x78, 0x4b, 0xf5, 0x87, 0x15, 0x1d, 0xdb, - 0x59, 0xc1, 0xb4, 0x92, 0x52, 0x06, 0xfb, 0x96, - 0x9a, 0xf2, 0x05, 0x9e, 0xa7, 0x57, 0xf2, 0xa5, - 0xcf, 0xe8, 0x5e, 0x61, 0x59, 0xd0, 0x81, 0xab, - 0x97, 0xdd, 0x5c, 0x90, 0x1c, 0x21, 0x5b, 0x48, - 0x5d, 0x93, 0x71, 0x98, 0x46, 0x6b, 0x2c, 0x8b, - 0xa3, 0xce, 0x5a, 0xed, 0x8e, 0x76, 0x92, 0x75, - 0x5b, 0x9b, 0x09, 0x5a, 0x9a, 0x06, 0xde, 0xc5, - 0x33, 0x73, 0xc5, 0xdb, 0x14, 0x5b, 0x82, 0x8b, - 0xd2, 0xdd, 0xf1, 0x1d, 0xc8, 0x1a, 0x6b, 0x16, - 0xba, 0x19, 0xa4, 0x0d, 0xaa, 0x11, 0xb7, 0x2c, - 0x88, 0x8d, 0xde, 0x94, 0x6a, 0x3d, 0xbf, 0x52, - 0x95, 0x10, 0xad, 0xa5, 0x2b, 0x9d, 0xd3, 0xc3, - 0x07, 0x60, 0x4e, 0x37, 0xed, 0x0f, 0xb5, 0xeb, - 0xd1, 0xda, 0x8a, 0xec, 0x54, 0xbd, 0xad, 0xbf, - 0x88, 0xaf, 0xca, 0x23, 0xdf, 0xd5, 0x84, 0xc4, - 0xa5, 0x21, 0x3f, 0x53, 0x8b, 0xe9, 0x3c, 0xbe, - 0x2c, 0xf6, 0xa5, 0x27, 0xe2, 0x18, 0x16, 0xe4, - 0x9f, 0xfb, 0xe3, 0x17, 0x58, 0x6e, 0xc6, 0x87, - 0x5e, 0x2a, 0x33, 0xcd, 0x02, 0xa3, 0x94, 0x2a, - 0x8f, 0x09, 0x6d, 0x6b, 0x0a, 0x4e, 0x62, 0x29, - 0xe9, 0x40, 0xf2, 0xba, 0xfc, 0x6b, 0x7d, 0x96, - 0x3f, 0x7e, 0x86, 0x19, 0x5d, 0x5f, 0xb4, 0xdd, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x9a, 0x32, 0x23, 0x75, 0xc3, 0x6c, 0x8a, 0x37, - 0xc0, 0xf2, 0x2a, 0xd6, 0x8e, 0xbc, 0x91, 0x68, - 0xf9, 0xd5, 0xc2, 0x85, 0x26, 0x61, 0x9c, 0xed, - 0x01, 0xcd, 0x5b, 0xd9, 0xa0, 0xc0, 0x75, 0xa8, - 0x36, 0x7c, 0xc3, 0x2f, 0x57, 0x3c, 0x46, 0xc5, - 0x57, 0x6a, 0x0b, 0x96, 0xe5, 0x6b, 0x3d, 0x45, - 0x10, 0xe1, 0x4f, 0xd1, 0x11, 0xa9, 0x3b, 0xe1, - 0x34, 0xbb, 0x30, 0xbc, 0x6b, 0x86, 0x2c, 0x01, - 0x35, 0x38, 0x26, 0x75, 0x15, 0x9f, 0x35, 0x7a, - 0xb7, 0x47, 0xe0, 0x72, 0xa4, 0x42, 0x90, 0x00, - 0x86, 0xea, 0xdf, 0xc1, 0x19, 0xee, 0x9d, 0x44, - 0xe4, 0x2c, 0x4a, 0x33, 0xea, 0x5c, 0x8c, 0x1e, - 0xc3, 0x93, 0x1b, 0x51, 0x00, 0x5f, 0x71, 0xb6, - 0xc5, 0xb0, 0x94, 0x9c, 0x45, 0x1f, 0xef, 0x1d, - 0x1f, 0xd6, 0x1b, 0xb9, 0xa4, 0xcf, 0xe6, 0xf1, - 0x48, 0xcd, 0xbe, 0x78, 0xb1, 0xf7, 0x0c, 0x01, - 0xd7, 0x64, 0xc7, 0xeb, 0x23, 0x20, 0x21, 0x49, - 0xfb, 0x71, 0xf3, 0xc3, 0x63, 0x94, 0x9c, 0x91, - 0x2f, 0xd6, 0xbe, 0x79, 0x43, 0x83, 0x14, 0x17, - 0xe4, 0x2a, 0x8c, 0xac, 0x02, 0x68, 0xec, 0x71, - 0x88, 0xc5, 0xfa, 0xb8, 0x98, 0x0e, 0xd7, 0x19, - 0x1d, 0x1a, 0x3d, 0x86, 0x2c, 0xb4, 0xc3, 0x03, - 0x7b, 0x2a, 0xa7, 0xb5, 0x69, 0x73, 0x0e, 0x0e, - 0xe0, 0x67, 0x04, 0xc1, 0x71, 0xa9, 0x29, 0x46, - 0x71, 0x96, 0x4f, 0x64, 0x27, 0xac, 0x7a, 0x10, - 0x70, 0xc5, 0x5f, 0x5b, 0xca, 0x3e, 0xb3, 0xcc, - 0x9a, 0xe9, 0xa5, 0x03, 0x7b, 0x93, 0x2b, 0x77, - 0xdd, 0xd5, 0xc2, 0x0a, 0x78, 0xef, 0x7c, 0x3a, - 0xea, 0x6e, 0xa4, 0xf7, 0x65, 0x50, 0x01, 0xdd, - 0x0e, 0x60, 0xef, 0x40, 0xb2, 0x28, 0xdc, 0xa9, - 0x7f, 0x1a, 0x98, 0x3d, 0x8d, 0xd4, 0xa0, 0xd6, - 0xec, 0xe3, 0x2f, 0x1e, 0x48, 0xa6, 0x88, 0x8f, - 0xe4, 0x25, 0xdc, 0xdf, 0xd5, 0xfa, 0x6d, 0x16, - 0x94, 0xbb, 0xf7, 0xe0, 0x4f, 0x6b, 0xb7, 0x49, - 0x5c, 0x89, 0xde, 0x9f, 0xeb, 0x7b, 0xad, 0xda, - 0x57, 0x5e, 0xae, 0xa5, 0xd6, 0xfd, 0xa4, 0x20, - 0x07, 0x12, 0x12, 0x73, 0x56, 0x6d, 0xb8, 0x65, - 0x41, 0x7a, 0xdb, 0xc6, 0x25, 0x19, 0xea, 0x1c, - 0x83, 0x4c, 0x48, 0x77, 0x92, 0x14, 0x97, 0xe5, - 0x3c, 0x90, 0x4d, 0x5a, 0xb0, 0x7a, 0xab, 0xc5, - 0xa4, 0xdc, 0x52, 0x24, 0x75, 0xe1, 0x8f, 0x8e, - 0x53, 0x39, 0x1e, 0x2d, 0x95, 0x2d, 0xd3, 0xa4, - 0x01, 0x6a, 0x9f, 0x85, 0x5b, 0xd2, 0xe5, 0xa9, - 0x56, 0x0e, 0xdf, 0x89, 0x6e, 0xaa, 0x0a, 0x68, - 0x9c, 0x47, 0x94, 0x0d, 0xb7, 0xeb, 0x8b, 0x2e, - 0xdb, 0x8d, 0x99, 0xf5, 0x7b, 0x34, 0xc1, 0x19, - 0xd6, 0xf3, 0x42, 0x8a, 0xba, 0x50, 0xe1, 0xb1, - 0x26, 0xf6, 0x8a, 0x21, 0x24, 0xa4, 0xe3, 0xb5, - 0x93, 0x84, 0xed, 0x41, 0x74, 0x8a, 0x39, 0x6a, - 0xf9, 0xb9, 0x25, 0x2e, 0x71, 0x8e, 0x37, 0x6a, - 0x17, 0x8a, 0x3b, 0x91, 0x4e, 0x3f, 0x93, 0x10, - 0x6e, 0xe9, 0xa9, 0xde, 0x10, 0x87, 0x3b, 0xbb, - 0x8c, 0x80, 0xc8, 0xd0, 0x23, 0x01, 0xfc, 0x46, - 0x38, 0x39, 0x6c, 0xf9, 0x3b, 0xff, 0x4b, 0xbf, - 0xd8, 0xee, 0xf1, 0xf7, 0x5a, 0x71, 0x6c, 0x17, - 0xd9, 0x7b, 0x0e, 0x5d, 0x14, 0x02, 0x6b, 0xd9, - 0x2d, 0x6d, 0xe2, 0xb4, 0xc8, 0xa2, 0xc1, 0xad, - 0x1c, 0x5f, 0x27, 0x0e, 0xd1, 0xd7, 0xf4, 0xa0, - 0xd6, 0x54, 0xc2, 0x94, 0x02, 0x50, 0xe1, 0xdc, - 0x82, 0xf2, 0x33, 0x2e, 0x46, 0xf2, 0x80, 0x83 -//}; -//unsigned int sig_grpx_member0_sha256_rndbase_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg1.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg1.inc deleted file mode 100644 index 27de6e3ed1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg1.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg1" - * Basename: None (random base) - * SigRl : group x sigrl - */ -//unsigned char sig_sha256_rndbase_msg1_dat[] = { - 0xfc, 0x15, 0xdf, 0x05, 0x15, 0xad, 0xda, 0xbe, - 0x91, 0x78, 0xba, 0x72, 0x1f, 0x32, 0xd0, 0x5d, - 0xcb, 0x08, 0xbd, 0x8f, 0x37, 0xa8, 0x6b, 0xfe, - 0x58, 0x5f, 0xe4, 0x66, 0xb9, 0xbc, 0x2d, 0x68, - 0x21, 0xa2, 0xa7, 0x4b, 0x37, 0x50, 0x56, 0x1f, - 0xae, 0x20, 0xf0, 0x33, 0x29, 0xd0, 0xec, 0x64, - 0xde, 0xd5, 0xf4, 0x08, 0x75, 0xa1, 0xf1, 0x73, - 0xea, 0x20, 0x1e, 0x4e, 0x9d, 0x7f, 0x26, 0xdb, - 0x19, 0xb7, 0x3e, 0xe9, 0x16, 0x76, 0xc8, 0x24, - 0x89, 0x08, 0x03, 0xfd, 0xad, 0x7f, 0x9e, 0x88, - 0x5f, 0x4a, 0x99, 0x0c, 0xcf, 0x60, 0x9b, 0xaf, - 0x14, 0xcc, 0x1f, 0xc8, 0x0e, 0x5a, 0xe6, 0x97, - 0x13, 0xbf, 0x26, 0x98, 0x64, 0xd8, 0xc7, 0x7e, - 0xba, 0x94, 0x6b, 0x85, 0x7d, 0xda, 0xc6, 0x2f, - 0x37, 0x21, 0xd7, 0xc8, 0x57, 0xa4, 0xff, 0x43, - 0x66, 0xd0, 0xf1, 0x9f, 0x2c, 0xc3, 0xda, 0x28, - 0x9d, 0x1d, 0x29, 0x02, 0xd0, 0x2e, 0xf9, 0x3a, - 0xa6, 0xb2, 0x24, 0x60, 0x9c, 0x6f, 0x71, 0x90, - 0xc4, 0x32, 0x71, 0x24, 0xfb, 0xec, 0xbe, 0xca, - 0x66, 0x44, 0x12, 0x4f, 0x39, 0x5f, 0x1e, 0xbe, - 0x55, 0xb1, 0x33, 0xff, 0x1a, 0xf9, 0x73, 0xfc, - 0x57, 0xfe, 0x0d, 0x6e, 0xd5, 0x55, 0x22, 0xc2, - 0x02, 0x41, 0x10, 0x11, 0x77, 0xb7, 0x12, 0x67, - 0xc6, 0xc9, 0x24, 0x89, 0x4b, 0x4c, 0x55, 0xf0, - 0xa1, 0xfb, 0x06, 0xb6, 0x35, 0x52, 0xbd, 0x06, - 0xb9, 0x6a, 0xc3, 0x8d, 0xd9, 0x8f, 0x03, 0x35, - 0x49, 0x78, 0x93, 0xdc, 0xef, 0xd8, 0xf1, 0xdf, - 0x82, 0x7f, 0x72, 0xf8, 0x61, 0x43, 0x09, 0xef, - 0xa2, 0x85, 0x88, 0x12, 0xb8, 0x71, 0x39, 0x27, - 0x46, 0xa0, 0x6a, 0x9a, 0x07, 0x12, 0x76, 0xd8, - 0x3b, 0x38, 0x65, 0xc0, 0x11, 0x46, 0x14, 0xd4, - 0x00, 0x90, 0x69, 0x3b, 0x66, 0xbe, 0xcb, 0xcc, - 0x61, 0x71, 0x4a, 0xc7, 0x03, 0xfc, 0x35, 0xcd, - 0x77, 0x89, 0xea, 0xdd, 0x30, 0x1f, 0x40, 0xa8, - 0xea, 0xd2, 0x12, 0x22, 0x51, 0xbd, 0x49, 0xa4, - 0x52, 0x80, 0x3e, 0xa2, 0xa5, 0x8e, 0xea, 0xd0, - 0xec, 0x43, 0x3e, 0xa8, 0x23, 0x5e, 0xac, 0x5c, - 0x0f, 0x6b, 0x34, 0xbd, 0x76, 0x77, 0x5a, 0x2d, - 0x78, 0x3e, 0x42, 0x11, 0xfc, 0x96, 0x8b, 0xe2, - 0x35, 0x87, 0x00, 0x93, 0x34, 0xf2, 0xf0, 0xb0, - 0x03, 0xba, 0x82, 0x0a, 0x38, 0x5b, 0xa6, 0xe9, - 0xaa, 0xf3, 0x8f, 0xb3, 0x66, 0xb5, 0x84, 0x80, - 0x40, 0x2f, 0xac, 0x3b, 0xcf, 0x49, 0x38, 0x17, - 0xde, 0x0f, 0xce, 0x57, 0x07, 0x2b, 0xb8, 0xd1, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x33, 0x99, 0x88, 0x92, 0x66, 0x39, 0xe7, 0x42, - 0xc8, 0x21, 0xad, 0xbd, 0x71, 0xa7, 0xb5, 0xea, - 0x6b, 0xef, 0x02, 0x48, 0x85, 0xc7, 0x53, 0xb0, - 0xca, 0xc7, 0x63, 0xe0, 0xe8, 0x3d, 0x80, 0x01, - 0x55, 0x6a, 0x6f, 0x1b, 0x2d, 0x4f, 0x33, 0x53, - 0x85, 0xb4, 0x47, 0x12, 0x9a, 0x1f, 0xcc, 0x7b, - 0x37, 0x32, 0xec, 0x68, 0xa4, 0x97, 0xfc, 0x25, - 0xe6, 0x69, 0x48, 0xd1, 0x65, 0xc9, 0xd2, 0x17, - 0x38, 0x07, 0x6d, 0x49, 0xbe, 0x06, 0xd5, 0x28, - 0xb2, 0xe6, 0x16, 0x16, 0x67, 0x82, 0x3c, 0xdb, - 0x2c, 0x5b, 0xb0, 0x64, 0x7f, 0x44, 0x11, 0x53, - 0xc6, 0x6f, 0xed, 0xbc, 0x8f, 0x1e, 0xd0, 0xca, - 0x29, 0xea, 0x97, 0xc4, 0x84, 0xe3, 0xfc, 0xf5, - 0xc1, 0xb4, 0xa2, 0x31, 0x13, 0x0c, 0x30, 0x08, - 0x32, 0x4c, 0x2e, 0x11, 0x38, 0x63, 0xb1, 0x5c, - 0x9b, 0xf3, 0xca, 0xf2, 0x9a, 0x4f, 0x5d, 0x75, - 0x5c, 0xa9, 0xe3, 0x62, 0x2e, 0xd8, 0x8b, 0xe8, - 0x14, 0x5f, 0x9f, 0x27, 0x0b, 0x36, 0x26, 0x08, - 0x54, 0x9f, 0xac, 0xf8, 0xc6, 0x81, 0x47, 0xd6, - 0x28, 0x0b, 0xbf, 0x99, 0xb1, 0x94, 0x92, 0xeb, - 0x02, 0x9a, 0x0d, 0xde, 0x32, 0xd9, 0xc9, 0x7f, - 0x0f, 0x26, 0xba, 0x5f, 0x76, 0x5e, 0xdc, 0x2d, - 0xf7, 0x61, 0x3c, 0x57, 0x73, 0xc5, 0xbc, 0x61, - 0x1e, 0xc7, 0xcd, 0x6c, 0x1f, 0xe8, 0xc9, 0x00, - 0x1f, 0x70, 0x41, 0x0b, 0x08, 0x35, 0x0c, 0x04, - 0xaa, 0x99, 0x5e, 0xf4, 0x45, 0xf0, 0xfb, 0xfb, - 0x97, 0x72, 0x1d, 0x72, 0xd5, 0xe2, 0x7e, 0xba, - 0x2e, 0x69, 0x2c, 0x08, 0x3d, 0x59, 0xb3, 0xc6, - 0x89, 0xbd, 0xed, 0x2b, 0x29, 0x9e, 0x8e, 0x04, - 0x46, 0x29, 0xc4, 0x40, 0x77, 0x60, 0x76, 0x58, - 0x47, 0x90, 0x23, 0x65, 0x20, 0x40, 0x84, 0xb2, - 0xc7, 0xd3, 0x1c, 0x15, 0x77, 0x94, 0x38, 0x49, - 0x49, 0x22, 0x21, 0x87, 0x41, 0x04, 0x17, 0xca, - 0x87, 0xb8, 0xdf, 0x3f, 0xb5, 0xa6, 0x2a, 0xce, - 0x19, 0xd2, 0xd3, 0x51, 0xd8, 0x32, 0xd7, 0x78, - 0x12, 0x66, 0x6c, 0x23, 0x22, 0xbc, 0x50, 0x99, - 0x2f, 0x53, 0xa9, 0x1d, 0xf0, 0x26, 0x9b, 0x5b, - 0xab, 0xd0, 0x14, 0x6d, 0x20, 0xd6, 0x5d, 0x48, - 0x05, 0x97, 0x6b, 0xbe, 0xa4, 0x9e, 0xf8, 0xbd, - 0x3e, 0x52, 0xe9, 0xcb, 0x66, 0xc0, 0xbf, 0xe1, - 0x25, 0x45, 0x48, 0xb1, 0x26, 0xb6, 0xe5, 0x65, - 0x17, 0x33, 0x4e, 0x4b, 0x0b, 0x74, 0x84, 0x0d, - 0xcd, 0x9c, 0x9a, 0x98, 0xaa, 0x75, 0x2e, 0xb5, - 0xb4, 0x3f, 0x4a, 0x0d, 0x29, 0x18, 0xa2, 0xed, - 0x18, 0xc9, 0x79, 0xc6, 0xb1, 0x0b, 0x23, 0x86, - 0x87, 0x67, 0xd2, 0x80, 0xcc, 0x82, 0xda, 0x43, - 0x98, 0x39, 0x10, 0x68, 0x78, 0x8f, 0xf9, 0xaa, - 0x8f, 0xa9, 0xcc, 0xd8, 0x52, 0xfc, 0xda, 0xd4, - 0x98, 0xa5, 0xaa, 0xcc, 0x7f, 0x43, 0x6d, 0x94, - 0xcc, 0x7f, 0x69, 0xa8, 0xc2, 0x30, 0x3d, 0x7b, - 0x1d, 0x87, 0x24, 0xcf, 0x14, 0x16, 0x37, 0xc8, - 0x59, 0x97, 0x0a, 0x31, 0xaa, 0xeb, 0x38, 0xf8, - 0xaf, 0xdc, 0x85, 0x0a, 0x37, 0x47, 0x19, 0x3f, - 0xab, 0xcd, 0x48, 0xdc, 0x2b, 0xf6, 0x42, 0xf1, - 0x41, 0xc2, 0xcc, 0x8a, 0xfc, 0xbb, 0xbd, 0xe3, - 0xd1, 0x2e, 0x39, 0x07, 0x91, 0x36, 0x40, 0x33, - 0x95, 0xa6, 0x0e, 0xcf, 0x9a, 0xcf, 0xbb, 0xb2, - 0x9b, 0x63, 0x86, 0x31, 0xec, 0x12, 0xb3, 0x1e, - 0xe3, 0xcb, 0xd1, 0x2c, 0x55, 0xca, 0x07, 0xec, - 0x23, 0x97, 0xc2, 0xa1, 0x4d, 0xa4, 0x11, 0x13 -//}; -//unsigned int sig_sha256_rndbase_msg1_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_bsn0_msg0.inc deleted file mode 100644 index b9855f06e2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_bsn0_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha384 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha384_bsn0_msg0_dat[] = { - 0x57, 0xe7, 0x8f, 0xfb, 0xf9, 0xa3, 0xba, 0x5e, - 0xac, 0xec, 0xb3, 0xa4, 0xf4, 0x13, 0x95, 0xa1, - 0x1c, 0x1d, 0xe1, 0xaf, 0xea, 0x16, 0xba, 0x6d, - 0xde, 0x4c, 0x43, 0xf0, 0x89, 0x59, 0x5e, 0xfa, - 0x0f, 0x18, 0xdd, 0x22, 0xf6, 0xd6, 0xfc, 0xe5, - 0x0f, 0xb2, 0x81, 0xb5, 0xa9, 0xa6, 0xe8, 0xee, - 0x14, 0x04, 0xec, 0x1b, 0x4e, 0x65, 0x82, 0x7f, - 0x96, 0x53, 0xc4, 0x3b, 0x29, 0x17, 0x39, 0xc0, - 0x8a, 0x3a, 0x3d, 0xef, 0x79, 0xe7, 0x7d, 0x06, - 0x00, 0x32, 0xc7, 0x4f, 0x82, 0x01, 0x71, 0x10, - 0xb1, 0x5b, 0x7b, 0x7c, 0x82, 0x10, 0xfd, 0xb4, - 0x8e, 0x7e, 0x87, 0x50, 0x9d, 0xc4, 0xf8, 0x4c, - 0x8b, 0xb2, 0xf9, 0x34, 0x17, 0x9e, 0x44, 0x93, - 0x47, 0xb4, 0x8c, 0x42, 0x55, 0x8a, 0xd9, 0xd8, - 0x12, 0x4a, 0xd9, 0x01, 0xce, 0x1a, 0x6b, 0x96, - 0x9d, 0x4c, 0x9b, 0xa9, 0x48, 0xae, 0x3c, 0xd6, - 0xc0, 0xb7, 0x0a, 0x62, 0xe7, 0xa9, 0xc8, 0xda, - 0x02, 0xc0, 0x1a, 0xb4, 0x8c, 0x8c, 0xda, 0x1d, - 0xe8, 0x2e, 0x8b, 0x16, 0x49, 0xd8, 0xe2, 0xd7, - 0x86, 0xab, 0x76, 0x20, 0x08, 0x9a, 0x66, 0x2e, - 0x60, 0x4f, 0x8d, 0xd9, 0x20, 0x0f, 0x85, 0x2a, - 0x9e, 0xa5, 0x95, 0x04, 0x3f, 0x82, 0xae, 0xbb, - 0x84, 0x35, 0xb4, 0xda, 0x93, 0x46, 0x46, 0x8c, - 0x6b, 0x14, 0x4a, 0x70, 0x26, 0xa4, 0xf7, 0xba, - 0xcd, 0x9d, 0x8e, 0x5a, 0x9d, 0x66, 0x87, 0xa6, - 0x50, 0x97, 0x1c, 0xea, 0x01, 0xea, 0x7e, 0xa5, - 0x1f, 0xf3, 0xc7, 0xff, 0x17, 0x75, 0x05, 0x0a, - 0xb8, 0x71, 0x79, 0x75, 0x5b, 0xfa, 0xee, 0xc7, - 0xb3, 0x1f, 0xed, 0xc5, 0x8c, 0x65, 0x05, 0x41, - 0x04, 0x82, 0xb6, 0xd9, 0xa4, 0x00, 0x12, 0xeb, - 0x1a, 0x26, 0xba, 0xad, 0x97, 0x3e, 0xe3, 0x0b, - 0x15, 0x98, 0x5d, 0xcd, 0xb3, 0x66, 0x58, 0xff, - 0x1d, 0x40, 0x99, 0xaf, 0xad, 0x19, 0x05, 0x06, - 0x7f, 0x42, 0x1e, 0xfc, 0x88, 0x23, 0x7b, 0xd4, - 0x6c, 0xd7, 0x3e, 0xa2, 0x16, 0x12, 0x83, 0x28, - 0x47, 0xf9, 0xe1, 0xed, 0x94, 0x29, 0xab, 0x7b, - 0xef, 0x20, 0x53, 0x9a, 0x8b, 0xdf, 0x0e, 0xd7, - 0x3e, 0x26, 0x26, 0x5a, 0x4a, 0x25, 0xa8, 0x09, - 0x76, 0x5e, 0xd0, 0x6a, 0x6c, 0xe5, 0x39, 0x10, - 0xcc, 0x77, 0xaa, 0x75, 0x28, 0x17, 0x43, 0xb9, - 0xd9, 0x7a, 0x4a, 0x36, 0xfb, 0x02, 0x42, 0x30, - 0xac, 0x9e, 0x28, 0x93, 0x54, 0x94, 0x9f, 0xbf, - 0xc2, 0x7c, 0xd7, 0xa4, 0x84, 0x89, 0x90, 0x74, - 0xf0, 0xcf, 0xcc, 0x0b, 0x1e, 0x8f, 0x98, 0x62, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x80, 0x71, 0x05, 0x55, 0xae, 0x18, 0xc1, 0x77, - 0x38, 0x6e, 0x5f, 0x17, 0xe1, 0xcb, 0x89, 0x00, - 0xc2, 0x43, 0x20, 0x3d, 0x63, 0x2a, 0xd8, 0xe2, - 0x3a, 0x7a, 0x20, 0xf0, 0x72, 0x21, 0x7d, 0x22, - 0xaf, 0x37, 0x4f, 0x98, 0x3a, 0x2b, 0x4f, 0x76, - 0x84, 0xed, 0x09, 0x74, 0x6c, 0x37, 0xf0, 0x44, - 0x17, 0x7e, 0xd6, 0x8c, 0x87, 0x5c, 0x98, 0x36, - 0xe1, 0xd9, 0x32, 0x30, 0x73, 0x31, 0x8a, 0x73, - 0x53, 0xf8, 0x5f, 0xa9, 0x0a, 0x72, 0xd8, 0x68, - 0x17, 0x8f, 0x8c, 0x97, 0xf9, 0xd2, 0x45, 0x42, - 0xcf, 0xd0, 0x82, 0x4a, 0x9c, 0xde, 0xca, 0xe1, - 0xbc, 0x63, 0xbd, 0xea, 0x75, 0xff, 0xe0, 0x61, - 0x89, 0x51, 0xb5, 0xbf, 0x08, 0x67, 0x19, 0x11, - 0x8e, 0x6b, 0x05, 0xe5, 0xc5, 0x52, 0xff, 0xb5, - 0x1c, 0x5a, 0xe3, 0x9a, 0xef, 0xc6, 0x52, 0xbc, - 0xe9, 0xc7, 0x4b, 0x1c, 0x21, 0xd8, 0xdc, 0x39, - 0x0e, 0x6b, 0x44, 0x5d, 0xae, 0x30, 0x98, 0xfc, - 0xdc, 0x54, 0xbe, 0xa5, 0xef, 0x90, 0x15, 0x9a, - 0x13, 0xac, 0x9f, 0xa8, 0xf7, 0xb0, 0xc7, 0xc5, - 0x67, 0xbd, 0xae, 0x8b, 0xa6, 0xc8, 0x20, 0xa2, - 0x2f, 0x26, 0x42, 0xe3, 0x8e, 0x56, 0xcc, 0xf0, - 0xfc, 0x24, 0x33, 0x93, 0x78, 0xa7, 0xdd, 0x5b, - 0x0b, 0x77, 0x7b, 0x36, 0xc4, 0xad, 0x95, 0x25, - 0x9b, 0x8a, 0x9f, 0xbc, 0xfb, 0xa0, 0x40, 0x18, - 0xc5, 0x3f, 0x32, 0x84, 0x85, 0xcb, 0xf4, 0xfd, - 0xf2, 0x03, 0xa9, 0xf4, 0x95, 0x50, 0x92, 0xe8, - 0xa8, 0x44, 0xe8, 0x92, 0xe0, 0x09, 0x71, 0x25, - 0x6c, 0xfb, 0x50, 0x38, 0x77, 0x6a, 0x7d, 0x6c, - 0xc6, 0x34, 0x72, 0xec, 0x50, 0x02, 0x0d, 0xce, - 0x2d, 0xfd, 0xe9, 0x2a, 0xf6, 0x8a, 0x90, 0x82, - 0x44, 0x45, 0xfb, 0x9f, 0x03, 0x22, 0xd0, 0x5e, - 0x8e, 0x01, 0xac, 0xa4, 0xb8, 0x20, 0xa1, 0x2d, - 0xff, 0xb2, 0x22, 0x4e, 0xe4, 0xe0, 0x68, 0x33, - 0x85, 0x29, 0x6b, 0xb6, 0x3c, 0xc8, 0x17, 0x40, - 0x80, 0x2c, 0x9a, 0x19, 0x58, 0x7c, 0x77, 0xdc, - 0xc9, 0xf7, 0x91, 0xa1, 0x6e, 0xfd, 0xd6, 0x3c, - 0x5e, 0x38, 0x9b, 0x90, 0xbf, 0xab, 0xab, 0x94, - 0x3d, 0x39, 0xc0, 0xe3, 0x90, 0x5c, 0xaf, 0xd1, - 0x81, 0x06, 0xe4, 0x03, 0x88, 0x90, 0xe1, 0x9a, - 0x09, 0x9d, 0x8a, 0xed, 0x81, 0xdf, 0x30, 0x85, - 0xc1, 0xe3, 0xd0, 0x72, 0x4e, 0x14, 0x03, 0x0b, - 0x72, 0x5f, 0x36, 0x7b, 0x13, 0xd7, 0xe9, 0x07, - 0x94, 0x89, 0xf3, 0x68, 0x6d, 0x86, 0x6b, 0x6a, - 0xa6, 0xdf, 0x68, 0x97, 0xf8, 0x15, 0x0f, 0xd1, - 0x8d, 0xeb, 0xd0, 0x43, 0xe6, 0x1d, 0x1e, 0x1a, - 0xc6, 0x31, 0x0c, 0x1d, 0xf0, 0x34, 0xe8, 0x8c, - 0x34, 0x39, 0xca, 0xf6, 0x35, 0xfe, 0xa4, 0xd2, - 0x1c, 0xb5, 0x96, 0x07, 0x3a, 0x40, 0xd0, 0x0b, - 0x7d, 0x20, 0x76, 0xeb, 0x24, 0xa1, 0xa8, 0x99, - 0x7c, 0xd1, 0x51, 0x3c, 0xe2, 0xf0, 0x96, 0xa6, - 0xeb, 0x0e, 0x8f, 0x8c, 0x35, 0xf4, 0x08, 0x26, - 0xf7, 0xd4, 0xbb, 0xf1, 0xd6, 0x4e, 0xa0, 0x9e, - 0xb8, 0x72, 0x60, 0xdf, 0x8f, 0x1d, 0xef, 0x86, - 0x86, 0x76, 0x56, 0x49, 0x4e, 0x31, 0x40, 0x47, - 0xce, 0xdf, 0x9d, 0x75, 0x5f, 0x7a, 0xe4, 0xc3, - 0x9c, 0xdf, 0xd7, 0x40, 0x2b, 0xf9, 0xb9, 0x12, - 0xf7, 0x1b, 0x9a, 0x55, 0x3f, 0x87, 0x3a, 0x67, - 0x75, 0xc4, 0xd9, 0xda, 0xd6, 0xc4, 0x30, 0xe6, - 0xc1, 0x53, 0xd1, 0x5c, 0x38, 0xdb, 0xff, 0x8d, - 0x21, 0x18, 0x6a, 0xb7, 0x1e, 0x05, 0x61, 0x05 -//}; -//unsigned int sig_grpx_member0_sha384_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_rndbase_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_rndbase_msg0.inc deleted file mode 100644 index b3b5888d49..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha384_rndbase_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha384 - * Message : "msg0" - * Basename: None (random base) - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha384_rndbase_msg0_dat[] = { - 0xa6, 0x0b, 0xac, 0x7d, 0xed, 0x65, 0xaa, 0x55, - 0xc7, 0xfc, 0x20, 0xde, 0x29, 0x02, 0x4d, 0x7f, - 0x24, 0xec, 0x24, 0x98, 0x94, 0xc9, 0x06, 0xd8, - 0x24, 0x14, 0x82, 0x06, 0xe6, 0xf0, 0x13, 0x6a, - 0x28, 0xfb, 0xed, 0xbf, 0x47, 0x25, 0x20, 0x14, - 0x5e, 0x68, 0x78, 0x1f, 0xc4, 0x41, 0x8c, 0x47, - 0x4a, 0xac, 0xdd, 0x88, 0x89, 0x95, 0xa6, 0x3a, - 0x52, 0x01, 0x87, 0xf0, 0xee, 0xf2, 0x8c, 0x19, - 0x4c, 0xe6, 0xb4, 0xc2, 0x2d, 0x8b, 0xdb, 0x45, - 0x91, 0x43, 0x79, 0xa5, 0x8f, 0x5b, 0x66, 0x54, - 0x34, 0x28, 0x1b, 0xe7, 0x10, 0x94, 0xbc, 0x88, - 0xcb, 0xf5, 0x4e, 0x6d, 0x3b, 0x46, 0x70, 0xb4, - 0xb6, 0x67, 0xf1, 0x64, 0xee, 0x1a, 0xe0, 0xb6, - 0x5d, 0x8c, 0xe6, 0xbd, 0xd0, 0x54, 0x7f, 0x51, - 0x1e, 0x4b, 0x55, 0x08, 0xb2, 0x1a, 0x22, 0x70, - 0x29, 0xba, 0x76, 0x59, 0xdb, 0x81, 0x95, 0x7b, - 0xc6, 0xd0, 0x7a, 0x0e, 0x4c, 0x6b, 0x54, 0xfb, - 0x01, 0xf7, 0x48, 0xc6, 0x62, 0x58, 0x3a, 0x68, - 0xa6, 0xb0, 0x31, 0x9f, 0x1c, 0x51, 0x90, 0x8b, - 0x59, 0xb4, 0x24, 0x8f, 0xd9, 0x56, 0xe4, 0xc0, - 0x58, 0x58, 0x5a, 0x1e, 0x8c, 0x75, 0x98, 0xcf, - 0xc8, 0x1c, 0x89, 0xc0, 0x94, 0x46, 0x82, 0xfc, - 0xc8, 0x10, 0x53, 0xc8, 0x55, 0xcd, 0x7e, 0x5b, - 0x7b, 0xd7, 0xfb, 0xa9, 0xe7, 0xcb, 0x9a, 0x9c, - 0x00, 0x8f, 0x95, 0x98, 0x7e, 0xe3, 0x24, 0x8b, - 0x7a, 0x8f, 0x19, 0x31, 0x1f, 0x7f, 0xcf, 0x75, - 0x39, 0x9a, 0x86, 0x21, 0x59, 0xf3, 0x66, 0xf6, - 0x7b, 0xf5, 0x0f, 0x36, 0x65, 0xe8, 0xbd, 0xca, - 0xed, 0x0e, 0x23, 0x62, 0x1c, 0x95, 0xb8, 0xfc, - 0x3d, 0x25, 0x63, 0x1a, 0x35, 0xd9, 0xbb, 0x88, - 0xed, 0xf9, 0x40, 0xe1, 0x93, 0xe8, 0x46, 0x59, - 0x40, 0x11, 0x58, 0x37, 0x82, 0x12, 0x85, 0xaf, - 0xf9, 0x76, 0x28, 0xcf, 0x26, 0x15, 0xdd, 0x1d, - 0xd5, 0x17, 0x03, 0x8f, 0xab, 0x79, 0xda, 0x93, - 0x1e, 0x7c, 0x03, 0xfd, 0x40, 0x3f, 0xaa, 0xb8, - 0xd1, 0x96, 0xe3, 0x64, 0x72, 0x6a, 0x0e, 0x62, - 0x21, 0x1a, 0x9c, 0x0b, 0xff, 0x4e, 0xea, 0x82, - 0xb2, 0xe2, 0xac, 0xa5, 0xab, 0x17, 0xb5, 0x58, - 0xae, 0x53, 0xc1, 0xa7, 0xeb, 0xd1, 0x7e, 0xc0, - 0xba, 0x26, 0xbf, 0x61, 0xc1, 0xe4, 0xe1, 0x19, - 0xfe, 0x7c, 0x41, 0x81, 0xc4, 0x82, 0x95, 0x51, - 0x1c, 0xc6, 0xd5, 0xf2, 0x7f, 0xa5, 0xee, 0x59, - 0xf7, 0xd1, 0x5e, 0x9c, 0xda, 0xf7, 0xe8, 0xa5, - 0x22, 0x2f, 0xc5, 0xf0, 0xa0, 0x73, 0xbd, 0xda, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x45, 0x60, 0xe3, 0x04, 0xa4, 0xff, 0xe1, 0xf0, - 0x26, 0x4e, 0x1d, 0xee, 0x9a, 0xe2, 0xdb, 0x9c, - 0x04, 0x7d, 0xf2, 0x88, 0x30, 0x44, 0x0b, 0x76, - 0x71, 0x64, 0x57, 0xfc, 0x43, 0xe0, 0x10, 0x32, - 0x03, 0xfe, 0x51, 0xfc, 0x0a, 0x57, 0x58, 0x31, - 0x19, 0x10, 0xce, 0xa3, 0x9b, 0xc1, 0x27, 0x65, - 0xad, 0xd7, 0x81, 0xd6, 0xe2, 0x59, 0xbf, 0xbd, - 0xe3, 0x59, 0x98, 0xcd, 0x37, 0xe0, 0xa9, 0xff, - 0x0d, 0x8f, 0x7e, 0xc8, 0x8e, 0xab, 0xd6, 0xb6, - 0xb6, 0x74, 0x6e, 0x5d, 0x7f, 0x60, 0x0e, 0x96, - 0x8c, 0x26, 0x27, 0xaf, 0x20, 0x8f, 0xee, 0x5c, - 0xcc, 0x61, 0x84, 0x3f, 0x39, 0x39, 0xb7, 0x07, - 0xbf, 0xf7, 0xcb, 0x75, 0x61, 0x34, 0xea, 0x06, - 0xb3, 0xc3, 0xd2, 0x2a, 0x51, 0x33, 0xce, 0x5e, - 0xb0, 0x26, 0x04, 0x48, 0x83, 0x5e, 0x3d, 0x59, - 0x8f, 0x50, 0x2b, 0xc6, 0xcd, 0x55, 0xf5, 0xb7, - 0x01, 0xd6, 0x84, 0x52, 0x1d, 0x22, 0x10, 0x92, - 0x10, 0x08, 0x3a, 0x63, 0xc2, 0x72, 0xfe, 0x9e, - 0x7e, 0x81, 0x0d, 0xa9, 0x16, 0x91, 0x0a, 0x55, - 0x9a, 0xf5, 0xae, 0x23, 0x2b, 0x8d, 0x67, 0x55, - 0x8c, 0x51, 0x19, 0x30, 0x1f, 0x9f, 0x8b, 0xc4, - 0xf4, 0x17, 0xab, 0xd1, 0x9d, 0x7a, 0xd8, 0xfa, - 0x5d, 0xdc, 0xe8, 0xc3, 0x24, 0x97, 0xae, 0x8a, - 0x64, 0x27, 0x86, 0x5f, 0x88, 0xf0, 0x92, 0xc3, - 0xa9, 0x13, 0x15, 0x1a, 0xc3, 0xbc, 0xba, 0x0a, - 0x3c, 0xb7, 0x8b, 0x46, 0xa9, 0x40, 0x94, 0x0e, - 0x17, 0x46, 0x3f, 0x6d, 0xcf, 0x0e, 0x0f, 0xf6, - 0xe6, 0xd7, 0x5c, 0x86, 0x44, 0xf7, 0x1a, 0x42, - 0xa0, 0xbc, 0x93, 0x9c, 0x66, 0x9d, 0x26, 0xa7, - 0x54, 0xad, 0x85, 0x03, 0x3c, 0x12, 0xa9, 0xab, - 0x56, 0xcc, 0xe7, 0x60, 0xb2, 0x5b, 0x06, 0x88, - 0x81, 0x47, 0xe4, 0x52, 0xde, 0x3d, 0xe0, 0x14, - 0x17, 0xea, 0xd1, 0x78, 0x30, 0xf2, 0xca, 0x6b, - 0xc4, 0x15, 0xad, 0x2f, 0x8e, 0x36, 0xa9, 0x18, - 0x88, 0x74, 0x62, 0xba, 0xf4, 0x6a, 0x64, 0x8c, - 0x20, 0x1a, 0x8f, 0x92, 0x00, 0x6d, 0x12, 0x68, - 0x52, 0x41, 0x3b, 0xc8, 0x88, 0xd9, 0xda, 0x6d, - 0x19, 0xc1, 0x32, 0x82, 0x6e, 0xd8, 0xe2, 0xd7, - 0x3b, 0x68, 0xf4, 0x87, 0x96, 0xe4, 0xf4, 0x91, - 0x52, 0x02, 0xf0, 0x02, 0xf6, 0x8e, 0xdd, 0x49, - 0x4d, 0xc6, 0x03, 0x0d, 0xf9, 0x27, 0x5c, 0x81, - 0xf0, 0xb8, 0xf4, 0xa1, 0x5f, 0x01, 0x88, 0x2a, - 0x05, 0x96, 0xbd, 0xbc, 0xe8, 0x0f, 0xec, 0xe5, - 0x83, 0xe9, 0xfc, 0x4c, 0xe1, 0xcb, 0xec, 0x51, - 0xaa, 0xb3, 0xc7, 0xd6, 0x64, 0x63, 0x5c, 0x66, - 0x46, 0xed, 0x7f, 0x49, 0x5a, 0x76, 0xb2, 0x8f, - 0x13, 0x19, 0x61, 0x3d, 0x95, 0x10, 0xb0, 0x5a, - 0x63, 0x35, 0xed, 0x0f, 0xdc, 0xf6, 0xd5, 0xf6, - 0x90, 0x52, 0xa3, 0x0c, 0x7c, 0xbc, 0x1f, 0x60, - 0xc4, 0x30, 0xd9, 0xe8, 0xe5, 0x70, 0xfa, 0x67, - 0xf2, 0x79, 0x76, 0x14, 0x4d, 0x5f, 0xae, 0x4f, - 0x2f, 0x93, 0x9d, 0x37, 0x1d, 0x53, 0xca, 0xd8, - 0x20, 0x1d, 0x5a, 0x2e, 0x3c, 0x9b, 0x6f, 0x3c, - 0xdb, 0xa9, 0xac, 0x4d, 0xe3, 0x46, 0x8c, 0x70, - 0xe7, 0x8b, 0xdd, 0x9c, 0x57, 0xd0, 0x5d, 0x6f, - 0x8c, 0x62, 0xc1, 0xd1, 0x83, 0xbc, 0x83, 0xa2, - 0x92, 0x6d, 0xad, 0xc5, 0xbd, 0xab, 0x48, 0xd0, - 0x43, 0xe0, 0xff, 0x5b, 0x90, 0x57, 0xa3, 0x6f, - 0xd6, 0xa3, 0x9e, 0x70, 0x23, 0x18, 0x9d, 0xa0, - 0x06, 0x5d, 0xa2, 0xe0, 0x43, 0xed, 0x3b, 0xd3 -//}; -//unsigned int sig_grpx_member0_sha384_rndbase_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_bsn0_msg0.inc deleted file mode 100644 index 072a2248b0..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_bsn0_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha512 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha512_bsn0_msg0_dat[] = { - 0x72, 0xed, 0x4f, 0x01, 0xf2, 0xfe, 0xc9, 0xf4, - 0x56, 0x4f, 0x11, 0x31, 0x62, 0x07, 0x02, 0x0f, - 0xed, 0xd0, 0x6b, 0xe8, 0xbf, 0xa9, 0x0b, 0x55, - 0xb8, 0xf7, 0xe9, 0x6e, 0xaa, 0x13, 0x2e, 0x6f, - 0xa7, 0xd5, 0xec, 0x4b, 0x3e, 0x23, 0x5f, 0x4f, - 0x61, 0x44, 0x52, 0xc1, 0x75, 0x0b, 0x13, 0xad, - 0xa1, 0x53, 0x0d, 0x6a, 0x73, 0xed, 0x5e, 0x49, - 0xa9, 0xed, 0x1d, 0x88, 0xde, 0xa6, 0x93, 0x18, - 0x4a, 0x58, 0xea, 0xc3, 0x7c, 0x9e, 0xf1, 0x2a, - 0x1a, 0xbf, 0x5a, 0xf8, 0xd5, 0xb4, 0xae, 0xa8, - 0x9a, 0x37, 0xdc, 0x1b, 0xe1, 0xab, 0xb0, 0xef, - 0x45, 0x88, 0x94, 0x48, 0x99, 0xc8, 0x70, 0x3b, - 0x25, 0x70, 0x5a, 0x84, 0x4c, 0x65, 0x29, 0x64, - 0xe2, 0x2b, 0x28, 0x84, 0xcf, 0x05, 0x83, 0xfb, - 0x00, 0xe9, 0x20, 0xc2, 0xb2, 0x12, 0x3c, 0x90, - 0x12, 0xeb, 0x85, 0x3a, 0x70, 0xe4, 0xed, 0x64, - 0x73, 0xc2, 0xef, 0x1b, 0x33, 0x7b, 0xa9, 0xf1, - 0x76, 0xae, 0xac, 0x99, 0xd1, 0xaa, 0x9c, 0xb1, - 0xcb, 0x17, 0x40, 0xf9, 0x9d, 0xa9, 0x75, 0x7f, - 0xe6, 0x9e, 0x8d, 0x31, 0xf0, 0x07, 0x7b, 0x33, - 0xb6, 0x11, 0x7e, 0xf3, 0xa0, 0xf2, 0x42, 0xdf, - 0xe2, 0x6a, 0xa0, 0x10, 0xb6, 0x6a, 0xda, 0x6d, - 0x1e, 0xf3, 0x18, 0xf1, 0xd7, 0x0c, 0x9b, 0x67, - 0x97, 0x62, 0xd6, 0xc7, 0x92, 0x61, 0xa0, 0x23, - 0x4e, 0xb2, 0xd3, 0x08, 0x5e, 0x74, 0x65, 0xd0, - 0xca, 0x0c, 0x9d, 0x5d, 0x81, 0x13, 0xa3, 0x16, - 0x6d, 0x44, 0xc4, 0x74, 0x4f, 0xf4, 0x33, 0x97, - 0xd5, 0xb5, 0x46, 0xc7, 0xde, 0x7c, 0xef, 0xbb, - 0xfc, 0x58, 0x16, 0xe3, 0x13, 0xc3, 0x7d, 0x24, - 0x1c, 0x8a, 0x50, 0x98, 0x31, 0x81, 0x66, 0xc3, - 0x4f, 0x75, 0xd7, 0xa8, 0xc4, 0xec, 0xe0, 0x63, - 0xf4, 0x48, 0x79, 0xdf, 0x5a, 0xec, 0xad, 0x64, - 0x48, 0x21, 0x28, 0x3b, 0x8a, 0x75, 0xcc, 0x37, - 0x78, 0x0f, 0x56, 0x4a, 0x1e, 0xbe, 0xc1, 0xd4, - 0x24, 0x6d, 0x0a, 0x62, 0x35, 0x3d, 0x87, 0xcf, - 0xd4, 0x45, 0xb7, 0x16, 0xab, 0xe7, 0xce, 0x2a, - 0xb3, 0xda, 0x32, 0xd1, 0x5d, 0xa8, 0x23, 0x51, - 0x3c, 0x6e, 0x24, 0x3e, 0x19, 0x34, 0xd1, 0xe7, - 0x69, 0x59, 0x2e, 0x2c, 0x56, 0x40, 0x92, 0x51, - 0x90, 0xbe, 0xcd, 0x7d, 0x42, 0x5c, 0xa9, 0xf0, - 0x4b, 0xcb, 0x5e, 0x2b, 0xb3, 0xa6, 0x15, 0xf3, - 0xfb, 0x60, 0x27, 0xad, 0x8e, 0x57, 0xff, 0x41, - 0x45, 0xa0, 0xb2, 0xb9, 0x89, 0xcc, 0x9e, 0x9e, - 0x36, 0x12, 0x3d, 0x5e, 0xdd, 0xcf, 0x54, 0xbc, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x78, 0xe5, 0x54, 0xb7, 0x82, 0x81, 0xb6, 0xf2, - 0xab, 0x11, 0x73, 0x08, 0x4f, 0x9a, 0xda, 0xcc, - 0xc5, 0x94, 0x78, 0x08, 0xc0, 0x22, 0xda, 0x06, - 0x87, 0xd4, 0xa0, 0x9f, 0x50, 0xb3, 0x04, 0xdc, - 0xbe, 0x5b, 0x02, 0x28, 0x71, 0x8f, 0x4f, 0x18, - 0x2b, 0xb1, 0xab, 0x62, 0x83, 0x9c, 0xb7, 0x1b, - 0x87, 0x48, 0x8f, 0xbe, 0x4f, 0x1c, 0x8d, 0x16, - 0xa4, 0xed, 0x4f, 0xe4, 0x10, 0x4c, 0x83, 0xd9, - 0xcb, 0xa3, 0xdc, 0xd2, 0x5e, 0xdd, 0xab, 0x2d, - 0x5d, 0x73, 0x88, 0x5f, 0x92, 0x66, 0x0f, 0xaa, - 0xed, 0x5c, 0x1e, 0xf5, 0xca, 0x82, 0xd7, 0xcb, - 0x04, 0x98, 0xb1, 0x4d, 0xb1, 0x6e, 0xd0, 0x04, - 0x48, 0xf8, 0x84, 0x66, 0xae, 0x01, 0x3e, 0x24, - 0x9f, 0xdf, 0x0c, 0x7a, 0x9a, 0x22, 0xd3, 0x46, - 0xe0, 0x0b, 0xb2, 0x68, 0x65, 0x64, 0x95, 0x8d, - 0x45, 0xa2, 0xb2, 0xd9, 0x49, 0x8b, 0xd7, 0x7d, - 0x0f, 0x1a, 0x80, 0xd3, 0x71, 0xd9, 0x05, 0xb3, - 0xff, 0x65, 0x2f, 0x7f, 0xe1, 0xb7, 0x68, 0xc6, - 0x4f, 0x22, 0x69, 0x2a, 0xcb, 0x5e, 0x45, 0xed, - 0x40, 0x30, 0xd5, 0xc7, 0xda, 0xf8, 0xb9, 0x22, - 0xa6, 0xe8, 0x00, 0x6c, 0xa2, 0x30, 0x37, 0x36, - 0xf8, 0xe6, 0xcb, 0xca, 0x5f, 0xc8, 0x9b, 0xc0, - 0x03, 0xba, 0x08, 0x5f, 0x81, 0xa4, 0x1d, 0x55, - 0x11, 0x5b, 0x34, 0x3c, 0x6b, 0x55, 0x5a, 0xc6, - 0xe2, 0x3b, 0xf3, 0xbc, 0x15, 0xa5, 0x70, 0x9a, - 0x1a, 0x4c, 0x9e, 0x53, 0x8b, 0xa3, 0x46, 0x5f, - 0xbc, 0x20, 0x15, 0x8a, 0xc7, 0x95, 0xb4, 0xdc, - 0x87, 0xbf, 0xce, 0x75, 0x8a, 0xa7, 0x5f, 0xc7, - 0x77, 0x8f, 0x4c, 0xd9, 0x72, 0x36, 0xc6, 0xb6, - 0xb6, 0x2a, 0x11, 0x59, 0xaf, 0x0f, 0x6c, 0xac, - 0x4d, 0xdd, 0x99, 0xd6, 0xa5, 0x85, 0x12, 0x08, - 0xeb, 0x38, 0x20, 0x0f, 0xb7, 0xe0, 0x09, 0x72, - 0x15, 0xfb, 0x11, 0x1e, 0x35, 0x4e, 0x01, 0xba, - 0x96, 0x0a, 0x0e, 0x51, 0x10, 0x8b, 0x68, 0x7c, - 0xf8, 0x8e, 0x56, 0x65, 0xe2, 0x25, 0x42, 0x43, - 0xeb, 0xf4, 0xca, 0xf2, 0xb7, 0x66, 0x3c, 0x38, - 0xb2, 0x99, 0xd1, 0x2f, 0x2d, 0x30, 0xbd, 0xa3, - 0x05, 0x41, 0x40, 0x26, 0x5b, 0x83, 0x06, 0x1f, - 0x2a, 0xad, 0xd2, 0x86, 0x1c, 0x7f, 0x1a, 0x80, - 0x79, 0x88, 0xa1, 0xc6, 0xd2, 0x9f, 0xf3, 0x51, - 0x7b, 0xd3, 0xe9, 0x6c, 0xd6, 0xe4, 0xaa, 0x21, - 0x4d, 0xe6, 0x42, 0xea, 0x53, 0x6f, 0xfe, 0xcd, - 0xf8, 0x67, 0x6d, 0xb3, 0x16, 0x67, 0x55, 0x51, - 0x60, 0xa5, 0xe4, 0x1e, 0x5f, 0xd0, 0xfc, 0xcd, - 0x82, 0xb1, 0x8f, 0xeb, 0x5f, 0xe3, 0xf3, 0xd5, - 0xc7, 0x9e, 0xa2, 0x31, 0x31, 0xee, 0x61, 0x29, - 0xe8, 0xe1, 0x8f, 0xe7, 0x9b, 0x94, 0x34, 0xec, - 0x18, 0xd4, 0xac, 0x30, 0xd9, 0xd5, 0x83, 0x08, - 0xba, 0x1d, 0x27, 0x08, 0xad, 0x89, 0x74, 0xcc, - 0xff, 0x5a, 0x8f, 0xc7, 0xca, 0x91, 0x57, 0xb3, - 0xf9, 0x8a, 0xc4, 0x33, 0xa2, 0xea, 0xa1, 0x60, - 0xc2, 0xfb, 0xea, 0xca, 0xf7, 0x97, 0xff, 0xb3, - 0x5a, 0xe3, 0x06, 0x45, 0x37, 0xf8, 0x48, 0xa8, - 0x51, 0x93, 0x71, 0xea, 0x5a, 0xfa, 0x7e, 0x32, - 0x68, 0x0a, 0x2f, 0x9d, 0x55, 0x94, 0x94, 0xe1, - 0x1c, 0x41, 0xce, 0x8d, 0xe6, 0x3b, 0xda, 0x32, - 0xb4, 0xf4, 0x90, 0xe6, 0xb0, 0x94, 0x17, 0x2e, - 0x5a, 0x36, 0xbb, 0x9b, 0xa1, 0x39, 0x1e, 0x69, - 0xf6, 0x2c, 0xca, 0x6e, 0xe1, 0xbb, 0x70, 0xd4, - 0x32, 0xdf, 0xd8, 0x88, 0x6b, 0x28, 0x14, 0x31 -//}; -//unsigned int sig_grpx_member0_sha512_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_rndbase_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_rndbase_msg0.inc deleted file mode 100644 index e6a7db1da1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member0/sig_sha512_rndbase_msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member0 - * HashAlg : Sha512 - * Message : "msg0" - * Basename: None (random base) - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha512_rndbase_msg0_dat[] = { - 0x43, 0xa4, 0x74, 0x4b, 0xcb, 0x17, 0xfa, 0xaf, - 0xb8, 0x6e, 0xb4, 0xca, 0x94, 0x4d, 0xe8, 0x5b, - 0x40, 0x88, 0x6c, 0x9c, 0xfa, 0xba, 0x4a, 0x4c, - 0x65, 0x94, 0xd1, 0x17, 0x90, 0x5b, 0x66, 0x12, - 0x46, 0xcf, 0xcc, 0x6e, 0x47, 0x2c, 0x0c, 0xa7, - 0x4e, 0xb4, 0x62, 0x57, 0xdc, 0x70, 0xbb, 0xd0, - 0x52, 0xa7, 0x38, 0x97, 0xec, 0x34, 0x8c, 0xfd, - 0xe6, 0x5f, 0xa1, 0x8b, 0x8a, 0x1e, 0x0c, 0x41, - 0xa9, 0x86, 0x53, 0x85, 0x0e, 0xaa, 0xc2, 0x1d, - 0xe9, 0x42, 0x18, 0x2e, 0x1f, 0xca, 0xa0, 0x41, - 0x46, 0x04, 0x10, 0xb9, 0xc7, 0x15, 0x88, 0x41, - 0x92, 0x53, 0x7b, 0xb0, 0xc2, 0xf1, 0x96, 0x8f, - 0xc8, 0xe7, 0x4a, 0x43, 0x0a, 0xa2, 0x92, 0x08, - 0xd3, 0xdb, 0x09, 0xae, 0x31, 0x6c, 0xef, 0x9f, - 0xb7, 0x58, 0x4b, 0x41, 0x69, 0xf7, 0x5b, 0xbc, - 0x62, 0x3b, 0xa9, 0x9f, 0x4b, 0xcb, 0x17, 0x6f, - 0x26, 0xce, 0x54, 0x7e, 0xaa, 0x3c, 0x1a, 0xfd, - 0xab, 0x3a, 0x67, 0x11, 0x89, 0x16, 0xac, 0xfa, - 0xbf, 0xfb, 0x17, 0x6e, 0x39, 0xd1, 0x5a, 0x88, - 0x02, 0xf3, 0x14, 0xaa, 0x5c, 0xef, 0xa1, 0x69, - 0xb1, 0x76, 0x82, 0x72, 0x9c, 0xaa, 0x20, 0xb2, - 0xa6, 0x21, 0xac, 0x60, 0x77, 0x0b, 0xbb, 0x24, - 0x6f, 0x14, 0x9e, 0xea, 0x87, 0xb0, 0x91, 0x70, - 0xf9, 0x05, 0x18, 0x62, 0x32, 0x03, 0xb9, 0x95, - 0xad, 0xce, 0x40, 0x1f, 0x00, 0x33, 0x64, 0xf7, - 0x2a, 0xd9, 0xea, 0xeb, 0x4f, 0x5b, 0x6a, 0xbb, - 0x23, 0x56, 0x74, 0x31, 0xa7, 0x44, 0xae, 0xdd, - 0x60, 0x01, 0xa9, 0xb4, 0x82, 0xed, 0x55, 0xcd, - 0x81, 0x39, 0x40, 0xf1, 0xf3, 0x25, 0x7e, 0x27, - 0xfa, 0x5e, 0x44, 0xc6, 0x40, 0xfd, 0xde, 0x0b, - 0xab, 0xae, 0x53, 0xf5, 0x05, 0x78, 0xd3, 0xeb, - 0x1f, 0x4f, 0xb2, 0x56, 0x48, 0xe9, 0x08, 0xb1, - 0xa4, 0xc6, 0xbc, 0x20, 0x8c, 0xf4, 0x5e, 0x65, - 0xd7, 0x52, 0x59, 0x66, 0xe3, 0xf6, 0xbc, 0xc2, - 0x23, 0x29, 0x4a, 0x98, 0x53, 0x1c, 0xf5, 0x37, - 0x2a, 0x8b, 0x3b, 0x42, 0xf2, 0x10, 0xb4, 0x33, - 0x8b, 0xd6, 0x54, 0x83, 0xc3, 0x8d, 0x2c, 0x77, - 0x46, 0xae, 0x09, 0xc0, 0x47, 0xb7, 0x33, 0x59, - 0xe0, 0xc7, 0x0f, 0xbb, 0xea, 0x42, 0xdf, 0xb6, - 0xa9, 0x19, 0xd4, 0x9a, 0xfd, 0x5f, 0x82, 0x18, - 0x3e, 0x97, 0x89, 0x79, 0xca, 0x92, 0xed, 0x33, - 0xa3, 0xc3, 0x8e, 0x34, 0xf0, 0x03, 0xb5, 0x83, - 0x28, 0x6f, 0x5f, 0x0c, 0x35, 0xee, 0x0f, 0x16, - 0x3e, 0xdd, 0xb3, 0xd4, 0x5d, 0x0b, 0xa5, 0x26, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xce, 0x9d, 0x84, 0x2d, 0xf0, 0x21, 0xe7, 0x25, - 0x11, 0xb5, 0xee, 0xb0, 0x4a, 0x4e, 0x8c, 0x3f, - 0x83, 0xd0, 0x91, 0xf2, 0x15, 0x88, 0xe3, 0x8c, - 0x9a, 0x24, 0xca, 0xea, 0x34, 0x4f, 0xa8, 0xee, - 0x3c, 0xf6, 0x8c, 0x62, 0xff, 0xa2, 0x93, 0x49, - 0x4d, 0xb9, 0x39, 0x25, 0xcb, 0x1b, 0x7e, 0x9b, - 0xef, 0xb6, 0xde, 0x4e, 0xc0, 0x80, 0x27, 0xac, - 0xdd, 0xf8, 0x34, 0xa2, 0xb4, 0x4b, 0x29, 0x04, - 0xd6, 0xc4, 0x98, 0x3a, 0x9c, 0x23, 0xec, 0xf5, - 0x90, 0x44, 0xfb, 0x04, 0x15, 0x77, 0xdd, 0x1c, - 0x3e, 0x6e, 0xc2, 0x97, 0x0c, 0x77, 0x83, 0x95, - 0xe4, 0x49, 0xdf, 0x28, 0x38, 0x80, 0x97, 0x70, - 0xa0, 0xf2, 0xa2, 0xb0, 0x23, 0x64, 0xce, 0x4b, - 0x7e, 0x1e, 0xd5, 0x07, 0x80, 0x3a, 0xe0, 0xb5, - 0xa6, 0xf2, 0x82, 0xa3, 0x3a, 0xd0, 0x5f, 0xe9, - 0x2b, 0x61, 0xb2, 0x15, 0x8e, 0x19, 0x81, 0x84, - 0x64, 0x4f, 0x9e, 0x3d, 0xc4, 0x94, 0xad, 0x9f, - 0x7c, 0x81, 0x16, 0x70, 0xb0, 0x93, 0xea, 0x7d, - 0x34, 0x55, 0xe7, 0xd0, 0xae, 0x24, 0xa7, 0x54, - 0xa5, 0x19, 0x0c, 0x71, 0x50, 0xea, 0x93, 0x07, - 0xbd, 0x67, 0xdf, 0xa3, 0x9a, 0xbe, 0xf8, 0x89, - 0xca, 0xe2, 0xab, 0xb3, 0xb1, 0xd2, 0xf2, 0x05, - 0xab, 0xa2, 0x1e, 0xa7, 0xda, 0xf4, 0x27, 0x83, - 0x8f, 0xee, 0xe1, 0x31, 0x82, 0x1b, 0x5d, 0x29, - 0xb1, 0x23, 0x11, 0x64, 0x86, 0x70, 0x99, 0x06, - 0x6d, 0xaf, 0xc2, 0xeb, 0xd2, 0x1a, 0xb7, 0x2f, - 0x92, 0x0b, 0x33, 0xfe, 0x5d, 0x9b, 0xc6, 0xdd, - 0x39, 0x84, 0xbe, 0xbf, 0x05, 0xff, 0x92, 0x9a, - 0x52, 0x08, 0x24, 0xb6, 0xc3, 0xa8, 0x84, 0x39, - 0xda, 0xf8, 0x26, 0xcb, 0x56, 0x12, 0xb5, 0xd3, - 0x03, 0x54, 0x3d, 0xf3, 0xf9, 0x36, 0xf4, 0xff, - 0xc4, 0xf6, 0x1f, 0x15, 0xed, 0x70, 0x18, 0x0a, - 0x38, 0x08, 0x6f, 0xf6, 0x3a, 0x61, 0x2d, 0x43, - 0x4a, 0x04, 0x48, 0x3f, 0xe9, 0xe8, 0x8c, 0xc7, - 0xd9, 0x18, 0x86, 0xfb, 0x7c, 0xc3, 0xa6, 0x87, - 0x66, 0xdc, 0x94, 0x65, 0x19, 0x0f, 0xe3, 0x69, - 0x09, 0x34, 0x4c, 0x47, 0x0a, 0xc1, 0x5f, 0x41, - 0xb6, 0x18, 0x3d, 0x5a, 0xfb, 0xf2, 0x52, 0x9a, - 0xc1, 0xbe, 0x1e, 0x86, 0x25, 0xe8, 0xd4, 0xa7, - 0xa9, 0x79, 0x03, 0x7b, 0xea, 0x44, 0x5e, 0x84, - 0x2d, 0x21, 0x27, 0x52, 0x65, 0xf4, 0x36, 0x78, - 0x89, 0x0a, 0xcb, 0x3e, 0x00, 0x08, 0xb9, 0x43, - 0xc9, 0x50, 0xf2, 0xfe, 0x1a, 0x15, 0x8b, 0xdf, - 0xac, 0xa8, 0x23, 0x73, 0xc8, 0xab, 0x8d, 0xa2, - 0x62, 0x62, 0x7b, 0xdd, 0x5c, 0x05, 0x36, 0x3a, - 0x08, 0xe5, 0xca, 0x9f, 0x1b, 0x38, 0x11, 0x43, - 0xb9, 0xc5, 0x5d, 0x84, 0x7f, 0xfc, 0x8c, 0x88, - 0x28, 0x84, 0x0a, 0xda, 0x90, 0xe0, 0x98, 0x29, - 0x9a, 0xae, 0x3a, 0x2d, 0xae, 0xc2, 0x45, 0xa3, - 0x92, 0xbd, 0xb6, 0x2b, 0x2c, 0xae, 0xb2, 0x7a, - 0x91, 0x73, 0x27, 0x09, 0xcf, 0xf3, 0x71, 0xdf, - 0xf9, 0xbd, 0x6d, 0xee, 0xd6, 0x1c, 0xd8, 0x8b, - 0xf5, 0xc1, 0x84, 0x93, 0xc1, 0x8d, 0x60, 0xec, - 0x6d, 0x98, 0x19, 0xf5, 0x39, 0xbd, 0x51, 0x31, - 0xd6, 0xc8, 0x3c, 0x28, 0xf9, 0xf5, 0x36, 0xfe, - 0x43, 0xd9, 0xf5, 0x3b, 0x13, 0x41, 0xda, 0x48, - 0xbc, 0x1f, 0x64, 0xb3, 0x70, 0x68, 0xa0, 0xda, - 0xea, 0xad, 0x70, 0xed, 0x5c, 0x80, 0x40, 0x3c, - 0xc0, 0x77, 0x18, 0x97, 0x0a, 0x60, 0x11, 0x05, - 0xcc, 0x2a, 0x91, 0x40, 0xa5, 0x5e, 0x0b, 0x14 -//}; -//unsigned int sig_grpx_member0_sha512_rndbase_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/mprivkey.inc deleted file mode 100644 index 62a5e29941..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/mprivkey.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : member1 - */ -//unsigned char mprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x14, 0x26, 0x0f, 0x4c, 0x15, 0xb6, 0xea, 0x44, - 0x5f, 0x3c, 0x01, 0xc2, 0xad, 0xe7, 0x00, 0x63, - 0x41, 0xa8, 0xff, 0xa3, 0x7a, 0x10, 0x00, 0x80, - 0xdf, 0xb0, 0x9c, 0x1e, 0x77, 0x19, 0x72, 0x6e, - 0x47, 0x4e, 0x27, 0x8c, 0xfb, 0x1d, 0x86, 0xf7, - 0x03, 0x85, 0x27, 0x93, 0xac, 0x0a, 0xbe, 0x94, - 0x24, 0x79, 0x23, 0x21, 0x0a, 0x80, 0xac, 0x00, - 0xdd, 0x78, 0xd8, 0x68, 0xb4, 0xf4, 0x81, 0x6c, - 0x0c, 0x89, 0x68, 0x9d, 0x6b, 0x0a, 0x77, 0x6c, - 0x7a, 0xdb, 0x96, 0xea, 0xaa, 0x8a, 0x47, 0xd2, - 0x59, 0xc6, 0x98, 0xde, 0x47, 0xb2, 0xc7, 0xab, - 0xf0, 0xb4, 0xac, 0x1c, 0x58, 0xe7, 0x20, 0x1f, - 0x5b, 0xcc, 0xd0, 0xef, 0x05, 0x3c, 0x02, 0x94, - 0xee, 0xaf, 0x1e, 0x12, 0x90, 0xd9, 0xc6, 0x05, - 0x36, 0x75, 0xc7, 0x46, 0x3c, 0x6c, 0x19, 0xaf, - 0xbe, 0xe7, 0x43, 0x88, 0x6c, 0x08, 0xa2, 0xb5 -//}; -//unsigned int mprivkey_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/sig_sha256_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/sig_sha256_bsn0_msg0.inc deleted file mode 100644 index 0b729f5218..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/member1/sig_sha256_bsn0_msg0.inc +++ /dev/null @@ -1,136 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : member1 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ - -//unsigned char sig_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0xfa, 0xd0, 0x0a, 0x0a, 0x32, 0xc3, 0xf4, 0x37, - 0x41, 0x79, 0x5d, 0xfe, 0xe4, 0x86, 0x46, 0x9b, - 0x92, 0x68, 0xae, 0xd4, 0xd0, 0xc9, 0x6f, 0xfa, - 0x2c, 0xe4, 0xf8, 0x19, 0x62, 0x8f, 0x63, 0x59, - 0x34, 0xf2, 0x9c, 0xae, 0x5e, 0x09, 0x42, 0x91, - 0x16, 0x5b, 0x78, 0x3f, 0x77, 0xa4, 0xb7, 0xef, - 0x33, 0xf7, 0x50, 0x0b, 0x7d, 0x6b, 0xa9, 0x0e, - 0xce, 0x78, 0x21, 0xd7, 0xdd, 0x63, 0x21, 0x20, - 0xda, 0xdc, 0xa0, 0x5f, 0xa0, 0x1e, 0xf3, 0x08, - 0x18, 0xd4, 0x0d, 0x33, 0x90, 0x36, 0x2b, 0xc6, - 0x30, 0xa8, 0x4a, 0xce, 0x8b, 0xf4, 0xfa, 0x09, - 0x8e, 0x37, 0x01, 0x19, 0x56, 0xd7, 0x73, 0xec, - 0x78, 0xd4, 0x2d, 0x3f, 0x64, 0x51, 0xe8, 0xf8, - 0x98, 0x70, 0x9e, 0x13, 0xd0, 0xca, 0xcf, 0x91, - 0x86, 0x54, 0x47, 0xea, 0xe7, 0x37, 0x3e, 0x8a, - 0x98, 0x0f, 0x16, 0x4b, 0xfb, 0xe0, 0x39, 0xa7, - 0x94, 0x12, 0x20, 0x27, 0x95, 0x40, 0xc0, 0x80, - 0x1c, 0x22, 0x36, 0x27, 0xd4, 0x67, 0x3e, 0xc2, - 0x8a, 0x68, 0xfb, 0x60, 0x15, 0x16, 0x52, 0xf1, - 0x6c, 0xdd, 0x8f, 0xf6, 0xbb, 0x28, 0x13, 0x0e, - 0xb4, 0x00, 0x22, 0x81, 0xf0, 0x4a, 0xeb, 0x1a, - 0x74, 0x07, 0x1e, 0x5f, 0xd6, 0xa1, 0x03, 0x35, - 0xa4, 0x48, 0x4a, 0x0f, 0x0a, 0xa4, 0x30, 0x4a, - 0x02, 0x52, 0xa7, 0xac, 0xdf, 0xf0, 0xf4, 0x3c, - 0xe1, 0xc6, 0xbd, 0xe1, 0x12, 0x70, 0x09, 0x0a, - 0x79, 0x83, 0x35, 0x85, 0x64, 0x93, 0xca, 0xb5, - 0xd7, 0x3d, 0x9b, 0xe7, 0xf0, 0x8f, 0xcf, 0x53, - 0xb5, 0xb0, 0x37, 0x95, 0x08, 0x72, 0x39, 0x89, - 0x3a, 0x3a, 0xf2, 0x9e, 0x5e, 0x04, 0xdd, 0x1d, - 0x0e, 0x55, 0x60, 0xef, 0x01, 0xe2, 0x51, 0x58, - 0xef, 0x3b, 0xe4, 0xab, 0x7f, 0x5d, 0x50, 0x5a, - 0x2d, 0xfd, 0x5f, 0x86, 0xd6, 0x0f, 0xbf, 0x77, - 0x7f, 0x64, 0xba, 0x95, 0xe8, 0x81, 0x4d, 0x8b, - 0xb9, 0xf4, 0x4d, 0x02, 0x29, 0x22, 0x37, 0x45, - 0xb4, 0x83, 0x31, 0x84, 0x39, 0x49, 0x97, 0xac, - 0x70, 0xe9, 0x15, 0xf3, 0xe5, 0x38, 0x01, 0x53, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xcb, 0xd2, 0x73, 0x50, 0x7b, 0x1d, 0xb4, 0x93, - 0xde, 0xe8, 0x23, 0x9c, 0xee, 0x77, 0x21, 0x0f, - 0x76, 0xf6, 0xec, 0x66, 0x0d, 0x26, 0xd9, 0x8a, - 0x08, 0x29, 0x7c, 0x40, 0x16, 0xf8, 0x9d, 0xdf, - 0x84, 0x0c, 0xf7, 0x7c, 0x74, 0x01, 0xd8, 0xe7, - 0xed, 0x83, 0x82, 0x2f, 0x0d, 0xfc, 0x77, 0x63, - 0xb6, 0x72, 0xba, 0xc1, 0x8e, 0x13, 0xd4, 0xcd, - 0x1f, 0x50, 0x95, 0x8f, 0x56, 0x89, 0x64, 0x1a, - 0x38, 0xbe, 0x82, 0x38, 0x24, 0x2b, 0xcc, 0x1b, - 0x76, 0xac, 0x31, 0xf7, 0x91, 0x49, 0x33, 0x48, - 0x05, 0x71, 0x73, 0x3c, 0xed, 0x26, 0x22, 0x26, - 0x2b, 0xca, 0x11, 0x5b, 0xb5, 0xc4, 0x13, 0x33, - 0x70, 0x43, 0xa6, 0x6f, 0x0f, 0x97, 0x92, 0xe7, - 0x71, 0xa4, 0x96, 0x79, 0x9f, 0xa3, 0x21, 0x10, - 0xb8, 0xc2, 0x9c, 0x30, 0x73, 0x72, 0x16, 0x85, - 0x2f, 0xac, 0x76, 0xfd, 0x90, 0x88, 0x03, 0x58, - 0x5b, 0xb5, 0x40, 0x40, 0xf9, 0x76, 0x39, 0x50, - 0x15, 0x8a, 0x39, 0xb5, 0x93, 0x68, 0xe1, 0x1d, - 0xcb, 0xce, 0x54, 0xe1, 0x50, 0xd9, 0xed, 0x75, - 0x6e, 0x28, 0x67, 0x9d, 0xb6, 0x80, 0x91, 0x7e, - 0x8e, 0xd9, 0x01, 0xd0, 0x45, 0xd7, 0xa9, 0x32, - 0xd1, 0xd6, 0x62, 0x48, 0x5e, 0xa9, 0xb9, 0x08, - 0x3a, 0x01, 0xa7, 0x7b, 0xa1, 0x1e, 0x58, 0x13, - 0xb3, 0x63, 0x4b, 0x1c, 0x14, 0x17, 0x3e, 0xe6, - 0x02, 0xe1, 0x76, 0x80, 0xda, 0xd5, 0x5b, 0xed, - 0x9d, 0xae, 0x05, 0x7e, 0x69, 0xb1, 0xbd, 0xc6, - 0x2c, 0x46, 0x28, 0x9d, 0x74, 0xd6, 0x19, 0xd8, - 0xb4, 0x50, 0x08, 0xb5, 0xb9, 0x51, 0x9a, 0xef, - 0xf7, 0x1d, 0x74, 0xf0, 0xf8, 0x65, 0x6f, 0x9e, - 0x8a, 0xb6, 0x77, 0x12, 0x95, 0x92, 0x91, 0xec, - 0x6b, 0x64, 0xfa, 0xd3, 0xc1, 0x08, 0x52, 0x0f, - 0xc9, 0x97, 0xcd, 0xd6, 0xda, 0x1b, 0x04, 0x01, - 0x2c, 0x51, 0xbd, 0x09, 0x39, 0x26, 0x8c, 0x70, - 0x46, 0x68, 0x4d, 0xf6, 0x07, 0xb8, 0x26, 0xb4, - 0xb2, 0xf9, 0x7a, 0x3b, 0x9b, 0x23, 0xbf, 0xed, - 0xfe, 0xca, 0x42, 0x73, 0x50, 0xe2, 0xf8, 0x9b, - 0x95, 0xf6, 0x22, 0x82, 0xa6, 0xfd, 0xfe, 0x75, - 0x9c, 0x9d, 0x0e, 0x13, 0xdd, 0xb5, 0xfc, 0x2a, - 0xc7, 0x59, 0x8f, 0xa8, 0xf5, 0x8c, 0xe1, 0x8b, - 0xd3, 0x95, 0xc2, 0x24, 0x9e, 0x62, 0x54, 0x34, - 0x17, 0x78, 0x84, 0xd8, 0x26, 0x82, 0x82, 0x41, - 0xbd, 0x66, 0xd2, 0xa1, 0x0a, 0x6a, 0xef, 0x98, - 0x0f, 0x3b, 0x79, 0xed, 0x1e, 0xb1, 0xb0, 0xce, - 0x33, 0x7a, 0x33, 0xfe, 0x73, 0x5e, 0x3f, 0x22, - 0xea, 0xb2, 0x08, 0xc3, 0x65, 0xa6, 0x5d, 0x00, - 0x07, 0xd4, 0xa9, 0x17, 0x86, 0xa7, 0x50, 0xa9, - 0x4f, 0xdf, 0xe0, 0x80, 0x3a, 0xcd, 0x16, 0x09, - 0x42, 0xa5, 0xc0, 0x50, 0xff, 0xba, 0xf2, 0xd3, - 0x6e, 0x6a, 0x20, 0x66, 0x15, 0x52, 0x51, 0x7b, - 0xb8, 0x0b, 0x71, 0x69, 0x5c, 0x4c, 0xd0, 0x74, - 0x60, 0x44, 0x65, 0x58, 0x19, 0x62, 0x1d, 0x0f, - 0x4b, 0xea, 0x7a, 0xb6, 0x3c, 0x54, 0x81, 0xd2, - 0xec, 0x53, 0xcf, 0x16, 0x4a, 0x1d, 0xfa, 0x01, - 0x94, 0xc7, 0x9e, 0x53, 0xbb, 0xa6, 0xe0, 0xb5, - 0x33, 0x6f, 0x9d, 0x6e, 0x81, 0x79, 0x18, 0x30, - 0xf9, 0x7b, 0xbb, 0x97, 0xf5, 0x9f, 0xa6, 0x1c, - 0xaa, 0x59, 0xd2, 0xe0, 0xf8, 0xc8, 0xc8, 0x56, - 0xbb, 0x91, 0x97, 0x29, 0xaf, 0xad, 0xc1, 0x5f, - 0x0d, 0x8e, 0x5a, 0x12, 0x8a, 0xc1, 0x64, 0x3c, - 0x2a, 0x82, 0x7b, 0xef, 0xfb, 0x67, 0xdc, 0x58 -//}; -//unsigned int sig_sha256_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey000.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey000.inc deleted file mode 100644 index 895fc7d395..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey000.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : privrevokedmember000 (revoked in grpX privrl) - */ - -//unsigned char mprivatekey000_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x1b, 0x31, 0xd8, 0x78, 0x27, 0xc5, 0x4a, 0x53, - 0x64, 0xe2, 0xcb, 0x12, 0x10, 0xcb, 0xfb, 0xb5, - 0x12, 0x03, 0x81, 0x3c, 0xee, 0x99, 0xbe, 0xb3, - 0x8b, 0xfe, 0xe9, 0xb9, 0x3f, 0x79, 0xcf, 0xe4, - 0xa3, 0x0f, 0x5c, 0xba, 0x7f, 0x4a, 0x9e, 0x34, - 0xda, 0x75, 0x97, 0x3d, 0x85, 0x44, 0x0b, 0x75, - 0x00, 0x80, 0x65, 0x53, 0x51, 0x07, 0x40, 0xcc, - 0xe7, 0x0f, 0x52, 0x49, 0xf4, 0xb6, 0x90, 0xe0, - 0x8f, 0xf3, 0x60, 0xe2, 0xe8, 0x01, 0x1d, 0xbb, - 0x02, 0xa3, 0x49, 0x99, 0xc5, 0x89, 0xfa, 0x40, - 0xbc, 0x65, 0xe7, 0x64, 0x1e, 0x1a, 0x0e, 0xe1, - 0xa0, 0x8e, 0xe0, 0x4a, 0x69, 0xeb, 0x65, 0x23, - 0xb1, 0x58, 0x6e, 0x93, 0x42, 0x67, 0x51, 0xfb, - 0x1b, 0x42, 0x4f, 0x0b, 0xe5, 0x11, 0x44, 0x6b, - 0xdd, 0x8b, 0xe8, 0xe9, 0x44, 0x09, 0x70, 0x6a, - 0xab, 0xaf, 0x54, 0xd8, 0x4a, 0xd3, 0x3d, 0x7c -//}; -//unsigned int mprivatekey000_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey001.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey001.inc deleted file mode 100644 index e9d5161359..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey001.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : privrevokedmember001 (revoked in grpX privrl) - */ - -//unsigned char mprivatekey001_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xae, 0x8f, 0x73, 0x56, 0xd4, 0xd4, 0x95, 0x28, - 0x0a, 0x9b, 0xb4, 0x57, 0x65, 0x8b, 0x68, 0x82, - 0x58, 0x42, 0x3f, 0x75, 0x0f, 0x60, 0x15, 0xc2, - 0x83, 0x26, 0x3b, 0xa6, 0x74, 0xab, 0x5f, 0x7a, - 0xc7, 0x99, 0x84, 0x0d, 0xe4, 0xed, 0xa7, 0x11, - 0xd9, 0x8a, 0xd0, 0x08, 0xb0, 0x1c, 0x29, 0x75, - 0x71, 0x99, 0xf5, 0x11, 0x7d, 0xf3, 0xa5, 0x55, - 0xae, 0xaf, 0x71, 0x1b, 0x25, 0x93, 0xbd, 0x30, - 0x50, 0x08, 0x2f, 0xb9, 0x46, 0x89, 0xbf, 0x9d, - 0xf5, 0xae, 0x5f, 0x4d, 0x28, 0x5c, 0x5c, 0x19, - 0x58, 0xfb, 0xec, 0xac, 0xac, 0xe1, 0x16, 0x27, - 0xd3, 0x19, 0x07, 0x76, 0x2c, 0x20, 0x29, 0xec, - 0xfb, 0x9c, 0x7f, 0x54, 0x34, 0xba, 0xc2, 0xdb, - 0x2b, 0xec, 0xca, 0x08, 0xf8, 0x19, 0x3f, 0x79, - 0xee, 0x02, 0x01, 0x1f, 0x7c, 0x6a, 0x3a, 0xdb, - 0x6b, 0x42, 0x31, 0xc7, 0x09, 0x4e, 0xb0, 0x1b -//}; -//unsigned int mprivatekey001_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey002.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey002.inc deleted file mode 100644 index 8e9af9d1ef..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/mprivatekey002.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : privrevokedmember002 (revoked in grpX privrl) - */ - -//unsigned char mprivatekey002_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xbb, 0x31, 0x32, 0x47, 0xde, 0xe1, 0xd5, 0x97, - 0xe9, 0xdf, 0x2a, 0xa1, 0x3b, 0xb4, 0x0d, 0x84, - 0xf0, 0x01, 0x61, 0x74, 0x9e, 0xde, 0x47, 0x9c, - 0xfa, 0xcc, 0x73, 0x63, 0x6e, 0x63, 0x8d, 0x5c, - 0xf8, 0x1c, 0xe8, 0x32, 0x5f, 0x1c, 0xed, 0xde, - 0x82, 0xc4, 0x29, 0x28, 0x8d, 0xf2, 0x5e, 0x4f, - 0xd6, 0x16, 0x9e, 0x87, 0xa2, 0x65, 0x61, 0x31, - 0x25, 0x8a, 0x81, 0xb5, 0x60, 0xf2, 0x08, 0xc9, - 0x83, 0x8d, 0xbe, 0x69, 0xb1, 0x8d, 0x0f, 0x4a, - 0x55, 0x1d, 0xdb, 0x72, 0x84, 0x33, 0x45, 0x02, - 0x34, 0xcd, 0x76, 0x94, 0x2b, 0xd6, 0x89, 0xab, - 0xa6, 0x9a, 0x87, 0x60, 0x54, 0x37, 0x5f, 0x04, - 0x8d, 0xa3, 0xbf, 0xfa, 0xd1, 0x1d, 0x03, 0x29, - 0x17, 0xca, 0xcd, 0x01, 0xda, 0x76, 0x49, 0x3b, - 0x97, 0xc9, 0xd3, 0xf5, 0x13, 0x75, 0xbe, 0x70, - 0xc4, 0x24, 0x43, 0xff, 0xaa, 0x44, 0x67, 0xba -//}; -//unsigned int mprivatekey002_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey000.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey000.inc deleted file mode 100644 index 90166b7f3d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey000.inc +++ /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 Test data for revoked privrl. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : privrevoked\member000 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2C, 0xBB, 0xFE, 0x06, 0x26, - 0x5F, 0x20, 0xBD, 0x9E, 0x49, 0x11, 0x31, 0xE0, - 0x7C, 0x99, 0x5E, 0xA0, 0x58, 0x4F, 0x1B, 0x3F, - 0xB4, 0x6E, 0xCD, 0x17, 0x61, 0x79, 0xA0, 0xFD, - 0x64, 0x60, 0xA4, 0xF8, 0x17, 0x81, 0xC3, 0x0A, - 0x4B, 0x6A, 0x72, 0x86, 0x96, 0xE3, 0xFA, 0x95, - 0x47, 0x45, 0xFB, 0x57, 0xEF, 0xCA, 0x82, 0x99, - 0x72, 0xDC, 0xE6, 0x78, 0xE3, 0x70, 0xA8, 0x28, - 0x38, 0xF7, 0x31, 0x44, 0xE9, 0xD3, 0xC8, 0xA8, - 0xF9, 0x72, 0x0D, 0x4F, 0xB5, 0x5E, 0x64, 0xD0, - 0x36, 0x0C, 0xEE, 0x7D, 0x67, 0x92, 0xD8, 0xF7, - 0xCB, 0x3C, 0xA3, 0x86, 0x06, 0x14, 0x6F, 0x79, - 0xAB, 0xB6, 0x8E, 0x27, 0x72, 0xBF, 0x87, 0x3D, - 0x3C, 0x28, 0xB6, 0xC4, 0x2D, 0x21, 0x2E, 0xBA, - 0x4E, 0x15, 0xA7, 0xFE, 0xD3, 0xF9, 0x5D, 0x8B, - 0x86, 0xD9, 0x1D, 0x6E, 0xD3, 0xAA, 0x3C, 0x8D, - 0xF4, 0xE8, 0x5D, 0x34, 0xEB, 0xB1, 0x28, 0x15, - 0x86, 0x0C, 0x17, 0x5E, 0x9F, 0x37, 0x02, 0x3C, - 0xDA, 0xF2, 0xAD, 0x95, 0xF8, 0x55, 0xB2, 0xCD, - 0x19, 0x12, 0x8F, 0xD8, 0xAB, 0x23, 0xC2, 0x51, - 0x22, 0x58, 0x2F, 0x9A, 0x86, 0x6D, 0x89, 0x44, - 0x78, 0x78, 0xEB, 0x4F, 0xA2, 0xD7, 0x06, 0x3A, - 0xBE, 0xCC, 0x27, 0x8E, 0x24, 0x07, 0x84, 0x10, - 0x9B, 0xBB, 0x1E, 0xC3, 0x1F, 0x96, 0xE8, 0x5F, - 0xDF, 0xC9, 0xFA, 0x8A, 0xDF, 0xB7, 0x1E, 0x4A, - 0x0E, 0x65, 0xE0, 0x1A, 0x1C, 0x74, 0xA0, 0xFE, - 0x4C, 0xD0, 0xDC, 0xB4, 0xEB, 0xA8, 0x03, 0xE0, - 0x89, 0xBC, 0x85, 0x5E, 0x82, 0xC8, 0xC5, 0x3D, - 0x0F, 0x29, 0xB9, 0x90, 0xA0, 0xBC, 0xB3, 0x73, - 0xAF, 0xF5, 0xEF, 0xA6, 0x55, 0x66, 0x23, 0x80, - 0x82, 0x6D, 0x53, 0xAB, 0x75, 0xAA, 0x9B, 0x08, - 0xDB, 0x2A, 0x72, 0x73, 0x88, 0x25, 0x91, 0x52, - 0xC3, 0x89, 0x4C, 0xD6, 0x24, 0x65, 0xB0, 0x30, - 0x09, 0x03, 0xAE, 0x24, 0x4D, 0x4B, 0x65, 0x66, - 0x7B, 0xA1, 0x2B, 0x36, 0xE6, 0xD8, 0x5C, 0x71, - 0xE6, 0xE0, 0xBB, 0x9F, 0x82, 0x0C, 0x53, 0x61, - 0xF8, 0xAB, 0x62, 0x48, 0x96, 0x4F, 0x04, 0xB9, - 0x31, 0x0C, 0x76, 0x62, 0x8A, 0xFB, 0x58, 0x56, - 0xA5, 0x3B, 0xF0, 0xB8, 0xE9, 0x8F, 0xE1, 0x47, - 0x12, 0x75, 0x2A, 0x30, 0x28, 0x93, 0xA9, 0xF0, - 0xEE, 0x22, 0xB0, 0x66, 0xFB, 0x0C, 0x2B, 0x09, - 0xAD, 0x07, 0x3C, 0x51, 0xFE, 0xD6, 0x8E, 0xED, - 0xC3, 0xFC, 0x68, 0x29, 0x0A, 0x1A, 0xB9, 0xD1, - 0x27, 0xAC, 0x52, 0xA0, 0x79, 0x5D, 0x44, 0x08, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xBC, 0xB0, 0x1D, 0x71, 0x43, 0xB1, 0x9C, 0x54, - 0x8E, 0x87, 0xE6, 0x61, 0x77, 0x78, 0xF6, 0x37, - 0x82, 0x49, 0xFB, 0xDA, 0x62, 0x38, 0x49, 0xE1, - 0xBA, 0x59, 0x89, 0x47, 0x40, 0xF1, 0xAE, 0x8D, - 0x80, 0x7B, 0xAC, 0xEF, 0x9E, 0x80, 0x43, 0xF4, - 0xF0, 0xDE, 0x7E, 0x77, 0x2A, 0x2B, 0x20, 0xAD, - 0x2C, 0x74, 0x19, 0xD8, 0x73, 0x64, 0xE9, 0xC1, - 0x00, 0x35, 0x77, 0xE2, 0x16, 0x02, 0x81, 0xE1, - 0x3D, 0x97, 0x90, 0x2F, 0x50, 0x46, 0xB4, 0x55, - 0x0F, 0x64, 0x1B, 0xEF, 0xA5, 0xA4, 0x80, 0x59, - 0x5D, 0xF2, 0xD5, 0x4D, 0x0C, 0x46, 0xBD, 0x28, - 0xCC, 0x98, 0xE8, 0x04, 0xB8, 0x07, 0x2A, 0x57, - 0xBD, 0xCE, 0x84, 0x1B, 0x8F, 0x85, 0x62, 0x5F, - 0x73, 0xBF, 0x71, 0x8C, 0xB5, 0xD5, 0x78, 0x45, - 0xB9, 0x7F, 0x93, 0xC3, 0x92, 0xCF, 0x06, 0xE9, - 0xD9, 0x25, 0x8E, 0x28, 0x51, 0x88, 0x26, 0x1D, - 0xE0, 0xAE, 0x4F, 0x9C, 0xED, 0xD2, 0x93, 0xA2, - 0xC8, 0x80, 0x32, 0x02, 0x67, 0xBB, 0x27, 0xDC, - 0x19, 0xF7, 0xB7, 0x67, 0xD1, 0xE3, 0x7E, 0xF1, - 0xB6, 0x16, 0x5A, 0xFE, 0xB6, 0x1C, 0x55, 0x5D, - 0x02, 0x86, 0x4F, 0xAB, 0x1E, 0xB2, 0x2A, 0xFD, - 0x91, 0xB6, 0x2B, 0x1A, 0x86, 0xFC, 0x14, 0x77, - 0xCB, 0xAD, 0x50, 0xC5, 0x9F, 0x7F, 0x9B, 0x86, - 0x0C, 0xD8, 0xAD, 0x3B, 0x17, 0xE6, 0x86, 0x6E, - 0x5B, 0x3B, 0xEE, 0x28, 0x9E, 0x79, 0xC5, 0x19, - 0x88, 0x5E, 0x9C, 0x5D, 0xD8, 0x44, 0x9C, 0x37, - 0xAD, 0x0E, 0x0E, 0x54, 0x8D, 0xB5, 0x42, 0x4C, - 0x52, 0xFB, 0xE4, 0x61, 0x2D, 0x32, 0x94, 0x77, - 0xF8, 0x19, 0x31, 0x92, 0x1A, 0x4B, 0x73, 0xB3, - 0xDE, 0x0E, 0x84, 0xD0, 0xBD, 0x55, 0xC4, 0xA6, - 0x5A, 0xDA, 0xD4, 0x3F, 0x86, 0xF5, 0xEB, 0x48, - 0x6B, 0xDA, 0xF5, 0xE9, 0x0A, 0x57, 0x4C, 0x87, - 0x87, 0x5C, 0x15, 0xFD, 0x48, 0x4E, 0xE3, 0xA0, - 0xC2, 0x7F, 0xE7, 0x3F, 0x25, 0x3D, 0x82, 0x1F, - 0xC8, 0xB0, 0x75, 0x59, 0x55, 0x9F, 0x5B, 0x51, - 0x97, 0xF0, 0xF5, 0xBC, 0xE1, 0xB0, 0xC1, 0x7D, - 0xD7, 0x32, 0xFB, 0xAE, 0x76, 0x96, 0xCE, 0x08, - 0xC0, 0xBA, 0x59, 0x4D, 0xE5, 0xDA, 0xFE, 0x4E, - 0xDD, 0x6D, 0xA8, 0x44, 0xC1, 0x0D, 0xEC, 0x1D, - 0xE0, 0xC1, 0xDF, 0x0B, 0xB8, 0x72, 0x5B, 0x2B, - 0x33, 0xBC, 0x50, 0xB4, 0x0C, 0x60, 0x14, 0x6A, - 0x3B, 0x47, 0xBC, 0x24, 0x68, 0x84, 0xEE, 0xD2, - 0x5F, 0xA5, 0xAC, 0x72, 0x87, 0xE4, 0x85, 0x23, - 0x36, 0x2B, 0x59, 0x51, 0x56, 0x71, 0x38, 0xB6, - 0x0D, 0x29, 0xC1, 0xFD, 0x07, 0xB0, 0x96, 0x7C, - 0xC2, 0x3F, 0x91, 0x17, 0x19, 0xC3, 0x1D, 0x4B, - 0xFE, 0x2A, 0xE8, 0x26, 0xB4, 0x11, 0x70, 0x54, - 0xB4, 0x44, 0x59, 0xCB, 0xB3, 0x16, 0xD4, 0x78, - 0x0E, 0xB6, 0x52, 0x47, 0x5F, 0xF5, 0x04, 0x61, - 0x71, 0xEA, 0x76, 0x53, 0x33, 0x6E, 0xEE, 0x84, - 0xF3, 0x8C, 0xCC, 0xC9, 0x67, 0xB7, 0xDE, 0xDF, - 0x2C, 0x49, 0x43, 0xD6, 0x7A, 0x8A, 0xB8, 0xFB, - 0x14, 0x9F, 0xD9, 0xC6, 0x00, 0x4D, 0xA3, 0x73, - 0x92, 0x50, 0x85, 0x9D, 0x92, 0x5A, 0x77, 0xC5, - 0x5A, 0xB2, 0x29, 0xB9, 0x97, 0x64, 0xE6, 0xF6, - 0x84, 0xE8, 0x9C, 0x68, 0x0D, 0xD7, 0x0E, 0xC2, - 0x63, 0x88, 0x9D, 0x83, 0x91, 0x14, 0x64, 0x99, - 0xAD, 0xBE, 0xBC, 0x35, 0x99, 0x76, 0x71, 0x4E, - 0x65, 0x79, 0x5E, 0xF5, 0x37, 0x09, 0x71, 0xF8, - 0x21, 0x00, 0xCA, 0x1B, 0x3F, 0xEF, 0x51, 0x1D -//}; -//unsigned int sig_grpx_member0_sha256_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey001.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey001.inc deleted file mode 100644 index c65af4795a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey001.inc +++ /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 Test data for revoked privrl. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : privrevoked\member001 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2C, 0xBB, 0xFE, 0x06, 0x26, - 0x5F, 0x20, 0xBD, 0x9E, 0x49, 0x11, 0x31, 0xE0, - 0x7C, 0x99, 0x5E, 0xA0, 0x58, 0x4F, 0x1B, 0x3F, - 0xB4, 0x6E, 0xCD, 0x17, 0x61, 0x79, 0xA0, 0xFD, - 0x64, 0x60, 0xA4, 0xF8, 0x17, 0x81, 0xC3, 0x0A, - 0x4B, 0x6A, 0x72, 0x86, 0x96, 0xE3, 0xFA, 0x95, - 0x47, 0x45, 0xFB, 0x57, 0xEF, 0xCA, 0x82, 0x99, - 0x72, 0xDC, 0xE6, 0x78, 0xE3, 0x70, 0xA8, 0x28, - 0x97, 0xD9, 0xAF, 0x30, 0xFA, 0x73, 0xBC, 0x33, - 0xA8, 0x5F, 0x52, 0x1A, 0x72, 0x93, 0xCF, 0xC3, - 0xA0, 0xE2, 0x73, 0x3C, 0xAA, 0x2A, 0x27, 0x52, - 0x21, 0x78, 0xD0, 0x7C, 0x74, 0x2E, 0xCB, 0xD5, - 0x80, 0x52, 0xCC, 0xDF, 0x55, 0x2A, 0xB9, 0x71, - 0x77, 0xE3, 0xCB, 0xAE, 0xC7, 0x55, 0x8A, 0xBF, - 0xDC, 0x55, 0x57, 0xD2, 0xFC, 0xE7, 0x33, 0xE9, - 0x58, 0x38, 0x0F, 0x36, 0x98, 0xD1, 0x50, 0xEE, - 0xB2, 0xCA, 0x4E, 0x22, 0x4B, 0xEB, 0xB8, 0x03, - 0x4A, 0x4F, 0x4D, 0xF6, 0x1A, 0x3D, 0xDD, 0x77, - 0x85, 0x4B, 0xC3, 0x8E, 0x3A, 0x26, 0x05, 0x7D, - 0x9B, 0xAF, 0x72, 0xC9, 0x04, 0x2C, 0x53, 0x4D, - 0x6B, 0x35, 0x26, 0x03, 0x2D, 0xA6, 0xB9, 0xFA, - 0x3D, 0x60, 0xCD, 0x95, 0x15, 0x81, 0x89, 0x72, - 0x88, 0x1E, 0x53, 0x20, 0x63, 0xC2, 0x1B, 0x5A, - 0x59, 0x48, 0xE5, 0x0F, 0xD6, 0xF5, 0x63, 0x3E, - 0x0C, 0x94, 0x8C, 0x3C, 0x18, 0x4C, 0x6A, 0x7C, - 0x6E, 0x51, 0xB2, 0x31, 0xFC, 0x35, 0xB4, 0x35, - 0xF3, 0x63, 0x69, 0x75, 0x31, 0x95, 0x2B, 0x1D, - 0x53, 0x2F, 0xC8, 0x59, 0x8F, 0xFD, 0xBA, 0x81, - 0xAE, 0xF8, 0x0A, 0x1B, 0xFE, 0xD1, 0xF0, 0x60, - 0xA8, 0x9C, 0xC6, 0x4E, 0x39, 0x7C, 0xC4, 0xFF, - 0xBB, 0xED, 0x4B, 0xC4, 0x66, 0xF2, 0xBE, 0xEA, - 0x83, 0x15, 0x7F, 0x62, 0xA7, 0xA0, 0x0E, 0x6A, - 0x68, 0xBF, 0xD6, 0xA5, 0xCE, 0xF4, 0x64, 0x85, - 0x9B, 0xAC, 0x97, 0xE8, 0x19, 0xDA, 0xCF, 0xCC, - 0xDF, 0xB5, 0x3E, 0xA5, 0xFC, 0xFD, 0x9C, 0x88, - 0x41, 0x54, 0x43, 0xA8, 0xF7, 0x86, 0xD3, 0x2E, - 0xC3, 0x27, 0x26, 0x23, 0x1C, 0x5C, 0xF8, 0xA8, - 0x4A, 0x9F, 0x52, 0x89, 0xEC, 0x71, 0x4D, 0x14, - 0xE1, 0x0E, 0x1A, 0x9C, 0x49, 0x2B, 0x39, 0xFD, - 0x8E, 0x87, 0x0A, 0x74, 0x2E, 0xAA, 0x91, 0xE8, - 0x7F, 0x06, 0xAD, 0x11, 0x9A, 0xA9, 0x33, 0x36, - 0x26, 0xA3, 0x21, 0xE8, 0xEF, 0x06, 0x7F, 0x36, - 0x2D, 0xEF, 0xAE, 0x63, 0x8A, 0x1A, 0xFC, 0xAD, - 0x72, 0xFF, 0xCA, 0x7B, 0xFF, 0xED, 0xD2, 0xCB, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x11, 0xBC, 0x6D, 0x79, 0x07, 0x9D, 0x50, 0x47, - 0xA4, 0x1D, 0x04, 0xBB, 0xEC, 0xBE, 0xEB, 0x07, - 0xCF, 0xB3, 0x5A, 0xC8, 0xBA, 0xB7, 0xCE, 0x92, - 0x72, 0x5F, 0xA5, 0xDA, 0x89, 0xDF, 0xC6, 0xEB, - 0x35, 0xDC, 0x53, 0x3C, 0xD8, 0x32, 0x7B, 0xD3, - 0xE7, 0xBD, 0x76, 0x28, 0xFA, 0x71, 0x3A, 0xD5, - 0x64, 0xD3, 0xC9, 0x39, 0x12, 0xA0, 0x86, 0x60, - 0xBB, 0x7B, 0xBA, 0xD3, 0xAF, 0xAC, 0x06, 0x07, - 0x0E, 0x15, 0xAA, 0xD7, 0x86, 0xD3, 0x2F, 0x56, - 0x9D, 0xE0, 0xE3, 0xAE, 0xBF, 0xE3, 0x53, 0x64, - 0x57, 0x98, 0xF3, 0x90, 0x12, 0xC9, 0xDD, 0x54, - 0xE3, 0x31, 0xAE, 0xB9, 0xF4, 0x3F, 0x3A, 0x0F, - 0xB5, 0xC0, 0x08, 0x30, 0x41, 0xE1, 0x9B, 0x3C, - 0xFD, 0x55, 0xDA, 0xD7, 0x7D, 0xB5, 0x6A, 0xB6, - 0x21, 0x4A, 0xAC, 0x4B, 0x7C, 0x41, 0x4E, 0x46, - 0xC6, 0x42, 0x87, 0x3B, 0xE1, 0x2D, 0xCB, 0xFE, - 0x66, 0xA7, 0x1E, 0xC1, 0xFD, 0xAC, 0xA3, 0xE5, - 0x8C, 0x8A, 0xB1, 0x6E, 0x90, 0xBA, 0x45, 0x8C, - 0x5C, 0xA5, 0x57, 0xB9, 0x0B, 0x58, 0x6B, 0x59, - 0x29, 0x5D, 0x98, 0x32, 0x85, 0xA7, 0x5A, 0x2F, - 0x95, 0x2D, 0x83, 0x16, 0x43, 0x04, 0x16, 0xB0, - 0x80, 0x32, 0xD0, 0x22, 0x8D, 0xFF, 0x21, 0xA4, - 0x04, 0x6A, 0x54, 0xE0, 0x0D, 0x4D, 0xBF, 0xA7, - 0x48, 0x1A, 0xDB, 0xD2, 0xDB, 0x84, 0xDE, 0x77, - 0x1A, 0x43, 0x36, 0x61, 0xF0, 0x7F, 0xB4, 0x99, - 0x75, 0xE5, 0x5D, 0xD6, 0xE2, 0x56, 0xC7, 0x17, - 0x9B, 0x38, 0x3E, 0x53, 0xF4, 0x4F, 0xBE, 0x82, - 0x3C, 0xEE, 0x89, 0x8A, 0x81, 0xD4, 0x9B, 0x72, - 0xD4, 0x55, 0xD1, 0x90, 0x34, 0x12, 0xA6, 0xED, - 0xA2, 0x6E, 0x7C, 0x50, 0xDB, 0x2C, 0x7C, 0xF9, - 0x34, 0xE7, 0xB8, 0xE1, 0xD2, 0xC8, 0x9E, 0x17, - 0x15, 0xA3, 0x22, 0xEC, 0x5A, 0xC4, 0x91, 0x2A, - 0x96, 0x19, 0x88, 0xBA, 0x73, 0xBE, 0x83, 0xA1, - 0x9F, 0x95, 0x17, 0x6F, 0x6A, 0xCE, 0x14, 0xF7, - 0x95, 0x60, 0xE8, 0xA9, 0xDF, 0x0B, 0xD9, 0xD7, - 0xE2, 0x98, 0xC0, 0x5C, 0x86, 0x83, 0x43, 0xE7, - 0xE1, 0x4F, 0xDA, 0x57, 0x27, 0xC7, 0x52, 0xE6, - 0x77, 0x05, 0x0B, 0x84, 0x46, 0x4B, 0xCB, 0x4D, - 0x2A, 0x4F, 0x39, 0xCC, 0xA3, 0x93, 0x42, 0xE0, - 0x9E, 0xA2, 0x4D, 0xAC, 0xC8, 0x9D, 0x1A, 0xAD, - 0x37, 0x01, 0xA4, 0x33, 0x58, 0xB7, 0x46, 0x60, - 0x82, 0xF9, 0xCB, 0xA6, 0x4D, 0x6B, 0xB5, 0x54, - 0x9E, 0xD8, 0xBA, 0x32, 0x96, 0xD8, 0xE0, 0x14, - 0x5E, 0xF8, 0x79, 0x53, 0x5B, 0xED, 0xC6, 0x93, - 0x3F, 0xEA, 0x3C, 0xD2, 0x34, 0xA2, 0xB8, 0x68, - 0x56, 0xC7, 0x2D, 0xA5, 0x0C, 0xB3, 0x5A, 0xFD, - 0x34, 0x93, 0x5B, 0x59, 0x08, 0x4E, 0x77, 0x7C, - 0x78, 0x81, 0x89, 0x10, 0xB4, 0x8A, 0x95, 0x8E, - 0x5A, 0xB7, 0x66, 0xF1, 0x26, 0xC1, 0x71, 0xA8, - 0x09, 0x0E, 0x5D, 0x60, 0x57, 0xC2, 0x79, 0xFD, - 0xE9, 0x59, 0xFC, 0x5A, 0xD2, 0x46, 0x0B, 0x3D, - 0x76, 0xC3, 0x65, 0xF0, 0x26, 0xAF, 0x8E, 0xF9, - 0x16, 0xFC, 0x6B, 0xC7, 0x4F, 0x8F, 0x36, 0x2A, - 0x7F, 0x20, 0x24, 0x70, 0x10, 0xF8, 0x32, 0x7D, - 0xF6, 0x64, 0xE3, 0x18, 0x37, 0x14, 0x0C, 0xD3, - 0xBC, 0x2C, 0x1F, 0x88, 0x39, 0xD0, 0xF7, 0x97, - 0xAC, 0x15, 0xFA, 0xED, 0x33, 0xEE, 0x10, 0x1A, - 0xB0, 0xEB, 0x98, 0x36, 0xB2, 0x5C, 0x82, 0x20, - 0xA2, 0x75, 0xF9, 0xE4, 0x72, 0xA9, 0xB2, 0x0C, - 0x6C, 0x12, 0xC1, 0x4D, 0x86, 0x3A, 0x42, 0x7F -//}; -//unsigned int sig_grpx_member0_sha256_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey002.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey002.inc deleted file mode 100644 index 704c6f900f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey002.inc +++ /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 Test data for revoked privrl. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : privrevoked\member002 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_grpx_member0_sha256_bsn0_msg0_dat[] = { - 0x70, 0x91, 0x63, 0x2C, 0xBB, 0xFE, 0x06, 0x26, - 0x5F, 0x20, 0xBD, 0x9E, 0x49, 0x11, 0x31, 0xE0, - 0x7C, 0x99, 0x5E, 0xA0, 0x58, 0x4F, 0x1B, 0x3F, - 0xB4, 0x6E, 0xCD, 0x17, 0x61, 0x79, 0xA0, 0xFD, - 0x64, 0x60, 0xA4, 0xF8, 0x17, 0x81, 0xC3, 0x0A, - 0x4B, 0x6A, 0x72, 0x86, 0x96, 0xE3, 0xFA, 0x95, - 0x47, 0x45, 0xFB, 0x57, 0xEF, 0xCA, 0x82, 0x99, - 0x72, 0xDC, 0xE6, 0x78, 0xE3, 0x70, 0xA8, 0x28, - 0x1D, 0xFB, 0xB5, 0x81, 0x0D, 0xDB, 0x30, 0x3B, - 0xD9, 0x3A, 0xFE, 0x9D, 0x94, 0xCD, 0x7D, 0x9F, - 0x7D, 0x68, 0xB6, 0x57, 0xE8, 0x26, 0x78, 0x2B, - 0x32, 0xC3, 0x14, 0xC7, 0xE4, 0xDE, 0x04, 0x7B, - 0x27, 0xBE, 0x27, 0xDA, 0x79, 0x25, 0x4E, 0x36, - 0x75, 0x0E, 0x6E, 0xD0, 0x78, 0x36, 0xA6, 0x23, - 0x57, 0x63, 0x71, 0xCC, 0x07, 0xFA, 0x57, 0xB6, - 0xF6, 0x9D, 0xA6, 0x00, 0x36, 0xA2, 0xAB, 0xBB, - 0x81, 0xC9, 0xAE, 0xA8, 0x3B, 0xA0, 0xA7, 0xCE, - 0x0B, 0xC6, 0xE3, 0x40, 0x32, 0xE5, 0x29, 0x8F, - 0x4E, 0x5E, 0xFD, 0x1B, 0x7A, 0x7E, 0x83, 0x8B, - 0x26, 0xC1, 0x7B, 0xEC, 0x62, 0x30, 0x1E, 0x6F, - 0xDD, 0x18, 0xD0, 0x89, 0x5B, 0xD9, 0xC5, 0xD7, - 0x1B, 0x94, 0x29, 0x81, 0xBC, 0xD8, 0x2D, 0xF3, - 0xE2, 0xD5, 0x2E, 0x7E, 0x4A, 0xA0, 0x87, 0xA9, - 0xAB, 0x73, 0xB1, 0x8C, 0x7B, 0x18, 0x1E, 0xDA, - 0x4E, 0x5D, 0x7B, 0x49, 0xA7, 0x0E, 0xD9, 0xD7, - 0x1A, 0x6C, 0xC6, 0x18, 0x25, 0x1F, 0x36, 0x49, - 0xFA, 0xB6, 0x54, 0xCE, 0x2D, 0x73, 0x70, 0x52, - 0xC8, 0xC3, 0xFE, 0x22, 0x5C, 0x58, 0x6A, 0x6E, - 0x60, 0xE1, 0x86, 0xA0, 0x7F, 0x38, 0x48, 0xEE, - 0xDC, 0x4B, 0xBC, 0xD1, 0xF4, 0x3D, 0x1A, 0x2B, - 0x6E, 0x95, 0x61, 0x41, 0x17, 0x66, 0xC3, 0xAE, - 0x05, 0xD4, 0x67, 0x6D, 0x29, 0x79, 0xB9, 0x3A, - 0x81, 0x28, 0xA9, 0x0C, 0xFA, 0xE3, 0xBD, 0x60, - 0x16, 0x53, 0xFF, 0x5C, 0x2B, 0x25, 0x29, 0x66, - 0x2D, 0x91, 0x5E, 0x97, 0xF2, 0x8C, 0x42, 0xE7, - 0xAE, 0x50, 0x08, 0x7E, 0xEF, 0x1B, 0xB0, 0xB2, - 0xA0, 0x5E, 0xDF, 0xB0, 0x49, 0x2A, 0xA8, 0x3D, - 0xA0, 0x95, 0x1A, 0xF6, 0x0B, 0xB1, 0x0D, 0x70, - 0x3E, 0x6B, 0xFC, 0x1B, 0x57, 0x4F, 0x01, 0xF8, - 0x1F, 0xF0, 0xDC, 0x7F, 0x7E, 0xF9, 0xF6, 0xA4, - 0xD3, 0x1B, 0x4C, 0x72, 0x9C, 0xB5, 0xAF, 0x9E, - 0xEF, 0x0B, 0x24, 0x39, 0xC0, 0x89, 0x6B, 0xE6, - 0x16, 0x4D, 0xFA, 0x2B, 0x71, 0xF1, 0x58, 0xC7, - 0x3E, 0xF1, 0xB3, 0x47, 0x48, 0xD9, 0xD5, 0x03, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x05, 0xED, 0x13, 0xC4, 0xB7, 0x70, 0x01, 0xA9, - 0x1F, 0x36, 0x29, 0x8E, 0x1F, 0x0B, 0x43, 0x0E, - 0xD9, 0x23, 0x1A, 0x80, 0xCD, 0x75, 0x2F, 0x84, - 0x44, 0x2D, 0x2B, 0xF2, 0xFD, 0x78, 0x9F, 0xF0, - 0xA8, 0xEC, 0xDC, 0x53, 0x38, 0x6B, 0x11, 0x9B, - 0x42, 0x7E, 0x3B, 0x8A, 0xBB, 0x48, 0x8A, 0x79, - 0x58, 0x99, 0xFD, 0xE2, 0x35, 0x63, 0x2F, 0xA1, - 0xDF, 0x1C, 0x3B, 0x2C, 0x93, 0xFA, 0xD4, 0x71, - 0x7A, 0xDC, 0x01, 0xFF, 0x9C, 0x5A, 0x3B, 0xD8, - 0xA4, 0x86, 0xBD, 0x51, 0x99, 0x13, 0x31, 0xDE, - 0x84, 0x8B, 0x44, 0x9F, 0x7C, 0x29, 0xED, 0x3E, - 0xB7, 0xE9, 0x81, 0x82, 0x87, 0xB1, 0x05, 0xD0, - 0x4B, 0xC5, 0x9B, 0x7D, 0x91, 0x67, 0xE9, 0x11, - 0x56, 0x79, 0x84, 0xEF, 0x59, 0x95, 0x6C, 0xF8, - 0xA7, 0xB7, 0x0B, 0x61, 0x4A, 0xF5, 0x73, 0x41, - 0xFD, 0x39, 0x82, 0xEC, 0xEB, 0x22, 0xA0, 0x22, - 0xF0, 0xAB, 0xDD, 0x15, 0x9D, 0x93, 0x73, 0xF1, - 0x31, 0xF2, 0xE7, 0x5E, 0xA1, 0x04, 0x95, 0x1D, - 0x88, 0xA5, 0x80, 0x05, 0x87, 0xF2, 0xBC, 0xAB, - 0xFE, 0x0A, 0x7B, 0x3F, 0xF3, 0x2E, 0xA9, 0x8A, - 0x98, 0x6D, 0xCB, 0x0A, 0xFA, 0x7B, 0x43, 0x98, - 0xFC, 0x5A, 0xC7, 0x4F, 0x17, 0x15, 0x45, 0xFA, - 0xC4, 0x5B, 0x4B, 0x79, 0xDE, 0x21, 0x1F, 0x1D, - 0x0F, 0xFF, 0x1B, 0xFB, 0xCF, 0x87, 0x9D, 0x11, - 0x0D, 0x3A, 0x29, 0x17, 0xAF, 0xC6, 0xDA, 0x22, - 0x5B, 0x58, 0xC7, 0xF6, 0xFB, 0x4F, 0x46, 0x8A, - 0xCA, 0x9B, 0x5E, 0xAA, 0x5A, 0xF7, 0xAE, 0xB5, - 0xAC, 0x0B, 0x0E, 0xE1, 0x54, 0xD5, 0x6A, 0x20, - 0x20, 0xC1, 0x8A, 0x31, 0xCC, 0xE8, 0xCE, 0x92, - 0xFA, 0x7F, 0xF7, 0xD0, 0x73, 0x42, 0xDA, 0x47, - 0xFB, 0x08, 0x63, 0x38, 0xA0, 0x0D, 0xB6, 0x73, - 0x06, 0x48, 0xCA, 0x10, 0x8C, 0xE3, 0xA3, 0xE4, - 0xC3, 0x2A, 0x77, 0xDB, 0x1E, 0x47, 0x6A, 0x95, - 0xF4, 0x99, 0x0C, 0xA6, 0x29, 0x8C, 0x4E, 0x20, - 0x8D, 0xB6, 0x8D, 0x77, 0x8A, 0x3E, 0x35, 0xB7, - 0x8A, 0x0B, 0xCE, 0x71, 0x92, 0xD8, 0x32, 0xBA, - 0xB1, 0xA0, 0x40, 0x28, 0x7B, 0xA3, 0x19, 0x12, - 0x05, 0xA7, 0x13, 0xC1, 0xDB, 0xE3, 0x2A, 0x9A, - 0xDC, 0x41, 0x95, 0x69, 0x47, 0x81, 0xC1, 0x3B, - 0x88, 0x78, 0xBA, 0x08, 0xC0, 0xDC, 0xAF, 0x24, - 0x1C, 0x17, 0xEF, 0xD0, 0xB3, 0x3E, 0xFA, 0x0B, - 0x9A, 0x62, 0xF8, 0x6F, 0xEC, 0x84, 0xA0, 0xC1, - 0xB7, 0x9E, 0x24, 0x9B, 0x05, 0x77, 0x80, 0x7E, - 0x2D, 0x5A, 0xBF, 0xD9, 0x90, 0xBB, 0x99, 0xF0, - 0x2D, 0xF7, 0x66, 0xB6, 0x77, 0xF5, 0xF2, 0xD3, - 0xA7, 0x57, 0x85, 0xAF, 0x39, 0x9A, 0x3D, 0x05, - 0x1E, 0xD7, 0x87, 0x6C, 0xF4, 0xA6, 0xDD, 0x36, - 0x57, 0x10, 0xB9, 0x4C, 0x55, 0xC7, 0x83, 0xFA, - 0x29, 0xAF, 0x4D, 0x8C, 0xCC, 0x13, 0x4B, 0x2D, - 0x0E, 0x9D, 0x8B, 0xFF, 0xCE, 0x70, 0x3D, 0x27, - 0x52, 0x99, 0x32, 0x69, 0xC2, 0xDC, 0xA1, 0x27, - 0x61, 0x98, 0x11, 0x3C, 0xC8, 0x60, 0x6F, 0xF1, - 0x8C, 0x86, 0x27, 0xA5, 0x18, 0x2C, 0xEE, 0x7B, - 0xF8, 0xEE, 0x72, 0x8A, 0x12, 0x59, 0xDF, 0x90, - 0x0F, 0x34, 0x4D, 0x38, 0x19, 0x6E, 0xBD, 0xE3, - 0x08, 0x77, 0x60, 0x88, 0x2F, 0x69, 0x5B, 0xF7, - 0x3B, 0x7E, 0x81, 0xD0, 0x04, 0xE7, 0x8C, 0x17, - 0xD5, 0x60, 0xC6, 0xED, 0xF0, 0x65, 0xAD, 0x54, - 0x60, 0xE7, 0x76, 0x34, 0x4F, 0x8D, 0xB6, 0x44, - 0x57, 0xBD, 0x20, 0xEB, 0x15, 0x89, 0xE4, 0xB1 -//}; -//unsigned int sig_grpx_member0_sha256_bsn0_msg0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl.inc deleted file mode 100644 index a16a36ae2e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl.inc +++ /dev/null @@ -1,40 +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 Test data. - * - * Type : Intel(R) EPID 2.0 private-key based revocation list - * Group : grpX - */ -//unsigned char privrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xb1, 0x58, 0x6e, 0x93, 0x42, 0x67, 0x51, 0xfb, - 0x1b, 0x42, 0x4f, 0x0b, 0xe5, 0x11, 0x44, 0x6b, - 0xdd, 0x8b, 0xe8, 0xe9, 0x44, 0x09, 0x70, 0x6a, - 0xab, 0xaf, 0x54, 0xd8, 0x4a, 0xd3, 0x3d, 0x7c, - 0xfb, 0x9c, 0x7f, 0x54, 0x34, 0xba, 0xc2, 0xdb, - 0x2b, 0xec, 0xca, 0x08, 0xf8, 0x19, 0x3f, 0x79, - 0xee, 0x02, 0x01, 0x1f, 0x7c, 0x6a, 0x3a, 0xdb, - 0x6b, 0x42, 0x31, 0xc7, 0x09, 0x4e, 0xb0, 0x1b, - 0x8d, 0xa3, 0xbf, 0xfa, 0xd1, 0x1d, 0x03, 0x29, - 0x17, 0xca, 0xcd, 0x01, 0xda, 0x76, 0x49, 0x3b, - 0x97, 0xc9, 0xd3, 0xf5, 0x13, 0x75, 0xbe, 0x70, - 0xc4, 0x24, 0x43, 0xff, 0xaa, 0x44, 0x67, 0xba -//}; -//unsigned int privrl_dat_len = 120; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl_single_entry_revoked_key000.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl_single_entry_revoked_key000.inc deleted file mode 100644 index abd8fb5d35..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/privrl_single_entry_revoked_key000.inc +++ /dev/null @@ -1,33 +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 Test data. - * - * Type : Intel(R) EPID 2.0 private-key based revocation list - * single entry, privrevoked/member000 - * Group : grpX - */ -//unsigned char privrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0xb1, 0x58, 0x6e, 0x93, 0x42, 0x67, 0x51, 0xfb, - 0x1b, 0x42, 0x4f, 0x0b, 0xe5, 0x11, 0x44, 0x6b, - 0xdd, 0x8b, 0xe8, 0xe9, 0x44, 0x09, 0x70, 0x6a, - 0xab, 0xaf, 0x54, 0xd8, 0x4a, 0xd3, 0x3d, 0x7c -//}; -//unsigned int privrl_dat_len = 56; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/pubkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/pubkey.inc deleted file mode 100644 index a7d7484393..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/pubkey.inc +++ /dev/null @@ -1,59 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group public key - * Group : grpX - */ -//unsigned char pubkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x3d, 0x4b, 0x62, 0xf9, 0xf9, 0x1a, 0x0f, 0xb1, - 0x58, 0x7b, 0x0e, 0x42, 0x0c, 0xba, 0x94, 0x10, - 0xb4, 0x4e, 0x75, 0x33, 0x37, 0x24, 0xc0, 0xd0, - 0x9e, 0xf6, 0xb8, 0xe6, 0x8b, 0x69, 0xaa, 0xb1, - 0x29, 0x8f, 0x2a, 0xc3, 0xd9, 0x1d, 0x50, 0x4d, - 0xa3, 0x75, 0x20, 0x07, 0x1a, 0xa1, 0x7b, 0x2f, - 0xad, 0x72, 0x47, 0xff, 0x46, 0x8e, 0x69, 0xb2, - 0x05, 0x9e, 0xda, 0x68, 0xca, 0xc7, 0x81, 0x4c, - 0x48, 0x7a, 0x66, 0x7d, 0x9f, 0x52, 0xb3, 0x45, - 0x59, 0x5e, 0xde, 0x15, 0xdc, 0x29, 0xea, 0x7e, - 0x0e, 0xbf, 0x5e, 0xf3, 0xd0, 0x7b, 0xf1, 0x79, - 0x00, 0x1a, 0xcb, 0xd2, 0x56, 0xdc, 0x6f, 0xb1, - 0x50, 0xe8, 0xa8, 0x37, 0x22, 0x44, 0xa5, 0x6b, - 0x8f, 0x11, 0x92, 0xe5, 0x02, 0xd4, 0x9f, 0x89, - 0x4f, 0x97, 0x3a, 0x46, 0x5a, 0xe7, 0x00, 0xf3, - 0xbf, 0xf2, 0x47, 0x28, 0xa5, 0xf9, 0x07, 0xf5, - 0xb0, 0x63, 0x98, 0x76, 0x04, 0xcf, 0x85, 0xd9, - 0xad, 0xf2, 0x02, 0x0c, 0x13, 0x2c, 0x45, 0x10, - 0x5b, 0xcb, 0xa8, 0x76, 0xde, 0x1e, 0xe6, 0x92, - 0x06, 0x91, 0x49, 0xc2, 0x1a, 0xe8, 0x80, 0x90, - 0x46, 0x20, 0xd0, 0xd6, 0x73, 0xae, 0x29, 0x02, - 0xc2, 0x3f, 0x85, 0x13, 0x1a, 0x66, 0xae, 0xc1, - 0x61, 0x52, 0x62, 0xbf, 0x70, 0x1b, 0x1b, 0x52, - 0xde, 0x76, 0x8c, 0x9b, 0x35, 0x42, 0xa8, 0x19, - 0x32, 0x6c, 0xa2, 0x9b, 0x44, 0x24, 0x96, 0x1e, - 0x48, 0x68, 0xc8, 0x83, 0x16, 0xfb, 0xc3, 0xf6, - 0xed, 0x73, 0x94, 0xd9, 0xd4, 0x60, 0x63, 0xc0, - 0x2c, 0x44, 0x54, 0x36, 0x20, 0x38, 0x5b, 0x12, - 0x23, 0x32, 0x63, 0x6d, 0x79, 0x40, 0xf0, 0x3c, - 0x60, 0x35, 0xe9, 0xfe, 0xa3, 0xb3, 0xad, 0xe7, - 0xfa, 0x9c, 0xf1, 0xd7, 0x98, 0xfe, 0x28, 0x9e, - 0xc1, 0x81, 0xe7, 0x51, 0xce, 0x07, 0xbc, 0xc5 -//}; -//unsigned int pubkey_dat_len = 272; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey000.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey000.inc deleted file mode 100644 index d05d3b8230..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey000.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : sigrevokedmember000 (revoked in grpX sigrl) - */ - -//unsigned char mprivatekey000_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xa6, 0x7f, 0x17, 0xb8, 0xef, 0xe3, 0xab, 0x01, - 0x3f, 0x25, 0x02, 0x5e, 0x19, 0x93, 0xa5, 0x34, - 0x3a, 0x23, 0xec, 0xe5, 0x71, 0x87, 0x7d, 0x33, - 0x7c, 0x6b, 0xbf, 0x2e, 0x63, 0xb6, 0x85, 0xeb, - 0xe6, 0x1a, 0x60, 0xd9, 0x1c, 0xef, 0xd1, 0xae, - 0x85, 0x96, 0xd9, 0x8e, 0xf8, 0xf9, 0x8b, 0x68, - 0xfe, 0x7c, 0x3a, 0xde, 0x0b, 0xea, 0xa7, 0x7f, - 0x1c, 0x65, 0x81, 0xda, 0x3a, 0xc5, 0xea, 0xe0, - 0x67, 0x80, 0xf0, 0x53, 0x2c, 0xfa, 0xe3, 0xec, - 0xfd, 0x35, 0x7b, 0xd8, 0xa6, 0xf6, 0x54, 0x4b, - 0xc0, 0xb3, 0x38, 0x6b, 0x40, 0xae, 0xd9, 0x50, - 0x3f, 0x9f, 0x01, 0x87, 0x70, 0x0f, 0x9f, 0xcd, - 0x79, 0xa7, 0x3b, 0x7c, 0xb3, 0xd3, 0xd1, 0xc0, - 0x75, 0xf1, 0x50, 0xd6, 0x03, 0x40, 0xf8, 0xd6, - 0xc5, 0xf5, 0x7b, 0x1f, 0xfa, 0x61, 0xd9, 0x58, - 0xbc, 0x1b, 0xcd, 0x92, 0x35, 0x97, 0xa2, 0xb9 -//}; -//unsigned int mprivatekey000_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey001.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey001.inc deleted file mode 100644 index e9d28775ff..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey001.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : sigrevokedmember001 (revoked in grpX sigrl) - */ - -//unsigned char mprivatekey001_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xdb, 0x1b, 0x7b, 0xaa, 0x93, 0xed, 0x33, 0x68, - 0x8d, 0x20, 0x80, 0x66, 0x12, 0xaa, 0xfb, 0x6c, - 0x84, 0x02, 0xf0, 0xbd, 0x4b, 0xa4, 0xac, 0x12, - 0xcc, 0xbf, 0xfb, 0xd2, 0x19, 0x64, 0x14, 0xa2, - 0xdc, 0xf6, 0x85, 0xcc, 0xd1, 0xb7, 0x15, 0x65, - 0x76, 0xf2, 0xf5, 0xdd, 0x91, 0x98, 0xa1, 0x6e, - 0x21, 0x64, 0xcc, 0x74, 0xe1, 0x9b, 0x7c, 0x56, - 0xd4, 0x2f, 0xf5, 0x5f, 0xd4, 0xec, 0x03, 0x69, - 0x27, 0x49, 0xcd, 0xd3, 0x90, 0x18, 0xb2, 0x82, - 0x74, 0x46, 0x2b, 0x70, 0xc3, 0xe9, 0xcb, 0x30, - 0xde, 0x4e, 0x9c, 0x19, 0x97, 0x93, 0x24, 0x8b, - 0x10, 0xe9, 0x68, 0xca, 0x64, 0xbf, 0xcd, 0x81, - 0x02, 0x5c, 0x15, 0x7e, 0x0f, 0x00, 0x82, 0x32, - 0x45, 0xcf, 0x91, 0xd3, 0x64, 0x5f, 0xf6, 0x0a, - 0x83, 0x83, 0xc6, 0x3c, 0x0a, 0x68, 0x2c, 0x1e, - 0x96, 0x4b, 0xfa, 0xde, 0x06, 0xfe, 0x1a, 0x73 -//}; -//unsigned int mprivatekey001_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey002.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey002.inc deleted file mode 100644 index 9bb5536bc2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrevoked/mprivatekey002.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : sigrevokedmember002 (revoked in grpX sigrl) - */ - -//unsigned char mprivatekey002_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x77, 0xb7, 0x7d, 0xd1, 0x1c, 0xd3, 0xb5, 0x42, - 0x0b, 0x4c, 0xfb, 0x15, 0x97, 0x14, 0x5c, 0x44, - 0x24, 0xea, 0x32, 0xc4, 0x8f, 0x36, 0xfd, 0x20, - 0x19, 0x5f, 0x68, 0x61, 0x09, 0xf5, 0xd0, 0x78, - 0xa9, 0xc4, 0x07, 0x83, 0x02, 0x49, 0xf7, 0x8f, - 0x31, 0x3d, 0xb2, 0x0d, 0x91, 0x15, 0xfa, 0x38, - 0x76, 0x09, 0xce, 0x7e, 0xc0, 0x4e, 0x16, 0x08, - 0x79, 0x8f, 0x8b, 0xe4, 0xc9, 0x11, 0x40, 0x21, - 0x41, 0x34, 0x3d, 0x59, 0xc1, 0x65, 0x6d, 0x14, - 0x23, 0x82, 0x83, 0x66, 0xef, 0x04, 0x7b, 0xfb, - 0x7b, 0x43, 0x87, 0xfe, 0x46, 0xdb, 0x92, 0x97, - 0x5f, 0xe4, 0x2e, 0xe4, 0x76, 0x40, 0x50, 0x66, - 0xdf, 0x41, 0x0e, 0xe7, 0x5d, 0xa2, 0xd2, 0x17, - 0x72, 0xae, 0x43, 0x56, 0x05, 0xee, 0x7d, 0x43, - 0xbb, 0x84, 0xbc, 0x28, 0x55, 0x56, 0xaf, 0x0d, - 0x71, 0x41, 0x1a, 0x4a, 0x26, 0x63, 0x83, 0x87 -//}; -//unsigned int mprivatekey002_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl.inc deleted file mode 100644 index 6aba0eb710..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl.inc +++ /dev/null @@ -1,76 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - */ -//unsigned char sigrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xa6, 0xad, 0xdd, 0xbe, 0x45, 0xcc, 0x88, 0xcc, - 0x18, 0x30, 0x68, 0x49, 0x77, 0xfe, 0xc0, 0x4f, - 0xf9, 0x27, 0xa9, 0x49, 0x66, 0x03, 0x1a, 0x3c, - 0x3c, 0x4f, 0xac, 0xb6, 0x94, 0x2e, 0xd7, 0xb0, - 0x01, 0xa3, 0x8c, 0x5e, 0x73, 0x1d, 0x2f, 0x20, - 0x86, 0xb7, 0x10, 0xbd, 0x8e, 0x63, 0x5b, 0x41, - 0x21, 0x23, 0x8d, 0xac, 0x87, 0xc0, 0x7e, 0x78, - 0xb2, 0x11, 0x33, 0x52, 0x50, 0xa7, 0x6f, 0x7a, - 0x09, 0x95, 0x63, 0x1b, 0x04, 0xce, 0x6b, 0x93, - 0x47, 0xa2, 0xb0, 0x1f, 0x2c, 0x89, 0x1c, 0xd7, - 0xaa, 0xd6, 0x88, 0xbd, 0xd5, 0x45, 0x6f, 0x06, - 0x2b, 0xcc, 0x3e, 0x02, 0x4f, 0xeb, 0xef, 0x9d, - 0xb2, 0xf9, 0x71, 0xea, 0xca, 0x8c, 0x9c, 0x00, - 0xcd, 0x7e, 0x1c, 0x15, 0x7d, 0x69, 0xe8, 0x52, - 0x03, 0x81, 0xc4, 0x31, 0x2e, 0x8f, 0x0d, 0x31, - 0xef, 0x18, 0x03, 0x37, 0x0f, 0xa3, 0x19, 0x7b, - 0x19, 0x6a, 0x11, 0x7c, 0xfb, 0x88, 0xd3, 0x08, - 0x17, 0x98, 0x9d, 0xd6, 0x5a, 0x87, 0xd3, 0xe8, - 0x69, 0x3f, 0x6c, 0x8b, 0xd8, 0xd4, 0x6c, 0x11, - 0x17, 0x2b, 0xae, 0xf2, 0x8d, 0xa4, 0x35, 0x55, - 0x32, 0x9e, 0x85, 0x6a, 0xc2, 0x9e, 0xee, 0x5b, - 0xcd, 0x23, 0x7a, 0x11, 0xa7, 0xdd, 0xde, 0xb2, - 0xd1, 0xc6, 0xb8, 0x02, 0x93, 0xdb, 0x1e, 0x69, - 0x99, 0x6d, 0xc6, 0x2f, 0x98, 0xab, 0x26, 0x89, - 0x02, 0x83, 0xfa, 0xa6, 0x65, 0xe9, 0xc6, 0x9f, - 0xf7, 0xc9, 0x7b, 0xda, 0x73, 0x1c, 0x60, 0x11, - 0x32, 0x85, 0x17, 0x49, 0xca, 0x0b, 0x96, 0x0c, - 0x47, 0x0d, 0xef, 0x94, 0x9c, 0x15, 0x05, 0xbe, - 0x4b, 0xed, 0xd6, 0xee, 0x7b, 0xbb, 0x14, 0x23, - 0x54, 0x31, 0x04, 0xf0, 0x81, 0x04, 0x44, 0xd2, - 0x02, 0x33, 0x60, 0xba, 0x5f, 0x4f, 0xae, 0x1f, - 0x2d, 0xce, 0xbb, 0xff, 0xe8, 0x55, 0xc7, 0xa8, - 0xa6, 0x50, 0xbe, 0xa7, 0xfb, 0x41, 0x9d, 0xf8, - 0x41, 0x9c, 0xdd, 0x92, 0x47, 0x9f, 0x6f, 0xf3, - 0x56, 0x25, 0x0e, 0xbc, 0xa0, 0x89, 0xf2, 0x7f, - 0x12, 0x45, 0x5b, 0xb4, 0xd6, 0xa5, 0xb5, 0x71, - 0x31, 0x70, 0xae, 0xaf, 0x65, 0x55, 0x0e, 0xa9, - 0x1a, 0x5d, 0xc0, 0x1f, 0x20, 0x71, 0x07, 0xce, - 0x3e, 0x5e, 0xd3, 0xee, 0x5b, 0x4c, 0x67, 0x21, - 0x64, 0x0c, 0x5c, 0x1c, 0xd3, 0x2d, 0x24, 0xc4, - 0xf8, 0xad, 0x31, 0x02, 0xc5, 0xb0, 0x45, 0xe8, - 0x60, 0xd2, 0x50, 0xf4, 0xd1, 0xd6, 0x2b, 0x85, - 0x53, 0xac, 0x73, 0x96, 0x98, 0xf9, 0x1b, 0x5e, - 0xb8, 0x0f, 0xa1, 0xd3, 0xba, 0x6e, 0x43, 0x92, - 0x31, 0x69, 0x82, 0x14, 0x4a, 0xff, 0x36, 0x44, - 0x58, 0xf6, 0x41, 0xe3, 0x46, 0x85, 0x83, 0x05, - 0x96, 0x87, 0x7c, 0x0c, 0x0b, 0x70, 0x24, 0x8e, - 0x42, 0xb0, 0xd5, 0x9e, 0x7f, 0xcb, 0x26, 0xe8 -//}; -//unsigned int sigrl_dat_len = 408; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_first_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_first_entry.inc deleted file mode 100644 index 3ca0386b69..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_first_entry.inc +++ /dev/null @@ -1,77 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - * Revoked signature : Member0/sig_sha256_bsn0_msg0 first entry - */ -//unsigned char sigrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59, - 0x19, 0x6a, 0x11, 0x7c, 0xfb, 0x88, 0xd3, 0x08, - 0x17, 0x98, 0x9d, 0xd6, 0x5a, 0x87, 0xd3, 0xe8, - 0x69, 0x3f, 0x6c, 0x8b, 0xd8, 0xd4, 0x6c, 0x11, - 0x17, 0x2b, 0xae, 0xf2, 0x8d, 0xa4, 0x35, 0x55, - 0x32, 0x9e, 0x85, 0x6a, 0xc2, 0x9e, 0xee, 0x5b, - 0xcd, 0x23, 0x7a, 0x11, 0xa7, 0xdd, 0xde, 0xb2, - 0xd1, 0xc6, 0xb8, 0x02, 0x93, 0xdb, 0x1e, 0x69, - 0x99, 0x6d, 0xc6, 0x2f, 0x98, 0xab, 0x26, 0x89, - 0x02, 0x83, 0xfa, 0xa6, 0x65, 0xe9, 0xc6, 0x9f, - 0xf7, 0xc9, 0x7b, 0xda, 0x73, 0x1c, 0x60, 0x11, - 0x32, 0x85, 0x17, 0x49, 0xca, 0x0b, 0x96, 0x0c, - 0x47, 0x0d, 0xef, 0x94, 0x9c, 0x15, 0x05, 0xbe, - 0x4b, 0xed, 0xd6, 0xee, 0x7b, 0xbb, 0x14, 0x23, - 0x54, 0x31, 0x04, 0xf0, 0x81, 0x04, 0x44, 0xd2, - 0x02, 0x33, 0x60, 0xba, 0x5f, 0x4f, 0xae, 0x1f, - 0x2d, 0xce, 0xbb, 0xff, 0xe8, 0x55, 0xc7, 0xa8, - 0xa6, 0x50, 0xbe, 0xa7, 0xfb, 0x41, 0x9d, 0xf8, - 0x41, 0x9c, 0xdd, 0x92, 0x47, 0x9f, 0x6f, 0xf3, - 0x56, 0x25, 0x0e, 0xbc, 0xa0, 0x89, 0xf2, 0x7f, - 0x12, 0x45, 0x5b, 0xb4, 0xd6, 0xa5, 0xb5, 0x71, - 0x31, 0x70, 0xae, 0xaf, 0x65, 0x55, 0x0e, 0xa9, - 0x1a, 0x5d, 0xc0, 0x1f, 0x20, 0x71, 0x07, 0xce, - 0x3e, 0x5e, 0xd3, 0xee, 0x5b, 0x4c, 0x67, 0x21, - 0x64, 0x0c, 0x5c, 0x1c, 0xd3, 0x2d, 0x24, 0xc4, - 0xf8, 0xad, 0x31, 0x02, 0xc5, 0xb0, 0x45, 0xe8, - 0x60, 0xd2, 0x50, 0xf4, 0xd1, 0xd6, 0x2b, 0x85, - 0x53, 0xac, 0x73, 0x96, 0x98, 0xf9, 0x1b, 0x5e, - 0xb8, 0x0f, 0xa1, 0xd3, 0xba, 0x6e, 0x43, 0x92, - 0x31, 0x69, 0x82, 0x14, 0x4a, 0xff, 0x36, 0x44, - 0x58, 0xf6, 0x41, 0xe3, 0x46, 0x85, 0x83, 0x05, - 0x96, 0x87, 0x7c, 0x0c, 0x0b, 0x70, 0x24, 0x8e, - 0x42, 0xb0, 0xd5, 0x9e, 0x7f, 0xcb, 0x26, 0xe8 -//}; -//unsigned int sigrl_dat_len = 408; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_last_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_last_entry.inc deleted file mode 100644 index f92cde6539..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_last_entry.inc +++ /dev/null @@ -1,77 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - * Revoked signature : Member0/sig_sha256_bsn0_msg0 last entry - */ -//unsigned char sigrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xa6, 0xad, 0xdd, 0xbe, 0x45, 0xcc, 0x88, 0xcc, - 0x18, 0x30, 0x68, 0x49, 0x77, 0xfe, 0xc0, 0x4f, - 0xf9, 0x27, 0xa9, 0x49, 0x66, 0x03, 0x1a, 0x3c, - 0x3c, 0x4f, 0xac, 0xb6, 0x94, 0x2e, 0xd7, 0xb0, - 0x01, 0xa3, 0x8c, 0x5e, 0x73, 0x1d, 0x2f, 0x20, - 0x86, 0xb7, 0x10, 0xbd, 0x8e, 0x63, 0x5b, 0x41, - 0x21, 0x23, 0x8d, 0xac, 0x87, 0xc0, 0x7e, 0x78, - 0xb2, 0x11, 0x33, 0x52, 0x50, 0xa7, 0x6f, 0x7a, - 0x09, 0x95, 0x63, 0x1b, 0x04, 0xce, 0x6b, 0x93, - 0x47, 0xa2, 0xb0, 0x1f, 0x2c, 0x89, 0x1c, 0xd7, - 0xaa, 0xd6, 0x88, 0xbd, 0xd5, 0x45, 0x6f, 0x06, - 0x2b, 0xcc, 0x3e, 0x02, 0x4f, 0xeb, 0xef, 0x9d, - 0xb2, 0xf9, 0x71, 0xea, 0xca, 0x8c, 0x9c, 0x00, - 0xcd, 0x7e, 0x1c, 0x15, 0x7d, 0x69, 0xe8, 0x52, - 0x03, 0x81, 0xc4, 0x31, 0x2e, 0x8f, 0x0d, 0x31, - 0xef, 0x18, 0x03, 0x37, 0x0f, 0xa3, 0x19, 0x7b, - 0x19, 0x6a, 0x11, 0x7c, 0xfb, 0x88, 0xd3, 0x08, - 0x17, 0x98, 0x9d, 0xd6, 0x5a, 0x87, 0xd3, 0xe8, - 0x69, 0x3f, 0x6c, 0x8b, 0xd8, 0xd4, 0x6c, 0x11, - 0x17, 0x2b, 0xae, 0xf2, 0x8d, 0xa4, 0x35, 0x55, - 0x32, 0x9e, 0x85, 0x6a, 0xc2, 0x9e, 0xee, 0x5b, - 0xcd, 0x23, 0x7a, 0x11, 0xa7, 0xdd, 0xde, 0xb2, - 0xd1, 0xc6, 0xb8, 0x02, 0x93, 0xdb, 0x1e, 0x69, - 0x99, 0x6d, 0xc6, 0x2f, 0x98, 0xab, 0x26, 0x89, - 0x02, 0x83, 0xfa, 0xa6, 0x65, 0xe9, 0xc6, 0x9f, - 0xf7, 0xc9, 0x7b, 0xda, 0x73, 0x1c, 0x60, 0x11, - 0x32, 0x85, 0x17, 0x49, 0xca, 0x0b, 0x96, 0x0c, - 0x47, 0x0d, 0xef, 0x94, 0x9c, 0x15, 0x05, 0xbe, - 0x4b, 0xed, 0xd6, 0xee, 0x7b, 0xbb, 0x14, 0x23, - 0x54, 0x31, 0x04, 0xf0, 0x81, 0x04, 0x44, 0xd2, - 0x02, 0x33, 0x60, 0xba, 0x5f, 0x4f, 0xae, 0x1f, - 0x2d, 0xce, 0xbb, 0xff, 0xe8, 0x55, 0xc7, 0xa8, - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59 -//}; -//unsigned int sigrl_dat_len = 408; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_middle_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_middle_entry.inc deleted file mode 100644 index ecd9138f0e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_middle_entry.inc +++ /dev/null @@ -1,77 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - * Revoked signature : Member0/sig_sha256_bsn0_msg0 middle entry - */ -//unsigned char sigrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xa6, 0xad, 0xdd, 0xbe, 0x45, 0xcc, 0x88, 0xcc, - 0x18, 0x30, 0x68, 0x49, 0x77, 0xfe, 0xc0, 0x4f, - 0xf9, 0x27, 0xa9, 0x49, 0x66, 0x03, 0x1a, 0x3c, - 0x3c, 0x4f, 0xac, 0xb6, 0x94, 0x2e, 0xd7, 0xb0, - 0x01, 0xa3, 0x8c, 0x5e, 0x73, 0x1d, 0x2f, 0x20, - 0x86, 0xb7, 0x10, 0xbd, 0x8e, 0x63, 0x5b, 0x41, - 0x21, 0x23, 0x8d, 0xac, 0x87, 0xc0, 0x7e, 0x78, - 0xb2, 0x11, 0x33, 0x52, 0x50, 0xa7, 0x6f, 0x7a, - 0x09, 0x95, 0x63, 0x1b, 0x04, 0xce, 0x6b, 0x93, - 0x47, 0xa2, 0xb0, 0x1f, 0x2c, 0x89, 0x1c, 0xd7, - 0xaa, 0xd6, 0x88, 0xbd, 0xd5, 0x45, 0x6f, 0x06, - 0x2b, 0xcc, 0x3e, 0x02, 0x4f, 0xeb, 0xef, 0x9d, - 0xb2, 0xf9, 0x71, 0xea, 0xca, 0x8c, 0x9c, 0x00, - 0xcd, 0x7e, 0x1c, 0x15, 0x7d, 0x69, 0xe8, 0x52, - 0x03, 0x81, 0xc4, 0x31, 0x2e, 0x8f, 0x0d, 0x31, - 0xef, 0x18, 0x03, 0x37, 0x0f, 0xa3, 0x19, 0x7b, - 0x19, 0x6a, 0x11, 0x7c, 0xfb, 0x88, 0xd3, 0x08, - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59, - 0x41, 0x9c, 0xdd, 0x92, 0x47, 0x9f, 0x6f, 0xf3, - 0x56, 0x25, 0x0e, 0xbc, 0xa0, 0x89, 0xf2, 0x7f, - 0x12, 0x45, 0x5b, 0xb4, 0xd6, 0xa5, 0xb5, 0x71, - 0x31, 0x70, 0xae, 0xaf, 0x65, 0x55, 0x0e, 0xa9, - 0x1a, 0x5d, 0xc0, 0x1f, 0x20, 0x71, 0x07, 0xce, - 0x3e, 0x5e, 0xd3, 0xee, 0x5b, 0x4c, 0x67, 0x21, - 0x64, 0x0c, 0x5c, 0x1c, 0xd3, 0x2d, 0x24, 0xc4, - 0xf8, 0xad, 0x31, 0x02, 0xc5, 0xb0, 0x45, 0xe8, - 0x60, 0xd2, 0x50, 0xf4, 0xd1, 0xd6, 0x2b, 0x85, - 0x53, 0xac, 0x73, 0x96, 0x98, 0xf9, 0x1b, 0x5e, - 0xb8, 0x0f, 0xa1, 0xd3, 0xba, 0x6e, 0x43, 0x92, - 0x31, 0x69, 0x82, 0x14, 0x4a, 0xff, 0x36, 0x44, - 0x58, 0xf6, 0x41, 0xe3, 0x46, 0x85, 0x83, 0x05, - 0x96, 0x87, 0x7c, 0x0c, 0x0b, 0x70, 0x24, 0x8e, - 0x42, 0xb0, 0xd5, 0x9e, 0x7f, 0xcb, 0x26, 0xe8 -//}; -//unsigned int sigrl_dat_len = 408; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_single_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_single_entry.inc deleted file mode 100644 index 95a6f0dc3f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_single_entry.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - * Revoked signature : Member0/sig_sha256_bsn0_msg0 - */ -//unsigned char sigrl_empty_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x81, 0xa5, 0xa5, 0x8f, 0xe6, 0x4e, 0x18, 0x04, - 0x05, 0x46, 0xa1, 0x30, 0x84, 0xde, 0x4f, 0x09, - 0x36, 0x5f, 0x59, 0xbe, 0xc0, 0x4f, 0x4f, 0xbc, - 0xde, 0xd1, 0xd1, 0x11, 0x11, 0x07, 0x7a, 0x2d, - 0x89, 0x9c, 0x1b, 0x21, 0x34, 0xeb, 0x84, 0xc4, - 0x2c, 0x82, 0x63, 0xce, 0x98, 0x30, 0x22, 0xee, - 0x2c, 0xec, 0x90, 0x95, 0x66, 0x94, 0x74, 0xf5, - 0xef, 0xff, 0x74, 0xfa, 0xad, 0x61, 0x6f, 0x59 -//}; -//unsigned int sigrl_empty_dat_len = 152; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_ver_2.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_ver_2.inc deleted file mode 100644 index d72268454d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/sigrl_ver_2.inc +++ /dev/null @@ -1,76 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : grpX - */ -//unsigned char sigrl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, - 0xa6, 0xad, 0xdd, 0xbe, 0x45, 0xcc, 0x88, 0xcc, - 0x18, 0x30, 0x68, 0x49, 0x77, 0xfe, 0xc0, 0x4f, - 0xf9, 0x27, 0xa9, 0x49, 0x66, 0x03, 0x1a, 0x3c, - 0x3c, 0x4f, 0xac, 0xb6, 0x94, 0x2e, 0xd7, 0xb0, - 0x01, 0xa3, 0x8c, 0x5e, 0x73, 0x1d, 0x2f, 0x20, - 0x86, 0xb7, 0x10, 0xbd, 0x8e, 0x63, 0x5b, 0x41, - 0x21, 0x23, 0x8d, 0xac, 0x87, 0xc0, 0x7e, 0x78, - 0xb2, 0x11, 0x33, 0x52, 0x50, 0xa7, 0x6f, 0x7a, - 0x09, 0x95, 0x63, 0x1b, 0x04, 0xce, 0x6b, 0x93, - 0x47, 0xa2, 0xb0, 0x1f, 0x2c, 0x89, 0x1c, 0xd7, - 0xaa, 0xd6, 0x88, 0xbd, 0xd5, 0x45, 0x6f, 0x06, - 0x2b, 0xcc, 0x3e, 0x02, 0x4f, 0xeb, 0xef, 0x9d, - 0xb2, 0xf9, 0x71, 0xea, 0xca, 0x8c, 0x9c, 0x00, - 0xcd, 0x7e, 0x1c, 0x15, 0x7d, 0x69, 0xe8, 0x52, - 0x03, 0x81, 0xc4, 0x31, 0x2e, 0x8f, 0x0d, 0x31, - 0xef, 0x18, 0x03, 0x37, 0x0f, 0xa3, 0x19, 0x7b, - 0x19, 0x6a, 0x11, 0x7c, 0xfb, 0x88, 0xd3, 0x08, - 0x17, 0x98, 0x9d, 0xd6, 0x5a, 0x87, 0xd3, 0xe8, - 0x69, 0x3f, 0x6c, 0x8b, 0xd8, 0xd4, 0x6c, 0x11, - 0x17, 0x2b, 0xae, 0xf2, 0x8d, 0xa4, 0x35, 0x55, - 0x32, 0x9e, 0x85, 0x6a, 0xc2, 0x9e, 0xee, 0x5b, - 0xcd, 0x23, 0x7a, 0x11, 0xa7, 0xdd, 0xde, 0xb2, - 0xd1, 0xc6, 0xb8, 0x02, 0x93, 0xdb, 0x1e, 0x69, - 0x99, 0x6d, 0xc6, 0x2f, 0x98, 0xab, 0x26, 0x89, - 0x02, 0x83, 0xfa, 0xa6, 0x65, 0xe9, 0xc6, 0x9f, - 0xf7, 0xc9, 0x7b, 0xda, 0x73, 0x1c, 0x60, 0x11, - 0x32, 0x85, 0x17, 0x49, 0xca, 0x0b, 0x96, 0x0c, - 0x47, 0x0d, 0xef, 0x94, 0x9c, 0x15, 0x05, 0xbe, - 0x4b, 0xed, 0xd6, 0xee, 0x7b, 0xbb, 0x14, 0x23, - 0x54, 0x31, 0x04, 0xf0, 0x81, 0x04, 0x44, 0xd2, - 0x02, 0x33, 0x60, 0xba, 0x5f, 0x4f, 0xae, 0x1f, - 0x2d, 0xce, 0xbb, 0xff, 0xe8, 0x55, 0xc7, 0xa8, - 0xa6, 0x50, 0xbe, 0xa7, 0xfb, 0x41, 0x9d, 0xf8, - 0x41, 0x9c, 0xdd, 0x92, 0x47, 0x9f, 0x6f, 0xf3, - 0x56, 0x25, 0x0e, 0xbc, 0xa0, 0x89, 0xf2, 0x7f, - 0x12, 0x45, 0x5b, 0xb4, 0xd6, 0xa5, 0xb5, 0x71, - 0x31, 0x70, 0xae, 0xaf, 0x65, 0x55, 0x0e, 0xa9, - 0x1a, 0x5d, 0xc0, 0x1f, 0x20, 0x71, 0x07, 0xce, - 0x3e, 0x5e, 0xd3, 0xee, 0x5b, 0x4c, 0x67, 0x21, - 0x64, 0x0c, 0x5c, 0x1c, 0xd3, 0x2d, 0x24, 0xc4, - 0xf8, 0xad, 0x31, 0x02, 0xc5, 0xb0, 0x45, 0xe8, - 0x60, 0xd2, 0x50, 0xf4, 0xd1, 0xd6, 0x2b, 0x85, - 0x53, 0xac, 0x73, 0x96, 0x98, 0xf9, 0x1b, 0x5e, - 0xb8, 0x0f, 0xa1, 0xd3, 0xba, 0x6e, 0x43, 0x92, - 0x31, 0x69, 0x82, 0x14, 0x4a, 0xff, 0x36, 0x44, - 0x58, 0xf6, 0x41, 0xe3, 0x46, 0x85, 0x83, 0x05, - 0x96, 0x87, 0x7c, 0x0c, 0x0b, 0x70, 0x24, 0x8e, - 0x42, 0xb0, 0xd5, 0x9e, 0x7f, 0xcb, 0x26, 0xe8 -//}; -//unsigned int sigrl_dat_len = 408; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey000.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey000.inc deleted file mode 100644 index 4dc89ff16a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey000.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember000 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey000_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x91, 0xd6, 0xcd, 0x65, 0x09, 0xbc, 0x30, 0x13, - 0x43, 0x50, 0x09, 0x25, 0x1c, 0x05, 0x66, 0x77, - 0xb0, 0x69, 0x38, 0x5b, 0x61, 0x49, 0x25, 0xec, - 0xf3, 0xa0, 0x00, 0x4b, 0xcb, 0xc9, 0xa3, 0x58, - 0xee, 0x72, 0xb6, 0x75, 0xf6, 0x79, 0xb8, 0xf1, - 0x8e, 0x1f, 0xe8, 0x8b, 0xf7, 0x1b, 0x84, 0xf9, - 0xd0, 0x27, 0x28, 0x8b, 0xf6, 0x2a, 0xe2, 0xf0, - 0xd9, 0xb7, 0xf7, 0xdf, 0x8d, 0x65, 0x75, 0xee, - 0xc8, 0xa3, 0xf2, 0xcd, 0xc3, 0x26, 0x5a, 0x13, - 0xf8, 0xa5, 0x39, 0x57, 0x44, 0x57, 0xb7, 0x96, - 0x2e, 0x5c, 0x3a, 0x7a, 0xe6, 0x38, 0x5a, 0x99, - 0xec, 0xe3, 0x4b, 0x6c, 0x77, 0x7a, 0x14, 0x8b, - 0xb2, 0x17, 0x61, 0x7d, 0x51, 0x64, 0xf6, 0xa4, - 0xbc, 0x97, 0xcd, 0x67, 0xde, 0x98, 0xce, 0xee, - 0x8d, 0x5e, 0x78, 0x84, 0x77, 0x9b, 0x99, 0x84, - 0x01, 0x9f, 0x66, 0x7c, 0xd4, 0x67, 0x81, 0x48 -//}; -//unsigned int mprivkey000_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey001.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey001.inc deleted file mode 100644 index c42eaadb88..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey001.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember001 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey001_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x2e, 0xcb, 0xb7, 0x36, 0x9b, 0x2b, 0x8d, 0xd1, - 0x03, 0x25, 0xd8, 0xe7, 0x57, 0x21, 0xac, 0x47, - 0x60, 0xe3, 0x1d, 0xb5, 0x78, 0xfa, 0x6d, 0x8c, - 0x00, 0x7d, 0x95, 0x91, 0x64, 0x31, 0xb6, 0x7d, - 0xdb, 0x18, 0x3a, 0x11, 0x99, 0x22, 0x93, 0x93, - 0x57, 0x8d, 0x9b, 0x23, 0x1d, 0x65, 0xa2, 0x78, - 0x18, 0xa0, 0xf4, 0x99, 0x1b, 0x67, 0xe2, 0xc7, - 0x4a, 0xb1, 0xfc, 0xa6, 0xdd, 0xae, 0x05, 0x20, - 0x3b, 0x26, 0xd9, 0xc6, 0x41, 0x2f, 0x38, 0x64, - 0xb4, 0xd7, 0x7b, 0xf3, 0x86, 0x01, 0x33, 0xc1, - 0x5f, 0x22, 0x30, 0xeb, 0x20, 0x94, 0x76, 0xad, - 0xb1, 0x15, 0xc3, 0xe0, 0x1c, 0xfe, 0x8d, 0x61, - 0x3f, 0xf7, 0xef, 0xfc, 0xcb, 0xfb, 0xeb, 0xa6, - 0xf9, 0x31, 0x3b, 0x9f, 0xd4, 0xa7, 0x21, 0x61, - 0xaa, 0x98, 0xf4, 0x8d, 0x79, 0x3c, 0xf0, 0x33, - 0x04, 0x0c, 0x79, 0x6d, 0x88, 0x02, 0xba, 0x1c -//}; -//unsigned int mprivkey001_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey002.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey002.inc deleted file mode 100644 index ef60d525de..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/mprivkey002.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember002 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey002_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xab, 0x31, 0xae, 0x14, 0x0c, 0xcf, 0x08, 0x26, - 0xfb, 0x6e, 0x67, 0x2c, 0xca, 0x71, 0x49, 0xba, - 0x84, 0x53, 0xc7, 0xe6, 0x2b, 0xee, 0xc7, 0xff, - 0x3a, 0x1e, 0x7e, 0x63, 0x1d, 0xf7, 0x2e, 0xee, - 0xc3, 0xa7, 0xfc, 0x69, 0x69, 0x44, 0x09, 0x5d, - 0xf9, 0xf0, 0xf4, 0x27, 0xca, 0x26, 0xe2, 0x3a, - 0x85, 0x8c, 0x8f, 0x01, 0x7b, 0xcf, 0xef, 0xac, - 0x1c, 0x07, 0x89, 0x0b, 0x41, 0x5f, 0x15, 0x42, - 0x9d, 0x62, 0xfc, 0x19, 0x8e, 0xe1, 0xde, 0x1f, - 0x37, 0x47, 0xe3, 0xc0, 0x72, 0xff, 0xdb, 0x0c, - 0x18, 0x3f, 0x21, 0x6d, 0x8e, 0xb0, 0xfb, 0xb6, - 0x6a, 0x15, 0x19, 0xc7, 0x47, 0x88, 0x88, 0x4a, - 0x90, 0xdb, 0xd9, 0x11, 0xf1, 0xef, 0x1a, 0x68, - 0x8d, 0x1c, 0x07, 0xfe, 0x04, 0xbd, 0xf2, 0x6c, - 0x8b, 0x1b, 0xd0, 0x7f, 0x96, 0x9a, 0x90, 0xed, - 0x34, 0x0c, 0x13, 0x6d, 0x7c, 0x0c, 0x32, 0x58 -//}; -//unsigned int mprivkey002_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked0sha256bsn0msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked0sha256bsn0msg0.inc deleted file mode 100644 index 338a3b8142..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked0sha256bsn0msg0.inc +++ /dev/null @@ -1,136 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : verrevoked/bsn0/mprivkey000 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ - -//unsigned char sig_revoked0msg0bsn0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x8b, 0xc9, 0x6e, 0xc0, 0x86, 0x04, 0x6f, 0x6c, - 0x89, 0xc2, 0x27, 0xfd, 0x61, 0x59, 0xb5, 0xd2, - 0x73, 0x96, 0xfa, 0xd6, 0xf8, 0xfa, 0x2c, 0x39, - 0xfe, 0xee, 0xef, 0x3e, 0x73, 0xd2, 0x38, 0x3f, - 0x3c, 0x04, 0x07, 0x78, 0xfd, 0x32, 0x9b, 0xc3, - 0x74, 0x90, 0xf2, 0xf5, 0x50, 0xe4, 0x69, 0x5d, - 0x30, 0x0c, 0x6a, 0x8a, 0x9c, 0xcf, 0xff, 0x78, - 0x28, 0x52, 0x6d, 0x20, 0x29, 0xef, 0x2d, 0x7a, - 0x70, 0x75, 0x91, 0x2d, 0xbd, 0x56, 0x9f, 0x18, - 0x65, 0x25, 0x5f, 0x3a, 0x15, 0x36, 0x10, 0x91, - 0xf9, 0x02, 0x37, 0x30, 0xb1, 0x75, 0x8a, 0x9b, - 0xb0, 0x99, 0xc1, 0x28, 0xb7, 0x7b, 0x15, 0x4d, - 0xfc, 0x66, 0x4d, 0xe3, 0x3c, 0x37, 0x57, 0xf2, - 0x64, 0xbb, 0x24, 0xe4, 0xfc, 0xbd, 0x56, 0x7a, - 0x3f, 0x3a, 0xa5, 0xcb, 0x66, 0xd3, 0xd2, 0x9f, - 0xe2, 0x51, 0x4b, 0xa8, 0x5d, 0x8f, 0x79, 0x38, - 0xa1, 0x25, 0xe4, 0x3c, 0xc0, 0xa5, 0x4e, 0x83, - 0xd5, 0x0a, 0x9f, 0xfa, 0x6f, 0x9d, 0xc2, 0x49, - 0x35, 0x71, 0x54, 0x2e, 0x62, 0x7b, 0x06, 0xb3, - 0x60, 0x57, 0x79, 0x77, 0xf4, 0x0e, 0x91, 0x6f, - 0xec, 0x58, 0xdc, 0xb2, 0x80, 0xe3, 0xd3, 0x5b, - 0xa7, 0x68, 0x31, 0x18, 0x6f, 0x9e, 0x47, 0x5f, - 0x99, 0xc8, 0x85, 0xd2, 0x25, 0xbb, 0x68, 0xb4, - 0x8f, 0x4c, 0x21, 0x85, 0x77, 0x2f, 0x62, 0x92, - 0xd0, 0xe1, 0x70, 0x5a, 0x02, 0xbc, 0xed, 0x69, - 0x46, 0xc0, 0xca, 0x83, 0xcc, 0xe6, 0xb9, 0xff, - 0x17, 0x90, 0xb7, 0xc3, 0xbb, 0x86, 0xa5, 0x41, - 0x55, 0x25, 0xcb, 0x3d, 0x18, 0x6e, 0x60, 0xaf, - 0x52, 0x70, 0xfc, 0xe5, 0x55, 0xfc, 0x7d, 0x8e, - 0xf2, 0x5b, 0xa1, 0x1c, 0xc2, 0x34, 0x31, 0x77, - 0xbc, 0x9d, 0x23, 0xc5, 0xbb, 0x01, 0xf0, 0x2b, - 0xa7, 0xaf, 0x52, 0xaa, 0x9a, 0xd9, 0x74, 0x58, - 0x96, 0x87, 0x54, 0x6c, 0xb6, 0x93, 0x0c, 0x9a, - 0x8f, 0x0f, 0xb6, 0x0e, 0x89, 0xb6, 0xb9, 0x0b, - 0xd3, 0x5c, 0xe4, 0x83, 0xad, 0x1c, 0x79, 0x7c, - 0x12, 0x36, 0x0d, 0xe2, 0xa7, 0xab, 0xd7, 0xd0, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xc5, 0x3b, 0x02, 0x5f, 0xcd, 0x67, 0x05, 0x99, - 0x74, 0x1f, 0x65, 0xa1, 0xdb, 0xee, 0xa2, 0x18, - 0x5d, 0xee, 0x82, 0xa9, 0x98, 0xab, 0xa6, 0x92, - 0x84, 0xf1, 0x08, 0x98, 0x36, 0x56, 0xe0, 0x63, - 0xa0, 0xc0, 0xd2, 0xff, 0xc3, 0x34, 0xc1, 0xc2, - 0x87, 0x00, 0x0d, 0x8b, 0x78, 0xc9, 0x68, 0x49, - 0xdf, 0xd8, 0xfa, 0xdc, 0x00, 0x80, 0xf7, 0xf4, - 0xa7, 0xf8, 0x1c, 0x8c, 0x96, 0xf3, 0x00, 0x3b, - 0xcf, 0x06, 0x8f, 0x66, 0x18, 0x68, 0x9b, 0xe6, - 0xca, 0x20, 0xe5, 0x5a, 0x4c, 0xf4, 0x87, 0x43, - 0xc8, 0xf4, 0x5c, 0x28, 0x8d, 0x35, 0x85, 0x1c, - 0xa5, 0x27, 0xd7, 0xcc, 0x8b, 0x7f, 0x96, 0x70, - 0xdd, 0xf2, 0x50, 0x60, 0xde, 0x45, 0x83, 0x8c, - 0x9b, 0x64, 0xe2, 0xd2, 0x49, 0x46, 0x48, 0xb0, - 0x7a, 0x67, 0x32, 0x2b, 0xb6, 0xea, 0xa8, 0x40, - 0x8d, 0x08, 0x2f, 0xd7, 0xd7, 0x2a, 0x2b, 0x4a, - 0x45, 0x9e, 0x5c, 0x56, 0x8c, 0x50, 0xaa, 0x81, - 0x46, 0x18, 0xc8, 0x46, 0x8a, 0x11, 0xf8, 0x89, - 0x3e, 0x32, 0x20, 0xb8, 0xf5, 0x7f, 0xc8, 0x25, - 0xda, 0xe0, 0x51, 0x39, 0xe9, 0x57, 0x87, 0x26, - 0xe9, 0x79, 0x70, 0xce, 0x75, 0x99, 0xe5, 0xab, - 0x6e, 0x6f, 0x73, 0xe9, 0xc2, 0x99, 0xc8, 0xb7, - 0x30, 0xdc, 0xe3, 0xd8, 0x95, 0x92, 0x4e, 0xb8, - 0xac, 0xf3, 0xc1, 0x9c, 0x97, 0x6e, 0xfe, 0x48, - 0x5e, 0xff, 0xce, 0x7a, 0x1b, 0x95, 0xb8, 0x90, - 0xb9, 0xd5, 0x8d, 0x44, 0xdc, 0x92, 0xf5, 0xf7, - 0x91, 0xe5, 0x2f, 0x28, 0x31, 0x7d, 0x21, 0x91, - 0x2b, 0xf0, 0x1d, 0x27, 0xd6, 0x46, 0x7a, 0x6d, - 0xdc, 0x70, 0x2e, 0x85, 0x55, 0x58, 0x8a, 0xd4, - 0xdb, 0x09, 0xea, 0xf7, 0x6a, 0x2c, 0x35, 0xcb, - 0xc5, 0xd1, 0x53, 0x07, 0x12, 0xbd, 0x25, 0x5e, - 0x05, 0x61, 0x43, 0xb8, 0xb3, 0x87, 0xf1, 0xb8, - 0x88, 0x58, 0xaf, 0x47, 0x04, 0x7e, 0x52, 0x6c, - 0x6c, 0x04, 0x58, 0xfb, 0x00, 0x67, 0x8f, 0xa5, - 0xb2, 0x99, 0x09, 0xed, 0x86, 0xa4, 0x5d, 0xdf, - 0x4b, 0xea, 0x4d, 0xa0, 0xb9, 0x1a, 0x4d, 0x98, - 0x1f, 0x76, 0x19, 0x84, 0x9c, 0x2a, 0x8e, 0xdb, - 0x8b, 0xdb, 0x5c, 0x60, 0xa5, 0x8c, 0x09, 0xea, - 0x0d, 0xff, 0x3e, 0x3e, 0x18, 0xf5, 0xa8, 0xf5, - 0xa0, 0x82, 0x15, 0xa0, 0xf5, 0x36, 0xc3, 0xb6, - 0x72, 0xab, 0x81, 0x8f, 0xae, 0x9c, 0x67, 0x63, - 0x49, 0xfe, 0x01, 0x66, 0xd2, 0x53, 0x9c, 0x97, - 0x0e, 0x58, 0x1c, 0x6f, 0xb6, 0x49, 0x16, 0x7a, - 0x43, 0xfc, 0x61, 0x0d, 0x36, 0x31, 0x28, 0x65, - 0x32, 0x62, 0x28, 0x44, 0x50, 0xda, 0xb1, 0x1b, - 0x7a, 0xd6, 0x27, 0x69, 0xc0, 0xe9, 0xab, 0x78, - 0xda, 0x27, 0xd7, 0x9e, 0x7e, 0x35, 0xcf, 0x8b, - 0x09, 0xc7, 0x2f, 0x5f, 0x8d, 0xa4, 0x29, 0xdb, - 0x83, 0x62, 0x89, 0x36, 0x86, 0x53, 0xcc, 0xe9, - 0x6f, 0xb9, 0x4a, 0x31, 0x9e, 0xf8, 0xa5, 0x7b, - 0x2f, 0xb6, 0xff, 0x2a, 0x5f, 0xbe, 0xb1, 0x71, - 0x42, 0xc0, 0xf8, 0x36, 0x51, 0xdb, 0xe9, 0x1a, - 0xe0, 0xcd, 0xaa, 0xc1, 0x0c, 0x1d, 0x74, 0x4c, - 0x00, 0x98, 0x38, 0xbd, 0x70, 0x39, 0xc9, 0xd3, - 0xdf, 0x4c, 0xeb, 0xde, 0x19, 0x2f, 0xf8, 0x52, - 0x5b, 0x1a, 0x2a, 0x91, 0x50, 0xb8, 0xd3, 0xca, - 0x67, 0x2e, 0x4e, 0xaf, 0xa5, 0xce, 0x54, 0xa6, - 0x02, 0x34, 0xa5, 0x8b, 0x0b, 0xf8, 0x96, 0x46, - 0x04, 0xe2, 0x45, 0xaa, 0xb3, 0x24, 0x99, 0x60, - 0x24, 0x42, 0xde, 0x75, 0x91, 0xcf, 0x5b, 0xfb -//}; -//unsigned int sig_revoked0msg0bsn0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked1sha256bsn0msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked1sha256bsn0msg0.inc deleted file mode 100644 index b27b723a9e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked1sha256bsn0msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : verrevoked/bsn0/mprivkey001 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_revoked1msg0bsn0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x07, 0x46, 0xed, 0xb8, 0x6a, 0x4e, 0x7f, 0x4b, - 0x9d, 0xcc, 0x18, 0x91, 0x88, 0xf6, 0x76, 0x4d, - 0x74, 0x02, 0x36, 0x62, 0xe6, 0xd4, 0xb5, 0xf0, - 0x2d, 0x70, 0x91, 0x49, 0x65, 0xdf, 0x19, 0x02, - 0x30, 0x6c, 0x11, 0xaa, 0x74, 0x8c, 0x55, 0x2e, - 0x4b, 0xa3, 0x00, 0x00, 0xb0, 0x38, 0xf4, 0xcd, - 0x5d, 0xc9, 0x1d, 0xaa, 0x1e, 0x44, 0x98, 0xa4, - 0xe1, 0x3f, 0x2f, 0x4f, 0x6c, 0xc9, 0x15, 0xb0, - 0xb4, 0x9c, 0xb0, 0xe1, 0x0d, 0x9e, 0x27, 0x6c, - 0xc4, 0x1f, 0x77, 0x8c, 0x93, 0x98, 0x19, 0x8f, - 0xfa, 0xf5, 0xa2, 0x29, 0x09, 0x88, 0x51, 0xfc, - 0x76, 0xd8, 0xcd, 0xe6, 0xc7, 0x88, 0xeb, 0xba, - 0x19, 0x28, 0xa2, 0xd4, 0x25, 0x76, 0x13, 0x9d, - 0x0f, 0xee, 0x7c, 0x24, 0xbe, 0xc6, 0x67, 0x41, - 0xee, 0xce, 0x35, 0xf5, 0x6e, 0x83, 0xef, 0xb7, - 0x28, 0x28, 0xaa, 0x4f, 0x81, 0x3c, 0xc5, 0xb1, - 0x26, 0xc0, 0x76, 0x1b, 0x34, 0xab, 0x95, 0xfc, - 0x3a, 0x8f, 0x55, 0x93, 0x0a, 0x14, 0x2c, 0x3a, - 0x4c, 0xac, 0x6d, 0xd8, 0x3f, 0xa3, 0x0d, 0x57, - 0x6f, 0xe3, 0xd7, 0x46, 0xe4, 0x0a, 0x74, 0x27, - 0x27, 0x7c, 0x11, 0x25, 0xc9, 0x39, 0xe4, 0xee, - 0xf6, 0xfb, 0x08, 0xd1, 0xee, 0xa0, 0xbd, 0x67, - 0x0d, 0x16, 0x5b, 0xf6, 0x58, 0x22, 0x86, 0x4c, - 0xcd, 0x6f, 0x96, 0x8e, 0x5e, 0xb9, 0xa8, 0x23, - 0x2a, 0x8c, 0x35, 0x1a, 0x56, 0x81, 0x44, 0xfd, - 0xd6, 0xb5, 0x4a, 0x9c, 0xc5, 0xad, 0x95, 0x63, - 0xff, 0x20, 0x57, 0x56, 0xd8, 0x4c, 0x7e, 0x65, - 0x91, 0xd4, 0x81, 0xee, 0xa6, 0xdf, 0x43, 0x5e, - 0x82, 0x21, 0xcd, 0xda, 0x13, 0xc0, 0x9e, 0xef, - 0xa7, 0x42, 0xff, 0x30, 0x0a, 0x74, 0x2d, 0x18, - 0x88, 0xe8, 0x69, 0x9d, 0xbc, 0x51, 0x9e, 0x8e, - 0x64, 0x5c, 0x05, 0x7f, 0x4d, 0xac, 0x64, 0xd4, - 0x88, 0xc7, 0xa5, 0xac, 0xf4, 0x25, 0x40, 0x9e, - 0x46, 0x67, 0x4d, 0x2a, 0x1e, 0x58, 0xe6, 0x41, - 0xcc, 0xbb, 0x6a, 0x10, 0x98, 0x46, 0xd1, 0x33, - 0x8c, 0xe6, 0x97, 0xb4, 0x1e, 0x0f, 0x61, 0x24, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xe0, 0x9c, 0xd6, 0x62, 0x37, 0xb4, 0xf4, 0xf1, - 0x84, 0x29, 0xe0, 0x3f, 0x0f, 0x55, 0xbb, 0x4b, - 0xc7, 0xac, 0xac, 0x55, 0xd9, 0xc7, 0x80, 0xfb, - 0x8b, 0xd7, 0x25, 0x7a, 0x03, 0x0d, 0x5a, 0xc9, - 0xa7, 0x14, 0xb1, 0x3d, 0xd8, 0x23, 0x25, 0x92, - 0x30, 0x7a, 0xb8, 0x1e, 0xe9, 0x35, 0x7d, 0x0f, - 0x61, 0x77, 0x5d, 0xb8, 0x08, 0x97, 0xf0, 0xfe, - 0x93, 0xf1, 0xdc, 0xcb, 0x36, 0x2f, 0x3c, 0x40, - 0xde, 0xaf, 0xa5, 0xd4, 0x91, 0x76, 0x08, 0xdf, - 0x67, 0x0c, 0xce, 0xe3, 0xdc, 0x68, 0xba, 0x89, - 0x0e, 0xf0, 0x9d, 0xd5, 0xdf, 0x2d, 0x52, 0xfa, - 0x6a, 0x59, 0xd3, 0x68, 0x78, 0x01, 0x6a, 0x66, - 0xa5, 0x8a, 0x39, 0x2d, 0x7e, 0x66, 0xbf, 0x71, - 0x21, 0x31, 0xa3, 0x3a, 0xff, 0x4d, 0x1d, 0xd5, - 0x68, 0x21, 0x4a, 0x6a, 0x80, 0x77, 0xab, 0x56, - 0xcb, 0x11, 0x43, 0x7c, 0xf4, 0x5e, 0x84, 0x9a, - 0xc5, 0xea, 0x5c, 0x00, 0x2d, 0x94, 0xf4, 0xcb, - 0x05, 0xbe, 0x56, 0x8f, 0x95, 0x62, 0x02, 0xe1, - 0xa8, 0x82, 0xa5, 0x96, 0x3b, 0x3f, 0x36, 0xbf, - 0x41, 0x44, 0x6a, 0xe3, 0x0b, 0xeb, 0x90, 0x81, - 0x32, 0x1a, 0x8e, 0x1d, 0x1e, 0xf4, 0x9a, 0x6e, - 0xcf, 0xf6, 0x7d, 0x1e, 0x25, 0xf7, 0xa6, 0x67, - 0x10, 0xed, 0x3b, 0x95, 0xf5, 0x23, 0xd3, 0xb8, - 0x7e, 0x91, 0x16, 0x10, 0x78, 0x81, 0xbb, 0x7c, - 0x9f, 0x76, 0x17, 0x8a, 0x90, 0x1a, 0x6c, 0x9d, - 0x24, 0x45, 0x58, 0xf2, 0x81, 0x36, 0x53, 0x77, - 0xf4, 0xa6, 0x1f, 0xd2, 0xef, 0x58, 0x19, 0x15, - 0xe4, 0x99, 0x03, 0x4d, 0x1f, 0x96, 0xc0, 0x81, - 0x3c, 0xf2, 0x92, 0x15, 0xca, 0x3c, 0x4e, 0x0f, - 0x96, 0x01, 0xdf, 0xeb, 0x1f, 0x07, 0xec, 0x91, - 0x22, 0x8a, 0x66, 0x15, 0x44, 0x28, 0xf4, 0xeb, - 0x20, 0xb6, 0x1b, 0x8c, 0xbe, 0x06, 0x45, 0x31, - 0x44, 0x4a, 0x5f, 0x9a, 0x2c, 0xac, 0x19, 0x13, - 0x52, 0x10, 0xad, 0xb5, 0x69, 0x23, 0xd8, 0xdf, - 0x41, 0x24, 0x5e, 0x33, 0x8e, 0xc1, 0x6e, 0xd1, - 0x42, 0x18, 0x9d, 0x1c, 0x4e, 0x2b, 0x92, 0x06, - 0x4f, 0x90, 0x63, 0x24, 0x6b, 0xd6, 0x7f, 0x14, - 0x63, 0x66, 0xf1, 0x84, 0xef, 0x3d, 0x92, 0x81, - 0xa2, 0xfb, 0x1b, 0xb5, 0x12, 0x44, 0x45, 0x1d, - 0x0c, 0x78, 0x52, 0x12, 0x80, 0x05, 0xcd, 0x57, - 0xea, 0xd4, 0x65, 0xc8, 0x61, 0x3d, 0x12, 0x5f, - 0x79, 0x32, 0xdc, 0xe4, 0xc2, 0xb2, 0x3e, 0xeb, - 0xcf, 0xed, 0x1c, 0x8d, 0x89, 0x3b, 0xfd, 0x4a, - 0xcd, 0x7b, 0x05, 0xa4, 0xe5, 0xee, 0x90, 0xa0, - 0x33, 0xcd, 0xee, 0x7e, 0xfd, 0xd0, 0xb9, 0x1c, - 0x47, 0x9f, 0x29, 0xa3, 0x60, 0x51, 0x7d, 0x4d, - 0x86, 0x3c, 0x03, 0x73, 0xd7, 0x26, 0x67, 0x6b, - 0x86, 0x0b, 0x29, 0x1e, 0x0d, 0x94, 0x93, 0xc0, - 0x37, 0xf2, 0xc3, 0x65, 0x96, 0x61, 0x40, 0x51, - 0x2a, 0x0f, 0xf3, 0xce, 0xb1, 0x85, 0x03, 0x29, - 0x34, 0x77, 0x37, 0x5a, 0x2c, 0xd3, 0xa5, 0x96, - 0xf9, 0x6e, 0x92, 0xba, 0x78, 0xca, 0xfb, 0x41, - 0x2f, 0x10, 0xee, 0x43, 0xd4, 0x35, 0xfd, 0x00, - 0x8b, 0x99, 0x31, 0xe2, 0x58, 0x40, 0x5a, 0x5c, - 0xc8, 0x20, 0x68, 0x3d, 0x8a, 0x97, 0x58, 0xbb, - 0x86, 0x11, 0x09, 0xeb, 0xe9, 0xd7, 0xf2, 0x71, - 0x3f, 0x45, 0xdc, 0x8f, 0x7e, 0xbe, 0x5b, 0x11, - 0x3b, 0xa2, 0x00, 0x35, 0x94, 0x47, 0xb7, 0x22, - 0xca, 0xae, 0x30, 0x20, 0x10, 0xf7, 0xbb, 0x10, - 0xc1, 0x54, 0xc0, 0x7d, 0xfe, 0xca, 0x17, 0x5e -//}; -//unsigned int sig_revoked1msg0bsn0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked2sha256bsn0msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked2sha256bsn0msg0.inc deleted file mode 100644 index 5dc82aa2a6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked2sha256bsn0msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : verrevoked/bsn0/mprivkey002 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : group x sigrl - */ -//unsigned char sig_revoked2msg0bsn0_dat[] = { - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - 0x8c, 0x10, 0x2f, 0x17, 0xa0, 0xe4, 0x1f, 0xc6, - 0xaa, 0xea, 0xd4, 0x82, 0x67, 0x61, 0x96, 0x47, - 0x9b, 0x46, 0x2c, 0x31, 0xbd, 0x29, 0x62, 0x2d, - 0xd8, 0x40, 0x44, 0xbc, 0x1d, 0xf0, 0x19, 0x02, - 0x4e, 0x4c, 0x2e, 0xc1, 0x0d, 0x43, 0x59, 0x8b, - 0xe0, 0x0d, 0xb4, 0x29, 0x20, 0x35, 0x1f, 0xb6, - 0x00, 0x07, 0xa3, 0xd9, 0x28, 0xd9, 0x48, 0x08, - 0x5e, 0x14, 0xca, 0x56, 0x72, 0xa4, 0xb6, 0x5a, - 0xfb, 0xda, 0x6b, 0x4c, 0xa0, 0xdc, 0xa8, 0x92, - 0x71, 0x65, 0x55, 0xb1, 0xe5, 0x56, 0x06, 0xb6, - 0xb1, 0xb0, 0x88, 0xe8, 0x05, 0xa6, 0x81, 0x1d, - 0x06, 0xb7, 0x88, 0xe8, 0x8d, 0xc3, 0xce, 0xf5, - 0x7a, 0x56, 0x3f, 0xb8, 0xdb, 0x73, 0xbc, 0x41, - 0xa9, 0xd9, 0xb7, 0x1f, 0x23, 0x1f, 0x4d, 0xae, - 0xd1, 0x83, 0x3d, 0xaf, 0xb9, 0x01, 0xfc, 0x94, - 0x4b, 0x06, 0x7b, 0x53, 0x9f, 0xaa, 0x92, 0xac, - 0xc6, 0x8a, 0x89, 0x5b, 0xcc, 0x1d, 0x35, 0x9e, - 0x27, 0xe6, 0x4e, 0x77, 0x02, 0x89, 0x4e, 0xd2, - 0xd7, 0xed, 0xdb, 0x6e, 0xce, 0xb9, 0x3c, 0xc6, - 0x77, 0x3c, 0x18, 0x6c, 0x6f, 0x48, 0x3b, 0xfc, - 0x6e, 0x6c, 0x89, 0xd7, 0x6c, 0xd6, 0xb1, 0x23, - 0xd0, 0x19, 0x58, 0xd4, 0x87, 0xbf, 0x30, 0x3e, - 0x84, 0xe3, 0x47, 0x43, 0xa0, 0xe3, 0xcf, 0x3a, - 0x68, 0x07, 0x46, 0x73, 0x0d, 0x87, 0x5f, 0x1b, - 0x51, 0x31, 0x5a, 0x76, 0xd7, 0x6e, 0x7f, 0x99, - 0x5b, 0xc5, 0x30, 0x76, 0xac, 0xf2, 0x74, 0xbc, - 0x8a, 0xc8, 0x80, 0xc0, 0x22, 0x65, 0xa2, 0x41, - 0x51, 0xde, 0x18, 0x65, 0xc4, 0x02, 0x8f, 0x8e, - 0x19, 0x27, 0xb4, 0x47, 0x18, 0x2c, 0xb6, 0x87, - 0x7e, 0xd6, 0x44, 0x33, 0xaa, 0xa4, 0xed, 0x07, - 0xeb, 0x40, 0xc3, 0x95, 0x60, 0x24, 0x4b, 0x5b, - 0xc9, 0x2b, 0x4d, 0xae, 0x9e, 0x94, 0x6c, 0x07, - 0xb8, 0xd5, 0x2a, 0x3c, 0xa3, 0x39, 0x55, 0x17, - 0xde, 0xee, 0x77, 0x43, 0x63, 0x09, 0xb1, 0xbd, - 0xab, 0x57, 0x08, 0x8e, 0x66, 0xd8, 0xec, 0x23, - 0x10, 0x62, 0x19, 0xb3, 0x4e, 0xa3, 0x55, 0x7b, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0x5d, 0x9b, 0xdc, 0x23, 0x31, 0xbe, 0x5a, 0xbf, - 0x04, 0x51, 0x20, 0xd0, 0xea, 0xb0, 0x3f, 0x13, - 0x12, 0x53, 0x94, 0xdb, 0xa8, 0x11, 0xc7, 0x98, - 0xef, 0x2f, 0x6b, 0xbc, 0xbc, 0x1a, 0x73, 0xa5, - 0x2c, 0xac, 0x63, 0x8d, 0x67, 0x09, 0x65, 0x6d, - 0xe9, 0xc0, 0x2a, 0x61, 0x2d, 0xce, 0xe8, 0xc0, - 0xa2, 0xa4, 0xf5, 0x85, 0xfd, 0x91, 0x70, 0x80, - 0x32, 0xb7, 0xd8, 0x2f, 0x0d, 0x8a, 0x06, 0xc1, - 0x81, 0xe2, 0xee, 0x73, 0xa1, 0x5d, 0xbe, 0xca, - 0xaf, 0xe9, 0x2d, 0x12, 0xd6, 0xdd, 0x0a, 0xc2, - 0xa0, 0x33, 0x09, 0x1f, 0x53, 0x9b, 0x8e, 0xc2, - 0x13, 0x8d, 0x2d, 0x6c, 0xe0, 0xe3, 0x49, 0xd7, - 0xb4, 0xf4, 0xd4, 0xae, 0x7a, 0x5c, 0x19, 0xe2, - 0x68, 0x8a, 0xff, 0xfa, 0x07, 0x2a, 0x9b, 0x64, - 0x9c, 0x14, 0x0d, 0xd5, 0x06, 0xb3, 0xb2, 0x5a, - 0x58, 0x45, 0xd7, 0xe9, 0x22, 0x75, 0x7a, 0x2d, - 0x00, 0xe0, 0x6a, 0xff, 0xbf, 0xad, 0x3f, 0x58, - 0xc6, 0x8a, 0x45, 0x25, 0x9d, 0x97, 0x85, 0x8c, - 0x1c, 0x58, 0xcd, 0xf8, 0x35, 0xbc, 0x87, 0x6b, - 0x71, 0x14, 0xb7, 0x80, 0xba, 0xe8, 0x84, 0x17, - 0x80, 0x32, 0x94, 0x1f, 0x7c, 0xaa, 0xb5, 0xd4, - 0x8a, 0xe8, 0xa4, 0xe0, 0x55, 0xaf, 0x16, 0x4a, - 0xcf, 0xa0, 0x32, 0xc5, 0xd0, 0xc6, 0x22, 0xd9, - 0x5f, 0x08, 0x0f, 0xe5, 0x7c, 0x43, 0xc6, 0x2e, - 0x79, 0x82, 0x33, 0x67, 0xdd, 0xd9, 0xb4, 0xda, - 0x2b, 0x7e, 0x36, 0x5d, 0x2c, 0x6a, 0xaf, 0x5d, - 0xe9, 0x45, 0xa0, 0xc8, 0x2b, 0x8d, 0x0b, 0xa4, - 0xb3, 0x79, 0x87, 0xd4, 0xe6, 0x37, 0xed, 0xfa, - 0x87, 0x7a, 0x3d, 0x8e, 0xa7, 0x1f, 0xdd, 0xa7, - 0xe3, 0x71, 0x9f, 0x6f, 0xe3, 0xb7, 0xc8, 0x50, - 0x1b, 0xfc, 0x74, 0x33, 0x66, 0x0f, 0x2a, 0xff, - 0xd7, 0xbb, 0xbd, 0x0d, 0xed, 0x36, 0x57, 0x4f, - 0x0d, 0x0a, 0x49, 0xe2, 0x29, 0xd3, 0x23, 0xfc, - 0x3e, 0x70, 0x04, 0x4b, 0x45, 0x35, 0xa7, 0xe9, - 0x11, 0x26, 0x0a, 0xbd, 0xf6, 0x78, 0x8b, 0xf1, - 0x7a, 0x9e, 0x69, 0xff, 0xcb, 0x5f, 0x6d, 0x76, - 0x3e, 0xc0, 0xd9, 0xf4, 0x02, 0xf6, 0x62, 0xc5, - 0x11, 0x62, 0x9e, 0xcb, 0xc8, 0xc4, 0x42, 0x2b, - 0x01, 0xcb, 0xc5, 0x5a, 0x54, 0x7c, 0xd0, 0x9e, - 0xa4, 0x59, 0xc7, 0x3d, 0x22, 0x13, 0xb4, 0x0e, - 0x1a, 0xfc, 0xaa, 0x9d, 0xc1, 0x45, 0x74, 0xd0, - 0xe3, 0xec, 0xf4, 0xc4, 0x38, 0x7e, 0x7d, 0xb6, - 0xe0, 0xee, 0x3a, 0x3f, 0x9b, 0x89, 0xaa, 0x01, - 0x17, 0xc3, 0xfe, 0xe7, 0x3d, 0x45, 0x24, 0x3d, - 0x69, 0xd2, 0xed, 0x3d, 0x68, 0xd7, 0xca, 0x4a, - 0xe4, 0x7f, 0x17, 0xfb, 0x78, 0x84, 0x41, 0xd0, - 0x26, 0x36, 0xf2, 0x52, 0x57, 0x73, 0xce, 0xa1, - 0x0f, 0x77, 0x06, 0x8e, 0xdf, 0x3a, 0x55, 0x94, - 0x9b, 0xf7, 0xf4, 0xc6, 0x2d, 0x77, 0x93, 0x77, - 0xc3, 0x88, 0xc1, 0x11, 0x0a, 0x99, 0xf7, 0x56, - 0xfd, 0x0b, 0xbc, 0x1e, 0xd8, 0x55, 0x6f, 0xc7, - 0x48, 0x60, 0xa4, 0x2d, 0x6b, 0x47, 0x12, 0x2e, - 0x23, 0x07, 0x71, 0x53, 0x64, 0x2c, 0xbe, 0xb2, - 0xde, 0xcb, 0xf7, 0xe3, 0x19, 0x18, 0xf8, 0x8f, - 0x10, 0xd6, 0xfd, 0x44, 0xbe, 0x7b, 0x0e, 0xe6, - 0x8b, 0xca, 0xf1, 0x36, 0xaa, 0x8d, 0xac, 0x7e, - 0x1e, 0x3b, 0x13, 0xee, 0x4a, 0xaf, 0x87, 0xf5, - 0xf0, 0x25, 0xce, 0x5b, 0xf5, 0x4a, 0x3a, 0xa4, - 0x71, 0x2e, 0x53, 0x74, 0xa9, 0xbe, 0x49, 0x97, - 0xab, 0x49, 0xca, 0x73, 0x47, 0x59, 0x41, 0xde -//}; -//unsigned int sig_revoked2msg0bsn0_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl.inc deleted file mode 100644 index df8d6bd618..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 verifier revocation list - * Group : grpX - * Bsn : "bsn0" - * Revoked : verrevoked/mprivatekey000 - * verrevoked/mprivatekey001 - * verrevoked/mprivatekey002 - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - -// B - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - -// version | n4 - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - - 0x8b, 0xc9, 0x6e, 0xc0, 0x86, 0x04, 0x6f, 0x6c, - 0x89, 0xc2, 0x27, 0xfd, 0x61, 0x59, 0xb5, 0xd2, - 0x73, 0x96, 0xfa, 0xd6, 0xf8, 0xfa, 0x2c, 0x39, - 0xfe, 0xee, 0xef, 0x3e, 0x73, 0xd2, 0x38, 0x3f, - 0x3c, 0x04, 0x07, 0x78, 0xfd, 0x32, 0x9b, 0xc3, - 0x74, 0x90, 0xf2, 0xf5, 0x50, 0xe4, 0x69, 0x5d, - 0x30, 0x0c, 0x6a, 0x8a, 0x9c, 0xcf, 0xff, 0x78, - 0x28, 0x52, 0x6d, 0x20, 0x29, 0xef, 0x2d, 0x7a, - - 0x07, 0x46, 0xed, 0xb8, 0x6a, 0x4e, 0x7f, 0x4b, - 0x9d, 0xcc, 0x18, 0x91, 0x88, 0xf6, 0x76, 0x4d, - 0x74, 0x02, 0x36, 0x62, 0xe6, 0xd4, 0xb5, 0xf0, - 0x2d, 0x70, 0x91, 0x49, 0x65, 0xdf, 0x19, 0x02, - 0x30, 0x6c, 0x11, 0xaa, 0x74, 0x8c, 0x55, 0x2e, - 0x4b, 0xa3, 0x00, 0x00, 0xb0, 0x38, 0xf4, 0xcd, - 0x5d, 0xc9, 0x1d, 0xaa, 0x1e, 0x44, 0x98, 0xa4, - 0xe1, 0x3f, 0x2f, 0x4f, 0x6c, 0xc9, 0x15, 0xb0, - - 0x8c, 0x10, 0x2f, 0x17, 0xa0, 0xe4, 0x1f, 0xc6, - 0xaa, 0xea, 0xd4, 0x82, 0x67, 0x61, 0x96, 0x47, - 0x9b, 0x46, 0x2c, 0x31, 0xbd, 0x29, 0x62, 0x2d, - 0xd8, 0x40, 0x44, 0xbc, 0x1d, 0xf0, 0x19, 0x02, - 0x4e, 0x4c, 0x2e, 0xc1, 0x0d, 0x43, 0x59, 0x8b, - 0xe0, 0x0d, 0xb4, 0x29, 0x20, 0x35, 0x1f, 0xb6, - 0x00, 0x07, 0xa3, 0xd9, 0x28, 0xd9, 0x48, 0x08, - 0x5e, 0x14, 0xca, 0x56, 0x72, 0xa4, 0xb6, 0x5a, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl_1entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl_1entry.inc deleted file mode 100644 index 538d6637d5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn0/verrl_1entry.inc +++ /dev/null @@ -1,50 +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 Test data. - * - * Type : Intel(R) EPID 2.0 verifier revocation list - * Group : grpX - * Bsn : "bsn0" - * Revoked : verrevoked/mprivatekey000 - * verrevoked/mprivatekey001 - * verrevoked/mprivatekey002 - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - -// B - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, - 0x5f, 0x20, 0xbd, 0x9e, 0x49, 0x11, 0x31, 0xe0, - 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, - 0x64, 0x60, 0xa4, 0xf8, 0x17, 0x81, 0xc3, 0x0a, - 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, - 0x72, 0xdc, 0xe6, 0x78, 0xe3, 0x70, 0xa8, 0x28, - -// version | n4 - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - - 0x8b, 0xc9, 0x6e, 0xc0, 0x86, 0x04, 0x6f, 0x6c, - 0x89, 0xc2, 0x27, 0xfd, 0x61, 0x59, 0xb5, 0xd2, - 0x73, 0x96, 0xfa, 0xd6, 0xf8, 0xfa, 0x2c, 0x39, - 0xfe, 0xee, 0xef, 0x3e, 0x73, 0xd2, 0x38, 0x3f, - 0x3c, 0x04, 0x07, 0x78, 0xfd, 0x32, 0x9b, 0xc3, - 0x74, 0x90, 0xf2, 0xf5, 0x50, 0xe4, 0x69, 0x5d, - 0x30, 0x0c, 0x6a, 0x8a, 0x9c, 0xcf, 0xff, 0x78, - 0x28, 0x52, 0x6d, 0x20, 0x29, 0xef, 0x2d, 0x7a, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey003.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey003.inc deleted file mode 100644 index 3009049dbd..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey003.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember003 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey003_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xdd, 0x5d, 0x03, 0xfb, 0xd2, 0x60, 0x36, 0xbc, - 0x5c, 0x16, 0xea, 0x9c, 0xd3, 0x47, 0x66, 0xec, - 0xc0, 0x71, 0x8b, 0xf8, 0x8e, 0x1c, 0xfb, 0x5b, - 0xaf, 0x60, 0x59, 0x78, 0xd0, 0x60, 0xde, 0x20, - 0xb3, 0x5c, 0x59, 0xb3, 0x29, 0x2e, 0x71, 0xbc, - 0x6d, 0xe9, 0x9d, 0xb5, 0x18, 0xce, 0xfb, 0x44, - 0x0f, 0x79, 0xf7, 0xb5, 0x45, 0x4d, 0xcd, 0x6b, - 0x6b, 0x42, 0x6b, 0x09, 0x38, 0x1e, 0xca, 0x30, - 0x6b, 0xda, 0xf8, 0xef, 0xef, 0x20, 0x38, 0x5a, - 0x30, 0xd3, 0xb8, 0x01, 0x0a, 0x3e, 0x76, 0x1e, - 0xaa, 0x60, 0x64, 0x43, 0x7c, 0x68, 0xcc, 0xfc, - 0xaf, 0x94, 0x4b, 0x61, 0x00, 0x54, 0x08, 0xa9, - 0x15, 0xa3, 0x46, 0xeb, 0x8d, 0x36, 0xcc, 0x1e, - 0x4c, 0x00, 0xe5, 0x71, 0xef, 0xea, 0xb2, 0x6a, - 0x7a, 0x1e, 0xba, 0x98, 0x68, 0x58, 0xd3, 0x02, - 0x98, 0xdd, 0x9b, 0xd1, 0x9c, 0x8e, 0x98, 0xec -//}; -//unsigned int mprivkey003_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey004.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey004.inc deleted file mode 100644 index 253228e91e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey004.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember004 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey004_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0xe9, 0x8d, 0x15, 0x88, 0xd4, 0x83, 0xc0, 0x70, - 0x60, 0xa8, 0xce, 0x0f, 0x13, 0x03, 0x4b, 0xc8, - 0x8d, 0xec, 0x33, 0xc0, 0x85, 0x1e, 0x3c, 0x69, - 0x6f, 0x87, 0x79, 0x51, 0x95, 0xe6, 0x1b, 0x35, - 0xf6, 0x15, 0x84, 0x40, 0x00, 0x91, 0xc8, 0x6c, - 0x67, 0xd0, 0x64, 0xd9, 0x1a, 0x45, 0xbb, 0x12, - 0x4f, 0xb1, 0xfd, 0x09, 0x8c, 0x1c, 0x8d, 0x5e, - 0xee, 0x8d, 0x69, 0x4f, 0x83, 0x19, 0x68, 0x0c, - 0x6e, 0xfe, 0xc2, 0x46, 0x89, 0xef, 0x6d, 0x26, - 0x7d, 0xd2, 0xd4, 0x6f, 0x05, 0xc2, 0x6e, 0x51, - 0x04, 0x2c, 0x6c, 0x7a, 0xfb, 0x5b, 0x25, 0x71, - 0x46, 0x39, 0xff, 0x88, 0x6d, 0xea, 0x16, 0x9a, - 0x90, 0x18, 0x15, 0xdd, 0x12, 0x04, 0x86, 0xba, - 0x8c, 0xfb, 0x41, 0x5f, 0x9f, 0xc8, 0x36, 0x4f, - 0xd5, 0x44, 0xa8, 0xdc, 0x16, 0x1f, 0xd2, 0x3a, - 0x30, 0x4b, 0xb3, 0xfa, 0xbf, 0x57, 0x46, 0xe2 -//}; -//unsigned int mprivkey004_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey005.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey005.inc deleted file mode 100644 index 0bf76c8ec6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/mprivkey005.inc +++ /dev/null @@ -1,45 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Member private key - * Group : grpX - * Signer : verrevokedmember005 (revoked in grpX bsn0 verrl) - */ - -//unsigned char mprivkey005_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x0c, 0x1e, 0x00, 0x97, 0x9e, 0xc0, 0x35, 0xfb, - 0x1d, 0xca, 0x18, 0xb5, 0xef, 0x29, 0x5c, 0x04, - 0xe1, 0xcc, 0xec, 0x37, 0x6e, 0x5b, 0x45, 0x23, - 0xf6, 0xb2, 0xf4, 0x34, 0x36, 0x19, 0x6c, 0xc1, - 0x0c, 0xb4, 0x29, 0xa6, 0xe0, 0x1d, 0x53, 0x3a, - 0xdd, 0xeb, 0xcb, 0x72, 0x2c, 0x76, 0x75, 0x99, - 0x67, 0xc7, 0x4f, 0xf9, 0x8f, 0x37, 0x6f, 0x49, - 0x0a, 0xe3, 0xe6, 0xa3, 0x0b, 0xfb, 0xb7, 0xfc, - 0xe5, 0x36, 0x11, 0x6d, 0x5d, 0xc1, 0x8b, 0x72, - 0x75, 0xc6, 0x1d, 0xe3, 0x5a, 0x98, 0x77, 0x20, - 0xcd, 0x27, 0xb7, 0x26, 0xfb, 0x7f, 0xfc, 0x94, - 0x35, 0x58, 0xfc, 0x3f, 0x35, 0x87, 0x32, 0x05, - 0x77, 0x1c, 0x5b, 0xc0, 0xc7, 0xe5, 0x00, 0xa2, - 0x47, 0xd2, 0x0a, 0x67, 0xa7, 0x1b, 0x15, 0x0c, - 0xc6, 0xb9, 0x7a, 0xd2, 0xad, 0x55, 0x58, 0x8d, - 0x7f, 0xa9, 0x6e, 0x44, 0x57, 0xc2, 0x5f, 0xe8 -//}; -//unsigned int mprivkey005_dat_len = 144; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/sig_revoked3sha256bsn1msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/sig_revoked3sha256bsn1msg0.inc deleted file mode 100644 index 25a00f85e8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/sig_revoked3sha256bsn1msg0.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : grpX - * Signer : verrevoked/bsn1/mprivkey003 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn1" - * SigRl : group x sigrl - */ -//unsigned char sig_revoked3msg0bsn1_dat[] = { - 0x4b, 0xb3, 0x62, 0x6c, 0xa5, 0x12, 0xaa, 0x7a, - 0x22, 0x7f, 0xde, 0xf0, 0x8f, 0x1e, 0x3c, 0xc8, - 0xda, 0x5f, 0x2f, 0x6d, 0x3b, 0xd0, 0x42, 0xec, - 0x62, 0xbf, 0x3c, 0x0f, 0xae, 0xd4, 0xf9, 0xa0, - 0x56, 0xc9, 0xd5, 0x33, 0xaa, 0x60, 0xab, 0x86, - 0x15, 0x48, 0xc2, 0xbb, 0xda, 0x3f, 0x37, 0x71, - 0x3e, 0xf2, 0xd5, 0x3c, 0xd3, 0xb9, 0x08, 0xa0, - 0x63, 0x26, 0x6e, 0x26, 0xca, 0x93, 0xc1, 0xe1, - 0x5a, 0x6b, 0xd9, 0x27, 0x3a, 0x6e, 0x51, 0xd6, - 0xe4, 0xc0, 0x83, 0xa7, 0x2d, 0xab, 0xd4, 0x57, - 0x07, 0xf3, 0xaa, 0xb2, 0xac, 0xbf, 0x21, 0x46, - 0x2e, 0xba, 0x8c, 0xc6, 0xb9, 0x6c, 0xcd, 0xbb, - 0xc0, 0x94, 0x3b, 0x1b, 0x45, 0xa9, 0x0a, 0x64, - 0x3e, 0x2c, 0x92, 0x02, 0x69, 0xfb, 0x72, 0x9b, - 0xe6, 0xf9, 0x06, 0x82, 0x01, 0x01, 0x43, 0x19, - 0xca, 0xea, 0x70, 0x01, 0x51, 0xae, 0x91, 0xad, - 0x1c, 0x6f, 0x78, 0x8c, 0xfd, 0x47, 0xdc, 0xb2, - 0xaa, 0xa4, 0x85, 0x1b, 0xb4, 0xa1, 0x2e, 0xcd, - 0x17, 0xad, 0x60, 0x11, 0x85, 0x01, 0x97, 0xe6, - 0x73, 0xd3, 0x19, 0x1b, 0x92, 0xb5, 0xd8, 0x75, - 0xf0, 0x26, 0x11, 0x44, 0xef, 0x03, 0x69, 0x39, - 0xb3, 0x00, 0xdc, 0x18, 0x79, 0xaf, 0x7a, 0x2c, - 0xc7, 0xdf, 0x26, 0xdb, 0x48, 0xb3, 0x39, 0x1f, - 0x5f, 0x29, 0xda, 0x3e, 0x43, 0x7f, 0xf3, 0x8e, - 0x81, 0x8c, 0x56, 0x3a, 0xec, 0xc8, 0xb8, 0x7c, - 0x53, 0xfc, 0x14, 0x8e, 0x84, 0x68, 0xff, 0x17, - 0x3d, 0x0c, 0x97, 0x42, 0xf7, 0x42, 0x09, 0xa5, - 0xcf, 0x5d, 0x29, 0x1b, 0xdb, 0x97, 0x32, 0xb1, - 0x39, 0x42, 0x66, 0xe2, 0x7b, 0x24, 0x47, 0x61, - 0xf3, 0x0b, 0x2a, 0x84, 0x74, 0xd4, 0xb0, 0x1b, - 0x88, 0x93, 0xc0, 0xa7, 0xf3, 0x6d, 0x28, 0x17, - 0x46, 0x15, 0xd9, 0x32, 0x86, 0xf2, 0x9a, 0x56, - 0xfa, 0x72, 0xf7, 0xa0, 0x60, 0x75, 0xb0, 0x40, - 0x76, 0x7c, 0xe4, 0x7f, 0x97, 0xd6, 0xc2, 0x1d, - 0x1e, 0xaf, 0xd8, 0xaf, 0x32, 0xeb, 0x7b, 0x2c, - 0xc1, 0x45, 0xcc, 0xe1, 0xec, 0x2c, 0xe5, 0x46, - 0x09, 0x60, 0x12, 0xd7, 0xae, 0xa1, 0xa4, 0xf0, - 0x4d, 0x46, 0xd6, 0x6d, 0x79, 0xba, 0x34, 0x37, - 0x5d, 0xc5, 0x3b, 0x2c, 0xba, 0x88, 0x7b, 0xf4, - 0xf6, 0xbe, 0x47, 0x18, 0x60, 0xb5, 0x47, 0xfc, - 0x1e, 0xaf, 0xf8, 0xaf, 0x71, 0x94, 0xe5, 0xeb, - 0xf2, 0x68, 0xc0, 0x73, 0x16, 0xdf, 0x6d, 0x1f, - 0x7e, 0x25, 0x1f, 0x17, 0x96, 0x6f, 0x93, 0x26, - 0xb4, 0x56, 0x63, 0xe7, 0x45, 0x7f, 0x33, 0xc6, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - 0xeb, 0xcf, 0x05, 0xca, 0xa9, 0x85, 0xed, 0xc1, - 0x61, 0xd4, 0x73, 0xe8, 0xd9, 0xe3, 0x9a, 0xee, - 0x9e, 0x3c, 0x9e, 0x2a, 0x9e, 0x9f, 0xc8, 0x83, - 0x3a, 0x31, 0x92, 0xf0, 0x46, 0x57, 0xb9, 0x9e, - 0xab, 0xfe, 0xee, 0xdd, 0x1c, 0x63, 0x24, 0x5a, - 0x97, 0x61, 0xa6, 0x76, 0x5b, 0xa4, 0x03, 0x70, - 0x65, 0xc5, 0x2b, 0x97, 0x5b, 0xce, 0x97, 0x90, - 0xdb, 0x55, 0x90, 0xb1, 0x1d, 0x3c, 0xf4, 0x2e, - 0xf7, 0x3b, 0x1c, 0x29, 0xd4, 0x80, 0x07, 0x19, - 0x68, 0x04, 0x65, 0x7c, 0x35, 0x43, 0x71, 0x19, - 0xe9, 0x32, 0x03, 0x1f, 0xa5, 0xf7, 0x99, 0x32, - 0x0b, 0xa8, 0xe4, 0xf0, 0x63, 0xb9, 0x1a, 0x79, - 0x4f, 0x82, 0xe2, 0xab, 0x2c, 0xb3, 0xb0, 0xff, - 0x33, 0xdc, 0xa9, 0xaf, 0x52, 0x2c, 0x16, 0x3d, - 0xf3, 0x49, 0x17, 0xd4, 0xaf, 0xf3, 0xbe, 0x51, - 0xca, 0xa8, 0x46, 0xf6, 0x15, 0xac, 0xea, 0x99, - 0x71, 0x37, 0xd5, 0x12, 0x57, 0xf0, 0xa1, 0x75, - 0xe5, 0x87, 0xe3, 0x42, 0xbc, 0xc5, 0xbb, 0xcf, - 0x7a, 0x53, 0xca, 0x9d, 0xd0, 0xb7, 0x15, 0x29, - 0x72, 0xfc, 0x75, 0x97, 0x55, 0x0b, 0xbf, 0xc7, - 0x6d, 0x54, 0x7a, 0x47, 0x0e, 0xb9, 0x30, 0xe1, - 0xf1, 0x0e, 0x98, 0x96, 0x33, 0x0f, 0x86, 0xbf, - 0x95, 0xf9, 0xa0, 0x74, 0x16, 0xbb, 0x64, 0xa0, - 0x4c, 0x91, 0x01, 0x9c, 0xa6, 0x17, 0x25, 0xab, - 0xe5, 0x87, 0xcb, 0x9b, 0x47, 0x10, 0x2d, 0x69, - 0xb8, 0x50, 0x67, 0x59, 0x26, 0xfe, 0xf5, 0x02, - 0x64, 0x82, 0x5e, 0xcd, 0x8e, 0x32, 0x0b, 0x5d, - 0x81, 0x65, 0x20, 0x9c, 0xd7, 0x6a, 0x46, 0xdd, - 0xb4, 0x86, 0xf9, 0x39, 0x20, 0xc7, 0xd8, 0x1a, - 0x29, 0xf2, 0xc6, 0x46, 0x7d, 0x08, 0xcc, 0x2e, - 0xba, 0xe4, 0x36, 0x0e, 0x52, 0xb3, 0xa8, 0xdf, - 0x25, 0xcd, 0x68, 0x5e, 0xeb, 0xb6, 0x4a, 0xd1, - 0xc9, 0x15, 0xef, 0x47, 0x0a, 0x5b, 0xeb, 0xf5, - 0xd2, 0xc4, 0x00, 0xc9, 0x43, 0x00, 0xe2, 0xba, - 0xca, 0xf4, 0x71, 0xbc, 0x39, 0xe5, 0x68, 0x8a, - 0x1a, 0x48, 0xc6, 0x71, 0x34, 0xaf, 0x75, 0x6d, - 0xdc, 0xb2, 0x3c, 0xd3, 0x31, 0x21, 0xd0, 0xd0, - 0x00, 0x2a, 0xa1, 0x5d, 0xe4, 0xc8, 0x8c, 0x86, - 0x07, 0x55, 0x2d, 0x2d, 0x8f, 0x94, 0x55, 0x05, - 0xd8, 0x2d, 0x4f, 0x26, 0xfe, 0x54, 0x88, 0xb0, - 0xac, 0xbd, 0xfc, 0x20, 0x13, 0xe8, 0x63, 0xf0, - 0x22, 0x17, 0x56, 0x6f, 0x3d, 0xe4, 0xc4, 0x08, - 0x28, 0xe5, 0x5b, 0x58, 0xed, 0x59, 0xf5, 0xe4, - 0x14, 0xf5, 0x10, 0xf6, 0x75, 0x3c, 0xe4, 0xaf, - 0xdf, 0xb2, 0x47, 0xa8, 0xb5, 0xc5, 0x25, 0x5a, - 0x5e, 0xeb, 0x03, 0x06, 0x18, 0x27, 0xfe, 0x96, - 0x92, 0x0b, 0x83, 0x7e, 0x23, 0x54, 0x7f, 0x87, - 0x1e, 0xfc, 0x63, 0x40, 0xab, 0xf0, 0xc7, 0x6a, - 0x64, 0x31, 0xed, 0xaf, 0xab, 0xbd, 0xbc, 0xa9, - 0x40, 0xf6, 0xde, 0xf5, 0xdd, 0x92, 0x98, 0xd4, - 0xb1, 0xa0, 0xe2, 0x13, 0x55, 0x05, 0x65, 0xb8, - 0x2c, 0x5f, 0x7e, 0xd3, 0x3f, 0xb6, 0xf4, 0x9b, - 0x3c, 0x2c, 0x1a, 0xc3, 0x30, 0x21, 0x15, 0xcc, - 0x98, 0x41, 0x01, 0x05, 0xa6, 0x9a, 0x2a, 0xd8, - 0x38, 0xd8, 0x55, 0x3f, 0xb7, 0x62, 0xaf, 0x36, - 0xc3, 0xc7, 0x0a, 0x16, 0x17, 0x98, 0x5c, 0xe5, - 0x57, 0x10, 0x6b, 0xdd, 0x1d, 0x9b, 0xb6, 0x40, - 0x85, 0xe5, 0xc1, 0xb0, 0x97, 0x8c, 0xbf, 0x31, - 0x54, 0x73, 0x62, 0xef, 0xa0, 0x05, 0x49, 0xf0, - 0xb0, 0xe7, 0x11, 0x1d, 0xf7, 0xae, 0x17, 0x1d -//}; -//unsigned int sig_revoked3msg0bsn1_dat_len = 840; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl.inc deleted file mode 100644 index 16c961641b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 verifier revocation list - * Group : grpX - * Bsn : "bsn1" - * Revoked : verrevoked/mprivatekey003 - * verrevoked/mprivatekey004 - * verrevoked/mprivatekey005 - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - -// B - 0x4b, 0xb3, 0x62, 0x6c, 0xa5, 0x12, 0xaa, 0x7a, - 0x22, 0x7f, 0xde, 0xf0, 0x8f, 0x1e, 0x3c, 0xc8, - 0xda, 0x5f, 0x2f, 0x6d, 0x3b, 0xd0, 0x42, 0xec, - 0x62, 0xbf, 0x3c, 0x0f, 0xae, 0xd4, 0xf9, 0xa0, - 0x56, 0xc9, 0xd5, 0x33, 0xaa, 0x60, 0xab, 0x86, - 0x15, 0x48, 0xc2, 0xbb, 0xda, 0x3f, 0x37, 0x71, - 0x3e, 0xf2, 0xd5, 0x3c, 0xd3, 0xb9, 0x08, 0xa0, - 0x63, 0x26, 0x6e, 0x26, 0xca, 0x93, 0xc1, 0xe1, - -// version | n4 - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - - 0x5a, 0x6b, 0xd9, 0x27, 0x3a, 0x6e, 0x51, 0xd6, - 0xe4, 0xc0, 0x83, 0xa7, 0x2d, 0xab, 0xd4, 0x57, - 0x07, 0xf3, 0xaa, 0xb2, 0xac, 0xbf, 0x21, 0x46, - 0x2e, 0xba, 0x8c, 0xc6, 0xb9, 0x6c, 0xcd, 0xbb, - 0xc0, 0x94, 0x3b, 0x1b, 0x45, 0xa9, 0x0a, 0x64, - 0x3e, 0x2c, 0x92, 0x02, 0x69, 0xfb, 0x72, 0x9b, - 0xe6, 0xf9, 0x06, 0x82, 0x01, 0x01, 0x43, 0x19, - 0xca, 0xea, 0x70, 0x01, 0x51, 0xae, 0x91, 0xad, - 0x5d, 0xb7, 0x24, 0xf8, 0xbc, 0xff, 0x55, 0x1a, - - 0x34, 0xd9, 0x4d, 0xf5, 0xa8, 0x13, 0x4c, 0x41, - 0x3c, 0x52, 0x9c, 0xde, 0x8b, 0x08, 0x9d, 0x3a, - 0xa0, 0xc9, 0xe9, 0xd6, 0x33, 0x9c, 0x05, 0x43, - 0x8c, 0x78, 0x63, 0xaf, 0x6d, 0x64, 0x5a, 0x0e, - 0x36, 0xce, 0xc4, 0xba, 0x94, 0xf9, 0x2f, 0xa9, - 0xce, 0x81, 0xea, 0xa9, 0x2a, 0xe4, 0x4d, 0x6b, - 0xec, 0xd3, 0xdd, 0xe1, 0x8b, 0x82, 0x1a, 0x54, - 0xeb, 0x23, 0x56, 0x4b, 0xb1, 0xe5, 0xa4, 0x25, - - 0x34, 0x89, 0xd7, 0x46, 0xb8, 0xcb, 0xed, 0xa1, - 0x1c, 0x92, 0xa9, 0xfd, 0x57, 0x56, 0xdf, 0x62, - 0x2e, 0x7d, 0x31, 0x44, 0x4a, 0x7d, 0xa2, 0x29, - 0x07, 0x1e, 0x51, 0xcc, 0x89, 0x8e, 0xee, 0xc4, - 0xda, 0x34, 0x93, 0x0f, 0x6a, 0xd0, 0x7b, 0x17, - 0x06, 0x78, 0x84, 0x37, 0x59, 0x5c, 0xcc, 0xa3, - 0x84, 0xb2, 0x95, 0x15, 0x5a, 0x58, 0xbe, 0x1f, - 0xe4, 0x21, 0x01, 0x39, 0xba, 0x27, 0x3e, 0xc8, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl_012revoked.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl_012revoked.inc deleted file mode 100644 index 906f5d7d1b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_x/verrevoked/bsn1/verrl_012revoked.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 verifier revocation list - * Group : grpX - * Bsn : "bsn1" - * Revoked : verrevoked/mprivatekey000 - * verrevoked/mprivatekey001 - * verrevoked/mprivatekey002 - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - -// B - 0x4b, 0xb3, 0x62, 0x6c, 0xa5, 0x12, 0xaa, 0x7a, - 0x22, 0x7f, 0xde, 0xf0, 0x8f, 0x1e, 0x3c, 0xc8, - 0xda, 0x5f, 0x2f, 0x6d, 0x3b, 0xd0, 0x42, 0xec, - 0x62, 0xbf, 0x3c, 0x0f, 0xae, 0xd4, 0xf9, 0xa0, - 0x56, 0xc9, 0xd5, 0x33, 0xaa, 0x60, 0xab, 0x86, - 0x15, 0x48, 0xc2, 0xbb, 0xda, 0x3f, 0x37, 0x71, - 0x3e, 0xf2, 0xd5, 0x3c, 0xd3, 0xb9, 0x08, 0xa0, - 0x63, 0x26, 0x6e, 0x26, 0xca, 0x93, 0xc1, 0xe1, - -// version | n4 - 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, - - 0x8b, 0xc9, 0x6e, 0xc0, 0x86, 0x04, 0x6f, 0x6c, - 0x89, 0xc2, 0x27, 0xfd, 0x61, 0x59, 0xb5, 0xd2, - 0x73, 0x96, 0xfa, 0xd6, 0xf8, 0xfa, 0x2c, 0x39, - 0xfe, 0xee, 0xef, 0x3e, 0x73, 0xd2, 0x38, 0x3f, - 0x3c, 0x04, 0x07, 0x78, 0xfd, 0x32, 0x9b, 0xc3, - 0x74, 0x90, 0xf2, 0xf5, 0x50, 0xe4, 0x69, 0x5d, - 0x30, 0x0c, 0x6a, 0x8a, 0x9c, 0xcf, 0xff, 0x78, - 0x28, 0x52, 0x6d, 0x20, 0x29, 0xef, 0x2d, 0x7a, - - 0x07, 0x46, 0xed, 0xb8, 0x6a, 0x4e, 0x7f, 0x4b, - 0x9d, 0xcc, 0x18, 0x91, 0x88, 0xf6, 0x76, 0x4d, - 0x74, 0x02, 0x36, 0x62, 0xe6, 0xd4, 0xb5, 0xf0, - 0x2d, 0x70, 0x91, 0x49, 0x65, 0xdf, 0x19, 0x02, - 0x30, 0x6c, 0x11, 0xaa, 0x74, 0x8c, 0x55, 0x2e, - 0x4b, 0xa3, 0x00, 0x00, 0xb0, 0x38, 0xf4, 0xcd, - 0x5d, 0xc9, 0x1d, 0xaa, 0x1e, 0x44, 0x98, 0xa4, - 0xe1, 0x3f, 0x2f, 0x4f, 0x6c, 0xc9, 0x15, 0xb0, - - 0x8c, 0x10, 0x2f, 0x17, 0xa0, 0xe4, 0x1f, 0xc6, - 0xaa, 0xea, 0xd4, 0x82, 0x67, 0x61, 0x96, 0x47, - 0x9b, 0x46, 0x2c, 0x31, 0xbd, 0x29, 0x62, 0x2d, - 0xd8, 0x40, 0x44, 0xbc, 0x1d, 0xf0, 0x19, 0x02, - 0x4e, 0x4c, 0x2e, 0xc1, 0x0d, 0x43, 0x59, 0x8b, - 0xe0, 0x0d, 0xb4, 0x29, 0x20, 0x35, 0x1f, 0xb6, - 0x00, 0x07, 0xa3, 0xd9, 0x28, 0xd9, 0x48, 0x08, - 0x5e, 0x14, 0xca, 0x56, 0x72, 0xa4, 0xb6, 0x5a, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.dat b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.dat deleted file mode 100644 index 9c0f0a4c0d..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.inc deleted file mode 100644 index c1fc635d16..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/cmember9/cmpprivkey.inc +++ /dev/null @@ -1,36 +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 Test data. - * - * Type : Intel(R) EPID 2.0 compressed private key - * Group : grpY - * Signer : member9 - */ -//unsigned char cmpprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, - 0x27, 0x8d, 0x99, 0x27, 0x35, 0x78, 0x6d, 0xf6, - 0x24, 0xdc, 0x18, 0x4d, 0xc0, 0xd5, 0x2c, 0xde, - 0x0d, 0xb1, 0x2c, 0x26, 0x6f, 0x02, 0xae, 0x41, - 0x80, 0xc2, 0xab, 0x2a, 0xa9, 0xd8, 0x3a, 0xbc, - 0x1d, 0x41, 0xca, 0x59, 0x4f, 0x40, 0xfe, 0x20, - 0x59, 0x1e, 0xdb, 0x28, 0x5a, 0x23, 0x6b, 0xce, - 0x21, 0x27, 0x66, 0xa2, 0x05, 0x97, 0xb7, 0x8d, - 0x27, 0xd8, 0x9d, 0xca, 0x37, 0x7d, 0x77, 0x30 -//}; -//unsigned int cmpprivkey_dat_len = 80; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/iprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/iprivkey.inc deleted file mode 100644 index d5444a83f5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/iprivkey.inc +++ /dev/null @@ -1,32 +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 Test data. - * - * Type : Intel(R) EPID 2.0 issuing private key - * Group : grpY - */ - -//unsigned char iprivkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, - 0x77, 0x65, 0xc8, 0xd0, 0x47, 0x53, 0x1e, 0xab, - 0x30, 0x57, 0x01, 0x49, 0x51, 0x26, 0xbf, 0xa2, - 0x00, 0xa4, 0x67, 0x12, 0x7a, 0x70, 0x40, 0x29, - 0x32, 0x95, 0x0d, 0x37, 0x6a, 0x53, 0xd7, 0x9e -//}; -//unsigned int iprivkey_dat_len = 48; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/pubkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/pubkey.inc deleted file mode 100644 index 592241af83..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grp_y/pubkey.inc +++ /dev/null @@ -1,59 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group public key - * Group : grpY - */ -//unsigned char pubkey_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, - 0x8f, 0x23, 0xda, 0x77, 0xed, 0xda, 0x2f, 0x0b, - 0x5b, 0xe8, 0x99, 0x6b, 0xf4, 0x52, 0x09, 0x5b, - 0xf2, 0x00, 0x77, 0x4e, 0xea, 0x44, 0x58, 0x4e, - 0x1c, 0x5c, 0xd6, 0x02, 0x77, 0xea, 0x99, 0x2f, - 0x75, 0xef, 0x33, 0xd6, 0x83, 0xe0, 0xc4, 0xdb, - 0x57, 0x48, 0x69, 0x27, 0xad, 0x69, 0xe5, 0x05, - 0xef, 0xda, 0xaa, 0x0e, 0xef, 0x41, 0xc5, 0x09, - 0xcd, 0x3e, 0x27, 0xb9, 0xce, 0x80, 0x28, 0xc9, - 0x76, 0x9d, 0x10, 0x18, 0x26, 0xa3, 0x51, 0xe8, - 0x3e, 0x3c, 0xb6, 0x29, 0xaa, 0x57, 0x84, 0x68, - 0x2f, 0x75, 0xc8, 0x51, 0xd4, 0xab, 0xed, 0x76, - 0x87, 0xb8, 0xbf, 0xf2, 0x14, 0x2f, 0xd2, 0x1e, - 0x18, 0xc8, 0x6a, 0xe1, 0xf4, 0xaf, 0xec, 0x47, - 0xe7, 0x00, 0xea, 0x18, 0x8e, 0xcf, 0x05, 0xdb, - 0x46, 0x78, 0xf5, 0xd8, 0xe7, 0xa8, 0x08, 0x5c, - 0xa1, 0xcb, 0x12, 0x14, 0x73, 0x74, 0x75, 0x35, - 0x09, 0x3b, 0x39, 0x52, 0x02, 0xa1, 0xbf, 0xcf, - 0x0b, 0xb0, 0x77, 0xc6, 0x9d, 0x3e, 0x50, 0x67, - 0x7d, 0x36, 0x9a, 0xb6, 0x84, 0x62, 0xd4, 0x09, - 0x6c, 0xef, 0xd7, 0x11, 0xce, 0x64, 0xf4, 0xe2, - 0x79, 0x58, 0x3c, 0x7a, 0x96, 0x2a, 0x8f, 0xaa, - 0x0f, 0xe1, 0x1a, 0xbd, 0x3a, 0x50, 0x1c, 0x29, - 0x24, 0x0d, 0xe7, 0xfc, 0xb5, 0xf4, 0x02, 0xaf, - 0x5e, 0xb0, 0xda, 0x52, 0x23, 0x40, 0x33, 0x2c, - 0xcf, 0xf9, 0xda, 0xf7, 0x38, 0x9a, 0xd3, 0x0f, - 0x69, 0x38, 0xec, 0x77, 0xd0, 0xe0, 0x30, 0x8a, - 0x66, 0x03, 0x5c, 0xd0, 0x05, 0x03, 0x87, 0xe6, - 0x5d, 0xef, 0x86, 0xe7, 0xf6, 0x8b, 0x04, 0xf8, - 0x30, 0x28, 0x9d, 0x22, 0xe6, 0xee, 0x40, 0x48, - 0x46, 0x5a, 0x2b, 0xff, 0xf2, 0xd4, 0x70, 0xf8, - 0x7e, 0x91, 0xea, 0x51, 0xac, 0x0b, 0xbd, 0xfc, - 0xe1, 0x91, 0xe1, 0x37, 0xb8, 0x11, 0xce, 0x6e -//}; -//unsigned int pubkey_dat_len = 272; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl.inc deleted file mode 100644 index 3968e0dbe7..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list - * Group : grpX - */ -//unsigned char grprl_dat[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -//}; -//unsigned int grprl_dat_len = 8; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_first_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_first_entry.inc deleted file mode 100644 index 5cad583bbf..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_first_entry.inc +++ /dev/null @@ -1,31 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list grpX revoked first entry - */ -//unsigned char grprl_dat[] = { - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x67, 0x56, 0x34, 0x21 -//}; -//unsigned int grprl_dat_len = 56; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_last_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_last_entry.inc deleted file mode 100644 index 0c9dcadb27..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_last_entry.inc +++ /dev/null @@ -1,31 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list grpX revoked last entry - */ -//unsigned char grprl_dat[] = { - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x67, 0x56, 0x34, 0x21, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, -//}; -//unsigned int grprl_dat_len = 56; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_middle_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_middle_entry.inc deleted file mode 100644 index 258273ef43..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_revoked_grp_x_middle_entry.inc +++ /dev/null @@ -1,31 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list grpX revoked middle entry - */ -//unsigned char grprl_dat[] = { - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, - 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x67, 0x56, 0x34, 0x21 -//}; -//unsigned int grprl_dat_len = 56; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_single_entry_revoked_grp_x.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_single_entry_revoked_grp_x.inc deleted file mode 100644 index 17573e48ec..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/grprl_single_entry_revoked_grp_x.inc +++ /dev/null @@ -1,27 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list single entry grpX revoked - */ -//unsigned char grprl_dat[] = { - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xee -//}; -//unsigned int grprl_dat_len = 24; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprecomp.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprecomp.inc deleted file mode 100644 index 219579787f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprecomp.inc +++ /dev/null @@ -1,106 +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 Test data. - * - * Type : Intel(R) EPID 2.0 member precomp - * Group : GroupA - * Member : 0 - * Issuer : Ikgf - */ - 0xbc, 0x74, 0xd9, 0xd2, 0xcc, 0x56, 0x28, 0xfd, 0x3d, 0x0b, 0x2b, 0x86, - 0xf4, 0xc6, 0xb2, 0x25, 0x19, 0x6b, 0x5b, 0x42, 0x35, 0x6a, 0xd9, 0x9c, - 0xf9, 0xb4, 0x30, 0xcb, 0xff, 0x39, 0xbb, 0x92, 0x41, 0x71, 0xf4, 0x49, - 0xc3, 0xfd, 0x36, 0xa3, 0xe0, 0xdd, 0x83, 0xf1, 0x34, 0x53, 0x2e, 0x16, - 0x2f, 0x45, 0x06, 0x10, 0x3d, 0x9a, 0xfd, 0x22, 0xb8, 0xf1, 0xfd, 0x52, - 0x3a, 0x24, 0xc5, 0x9c, 0xdd, 0x54, 0x9c, 0xff, 0xb0, 0x4d, 0xb9, 0xe5, - 0x21, 0x62, 0x61, 0xaa, 0x76, 0xc3, 0xc1, 0x25, 0x47, 0xe4, 0x3b, 0x62, - 0xab, 0x5f, 0x2c, 0x56, 0xe1, 0x24, 0x9c, 0x21, 0xec, 0x6b, 0x1d, 0x80, - 0x1d, 0xca, 0xc5, 0x45, 0x34, 0xee, 0x4e, 0xc6, 0x20, 0x94, 0x14, 0x98, - 0x0e, 0xd6, 0x88, 0x1d, 0x69, 0xfd, 0x25, 0xd3, 0xe3, 0x08, 0x3f, 0x62, - 0x82, 0xa9, 0xf2, 0x13, 0xd6, 0x54, 0xda, 0x12, 0xec, 0x4e, 0xd2, 0x92, - 0xe1, 0x82, 0x3f, 0x54, 0xf8, 0xc7, 0x0e, 0x21, 0x90, 0x49, 0xa1, 0x73, - 0xa2, 0x03, 0xd0, 0xc7, 0x1c, 0xc2, 0x36, 0x1f, 0xb5, 0x8e, 0x22, 0xaf, - 0xb5, 0x96, 0xad, 0xba, 0xde, 0xe6, 0x45, 0xb9, 0xee, 0x39, 0x74, 0x53, - 0x62, 0x68, 0xa6, 0x37, 0x33, 0x65, 0x47, 0x3b, 0xf2, 0xa3, 0x35, 0xd0, - 0xe9, 0x50, 0x49, 0x68, 0x23, 0x9a, 0xa0, 0x33, 0x66, 0x2f, 0x84, 0x23, - 0x43, 0x95, 0x35, 0xea, 0x1d, 0xfe, 0x3a, 0xe4, 0x45, 0x6f, 0xad, 0x86, - 0x7a, 0x4b, 0xf8, 0xb7, 0x32, 0xaf, 0x79, 0x7c, 0x45, 0x8d, 0xd9, 0x36, - 0x0d, 0x66, 0xcb, 0x47, 0x07, 0xf4, 0x75, 0xae, 0x38, 0xe1, 0x32, 0x67, - 0x80, 0x73, 0x0b, 0x98, 0xb7, 0x8d, 0xa3, 0x03, 0x94, 0x59, 0x0c, 0x04, - 0xa8, 0x3e, 0xf8, 0x39, 0xc9, 0x25, 0x74, 0xb5, 0x9c, 0x62, 0x79, 0xb9, - 0xf0, 0x20, 0x0b, 0x41, 0xb1, 0x76, 0x2a, 0x93, 0x15, 0xfa, 0x7a, 0x55, - 0xe4, 0x50, 0xf3, 0xe1, 0x54, 0xf8, 0x9e, 0x42, 0x84, 0xaf, 0xb6, 0xc2, - 0x2e, 0x98, 0xd5, 0xfd, 0x31, 0xe4, 0x16, 0x2b, 0x4d, 0x32, 0x96, 0x04, - 0x4f, 0xca, 0x8b, 0x8d, 0x3c, 0x24, 0xb4, 0xc3, 0x86, 0x3b, 0x06, 0xc9, - 0x45, 0xc9, 0xb1, 0x90, 0xac, 0xc3, 0xd6, 0xec, 0x80, 0x5b, 0x84, 0xcb, - 0x5e, 0x7b, 0xc4, 0xcb, 0x63, 0x9e, 0xca, 0x09, 0x92, 0xca, 0x70, 0xfd, - 0x24, 0x2a, 0x81, 0x37, 0x5a, 0x85, 0x72, 0x4a, 0x46, 0x2d, 0x29, 0x38, - 0x8f, 0xc3, 0x59, 0xc7, 0xe9, 0x76, 0x24, 0xea, 0xd4, 0xef, 0x06, 0x12, - 0xf5, 0xab, 0xab, 0xa1, 0x59, 0x13, 0xc8, 0x1d, 0xdf, 0x0f, 0x41, 0xbe, - 0x98, 0x65, 0x00, 0x11, 0x41, 0x7c, 0x6e, 0x29, 0x83, 0x73, 0xfd, 0x81, - 0xff, 0xe8, 0xd8, 0x7f, 0xa1, 0x00, 0x62, 0x11, 0x14, 0x38, 0x06, 0x57, - 0x20, 0x81, 0xaa, 0x9e, 0xaf, 0xfe, 0xee, 0x68, 0xee, 0x30, 0x1a, 0x83, - 0xe7, 0x32, 0xc3, 0xfc, 0x69, 0xe5, 0x19, 0x29, 0x4e, 0xee, 0xb0, 0xf1, - 0x63, 0xaf, 0x41, 0x3d, 0x3b, 0xb9, 0xbb, 0x2e, 0xde, 0xd7, 0x0b, 0xbe, - 0x11, 0x8f, 0x4a, 0x94, 0x4c, 0x57, 0xf3, 0x64, 0x38, 0x5a, 0xc6, 0xb8, - 0x5d, 0xa1, 0x9d, 0xc8, 0xfa, 0x32, 0xe2, 0x08, 0xf4, 0x26, 0x3f, 0x75, - 0xb5, 0x35, 0x9a, 0xe9, 0xd6, 0x1d, 0x35, 0x41, 0x9b, 0x20, 0x2b, 0x54, - 0xb9, 0x66, 0x6c, 0xc6, 0xb7, 0x44, 0x82, 0x9b, 0x74, 0xe8, 0x09, 0x04, - 0xa4, 0xf2, 0x7a, 0x8f, 0xe8, 0x6f, 0x3c, 0xa0, 0x18, 0xab, 0x66, 0xf6, - 0x39, 0x34, 0x70, 0xf3, 0xa6, 0xd3, 0xc9, 0xe1, 0x97, 0xe2, 0xdc, 0x4d, - 0xca, 0x02, 0xb6, 0x73, 0x07, 0xf3, 0x8c, 0xd0, 0xab, 0xd9, 0x12, 0x45, - 0x70, 0x7c, 0x3a, 0x24, 0x64, 0xce, 0x9e, 0x38, 0x4d, 0x5d, 0xe1, 0x9d, - 0xf2, 0x4b, 0x58, 0xdc, 0x71, 0xb3, 0x61, 0x56, 0x14, 0x62, 0x2a, 0x1b, - 0x36, 0x5e, 0xc9, 0x15, 0xf3, 0x50, 0xe6, 0xc0, 0x93, 0x62, 0xd0, 0x69, - 0xab, 0xd4, 0xe5, 0x9b, 0xa6, 0xa7, 0xa3, 0x0c, 0x51, 0xad, 0xf7, 0x38, - 0x6f, 0x1d, 0xcf, 0x43, 0xda, 0x83, 0x95, 0xc6, 0xfb, 0xd8, 0x90, 0x5e, - 0x35, 0x30, 0x0b, 0x7b, 0x45, 0xd0, 0x12, 0x32, 0x95, 0xc3, 0x96, 0xdc, - 0x0a, 0x68, 0xcc, 0xcf, 0x19, 0x0b, 0x13, 0xc7, 0x6a, 0x7a, 0x53, 0x36, - 0x5b, 0x24, 0xc5, 0x84, 0x5c, 0xeb, 0x9e, 0xeb, 0xdc, 0x91, 0x17, 0xb3, - 0x29, 0xfd, 0xee, 0x55, 0xc9, 0x8c, 0xcd, 0xbe, 0x3a, 0x66, 0xf3, 0xba, - 0x79, 0xfe, 0xc7, 0xf8, 0x08, 0xeb, 0xd2, 0x3a, 0x17, 0x3c, 0x36, 0x29, - 0xc1, 0xde, 0xa9, 0xab, 0x80, 0xdb, 0x6c, 0xdd, 0xfb, 0xe5, 0xb1, 0x12, - 0x25, 0x2f, 0xa3, 0x3d, 0x0e, 0x72, 0xde, 0xaf, 0x86, 0x93, 0x35, 0x18, - 0x96, 0x19, 0x47, 0xfd, 0x8f, 0xae, 0x7b, 0xe7, 0xac, 0x6e, 0x53, 0x10, - 0x1e, 0x66, 0x54, 0xc0, 0x36, 0x0e, 0x73, 0x35, 0xb3, 0x20, 0xf9, 0xaa, - 0x25, 0x4a, 0x66, 0xaf, 0xc9, 0x2f, 0xd1, 0x19, 0x8b, 0x8f, 0x93, 0xbe, - 0x3a, 0x30, 0xa5, 0x24, 0xc2, 0xad, 0x30, 0xfc, 0x97, 0xfe, 0x6c, 0xe0, - 0x7f, 0x98, 0x71, 0x37, 0x33, 0x26, 0xc3, 0x75, 0xc8, 0x51, 0xe6, 0xf2, - 0x99, 0xf0, 0x0f, 0x7d, 0x5d, 0x12, 0x26, 0x9d, 0x96, 0xeb, 0xd5, 0x08, - 0x28, 0x34, 0x90, 0x1c, 0xdb, 0x98, 0xbd, 0x8a, 0xeb, 0x93, 0x0d, 0xd0, - 0x57, 0x3e, 0xb8, 0x65, 0xdd, 0xa6, 0xa9, 0x81, 0xd6, 0xca, 0x62, 0x4b, - 0x24, 0xed, 0xf4, 0x36, 0xf0, 0x83, 0xd6, 0x0e, 0x53, 0xf2, 0x50, 0x89, - 0x70, 0x23, 0x19, 0x7b, 0xd0, 0x7e, 0x67, 0xa3, 0x45, 0x72, 0x9d, 0x11, - 0xbe, 0xbb, 0xe1, 0x72, 0x51, 0xf6, 0x5f, 0x4e, 0x2c, 0xca, 0x61, 0x3d, - 0xaa, 0xfd, 0xb7, 0x61, 0xbc, 0x3a, 0xd2, 0x20, 0x18, 0xa2, 0xee, 0x04, - 0xe4, 0x6b, 0xf3, 0x84, 0x26, 0xc2, 0x43, 0xa4, 0xfe, 0x4e, 0x14, 0x5c, - 0xbe, 0xe7, 0x11, 0x4a, 0x61, 0x33, 0x7d, 0xeb, 0x71, 0x98, 0x7c, 0xf0, - 0x44, 0xe2, 0x41, 0x17, 0x39, 0xd0, 0x4e, 0xe2, 0x9c, 0xcc, 0x8d, 0x76, - 0x3c, 0xb8, 0x0f, 0x63, 0x4a, 0x56, 0x7c, 0xf8, 0xab, 0xbd, 0x87, 0xcc, - 0xa2, 0x29, 0xb9, 0x3c, 0xcc, 0x12, 0xd2, 0x9d, 0x6f, 0xbd, 0x28, 0xc3, - 0x0c, 0x2f, 0x83, 0x8c, 0xf3, 0xad, 0x3d, 0xc6, 0x92, 0xba, 0x0b, 0x28, - 0x47, 0x81, 0x78, 0xbe, 0x2b, 0xe0, 0x6a, 0x47, 0xba, 0xf3, 0xbe, 0x39, - 0x30, 0x49, 0x0b, 0x35, 0x34, 0x80, 0x70, 0xc2, 0x75, 0x54, 0x65, 0xd8, - 0xc8, 0x1c, 0x26, 0xb8, 0x97, 0x61, 0x57, 0xcf, 0x2d, 0xb8, 0xd1, 0xdd, - 0xb0, 0xf1, 0xa9, 0x0f, 0x3f, 0x7e, 0xfe, 0xd3, 0xee, 0xdc, 0x75, 0xbf, - 0xc2, 0xf1, 0x30, 0xd6, 0x60, 0x1b, 0xcd, 0x7b, 0x87, 0xde, 0x0b, 0x58, - 0x5c, 0xac, 0x84, 0xda, 0xef, 0x86, 0x86, 0x8d, 0x8e, 0xfd, 0x6f, 0x93, - 0x32, 0x8d, 0xac, 0x7b, 0x8f, 0x2a, 0x8a, 0x5f, 0xf1, 0xea, 0xbb, 0x8e, - 0x6d, 0xbf, 0xe0, 0x59, 0x90, 0xc2, 0xd3, 0x3d, 0x8a, 0x03, 0x64, 0x11, - 0xdd, 0xf1, 0xfc, 0x2d, 0x26, 0x8a, 0x6f, 0x39, 0x25, 0xa9, 0xaa, 0x61, - 0x45, 0x5b, 0x7b, 0x36, 0xfd, 0x82, 0xd2, 0x6a, 0x8c, 0x9a, 0xf1, 0xc2 \ No newline at end of file diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprivkey.inc deleted file mode 100644 index 2017fa0dd8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/member0/mprivkey.inc +++ /dev/null @@ -1,36 +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 Test data. - * - * Type : Intel(R) EPID 2.0 member private-key - * Group : GroupA - * Member : 0 - * Issuer : Ikgf - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xca, 0x24, 0x49, 0x67, 0x86, 0x98, 0xfe, 0x05, - 0xd2, 0x66, 0xc5, 0x7c, 0xd2, 0x40, 0xb6, 0xed, 0x4f, 0x76, 0xc0, 0xb8, - 0x08, 0x62, 0x9a, 0x56, 0x46, 0x76, 0x01, 0x40, 0xd8, 0xa3, 0xe1, 0xb8, - 0x2f, 0x83, 0x64, 0x88, 0x99, 0xca, 0xd3, 0x2b, 0xd9, 0x50, 0xfb, 0x74, - 0x8b, 0xa5, 0x32, 0xb8, 0xce, 0x31, 0xd7, 0x56, 0x4b, 0xdd, 0xdd, 0x1c, - 0x0e, 0x5e, 0xba, 0x34, 0x68, 0x66, 0xbc, 0xb6, 0x9c, 0x92, 0xf0, 0x2f, - 0xa2, 0x27, 0x56, 0xc1, 0xef, 0x3a, 0x21, 0x5e, 0x9a, 0x05, 0x13, 0x63, - 0x0e, 0x2f, 0x12, 0xac, 0x95, 0xb9, 0x26, 0x6d, 0x1d, 0xe2, 0xcf, 0x64, - 0x4a, 0x09, 0xdd, 0x4f, 0x15, 0x9d, 0x08, 0x6b, 0x93, 0xbf, 0x95, 0x89, - 0x11, 0xb8, 0x31, 0x11, 0xb1, 0x36, 0x76, 0x4d, 0x0a, 0xbe, 0x5a, 0x42, - 0xe7, 0x44, 0xbb, 0x17, 0x6d, 0x36, 0x7b, 0x80, 0x0b, 0x10, 0x1e, 0xc6 \ No newline at end of file diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/privrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/privrl.inc deleted file mode 100644 index 2b2edc3539..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/privrl.inc +++ /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. - ############################################################################*/ -/*! - * \file - * \brief Test data. - * - * Type : Intel(R) EPID 2.0 private-key based revocation list - * Group : GroupA - * Issuer : iKGF - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x1d, 0x79, 0x15, 0xee, 0xc2, 0x0b, 0x17, 0xc4, - 0xd4, 0xcb, 0x43, 0x3c, 0x5c, 0xad, 0x68, 0x3a, - 0x03, 0x6d, 0xdf, 0xea, 0x78, 0x42, 0x9a, 0xc3, - 0xfc, 0xc9, 0x93, 0xdd, 0x71, 0x44, 0xba, 0xcb, - 0x36, 0xcd, 0x95, 0x0d, 0xa2, 0x77, 0x96, 0x89, - 0x91, 0xca, 0xf6, 0x02, 0xca, 0x20, 0xff, 0x73, - 0x37, 0x97, 0xb1, 0x46, 0x8c, 0xaf, 0x64, 0xb6, - 0x0c, 0x48, 0xa6, 0x3e, 0xbd, 0x92, 0x71, 0xf8, - 0x52, 0x21, 0x71, 0x2b, 0x5a, 0x9f, 0x9d, 0xc9, - 0x44, 0x41, 0x15, 0xa0, 0xd8, 0x39, 0xa9, 0xad, - 0x49, 0x64, 0x68, 0x38, 0xa8, 0xef, 0xa5, 0x95, - 0x14, 0x6a, 0xe2, 0x7d, 0xee, 0x96, 0xae, 0x9e diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/pubkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/pubkey.inc deleted file mode 100644 index 00fabe210e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/pubkey.inc +++ /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 Test data. - * - * Type : Intel(R) EPID 2.0 group public-key - * Group : GroupA - * Issuer : Ikgf - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x45, 0xcb, 0x06, 0x04, 0xb3, 0xf7, 0x23, 0xb2, - 0xd1, 0xd1, 0x0d, 0x4f, 0x51, 0x7b, 0xbb, 0x8f, 0x71, 0x15, 0xd7, 0xf1, - 0xdc, 0x15, 0x37, 0xc8, 0xb8, 0x3d, 0x68, 0x0a, 0x18, 0xa5, 0x34, 0x14, - 0x0c, 0xdc, 0xd9, 0x15, 0x7e, 0xba, 0x56, 0xc5, 0xe5, 0x61, 0xfa, 0x6a, - 0x86, 0xa0, 0xac, 0x6a, 0x81, 0x36, 0x6d, 0x01, 0x5f, 0x86, 0xc0, 0x04, - 0x8b, 0x1e, 0xff, 0x49, 0xd9, 0x37, 0x96, 0x66, 0xf1, 0xc3, 0x16, 0xb5, - 0xc5, 0x1c, 0x67, 0xb6, 0xff, 0x28, 0x23, 0x79, 0x59, 0xea, 0x80, 0xe6, - 0x09, 0x07, 0xe7, 0xd3, 0x38, 0xec, 0xb9, 0x16, 0x83, 0x88, 0xda, 0x64, - 0xdd, 0xc4, 0x9d, 0x6a, 0x5c, 0xb2, 0x1c, 0x88, 0x97, 0xea, 0xaf, 0xa9, - 0xf3, 0x3e, 0x07, 0xea, 0xb6, 0x2a, 0xd5, 0x7a, 0xed, 0x32, 0xd9, 0x3d, - 0x90, 0xd7, 0xb9, 0x91, 0x08, 0x05, 0x9e, 0xe3, 0x22, 0x75, 0x06, 0x35, - 0xe5, 0xc4, 0x77, 0xad, 0x52, 0xb9, 0x7c, 0x04, 0x2d, 0x7e, 0x81, 0xf2, - 0x5d, 0x5d, 0x52, 0x7d, 0xd7, 0x1d, 0x29, 0xfb, 0x6a, 0xa7, 0xbc, 0xb5, - 0xa9, 0x1a, 0xa6, 0xfd, 0x20, 0xea, 0xf2, 0x98, 0xe2, 0x67, 0x33, 0x28, - 0x67, 0x5f, 0xbe, 0x23, 0xa0, 0x43, 0xe8, 0x71, 0xaa, 0xab, 0xf6, 0xf0, - 0x6a, 0x2b, 0x52, 0xa8, 0x61, 0x51, 0x22, 0x44, 0x00, 0x91, 0xd7, 0xf1, - 0x7e, 0x05, 0x48, 0xdc, 0x51, 0x0c, 0xef, 0xa0, 0xf3, 0x72, 0xcd, 0x59, - 0xd4, 0x7a, 0x2a, 0x60, 0xa3, 0x62, 0x54, 0xa8, 0xb6, 0x8f, 0xed, 0x90, - 0xdf, 0x3e, 0x94, 0xe8, 0xa4, 0x89, 0x32, 0xaa, 0x52, 0x5a, 0x97, 0xae, - 0x4c, 0x86, 0xf4, 0xba, 0xec, 0xc6, 0x36, 0x13, 0x87, 0x42, 0x5d, 0x16, - 0x49, 0x12, 0x66, 0xc5, 0xe0, 0xe4, 0x9b, 0xf9, 0x68, 0xaa, 0xa9, 0x95, - 0x81, 0x16, 0x5c, 0xd2, 0xca, 0xd4, 0x2e, 0x61 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_msg0_sha256_sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_msg0_sha256_sigrl.inc deleted file mode 100644 index 0cc91af29a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_msg0_sha256_sigrl.inc +++ /dev/null @@ -1,98 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: groupA - * Issuer : iKGF - * Signer: member0 - * HashAlg: Sha256 - * Message: "msg0" - * Basename: None (random base) - * SigRl: SigRl of group - */ - 0x9e, 0x45, 0x73, 0x32, 0x27, 0x75, 0xb0, 0x65, 0x22, 0xd4, 0x90, 0xbf, - 0x5b, 0xcd, 0x4d, 0xfd, 0xd1, 0x6e, 0xe7, 0xa0, 0x18, 0xe4, 0x3b, 0xdb, - 0x2e, 0xf2, 0xb7, 0x58, 0xfb, 0xa6, 0xb5, 0xc3, 0x22, 0x3c, 0x62, 0x88, - 0x26, 0xc4, 0x20, 0x5f, 0xf2, 0x76, 0x8b, 0xc5, 0x2e, 0x09, 0x4f, 0x4d, - 0xee, 0xd9, 0xc6, 0x87, 0xe8, 0xba, 0xba, 0x51, 0x00, 0x98, 0x3c, 0x37, - 0x26, 0x13, 0x1c, 0x8e, 0x1a, 0x72, 0x0b, 0xd3, 0x26, 0xce, 0xd2, 0x78, - 0x3c, 0xd8, 0x70, 0x4a, 0xa6, 0xd5, 0x44, 0xb9, 0xa5, 0xac, 0x0f, 0x5a, - 0x7a, 0x0e, 0xdf, 0x71, 0xc0, 0xa8, 0xdd, 0x84, 0xf8, 0xc3, 0x4e, 0xfe, - 0x53, 0xdb, 0x54, 0x97, 0x0a, 0x23, 0xbe, 0x80, 0x7f, 0xb8, 0x91, 0x92, - 0x83, 0x30, 0x10, 0x65, 0x62, 0x1c, 0xfa, 0x4b, 0xe5, 0x5c, 0x07, 0xde, - 0x0b, 0x41, 0x3e, 0xf3, 0xcf, 0x8f, 0x24, 0xc9, 0xb6, 0xe5, 0xfb, 0xee, - 0xa6, 0x0e, 0x19, 0x0f, 0xa7, 0x16, 0xcf, 0x7e, 0xac, 0xb6, 0xa2, 0xb7, - 0x57, 0x30, 0x9f, 0x13, 0x84, 0x71, 0x6a, 0x9c, 0x0e, 0x3d, 0x6f, 0x0c, - 0x37, 0xb6, 0xde, 0xdb, 0x15, 0x95, 0x30, 0xe7, 0xba, 0x1f, 0x7e, 0xc7, - 0x1e, 0x3f, 0x02, 0x66, 0x0f, 0xb8, 0x50, 0xd7, 0xcf, 0xde, 0xe1, 0x28, - 0xd1, 0x61, 0x95, 0x4d, 0xfd, 0x6c, 0xd2, 0xb0, 0x39, 0xca, 0xf9, 0xf1, - 0xce, 0x42, 0x8d, 0xe1, 0x67, 0x40, 0x84, 0xe8, 0xef, 0x9c, 0x9b, 0x27, - 0x9f, 0x32, 0x7f, 0x72, 0xb8, 0x15, 0x99, 0xb9, 0xad, 0x02, 0x5b, 0x66, - 0xa7, 0x5f, 0xb6, 0x4d, 0xcc, 0x23, 0x2e, 0xc6, 0xa6, 0x24, 0x9d, 0xf2, - 0x31, 0xfd, 0x5b, 0x7a, 0x9e, 0x62, 0xb6, 0x4e, 0x9a, 0x26, 0xff, 0x92, - 0xd6, 0x2d, 0x59, 0xd4, 0x65, 0xdc, 0x67, 0x58, 0x2e, 0xf4, 0x8b, 0x7e, - 0xd7, 0x5d, 0xc2, 0x8b, 0x24, 0x77, 0xa4, 0x51, 0x67, 0xcb, 0x14, 0x90, - 0x8f, 0xf1, 0xb8, 0xee, 0x85, 0xa5, 0xd8, 0x66, 0x7b, 0xa5, 0x5e, 0xf6, - 0xfa, 0xe2, 0x50, 0xbd, 0x9b, 0xf0, 0xfb, 0xc7, 0x4a, 0xea, 0x95, 0xcf, - 0x27, 0x02, 0x37, 0xa9, 0xec, 0x43, 0xe5, 0xa1, 0xa0, 0x53, 0xf7, 0x2c, - 0x4e, 0xd0, 0x84, 0x7a, 0x56, 0xe7, 0x55, 0x80, 0x91, 0x11, 0x53, 0xb7, - 0xbc, 0xc6, 0x73, 0x1d, 0x7d, 0x24, 0x06, 0x52, 0x5e, 0x86, 0xd4, 0x43, - 0xde, 0xde, 0xe9, 0x95, 0x9f, 0x86, 0x03, 0xcc, 0x2e, 0x0d, 0xec, 0xa0, - 0x1a, 0x5c, 0xe5, 0x93, 0x89, 0xfb, 0x7a, 0x9e, 0x79, 0x4f, 0x85, 0x8e, - 0xe8, 0x91, 0x18, 0x4f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0xcf, 0x8a, 0x04, 0x78, 0x6d, 0xcc, 0x0b, 0xac, 0x42, 0x2e, 0xe3, 0x46, - 0xeb, 0x20, 0xcb, 0x19, 0x64, 0x23, 0x2d, 0xd2, 0xf6, 0xef, 0xa0, 0xf0, - 0xd1, 0xf2, 0x84, 0x53, 0xb3, 0x91, 0xec, 0x3c, 0xa0, 0x1c, 0xb8, 0x66, - 0xb3, 0x6e, 0xb1, 0x2b, 0x72, 0x65, 0x3e, 0x30, 0xfe, 0xef, 0x58, 0xd0, - 0x3b, 0x31, 0x3b, 0xb9, 0x5a, 0x61, 0x26, 0x77, 0xea, 0x87, 0xf3, 0x09, - 0x47, 0xc2, 0x8d, 0x96, 0xb9, 0x05, 0x40, 0xf3, 0x48, 0xe8, 0x1b, 0x71, - 0x39, 0x2f, 0xd3, 0x6f, 0xad, 0x1b, 0x7e, 0x33, 0xd2, 0x8f, 0x5b, 0xf4, - 0x5a, 0xdc, 0x66, 0xcb, 0xd5, 0xcf, 0xc9, 0x91, 0xb6, 0x7a, 0xd8, 0xe4, - 0x81, 0x86, 0xb6, 0x88, 0xc4, 0x59, 0x8e, 0x03, 0x09, 0x8e, 0x29, 0xba, - 0x16, 0x23, 0x84, 0x5f, 0x30, 0x93, 0x13, 0xb4, 0xe9, 0xdf, 0x28, 0x49, - 0xa8, 0x4a, 0xce, 0x69, 0xd1, 0xc6, 0x25, 0x26, 0xf2, 0x5c, 0x4d, 0x0b, - 0xa0, 0x2b, 0xbe, 0xec, 0xb2, 0x09, 0x30, 0x8b, 0xd8, 0xb4, 0x09, 0x68, - 0x01, 0x82, 0x00, 0x9d, 0x65, 0x54, 0x19, 0xf0, 0x4f, 0xd1, 0x4d, 0xe9, - 0x60, 0xcf, 0x8c, 0xab, 0xd3, 0xb6, 0x06, 0xa4, 0x78, 0xea, 0xf1, 0xd0, - 0xba, 0x9f, 0x53, 0x89, 0x9b, 0xdf, 0xc9, 0xe4, 0xf5, 0x7b, 0x98, 0x5f, - 0x41, 0x59, 0x0c, 0x78, 0x71, 0x6b, 0xf9, 0xa8, 0xf1, 0x82, 0x1b, 0xf6, - 0xb1, 0x92, 0xa8, 0xd9, 0xbf, 0x65, 0xe7, 0xf0, 0x3a, 0x05, 0xe1, 0xba, - 0x03, 0xb6, 0xc6, 0x52, 0x0f, 0xb2, 0x6c, 0x5d, 0x70, 0x01, 0x1b, 0x30, - 0x3e, 0x65, 0x28, 0xbd, 0x90, 0xa5, 0x2d, 0x6c, 0xdf, 0xac, 0xe7, 0xa0, - 0xe2, 0x3a, 0xe6, 0x3a, 0xe9, 0xe6, 0x21, 0x5f, 0x27, 0xe4, 0x53, 0x4b, - 0xa2, 0x88, 0x7b, 0x66, 0x42, 0x77, 0x5b, 0x25, 0xe0, 0x76, 0x27, 0xbd, - 0x5b, 0x13, 0x7b, 0x7e, 0x81, 0x92, 0x74, 0xcf, 0xcd, 0x4a, 0xf6, 0x6d, - 0x61, 0xcd, 0x99, 0x4c, 0x54, 0x91, 0x48, 0x6f, 0xb6, 0xf3, 0xb7, 0xde, - 0xf3, 0x75, 0xe9, 0xd6, 0xbb, 0x43, 0x0c, 0xaf, 0x31, 0x76, 0x7f, 0x3c, - 0x87, 0x6e, 0xf8, 0xbe, 0x04, 0x99, 0xf5, 0x00, 0x15, 0x76, 0xc2, 0x0e, - 0x65, 0xfd, 0xe5, 0x26, 0x2d, 0x41, 0x36, 0xca, 0x2d, 0x17, 0xc0, 0x27, - 0xdf, 0xdd, 0xcc, 0xaa, 0x04, 0x96, 0x62, 0x50, 0x43, 0xce, 0x49, 0x86, - 0xb5, 0xf7, 0xd9, 0x11, 0xaf, 0x2c, 0xe5, 0x7c, 0xc8, 0x01, 0x6b, 0xb9, - 0xfe, 0x0c, 0x19, 0x47, 0x3f, 0xac, 0x56, 0x69, 0xb0, 0xb8, 0xd5, 0x5f, - 0x6b, 0xd8, 0xc7, 0x85, 0xd9, 0xe1, 0xc2, 0x85, 0xf8, 0x90, 0xd6, 0xa7, - 0xc9, 0x18, 0xe3, 0x48, 0x8b, 0xc8, 0x61, 0xb5, 0x60, 0x0c, 0x6b, 0x94, - 0xce, 0x0b, 0x00, 0x5e, 0xaf, 0x01, 0xde, 0xfd, 0x68, 0x25, 0x01, 0xef, - 0x4f, 0xa5, 0xe4, 0xeb, 0x96, 0xba, 0x58, 0x50, 0x0b, 0xb1, 0xd1, 0xfa, - 0x2e, 0x3d, 0xc3, 0x5a, 0xc7, 0x68, 0x73, 0x78, 0x36, 0x9b, 0x0b, 0x86, - 0xcf, 0x0b, 0x34, 0x19, 0x35, 0x53, 0x23, 0x12, 0xd7, 0x21, 0xaa, 0xe3, - 0xc0, 0x0b, 0xec, 0xe1, 0xbc, 0x26, 0x0d, 0x70, 0xf6, 0xd0, 0x68, 0xf2, - 0x94, 0x79, 0x37, 0x0a, 0x2e, 0x98, 0xb3, 0x09, 0x97, 0x0f, 0xa3, 0x8e, - 0x40, 0xeb, 0x61, 0xa4, 0x06, 0x19, 0x7f, 0x0a, 0x04, 0x9a, 0x29, 0x9f, - 0xfa, 0xe4, 0x2c, 0x0b, 0xc6, 0xc0, 0xfa, 0x1d, 0xa0, 0x24, 0x7c, 0x58, - 0x8e, 0xce, 0x08, 0x82, 0x14, 0x4c, 0xf0, 0x78, 0x0d, 0x31, 0xdc, 0x97 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0.inc deleted file mode 100644 index 0feea00c7f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0.inc +++ /dev/null @@ -1,58 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : groupA - * Issuer : iKGF - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : SigRl of group - */ - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, 0x5f, 0x20, 0xbd, 0x9e, - 0x49, 0x11, 0x31, 0xe0, 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, 0x64, 0x60, 0xa4, 0xf8, - 0x17, 0x81, 0xc3, 0x0a, 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, 0x72, 0xdc, 0xe6, 0x78, - 0xe3, 0x70, 0xa8, 0x28, 0x1f, 0x63, 0x25, 0xf1, 0xb0, 0x2f, 0x03, 0x92, - 0xc7, 0x15, 0x23, 0x27, 0xd7, 0xb3, 0x16, 0x3f, 0x91, 0x29, 0xa1, 0x72, - 0x1d, 0xb7, 0x74, 0x34, 0xc2, 0xe4, 0x8d, 0x71, 0x4f, 0x43, 0xcd, 0x48, - 0x73, 0x72, 0xaa, 0x7d, 0x58, 0x7a, 0x91, 0x17, 0x42, 0x56, 0x5c, 0xe1, - 0x50, 0x6b, 0x13, 0x39, 0x7a, 0x54, 0x7b, 0x0c, 0xa4, 0xe4, 0xaa, 0xc0, - 0x98, 0x20, 0xb8, 0x29, 0xb3, 0x2f, 0x9b, 0x40, 0xff, 0x48, 0x6b, 0xa5, - 0x8e, 0xdb, 0xe4, 0x31, 0xc8, 0xd2, 0xe7, 0x2a, 0x95, 0xdf, 0x72, 0x86, - 0x79, 0x80, 0x91, 0x1b, 0x73, 0x26, 0x81, 0x3f, 0x06, 0x28, 0x92, 0x46, - 0x4c, 0xa1, 0x41, 0x38, 0xc5, 0x12, 0xe7, 0x51, 0x42, 0x49, 0xe8, 0x41, - 0x28, 0xb4, 0xd1, 0x42, 0xf4, 0xc4, 0x38, 0x13, 0x64, 0x58, 0x13, 0x05, - 0x65, 0xdd, 0x85, 0x76, 0x5a, 0x25, 0xe9, 0x46, 0xfc, 0x19, 0x64, 0x78, - 0xc2, 0xe6, 0x57, 0xba, 0x6b, 0x77, 0xf6, 0x64, 0xea, 0x27, 0x27, 0x9c, - 0x8c, 0x05, 0xc2, 0xb9, 0x23, 0x83, 0xd4, 0xa6, 0x3f, 0x3e, 0x57, 0x43, - 0x8a, 0xa2, 0x2f, 0x9b, 0x2c, 0x82, 0x4c, 0x9c, 0xd0, 0x8a, 0xfa, 0x4b, - 0xf3, 0x49, 0x5e, 0x84, 0x53, 0x69, 0x92, 0xbc, 0xb1, 0xfd, 0xd2, 0x88, - 0x46, 0x71, 0x16, 0x71, 0xe0, 0x97, 0x81, 0x36, 0x70, 0xc5, 0x0f, 0xd6, - 0x00, 0x64, 0x53, 0x81, 0xe7, 0x56, 0xc4, 0x56, 0xf7, 0xeb, 0x84, 0x72, - 0xb0, 0xd8, 0x52, 0x61, 0x9c, 0xfb, 0xc9, 0x4f, 0x90, 0x94, 0xf8, 0x6a, - 0x90, 0xf4, 0x0a, 0xaa, 0x54, 0xf5, 0xb4, 0xd6, 0xde, 0xfb, 0xa7, 0x5c, - 0xf7, 0xe6, 0xb7, 0x55, 0xa1, 0x07, 0x19, 0x3c, 0x32, 0xfb, 0x09, 0xa0, - 0x54, 0x20, 0xba, 0x73, 0x2a, 0xed, 0xea, 0x91, 0xc6, 0x62, 0x64, 0x48, - 0x6c, 0x91, 0x4b, 0x0e, 0xd1, 0x1e, 0x20, 0x4c, 0x4b, 0x13, 0x9f, 0xe1, - 0x9f, 0x0a, 0x84, 0x41, 0x4b, 0x29, 0xb8, 0x90, 0x46, 0x09, 0x00, 0xde, - 0x48, 0xd2, 0xb9, 0x8a, 0x6f, 0x61, 0xd3, 0x1e, 0xc4, 0x7b, 0x59, 0x16, - 0xa6, 0xc4, 0x4a, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0_revkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0_revkey.inc deleted file mode 100644 index c3f1160bcb..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0_revkey.inc +++ /dev/null @@ -1,61 +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 Test data for revoked privrl. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : groupA - * Issuer : iKGF - * Signer : privrevokedmember0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : SigRl of group - */ - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, 0x5f, 0x20, 0xbd, 0x9e, - 0x49, 0x11, 0x31, 0xe0, 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, 0x64, 0x60, 0xa4, 0xf8, - 0x17, 0x81, 0xc3, 0x0a, 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, 0x72, 0xdc, 0xe6, 0x78, - 0xe3, 0x70, 0xa8, 0x28, 0xc8, 0x0b, 0x3e, 0xdf, 0xfc, 0xde, 0x52, 0xee, - 0xf7, 0xe7, 0xe7, 0x01, 0x85, 0xda, 0xef, 0x3f, 0xdb, 0x54, 0x46, 0x8f, - 0xdf, 0x78, 0x57, 0x38, 0x5a, 0x7c, 0x96, 0xcd, 0x44, 0x04, 0x95, 0x97, - 0xc8, 0x6c, 0xc7, 0x58, 0x5f, 0xbb, 0x9a, 0xcf, 0xb1, 0x78, 0xae, 0xef, - 0x65, 0xd6, 0xe0, 0xdb, 0x4f, 0xd5, 0x66, 0x93, 0x7c, 0xe6, 0x02, 0x2a, - 0x28, 0x45, 0x6f, 0x40, 0x8f, 0xe2, 0x5b, 0x29, 0x8b, 0x54, 0x37, 0xe9, - 0xee, 0xc8, 0x3e, 0x57, 0x3f, 0xd8, 0x80, 0xb2, 0x95, 0x97, 0xa2, 0x13, - 0x21, 0xf4, 0x5c, 0xbd, 0x44, 0xd3, 0x3e, 0x43, 0xb9, 0x23, 0xe9, 0xdd, - 0xd5, 0x9b, 0x88, 0xd3, 0xda, 0x1e, 0x17, 0x00, 0x1b, 0x00, 0x6e, 0x52, - 0xde, 0xb2, 0xa5, 0xbd, 0x9b, 0x32, 0xee, 0x9b, 0x9e, 0x75, 0x14, 0xe8, - 0x0e, 0xcb, 0xfc, 0x38, 0x44, 0x99, 0x08, 0x66, 0xc6, 0x66, 0xe0, 0x4f, - 0xf2, 0xac, 0x26, 0x16, 0x6f, 0x4a, 0xd9, 0x49, 0xad, 0x1e, 0x59, 0x6c, - 0xd3, 0x50, 0x3c, 0xb4, 0x55, 0xe4, 0xa3, 0x5f, 0xfb, 0x5b, 0xc5, 0xcd, - 0x7f, 0xc1, 0x2d, 0x17, 0xad, 0xde, 0x6e, 0x76, 0x3a, 0x87, 0x40, 0xc4, - 0xb9, 0xd9, 0xef, 0x13, 0x2f, 0x70, 0x77, 0x0d, 0xff, 0xf0, 0x1a, 0x08, - 0x36, 0xd3, 0xb9, 0xec, 0x13, 0x93, 0x96, 0x7a, 0x8f, 0x3a, 0x07, 0xe2, - 0xaa, 0x51, 0x89, 0x75, 0xa9, 0x6a, 0xe0, 0xef, 0x35, 0xf7, 0x59, 0xa4, - 0x08, 0xf0, 0xf8, 0x0b, 0x83, 0xda, 0xfd, 0x15, 0xb7, 0x9b, 0xb6, 0x70, - 0x61, 0xe9, 0xd1, 0x67, 0xae, 0x33, 0x65, 0x92, 0x3a, 0x1e, 0x6a, 0x9f, - 0x76, 0xa4, 0x7a, 0xf2, 0xe9, 0xd9, 0x79, 0x19, 0x88, 0xb4, 0x98, 0x20, - 0xbb, 0x75, 0x02, 0x3c, 0xc7, 0x28, 0x7b, 0x9d, 0xde, 0xf1, 0xac, 0x04, - 0xef, 0x64, 0xe4, 0xf9, 0xc0, 0x6d, 0x9e, 0xbc, 0x2e, 0x5c, 0x0b, 0x2a, - 0x80, 0x03, 0xb7, 0xdf, 0x22, 0xcf, 0xe0, 0x7d, 0x7f, 0xc9, 0x08, 0x61, - 0x87, 0xea, 0x28, 0xf4, 0xec, 0xd2, 0x07, 0x9b, 0x47, 0x39, 0x34, 0x0e, - 0xda, 0x29, 0x8a, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - - - diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_rndbase_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_rndbase_msg0.inc deleted file mode 100644 index d8a19f2438..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sha256_rndbase_msg0.inc +++ /dev/null @@ -1,98 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : groupA - * Signer : member0 - * Issuer : iKGF - * HashAlg : Sha256 - * Message : "msg0" - * Basename: None (random base) - * SigRl : SigRl of group - */ - 0xa9, 0x4b, 0x40, 0x3c, 0xdb, 0x6b, 0x14, 0xec, 0x93, 0x51, 0x6e, 0x2a, - 0x44, 0x81, 0xa5, 0x92, 0x96, 0x03, 0x2c, 0x77, 0x20, 0x41, 0xad, 0x10, - 0xce, 0xe1, 0xe9, 0xab, 0xcb, 0x3f, 0x6b, 0xbe, 0x65, 0xa1, 0xe6, 0xa9, - 0x27, 0xbb, 0x2d, 0x44, 0x63, 0xf2, 0xf9, 0x81, 0xf3, 0x19, 0x57, 0x4d, - 0xb8, 0xd0, 0x47, 0xd2, 0xaf, 0x4c, 0xa9, 0x64, 0xfd, 0xfc, 0xc4, 0x48, - 0x13, 0x61, 0xd2, 0xfe, 0x60, 0x50, 0xdd, 0xe4, 0x96, 0xfc, 0x39, 0x57, - 0x5f, 0xbd, 0xa5, 0x18, 0x21, 0x5a, 0x12, 0x42, 0x03, 0xdd, 0xb3, 0xb3, - 0xc5, 0xc4, 0x1b, 0x9a, 0xb8, 0x31, 0x4f, 0xd2, 0x3d, 0x71, 0x6f, 0x46, - 0x8d, 0x2a, 0x85, 0x12, 0x0d, 0x88, 0xeb, 0xee, 0x27, 0xa6, 0xd5, 0x75, - 0x82, 0x09, 0x66, 0xf5, 0xab, 0x9e, 0x92, 0xeb, 0x58, 0xce, 0x8b, 0x5c, - 0x67, 0x75, 0x0e, 0x5f, 0xd2, 0x22, 0xcb, 0x92, 0x2f, 0x8a, 0xc5, 0x4a, - 0x2d, 0x9b, 0x6f, 0x9a, 0x39, 0x91, 0x9a, 0xc2, 0x9b, 0x89, 0x91, 0x6b, - 0xdd, 0x5c, 0xc9, 0x66, 0xcb, 0xf7, 0x58, 0xa8, 0x2b, 0x6d, 0xb8, 0x2b, - 0xe0, 0x39, 0xec, 0x95, 0x0e, 0x4c, 0x3b, 0x74, 0x39, 0x34, 0x1b, 0xd8, - 0x8c, 0xe7, 0xf5, 0x3b, 0xdb, 0xba, 0xd2, 0xc7, 0xee, 0x65, 0x90, 0xcf, - 0xcb, 0x65, 0x52, 0x3b, 0x2a, 0xc4, 0x05, 0x5a, 0x72, 0xd2, 0xbb, 0xdd, - 0x8e, 0x3b, 0x2a, 0x02, 0xec, 0xec, 0x36, 0x37, 0xb5, 0x44, 0x1a, 0x9a, - 0xee, 0x8b, 0x49, 0x37, 0xc6, 0x4a, 0x7e, 0x7e, 0xa1, 0x8c, 0x57, 0x3f, - 0x8b, 0xec, 0xd5, 0x29, 0xee, 0x2a, 0xf9, 0x95, 0x52, 0xe1, 0xde, 0x8a, - 0xd5, 0xcd, 0xfe, 0x68, 0x4b, 0xe8, 0x4f, 0xd4, 0x4f, 0x02, 0xdd, 0x0f, - 0xe1, 0x22, 0xe7, 0x95, 0xfb, 0xc4, 0x7c, 0x8a, 0xa6, 0x82, 0x72, 0xd2, - 0x43, 0x88, 0x9e, 0x67, 0xd9, 0xa5, 0x04, 0x2a, 0x71, 0x24, 0x02, 0x52, - 0x6c, 0x67, 0x6c, 0xa3, 0xfd, 0x47, 0xf2, 0xcc, 0x0c, 0xbd, 0x81, 0x2b, - 0x16, 0x84, 0x90, 0x35, 0x44, 0xcf, 0x75, 0xf5, 0xc1, 0xd7, 0x63, 0x89, - 0x65, 0x2f, 0xec, 0x61, 0xa2, 0xad, 0x10, 0x77, 0x95, 0xb8, 0x21, 0xf2, - 0x7c, 0x36, 0x56, 0x24, 0x99, 0xf0, 0x27, 0x11, 0x02, 0x03, 0x31, 0x32, - 0xee, 0x86, 0x71, 0x06, 0xd3, 0xfd, 0xe7, 0xc7, 0x6d, 0x30, 0xbe, 0x39, - 0x07, 0xa5, 0xd0, 0x2d, 0xb3, 0x00, 0x1c, 0x8c, 0x4e, 0x74, 0xdc, 0x07, - 0xd3, 0x60, 0x95, 0xc1, 0x2c, 0xaa, 0x93, 0x67, 0xb3, 0x8d, 0x42, 0x2e, - 0x6d, 0x22, 0x50, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0xe7, 0x2a, 0x73, 0x9d, 0xc0, 0x60, 0x48, 0xed, 0xf1, 0xef, 0x0a, 0x93, - 0xf7, 0x12, 0x70, 0x39, 0xb5, 0x54, 0x5b, 0xc9, 0x8d, 0xc5, 0x6a, 0x48, - 0xd3, 0xc1, 0xe9, 0xef, 0x77, 0x7b, 0x16, 0x3d, 0x54, 0x35, 0xca, 0xbb, - 0xa0, 0x71, 0x69, 0x69, 0xfc, 0x81, 0x5c, 0x29, 0x7d, 0x55, 0x7c, 0x99, - 0x2a, 0xfc, 0xd6, 0x08, 0xed, 0xdd, 0xe0, 0x35, 0x29, 0x7d, 0xe6, 0xb5, - 0x45, 0x60, 0xb7, 0x34, 0x7b, 0xeb, 0x1a, 0xb7, 0x03, 0x41, 0xdd, 0x89, - 0xaa, 0x4d, 0xdf, 0x34, 0x1e, 0xc1, 0xb8, 0xd4, 0x26, 0xc9, 0xdb, 0x38, - 0x78, 0x1c, 0x20, 0x88, 0x78, 0x4a, 0x0e, 0xe5, 0x65, 0x20, 0x54, 0xab, - 0xc9, 0x61, 0x85, 0x02, 0x24, 0x36, 0x79, 0xbe, 0xea, 0xc7, 0x6b, 0x6e, - 0x2f, 0x3c, 0xea, 0x78, 0x38, 0x89, 0xb6, 0x88, 0x07, 0xdd, 0xb1, 0x2f, - 0xda, 0x20, 0x48, 0x91, 0x34, 0x05, 0x0e, 0x70, 0xe7, 0x96, 0x67, 0x40, - 0xa4, 0xda, 0xa0, 0xfb, 0x88, 0x2d, 0x8b, 0x49, 0x40, 0xa6, 0x42, 0x81, - 0xf6, 0x2e, 0x23, 0xe8, 0x10, 0x03, 0x46, 0x0e, 0x77, 0x4a, 0x53, 0xab, - 0xdc, 0xd2, 0x39, 0x9c, 0x27, 0xd8, 0x61, 0x7c, 0x58, 0x1f, 0xf1, 0x31, - 0xd7, 0x0c, 0x38, 0xa7, 0xd3, 0x23, 0x5b, 0x22, 0xb8, 0x25, 0xb9, 0x43, - 0x78, 0xe6, 0xd8, 0xcc, 0x00, 0x8e, 0xf1, 0x4f, 0xbd, 0x84, 0x8d, 0x09, - 0x27, 0x45, 0xbd, 0x4c, 0xb9, 0x3e, 0x6d, 0x65, 0xeb, 0xed, 0xfd, 0xc5, - 0x3e, 0x28, 0x89, 0x2b, 0x76, 0xc4, 0x56, 0xcf, 0xbb, 0x9e, 0xec, 0xd2, - 0x21, 0x41, 0xcf, 0x44, 0x6c, 0x86, 0xb0, 0x46, 0x46, 0xef, 0xa0, 0x24, - 0x64, 0xf6, 0xb8, 0xbc, 0x66, 0xf0, 0x26, 0x0d, 0x80, 0x25, 0xb0, 0xa4, - 0x9f, 0x5b, 0xb9, 0x82, 0x40, 0xea, 0xde, 0xb5, 0x84, 0x1a, 0x77, 0xd0, - 0xa5, 0x24, 0xc5, 0xae, 0x5c, 0xe7, 0x2a, 0xbf, 0x1d, 0x9c, 0x76, 0x4c, - 0xcd, 0xf1, 0x68, 0xa8, 0xa6, 0x30, 0xb5, 0xbb, 0x99, 0x8c, 0x23, 0x94, - 0xd3, 0x1d, 0xa1, 0x90, 0xee, 0x6e, 0xba, 0xd6, 0xc0, 0xa5, 0x0a, 0x84, - 0xfd, 0xc5, 0x4e, 0x81, 0xb4, 0x33, 0x22, 0x3b, 0xf3, 0x51, 0xb3, 0x18, - 0x06, 0x5d, 0x2d, 0xf0, 0xfd, 0x9b, 0x34, 0xbc, 0x30, 0x02, 0x7f, 0xcb, - 0x24, 0x38, 0xeb, 0x7c, 0xeb, 0x55, 0x46, 0x9b, 0x0f, 0xfb, 0x1e, 0x7a, - 0xfd, 0xe2, 0xe3, 0x7a, 0x46, 0x45, 0x8f, 0xe2, 0x78, 0x88, 0xfa, 0xa8, - 0x8f, 0x4e, 0x85, 0x14, 0xfa, 0x3e, 0x4c, 0x67, 0xe2, 0x76, 0x9e, 0x82, - 0xe4, 0x70, 0x7e, 0x69, 0x48, 0xec, 0xdb, 0x0b, 0xd0, 0xc2, 0x3c, 0xc6, - 0xce, 0x51, 0x7d, 0x0f, 0x5d, 0xb7, 0x2f, 0x31, 0xd7, 0x69, 0x8a, 0x74, - 0xd6, 0x81, 0x89, 0xb3, 0x7a, 0x16, 0xd7, 0xf4, 0xb3, 0x74, 0x41, 0x40, - 0xf7, 0x39, 0xf5, 0x66, 0x94, 0xa6, 0xf5, 0x7b, 0x8f, 0xf7, 0x2e, 0x66, - 0x47, 0x5f, 0x2d, 0x1e, 0x52, 0xc7, 0x93, 0xd6, 0xed, 0xa8, 0x06, 0x8e, - 0x73, 0x2e, 0xce, 0x21, 0xf4, 0xe6, 0xa3, 0x89, 0x26, 0xa4, 0x07, 0x49, - 0x58, 0x6c, 0x22, 0xef, 0xa1, 0x18, 0xe8, 0x1d, 0x4b, 0x4a, 0x26, 0xdd, - 0xa0, 0x09, 0xe3, 0xfd, 0x64, 0x99, 0xff, 0x88, 0xf9, 0xb6, 0xe6, 0xfb, - 0x7b, 0x66, 0x0a, 0x82, 0x3b, 0xa1, 0x31, 0xab, 0x31, 0x75, 0xe8, 0xc0, - 0xb9, 0xf2, 0x0d, 0xa3, 0x78, 0xf8, 0x02, 0x0b, 0xe4, 0x3c, 0x20, 0xdc, - 0x4c, 0x6e, 0x2b, 0xa8, 0xd5, 0x81, 0x33, 0x1f, 0x51, 0xf9, 0x25, 0x7f diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sigrevoked_sha256_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sigrevoked_sha256_bsn0_msg0.inc deleted file mode 100644 index a65e1c38e5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_sigrevoked_sha256_bsn0_msg0.inc +++ /dev/null @@ -1,98 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : groupA - * Issuer : iKGF - * Signer : member0 revoked in SigRl - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : SigRl of group - */ - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, 0x5f, 0x20, 0xbd, 0x9e, - 0x49, 0x11, 0x31, 0xe0, 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, 0x64, 0x60, 0xa4, 0xf8, - 0x17, 0x81, 0xc3, 0x0a, 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, 0x72, 0xdc, 0xe6, 0x78, - 0xe3, 0x70, 0xa8, 0x28, 0x62, 0x54, 0xa2, 0xdf, 0x64, 0x8d, 0xe9, 0x24, - 0xd5, 0x67, 0x49, 0xf0, 0x0f, 0x23, 0x35, 0xbd, 0xfd, 0x1e, 0xa2, 0x80, - 0x47, 0x26, 0x41, 0x00, 0xb9, 0xac, 0x71, 0xde, 0x03, 0x21, 0x79, 0x53, - 0xfc, 0x50, 0x4d, 0x48, 0x1c, 0xda, 0xd5, 0x1d, 0x8b, 0x1d, 0x14, 0xd3, - 0xd0, 0x1e, 0x17, 0x74, 0x85, 0x7a, 0xa7, 0xc8, 0x8e, 0x8f, 0x0a, 0x49, - 0x9c, 0xe6, 0x57, 0x7e, 0xbc, 0xbd, 0xf3, 0xd0, 0x40, 0x1d, 0xd2, 0x66, - 0x68, 0x0f, 0xa8, 0xc4, 0xa0, 0x8b, 0x58, 0x33, 0x9b, 0x8a, 0x09, 0xc5, - 0x72, 0x35, 0x27, 0xa6, 0xb9, 0x83, 0xd0, 0xe3, 0x9e, 0xf4, 0xca, 0x3f, - 0xab, 0x69, 0xcb, 0x5d, 0xca, 0xcc, 0x36, 0x40, 0xbc, 0x80, 0x5b, 0x81, - 0x25, 0xcc, 0x31, 0xe5, 0x7d, 0x3f, 0x1d, 0xe9, 0x1b, 0xc6, 0x64, 0x4a, - 0x00, 0x58, 0xfa, 0xe2, 0x3c, 0x4f, 0x4c, 0xc6, 0xa7, 0x14, 0xa6, 0xf6, - 0x5f, 0xad, 0xf5, 0x7e, 0x5f, 0x78, 0x98, 0x1c, 0xe4, 0xca, 0xfb, 0x9a, - 0x96, 0xdd, 0x53, 0x64, 0x4b, 0x67, 0xd1, 0x1e, 0xd8, 0xf5, 0xc2, 0xdb, - 0x46, 0x21, 0x14, 0xfd, 0xcc, 0x54, 0x35, 0x0a, 0x4a, 0xd6, 0x96, 0xe7, - 0xc6, 0xdc, 0xc2, 0x12, 0x4e, 0x54, 0x81, 0x8c, 0xf6, 0xca, 0xa5, 0xad, - 0xab, 0x07, 0xe0, 0x8b, 0x78, 0x56, 0x99, 0x5e, 0x26, 0x94, 0xd7, 0x6d, - 0x93, 0x9a, 0x0f, 0xab, 0x35, 0xc0, 0xc9, 0x82, 0x54, 0xef, 0xf5, 0xed, - 0x56, 0x26, 0xda, 0x82, 0xb9, 0x8e, 0x26, 0x2b, 0xda, 0x8f, 0xba, 0x81, - 0xba, 0xfe, 0x9d, 0x89, 0x45, 0x02, 0xb0, 0x38, 0x4b, 0x4e, 0x36, 0x4f, - 0xe0, 0xb6, 0xb6, 0x70, 0xad, 0x05, 0xd9, 0xe4, 0xbe, 0xc9, 0xcb, 0x43, - 0x19, 0x54, 0x8d, 0x65, 0xb9, 0x97, 0x85, 0x3a, 0x96, 0xee, 0xaf, 0x92, - 0x49, 0xbb, 0xa5, 0xb5, 0x92, 0xbd, 0x1e, 0xa4, 0x8f, 0xdd, 0xc4, 0x62, - 0xfc, 0xc8, 0x25, 0x11, 0x4a, 0x6f, 0xe6, 0xfa, 0xbc, 0xd5, 0xf5, 0xf6, - 0x79, 0x13, 0xd4, 0x9b, 0x46, 0x1e, 0x97, 0xb3, 0x13, 0xf2, 0x65, 0x7f, - 0xe1, 0xb9, 0x30, 0xa0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_test1_basename1_sha256.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_test1_basename1_sha256.inc deleted file mode 100644 index a7a956b9f0..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sig_test1_basename1_sha256.inc +++ /dev/null @@ -1,59 +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 Test data. - * - * Type: Intel(R) EPID 2.0 Signature - * Group: groupA - * Issuer : iKGF - * Signer: member0 - * HashAlg: Sha256 - * Message: "test1" - * Basename: "basename1" - * SigRl: Empty - */ - 0xa6, 0x13, 0x29, 0xb6, 0x61, 0xa2, 0xb8, 0xd7, 0x49, 0x86, 0xcb, 0xaf, - 0x94, 0x4d, 0x9e, 0x51, 0xcf, 0xd3, 0x5d, 0x0f, 0x33, 0x9a, 0x59, 0x0d, - 0xe7, 0xc9, 0xb9, 0x7f, 0x83, 0xae, 0x27, 0xe6, 0x40, 0xf0, 0x88, 0x13, - 0xe2, 0xb6, 0x6a, 0x43, 0x26, 0xa3, 0x21, 0xea, 0x00, 0x78, 0xcd, 0xce, - 0x0e, 0x14, 0x7a, 0xde, 0xcf, 0xaa, 0x7b, 0xc5, 0x7e, 0x7c, 0xaf, 0xe4, - 0x5e, 0x8a, 0xdd, 0xc7, 0x2b, 0x4e, 0x81, 0x50, 0xcc, 0xf9, 0xcc, 0x85, - 0xcb, 0x8c, 0xe5, 0x76, 0x26, 0xd2, 0x30, 0x62, 0x12, 0x6b, 0xbc, 0xfb, - 0xf9, 0x91, 0x47, 0x55, 0x54, 0x5c, 0x5b, 0xce, 0x75, 0xaf, 0x69, 0xa3, - 0x26, 0xa6, 0xb7, 0xd5, 0x33, 0xe1, 0xbb, 0xd4, 0x94, 0xca, 0x05, 0xc5, - 0xc3, 0x64, 0xe8, 0xd8, 0x12, 0xa8, 0x5b, 0x0d, 0x12, 0xf6, 0x53, 0xa2, - 0xfa, 0x28, 0x59, 0xc4, 0xc3, 0x6f, 0x6a, 0xd8, 0x7d, 0x77, 0x17, 0x11, - 0xa2, 0xf3, 0x70, 0xa4, 0x85, 0xc8, 0x65, 0xb2, 0x8b, 0x30, 0x1b, 0x75, - 0x2b, 0x96, 0x95, 0xa7, 0xd5, 0x1c, 0x4e, 0xae, 0xc4, 0xdc, 0xa3, 0x48, - 0x84, 0x53, 0xee, 0xaa, 0xc5, 0xe0, 0x26, 0x9e, 0xde, 0x4c, 0x21, 0x78, - 0xea, 0x38, 0xb4, 0x53, 0xce, 0xe4, 0xea, 0x4f, 0x08, 0x08, 0x4f, 0x08, - 0x21, 0xca, 0xfc, 0x01, 0xa4, 0xc9, 0x23, 0xa8, 0x9a, 0x00, 0xe0, 0x14, - 0x8b, 0xec, 0x5f, 0x2e, 0xbb, 0x22, 0x6a, 0x63, 0xda, 0x99, 0xd6, 0xf8, - 0xa1, 0x7d, 0x4c, 0x1a, 0xde, 0x19, 0xa4, 0x52, 0x1b, 0x54, 0xa9, 0x42, - 0x2c, 0xb4, 0x7a, 0x8d, 0xc8, 0xe6, 0x0b, 0x35, 0x70, 0x03, 0x08, 0x88, - 0xfe, 0x0f, 0xab, 0x62, 0x95, 0x35, 0xf4, 0xfc, 0x46, 0x26, 0x99, 0x59, - 0xdf, 0x25, 0x96, 0x0d, 0x10, 0x89, 0xcb, 0x52, 0x95, 0xba, 0xa7, 0xe9, - 0xc4, 0x34, 0xf2, 0xee, 0xbd, 0x02, 0x99, 0x38, 0x8d, 0xef, 0x80, 0xa5, - 0xc3, 0x54, 0xb1, 0x78, 0xf3, 0xf5, 0xc5, 0xf3, 0xf4, 0x08, 0xc6, 0x51, - 0xf1, 0x4d, 0x6d, 0x28, 0x95, 0x02, 0x55, 0xc9, 0x60, 0xba, 0x23, 0x81, - 0x2f, 0xe6, 0xb0, 0x47, 0x23, 0x40, 0x85, 0xf6, 0x11, 0x8f, 0xa3, 0x71, - 0xa2, 0x69, 0x47, 0xc4, 0x79, 0x26, 0x67, 0x84, 0xb1, 0x43, 0xde, 0xe4, - 0xb2, 0xad, 0xb4, 0x71, 0xba, 0xb6, 0xbb, 0xf8, 0xae, 0x77, 0xcd, 0x3f, - 0x40, 0xe9, 0x9c, 0x7c, 0x90, 0xb6, 0x98, 0xac, 0xa8, 0x6f, 0x67, 0x94, - 0xe1, 0x97, 0xc1, 0x38, 0xd5, 0x05, 0xd0, 0x7b, 0x77, 0x8e, 0xc9, 0x17, - 0xb7, 0x21, 0x15, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrevokedmember0/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrevokedmember0/mprivkey.inc deleted file mode 100644 index e8059b8d7b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrevokedmember0/mprivkey.inc +++ /dev/null @@ -1,36 +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 Test data. - * - * Type : Intel(R) EPID 2.0 member private-key - * Group : GroupA - * Member : sigrevokedmember0 - * Issuer : Ikgf - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x39, 0x88, 0x2e, 0xee, 0xbb, 0x26, 0xa6, 0x85, - 0xa0, 0x06, 0x6b, 0xb4, 0x7f, 0x81, 0x2a, 0x02, 0x13, 0xf3, 0x2e, 0xcf, - 0x10, 0xeb, 0xfd, 0xce, 0xa0, 0x39, 0xd2, 0xb7, 0xb3, 0x52, 0xd0, 0x5a, - 0x9b, 0x2d, 0x47, 0xbc, 0x5f, 0x30, 0x57, 0x5b, 0x60, 0xdf, 0xa1, 0x5a, - 0x16, 0xb6, 0xff, 0x5f, 0x55, 0xc5, 0x34, 0xf9, 0x59, 0x55, 0x78, 0xa6, - 0xa6, 0x5d, 0xc6, 0x52, 0x81, 0x41, 0x35, 0x83, 0x56, 0xe0, 0x5e, 0x7b, - 0xaa, 0x17, 0x8d, 0x0d, 0x8f, 0xc5, 0xaf, 0xf7, 0xcc, 0x3a, 0xc1, 0xb8, - 0x96, 0xfd, 0xdc, 0x71, 0x8a, 0x88, 0x5c, 0x13, 0x55, 0x1b, 0x22, 0xbd, - 0x42, 0x0e, 0xc2, 0x49, 0x48, 0x5b, 0xa0, 0x03, 0xea, 0x4b, 0x79, 0x0b, - 0xb5, 0xed, 0x1a, 0x81, 0x6d, 0xb2, 0xe8, 0x41, 0xca, 0x1b, 0xb1, 0xc0, - 0xf7, 0x11, 0x42, 0x3f, 0x24, 0xea, 0x55, 0x02, 0x82, 0x4d, 0x11, 0x48 \ No newline at end of file diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrl.inc deleted file mode 100644 index e0b631f18c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupa/sigrl.inc +++ /dev/null @@ -1,57 +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 Test data. - * - * Type : Intel(R) EPID 2.0 signature based revocation list - * Group : GroupA - * Issuer : iKGF - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x4d, 0xaa, 0xa4, 0xb2, 0x80, 0xa9, 0x7a, 0x51, 0xfd, 0x1a, 0x3c, 0x44, - 0x5b, 0x17, 0x35, 0x3a, 0x88, 0x02, 0xce, 0x92, 0xfa, 0xac, 0x3e, 0x74, - 0x4a, 0xb7, 0x0b, 0xbe, 0xce, 0x77, 0x83, 0x71, 0x3c, 0x2d, 0xfd, 0xf4, - 0x56, 0x5a, 0x8a, 0x22, 0x10, 0x28, 0x8c, 0x2a, 0x73, 0x0f, 0x84, 0x11, - 0xb5, 0x97, 0x15, 0x17, 0x57, 0x04, 0x7d, 0x1c, 0x40, 0xce, 0x7d, 0xa1, - 0xe0, 0x75, 0xaa, 0x19, 0x5b, 0x62, 0xe7, 0x53, 0x26, 0xfc, 0xae, 0x2b, - 0x9d, 0x21, 0x7d, 0x0e, 0xf8, 0xc2, 0x80, 0xc6, 0x64, 0x20, 0xea, 0x04, - 0x32, 0xb8, 0x96, 0xd9, 0x72, 0x56, 0x6c, 0xea, 0xdd, 0xe8, 0x49, 0xa0, - 0xea, 0x5f, 0xbe, 0x0a, 0x8b, 0x2d, 0x17, 0x03, 0xd9, 0xe0, 0x0a, 0x24, - 0xc2, 0xa6, 0xf4, 0x97, 0x7d, 0x0f, 0xfd, 0xee, 0x09, 0x62, 0xba, 0x31, - 0x51, 0x6b, 0x3d, 0x1e, 0x91, 0xe3, 0xbc, 0xd5, 0x4d, 0xaa, 0xa4, 0xb2, - 0x80, 0xa9, 0x7a, 0x51, 0xfd, 0x1a, 0x3c, 0x44, 0x5b, 0x17, 0x35, 0x3a, - 0x88, 0x02, 0xce, 0x92, 0xfa, 0xac, 0x3e, 0x74, 0x4a, 0xb7, 0x0b, 0xbe, - 0xce, 0x77, 0x83, 0x71, 0x3c, 0x2d, 0xfd, 0xf4, 0x56, 0x5a, 0x8a, 0x22, - 0x10, 0x28, 0x8c, 0x2a, 0x73, 0x0f, 0x84, 0x11, 0xb5, 0x97, 0x15, 0x17, - 0x57, 0x04, 0x7d, 0x1c, 0x40, 0xce, 0x7d, 0xa1, 0xe0, 0x75, 0xaa, 0x19, - 0xda, 0x7f, 0x40, 0x65, 0x27, 0x0c, 0x47, 0x39, 0x5e, 0xcb, 0xbc, 0xca, - 0xc6, 0x5b, 0xdc, 0x48, 0xe0, 0x7a, 0x71, 0x54, 0x15, 0x21, 0xea, 0x40, - 0xb8, 0x49, 0x9e, 0x6b, 0x6a, 0xdd, 0x97, 0xc1, 0x77, 0xcf, 0x43, 0x55, - 0x64, 0x97, 0x2d, 0x14, 0x9c, 0x64, 0x22, 0xb2, 0x29, 0xa0, 0xe2, 0x90, - 0x1b, 0x00, 0xb2, 0xcd, 0x58, 0xf7, 0xd3, 0x90, 0x10, 0x1e, 0x0f, 0x61, - 0xad, 0xad, 0x71, 0x93, 0x4d, 0xaa, 0xa4, 0xb2, 0x80, 0xa9, 0x7a, 0x51, - 0xfd, 0x1a, 0x3c, 0x44, 0x5b, 0x17, 0x35, 0x3a, 0x88, 0x02, 0xce, 0x92, - 0xfa, 0xac, 0x3e, 0x74, 0x4a, 0xb7, 0x0b, 0xbe, 0xce, 0x77, 0x83, 0x71, - 0x3c, 0x2d, 0xfd, 0xf4, 0x56, 0x5a, 0x8a, 0x22, 0x10, 0x28, 0x8c, 0x2a, - 0x73, 0x0f, 0x84, 0x11, 0xb5, 0x97, 0x15, 0x17, 0x57, 0x04, 0x7d, 0x1c, - 0x40, 0xce, 0x7d, 0xa1, 0xe0, 0x75, 0xaa, 0x19, 0x3d, 0xa2, 0xbd, 0xc5, - 0x15, 0x67, 0x50, 0x88, 0x02, 0x0a, 0x37, 0xa3, 0x77, 0xef, 0x89, 0xf4, - 0x1b, 0x2a, 0x20, 0x04, 0xc8, 0x2c, 0x3f, 0xb5, 0x82, 0x9d, 0x55, 0xd1, - 0xb1, 0x4b, 0x18, 0x4d, 0xbb, 0x21, 0x5d, 0x09, 0x48, 0x44, 0x2c, 0xd3, - 0x4f, 0xc8, 0x29, 0xcb, 0x2e, 0xf9, 0xbf, 0xc5, 0x34, 0xb2, 0x94, 0x4e, - 0x1b, 0xf0, 0xa6, 0x9c, 0x32, 0x4f, 0x56, 0x0b, 0x68, 0x7b, 0xa9, 0x7b diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/member0/mprivkey.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/member0/mprivkey.inc deleted file mode 100644 index 33408c977c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/member0/mprivkey.inc +++ /dev/null @@ -1,36 +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 Test data. - * - * Type : Intel(R) EPID 2.0 member private-key - * Group : GroupB - * Member : 0 - * Issuer : Ikgf - */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x5e, 0xbe, 0x58, 0xb5, 0xc5, 0xdb, 0xee, 0x60, - 0x7a, 0xdb, 0x17, 0x93, 0xf8, 0x15, 0xb8, 0x0c, 0xec, 0x9b, 0xd0, 0x8c, - 0x0f, 0x5d, 0x71, 0xf8, 0xe6, 0xd3, 0xcf, 0x85, 0x74, 0xe2, 0xc1, 0xa3, - 0x89, 0x74, 0xb2, 0xcd, 0x77, 0x9a, 0x25, 0xad, 0x6f, 0x85, 0xe2, 0x26, - 0x89, 0xa1, 0xc7, 0xef, 0x70, 0x5e, 0x5c, 0xb4, 0xde, 0x3c, 0x3b, 0xbf, - 0x27, 0x8c, 0x6f, 0x25, 0x24, 0xa4, 0x10, 0xe2, 0x83, 0x91, 0xa3, 0x01, - 0x60, 0xf4, 0x47, 0x2e, 0xe2, 0x55, 0x10, 0x55, 0xcc, 0x18, 0xef, 0xdc, - 0x9f, 0xe1, 0xb0, 0x93, 0x74, 0x58, 0xdd, 0x13, 0x8f, 0xc8, 0xce, 0x87, - 0x76, 0x80, 0x02, 0x8b, 0x8f, 0xb9, 0x5d, 0x46, 0x25, 0xcb, 0x20, 0x43, - 0xda, 0x66, 0xd3, 0x50, 0x6e, 0x10, 0xf2, 0x32, 0x6a, 0x39, 0x36, 0xd2, - 0x97, 0x01, 0x08, 0x6c, 0x8e, 0x9e, 0x25, 0xa7, 0x7c, 0x86, 0xd4, 0xad \ No newline at end of file diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/sig_grouprevoked_sha256_bsn0_msg0.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/sig_grouprevoked_sha256_bsn0_msg0.inc deleted file mode 100644 index ecdbeb7e8d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/groupb/sig_grouprevoked_sha256_bsn0_msg0.inc +++ /dev/null @@ -1,98 +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 Test data. - * - * Type : Intel(R) EPID 2.0 Signature - * Group : groupB - * Issuer : iKGF - * Signer : member0 - * HashAlg : Sha256 - * Message : "msg0" - * Basename: "bsn0" - * SigRl : SigRl of group - */ - 0x70, 0x91, 0x63, 0x2c, 0xbb, 0xfe, 0x06, 0x26, 0x5f, 0x20, 0xbd, 0x9e, - 0x49, 0x11, 0x31, 0xe0, 0x7c, 0x99, 0x5e, 0xa0, 0x58, 0x4f, 0x1b, 0x3f, - 0xb4, 0x6e, 0xcd, 0x17, 0x61, 0x79, 0xa0, 0xfd, 0x64, 0x60, 0xa4, 0xf8, - 0x17, 0x81, 0xc3, 0x0a, 0x4b, 0x6a, 0x72, 0x86, 0x96, 0xe3, 0xfa, 0x95, - 0x47, 0x45, 0xfb, 0x57, 0xef, 0xca, 0x82, 0x99, 0x72, 0xdc, 0xe6, 0x78, - 0xe3, 0x70, 0xa8, 0x28, 0x9e, 0x33, 0x16, 0x72, 0x80, 0x10, 0x54, 0x16, - 0x58, 0x56, 0x74, 0x64, 0xd2, 0x8e, 0x6f, 0x5c, 0x17, 0xbc, 0x34, 0xcf, - 0xaa, 0x09, 0xbe, 0x2e, 0xef, 0x3d, 0xa2, 0xf2, 0xbd, 0x22, 0xaa, 0xac, - 0xf3, 0x42, 0xc1, 0xfe, 0xdc, 0x7d, 0xd6, 0x48, 0xe9, 0x03, 0x21, 0xda, - 0x45, 0x99, 0x41, 0x8e, 0xe0, 0x31, 0xd3, 0x3b, 0x4a, 0x87, 0x09, 0x13, - 0xcf, 0x1d, 0xf9, 0xad, 0xbc, 0xc0, 0x95, 0x44, 0x32, 0x12, 0x35, 0xa4, - 0x7d, 0x36, 0xbe, 0xff, 0xa4, 0x49, 0x33, 0xc8, 0x1f, 0x96, 0xf0, 0xfe, - 0x2d, 0xbc, 0xec, 0xef, 0xfd, 0x5e, 0xb4, 0x7d, 0xe6, 0x12, 0xd5, 0x1b, - 0x2a, 0x4f, 0x72, 0x47, 0x22, 0x0d, 0xdc, 0xf8, 0x20, 0xbf, 0x08, 0xf6, - 0xfc, 0x28, 0xff, 0x9f, 0x0f, 0x87, 0x5d, 0x80, 0x4e, 0x7a, 0xf8, 0xdd, - 0x4e, 0x73, 0x9e, 0x26, 0x1b, 0x7b, 0xcd, 0x56, 0xfc, 0x4c, 0x2a, 0xd8, - 0x51, 0x5a, 0x38, 0x11, 0x4a, 0x5c, 0x10, 0xe2, 0x8f, 0x0c, 0x1c, 0x18, - 0x04, 0x01, 0x96, 0x6d, 0x21, 0xdd, 0x02, 0xd2, 0xf5, 0xa5, 0xcc, 0xf4, - 0x78, 0x35, 0x96, 0x99, 0xae, 0xc5, 0x1d, 0xc4, 0xd9, 0xe1, 0x02, 0x53, - 0x76, 0xe1, 0x4a, 0x0e, 0xd8, 0x19, 0x9b, 0x61, 0x87, 0xea, 0x30, 0x83, - 0x8a, 0xa0, 0x8f, 0x19, 0xab, 0x38, 0x4d, 0x1b, 0x07, 0xc1, 0xea, 0x91, - 0x6e, 0x71, 0x73, 0x9a, 0x35, 0xe9, 0x97, 0x75, 0x20, 0x91, 0xbb, 0x37, - 0xb1, 0x01, 0x77, 0xad, 0xec, 0x2c, 0x68, 0x47, 0xd5, 0x08, 0x95, 0x3b, - 0xf5, 0x14, 0x4a, 0x19, 0x2e, 0xad, 0xb8, 0xac, 0xfc, 0x93, 0x00, 0xa4, - 0x83, 0xdd, 0x52, 0x23, 0xe6, 0x4e, 0x20, 0xeb, 0x67, 0xc7, 0x84, 0xa9, - 0x14, 0x4f, 0x90, 0x18, 0x90, 0x55, 0xad, 0xa3, 0x68, 0x7e, 0xcf, 0xd3, - 0xf2, 0xe5, 0xfe, 0x13, 0xd4, 0x47, 0x76, 0x29, 0x6e, 0x8c, 0xfc, 0x7f, - 0xad, 0x1c, 0x80, 0x64, 0xbf, 0xb5, 0xd7, 0x62, 0x08, 0x8e, 0x1c, 0xb2, - 0xb7, 0x4b, 0x8f, 0x6e, 0x11, 0xfd, 0x48, 0xe4, 0x8c, 0x13, 0x16, 0x75, - 0xe7, 0x83, 0xf8, 0xef, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x86, 0x92, 0xbc, 0x07, 0x76, 0x7a, 0xff, 0x03, 0x70, 0x26, 0xe5, 0xef, - 0x13, 0x7a, 0x5a, 0xdd, 0x8f, 0x3a, 0x4d, 0x8a, 0xe0, 0xbb, 0x87, 0xff, - 0xd7, 0xed, 0xce, 0xd1, 0x84, 0x1b, 0xa8, 0x70, 0x8b, 0x35, 0xf2, 0xab, - 0xa6, 0x85, 0x8a, 0xd6, 0xb6, 0x31, 0x99, 0x13, 0xdd, 0x29, 0x64, 0xa9, - 0x7f, 0xbe, 0x12, 0x58, 0x1b, 0x86, 0x55, 0x66, 0x7e, 0x03, 0x9e, 0x37, - 0xbb, 0x8a, 0xf3, 0x44, 0x94, 0x35, 0x32, 0x96, 0x6f, 0x4a, 0x31, 0x1a, - 0xf3, 0xa8, 0x09, 0x19, 0x08, 0x29, 0x83, 0x65, 0x51, 0x1f, 0xd4, 0x4c, - 0x43, 0x8f, 0xf2, 0x93, 0x8f, 0x1a, 0x7f, 0x3c, 0x4c, 0x00, 0x80, 0x0f, - 0x31, 0x06, 0xb1, 0x59, 0x62, 0x8a, 0xb1, 0x37, 0xa7, 0xb9, 0xfc, 0xc9, - 0xbd, 0xf1, 0xca, 0xf2, 0xd4, 0x41, 0xa0, 0xc9, 0xb8, 0x62, 0x84, 0x4f, - 0x55, 0x80, 0xa0, 0x33, 0xdf, 0x80, 0xb7, 0x71, 0x6d, 0xda, 0x75, 0xd6, - 0xc9, 0x91, 0xed, 0x43, 0x0e, 0x44, 0x96, 0xd6, 0x97, 0x2a, 0x38, 0x87, - 0x07, 0x1e, 0x3a, 0xa8, 0xc2, 0x48, 0x38, 0x3c, 0x8c, 0x8f, 0xd0, 0xfe, - 0xa7, 0xbe, 0x05, 0xa0, 0x21, 0x83, 0x7e, 0xbc, 0x2e, 0xa8, 0x66, 0x04, - 0xfe, 0x90, 0x44, 0xa6, 0xc7, 0xe0, 0xa6, 0xb5, 0xf9, 0x42, 0xd9, 0x24, - 0xe4, 0x48, 0xa4, 0x14, 0x3c, 0xf9, 0x69, 0xc5, 0x4c, 0x07, 0x49, 0xa4, - 0xfe, 0x3d, 0xae, 0x18, 0xb2, 0x15, 0x01, 0xa7, 0xec, 0xbf, 0xc4, 0x33, - 0xd6, 0x44, 0xd6, 0x27, 0x4c, 0xcd, 0x58, 0x61, 0x97, 0x15, 0xd2, 0x15, - 0xa4, 0xd6, 0x62, 0xfe, 0x9c, 0x56, 0x8e, 0xfc, 0xdf, 0x40, 0x17, 0xbb, - 0x64, 0x76, 0x95, 0x76, 0x74, 0xbb, 0xe6, 0xcd, 0xbc, 0x41, 0x33, 0xaf, - 0x3e, 0xac, 0x44, 0x41, 0x95, 0xb9, 0x93, 0xff, 0xb0, 0xe2, 0x98, 0x0e, - 0x30, 0x8c, 0x03, 0x06, 0x68, 0xc8, 0x7e, 0x64, 0xeb, 0xdb, 0xa9, 0x65, - 0x5f, 0xf2, 0x76, 0xc8, 0xa4, 0x75, 0x28, 0xf4, 0x7c, 0xc4, 0xb3, 0xa0, - 0x5e, 0xd7, 0x10, 0x45, 0x51, 0x0d, 0x13, 0x1c, 0x18, 0x2f, 0x6a, 0x16, - 0x6f, 0x64, 0xc4, 0x09, 0xd7, 0x7c, 0x41, 0x94, 0xd4, 0x23, 0x82, 0xbe, - 0x08, 0xca, 0x48, 0x84, 0x9a, 0x72, 0x96, 0xe2, 0x1c, 0x8e, 0x95, 0x59, - 0xc4, 0xd7, 0x25, 0xc0, 0x5d, 0x91, 0xb5, 0xd9, 0x4c, 0xd1, 0x75, 0xe8, - 0xda, 0x55, 0xdf, 0x44, 0x0f, 0x20, 0x18, 0xfb, 0x49, 0xdf, 0xe5, 0xcb, - 0xdf, 0xfe, 0x75, 0xfd, 0x44, 0x01, 0x5d, 0x28, 0x8f, 0xf9, 0xc2, 0xcb, - 0xa3, 0xed, 0x3b, 0x1e, 0x78, 0xe3, 0x0c, 0x3a, 0xac, 0xbc, 0xfe, 0x9e, - 0xff, 0x99, 0x1b, 0x35, 0xca, 0xf7, 0x00, 0x51, 0xa2, 0x6d, 0xb1, 0x0a, - 0xec, 0xaa, 0x99, 0x48, 0x07, 0x1a, 0x68, 0x99, 0xf0, 0xeb, 0x09, 0x07, - 0xc5, 0x68, 0xb4, 0xb5, 0x41, 0xb8, 0xd1, 0x18, 0x99, 0x4e, 0x68, 0x25, - 0xc9, 0x4d, 0x32, 0x58, 0xeb, 0xcb, 0x3b, 0x73, 0x8a, 0x26, 0x50, 0x58, - 0x00, 0x41, 0xc6, 0xf8, 0xc6, 0x6c, 0xf8, 0x28, 0xe3, 0x99, 0xf2, 0xcd, - 0xa0, 0x6f, 0xc3, 0x22, 0xd4, 0x00, 0x87, 0xd2, 0x75, 0x7f, 0xaa, 0x84, - 0x11, 0x10, 0x7f, 0x7a, 0x28, 0x4b, 0x69, 0xf9, 0xfa, 0x22, 0xa7, 0x95, - 0x37, 0x61, 0x46, 0x61, 0xf0, 0x66, 0x5e, 0x92, 0x5c, 0x2e, 0xd8, 0x97, - 0x86, 0xa5, 0x3b, 0x2c, 0x45, 0x98, 0x1a, 0x6a, 0xc0, 0xb2, 0xff, 0x1d, - 0x99, 0x5c, 0x32, 0x10, 0x82, 0xd3, 0x63, 0x82, 0x8c, 0x89, 0xa2, 0x5d diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/grprl.inc b/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/grprl.inc deleted file mode 100644 index 4059011ee5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/testdata/ikgf/grprl.inc +++ /dev/null @@ -1,124 +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 Test data. - * - * Type : Intel(R) EPID 2.0 group revocation list - * Group : GroupA - * Issuer : iKGF - */ - 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, - 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, 0x02, - 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, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/common/types.h b/sgx-jvm/linux-sgx/external/epid/epid/common/types.h deleted file mode 100644 index 03ba77559b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/common/types.h +++ /dev/null @@ -1,348 +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_TYPES_H_ -#define EPID_COMMON_TYPES_H_ - -#include // for CHAR_BIT - -/*! - * \file - * \brief SDK data types. -*/ - -/// SDK data types. -/*! - \defgroup EpidTypes types - Defines serialized data types used by the SDK. - - Most of the types defined here are fixed size binary buffers of various sizes - that are semantically mapped to the types of various inputs to the EPID APIs. - - For example ::GtElemStr is a 384 byte buffer that represents a serialized - value that is compatible with a ::FfElement belonging to the ::FiniteField - GT. - - \ingroup EpidCommon - @{ -*/ - -/// Recognized hash algorithms -typedef enum { - /// SHA-256 - kSha256 = 0, - /// SHA-384 - kSha384 = 1, - /// SHA-512 - kSha512 = 2, - /// SHA-512/256 - kSha512_256 = 3, - /// Reserved for SHA3/256 - kSha3_256 = 4, - /// Reserved for SHA3/384 - kSha3_384 = 5, - /// Reserved for SHA3/512 - kSha3_512 = 6, -} HashAlg; - -#pragma pack(1) -/// 8 bit octet string -typedef struct OctStr8 { - unsigned char data[8 / CHAR_BIT]; ///< 8 bit data -} OctStr8; -/// 16 bit octet string -typedef struct OctStr16 { - unsigned char data[16 / CHAR_BIT]; ///< 16 bit data -} OctStr16; -/// 32 bit octet string -typedef struct OctStr32 { - unsigned char data[32 / CHAR_BIT]; ///< 32 bit data -} OctStr32; -/// 64 bit octet string -typedef struct OctStr64 { - unsigned char data[64 / CHAR_BIT]; ///< 64 bit data -} OctStr64; -/// 128 bit octet string -typedef struct OctStr128 { - unsigned char data[128 / CHAR_BIT]; ///< 128 bit data -} OctStr128; -/// 256 bit octet string -typedef struct OctStr256 { - unsigned char data[256 / CHAR_BIT]; ///< 256 bit data -} OctStr256; -/// 512 bit octet string -typedef struct OctStr512 { - unsigned char data[512 / CHAR_BIT]; ///< 512 bit data -} OctStr512; - -/// Serialized BigNum -typedef struct BigNumStr { - OctStr256 data; ///< 256 bit octet string -} BigNumStr; -/// a number in [0, p-1] -typedef struct FpElemStr { - OctStr256 data; ///< 256 bit octet string -} FpElemStr; -/// a number in [0, q-1] -typedef struct FqElemStr { - OctStr256 data; ///< 256 bit octet string -} FqElemStr; - -/// Serialized G1 element -typedef struct G1ElemStr { - FqElemStr x; ///< an integer between [0, q-1] - FqElemStr y; ///< an integer between [0, q-1] -} G1ElemStr; - -/// Serialized G2 element -typedef struct G2ElemStr { - FqElemStr x[2]; ///< an integer between [0, q-1] - FqElemStr y[2]; ///< an integer between [0, q-1] -} G2ElemStr; - -/// Serialized GT element -typedef struct GtElemStr { - FqElemStr x[12]; ///< an integer between [0, q-1] -} GtElemStr; - -/// Intel(R) EPID 2.0 Parameters. -/*! - * Intel(R) EPID 2.0 parameters: (p, q, b, t, neg, beta, xi0, xi1, - * g1, g2) - */ -typedef struct Epid2Params { - BigNumStr p; ///< a prime - BigNumStr q; ///< a prime - FqElemStr b; ///< an integer between [0, q-1] - OctStr64 t; ///< an integer - OctStr8 neg; ///< a boolean - FqElemStr beta; ///< an integer between [0, q-1] - FqElemStr xi[2]; ///< array of integers between [0, q-1] - G1ElemStr g1; ///< a generator (an element) of G1 - G2ElemStr g2; ///< a generator (an element) of G2 -} Epid2Params; - -/// group ID, EPID Provisioning Protocol in SGX uses 32 bits GroupId -typedef OctStr32 GroupId; -typedef OctStr32 RLver_t; -typedef OctStr32 RLCount; - -typedef struct MemberPrecomp{ - GtElemStr e12; ///< an element in GT - GtElemStr e22; ///< an element in GT - GtElemStr e2w; ///< an element in GT - GtElemStr ea2; ///< an element in GT -} MemberPrecomp; - -/// Intel(R) EPID 2.0 group public key -/*! - * Group public key: (gid, h1, h2, w) - */ -typedef struct GroupPubKey { - GroupId gid; ///< group ID - G1ElemStr h1; ///< an element in G1 - G1ElemStr h2; ///< an element in G1 - G2ElemStr w; ///< an element in G2 -} GroupPubKey; - -/// Intel(R) EPID 2.0 issuing private key -/*! - * Issuing private key: (gid, gamma) - */ -typedef struct IPrivKey { - GroupId gid; ///< group ID - FpElemStr gamma; ///< an integer between [0, p-1] -} IPrivKey; - -/// Intel(R) EPID 2.0 private key -/*! - * Private key: (gid, A, x, f) - */ -typedef struct PrivKey { - GroupId gid; ///< group ID - G1ElemStr A; ///< an element in G1 - FpElemStr x; ///< an integer between [0, p-1] - FpElemStr f; ///< an integer between [0, p-1] -} PrivKey; - -/// 256 bit seed derived from fuse key -typedef OctStr256 Seed; - -/// Compressed private key -/*! - * Compressed Private key: (gid, A.x, seed) - */ -typedef struct CompressedPrivKey { - GroupId gid; ///< group ID - FqElemStr ax; ///< an integer between [0, p-1] - Seed seed; ///< 256 bit rekey seed -} CompressedPrivKey; - -/// Membership credential -/*! - * Membership credential: (gid, A, x) - */ -typedef struct MembershipCredential { - GroupId gid; ///< group ID - G1ElemStr A; ///< an element in G1 - FpElemStr x; ///< an integer between [0, p-1] -} MembershipCredential; - -/// 256 bit nonce chosen by issuer -typedef OctStr256 IssuerNonce; - -/// Join request -/*! - * Join request: (F, c, s) - */ -typedef struct JoinRequest { - G1ElemStr F; ///< an element in G1 - FpElemStr c; ///< an integer between [0, p-1] - FpElemStr s; ///< an integer between [0, p-1] -} JoinRequest; - -//////////////////////// - -/// Intel(R) EPID 2.0 basic signature. -/*! - * Basic signature: (B, K, T, c, sx, sf, sa, sb) - */ -typedef struct BasicSignature { - G1ElemStr B; ///< an element in G1 - G1ElemStr K; ///< an element in G1 - G1ElemStr T; ///< an element in G1 - FpElemStr c; ///< an integer between [0, p-1] - FpElemStr sx; ///< an integer between [0, p-1] - FpElemStr sf; ///< an integer between [0, p-1] - FpElemStr sa; ///< an integer between [0, p-1] - FpElemStr sb; ///< an integer between [0, p-1] -} BasicSignature; - -/// -/*! - * \brief - * non-revoked Proof. - * - * Non-revoked Proof: (T, c, smu, snu) - */ -typedef struct NrProof { - G1ElemStr T; ///< an element in G1 - FpElemStr c; ///< an integer between [0, p-1] - FpElemStr smu; ///< an integer between [0, p-1] - FpElemStr snu; ///< an integer between [0, p-1] -} NrProof; - -/// Intel(R) EPID 2.0 Signature -/*! - * Signature: (sigma0, RLver, n2, sigma[0], ..., sigma[n2-1]) - */ -typedef struct EpidSignature { - BasicSignature sigma0; ///< basic signature - OctStr32 rl_ver; ///< revocation list version number - OctStr32 n2; ///< number of entries in SigRL - NrProof sigma[1]; ///< array of non-revoked proofs (flexible array) -} EpidSignature; - -/// private-key based revocation list. -/*! - * Private-key based revocation list PrivRL: (gid, RLver, n1, f[0], - * ..., f[n1-1]) - */ -typedef struct PrivRl { - GroupId gid; ///< group ID - OctStr32 version; ///< revocation list version number - OctStr32 n1; ///< number of entries in PrivRL - FpElemStr f[1]; ///< integers between [1, p-1] (flexible array) -} PrivRl; - -/// entry in SigRL (B,K) -typedef struct SigRlEntry { - G1ElemStr b; ///< an element of G1 - G1ElemStr k; ///< an element of G1 -} SigRlEntry; - -/// signature based revocation list -/*! - * Signature based revocation list SigRL: (gid, RLver, n2, B[0], - * K[0], ..., B[n2-1], K[n2-1]) - */ -typedef struct SigRl { - GroupId gid; ///< group ID - OctStr32 version; ///< revocation list version number - OctStr32 n2; ///< number of entries in SigRL - SigRlEntry bk[1]; ///< revoked Bs and Ks (flexible array) -} SigRl; - -/// group revocation list -/*! - * Group revocation list GroupRL: (RLver, n3, gid[0], ..., - * gid[n3-1]) - */ -typedef struct GroupRl { - OctStr32 version; ///< revocation list version number - OctStr32 n3; ///< number of entries in GroupRL - GroupId gid[1]; ///< revoked group IDs (flexible array) -} GroupRl; - -/*! verifier revocation list - * Verifier revocation list VerifierRL: (gid, B, RLver, n4, K[0], - * ..., K[n4-1]) - */ -typedef struct VerifierRl { - GroupId gid; ///< group ID - G1ElemStr B; ///< an element in G1 - OctStr32 version; ///< revocation list version number - OctStr32 n4; ///< number of entries in VerifierRL - G1ElemStr K[1]; ///< elements in G1 (flexible array) -} VerifierRl; - -/// element to store seed values for later rekey -typedef G1ElemStr ReKeySeed; - -/// Serialized Fq2 element -typedef struct Fq2ElemStr { - FqElemStr a[2]; ///< polynomial coefficient -} Fq2ElemStr; - -/// Serialized Fq2^3 element -typedef struct Fq6ElemStr { - Fq2ElemStr a[3]; ///< polynomial coefficient -} Fq6ElemStr; - -/// Serialized Fq2^3^2 element -typedef struct Fq12ElemStr { - Fq6ElemStr a[2]; ///< polynomial coefficient -} Fq12ElemStr; - -/// ECDSA Signature using NIST 256-bit curve secp256r1 -typedef struct EcdsaSignature { - OctStr256 x; ///< 256-bit integer - OctStr256 y; ///< 256-bit integer -} EcdsaSignature; - -/// ECDSA Public Key -typedef struct EcdsaPublicKey { - OctStr256 x; ///< 256-bit integer - OctStr256 y; ///< 256-bit integer -} EcdsaPublicKey; - -/// ECDSA Private Key -typedef struct EcdsaPrivateKey { - OctStr256 data; ///< 256-bit integer -} EcdsaPrivateKey; -#pragma pack() - -/*! @} */ -#endif // EPID_COMMON_TYPES_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/api.h b/sgx-jvm/linux-sgx/external/epid/epid/member/api.h deleted file mode 100644 index 75d99dfbc6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/api.h +++ /dev/null @@ -1,482 +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_MEMBER_API_H_ -#define EPID_MEMBER_API_H_ - -#include -#include "epid/common/stdtypes.h" -#include "epid/common/types.h" -#include "epid/common/errors.h" -#include "epid/common/bitsupplier.h" - -#ifdef __cplusplus -extern "C"{ -#endif -/*! - * \file - * \brief Intel(R) EPID SDK member API. - */ - -/// Member functionality -/*! - \defgroup EpidMemberModule member - - Defines the APIs needed by Intel(R) EPID members. Each member - context (::MemberCtx) represents membership in a single group. - - \ingroup EpidModule - @{ -*/ - -/// Internal context of member. -typedef struct MemberCtx MemberCtx; - -/// Pre-computed member settings. -/*! - Serialized form of the information about a member that remains stable for - a given set of keys. - - \note e12 = 0 implies that this data is not valid - */ -#pragma pack(1) - -/// Pre-computed signature. -/*! - Serialized form of an intermediate signature that does not depend on - basename or message. This can be used to time-shift compute time needed to - sign a message. - */ -typedef struct PreComputedSignature { - G1ElemStr B; ///< an element in G1 - G1ElemStr K; ///< an element in G1 - G1ElemStr T; ///< an element in G1 - G1ElemStr R1; ///< an element in G1 - GtElemStr R2; ///< an element in G1 - FpElemStr a; ///< an integer between [0, p-1] - FpElemStr b; ///< an integer between [0, p-1] - FpElemStr rx; ///< an integer between [0, p-1] - FpElemStr rf; ///< an integer between [0, p-1] - FpElemStr ra; ///< an integer between [0, p-1] - FpElemStr rb; ///< an integer between [0, p-1] -} PreComputedSignature; -#pragma pack() - -/// Creates a new member context. -/*! - Must be called to create the member context that is used by - other "Member" APIs. - - Allocates memory for the context, then initializes it. - - EpidMemberDelete() must be called to safely release the member context. - - \param[in] pub_key - The group certificate. - \param[in] priv_key - The member private key. - \param[in] precomp - Optional pre-computed data. If NULL the value is computed internally and is - readable using EpidMemberWritePrecomp(). - \param[in] rnd_func - Random number generator. - \param[in] rnd_param - Pass through context data for rnd_func. - \param[out] ctx - Newly constructed member context. - - \returns ::EpidStatus - - \warning - For security rnd_func should be a cryptographically secure random - number generator. - - \note - If the result is not ::kEpidNoErr the content of ctx is undefined. - - \see EpidMemberDelete - \see EpidMemberWritePrecomp - */ -EpidStatus EpidMemberCreate(GroupPubKey const* pub_key, PrivKey const* priv_key, - MemberPrecomp const* precomp, BitSupplier rnd_func, - void* rnd_param, MemberCtx** ctx); - -/// Deletes an existing member context. -/*! - Must be called to safely release a member context created using - EpidMemberCreate(). - - De-initializes the context, frees memory used by the context, and sets the - context pointer to NULL. - - \param[in,out] ctx - The member context. Can be NULL. - - \see EpidMemberCreate - */ -void EpidMemberDelete(MemberCtx** ctx); - -/// Serializes the pre-computed member settings. -/*! - \param[in] ctx - The member context. - \param[out] precomp - The Serialized pre-computed member settings. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr, the content of precomp is undefined. - */ -EpidStatus EpidMemberWritePrecomp(MemberCtx const* ctx, MemberPrecomp* precomp); - -/// Sets the hash algorithm to be used by a member. -/*! - \param[in] ctx - The member context. - \param[in] hash_alg - The hash algorithm to use. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr, the hash algorithm used by the member is - undefined. - - \see EpidMemberCreate - \see ::HashAlg - */ -EpidStatus EpidMemberSetHashAlg(MemberCtx* ctx, HashAlg hash_alg); - -/// Computes the size in bytes required for a Intel(R) EPID signature. -/*! - \param[in] sig_rl - The signature based revocation list that is used. NULL is treated as - a zero length list. - - \returns - Size in bytes of an Intel(R) EPID signature including proofs for each entry - in the signature based revocation list. - - \see ::SigRl -*/ -size_t EpidGetSigSize(SigRl const* sig_rl); - -/// Writes a Intel(R) EPID signature. -/*! - \param[in] ctx - The member context. - \param[in] msg - The message to sign. - \param[in] msg_len - The length in bytes of message. - \param[in] basename - Optional basename. If basename is NULL a random basename is used. - Signatures generated using random basenames are anonymous. Signatures - generated using the same basename are linkable by the verifier. If a - basename is provided, it must already be registered, or - ::kEpidBadArgErr is returned. - \param[in] basename_len - The size of basename in bytes. Must be 0 basename is NULL. - \param[in] sig_rl - The signature based revocation list. - \param[in] sig_rl_size - The size in bytes of the signature based revocation list. - \param[out] sig - The generated signature - \param[in] sig_len - The size of signature in bytes. Must be equal to value returned by - EpidGetSigSize(). - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the content of sig is undefined. - - \see - EpidMemberCreate - \see - EpidMemberSetHashAlg - \see - EpidGetSigSize - */ -EpidStatus EpidSign(MemberCtx const* ctx, void const* msg, size_t msg_len, - void const* basename, size_t basename_len, - SigRl const* sig_rl, size_t sig_rl_size, EpidSignature* sig, - size_t sig_len); - -/// Registers a basename with a member. -/*! - - To prevent loss of privacy, the member keeps a list of basenames - (corresponding to authorized verifiers). The member signs a message - with a basename only if the basename is in the member's basename - list. - - \warning - The use of a name-based signature creates a platform unique - pseudonymous identifier. Because it reduces the member's privacy, the - user should be notified when it is used and should have control over - its use. - - \param[in] ctx - The member context. - \param[in] basename - The basename. - \param[in] basename_len - Length of the basename. - - \returns ::EpidStatus - - \retval ::kEpidDuplicateErr - The basename was already registered. - - \note - If the result is not ::kEpidNoErr or ::kEpidDuplicateErr it is undefined if the - basename is registered. - */ -EpidStatus EpidRegisterBaseName(MemberCtx* ctx, void const* basename, - size_t basename_len); - -/// Extends the member's pool of pre-computed signatures. -/*! - Can either generate new pre-computed signatures or import existing ones. - ::EpidWritePreSigs can be used to export pre-computed signatures. - - \param[in] ctx - The member context. - \param[in] number_presigs - The number of pre-computed signatures to add to the internal pool. - \param[in,out] presigs - Optional array of valid pre-computed signatures to import. If presigs is not - NULL it most contain at least number_presigs pre-computed signatures. - - \returns ::EpidStatus - - \note - presigs buffer is zeroed out before return to prevent pre-computed - signatures from being reused. - - \note - If the result is not ::kEpidNoErr the state of the pre-computed signature - pool, and of presigs, is undefined. - - \see ::EpidMemberCreate - \see ::EpidWritePreSigs - */ -EpidStatus EpidAddPreSigs(MemberCtx* ctx, size_t number_presigs, - PreComputedSignature* presigs); - -/// Gets the number of pre-computed signatures in the member's pool. -/*! - \param[in] ctx - The member context. - - \returns - Number of remaining pre-computed signatures. Returns 0 if ctx is NULL. - - \see ::EpidMemberCreate - \see ::EpidWritePreSigs -*/ -size_t EpidGetNumPreSigs(MemberCtx const* ctx); - -/// Serializes pre-computed signatures from the member's pool. -/*! - Removes requested number of pre-computed signatures from member's pool and - stores them in presigs array. Use ::EpidAddPreSigs to add pre-computed - signatures to the pool. - - \param[in] ctx - The member context. - \param[out] presigs - An existing buffer of pre-computed signatures. - \param[in] number_presigs - Number of pre-computed signatures to read. Number_presigs must not be greater - than the value returned by ::EpidGetNumPreSigs. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the state of the pre-computed signature - pool, and of presigs, is undefined. - - \see ::EpidMemberCreate - \see ::EpidGetNumPreSigs - \see ::EpidAddPreSigs -*/ -EpidStatus EpidWritePreSigs(MemberCtx* ctx, PreComputedSignature* presigs, - size_t number_presigs); - -/// Creates a request to join a group. -/*! - The created request is part of the interaction with an issuer needed to join - a group. This interaction with the issuer is outside the scope of this API. - - \param[in] pub_key - The group certificate of group to join. - \param[in] ni - The nonce chosen by issuer as part of join protocol. - \param[in] f - A randomly selected integer in [1, p-1]. - \param[in] rnd_func - Random number generator. - \param[in] rnd_param - Pass through context data for rnd_func. - \param[in] hash_alg - The hash algorithm to be used. - \param[out] join_request - The join request. - - \returns ::EpidStatus - - \warning - For security rnd_func should be a cryptographically secure random - number generator. - - \note - The default hash algorithm in Member is SHA-512. This is the - recommended option if you do not override the hash algorithm - elsewhere. - - \note - If the result is not ::kEpidNoErr, the content of join_request is undefined. - - \see ::HashAlg - */ -EpidStatus EpidRequestJoin(GroupPubKey const* pub_key, IssuerNonce const* ni, - FpElemStr const* f, BitSupplier rnd_func, - void* rnd_param, HashAlg hash_alg, - JoinRequest* join_request); - -/// Creates a basic signature for use in constrained environment. -/*! - Used in constrained environments where, due to limited memory, it may not - be possible to process through a large and potentially unbounded revocation - list. - - \param[in] ctx - The member context. - \param[in] msg - The message. - \param[in] msg_len - The length of message in bytes. - \param[in] basename - Optional basename. If basename is NULL a random basename is used. - Signatures generated using random basenames are anonymous. Signatures - generated using the same basename are linkable by the verifier. If a - basename is provided it must already be registered or - ::kEpidBadArgErr is returned. - \param[in] basename_len - The size of basename in bytes. Must be 0 basename is NULL. - \param[out] sig - The generated basic signature - - \returns ::EpidStatus - - \note - This function should be used in conjunction with EpidNrProve() - - \note - If the result is not ::kEpidNoErr the content of sig, is undefined. - - \see EpidMemberCreate - \see EpidNrProve - */ -EpidStatus EpidSignBasic(MemberCtx const* ctx, void const* msg, size_t msg_len, - void const* basename, size_t basename_len, - BasicSignature* sig); - -/// Calculates a non-revoked proof for a single signature based revocation -/// list entry. -/*! - Used in constrained environments where, due to limited memory, it may not - be possible to process through a large and potentially unbounded revocation - list. - - \param[in] ctx - The member context. - \param[in] msg - The message. - \param[in] msg_len - The length of message in bytes. - \param[in] sig - The basic signature. - \param[in] sigrl_entry - The signature based revocation list entry. - \param[out] proof - The generated non-revoked proof. - - \returns ::EpidStatus - - \note - This function should be used in conjunction with EpidSignBasic(). - - \note - If the result is not ::kEpidNoErr, the content of proof is undefined. - - \see EpidMemberCreate - \see EpidSignBasic - */ -EpidStatus EpidNrProve(MemberCtx const* ctx, void const* msg, size_t msg_len, - BasicSignature const* sig, SigRlEntry const* sigrl_entry, - NrProof* proof); - -/// Tests if a member private key is valid without checking revocation. -/*! - Used to check that a member private key is a valid key for a group. This - is useful as a cross check when creating a new member private key as part of - the join process - - \param[in] pub_key - The public key of the group. - \param[in] priv_key - The private key to check. - - \result bool - - \retval true - if the private key is valid for the group of the public key - \retval false - if the private key is not valid for the group of the public key - - - \see EpidRequestJoin - */ -bool EpidIsPrivKeyInGroup(GroupPubKey const* pub_key, PrivKey const* priv_key); - -/// Decompresses compressed member private key. -/*! - - Converts a compressed member private key into a member - private key for use by other member APIs. - - \param[in] pub_key - The public key of the group. - \param[in] compressed_privkey - The compressed member private key to be decompressed. - \param[out] priv_key - The member private key. - - \returns ::EpidStatus - */ -EpidStatus EpidDecompressPrivKey(GroupPubKey const* pub_key, - CompressedPrivKey const* compressed_privkey, - PrivKey* priv_key); - -#ifdef __cplusplus -}; -#endif -/*! @} */ -#endif // EPID_MEMBER_API_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/context.c b/sgx-jvm/linux-sgx/external/epid/epid/member/context.c deleted file mode 100644 index fa76af22a0..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/context.c +++ /dev/null @@ -1,422 +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 Member context implementation. - */ - -#include - -#include "epid/member/api.h" -#include "epid/member/context.h" -#include "epid/member/privkey.h" -#include "epid/common/memory.h" - -/// Perform pre-computation and store in context -static EpidStatus DoPrecomputation(MemberCtx* ctx); - -/// Read Member precomp -static EpidStatus ReadPrecomputation(MemberPrecomp const* precomp_str, - MemberCtx* ctx); - -EpidStatus EpidMemberCreate(GroupPubKey const* pub_key, PrivKey const* priv_key, - MemberPrecomp const* precomp, BitSupplier rnd_func, - void* rnd_param, MemberCtx** ctx) { - EpidStatus result = kEpidErr; - MemberCtx* member_ctx = NULL; - - if (!pub_key || !priv_key || !rnd_func || !ctx) { - return kEpidBadArgErr; - } - - // The member verifies that gid in public key and in private key - // match. If mismatch, abort and return operation failed. - if (memcmp(&pub_key->gid, &priv_key->gid, sizeof(GroupId))) { - return kEpidBadArgErr; - } - - // Allocate memory for VerifierCtx - member_ctx = SAFE_ALLOC(sizeof(MemberCtx)); - if (!member_ctx) { - return kEpidMemAllocErr; - } - - do { - // set the default hash algorithm to sha512 - member_ctx->hash_alg = kSha512; - - // Internal representation of Epid2Params - result = CreateEpid2Params(&member_ctx->epid2_params); - if (kEpidNoErr != result) { - break; - } - // Internal representation of Group Pub Key - result = - CreateGroupPubKey(pub_key, member_ctx->epid2_params->G1, - member_ctx->epid2_params->G2, &member_ctx->pub_key); - if (kEpidNoErr != result) { - break; - } - // Internal representation of Member Priv Key - result = CreatePrivKey(priv_key, member_ctx->epid2_params->G1, - member_ctx->epid2_params->Fp, &member_ctx->priv_key); - if (kEpidNoErr != result) { - break; - } - // Allocate member_ctx->e12 - result = NewFfElement(member_ctx->epid2_params->GT, &member_ctx->e12); - if (kEpidNoErr != result) { - break; - } - // Allocate member_ctx->e22 - result = NewFfElement(member_ctx->epid2_params->GT, &member_ctx->e22); - if (kEpidNoErr != result) { - break; - } - // Allocate member_ctx->e2w - result = NewFfElement(member_ctx->epid2_params->GT, &member_ctx->e2w); - if (kEpidNoErr != result) { - break; - } - // Allocate member_ctx->ea2 - result = NewFfElement(member_ctx->epid2_params->GT, &member_ctx->ea2); - if (kEpidNoErr != result) { - break; - } - // precomputation - if (precomp != NULL) { - result = ReadPrecomputation(precomp, member_ctx); - } else { - result = DoPrecomputation(member_ctx); - } - if (kEpidNoErr != result) { - break; - } - result = SetKeySpecificCommitValues(pub_key, &member_ctx->commit_values); - if (kEpidNoErr != result) { - break; - } - - member_ctx->rnd_func = rnd_func; - member_ctx->rnd_param = rnd_param; - member_ctx->allowed_basenames = NULL; - - if (!CreateStack(sizeof(PreComputedSignature), &member_ctx->presigs)) { - result = kEpidMemAllocErr; - break; - } - - *ctx = member_ctx; - result = kEpidNoErr; - } while (0); - - if (kEpidNoErr != result) { - DeleteFfElement(&member_ctx->ea2); - DeleteFfElement(&member_ctx->e2w); - DeleteFfElement(&member_ctx->e22); - DeleteFfElement(&member_ctx->e12); - DeleteEpid2Params(&member_ctx->epid2_params); - DeleteGroupPubKey(&member_ctx->pub_key); - DeletePrivKey(&member_ctx->priv_key); - DeleteStack(&member_ctx->presigs); - SAFE_FREE(member_ctx); - } - - return (result); -} - -void EpidMemberDelete(MemberCtx** ctx) { - if (ctx && *ctx) { - DeleteGroupPubKey(&(*ctx)->pub_key); - DeleteFfElement(&(*ctx)->e12); - DeleteFfElement(&(*ctx)->e22); - DeleteFfElement(&(*ctx)->e2w); - DeleteFfElement(&(*ctx)->ea2); - DeleteEpid2Params(&(*ctx)->epid2_params); - DeletePrivKey(&(*ctx)->priv_key); - DeleteBasenames(&(*ctx)->allowed_basenames); - DeleteStack(&(*ctx)->presigs); - SAFE_FREE(*ctx); - } -} - -EpidStatus EpidMemberWritePrecomp(MemberCtx const* ctx, - MemberPrecomp* precomp) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; // an element in GT - FfElement* e22 = NULL; // an element in GT - FfElement* e2w = NULL; // an element in GT - FfElement* ea2 = NULL; // an element in GT - FiniteField* GT = NULL; // Finite field GT(Fq12 ) - if (!ctx) { - return kEpidBadArgErr; - } - if (!precomp) { - return kEpidBadArgErr; - } - if (!ctx->e12 || !ctx->e22 || !ctx->e2w || !ctx->ea2 || !ctx->epid2_params || - !(ctx->epid2_params->GT)) { - return kEpidBadArgErr; - } - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - ea2 = ctx->ea2; - GT = ctx->epid2_params->GT; - result = WriteFfElement(GT, e12, &(precomp->e12), sizeof(precomp->e12)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, e22, &(precomp->e22), sizeof(precomp->e22)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, e2w, &(precomp->e2w), sizeof(precomp->e2w)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, ea2, &(precomp->ea2), sizeof(precomp->ea2)); - if (kEpidNoErr != result) { - return result; - } - return result; -} - -EpidStatus EpidMemberSetHashAlg(MemberCtx* ctx, HashAlg hash_alg) { - if (!ctx) return kEpidBadArgErr; - if (kSha256 != hash_alg && kSha384 != hash_alg && kSha512 != hash_alg) - return kEpidBadArgErr; - ctx->hash_alg = hash_alg; - return kEpidNoErr; -} - -EpidStatus EpidRegisterBaseName(MemberCtx* ctx, void const* basename, - size_t basename_len) { - EpidStatus result = kEpidErr; - if (basename_len == 0) { - return kEpidBadArgErr; - } - if (!ctx || !basename) { - return kEpidBadArgErr; - } - - if (ContainsBasename(ctx->allowed_basenames, basename, basename_len)) { - return kEpidDuplicateErr; - } - - result = AddBasename(&ctx->allowed_basenames, basename, basename_len); - - return result; -} - -void DeleteBasenames(AllowedBasename** rootnode) { - if (rootnode && *rootnode) { - AllowedBasename* currentnode = *rootnode; - while (currentnode) { - AllowedBasename* deletenode = currentnode; - currentnode = currentnode->next; - SAFE_FREE(deletenode); - } - *rootnode = NULL; - } -} - -EpidStatus AddBasename(AllowedBasename** rootnode, void const* basename, - size_t length) { - EpidStatus result = kEpidErr; - AllowedBasename* newnode = NULL; - AllowedBasename* currentnode = NULL; - if (length > (SIZE_MAX - sizeof(AllowedBasename)) + 1) { - return kEpidBadArgErr; - } - if (!basename) { - return kEpidBadArgErr; - } - - newnode = SAFE_ALLOC(sizeof(AllowedBasename) + (length - 1)); - if (!newnode) { - return kEpidMemAllocErr; - } - newnode->next = NULL; - newnode->length = length; - if (0 != memcpy_S(newnode->name, length, basename, length)) { - SAFE_FREE(newnode); - return kEpidBadArgErr; - } - if (*rootnode == NULL) { - *rootnode = newnode; - return kEpidNoErr; - } - currentnode = *rootnode; - while (currentnode->next != NULL) { - currentnode = currentnode->next; - } - currentnode->next = newnode; - result = kEpidNoErr; - - return result; -} - -bool ContainsBasename(AllowedBasename const* rootnode, void const* basename, - size_t length) { - if (length != 0) { - while (rootnode != NULL) { - if (rootnode->length == length) { - if (!memcmp(rootnode->name, basename, length)) { - return true; - } - } - rootnode = rootnode->next; - } - } - return false; -} - -EpidStatus EpidAddPreSigs(MemberCtx* ctx, size_t number_presigs, - PreComputedSignature* presigs) { - PreComputedSignature* new_presigs; - if (!ctx) return kEpidBadArgErr; - if (!ctx->presigs) return kEpidBadArgErr; - - if (0 == number_presigs) return kEpidNoErr; - if (number_presigs > SIZE_MAX / sizeof(PreComputedSignature)) - return kEpidBadArgErr; // integer overflow - - new_presigs = - (PreComputedSignature*)StackPushN(ctx->presigs, number_presigs, presigs); - if (!new_presigs) return kEpidMemAllocErr; - - if (presigs) { - memset(presigs, 0, number_presigs * sizeof(PreComputedSignature)); - } else { - size_t i; - for (i = 0; i < number_presigs; i++) { - EpidStatus sts = EpidComputePreSig(ctx, &new_presigs[i]); - if (kEpidNoErr != sts) { - // roll back pre-computed-signature pool - StackPopN(ctx->presigs, number_presigs, 0); - return sts; - } - } - } - return kEpidNoErr; -} - -size_t EpidGetNumPreSigs(MemberCtx const* ctx) { - return (ctx && ctx->presigs) ? StackGetSize(ctx->presigs) : (size_t)0; -} - -EpidStatus EpidWritePreSigs(MemberCtx* ctx, PreComputedSignature* presigs, - size_t number_presigs) { - if (!ctx || (!presigs && (0 != number_presigs))) return kEpidBadArgErr; - if (!ctx->presigs) return kEpidBadArgErr; - - if (0 == number_presigs) return kEpidNoErr; - - return StackPopN(ctx->presigs, number_presigs, presigs) ? kEpidNoErr - : kEpidBadArgErr; -} - -static EpidStatus DoPrecomputation(MemberCtx* ctx) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; - FfElement* e22 = NULL; - FfElement* e2w = NULL; - FfElement* ea2 = NULL; - Epid2Params_* params = NULL; - GroupPubKey_* pub_key = NULL; - PairingState* ps_ctx = NULL; - if (!ctx) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->GT || - !ctx->epid2_params->pairing_state || !ctx->pub_key || !ctx->priv_key || - !ctx->e12 || !ctx->e22 || !ctx->e2w || !ctx->ea2) { - return kEpidBadArgErr; - } - pub_key = ctx->pub_key; - params = ctx->epid2_params; - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - ea2 = ctx->ea2; - ps_ctx = params->pairing_state; - // do precomputation - // 1. The member computes e12 = pairing(h1, g2). - result = Pairing(ps_ctx, e12, pub_key->h1, params->g2); - if (kEpidNoErr != result) { - return result; - } - // 2. The member computes e22 = pairing(h2, g2). - result = Pairing(ps_ctx, e22, pub_key->h2, params->g2); - if (kEpidNoErr != result) { - return result; - } - // 3. The member computes e2w = pairing(h2, w). - result = Pairing(ps_ctx, e2w, pub_key->h2, pub_key->w); - if (kEpidNoErr != result) { - return result; - } - // 4. The member computes ea2 = pairing(A, g2). - result = Pairing(ps_ctx, ea2, ctx->priv_key->A, params->g2); - if (kEpidNoErr != result) { - return result; - } - return kEpidNoErr; -} - -static EpidStatus ReadPrecomputation(MemberPrecomp const* precomp_str, - MemberCtx* ctx) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; - FfElement* e22 = NULL; - FfElement* e2w = NULL; - FfElement* ea2 = NULL; - FiniteField* GT = NULL; - Epid2Params_* params = NULL; - if (!ctx || !precomp_str) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->GT || !ctx->e12 || !ctx->e22 || - !ctx->e2w || !ctx->ea2) { - return kEpidBadArgErr; - } - params = ctx->epid2_params; - GT = params->GT; - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - ea2 = ctx->ea2; - - result = ReadFfElement(GT, &precomp_str->e12, sizeof(precomp_str->e12), e12); - if (kEpidNoErr != result) { - return result; - } - result = ReadFfElement(GT, &precomp_str->e22, sizeof(precomp_str->e22), e22); - if (kEpidNoErr != result) { - return result; - } - result = ReadFfElement(GT, &precomp_str->e2w, sizeof(precomp_str->e2w), e2w); - if (kEpidNoErr != result) { - return result; - } - result = ReadFfElement(GT, &precomp_str->ea2, sizeof(precomp_str->ea2), ea2); - if (kEpidNoErr != result) { - return result; - } - return kEpidNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/context.h b/sgx-jvm/linux-sgx/external/epid/epid/member/context.h deleted file mode 100644 index 8fa65f21a0..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/context.h +++ /dev/null @@ -1,85 +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_MEMBER_CONTEXT_H_ -#define EPID_MEMBER_CONTEXT_H_ -/*! - * \file - * \brief Member context interface. - */ - -#include -#include "epid/member/api.h" -#include "epid/common/errors.h" -#include "epid/common/epid2params.h" -#include "epid/common/grouppubkey.h" -#include "epid/common/stack.h" -#include "epid/common/commitment.h" -#include "epid/member/privkey.h" - -/// Internal implementation of base name -typedef struct AllowedBasename { - struct AllowedBasename* next; ///< pointer to the next base name - size_t length; ///< size of base name - uint8_t name[1]; ///< base name (flexible array) -} AllowedBasename; - -/// Member context definition -struct MemberCtx { - GroupPubKey_* pub_key; ///< group public key - FfElement* e12; ///< an element in GT - FfElement* e22; ///< an element in GT - FfElement* e2w; ///< an element in GT - FfElement* ea2; ///< an element in GT - Epid2Params_* epid2_params; ///< Intel(R) EPID 2.0 params - PrivKey_* priv_key; ///< Member private key - - BitSupplier rnd_func; ///< Pseudo random number generation function - void* rnd_param; ///< Pointer to user context for rnd_func - HashAlg hash_alg; ///< Hash algorithm to use - AllowedBasename* allowed_basenames; ///< Base name list - Stack* presigs; ///< Pre-computed signatures pool - CommitValues commit_values; ///< Values that are hashed to create commitment -}; - -/// Delete base name list -void DeleteBasenames(AllowedBasename** rootnode); - -/// Add new base name to list -EpidStatus AddBasename(AllowedBasename** rootnode, void const* basename, - size_t length); - -/// Check if given base name exist in the list -bool ContainsBasename(AllowedBasename const* rootnode, void const* basename, - size_t length); - -/// Performs Pre-computation that can be used to speed up signing -/*! - \warning - Do not re-use the same pre-computed signature to generate more than - one signature. If a pre-computed signature is used for computing - two signatures, an attacker could learn the Intel(R) EPID private key. - - \param[in] ctx - The member context. - \param[out] precompsig - The pre-computed signature. - - \returns ::EpidStatus - */ -EpidStatus EpidComputePreSig(MemberCtx const* ctx, - PreComputedSignature* precompsig); - -#endif // EPID_MEMBER_CONTEXT_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/decompress_privkey.c b/sgx-jvm/linux-sgx/external/epid/epid/member/decompress_privkey.c deleted file mode 100644 index 17e400ae49..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/decompress_privkey.c +++ /dev/null @@ -1,290 +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 EpidDecompressPrivKey implementation. - */ - -#include "epid/member/api.h" - -#include "epid/common/memory.h" -#include "epid/common/epid2params.h" -#include "epid/common/math/bignum-internal.h" -#include "epid/common/math/hash.h" -#include "epid/member/privkey.h" - -/// Handle Intel(R) EPID Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -/// Implements the derivation method used by private key decompression -/// Derives two integers x, f between [1, p-1] from the seed value -static EpidStatus DeriveXF(FpElemStr* x, FpElemStr* f, Seed const* seed, - FpElemStr const* p); - -EpidStatus EpidDecompressPrivKey(GroupPubKey const* pub_key, - CompressedPrivKey const* compressed_privkey, - PrivKey* priv_key) { - EpidStatus result = kEpidErr; - Epid2Params_* epid2_params = 0; - PrivKey_ priv_key_ = {{{0}}, 0, 0, 0}; - FfElement* Ax = 0; - EcPoint* t1 = 0; - EcPoint* t2 = 0; - FfElement* t3 = 0; - FfElement* t4 = 0; - BigNum* bn_pminus1 = 0; - BigNum* bn_one = 0; - EcPoint* h1 = 0; - EcPoint* w = 0; - - // check parameters - if (!pub_key || !compressed_privkey || !priv_key) { - return kEpidBadArgErr; - } - - // Internal representation of Epid2Params - result = CreateEpid2Params(&epid2_params); - if (kEpidNoErr != result) { - return result; - } - - do { - uint8_t bn_one_str = 1; - FpElemStr p_str = {0}; - bool is_valid = false; - // shortcuts - EcGroup* G1 = epid2_params->G1; - EcGroup* G2 = epid2_params->G2; - FiniteField* GT = epid2_params->GT; - EcPoint* g1 = epid2_params->g1; - EcPoint* g2 = epid2_params->g2; - PairingState* ps_ctx = epid2_params->pairing_state; - FiniteField* Fp = epid2_params->Fp; - FiniteField* Fq = epid2_params->Fq; - BigNum* p = epid2_params->p; - - // In the following process, temporary variables t1 (an element of - // G2), t2 (an element of G1), t3, t4 (elements of GT) are used. - // Let the compressed private key be (gid, A.x, seed). Let the - // Intel(R) EPID public key be (gid, h1, h2, w). - - // Create a new Priv Key - result = NewEcPoint(G1, &priv_key_.A); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(Fp, &priv_key_.x); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(Fp, &priv_key_.f); - BREAK_ON_EPID_ERROR(result); - - result = NewFfElement(Fq, &Ax); - BREAK_ON_EPID_ERROR(result); - result = NewEcPoint(G2, &t1); - BREAK_ON_EPID_ERROR(result); - result = NewEcPoint(G1, &t2); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(GT, &t3); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(GT, &t4); - BREAK_ON_EPID_ERROR(result); - result = NewBigNum(sizeof(BigNumStr), &bn_pminus1); - BREAK_ON_EPID_ERROR(result); - result = NewBigNum(sizeof(bn_one_str), &bn_one); - BREAK_ON_EPID_ERROR(result); - - result = NewEcPoint(G1, &h1); - BREAK_ON_EPID_ERROR(result); - result = ReadEcPoint(G1, &(pub_key->h1), sizeof(pub_key->h1), h1); - BREAK_ON_EPID_ERROR(result); - result = NewEcPoint(G2, &w); - BREAK_ON_EPID_ERROR(result); - result = ReadEcPoint(G2, &(pub_key->w), sizeof(pub_key->w), w); - BREAK_ON_EPID_ERROR(result); - - result = WriteBigNum(p, sizeof(p_str), &p_str); - BREAK_ON_EPID_ERROR(result); - - result = ReadBigNum(&bn_one_str, sizeof(bn_one_str), bn_one); - BREAK_ON_EPID_ERROR(result); - - // 1. The member derives x and f from seed. The derivation - // function must be the same as the one used in the key - // generation above. This step is out of scope of this - // specification. - result = - DeriveXF(&priv_key->x, &priv_key->f, &compressed_privkey->seed, &p_str); - BREAK_ON_EPID_ERROR(result); - // 2. The member computes A = G1.makePoint(A.x). - result = ReadFfElement(Fq, &compressed_privkey->ax, - sizeof(compressed_privkey->ax), Ax); - BREAK_ON_EPID_ERROR(result); - result = EcMakePoint(G1, Ax, priv_key_.A); - BREAK_ON_EPID_ERROR(result); - // 3. The member tests whether (A, x, f) is a valid Intel(R) EPID - // private key as follows: - // a. It computes t1 = G2.sscmExp(g2, x). - result = EcSscmExp(G2, g2, (BigNumStr const*)&priv_key->x, t1); - BREAK_ON_EPID_ERROR(result); - // b. It computes t1 = G2.mul(t1, w). - result = EcMul(G2, t1, w, t1); - BREAK_ON_EPID_ERROR(result); - // c. It computes t3 = pairing(A, t1). - result = Pairing(ps_ctx, t3, priv_key_.A, t1); - BREAK_ON_EPID_ERROR(result); - // d. It computes t2 = G1.sscmExp(h1, f). - result = EcSscmExp(G1, h1, (BigNumStr const*)&priv_key->f, t2); - BREAK_ON_EPID_ERROR(result); - // e. It computes t2 = G1.mul(t2, g1). - result = EcMul(G1, t2, g1, t2); - BREAK_ON_EPID_ERROR(result); - // f. It computes t4 = pairing(t2, g2). - result = Pairing(ps_ctx, t4, t2, g2); - BREAK_ON_EPID_ERROR(result); - // g. If GT.isEqual(t3, t4) = false - result = FfIsEqual(GT, t3, t4, &is_valid); - BREAK_ON_EPID_ERROR(result); - if (!is_valid) { - // i. It computes t3 = GT.exp(t3, p-1). - result = BigNumSub(p, bn_one, bn_pminus1); - BREAK_ON_EPID_ERROR(result); - result = FfExp(GT, t3, bn_pminus1, t3); - BREAK_ON_EPID_ERROR(result); - // ii. If GT.isEqual(t3, t4) = false again, it reports bad - // Intel(R) EPID private key and exits. - result = FfIsEqual(GT, t3, t4, &is_valid); - BREAK_ON_EPID_ERROR(result); - if (!is_valid) { - result = kEpidBadArgErr; // Invalid Member key - break; - } - // iii. It sets A = G1.inverse(A). - result = EcInverse(G1, priv_key_.A, priv_key_.A); - BREAK_ON_EPID_ERROR(result); - // NOTE A is modified here in this step. - } - // 4. The decompressed Intel(R) EPID private key is (gid, A, x, f). - // x, f already filled in. - memcpy_S(&priv_key->gid, sizeof(priv_key->gid), &pub_key->gid, - sizeof(pub_key->gid)); - result = WriteEcPoint(G1, priv_key_.A, &priv_key->A, sizeof(priv_key->A)); - BREAK_ON_EPID_ERROR(result); - - result = kEpidNoErr; - } while (0); - - DeleteEcPoint(&priv_key_.A); - DeleteFfElement(&priv_key_.x); - DeleteFfElement(&priv_key_.f); - DeleteFfElement(&Ax); - DeleteEcPoint(&t1); - DeleteEcPoint(&t2); - DeleteFfElement(&t3); - DeleteFfElement(&t4); - DeleteBigNum(&bn_pminus1); - DeleteBigNum(&bn_one); - DeleteEcPoint(&h1); - DeleteEcPoint(&w); - DeleteEpid2Params(&epid2_params); - - return result; -} - -static EpidStatus DeriveXF(FpElemStr* x, FpElemStr* f, Seed const* seed, - FpElemStr const* p) { - EpidStatus result = kEpidErr; - - BigNum* bn_x = 0; - BigNum* bn_f = 0; - BigNum* bn_p = 0; - - do { - char msgstr[] = { - 0x00, 0x45, 0x43, 0x43, 0x2d, 0x53, 0x61, 0x66, 0x65, 0x49, 0x44, - }; -#pragma pack(1) - struct { - Seed seed; - char msg[11]; - } hashbuf; -#pragma pack() - - Sha256Digest digest[2]; - Ipp8u str512[512 / 8]; - - result = NewBigNum(sizeof(*p), &bn_p); - BREAK_ON_EPID_ERROR(result); - result = ReadBigNum(p, sizeof(*p), bn_p); - BREAK_ON_EPID_ERROR(result); - - result = NewBigNum(sizeof(digest), &bn_x); - BREAK_ON_EPID_ERROR(result); - result = NewBigNum(sizeof(digest), &bn_f); - BREAK_ON_EPID_ERROR(result); - - // compute x - memcpy_S(&hashbuf.seed, sizeof(hashbuf.seed), seed, sizeof(*seed)); - memcpy_S(&hashbuf.msg[0], sizeof(hashbuf.msg), msgstr, sizeof(msgstr)); - hashbuf.msg[0] = 0x06; - result = Sha256MessageDigest(&hashbuf, sizeof(hashbuf), &digest[0]); - BREAK_ON_EPID_ERROR(result); - hashbuf.msg[0] = 0x07; - result = Sha256MessageDigest(&hashbuf, sizeof(hashbuf), &digest[1]); - BREAK_ON_EPID_ERROR(result); - - result = ReadBigNum(&digest, sizeof(digest), bn_x); - BREAK_ON_EPID_ERROR(result); - - result = BigNumMod(bn_x, bn_p, bn_x); - BREAK_ON_EPID_ERROR(result); - - result = WriteBigNum(bn_x, sizeof(str512), str512); - BREAK_ON_EPID_ERROR(result); - - memcpy_S(x, sizeof(*x), &str512[sizeof(str512) / 2], sizeof(*x)); - - // compute f - memcpy_S(&hashbuf.seed, sizeof(hashbuf.seed), seed, sizeof(*seed)); - memcpy_S(&hashbuf.msg[0], sizeof(hashbuf.msg), msgstr, sizeof(msgstr)); - hashbuf.msg[0] = 0x08; - result = Sha256MessageDigest(&hashbuf, sizeof(hashbuf), &digest[0]); - BREAK_ON_EPID_ERROR(result); - hashbuf.msg[0] = 0x09; - result = Sha256MessageDigest(&hashbuf, sizeof(hashbuf), &digest[1]); - BREAK_ON_EPID_ERROR(result); - - result = ReadBigNum(&digest, sizeof(digest), bn_f); - BREAK_ON_EPID_ERROR(result); - - result = BigNumMod(bn_f, bn_p, bn_f); - BREAK_ON_EPID_ERROR(result); - - result = WriteBigNum(bn_f, sizeof(str512), str512); - BREAK_ON_EPID_ERROR(result); - - memcpy_S(f, sizeof(*f), &str512[sizeof(str512) / 2], sizeof(*f)); - - result = kEpidNoErr; - } while (0); - - DeleteBigNum(&bn_x); - DeleteBigNum(&bn_f); - DeleteBigNum(&bn_p); - - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/get_sigsize.c b/sgx-jvm/linux-sgx/external/epid/epid/member/get_sigsize.c deleted file mode 100644 index c92a21ca2a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/get_sigsize.c +++ /dev/null @@ -1,35 +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 EpidGetSigSize implementation. - */ -#include "epid/member/api.h" -#include "epid/common/endian_convert.h" - -size_t EpidGetSigSize(SigRl const* sig_rl) { - const size_t kMinSigSize = sizeof(EpidSignature) - sizeof(NrProof); - if (!sig_rl) { - return kMinSigSize; - } else { - if (ntohl(sig_rl->n2) > (SIZE_MAX - kMinSigSize) / sizeof(NrProof)) { - return kMinSigSize; - } else { - return kMinSigSize + ntohl(sig_rl->n2) * sizeof(NrProof); - } - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/member.parts b/sgx-jvm/linux-sgx/external/epid/epid/member/member.parts deleted file mode 100644 index aa0766d704..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/member.parts +++ /dev/null @@ -1,99 +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('member') - - - -api_headers = Pattern(src_dir='.', - includes=['api.h'], - excludes=[''], - recursive=False).files() - - -member_headers = Pattern(src_dir='.', - includes=['*.h'], - excludes=['api.h'], - recursive=False).files() - - -src_files = Pattern(src_dir='.', - includes=['*.c'], - excludes=['*-test.cc'], - recursive=True).files() - - -#unit tests -utest_files = Pattern(src_dir='.', - includes=['*-test.cc', - '*-testhelper.cc',], - excludes=[], - recursive=True).files() - -utest_header_files = Pattern(src_dir='.', - includes=['*-testhelper.h',], - excludes=[], - recursive=True).files() - -parts_file = Pattern(src_dir='.', - includes=['member.parts'], - excludes=[], - recursive=False).files() - - -if 'install_package' in env['MODE']: - env.InstallTopLevel(api_headers + member_headers, - sub_dir='epid/${PART_SHORT_NAME}') - env.InstallTopLevel(src_files, sub_dir='epid/${PART_SHORT_NAME}') - env.InstallTopLevel(utest_files, - sub_dir='epid/${PART_SHORT_NAME}/unittests') - env.InstallTopLevel(utest_header_files, - sub_dir='epid/${PART_SHORT_NAME}/unittests') - 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) - env.SdkInclude(api_headers, sub_dir='epid/${PART_SHORT_NAME}') - - if 'install_lib' in env['MODE']: - env.InstallLib(outputs) - env.InstallInclude(api_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') or - env.isConfigBasedOn('static_crt_debug')), - depends=[Component('gtest'), - Component('common-testhelper'), - Component('member'), - Component('verifier')], - INSTALL_BIN='${INSTALL_TEST_BIN}') diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/nr_prove.c b/sgx-jvm/linux-sgx/external/epid/epid/member/nr_prove.c deleted file mode 100644 index ed67b9c68c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/nr_prove.c +++ /dev/null @@ -1,288 +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 EpidNrProve implementation. - */ -#include "epid/common/memory.h" -#include "epid/member/api.h" -#include "epid/member/context.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -#pragma pack(1) -/// Storage for values to create commitment in NrProve algorithm -typedef struct NrVerifyCommitValues { - BigNumStr p; //!< A large prime (256-bit) - G1ElemStr g1; //!< Generator of G1 (512-bit) - G1ElemStr b; //!< (element of G1): part of basic signature Sigma0 - G1ElemStr k; //!< (element of G1): part of basic signature Sigma0 - G1ElemStr bp; //!< (element of G1): one entry in SigRL - G1ElemStr kp; //!< (element of G1): one entry in SigRL - G1ElemStr t; //!< element of G1 - G1ElemStr r1; //!< element of G1 - G1ElemStr r2; //!< element of G1 - uint8_t msg[1]; //!< message -} NrVerifyCommitValues; -#pragma pack() - -EpidStatus EpidNrProve(MemberCtx const* ctx, void const* msg, size_t msg_len, - BasicSignature const* sig, SigRlEntry const* sigrl_entry, - NrProof* proof) { - EpidStatus res = kEpidErr; - NrVerifyCommitValues* commit_values = NULL; - size_t const commit_len = sizeof(*commit_values) - 1 + msg_len; - EcPoint* T = NULL; - EcPoint* R1 = NULL; - EcPoint* R2 = NULL; - FfElement* mu = NULL; - FfElement* nu = NULL; - FfElement* rmu = NULL; - FfElement* rnu = NULL; - FfElement* c = NULL; - FfElement* smu = NULL; - FfElement* snu = NULL; - EcPoint* B = NULL; - EcPoint* K = NULL; - EcPoint* rlB = NULL; - EcPoint* rlK = NULL; - FfElement const* f = NULL; - if (!ctx || (0 != msg_len && !msg) || !sig || !sigrl_entry || !proof) - return kEpidBadArgErr; - if (msg_len > ((SIZE_MAX - sizeof(*commit_values)) + 1)) - return kEpidBadArgErr; - if (!ctx->epid2_params || !ctx->priv_key) return kEpidBadArgErr; - - do { - bool is_identity = false; - BigNumStr mu_str = {0}; - BigNumStr nu_str = {0}; - BigNumStr rmu_str = {0}; - BigNumStr rnu_str = {0}; - BitSupplier rnd_func = ctx->rnd_func; - void* rnd_param = ctx->rnd_param; - FiniteField* Fp = ctx->epid2_params->Fp; - EcGroup* G1 = ctx->epid2_params->G1; - static const BigNumStr one = { - {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}}; - - // Check required parameters - if (!ctx->priv_key->f || !rnd_func || !Fp || !G1) return kEpidBadArgErr; - - f = ctx->priv_key->f; - - commit_values = SAFE_ALLOC(commit_len); - if (!commit_values) { - res = kEpidMemAllocErr; - break; - } - - // The following variables T, R1, R2 (elements of G1), and mu, nu, - // rmu, rnu, c, smu, snu (256-bit integers) are used. - res = NewEcPoint(G1, &T); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &R1); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &R2); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &mu); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &nu); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &rmu); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &rnu); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &c); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &smu); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &snu); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &B); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &K); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &rlB); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &rlK); - BREAK_ON_EPID_ERROR(res); - - res = ReadEcPoint(G1, (const uint8_t*)&(sig->B), sizeof(sig->B), B); - BREAK_ON_EPID_ERROR(res); - res = ReadEcPoint(G1, (const uint8_t*)&(sig->K), sizeof(sig->K), K); - BREAK_ON_EPID_ERROR(res); - res = ReadEcPoint(G1, (const uint8_t*)&(sigrl_entry->b), - sizeof(sigrl_entry->b), rlB); - BREAK_ON_EPID_ERROR(res); - res = ReadEcPoint(G1, (const uint8_t*)&(sigrl_entry->k), - sizeof(sigrl_entry->k), rlK); - BREAK_ON_EPID_ERROR(res); - - // 1. The member chooses random mu from [1, p-1]. - res = FfGetRandom(Fp, &one, rnd_func, rnd_param, mu); - BREAK_ON_EPID_ERROR(res); - // 2. The member computes nu = (- f * mu) mod p. - res = FfMul(Fp, mu, f, nu); - BREAK_ON_EPID_ERROR(res); - res = FfNeg(Fp, nu, nu); - BREAK_ON_EPID_ERROR(res); - // 3. The member computes T = G1.sscmMultiExp(K', mu, B', nu). - res = WriteFfElement(Fp, mu, (uint8_t*)&mu_str, sizeof(mu_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, nu, (uint8_t*)&nu_str, sizeof(nu_str)); - BREAK_ON_EPID_ERROR(res); - { - EcPoint const* points[2]; - BigNumStr const* exponents[2]; - points[0] = rlK; - points[1] = rlB; - exponents[0] = &mu_str; - exponents[1] = &nu_str; - res = EcSscmMultiExp(G1, points, exponents, COUNT_OF(points), T); - BREAK_ON_EPID_ERROR(res); - } - // 4. The member chooses rmu, rnu randomly from [1, p-1]. - res = FfGetRandom(Fp, &one, rnd_func, rnd_param, rmu); - BREAK_ON_EPID_ERROR(res); - res = FfGetRandom(Fp, &one, rnd_func, rnd_param, rnu); - BREAK_ON_EPID_ERROR(res); - // 5. The member computes R1 = G1.sscmMultiExp(K, rmu, B, rnu). - res = WriteFfElement(Fp, rmu, (uint8_t*)&rmu_str, sizeof(rmu_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, rnu, (uint8_t*)&rnu_str, sizeof(rnu_str)); - BREAK_ON_EPID_ERROR(res); - { - EcPoint const* points[2]; - BigNumStr const* exponents[2]; - points[0] = K; - points[1] = B; - exponents[0] = &rmu_str; - exponents[1] = &rnu_str; - res = EcSscmMultiExp(G1, points, exponents, COUNT_OF(points), R1); - BREAK_ON_EPID_ERROR(res); - } - // 6. The member computes R2 = G1.sscmMultiExp(K', rmu, B', rnu). - { - EcPoint const* points[2]; - BigNumStr const* exponents[2]; - points[0] = rlK; - points[1] = rlB; - exponents[0] = &rmu_str; - exponents[1] = &rnu_str; - res = EcSscmMultiExp(G1, points, exponents, COUNT_OF(points), R2); - BREAK_ON_EPID_ERROR(res); - } - // 7. The member computes c = Fp.hash(p || g1 || B || K || B' || - // K' || T || R1 || R2 || m). Refer to Section 7.1 for hash - // operation over a prime field. - - // commit_values is allocated such that there are msg_len bytes available - // starting at commit_values->msg - if (msg) { - if (0 != memcpy_S(&commit_values->msg[0], msg_len, msg, msg_len)) { - res = kEpidBadArgErr; - break; - } - } - if (0 != memcpy_S(&commit_values->p, sizeof(commit_values->p), - &ctx->commit_values.p, sizeof(ctx->commit_values.p))) { - res = kEpidBadArgErr; - break; - } - if (0 != memcpy_S(&commit_values->g1, sizeof(commit_values->g1), - &ctx->commit_values.g1, sizeof(ctx->commit_values.g1))) { - res = kEpidBadArgErr; - break; - } - commit_values->b = sig->B; - commit_values->k = sig->K; - commit_values->bp = sigrl_entry->b; - commit_values->kp = sigrl_entry->k; - res = WriteEcPoint(G1, T, (uint8_t*)&commit_values->t, - sizeof(commit_values->t)); - BREAK_ON_EPID_ERROR(res); - res = WriteEcPoint(G1, R1, (uint8_t*)&commit_values->r1, - sizeof(commit_values->r1)); - BREAK_ON_EPID_ERROR(res); - res = WriteEcPoint(G1, R2, (uint8_t*)&commit_values->r2, - sizeof(commit_values->r2)); - BREAK_ON_EPID_ERROR(res); - res = FfHash(Fp, (uint8_t*)commit_values, commit_len, ctx->hash_alg, c); - BREAK_ON_EPID_ERROR(res); - - // 8. The member computes smu = (rmu + c * mu) mod p. - res = FfMul(Fp, c, mu, smu); - BREAK_ON_EPID_ERROR(res); - res = FfAdd(Fp, rmu, smu, smu); - BREAK_ON_EPID_ERROR(res); - // 9. The member computes snu = (rnu + c * nu) mod p. - res = FfMul(Fp, c, nu, snu); - BREAK_ON_EPID_ERROR(res); - res = FfAdd(Fp, rnu, snu, snu); - BREAK_ON_EPID_ERROR(res); - // 10. The member outputs sigma = (T, c, smu, snu), a non-revoked - // proof. If G1.is_identity(T) = true, the member also outputs - // "failed". - - if (0 != memcpy_S(&proof->T, sizeof(proof->T), &commit_values->t, - sizeof(commit_values->t))) { - res = kEpidBadArgErr; - break; - } - res = WriteFfElement(Fp, c, (uint8_t*)&proof->c, sizeof(proof->c)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, smu, (uint8_t*)&proof->smu, sizeof(proof->smu)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, snu, (uint8_t*)&proof->snu, sizeof(proof->snu)); - BREAK_ON_EPID_ERROR(res); - - res = EcIsIdentity(G1, T, &is_identity); - BREAK_ON_EPID_ERROR(res); - if (is_identity) { - res = kEpidSigRevokedinSigRl; - BREAK_ON_EPID_ERROR(res); - } - res = kEpidNoErr; - } while (0); - - f = NULL; - SAFE_FREE(commit_values) - DeleteEcPoint(&T); - DeleteEcPoint(&R1); - DeleteEcPoint(&R2); - DeleteFfElement(&mu); - DeleteFfElement(&nu); - DeleteFfElement(&rmu); - DeleteFfElement(&rnu); - DeleteFfElement(&c); - DeleteFfElement(&smu); - DeleteFfElement(&snu); - DeleteEcPoint(&B); - DeleteEcPoint(&K); - DeleteEcPoint(&rlB); - DeleteEcPoint(&rlK); - - return res; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/presig.c b/sgx-jvm/linux-sgx/external/epid/epid/member/presig.c deleted file mode 100644 index 8f1279bcde..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/presig.c +++ /dev/null @@ -1,229 +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 EpidComputePreSig implementation. - */ - -#include "epid/member/context.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -EpidStatus EpidComputePreSig(MemberCtx const* ctx, - PreComputedSignature* precompsig) { - EpidStatus res = kEpidNotImpl; - - EcPoint* B = NULL; - EcPoint* K = NULL; - EcPoint* T = NULL; - EcPoint* R1 = NULL; - - FfElement* R2 = NULL; - - FfElement* a = NULL; - FfElement* b = NULL; - FfElement* rx = NULL; - FfElement* rf = NULL; - FfElement* ra = NULL; - FfElement* rb = NULL; - FfElement* t1 = NULL; - FfElement* t2 = NULL; - FfElement* f = NULL; - - if (!ctx || !precompsig) return kEpidBadArgErr; - if (!ctx->epid2_params || !ctx->pub_key || !ctx->priv_key) - return kEpidBadArgErr; - - do { - // handy shorthands: - EcGroup* G1 = ctx->epid2_params->G1; - FiniteField* GT = ctx->epid2_params->GT; - FiniteField* Fp = ctx->epid2_params->Fp; - EcPoint* h2 = ctx->pub_key->h2; - EcPoint* A = ctx->priv_key->A; - FfElement* x = ctx->priv_key->x; - BigNumStr f_str = {0}; - BigNumStr a_str = {0}; - BigNumStr t1_str = {0}; - BigNumStr rf_str = {0}; - BigNumStr t2_str = {0}; - BigNumStr ra_str = {0}; - static const BigNumStr one = { - {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}}; - - if (!G1 || !GT || !Fp || !h2 || !A || !x || !ctx->priv_key->f || - !ctx->e12 || !ctx->e22 || !ctx->e2w || !ctx->ea2) { - res = kEpidBadArgErr; - BREAK_ON_EPID_ERROR(res); - } - f = ctx->priv_key->f; - // The following variables B, K, T, R1 (elements of G1), R2 - // (elements of GT), a, b, rx, rf, ra, rb, t1, t2 (256-bit - // integers) are used. - res = NewEcPoint(G1, &B); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &K); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &T); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &R1); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(GT, &R2); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &a); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &b); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &rx); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &rf); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &ra); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &rb); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &t1); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &t2); - BREAK_ON_EPID_ERROR(res); - // 1. The member expects the pre-computation is done (e12, e22, e2w, - // ea2). Refer to Section 3.5 for the computation of these - // values. - - // 2. The member verifies gid in public key matches gid in private - // key. - // 3. The member computes B = G1.getRandom(). - res = EcGetRandom(G1, ctx->rnd_func, ctx->rnd_param, B); - BREAK_ON_EPID_ERROR(res); - // 4. The member computes K = G1.sscmExp(B, f). - res = WriteFfElement(Fp, f, &f_str, sizeof(f_str)); - BREAK_ON_EPID_ERROR(res); - res = EcExp(G1, B, &f_str, K); - BREAK_ON_EPID_ERROR(res); - // 5. The member chooses randomly an integers a from [1, p-1]. - res = FfGetRandom(Fp, &one, ctx->rnd_func, ctx->rnd_param, a); - BREAK_ON_EPID_ERROR(res); - // 6. The member computes T = G1.sscmExp(h2, a). - res = WriteFfElement(Fp, a, &a_str, sizeof(a_str)); - BREAK_ON_EPID_ERROR(res); - res = EcExp(G1, h2, &a_str, T); - BREAK_ON_EPID_ERROR(res); - // 7. The member computes T = G1.mul(T, A). - res = EcMul(G1, T, A, T); - BREAK_ON_EPID_ERROR(res); - // 8. The member computes b = (a * x) mod p. - res = FfMul(Fp, a, x, b); - BREAK_ON_EPID_ERROR(res); - // 9. The member chooses rx, rf, ra, rb randomly from [1, p-1]. - res = FfGetRandom(Fp, &one, ctx->rnd_func, ctx->rnd_param, rx); - BREAK_ON_EPID_ERROR(res); - res = FfGetRandom(Fp, &one, ctx->rnd_func, ctx->rnd_param, rf); - BREAK_ON_EPID_ERROR(res); - res = FfGetRandom(Fp, &one, ctx->rnd_func, ctx->rnd_param, ra); - BREAK_ON_EPID_ERROR(res); - res = FfGetRandom(Fp, &one, ctx->rnd_func, ctx->rnd_param, rb); - BREAK_ON_EPID_ERROR(res); - // 10. The member computes t1 = (- rx) mod p. - res = FfNeg(Fp, rx, t1); - BREAK_ON_EPID_ERROR(res); - // 11. The member computes t2 = (rb - a * rx) mod p. - res = FfMul(Fp, a, rx, t2); - BREAK_ON_EPID_ERROR(res); - res = FfNeg(Fp, t2, t2); - BREAK_ON_EPID_ERROR(res); - res = FfAdd(Fp, rb, t2, t2); - BREAK_ON_EPID_ERROR(res); - // 12. The member computes R1 = G1.sscmExp(B, rf). - res = WriteFfElement(Fp, rf, &rf_str, sizeof(rf_str)); - BREAK_ON_EPID_ERROR(res); - res = EcExp(G1, B, &rf_str, R1); - BREAK_ON_EPID_ERROR(res); - // 13. The member computes R2 = GT.sscmMultiExp(ea2, t1, e12, rf, - // e22, t2, e2w, ra). - res = WriteFfElement(Fp, t1, &t1_str, sizeof(t1_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, t2, &t2_str, sizeof(t2_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, ra, &ra_str, sizeof(ra_str)); - BREAK_ON_EPID_ERROR(res); - { - FfElement const* points[4]; - BigNumStr const* exponents[4]; - points[0] = ctx->ea2; - points[1] = ctx->e12; - points[2] = ctx->e22; - points[3] = ctx->e2w; - exponents[0] = &t1_str; - exponents[1] = &rf_str; - exponents[2] = &t2_str; - exponents[3] = &ra_str; - res = FfMultiExp(GT, points, exponents, COUNT_OF(points), R2); - BREAK_ON_EPID_ERROR(res); - } - // 14. The member sets and outputs pre-sigma = (B, K, T, a, b, rx, - // rf, ra, rb, R1, R2). - res = WriteEcPoint(G1, B, &precompsig->B, sizeof(precompsig->B)); - BREAK_ON_EPID_ERROR(res); - res = WriteEcPoint(G1, K, &precompsig->K, sizeof(precompsig->K)); - BREAK_ON_EPID_ERROR(res); - res = WriteEcPoint(G1, T, &precompsig->T, sizeof(precompsig->T)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, a, &precompsig->a, sizeof(precompsig->a)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, b, &precompsig->b, sizeof(precompsig->b)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, rx, &precompsig->rx, sizeof(precompsig->rx)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, rf, &precompsig->rf, sizeof(precompsig->rf)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, ra, &precompsig->ra, sizeof(precompsig->ra)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, rb, &precompsig->rb, sizeof(precompsig->rb)); - BREAK_ON_EPID_ERROR(res); - res = WriteEcPoint(G1, R1, &precompsig->R1, sizeof(precompsig->R1)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(GT, R2, &precompsig->R2, sizeof(precompsig->R2)); - BREAK_ON_EPID_ERROR(res); - // 15. The member stores pre-sigma in the secure storage of the - // member. - res = kEpidNoErr; - } while (0); - - f = NULL; - DeleteEcPoint(&B); - DeleteEcPoint(&K); - DeleteEcPoint(&T); - DeleteEcPoint(&R1); - DeleteFfElement(&R2); - DeleteFfElement(&a); - DeleteFfElement(&b); - DeleteFfElement(&rx); - DeleteFfElement(&rf); - DeleteFfElement(&ra); - DeleteFfElement(&rb); - DeleteFfElement(&t1); - DeleteFfElement(&t2); - - return (res); -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.c b/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.c deleted file mode 100644 index bb24046053..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.c +++ /dev/null @@ -1,88 +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 Private key implementation. - */ - -#include "epid/common/memory.h" -#include "epid/member/privkey.h" - -EpidStatus CreatePrivKey(PrivKey const* priv_key_str, EcGroup* G1, - FiniteField* Fp, PrivKey_** priv_key) { - EpidStatus result = kEpidErr; - PrivKey_* priv_key_ = NULL; - - // check parameters - if (!priv_key_str || !G1 || !Fp || !priv_key) return kEpidBadArgErr; - - do { - priv_key_ = SAFE_ALLOC(sizeof(*priv_key_)); - - if (!priv_key_) { - result = kEpidMemAllocErr; - break; - } - - result = NewEcPoint(G1, &priv_key_->A); - if (kEpidNoErr != result) break; - - result = NewFfElement(Fp, &priv_key_->x); - if (kEpidNoErr != result) break; - - result = NewFfElement(Fp, &priv_key_->f); - if (kEpidNoErr != result) break; - - if (0 != memcpy_S(&priv_key_->gid, sizeof(priv_key_->gid), - &priv_key_str->gid, sizeof(priv_key_str->gid))) { - result = kEpidBadArgErr; - break; - } - - result = ReadEcPoint(G1, &priv_key_str->A, sizeof(priv_key_str->A), - priv_key_->A); - if (kEpidNoErr != result) break; - - result = ReadFfElement(Fp, &priv_key_str->x, sizeof(priv_key_str->x), - priv_key_->x); - if (kEpidNoErr != result) break; - - result = ReadFfElement(Fp, &priv_key_str->f, sizeof(priv_key_str->f), - priv_key_->f); - if (kEpidNoErr != result) break; - - *priv_key = priv_key_; - result = kEpidNoErr; - } while (0); - - if (kEpidNoErr != result) { - DeletePrivKey(&priv_key_); - } - - return (result); -} - -void DeletePrivKey(PrivKey_** priv_key) { - if (priv_key) { - if (*priv_key) { - DeleteEcPoint(&((*priv_key)->A)); - DeleteFfElement(&((*priv_key)->x)); - DeleteFfElement(&((*priv_key)->f)); - } - SAFE_FREE(*priv_key); - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.h b/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.h deleted file mode 100644 index b75185dbf4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/privkey.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_MEMBER_PRIVKEY_H_ -#define EPID_MEMBER_PRIVKEY_H_ -/*! -* \file - * \brief Private key private interface. -* \addtogroup EpidCommon -* @{ -*/ -#include "epid/common/errors.h" -#include "epid/common/math/ecgroup.h" -#include "epid/common/types.h" - -/*! - * \brief - * Internal implementation of PrivKey - */ -typedef struct PrivKey_ { - GroupId gid; ///< group ID - EcPoint* A; ///< an element in G1 - FfElement* x; ///< an integer between [0, p-1] - FfElement* f; ///< an integer between [0, p-1] -} PrivKey_; - -/// Constructs internal representation of PrivKey -/*! - This function allocates memory and initializes gid, A, x, f parameters. - - \param[in] priv_key_str - Serialized representation of private key - \param[in] G1 - EcGroup containing element A - \param[in] Fp - FiniteField containing elements x and f - \param[out] priv_key - Newly created private key: (gid, A, x, f) - - \returns ::EpidStatus -*/ -EpidStatus CreatePrivKey(PrivKey const* priv_key_str, EcGroup* G1, - FiniteField* Fp, PrivKey_** priv_key); - -/// Deallocate storage for internal representation of PrivKey -/*! - Frees memory pointed to by Member private key. Nulls the pointer. - - \param[in] priv_key - Member private key to be freed -*/ -void DeletePrivKey(PrivKey_** priv_key); - -/*! @} */ -#endif // EPID_MEMBER_PRIVKEY_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/request_join.c b/sgx-jvm/linux-sgx/external/epid/epid/member/request_join.c deleted file mode 100644 index 0e825e96a8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/request_join.c +++ /dev/null @@ -1,418 +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 EpidRequestJoin implementation. - */ - -#include -#include -#include "epid/common/epid2params.h" -#include "epid/common/math/finitefield.h" -#include "epid/common/math/ecgroup.h" - -#pragma pack(1) -/// Storage for values to create commitment in Sign and Verify algorithms -typedef struct JoinPCommitValues { - BigNumStr p; ///< Intel(R) EPID 2.0 parameter p - G1ElemStr g1; ///< Intel(R) EPID 2.0 parameter g1 - G2ElemStr g2; ///< Intel(R) EPID 2.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 F; ///< Variable F computed in algorithm - G1ElemStr R; ///< Variable R computed in algorithm - IssuerNonce NI; ///< Nonce -} JoinPCommitValues; -#pragma pack() - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -EpidStatus EpidRequestJoin(GroupPubKey const* pub_key, IssuerNonce const* ni, - FpElemStr const* f, BitSupplier rnd_func, - void* rnd_param, HashAlg hash_alg, - JoinRequest* join_request) { - EpidStatus sts; - static const BigNumStr one = { - {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}}; - BigNumStr r_str; - JoinPCommitValues commit_values; - Epid2Params_* params = NULL; - FfElement* r_el = NULL; - FfElement* f_el = NULL; - FfElement* c_el = NULL; - FfElement* cf_el = NULL; - FfElement* s_el = NULL; - EcPoint* f_pt = NULL; - EcPoint* r_pt = NULL; - EcPoint* h1_pt = NULL; - - if (!pub_key || !ni || !f || !rnd_func || !join_request) { - return kEpidBadArgErr; - } - if (kSha256 != hash_alg && kSha384 != hash_alg && kSha512 != hash_alg) { - return kEpidBadArgErr; - } - - do { - sts = CreateEpid2Params(¶ms); - BREAK_ON_EPID_ERROR(sts); - if (!params->Fp || !params->G1) { - sts = kEpidBadArgErr; - break; - } - sts = NewFfElement(params->Fp, &r_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(params->Fp, &f_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(params->Fp, &c_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(params->Fp, &cf_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(params->Fp, &s_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(params->G1, &f_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(params->G1, &h1_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(params->G1, &r_pt); - BREAK_ON_EPID_ERROR(sts); - - sts = ReadFfElement(params->Fp, (uint8_t const*)f, sizeof(*f), f_el); - BREAK_ON_EPID_ERROR(sts); - sts = ReadEcPoint(params->G1, (uint8_t*)&pub_key->h1, sizeof(pub_key->h1), - h1_pt); - BREAK_ON_EPID_ERROR(sts); - - // Step 1. The member chooses a random integer r from [1, p-1]. - sts = FfGetRandom(params->Fp, &one, rnd_func, rnd_param, r_el); - BREAK_ON_EPID_ERROR(sts); - sts = WriteFfElement(params->Fp, r_el, (uint8_t*)&r_str, sizeof(r_str)); - - // Step 2. The member computes F = G1.sscmExp(h1, f). - sts = EcExp(params->G1, h1_pt, (BigNumStr const*)f, f_pt); - BREAK_ON_EPID_ERROR(sts); - - // Step 3. The member computes R = G1.sscmExp(h1, r). - sts = EcExp(params->G1, h1_pt, (BigNumStr const*)&r_str, r_pt); - BREAK_ON_EPID_ERROR(sts); - - // Step 4. The member computes c = Fp.hash(p || g1 || g2 || h1 || h2 || w || - // F || R || NI). Refer to Section 7.1 for hash operation over a prime - // field. - sts = WriteBigNum(params->p, sizeof(commit_values.p), - (uint8_t*)&commit_values.p); - BREAK_ON_EPID_ERROR(sts); - sts = WriteEcPoint(params->G1, params->g1, (uint8_t*)&commit_values.g1, - sizeof(commit_values.g1)); - BREAK_ON_EPID_ERROR(sts); - sts = WriteEcPoint(params->G2, params->g2, (uint8_t*)&commit_values.g2, - sizeof(commit_values.g2)); - BREAK_ON_EPID_ERROR(sts); - commit_values.h1 = pub_key->h1; - commit_values.h2 = pub_key->h2; - commit_values.w = pub_key->w; - sts = WriteEcPoint(params->G1, f_pt, (uint8_t*)&commit_values.F, - sizeof(commit_values.F)); - BREAK_ON_EPID_ERROR(sts); - sts = WriteEcPoint(params->G1, r_pt, (uint8_t*)&commit_values.R, - sizeof(commit_values.R)); - BREAK_ON_EPID_ERROR(sts); - commit_values.NI = *ni; - sts = FfHash(params->Fp, (uint8_t*)&commit_values, sizeof(commit_values), - hash_alg, c_el); - BREAK_ON_EPID_ERROR(sts); - - // Step 5. The member computes s = (r + c * f) mod p. - sts = FfMul(params->Fp, c_el, f_el, cf_el); - BREAK_ON_EPID_ERROR(sts); - sts = FfAdd(params->Fp, r_el, cf_el, s_el); - BREAK_ON_EPID_ERROR(sts); - - // Step 6. The output join request is (F, c, s). - sts = WriteFfElement(params->Fp, c_el, (uint8_t*)&join_request->c, - sizeof(join_request->c)); - BREAK_ON_EPID_ERROR(sts); - sts = WriteFfElement(params->Fp, s_el, (uint8_t*)&join_request->s, - sizeof(join_request->s)); - BREAK_ON_EPID_ERROR(sts); - sts = WriteEcPoint(params->G1, f_pt, (uint8_t*)&join_request->F, - sizeof(join_request->F)); - BREAK_ON_EPID_ERROR(sts); - - sts = kEpidNoErr; - } while (0); - DeleteEcPoint(&h1_pt); - DeleteEcPoint(&r_pt); - DeleteEcPoint(&f_pt); - DeleteFfElement(&s_el); - DeleteFfElement(&cf_el); - DeleteFfElement(&c_el); - DeleteFfElement(&f_el); - DeleteFfElement(&r_el); - DeleteEpid2Params(¶ms); - return sts; -} - -// implements section 3.2.2 "Validation of Private Key" from -// Intel(R) EPID 2.0 Spec -bool EpidIsPrivKeyInGroup(GroupPubKey const* pub_key, PrivKey const* priv_key) { - bool result; - - // Intel(R) EPID Parameters - Epid2Params_* params = NULL; - PairingState* ps = NULL; - - // private key - EcPoint* a_pt = NULL; // an element in G1 - FfElement* x_el = NULL; // an integer between [1, p-1] - FfElement* f_el = NULL; // an integer between [1, p-1] - - // public key - EcPoint* h1_pt = NULL; // an element in G1 - EcPoint* h2_pt = NULL; // an element in G1 - EcPoint* w_pt = NULL; // an element in G2 - - // local variables - EcPoint* t1_pt = NULL; // an element in G2 - EcPoint* t2_pt = NULL; // an element in G1 - FfElement* t3_el = NULL; // an element in GT - FfElement* t4_el = NULL; // an element in GT - - if (!pub_key || !priv_key) { - return false; - } - - do { - EpidStatus sts; - EcGroup* G1 = NULL; - EcGroup* G2 = NULL; - FiniteField* GT = NULL; - FiniteField* Fp = NULL; - BigNumStr t_str = {0}; - - sts = CreateEpid2Params(¶ms); - if (kEpidNoErr != sts) { - result = false; - break; - } - - G1 = params->G1; - G2 = params->G2; - GT = params->GT; - Fp = params->Fp; - - sts = WriteBigNum(params->t, sizeof(t_str), &t_str); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewPairingState(G1, G2, GT, &t_str, params->neg, &ps); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Load private key - sts = NewEcPoint(G1, &a_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadEcPoint(G1, &priv_key->A, sizeof(priv_key->A), a_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewFfElement(Fp, &x_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadFfElement(Fp, &priv_key->x, sizeof(priv_key->x), x_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewFfElement(Fp, &f_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadFfElement(Fp, &priv_key->f, sizeof(priv_key->f), f_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Load public key - sts = NewEcPoint(G1, &h1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadEcPoint(G1, &pub_key->h1, sizeof(pub_key->h1), h1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewEcPoint(G1, &h2_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadEcPoint(G1, &pub_key->h2, sizeof(pub_key->h2), h2_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewEcPoint(G2, &w_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = ReadEcPoint(G2, &pub_key->w, sizeof(pub_key->w), w_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // local variables - sts = NewEcPoint(G2, &t1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewEcPoint(G1, &t2_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewFfElement(GT, &t3_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = NewFfElement(GT, &t4_el); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 1. The member verifies that the gid in the public key matches the - // gid in the private key. - if (0 != memcmp(&pub_key->gid, &priv_key->gid, sizeof(priv_key->gid))) { - result = false; - break; - } - - // Step 2. The member computes t1 = G2.sscmExp(g2, x). - sts = EcSscmExp(G2, params->g2, (BigNumStr const*)&priv_key->x, t1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 3. The member computes t1 = G2.mul(t1, w). - sts = EcMul(G2, t1_pt, w_pt, t1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 4. The member computes t3 = pairing(A, t1). - sts = Pairing(ps, t3_el, a_pt, t1_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 5. The member computes t2 = G1.sscmExp(h1, f). - sts = EcSscmExp(G1, h1_pt, (BigNumStr const*)&priv_key->f, t2_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 6. The member computes t2 = G1.mul(t2, g1). - sts = EcMul(G1, t2_pt, params->g1, t2_pt); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 7. The member computes t4 = pairing(t2, g2). - sts = WriteBigNum(params->t, sizeof(t_str), &t_str); - if (kEpidNoErr != sts) { - result = false; - break; - } - - sts = Pairing(ps, t4_el, t2_pt, params->g2); - if (kEpidNoErr != sts) { - result = false; - break; - } - - // Step 8. If GT.isEqual(t3, t4) = false, reports bad private key. - sts = FfIsEqual(GT, t3_el, t4_el, &result); - if (kEpidNoErr != sts) { - result = false; - break; - } - } while (0); - - // local variables - DeleteFfElement(&t4_el); - DeleteFfElement(&t3_el); - DeleteEcPoint(&t2_pt); - DeleteEcPoint(&t1_pt); - - // public key - DeleteEcPoint(&w_pt); - DeleteEcPoint(&h2_pt); - DeleteEcPoint(&h1_pt); - - // private key - DeleteFfElement(&f_el); - DeleteFfElement(&x_el); - DeleteEcPoint(&a_pt); - - // Intel(R) EPID Parameters - DeletePairingState(&ps); - DeleteEpid2Params(¶ms); - - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/sign.c b/sgx-jvm/linux-sgx/external/epid/epid/member/sign.c deleted file mode 100644 index 8dd2170242..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/sign.c +++ /dev/null @@ -1,110 +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 EpidSign implementation. - */ - -#include -#include "epid/common/endian_convert.h" -#include "epid/common/memory.h" -#include "epid/common/sigrlvalid.h" -#include "epid/member/api.h" -#include "epid/member/context.h" - -EpidStatus EpidSign(MemberCtx const* ctx, void const* msg, size_t msg_len, - void const* basename, size_t basename_len, - SigRl const* sig_rl, size_t sig_rl_size, EpidSignature* sig, - size_t sig_len) { - EpidStatus result = kEpidErr; - uint32_t num_sig_rl = 0; - OctStr32 octstr32_0 = {{0x00, 0x00, 0x00, 0x00}}; - if (!ctx || !sig) { - return kEpidBadArgErr; - } - if (!ctx->pub_key) { - return kEpidBadArgErr; - } - if (!msg && (0 != msg_len)) { - // if message is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!basename && (0 != basename_len)) { - // if basename is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (sig_rl && (sig_rl_size < sizeof(SigRl) - sizeof(SigRlEntry))) { - return kEpidBadArgErr; - } - if (sig_rl && EpidGetSigSize(sig_rl) > sig_len) { - return kEpidBadArgErr; - } - - // 11. The member sets sigma0 = (B, K, T, c, sx, sf, sa, sb). - result = - EpidSignBasic(ctx, msg, msg_len, basename, basename_len, &sig->sigma0); - if (kEpidNoErr != result) { - return result; - } - - if (!sig_rl) { - // 12. If SigRL is not provided as input, - // a. The member sets RLver = 0 and n2 = 0. - // b. The member outputs (sigma0, RLver, n2) and returns "succeeded". - sig->rl_ver = octstr32_0; - sig->n2 = octstr32_0; - return kEpidNoErr; - } else { - uint32_t i = 0; - EpidStatus nr_prove_status = kEpidNoErr; - // 13. If SigRL is provided as input, the member proceeds with - // the following steps: - // a. The member verifies that gid in public key and in SigRL - // match. - if (!IsSigRlValid(&ctx->pub_key->gid, sig_rl, sig_rl_size)) { - return kEpidBadArgErr; - } - // b. The member copies RLver and n2 values in SigRL to the - // signature. - if (0 != memcpy_S(&sig->rl_ver, sizeof(sig->rl_ver), &sig_rl->version, - sizeof(sig_rl->version))) - return kEpidBadArgErr; - if (0 != - memcpy_S(&sig->n2, sizeof(sig->n2), &sig_rl->n2, sizeof(sig_rl->n2))) - return kEpidBadArgErr; - // c. For i = 0, ..., n2-1, the member computes sigma[i] = - // nrProve(f, B, K, B[i], K[i]). The details of nrProve() - // will be given in the next subsection. - num_sig_rl = ntohl(sig_rl->n2); - for (i = 0; i < num_sig_rl; i++) { - result = EpidNrProve(ctx, msg, msg_len, &sig->sigma0, &sig_rl->bk[i], - &sig->sigma[i]); - if (kEpidNoErr != result) { - nr_prove_status = result; - } - } - if (kEpidNoErr != nr_prove_status) { - memset(&sig->sigma[0], 0, num_sig_rl * sizeof(sig->sigma[0])); - return nr_prove_status; - } - } - // d. The member outputs (sigma0, RLver, n2, sigma[0], ..., - // sigma[n2-1]). - // e. If any of the nrProve() functions outputs "failed", the - // member returns "revoked", otherwise returns "succeeded". - return kEpidNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/signbasic.c b/sgx-jvm/linux-sgx/external/epid/epid/member/signbasic.c deleted file mode 100644 index dc3227dd18..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/signbasic.c +++ /dev/null @@ -1,272 +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 EpidSignBasic implementation. - */ - -#include // memset - -#include "epid/common/stack.h" -#include "epid/member/api.h" -#include "epid/member/context.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -EpidStatus EpidSignBasic(MemberCtx const* ctx, void const* msg, size_t msg_len, - void const* basename, size_t basename_len, - BasicSignature* sig) { - EpidStatus result = kEpidErr; - // Values to be affected by basename - EcPoint* B = NULL; - EcPoint* K = NULL; - EcPoint* R1 = NULL; - // data from presig - EcPoint* T = NULL; - FfElement* a = NULL; - FfElement* b = NULL; - FfElement* rx = NULL; - FfElement* rf = NULL; - FfElement* ra = NULL; - FfElement* rb = NULL; - FfElement* R2 = NULL; - - // final calculatoin data - FfElement* sx = NULL; - FfElement* sf = NULL; - FfElement* sa = NULL; - FfElement* sb = NULL; - FfElement* c_hash = NULL; - // priv key data, need to clear after use - BigNumStr f_str = {0}; - if (!ctx || !sig) { - return kEpidBadArgErr; - } - if (!msg && (0 != msg_len)) { - // if message is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!basename && (0 != basename_len)) { - // if basename is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->priv_key || !ctx->epid2_params->G1 || - !ctx->epid2_params->GT || !ctx->epid2_params->Fp || !ctx->priv_key->f) { - return kEpidBadArgErr; - } - - do { - PreComputedSignature curr_presig; - G1ElemStr B_str = {0}; - G1ElemStr K_str = {0}; - CommitValues commit_values = ctx->commit_values; - - // create all required elemnts - result = NewEcPoint(ctx->epid2_params->G1, &B); - BREAK_ON_EPID_ERROR(result); - result = NewEcPoint(ctx->epid2_params->G1, &K); - BREAK_ON_EPID_ERROR(result); - result = NewEcPoint(ctx->epid2_params->G1, &R1); - BREAK_ON_EPID_ERROR(result); - - result = NewEcPoint(ctx->epid2_params->G1, &T); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->GT, &R2); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &sx); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &sf); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &sa); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &sb); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &c_hash); - BREAK_ON_EPID_ERROR(result); - - result = NewFfElement(ctx->epid2_params->Fp, &a); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &b); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &rx); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &rf); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &ra); - BREAK_ON_EPID_ERROR(result); - result = NewFfElement(ctx->epid2_params->Fp, &rb); - BREAK_ON_EPID_ERROR(result); - - if (StackGetSize(ctx->presigs)) { - // Use existing pre-computed signature - if (!StackPopN(ctx->presigs, 1, &curr_presig)) { - result = kEpidErr; - break; - } - } else { - // generate a new pre-computed signature - result = EpidComputePreSig(ctx, &curr_presig); - BREAK_ON_EPID_ERROR(result); - } - // 3. If the pre-computed signature pre-sigma exists, the member - // loads (B, K, T, a, b, rx, rf, ra, rb, R1, R2) from - // pre-sigma. Refer to Section 4.4 for the computation of - // these values. - result = ReadEcPoint(ctx->epid2_params->G1, &curr_presig.B, - sizeof(curr_presig.B), B); - BREAK_ON_EPID_ERROR(result); - result = ReadEcPoint(ctx->epid2_params->G1, &curr_presig.K, - sizeof(curr_presig.K), K); - BREAK_ON_EPID_ERROR(result); - result = ReadEcPoint(ctx->epid2_params->G1, &curr_presig.T, - sizeof(curr_presig.T), T); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.a, - sizeof(curr_presig.a), a); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.b, - sizeof(curr_presig.b), b); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.rx, - sizeof(curr_presig.rx), rx); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.rf, - sizeof(curr_presig.rf), rf); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.ra, - sizeof(curr_presig.ra), ra); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->Fp, &curr_presig.rb, - sizeof(curr_presig.rb), rb); - BREAK_ON_EPID_ERROR(result); - result = ReadEcPoint(ctx->epid2_params->G1, &curr_presig.R1, - sizeof(curr_presig.R1), R1); - BREAK_ON_EPID_ERROR(result); - result = ReadFfElement(ctx->epid2_params->GT, &curr_presig.R2, - sizeof(curr_presig.R2), R2); - BREAK_ON_EPID_ERROR(result); - - if (basename) { - // If basename is provided, the member does the following: - // make sure basename is registered/allowed - if (!ContainsBasename(ctx->allowed_basenames, basename, basename_len)) { - result = kEpidBadArgErr; - break; - } else { - // basename valid, can modify parameters - // a. The member computes B = G1.hash(bsn). - result = EcHash(ctx->epid2_params->G1, basename, basename_len, - ctx->hash_alg, B); - BREAK_ON_EPID_ERROR(result); - // b. The member computes K = G1.sscmExp(B, f), where B comes - // from step a. - result = WriteFfElement(ctx->epid2_params->Fp, ctx->priv_key->f, &f_str, - sizeof(f_str)); - BREAK_ON_EPID_ERROR(result); - result = EcSscmExp(ctx->epid2_params->G1, B, &f_str, K); - BREAK_ON_EPID_ERROR(result); - // c. The member computes R1 = G1.sscmExp(B, rf), where B comes - // from step a. - result = EcSscmExp(ctx->epid2_params->G1, B, - (const BigNumStr*)&curr_presig.rf, R1); - BREAK_ON_EPID_ERROR(result); - // d. The member over-writes the B, K, and R1 values. - } - } - // 5. The member computes t3 = Fp.hash(p || g1 || g2 || h1 || h2 - // || w || B || K || T || R1 || R2). Refer to Section 7.1 for - // hash operation over a prime field. - // 6. The member computes c = Fp.hash(t3 || m). - result = WriteEcPoint(ctx->epid2_params->G1, B, &B_str, sizeof(B_str)); - BREAK_ON_EPID_ERROR(result); - result = WriteEcPoint(ctx->epid2_params->G1, K, &K_str, sizeof(K_str)); - BREAK_ON_EPID_ERROR(result); - result = SetCalculatedCommitValues(&B_str, &K_str, &curr_presig.T, R1, - ctx->epid2_params->G1, R2, - ctx->epid2_params->GT, &commit_values); - BREAK_ON_EPID_ERROR(result); - result = CalculateCommitmentHash(&commit_values, ctx->epid2_params->Fp, - ctx->hash_alg, msg, msg_len, c_hash); - BREAK_ON_EPID_ERROR(result); - // 7. The member computes sx = (rx + c * x) mod p. - result = FfMul(ctx->epid2_params->Fp, c_hash, ctx->priv_key->x, sx); - BREAK_ON_EPID_ERROR(result); - result = FfAdd(ctx->epid2_params->Fp, rx, sx, sx); - // 8. The member computes sf = (rf + c * f) mod p. - result = FfMul(ctx->epid2_params->Fp, c_hash, ctx->priv_key->f, sf); - BREAK_ON_EPID_ERROR(result); - result = FfAdd(ctx->epid2_params->Fp, rf, sf, sf); - BREAK_ON_EPID_ERROR(result); - // 9. The member computes sa = (ra + c * a) mod p. - result = FfMul(ctx->epid2_params->Fp, c_hash, a, sa); - BREAK_ON_EPID_ERROR(result); - result = FfAdd(ctx->epid2_params->Fp, ra, sa, sa); - BREAK_ON_EPID_ERROR(result); - // 10. The member computes sb = (rb + c * b) mod p. - result = FfMul(ctx->epid2_params->Fp, c_hash, b, sb); - BREAK_ON_EPID_ERROR(result); - result = FfAdd(ctx->epid2_params->Fp, rb, sb, sb); - BREAK_ON_EPID_ERROR(result); - // 11. The member sets sigma0 = (B, K, T, c, sx, sf, sa, sb). - result = WriteEcPoint(ctx->epid2_params->G1, B, &sig->B, sizeof(sig->B)); - BREAK_ON_EPID_ERROR(result); - result = WriteEcPoint(ctx->epid2_params->G1, K, &sig->K, sizeof(sig->K)); - BREAK_ON_EPID_ERROR(result); - result = WriteEcPoint(ctx->epid2_params->G1, T, &sig->T, sizeof(sig->T)); - BREAK_ON_EPID_ERROR(result); - result = - WriteFfElement(ctx->epid2_params->Fp, c_hash, &sig->c, sizeof(sig->c)); - BREAK_ON_EPID_ERROR(result); - result = - WriteFfElement(ctx->epid2_params->Fp, sx, &sig->sx, sizeof(sig->sx)); - BREAK_ON_EPID_ERROR(result); - result = - WriteFfElement(ctx->epid2_params->Fp, sf, &sig->sf, sizeof(sig->sf)); - BREAK_ON_EPID_ERROR(result); - result = - WriteFfElement(ctx->epid2_params->Fp, sa, &sig->sa, sizeof(sig->sa)); - BREAK_ON_EPID_ERROR(result); - result = - WriteFfElement(ctx->epid2_params->Fp, sb, &sig->sb, sizeof(sig->sb)); - BREAK_ON_EPID_ERROR(result); - result = kEpidNoErr; - } while (0); - // remove all data - DeleteEcPoint(&B); - DeleteEcPoint(&K); - DeleteEcPoint(&R1); - - DeleteEcPoint(&T); - DeleteFfElement(&R2); - DeleteFfElement(&sx); - DeleteFfElement(&sf); - DeleteFfElement(&sa); - DeleteFfElement(&sb); - DeleteFfElement(&c_hash); - DeleteFfElement(&a); - DeleteFfElement(&b); - DeleteFfElement(&rx); - DeleteFfElement(&rf); - DeleteFfElement(&ra); - DeleteFfElement(&rb); - - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/compute_presig-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/compute_presig-test.cc deleted file mode 100644 index 74dc1c9af2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/compute_presig-test.cc +++ /dev/null @@ -1,93 +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 ComputePreSig unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/member/context.h" -} - -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.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" -#include "epid/common-testhelper/epid_params-testhelper.h" - -namespace { - -TEST_F(EpidMemberTest, ComputePreSigFailsGivenNullPointer) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig; - EXPECT_EQ(kEpidBadArgErr, EpidComputePreSig(nullptr, &presig)); - EXPECT_EQ(kEpidBadArgErr, EpidComputePreSig(member, nullptr)); -} - -TEST_F(EpidMemberTest, - ComputePreSigGeneratedPreComputedSignatureCanBeDeserialized) { - 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}}}; - - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig; - EXPECT_EQ(kEpidNoErr, EpidComputePreSig(member, &presig)); - - Epid20Params params; - FiniteFieldObj Fp(p_str); - FfElementObj Fp_element(&Fp); - - FfElementObj GT_element(¶ms.GT); - EcPointObj G1_pt(¶ms.G1); - - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(params.G1, &presig.B, sizeof(presig.B), G1_pt)); - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(params.G1, &presig.K, sizeof(presig.K), G1_pt)); - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(params.G1, &presig.T, sizeof(presig.T), G1_pt)); - EXPECT_EQ(kEpidNoErr, - ReadEcPoint(params.G1, &presig.R1, sizeof(presig.R1), G1_pt)); - EXPECT_EQ(kEpidNoErr, ReadFfElement(params.GT, &presig.R2, sizeof(presig.R2), - GT_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.a, sizeof(presig.a), Fp_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.b, sizeof(presig.b), Fp_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.rx, sizeof(presig.rx), Fp_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.rf, sizeof(presig.rf), Fp_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.ra, sizeof(presig.ra), Fp_element)); - EXPECT_EQ(kEpidNoErr, - ReadFfElement(Fp, &presig.rb, sizeof(presig.rb), Fp_element)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/context-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/context-test.cc deleted file mode 100644 index 84a58e282a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/context-test.cc +++ /dev/null @@ -1,264 +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 Member unit tests. - */ -#include -#include -#include "gtest/gtest.h" - -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/member/unittests/member-testhelper.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/member/context.h" -} -bool operator==(MemberPrecomp const& lhs, MemberPrecomp const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -namespace { -////////////////////////////////////////////////////////////////////////// -// EpidMemberDelete Tests -TEST_F(EpidMemberTest, DeleteWorksGivenNullMemberCtx) { - EpidMemberDelete(nullptr); - MemberCtx* member_ctx = nullptr; - EpidMemberDelete(&member_ctx); -} -TEST_F(EpidMemberTest, DeleteNullsMemberCtx) { - MemberCtx* ctx = nullptr; - Prng my_prng; - EpidMemberCreate(nullptr, &this->member_private_key, &this->member_precomp, - &Prng::Generate, &my_prng, &ctx); - EpidMemberDelete(&ctx); - EXPECT_EQ(nullptr, ctx); -} -////////////////////////////////////////////////////////////////////////// -// EpidMemberCreate Tests -// test that create fails if any mandatory parameters are NULL -TEST_F(EpidMemberTest, CreateFailsGivenNullParameters) { - MemberCtx* member_ctx = nullptr; - Prng my_prng; - EXPECT_EQ(kEpidBadArgErr, - EpidMemberCreate(nullptr, &this->member_private_key, - &this->member_precomp, &Prng::Generate, &my_prng, - &member_ctx)); - EpidMemberDelete(&member_ctx); - - EXPECT_EQ( - kEpidBadArgErr, - EpidMemberCreate(&this->group_public_key, nullptr, &this->member_precomp, - &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); - - EXPECT_EQ( - kEpidBadArgErr, - EpidMemberCreate(&this->group_public_key, &this->member_private_key, - &this->member_precomp, nullptr, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); - - EXPECT_EQ(kEpidBadArgErr, - EpidMemberCreate(&this->group_public_key, &this->member_private_key, - &this->member_precomp, &Prng::Generate, &my_prng, - nullptr)); - EpidMemberDelete(nullptr); -} - -// test that create succeeds with valid parameters -TEST_F(EpidMemberTest, CreateSucceedsGivenValidParameters) { - MemberCtx* member_ctx = nullptr; - Prng my_prng; - - // pass the whole list of parameters - EXPECT_EQ(kEpidNoErr, - EpidMemberCreate(&this->group_public_key, &this->member_private_key, - &this->member_precomp, &Prng::Generate, &my_prng, - &member_ctx)); - EpidMemberDelete(&member_ctx); - - // pass the whole list of parameters but member_precomp - EXPECT_EQ(kEpidNoErr, - EpidMemberCreate(&this->group_public_key, &this->member_private_key, - nullptr, &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); -} -// test that create succeeds with valid IKGF given parameters -TEST_F(EpidMemberTest, CreateSucceedsGivenValidParametersUsingIKGFData) { - const GroupPubKey grp_public_key = { -#include "epid/common/testdata/ikgf/groupa/pubkey.inc" - }; - const PrivKey mbr_private_key = { -#include "epid/common/testdata/ikgf/groupa/member0/mprivkey.inc" - }; - - const MemberPrecomp mbr_precomp = { -#include "epid/common/testdata/ikgf/groupa/member0/mprecomp.inc" - }; - - MemberCtx* member_ctx = nullptr; - Prng my_prng; - - // pass the whole list of parameters - EXPECT_EQ(kEpidNoErr, - EpidMemberCreate(&grp_public_key, &mbr_private_key, &mbr_precomp, - &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); - - // pass the whole list of parameters but member_precomp - EXPECT_EQ(kEpidNoErr, - EpidMemberCreate(&grp_public_key, &mbr_private_key, nullptr, - &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); -} - -TEST_F(EpidMemberTest, CreateFailsForInvalidGroupPubKey) { - MemberCtx* member_ctx = nullptr; - Prng my_prng; - GroupPubKey gpk_h1 = this->group_public_key; - gpk_h1.h1.x.data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidMemberCreate(&gpk_h1, &this->member_private_key, - &this->member_precomp, &Prng::Generate, &my_prng, - &member_ctx)); - EpidMemberDelete(&member_ctx); - GroupPubKey gpk_h2 = this->group_public_key; - gpk_h2.h2.x.data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidMemberCreate(&gpk_h2, &this->member_private_key, - &this->member_precomp, &Prng::Generate, &my_prng, - &member_ctx)); - EpidMemberDelete(&member_ctx); - GroupPubKey gpk_w = this->group_public_key; - gpk_w.w.x[0].data.data[0]++; - EXPECT_EQ( - kEpidBadArgErr, - EpidMemberCreate(&gpk_w, &this->member_private_key, &this->member_precomp, - &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); -} -TEST_F(EpidMemberTest, CreateFailsForInvalidPrivateKey) { - MemberCtx* member_ctx = nullptr; - Prng my_prng; - PrivKey pk_A = this->member_private_key; - pk_A.A.x.data.data[0]++; - EXPECT_EQ( - kEpidBadArgErr, - EpidMemberCreate(&this->group_public_key, &pk_A, &this->member_precomp, - &Prng::Generate, &my_prng, &member_ctx)); - EpidMemberDelete(&member_ctx); -} - -////////////////////////////////////////////////////////////////////////// -// EpidMemberSetHashAlg -TEST_F(EpidMemberTest, SetHashAlgFailsGivenNullPtr) { - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(nullptr, kSha256)); -} -TEST_F(EpidMemberTest, SetHashAlgCanSetValidAlgorithm) { - Prng my_prng; - MemberCtxObj member_ctx(this->group_public_key, this->member_private_key, - &Prng::Generate, &my_prng); - EXPECT_EQ(kEpidNoErr, EpidMemberSetHashAlg(member_ctx, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidMemberSetHashAlg(member_ctx, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidMemberSetHashAlg(member_ctx, kSha512)); -} -TEST_F(EpidMemberTest, SetHashAlgFailsForNonSupportedAlgorithm) { - Prng my_prng; - MemberCtxObj member_ctx(this->group_public_key, this->member_private_key, - &Prng::Generate, &my_prng); - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(member_ctx, kSha512_256)); - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(member_ctx, kSha3_256)); - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(member_ctx, kSha3_384)); - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(member_ctx, kSha3_512)); - EXPECT_EQ(kEpidBadArgErr, EpidMemberSetHashAlg(member_ctx, (HashAlg)-1)); -} -////////////////////////////////////////////////////////////////////////// -// EpidRegisterBaseName -TEST_F(EpidMemberTest, RegisterBaseNameFailsGivenNullPtr) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector basename = {'_', 'b', 'a', 's', 'e', 'n', 'a', 'm', 'e'}; - EXPECT_EQ(kEpidBadArgErr, - EpidRegisterBaseName(member, nullptr, basename.size())); - EXPECT_EQ(kEpidBadArgErr, - EpidRegisterBaseName(nullptr, basename.data(), basename.size())); -} -TEST_F(EpidMemberTest, RegisterBaseNameFailsGivenDuplicateBaseName) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector basename = {'d', 'b', 'a', 's', 'e', 'n', 'a', 'm', 'e'}; - EXPECT_EQ(kEpidNoErr, - EpidRegisterBaseName(member, basename.data(), basename.size())); - EXPECT_EQ(kEpidDuplicateErr, - EpidRegisterBaseName(member, basename.data(), basename.size())); -} -TEST_F(EpidMemberTest, RegisterBaseNameFailsGivenInvalidBaseName) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector basename = {}; - std::vector basename2 = {'b', 's', 'n'}; - EXPECT_EQ(kEpidBadArgErr, - EpidRegisterBaseName(member, basename.data(), basename.size())); - EXPECT_EQ(kEpidBadArgErr, EpidRegisterBaseName(member, basename2.data(), 0)); -} -TEST_F(EpidMemberTest, RegisterBaseNameSucceedsGivenUniqueBaseName) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector basename = {'b', 's', 'n', '0', '1'}; - EXPECT_EQ(kEpidNoErr, - EpidRegisterBaseName(member, basename.data(), basename.size())); -} -////////////////////////////////////////////////////////////////////////// -// EpidMemberWritePrecomp -TEST_F(EpidMemberTest, MemberWritePrecompFailsGivenNullPointer) { - MemberPrecomp precomp; - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - MemberCtx* ctx = member; - EXPECT_EQ(kEpidBadArgErr, EpidMemberWritePrecomp(nullptr, &precomp)); - EXPECT_EQ(kEpidBadArgErr, EpidMemberWritePrecomp(ctx, nullptr)); -} -TEST_F(EpidMemberTest, MemberWritePrecompSucceedGivenValidArgument) { - MemberPrecomp precomp; - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - MemberCtx* ctx = member; - EXPECT_EQ(kEpidNoErr, EpidMemberWritePrecomp(ctx, &precomp)); - MemberPrecomp expected_precomp = this->member_precomp; - EXPECT_EQ(expected_precomp, precomp); - - MemberCtxObj member2(this->group_public_key, this->member_private_key, - &Prng::Generate, &my_prng); - MemberCtx* ctx2 = member2; - EXPECT_EQ(kEpidNoErr, EpidMemberWritePrecomp(ctx2, &precomp)); - EXPECT_EQ(expected_precomp, precomp); -} -TEST_F(EpidMemberTest, DefaultHashAlgIsSha512) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - MemberCtx* ctx = member; - EXPECT_EQ(kSha512, ctx->hash_alg); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/decompress_privkey-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/decompress_privkey-test.cc deleted file mode 100644 index 380e1ddca6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/decompress_privkey-test.cc +++ /dev/null @@ -1,97 +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 DecompressPrivKey unit tests. - */ -#include -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -} - -#include "epid/member/unittests/member-testhelper.h" - -bool operator==(PrivKey const& lhs, PrivKey const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -namespace { - -TEST_F(EpidMemberTest, DecompressPrivKeyFailsGivenNullParameters) { - auto const& pub_key = this->kGrpXKey; - auto const& compressed_privkey = this->kGrpXMember9CompressedKey; - PrivKey priv_key = {}; - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(nullptr, &compressed_privkey, &priv_key)); - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key, nullptr, &priv_key)); - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key, &compressed_privkey, nullptr)); -} - -TEST_F(EpidMemberTest, CanDecompressPrivKeyGivenValidCompressedKey) { - auto const& pub_key = this->kGrpXKey; - auto const& compressed_privkey = this->kGrpXMember9CompressedKey; - auto const& expected_decompressed_key = this->kGrpXMember9PrivKey; - PrivKey priv_key = {}; - EXPECT_EQ(kEpidNoErr, - EpidDecompressPrivKey(&pub_key, &compressed_privkey, &priv_key)); - EXPECT_EQ(expected_decompressed_key, priv_key); -} - -TEST_F(EpidMemberTest, DecompressPrivKeyFailsGivenKeysMissmatch) { - auto const& pub_key = this->kGrpYKey; - auto const& compressed_privkey = this->kGrpXMember9CompressedKey; - PrivKey priv_key = {}; - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key, &compressed_privkey, &priv_key)); -} - -TEST_F(EpidMemberTest, DecompressPrivKeyFailsGivenInvalidGroupKey) { - // Test for cases when h1 or w of group public key are invalid. - // Note h2 of group public key is not used for key decompression. - auto const& compressed_privkey = this->kGrpXMember9CompressedKey; - PrivKey priv_key = {}; - - auto pub_key_h1 = this->kGrpXKey; - pub_key_h1.h1.x.data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key_h1, &compressed_privkey, &priv_key)); - - auto pub_key_w = this->kGrpXKey; - pub_key_w.w.x[0].data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key_w, &compressed_privkey, &priv_key)); -} - -TEST_F(EpidMemberTest, DecompressPrivKeyFailsGivenInvalidCompressedKey) { - auto const& pub_key = this->kGrpXKey; - PrivKey priv_key = {}; - - auto compressed_privkey_ax = this->kGrpXMember9CompressedKey; - compressed_privkey_ax.ax.data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidDecompressPrivKey(&pub_key, &compressed_privkey_ax, &priv_key)); - - auto compressed_privkey_seed = this->kGrpXMember9CompressedKey; - compressed_privkey_seed.seed.data[0]++; - EXPECT_EQ(kEpidBadArgErr, EpidDecompressPrivKey( - &pub_key, &compressed_privkey_seed, &priv_key)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/get_sigsize-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/get_sigsize-test.cc deleted file mode 100644 index 043de171c1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/get_sigsize-test.cc +++ /dev/null @@ -1,96 +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 GetSigSize unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -} - -#include "epid/member/unittests/member-testhelper.h" - -namespace { - -TEST_F(EpidMemberTest, GetSigSizeReturnsSizeofBasicSigGivenNullPointer) { - size_t sig_size_without_sig_rl = sizeof(EpidSignature) - sizeof(NrProof); - EXPECT_EQ(sig_size_without_sig_rl, EpidGetSigSize(nullptr)); -} - -TEST_F(EpidMemberTest, GetSigSizeReturnsCorrectValueGivenValidSigRl) { - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - OctStr32 octstr32_0 = {0x00, 0x00, 0x00, 0x00}; - OctStr32 octstr32_1 = {0x00, 0x00, 0x00, 0x01}; - OctStr32 octstr32_2 = {0x00, 0x00, 0x00, 0x02}; - OctStr32 octstr32_16 = {0x00, 0x00, 0x00, 0x10}; - OctStr32 octstr32_256 = {0x00, 0x00, 0x01, 0x00}; - OctStr32 octstr32_65536 = {0x00, 0x01, 0x00, 0x00}; - OctStr32 octstr32_4294967295 = {0xff, 0xff, 0xff, 0xff}; - - size_t one_entry_size = sizeof(NrProof); - size_t sig_size_0_entries = sizeof(EpidSignature) - one_entry_size; - size_t sig_size_1_entry = sig_size_0_entries + one_entry_size; - size_t sig_size_2_entries = sig_size_0_entries + 2 * one_entry_size; - size_t sig_size_16_entries = sig_size_0_entries + 16 * one_entry_size; - size_t sig_size_256_entries = sig_size_0_entries + 256 * one_entry_size; - size_t sig_size_65536_entries = sig_size_0_entries + 65536 * one_entry_size; - // no entries - srl.n2 = octstr32_0; - EXPECT_EQ(sig_size_0_entries, EpidGetSigSize(&srl)); - // 1 entry - srl.n2 = octstr32_1; - EXPECT_EQ(sig_size_1_entry, EpidGetSigSize(&srl)); - // 2 entries - srl.n2 = octstr32_2; - EXPECT_EQ(sig_size_2_entries, EpidGetSigSize(&srl)); - // 16 entries - srl.n2 = octstr32_16; - EXPECT_EQ(sig_size_16_entries, EpidGetSigSize(&srl)); - // 256 entries - srl.n2 = octstr32_256; - EXPECT_EQ(sig_size_256_entries, EpidGetSigSize(&srl)); - // 65536 entries - srl.n2 = octstr32_65536; - EXPECT_EQ(sig_size_65536_entries, EpidGetSigSize(&srl)); - // 4294967295 entries - srl.n2 = octstr32_4294967295; -#if (SIZE_MAX <= 0xFFFFFFFF) // When size_t value is 32 bit or lower - EXPECT_EQ(sig_size_0_entries, EpidGetSigSize(&srl)); -#else - size_t sig_size_4294967295_entries = - sig_size_0_entries + 4294967295 * one_entry_size; - EXPECT_EQ(sig_size_4294967295_entries, EpidGetSigSize(&srl)); -#endif -} - -TEST_F(EpidMemberTest, - GetSigSizeReturnsCorrectValueGivenValidSigRlUsingIKGFData) { - const std::vector sigrl_bin = { -#include "epid/common/testdata/ikgf/groupa/sigrl.inc" - }; - - SigRl const* sig_rl = reinterpret_cast(sigrl_bin.data()); - size_t sig_size_3_entries = - sizeof(EpidSignature) - sizeof(NrProof) + 3 * sizeof(NrProof); - // 3 entries - EXPECT_EQ(sig_size_3_entries, EpidGetSigSize(sig_rl)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/main-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/main-test.cc deleted file mode 100644 index 70f2d3a182..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/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/member/unittests/member-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/member-testhelper.cc deleted file mode 100644 index 64d1f2e66c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/member-testhelper.cc +++ /dev/null @@ -1,522 +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 Member C++ wrapper implementation. - */ - -#include "epid/member/unittests/member-testhelper.h" - -#include -#include - -MemberCtxObj::MemberCtxObj(GroupPubKey const& pub_key, PrivKey const& priv_key, - BitSupplier rnd_func, void* rnd_param) - : ctx_(nullptr) { - auto sts = EpidMemberCreate(&pub_key, &priv_key, nullptr, rnd_func, rnd_param, - &ctx_); - if (kEpidNoErr != sts) { - printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:"); - throw std::logic_error(std::string("Failed to call: ") + - "EpidMemberCreate()"); - } -} - -MemberCtxObj::MemberCtxObj(GroupPubKey const& pub_key, PrivKey const& priv_key, - MemberPrecomp const& precomp, BitSupplier rnd_func, - void* rnd_param) - : ctx_(nullptr) { - auto sts = EpidMemberCreate(&pub_key, &priv_key, &precomp, rnd_func, - rnd_param, &ctx_); - if (kEpidNoErr != sts) { - printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:"); - throw std::logic_error(std::string("Failed to call: ") + - "EpidMemberCreate()"); - } -} - -MemberCtxObj::~MemberCtxObj() { EpidMemberDelete(&ctx_); } - -MemberCtx* MemberCtxObj::ctx() const { return ctx_; } - -MemberCtxObj::operator MemberCtx*() const { return ctx_; } - -MemberCtxObj::operator const MemberCtx*() const { return ctx_; } - -/// Arbitrary test data were generated based on Intel(R) EPID 2.0 parameters -const GroupPubKey EpidMemberTest::group_public_key = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01}, // group id - {{{{0xb3, 0x6f, 0xff, 0x81, 0xe2, 0x1b, 0x17, 0xeb, 0x3d, 0x75, 0x3d, 0x61, - 0x7e, 0x27, 0xb0, 0xcb, 0xd0, 0x6d, 0x8f, 0x9d, 0x64, 0xce, 0xe3, 0xce, - 0x43, 0x4c, 0x62, 0xfd, 0xb5, 0x80, 0xe0, 0x99}}}, - {{{0x3a, 0x07, 0x56, 0x80, 0xe0, 0x88, 0x59, 0xa4, 0xfd, 0xb5, 0xb7, 0x9d, - 0xe9, 0x4d, 0xae, 0x9c, 0xee, 0x3d, 0x66, 0x42, 0x82, 0x45, 0x7e, 0x7f, - 0xd8, 0x69, 0x3e, 0xa1, 0x74, 0xf4, 0x59, 0xee}}}}, // h1 - {{{{0xd2, 0x74, 0x2e, 0x9f, 0x63, 0xc2, 0x51, 0x8e, 0xd5, 0xdb, 0xca, 0x1c, - 0x54, 0x74, 0x10, 0x7b, 0xdc, 0x99, 0xed, 0x42, 0xd5, 0x5b, 0xa7, 0x04, - 0x29, 0x66, 0x61, 0x63, 0xbc, 0xdd, 0x7f, 0xe1}}}, - {{{0x76, 0x5d, 0xc0, 0x6e, 0xe3, 0x14, 0xac, 0x72, 0x48, 0x12, 0x0a, 0xa6, - 0xe8, 0x5b, 0x08, 0x7b, 0xda, 0x3f, 0x51, 0x7d, 0xde, 0x4c, 0xea, 0xcb, - 0x93, 0xa5, 0x6e, 0xcc, 0xe7, 0x8e, 0x10, 0x84}}}}, // h2 - {{{{{0xbd, 0x19, 0x5a, 0x95, 0xe2, 0x0f, 0xca, 0x1c, 0x50, 0x71, 0x94, 0x51, - 0x40, 0x1b, 0xa5, 0xb6, 0x78, 0x87, 0x53, 0xf6, 0x6a, 0x95, 0xca, 0xc6, - 0x8d, 0xcd, 0x36, 0x88, 0x7, 0x28, 0xe8, 0x96}}}, - {{{0xca, 0x78, 0x11, 0x5b, 0xb8, 0x6a, 0xe7, 0xe5, 0xa6, 0x65, 0x7a, 0x68, - 0x15, 0xd7, 0x75, 0xf8, 0x24, 0x14, 0xcf, 0xd1, 0x0f, 0x6c, 0x56, 0xf5, - 0x22, 0xd9, 0xfd, 0xe0, 0xe2, 0xf4, 0xb3, 0xa1}}}}, - {{{{0x90, 0x21, 0xa7, 0xe0, 0xe8, 0xb3, 0xc7, 0x25, 0xbc, 0x07, 0x72, 0x30, - 0x5d, 0xee, 0xf5, 0x6a, 0x89, 0x88, 0x46, 0xdd, 0x89, 0xc2, 0x39, 0x9c, - 0x0a, 0x3b, 0x58, 0x96, 0x57, 0xe4, 0xf3, 0x3c}}}, - {{{0x79, 0x51, 0x69, 0x36, 0x1b, 0xb6, 0xf7, 0x05, 0x5d, 0x0a, 0x88, 0xdb, - 0x1f, 0x3d, 0xea, 0xa2, 0xba, 0x6b, 0xf0, 0xda, 0x8e, 0x25, 0xc6, 0xad, - 0x83, 0x7d, 0x3e, 0x31, 0xee, 0x11, 0x40, 0xa9}}}}} // w -}; - -const PrivKey EpidMemberTest::member_private_key = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01}, // group id - {{{{0x46, 0xc9, 0x69, 0xee, 0xf4, 0x68, 0xe1, 0x5f, 0xac, 0xbf, 0xdd, 0x77, - 0xeb, 0x4c, 0xaf, 0x8a, 0x87, 0x68, 0x3f, 0x4e, 0xda, 0xf2, 0x96, 0xec, - 0x57, 0x08, 0x90, 0xe8, 0x19, 0x62, 0x54, 0xdb}}}, - {{{0x1e, 0x52, 0x23, 0x16, 0x91, 0xe4, 0xa8, 0x1d, 0x9a, 0x1b, 0x8a, 0xad, - 0x0a, 0xcf, 0x36, 0x4f, 0xae, 0x43, 0xde, 0x62, 0xff, 0xa6, 0x4b, 0xa8, - 0x16, 0x24, 0x98, 0x80, 0x82, 0x80, 0x37, 0x77}}}}, // A - {0x0a, 0x30, 0xae, 0x43, 0xa1, 0xe0, 0xd7, 0xdf, 0x10, 0x5e, 0xaf, 0xd8, - 0x5a, 0x61, 0x10, 0x86, 0xd0, 0x9d, 0xb9, 0xe4, 0x46, 0xdd, 0xb7, 0x1b, - 0x00, 0x14, 0x7c, 0x6b, 0x13, 0x72, 0xc3, 0x77}, // x - {0x48, 0x40, 0xb5, 0x6c, 0x6d, 0x47, 0x09, 0x0b, 0x05, 0xd6, 0x43, 0x56, - 0xe0, 0x7c, 0xc6, 0x8e, 0xa1, 0x65, 0x67, 0xfd, 0xa7, 0x07, 0x87, 0x9b, - 0x36, 0x2d, 0x41, 0x35, 0x63, 0x61, 0x31, 0xc7} // f -}; - -const MemberPrecomp EpidMemberTest::member_precomp = { - {0xd8, 0x14, 0xba, 0x4b, 0x44, 0x03, 0x55, 0x6c, 0xf6, 0x42, 0xe8, 0xf0, - 0x4c, 0xb5, 0xe7, 0xd4, 0xa2, 0xa3, 0x69, 0x47, 0xf5, 0xd4, 0xc8, 0xe9, - 0xc5, 0x5a, 0x39, 0xb5, 0x55, 0xa5, 0xd3, 0xfb, 0xf3, 0x85, 0x5a, 0x0d, - 0xd5, 0xee, 0xde, 0xf4, 0xa8, 0xb1, 0x8b, 0xcf, 0xa9, 0x0d, 0x29, 0xbf, - 0x86, 0x27, 0x9c, 0x1f, 0x96, 0xed, 0xd8, 0x44, 0x01, 0x35, 0x1a, 0xce, - 0xfd, 0x4e, 0x6f, 0xa1, 0x66, 0x0d, 0x59, 0x08, 0x6d, 0xa2, 0xe4, 0x99, - 0x83, 0xdc, 0x39, 0x28, 0xb7, 0x1c, 0x1a, 0x33, 0xad, 0xca, 0x5c, 0x35, - 0x26, 0x1f, 0xab, 0xba, 0x0d, 0x53, 0xaf, 0xe0, 0x72, 0x14, 0xc5, 0xa7, - 0x2e, 0x58, 0x26, 0xc9, 0x8e, 0xfa, 0x6f, 0x62, 0xfc, 0xf0, 0x08, 0x3e, - 0xa3, 0x11, 0x3a, 0xf0, 0xb8, 0x3b, 0x2d, 0x3e, 0xec, 0xd5, 0xbc, 0xf2, - 0x05, 0x68, 0xf4, 0x40, 0xce, 0x2c, 0x8f, 0xdd, 0xa4, 0xe5, 0xe1, 0xb5, - 0xbe, 0xbd, 0x3e, 0xd4, 0xf6, 0x9a, 0xb3, 0x37, 0x24, 0x0d, 0xea, 0x13, - 0xd7, 0x1f, 0xa2, 0x75, 0x68, 0xa1, 0xbe, 0x2c, 0x01, 0x42, 0x2a, 0xae, - 0x6f, 0xae, 0x7a, 0x72, 0x3a, 0x11, 0x03, 0x58, 0x02, 0x0d, 0xf0, 0xb0, - 0xd9, 0x6f, 0xb1, 0xe4, 0xf2, 0x70, 0xb8, 0xff, 0x22, 0x56, 0x7c, 0xb3, - 0x80, 0xfd, 0xdf, 0xe5, 0xab, 0xcc, 0x18, 0x7a, 0xfd, 0x91, 0xd0, 0xb0, - 0x63, 0x40, 0xd4, 0x71, 0xfa, 0x03, 0xf5, 0xf1, 0x26, 0xe1, 0xa5, 0x5a, - 0xd9, 0x6d, 0xf5, 0x5a, 0x7b, 0x2a, 0x3a, 0xfe, 0x94, 0x9e, 0x74, 0x41, - 0x79, 0x49, 0x7e, 0x48, 0x1d, 0x58, 0x5e, 0xf6, 0x98, 0xa3, 0x6e, 0x61, - 0x8e, 0x9f, 0x1f, 0xcd, 0x15, 0x01, 0x16, 0xa5, 0xe0, 0xab, 0xd6, 0xd6, - 0x1f, 0x1c, 0xf5, 0x81, 0x76, 0xc1, 0xec, 0x10, 0xc2, 0xcc, 0x68, 0x59, - 0x4d, 0x47, 0xef, 0x4b, 0x7f, 0xd8, 0x78, 0x9c, 0xfe, 0x9a, 0x86, 0x7e, - 0x0c, 0xfd, 0x3e, 0x0a, 0x7a, 0x72, 0x8b, 0x14, 0x5f, 0xe6, 0x5f, 0x19, - 0xa3, 0x0a, 0x1b, 0x71, 0xdc, 0xd2, 0xae, 0x35, 0xc3, 0x11, 0xa5, 0xd3, - 0xea, 0xe1, 0xa9, 0xe7, 0x70, 0x0c, 0x7a, 0x39, 0x56, 0x3c, 0xe4, 0xe7, - 0xf9, 0xb6, 0xf1, 0x15, 0x40, 0xab, 0xb6, 0xc4, 0xad, 0xbd, 0xf4, 0xcc, - 0x13, 0xb7, 0xa8, 0xb6, 0x92, 0x1e, 0x72, 0x27, 0xa7, 0xff, 0xd9, 0xea, - 0x2f, 0x91, 0x96, 0x22, 0xd2, 0xc4, 0x4d, 0x80, 0xdc, 0x47, 0x66, 0x87, - 0xcc, 0xcf, 0xc5, 0x64, 0xf7, 0xb2, 0x34, 0xed, 0xd5, 0x44, 0x44, 0xcc, - 0x57, 0x41, 0xc7, 0x92, 0xb7, 0x5c, 0x12, 0xf7, 0x81, 0xf2, 0x92, 0x35, - 0x3e, 0x4b, 0xdf, 0xf8, 0xda, 0x68, 0xac, 0x30, 0xe3, 0xdd, 0x9e, 0x22, - 0xaa, 0x6d, 0x77, 0xdd, 0xac, 0xd9, 0x11, 0x6e, 0xfb, 0x1a, 0x88, - 0xb3}, // e12 - { - 0x07, 0x3f, 0x9d, 0x47, 0x82, 0xb8, 0x3d, 0x6a, 0xe0, 0x36, 0xab, 0xa6, - 0xfa, 0xe6, 0xd2, 0x1c, 0xc8, 0xb2, 0xd0, 0x01, 0xd4, 0x96, 0xdc, 0x2e, - 0xf8, 0x19, 0xdc, 0x70, 0x1b, 0xf9, 0x73, 0x0c, 0x2b, 0xc2, 0xe2, 0x1d, - 0x85, 0x53, 0x81, 0x51, 0xfb, 0xca, 0x16, 0x86, 0xd4, 0x4e, 0xfd, 0x1a, - 0x59, 0xe3, 0x97, 0xc4, 0x7f, 0x99, 0xd8, 0x66, 0x08, 0xa1, 0xe4, 0x9f, - 0xbb, 0x3a, 0xce, 0xa5, 0x23, 0x9c, 0x83, 0x13, 0xc5, 0xc8, 0xf2, 0x16, - 0x1e, 0xe8, 0xe6, 0xc5, 0x36, 0x57, 0x2c, 0xdf, 0x73, 0xb4, 0xe2, 0xb2, - 0xcb, 0xeb, 0xbb, 0xf7, 0x45, 0xd1, 0x44, 0xbd, 0x6e, 0x92, 0x95, 0x00, - 0xe5, 0x89, 0xb5, 0x91, 0x78, 0xc7, 0x44, 0xb1, 0x2f, 0x37, 0xdf, 0xfb, - 0xe7, 0x8a, 0x44, 0x3f, 0x3d, 0x06, 0x5f, 0x5b, 0x1c, 0x5f, 0xce, 0x11, - 0x05, 0x35, 0x3c, 0xad, 0x92, 0x7e, 0x79, 0xb8, 0xff, 0x28, 0x05, 0xe4, - 0x04, 0x2c, 0xb6, 0x1d, 0x22, 0xab, 0x36, 0x00, 0x5f, 0x74, 0xf1, 0xe3, - 0xf6, 0xa6, 0x68, 0xe6, 0x7b, 0x25, 0xb8, 0xcf, 0x19, 0xb0, 0x1a, 0xdd, - 0x0f, 0xad, 0x63, 0x73, 0x62, 0x1b, 0xe7, 0x94, 0x5d, 0xbf, 0x3d, 0xf1, - 0xf9, 0x8e, 0xab, 0x59, 0xe5, 0xd1, 0x7c, 0x62, 0xdd, 0xbc, 0x40, 0x07, - 0x70, 0x5b, 0x13, 0xf6, 0x12, 0x09, 0xb4, 0x0d, 0x3e, 0xab, 0x8b, 0x70, - 0x60, 0x1d, 0xd4, 0x61, 0x37, 0x28, 0x98, 0x3e, 0x7e, 0xdc, 0xfd, 0xd2, - 0xc0, 0x2f, 0x4b, 0x71, 0x31, 0x34, 0xd7, 0x69, 0x41, 0x5e, 0xaa, 0x72, - 0xe4, 0xdf, 0xeb, 0xfe, 0x8d, 0xcd, 0x68, 0xfc, 0x68, 0x55, 0xbe, 0x32, - 0x7d, 0x24, 0xc5, 0x07, 0x0f, 0xa8, 0xbd, 0x5a, 0xfe, 0xe7, 0xec, 0xdb, - 0xfd, 0x19, 0xc8, 0xa9, 0x20, 0xa2, 0x7f, 0x6c, 0xa6, 0x62, 0xec, 0xed, - 0x9b, 0x79, 0xbf, 0x9c, 0x0e, 0x31, 0x0b, 0x25, 0x2f, 0xd3, 0xcc, 0xa0, - 0xdd, 0xb2, 0xf2, 0x69, 0x26, 0x85, 0x21, 0x06, 0x94, 0x56, 0x5f, 0x59, - 0x5c, 0xf5, 0xb7, 0x82, 0xce, 0x0f, 0xdd, 0x40, 0xdb, 0x83, 0xac, 0x3c, - 0x41, 0xa0, 0x1b, 0xb1, 0xaf, 0xda, 0x55, 0xbf, 0x6b, 0x1a, 0xef, 0xe6, - 0x90, 0xe7, 0xaa, 0x0f, 0x04, 0x3c, 0x9f, 0x5b, 0xb7, 0xcd, 0x98, 0xa8, - 0x9e, 0xff, 0x54, 0x26, 0xc8, 0xd5, 0x5c, 0x30, 0x5e, 0xa2, 0x99, 0x8e, - 0x34, 0xd5, 0x98, 0x9f, 0xcd, 0x57, 0xd1, 0x4d, 0x1d, 0xee, 0x01, 0x5d, - 0x5a, 0x6d, 0xb2, 0xf1, 0xcf, 0x4b, 0xc0, 0x21, 0x23, 0x96, 0x05, 0xf9, - 0xc9, 0x66, 0xe5, 0x25, 0x9d, 0xa3, 0x8e, 0x78, 0x43, 0x19, 0xc1, 0x7f, - 0x7b, 0xef, 0xf5, 0xed, 0x00, 0xb7, 0x45, 0x1f, 0x4e, 0xa9, 0xfa, 0xe3, - 0xff, 0x54, 0xf2, 0x21, 0x73, 0xf8, 0x6b, 0xa1, 0xc7, 0x31, 0x4d, 0x6a, - }, // e22 - { - 0x49, 0x0d, 0x0f, 0x2a, 0x5c, 0x6a, 0x3b, 0xad, 0x71, 0xc9, 0x22, 0x49, - 0xe8, 0x08, 0xdd, 0xba, 0x79, 0x57, 0xb7, 0xc7, 0x61, 0xe4, 0xdb, 0x84, - 0x68, 0x57, 0xb9, 0x30, 0x83, 0xa4, 0xdc, 0xef, 0x70, 0x93, 0x28, 0xe2, - 0x6f, 0xb9, 0xbc, 0x15, 0x28, 0x3a, 0x30, 0xbd, 0x96, 0x83, 0xdb, 0xf2, - 0x9d, 0x1e, 0xc7, 0x64, 0x6d, 0x2e, 0x7c, 0xa2, 0xf3, 0xaa, 0x2f, 0x4b, - 0x6d, 0x86, 0x9e, 0x48, 0x20, 0x29, 0x4b, 0x1f, 0x8d, 0xc2, 0x93, 0xc3, - 0x55, 0x25, 0x8e, 0xb0, 0x8a, 0x7e, 0x64, 0x45, 0x3f, 0xf4, 0x1d, 0x16, - 0x4c, 0x88, 0x2d, 0x54, 0xbe, 0xa8, 0x67, 0x70, 0x81, 0xc5, 0xb9, 0x5c, - 0x16, 0x00, 0xef, 0x78, 0xf6, 0x4d, 0x6a, 0xeb, 0xfd, 0xa2, 0x0d, 0x52, - 0x86, 0xf3, 0x04, 0x4b, 0xd8, 0xf0, 0x7d, 0x50, 0x8b, 0xad, 0xc0, 0x37, - 0xdb, 0x38, 0xf2, 0x7d, 0x1f, 0x8b, 0x13, 0x83, 0x7b, 0xcc, 0xe8, 0x25, - 0xfe, 0xfa, 0x0c, 0x02, 0x05, 0x2e, 0x75, 0x12, 0xa1, 0x0a, 0x89, 0xab, - 0xf1, 0xb2, 0x08, 0x47, 0x9a, 0xea, 0xef, 0x1d, 0xa4, 0x9f, 0xde, 0x89, - 0x47, 0x3e, 0x7c, 0x5e, 0x4a, 0x40, 0xdc, 0xec, 0xc5, 0x1b, 0x7e, 0x33, - 0x0a, 0x19, 0x69, 0x27, 0xa6, 0xcc, 0x25, 0xfc, 0xf9, 0xeb, 0xbd, 0xb7, - 0x8a, 0xdb, 0x45, 0x5f, 0x9d, 0x9e, 0x01, 0xde, 0x3d, 0x91, 0x10, 0x99, - 0x13, 0xbf, 0xc0, 0xfa, 0x9d, 0xd4, 0x0f, 0xb3, 0x09, 0xf3, 0xa1, 0xae, - 0x68, 0xe1, 0x1b, 0x48, 0x85, 0x9f, 0x81, 0x66, 0x91, 0xe2, 0xf0, 0x7b, - 0x29, 0xdb, 0x8f, 0x5d, 0x99, 0xa9, 0xd3, 0x39, 0x30, 0xd9, 0x1b, 0x94, - 0x2a, 0x1c, 0x5c, 0xe9, 0xc0, 0x3f, 0x6e, 0xb2, 0x27, 0xbe, 0x74, 0x7a, - 0xca, 0xe1, 0x0f, 0x6a, 0x43, 0x2e, 0x98, 0x65, 0xaf, 0x7f, 0x6e, 0x5a, - 0x55, 0x98, 0xc1, 0x58, 0x29, 0xb3, 0x86, 0x54, 0x0f, 0x57, 0x91, 0x89, - 0x29, 0xb1, 0x98, 0x79, 0xcc, 0x95, 0x39, 0xd0, 0xab, 0xe0, 0x9f, 0xf3, - 0xda, 0xf9, 0x5e, 0xd9, 0x34, 0xbb, 0x72, 0xda, 0xe5, 0x72, 0xd3, 0xf8, - 0x9b, 0xf9, 0x14, 0x84, 0x48, 0x81, 0x54, 0x4f, 0xe6, 0x2b, 0x80, 0xc8, - 0xc1, 0x79, 0xfe, 0x83, 0xff, 0x76, 0xa3, 0x6d, 0xfe, 0x37, 0x78, 0xc5, - 0x30, 0x7a, 0x50, 0xe2, 0x5d, 0x12, 0xdc, 0x72, 0xe9, 0x58, 0x7c, 0x07, - 0x4f, 0xff, 0x15, 0x8a, 0x97, 0x3b, 0xcb, 0x60, 0xfa, 0x4e, 0xde, 0x8c, - 0x80, 0x3a, 0x8b, 0x0b, 0xc6, 0x1d, 0xa3, 0xce, 0x6a, 0xb3, 0x50, 0x69, - 0x03, 0x96, 0xca, 0xc0, 0xb6, 0x94, 0x6f, 0x8f, 0xab, 0x6f, 0x5b, 0x00, - 0x2a, 0x1d, 0x90, 0xa7, 0x81, 0xc6, 0x15, 0x77, 0x79, 0xf3, 0x36, 0x23, - 0xd1, 0x46, 0x25, 0x58, 0x6f, 0x7b, 0x22, 0xac, 0x4c, 0x7a, 0xf3, 0x9f, - }, // e2w - { - 0x8d, 0x71, 0xe2, 0xb0, 0x73, 0x2f, 0x4a, 0xba, 0x64, 0xe8, 0x7a, 0x12, - 0xaf, 0xe4, 0x4f, 0xdb, 0x6b, 0x3e, 0x38, 0x07, 0x0c, 0x79, 0x22, 0x48, - 0x1b, 0x9d, 0x33, 0x53, 0x5c, 0x75, 0x3b, 0x40, 0x5e, 0x18, 0xd1, 0x92, - 0x4a, 0xd1, 0x82, 0x1c, 0xc7, 0x3a, 0xf7, 0x7e, 0x32, 0x19, 0x99, 0x5d, - 0x01, 0x0e, 0xb0, 0xf2, 0x8f, 0x80, 0xc6, 0xb9, 0xeb, 0x1f, 0x9e, 0xae, - 0x9e, 0xe0, 0x99, 0xfd, 0xe8, 0x93, 0x11, 0x61, 0x7d, 0xc2, 0x49, 0xdb, - 0xa8, 0x73, 0xa4, 0xa9, 0x33, 0xe2, 0x04, 0xd1, 0x7d, 0x8b, 0xe1, 0xd6, - 0x2b, 0x10, 0x6c, 0x79, 0x02, 0xbf, 0xfc, 0x53, 0x03, 0xa9, 0xbc, 0x30, - 0x4d, 0x4d, 0xf4, 0x32, 0xce, 0x9a, 0x4a, 0xfa, 0xd6, 0x7f, 0x26, 0x17, - 0xc5, 0xf6, 0xed, 0xe4, 0xcc, 0xb9, 0x79, 0xe2, 0xa8, 0x86, 0xbb, 0xd7, - 0xfb, 0x05, 0xd2, 0x81, 0xbe, 0x07, 0x1c, 0x47, 0x48, 0x4f, 0x6d, 0x6b, - 0x52, 0x42, 0xe4, 0xc6, 0x20, 0x46, 0xa3, 0xae, 0x5b, 0x55, 0x55, 0xfe, - 0x4a, 0xad, 0xf2, 0x32, 0x07, 0x0f, 0x91, 0xa9, 0xe5, 0xd3, 0x86, 0x08, - 0x73, 0x93, 0xc7, 0x1e, 0x6b, 0xcd, 0x69, 0xd0, 0xfb, 0xc1, 0x74, 0xc2, - 0xb8, 0x90, 0xc8, 0xf8, 0x93, 0xbf, 0x08, 0x0f, 0x15, 0x19, 0x26, 0x71, - 0x4a, 0x9e, 0xdf, 0xdf, 0xca, 0x6f, 0xca, 0xfd, 0x67, 0xec, 0x4d, 0x21, - 0x5b, 0x99, 0xbd, 0x4b, 0x79, 0x22, 0x2d, 0xe4, 0x24, 0x72, 0x88, 0x93, - 0xce, 0xe6, 0x7f, 0xef, 0x35, 0x83, 0x67, 0x39, 0xb9, 0x34, 0x80, 0x64, - 0x0a, 0xf4, 0xff, 0x42, 0x9d, 0xee, 0xda, 0xb8, 0xd3, 0xdc, 0x1d, 0x0d, - 0x9f, 0x45, 0xe9, 0xbe, 0xf4, 0x3e, 0xa6, 0x58, 0x8b, 0xf0, 0xfd, 0x01, - 0x73, 0x63, 0xd0, 0xc6, 0x9d, 0xb9, 0x32, 0xd1, 0x91, 0xfe, 0xb1, 0xf5, - 0x4b, 0x48, 0xb4, 0x46, 0xae, 0x61, 0xd7, 0x90, 0xfe, 0x86, 0x74, 0x68, - 0xee, 0x78, 0x86, 0x65, 0x99, 0x6d, 0x7b, 0xf0, 0x17, 0x1a, 0x4c, 0xb0, - 0x37, 0x73, 0xdc, 0x38, 0x41, 0xfa, 0x02, 0xd2, 0x13, 0x8f, 0x71, 0xb4, - 0x0a, 0x72, 0x70, 0x0f, 0xe1, 0x2c, 0x9a, 0xa9, 0x51, 0xfa, 0xb2, 0xbf, - 0x84, 0xf2, 0xa6, 0xfb, 0xc3, 0x83, 0x16, 0x7e, 0x27, 0xec, 0x06, 0x5d, - 0x64, 0x79, 0xe7, 0x42, 0x30, 0xf8, 0x2d, 0xbc, 0x0f, 0x07, 0x8b, 0xf2, - 0x99, 0xda, 0x91, 0x4c, 0x65, 0xcf, 0x7f, 0x57, 0x2d, 0x2f, 0x67, 0xe7, - 0xfb, 0x75, 0xe9, 0xb2, 0xa3, 0x72, 0x60, 0x88, 0x2b, 0x14, 0x31, 0x62, - 0xbc, 0x45, 0x59, 0x5c, 0x58, 0x39, 0xb3, 0x4a, 0xeb, 0xb9, 0x18, 0x24, - 0x05, 0xcb, 0xda, 0xd3, 0x5e, 0x54, 0xba, 0xda, 0xfd, 0xfc, 0xa0, 0x02, - 0xb3, 0xde, 0x52, 0x3e, 0xc0, 0xd0, 0xb8, 0x19, 0x85, 0x1b, 0x7b, 0xe3, - } // ea2 -}; -const PreComputedSignature EpidMemberTest::precomputed_signatures[2] = { - { - {{{{0x5c, 0x1b, 0x75, 0x1c, 0xc7, 0x2c, 0xf7, 0x4a, 0x97, 0x43, 0xf2, - 0x1a, 0x70, 0x80, 0x90, 0x61, 0xf5, 0x9e, 0x9b, 0x43, 0x92, 0x2f, - 0x05, 0x28, 0xcc, 0x4c, 0xb4, 0xb2, 0x80, 0x15, 0x58, 0x14}}}, - {{{ - 0x3f, 0x7f, 0xd0, 0x95, 0x08, 0x98, 0x0b, 0xae, 0x88, 0xf8, 0x2c, - 0x18, 0x8b, 0x72, 0x50, 0x95, 0x78, 0x41, 0xae, 0x4e, 0x6e, 0xea, - 0x3d, 0xa6, 0x23, 0x91, 0x4a, 0x02, 0x5d, 0x3f, 0x97, 0xd9, - }}}}, // B - {{{{0xb0, 0xdb, 0x88, 0x23, 0x18, 0x95, 0xba, 0x60, 0x72, 0x43, 0xb4, - 0x57, 0xbd, 0x20, 0xd2, 0x28, 0x97, 0xf7, 0x3a, 0x50, 0x06, 0xc5, - 0x89, 0xc9, 0x9f, 0x7a, 0x2a, 0x80, 0x91, 0xee, 0x7a, 0xf8}}}, - {{{0x70, 0xf3, 0x95, 0x12, 0xe4, 0x95, 0xca, 0x19, 0x43, 0x1a, 0x5d, - 0x47, 0x33, 0x71, 0x69, 0xfb, 0x14, 0x5f, 0xbd, 0x3f, 0xb2, 0x72, - 0x22, 0x3f, 0x63, 0xc3, 0xe9, 0x7c, 0x18, 0x82, 0x88, - 0x03}}}}, // K - {{{{0x75, 0x39, 0x21, 0x47, 0x04, 0xfd, 0xb7, 0x71, 0xb2, 0xf5, 0xa9, - 0x83, 0x7f, 0x27, 0x1d, 0x8f, 0xff, 0x07, 0x3c, 0xfb, 0xe9, 0x0d, - 0x14, 0x9c, 0xa6, 0xee, 0x06, 0x1e, 0x3d, 0xd3, 0xfb, 0x92}}}, - {{{0x51, 0x64, 0x11, 0x6d, 0x22, 0xc7, 0xed, 0x67, 0x21, 0xfe, 0x76, - 0x27, 0xf9, 0x43, 0x43, 0x64, 0x11, 0x01, 0x63, 0xc8, 0xda, 0x42, - 0x4e, 0x02, 0xe7, 0xf2, 0xb8, 0xa4, 0x16, 0x5b, 0x39, - 0xc2}}}}, // T - {{{{0x60, 0x25, 0xeb, 0xe8, 0x51, 0xd5, 0xe0, 0xf3, 0xcc, 0xb2, 0xc2, - 0xe3, 0xd7, 0x5c, 0x84, 0x41, 0x57, 0x2b, 0x5b, 0x00, 0xac, 0x1d, - 0x14, 0x89, 0xba, 0xb3, 0x34, 0xf0, 0x8a, 0xd4, 0x72, 0x5e}}}, - {{{0x93, 0xb7, 0xed, 0x03, 0xdd, 0xc7, 0xc9, 0xfa, 0x2c, 0x32, 0x84, - 0x40, 0xd4, 0xa2, 0x74, 0x76, 0x02, 0xef, 0x0c, 0xc6, 0xe4, 0xc2, - 0x9f, 0xd7, 0x18, 0x96, 0xdc, 0x97, 0x22, 0x4e, 0xbf, - 0xfc}}}}, // R1 - { - 0xe4, 0x5f, 0x6c, 0x74, 0x0b, 0xb7, 0x26, 0x59, 0x62, 0x5e, 0x69, - 0x71, 0x01, 0xa8, 0x32, 0xc1, 0xa7, 0xae, 0x32, 0x9e, 0xc2, 0xaf, - 0x9a, 0x55, 0x6c, 0x71, 0x37, 0x80, 0xc7, 0xe1, 0x8b, 0x1c, 0xa1, - 0x0c, 0xce, 0x60, 0x10, 0x18, 0x14, 0xe9, 0x66, 0x84, 0xe0, 0x52, - 0x9d, 0xee, 0x42, 0x0f, 0x47, 0xba, 0xcc, 0xc1, 0xea, 0xeb, 0x93, - 0x18, 0x04, 0x39, 0x7e, 0x36, 0x59, 0x73, 0xd3, 0xf8, 0xa4, 0x67, - 0x64, 0x6a, 0x24, 0x00, 0xd3, 0x4b, 0x0b, 0x17, 0x7f, 0xc6, 0xca, - 0x1a, 0xe3, 0x29, 0x4a, 0x4d, 0x23, 0x7d, 0x02, 0xa4, 0xd3, 0x26, - 0xed, 0xe6, 0x4d, 0xb7, 0xc6, 0x2d, 0x70, 0x85, 0xf0, 0xa4, 0x54, - 0x7f, 0xe9, 0x6e, 0x17, 0xb3, 0x36, 0xa4, 0x30, 0xfc, 0xca, 0x80, - 0x8c, 0x8b, 0x17, 0x6f, 0xe8, 0x22, 0x76, 0x27, 0xd7, 0x42, 0xd5, - 0x14, 0x27, 0x9a, 0x8d, 0x0c, 0x9c, 0x43, 0x7e, 0x41, 0x7a, 0x73, - 0xd9, 0xee, 0xef, 0xc7, 0x42, 0x77, 0xbe, 0x27, 0xa3, 0x8f, 0xa1, - 0x77, 0xaf, 0xdc, 0xa2, 0xfc, 0xf1, 0x3d, 0xd6, 0x00, 0xf3, 0x9c, - 0x43, 0xe9, 0xff, 0xc7, 0x9f, 0x5f, 0x6c, 0xa9, 0x16, 0x47, 0x73, - 0xbb, 0x31, 0x45, 0xb1, 0xcf, 0x7f, 0x39, 0xdd, 0x27, 0x78, 0x03, - 0x45, 0x24, 0x67, 0x08, 0x04, 0xf1, 0xbf, 0xfa, 0x7f, 0xe2, 0x2f, - 0x1f, 0x2c, 0x68, 0xfe, 0x4e, 0x0a, 0xcf, 0xd7, 0xf5, 0x0b, 0xd2, - 0xe2, 0x55, 0x54, 0x15, 0xa6, 0x3d, 0x0c, 0xc3, 0x49, 0xcd, 0x86, - 0xa7, 0x51, 0x12, 0x08, 0x4c, 0xf6, 0x05, 0xbc, 0xdc, 0xb1, 0x22, - 0xe4, 0x92, 0x33, 0x92, 0x8f, 0x6b, 0xee, 0x74, 0x96, 0xaf, 0x7c, - 0x47, 0x65, 0xb6, 0x4d, 0xd8, 0xd4, 0x21, 0xa8, 0xfa, 0xf9, 0x03, - 0xc7, 0xf4, 0x82, 0xde, 0x0a, 0xd9, 0x4c, 0x92, 0xfc, 0x48, 0x65, - 0x1a, 0x4c, 0xb9, 0xf9, 0x91, 0x9e, 0xf4, 0x88, 0x9e, 0x83, 0xa9, - 0x3a, 0x2e, 0x50, 0x94, 0xde, 0xb0, 0x24, 0xf3, 0x9b, 0xa0, 0x9e, - 0x0c, 0x49, 0xb2, 0xe2, 0x53, 0xfc, 0x52, 0x9b, 0x4b, 0x3b, 0x53, - 0xdf, 0xfe, 0x76, 0x99, 0x19, 0x90, 0xb8, 0xf2, 0x8c, 0xda, 0x57, - 0xfc, 0x35, 0xf6, 0xeb, 0xb4, 0x3c, 0xde, 0xff, 0x75, 0xf2, 0x50, - 0x27, 0x20, 0x42, 0x33, 0xd8, 0x6c, 0x5f, 0xba, 0x3d, 0xed, 0x90, - 0x77, 0xbc, 0x97, 0x10, 0xe0, 0x37, 0x21, 0x9e, 0x37, 0xf4, 0x89, - 0x34, 0x7c, 0x4a, 0x27, 0x8b, 0x58, 0x99, 0x83, 0x0a, 0xa7, 0x80, - 0x11, 0xc4, 0x88, 0xf2, 0xbb, 0xc0, 0x99, 0x9f, 0x6f, 0x60, 0x12, - 0x2d, 0x52, 0x20, 0x3a, 0xc0, 0x50, 0x75, 0x97, 0xc9, 0xdb, 0x01, - 0x3d, 0x05, 0x21, 0x3a, 0x16, 0x67, 0x0f, 0x7b, 0x51, 0x4a, 0x33, - 0x93, 0x53, 0x78, 0xd0, 0xb4, 0x91, 0xfc, 0x32, 0x49, 0x5e, - }, // R2 - {0x02, 0x5c, 0x15, 0x7e, 0x0f, 0x00, 0x82, 0x32, 0x45, 0xcf, 0x91, 0xd3, - 0x64, 0x5f, 0xf6, 0x0a, 0x83, 0x83, 0xc6, 0x3c, 0x0a, 0x68, 0x2c, 0x1e, - 0x96, 0x4b, 0xfa, 0xde, 0x06, 0xfe, 0x1a, 0x73}, // a - {0xea, 0x9d, 0xe1, 0x57, 0x32, 0x2e, 0x74, 0xd5, 0xbe, 0x49, 0xc4, 0xc8, - 0x23, 0x7d, 0x93, 0x74, 0x05, 0xee, 0xc2, 0x3d, 0xec, 0xd5, 0xbd, 0x4c, - 0x2f, 0x1d, 0x77, 0x88, 0x2b, 0x81, 0x5e, 0xc4}, // b - {0x98, 0x43, 0xdc, 0x08, 0x7b, 0x99, 0xff, 0x4a, 0x38, 0xbd, 0x5f, 0xe9, - 0xfc, 0xb9, 0x40, 0x3c, 0x31, 0x9b, 0x57, 0x7e, 0xff, 0x1c, 0x80, 0x92, - 0x79, 0x97, 0x3d, 0xa9, 0xbb, 0x70, 0xe7, 0x4b}, // rx - {0x85, 0x09, 0xac, 0xad, 0xcb, 0x5f, 0x24, 0x36, 0x21, 0x9e, 0xc7, 0x3a, - 0x2b, 0xf6, 0x63, 0xe7, 0x0d, 0xef, 0x3f, 0x4d, 0x40, 0x94, 0x49, 0x7b, - 0x2c, 0x89, 0xfe, 0xdc, 0xe7, 0x5b, 0xc5, 0x72}, // rf - {0x0d, 0x6b, 0x41, 0x78, 0x87, 0xb7, 0x90, 0x17, 0x5c, 0xe1, 0x9d, 0xcb, - 0x5d, 0x87, 0x69, 0xe6, 0xdd, 0xc0, 0xef, 0xbb, 0x3f, 0x4d, 0xaf, 0xec, - 0x3a, 0x66, 0x66, 0xb3, 0x51, 0x49, 0xb8, 0xae}, // ra - {0xaa, 0x42, 0x63, 0x36, 0x47, 0xe3, 0x9d, 0x5e, 0x7f, 0xcd, 0x07, 0xee, - 0x26, 0xdc, 0xaf, 0x88, 0xf1, 0x9b, 0xae, 0xa4, 0x7c, 0xff, 0x2e, 0x4f, - 0x7b, 0x6d, 0xb1, 0x42, 0x50, 0x9d, 0x89, 0x39} // rb - }, - { - {{{{0x10, 0x11, 0x7a, 0x7a, 0xbd, 0xe9, 0x4f, 0x96, 0xd7, 0x1e, 0x53, - 0x05, 0x8d, 0x69, 0xb1, 0xdb, 0x3e, 0xf1, 0x3c, 0x24, 0xe2, 0x83, - 0x06, 0x4b, 0xd6, 0xd9, 0xc6, 0x24, 0xf4, 0x7f, 0x67, 0x2c}}}, - {{{0x1a, 0xaf, 0x95, 0xfa, 0x7e, 0x59, 0xd2, 0x93, 0x39, 0x09, 0xae, - 0x0b, 0xc3, 0xe8, 0xe5, 0xf7, 0x36, 0xe7, 0x06, 0xbf, 0xe3, 0xd2, - 0x20, 0xbf, 0xd2, 0x31, 0x3f, 0xc1, 0x15, 0x61, 0x61, - 0x03}}}}, // B - {{{{0xcc, 0x9e, 0x80, 0x5e, 0x0c, 0x32, 0x44, 0x70, 0xe0, 0x44, 0x27, - 0x7a, 0x01, 0xee, 0x51, 0x19, 0xa1, 0x4d, 0x0a, 0x24, 0x8b, 0xa2, - 0xf8, 0xa3, 0x26, 0x56, 0x8c, 0x70, 0xe1, 0xa1, 0x83, 0x70}}}, - {{{0x4d, 0xf0, 0x73, 0x6f, 0xf4, 0x62, 0xc4, 0x30, 0x3e, 0xde, 0xff, - 0xc0, 0x93, 0x92, 0xa4, 0x03, 0x6f, 0x84, 0x3a, 0x3c, 0x34, 0x25, - 0x83, 0xb5, 0x2b, 0x90, 0x95, 0x6b, 0x24, 0x82, 0x6e, - 0xe6}}}}, // K - {{{{0xc6, 0x4c, 0xc8, 0x9d, 0xdc, 0x63, 0x46, 0x5b, 0xab, 0x79, 0xea, - 0x49, 0x76, 0x47, 0x68, 0xe6, 0x2e, 0x7d, 0x0b, 0x49, 0xc0, 0x29, - 0xe4, 0xc8, 0x84, 0xb5, 0x04, 0x2d, 0x15, 0xaa, 0x0d, 0xd4}}}, - {{{0x71, 0x43, 0xd0, 0x24, 0x3e, 0x00, 0xf4, 0x94, 0xad, 0x1e, 0x1e, - 0x32, 0xea, 0x21, 0x4d, 0x83, 0xae, 0x63, 0x3c, 0x5a, 0xd4, 0xa5, - 0x79, 0x9b, 0x2c, 0xad, 0x03, 0x50, 0xb6, 0x57, 0x0a, - 0xbf}}}}, // T - {{{{0xdd, 0x13, 0x14, 0x5a, 0x7d, 0x23, 0xc5, 0xf0, 0xcb, 0xa7, 0xd1, - 0x79, 0x7a, 0x59, 0x91, 0xf3, 0x8f, 0xb3, 0xff, 0x27, 0x52, 0x0e, - 0xe4, 0xc8, 0xb2, 0xe1, 0xc5, 0x29, 0x16, 0x2e, 0x0f, 0xcf}}}, - {{{0xcd, 0xb1, 0xed, 0x9a, 0xf3, 0x8a, 0xdd, 0x97, 0xe3, 0x58, 0xd8, - 0x66, 0xc0, 0xb9, 0xe6, 0x5e, 0x86, 0x6b, 0xfc, 0xde, 0x25, 0x2b, - 0x3c, 0x97, 0x4e, 0xc9, 0x26, 0x12, 0xf7, 0xde, 0xa6, - 0x88}}}}, // R1 - {0x75, 0x5e, 0x75, 0xe8, 0x80, 0xa3, 0x3b, 0x5d, 0xb7, 0xf1, 0x93, 0x4e, - 0x55, 0x6a, 0x14, 0x24, 0x8c, 0x74, 0xcd, 0x58, 0x25, 0xf8, 0x26, 0x6f, - 0x21, 0xc1, 0x1f, 0xb1, 0x7a, 0xc5, 0x48, 0x6b, 0x01, 0x4e, 0xa0, 0xa7, - 0xac, 0x55, 0x5b, 0x68, 0xba, 0x69, 0x17, 0xb0, 0x1e, 0x4a, 0x88, 0x70, - 0xbc, 0xb8, 0x12, 0xd7, 0x3d, 0x1b, 0xb4, 0xee, 0x79, 0xdb, 0xa1, 0x31, - 0xfb, 0x09, 0x3e, 0x89, 0xf6, 0x92, 0x0a, 0x81, 0x6a, 0xde, 0xe6, 0xb9, - 0x26, 0x9e, 0x5f, 0x2a, 0x52, 0xa2, 0x2e, 0x44, 0x0c, 0x15, 0xce, 0xbf, - 0x1f, 0xcf, 0x95, 0xe5, 0x17, 0x1c, 0xf3, 0xd2, 0x90, 0x04, 0xa4, 0xfa, - 0x0e, 0x92, 0x8b, 0xa4, 0xcd, 0x2b, 0xdf, 0x78, 0x71, 0x98, 0xd7, 0x9f, - 0xcd, 0xd1, 0x5e, 0x06, 0xdb, 0x6b, 0xdb, 0xff, 0x8d, 0xb4, 0x10, 0x73, - 0xc8, 0xf6, 0xb9, 0x42, 0x54, 0xc4, 0x6a, 0xc3, 0xbb, 0xdc, 0xec, 0x6d, - 0x2f, 0xec, 0xda, 0xb7, 0x74, 0x02, 0x59, 0xb9, 0xe0, 0x4c, 0xc5, 0x41, - 0x8a, 0x00, 0x2b, 0x10, 0x45, 0x9a, 0xc3, 0x77, 0x98, 0x66, 0xcf, 0xcb, - 0x44, 0xe7, 0x9a, 0x56, 0x40, 0xde, 0x74, 0x9b, 0x9f, 0x34, 0x9f, 0xc0, - 0x59, 0x28, 0x27, 0x3f, 0x90, 0xe0, 0xaa, 0xba, 0x0d, 0x13, 0x8a, 0xec, - 0x97, 0x2a, 0xef, 0xe7, 0xc9, 0x8f, 0xfa, 0xef, 0x14, 0x3a, 0xc2, 0x39, - 0xf6, 0x54, 0xab, 0x28, 0x15, 0x9f, 0x8d, 0x91, 0x49, 0x94, 0x27, 0x72, - 0x47, 0x97, 0x2a, 0x88, 0xb4, 0x95, 0xf4, 0xb7, 0xf3, 0x4d, 0xe3, 0xf0, - 0x53, 0x69, 0x58, 0xaf, 0xb7, 0x22, 0x52, 0x05, 0x9c, 0xac, 0x52, 0xbb, - 0x39, 0xc6, 0x6b, 0xfd, 0xfd, 0xdb, 0x1c, 0xf8, 0xa6, 0xce, 0xd6, 0xe6, - 0x4a, 0xd5, 0xb4, 0xcf, 0x68, 0x24, 0x79, 0xf6, 0xb0, 0xb8, 0x62, 0x37, - 0xc6, 0xa9, 0x14, 0x25, 0x07, 0xec, 0xde, 0x3a, 0x18, 0x13, 0xf9, 0x35, - 0x8d, 0xd7, 0x40, 0x34, 0x8c, 0xe9, 0x3f, 0x97, 0xe1, 0x6e, 0xcf, 0x9e, - 0xb0, 0x5d, 0x15, 0x5f, 0xd7, 0xd4, 0x92, 0x26, 0xa4, 0x87, 0x77, 0x47, - 0x95, 0x53, 0x78, 0x4b, 0x77, 0xd4, 0xb4, 0xd4, 0xad, 0xd2, 0xeb, 0xfb, - 0x70, 0x7b, 0xea, 0x6d, 0x88, 0x9b, 0xb6, 0xf9, 0x95, 0xa2, 0xae, 0x77, - 0xd3, 0x29, 0x43, 0xeb, 0x25, 0x09, 0x3c, 0x68, 0xc5, 0xba, 0x6f, 0x6e, - 0x19, 0x6a, 0x41, 0xb5, 0x02, 0x3f, 0x2e, 0xbe, 0x8e, 0xc4, 0x72, 0x47, - 0x65, 0x7d, 0x2a, 0xbb, 0x55, 0xea, 0x01, 0x2c, 0x24, 0x28, 0x1d, 0x90, - 0x63, 0xe5, 0x8e, 0x4f, 0xb7, 0x0e, 0x86, 0x09, 0x18, 0x5f, 0x1d, 0x69, - 0x72, 0x1a, 0xff, 0x25, 0xb2, 0x82, 0x19, 0x66, 0xbc, 0x68, 0x02, 0x07, - 0x02, 0x05, 0x07, 0x80, 0x88, 0xc9, 0x85, 0xf7, 0xa9, 0x32, 0x0a, - 0x48}, // R2 - {0xb2, 0x9f, 0x28, 0x17, 0xa9, 0x3b, 0x93, 0x5d, 0x84, 0xaa, 0xb9, 0xd2, - 0x61, 0x4c, 0xe4, 0x64, 0x79, 0x2b, 0xc2, 0x87, 0xe4, 0x7f, 0xe2, 0xd6, - 0xe7, 0x20, 0x7f, 0x3f, 0x65, 0x3d, 0x03, 0xa5}, // a - {0xf2, 0xfa, 0x9f, 0x28, 0x8f, 0x1f, 0xd0, 0x6b, 0xa2, 0xe3, 0x37, 0xce, - 0x1c, 0x43, 0x82, 0x81, 0x18, 0x01, 0x75, 0x04, 0xf0, 0x2b, 0xb5, 0xb0, - 0x46, 0x5d, 0x44, 0x7f, 0xaa, 0xb3, 0x8a, 0xd2}, // b - {0xf3, 0xe0, 0xab, 0x75, 0x37, 0x41, 0x61, 0x0d, 0xf5, 0x4a, 0x1f, 0xa6, - 0xee, 0xa5, 0xc6, 0x55, 0xd2, 0xa6, 0xce, 0x1c, 0x08, 0x64, 0x75, 0x22, - 0x15, 0x81, 0x45, 0x76, 0x21, 0x2c, 0x32, 0xca}, // rx - {0x6e, 0xfc, 0x5c, 0x0a, 0x79, 0x3a, 0x5d, 0xca, 0xe6, 0xdc, 0x30, 0x12, - 0x96, 0x5a, 0x95, 0x3f, 0x8b, 0xa6, 0x86, 0x6d, 0x43, 0xf4, 0x4e, 0xfd, - 0x4f, 0xf2, 0x7a, 0x80, 0xa5, 0xcc, 0x05, 0x56}, // rf - {0xcb, 0x58, 0xde, 0x49, 0xd7, 0x19, 0xfa, 0xbf, 0x5f, 0x82, 0x19, 0x0e, - 0x60, 0xb5, 0x0d, 0xde, 0xda, 0xb5, 0xf2, 0xb0, 0xcc, 0x2f, 0x65, 0x5e, - 0x71, 0x08, 0xd6, 0xb5, 0xd5, 0xbc, 0x67, 0xc1}, // ra - {0xe0, 0x3a, 0x71, 0xa7, 0x86, 0x56, 0xea, 0xd0, 0x19, 0xce, 0xa9, 0x65, - 0xe8, 0x26, 0x11, 0x56, 0x5c, 0xcb, 0x04, 0x65, 0x36, 0xfd, 0xd9, 0x39, - 0x35, 0xfa, 0x78, 0xa5, 0xc2, 0x3c, 0x2e, 0x17} // rb - }}; -const std::vector EpidMemberTest::group_public_key_data_ikgf = { -#include "epid/common/testdata/ikgf/groupa/pubkey.inc" -}; -const std::vector EpidMemberTest::member_private_key_data_ikgf = { -#include "epid/common/testdata/ikgf/groupa/member0/mprivkey.inc" -}; - -const std::vector EpidMemberTest::grp01_member0_sig_test1_sha256 = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha256.inc" -}; -const std::vector EpidMemberTest::grp01_member0_sig_test1_sha384 = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha384.inc" -}; -const std::vector EpidMemberTest::grp01_member0_sig_test1_sha512 = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha512.inc" -}; -const std::vector EpidMemberTest::test1_msg = {'t', 'e', 's', 't', - '1'}; -std::vector EpidMemberTest::sig_rl_data = { -#include "epid/common/testdata/grp01/sigrl.inc" -}; -std::vector EpidMemberTest::sig_rl_5_entry_data = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x00, 0x00, 0x00, 0x05, - // bk's - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, 0x8, - 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, 0x2e, - 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, 0x67, - 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, 0x9d, 0xc7, - 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, 0x7d, 0xfe, - 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, 0x89, 0xb2, - 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, 0xcf, 0xd, 0x40, - 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, 0x4f, 0x7a, 0xb5, - 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, 0x33, 0xad, 0xf6, - 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, 0xce, 0xec, 0xd1, - 0xa8, 0xc, 0x8b, - - 0x71, 0x8a, 0xb5, 0x1, 0x7f, 0x7c, 0x92, 0x9a, 0xa2, 0xc9, 0x81, 0x10, 0xfe, - 0xbf, 0xc, 0x53, 0xa4, 0x43, 0xaf, 0x31, 0x74, 0x12, 0x25, 0x60, 0x3e, 0xc0, - 0x21, 0xe6, 0x63, 0x9a, 0xd2, 0x67, 0x2d, 0xb5, 0xd5, 0x82, 0xc4, 0x49, - 0x29, 0x51, 0x42, 0x8f, 0xe0, 0xe, 0xd1, 0x73, 0x27, 0xf5, 0x77, 0x16, 0x4, - 0x40, 0x8a, 0x0, 0xe, 0x3a, 0x5d, 0x37, 0x42, 0xd3, 0x8, 0x40, 0xbd, 0x69, - 0xf7, 0x5f, 0x74, 0x21, 0x50, 0xf4, 0xce, 0xfe, 0xd9, 0xdd, 0x97, 0x6c, - 0xa8, 0xa5, 0x60, 0x6b, 0xf8, 0x1b, 0xba, 0x2, 0xb2, 0xca, 0x5, 0x44, 0x9b, - 0xb1, 0x5e, 0x3a, 0xa4, 0x35, 0x7a, 0x51, 0xfa, 0xcf, 0xa4, 0x4, 0xe9, 0xf3, - 0xbf, 0x38, 0xd4, 0x24, 0x9, 0x52, 0xf3, 0x58, 0x3d, 0x9d, 0x4b, 0xb3, 0x37, - 0x4b, 0xec, 0x87, 0xe1, 0x64, 0x60, 0x3c, 0xb6, 0xf7, 0x7b, 0xff, 0x40, - 0x11, - - 0x6e, 0x22, 0xaa, 0x10, 0x84, 0x58, 0x8b, 0xff, 0xd8, 0x37, 0x8, 0xa9, 0xe9, - 0xdb, 0xf6, 0x1f, 0x69, 0x10, 0x95, 0x6c, 0xbf, 0xd, 0x11, 0x48, 0x6f, 0x1b, - 0x3c, 0x62, 0x46, 0x13, 0x89, 0x13, 0x5f, 0xa1, 0x3, 0x62, 0xed, 0x62, 0xdf, - 0x3d, 0xbf, 0xcd, 0xb7, 0x41, 0x48, 0x81, 0x3, 0x9f, 0x54, 0xa, 0xe, 0xb3, - 0x35, 0xf9, 0xde, 0x24, 0xba, 0x6d, 0x4c, 0x7f, 0xfc, 0xc1, 0xb4, 0xce, - 0x6d, 0xa1, 0x73, 0x7c, 0xaa, 0xb, 0xad, 0x2, 0xd6, 0x37, 0x85, 0xe, 0xbb, - 0x48, 0x11, 0x38, 0xc4, 0xaa, 0x1b, 0xf, 0xcf, 0xc1, 0x9c, 0x26, 0xcc, 0x95, - 0xc2, 0x5b, 0x49, 0x9, 0x3d, 0xe9, 0x7d, 0xce, 0xc7, 0xa6, 0x4, 0x3e, 0x7c, - 0x9e, 0x28, 0xde, 0x8, 0x11, 0xe, 0x61, 0x3b, 0xc0, 0x9c, 0x6b, 0x58, 0x23, - 0xe6, 0x40, 0x7b, 0xbd, 0xb8, 0x72, 0xf, 0xe0, 0xee, 0xcf, 0xba, 0xb4, - - 0xc4, 0xff, 0xaf, 0x48, 0x15, 0xda, 0x60, 0x40, 0xcc, 0xd7, 0xf2, 0x68, - 0xf7, 0xe2, 0x70, 0x12, 0x8d, 0x15, 0xa5, 0xb7, 0xe6, 0x4c, 0x23, 0xea, - 0x4d, 0x8a, 0x51, 0x6, 0x67, 0x3, 0x4c, 0x83, 0x6f, 0x28, 0x67, 0xcf, 0x63, - 0x46, 0x3e, 0x8a, 0x45, 0x9f, 0xed, 0x1a, 0xde, 0xa7, 0xad, 0xb2, 0x2b, 0xf, - 0x8b, 0xab, 0x7c, 0x70, 0xff, 0xc3, 0xa8, 0x6e, 0x8c, 0xaa, 0xb1, 0xf6, - 0x20, 0xe3, 0xb9, 0xf1, 0xc3, 0x3d, 0x5, 0x6a, 0x1e, 0x26, 0x2d, 0xf4, 0xd, - 0xe4, 0x53, 0x63, 0x67, 0x23, 0x48, 0xa8, 0x1, 0xa8, 0xee, 0xe1, 0x5f, 0x64, - 0xe3, 0x2c, 0x71, 0xe2, 0x10, 0x82, 0x0, 0x52, 0xd7, 0x74, 0x87, 0xff, 0x1c, - 0x0, 0x19, 0xe6, 0x4d, 0x15, 0x91, 0x6d, 0xf3, 0x38, 0x3b, 0xee, 0xf3, 0xd5, - 0xd1, 0xc7, 0x6d, 0xd9, 0x8e, 0x55, 0x70, 0x90, 0xb0, 0xb, 0x3c, 0x4a, 0x67, - 0x19, - - 0x4f, 0x98, 0x92, 0xf9, 0x18, 0x38, 0xf5, 0xb4, 0xf7, 0x2f, 0xa7, 0x21, - 0x71, 0x52, 0x27, 0xd0, 0x57, 0x4f, 0x9c, 0x30, 0xe, 0xb2, 0x27, 0xce, 0xd7, - 0xb2, 0x9f, 0xc0, 0xf6, 0xc3, 0xb0, 0x7c, 0x40, 0x18, 0x75, 0x4a, 0xde, - 0xb0, 0x9f, 0x46, 0x8a, 0x5a, 0xeb, 0x4f, 0xcb, 0x5e, 0x60, 0xf5, 0xca, - 0xf4, 0x98, 0xaf, 0x62, 0x9b, 0x7e, 0x10, 0xda, 0xba, 0x2f, 0x47, 0x64, - 0xf2, 0xc0, 0x84, 0x19, 0x75, 0xe0, 0xe4, 0xff, 0x20, 0xda, 0x7d, 0xe5, 0xd, - 0xc8, 0xf8, 0xe3, 0x83, 0x61, 0x19, 0x17, 0xf1, 0xa9, 0x1b, 0xff, 0x39, - 0x79, 0x88, 0x1, 0xfb, 0xe7, 0x23, 0xd2, 0xac, 0xe0, 0x49, 0x12, 0x2a, 0x38, - 0xb4, 0x7c, 0xc2, 0x1b, 0x88, 0x5f, 0x68, 0x32, 0x11, 0xd9, 0xfd, 0xdc, - 0x65, 0x2, 0xb3, 0x74, 0x2c, 0x13, 0xf2, 0xd8, 0xf1, 0x45, 0xc5, 0xd1, 0xf4, - 0xa3, 0x38, 0x81, 0x92}; -const std::vector EpidMemberTest::kMsg0 = {'m', 's', 'g', '0'}; -const std::vector EpidMemberTest::kBsn0 = {'b', 's', 'n', '0'}; -const std::vector EpidMemberTest::kMsg1 = {'m', 's', 'g', '1'}; -const std::vector EpidMemberTest::kBsn1 = {'b', 's', 'n', '1'}; - -const GroupPubKey EpidMemberTest::kGrpXKey = { -#include "epid/common/testdata/grp_x/pubkey.inc" -}; - -const CompressedPrivKey EpidMemberTest::kGrpXMember9CompressedKey = { -#include "epid/common/testdata/grp_x/cmember9/cmpprivkey.inc" -}; -const PrivKey EpidMemberTest::kGrpXMember9PrivKey = { -#include "epid/common/testdata/grp_x/cmember9/mprivkey.inc" -}; - -const GroupPubKey EpidMemberTest::kGrpYKey = { -#include "epid/common/testdata/grp_y/pubkey.inc" -}; - -const CompressedPrivKey EpidMemberTest::kGrpYMember9CompressedKey = { -#include "epid/common/testdata/grp_y/cmember9/cmpprivkey.inc" -}; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/member-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/member-testhelper.h deleted file mode 100644 index 92be0b1ea5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/member-testhelper.h +++ /dev/null @@ -1,116 +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 Member C++ wrapper interface. - */ -#ifndef EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_ -#define EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_ - -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -} - -/// C++ Wrapper to manage memory for MemberCtx via RAII -class MemberCtxObj { - public: - /// Create a MemberCtx - explicit MemberCtxObj(GroupPubKey const& pub_key, PrivKey const& priv_key, - BitSupplier rnd_func, void* rnd_param); - /// Create a MemberCtx given precomputation blob - MemberCtxObj(GroupPubKey const& pub_key, PrivKey const& priv_key, - MemberPrecomp const& precomp, BitSupplier rnd_func, - void* rnd_param); - - // This class instances are not meant to be copied. - // Explicitly delete copy constructor and assignment operator. - MemberCtxObj(const MemberCtxObj&) = delete; - MemberCtxObj& operator=(const MemberCtxObj&) = delete; - - /// Destroy the MemberCtx - ~MemberCtxObj(); - /// get a pointer to the stored MemberCtx - MemberCtx* ctx() const; - /// cast operator to get the pointer to the stored MemberCtx - operator MemberCtx*() const; - /// const cast operator to get the pointer to the stored MemberCtx - operator const MemberCtx*() const; - - private: - /// The stored MemberCtx - MemberCtx* ctx_; -}; - -/// Test fixture class for EpidMember -class EpidMemberTest : public ::testing::Test { - public: - /// test data - static const GroupPubKey group_public_key; - /// test data - static const PrivKey member_private_key; - /// test data - static const std::vector group_public_key_data_ikgf; - /// test data - static const std::vector member_private_key_data_ikgf; - /// test data - static const MemberPrecomp member_precomp; - /// test data - static const PreComputedSignature precomputed_signatures[2]; - /// test data - static const std::vector grp01_member0_sig_test1_sha256; - /// test data - static const std::vector grp01_member0_sig_test1_sha384; - /// test data - static const std::vector grp01_member0_sig_test1_sha512; - /// test data - static const std::vector test1_msg; - /// signature based revocation list with 50 entries - static std::vector sig_rl_data; - /// signature based revocation list with 5 entries - static std::vector sig_rl_5_entry_data; - /// a message - static const std::vector kMsg0; - /// a message - static const std::vector kMsg1; - /// a basename - static const std::vector kBsn0; - /// a basename - static const std::vector kBsn1; - - /// a group key in group X - static const GroupPubKey kGrpXKey; - /// a compressed private key in group X - static const CompressedPrivKey kGrpXMember9CompressedKey; - /// a private key in group X - static const PrivKey kGrpXMember9PrivKey; - - /// a group key in group Y - static const GroupPubKey kGrpYKey; - /// a compressed private key in group Y - static const CompressedPrivKey kGrpYMember9CompressedKey; - - /// setup called before each TEST_F starts - virtual void SetUp() {} - /// teardown called after each TEST_F finishes - virtual void TearDown() {} -}; - -#endif // EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/nr_prove-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/nr_prove-test.cc deleted file mode 100644 index 388ca5e610..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/nr_prove-test.cc +++ /dev/null @@ -1,299 +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 NrProve unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/verifier/api.h" -} - -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" - -namespace { - -TEST_F(EpidMemberTest, NrProveFailsGivenNullParameters) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature const* basic_sig = - &reinterpret_cast( - this->grp01_member0_sig_test1_sha256.data()) - ->sigma0; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - EXPECT_EQ(kEpidBadArgErr, EpidNrProve(nullptr, msg.data(), msg.size(), - basic_sig, &sig_rl->bk[0], &proof)); - EXPECT_EQ(kEpidBadArgErr, EpidNrProve(member, nullptr, msg.size(), basic_sig, - &sig_rl->bk[0], &proof)); - EXPECT_EQ(kEpidBadArgErr, EpidNrProve(member, msg.data(), msg.size(), nullptr, - &sig_rl->bk[0], &proof)); - EXPECT_EQ(kEpidBadArgErr, EpidNrProve(member, msg.data(), msg.size(), - basic_sig, nullptr, &proof)); - EXPECT_EQ(kEpidBadArgErr, EpidNrProve(member, msg.data(), msg.size(), - basic_sig, &sig_rl->bk[0], nullptr)); -} - -TEST_F(EpidMemberTest, NrProveFailsGivenInvalidSigRlEntry) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature const* basic_sig = - &reinterpret_cast( - this->grp01_member0_sig_test1_sha256.data()) - ->sigma0; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - SigRlEntry sig_rl_enty_invalid_k = sig_rl->bk[0]; - sig_rl_enty_invalid_k.k.x.data.data[31]++; // make it not in EC group - EXPECT_EQ(kEpidBadArgErr, - EpidNrProve(member, msg.data(), msg.size(), basic_sig, - &sig_rl_enty_invalid_k, &proof)); - - SigRlEntry sig_rl_enty_invalid_b = sig_rl->bk[0]; - sig_rl_enty_invalid_b.b.x.data.data[31]++; // make it not in EC group - EXPECT_EQ(kEpidBadArgErr, - EpidNrProve(member, msg.data(), msg.size(), basic_sig, - &sig_rl_enty_invalid_b, &proof)); -} - -TEST_F(EpidMemberTest, NrProveFailsGivenInvalidBasicSig) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature const* basic_sig = - &reinterpret_cast( - this->grp01_member0_sig_test1_sha256.data()) - ->sigma0; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - // invalid basic sig in this case is invalid B or K value only!! - BasicSignature basic_sig_invalid_B = *basic_sig; - basic_sig_invalid_B.B.x.data.data[31]++; // make it not in EC group; - EXPECT_EQ(kEpidBadArgErr, - EpidNrProve(member, msg.data(), msg.size(), &basic_sig_invalid_B, - &sig_rl->bk[0], &proof)); - - BasicSignature basic_sig_invalid_K = *basic_sig; - basic_sig_invalid_K.K.x.data.data[31]++; // make it not in EC group - EXPECT_EQ(kEpidBadArgErr, - EpidNrProve(member, msg.data(), msg.size(), &basic_sig_invalid_K, - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofForEmptyMessage) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha256)); - ASSERT_EQ(kEpidNoErr, - EpidSignBasic(member, nullptr, 0, nullptr, 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, nullptr, 0, &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha256)); - EXPECT_EQ(kEpidNoErr, - EpidNrVerify(ctx, &basic_sig, nullptr, 0, &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofUsingDefaultHashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofUsingDefaultHashAlgUsingIKGFData) { - Prng my_prng; - GroupPubKey grp_public_key = *reinterpret_cast( - this->group_public_key_data_ikgf.data()); - PrivKey mbr_private_key = *reinterpret_cast( - this->member_private_key_data_ikgf.data()); - const std::vector sigrl_bin = { -#include "epid/common/testdata/ikgf/groupa/sigrl.inc" - }; - - MemberCtxObj member(grp_public_key, mbr_private_key, &Prng::Generate, - &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = reinterpret_cast(sigrl_bin.data()); - - NrProof proof; - - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(grp_public_key); - - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofUsingSha256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha256)); - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofUsingSha384HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha384)); - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, GeneratesNrProofUsingSha512HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512)); - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512)); - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -TEST_F(EpidMemberTest, DISABLED_GeneratesNrProofUsingSha512256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - BasicSignature basic_sig; - auto msg = this->test1_msg; - SigRl const* sig_rl = - reinterpret_cast(this->sig_rl_data.data()); - - NrProof proof; - - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512_256)); - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - EXPECT_EQ(kEpidNoErr, EpidNrProve(member, msg.data(), msg.size(), &basic_sig, - &sig_rl->bk[0], &proof)); - - // Check proof by doing an NrVerify - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512_256)); - EXPECT_EQ(kEpidNoErr, EpidNrVerify(ctx, &basic_sig, msg.data(), msg.size(), - &sig_rl->bk[0], &proof)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/presig-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/presig-test.cc deleted file mode 100644 index 06c5ead71d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/presig-test.cc +++ /dev/null @@ -1,246 +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 ComputePreSig unit tests. - */ -#include -#include -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -} - -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -bool operator==(PreComputedSignature const& lhs, - PreComputedSignature const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} - -bool operator!=(PreComputedSignature const& lhs, - PreComputedSignature const& rhs) { - return !(lhs == rhs); -} - -namespace { - -/////////////////////////////////////////////////////////////////////// -// EpidAddPreSigs -TEST_F(EpidMemberTest, AddPreSigsFailsGivenNullPointer) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig = this->precomputed_signatures[0]; - - EXPECT_EQ(kEpidBadArgErr, EpidAddPreSigs(nullptr, 1, &presig)); -} - -TEST_F(EpidMemberTest, AddPreSigsFailsGivenHugeNumberOfPreSigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig = this->precomputed_signatures[0]; - - // number_presigs = 0x80..01 of size equal to sizeof(size_t) - EXPECT_EQ(kEpidBadArgErr, - EpidAddPreSigs(member, (SIZE_MAX >> 1) + 2, &presig)); -} - -TEST_F(EpidMemberTest, - AddPreSigsComputesSpecifiedNumberOfPresigsIfInputPresigsNull) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - ASSERT_EQ(kEpidNoErr, EpidAddPreSigs(member, 2, nullptr)); - ASSERT_EQ(kEpidNoErr, EpidAddPreSigs(member, 1, nullptr)); - // request to generate 0 pre-computed signatures do nothing - ASSERT_EQ(kEpidNoErr, EpidAddPreSigs(member, 0, nullptr)); - EXPECT_EQ((size_t)3, EpidGetNumPreSigs(member)); -} - -TEST_F(EpidMemberTest, AddPreSigsClearsInputPresigBuffer) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - // For a test purposes allocate an array of precomputed signatures with - // all elements initialized to the same precomputed signature. - // Warning: Do not use precomputed signatures twice in production code! - std::vector presigs(2, this->precomputed_signatures[0]); - - ASSERT_EQ(kEpidNoErr, EpidAddPreSigs(member, presigs.size(), presigs.data())); - EXPECT_TRUE(std::all_of((uint8_t*)presigs.data(), - (uint8_t*)(presigs.data() + presigs.size()), - [](uint8_t a) { return 0 == a; })); -} - -TEST_F(EpidMemberTest, AddPreSigsAddsCorrectNumberOfPresigsGivenValidInput) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - // For a test purposes allocate an arrays of precomputed signatures with - // all elements initialized to the same precomputed signature. - // Warning: Do not use precomputed signatures twice in production code! - std::vector presigs1(2, - this->precomputed_signatures[0]); - std::vector presigs2 = presigs1; - - // add - ASSERT_EQ(kEpidNoErr, - EpidAddPreSigs(member, presigs1.size(), presigs1.data())); - // extend - ASSERT_EQ(kEpidNoErr, - EpidAddPreSigs(member, presigs2.size(), presigs2.data())); - // add empty pre-computed signatures array does not affect internal pool - ASSERT_EQ(kEpidNoErr, EpidAddPreSigs(member, 0, presigs2.data())); - EXPECT_EQ(presigs1.size() + presigs2.size(), EpidGetNumPreSigs(member)); -} - -/////////////////////////////////////////////////////////////////////// -// EpidGetNumPreSigs -TEST_F(EpidMemberTest, GetNumPreSigsReturnsZeroGivenNullptr) { - EXPECT_EQ((size_t)0, EpidGetNumPreSigs(nullptr)); -} - -TEST_F(EpidMemberTest, NumPreSigsForNewleyCreatedContextIsZero) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - EXPECT_EQ((size_t)0, EpidGetNumPreSigs(member)); -} - -TEST_F(EpidMemberTest, GetNumPreSigsReturnsNumberOfAddedPresigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - // For a test purposes allocate an array of precomputed signatures with - // all elements initialized to the same precomputed signature. - // Warning: Do not use precomputed signatures twice in production code! - std::vector presigs(5, this->precomputed_signatures[0]); - - THROW_ON_EPIDERR(EpidAddPreSigs(member, presigs.size(), presigs.data())); - EXPECT_EQ(presigs.size(), EpidGetNumPreSigs(member)); -} -/////////////////////////////////////////////////////////////////////// -// EpidWritePreSigs -TEST_F(EpidMemberTest, WritePreSigsFailsGivenNullPointer) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - PreComputedSignature presig; - - EXPECT_EQ(kEpidBadArgErr, EpidWritePreSigs(nullptr, &presig, 0)); -} - -TEST_F(EpidMemberTest, WritePreSigsFailsGivenWrongNumberOfPresigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig = this->precomputed_signatures[0]; - - // add one pre-computed signature - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, &presig)); - // export more pre-computed signatures than available - EXPECT_EQ(kEpidBadArgErr, EpidWritePreSigs(member, &presig, 2)); -} - -TEST_F(EpidMemberTest, WritePreSigsClearsPresigsOnSuccess) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - std::vector presigs( - COUNT_OF(this->precomputed_signatures)); - presigs.assign(std::begin(this->precomputed_signatures), - std::end(this->precomputed_signatures)); - - THROW_ON_EPIDERR(EpidAddPreSigs(member, presigs.size(), presigs.data())); - - // can export some but not all - EXPECT_EQ(kEpidNoErr, EpidWritePreSigs(member, presigs.data(), 1)); - EXPECT_EQ(presigs.size() - 1, EpidGetNumPreSigs(member)); - // can export all the rest - EXPECT_EQ(kEpidNoErr, - EpidWritePreSigs(member, presigs.data() + 1, presigs.size() - 1)); - // check that all exported - EXPECT_EQ((size_t)0, EpidGetNumPreSigs(member)); - // check that both write operations export (and leave) correct values. - EXPECT_EQ(presigs.end(), std::unique(presigs.begin(), presigs.end())); -} - -TEST_F(EpidMemberTest, CanWriteAddedPresigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig0 = this->precomputed_signatures[0]; - PreComputedSignature presig1 = this->precomputed_signatures[1]; - PreComputedSignature presigs[2] = {presig0, presig1}; - - THROW_ON_EPIDERR(EpidAddPreSigs(member, COUNT_OF(presigs), presigs)); - - EXPECT_EQ(kEpidNoErr, EpidWritePreSigs(member, presigs, COUNT_OF(presigs))); - // compare ignoring order - EXPECT_TRUE((presig0 == presigs[0] && presig1 == presigs[1]) || - (presig0 == presigs[1] && presig1 == presigs[0])); -} - -TEST_F(EpidMemberTest, CanWriteGeneratedPresigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature zero_buffer; - memset(&zero_buffer, 0, sizeof(zero_buffer)); - PreComputedSignature presigs[2] = {zero_buffer, zero_buffer}; - - THROW_ON_EPIDERR(EpidAddPreSigs(member, COUNT_OF(presigs), nullptr)); - - EXPECT_EQ(kEpidNoErr, EpidWritePreSigs(member, presigs, COUNT_OF(presigs))); - // check pre-computed signature were written - EXPECT_NE(zero_buffer, presigs[0]); - EXPECT_NE(zero_buffer, presigs[1]); -} - -TEST_F(EpidMemberTest, WritePreSigsCanWriteZeroPresigs) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - - PreComputedSignature presig; - - EXPECT_EQ(kEpidNoErr, EpidWritePreSigs(member, &presig, 0)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/request_join-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/request_join-test.cc deleted file mode 100644 index 61760a22c2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/request_join-test.cc +++ /dev/null @@ -1,320 +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 RequestJoin unit tests. - */ - -#include -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/common/math/ecgroup.h" -#include "epid/common/math/finitefield.h" -#include "epid/common/epid2params.h" -} - -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/common-testhelper/finite_field_wrapper-testhelper.h" -#include "epid/common-testhelper/ffelement_wrapper-testhelper.h" -#include "epid/common-testhelper/epid_params-testhelper.h" -#include "epid/common-testhelper/ecgroup_wrapper-testhelper.h" -#include "epid/common-testhelper/ecpoint_wrapper-testhelper.h" - -namespace { - -// local constant for RequestJoin tests. This can be hoisted later if needed -// avoids cpplint warning about multiple includes. -const GroupPubKey kPubKey = { -#include "epid/common/testdata/grp01/gpubkey.inc" -}; - -TEST_F(EpidMemberTest, RequestJoinFailsGivenNullParameters) { - GroupPubKey pub_key = kPubKey; - IssuerNonce ni; - FpElemStr f; - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request; - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(nullptr, &ni, &f, rnd_func, - rnd_param, kSha256, &join_request)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, nullptr, &f, rnd_func, - rnd_param, kSha256, &join_request)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, &ni, nullptr, rnd_func, - rnd_param, kSha256, &join_request)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, - rnd_param, kSha256, nullptr)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, &ni, &f, nullptr, - rnd_param, kSha256, &join_request)); -} - -TEST_F(EpidMemberTest, RequestJoinFailsGivenInvalidGroupKey) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request; - GroupPubKey pub_key = kPubKey; - FpElemStr f = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - pub_key.h1.x.data.data[15] = 0xff; - Epid20Params params; - EcPointObj pt(¶ms.G1); - ASSERT_NE(kEpidNoErr, ReadEcPoint(params.G1, (uint8_t*)&pub_key.h1, - sizeof(pub_key.h1), pt)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, - rnd_param, kSha256, &join_request)); -} - -TEST_F(EpidMemberTest, RequestJoinFailsGivenInvalidFValue) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request; - GroupPubKey pub_key = kPubKey; - FpElemStr f = { - 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, 0x00, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - - const BigNumStr 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}}}; - FiniteFieldObj Fp(p); - FfElementObj el(&Fp); - ASSERT_NE(kEpidNoErr, ReadFfElement(Fp, (uint8_t*)&f, sizeof(f), el)); - EXPECT_EQ(kEpidBadArgErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, - rnd_param, kSha256, &join_request)); -} - -TEST_F(EpidMemberTest, - GeneratesValidJoinRequestGivenValidParametersUsingIKGFData) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request; - FpElemStr f = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - const GroupPubKey* grp_public_key = reinterpret_cast( - this->group_public_key_data_ikgf.data()); - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(grp_public_key, &ni, &f, rnd_func, - rnd_param, kSha256, &join_request)); -} - -TEST_F(EpidMemberTest, GeneratesValidJoinRequestGivenValidParameters) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request; - GroupPubKey pub_key = kPubKey; - FpElemStr f = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, rnd_param, - kSha256, &join_request)); -} - -TEST_F(EpidMemberTest, GeneratesDiffJoinRequestsOnMultipleCalls) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request1; - JoinRequest join_request2; - GroupPubKey pub_key = kPubKey; - FpElemStr f = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - prng.set_seed(0x1234); - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, rnd_param, - kSha256, &join_request1)); - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, rnd_param, - kSha256, &join_request2)); - EXPECT_NE(0, memcmp(&join_request1, &join_request2, sizeof(join_request1))); -} - -TEST_F(EpidMemberTest, GeneratesDiffJoinRequestsGivenDiffHashAlgs) { - Prng prng; - BitSupplier rnd_func = Prng::Generate; - void* rnd_param = &prng; - JoinRequest join_request1; - JoinRequest join_request2; - GroupPubKey pub_key = kPubKey; - FpElemStr f = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, - }; - IssuerNonce ni = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, - 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, - }; - prng.set_seed(0x1234); - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, rnd_param, - kSha256, &join_request1)); - prng.set_seed(0x1234); - EXPECT_EQ(kEpidNoErr, EpidRequestJoin(&pub_key, &ni, &f, rnd_func, rnd_param, - kSha512, &join_request2)); - EXPECT_NE(0, memcmp(&join_request1, &join_request2, sizeof(join_request1))); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationFailsGivenNullParameters) { - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, nullptr)); - EXPECT_FALSE(EpidIsPrivKeyInGroup(nullptr, &this->kGrpXMember9PrivKey)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationFailsGivenGroupIDMissmatch) { - // Check wrong gid for GroupPubKey - GroupPubKey group_pub_key = this->kGrpXKey; - group_pub_key.gid.data[0] = group_pub_key.gid.data[0] ^ 0xFF; - EXPECT_FALSE( - EpidIsPrivKeyInGroup(&group_pub_key, &this->kGrpXMember9PrivKey)); - // Check wrong gid for PrivKey - PrivKey priv_key = this->kGrpXMember9PrivKey; - priv_key.gid.data[sizeof(priv_key.gid.data) - 1] = - priv_key.gid.data[sizeof(priv_key.gid.data) - 1] ^ 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, &priv_key)); - // Check wrong gid for both GroupPubKey and PrivKey - EXPECT_FALSE(EpidIsPrivKeyInGroup(&group_pub_key, &priv_key)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationRejectsInvalidPrivKey) { - // test for invalid key components values (eg. out of range, not in EC group) - PrivKey priv_key = this->kGrpXMember9PrivKey; - priv_key.A.x.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, &priv_key)); - - priv_key = this->kGrpXMember9PrivKey; - priv_key.A.y.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, &priv_key)); - - priv_key = this->kGrpXMember9PrivKey; - FpElemStr inv_f = { - 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, 0x00, - }; - priv_key.f = inv_f; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, &priv_key)); - - priv_key = this->kGrpXMember9PrivKey; - priv_key.x.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&this->kGrpXKey, &priv_key)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationRejectsInvalidGroupKey) { - // test for invalid key components values (eg. out of range, not in EC group) - GroupPubKey pub_key = this->kGrpXKey; - pub_key.h1.x.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.h1.y.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.h2.x.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.h2.y.data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.w.x[0].data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.w.x[1].data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.w.y[0].data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); - - pub_key = this->kGrpXKey; - pub_key.w.y[1].data.data[0] = 0xFF; - EXPECT_FALSE(EpidIsPrivKeyInGroup(&pub_key, &this->kGrpXMember9PrivKey)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationRejectsKeyNotInGroup) { - EXPECT_FALSE( - EpidIsPrivKeyInGroup(&this->kGrpYKey, &this->kGrpXMember9PrivKey)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationRejectsKeyNotInGroupUsingIKGFData) { - const GroupPubKey* grp_public_key = reinterpret_cast( - this->group_public_key_data_ikgf.data()); - const PrivKey mbr_private_key = { -#include "epid/common/testdata/ikgf/groupb/member0/mprivkey.inc" - }; - EXPECT_FALSE(EpidIsPrivKeyInGroup(grp_public_key, &mbr_private_key)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationAcceptsKeyInGroup) { - EXPECT_TRUE( - EpidIsPrivKeyInGroup(&this->kGrpXKey, &this->kGrpXMember9PrivKey)); -} - -TEST_F(EpidMemberTest, PrivateKeyValidationAcceptsKeyInGroupUsingIKGFData) { - const GroupPubKey* grp_public_key = reinterpret_cast( - this->group_public_key_data_ikgf.data()); - const PrivKey* mbr_private_key = reinterpret_cast( - this->member_private_key_data_ikgf.data()); - EXPECT_TRUE(EpidIsPrivKeyInGroup(grp_public_key, mbr_private_key)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/sign-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/sign-test.cc deleted file mode 100644 index b9c53608b3..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/sign-test.cc +++ /dev/null @@ -1,1051 +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 Sign unit tests. - */ -#include -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/member/context.h" -#include "epid/verifier/api.h" -} - -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -namespace { - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -///////////////////////////////////////////////////////////////////////// -// Simple error cases - -TEST_F(EpidMemberTest, SignFailsGivenNullParameters) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->group_public_key.gid; - std::vector sig(EpidGetSigSize(&srl)); - EXPECT_EQ(kEpidBadArgErr, EpidSign(nullptr, msg.data(), msg.size(), - bsn.data(), bsn.size(), &srl, sizeof(srl), - (EpidSignature*)sig.data(), sig.size())); - EXPECT_EQ(kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), - &srl, sizeof(srl), nullptr, sig.size())); - EXPECT_EQ(kEpidBadArgErr, - EpidSign(member, nullptr, msg.size(), bsn.data(), bsn.size(), &srl, - sizeof(srl), (EpidSignature*)sig.data(), sig.size())); - EXPECT_EQ(kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), nullptr, bsn.size(), &srl, - sizeof(srl), (EpidSignature*)sig.data(), sig.size())); -} - -TEST_F(EpidMemberTest, SignFailsGivenWrongSigLen) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->group_public_key.gid; - - // signature buffer one byte less than needed - std::vector sig_small(EpidGetSigSize(&srl) - 1); - EXPECT_EQ(kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), - &srl, sizeof(srl), (EpidSignature*)sig_small.data(), - sig_small.size())); - - // signature buffer is one byte - a less than allowed for EpidSignature - std::vector sig_one(1); - EXPECT_EQ( - kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), &srl, - sizeof(srl), (EpidSignature*)sig_one.data(), sig_one.size())); -} - -TEST_F(EpidMemberTest, SignFailsGivenWrongSigRlLen) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->group_public_key.gid; - - std::vector sig(EpidGetSigSize(&srl)); - std::vector srl_reduced(1); - EXPECT_EQ(kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), - (SigRl*)srl_reduced.data(), srl_reduced.size(), - (EpidSignature*)sig.data(), sig.size())); -} - -TEST_F(EpidMemberTest, SignFailsGivenUnregisteredBasename) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& bsn1 = this->kBsn1; - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->group_public_key.gid; - std::vector sig(EpidGetSigSize(&srl)); - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ( - kEpidBadArgErr, - EpidSign(member, msg.data(), msg.size(), bsn1.data(), bsn1.size(), &srl, - sizeof(srl), (EpidSignature*)sig.data(), sig.size())); -} - -///////////////////////////////////////////////////////////////////////// -// Anonymity - -TEST_F(EpidMemberTest, SignaturesOfSameMessageAreDifferent) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig1(EpidGetSigSize(nullptr)); - std::vector sig2(EpidGetSigSize(nullptr)); - // without signature based revocation list - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), nullptr, 0, nullptr, 0, - (EpidSignature*)sig1.data(), sig1.size())); - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), nullptr, 0, nullptr, 0, - (EpidSignature*)sig2.data(), sig2.size())); - EXPECT_TRUE(sig1.size() == sig2.size() && - 0 != memcmp(sig1.data(), sig2.data(), sig1.size())); - // with signature based revocation list - uint8_t sig_rl_data_n2_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x01, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b}; - SigRl* srl1 = reinterpret_cast(sig_rl_data_n2_one); - size_t srl1_size = sizeof(sig_rl_data_n2_one); - std::vector sig3(EpidGetSigSize(srl1)); - std::vector sig4(EpidGetSigSize(srl1)); - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), nullptr, 0, srl1, - srl1_size, (EpidSignature*)sig3.data(), sig3.size())); - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), nullptr, 0, srl1, - srl1_size, (EpidSignature*)sig4.data(), sig4.size())); - EXPECT_TRUE(sig3.size() == sig4.size() && - 0 != memcmp(sig3.data(), sig4.data(), sig3.size())); -} -TEST_F(EpidMemberTest, SignaturesOfSameMessageWithSameBasenameAreDifferent) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - std::vector sig1(EpidGetSigSize(nullptr)); - std::vector sig2(EpidGetSigSize(nullptr)); - // without signature based revocation list - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), - nullptr, 0, (EpidSignature*)sig1.data(), sig1.size())); - EXPECT_EQ(kEpidNoErr, - EpidSign(member, msg.data(), msg.size(), bsn.data(), bsn.size(), - nullptr, 0, (EpidSignature*)sig2.data(), sig2.size())); - EXPECT_TRUE(sig1.size() == sig2.size() && - 0 != memcmp(sig1.data(), sig2.data(), sig1.size())); - - // with signature based revocation list - uint8_t sig_rl_data_n2_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x01, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b}; - SigRl* srl1 = reinterpret_cast(sig_rl_data_n2_one); - size_t srl1_size = sizeof(sig_rl_data_n2_one); - std::vector sig3(EpidGetSigSize(srl1)); - std::vector sig4(EpidGetSigSize(srl1)); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), bsn.data(), - bsn.size(), srl1, srl1_size, - (EpidSignature*)sig3.data(), sig3.size())); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), bsn.data(), - bsn.size(), srl1, srl1_size, - (EpidSignature*)sig4.data(), sig4.size())); - EXPECT_TRUE(sig3.size() == sig4.size() && - 0 != memcmp(sig3.data(), sig4.data(), sig3.size())); -} - -///////////////////////////////////////////////////////////////////////// -// Variable basename - -TEST_F(EpidMemberTest, SignsMessageUsingRandomBaseNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignsMessageUsingRandomBaseWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageUsingBasenameNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), bsn.data(), - bsn.size(), nullptr, 0, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} - -TEST_F(EpidMemberTest, SignsMessageUsingBasenameWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), bsn.data(), - bsn.size(), srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} - -TEST_F(EpidMemberTest, SignsUsingRandomBaseWithRegisteredBasenamesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignsUsingRandomBaseWithRegisteredBasenamesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsUsingRandomBaseWithoutRegisteredBasenamesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, - SignsUsingRandomBaseWithoutRegisteredBasenamesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -///////////////////////////////////////////////////////////////////////// -// Variable sigRL - -TEST_F(EpidMemberTest, SignFailsGivenInvalidSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - - // sign fail with mismatch gid - uint8_t sig_rl_data_n2_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x01, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b}; - SigRl* srl = reinterpret_cast(sig_rl_data_n2_one); - size_t srl_size = sizeof(sig_rl_data_n2_one); - size_t sig_len = EpidGetSigSize(srl); - std::vector newsig(sig_len); - EpidSignature* sig = (EpidSignature*)newsig.data(); - - EXPECT_EQ(kEpidBadArgErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - - // sign fail given invalid sigrl size - uint8_t sig_rl_data_n_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x00, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b}; - SigRl* srl1 = reinterpret_cast(sig_rl_data_n_one); - size_t srl1_size = sizeof(sig_rl_data_n_one); - size_t sig_len1 = EpidGetSigSize(srl1); - std::vector newsig1(sig_len1); - EpidSignature* sig1 = (EpidSignature*)newsig1.data(); - - EXPECT_EQ(kEpidBadArgErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl1, srl1_size, sig1, sig_len1)); -} - -TEST_F(EpidMemberTest, SignsMessageGivenNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - - size_t sig_len = EpidGetSigSize(nullptr); - std::vector newsig(sig_len); - EpidSignature* sig = (EpidSignature*)newsig.data(); - - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignsMessageGivenNoSigRlUsingIKGFData) { - GroupPubKey grp_public_key = *reinterpret_cast( - this->group_public_key_data_ikgf.data()); - PrivKey mbr_private_key = *reinterpret_cast( - this->member_private_key_data_ikgf.data()); - Prng my_prng; - auto& msg = this->kMsg0; - - size_t sig_len = EpidGetSigSize(nullptr); - std::vector newsig(sig_len); - // using ikgf keys - MemberCtxObj member(grp_public_key, mbr_private_key, &Prng::Generate, - &my_prng); - EpidSignature* sig = (EpidSignature*)newsig.data(); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(grp_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageGivenSigRlWithNoEntries) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - - uint8_t sig_rl_data_n2_zero[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x00, - // not bk's - }; - SigRl const* srl = reinterpret_cast(sig_rl_data_n2_zero); - size_t srl_size = sizeof(sig_rl_data_n2_zero); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageGivenSigRlWithEntries) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - uint8_t sig_rl_data_n2_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x02, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b, - - 0x71, 0x8a, 0xb5, 0x1, 0x7f, 0x7c, 0x92, 0x9a, 0xa2, 0xc9, 0x81, 0x10, - 0xfe, 0xbf, 0xc, 0x53, 0xa4, 0x43, 0xaf, 0x31, 0x74, 0x12, 0x25, 0x60, - 0x3e, 0xc0, 0x21, 0xe6, 0x63, 0x9a, 0xd2, 0x67, 0x2d, 0xb5, 0xd5, 0x82, - 0xc4, 0x49, 0x29, 0x51, 0x42, 0x8f, 0xe0, 0xe, 0xd1, 0x73, 0x27, 0xf5, - 0x77, 0x16, 0x4, 0x40, 0x8a, 0x0, 0xe, 0x3a, 0x5d, 0x37, 0x42, 0xd3, 0x8, - 0x40, 0xbd, 0x69, 0xf7, 0x5f, 0x74, 0x21, 0x50, 0xf4, 0xce, 0xfe, 0xd9, - 0xdd, 0x97, 0x6c, 0xa8, 0xa5, 0x60, 0x6b, 0xf8, 0x1b, 0xba, 0x2, 0xb2, - 0xca, 0x5, 0x44, 0x9b, 0xb1, 0x5e, 0x3a, 0xa4, 0x35, 0x7a, 0x51, 0xfa, - 0xcf, 0xa4, 0x4, 0xe9, 0xf3, 0xbf, 0x38, 0xd4, 0x24, 0x9, 0x52, 0xf3, - 0x58, 0x3d, 0x9d, 0x4b, 0xb3, 0x37, 0x4b, 0xec, 0x87, 0xe1, 0x64, 0x60, - 0x3c, 0xb6, 0xf7, 0x7b, 0xff, 0x40, 0x11}; - SigRl* srl = reinterpret_cast(sig_rl_data_n2_one); - size_t srl_size = sizeof(sig_rl_data_n2_one); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageGivenSigRlWithEntriesUsingIKGFData) { - GroupPubKey grp_public_key = *reinterpret_cast( - this->group_public_key_data_ikgf.data()); - PrivKey mbr_private_key = *reinterpret_cast( - this->member_private_key_data_ikgf.data()); - Prng my_prng; - auto& msg = this->kMsg0; - // using ikgf keys - MemberCtxObj member_ikgf(grp_public_key, mbr_private_key, &Prng::Generate, - &my_prng); - uint8_t sig_rl_data_n2_one_gid0[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x02, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b, - - 0x71, 0x8a, 0xb5, 0x1, 0x7f, 0x7c, 0x92, 0x9a, 0xa2, 0xc9, 0x81, 0x10, - 0xfe, 0xbf, 0xc, 0x53, 0xa4, 0x43, 0xaf, 0x31, 0x74, 0x12, 0x25, 0x60, - 0x3e, 0xc0, 0x21, 0xe6, 0x63, 0x9a, 0xd2, 0x67, 0x2d, 0xb5, 0xd5, 0x82, - 0xc4, 0x49, 0x29, 0x51, 0x42, 0x8f, 0xe0, 0xe, 0xd1, 0x73, 0x27, 0xf5, - 0x77, 0x16, 0x4, 0x40, 0x8a, 0x0, 0xe, 0x3a, 0x5d, 0x37, 0x42, 0xd3, 0x8, - 0x40, 0xbd, 0x69, 0xf7, 0x5f, 0x74, 0x21, 0x50, 0xf4, 0xce, 0xfe, 0xd9, - 0xdd, 0x97, 0x6c, 0xa8, 0xa5, 0x60, 0x6b, 0xf8, 0x1b, 0xba, 0x2, 0xb2, - 0xca, 0x5, 0x44, 0x9b, 0xb1, 0x5e, 0x3a, 0xa4, 0x35, 0x7a, 0x51, 0xfa, - 0xcf, 0xa4, 0x4, 0xe9, 0xf3, 0xbf, 0x38, 0xd4, 0x24, 0x9, 0x52, 0xf3, - 0x58, 0x3d, 0x9d, 0x4b, 0xb3, 0x37, 0x4b, 0xec, 0x87, 0xe1, 0x64, 0x60, - 0x3c, 0xb6, 0xf7, 0x7b, 0xff, 0x40, 0x11}; - SigRl* srl_ikgf = reinterpret_cast(sig_rl_data_n2_one_gid0); - size_t srl_size = sizeof(sig_rl_data_n2_one_gid0); - std::vector sig_data_ikgf(EpidGetSigSize(srl_ikgf)); - EpidSignature* sig_ikgf = - reinterpret_cast(sig_data_ikgf.data()); - size_t sig_len = sig_data_ikgf.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member_ikgf, msg.data(), msg.size(), nullptr, - 0, srl_ikgf, srl_size, sig_ikgf, sig_len)); - VerifierCtxObj ctx_ikgf(grp_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx_ikgf, srl_ikgf, srl_size)); - EXPECT_EQ(kEpidSigValid, EpidVerify(ctx_ikgf, sig_ikgf, sig_len, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignMessageReportsIfMemberRevoked) { - // note: a complete sig + nr proof should still be returned!! - const GroupPubKey pub_key = { -#include "epid/common/testdata/grp_x/pubkey.inc" - }; - const PrivKey priv_key = { -#include "epid/common/testdata/grp_x/member0/mprivkey.inc" - }; - Prng my_prng; - MemberCtxObj member(pub_key, priv_key, this->member_precomp, &Prng::Generate, - &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - const std::vector kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry = { -#include "epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_middle_entry.inc" - }; - auto srl = reinterpret_cast( - kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry.data()); - size_t srl_size = kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry.size(); - - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidBadArgErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - - VerifierCtxObj ctx(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - - EXPECT_EQ(kEpidSigInvalid, EpidVerify(ctx, sig, sig_len, msg.data(), - msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidMemberTest, SignMessageReportsIfMemberRevokedUsingIKGFData) { - // note: a complete sig + nr proof should still be returned!! - GroupPubKey grp_public_key = *reinterpret_cast( - this->group_public_key_data_ikgf.data()); - const PrivKey member_private_key_revoked_by_sig = { -#include "epid/common/testdata/ikgf/groupa/sigrevokedmember0/mprivkey.inc" - }; - Prng my_prng; - MemberCtxObj member(grp_public_key, member_private_key_revoked_by_sig, - &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - const std::vector sig_Rl = { -#include "epid/common/testdata/ikgf/groupa/sigrl.inc" - }; - auto srl = reinterpret_cast(sig_Rl.data()); - size_t srl_size = sig_Rl.size(); - - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidSign(member, msg.data(), msg.size(), nullptr, 0, srl, srl_size, - sig, sig_len)); - - VerifierCtxObj ctx(grp_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - - EXPECT_EQ(kEpidSigInvalid, EpidVerify(ctx, sig, sig_len, msg.data(), - msg.size(), bsn.data(), bsn.size())); -} -///////////////////////////////////////////////////////////////////////// -// Variable hash alg - -TEST_F(EpidMemberTest, SignsMessageUsingSha256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha256)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageUsingSha384HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha384)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageUsingSha512HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512)); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, DISABLED_SignsMessageUsingSha512256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512_256)); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512_256)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -///////////////////////////////////////////////////////////////////////// -// Variable precomputed signatures - -TEST_F(EpidMemberTest, SignConsumesPrecomputedSignaturesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 3, nullptr)); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - EXPECT_EQ((size_t)2, EpidGetNumPreSigs(member)); -} - -TEST_F(EpidMemberTest, SignConsumesPrecomputedSignaturesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 3, nullptr)); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - EXPECT_EQ((size_t)2, EpidGetNumPreSigs(member)); -} - -TEST_F(EpidMemberTest, SignsMessageWithPrecomputedSignaturesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, nullptr)); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageWithPrecomputedSignaturesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, nullptr)); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageWithoutPrecomputedSignaturesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - // test sign without precomputed signatures - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsMessageWithoutPrecomputedSignaturesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - // test sign without precomputed signatures - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignFailsOnBadPrecomputedSignaturesNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - PreComputedSignature precompsig; - precompsig = this->precomputed_signatures[0]; - precompsig.B.x.data.data[0]++; - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, &precompsig)); - auto& msg = this->kMsg0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidBadArgErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)); -} - -TEST_F(EpidMemberTest, SignFailsOnBadPrecomputedSignaturesWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - PreComputedSignature precompsig; - precompsig = this->precomputed_signatures[0]; - precompsig.B.x.data.data[0]++; - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, &precompsig)); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidBadArgErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)); -} - -///////////////////////////////////////////////////////////////////////// -// Variable messages - -TEST_F(EpidMemberTest, SignsEmptyMessageNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), 0, bsn.data(), bsn.size(), - nullptr, 0, sig, sig_len)); - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, EpidVerify(ctx, sig, sig_len, msg.data(), 0, - bsn.data(), bsn.size())); -} - -TEST_F(EpidMemberTest, SignsEmptyMessageWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), 0, nullptr, 0, srl, - srl_size, sig, sig_len)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), 0, nullptr, 0)); -} - -TEST_F(EpidMemberTest, SignsShortMessageNoSigRl) { - // check: 1, 13, 128, 256, 512, 1021, 1024 bytes - // 13 and 1021 are primes - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - VerifierCtxObj ctx(this->group_public_key); - size_t lengths[] = {1, 13, 128, 256, - 512, 1021, 1024}; // have desired lengths to loop over - std::vector msg( - lengths[COUNT_OF(lengths) - 1]); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg[n] = (uint8_t)n; - } - for (auto length : lengths) { - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), length, nullptr, 0, - nullptr, 0, sig, sig_len)) - << "EpidSign for message_len: " << length << " failed"; - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), length, nullptr, 0)) - << "EpidVerify for message_len: " << length << " failed"; - } -} - -TEST_F(EpidMemberTest, SignsShortMessageWithSigRl) { - // check: 1, 13, 128, 256, 512, 1021, 1024 bytes - // 13 and 1021 are primes - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - size_t message_len = 0; - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - size_t lengths[] = {1, 13, 128, 256, - 512, 1021, 1024}; // have desired lengths to loop over - std::vector msg( - lengths[COUNT_OF(lengths) - 1]); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg.at(n) = (uint8_t)n; - } - for (auto length : lengths) { - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), length, nullptr, 0, srl, - srl_size, sig, sig_len)) - << "EpidSign for message_len: " << message_len << " failed"; - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), length, nullptr, 0)) - << "EpidVerify for message_len: " << message_len << " failed"; - } -} - -TEST_F(EpidMemberTest, SignsLongMessageNoSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - std::vector sig_data(EpidGetSigSize(nullptr)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - VerifierCtxObj ctx(this->group_public_key); - std::vector msg(1000000); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg.at(n) = (uint8_t)n; - } - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - nullptr, 0, sig, sig_len)) - << "EpidSign for message_len: " << 1000000 << " failed"; - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)) - << "EpidVerify for message_len: " << 1000000 << " failed"; -} - -TEST_F(EpidMemberTest, SignsLongMessageWithSigRl) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - SigRl const* srl = - reinterpret_cast(this->sig_rl_5_entry_data.data()); - size_t srl_size = this->sig_rl_5_entry_data.size() * sizeof(uint8_t); - std::vector sig_data(EpidGetSigSize(srl)); - EpidSignature* sig = reinterpret_cast(sig_data.data()); - size_t sig_len = sig_data.size() * sizeof(uint8_t); - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(ctx, srl, srl_size)); - std::vector msg(1000000); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg.at(n) = (uint8_t)n; - } - EXPECT_EQ(kEpidNoErr, EpidSign(member, msg.data(), msg.size(), nullptr, 0, - srl, srl_size, sig, sig_len)) - << "EpidSign for message_len: " << 1000000 << " failed"; - EXPECT_EQ(kEpidSigValid, - EpidVerify(ctx, sig, sig_len, msg.data(), msg.size(), nullptr, 0)) - << "EpidVerify for message_len: " << 1000000 << " failed"; -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/signbasic-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/signbasic-test.cc deleted file mode 100644 index 23ec1caa7f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/member/unittests/signbasic-test.cc +++ /dev/null @@ -1,401 +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 SignBasic unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/member/api.h" -#include "epid/verifier/api.h" -} - -#include "epid/common-testhelper/errors-testhelper.h" -#include "epid/common-testhelper/prng-testhelper.h" -#include "epid/member/unittests/member-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" - -namespace { - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -///////////////////////////////////////////////////////////////////////// -// Simple error cases -TEST_F(EpidMemberTest, SignBasicFailsGivenNullParameters) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - BasicSignature basic_sig; - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(nullptr, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), nullptr)); - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, nullptr, msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, msg.data(), msg.size(), - nullptr, bsn.size(), &basic_sig)); -} -TEST_F(EpidMemberTest, SignBasicFailsForBasenameWithoutRegisteredBasenames) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - BasicSignature basic_sig; - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); -} -TEST_F(EpidMemberTest, SignBasicFailsIfGivenUnregisteredBasename) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn0 = this->kBsn0; - auto& bsn1 = this->kBsn1; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn0.data(), bsn0.size())); - BasicSignature basic_sig; - EXPECT_EQ(kEpidBadArgErr, - EpidSignBasic(member, msg.data(), msg.size(), bsn1.data(), - bsn1.size(), &basic_sig)); -} -///////////////////////////////////////////////////////////////////////// -// Anonymity -TEST_F(EpidMemberTest, BasicSignaturesOfSameMessageAreDifferent) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - BasicSignature basic_sig1; - BasicSignature basic_sig2; - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig1)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig2)); - EXPECT_NE(0, memcmp(&basic_sig1, &basic_sig2, sizeof(BasicSignature))); -} -TEST_F(EpidMemberTest, - BasicSignaturesOfSameMessageWithSameBasenameAreDifferent) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - BasicSignature basic_sig1; - BasicSignature basic_sig2; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig1)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig2)); - EXPECT_NE(0, memcmp(&basic_sig1, &basic_sig2, sizeof(BasicSignature))); -} -///////////////////////////////////////////////////////////////////////// -// Variable basename -TEST_F(EpidMemberTest, SignBasicSucceedsUsingRandomBase) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignBasicSucceedsUsingBasename) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} -TEST_F(EpidMemberTest, SignBasicSucceedsUsingBasenameUsingIKGFData) { - Prng my_prng; - GroupPubKey grp_public_key = *reinterpret_cast( - this->group_public_key_data_ikgf.data()); - PrivKey mbr_private_key = *reinterpret_cast( - this->member_private_key_data_ikgf.data()); - MemberCtxObj member(grp_public_key, mbr_private_key, &Prng::Generate, - &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(grp_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} -TEST_F(EpidMemberTest, - SignBasicSucceedsUsingRandomBaseWithRegisteredBasenames) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} -TEST_F(EpidMemberTest, - SignBasicSucceedsUsingRandomBaseWithoutRegisteredBasenames) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -///////////////////////////////////////////////////////////////////////// -// Variable hash alg -TEST_F(EpidMemberTest, SignBasicSucceedsUsingSha256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha256)); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignBasicSucceedsUsingSha384HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha384)); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, SignBasicSucceedsUsingSha512HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512)); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -TEST_F(EpidMemberTest, DISABLED_SignBasicSucceedsUsingSha512256HashAlg) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - THROW_ON_EPIDERR(EpidMemberSetHashAlg(member, kSha512_256)); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(ctx, kSha512_256)); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} -///////////////////////////////////////////////////////////////////////// -TEST_F(EpidMemberTest, SignBasicFailsForInvalidMemberPrecomp) { - Prng my_prng; - MemberPrecomp mbr_precomp = this->member_precomp; - mbr_precomp.e12.x[0].data.data[0]++; - MemberCtxObj member(this->group_public_key, this->member_private_key, - mbr_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - auto& bsn = this->kBsn0; - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); -} -// Variable precomputed signatures -TEST_F(EpidMemberTest, SignBasicFailsForInvalidPrecomputedSignature) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - PreComputedSignature precompsig = this->precomputed_signatures[0]; - precompsig.B.x.data.data[0]++; - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, &precompsig)); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - auto& bsn = this->kBsn0; - EXPECT_EQ(kEpidBadArgErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); -} -TEST_F(EpidMemberTest, SignBasicConsumesPrecomputedSignatures) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 3, nullptr)); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - // use 1 precomputed signature - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - EXPECT_EQ((size_t)2, EpidGetNumPreSigs(member)); -} -TEST_F(EpidMemberTest, SignBasicSucceedsWithPrecomputedSignatures) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, nullptr)); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} -TEST_F(EpidMemberTest, SignBasicSucceedsWithoutPrecomputedSignatures) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - THROW_ON_EPIDERR(EpidAddPreSigs(member, 1, nullptr)); - auto& msg = this->kMsg0; - BasicSignature basic_sig; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - ASSERT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // test sign without precomputed signatures - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), - bsn.data(), bsn.size(), &basic_sig)); - // verify basic signature - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, - EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), msg.size(), - bsn.data(), bsn.size())); -} -///////////////////////////////////////////////////////////////////////// -// Variable messages -TEST_F(EpidMemberTest, SignBasicSucceedsGivenEmptyMessage) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - THROW_ON_EPIDERR(EpidRegisterBaseName(member, bsn.data(), bsn.size())); - BasicSignature basic_sig; - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), 0, bsn.data(), - bsn.size(), &basic_sig)); - VerifierCtxObj ctx(this->group_public_key); - EXPECT_EQ(kEpidSigValid, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), 0, - bsn.data(), bsn.size())); -} -TEST_F(EpidMemberTest, SignBasicSucceedsWithShortMessage) { - // check: 1, 13, 128, 256, 512, 1021, 1024 bytes - // 13 and 1021 are primes - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - BasicSignature basic_sig; - VerifierCtxObj ctx(this->group_public_key); - size_t lengths[] = {1, 13, 128, 256, - 512, 1021, 1024}; // have desired lengths to loop over - std::vector msg( - lengths[COUNT_OF(lengths) - 1]); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg.at(n) = (uint8_t)n; - } - for (auto length : lengths) { - EXPECT_EQ(kEpidNoErr, - EpidSignBasic(member, msg.data(), length, nullptr, 0, &basic_sig)) - << "EpidSignBasic for message_len: " << length << " failed"; - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - length, nullptr, 0)) - << "EpidVerifyBasicSig for message_len: " << length << " failed"; - } -} -TEST_F(EpidMemberTest, SignBasicSucceedsWithLongMessage) { - Prng my_prng; - MemberCtxObj member(this->group_public_key, this->member_private_key, - this->member_precomp, &Prng::Generate, &my_prng); - BasicSignature basic_sig; - VerifierCtxObj ctx(this->group_public_key); - { // 1000000 - std::vector msg(1000000); // allocate message for max size - for (size_t n = 0; n < msg.size(); n++) { - msg.at(n) = (uint8_t)n; - } - EXPECT_EQ(kEpidNoErr, EpidSignBasic(member, msg.data(), msg.size(), nullptr, - 0, &basic_sig)) - << "EpidSignBasic for message_len: " << 1000000 << " failed"; - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(ctx, &basic_sig, msg.data(), - msg.size(), nullptr, 0)) - << "EpidVerifyBasicSig for message_len: " << 1000000 << " failed"; - } -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/api.h b/sgx-jvm/linux-sgx/external/epid/epid/verifier/api.h deleted file mode 100644 index 74440dd078..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/api.h +++ /dev/null @@ -1,472 +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_VERIFIER_API_H_ -#define EPID_VERIFIER_API_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include -#include "epid/common/stdtypes.h" -#include "epid/common/types.h" -#include "epid/common/errors.h" - -/*! - * \file - * \brief Intel(R) EPID SDK verifier API. - */ - -/// Verifier functionality -/*! - \defgroup EpidVerifierModule verifier - - Defines the APIs needed by Intel(R) EPID verifiers. Each verifier - context (::VerifierCtx) represents a verifier for a single group. - - \ingroup EpidModule - @{ -*/ - -/// Internal context of verifier. -typedef struct VerifierCtx VerifierCtx; - -/// Pre-computed member settings. -/*! - Serialized form of the information about a member that remains stable for - a given set of keys. - - \note e12 = 0 implies that this data is not valid - */ -#pragma pack(1) -typedef struct VerifierPrecomp { - GtElemStr e12; ///< an element in GT - GtElemStr e22; ///< an element in GT - GtElemStr e2w; ///< an element in GT - GtElemStr eg12; ///< an element in GT -} VerifierPrecomp; -#pragma pack() - -/// Creates a new verifier context. -/*! - Must be called to create the verifier context that is used by - other "Verifier" APIs. - - Allocates memory for the context, then initializes it. - - EpidVerifierDelete() must be called to safely release the member context. - - - \param[in] pub_key - The group certificate. - \param[in] precomp - Optional pre-computed data. If NULL the value is computed internally and is - readable using EpidVerifierWritePrecomp(). - \param[out] ctx - Newly constructed verifier context. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the content of ctx is undefined. - - \see EpidVerifierDelete - \see EpidVerifierWritePrecomp - */ -EpidStatus EpidVerifierCreate(GroupPubKey const* pub_key, - VerifierPrecomp const* precomp, - VerifierCtx** ctx); - -/// Deletes an existing verifier context. -/*! - Must be called to safely release a verifier context created using - EpidVerifierCreate(). - - De-initializes the context, frees memory used by the context, and sets the - context pointer to NULL. - - \param[in,out] ctx - The verifier context. Can be NULL. - - \see EpidVerifierCreate - */ -void EpidVerifierDelete(VerifierCtx** ctx); - -/// Serializes the pre-computed verifier settings. -/*! - \param[in] ctx - The verifier context. - \param[out] precomp - The Serialized pre-computed verifier settings. - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the content of precomp is undefined. - */ -EpidStatus EpidVerifierWritePrecomp(VerifierCtx const* ctx, - VerifierPrecomp* precomp); - -/// Sets the private key based revocation list. -/*! - The caller is responsible for insuring the revocation list is authorized, - e.g signed by the issuer. The caller is also responsible checking the version - of the revocation list. The call fails if trying to set an older version - of the revocation list than was last set. - - \attention - The memory pointed to by priv_rl is accessed directly by the verifier - until a new list is set or the verifier is destroyed. Do not modify the - contents of this memory. The behavior of subsequent operations that rely on - the revocation list is undefined if the memory is modified. - - \attention - It is the responsibility of the caller to free the memory pointed to by priv_rl - after the verifier is no longer using it. - - \param[in,out] ctx - The verifier context. - \param[in] priv_rl - The private key based revocation list. - \param[in] priv_rl_size - The size of the private key based revocation list in bytes. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the private key based revocation list - pointed to by the verifier is undefined. - - \see EpidVerifierCreate - */ -EpidStatus EpidVerifierSetPrivRl(VerifierCtx* ctx, PrivRl const* priv_rl, - size_t priv_rl_size); - -/// Sets the signature based revocation list. -/*! - The caller is responsible for insuring the revocation list is authorized, - e.g signed by the issuer. The caller is also responsible checking the version - of the revocation list. The call fails if trying to set an older version - of the revocation list than was last set. - - \attention - The memory pointed to by sig_rl is accessed directly by the verifier - until a new list is set or the verifier is destroyed. Do not modify the - contents of this memory. The behavior of subsequent operations that rely on - the revocation list is undefined if the memory is modified. - - \attention - It is the responsibility of the caller to free the memory pointed to by sig_rl - after the verifier is no longer using it. - - \param[in,out] ctx - The verifier context. - \param[in] sig_rl - The signature based revocation list. - \param[in] sig_rl_size - The size of the signature based revocation list in bytes. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the signature based revocation list pointed - to by the verifier is undefined. - - \see EpidVerifierCreate - */ -EpidStatus EpidVerifierSetSigRl(VerifierCtx* ctx, SigRl const* sig_rl, - size_t sig_rl_size); - -/// Sets the group based revocation list. -/*! - The caller is responsible for insuring the revocation list is authorized, - e.g signed by the issuer. The caller is also responsible checking the version - of the revocation list. The call fails if trying to set an older version - of the revocation list than was last set. - - \attention - The memory pointed to by grp_rl is accessed directly by the verifier - until a new list is set or the verifier is destroyed. Do not modify the - contents of this memory. The behavior of subsequent operations that rely on - the revocation list is undefined if the memory is modified. - - \attention - It is the responsibility of the caller to free the memory pointed to by grp_rl - after the verifier is no longer using it. - - \param[in,out] ctx - The verifier context. - \param[in] grp_rl - The group based revocation list. - \param[in] grp_rl_size - The size of the group based revocation list in bytes. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the group based revocation list pointed - to by the verifier is undefined. - - \see EpidVerifierCreate - */ -EpidStatus EpidVerifierSetGroupRl(VerifierCtx* ctx, GroupRl const* grp_rl, - size_t grp_rl_size); - -/// Sets the verifier revocation list. -/*! - The caller is responsible for insuring the revocation list is authorized, - e.g signed by the issuer. The caller is also responsible checking the version - of the revocation list. The call fails if trying to set an older version - of the revocation list than was last set. - - \attention - The memory pointed to by ver_rl is accessed directly by the verifier - until a new list is set or the verifier is destroyed. Do not modify the - contents of this memory. The behavior of subsequent operations that rely on - the revocation list is undefined if the memory is modified. - - \attention - It is the responsibility of the caller to free the memory pointed to by ver_rl - after the verifier is no longer using it. - - \param[in,out] ctx - The verifier context. - \param[in] ver_rl - The verifier revocation list. - \param[in] ver_rl_size - The size of the verifier revocation list in bytes. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr the verifier revocation list pointed - to by the verifier is undefined. - - \see EpidVerifierCreate - */ -EpidStatus EpidVerifierSetVerifierRl(VerifierCtx* ctx, VerifierRl const* ver_rl, - size_t ver_rl_size); - -/// Sets the hash algorithm to be used by a verifier. -/*! - \param[in] ctx - The verifier context. - \param[in] hash_alg - The hash algorithm to use. - - \returns ::EpidStatus - - \note - If the result is not ::kEpidNoErr, the hash algorithm used by the - verifier is undefined. - - \see EpidVerifierCreate - \see ::HashAlg - */ -EpidStatus EpidVerifierSetHashAlg(VerifierCtx* ctx, HashAlg hash_alg); - -/// Verifies a signature and checks revocation status. -/*! - \param[in] ctx - The verifier context. - \param[in] sig - The signature. - \param[in] sig_len - The size of sig in bytes. - \param[in] msg - The message that was signed. - \param[in] msg_len - The size of msg in bytes. - \param[in] basename - The basename. Pass NULL if not specified - \param[in] basename_len - Number of bytes in basename buffer. Must be 0 if basename is NULL. - - \returns ::EpidStatus - - \retval ::kEpidSigValid - Signature validated successfully - \retval ::kEpidSigInvalid - Signature is invalid - \retval ::kEpidSigRevokedinGroupRl - Signature revoked in GroupRl - \retval ::kEpidSigRevokedinPrivRl - Signature revoked in PrivRl - \retval ::kEpidSigRevokedinSigRl - Signature revoked in SigRl - \retval ::kEpidSigRevokedinVerifierRl - Signature revoked in VerifierRl - - \note - If the result is not ::kEpidNoErr or one of the values listed above the - verify should be considered to have failed. - - \see EpidVerifierCreate - \see EpidSignBasic - \see EpidSign - */ -EpidStatus EpidVerify(VerifierCtx const* ctx, EpidSignature const* sig, - size_t sig_len, void const* msg, size_t msg_len, - void const* basename, size_t basename_len); - -/// Determines if two signatures are linked. -/*! - - The Intel(R) EPID scheme allows signatures to be linked. If basename - option is specified when signing, signatures with the same basename - are linkable. This linking capability allows the verifier, or - anyone, to know whether two Intel(R) EPID signatures are generated - by the same member. - - \param[in] sig1 - A basic signature. - \param[in] sig2 - A basic signature. - - \result bool - - \retval true - if the signatures were generated by the same member - \retval false - if it couldn't be determined if the signatures were generated by - the same member - - \note - The input signatures should be verified using EpidVerifyBasicSig() before - invocation. Behavior is undefined if either of the signatures cannot be - verified. - - \see EpidVerifyBasicSig - \see EpidSignBasic - \see EpidSign - */ -bool EpidAreSigsLinked(BasicSignature const* sig1, BasicSignature const* sig2); - -/// Verifies a member signature without revocation checks. -/*! - Used in constrained environments where, due to limited memory, it may not - be possible to process through a large and potentially unbounded revocation - list. - - \param[in] ctx - The verifier context. - \param[in] sig - The basic signature. - \param[in] msg - The message that was signed. - \param[in] msg_len - The size of msg in bytes. - \param[in] basename - The basename. Pass NULL if not specified - \param[in] basename_len - Number of bytes in basename buffer. Must be 0 if basename is NULL. - - \returns ::EpidStatus - - \note - This function should be used in conjunction with EpidNrVerify() and - EpidCheckPrivRlEntry(). - - \note - If the result is not ::kEpidNoErr the verify should be considered to have - failed. - - \see EpidVerifierCreate - \see EpidSignBasic - \see EpidSign - */ -EpidStatus EpidVerifyBasicSig(VerifierCtx const* ctx, BasicSignature const* sig, - void const* msg, size_t msg_len, - void const* basename, size_t basename_len); - -/// Verifies the non-revoked proof for a single signature based revocation list -/// entry. -/*! - Used in constrained environments where, due to limited memory, it may not - be possible to process through a large and potentially unbounded revocation - list. - - \param[in] ctx - The verifier context. - \param[in] sig - The basic signature. - \param[in] msg - The message that was signed. - \param[in] msg_len - The size of msg in bytes. - \param[in] sigrl_entry - The signature based revocation list entry. - \param[in] proof - The non-revoked proof. - - \returns ::EpidStatus - - \note - Sig should be verified using EpidVerifyBasicSig() before invocation. Behavior - is undefined if sig cannot be verified. - - \note - This function should be used in conjunction with EpidVerifyBasicSig() and - EpidCheckPrivRlEntry(). - - \note - If the result is not ::kEpidNoErr, the verification should be - considered to have failed. - - \see EpidVerifierCreate - \see EpidVerifyBasicSig - \see EpidCheckPrivRlEntry - */ -EpidStatus EpidNrVerify(VerifierCtx const* ctx, BasicSignature const* sig, - void const* msg, size_t msg_len, - SigRlEntry const* sigrl_entry, NrProof const* proof); - -/// Verifies a signature has not been revoked in the private key based -/// revocation list. -/*! - Used in constrained environments where, due to limited memory, it may not - be possible to process through a large and potentially unbounded revocation - list. - - \param[in] ctx - The verifier context. - \param[in] sig - The basic signature. - \param[in] f - The private key based revocation list entry. - - \note - Sig should be verified using EpidVerifyBasicSig() before invocation. Behavior - is undefined if sig cannot be verified. - - \note - This function should be used in conjunction with EpidNrVerify() and - EpidVerifyBasicSig(). - - \note - If the result is not ::kEpidNoErr the verify should be considered to have - failed. - - \returns ::EpidStatus - \see EpidVerifierCreate - \see EpidNrVerify - \see EpidVerifyBasicSig - */ -EpidStatus EpidCheckPrivRlEntry(VerifierCtx const* ctx, - BasicSignature const* sig, FpElemStr const* f); - -#ifdef __cplusplus -}; -#endif -/*! @} */ -#endif // EPID_VERIFIER_API_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/check_privrl_entry.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/check_privrl_entry.c deleted file mode 100644 index 96e579276c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/check_privrl_entry.c +++ /dev/null @@ -1,82 +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 EpidCheckPrivRlEntry implementation. - */ - -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" -EpidStatus EpidCheckPrivRlEntry(VerifierCtx const* ctx, - BasicSignature const* sig, FpElemStr const* f) { - EpidStatus result = kEpidErr; - EcPoint* b = NULL; - EcPoint* k = NULL; - EcPoint* t4 = NULL; - EcGroup* G1 = NULL; - if (!ctx || !sig || !f) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->G1) { - return kEpidBadArgErr; - } - do { - // Section 4.1.2 Step 4.b For i = 0, ... , n1-1, the verifier computes t4 - // =G1.exp(B, f[i]) and verifies that G1.isEqual(t4, K) = false. - bool compare_result = false; - G1 = ctx->epid2_params->G1; - result = NewEcPoint(G1, &b); - if (kEpidNoErr != result) { - break; - } - result = NewEcPoint(G1, &k); - if (kEpidNoErr != result) { - break; - } - result = NewEcPoint(G1, &t4); - if (kEpidNoErr != result) { - break; - } - result = ReadEcPoint(G1, &sig->B, sizeof(sig->B), b); - if (kEpidNoErr != result) { - break; - } - result = ReadEcPoint(G1, &sig->K, sizeof(sig->K), k); - if (kEpidNoErr != result) { - break; - } - result = EcExp(G1, b, (BigNumStr const*)f, t4); - if (kEpidNoErr != result) { - break; - } - result = EcIsEqual(G1, t4, k, &compare_result); - if (kEpidNoErr != result) { - break; - } - // if t4 == k, sig revoked in PrivRl - if (compare_result) { - result = kEpidSigRevokedinPrivRl; - } else { - result = kEpidNoErr; - } - } while (0); - - DeleteEcPoint(&t4); - DeleteEcPoint(&k); - DeleteEcPoint(&b); - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.c deleted file mode 100644 index c034c691b2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.c +++ /dev/null @@ -1,466 +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 context implementation. - */ -#include -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" -#include "epid/common/epid2params.h" -#include "epid/common/memory.h" -#include "epid/common/math/pairing.h" -#include "epid/common/endian_convert.h" -#include "epid/common/sigrlvalid.h" - -/// create Verifier precomp of the VerifierCtx -static EpidStatus DoPrecomputation(VerifierCtx* ctx); - -/// Read Verifier precomp -static EpidStatus ReadPrecomputation(VerifierPrecomp const* precomp_str, - VerifierCtx* ctx); - -/// Internal function to prove if group based revocation list is valid -static bool IsGroupRlValid(GroupRl const* group_rl, size_t grp_rl_size) { - const size_t kMinGroupRlSize = sizeof(GroupRl) - sizeof(GroupId); - size_t input_grp_rl_size = 0; - - if (!group_rl) { - return false; - } - if (grp_rl_size < kMinGroupRlSize) { - return false; - } - if (ntohl(group_rl->n3) > (SIZE_MAX - kMinGroupRlSize) / sizeof(GroupId)) { - return false; - } - input_grp_rl_size = kMinGroupRlSize + (ntohl(group_rl->n3) * sizeof(GroupId)); - if (input_grp_rl_size != grp_rl_size) { - return false; - } - return true; -} - -/// Internal function to verify if private key based revocation list is valid -static bool IsPrivRlValid(GroupId const* gid, PrivRl const* priv_rl, - size_t priv_rl_size) { - const size_t kMinPrivRlSize = sizeof(PrivRl) - sizeof(FpElemStr); - size_t input_priv_rl_size = 0; - - if (!gid || !priv_rl) { - return false; - } - if (kMinPrivRlSize > priv_rl_size) { - return false; - } - if (ntohl(priv_rl->n1) > - (SIZE_MAX - kMinPrivRlSize) / sizeof(priv_rl->f[0])) { - return false; - } - // sanity check of intput PrivRl size - input_priv_rl_size = - kMinPrivRlSize + ntohl(priv_rl->n1) * sizeof(priv_rl->f[0]); - if (input_priv_rl_size != priv_rl_size) { - return false; - } - // verify that gid given and gid in PrivRl match - if (0 != memcmp(gid, &priv_rl->gid, sizeof(*gid))) { - return false; - } - return true; -} - -/// Internal function to verify if verifier revocation list is valid -static bool IsVerifierRlValid(GroupId const* gid, VerifierRl const* ver_rl, - size_t ver_rl_size) { - const size_t kMinVerifierRlSize = sizeof(VerifierRl) - sizeof(G1ElemStr); - size_t expected_verifier_rl_size = 0; - - if (!gid || !ver_rl || kMinVerifierRlSize > ver_rl_size) { - return false; - } - if (ntohl(ver_rl->n4) > - (SIZE_MAX - kMinVerifierRlSize) / sizeof(ver_rl->K[0])) { - return false; - } - // sanity check of input VerifierRl size - expected_verifier_rl_size = - kMinVerifierRlSize + ntohl(ver_rl->n4) * sizeof(ver_rl->K[0]); - if (expected_verifier_rl_size != ver_rl_size) { - return false; - } - - // verify that gid in public key and gid in SigRl match - if (0 != memcmp(gid, &ver_rl->gid, sizeof(*gid))) { - return false; - } - - return true; -} - -EpidStatus EpidVerifierCreate(GroupPubKey const* pubkey, - VerifierPrecomp const* precomp, - VerifierCtx** ctx) { - EpidStatus result = kEpidErr; - VerifierCtx* verifier_ctx = NULL; - if (!pubkey || !ctx) { - return kEpidBadArgErr; - } - do { - // Allocate memory for VerifierCtx - verifier_ctx = SAFE_ALLOC(sizeof(VerifierCtx)); - if (!verifier_ctx) { - result = kEpidMemAllocErr; - break; - } - - // set SHA512 as the default hash algorithm - verifier_ctx->hash_alg = kSha512; - - // Internal representation of Epid2Params - result = CreateEpid2Params(&verifier_ctx->epid2_params); - if (kEpidNoErr != result) { - break; - } - // Internal representation of Group Pub Key - result = CreateGroupPubKey(pubkey, verifier_ctx->epid2_params->G1, - verifier_ctx->epid2_params->G2, - &verifier_ctx->pub_key); - if (kEpidNoErr != result) { - break; - } - // Store group public key strings for later use - result = SetKeySpecificCommitValues(pubkey, &verifier_ctx->commit_values); - if (kEpidNoErr != result) { - break; - } - // Allocate verifier_ctx->e12 - result = NewFfElement(verifier_ctx->epid2_params->GT, &verifier_ctx->e12); - if (kEpidNoErr != result) { - break; - } - // Allocate verifier_ctx->e22 - result = NewFfElement(verifier_ctx->epid2_params->GT, &verifier_ctx->e22); - if (kEpidNoErr != result) { - break; - } - // Allocate verifier_ctx->e2w - result = NewFfElement(verifier_ctx->epid2_params->GT, &verifier_ctx->e2w); - if (kEpidNoErr != result) { - break; - } - // Allocate verifier_ctx->eg12 - result = NewFfElement(verifier_ctx->epid2_params->GT, &verifier_ctx->eg12); - if (kEpidNoErr != result) { - break; - } - // precomputation - if (precomp != NULL) { - result = ReadPrecomputation(precomp, verifier_ctx); - } else { - result = DoPrecomputation(verifier_ctx); - } - if (kEpidNoErr != result) { - break; - } - verifier_ctx->sig_rl = NULL; - verifier_ctx->group_rl = NULL; - verifier_ctx->priv_rl = NULL; - verifier_ctx->verifier_rl = NULL; - *ctx = verifier_ctx; - result = kEpidNoErr; - } while (0); - - if (kEpidNoErr != result && verifier_ctx) { - DeleteFfElement(&verifier_ctx->eg12); - DeleteFfElement(&verifier_ctx->e2w); - DeleteFfElement(&verifier_ctx->e22); - DeleteFfElement(&verifier_ctx->e12); - DeleteEpid2Params(&verifier_ctx->epid2_params); - DeleteGroupPubKey(&verifier_ctx->pub_key); - SAFE_FREE(verifier_ctx); - } - return result; -} - -void EpidVerifierDelete(VerifierCtx** ctx) { - if (ctx && *ctx) { - DeleteFfElement(&(*ctx)->eg12); - DeleteFfElement(&(*ctx)->e2w); - DeleteFfElement(&(*ctx)->e22); - DeleteFfElement(&(*ctx)->e12); - DeleteGroupPubKey(&(*ctx)->pub_key); - DeleteEpid2Params(&(*ctx)->epid2_params); - (*ctx)->priv_rl = NULL; - (*ctx)->sig_rl = NULL; - (*ctx)->group_rl = NULL; - (*ctx)->verifier_rl = NULL; - SAFE_FREE(*ctx); - } -} - -EpidStatus EpidVerifierWritePrecomp(VerifierCtx const* ctx, - VerifierPrecomp* precomp) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; // an element in GT - FfElement* e22 = NULL; // an element in GT - FfElement* e2w = NULL; // an element in GT - FfElement* eg12 = NULL; // an element in GT - FiniteField* GT = NULL; // Finite field GT(Fq12 ) - if (!ctx) { - return kEpidBadArgErr; - } - if (!precomp) { - return kEpidBadArgErr; - } - if (!ctx->e12 || !ctx->e22 || !ctx->e2w || !ctx->eg12 || !ctx->epid2_params || - !(ctx->epid2_params->GT)) { - return kEpidBadArgErr; - } - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - eg12 = ctx->eg12; - GT = ctx->epid2_params->GT; - result = WriteFfElement(GT, e12, &(precomp->e12), sizeof(precomp->e12)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, e22, &(precomp->e22), sizeof(precomp->e22)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, e2w, &(precomp->e2w), sizeof(precomp->e2w)); - if (kEpidNoErr != result) { - return result; - } - result = WriteFfElement(GT, eg12, &(precomp->eg12), sizeof(precomp->eg12)); - if (kEpidNoErr != result) { - return result; - } - return result; -} - -EpidStatus EpidVerifierSetPrivRl(VerifierCtx* ctx, PrivRl const* priv_rl, - size_t priv_rl_size) { - const size_t kMinPrivRlSize = sizeof(PrivRl) - sizeof(FpElemStr); - if (!ctx || !priv_rl) { - return kEpidBadArgErr; - } - if (kMinPrivRlSize > priv_rl_size) { - return kEpidBadArgErr; - } - if (!ctx->pub_key) { - return kEpidBadArgErr; - } - // Do not set an older version of priv rl - if (ctx->priv_rl) { - unsigned int current_ver = 0; - unsigned int incoming_ver = 0; - current_ver = ntohl(ctx->priv_rl->version); - incoming_ver = ntohl(priv_rl->version); - if (current_ver >= incoming_ver) { - return kEpidBadArgErr; - } - } - if (!IsPrivRlValid(&ctx->pub_key->gid, priv_rl, priv_rl_size)) { - return kEpidBadArgErr; - } - ctx->priv_rl = priv_rl; - return kEpidNoErr; -} - -EpidStatus EpidVerifierSetSigRl(VerifierCtx* ctx, SigRl const* sig_rl, - size_t sig_rl_size) { - const size_t kMinSigRlSize = sizeof(SigRl) - sizeof(SigRlEntry); - if (!ctx || !sig_rl) { - return kEpidBadArgErr; - } - if (kMinSigRlSize > sig_rl_size) { - return kEpidBadArgErr; - } - if (!ctx->pub_key) { - return kEpidBadArgErr; - } - // Do not set an older version of sig rl - if (ctx->sig_rl) { - unsigned int current_ver = 0; - unsigned int incoming_ver = 0; - current_ver = ntohl(ctx->sig_rl->version); - incoming_ver = ntohl(sig_rl->version); - if (current_ver >= incoming_ver) { - return kEpidBadArgErr; - } - } - if (!IsSigRlValid(&ctx->pub_key->gid, sig_rl, sig_rl_size)) { - return kEpidBadArgErr; - } - ctx->sig_rl = sig_rl; - - return kEpidNoErr; -} - -EpidStatus EpidVerifierSetGroupRl(VerifierCtx* ctx, GroupRl const* grp_rl, - size_t grp_rl_size) { - if (!ctx || !grp_rl) { - return kEpidBadArgErr; - } - if (!ctx->pub_key) { - return kEpidBadArgErr; - } - if (!IsGroupRlValid(grp_rl, grp_rl_size)) { - return kEpidBadArgErr; - } - // Do not set an older version of group rl - if (ctx->group_rl) { - unsigned int current_ver = 0; - unsigned int incoming_ver = 0; - current_ver = ntohl(ctx->group_rl->version); - incoming_ver = ntohl(grp_rl->version); - if (current_ver >= incoming_ver) { - return kEpidBadArgErr; - } - } - ctx->group_rl = grp_rl; - - return kEpidNoErr; -} - -EpidStatus EpidVerifierSetVerifierRl(VerifierCtx* ctx, VerifierRl const* ver_rl, - size_t ver_rl_size) { - if (!ctx || !ver_rl) { - return kEpidBadArgErr; - } - if (!ctx->pub_key) { - return kEpidBadArgErr; - } - if (!IsVerifierRlValid(&ctx->pub_key->gid, ver_rl, ver_rl_size)) { - return kEpidBadArgErr; - } - // Do not set an older version of verifier rl - if (ctx->verifier_rl) { - unsigned int current_ver = 0; - unsigned int incoming_ver = 0; - current_ver = ntohl(ctx->verifier_rl->version); - incoming_ver = ntohl(ver_rl->version); - if (current_ver >= incoming_ver) { - return kEpidBadArgErr; - } - } - - ctx->verifier_rl = ver_rl; - - return kEpidNoErr; -} - -EpidStatus EpidVerifierSetHashAlg(VerifierCtx* ctx, HashAlg hash_alg) { - if (!ctx) return kEpidBadArgErr; - if (kSha256 != hash_alg && kSha384 != hash_alg && kSha512 != hash_alg) - return kEpidBadArgErr; - ctx->hash_alg = hash_alg; - return kEpidNoErr; -} - -static EpidStatus DoPrecomputation(VerifierCtx* ctx) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; - FfElement* e22 = NULL; - FfElement* e2w = NULL; - FfElement* eg12 = NULL; - Epid2Params_* params = NULL; - GroupPubKey_* pub_key = NULL; - PairingState* ps_ctx = NULL; - if (!ctx) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->GT || - !ctx->epid2_params->pairing_state || !ctx->pub_key || !ctx->e12 || - !ctx->e22 || !ctx->e2w || !ctx->eg12) { - return kEpidBadArgErr; - } - pub_key = ctx->pub_key; - params = ctx->epid2_params; - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - eg12 = ctx->eg12; - ps_ctx = params->pairing_state; - // do precomputation - // 1. The verifier computes e12 = pairing(h1, g2). - result = Pairing(ps_ctx, e12, pub_key->h1, params->g2); - if (kEpidNoErr != result) { - return result; - } - // 2. The verifier computes e22 = pairing(h2, g2). - result = Pairing(ps_ctx, e22, pub_key->h2, params->g2); - if (kEpidNoErr != result) { - return result; - } - // 3. The verifier computes e2w = pairing(h2, w). - result = Pairing(ps_ctx, e2w, pub_key->h2, pub_key->w); - if (kEpidNoErr != result) { - return result; - } - // 4. The verifier computes eg12 = pairing(g1, g2). - result = Pairing(ps_ctx, eg12, params->g1, params->g2); - if (kEpidNoErr != result) { - return result; - } - return kEpidNoErr; -} -static EpidStatus ReadPrecomputation(VerifierPrecomp const* precomp_str, - VerifierCtx* ctx) { - EpidStatus result = kEpidErr; - FfElement* e12 = NULL; - FfElement* e22 = NULL; - FfElement* e2w = NULL; - FfElement* eg12 = NULL; - FiniteField* GT = NULL; - Epid2Params_* params = NULL; - if (!ctx) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->GT || !ctx->e12 || !ctx->e22 || - !ctx->e2w || !ctx->eg12) { - return kEpidBadArgErr; - } - params = ctx->epid2_params; - GT = params->GT; - e12 = ctx->e12; - e22 = ctx->e22; - e2w = ctx->e2w; - eg12 = ctx->eg12; - - result = ReadFfElement(GT, &precomp_str->e12, sizeof(precomp_str->e12), e12); - if (kEpidNoErr != result) { - return result; - } - result = ReadFfElement(GT, &precomp_str->e22, sizeof(precomp_str->e22), e22); - if (kEpidNoErr != result) { - return result; - } - result = ReadFfElement(GT, &precomp_str->e2w, sizeof(precomp_str->e2w), e2w); - if (kEpidNoErr != result) { - return result; - } - result = - ReadFfElement(GT, &precomp_str->eg12, sizeof(precomp_str->eg12), eg12); - if (kEpidNoErr != result) { - return result; - } - return kEpidNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.h b/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.h deleted file mode 100644 index 049f5f7fa2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/context.h +++ /dev/null @@ -1,43 +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_VERIFIER_CONTEXT_H_ -#define EPID_VERIFIER_CONTEXT_H_ -/*! - * \file - * \brief Verifier context interface. - */ -#include "epid/common/grouppubkey.h" -#include "epid/common/math/ecgroup.h" -#include "epid/common/math/finitefield.h" -#include "epid/common/epid2params.h" -#include "epid/common/commitment.h" - -/// Verifier context definition -struct VerifierCtx { - GroupPubKey_* pub_key; ///< group public key - FfElement* e12; ///< an element in GT - FfElement* e22; ///< an element in GT - FfElement* e2w; ///< an element in GT - FfElement* eg12; ///< an element in GT - PrivRl const* priv_rl; ///< Private key based revocation list - not owned - SigRl const* sig_rl; ///< Signature based revocation list - not owned - GroupRl const* group_rl; ///< Group revocation list - not owned - VerifierRl const* verifier_rl; ///< Verifier revocation list - not owned - Epid2Params_* epid2_params; ///< Intel(R) EPID 2.0 params - CommitValues commit_values; ///< Values that are hashed to create commitment - HashAlg hash_alg; ///< Hash algorithm to use -}; -#endif // EPID_VERIFIER_CONTEXT_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/nrverify.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/nrverify.c deleted file mode 100644 index b139f1135e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/nrverify.c +++ /dev/null @@ -1,243 +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 NrVerfy implementation. - */ - -#include "epid/common/memory.h" -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -#pragma pack(1) -/// Storage for values to create commitment in NrVerify algorithm -typedef struct NrVerifyCommitValues { - BigNumStr p; //!< A large prime (256-bit) - G1ElemStr g1; //!< Generator of G1 (512-bit) - G1ElemStr b; //!< (element of G1): part of basic signature Sigma0 - G1ElemStr k; //!< (element of G1): part of basic signature Sigma0 - G1ElemStr bp; //!< (element of G1): one entry in SigRL - G1ElemStr kp; //!< (element of G1): one entry in SigRL - G1ElemStr t; //!< element of G1 - G1ElemStr r1; //!< element of G1 - G1ElemStr r2; //!< element of G1 - uint8_t msg[1]; //!< message -} NrVerifyCommitValues; -#pragma pack() - -EpidStatus EpidNrVerify(VerifierCtx const* ctx, BasicSignature const* sig, - void const* msg, size_t msg_len, - SigRlEntry const* sigrl_entry, NrProof const* proof) { - size_t const cv_header_len = sizeof(NrVerifyCommitValues) - sizeof(uint8_t); - EpidStatus sts = kEpidErr; - NrVerifyCommitValues* commit_values = NULL; - size_t const commit_len = sizeof(*commit_values) + msg_len - 1; - EcPoint* t_pt = NULL; - EcPoint* k_pt = NULL; - EcPoint* b_pt = NULL; - EcPoint* kp_pt = NULL; - EcPoint* bp_pt = NULL; - EcPoint* r1_pt = NULL; - EcPoint* r2_pt = NULL; - FfElement* c_el = NULL; - FfElement* nc_el = NULL; - FfElement* smu_el = NULL; - FfElement* snu_el = NULL; - FfElement* commit_hash = NULL; - if (!ctx || !sig || !proof || !sigrl_entry) { - return kEpidBadArgErr; - } - if (!msg && (0 != msg_len)) { - return kEpidBadArgErr; - } - if (msg_len > (SIZE_MAX - cv_header_len)) { - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->epid2_params->G1 || !ctx->epid2_params->Fp) { - return kEpidBadArgErr; - } - do { - EcGroup* G1 = ctx->epid2_params->G1; - FiniteField* Fp = ctx->epid2_params->Fp; - G1ElemStr const* b = &sig->B; - G1ElemStr const* k = &sig->K; - G1ElemStr const* bp = &sigrl_entry->b; - G1ElemStr const* kp = &sigrl_entry->k; - EcPoint const* r1p[2]; - FpElemStr const* r1b[2]; - EcPoint const* r2p[3]; - FpElemStr const* r2b[3]; - FpElemStr nc_str; - bool t_is_identity; - bool c_is_equal; - - commit_values = SAFE_ALLOC(commit_len); - if (commit_values == NULL) { - sts = kEpidMemAllocErr; - break; - } - - // allocate local memory - sts = NewEcPoint(G1, &t_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &k_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &b_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &kp_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &bp_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &r1_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewEcPoint(G1, &r2_pt); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(Fp, &c_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(Fp, &nc_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(Fp, &smu_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(Fp, &snu_el); - BREAK_ON_EPID_ERROR(sts); - sts = NewFfElement(Fp, &commit_hash); - BREAK_ON_EPID_ERROR(sts); - - // 1. The verifier verifies that G1.inGroup(T) = true. - sts = ReadEcPoint(G1, &proof->T, sizeof(proof->T), t_pt); - if (kEpidNoErr != sts) { - sts = kEpidBadArgErr; - break; - } - - // 2. The verifier verifies that G1.isIdentity(T) = false. - sts = EcIsIdentity(G1, t_pt, &t_is_identity); - BREAK_ON_EPID_ERROR(sts); - if (t_is_identity) { - sts = kEpidBadArgErr; - break; - } - - // 3. The verifier verifies that c, smu, snu in [0, p-1]. - sts = ReadFfElement(Fp, &proof->c, sizeof(proof->c), c_el); - BREAK_ON_EPID_ERROR(sts); - sts = ReadFfElement(Fp, &proof->smu, sizeof(proof->smu), smu_el); - BREAK_ON_EPID_ERROR(sts); - sts = ReadFfElement(Fp, &proof->snu, sizeof(proof->snu), snu_el); - BREAK_ON_EPID_ERROR(sts); - - // 4. The verifier computes nc = (- c) mod p. - sts = FfNeg(Fp, c_el, nc_el); - BREAK_ON_EPID_ERROR(sts); - - sts = WriteFfElement(Fp, nc_el, &nc_str, sizeof(nc_str)); - BREAK_ON_EPID_ERROR(sts); - - // 5. The verifier computes R1 = G1.multiExp(K, smu, B, snu). - sts = ReadEcPoint(G1, k, sizeof(*k), k_pt); - if (kEpidNoErr != sts) { - sts = kEpidBadArgErr; - break; - } - sts = ReadEcPoint(G1, b, sizeof(*b), b_pt); - if (kEpidNoErr != sts) { - sts = kEpidBadArgErr; - break; - } - r1p[0] = k_pt; - r1p[1] = b_pt; - r1b[0] = &proof->smu; - r1b[1] = &proof->snu; - sts = EcMultiExp(G1, r1p, (const BigNumStr**)r1b, 2, r1_pt); - BREAK_ON_EPID_ERROR(sts); - - // 6. The verifier computes R2 = G1.multiExp(K', smu, B', snu, T, nc). - sts = ReadEcPoint(G1, kp, sizeof(*kp), kp_pt); - if (kEpidNoErr != sts) { - sts = kEpidBadArgErr; - break; - } - sts = ReadEcPoint(G1, bp, sizeof(*bp), bp_pt); - if (kEpidNoErr != sts) { - sts = kEpidBadArgErr; - break; - } - r2p[0] = kp_pt; - r2p[1] = bp_pt; - r2p[2] = t_pt; - r2b[0] = &proof->smu; - r2b[1] = &proof->snu; - r2b[2] = &nc_str; - sts = EcMultiExp(G1, r2p, (const BigNumStr**)r2b, 3, r2_pt); - BREAK_ON_EPID_ERROR(sts); - - // 7. The verifier verifies c = Fp.hash(p || g1 || B || K || - // B' || K' || T || R1 || R2 || m). - // Refer to Section 7.1 for hash operation over a prime field. - - // commit_values is allocated such that there are msg_len bytes available - // starting at commit_values->msg - if (msg) { - if (0 != memcpy_S(&commit_values->msg[0], msg_len, msg, msg_len)) { - sts = kEpidBadArgErr; - break; - } - } - commit_values->p = ctx->commit_values.p; - commit_values->g1 = ctx->commit_values.g1; - commit_values->b = sig->B; - commit_values->k = sig->K; - commit_values->bp = sigrl_entry->b; - commit_values->kp = sigrl_entry->k; - commit_values->t = proof->T; - sts = - WriteEcPoint(G1, r1_pt, &commit_values->r1, sizeof(commit_values->r1)); - BREAK_ON_EPID_ERROR(sts); - sts = - WriteEcPoint(G1, r2_pt, &commit_values->r2, sizeof(commit_values->r2)); - BREAK_ON_EPID_ERROR(sts); - sts = FfHash(Fp, commit_values, commit_len, ctx->hash_alg, commit_hash); - BREAK_ON_EPID_ERROR(sts); - sts = FfIsEqual(Fp, c_el, commit_hash, &c_is_equal); - BREAK_ON_EPID_ERROR(sts); - if (!c_is_equal) { - sts = kEpidBadArgErr; - break; - } - sts = kEpidNoErr; - } while (0); - SAFE_FREE(commit_values); - DeleteFfElement(&commit_hash); - DeleteFfElement(&snu_el); - DeleteFfElement(&smu_el); - DeleteFfElement(&nc_el); - DeleteFfElement(&c_el); - DeleteEcPoint(&r2_pt); - DeleteEcPoint(&r1_pt); - DeleteEcPoint(&bp_pt); - DeleteEcPoint(&kp_pt); - DeleteEcPoint(&b_pt); - DeleteEcPoint(&k_pt); - DeleteEcPoint(&t_pt); - return sts; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/sigs_linked.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/sigs_linked.c deleted file mode 100644 index 733233cc4d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/sigs_linked.c +++ /dev/null @@ -1,31 +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 AreSigsLinked implementation. - */ - -#include - -#include - -// implements section 4.3 "Signature Linking" from Intel(R) EPID 2.0 Spec -bool EpidAreSigsLinked(BasicSignature const* sig1, BasicSignature const* sig2) { - // Step 1. If B1 = B2 and K1 = K2, output true, otherwise output false. - return (sig1 && sig2 && 0 == memcmp(&sig1->B, &sig2->B, sizeof(sig2->B)) && - 0 == memcmp(&sig1->K, &sig2->K, sizeof(sig2->K))); -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/check_privrl_entry-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/check_privrl_entry-test.cc deleted file mode 100644 index 7ec5275e2a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/check_privrl_entry-test.cc +++ /dev/null @@ -1,116 +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 CheckPrivRlEntry unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" - -namespace { - -TEST_F(EpidVerifierTest, CheckPrivRlEntryFailsGivenNullPtr) { - // check ctx, sig, f for NULL - auto& pub_key = this->kGrpXKey; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - FpElemStr fp_str = ((PrivRl const*)priv_rl.data())->f[0]; - BasicSignature basic_signature = ((EpidSignature const*)sig.data())->sigma0; - - EXPECT_EQ(kEpidBadArgErr, - EpidCheckPrivRlEntry(nullptr, &basic_signature, &fp_str)); - EXPECT_EQ(kEpidBadArgErr, EpidCheckPrivRlEntry(verifier, nullptr, &fp_str)); - EXPECT_EQ(kEpidBadArgErr, - EpidCheckPrivRlEntry(verifier, &basic_signature, nullptr)); -} - -TEST_F(EpidVerifierTest, CheckPrivRlEntryFailsGivenRevokedPrivKey) { - // test a revoked priv key - // check ctx, sig, f for NULL - auto& pub_key = this->kGrpXKey; - auto& priv_rl = this->kGrpXPrivRl; - // signed using revoked key - auto& sig = this->kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - FpElemStr fp_str = ((PrivRl const*)priv_rl.data())->f[0]; - BasicSignature basic_signature = ((EpidSignature const*)sig.data())->sigma0; - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidCheckPrivRlEntry(verifier, &basic_signature, &fp_str)); -} - -TEST_F(EpidVerifierTest, - CheckPrivRlEntryFailsGivenRevokedPrivKeyUsingIkgfData) { - // test a revoked priv key - // check ctx, sig, f for NULL - auto& pub_key = this->pub_key_ikgf_str; - auto& priv_rl = this->kPrivRlIkgf; - // signed using revoked key - auto& sig = this->kSigRevokedPrivKeySha256Bsn0Msg0Ikgf; - - VerifierCtxObj verifier(pub_key); - - FpElemStr fp_str = ((PrivRl const*)priv_rl.data())->f[2]; - BasicSignature basic_signature = ((EpidSignature const*)sig.data())->sigma0; - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidCheckPrivRlEntry(verifier, &basic_signature, &fp_str)); -} - -TEST_F(EpidVerifierTest, CheckPrivRlEntrySucceedsGivenUnRevokedPrivKey) { - // test a non revoked priv key - auto& pub_key = this->kGrpXKey; - auto& priv_rl = this->kGrpXPrivRl; - // signed using un revoked key - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - FpElemStr fp_str = ((PrivRl const*)priv_rl.data())->f[0]; - BasicSignature basic_signature = ((EpidSignature const*)sig.data())->sigma0; - - EXPECT_EQ(kEpidNoErr, - EpidCheckPrivRlEntry(verifier, &basic_signature, &fp_str)); -} - -TEST_F(EpidVerifierTest, - CheckPrivRlEntrySucceedsGivenUnRevokedPrivKeyUsingIkgfData) { - // test a non revoked priv key - auto& pub_key = this->pub_key_ikgf_str; - auto& priv_rl = this->kPrivRlIkgf; - // signed using un revoked key - auto& sig = this->kSigMember0Sha256Bsn0Msg0Ikgf; - - VerifierCtxObj verifier(pub_key); - FpElemStr fp_str = ((PrivRl const*)priv_rl.data())->f[0]; - BasicSignature basic_signature = ((EpidSignature const*)sig.data())->sigma0; - - EXPECT_EQ(kEpidNoErr, - EpidCheckPrivRlEntry(verifier, &basic_signature, &fp_str)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/context-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/context-test.cc deleted file mode 100644 index a5941b141e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/context-test.cc +++ /dev/null @@ -1,597 +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 VerifierCreate unit tests. - */ - -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" -bool operator==(VerifierPrecomp const& lhs, VerifierPrecomp const& rhs) { - return 0 == std::memcmp(&lhs, &rhs, sizeof(lhs)); -} -namespace { -////////////////////////////////////////////////////////////////////////// -// EpidVerifierCreate Tests -TEST_F(EpidVerifierTest, CreateFailsGivenNullPointer) { - VerifierCtx* ctx = nullptr; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierCreate(&this->pub_key_str, &this->verifier_precomp_str, - nullptr)); - EpidVerifierDelete(&ctx); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierCreate(nullptr, &this->verifier_precomp_str, &ctx)); - EpidVerifierDelete(&ctx); -} -TEST_F(EpidVerifierTest, CreateSucceedsGivenNullPrecomp) { - VerifierCtx* ctx = nullptr; - EXPECT_EQ(kEpidNoErr, EpidVerifierCreate(&this->pub_key_str, nullptr, &ctx)); - EpidVerifierDelete(&ctx); -} -TEST_F(EpidVerifierTest, CreateSucceedsGivenNullPrecompUsingIkgfData) { - VerifierCtx* ctx = nullptr; - EXPECT_EQ(kEpidNoErr, - EpidVerifierCreate(&this->pub_key_ikgf_str, nullptr, &ctx)); - EpidVerifierDelete(&ctx); -} -TEST_F(EpidVerifierTest, CreateFailsGivenInvalidPubkey) { - VerifierCtx* ctx = nullptr; - GroupPubKey pubkey_with_bad_h1 = this->pub_key_str; - pubkey_with_bad_h1.h1.x.data.data[31]++; // munge h1 so not in G1 - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierCreate(&pubkey_with_bad_h1, nullptr, &ctx)); - EpidVerifierDelete(&ctx); - GroupPubKey pubkey_with_bad_h2 = this->pub_key_str; - pubkey_with_bad_h2.h2.x.data.data[31]++; // munge h2 so not in G1 - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierCreate(&pubkey_with_bad_h2, nullptr, &ctx)); - EpidVerifierDelete(&ctx); - GroupPubKey pubkey_with_bad_w = this->pub_key_str; - pubkey_with_bad_w.w.x[0].data.data[31]++; // munge w so not in G2 - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierCreate(&pubkey_with_bad_w, nullptr, &ctx)); - EpidVerifierDelete(&ctx); -} -////////////////////////////////////////////////////////////////////////// -// EpidVerifierDelete Tests -TEST_F(EpidVerifierTest, DeleteNullsVerifierCtx) { - VerifierCtx* ctx = nullptr; - EpidVerifierCreate(&this->pub_key_str, nullptr, &ctx); - EpidVerifierDelete(&ctx); - EXPECT_EQ(nullptr, ctx); -} -TEST_F(EpidVerifierTest, DeleteWorksGivenNullVerifierCtx) { - EpidVerifierDelete(nullptr); - VerifierCtx* ctx = nullptr; - EpidVerifierDelete(&ctx); -} - -////////////////////////////////////////////////////////////////////////// -// EpidVerifierWritePrecomp -TEST_F(EpidVerifierTest, WritePrecompFailsGivenNullPointer) { - VerifierPrecomp precomp; - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierCtx* ctx = verifier; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierWritePrecomp(nullptr, &precomp)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifierWritePrecomp(ctx, nullptr)); -} -TEST_F(EpidVerifierTest, WritePrecompSucceedGivenValidArgument) { - VerifierPrecomp precomp; - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierCtx* ctx = verifier; - EXPECT_EQ(kEpidNoErr, EpidVerifierWritePrecomp(ctx, &precomp)); - VerifierPrecomp expected_precomp = this->verifier_precomp_str; - EXPECT_EQ(expected_precomp, precomp); - - VerifierCtxObj verifier2(this->pub_key_str); - VerifierCtx* ctx2 = verifier2; - EXPECT_EQ(kEpidNoErr, EpidVerifierWritePrecomp(ctx2, &precomp)); - EXPECT_EQ(expected_precomp, precomp); -} -////////////////////////////////////////////////////////////////////////// -// EpidVerifierSetPrivRl -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenNullPointer) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetPrivRl(nullptr, &prl, sizeof(prl))); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetPrivRl(verifier, nullptr, sizeof(prl))); -} - -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenZeroSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetPrivRl(verifier, &prl, 0)); -} - -// Size parameter must be at least big enough for n1 == 0 case -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenTooSmallSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - EXPECT_EQ( - kEpidBadArgErr, - EpidVerifierSetPrivRl(verifier, &prl, (sizeof(prl) - sizeof(prl.f)) - 1)); - prl.n1 = this->octstr32_1; - EXPECT_EQ( - kEpidBadArgErr, - EpidVerifierSetPrivRl(verifier, &prl, (sizeof(prl) - sizeof(prl.f)) - 1)); -} - -// Size parameter must be cross-checked with n1 value in priv_rl -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenN1TooBigForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - prl.n1 = this->octstr32_1; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl) - sizeof(prl.f))); -} - -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenN1TooSmallForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl))); -} - -TEST_F(EpidVerifierTest, SetPrivRlPassesGivenDefaultPrivRl) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidNoErr, - EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl) - sizeof(prl.f))); -} - -TEST_F(EpidVerifierTest, SetPrivRlPassesGivenDefaultPrivRlUsingIkgfData) { - VerifierCtxObj verifier(this->pub_key_ikgf_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_ikgf_str.gid; - EXPECT_EQ(kEpidNoErr, - EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl) - sizeof(prl.f))); -} - -TEST_F(EpidVerifierTest, SetPrivRlPassesGivenPrivRlWithSingleElement) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - prl.n1 = this->octstr32_1; - EXPECT_EQ(kEpidNoErr, EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl))); -} - -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenBadGroupId) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - prl.gid.data[0] = ~prl.gid.data[0]; - prl.n1 = this->octstr32_1; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl))); -} - -TEST_F(EpidVerifierTest, SetPrivRlFailsGivenOldVersion) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - PrivRl prl = {{0}, {0}, {0}, {0}}; - prl.gid = this->pub_key_str.gid; - prl.version = this->octstr32_1; - EXPECT_EQ(kEpidNoErr, - EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl) - sizeof(prl.f))); - OctStr32 octstr32_0 = {0x00, 0x00, 0x00, 0x00}; - prl.version = octstr32_0; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetPrivRl(verifier, &prl, sizeof(prl) - sizeof(prl.f))); -} - -////////////////////////////////////////////////////////////////////////// -// EpidVerifierSetSigRl -TEST_F(EpidVerifierTest, SetSigRlFailsGivenNullPointer) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetSigRl(nullptr, &srl, sizeof(SigRl))); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, nullptr, sizeof(SigRl))); -} - -TEST_F(EpidVerifierTest, SetSigRlFailsGivenZeroSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetSigRl(verifier, &srl, 0)); -} - -// Size parameter must be at least big enough for n2 == 0 case -TEST_F(EpidVerifierTest, SetSigRlFailsGivenTooSmallSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - EXPECT_EQ( - kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, &srl, (sizeof(srl) - sizeof(srl.bk)) - 1)); - srl.n2 = this->octstr32_1; - EXPECT_EQ( - kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, &srl, (sizeof(srl) - sizeof(srl.bk)) - 1)); -} - -TEST_F(EpidVerifierTest, SetSigRlFailsGivenN2TooBigForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - srl.n2 = this->octstr32_1; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, &srl, sizeof(srl) - sizeof(srl.bk))); -} - -TEST_F(EpidVerifierTest, SetSigRlFailsGivenN2TooSmallForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetSigRl(verifier, &srl, sizeof(srl))); -} - -TEST_F(EpidVerifierTest, SetSigRlWorksGivenDefaultSigRl) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierCtx* ctx = verifier; - SigRl const* sig_rl = - reinterpret_cast(this->kGrp01SigRl.data()); - size_t sig_rl_size = this->kGrp01SigRl.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetSigRl(ctx, sig_rl, sig_rl_size)); -} - -TEST_F(EpidVerifierTest, SetSigRlWorksGivenDefaultSigRlUsingIkgfData) { - VerifierCtxObj verifier(this->pub_key_ikgf_str, - this->verifier_precomp_ikgf_str); - VerifierCtx* ctx = verifier; - SigRl const* sig_rl = reinterpret_cast(this->kSigRlIkgf.data()); - size_t sig_rl_size = this->kSigRlIkgf.size() * sizeof(uint8_t); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetSigRl(ctx, sig_rl, sig_rl_size)); -} - -TEST_F(EpidVerifierTest, SetSigRlWorksGivenSigRlWithNoElements) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - - uint8_t sig_rl_data_n2_zero[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2A, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x00, - // not bk's - }; - SigRl* sig_rl = reinterpret_cast(sig_rl_data_n2_zero); - size_t sig_rl_size = sizeof(sig_rl_data_n2_zero); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetSigRl(verifier, sig_rl, sig_rl_size)); -} - -TEST_F(EpidVerifierTest, SetSigRlWorksGivenSigRlWithOneElement) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - - uint8_t sig_rl_data_n2_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2A, - // version - 0x00, 0x00, 0x00, 0x00, - // n2 - 0x0, 0x00, 0x00, 0x01, - // one bk - 0x9c, 0xa5, 0xe5, 0xae, 0x5f, 0xae, 0x51, 0x59, 0x33, 0x35, 0x27, 0xd, - 0x8, 0xb1, 0xbe, 0x5d, 0x69, 0x50, 0x84, 0xc5, 0xfe, 0xe2, 0x87, 0xea, - 0x2e, 0xef, 0xfa, 0xee, 0x67, 0xf2, 0xd8, 0x28, 0x56, 0x43, 0xc6, 0x94, - 0x67, 0xa6, 0x72, 0xf6, 0x41, 0x15, 0x4, 0x58, 0x42, 0x16, 0x88, 0x57, - 0x9d, 0xc7, 0x71, 0xd1, 0xc, 0x84, 0x13, 0xa, 0x90, 0x23, 0x18, 0x8, 0xad, - 0x7d, 0xfe, 0xf5, 0xc8, 0xae, 0xfc, 0x51, 0x40, 0xa7, 0xd1, 0x28, 0xc2, - 0x89, 0xb2, 0x6b, 0x4e, 0xb4, 0xc1, 0x55, 0x87, 0x98, 0xbd, 0x72, 0xf9, - 0xcf, 0xd, 0x40, 0x15, 0xee, 0x32, 0xc, 0xf3, 0x56, 0xc5, 0xc, 0x61, 0x9d, - 0x4f, 0x7a, 0xb5, 0x2b, 0x16, 0xa9, 0xa3, 0x97, 0x38, 0xe2, 0xdd, 0x3a, - 0x33, 0xad, 0xf6, 0x7b, 0x68, 0x8b, 0x68, 0xcf, 0xa3, 0xd3, 0x98, 0x37, - 0xce, 0xec, 0xd1, 0xa8, 0xc, 0x8b}; - SigRl* sig_rl = reinterpret_cast(sig_rl_data_n2_one); - size_t sig_rl_size = sizeof(sig_rl_data_n2_one); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetSigRl(verifier, sig_rl, sig_rl_size)); -} - -TEST_F(EpidVerifierTest, SetSigRlFailsGivenBadGroupId) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - srl.gid.data[0] = ~srl.gid.data[0]; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, &srl, sizeof(srl) - sizeof(srl.bk))); -} - -TEST_F(EpidVerifierTest, SetSigRlFailsGivenOldVersion) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - SigRl srl = {{{0}}, {{0}}, {{0}}, {{{{0}, {0}}, {{0}, {0}}}}}; - srl.gid = this->pub_key_str.gid; - srl.version = this->octstr32_1; - EXPECT_EQ(kEpidNoErr, - EpidVerifierSetSigRl(verifier, &srl, sizeof(srl) - sizeof(srl.bk))); - OctStr32 octstr32_0 = {0x00, 0x00, 0x00, 0x00}; - srl.version = octstr32_0; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetSigRl(verifier, &srl, sizeof(srl) - sizeof(srl.bk))); -} - -////////////////////////////////////////////////////////////////////////// -// EpidVerifierSetGroupRl -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenNullPointer) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl grl = {{0}, {0}, {0}}; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetGroupRl(nullptr, &grl, sizeof(grl))); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, nullptr, sizeof(grl))); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenSizeZero) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl grl = {{0}, {0}, {0}}; - size_t grl_size = 0; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetGroupRl(verifier, &grl, grl_size)); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenSizeTooSmall) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl grl = {{0}, {0}, {0}}; - size_t grl_size = sizeof(grl) - sizeof(grl.gid[0]); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, &grl, grl_size - 1)); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenSizeTooLarge) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl grl = {{0}, {0}, {0}}; - size_t grl_size = sizeof(grl) - sizeof(grl.gid[0]); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, &grl, grl_size + 1)); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenN3ZeroAndGroupRLSizeTooBig) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* group_rl = (GroupRl*)this->group_rl_3gid_n0_buf.data(); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, group_rl, - this->group_rl_3gid_n0_buf.size())); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenN3TooSmall) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* group_rl = (GroupRl*)this->group_rl_3gid_n2_buf.data(); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, group_rl, - this->group_rl_3gid_n2_buf.size())); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenN3TooLarge) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* group_rl = (GroupRl*)this->group_rl_3gid_n4_buf.data(); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, group_rl, - this->group_rl_3gid_n4_buf.size())); -} - -TEST_F(EpidVerifierTest, SetGroupRlSucceedsGivenEmptyRL) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* empty_grl = (GroupRl*)this->group_rl_empty_buf.data(); - size_t grl_size = this->group_rl_empty_buf.size(); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetGroupRl(verifier, empty_grl, grl_size)); -} -TEST_F(EpidVerifierTest, SetGroupRlSucceedsGivenDefaultGroupRLUsingIkgfData) { - VerifierCtxObj verifier(this->pub_key_ikgf_str, - this->verifier_precomp_ikgf_str); - GroupRl* empty_grl = (GroupRl*)this->group_rl_empty_buf.data(); - size_t grl_size = this->group_rl_empty_buf.size(); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetGroupRl(verifier, empty_grl, grl_size)); -} -TEST_F(EpidVerifierTest, SetGroupRlSucceedsGivenRLWith3gid) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* group_rl = (GroupRl*)this->group_rl_3gid_buf.data(); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetGroupRl(verifier, group_rl, - this->group_rl_3gid_buf.size())); -} - -TEST_F(EpidVerifierTest, SetGroupRlFailsGivenOldVersion) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - GroupRl* group_rl = (GroupRl*)this->group_rl_3gid_buf.data(); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetGroupRl(verifier, group_rl, - this->group_rl_3gid_buf.size())); - GroupRl* empty_grl = (GroupRl*)this->group_rl_empty_buf.data(); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetGroupRl(verifier, empty_grl, - this->group_rl_empty_buf.size())); -} -////////////////////////////////////////////////////////////////////////// -// EpidVerifierSetVerifierRl -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenNullPointer) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(nullptr, &ver_rl, sizeof(ver_rl))); - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(verifier, nullptr, sizeof(ver_rl))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenSizeZero) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetVerifierRl(verifier, &ver_rl, 0)); -} - -// Size parameter must be at least equal to minimum value for n4 == 0 case -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenSizeTooSmall) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl( - verifier, &ver_rl, sizeof(ver_rl) - sizeof(ver_rl.K[0]) - 1)); - ver_rl.n4 = this->octstr32_1; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl( - verifier, &ver_rl, sizeof(ver_rl) - sizeof(ver_rl.K[0]) - 1)); -} - -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenN4TooBigForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - ver_rl.n4 = this->octstr32_1; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(verifier, &ver_rl, - sizeof(ver_rl) - sizeof(ver_rl.K[0]))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenN4TooSmallForSize) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(verifier, &ver_rl, sizeof(ver_rl))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlWorksGivenDefaultVerifierRl) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl const* ver_rl_ptr = - reinterpret_cast(this->kGrp01VerRl.data()); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetVerifierRl( - verifier, ver_rl_ptr, - this->kGrp01VerRl.size() * sizeof(uint8_t))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlWorksGivenVerifierRlWithNoElements) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - uint8_t ver_rl_data_n4_zero[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2A, - // B - 0x41, 0x63, 0xfd, 0x06, 0xb8, 0xb1, 0xa6, 0x32, 0xa5, 0xe3, 0xeb, 0xc4, - 0x40, 0x11, 0x37, 0xc0, 0x62, 0x0d, 0xe1, 0xca, 0xe9, 0x79, 0xad, 0xff, - 0x1d, 0x13, 0xb3, 0xda, 0xa0, 0x10, 0x8a, 0xa8, 0x30, 0x72, 0xa4, 0xe8, - 0x27, 0xb5, 0xad, 0xdb, 0xac, 0x89, 0xd8, 0x37, 0x79, 0xd9, 0x8c, 0xd0, - 0xb3, 0xef, 0x94, 0x17, 0x4f, 0x05, 0x53, 0x4c, 0x4d, 0xf0, 0x77, 0xf7, - 0xb6, 0xaf, 0xb8, 0xfa, - // version - 0x00, 0x00, 0x00, 0x00, - // n4 - 0x00, 0x00, 0x00, 0x00, - // no k's - }; - - VerifierRl* ver_rl_ptr = reinterpret_cast(ver_rl_data_n4_zero); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetVerifierRl(verifier, ver_rl_ptr, - sizeof(ver_rl_data_n4_zero))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlWorksGivenVerifierRlWithOneElement) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - uint8_t ver_rl_data_n4_one[] = { - // gid - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2A, - // B - 0x41, 0x63, 0xfd, 0x06, 0xb8, 0xb1, 0xa6, 0x32, 0xa5, 0xe3, 0xeb, 0xc4, - 0x40, 0x11, 0x37, 0xc0, 0x62, 0x0d, 0xe1, 0xca, 0xe9, 0x79, 0xad, 0xff, - 0x1d, 0x13, 0xb3, 0xda, 0xa0, 0x10, 0x8a, 0xa8, 0x30, 0x72, 0xa4, 0xe8, - 0x27, 0xb5, 0xad, 0xdb, 0xac, 0x89, 0xd8, 0x37, 0x79, 0xd9, 0x8c, 0xd0, - 0xb3, 0xef, 0x94, 0x17, 0x4f, 0x05, 0x53, 0x4c, 0x4d, 0xf0, 0x77, 0xf7, - 0xb6, 0xaf, 0xb8, 0xfa, - // version - 0x00, 0x00, 0x00, 0x00, - // n4 - 0x00, 0x00, 0x00, 0x01, - // k's - 0xdc, 0x41, 0x24, 0xe7, 0xb8, 0xf2, 0x6d, 0xc4, 0x01, 0xf9, 0x5d, 0xf8, - 0xd9, 0x23, 0x32, 0x29, 0x0a, 0xe1, 0xf6, 0xdc, 0xa1, 0xef, 0x52, 0xf7, - 0x3a, 0x3c, 0xe6, 0x7e, 0x3d, 0x0e, 0xe8, 0x86, 0xa9, 0x58, 0xf4, 0xfe, - 0xfa, 0x8b, 0xe4, 0x1c, 0xad, 0x58, 0x5b, 0x1c, 0xc7, 0x54, 0xee, 0x7e, - 0xe7, 0x12, 0x6a, 0x4b, 0x01, 0x63, 0xb4, 0xdb, 0x6e, 0xe7, 0x7a, 0xe9, - 0x62, 0xa5, 0xb4, 0xe3, - }; - VerifierRl* ver_rl_ptr = reinterpret_cast(ver_rl_data_n4_one); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetVerifierRl(verifier, ver_rl_ptr, - sizeof(ver_rl_data_n4_one))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenBadGroupId) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - ver_rl.gid.data[0] = ~ver_rl.gid.data[0]; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(verifier, &ver_rl, - sizeof(ver_rl) - sizeof(ver_rl.K[0]))); -} - -TEST_F(EpidVerifierTest, SetVerifierRlFailsGivenOldVersion) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierRl ver_rl = {{0}, {{0}, {0}}, {0}, {0}, {{{0}, {0}}}}; - ver_rl.gid = this->pub_key_str.gid; - ver_rl.version = this->octstr32_1; - EXPECT_EQ(kEpidNoErr, - EpidVerifierSetVerifierRl(verifier, &ver_rl, - sizeof(ver_rl) - sizeof(ver_rl.K[0]))); - OctStr32 octstr32_0 = {0x00, 0x00, 0x00, 0x00}; - ver_rl.version = octstr32_0; - EXPECT_EQ(kEpidBadArgErr, - EpidVerifierSetVerifierRl(verifier, &ver_rl, - sizeof(ver_rl) - sizeof(ver_rl.K[0]))); -} - -////////////////////////////////////////////////////////////////////////// -// EpidVerifierSetHashAlg -TEST_F(EpidVerifierTest, SetHashAlgFailsGivenNullPointer) { - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetHashAlg(nullptr, kSha256)); -} -TEST_F(EpidVerifierTest, SetHashAlgCanSetValidAlgoritm) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetHashAlg(verifier, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidVerifierSetHashAlg(verifier, kSha512)); - // DE2089 - SHA-512/256 Hash Alg is not supported by EpidMemberSetHashAlg - // EXPECT_EQ(kEpidNoErr, EpidVerifierSetHashAlg(verifier, kSha512_256)); -} -TEST_F(EpidVerifierTest, SetHashAlgCanFailForNonSupportedAlgoritms) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetHashAlg(verifier, kSha3_256)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetHashAlg(verifier, kSha3_384)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetHashAlg(verifier, kSha3_512)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifierSetHashAlg(verifier, (HashAlg)-1)); -} -TEST_F(EpidVerifierTest, DefaultHashAlgIsSha512) { - VerifierCtxObj verifier(this->pub_key_str, this->verifier_precomp_str); - VerifierCtx* ctx = verifier; - EXPECT_EQ(kSha512, ctx->hash_alg); -} -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/main-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/main-test.cc deleted file mode 100644 index 70f2d3a182..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/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/verifier/unittests/nrverify-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/nrverify-test.cc deleted file mode 100644 index dbe3133308..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/nrverify-test.cc +++ /dev/null @@ -1,265 +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 NrVerify unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" - -namespace { - -///////////////////////////////////////////////////////////////////////// -// Simple Errors - -TEST_F(EpidVerifierTest, NrVerifyFailsGivenNullParameters) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(nullptr, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); - - EXPECT_EQ(kEpidBadArgErr, EpidNrVerify(verifier, nullptr, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); - - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, nullptr, - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); - - EXPECT_EQ( - kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), nullptr, &epid_signature->sigma[0])); - - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], nullptr)); -} - -///////////////////////////////////////////////////////////////////// -// Reject - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithTNotInG1) { - // * 4.2.2 step 1 - The verifier verifies that G1.inGroup(T) = true. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - NrProof nr_proof = epid_signature->sigma[0]; - nr_proof.T.x.data.data[0]++; - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], &nr_proof)); -} - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithTIdentityOfG1) { - // * 4.2.2 step 2 - The verifier verifies that G1.isIdentity(T) = false. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - NrProof nr_proof = epid_signature->sigma[0]; - nr_proof.T = this->G1_identity_str; - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], &nr_proof)); -} - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithCNotInRange) { - // * 4.2.2 step 3 - The verifier verifies that c, smu, snu in [0, p-1]. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - NrProof nr_proof = epid_signature->sigma[0]; - nr_proof.c.data = this->params_str.p.data; - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], &nr_proof)); -} - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithSmuNotInRange) { - // * 4.2.2 step 3 - The verifier verifies that c, smu, snu in [0, p-1]. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - NrProof nr_proof = epid_signature->sigma[0]; - nr_proof.smu.data = this->params_str.p.data; - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], &nr_proof)); -} - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithSnuNotInRange) { - // * 4.2.2 step 3 - The verifier verifies that c, smu, snu in [0, p-1]. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - NrProof nr_proof = epid_signature->sigma[0]; - nr_proof.snu.data = this->params_str.p.data; - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], &nr_proof)); -} - -// 4.2.2 step 4 - The verifier computes nc = (- c) mod p. -// This Step is not testable - -// 4.2.2 step 5 - The verifier computes R1 = G1.multiExp(K, smu, B, snu). -// This Step is not testable - -// 4.2.2 step 6 - The verifier computes R2 = G1.multiExp(K', smu, B', snu, -// T, nc). -// This Step is not testable - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithInvalidCommitment) { - // * 4.2.2 step 7 - The verifier verifies c = Fp.hash(p || g1 || B || K || - // B' || K' || T || R1 || R2 || m). - // Refer to Section 7.1 for hash operation over a - // prime field. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - std::vector test_msg = this->kTest0; - test_msg[0]++; - EXPECT_EQ( - kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature->sigma0, test_msg.data(), - test_msg.size(), &sig_rl->bk[0], &epid_signature->sigma[0])); -} - -TEST_F(EpidVerifierTest, NrVerifyRejectsSigWithValidCommitmentDiffHashAlg) { - // * 4.2.2 step 7 - The verifier verifies c = Fp.hash(p || g1 || B || K || - // B' || K' || T || R1 || R2 || m). - // Refer to Section 7.1 for hash operation over a - // prime field. - // result must be kEpidBadArgErr - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature_sha256 = - reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - EpidSignature const* epid_signature_sha384 = - reinterpret_cast( - this->kSigGrp01Member0Sha384RandombaseTest0.data()); - SigRl const* sig_rl = reinterpret_cast(&this->kGrp01SigRl); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha384)); - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature_sha256->sigma0, - this->kTest0.data(), this->kTest0.size(), - &sig_rl->bk[0], &epid_signature_sha256->sigma[0])); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - EXPECT_EQ(kEpidBadArgErr, - EpidNrVerify(verifier, &epid_signature_sha384->sigma0, - this->kTest0.data(), this->kTest0.size(), - &sig_rl->bk[0], &epid_signature_sha384->sigma[0])); -} - -///////////////////////////////////////////////////////////////////// -// Accept -// 4.2.2 step 8 - If all the above verifications succeed, the verifier -// outputs true. If any of the above verifications fails, -// the verifier aborts and outputs false - -TEST_F(EpidVerifierTest, NrVerifyAcceptsSigWithRandomBaseNameSha256) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha256RandombaseTest0.data()); - SigRl const* sig_rl = - reinterpret_cast(this->kGrp01SigRl.data()); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidSigValid, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); -} - -TEST_F(EpidVerifierTest, - NrVerifyAcceptsSigWithRandomBaseNameSha256UsingIkgfData) { - VerifierCtxObj verifier(this->pub_key_ikgf_str); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigMember0Sha256RandombaseMsg0Ikgf.data()); - SigRl const* sig_rl = reinterpret_cast(this->kSigRlIkgf.data()); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidSigValid, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kMsg0.data(), - this->kMsg0.size(), &sig_rl->bk[2], - &epid_signature->sigma[2])); -} - -TEST_F(EpidVerifierTest, NrVerifyAcceptsSigWithRandomBaseNameSha384) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha384RandombaseTest0.data()); - SigRl const* sig_rl = - reinterpret_cast(this->kGrp01SigRl.data()); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha384)); - EXPECT_EQ(kEpidSigValid, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); -} - -TEST_F(EpidVerifierTest, NrVerifyAcceptsSigWithRandomBaseNameSha512) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha512RandombaseTest0.data()); - SigRl const* sig_rl = - reinterpret_cast(this->kGrp01SigRl.data()); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - EXPECT_EQ(kEpidSigValid, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest0.data(), - this->kTest0.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); -} - -TEST_F(EpidVerifierTest, - DISABLED_NrVerifyAcceptsSigWithRandomBaseNameSha512256) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidSignature const* epid_signature = reinterpret_cast( - this->kSigGrp01Member0Sha512256RandombaseTest1.data()); - SigRl const* sig_rl = - reinterpret_cast(this->kGrp01SigRl.data()); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512_256)); - EXPECT_EQ(kEpidSigValid, - EpidNrVerify(verifier, &epid_signature->sigma0, this->kTest1.data(), - this->kTest1.size(), &sig_rl->bk[0], - &epid_signature->sigma[0])); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/sigs_linked-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/sigs_linked-test.cc deleted file mode 100644 index a131cdb410..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/sigs_linked-test.cc +++ /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 AreSigsLinkable unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" - -namespace { - -TEST_F(EpidVerifierTest, AreSigsLinkedReturnsFalseGivenNullParameters) { - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - EXPECT_FALSE(EpidAreSigsLinked(nullptr, nullptr)); - EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig.data(), nullptr)); - EXPECT_FALSE(EpidAreSigsLinked(nullptr, (BasicSignature const*)sig.data())); -} - -TEST_F(EpidVerifierTest, SigsBySameMemberWithRandomBaseAreNotLinkable) { - auto& sig1 = this->kSigGrpXMember0Sha256RandbaseMsg0; - auto& sig2 = this->kSigGrpXMember0Sha256RandbaseMsg1; - EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(), - (BasicSignature const*)sig2.data())); -} - -TEST_F(EpidVerifierTest, SigsBySameMemberWithSameBasenameAreLinkable) { - auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& sig2 = this->kSigGrpXMember0Sha256Bsn0Msg1; - EXPECT_TRUE(EpidAreSigsLinked((BasicSignature const*)sig1.data(), - (BasicSignature const*)sig2.data())); -} - -TEST_F(EpidVerifierTest, SigsBySameMemberWithDifferentBasenameAreNotLinkable) { - auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& sig2 = this->kSigGrpXMember0Sha256Bsn1Msg0; - EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(), - (BasicSignature const*)sig2.data())); -} - -TEST_F(EpidVerifierTest, SigsByDifferentMembersWithSameBasenameAreNotLinkable) { - auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& sig2 = this->kSigGrpXMember1Sha256Bsn0Msg0; - EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(), - (BasicSignature const*)sig2.data())); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/pub_key_sigrl_verify.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/pub_key_sigrl_verify.inc deleted file mode 100644 index 0a05d35ee9..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/pub_key_sigrl_verify.inc +++ /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. - ############################################################################*/ -// group_pub_key -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xB3, 0x6F, 0xFF, 0x81, 0xE2, 0x1B, 0x17, 0xEB, 0x3D, - 0x75, 0x3D, 0x61, 0x7E, 0x27, 0xB0, 0xCB, 0xD0, 0x6D, 0x8F, 0x9D, 0x64, - 0xCE, 0xE3, 0xCE, 0x43, 0x4C, 0x62, 0xFD, 0xB5, 0x80, 0xE0, 0x99, 0x3A, - 0x07, 0x56, 0x80, 0xE0, 0x88, 0x59, 0xA4, 0xFD, 0xB5, 0xB7, 0x9D, 0xE9, - 0x4D, 0xAE, 0x9C, 0xEE, 0x3D, 0x66, 0x42, 0x82, 0x45, 0x7E, 0x7F, 0xD8, - 0x69, 0x3E, 0xA1, 0x74, 0xF4, 0x59, 0xEE, 0xD2, 0x74, 0x2E, 0x9F, 0x63, - 0xC2, 0x51, 0x8E, 0xD5, 0xDB, 0xCA, 0x1C, 0x54, 0x74, 0x10, 0x7B, 0xDC, - 0x99, 0xED, 0x42, 0xD5, 0x5B, 0xA7, 0x04, 0x29, 0x66, 0x61, 0x63, 0xBC, - 0xDD, 0x7F, 0xE1, 0x76, 0x5D, 0xC0, 0x6E, 0xE3, 0x14, 0xAC, 0x72, 0x48, - 0x12, 0x0A, 0xA6, 0xE8, 0x5B, 0x08, 0x7B, 0xDA, 0x3F, 0x51, 0x7D, 0xDE, - 0x4C, 0xEA, 0xCB, 0x93, 0xA5, 0x6E, 0xCC, 0xE7, 0x8E, 0x10, 0x84, 0xBD, - 0x19, 0x5A, 0x95, 0xE2, 0x0F, 0xCA, 0x1C, 0x50, 0x71, 0x94, 0x51, 0x40, - 0x1B, 0xA5, 0xB6, 0x78, 0x87, 0x53, 0xF6, 0x6A, 0x95, 0xCA, 0xC6, 0x8D, - 0xCD, 0x36, 0x88, 0x07, 0x28, 0xE8, 0x96, 0xCA, 0x78, 0x11, 0x5B, 0xB8, - 0x6A, 0xE7, 0xE5, 0xA6, 0x65, 0x7A, 0x68, 0x15, 0xD7, 0x75, 0xF8, 0x24, - 0x14, 0xCF, 0xD1, 0x0F, 0x6C, 0x56, 0xF5, 0x22, 0xD9, 0xFD, 0xE0, 0xE2, - 0xF4, 0xB3, 0xA1, 0x90, 0x21, 0xA7, 0xE0, 0xE8, 0xB3, 0xC7, 0x25, 0xBC, - 0x07, 0x72, 0x30, 0x5D, 0xEE, 0xF5, 0x6A, 0x89, 0x88, 0x46, 0xDD, 0x89, - 0xC2, 0x39, 0x9C, 0x0A, 0x3B, 0x58, 0x96, 0x57, 0xE4, 0xF3, 0x3C, 0x79, - 0x51, 0x69, 0x36, 0x1B, 0xB6, 0xF7, 0x05, 0x5D, 0x0A, 0x88, 0xDB, 0x1F, - 0x3D, 0xEA, 0xA2, 0xBA, 0x6B, 0xF0, 0xDA, 0x8E, 0x25, 0xC6, 0xAD, 0x83, - 0x7D, 0x3E, 0x31, 0xEE, 0x11, 0x40, 0xA9, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_first.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_first.inc deleted file mode 100644 index 3491a2265c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_first.inc +++ /dev/null @@ -1,54 +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. - ############################################################################*/ -// Intel(R) EPID signature -{{{0xFA, 0x09, 0xAF, 0x0D, 0x5C, 0x89, 0x0F, 0x27, 0x03, 0xD2, 0xC1, 0xEB, 0xC8, - 0x74, 0xA0, 0x40, 0x32, 0x94, 0xCD, 0x5B, 0xC6, 0xCD, 0xA6, 0x4B, 0xC6, 0xF2, - 0x4B, 0xB9, 0xB6, 0xC8, 0x41, 0x49}, - {0x71, 0xAC, 0x52, 0x30, 0xF0, 0xFE, 0x70, 0xF9, 0x95, 0x50, 0xAA, 0xE0, 0xD5, - 0xC9, 0xE2, 0x1A, 0xEA, 0xB9, 0xB2, 0x0D, 0x6C, 0xB4, 0x40, 0x41, 0x06, 0x83, - 0x82, 0xE6, 0x69, 0x72, 0xB3, 0x51}}, - {{0x54, 0x96, 0x07, 0xF0, 0xB8, 0x0D, 0x39, 0x25, 0x4E, 0x11, 0x81, 0xA1, 0xF8, - 0xFE, 0x39, 0xF6, 0xAA, 0x70, 0x6C, 0x1D, 0x44, 0x38, 0x08, 0x6F, 0x4E, 0x0F, - 0xA3, 0x6B, 0x8D, 0xD2, 0x29, 0x88}, - {0x23, 0x18, 0x56, 0x3E, 0x6D, 0x67, 0xDF, 0x54, 0x38, 0xCD, 0x42, 0x5B, 0x13, - 0x2B, 0x32, 0xC6, 0x77, 0x19, 0x42, 0x0A, 0x04, 0x91, 0xBF, 0xFF, 0x90, 0x60, - 0x83, 0xD9, 0x60, 0x4B, 0xBA, 0x93}}, - {{0x0C, 0xA6, 0x30, 0x03, 0xEF, 0x58, 0x49, 0x0C, 0xD4, 0x62, 0x3E, 0x25, 0xD5, - 0x91, 0xFA, 0xCD, 0xB0, 0xC9, 0xE6, 0x94, 0x34, 0xDF, 0xEC, 0x8A, 0x4C, 0x9F, - 0xE0, 0xDB, 0x43, 0x01, 0x53, 0xC5}, - {0x78, 0x82, 0x0A, 0x4B, 0x38, 0xBA, 0x32, 0x39, 0x9A, 0x7C, 0x84, 0xC9, 0x27, - 0x74, 0x35, 0x5B, 0x01, 0x5A, 0x6E, 0x32, 0x6B, 0x12, 0xEF, 0x40, 0xC9, 0xB8, - 0x31, 0xFD, 0x73, 0x55, 0x2A, 0x15}}, - {0x70, 0xB9, 0xA5, 0xCA, 0x38, 0x6F, 0x05, 0xB7, 0x0A, 0xD8, 0x89, 0xD8, 0xDA, - 0x6B, 0xB3, 0xE8, 0x9E, 0xFB, 0x3B, 0xDC, 0xE5, 0xBB, 0x4D, 0x43, 0x90, 0xB0, - 0x4F, 0xC2, 0xDA, 0x90, 0x63, 0x2D}, - {0xDE, 0x00, 0x1F, 0xFC, 0x9E, 0x3D, 0x21, 0x64, 0x3D, 0x69, 0x60, 0x16, 0x23, - 0x6F, 0x84, 0x19, 0xCB, 0x62, 0x98, 0x59, 0xC0, 0xB2, 0xED, 0x66, 0xE8, 0x87, - 0xB5, 0xAB, 0x7C, 0xDB, 0x86, 0x45}, - {0x27, 0x08, 0xE3, 0xA6, 0x5F, 0x94, 0x29, 0xA4, 0x0F, 0x49, 0xF1, 0xF6, 0x84, - 0xB6, 0xF0, 0x8F, 0x1C, 0x6E, 0x0A, 0xE4, 0x32, 0x73, 0xCD, 0x91, 0x28, 0x74, - 0x7F, 0x71, 0x76, 0x9F, 0x44, 0x52}, - {0xD6, 0x16, 0xAD, 0x45, 0x86, 0x2B, 0xE8, 0x85, 0xC4, 0x8B, 0x39, 0xB2, 0x5E, - 0xCC, 0x86, 0x1E, 0xD2, 0x9E, 0x4D, 0xA0, 0x17, 0x3D, 0xF7, 0xD1, 0x2D, 0xC2, - 0x7E, 0x22, 0xFA, 0x8D, 0xC7, 0xF3}, - {0xC5, 0x75, 0x8E, 0x8F, 0x17, 0xFD, 0x10, 0x24, 0x83, 0xCA, 0x22, 0xEB, 0x85, - 0xB6, 0x07, 0xD5, 0x9A, 0xEE, 0xC2, 0xC5, 0x87, 0x5B, 0xF3, 0x58, 0xDE, 0x1E, - 0x34, 0xBC, 0xBD, 0x61, 0xEB, 0x01}}, - {0}, {0}, { - { - {{0}, {0}}, {0}, {0}, { 0 } - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_last.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_last.inc deleted file mode 100644 index 1aab4315e6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_last.inc +++ /dev/null @@ -1,54 +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. - ############################################################################*/ -// Intel(R) EPID signature -{{{0x72, 0x78, 0x08, 0xEE, 0x07, 0xE2, 0x27, 0x1F, 0x7B, 0x96, 0x64, 0xED, 0x20, - 0x8E, 0x41, 0x4C, 0x3A, 0x03, 0x3D, 0x9E, 0x4C, 0xA2, 0x60, 0x9D, 0xD2, 0x3D, - 0x03, 0x0D, 0xF6, 0x2D, 0x9A, 0x65}, - {0x30, 0xAB, 0x45, 0x2C, 0x1E, 0xA1, 0xE7, 0x3E, 0x2E, 0xFD, 0x13, 0x1B, 0xF0, - 0x45, 0x04, 0xBB, 0x1B, 0x18, 0xCA, 0x11, 0x8B, 0xC8, 0xB7, 0x89, 0x27, 0x4E, - 0xC4, 0x52, 0xA9, 0x2C, 0x1B, 0x4F}}, - {{0x86, 0x05, 0x9B, 0x8B, 0x5E, 0x75, 0xA7, 0x24, 0x03, 0x85, 0xCB, 0xAB, 0x84, - 0xAD, 0x79, 0xCE, 0x89, 0x0F, 0x8D, 0x96, 0x9F, 0xBE, 0xDE, 0xF3, 0xA8, 0xA2, - 0x1C, 0x96, 0x83, 0xB2, 0xC9, 0xC4}, - {0x2F, 0xB9, 0x68, 0x42, 0x5D, 0x40, 0x2F, 0x99, 0x7A, 0xFB, 0x7B, 0xD4, 0x69, - 0x94, 0xA1, 0x27, 0x79, 0xD1, 0x25, 0xD5, 0x68, 0xB4, 0xB1, 0x6A, 0x6D, 0xCC, - 0x0E, 0xB4, 0x28, 0xBA, 0x1C, 0x6D}}, - {{0x08, 0x51, 0xF0, 0xA5, 0x64, 0x13, 0xF3, 0x72, 0xF2, 0xBB, 0xE4, 0x00, 0x35, - 0x9D, 0x29, 0x89, 0x99, 0x8F, 0x02, 0x38, 0xD9, 0xD0, 0xCF, 0x66, 0xF1, 0xAD, - 0x96, 0x3A, 0xC1, 0xD3, 0x76, 0x58}, - {0x56, 0xA1, 0x3F, 0x96, 0x44, 0x87, 0xAA, 0x12, 0xB7, 0x10, 0xAB, 0xF1, 0x1D, - 0x6B, 0x58, 0x26, 0xDA, 0x7A, 0x7D, 0x24, 0xBC, 0x2B, 0xAA, 0x30, 0x33, 0x7E, - 0x33, 0x05, 0x21, 0x77, 0xD6, 0x3A}}, - {0x3A, 0xEA, 0x90, 0x08, 0x1B, 0x15, 0xDB, 0x87, 0x3A, 0x16, 0xB6, 0x3E, 0xDE, - 0x08, 0x66, 0x19, 0x05, 0x9C, 0x0C, 0xB5, 0xE1, 0x05, 0x77, 0x91, 0x4B, 0xFC, - 0x17, 0x9F, 0xDB, 0x80, 0xBF, 0x39}, - {0x3B, 0x19, 0x01, 0x50, 0x5C, 0x7E, 0x3E, 0x36, 0x07, 0xF2, 0x98, 0xE0, 0x0D, - 0x7A, 0x22, 0x04, 0x56, 0x1E, 0xAD, 0x30, 0xEB, 0x4D, 0xD1, 0x58, 0xEC, 0xF8, - 0xA1, 0x98, 0xE7, 0x26, 0x07, 0x02}, - {0x82, 0x25, 0x94, 0x87, 0xE3, 0x9F, 0xA9, 0x8E, 0x3C, 0xEC, 0x28, 0x34, 0x9D, - 0xDC, 0x84, 0x29, 0xEB, 0x62, 0x12, 0xBB, 0x88, 0x7B, 0xE1, 0x21, 0x6C, 0x77, - 0xE3, 0xA2, 0x92, 0x78, 0x29, 0xB0}, - {0x0D, 0xAF, 0xF4, 0x8A, 0xA8, 0xBF, 0xAE, 0x8A, 0xDE, 0xBC, 0x24, 0x65, 0xD0, - 0x3A, 0x67, 0x31, 0xA4, 0xFD, 0xF9, 0xE2, 0xF2, 0x42, 0xD1, 0xDB, 0x1D, 0xEB, - 0xC3, 0x15, 0x06, 0x86, 0xD6, 0xE9}, - {0xE4, 0x24, 0x70, 0x13, 0x7D, 0xD0, 0xF3, 0x75, 0xF8, 0xEE, 0xD9, 0xAB, 0x7A, - 0x3C, 0xF0, 0x5D, 0xCB, 0xBA, 0x53, 0x06, 0x91, 0xD3, 0xCA, 0xB7, 0x56, 0x26, - 0x2F, 0xD1, 0x94, 0x5F, 0x48, 0x92}}, - {0}, {0}, { - { - {{0}, {0}}, {0}, {0}, { 0 } - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_middle.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_middle.inc deleted file mode 100644 index 956eed2cf2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/signature_sigrl_middle.inc +++ /dev/null @@ -1,54 +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. - ############################################################################*/ -// Intel(R) EPID signature -{{{0x76, 0xD1, 0xFF, 0xBE, 0xD4, 0xE4, 0x71, 0x78, 0x1A, 0xD4, 0x98, 0xFD, 0x00, - 0x2C, 0x71, 0x76, 0x13, 0xB9, 0xF4, 0xF0, 0x22, 0x0A, 0xA1, 0x22, 0xDB, 0x59, - 0x6A, 0xEC, 0xBC, 0x25, 0xDC, 0xAB}, - {0x14, 0x9B, 0x0A, 0x4E, 0x1C, 0x15, 0xD0, 0x6A, 0xD4, 0x3C, 0xDD, 0xE5, 0x26, - 0x13, 0x6B, 0xB0, 0xAF, 0xD0, 0x93, 0xFF, 0x3A, 0x6A, 0xDC, 0x39, 0x64, 0x73, - 0x77, 0x1F, 0x86, 0xAF, 0x69, 0x80}}, - {{0x1D, 0x85, 0x34, 0xF2, 0x71, 0x94, 0xDE, 0x90, 0xD5, 0xA8, 0x7B, 0x7D, 0x6F, - 0xB5, 0xA8, 0x36, 0xD0, 0x2D, 0x85, 0xDE, 0x6E, 0x4D, 0xB8, 0x41, 0x57, 0x56, - 0x33, 0xCA, 0xF3, 0x42, 0xA9, 0x04}, - {0x87, 0x38, 0x46, 0xC6, 0x8C, 0x29, 0x65, 0x53, 0xFC, 0xD6, 0x2C, 0xE7, 0x9B, - 0x29, 0xDD, 0x70, 0x0C, 0xBE, 0x84, 0xE6, 0x7B, 0x97, 0xC0, 0x48, 0x61, 0x01, - 0x97, 0x7A, 0xE4, 0x5C, 0xD5, 0xFB}}, - {{0xDA, 0xDB, 0xDB, 0xED, 0x12, 0x7D, 0x7D, 0x19, 0xF1, 0xF8, 0x6A, 0xE5, 0xE5, - 0xCD, 0xD4, 0x79, 0xDD, 0xE7, 0x40, 0xC0, 0xD2, 0xC7, 0x6A, 0xEA, 0x24, 0x88, - 0x56, 0x3A, 0xDF, 0xFB, 0x3C, 0x91}, - {0x5D, 0x24, 0x8F, 0x61, 0xA8, 0xDD, 0x06, 0x92, 0x26, 0x75, 0xA1, 0xC9, 0x66, - 0x56, 0x89, 0x01, 0x06, 0x72, 0x0F, 0xA6, 0x2D, 0x5B, 0x66, 0x6E, 0x39, 0x7E, - 0x68, 0xF0, 0x5E, 0x63, 0x90, 0x11}}, - {0x69, 0x35, 0x27, 0xED, 0x5F, 0x25, 0xD5, 0x19, 0x08, 0x2F, 0x40, 0xDD, 0x9F, - 0x1F, 0xEA, 0x9E, 0x5E, 0x50, 0xAF, 0x26, 0x99, 0x0F, 0x75, 0x27, 0xAB, 0x70, - 0x84, 0x23, 0xE9, 0x52, 0xB8, 0x4B}, - {0x17, 0x57, 0x3F, 0x46, 0xC0, 0x89, 0xD9, 0x49, 0x99, 0xFC, 0x73, 0x44, 0x59, - 0xBC, 0x85, 0x57, 0x0D, 0x0F, 0x1A, 0xAC, 0x8F, 0xF3, 0xA0, 0xEF, 0x32, 0xC0, - 0x8E, 0xA8, 0xC1, 0xA7, 0x54, 0x8D}, - {0x9B, 0xF7, 0x93, 0xB0, 0x4C, 0x8C, 0x99, 0x4F, 0x56, 0x7B, 0xE8, 0xF0, 0x09, - 0x83, 0xFC, 0x8A, 0x3E, 0x25, 0x3F, 0xED, 0x5B, 0xE2, 0x7B, 0xE9, 0x8B, 0x6B, - 0x58, 0xCC, 0x81, 0x54, 0x87, 0x82}, - {0xC2, 0xDD, 0xF2, 0xD6, 0x89, 0xFB, 0x5A, 0x33, 0x51, 0xD5, 0x83, 0x12, 0x0C, - 0xAF, 0x6D, 0x30, 0xFF, 0x8C, 0xAD, 0x2A, 0x6E, 0x6C, 0xFB, 0x9C, 0x23, 0x53, - 0x45, 0x59, 0x56, 0x01, 0x78, 0x9B}, - {0x2A, 0xB0, 0xCD, 0xDE, 0x0D, 0xB1, 0xB7, 0x25, 0x8D, 0xEF, 0xE6, 0x1D, 0x0E, - 0x69, 0xE3, 0x5F, 0xDF, 0xA9, 0xD4, 0x4D, 0xB9, 0x0C, 0x0C, 0xBA, 0xCC, 0x5E, - 0xEE, 0x95, 0x49, 0x52, 0x88, 0xEB}}, - {0}, {0}, { - { - {{0}, {0}}, {0}, {0}, { 0 } - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_five_entries.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_five_entries.inc deleted file mode 100644 index eaa49b2e53..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_five_entries.inc +++ /dev/null @@ -1,113 +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. - ############################################################################*/ - -// sigRL 5 entry - -// gid -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - -// version -0x00, 0x00, 0x00, 0x05, - -// n2 -0x00, 0x00, 0x00, 0x05, - -// bk's -0xFA, 0x09, 0xAF, 0x0D, 0x5C, 0x89, 0x0F, 0x27, -0x03, 0xD2, 0xC1, 0xEB, 0xC8, 0x74, 0xA0, 0x40, -0x32, 0x94, 0xCD, 0x5B, 0xC6, 0xCD, 0xA6, 0x4B, -0xC6, 0xF2, 0x4B, 0xB9, 0xB6, 0xC8, 0x41, 0x49, -0x71, 0xAC, 0x52, 0x30, 0xF0, 0xFE, 0x70, 0xF9, -0x95, 0x50, 0xAA, 0xE0, 0xD5, 0xC9, 0xE2, 0x1A, -0xEA, 0xB9, 0xB2, 0x0D, 0x6C, 0xB4, 0x40, 0x41, -0x06, 0x83, 0x82, 0xE6, 0x69, 0x72, 0xB3, 0x51, -0x54, 0x96, 0x07, 0xF0, 0xB8, 0x0D, 0x39, 0x25, -0x4E, 0x11, 0x81, 0xA1, 0xF8, 0xFE, 0x39, 0xF6, -0xAA, 0x70, 0x6C, 0x1D, 0x44, 0x38, 0x08, 0x6F, -0x4E, 0x0F, 0xA3, 0x6B, 0x8D, 0xD2, 0x29, 0x88, -0x23, 0x18, 0x56, 0x3E, 0x6D, 0x67, 0xDF, 0x54, -0x38, 0xCD, 0x42, 0x5B, 0x13, 0x2B, 0x32, 0xC6, -0x77, 0x19, 0x42, 0x0A, 0x04, 0x91, 0xBF, 0xFF, -0x90, 0x60, 0x83, 0xD9, 0x60, 0x4B, 0xBA, 0x93, - -0x39, 0x97, 0x09, 0x11, 0x30, 0xB0, 0x2A, 0x29, -0xA7, 0x9B, 0xF1, 0xEF, 0xE9, 0xE5, 0xC7, 0x03, -0x17, 0xE6, 0x4F, 0x6F, 0x49, 0x4D, 0xEB, 0x0F, -0xFD, 0x1C, 0x3F, 0xCE, 0xCC, 0xC8, 0x40, 0x6B, -0x23, 0xD3, 0xEC, 0x78, 0x78, 0x15, 0x4A, 0x34, -0x0F, 0xD1, 0xD3, 0xFA, 0xD2, 0xB2, 0x5A, 0xC9, -0xEC, 0xA2, 0x41, 0xE1, 0x46, 0x6D, 0xED, 0xB3, -0x4A, 0xA6, 0xDF, 0xB6, 0xC2, 0x11, 0x49, 0x0D, -0xC9, 0x23, 0xD9, 0x1D, 0x7A, 0xC8, 0x45, 0xAA, -0x02, 0xBA, 0x44, 0xE0, 0xA4, 0xF0, 0xC0, 0x51, -0xAE, 0x67, 0xB3, 0x88, 0x58, 0xB2, 0x92, 0xEA, -0x1D, 0x12, 0x6E, 0x49, 0xC3, 0x13, 0xEA, 0x8E, -0xB7, 0x99, 0x4F, 0x57, 0x7E, 0x06, 0x99, 0xE1, -0x3B, 0x59, 0x2C, 0xD1, 0x43, 0x5D, 0x9E, 0x68, -0xF2, 0x8E, 0x0C, 0xAF, 0x3E, 0x68, 0x6B, 0xD5, -0xD9, 0x3A, 0x30, 0xF4, 0x0B, 0x01, 0x49, 0x9B, - -0x76, 0xD1, 0xFF, 0xBE, 0xD4, 0xE4, 0x71, 0x78, -0x1A, 0xD4, 0x98, 0xFD, 0x00, 0x2C, 0x71, 0x76, -0x13, 0xB9, 0xF4, 0xF0, 0x22, 0x0A, 0xA1, 0x22, -0xDB, 0x59, 0x6A, 0xEC, 0xBC, 0x25, 0xDC, 0xAB, -0x14, 0x9B, 0x0A, 0x4E, 0x1C, 0x15, 0xD0, 0x6A, -0xD4, 0x3C, 0xDD, 0xE5, 0x26, 0x13, 0x6B, 0xB0, -0xAF, 0xD0, 0x93, 0xFF, 0x3A, 0x6A, 0xDC, 0x39, -0x64, 0x73, 0x77, 0x1F, 0x86, 0xAF, 0x69, 0x80, -0x1D, 0x85, 0x34, 0xF2, 0x71, 0x94, 0xDE, 0x90, -0xD5, 0xA8, 0x7B, 0x7D, 0x6F, 0xB5, 0xA8, 0x36, -0xD0, 0x2D, 0x85, 0xDE, 0x6E, 0x4D, 0xB8, 0x41, -0x57, 0x56, 0x33, 0xCA, 0xF3, 0x42, 0xA9, 0x04, -0x87, 0x38, 0x46, 0xC6, 0x8C, 0x29, 0x65, 0x53, -0xFC, 0xD6, 0x2C, 0xE7, 0x9B, 0x29, 0xDD, 0x70, -0x0C, 0xBE, 0x84, 0xE6, 0x7B, 0x97, 0xC0, 0x48, -0x61, 0x01, 0x97, 0x7A, 0xE4, 0x5C, 0xD5, 0xFB, - -0xFC, 0xF6, 0x00, 0xD1, 0xB9, 0x82, 0xAA, 0x79, -0x6C, 0x96, 0xE1, 0xB6, 0x15, 0x93, 0x4D, 0xF4, -0xFB, 0xBF, 0xBC, 0x3E, 0xE3, 0x87, 0xB6, 0xA3, -0xB5, 0xFD, 0x25, 0x42, 0xBC, 0x58, 0x52, 0x09, -0x4E, 0x99, 0x15, 0x66, 0x56, 0x44, 0x1C, 0x5D, -0xDE, 0x8F, 0xE0, 0x40, 0x08, 0x49, 0xDB, 0x4E, -0xDA, 0x8B, 0x77, 0x44, 0x3F, 0x77, 0xEE, 0x7B, -0x48, 0x0E, 0xCC, 0x5F, 0x1C, 0x05, 0x74, 0x6B, -0x2F, 0xD8, 0x1C, 0x01, 0x7E, 0xDF, 0x65, 0x7B, -0x17, 0x8F, 0xA7, 0xC3, 0x03, 0x04, 0x27, 0xEC, -0xFA, 0x0A, 0x22, 0x8E, 0x4E, 0xBF, 0x67, 0x9D, -0x81, 0xA2, 0x6D, 0xF4, 0x21, 0x66, 0xC5, 0x17, -0x3D, 0x55, 0x29, 0xF3, 0x53, 0x61, 0x26, 0x8D, -0xB5, 0x32, 0xF4, 0xD0, 0x94, 0x5D, 0xA9, 0x0E, -0x52, 0x2C, 0x48, 0x7B, 0xA4, 0xFE, 0x4F, 0x98, -0x5F, 0xF1, 0x4D, 0xD9, 0x69, 0xC4, 0x94, 0x70, - -0x72, 0x78, 0x08, 0xEE, 0x07, 0xE2, 0x27, 0x1F, -0x7B, 0x96, 0x64, 0xED, 0x20, 0x8E, 0x41, 0x4C, -0x3A, 0x03, 0x3D, 0x9E, 0x4C, 0xA2, 0x60, 0x9D, -0xD2, 0x3D, 0x03, 0x0D, 0xF6, 0x2D, 0x9A, 0x65, -0x30, 0xAB, 0x45, 0x2C, 0x1E, 0xA1, 0xE7, 0x3E, -0x2E, 0xFD, 0x13, 0x1B, 0xF0, 0x45, 0x04, 0xBB, -0x1B, 0x18, 0xCA, 0x11, 0x8B, 0xC8, 0xB7, 0x89, -0x27, 0x4E, 0xC4, 0x52, 0xA9, 0x2C, 0x1B, 0x4F, -0x86, 0x05, 0x9B, 0x8B, 0x5E, 0x75, 0xA7, 0x24, -0x03, 0x85, 0xCB, 0xAB, 0x84, 0xAD, 0x79, 0xCE, -0x89, 0x0F, 0x8D, 0x96, 0x9F, 0xBE, 0xDE, 0xF3, -0xA8, 0xA2, 0x1C, 0x96, 0x83, 0xB2, 0xC9, 0xC4, -0x2F, 0xB9, 0x68, 0x42, 0x5D, 0x40, 0x2F, 0x99, -0x7A, 0xFB, 0x7B, 0xD4, 0x69, 0x94, 0xA1, 0x27, -0x79, 0xD1, 0x25, 0xD5, 0x68, 0xB4, 0xB1, 0x6A, -0x6D, 0xCC, 0x0E, 0xB4, 0x28, 0xBA, 0x1C, 0x6D, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_single_entry.inc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_single_entry.inc deleted file mode 100644 index 7e41dc8678..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/testdata/sigrl/sigrl_single_entry.inc +++ /dev/null @@ -1,29 +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. - ############################################################################*/ -// sigrl 1 entry -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xFA, - 0x09, 0xAF, 0x0D, 0x5C, 0x89, 0x0F, 0x27, 0x03, 0xD2, 0xC1, 0xEB, 0xC8, - 0x74, 0xA0, 0x40, 0x32, 0x94, 0xCD, 0x5B, 0xC6, 0xCD, 0xA6, 0x4B, 0xC6, - 0xF2, 0x4B, 0xB9, 0xB6, 0xC8, 0x41, 0x49, 0x71, 0xAC, 0x52, 0x30, 0xF0, - 0xFE, 0x70, 0xF9, 0x95, 0x50, 0xAA, 0xE0, 0xD5, 0xC9, 0xE2, 0x1A, 0xEA, - 0xB9, 0xB2, 0x0D, 0x6C, 0xB4, 0x40, 0x41, 0x06, 0x83, 0x82, 0xE6, 0x69, - 0x72, 0xB3, 0x51, 0x54, 0x96, 0x07, 0xF0, 0xB8, 0x0D, 0x39, 0x25, 0x4E, - 0x11, 0x81, 0xA1, 0xF8, 0xFE, 0x39, 0xF6, 0xAA, 0x70, 0x6C, 0x1D, 0x44, - 0x38, 0x08, 0x6F, 0x4E, 0x0F, 0xA3, 0x6B, 0x8D, 0xD2, 0x29, 0x88, 0x23, - 0x18, 0x56, 0x3E, 0x6D, 0x67, 0xDF, 0x54, 0x38, 0xCD, 0x42, 0x5B, 0x13, - 0x2B, 0x32, 0xC6, 0x77, 0x19, 0x42, 0x0A, 0x04, 0x91, 0xBF, 0xFF, 0x90, - 0x60, 0x83, 0xD9, 0x60, 0x4B, 0xBA, 0x93, diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.cc deleted file mode 100644 index d9b246279f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.cc +++ /dev/null @@ -1,657 +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 Test fixture class for EpidVerifier. - */ - -#include "epid/verifier/unittests/verifier-testhelper.h" - -const G1ElemStr EpidVerifierTest::G1_identity_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}}}}; - -const GroupPubKey EpidVerifierTest::pub_key_str = { - // gid - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x2A, - }, - // h1 - {{0xB3, 0x6F, 0xFF, 0x81, 0xE2, 0x1B, 0x17, 0xEB, 0x3D, 0x75, 0x3D, 0x61, - 0x7E, 0x27, 0xB0, 0xCB, 0xD0, 0x6D, 0x8F, 0x9D, 0x64, 0xCE, 0xE3, 0xCE, - 0x43, 0x4C, 0x62, 0xFD, 0xB5, 0x80, 0xE0, 0x99}, - {0x3A, 0x07, 0x56, 0x80, 0xE0, 0x88, 0x59, 0xA4, 0xFD, 0xB5, 0xB7, 0x9D, - 0xE9, 0x4D, 0xAE, 0x9C, 0xEE, 0x3D, 0x66, 0x42, 0x82, 0x45, 0x7E, 0x7F, - 0xD8, 0x69, 0x3E, 0xA1, 0x74, 0xF4, 0x59, 0xEE}}, - // h2 - {{0xD2, 0x74, 0x2E, 0x9F, 0x63, 0xC2, 0x51, 0x8E, 0xD5, 0xDB, 0xCA, 0x1C, - 0x54, 0x74, 0x10, 0x7B, 0xDC, 0x99, 0xED, 0x42, 0xD5, 0x5B, 0xA7, 0x04, - 0x29, 0x66, 0x61, 0x63, 0xBC, 0xDD, 0x7F, 0xE1}, - {0x76, 0x5D, 0xC0, 0x6E, 0xE3, 0x14, 0xAC, 0x72, 0x48, 0x12, 0x0A, 0xA6, - 0xE8, 0x5B, 0x08, 0x7B, 0xDA, 0x3F, 0x51, 0x7D, 0xDE, 0x4C, 0xEA, 0xCB, - 0x93, 0xA5, 0x6E, 0xCC, 0xE7, 0x8E, 0x10, 0x84}}, - // w - {{{0xBD, 0x19, 0x5A, 0x95, 0xE2, 0x0F, 0xCA, 0x1C, 0x50, 0x71, 0x94, 0x51, - 0x40, 0x1B, 0xA5, 0xB6, 0x78, 0x87, 0x53, 0xF6, 0x6A, 0x95, 0xCA, 0xC6, - 0x8D, 0xCD, 0x36, 0x88, 0x07, 0x28, 0xE8, 0x96}, - {0xCA, 0x78, 0x11, 0x5B, 0xB8, 0x6A, 0xE7, 0xE5, 0xA6, 0x65, 0x7A, 0x68, - 0x15, 0xD7, 0x75, 0xF8, 0x24, 0x14, 0xCF, 0xD1, 0x0F, 0x6C, 0x56, 0xF5, - 0x22, 0xD9, 0xFD, 0xE0, 0xE2, 0xF4, 0xB3, 0xA1}}, - {{0x90, 0x21, 0xA7, 0xE0, 0xE8, 0xB3, 0xC7, 0x25, 0xBC, 0x07, 0x72, 0x30, - 0x5D, 0xEE, 0xF5, 0x6A, 0x89, 0x88, 0x46, 0xDD, 0x89, 0xC2, 0x39, 0x9C, - 0x0A, 0x3B, 0x58, 0x96, 0x57, 0xE4, 0xF3, 0x3C}, - {0x79, 0x51, 0x69, 0x36, 0x1B, 0xB6, 0xF7, 0x05, 0x5D, 0x0A, 0x88, 0xDB, - 0x1F, 0x3D, 0xEA, 0xA2, 0xBA, 0x6B, 0xF0, 0xDA, 0x8E, 0x25, 0xC6, 0xAD, - 0x83, 0x7D, 0x3E, 0x31, 0xEE, 0x11, 0x40, 0xA9}}}}; - -const GroupPubKey EpidVerifierTest::pub_key_ikgf_str = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00}, // group id - {{{{0x45, 0xcb, 0x06, 0x04, 0xb3, 0xf7, 0x23, 0xb2, 0xd1, 0xd1, 0x0d, 0x4f, - 0x51, 0x7b, 0xbb, 0x8f, 0x71, 0x15, 0xd7, 0xf1, 0xdc, 0x15, 0x37, 0xc8, - 0xb8, 0x3d, 0x68, 0x0a, 0x18, 0xa5, 0x34, 0x14}}}, - {{{0x0c, 0xdc, 0xd9, 0x15, 0x7e, 0xba, 0x56, 0xc5, 0xe5, 0x61, 0xfa, 0x6a, - 0x86, 0xa0, 0xac, 0x6a, 0x81, 0x36, 0x6d, 0x01, 0x5f, 0x86, 0xc0, 0x04, - 0x8b, 0x1e, 0xff, 0x49, 0xd9, 0x37, 0x96, 0x66}}}}, // h1 - {{{{0xf1, 0xc3, 0x16, 0xb5, 0xc5, 0x1c, 0x67, 0xb6, 0xff, 0x28, 0x23, 0x79, - 0x59, 0xea, 0x80, 0xe6, 0x09, 0x07, 0xe7, 0xd3, 0x38, 0xec, 0xb9, 0x16, - 0x83, 0x88, 0xda, 0x64, 0xdd, 0xc4, 0x9d, 0x6a}}}, - {{{0x5c, 0xb2, 0x1c, 0x88, 0x97, 0xea, 0xaf, 0xa9, 0xf3, 0x3e, 0x07, 0xea, - 0xb6, 0x2a, 0xd5, 0x7a, 0xed, 0x32, 0xd9, 0x3d, 0x90, 0xd7, 0xb9, 0x91, - 0x08, 0x05, 0x9e, 0xe3, 0x22, 0x75, 0x06, 0x35}}}}, // h2 - {{{{{0xe5, 0xc4, 0x77, 0xad, 0x52, 0xb9, 0x7c, 0x04, 0x2d, 0x7e, 0x81, 0xf2, - 0x5d, 0x5d, 0x52, 0x7d, 0xd7, 0x1d, 0x29, 0xfb, 0x6a, 0xa7, 0xbc, 0xb5, - 0xa9, 0x1a, 0xa6, 0xfd, 0x20, 0xea, 0xf2, 0x98}}}, - {{{0xe2, 0x67, 0x33, 0x28, 0x67, 0x5f, 0xbe, 0x23, 0xa0, 0x43, 0xe8, 0x71, - 0xaa, 0xab, 0xf6, 0xf0, 0x6a, 0x2b, 0x52, 0xa8, 0x61, 0x51, 0x22, 0x44, - 0x00, 0x91, 0xd7, 0xf1, 0x7e, 0x05, 0x48, 0xdc}}}}, - {{{{0x51, 0x0c, 0xef, 0xa0, 0xf3, 0x72, 0xcd, 0x59, 0xd4, 0x7a, 0x2a, 0x60, - 0xa3, 0x62, 0x54, 0xa8, 0xb6, 0x8f, 0xed, 0x90, 0xdf, 0x3e, 0x94, 0xe8, - 0xa4, 0x89, 0x32, 0xaa, 0x52, 0x5a, 0x97, 0xae}}}, - {{{0x4c, 0x86, 0xf4, 0xba, 0xec, 0xc6, 0x36, 0x13, 0x87, 0x42, 0x5d, 0x16, - 0x49, 0x12, 0x66, 0xc5, 0xe0, 0xe4, 0x9b, 0xf9, 0x68, 0xaa, 0xa9, 0x95, - 0x81, 0x16, 0x5c, 0xd2, 0xca, 0xd4, 0x2e, 0x61}}}}} // w -}; - -const GroupPubKey EpidVerifierTest::pub_key_rev_group_ikgf_str = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x78, 0x8a, 0xb6, 0x0f, 0x9a, 0xf5, 0xe4, 0xd1, - 0xe7, 0x39, 0x6a, 0x79, 0x6c, 0xb5, 0xd1, 0xa1, 0x83, 0xec, 0xa1, 0x01, - 0xfe, 0xe8, 0x72, 0xce, 0xce, 0x05, 0x9a, 0x4f, 0xa5, 0x17, 0x1b, 0xed, - 0x30, 0xc5, 0x00, 0xc0, 0xb4, 0xdb, 0x5e, 0xa6, 0xe2, 0x24, 0x23, 0xab, - 0xf5, 0x09, 0xf2, 0x4a, 0x7e, 0x72, 0xfa, 0xc3, 0xbf, 0x33, 0x93, 0x23, - 0x48, 0x89, 0xd2, 0x98, 0x08, 0xe1, 0x01, 0xba, 0x9d, 0xa9, 0xe5, 0x41, - 0x46, 0x2e, 0xbb, 0x9e, 0x6a, 0xfd, 0x28, 0x85, 0x94, 0xd5, 0x6e, 0x5a, - 0xfa, 0x42, 0x71, 0x6e, 0xdc, 0x7e, 0xdb, 0xd1, 0xf2, 0x84, 0x11, 0x08, - 0x4f, 0x0f, 0x22, 0x1f, 0x32, 0xbe, 0xd7, 0x6f, 0x55, 0x17, 0x17, 0x4a, - 0xa7, 0x46, 0xeb, 0xca, 0x02, 0x65, 0x53, 0xca, 0xd7, 0x93, 0x03, 0x01, - 0xe1, 0x54, 0xfc, 0xdd, 0xb4, 0x95, 0x5a, 0x5c, 0x0c, 0x8c, 0x13, 0x65, - 0x02, 0x16, 0xf0, 0xfc, 0xbb, 0x02, 0x5f, 0x87, 0x83, 0x8c, 0xd0, 0x3e, - 0x69, 0xc8, 0xf5, 0x7c, 0x09, 0xdd, 0x48, 0x65, 0x82, 0x48, 0x6f, 0xb5, - 0x35, 0x0c, 0xc4, 0x04, 0x2d, 0x83, 0x0a, 0x3e, 0xa0, 0x0f, 0x5f, 0x8e, - 0x61, 0xf7, 0xc3, 0xb5, 0x5c, 0x66, 0xf8, 0xf8, 0xa3, 0x0a, 0xc1, 0x50, - 0xcd, 0xb0, 0x44, 0x19, 0x14, 0x07, 0xf1, 0xad, 0x7a, 0xec, 0x73, 0xac, - 0x55, 0x01, 0x8a, 0xa6, 0x62, 0x9b, 0x30, 0xf3, 0xf9, 0xc5, 0xd1, 0x3d, - 0xf2, 0x36, 0x13, 0x28, 0x4d, 0xbf, 0x95, 0x88, 0x76, 0x6b, 0xb0, 0x18, - 0xd8, 0x3f, 0xa6, 0x22, 0x69, 0x13, 0x06, 0xa4, 0x04, 0xbf, 0x52, 0x8e, - 0xf0, 0x11, 0x99, 0x65, 0xb9, 0xf8, 0x57, 0x0b, 0xf6, 0xc2, 0xe8, 0xaf, - 0xee, 0xd4, 0x6e, 0xa7, 0x49, 0x7b, 0xeb, 0x8f, 0x92, 0x66, 0x45, 0xda, - 0xb4, 0x01, 0xa8, 0xee, 0x7c, 0xdf, 0x8e, 0x08}; - -const VerifierPrecomp EpidVerifierTest::verifier_precomp_str = { - // e12 - {0xD8, 0x14, 0xBA, 0x4B, 0x44, 0x03, 0x55, 0x6C, 0xF6, 0x42, 0xE8, 0xF0, - 0x4C, 0xB5, 0xE7, 0xD4, 0xA2, 0xA3, 0x69, 0x47, 0xF5, 0xD4, 0xC8, 0xE9, - 0xC5, 0x5A, 0x39, 0xB5, 0x55, 0xA5, 0xD3, 0xFB, 0xF3, 0x85, 0x5A, 0x0D, - 0xD5, 0xEE, 0xDE, 0xF4, 0xA8, 0xB1, 0x8B, 0xCF, 0xA9, 0x0D, 0x29, 0xBF, - 0x86, 0x27, 0x9C, 0x1F, 0x96, 0xED, 0xD8, 0x44, 0x01, 0x35, 0x1A, 0xCE, - 0xFD, 0x4E, 0x6F, 0xA1, 0x66, 0x0D, 0x59, 0x08, 0x6D, 0xA2, 0xE4, 0x99, - 0x83, 0xDC, 0x39, 0x28, 0xB7, 0x1C, 0x1A, 0x33, 0xAD, 0xCA, 0x5C, 0x35, - 0x26, 0x1F, 0xAB, 0xBA, 0x0D, 0x53, 0xAF, 0xE0, 0x72, 0x14, 0xC5, 0xA7, - 0x2E, 0x58, 0x26, 0xC9, 0x8E, 0xFA, 0x6F, 0x62, 0xFC, 0xF0, 0x08, 0x3E, - 0xA3, 0x11, 0x3A, 0xF0, 0xB8, 0x3B, 0x2D, 0x3E, 0xEC, 0xD5, 0xBC, 0xF2, - 0x05, 0x68, 0xF4, 0x40, 0xCE, 0x2C, 0x8F, 0xDD, 0xA4, 0xE5, 0xE1, 0xB5, - 0xBE, 0xBD, 0x3E, 0xD4, 0xF6, 0x9A, 0xB3, 0x37, 0x24, 0x0D, 0xEA, 0x13, - 0xD7, 0x1F, 0xA2, 0x75, 0x68, 0xA1, 0xBE, 0x2C, 0x01, 0x42, 0x2A, 0xAE, - 0x6F, 0xAE, 0x7A, 0x72, 0x3A, 0x11, 0x03, 0x58, 0x02, 0x0D, 0xF0, 0xB0, - 0xD9, 0x6F, 0xB1, 0xE4, 0xF2, 0x70, 0xB8, 0xFF, 0x22, 0x56, 0x7C, 0xB3, - 0x80, 0xFD, 0xDF, 0xE5, 0xAB, 0xCC, 0x18, 0x7A, 0xFD, 0x91, 0xD0, 0xB0, - 0x63, 0x40, 0xD4, 0x71, 0xFA, 0x03, 0xF5, 0xF1, 0x26, 0xE1, 0xA5, 0x5A, - 0xD9, 0x6D, 0xF5, 0x5A, 0x7B, 0x2A, 0x3A, 0xFE, 0x94, 0x9E, 0x74, 0x41, - 0x79, 0x49, 0x7E, 0x48, 0x1D, 0x58, 0x5E, 0xF6, 0x98, 0xA3, 0x6E, 0x61, - 0x8E, 0x9F, 0x1F, 0xCD, 0x15, 0x01, 0x16, 0xA5, 0xE0, 0xAB, 0xD6, 0xD6, - 0x1F, 0x1C, 0xF5, 0x81, 0x76, 0xC1, 0xEC, 0x10, 0xC2, 0xCC, 0x68, 0x59, - 0x4D, 0x47, 0xEF, 0x4B, 0x7F, 0xD8, 0x78, 0x9C, 0xFE, 0x9A, 0x86, 0x7E, - 0x0C, 0xFD, 0x3E, 0x0A, 0x7A, 0x72, 0x8B, 0x14, 0x5F, 0xE6, 0x5F, 0x19, - 0xA3, 0x0A, 0x1B, 0x71, 0xDC, 0xD2, 0xAE, 0x35, 0xC3, 0x11, 0xA5, 0xD3, - 0xEA, 0xE1, 0xA9, 0xE7, 0x70, 0x0C, 0x7A, 0x39, 0x56, 0x3C, 0xE4, 0xE7, - 0xF9, 0xB6, 0xF1, 0x15, 0x40, 0xAB, 0xB6, 0xC4, 0xAD, 0xBD, 0xF4, 0xCC, - 0x13, 0xB7, 0xA8, 0xB6, 0x92, 0x1E, 0x72, 0x27, 0xA7, 0xFF, 0xD9, 0xEA, - 0x2F, 0x91, 0x96, 0x22, 0xD2, 0xC4, 0x4D, 0x80, 0xDC, 0x47, 0x66, 0x87, - 0xCC, 0xCF, 0xC5, 0x64, 0xF7, 0xB2, 0x34, 0xED, 0xD5, 0x44, 0x44, 0xCC, - 0x57, 0x41, 0xC7, 0x92, 0xB7, 0x5C, 0x12, 0xF7, 0x81, 0xF2, 0x92, 0x35, - 0x3E, 0x4B, 0xDF, 0xF8, 0xDA, 0x68, 0xAC, 0x30, 0xE3, 0xDD, 0x9E, 0x22, - 0xAA, 0x6D, 0x77, 0xDD, 0xAC, 0xD9, 0x11, 0x6E, 0xFB, 0x1A, 0x88, 0xB3}, - // e22 - {0x07, 0x3F, 0x9D, 0x47, 0x82, 0xB8, 0x3D, 0x6A, 0xE0, 0x36, 0xAB, 0xA6, - 0xFA, 0xE6, 0xD2, 0x1C, 0xC8, 0xB2, 0xD0, 0x01, 0xD4, 0x96, 0xDC, 0x2E, - 0xF8, 0x19, 0xDC, 0x70, 0x1B, 0xF9, 0x73, 0x0C, 0x2B, 0xC2, 0xE2, 0x1D, - 0x85, 0x53, 0x81, 0x51, 0xFB, 0xCA, 0x16, 0x86, 0xD4, 0x4E, 0xFD, 0x1A, - 0x59, 0xE3, 0x97, 0xC4, 0x7F, 0x99, 0xD8, 0x66, 0x08, 0xA1, 0xE4, 0x9F, - 0xBB, 0x3A, 0xCE, 0xA5, 0x23, 0x9C, 0x83, 0x13, 0xC5, 0xC8, 0xF2, 0x16, - 0x1E, 0xE8, 0xE6, 0xC5, 0x36, 0x57, 0x2C, 0xDF, 0x73, 0xB4, 0xE2, 0xB2, - 0xCB, 0xEB, 0xBB, 0xF7, 0x45, 0xD1, 0x44, 0xBD, 0x6E, 0x92, 0x95, 0x00, - 0xE5, 0x89, 0xB5, 0x91, 0x78, 0xC7, 0x44, 0xB1, 0x2F, 0x37, 0xDF, 0xFB, - 0xE7, 0x8A, 0x44, 0x3F, 0x3D, 0x06, 0x5F, 0x5B, 0x1C, 0x5F, 0xCE, 0x11, - 0x05, 0x35, 0x3C, 0xAD, 0x92, 0x7E, 0x79, 0xB8, 0xFF, 0x28, 0x05, 0xE4, - 0x04, 0x2C, 0xB6, 0x1D, 0x22, 0xAB, 0x36, 0x00, 0x5F, 0x74, 0xF1, 0xE3, - 0xF6, 0xA6, 0x68, 0xE6, 0x7B, 0x25, 0xB8, 0xCF, 0x19, 0xB0, 0x1A, 0xDD, - 0x0F, 0xAD, 0x63, 0x73, 0x62, 0x1B, 0xE7, 0x94, 0x5D, 0xBF, 0x3D, 0xF1, - 0xF9, 0x8E, 0xAB, 0x59, 0xE5, 0xD1, 0x7C, 0x62, 0xDD, 0xBC, 0x40, 0x07, - 0x70, 0x5B, 0x13, 0xF6, 0x12, 0x09, 0xB4, 0x0D, 0x3E, 0xAB, 0x8B, 0x70, - 0x60, 0x1D, 0xD4, 0x61, 0x37, 0x28, 0x98, 0x3E, 0x7E, 0xDC, 0xFD, 0xD2, - 0xC0, 0x2F, 0x4B, 0x71, 0x31, 0x34, 0xD7, 0x69, 0x41, 0x5E, 0xAA, 0x72, - 0xE4, 0xDF, 0xEB, 0xFE, 0x8D, 0xCD, 0x68, 0xFC, 0x68, 0x55, 0xBE, 0x32, - 0x7D, 0x24, 0xC5, 0x07, 0x0F, 0xA8, 0xBD, 0x5A, 0xFE, 0xE7, 0xEC, 0xDB, - 0xFD, 0x19, 0xC8, 0xA9, 0x20, 0xA2, 0x7F, 0x6C, 0xA6, 0x62, 0xEC, 0xED, - 0x9B, 0x79, 0xBF, 0x9C, 0x0E, 0x31, 0x0B, 0x25, 0x2F, 0xD3, 0xCC, 0xA0, - 0xDD, 0xB2, 0xF2, 0x69, 0x26, 0x85, 0x21, 0x06, 0x94, 0x56, 0x5F, 0x59, - 0x5C, 0xF5, 0xB7, 0x82, 0xCE, 0x0F, 0xDD, 0x40, 0xDB, 0x83, 0xAC, 0x3C, - 0x41, 0xA0, 0x1B, 0xB1, 0xAF, 0xDA, 0x55, 0xBF, 0x6B, 0x1A, 0xEF, 0xE6, - 0x90, 0xE7, 0xAA, 0x0F, 0x04, 0x3C, 0x9F, 0x5B, 0xB7, 0xCD, 0x98, 0xA8, - 0x9E, 0xFF, 0x54, 0x26, 0xC8, 0xD5, 0x5C, 0x30, 0x5E, 0xA2, 0x99, 0x8E, - 0x34, 0xD5, 0x98, 0x9F, 0xCD, 0x57, 0xD1, 0x4D, 0x1D, 0xEE, 0x01, 0x5D, - 0x5A, 0x6D, 0xB2, 0xF1, 0xCF, 0x4B, 0xC0, 0x21, 0x23, 0x96, 0x05, 0xF9, - 0xC9, 0x66, 0xE5, 0x25, 0x9D, 0xA3, 0x8E, 0x78, 0x43, 0x19, 0xC1, 0x7F, - 0x7B, 0xEF, 0xF5, 0xED, 0x00, 0xB7, 0x45, 0x1F, 0x4E, 0xA9, 0xFA, 0xE3, - 0xFF, 0x54, 0xF2, 0x21, 0x73, 0xF8, 0x6B, 0xA1, 0xC7, 0x31, 0x4D, 0x6A}, - // e2w - {0x49, 0x0D, 0x0F, 0x2A, 0x5C, 0x6A, 0x3B, 0xAD, 0x71, 0xC9, 0x22, 0x49, - 0xE8, 0x08, 0xDD, 0xBA, 0x79, 0x57, 0xB7, 0xC7, 0x61, 0xE4, 0xDB, 0x84, - 0x68, 0x57, 0xB9, 0x30, 0x83, 0xA4, 0xDC, 0xEF, 0x70, 0x93, 0x28, 0xE2, - 0x6F, 0xB9, 0xBC, 0x15, 0x28, 0x3A, 0x30, 0xBD, 0x96, 0x83, 0xDB, 0xF2, - 0x9D, 0x1E, 0xC7, 0x64, 0x6D, 0x2E, 0x7C, 0xA2, 0xF3, 0xAA, 0x2F, 0x4B, - 0x6D, 0x86, 0x9E, 0x48, 0x20, 0x29, 0x4B, 0x1F, 0x8D, 0xC2, 0x93, 0xC3, - 0x55, 0x25, 0x8E, 0xB0, 0x8A, 0x7E, 0x64, 0x45, 0x3F, 0xF4, 0x1D, 0x16, - 0x4C, 0x88, 0x2D, 0x54, 0xBE, 0xA8, 0x67, 0x70, 0x81, 0xC5, 0xB9, 0x5C, - 0x16, 0x00, 0xEF, 0x78, 0xF6, 0x4D, 0x6A, 0xEB, 0xFD, 0xA2, 0x0D, 0x52, - 0x86, 0xF3, 0x04, 0x4B, 0xD8, 0xF0, 0x7D, 0x50, 0x8B, 0xAD, 0xC0, 0x37, - 0xDB, 0x38, 0xF2, 0x7D, 0x1F, 0x8B, 0x13, 0x83, 0x7B, 0xCC, 0xE8, 0x25, - 0xFE, 0xFA, 0x0C, 0x02, 0x05, 0x2E, 0x75, 0x12, 0xA1, 0x0A, 0x89, 0xAB, - 0xF1, 0xB2, 0x08, 0x47, 0x9A, 0xEA, 0xEF, 0x1D, 0xA4, 0x9F, 0xDE, 0x89, - 0x47, 0x3E, 0x7C, 0x5E, 0x4A, 0x40, 0xDC, 0xEC, 0xC5, 0x1B, 0x7E, 0x33, - 0x0A, 0x19, 0x69, 0x27, 0xA6, 0xCC, 0x25, 0xFC, 0xF9, 0xEB, 0xBD, 0xB7, - 0x8A, 0xDB, 0x45, 0x5F, 0x9D, 0x9E, 0x01, 0xDE, 0x3D, 0x91, 0x10, 0x99, - 0x13, 0xBF, 0xC0, 0xFA, 0x9D, 0xD4, 0x0F, 0xB3, 0x09, 0xF3, 0xA1, 0xAE, - 0x68, 0xE1, 0x1B, 0x48, 0x85, 0x9F, 0x81, 0x66, 0x91, 0xE2, 0xF0, 0x7B, - 0x29, 0xDB, 0x8F, 0x5D, 0x99, 0xA9, 0xD3, 0x39, 0x30, 0xD9, 0x1B, 0x94, - 0x2A, 0x1C, 0x5C, 0xE9, 0xC0, 0x3F, 0x6E, 0xB2, 0x27, 0xBE, 0x74, 0x7A, - 0xCA, 0xE1, 0x0F, 0x6A, 0x43, 0x2E, 0x98, 0x65, 0xAF, 0x7F, 0x6E, 0x5A, - 0x55, 0x98, 0xC1, 0x58, 0x29, 0xB3, 0x86, 0x54, 0x0F, 0x57, 0x91, 0x89, - 0x29, 0xB1, 0x98, 0x79, 0xCC, 0x95, 0x39, 0xD0, 0xAB, 0xE0, 0x9F, 0xF3, - 0xDA, 0xF9, 0x5E, 0xD9, 0x34, 0xBB, 0x72, 0xDA, 0xE5, 0x72, 0xD3, 0xF8, - 0x9B, 0xF9, 0x14, 0x84, 0x48, 0x81, 0x54, 0x4F, 0xE6, 0x2B, 0x80, 0xC8, - 0xC1, 0x79, 0xFE, 0x83, 0xFF, 0x76, 0xA3, 0x6D, 0xFE, 0x37, 0x78, 0xC5, - 0x30, 0x7A, 0x50, 0xE2, 0x5D, 0x12, 0xDC, 0x72, 0xE9, 0x58, 0x7C, 0x07, - 0x4F, 0xFF, 0x15, 0x8A, 0x97, 0x3B, 0xCB, 0x60, 0xFA, 0x4E, 0xDE, 0x8C, - 0x80, 0x3A, 0x8B, 0x0B, 0xC6, 0x1D, 0xA3, 0xCE, 0x6A, 0xB3, 0x50, 0x69, - 0x03, 0x96, 0xCA, 0xC0, 0xB6, 0x94, 0x6F, 0x8F, 0xAB, 0x6F, 0x5B, 0x00, - 0x2A, 0x1D, 0x90, 0xA7, 0x81, 0xC6, 0x15, 0x77, 0x79, 0xF3, 0x36, 0x23, - 0xD1, 0x46, 0x25, 0x58, 0x6F, 0x7B, 0x22, 0xAC, 0x4C, 0x7A, 0xF3, 0x9F}, - // eg12 - {0xA8, 0x8E, 0x9A, 0xF9, 0x25, 0x12, 0x98, 0xE2, 0xC3, 0x61, 0x2E, 0xE8, - 0xD6, 0xA6, 0x77, 0x16, 0x49, 0x04, 0x75, 0x69, 0xD1, 0x83, 0x2D, 0x3F, - 0x2A, 0x79, 0xB6, 0x9B, 0xC9, 0x1D, 0x03, 0x90, 0x2A, 0xD8, 0x11, 0x9F, - 0x26, 0x36, 0xE7, 0xE9, 0x3A, 0x05, 0x4C, 0x15, 0x49, 0x93, 0xDA, 0xE9, - 0xD0, 0x5A, 0xE4, 0x8D, 0x8A, 0xFA, 0x04, 0xF1, 0x20, 0x84, 0x56, 0xEC, - 0x3C, 0x27, 0x19, 0x5C, 0xF1, 0xAF, 0xBF, 0xF6, 0x0E, 0x58, 0x84, 0x2D, - 0x94, 0x11, 0xF4, 0xB5, 0xF4, 0x14, 0x51, 0xB0, 0x90, 0x46, 0x1A, 0x81, - 0xED, 0xCF, 0x91, 0x66, 0x58, 0xA6, 0x36, 0x3A, 0x52, 0x18, 0x5A, 0xC1, - 0x08, 0x4C, 0x99, 0xD3, 0xDC, 0xCE, 0x7F, 0xCE, 0x78, 0xE0, 0x38, 0x87, - 0x32, 0xF1, 0x80, 0x3C, 0x7B, 0x67, 0xAA, 0x6F, 0xDD, 0xE0, 0xFC, 0xCB, - 0xD0, 0xB0, 0x3A, 0x59, 0x52, 0x2A, 0x84, 0xE4, 0xF8, 0x4A, 0xFF, 0x50, - 0xA0, 0x65, 0xC4, 0xEE, 0xF4, 0x9C, 0xAA, 0x34, 0x46, 0xF9, 0xD2, 0x6C, - 0xA1, 0x61, 0x71, 0x49, 0x32, 0x25, 0x84, 0x54, 0x90, 0x44, 0xBE, 0xA4, - 0x0B, 0xF7, 0xFE, 0x26, 0x81, 0x63, 0x73, 0xF7, 0x2F, 0xF2, 0xFA, 0x24, - 0x52, 0xA4, 0xD9, 0x4C, 0xC1, 0xA7, 0xA5, 0xC3, 0x03, 0x36, 0x13, 0x9B, - 0x16, 0x45, 0x16, 0xCB, 0x4B, 0x99, 0x38, 0xF3, 0x6D, 0xC8, 0x7E, 0xAB, - 0xB3, 0x53, 0xDF, 0xB6, 0x82, 0x60, 0x12, 0x11, 0x36, 0x69, 0x0E, 0x05, - 0x31, 0x8E, 0xCF, 0xD7, 0x3F, 0x32, 0xE7, 0x95, 0x84, 0x1D, 0xC8, 0xB5, - 0xBE, 0x49, 0x17, 0x9D, 0xCF, 0xA9, 0x5A, 0x2A, 0xC4, 0x11, 0x86, 0xE8, - 0x6C, 0x02, 0x56, 0xB0, 0x25, 0x2F, 0xA0, 0x06, 0xB3, 0x62, 0xB2, 0x11, - 0xAF, 0xBE, 0xA4, 0xE8, 0x61, 0x64, 0x85, 0xFB, 0xEB, 0x1C, 0xF1, 0xBC, - 0x2C, 0xAE, 0x10, 0x51, 0x16, 0xA6, 0xC0, 0xB3, 0x86, 0x8E, 0x6D, 0x79, - 0xB6, 0xBD, 0xDE, 0x1E, 0x26, 0x06, 0x46, 0x65, 0x82, 0x84, 0x5A, 0x97, - 0xD3, 0xB7, 0x93, 0x78, 0x6B, 0x9D, 0x14, 0x33, 0x94, 0x43, 0x34, 0x04, - 0x45, 0xD1, 0x47, 0xD4, 0x2F, 0x17, 0xCF, 0xF1, 0xDD, 0xEA, 0x11, 0x52, - 0xAE, 0x01, 0x88, 0x3A, 0x10, 0xEE, 0x5C, 0x16, 0xCD, 0xB5, 0x48, 0xE9, - 0x16, 0x2C, 0x70, 0xB4, 0x1E, 0x19, 0x38, 0xE0, 0x18, 0xE9, 0xAE, 0xC5, - 0xDA, 0x74, 0x41, 0x2D, 0x70, 0x07, 0x60, 0x37, 0x27, 0x66, 0xF7, 0x00, - 0xBB, 0x79, 0x51, 0xF3, 0x7C, 0x8A, 0x2B, 0xB5, 0x69, 0x6E, 0x10, 0x1F, - 0xE0, 0x0A, 0x5E, 0xBE, 0xB4, 0x4E, 0x0E, 0x02, 0x59, 0xB5, 0xCB, 0x4A, - 0x6A, 0x86, 0x8B, 0xCC, 0xA2, 0x13, 0xA0, 0xE9, 0xF2, 0x5C, 0xB0, 0x23, - 0xB2, 0x15, 0xF9, 0xBB, 0x43, 0xC1, 0x54, 0xF4, 0xC8, 0xAB, 0x16, 0xA6}}; - -const VerifierPrecomp EpidVerifierTest::verifier_precomp_ikgf_str = { - 0xbc, 0x74, 0xd9, 0xd2, 0xcc, 0x56, 0x28, 0xfd, 0x3d, 0x0b, 0x2b, 0x86, - 0xf4, 0xc6, 0xb2, 0x25, 0x19, 0x6b, 0x5b, 0x42, 0x35, 0x6a, 0xd9, 0x9c, - 0xf9, 0xb4, 0x30, 0xcb, 0xff, 0x39, 0xbb, 0x92, 0x41, 0x71, 0xf4, 0x49, - 0xc3, 0xfd, 0x36, 0xa3, 0xe0, 0xdd, 0x83, 0xf1, 0x34, 0x53, 0x2e, 0x16, - 0x2f, 0x45, 0x06, 0x10, 0x3d, 0x9a, 0xfd, 0x22, 0xb8, 0xf1, 0xfd, 0x52, - 0x3a, 0x24, 0xc5, 0x9c, 0xdd, 0x54, 0x9c, 0xff, 0xb0, 0x4d, 0xb9, 0xe5, - 0x21, 0x62, 0x61, 0xaa, 0x76, 0xc3, 0xc1, 0x25, 0x47, 0xe4, 0x3b, 0x62, - 0xab, 0x5f, 0x2c, 0x56, 0xe1, 0x24, 0x9c, 0x21, 0xec, 0x6b, 0x1d, 0x80, - 0x1d, 0xca, 0xc5, 0x45, 0x34, 0xee, 0x4e, 0xc6, 0x20, 0x94, 0x14, 0x98, - 0x0e, 0xd6, 0x88, 0x1d, 0x69, 0xfd, 0x25, 0xd3, 0xe3, 0x08, 0x3f, 0x62, - 0x82, 0xa9, 0xf2, 0x13, 0xd6, 0x54, 0xda, 0x12, 0xec, 0x4e, 0xd2, 0x92, - 0xe1, 0x82, 0x3f, 0x54, 0xf8, 0xc7, 0x0e, 0x21, 0x90, 0x49, 0xa1, 0x73, - 0xa2, 0x03, 0xd0, 0xc7, 0x1c, 0xc2, 0x36, 0x1f, 0xb5, 0x8e, 0x22, 0xaf, - 0xb5, 0x96, 0xad, 0xba, 0xde, 0xe6, 0x45, 0xb9, 0xee, 0x39, 0x74, 0x53, - 0x62, 0x68, 0xa6, 0x37, 0x33, 0x65, 0x47, 0x3b, 0xf2, 0xa3, 0x35, 0xd0, - 0xe9, 0x50, 0x49, 0x68, 0x23, 0x9a, 0xa0, 0x33, 0x66, 0x2f, 0x84, 0x23, - 0x43, 0x95, 0x35, 0xea, 0x1d, 0xfe, 0x3a, 0xe4, 0x45, 0x6f, 0xad, 0x86, - 0x7a, 0x4b, 0xf8, 0xb7, 0x32, 0xaf, 0x79, 0x7c, 0x45, 0x8d, 0xd9, 0x36, - 0x0d, 0x66, 0xcb, 0x47, 0x07, 0xf4, 0x75, 0xae, 0x38, 0xe1, 0x32, 0x67, - 0x80, 0x73, 0x0b, 0x98, 0xb7, 0x8d, 0xa3, 0x03, 0x94, 0x59, 0x0c, 0x04, - 0xa8, 0x3e, 0xf8, 0x39, 0xc9, 0x25, 0x74, 0xb5, 0x9c, 0x62, 0x79, 0xb9, - 0xf0, 0x20, 0x0b, 0x41, 0xb1, 0x76, 0x2a, 0x93, 0x15, 0xfa, 0x7a, 0x55, - 0xe4, 0x50, 0xf3, 0xe1, 0x54, 0xf8, 0x9e, 0x42, 0x84, 0xaf, 0xb6, 0xc2, - 0x2e, 0x98, 0xd5, 0xfd, 0x31, 0xe4, 0x16, 0x2b, 0x4d, 0x32, 0x96, 0x04, - 0x4f, 0xca, 0x8b, 0x8d, 0x3c, 0x24, 0xb4, 0xc3, 0x86, 0x3b, 0x06, 0xc9, - 0x45, 0xc9, 0xb1, 0x90, 0xac, 0xc3, 0xd6, 0xec, 0x80, 0x5b, 0x84, 0xcb, - 0x5e, 0x7b, 0xc4, 0xcb, 0x63, 0x9e, 0xca, 0x09, 0x92, 0xca, 0x70, 0xfd, - 0x24, 0x2a, 0x81, 0x37, 0x5a, 0x85, 0x72, 0x4a, 0x46, 0x2d, 0x29, 0x38, - 0x8f, 0xc3, 0x59, 0xc7, 0xe9, 0x76, 0x24, 0xea, 0xd4, 0xef, 0x06, 0x12, - 0xf5, 0xab, 0xab, 0xa1, 0x59, 0x13, 0xc8, 0x1d, 0xdf, 0x0f, 0x41, 0xbe, - 0x98, 0x65, 0x00, 0x11, 0x41, 0x7c, 0x6e, 0x29, 0x83, 0x73, 0xfd, 0x81, - 0xff, 0xe8, 0xd8, 0x7f, 0xa1, 0x00, 0x62, 0x11, 0x14, 0x38, 0x06, 0x57, - 0x20, 0x81, 0xaa, 0x9e, 0xaf, 0xfe, 0xee, 0x68, 0xee, 0x30, 0x1a, 0x83, - 0xe7, 0x32, 0xc3, 0xfc, 0x69, 0xe5, 0x19, 0x29, 0x4e, 0xee, 0xb0, 0xf1, - 0x63, 0xaf, 0x41, 0x3d, 0x3b, 0xb9, 0xbb, 0x2e, 0xde, 0xd7, 0x0b, 0xbe, - 0x11, 0x8f, 0x4a, 0x94, 0x4c, 0x57, 0xf3, 0x64, 0x38, 0x5a, 0xc6, 0xb8, - 0x5d, 0xa1, 0x9d, 0xc8, 0xfa, 0x32, 0xe2, 0x08, 0xf4, 0x26, 0x3f, 0x75, - 0xb5, 0x35, 0x9a, 0xe9, 0xd6, 0x1d, 0x35, 0x41, 0x9b, 0x20, 0x2b, 0x54, - 0xb9, 0x66, 0x6c, 0xc6, 0xb7, 0x44, 0x82, 0x9b, 0x74, 0xe8, 0x09, 0x04, - 0xa4, 0xf2, 0x7a, 0x8f, 0xe8, 0x6f, 0x3c, 0xa0, 0x18, 0xab, 0x66, 0xf6, - 0x39, 0x34, 0x70, 0xf3, 0xa6, 0xd3, 0xc9, 0xe1, 0x97, 0xe2, 0xdc, 0x4d, - 0xca, 0x02, 0xb6, 0x73, 0x07, 0xf3, 0x8c, 0xd0, 0xab, 0xd9, 0x12, 0x45, - 0x70, 0x7c, 0x3a, 0x24, 0x64, 0xce, 0x9e, 0x38, 0x4d, 0x5d, 0xe1, 0x9d, - 0xf2, 0x4b, 0x58, 0xdc, 0x71, 0xb3, 0x61, 0x56, 0x14, 0x62, 0x2a, 0x1b, - 0x36, 0x5e, 0xc9, 0x15, 0xf3, 0x50, 0xe6, 0xc0, 0x93, 0x62, 0xd0, 0x69, - 0xab, 0xd4, 0xe5, 0x9b, 0xa6, 0xa7, 0xa3, 0x0c, 0x51, 0xad, 0xf7, 0x38, - 0x6f, 0x1d, 0xcf, 0x43, 0xda, 0x83, 0x95, 0xc6, 0xfb, 0xd8, 0x90, 0x5e, - 0x35, 0x30, 0x0b, 0x7b, 0x45, 0xd0, 0x12, 0x32, 0x95, 0xc3, 0x96, 0xdc, - 0x0a, 0x68, 0xcc, 0xcf, 0x19, 0x0b, 0x13, 0xc7, 0x6a, 0x7a, 0x53, 0x36, - 0x5b, 0x24, 0xc5, 0x84, 0x5c, 0xeb, 0x9e, 0xeb, 0xdc, 0x91, 0x17, 0xb3, - 0x29, 0xfd, 0xee, 0x55, 0xc9, 0x8c, 0xcd, 0xbe, 0x3a, 0x66, 0xf3, 0xba, - 0x79, 0xfe, 0xc7, 0xf8, 0x08, 0xeb, 0xd2, 0x3a, 0x17, 0x3c, 0x36, 0x29, - 0xc1, 0xde, 0xa9, 0xab, 0x80, 0xdb, 0x6c, 0xdd, 0xfb, 0xe5, 0xb1, 0x12, - 0x25, 0x2f, 0xa3, 0x3d, 0x0e, 0x72, 0xde, 0xaf, 0x86, 0x93, 0x35, 0x18, - 0x96, 0x19, 0x47, 0xfd, 0x8f, 0xae, 0x7b, 0xe7, 0xac, 0x6e, 0x53, 0x10, - 0x1e, 0x66, 0x54, 0xc0, 0x36, 0x0e, 0x73, 0x35, 0xb3, 0x20, 0xf9, 0xaa, - 0x25, 0x4a, 0x66, 0xaf, 0xc9, 0x2f, 0xd1, 0x19, 0x8b, 0x8f, 0x93, 0xbe, - 0x3a, 0x30, 0xa5, 0x24, 0xc2, 0xad, 0x30, 0xfc, 0x97, 0xfe, 0x6c, 0xe0, - 0x7f, 0x98, 0x71, 0x37, 0x33, 0x26, 0xc3, 0x75, 0xc8, 0x51, 0xe6, 0xf2, - 0x99, 0xf0, 0x0f, 0x7d, 0x5d, 0x12, 0x26, 0x9d, 0x96, 0xeb, 0xd5, 0x08, - 0x28, 0x34, 0x90, 0x1c, 0xdb, 0x98, 0xbd, 0x8a, 0xeb, 0x93, 0x0d, 0xd0, - 0x57, 0x3e, 0xb8, 0x65, 0xdd, 0xa6, 0xa9, 0x81, 0xd6, 0xca, 0x62, 0x4b, - 0x24, 0xed, 0xf4, 0x36, 0xf0, 0x83, 0xd6, 0x0e, 0x53, 0xf2, 0x50, 0x89, - 0x70, 0x23, 0x19, 0x7b, 0xd0, 0x7e, 0x67, 0xa3, 0x45, 0x72, 0x9d, 0x11, - 0xbe, 0xbb, 0xe1, 0x72, 0x51, 0xf6, 0x5f, 0x4e, 0x2c, 0xca, 0x61, 0x3d, - 0xaa, 0xfd, 0xb7, 0x61, 0xbc, 0x3a, 0xd2, 0x20, 0x18, 0xa2, 0xee, 0x04, - 0xe4, 0x6b, 0xf3, 0x84, 0x26, 0xc2, 0x43, 0xa4, 0xfe, 0x4e, 0x14, 0x5c, - 0xbe, 0xe7, 0x11, 0x4a, 0x61, 0x33, 0x7d, 0xeb, 0x71, 0x98, 0x7c, 0xf0, - 0x44, 0xe2, 0x41, 0x17, 0x39, 0xd0, 0x4e, 0xe2, 0x9c, 0xcc, 0x8d, 0x76, - 0x3c, 0xb8, 0x0f, 0x63, 0x4a, 0x56, 0x7c, 0xf8, 0xab, 0xbd, 0x87, 0xcc, - 0xa2, 0x29, 0xb9, 0x3c, 0xcc, 0x12, 0xd2, 0x9d, 0x6f, 0xbd, 0x28, 0xc3, - 0x0c, 0x2f, 0x83, 0x8c, 0xf3, 0xad, 0x3d, 0xc6, 0x92, 0xba, 0x0b, 0x28, - 0x47, 0x81, 0x78, 0xbe, 0x2b, 0xe0, 0x6a, 0x47, 0xba, 0xf3, 0xbe, 0x39, - 0x30, 0x49, 0x0b, 0x35, 0x34, 0x80, 0x70, 0xc2, 0x75, 0x54, 0x65, 0xd8, - 0xc8, 0x1c, 0x26, 0xb8, 0x97, 0x61, 0x57, 0xcf, 0x2d, 0xb8, 0xd1, 0xdd, - 0xb0, 0xf1, 0xa9, 0x0f, 0x3f, 0x7e, 0xfe, 0xd3, 0xee, 0xdc, 0x75, 0xbf, - 0xc2, 0xf1, 0x30, 0xd6, 0x60, 0x1b, 0xcd, 0x7b, 0x87, 0xde, 0x0b, 0x58, - 0x5c, 0xac, 0x84, 0xda, 0xef, 0x86, 0x86, 0x8d, 0x8e, 0xfd, 0x6f, 0x93, - 0x32, 0x8d, 0xac, 0x7b, 0x8f, 0x2a, 0x8a, 0x5f, 0xf1, 0xea, 0xbb, 0x8e, - 0x6d, 0xbf, 0xe0, 0x59, 0x90, 0xc2, 0xd3, 0x3d, 0x8a, 0x03, 0x64, 0x11, - 0xdd, 0xf1, 0xfc, 0x2d, 0x26, 0x8a, 0x6f, 0x39, 0x25, 0xa9, 0xaa, 0x61, - 0x45, 0x5b, 0x7b, 0x36, 0xfd, 0x82, 0xd2, 0x6a, 0x8c, 0x9a, 0xf1, 0xc2}; - -const std::vector EpidVerifierTest::group_rl_empty_buf = { - // RLVer - 0x00, 0x00, 0x00, 0x00, - // n3 - 0x00, 0x00, 0x00, 0x00}; - -const std::vector EpidVerifierTest::group_rl_3gid_buf = { - // RLVer - 0x00, 0x00, 0x00, 0x03, - // n3 - 0x00, 0x00, 0x00, 0x03, - // gid[0] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // gid[1] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, - // gid[2] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, -}; - -const std::vector EpidVerifierTest::group_rl_3gid_n0_buf = { - // RLVer - 0x00, 0x00, 0x00, 0x03, - // n3 - 0x00, 0x00, 0x00, 0x00, - // gid[0] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // gid[1] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, - // gid[2] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, -}; - -const std::vector EpidVerifierTest::group_rl_3gid_n2_buf = { - // RLVer - 0x00, 0x00, 0x00, 0x03, - // n3 - 0x00, 0x00, 0x00, 0x02, - // gid[0] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // gid[1] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, - // gid[2] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, -}; - -const std::vector EpidVerifierTest::group_rl_3gid_n4_buf = { - // RLVer - 0x00, 0x00, 0x00, 0x03, - // n3 - 0x00, 0x00, 0x00, 0x04, - // gid[0] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // gid[1] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, - // gid[2] - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, -}; - -const Epid2Params EpidVerifierTest::params_str = { -#include "epid/common/epid2params_ate.inc" -}; -const GroupPubKey EpidVerifierTest::kGrp01Key = { -#include "epid/common/testdata/grp01/gpubkey.inc" -}; -const std::vector EpidVerifierTest::kGrp01PrivRl = { -#include "epid/common/testdata/grp01/privrl.inc" -}; -const std::vector EpidVerifierTest::kGrp01SigRl = { -#include "epid/common/testdata/grp01/sigrl.inc" -}; -const std::vector EpidVerifierTest::kSigRlIkgf = { -#include "epid/common/testdata/ikgf/groupa/sigrl.inc" -}; -const std::vector EpidVerifierTest::kGrp01VerRl = { -#include "epid/common/testdata/grp01/verrl.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha256RandombaseTest0 = { -#include "epid/common/testdata/grp01/member0/sig_test0_sha256_sigrl.inc" -}; -const std::vector - EpidVerifierTest::kSigMember0Sha256RandombaseMsg0Ikgf = { -#include "epid/common/testdata/ikgf/groupa/sig_msg0_sha256_sigrl.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha384RandombaseTest0 = { -#include "epid/common/testdata/grp01/member0/sig_test0_sha384_sigrl.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha512RandombaseTest0 = { -#include "epid/common/testdata/grp01/member0/sig_test0_sha512_sigrl.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha512256RandombaseTest1 = {0}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha256RandombaseTest1NoSigRl = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha256.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha256Basename1Test1NoSigRl = { -#include "epid/common/testdata/grp01/member0/sig_test1_basename1_sha256.inc" -}; -const std::vector - EpidVerifierTest::kSigSha256Basename1Test1NoSigRlIkgf = { -#include "epid/common/testdata/ikgf/groupa/sig_test1_basename1_sha256.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha384RandombaseTest1NoSigRl = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha384.inc" -}; -const std::vector - EpidVerifierTest::kSigGrp01Member0Sha512RandombaseTest1NoSigRl = { -#include "epid/common/testdata/grp01/member0/sig_test1_sha512.inc" -}; - -const std::vector EpidVerifierTest::kTest0 = { - 't', 'e', 's', 't', ' ', 'm', 'e', 's', 's', 'a', 'g', 'e', 0x0}; -const std::vector EpidVerifierTest::kTest1 = {'t', 'e', 's', 't', '1'}; -const std::vector EpidVerifierTest::kBasename1 = { - 'b', 'a', 's', 'e', 'n', 'a', 'm', 'e', '1'}; - -const OctStr32 EpidVerifierTest::octstr32_1 = {0x00, 0x00, 0x00, 0x01}; - -const GroupPubKey EpidVerifierTest::pub_key_sigrl_verify = { -#include "epid/verifier/unittests/testdata/sigrl/pub_key_sigrl_verify.inc" -}; -const std::vector EpidVerifierTest::sigrl_single_entry = { -#include "epid/verifier/unittests/testdata/sigrl/sigrl_single_entry.inc" -}; -const std::vector EpidVerifierTest::sigrl_five_entries = { -#include "epid/verifier/unittests/testdata/sigrl/sigrl_five_entries.inc" -}; -const EpidSignature EpidVerifierTest::signature_sigrl_first = { -#include "epid/verifier/unittests/testdata/sigrl/signature_sigrl_first.inc" -}; -const EpidSignature EpidVerifierTest::signature_sigrl_middle = { -#include "epid/verifier/unittests/testdata/sigrl/signature_sigrl_middle.inc" -}; -const EpidSignature EpidVerifierTest::signature_sigrl_last = { -#include "epid/verifier/unittests/testdata/sigrl/signature_sigrl_last.inc" -}; - -const std::vector EpidVerifierTest::kGrpRl = { -#include "epid/common/testdata/grprl.inc" -}; -const std::vector EpidVerifierTest::kGrpRlIkgf = { -#include "epid/common/testdata/ikgf/grprl.inc" -}; -const std::vector EpidVerifierTest::kGrpRlRevokedGrpXOnlyEntry = { -#include "epid/common/testdata/grprl_single_entry_revoked_grp_x.inc" -}; -const std::vector EpidVerifierTest::kGrpRlRevokedGrpXFirstEntry = { -#include "epid/common/testdata/grprl_revoked_grp_x_first_entry.inc" -}; -const std::vector EpidVerifierTest::kGrpRlRevokedGrpXMiddleEntry = { -#include "epid/common/testdata/grprl_revoked_grp_x_middle_entry.inc" -}; -const std::vector EpidVerifierTest::kGrpRlRevokedGrpXLastEntry = { -#include "epid/common/testdata/grprl_revoked_grp_x_last_entry.inc" -}; - -const std::vector EpidVerifierTest::kBsn0 = {'b', 's', 'n', '0'}; -const std::vector EpidVerifierTest::kMsg0 = {'m', 's', 'g', '0'}; - -const GroupPubKey EpidVerifierTest::kGrpXKey = { -#include "epid/common/testdata/grp_x/pubkey.inc" -}; -const std::vector EpidVerifierTest::kGrpXPrivRl = { -#include "epid/common/testdata/grp_x/privrl.inc" -}; -const std::vector EpidVerifierTest::kPrivRlIkgf = { -#include "epid/common/testdata/ikgf/groupa/privrl.inc" -}; -const std::vector - EpidVerifierTest::kGrpXPrivRlRevokedPrivKey000OnlyEntry = { -#include "epid/common/testdata/grp_x/privrl_single_entry_revoked_key000.inc" -}; -const std::vector EpidVerifierTest::kGrpXSigRl = { -#include "epid/common/testdata/grp_x/sigrl.inc" -}; - -const std::vector EpidVerifierTest::kGrpXSigRlVersion2 = { -#include "epid/common/testdata/grp_x/sigrl_ver_2.inc" -}; - -const std::vector - EpidVerifierTest::kGrpXSigRlMember0Sha256Bsn0Msg0OnlyEntry = { -#include "epid/common/testdata/grp_x/sigrl_single_entry.inc" -}; -const std::vector - EpidVerifierTest::kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry = { -#include "epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_first_entry.inc" -}; -const std::vector - EpidVerifierTest::kGrpXSigRlMember0Sha256Bsn0Msg0MiddleEntry = { -#include "epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_middle_entry.inc" -}; -const std::vector - EpidVerifierTest::kGrpXSigRlMember0Sha256Bsn0Msg0LastEntry = { -#include "epid/common/testdata/grp_x/sigrl_member0_sig_sha256_bsn0_msg0_revoked_last_entry.inc" -}; - -const std::vector EpidVerifierTest::kGrpXBsn0VerRl = { -#include "epid/common/testdata/grp_x/verrevoked/bsn0/verrl.inc" -}; -const std::vector EpidVerifierTest::kGrpXBsn0VerRlSingleEntry = { -#include "epid/common/testdata/grp_x/verrevoked/bsn0/verrl_1entry.inc" -}; -const std::vector EpidVerifierTest::kGrpXBsn1VerRl = { -#include "epid/common/testdata/grp_x/verrevoked/bsn1/verrl.inc" -}; -const std::vector EpidVerifierTest::kGrpXBsn1VerRl_012 = { -#include "epid/common/testdata/grp_x/verrevoked/bsn1/verrl_012revoked.inc" -}; -// clang-format off -const std::vector - EpidVerifierTest::kSigGrpXVerRevokedMember0Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked0sha256bsn0msg0.inc" -}; -const std::vector - EpidVerifierTest::kSigGrpXVerRevokedMember1Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked1sha256bsn0msg0.inc" -}; -const std::vector - EpidVerifierTest::kSigGrpXVerRevokedMember2Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/verrevoked/bsn0/sig_revoked2sha256bsn0msg0.inc" -}; -const std::vector - EpidVerifierTest::kSigGrpXVerRevokedMember3Sha256Bsn1Msg0 = { -#include "epid/common/testdata/grp_x/verrevoked/bsn1/sig_revoked3sha256bsn1msg0.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember0Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0.inc" -}; -const std::vector EpidVerifierTest::kSigMember0Sha256Bsn0Msg0Ikgf = { -#include "epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigRevSigMember0Sha256Bsn0Msg0Ikgf = { -#include "epid/common/testdata/ikgf/groupa/sig_sigrevoked_sha256_bsn0_msg0.inc" -}; -const std::vector - EpidVerifierTest::kRevGroupSigMember0Sha256Bsn0Msg0Ikgf = { -#include "epid/common/testdata/ikgf/groupb/sig_grouprevoked_sha256_bsn0_msg0.inc" -}; -const std::vector - EpidVerifierTest::kSigGrpXMember0Sha256Bsn0Msg0SingleEntrySigRl = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg0_rl_singleentry.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey000.inc" -}; -const std::vector -EpidVerifierTest::kSigRevokedPrivKeySha256Bsn0Msg0Ikgf = { -#include "epid/common/testdata/ikgf/groupa/sig_sha256_bsn0_msg0_revkey.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey001.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/privrevoked/signatures/sig_sha256_bsn0_msg0_revkey002.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember0Sha256Bsn0Msg1 = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_bsn0_msg1.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember0Sha256Bsn1Msg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_bsn1_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha256RandbaseMsg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigMember0Sha256RandbaseMsg0Ikgf = { -#include "epid/common/testdata/ikgf/groupa/sig_sha256_rndbase_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha256RandbaseMsg1 = { -#include "epid/common/testdata/grp_x/member0/sig_sha256_rndbase_msg1.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember0Sha384Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha384_bsn0_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha384RandbaseMsg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha384_rndbase_msg0.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember0Sha512Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha512_bsn0_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha512RandbaseMsg0 = { -#include "epid/common/testdata/grp_x/member0/sig_sha512_rndbase_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha512256Bsn0Msg0 = { -// #include "epid/common/testdata/grp_x/member0/sig_sha256512_bsn0_msg0.inc" -}; -const std::vector -EpidVerifierTest::kSigGrpXMember0Sha512256RandbaseMsg0 = { -// #include "epid/common/testdata/grp_x/member0/sig_sha512256_rndbase_msg0.inc" -}; -const std::vector EpidVerifierTest::kSigGrpXMember1Sha256Bsn0Msg0 = { -#include "epid/common/testdata/grp_x/member1/sig_sha256_bsn0_msg0.inc" -}; diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.h b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.h deleted file mode 100644 index 66fb410bd2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifier-testhelper.h +++ /dev/null @@ -1,252 +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 Test fixture class for EpidVerifier. - */ -#ifndef EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_ -#define EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_ - -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -} - -/// Test fixture class for EpidVerifier -class EpidVerifierTest : public ::testing::Test { - public: - /// Serialized identity element in G1 - static const G1ElemStr G1_identity_str; - /// test public key - static const GroupPubKey pub_key_str; - /// test public key from Ikgf - static const GroupPubKey pub_key_ikgf_str; - /// test public key of revoked group from Ikgf - static const GroupPubKey pub_key_rev_group_ikgf_str; - /// verifier pre-computation data associated with pub_key_str - static const VerifierPrecomp verifier_precomp_str; - /// verifier pre-computation data associated with pub_key_str from Ikgf - static const VerifierPrecomp verifier_precomp_ikgf_str; - /// Intel(R) EPID 2.0 parameters - static const Epid2Params params_str; - /// public key in Grp01 - static const GroupPubKey kGrp01Key; - /// private key based revocation list in Grp01 - static const std::vector kGrp01PrivRl; - /// signature based revocation list in Grp01 - static const std::vector kGrp01SigRl; - /// signature based revocation list from Ikgf - static const std::vector kSigRlIkgf; - /// number of SigRl entries for Grp01 - static const uint32_t kGrp01SigRlN2 = 50; - /// verifier revocation list in Grp01 - static const std::vector kGrp01VerRl; - /// C string with a message "test message" - static const std::vector kTest0; - /// the message "test1" - static const std::vector kTest1; - /// the basename "basename1" - static const std::vector kBasename1; - /// Signature of Test0 with RandomBase by Grp01 Member0 using Sha256 - static const std::vector kSigGrp01Member0Sha256RandombaseTest0; - /// Signature of Test with RandomBase, Member0 using Sha256 from Ikgf - static const std::vector kSigMember0Sha256RandombaseMsg0Ikgf; - /// Signature of Test1 with Basename1 by Grp01 Member0 using Sha256 - static const std::vector kSigGrp01Member0Sha256Basename1Test1; - /// Signature of Test1 with RandomBase by Grp01 Member0 using Sha384 - static const std::vector kSigGrp01Member0Sha384RandombaseTest0; - /// Signature of Test1 with RandomBase by Grp01 Member0 using Sha512 - static const std::vector kSigGrp01Member0Sha512RandombaseTest0; - /// Signature of Test1 with RandomBase by Grp01 Member0 using Sha512_256 - static const std::vector kSigGrp01Member0Sha512256RandombaseTest1; - /// Sig of Test1 with RandomBase by Grp01(no SigRl) Member0 using Sha256 - static const std::vector - kSigGrp01Member0Sha256RandombaseTest1NoSigRl; - /// Sig of Test1 with Basename1 by Grp01(no SigRl) Member0 using Sha256 - static const std::vector kSigGrp01Member0Sha256Basename1Test1NoSigRl; - /// Sig of Test1 with Basename1 by Member0 using Sha256 from Ikgf - static const std::vector kSigSha256Basename1Test1NoSigRlIkgf; - /// Sig of Test1 with RandomBase by Grp01(no SigRl) Member0 using Sha384 - static const std::vector - kSigGrp01Member0Sha384RandombaseTest1NoSigRl; - /// Sig of Test1 with RandomBase by Grp01(no SigRl) Member0 using Sha512 - static const std::vector - kSigGrp01Member0Sha512RandombaseTest1NoSigRl; - /// group based rl test data (empty rl) - static const std::vector group_rl_empty_buf; - /// group based rl test data (v=3, n=3, 3 revoked gid) - static const std::vector group_rl_3gid_buf; - /// group based rl test data (v=3, n=0, 3 revoked gid) - static const std::vector group_rl_3gid_n0_buf; - /// group based rl test data (v=3, n=2, 3 revoked gid) - static const std::vector group_rl_3gid_n2_buf; - /// group based rl test data (v=3, n=4, 3 revoked gid) - static const std::vector group_rl_3gid_n4_buf; - /// a message - static const std::vector kMsg0; - /// a message - static const std::vector kMsg1; - /// a basename - static const std::vector kBsn0; - /// a basename - static const std::vector kBsn1; - - /// a group revocation list - static const std::vector kGrpRl; - /// a group revocation list from Ikgf - static const std::vector kGrpRlIkgf; - /// a group revocation list with single group revoked - static const std::vector kGrpRlRevokedGrpXOnlyEntry; - /// a group revocation list with multiple entries - static const std::vector kGrpRlRevokedGrpXFirstEntry; - /// a group revocation list with multiple entries - static const std::vector kGrpRlRevokedGrpXMiddleEntry; - /// a group revocation list with multiple entries - static const std::vector kGrpRlRevokedGrpXLastEntry; - /// the privrl from Ikgf - static const std::vector kPrivRlIkgf; - - /// a group key in group X - static const GroupPubKey kGrpXKey; - /// the privrl of group X - static const std::vector kGrpXPrivRl; - - /// the privrl of group X with single entry PrivKey000 revoked - static const std::vector kGrpXPrivRlRevokedPrivKey000OnlyEntry; - /// the sigrl of group X - static const std::vector kGrpXSigRl; - /// a verifierrl of group X with bsn0 for some verifier - static const std::vector kGrpXBsn0VerRl; - /// a verifierrl of group X with bsn0 for some verifier with single entry - static const std::vector kGrpXBsn0VerRlSingleEntry; - /// a verifierrl of group X with bsn1 for some verifier - static const std::vector kGrpXBsn1VerRl; - /// a verifierrl of group X with bsn1 for some verifier with 0-2 revoked - static const std::vector kGrpXBsn1VerRl_012; - - /// the sigrl of group X corrputed - static const std::vector kGrpXSigRlVersion2; - - /// a group key in group Y - static const GroupPubKey kGrpYKey; - /// the privrl of group Y - static const std::vector kGrpYPrivRl; - /// the sigrl of group Y - static const std::vector kGrpYSigRl; - /// a verifierrl of group Y for some verifier - static const std::vector kGrpYVerRl; - - /// the sigrl of group X - static const std::vector kGrpXSigRlMember0Sha256Bsn0Msg0OnlyEntry; - /// the sigrl of group X - static const std::vector kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry; - /// the sigrl of group X - static const std::vector kGrpXSigRlMember0Sha256Bsn0Msg0MiddleEntry; - /// the sigrl of group X - static const std::vector kGrpXSigRlMember0Sha256Bsn0Msg0LastEntry; - - /// signature of msg0 by member0 of groupX with Sha256 bsn0 - static const std::vector kSigGrpXMember0Sha256Bsn0Msg0; - /// signature of msg0 by member0 with Sha256 bsn0 from Ikgf - static const std::vector kSigMember0Sha256Bsn0Msg0Ikgf; - /// signature of msg0 by member0 from SigRl first entry with Sha256 bsn0 from - /// Ikgf - static const std::vector kSigRevSigMember0Sha256Bsn0Msg0Ikgf; - /// signature of msg0 by member0 from revoked Group with Sha256 bsn0 from Ikgf - static const std::vector kRevGroupSigMember0Sha256Bsn0Msg0Ikgf; - /// signature of msg0 by member0 of groupX with Sha256 bsn0 single entry sigrl - static const std::vector - kSigGrpXMember0Sha256Bsn0Msg0SingleEntrySigRl; - /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key - /// 000 - static const std::vector kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0; - /// signature of msg0 by member0 with Sha256 bsn0 with revoked key from Ikgf - static const std::vector kSigRevokedPrivKeySha256Bsn0Msg0Ikgf; - /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key - /// 001 - static const std::vector kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0; - /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key - /// 002 - static const std::vector kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0; - /// signature of msg1 by member0 of groupX with Sha256 bsn0 - static const std::vector kSigGrpXMember0Sha256Bsn0Msg1; - /// signature of msg0 by member0 of groupX with Sha256 bsn1 - static const std::vector kSigGrpXMember0Sha256Bsn1Msg0; - /// signature of msg0 by member0 of groupX with Sha256 rnd base - static const std::vector kSigGrpXMember0Sha256RandbaseMsg0; - /// signature of msg0 by member0 of groupA with Sha256 rnd base - static const std::vector kSigMember0Sha256RandbaseMsg0Ikgf; - /// signature of msg1 by member0 of groupX with Sha256 rnd base - static const std::vector kSigGrpXMember0Sha256RandbaseMsg1; - /// signature of msg0 by member0 of groupX with Sha384 bsn0 - static const std::vector kSigGrpXMember0Sha384Bsn0Msg0; - /// signature of msg0 by member0 of groupX with Sha384 rnd base - static const std::vector kSigGrpXMember0Sha384RandbaseMsg0; - /// signature of msg0 by member0 of groupX with Sha512 bsn0 - static const std::vector kSigGrpXMember0Sha512Bsn0Msg0; - /// signature of msg0 by member0 of groupX with Sha512 rnd base - static const std::vector kSigGrpXMember0Sha512RandbaseMsg0; - /// signature of msg0 by member0 of groupX with Sha512256 bsn0 - static const std::vector kSigGrpXMember0Sha512256Bsn0Msg0; - /// signature of msg0 by member0 of groupX with Sha512256 rnd base - static const std::vector kSigGrpXMember0Sha512256RandbaseMsg0; - - /// signature of msg0 by verrevokedmember0 of groupX Sha256 bsn0 - static const std::vector kSigGrpXVerRevokedMember0Sha256Bsn0Msg0; - /// signature of msg0 by verrevokedmember1 of groupX Sha256 bsn0 - static const std::vector kSigGrpXVerRevokedMember1Sha256Bsn0Msg0; - /// signature of msg0 by verrevokedmember2 of groupX Sha256 bsn0 - static const std::vector kSigGrpXVerRevokedMember2Sha256Bsn0Msg0; - /// signature of msg0 by verrevokedmember3 of groupX Sha256 bsn1 - static const std::vector kSigGrpXVerRevokedMember3Sha256Bsn1Msg0; - /// signature of msg0 by member1 of groupX with Sha256 bsn0 - static const std::vector kSigGrpXMember1Sha256Bsn0Msg0; - - ///////////////////////////////////////////////////////////////////// - // EpidVerify Signature Based Revocation List Reject - /// GroupPubKey to be used for EpidVerify Signature Based Revocation List - /// Reject tests - static const GroupPubKey pub_key_sigrl_verify; - /// SigRl with 1 entry - static const std::vector sigrl_single_entry; - /// SigRl with 1 entry - static const std::vector sigrl_five_entries; - /// First entry in sigrl_five_entries - static const EpidSignature signature_sigrl_first; - /// Middle entry in sigrl_five_entries - static const EpidSignature signature_sigrl_middle; - /// Last entry in sigrl_five_entries - static const EpidSignature signature_sigrl_last; - - /// setup called before each TEST_F starts - virtual void SetUp() {} - /// teardown called after each TEST_F finishes - virtual void TearDown() {} - - /// value "1" represented as an octstr constant - /*! - this value is used frequently to set 32 bit fields. describing as a constant - here - to reduce replication in code. - */ - static const OctStr32 octstr32_1; -}; - -#endif // EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verify-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verify-test.cc deleted file mode 100644 index e16ddfaeb7..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verify-test.cc +++ /dev/null @@ -1,1143 +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 Verify unit tests. - */ - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -#include "epid/common/endian_convert.h" -#include "epid/common/memory.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" - -namespace { - -///////////////////////////////////////////////////////////////////////// -// Simple Errors - -TEST_F(EpidVerifierTest, VerifyFailsGivenNullParameters) { - VerifierCtxObj verifier(this->kGrp01Key); - auto& sig = this->kSigGrp01Member0Sha256RandombaseTest0; - auto& msg = this->kTest0; - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(nullptr, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); - EXPECT_EQ(kEpidBadArgErr, EpidVerify(verifier, nullptr, sig.size(), - msg.data(), msg.size(), nullptr, 0)); - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - nullptr, msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyFailsGivenSigLenTooShortForRlCount) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidVerifierSetSigRl(verifier, (SigRl const*)this->kGrp01SigRl.data(), - this->kGrp01SigRl.size()); - auto sig = this->kSigGrp01Member0Sha256RandombaseTest0; - auto n2 = this->kGrp01SigRlN2; - sig.resize(sizeof(EpidSignature) + - (n2 - 2) * sizeof(((EpidSignature*)0)->sigma)); - auto& msg = this->kTest0; - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyFailsGivenSigLenTooLongForRlCount) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidVerifierSetSigRl(verifier, (SigRl const*)this->kGrp01SigRl.data(), - this->kGrp01SigRl.size()); - auto sig = this->kSigGrp01Member0Sha256RandombaseTest0; - auto n2 = this->kGrp01SigRlN2; - sig.resize(sizeof(EpidSignature) + n2 * sizeof(((EpidSignature*)0)->sigma)); - auto& msg = this->kTest0; - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -#if (SIZE_MAX <= 0xFFFFFFFF) // When size_t value is 32 bit or lower -TEST_F(EpidVerifierTest, VerifyFailsGivenRlCountTooBig) { - VerifierCtxObj verifier(this->kGrp01Key); - EpidVerifierSetSigRl(verifier, (SigRl const*)this->kGrp01SigRl.data(), - this->kGrp01SigRl.size()); - auto sig = this->kSigGrp01Member0Sha256RandombaseTest0; - uint32_t n2 = SIZE_MAX / sizeof(NrProof) + 1; - uint32_t n2_ = ntohl(n2); - EpidSignature* sig_struct = (EpidSignature*)sig.data(); - memcpy_S(&(sig_struct->n2), sizeof(sig_struct->n2), &n2_, sizeof(n2_)); - sig.resize(sizeof(EpidSignature) + (n2 - 1) * sizeof(NrProof)); - auto& msg = this->kTest0; - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} -#endif - -///////////////////////////////////////////////////////////////////// -// -// 4.1.2 step 1 - The verifier reads the pre-computed (e12, e22, e2w, eg12). -// Refer to Section 3.6 for the computation of these values. -// This Step is not testable - -///////////////////////////////////////////////////////////////////// -// Non-Revocation List Reject -// 4.1.2 step 2 - The verifier verifies the basic signature Sigma0 as -// follows: - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithBNotInG1) { - // * 4.1.2 step 2.a - The verifier verifies G1.inGroup(B) = true. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.B.x.data.data[31]++; - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithBIdentityOfG1) { - // * 4.1.2 step 2.b - The verifier verifies that G1.isIdentity(B) is false. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.B = this->G1_identity_str; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithDiffBaseNameSameHashAlg) { - // * 4.1.2 step 2.c - If bsn is provided, the verifier verifies - // B = G1.hash(bsn). - // result must be kEpidSigInvalid - auto& pub_key = this->kGrpXKey; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& msg = this->kMsg0; - auto& bsn = this->kBasename1; - - VerifierCtxObj verifier(pub_key); - - EXPECT_EQ(kEpidSigInvalid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithSameBaseNameDiffHashAlg) { - // * 4.1.2 step 2.c - If bsn is provided, the verifier verifies - // B = G1.hash(bsn). - // result must be kEpidSigInvalid - auto& pub_key = this->kGrpXKey; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - EXPECT_EQ(kEpidSigInvalid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithKNotInG1) { - // * 4.1.2 step 2.d - The verifier verifies G1.inGroup(K) = true. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.K.x.data.data[31]++; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithTNotInG1) { - // * 4.1.2 step 2.e - The verifier verifies G1.inGroup(T) = true. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.T.x.data.data[31]++; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithCNotInRange) { - // * 4.1.2 step 2.f - The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.c.data = this->params_str.p.data; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithSxNotInRange) { - // * 4.1.2 step 2.f - The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.sx.data = this->params_str.p.data; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithSfNotInRange) { - // * 4.1.2 step 2.f - The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.sf.data = this->params_str.p.data; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithSaNotInRange) { - // * 4.1.2 step 2.f - The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.sa.data = this->params_str.p.data; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigWithSbNotInRange) { - // * 4.1.2 step 2.f - The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - - EpidSignature sig = *( - const EpidSignature*)(this->kSigGrp01Member0Sha256RandombaseTest0.data()); - sig.sigma0.sb.data = this->params_str.p.data; - size_t size = this->kSigGrp01Member0Sha256RandombaseTest0.size(); - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, &sig, size, msg.data(), - msg.size(), nullptr, 0)); -} - -// 4.1.2 step 2.g - The verifier computes nc = (-c) mod p. -// This Step is not testable - -// 4.1.2 step 2.h - The verifier computes nsx = (-sx) mod p. -// This Step is not testable - -// 4.1.2 step 2.i - The verifier computes R1 = G1.multiExp(B, sf, K, nc). -// This Step is not testable - -// 4.1.2 step 2.j - The verifier computes t1 = G2.multiExp(g2, nsx, w, nc). -// This Step is not testable - -// 4.1.2 step 2.k - The verifier computes R2 = pairing(T, t1). -// This Step is not testable - -// 4.1.2 step 2.l - The verifier compute t2 = GT.multiExp(e12, sf, e22, sb, -// e2w, sa, eg12, c). -// This Step is not testable - -// 4.1.2 step 2.m - The verifier compute R2 = GT.mul(R2, t2). -// This Step is not testable - -// 4.1.2 step 2.n - The verifier compute t3 = Fp.hash(p || g1 || g2 || h1 -// || h2 || w || B || K || T || R1 || R2). -// Refer to Section 7.1 for hash operation over a prime -// field. -// This Step is not testable - -TEST_F(EpidVerifierTest, VerifyRejectsSigDifferingOnlyInMsg) { - // * 4.1.2 step 2.o - The verifier verifies c = Fp.hash(t3 || m). - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& sig = this->kSigGrp01Member0Sha256RandombaseTest0; - - auto msg = this->kTest0; - msg[0]++; - EXPECT_EQ(kEpidSigInvalid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigDifferingOnlyInBaseName) { - // * 4.1.2 step 2.o - The verifier verifies c = Fp.hash(t3 || m). - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - - // copy sig data to a local buffer - auto sig_data = this->kSigGrpXMember0Sha256Bsn0Msg0; - EpidSignature* sig = (EpidSignature*)sig_data.data(); - // simulate change to basename - sig->sigma0.B.x.data.data[0] += 1; - auto msg = this->kTest1; - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, sig, sig_data.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigDifferingOnlyInGroup) { - // * 4.1.2 step 2.o - The verifier verifies c = Fp.hash(t3 || m). - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - - // copy sig data to a local buffer - auto sig_data = this->kSigGrpXMember0Sha256Bsn0Msg0; - EpidSignature* sig = (EpidSignature*)sig_data.data(); - // simulate change to h1 - sig->sigma0.T.x.data.data[0] += 1; - auto msg = this->kTest1; - EXPECT_EQ(kEpidSigInvalid, EpidVerify(verifier, sig, sig_data.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigDifferingOnlyInHashAlg) { - // * 4.1.2 step 2.o - The verifier verifies c = Fp.hash(t3 || m). - // result must be kEpidSigInvalid - VerifierCtxObj verifier(this->kGrp01Key); - auto& msg = this->kTest0; - auto& sig = this->kSigGrp01Member0Sha256RandombaseTest0; - - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - EXPECT_EQ(kEpidSigInvalid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -// 4.1.2 step 2.p - If any of the above verifications fails, the verifier -// aborts and outputs 1. -// This Step is an aggregate of the above steps - -///////////////////////////////////////////////////////////////////// -// Group Based Revocation List Reject -// 4.1.2 step 3 - If GroupRL is provided - -TEST_F(EpidVerifierTest, VerifyRejectsFromGroupRlSingleEntry) { - // * 4.1.2 step 3.a - The verifier verifies that gid does not match any entry - // in GroupRL. - // result must be kEpidSigRevokedinGroupRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRlRevokedGrpXOnlyEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinGroupRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsFromGroupRlFirstEntry) { - // * 4.1.2 step 3.a - The verifier verifies that gid does not match any entry - // in GroupRL. - // result must be kEpidSigRevokedinGroupRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRlRevokedGrpXFirstEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinGroupRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsFromGroupRlFirstEntryUsingIkgfData) { - // result must be kEpidSigRevokedinGroupRl - auto& pub_key = this->pub_key_rev_group_ikgf_str; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRlIkgf; - auto& sig = this->kRevGroupSigMember0Sha256Bsn0Msg0Ikgf; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinGroupRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsFromGroupRlMiddleEntry) { - // * 4.1.2 step 3.a - The verifier verifies that gid does not match any entry - // in GroupRL. - // result must be kEpidSigRevokedinGroupRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRlRevokedGrpXMiddleEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinGroupRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsFromGroupRlLastEntry) { - // * 4.1.2 step 3.a - The verifier verifies that gid does not match any entry - // in GroupRL. - // result must be kEpidSigRevokedinGroupRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRlRevokedGrpXLastEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinGroupRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -// 4.1.2 step 3.b - If gid matches an entry in GroupRL, aborts and returns 2. -// This Step is an aggregate of the above steps - -///////////////////////////////////////////////////////////////////// -// Private Based Revocation List Reject -// 4.1.2 step 4 - If PrivRL is provided - -// * 4.1.2 step 4.a - The verifier verifies that gid in the public key and in -// PrivRL match. If mismatch, abort and return -// "operation failed". -// Not possible, checked in EpidVerifierSetPrivRl - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromPrivRlSingleEntry) { - // * 4.1.2 step 4.b - For i = 0, ?, n1-1, - // the verifier computes t4 =G1.exp(B, f[i]) - // and verifies that G1.isEqual(t4, K) = false. - // A faster private-key revocation check algorithm is - // provided in Section 4.5. - // result must be kEpidSigRevokedinPrivRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& priv_rl = this->kGrpXPrivRlRevokedPrivKey000OnlyEntry; - auto& sig = this->kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromPrivRlFirstEntry) { - // * 4.1.2 step 4.b - For i = 0, ?, n1-1, - // the verifier computes t4 =G1.exp(B, f[i]) - // and verifies that G1.isEqual(t4, K) = false. - // A faster private-key revocation check algorithm is - // provided in Section 4.5. - // result must be kEpidSigRevokedinPrivRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig = this->kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromPrivRlFirstEntryUsingIkgfData) { - // * 4.1.2 step 4.b - For i = 0, ?, n1-1, - // the verifier computes t4 =G1.exp(B, f[i]) - // and verifies that G1.isEqual(t4, K) = false. - // A faster private-key revocation check algorithm is - // provided in Section 4.5. - // result must be kEpidSigRevokedinPrivRl - auto& pub_key = this->pub_key_ikgf_str; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& priv_rl = this->kPrivRlIkgf; - auto& sig = this->kSigRevokedPrivKeySha256Bsn0Msg0Ikgf; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromPrivRlMiddleEntry) { - // * 4.1.2 step 4.b - For i = 0, ?, n1-1, - // the verifier computes t4 =G1.exp(B, f[i]) - // and verifies that G1.isEqual(t4, K) = false. - // A faster private-key revocation check algorithm is - // provided in Section 4.5. - // result must be kEpidSigRevokedinPrivRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig = this->kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromPrivRlLastEntry) { - // * 4.1.2 step 4.b - For i = 0, ?, n1-1, - // the verifier computes t4 =G1.exp(B, f[i]) - // and verifies that G1.isEqual(t4, K) = false. - // A faster private-key revocation check algorithm is - // provided in Section 4.5. - // result must be kEpidSigRevokedinPrivRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig = this->kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinPrivRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -// 4.1.2 step 4.c - If the above step fails, the verifier aborts and -// output 3. -// This Step is an aggregate of the above steps - -///////////////////////////////////////////////////////////////////// -// Signature Based Revocation List Reject -// 4.1.2 step 5 - If SigRL is provided - -// * 4.1.2 step 5.a - The verifier verifies that gid in the public key and in -// SigRL match. If mismatch, abort and return -// "operation failed". -// Not possible, checked in EpidVerifierSetSigRl - -TEST_F(EpidVerifierTest, VerifyFailsOnSigRlverNotMatchSigRlRlver) { - // * 4.1.2 step 5.b - The verifier verifies that RLver in Sigma and in SigRL - // match. If mismatch, abort and output "operation failed". - // result must be "operation failed" (not kEpidSig*) - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlVersion2; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyFailsOnSigN2NotMatchSigRlN2) { - // * 4.1.2 step 5.c - The verifier verifies that n2 in Sigma and in SigRL - // match. If mismatch, abort and output "operation failed". - // result must be "operation failed" (not kEpidSig*) - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlMember0Sha256Bsn0Msg0OnlyEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidBadArgErr, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromSigRlSingleEntry) { - // * 4.1.2 step 5.d - For i = 0, ..., n2-1, the verifier verifies - // nrVerify(B, K, B[i], K[i], Sigma[i]) = true. The details - // of nrVerify() will be given in the next subsection. - // result must be kEpidSigRevokedinSigRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlMember0Sha256Bsn0Msg0OnlyEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0SingleEntrySigRl; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromSigRlFirstEntry) { - // * 4.1.2 step 5.d - For i = 0, ..., n2-1, the verifier verifies - // nrVerify(B, K, B[i], K[i], Sigma[i]) = true. The details - // of nrVerify() will be given in the next subsection. - // result must be kEpidSigRevokedinSigRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromSigRlFirstEntryUsingIkgfData) { - auto& pub_key = this->pub_key_ikgf_str; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kSigRlIkgf; - auto& sig = this->kSigRevSigMember0Sha256Bsn0Msg0Ikgf; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromSigRlMiddleEntry) { - // * 4.1.2 step 5.d - For i = 0, ..., n2-1, the verifier verifies - // nrVerify(B, K, B[i], K[i], Sigma[i]) = true. The details - // of nrVerify() will be given in the next subsection. - // result must be kEpidSigRevokedinSigRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlMember0Sha256Bsn0Msg0MiddleEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromSigRlLastEntry) { - // * 4.1.2 step 5.d - For i = 0, ..., n2-1, the verifier verifies - // nrVerify(B, K, B[i], K[i], Sigma[i]) = true. The details - // of nrVerify() will be given in the next subsection. - // result must be kEpidSigRevokedinSigRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& sig_rl = this->kGrpXSigRlMember0Sha256Bsn0Msg0LastEntry; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinSigRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -// 4.1.2 step 5.e - If the above step fails, the verifier aborts and -// output 4. -// This Step is an aggregate of the above steps - -///////////////////////////////////////////////////////////////////// -// Verifier Based Revocation List Reject -// 4.1.2 step 6 - If VerifierRL is provided - -// * 4.1.2 step 6.a - The verifier verifies that gid in the public key and in -// VerifierRL match. If mismatch, abort and return -// "operation failed". -// Not possible, checked in EpidVerifierSetVerifierRl - -TEST_F(EpidVerifierTest, - VerifyDoesNotRejectSigFromMemberIfBaseNameIsOnlyDiffInVerifierRl) { - // * 4.1.2 step 6.b - The verifier verifies that B in the signature and in - // VerifierRL match. If mismatch, go to step 7. - // result must be "operation failed" (not kEpidSig*) - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn1VerRl_012; - auto& sig = this->kSigGrpXVerRevokedMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromVerifierRlSingleEntry) { - // * 4.1.2 step 6.c - For i = 0, ..., n4-1, the verifier verifies that - // K != K[i]. - // result must be kEpidSigRevokedinVerifierRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRlSingleEntry; - auto& sig = this->kSigGrpXVerRevokedMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinVerifierRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromVerifierRlFirstEntry) { - // * 4.1.2 step 6.c - For i = 0, ..., n4-1, the verifier verifies that - // K != K[i]. - // result must be kEpidSigRevokedinVerifierRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXVerRevokedMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinVerifierRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromVerifierRlMiddleEntry) { - // * 4.1.2 step 6.c - For i = 0, ..., n4-1, the verifier verifies that - // K != K[i]. - // result must be kEpidSigRevokedinVerifierRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXVerRevokedMember1Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinVerifierRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyRejectsSigFromVerifierRlLastEntry) { - // * 4.1.2 step 6.c - For i = 0, ..., n4-1, the verifier verifies that - // K != K[i]. - // result must be kEpidSigRevokedinVerifierRl - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXVerRevokedMember2Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigRevokedinVerifierRl, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -// 4.1.2 step 6.d - If the above step fails, the verifier aborts and -// output 5 -// This Step is an aggregate of the above steps - -///////////////////////////////////////////////////////////////////// -// Accept -// 4.1.2 step 7 - If all the above verifications succeed, the verifier -// outputs 0 - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithBaseNameNoRlSha256) { - auto& pub_key = this->kGrpXKey; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithBaseNameAllRlSha256) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithRandomBaseNameNoRlSha256) { - auto& pub_key = this->kGrpXKey; - auto& sig = this->kSigGrpXMember0Sha256RandbaseMsg0; - auto& msg = this->kMsg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithRandomBaseNameAllRlSha256) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& sig = this->kSigGrpXMember0Sha256RandbaseMsg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, - VerifyAcceptsSigWithRandomBaseNameAllRlSha256UsingIkgfData) { - auto& pub_key = this->pub_key_ikgf_str; - auto& msg = this->kMsg0; - auto& grp_rl = this->kGrpRlIkgf; - auto& priv_rl = this->kPrivRlIkgf; - auto& sig_rl = this->kSigRlIkgf; - auto& sig = this->kSigMember0Sha256RandbaseMsg0Ikgf; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithBaseNameAllRlSha384) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXMember0Sha384Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha384)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithRandomBaseNameAllRlSha384) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& sig = this->kSigGrpXMember0Sha384RandbaseMsg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha384)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithBaseNameAllRlSha512) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXMember0Sha512Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, VerifyAcceptsSigWithRandomBaseNameAllRlSha512) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& sig = this->kSigGrpXMember0Sha512RandbaseMsg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, DISABLED_VerifyAcceptsSigWithBaseNameAllRlSha512256) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& bsn = this->kBsn0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& ver_rl = this->kGrpXBsn0VerRl; - auto& sig = this->kSigGrpXMember0Sha512256Bsn0Msg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512_256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetVerifierRl( - verifier, (VerifierRl const*)ver_rl.data(), ver_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), bsn.data(), bsn.size())); -} - -TEST_F(EpidVerifierTest, - DISABLED_VerifyAcceptsSigWithRandomBaseNameAllRlSha512256) { - auto& pub_key = this->kGrpXKey; - auto& msg = this->kMsg0; - auto& grp_rl = this->kGrpRl; - auto& priv_rl = this->kGrpXPrivRl; - auto& sig_rl = this->kGrpXSigRl; - auto& sig = this->kSigGrpXMember0Sha512256RandbaseMsg0; - - VerifierCtxObj verifier(pub_key); - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512_256)); - THROW_ON_EPIDERR(EpidVerifierSetGroupRl( - verifier, (GroupRl const*)grp_rl.data(), grp_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetPrivRl( - verifier, (PrivRl const*)priv_rl.data(), priv_rl.size())); - THROW_ON_EPIDERR(EpidVerifierSetSigRl(verifier, (SigRl const*)sig_rl.data(), - sig_rl.size())); - - EXPECT_EQ(kEpidSigValid, - EpidVerify(verifier, (EpidSignature const*)sig.data(), sig.size(), - msg.data(), msg.size(), nullptr, 0)); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifybasic-test.cc b/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifybasic-test.cc deleted file mode 100644 index eac2542399..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/unittests/verifybasic-test.cc +++ /dev/null @@ -1,161 +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 VerifyBasicSig unit tests. - */ - -#include -#include - -#include "gtest/gtest.h" - -extern "C" { -#include "epid/verifier/api.h" -} - -#include "epid/verifier/unittests/verifier-testhelper.h" -#include "epid/common-testhelper/verifier_wrapper-testhelper.h" -#include "epid/common-testhelper/errors-testhelper.h" - -namespace { - -TEST_F(EpidVerifierTest, VerifyBasicSigFailsGivenNullPtr) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - - EXPECT_EQ(kEpidBadArgErr, EpidVerifyBasicSig(nullptr, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifyBasicSig(verifier, nullptr, msg.data(), - msg.size(), nullptr, 0)); - EXPECT_EQ(kEpidBadArgErr, EpidVerifyBasicSig(verifier, &basic_sig, nullptr, - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigFailsGivenIncorrectLegth) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - - EXPECT_EQ(kEpidBadArgErr, EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), - msg.size(), nullptr, 1)); -} - -TEST_F(EpidVerifierTest, - VerifyBasicSigCanVerifyValidSignatureWithSHA512AsDefault) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha512RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigCanVerifyValidSignatureWithSHA256) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigCanVerifyValidSignatureWithSHA384) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha384RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha384)); - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigCanVerifyValidSignatureWithSHA512) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha512RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha512)); - EXPECT_EQ(kEpidNoErr, EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), - msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, - VerifyBasicSigDetectsInvalidSignatureGivenMatchingMessage) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - BasicSignature corrupted_basic_sig = basic_sig; - corrupted_basic_sig.B.x.data.data[0]++; - EXPECT_NE(kEpidNoErr, EpidVerifyBasicSig(verifier, &corrupted_basic_sig, - msg.data(), msg.size(), nullptr, 0)); -} - -TEST_F(EpidVerifierTest, - VerifyBasicSigDetectsInvalidSignatureGivenMessageMismatch) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256RandombaseTest1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto msg = this->kTest1; - msg[0]++; // change message for signature verification to fail - EXPECT_EQ(kEpidSigInvalid, - EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), msg.size(), - nullptr, 0)); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigCanVerifyWithBasename) { - VerifierCtxObj verifier(this->kGrp01Key); - auto const& sig = (EpidSignature const*)this - ->kSigGrp01Member0Sha256Basename1Test1NoSigRl.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - auto& basename = this->kBasename1; - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidNoErr, - EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), msg.size(), - basename.data(), basename.size())); -} - -TEST_F(EpidVerifierTest, VerifyBasicSigCanVerifyWithBasenameUsingIkgfData) { - VerifierCtxObj verifier(this->pub_key_ikgf_str); - auto const& sig = - (EpidSignature const*)this->kSigSha256Basename1Test1NoSigRlIkgf.data(); - const BasicSignature basic_sig = sig->sigma0; - auto& msg = this->kTest1; - auto& basename = this->kBasename1; - THROW_ON_EPIDERR(EpidVerifierSetHashAlg(verifier, kSha256)); - EXPECT_EQ(kEpidNoErr, - EpidVerifyBasicSig(verifier, &basic_sig, msg.data(), msg.size(), - basename.data(), basename.size())); -} - -} // namespace diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifier.parts b/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifier.parts deleted file mode 100644 index 4027ed36ce..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifier.parts +++ /dev/null @@ -1,91 +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('verifier') - -api_headers = Pattern(src_dir='.', - includes=['api.h'], - excludes=[''], - recursive=False).files() - -verifier_headers = Pattern(src_dir='.', - includes=['*.h'], - excludes=['api.h'], - recursive=False).files() - - -src_files = Pattern(src_dir='.', - includes=['*.c'], - excludes=['*-test.cc'], - recursive=True).files() - - -#unit tests -utest_files = Pattern(src_dir='.', - includes=['*-test.cc', '*-testhelper.cc'], - excludes=[], - recursive=True).files() -utest_include_files = Pattern(src_dir='.', - includes=['*-testhelper.h'], - excludes=[], - recursive=True).files() -utest_data_files = Pattern(src_dir='unittests/testdata/sigrl', - includes=['*.inc'], - excludes=[], - recursive=False).files() -parts_file = ['verifier.parts'] - -if 'install_package' in env['MODE']: - env.InstallTopLevel(api_headers + verifier_headers, - sub_dir='epid/${PART_SHORT_NAME}') - env.InstallTopLevel(src_files, sub_dir='epid/${PART_SHORT_NAME}') - env.InstallTopLevel(utest_files + utest_include_files, - sub_dir='epid/${PART_SHORT_NAME}/unittests') - env.InstallTopLevel( - utest_data_files, - sub_dir='epid/${PART_SHORT_NAME}/unittests/testdata/sigrl') - 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) - env.SdkInclude(api_headers, sub_dir='epid/${PART_SHORT_NAME}') - - if 'install_lib' in env['MODE']: - env.InstallLib(outputs) - env.InstallInclude(api_headers, sub_dir='${PART_SHORT_NAME}') - - 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') or - env.isConfigBasedOn('static_crt_debug')), - depends=[Component('gtest'), - Component('common-testhelper'), - Component('verifier')], - INSTALL_BIN='${INSTALL_TEST_BIN}') diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verify.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/verify.c deleted file mode 100644 index b566718970..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verify.c +++ /dev/null @@ -1,204 +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 Verify implementation. - */ -#include -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" -#include "epid/common/endian_convert.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -static size_t EpidGetSignatureRlCount(EpidSignature const* sig) { - if (!sig) - return 0; - else - return ntohl(sig->n2); -} - -static size_t EpidGetGroupRlCount(GroupRl const* rl) { - if (!rl) - return 0; - else - return ntohl(rl->n3); -} - -static size_t EpidGetPrivRlCount(PrivRl const* rl) { - if (!rl) - return 0; - else - return ntohl(rl->n1); -} - -static size_t EpidGetSigRlCount(SigRl const* rl) { - if (!rl) - return 0; - else - return ntohl(rl->n2); -} - -static size_t EpidGetVerifierRlCount(VerifierRl const* rl) { - if (!rl) - return 0; - else - return ntohl(rl->n4); -} - -// implements section 4.1.2 "Verify algorithm" from Intel(R) EPID 2.0 Spec -EpidStatus EpidVerify(VerifierCtx const* ctx, EpidSignature const* sig, - size_t sig_len, void const* msg, size_t msg_len, - void const* basename, size_t basename_len) { - // Step 1. Setup - size_t const sig_header_len = (sizeof(EpidSignature) - sizeof(NrProof)); - EpidStatus sts = kEpidErr; - size_t rl_count = 0; - size_t i; - if (!ctx || !sig) { - return kEpidBadArgErr; - } - if (!msg && (0 != msg_len)) { - // if message is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!basename && (0 != basename_len)) { - // if basename is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!ctx->epid2_params || !ctx->pub_key) { - return kEpidBadArgErr; - } - if (sig_len < sig_header_len) { - return kEpidBadArgErr; - } - rl_count = EpidGetSignatureRlCount(sig); - if (rl_count > (SIZE_MAX - sig_header_len) / sizeof(sig->sigma[0]) || - (rl_count * sizeof(sig->sigma[0])) + sig_header_len != sig_len) { - return kEpidBadArgErr; - } - // Step 2. The verifier verifies the basic signature Sigma0 as follows: - sts = EpidVerifyBasicSig(ctx, &sig->sigma0, msg, msg_len, basename, - basename_len); - if (sts != kEpidNoErr) { - // p. If any of the above verifications fails, the verifier aborts and - // outputs 1 - return kEpidSigInvalid; - } - - // Step 3. If GroupRL is provided, - if (ctx->group_rl) { - // a. The verifier verifies that gid does not match any entry in GroupRL. - size_t grouprl_count = EpidGetGroupRlCount(ctx->group_rl); - for (i = 0; i < grouprl_count; ++i) { - if (0 == memcmp(&ctx->pub_key->gid, &ctx->group_rl->gid[i], - sizeof(ctx->pub_key->gid))) { - // b. If gid matches an entry in GroupRL, aborts and returns 2. - return kEpidSigRevokedinGroupRl; - } - } - } - - // Step 4. If PrivRL is provided, - if (ctx->priv_rl) { - size_t privrl_count = EpidGetPrivRlCount(ctx->priv_rl); - // a. The verifier verifies that gid in the public key and in PrivRL match. - // If mismatch, abort and return "operation failed". - if (0 != memcmp(&ctx->pub_key->gid, &ctx->priv_rl->gid, - sizeof(ctx->pub_key->gid))) { - return kEpidBadArgErr; - } - // b. For i = 0, ..., n1-1, the verifier computes t4 =G1.exp(B, f[i]) and - // verifies that G1.isEqual(t4, K) = false. A faster private-key revocation - // check algorithm is provided in Section 4.5. - for (i = 0; i < privrl_count; ++i) { - sts = EpidCheckPrivRlEntry(ctx, &sig->sigma0, &ctx->priv_rl->f[i]); - if (sts != kEpidNoErr) { - // c. If the above step fails, the verifier aborts and output 3. - return kEpidSigRevokedinPrivRl; - } - } - } - - // Step 5. If SigRL is provided, - if (ctx->sig_rl) { - size_t sigrl_count = EpidGetSigRlCount(ctx->sig_rl); - // a. The verifier verifies that gid in the public key and in SigRL match. - // If mismatch, abort and return "operation failed". - if (0 != memcmp(&ctx->pub_key->gid, &ctx->sig_rl->gid, - sizeof(ctx->pub_key->gid))) { - return kEpidBadArgErr; - } - - // b. The verifier verifies that RLver in Sigma and in SigRL match. If - // mismatch, abort and output "operation failed". - if (0 != memcmp(&ctx->sig_rl->version, &sig->rl_ver, - sizeof(ctx->sig_rl->version))) { - return kEpidBadArgErr; - } - - // c. The verifier verifies that n2 in Sigma and in SigRL match. If - // mismatch, abort and output "operation failed". - if (sigrl_count != rl_count) { - return kEpidBadArgErr; - } - - // d. For i = 0, ..., n2-1, the verifier verifies nrVerify(B, K, B[i], - // K[i], Sigma[i]) = true. The details of nrVerify() will be given in the - // next subsection. - for (i = 0; i < sigrl_count; ++i) { - sts = EpidNrVerify(ctx, &sig->sigma0, msg, msg_len, &ctx->sig_rl->bk[i], - &sig->sigma[i]); - if (sts != kEpidNoErr) { - // e. If the above step fails, the verifier aborts and output 4. - return kEpidSigRevokedinSigRl; - } - } - } - - // Step 6. If VerifierRL is provided, - if (ctx->verifier_rl) { - // a. The verifier verifies that gid in the public key and in VerifierRL - // match. If mismatch, abort and return "operation failed". - if (0 != memcmp(&ctx->pub_key->gid, &ctx->verifier_rl->gid, - sizeof(ctx->pub_key->gid))) { - return kEpidBadArgErr; - } - - // b. The verifier verifies that B in the signature and in VerifierRL - // match. If mismatch, go to step 7. - if (0 == - memcmp(&ctx->verifier_rl->B, &sig->sigma0.B, sizeof(sig->sigma0.B))) { - size_t verifierrl_count = EpidGetVerifierRlCount(ctx->verifier_rl); - // c. For i = 0, ..., n4-1, the verifier verifies that K != K[i]. - for (i = 0; i < verifierrl_count; ++i) { - if (0 == memcmp(&ctx->verifier_rl->K[i], &sig->sigma0.K, - sizeof(sig->sigma0.K))) { - // d. If the above step fails, the verifier aborts and output 5. - return kEpidSigRevokedinVerifierRl; - } - } - } - } - - // Step 7. If all the above verifications succeed, the verifier outputs 0. - return kEpidSigValid; -} diff --git a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifybasic.c b/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifybasic.c deleted file mode 100644 index 7d0a00e742..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/epid/verifier/verifybasic.c +++ /dev/null @@ -1,323 +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 VerifyBasicSig implementation. - */ - -#include "epid/verifier/api.h" -#include "epid/verifier/context.h" -#include "epid/common/memory.h" - -/// Handle SDK Error with Break -#define BREAK_ON_EPID_ERROR(ret) \ - if (kEpidNoErr != (ret)) { \ - break; \ - } - -/// Count of elements in array -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -EpidStatus EpidVerifyBasicSig(VerifierCtx const* ctx, BasicSignature const* sig, - void const* msg, size_t msg_len, - void const* basename, size_t basename_len) { - EpidStatus res = kEpidNotImpl; - - EcPoint* B = NULL; - EcPoint* K = NULL; - EcPoint* T = NULL; - EcPoint* R1 = NULL; - EcPoint* t4 = NULL; - - EcPoint* t1 = NULL; - - FfElement* R2 = NULL; - FfElement* t2 = NULL; - - FfElement* c = NULL; - FfElement* sx = NULL; - FfElement* sf = NULL; - FfElement* sa = NULL; - FfElement* sb = NULL; - FfElement* nc = NULL; - FfElement* nsx = NULL; - EcPoint* basename_hash = NULL; - FfElement* c_hash = NULL; - - if (!ctx || !sig) return kEpidBadArgErr; - if (!msg && (0 != msg_len)) { - // if message is non-empty it must have both length and content - return kEpidBadArgErr; - } - if (!basename && (0 != basename_len)) return kEpidBadArgErr; - if (!ctx->epid2_params || !ctx->pub_key) return kEpidBadArgErr; - - do { - bool cmp_result = false; - BigNumStr c_str = {0}; - BigNumStr sf_str = {0}; - BigNumStr nc_str = {0}; - BigNumStr nsx_str = {0}; - BigNumStr sb_str = {0}; - BigNumStr sa_str = {0}; - // handy shorthands: - EcGroup* G1 = ctx->epid2_params->G1; - EcGroup* G2 = ctx->epid2_params->G2; - FiniteField* GT = ctx->epid2_params->GT; - FiniteField* Fp = ctx->epid2_params->Fp; - EcPoint* g1 = ctx->epid2_params->g1; - EcPoint* g2 = ctx->epid2_params->g2; - EcPoint* w = ctx->pub_key->w; - CommitValues commit_values = ctx->commit_values; - - if (!G1 || !G2 || !GT || !Fp || !g1 || !g2 || !w) { - res = kEpidBadArgErr; - BREAK_ON_EPID_ERROR(res); - } - - // The following variables B, K, T, R1, t4 (elements of G1), t1 - // (element of G2), R2, t2 (elements of GT), c, sx, sf, sa, sb, - // nc, nsx, t3 (256-bit integers) are used. - res = NewEcPoint(G1, &B); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &K); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &T); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &R1); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &t4); - BREAK_ON_EPID_ERROR(res); - - res = NewEcPoint(G2, &t1); - BREAK_ON_EPID_ERROR(res); - - res = NewFfElement(GT, &R2); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(GT, &t2); - BREAK_ON_EPID_ERROR(res); - - res = NewFfElement(Fp, &c); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &sx); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &sf); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &sa); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &sb); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &nc); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &nsx); - BREAK_ON_EPID_ERROR(res); - res = NewEcPoint(G1, &basename_hash); - BREAK_ON_EPID_ERROR(res); - res = NewFfElement(Fp, &c_hash); - BREAK_ON_EPID_ERROR(res); - - // 1. The verifier expect pre-computation is done (e12, e22, e2w, - // eg12). Refer to Section 3.6 for the computation of these - // values. - - // 2. The verifier verifies the basic signature sigma0 as follows: - // a. The verifier verifies G1.inGroup(B) = true. - res = ReadEcPoint(G1, &(sig->B), sizeof(sig->B), B); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - // b. The verifier verifies that G1.isIdentity(B) is false. - res = EcIsIdentity(G1, B, &cmp_result); - BREAK_ON_EPID_ERROR(res); - if (cmp_result != false) { - res = kEpidSigInvalid; - break; - } - // c. If bsn is provided, the verifier verifies B = - // G1.hash(bsn). - if (basename && basename_len > 0) { - res = EcHash(G1, basename, basename_len, ctx->hash_alg, basename_hash); - BREAK_ON_EPID_ERROR(res); - res = EcIsEqual(G1, basename_hash, B, &cmp_result); - BREAK_ON_EPID_ERROR(res); - if (cmp_result != true) { - res = kEpidSigInvalid; - break; - } - } - // d. The verifier verifies G1.inGroup(K) = true. - res = ReadEcPoint(G1, &(sig->K), sizeof(sig->K), K); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - // e. The verifier verifies G1.inGroup(T) = true. - res = ReadEcPoint(G1, &(sig->T), sizeof(sig->T), T); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - // f. The verifier verifies c, sx, sf, sa, sb in [0, p-1]. - res = ReadFfElement(Fp, &(sig->c), sizeof(sig->c), c); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - res = WriteFfElement(Fp, c, &c_str, sizeof(c_str)); - BREAK_ON_EPID_ERROR(res); - res = ReadFfElement(Fp, &(sig->sx), sizeof(sig->sx), sx); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - res = ReadFfElement(Fp, &(sig->sf), sizeof(sig->sf), sf); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - res = ReadFfElement(Fp, &(sig->sa), sizeof(sig->sa), sa); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - res = ReadFfElement(Fp, &(sig->sb), sizeof(sig->sb), sb); - if (kEpidNoErr != res) { - if (kEpidBadArgErr == res) { - res = kEpidSigInvalid; - } - break; - } - // g. The verifier computes nc = (-c) mod p. - res = FfNeg(Fp, c, nc); - BREAK_ON_EPID_ERROR(res); - // h. The verifier computes nsx = (-sx) mod p. - res = FfNeg(Fp, sx, nsx); - BREAK_ON_EPID_ERROR(res); - // i. The verifier computes R1 = G1.multiExp(B, sf, K, nc). - res = WriteFfElement(Fp, sf, &sf_str, sizeof(sf_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, nc, &nc_str, sizeof(nc_str)); - BREAK_ON_EPID_ERROR(res); - { - EcPoint const* points[2]; - BigNumStr const* exponents[2]; - points[0] = B; - points[1] = K; - exponents[0] = &sf_str; - exponents[1] = &nc_str; - res = EcMultiExp(G1, points, exponents, COUNT_OF(points), R1); - BREAK_ON_EPID_ERROR(res); - } - // j. The verifier computes t1 = G2.multiExp(g2, nsx, w, nc). - res = WriteFfElement(Fp, nsx, &nsx_str, sizeof(nsx_str)); - BREAK_ON_EPID_ERROR(res); - { - EcPoint const* points[2]; - BigNumStr const* exponents[2]; - points[0] = g2; - points[1] = w; - exponents[0] = &nsx_str; - exponents[1] = &nc_str; - res = EcMultiExp(G2, points, exponents, COUNT_OF(points), t1); - BREAK_ON_EPID_ERROR(res); - } - // k. The verifier computes R2 = pairing(T, t1). - res = Pairing(ctx->epid2_params->pairing_state, R2, T, t1); - BREAK_ON_EPID_ERROR(res); - // l. The verifier compute t2 = GT.multiExp(e12, sf, e22, sb, - // e2w, sa, eg12, c). - res = WriteFfElement(Fp, sb, &sb_str, sizeof(sb_str)); - BREAK_ON_EPID_ERROR(res); - res = WriteFfElement(Fp, sa, &sa_str, sizeof(sa_str)); - BREAK_ON_EPID_ERROR(res); - { - FfElement const* points[4]; - BigNumStr const* exponents[4]; - points[0] = ctx->e12; - points[1] = ctx->e22; - points[2] = ctx->e2w; - points[3] = ctx->eg12; - exponents[0] = &sf_str; - exponents[1] = &sb_str; - exponents[2] = &sa_str; - exponents[3] = &c_str; - res = FfMultiExp(GT, points, exponents, COUNT_OF(points), t2); - BREAK_ON_EPID_ERROR(res); - } - // m. The verifier compute R2 = GT.mul(R2, t2). - res = FfMul(GT, R2, t2, R2); - BREAK_ON_EPID_ERROR(res); - // n. The verifier compute t3 = Fp.hash(p || g1 || g2 || h1 || - // h2 || w || B || K || T || R1 || R2). - // o. The verifier verifies c = Fp.hash(t3 || m). - res = SetCalculatedCommitValues(&sig->B, &sig->K, &sig->T, R1, G1, R2, GT, - &commit_values); - BREAK_ON_EPID_ERROR(res); - res = CalculateCommitmentHash(&commit_values, Fp, ctx->hash_alg, msg, - msg_len, c_hash); - BREAK_ON_EPID_ERROR(res); - - res = FfIsEqual(Fp, c, c_hash, &cmp_result); - BREAK_ON_EPID_ERROR(res); - if (cmp_result != true) { - // p. If any of the above verifications fails, the verifier - // aborts and outputs 1. - res = kEpidSigInvalid; - break; - } - - res = kEpidNoErr; - } while (0); - - DeleteEcPoint(&B); - DeleteEcPoint(&K); - DeleteEcPoint(&T); - DeleteEcPoint(&R1); - DeleteEcPoint(&t4); - - DeleteEcPoint(&t1); - - DeleteFfElement(&R2); - DeleteFfElement(&t2); - - DeleteFfElement(&c); - DeleteFfElement(&sx); - DeleteFfElement(&sf); - DeleteFfElement(&sa); - DeleteFfElement(&sb); - DeleteFfElement(&nc); - DeleteFfElement(&nsx); - DeleteEcPoint(&basename_hash); - DeleteFfElement(&c_hash); - - return (res); -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/README.md b/sgx-jvm/linux-sgx/external/epid/example/data/README.md deleted file mode 100644 index 6e2bc05407..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/data/README.md +++ /dev/null @@ -1,161 +0,0 @@ -# Sample Issuer Material - -This folder contains sample issuer material for use with the Intel(R) -EPID SDK. All data files are in binary format. - -## Directory Structure - - data - |__ groupa - | |__ member0 - | | |__ mprivkey.dat - | | - | |__ member1 - | | |__ mprivkey.dat - | | - | |__ privrevokedmember0 - | | |__ mprivkey.dat - | | - | |__ privrevokedmember1 - | | |__ mprivkey.dat - | | - | |__ privrevokedmember2 - | | |__ mprivkey.dat - | | - | |__ sigrevokedmember0 - | | |__ mprivkey.dat - | | - | |__ sigrevokedmember1 - | | |__ mprivkey.dat - | | - | |__ sigrevokedmember2 - | | |__ mprivkey.dat - | | - | |__ privrl.bin - | |__ pubkey.bin - | |__ sigrl.bin - | - |__ groupb - | |__ member0 - | | |__ mprivkey.dat - | | - | |__ member1 - | | |__ mprivkey.dat - | | - | |__ privrevokedmember0 - | | |__ mprivkey.dat - | | - | |__ sigrevokedmember0 - | | |__ mprivkey.dat - | | - | |__ privrl.bin - | |__ pubkey.bin - | |__ sigrl.bin - | - |__ grprl.bin - |__ grprl_empty.bin - |__ mprivkey.dat - |__ pubkey.bin - |__ cacert.bin - - -## Description - -There are 2 groups - -- **groupa** - -- **groupb** - - -_Note: No compressed key sample material is included in the package._ - -### Group A - -**groupa** contains 8 members. Each member has a member private key -`mprivkey.dat`. Here are the members: - -- **member0** - a member in good standing - -- **member1** - a member in good standing - -- **privrevokedmember0** - a member revoked using its private key - -- **privrevokedmember1** - a member revoked using its private key - -- **privrevokedmember2** - a member revoked using its private key - -- **sigrevokedmember0** - a member revoked using a signature - -- **sigrevokedmember1** - a member revoked using a signature - -- **sigrevokedmember2** - a member revoked using a signature - - -In addition, **groupa** contain the following revocation lists: - -- `pubkey.bin` - group public key - -- `privrl.bin` - private key based revocation list with 3 entries - - **privrevokedmember0**, **privrevokedmember1** and - **privrevokedmember2** - -- `sigrl.bin` - signature based revocation list with 3 entries - - **sigrevokedmember0**, **sigrevokedmember2** and - **sigrevokedmember2** - - -### Group B - -**groupb** contains 3 members. Each member has a member private key -`mprivkey.dat`. Here are the members: - -- **member0** - a member in good standing - -- **privrevokedmember0** - a member whose private key is revoked - -- **sigrevokedmember0** - a member whose signature is revoked - - -In addition, **groupb** contain the following revocation lists: - -- `pubkey.bin` - group public key - -- `privrl.bin` - private key based revocation list with 1 entry - - **privrevokedmember0** - -- `sigrl.bin` - signature based revocation list with 1 entries - - **sigrevokedmember0** - - -### Default files - -- `/data/cacert.bin` - CA certificate used as default input to signmsg - and verifysig - -- `/data/grprl.bin` - group revocation list with one entry **groupb** used - as default input to verifysig - -- `/data/pubkey.bin` - public key of a group A used as default input - to signmsg and verifysig - -- `/data/mprivkey.dat` - private key of a member0 in the group A above - used as default input to signmsg - - -### Group revocation lists - -There are 2 group revocation lists: - -- `grprl.bin` - group revocation list with 1 entry - **groupb** - -- `grprl_empty.bin` - group revocation list with 0 entry - - -### IoT EPID Issuing CA certificate - -- `/data/cacert.bin` - CA certificate used to check that revocation - lists and group public keys are authorized by the issuer, e.g., - signed by the issuer - - diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/cacert.bin b/sgx-jvm/linux-sgx/external/epid/example/data/cacert.bin deleted file mode 100644 index fcbcc1f674..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/cacert.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/data.parts b/sgx-jvm/linux-sgx/external/epid/example/data/data.parts deleted file mode 100644 index bcf32b1a3e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/data/data.parts +++ /dev/null @@ -1,70 +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('*') - -# Normal stuff that all Parts should have -env.PartName("sample_data") - -#files -data_files = Pattern(src_dir='../data', - includes=[ - 'cacert.bin', - 'grprl.bin', - 'grprl_empty.bin', - 'README.md', - 'groupa/privrl.bin', - 'groupa/pubkey.bin', - 'groupa/sigrl.bin', - 'groupa/member0/mprivkey.dat', - 'groupa/member1/mprivkey.dat', - 'groupa/privrevokedmember0/mprivkey.dat', - 'groupa/privrevokedmember1/mprivkey.dat', - 'groupa/privrevokedmember2/mprivkey.dat', - 'groupa/sigrevokedmember0/mprivkey.dat', - 'groupa/sigrevokedmember1/mprivkey.dat', - 'groupa/sigrevokedmember2/mprivkey.dat', - 'groupb/privrl.bin', - 'groupb/pubkey.bin', - 'groupb/sigrl.bin', - 'groupb/member0/mprivkey.dat', - 'groupb/privrevokedmember0/mprivkey.dat', - 'groupb/sigrevokedmember0/mprivkey.dat', - ], - recursive=True) - -sample_default_files = Pattern(src_dir='../data', - includes=[ - 'cacert.bin', - 'grprl.bin', - 'mprivkey.dat', - 'pubkey.bin', - ], - recursive=True) - -if 'install_package' in env['MODE']: - env.InstallTopLevel(data_files, sub_dir='example/data') - env.InstallTopLevel(sample_default_files, sub_dir='example/data') - part_file = ['data.parts'] - env.InstallTopLevel(part_file, sub_dir='example/data') -else: - env.InstallData(data_files, - sub_dir='data', - no_pkg=False) - - env.InstallData(sample_default_files, - sub_dir='', - no_pkg=False) diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member0/mprivkey.dat deleted file mode 100644 index 8bf5d47249..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member1/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member1/mprivkey.dat deleted file mode 100644 index c11c0cafbb..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/member1/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember0/mprivkey.dat deleted file mode 100644 index bbb3bde5db..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember1/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember1/mprivkey.dat deleted file mode 100644 index b2694cdb4c..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember1/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember2/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember2/mprivkey.dat deleted file mode 100644 index 38a2eacced..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrevokedmember2/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrl.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrl.bin deleted file mode 100644 index e3bca59da8..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/privrl.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/pubkey.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/pubkey.bin deleted file mode 100644 index 5f766c81ef..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/pubkey.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember0/mprivkey.dat deleted file mode 100644 index c4c273cd48..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember1/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember1/mprivkey.dat deleted file mode 100644 index cdc7911d0a..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember1/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember2/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember2/mprivkey.dat deleted file mode 100644 index b5b9edee9f..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrevokedmember2/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrl.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrl.bin deleted file mode 100644 index bc9ef56f76..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupa/sigrl.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/member0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/member0/mprivkey.dat deleted file mode 100644 index faa4a6f31c..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/member0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrevokedmember0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrevokedmember0/mprivkey.dat deleted file mode 100644 index 0e5990a736..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrevokedmember0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrl.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrl.bin deleted file mode 100644 index 5ff658f3c0..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/privrl.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/pubkey.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/pubkey.bin deleted file mode 100644 index 0d0ba5210b..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/pubkey.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrevokedmember0/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrevokedmember0/mprivkey.dat deleted file mode 100644 index ef59eb25c3..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrevokedmember0/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrl.bin b/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrl.bin deleted file mode 100644 index b55ea33cff..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/groupb/sigrl.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/grprl.bin b/sgx-jvm/linux-sgx/external/epid/example/data/grprl.bin deleted file mode 100644 index 2774f2b253..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/grprl.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/grprl_empty.bin b/sgx-jvm/linux-sgx/external/epid/example/data/grprl_empty.bin deleted file mode 100644 index 14536dedcd..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/grprl_empty.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/mprivkey.dat b/sgx-jvm/linux-sgx/external/epid/example/data/mprivkey.dat deleted file mode 100644 index 8bf5d47249..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/mprivkey.dat and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/data/pubkey.bin b/sgx-jvm/linux-sgx/external/epid/example/data/pubkey.bin deleted file mode 100644 index 5f766c81ef..0000000000 Binary files a/sgx-jvm/linux-sgx/external/epid/example/data/pubkey.bin and /dev/null differ diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/signmsg.parts b/sgx-jvm/linux-sgx/external/epid/example/signmsg/signmsg.parts deleted file mode 100644 index 23efe4ad5c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/signmsg.parts +++ /dev/null @@ -1,51 +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('*') - -# Normal stuff that all Parts should have -env.PartName("signmsg") - -src_files = Pattern(src_dir='src/', - includes=['*.c'], - recursive=True).files() -inc_files = Pattern(src_dir='src/', - includes=['*.h'], - recursive=True).files() -parts_file = ['signmsg.parts'] - -if 'install_package' in env['MODE']: - env.InstallTopLevel(inc_files + src_files,sub_dir='example/${PART_SHORT_NAME}/src') - env.InstallTopLevel(parts_file, sub_dir='example/${PART_SHORT_NAME}') -else: - env.DependsOn([ - Component('member'), - Component('util') - ]) - - env.Append(CPPPATH='#/example/signmsg') - - if env['TARGET_PLATFORM']['OS'] == 'win32': - if env.isConfigBasedOn('debug'): - env['PDB'] = '${PART_NAME}.pdb' - - outputs = env.Program('${PART_NAME}', src_files, - no_import_lib=True) - - env.InstallBin(outputs, - no_pkg=False, - INSTALL_BIN='${INSTALL_SAMPLE_BIN}') - diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/main.c b/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/main.c deleted file mode 100644 index 96188176f3..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/main.c +++ /dev/null @@ -1,385 +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 Signmsg example implementation. - * - */ - -#include -#include -#include - -#include "util/argutil.h" -#include "util/buffutil.h" -#include "util/convutil.h" -#include "util/envutil.h" -#include "util/stdtypes.h" -#include "src/signmsg.h" - -// Defaults - -#define PROGRAM_NAME ("signmsg") -#define MPRIVKEYFILE_DEFAULT ("mprivkey.dat") -#define PUBKEYFILE_DEFAULT ("pubkey.bin") -#define SIGRL_DEFAULT (NULL) -#define SIG_DEFAULT ("sig.dat") -#define CACERT_DEFAULT ("cacert.bin") -#define HASHALG_DEFAULT ("SHA-512") -#define MPRECMPI_DEFAULT NULL -#define MPRECMPO_DEFAULT NULL - -/// Print usage message -void PrintUsage() { - log_fmt( - "Usage: %s [OPTION]...\n" - "Create Intel(R) EPID signature of message\n" - "\n" - "Options:\n" - "\n" - "--sig=FILE write signature to FILE (default: %s)\n" - "--msg=MESSAGE MESSAGE to sign\n" - "--bsn=BASENAME BASENAME to sign with (default: random)\n" - "--sigrl=FILE load signature based revocation list from FILE\n" - "--gpubkey=FILE load group public key from FILE\n" - " (default: %s)\n" - "--mprivkey=FILE load member private key from FILE\n" - " (default: %s)\n" - "--mprecmpi=FILE load pre-computed member data from FILE\n" - "--mprecmpo=FILE write pre-computed member data to FILE\n" - "--hashalg=NAME SHA-256 | SHA-384 | SHA-512 (default: %s)\n" - "--capubkey=FILE load IoT Issuing CA public key from FILE\n" - " (default: %s)\n" - "-h,--help display this help and exit\n" - "-v,--verbose print status messages to stdout\n" - "\n", - PROGRAM_NAME, SIG_DEFAULT, PUBKEYFILE_DEFAULT, MPRIVKEYFILE_DEFAULT, - HASHALG_DEFAULT, CACERT_DEFAULT); -} - -/// Main entrypoint -int main(int argc, char* argv[]) { - // intermediate return value for C style functions - int ret_value = EXIT_SUCCESS; - - // intermediate return value for EPID functions - EpidStatus result = kEpidErr; - - // Temp option pointer - char const* opt_str = 0; - - // User Settings - - // Signature file name parameter - char const* sig_file = SIG_DEFAULT; - - // Message string parameter - char const* msg_str = NULL; - size_t msg_size = 0; - - // Basename string parameter - char const* basename_str = NULL; - size_t basename_size = 0; - - // SigRl file name parameter - char const* sigrl_file = SIGRL_DEFAULT; - - // Group public key file name parameter - char const* pubkey_file = PUBKEYFILE_DEFAULT; - - // Member private key file name parameter - char const* mprivkey_file = MPRIVKEYFILE_DEFAULT; - - // Member pre-computed settings input file name parameter - char const* mprecmpi_file = MPRECMPI_DEFAULT; - - // Member pre-computed settings output file name parameter - char const* mprecmpo_file = MPRECMPO_DEFAULT; - - // Hash algorithm name parameter - char const* hashalg_str = HASHALG_DEFAULT; - - // CA certificate file name parameter - char const* cacert_file = CACERT_DEFAULT; - - // Verbose flag parameter - bool verbose = false; - - // Buffers and computed values - - // Signature buffer - EpidSignature* sig = NULL; - size_t sig_size = 0; - - // SigRl file - unsigned char* signed_sig_rl = NULL; - size_t signed_sig_rl_size = 0; - - // Group public key file - unsigned char* signed_pubkey = NULL; - size_t signed_pubkey_size = 0; - - // CA certificate - EpidCaCertificate cacert = {0}; - - // Member private key buffer - unsigned char* mprivkey = NULL; - size_t mprivkey_size = 0; - - // Member pre-computed settings - MemberPrecomp member_precmp = {0}; - - // Flag that Member pre-computed settings input is valid - bool use_precmp_in; - - // Hash algorithm - HashAlg hashalg; - - // set program name for logging - set_prog_name(PROGRAM_NAME); - do { - // Read command line args - - if (argc < 1) { - PrintUsage(); - ret_value = EXIT_FAILURE; - break; - } - - if (CmdOptionExists(argc, argv, "--help") || - CmdOptionExists(argc, argv, "-h")) { - PrintUsage(); - ret_value = EXIT_SUCCESS; - break; - } - - if (CmdOptionExists(argc, argv, "--verbose") || - CmdOptionExists(argc, argv, "-v")) { - verbose = ToggleVerbosity(); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--sig"))) { - sig_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--msg"))) { - msg_str = opt_str; - msg_size = strlen(msg_str); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--bsn"))) { - basename_str = opt_str; - basename_size = strlen(basename_str); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--sigrl"))) { - sigrl_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--gpubkey"))) { - pubkey_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--mprivkey"))) { - mprivkey_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--mprecmpi"))) { - mprecmpi_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--mprecmpo"))) { - mprecmpo_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--hashalg"))) { - hashalg_str = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--capubkey"))) { - cacert_file = opt_str; - } - - // convert command line args to usable formats - - // CA certificate - if (0 != ReadLoud(cacert_file, &cacert, sizeof(cacert))) { - ret_value = EXIT_FAILURE; - break; - } - // Security note: - // Application must confirm that IoT EPID Issuing CA certificate is - // authorized by IoT EPID Root CA, e.g., signed by IoT EPID Root CA. - if (!IsCaCertAuthorizedByRootCa(&cacert, sizeof(cacert))) { - log_error("CA certificate is not authorized"); - ret_value = EXIT_FAILURE; - break; - } - - // SigRl - if (FileExists(sigrl_file)) { - signed_sig_rl = NewBufferFromFile(sigrl_file, &signed_sig_rl_size); - if (!signed_sig_rl) { - ret_value = EXIT_FAILURE; - break; - } - - if (0 != ReadLoud(sigrl_file, signed_sig_rl, signed_sig_rl_size)) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Group public key file - signed_pubkey = NewBufferFromFile(pubkey_file, &signed_pubkey_size); - if (!signed_pubkey) { - ret_value = EXIT_FAILURE; - break; - } - if (0 != ReadLoud(pubkey_file, signed_pubkey, signed_pubkey_size)) { - ret_value = EXIT_FAILURE; - break; - } - - // Member private key - mprivkey = NewBufferFromFile(mprivkey_file, &mprivkey_size); - if (!mprivkey) { - ret_value = EXIT_FAILURE; - break; - } - if (mprivkey_size != sizeof(PrivKey) && - mprivkey_size != sizeof(CompressedPrivKey)) { - log_error("Private Key file size is inconsistent"); - ret_value = EXIT_FAILURE; - break; - } - - if (0 != ReadLoud(mprivkey_file, mprivkey, mprivkey_size)) { - ret_value = EXIT_FAILURE; - break; - } - - // Load Member pre-computed settings - use_precmp_in = false; - if (mprecmpi_file) { - if (sizeof(MemberPrecomp) != GetFileSize(mprecmpi_file)) { - log_error("incorrect input precomp size"); - ret_value = EXIT_FAILURE; - break; - } - use_precmp_in = true; - - if (0 != ReadLoud(mprecmpi_file, &member_precmp, sizeof(MemberPrecomp))) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Hash algorithm - if (!StringToHashAlg(hashalg_str, &hashalg)) { - ret_value = EXIT_FAILURE; - break; - } - - if (hashalg != kSha256 && hashalg != kSha384 && hashalg != kSha512) { - log_error("unsupported hash algorithm %s", HashAlgToString(hashalg)); - ret_value = EXIT_FAILURE; - break; - } - - // Report Settings - if (verbose) { - log_msg("=============================================="); - log_msg("Signing Message:"); - log_msg(""); - log_msg(" [in] Message Len: %d", (int)msg_size); - log_msg(" [in] Message: "); - PrintBuffer(msg_str, msg_size); - log_msg(""); - log_msg(" [in] BaseName Len: %d", (int)basename_size); - log_msg(" [in] BaseName: "); - PrintBuffer(basename_str, basename_size); - log_msg(""); - log_msg(" [in] SigRl Len: %d", (int)signed_sig_rl_size); - log_msg(" [in] SigRl: "); - PrintBuffer(signed_sig_rl, signed_sig_rl_size); - log_msg(""); - log_msg(" [in] Group Public Key: "); - PrintBuffer(signed_pubkey, signed_pubkey_size); - log_msg(""); - log_msg(" [in] Member Private Key: "); - PrintBuffer(&mprivkey, sizeof(mprivkey)); - log_msg(""); - log_msg(" [in] Hash Algorithm: %s", HashAlgToString(hashalg)); - log_msg(""); - log_msg(" [in] IoT EPID Issuing CA Certificate: "); - PrintBuffer(&cacert, sizeof(cacert)); - if (use_precmp_in) { - log_msg(""); - log_msg(" [in] Member PreComp: "); - PrintBuffer(&member_precmp, sizeof(member_precmp)); - } - log_msg("=============================================="); - } - - // Sign - result = SignMsg(msg_str, msg_size, basename_str, basename_size, - signed_sig_rl, signed_sig_rl_size, signed_pubkey, - signed_pubkey_size, mprivkey, mprivkey_size, hashalg, - &member_precmp, use_precmp_in, &sig, &sig_size, &cacert); - - // Report Result - if (kEpidNoErr != result) { - if (kEpidSigRevokedinSigRl == result) { - log_error("signature revoked in SigRL"); - } else { - log_error("function SignMsg returned %s", EpidStatusToString(result)); - ret_value = EXIT_FAILURE; - break; - } - } - - if (sig && sig_size != 0) { - // Store signature - if (0 != WriteLoud(sig, sig_size, sig_file)) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Store Member pre-computed settings - if (mprecmpo_file) { - if (0 != - WriteLoud(&member_precmp, sizeof(member_precmp), mprecmpo_file)) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Success - ret_value = EXIT_SUCCESS; - } while (0); - - // Free allocated buffers - if (sig) free(sig); - if (signed_sig_rl) free(signed_sig_rl); - if (signed_pubkey) free(signed_pubkey); - if (mprivkey) free(mprivkey); - - return ret_value; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.c b/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.c deleted file mode 100644 index e1da167f83..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.c +++ /dev/null @@ -1,98 +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 implementation. - */ -#include -#include -#include - -#include "src/prng.h" - -EpidStatus PrngCreate(void** prng) { - // Security note: - // Random number generator used in the samples not claimed to be a - // cryptographically secure pseudo-random number generator. - EpidStatus sts = kEpidErr; - int prng_ctx_size = 0; - IppsPRNGState* prng_ctx = NULL; - int seed_ctx_size = 0; - IppsBigNumState* seed_ctx = NULL; - time_t seed_value; - - if (!prng) return kEpidBadArgErr; - - if (ippStsNoErr != ippsPRNGGetSize(&prng_ctx_size)) return kEpidErr; - if (ippStsNoErr != - ippsBigNumGetSize((sizeof(seed_value) + 3) / 4, &seed_ctx_size)) - return kEpidErr; - - do { - prng_ctx = (IppsPRNGState*)calloc(1, prng_ctx_size); - - if (!prng_ctx) { - sts = kEpidNoMemErr; - break; - } - if (ippStsNoErr != ippsPRNGInit(sizeof(seed_value) * 8, prng_ctx)) { - sts = kEpidErr; - break; - } - - // seed PRNG - seed_ctx = (IppsBigNumState*)calloc(1, seed_ctx_size); - if (!seed_ctx) { - sts = kEpidNoMemErr; - break; - } - if (ippStsNoErr != ippsBigNumInit((sizeof(seed_value) + 3) / 4, seed_ctx)) { - sts = kEpidErr; - break; - } - time(&seed_value); - if (ippStsNoErr != - ippsSetOctString_BN((void*)&seed_value, sizeof(seed_value), seed_ctx)) { - sts = kEpidErr; - break; - } - if (ippStsNoErr != ippsPRNGSetSeed(seed_ctx, prng_ctx)) { - sts = kEpidErr; - break; - } - - *prng = prng_ctx; - prng_ctx = NULL; - sts = kEpidNoErr; - } while (0); - - if (seed_ctx) free(seed_ctx); - if (prng_ctx) free(prng_ctx); - return sts; -} - -void PrngDelete(void** prng) { - if (prng && *prng) { - free(*prng); - *prng = NULL; - } -} - -// simple wrapper to hide IPP implementation. -int __STDCALL PrngGen(unsigned int* rand_data, int num_bits, void* user_data) { - return ippsPRNGen(rand_data, num_bits, (IppsPRNGState*)user_data); -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.h b/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.h deleted file mode 100644 index a56051232e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/prng.h +++ /dev/null @@ -1,36 +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 EXAMPLE_SIGNMSG_SRC_PRNG_H_ -#define EXAMPLE_SIGNMSG_SRC_PRNG_H_ - -#include "epid/common/errors.h" - -/// Creates Pseudo Random Number Generator for ::PrngGen() -EpidStatus PrngCreate(void** prng); - -/// Delete object allocated with ::PrngCreate() -void PrngDelete(void** prng); - -/// BitSupplier type of function -int __STDCALL PrngGen(unsigned int* rand_data, int num_bits, void* user_data); - -#endif // EXAMPLE_SIGNMSG_SRC_PRNG_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.c b/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.c deleted file mode 100644 index cbb48466f1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.c +++ /dev/null @@ -1,171 +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 Message signing implementation. - */ -#include -#include -#include "src/signmsg.h" -#include "src/prng.h" -#include "util/envutil.h" -#include "util/stdtypes.h" -#include "util/buffutil.h" - -bool IsCaCertAuthorizedByRootCa(void const* data, size_t size) { - // Implementation of this function is out of scope of the sample. - // In an actual implementation Issuing CA certificate must be validated - // with CA Root certificate before using it in parse functions. - (void)data; - (void)size; - return true; -} - -EpidStatus SignMsg(void const* msg, size_t msg_len, void const* basename, - size_t basename_len, unsigned char const* signed_sig_rl, - size_t signed_sig_rl_size, - unsigned char const* signed_pubkey, - size_t signed_pubkey_size, unsigned char const* priv_key_ptr, - size_t privkey_size, HashAlg hash_alg, - MemberPrecomp* member_precomp, bool member_precomp_is_input, - EpidSignature** sig, size_t* sig_len, - EpidCaCertificate const* cacert) { - EpidStatus sts = kEpidErr; - void* prng = NULL; - MemberCtx* member = NULL; - - SigRl* sig_rl = NULL; - size_t sig_rl_size = 0; - - do { - GroupPubKey pub_key = {0}; - PrivKey priv_key = {0}; - - if (!sig) { - sts = kEpidBadArgErr; - break; - } - - // authenticate and extract group public key - sts = EpidParseGroupPubKeyFile(signed_pubkey, signed_pubkey_size, cacert, - &pub_key); - if (kEpidNoErr != sts) { - break; - } - - if (signed_sig_rl) { - // authenticate and determine space needed for SigRl - sts = EpidParseSigRlFile(signed_sig_rl, signed_sig_rl_size, cacert, - sig_rl, &sig_rl_size); - if (kEpidSigInvalid == sts) { - // authentication failure - break; - } - if (kEpidNoErr != sts) { - break; - } - sig_rl = AllocBuffer(sig_rl_size); - if (!sig_rl) { - sts = kEpidMemAllocErr; - break; - } - - // fill the SigRl - sts = EpidParseSigRlFile(signed_sig_rl, signed_sig_rl_size, cacert, - sig_rl, &sig_rl_size); - if (kEpidSigInvalid == sts) { - // authentication failure - break; - } - if (kEpidNoErr != sts) { - break; - } - } - - // acquire PRNG - sts = PrngCreate(&prng); - if (kEpidNoErr != sts) { - break; - } - - // decompress private key - if (privkey_size == sizeof(PrivKey)) { - priv_key = *(PrivKey*)priv_key_ptr; - } else if (privkey_size == sizeof(CompressedPrivKey)) { - sts = EpidDecompressPrivKey(&pub_key, (CompressedPrivKey*)priv_key_ptr, - &priv_key); - if (kEpidNoErr != sts) { - break; - } - } else { - sts = kEpidErr; - break; - } - - // create member - sts = EpidMemberCreate(&pub_key, &priv_key, - member_precomp_is_input ? member_precomp : NULL, - PrngGen, prng, &member); - if (kEpidNoErr != sts) { - break; - } - - // return member pre-computation blob if requested - sts = EpidMemberWritePrecomp(member, member_precomp); - if (kEpidNoErr != sts) { - break; - } - - // register any provided basename as allowed - if (0 != basename_len) { - sts = EpidRegisterBaseName(member, basename, basename_len); - if (kEpidNoErr != sts) { - break; - } - } - - sts = EpidMemberSetHashAlg(member, hash_alg); - if (kEpidNoErr != sts) { - break; - } - - // Signature - // Note: Signature size must be computed after sig_rl is loaded. - *sig_len = EpidGetSigSize(sig_rl); - - *sig = AllocBuffer(*sig_len); - if (!*sig) { - sts = kEpidMemAllocErr; - break; - } - - // sign message - sts = EpidSign(member, msg, msg_len, basename, basename_len, sig_rl, - sig_rl_size, *sig, *sig_len); - if (kEpidNoErr != sts) { - break; - } - sts = kEpidNoErr; - } while (0); - - PrngDelete(&prng); - EpidMemberDelete(&member); - - if (sig_rl) free(sig_rl); - - return sts; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.h b/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.h deleted file mode 100644 index 4426ea9363..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/signmsg/src/signmsg.h +++ /dev/null @@ -1,42 +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 Message signing interface. - */ - -#ifndef EXAMPLE_SIGNMSG_SRC_SIGNMSG_H_ -#define EXAMPLE_SIGNMSG_SRC_SIGNMSG_H_ - -#include "epid/member/api.h" -#include "epid/common/file_parser.h" - -/// Check if opaque data blob containing CA certificate is authorized -bool IsCaCertAuthorizedByRootCa(void const* data, size_t size); - -/// Create Intel(R) EPID signature of message -EpidStatus SignMsg(void const* msg, size_t msg_len, void const* basename, - size_t basename_len, unsigned char const* signed_sig_rl, - size_t signed_sig_rl_size, - unsigned char const* signed_pubkey, - size_t signed_pubkey_size, unsigned char const* priv_key, - size_t privkey_size, HashAlg hash_alg, - MemberPrecomp* member_precomp, bool member_precomp_is_input, - EpidSignature** sig, size_t* sig_len, - EpidCaCertificate const* cacert); - -#endif // EXAMPLE_SIGNMSG_SRC_SIGNMSG_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/argutil.h b/sgx-jvm/linux-sgx/external/epid/example/util/argutil.h deleted file mode 100644 index 365a50cc35..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/argutil.h +++ /dev/null @@ -1,52 +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 Argument parsing utilities interface. - */ -#ifndef EXAMPLE_UTIL_ARGUTIL_H_ -#define EXAMPLE_UTIL_ARGUTIL_H_ - -/// get the index of an option in argv -/*! - \param[in] argc number of arguments - \param[in] argv list of arguments - \param[in] name of option - \returns index of the option in argv -*/ -int GetOptionIndex(int argc, char* const argv[], char const* option); - -/// test if an option is in argv -/*! - \param[in] argc number of arguments - \param[in] argv list of arguments - \param[in] name of option - \retval true option is in argv - \retval false option is not in argv -*/ -int CmdOptionExists(int argc, char* const argv[], char const* option); - -/// find option in argv -/*! - \param[in] argc number of arguments - \param[in] argv list of arguments - \param[in] name of option - \returns pointer from argv for option -*/ -char const* GetCmdOption(int argc, char* const argv[], char const* option); - -#endif // EXAMPLE_UTIL_ARGUTIL_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/buffutil.h b/sgx-jvm/linux-sgx/external/epid/example/util/buffutil.h deleted file mode 100644 index 8e85edcd1a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/buffutil.h +++ /dev/null @@ -1,146 +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 Buffer handling utilities interface. - */ -#ifndef EXAMPLE_UTIL_BUFFUTIL_H_ -#define EXAMPLE_UTIL_BUFFUTIL_H_ - -#include -#include "util/stdtypes.h" - -/// Options controlling how a buffer should be printed. -typedef struct BufferPrintOptions { - bool show_header; - bool show_offset; - bool show_hex; - bool show_ascii; - size_t bytes_per_group; - size_t groups_per_line; -} BufferPrintOptions; - -/// Toggle verbose logging -bool ToggleVerbosity(); - -/// Test if file exists -/*! - \param[in] filename - The file path. - - \returns bool -*/ -bool FileExists(char const* filename); - -/// Get file size -/*! - \param[in] filename - - The file path. - \returns size of the file in bytes -*/ -size_t GetFileSize(char const* filename); - -/// Allocate a buffer of a fixed size -/*! - Logs an error message on failure. - - \param[out] buffer - A pointer to the buffer to allocate. - \param[in] size - the requested size of the buffer in bytes. - - \returns - A pointer to the allocated buffer or NULL if the allocation failed. - -*/ -void* AllocBuffer(size_t size); - -/// Allocate a buffer to hold the content of a file and load -/*! - Logs an error message on failure. - - \param[in] filename - The file path. - \param[out] size - The allocated size of the buffer in bytes (same as file size). - - \returns - A pointer to the allocated buffer or NULL if the allocation failed. - - \see ToggleVerbosity() -*/ -void* NewBufferFromFile(const char* filename, size_t* size); - -/// Read a buffer from a file with logging -/*! - - Verbosity of logging controlled by verbosity state - - - \param[in] filename - The file path. - \param[in,out] buf - The buffer. - \param[in] size - The size of the buffer in bytes. - - \returns 0 on success, non-zero failure - - \see ToggleVerbosity() -*/ -int ReadLoud(char const* filename, void* buf, size_t size); - -/// write a buffer from a file with logging -/*! - - Verbosity of logging controlled by verbosity state - - \param[in] buf - The buffer. - \param[in] size - The size of the buffer in bytes. - \param[in] filename - The file path. - - \returns 0 on success, non-zero failure - - \see ToggleVerbosity() -*/ -int WriteLoud(void* buf, size_t size, char const* filename); - -/// print a buffer to standard out using user provided options -/*! - \param[in] buf - The buffer. - \param[in] size - The size of the buffer in bytes. - \param[in] opts - The formatting options. -*/ -void PrintBufferOpt(const void* buffer, size_t size, BufferPrintOptions opts); - -/// print a buffer to standard out using default options -/*! - \param[in] buf - The buffer. - \param[in] size - The size of the buffer in bytes. -*/ -void PrintBuffer(const void* buffer, size_t size); - -#endif // EXAMPLE_UTIL_BUFFUTIL_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/convutil.h b/sgx-jvm/linux-sgx/external/epid/example/util/convutil.h deleted file mode 100644 index 0d59431128..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/convutil.h +++ /dev/null @@ -1,61 +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 Conversion utilities interface. - */ -#ifndef EXAMPLE_UTIL_CONVUTIL_H_ -#define EXAMPLE_UTIL_CONVUTIL_H_ - -#include -#include "epid/common/types.h" -#include "epid/common/file_parser.h" -#include "util/stdtypes.h" - -/// convert a hash algorithm to a string -/*! - \param[in] alg a hash algorithm - \returns string representing the algorithm -*/ -char const* HashAlgToString(HashAlg alg); - -/// convert a string to a hash algorithm -/*! - \param[in] str a string - \param[out] alg a hash algorithm - \retval true string represents a hash algorithm - \retval false string does not represent a hash algorithm -*/ -bool StringToHashAlg(char const* str, HashAlg* alg); - -/// convert an EPID file type to a string -/*! -\param[in] type an EPID file type -\returns string representing the algorithm -*/ -char const* EpidFileTypeToString(EpidFileType type); - -/// convert a string to an EPID file type -/*! -\param[in] str a string -\param[out] type an EPID file type -\retval true string represents an EPID file type -\retval false string does not represent an EPID file type -*/ -bool StringToEpidFileType(char const* str, EpidFileType* type); - -#endif // EXAMPLE_UTIL_CONVUTIL_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/envutil.h b/sgx-jvm/linux-sgx/external/epid/example/util/envutil.h deleted file mode 100644 index 794f22987c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/envutil.h +++ /dev/null @@ -1,54 +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 Environment utilities interface. - */ -#ifndef EXAMPLE_UTIL_ENVUTIL_H_ -#define EXAMPLE_UTIL_ENVUTIL_H_ - -/// set the program name -void set_prog_name(char const* name); - -/// get the program name -char const* get_prog_name(); - -/// log an error -/*! -This function may add or format the message before writing it out - -output is written to the error stream -*/ -int log_error(char const* msg, ...); - -/// log a message -/*! -This function may add or format the message before writing it out - -output is written to the standard output stream -*/ -int log_msg(char const* msg, ...); - -/// log a formatted message -/*! -This function will not add or format the message before writing it out - -output is written to the standard output stream -*/ -int log_fmt(char const* msg, ...); - -#endif // EXAMPLE_UTIL_ENVUTIL_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/src/argutil.c b/sgx-jvm/linux-sgx/external/epid/example/util/src/argutil.c deleted file mode 100644 index fb3ac4aa34..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/src/argutil.c +++ /dev/null @@ -1,70 +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 Argument parsing utilities implementation. - */ - -#include -#include "util/argutil.h" -#include "util/envutil.h" - -int GetOptionIndex(int argc, char* const argv[], char const* option) { - int result = -1; - int ca = 0; - for (ca = argc - 1; ca > 0; ca--) { - if (0 == strncmp(argv[ca], option, strlen(option))) { - if (strlen(argv[ca]) > strlen(option) && - '=' != *(argv[ca] + strlen(option))) { - continue; - } else { - result = ca; - break; - } - } - } - return result; -} - -// this finds options that start with option= -int GetCmdOptionIndex(int argc, char* const argv[], char const* option) { - int result = -1; - int ca = 0; - for (ca = argc - 1; ca > 0; ca--) { - if (0 == strcmp(argv[ca], option)) { - result = ca; - break; - } - } - return result; -} - -int CmdOptionExists(int argc, char* const argv[], char const* option) { - return (-1 != GetOptionIndex(argc, argv, option)); -} - -char const* GetCmdOption(int argc, char* const argv[], char const* option) { - char const* optionarg = 0; - int option_index = GetOptionIndex(argc, argv, option); - if (-1 != option_index) { - // we have the option - if (strlen(argv[option_index]) > strlen(option) + 1) { - optionarg = argv[option_index] + strlen(option) + 1; - } - } - return optionarg; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/src/bufutil.c b/sgx-jvm/linux-sgx/external/epid/example/util/src/bufutil.c deleted file mode 100644 index dae77dd840..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/src/bufutil.c +++ /dev/null @@ -1,355 +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 Buffer handling utilities implementation. - */ - -#include - -#include -#include -#include -#include "util/envutil.h" - -/// file static variable that indicates verbose logging -static bool g_bufutil_verbose = false; - -bool ToggleVerbosity() { - g_bufutil_verbose = (g_bufutil_verbose) ? false : true; - return g_bufutil_verbose; -} - -bool FileExists(char const* filename) { - FILE* fp = NULL; - if (!filename || !filename[0]) { - return false; - } - fp = fopen(filename, "rb"); - if (fp) { - fclose(fp); - return true; - } - return false; -} - -size_t GetFileSize(char const* filename) { - size_t file_length = 0; - FILE* fp = fopen(filename, "rb"); - if (fp) { - fseek(fp, 0, SEEK_END); - file_length = ftell(fp); - fclose(fp); - } - return file_length; -} - -void* AllocBuffer(size_t size) { - void* buffer = NULL; - if (size) { - buffer = malloc(size); - } - if (!buffer) { - log_error("failed to allocate memory"); - } - return buffer; -} - -void* NewBufferFromFile(const char* filename, size_t* size) { - void* buffer = NULL; - - do { - size_t len = 0; - - if (!FileExists(filename)) { - log_error("cannot access '%s'", filename); - break; - } - - len = GetFileSize(filename); - if (len == 0) { - log_error("cannot load empty file '%s'", filename); - break; - } - - buffer = AllocBuffer(len); - - if (buffer) { - if (0 != ReadLoud(filename, buffer, len)) { - free(buffer); - buffer = NULL; - break; - } - } - - if (size) { - *size = len; - } - } while (0); - return buffer; -} - -int ReadBufferFromFile(const char* filename, void* buffer, size_t size) { - int result = 0; - FILE* file = NULL; - do { - size_t bytes_read = 0; - size_t file_size = 0; - file = fopen(filename, "rb"); - if (!file) { - result = -1; - break; - } - fseek(file, 0, SEEK_END); - file_size = ftell(file); - fseek(file, 0, SEEK_SET); - if ((size_t)file_size != size) { - result = -1; - break; - } - - if (buffer && (0 != size)) { - bytes_read = fread(buffer, 1, size, file); - if (bytes_read != size) { - result = -1; - break; - } - } - } while (0); - - if (file) { - fclose(file); - } - - return result; -} - -int WriteBufferToFile(const void* buffer, size_t size, const char* filename) { - int result = 0; - FILE* file = NULL; - do { - size_t bytes_written = 0; - - file = fopen(filename, "wb"); - if (!file) { - result = -1; - break; - } - bytes_written = fwrite(buffer, 1, size, file); - if (bytes_written != size) { - result = -1; - break; - } - } while (0); - - if (file) { - fclose(file); - } - - return result; -} - -int ReadLoud(char const* filename, void* buf, size_t size) { - int result; - - if (!buf || 0 == size) { - log_error("internal error: invalid buffer to ReadLoud"); - return -1; - } - - if (g_bufutil_verbose) { - log_msg("reading %s", filename); - } - - if (!FileExists(filename)) { - log_error("cannot access '%s' for reading", filename); - return -1; - } - - if (size != GetFileSize(filename)) { - log_error("unexpected file size for '%s'. Expected: %d; got: %d", filename, - (int)size, (int)GetFileSize(filename)); - return -1; - } - - result = ReadBufferFromFile(filename, buf, size); - if (0 != result) { - log_error("failed to read from `%s`", filename); - return result; - } - - if (g_bufutil_verbose) { - PrintBuffer(buf, size); - } - - return result; -} - -int WriteLoud(void* buf, size_t size, char const* filename) { - int result = -1; - - if (!buf || 0 == size) { - log_error("internal error: invalid buffer to WriteLoud"); - return -1; - } - - if (g_bufutil_verbose) { - log_msg("writing %s", filename); - } - - result = WriteBufferToFile(buf, size, filename); - - if (0 != result) { - log_error("failed to write to `%s`", filename); - return result; - } - - if (g_bufutil_verbose) { - PrintBuffer(buf, size); - } - - return result; -} - -void PrintBuffer(const void* buffer, size_t size) { - BufferPrintOptions opts; - opts.show_header = true; - opts.show_offset = true; - opts.show_hex = true; - opts.show_ascii = true; - opts.bytes_per_group = 2; - opts.groups_per_line = 8; - PrintBufferOpt(buffer, size, opts); -} - -void PrintBufferOpt(const void* buffer, size_t size, BufferPrintOptions opts) { - unsigned char* bytes = (unsigned char*)buffer; - size_t bytes_per_line = opts.bytes_per_group * opts.groups_per_line; - size_t line_offset = 0; - size_t byte_offset = 0; - size_t byte_col = 0; - if (opts.show_header) { - if (opts.show_offset) { - log_fmt(" offset"); - log_fmt(": "); - } - - if (opts.show_hex) { - byte_col = 0; - while (byte_col < bytes_per_line) { - log_fmt("%x%x", (int)byte_col, (int)byte_col); - if (0 == (byte_col + 1) % opts.bytes_per_group) { - log_fmt(" "); - } - byte_col += 1; - } - } - - if (opts.show_hex && opts.show_ascii) { - log_fmt("| "); - } - - if (opts.show_ascii) { - byte_col = 0; - while (byte_col < bytes_per_line) { - log_fmt("%x", (int)byte_col); - byte_col += 1; - } - } - - log_fmt("\n"); - - if (opts.show_offset) { - log_fmt("--------"); - log_fmt(": "); - } - - if (opts.show_hex) { - byte_col = 0; - while (byte_col < bytes_per_line) { - log_fmt("--"); - if (0 == (byte_col + 1) % opts.bytes_per_group) { - log_fmt("-"); - } - byte_col += 1; - } - } - - if (opts.show_hex && opts.show_ascii) { - log_fmt("|-"); - } - - if (opts.show_ascii) { - byte_col = 0; - while (byte_col < bytes_per_line) { - log_fmt("-"); - byte_col += 1; - } - } - log_fmt("\n"); - } - - line_offset = 0; - - while (line_offset < size) { - if (opts.show_offset) { - log_fmt("%08x", (int)line_offset); - log_fmt(": "); - } - - if (opts.show_hex) { - byte_col = 0; - while (byte_col < bytes_per_line) { - byte_offset = line_offset + byte_col; - if (byte_offset < size) { - log_fmt("%02x", (int)bytes[byte_offset]); - } else { - log_fmt(" "); - } - if (0 == (byte_col + 1) % opts.bytes_per_group) { - log_fmt(" "); - } - byte_col += 1; - } - } - - if (opts.show_hex && opts.show_ascii) { - log_fmt("| "); - } - - if (opts.show_ascii) { - byte_col = 0; - while (byte_col < bytes_per_line) { - byte_offset = line_offset + byte_col; - if (byte_offset < size) { - unsigned char ch = bytes[byte_offset]; - if (isprint(ch)) { - log_fmt("%c", ch); - } else { - log_fmt("."); - } - } else { - log_fmt(" "); - } - byte_col += 1; - } - } - - log_fmt("\n"); - line_offset += bytes_per_line; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/src/convutil.c b/sgx-jvm/linux-sgx/external/epid/example/util/src/convutil.c deleted file mode 100644 index 271f9389ba..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/src/convutil.c +++ /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 Conversion utilities implementation. - * - */ - -#include -#include -#include -#include "util/convutil.h" -#include "util/envutil.h" - -const char* hash_alg_to_string[] = {"SHA-256", "SHA-384", "SHA-512", - "SHA-512/256", "SHA3/256", "SHA3/384", - "SHA3/512"}; - -#define COUNT_OF(A) (sizeof(A) / sizeof((A)[0])) - -char const* HashAlgToString(HashAlg alg) { - if ((int)alg < 0 || (size_t)alg >= COUNT_OF(hash_alg_to_string)) - return "unknown"; - return hash_alg_to_string[alg]; -} - -bool StringToHashAlg(char const* str, HashAlg* alg) { - size_t i; - if (!alg || !str) return false; - for (i = 0; i < COUNT_OF(hash_alg_to_string); i++) { - if (0 == strcmp(str, hash_alg_to_string[i])) { - *alg = (HashAlg)i; - return true; - } - } - log_error("hash algorithm \"%s\" is unknown", str); - return false; -} - -const char* epid_file_type_to_string[kNumFileTypes] = { - "IssuingCaPubKey", "GroupPubKey", "PrivRl", "SigRl", "GroupRl"}; - -char const* EpidFileTypeToString(EpidFileType type) { - if ((int)type < 0 || (size_t)type >= COUNT_OF(epid_file_type_to_string)) - return "unknown"; - return epid_file_type_to_string[type]; -} - -bool StringToEpidFileType(char const* str, EpidFileType* type) { - size_t i; - if (!type || !str) return false; - for (i = 0; i < COUNT_OF(epid_file_type_to_string); i++) { - if (0 == strcmp(str, epid_file_type_to_string[i])) { - *type = (EpidFileType)i; - return true; - } - } - log_error("epid file type \"%s\" is unknown", str); - return false; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/src/envutil.c b/sgx-jvm/linux-sgx/external/epid/example/util/src/envutil.c deleted file mode 100644 index dbec17889c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/src/envutil.c +++ /dev/null @@ -1,91 +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 Environment utilities implementation. - */ - -#include -#include -#include "util/envutil.h" - -static char const* prog_name = NULL; - -void set_prog_name(char const* name) { prog_name = name; } - -char const* get_prog_name() { return prog_name; } - -int log_error(char const* msg, ...) { - int result = 0; - int local_result = 0; - va_list args; - va_start(args, msg); - do { - local_result = fprintf(stderr, "%s: ", prog_name); - if (local_result < 0) { - result = local_result; - break; - } - result += local_result; - local_result = vfprintf(stderr, msg, args); - if (local_result < 0) { - result = local_result; - break; - } - result += local_result; - local_result = fprintf(stderr, "\n"); - if (local_result < 0) { - result = local_result; - break; - } - result += local_result; - } while (0); - va_end(args); - return result; -} - -int log_msg(char const* msg, ...) { - int result = 0; - int local_result = 0; - va_list args; - va_start(args, msg); - do { - local_result = vfprintf(stdout, msg, args); - if (local_result < 0) { - result = local_result; - break; - } - result += local_result; - local_result = fprintf(stdout, "\n"); - if (local_result < 0) { - result = local_result; - break; - } - result += local_result; - } while (0); - va_end(args); - return result; -} - -int log_fmt(char const* msg, ...) { - int result = 0; - va_list args; - va_start(args, msg); - result = vfprintf(stdout, msg, args); - va_end(args); - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/stdtypes.h b/sgx-jvm/linux-sgx/external/epid/example/util/stdtypes.h deleted file mode 100644 index 8eb0a22a1b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/stdtypes.h +++ /dev/null @@ -1,37 +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 EXAMPLE_UTIL_STDTYPES_H_ -#define EXAMPLE_UTIL_STDTYPES_H_ - -/*! - * \file - * \brief C99 standard data types. - */ - -#include // Fixed-width integer types - -#ifndef __cplusplus -#ifndef _Bool -/// Boolean type -typedef char bool; -/// integer constant 1 -#define true 1 -/// integer constant 0 -#define false 0 -#endif // -#endif // ifndef __cplusplus - -#endif // EXAMPLE_UTIL_STDTYPES_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/util/util.parts b/sgx-jvm/linux-sgx/external/epid/example/util/util.parts deleted file mode 100644 index 08213937c4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/util/util.parts +++ /dev/null @@ -1,59 +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("util") - -src_files = Pattern(src_dir='src', - includes=['*.c'], - recursive=True).files() - -api_headers = Pattern(src_dir='.', - includes=['*.h'], - recursive=False).files() -parts_file = ['util.parts'] - -#unit tests -utest_files = Pattern(src_dir='.', - includes=['*-test.cc', '*-testhelper.cc'], - excludes=[], - recursive=True).files() - -if 'install_package' in env['MODE']: - env.InstallTopLevel(src_files, sub_dir='example/${PART_SHORT_NAME}/src') - env.InstallTopLevel(api_headers, sub_dir='example/${PART_SHORT_NAME}') - env.InstallTopLevel(utest_files, sub_dir='example/${PART_SHORT_NAME}/utest') - env.InstallTopLevel(parts_file, sub_dir='example/${PART_SHORT_NAME}') -else: - env.DependsOn([Component('common', requires=REQ.HEADERS)]) - - env.Append(CPPPATH='#/example') - - testenv = env.Clone() - - env.SdkInclude(api_headers, sub_dir='${PART_SHORT_NAME}') - - if env['TARGET_PLATFORM']['OS'] == 'win32': - if env.isConfigBasedOn('debug'): - env['PDB'] = '${PART_NAME}.pdb' - - #env.Append(CPPDEFINES = 'ENABLE_UTIL_DEBUG_PRINT_') - env.Append(CPPDEFINES='_CRT_SECURE_NO_WARNINGS') - - outputs = env.Library('${PART_NAME}', src_files) - - env.Sdk(outputs) diff --git a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/main.c b/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/main.c deleted file mode 100644 index 6e91829ded..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/main.c +++ /dev/null @@ -1,418 +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 Verifysig example implementation. - */ - -#include -#include -#include - -#include "epid/common/errors.h" -#include "epid/common/types.h" -#include "epid/verifier/api.h" - -#include "util/argutil.h" -#include "util/buffutil.h" -#include "util/convutil.h" -#include "util/envutil.h" -#include "src/verifysig.h" - -// Defaults -#define PROGRAM_NAME ("verifysig") -#define PUBKEYFILE_DEFAULT ("pubkey.bin") -#define PRIVRL_DEFAULT NULL -#define SIGRL_DEFAULT NULL -#define GRPRL_DEFAULT ("grprl.bin") -#define VERIFIERRL_DEFAULT NULL -#define SIG_DEFAULT ("sig.dat") -#define CACERT_DEFAULT ("cacert.bin") -#define HASHALG_DEFAULT ("SHA-512") -#define VPRECMPI_DEFAULT NULL -#define VPRECMPO_DEFAULT NULL - -/// Print usage message -void PrintUsage() { - log_fmt( - "Usage: %s [OPTION]...\n" - "Verify signature was created by group member in good standing\n" - "\n" - "Options:\n" - "\n" - "--sig=FILE load signature from FILE (default: %s)\n" - "--msg=MESSAGE MESSAGE that was signed (default: empty)\n" - "--bsn=BASENAME BASENAME used in signature (default: random)\n" - "--privrl=FILE load private key revocation list from FILE\n" - "--sigrl=FILE load signature based revocation list from FILE\n" - "--grprl=FILE load group revocation list from FILE\n" - " (default: %s)\n" - "--verifierrl=FILE load verifier revocation list from FILE\n" - "--gpubkey=FILE load group public key from FILE (default: %s)\n" - "--vprecmpi=FILE load pre-computed verifier data from FILE\n" - "--vprecmpo=FILE write pre-computed verifier data to FILE\n" - "--hashalg=NAME SHA-256 | SHA-384 | SHA-512 (default: %s)\n" - "--capubkey=FILE load IoT Issuing CA public key from FILE\n" - " (default: %s)\n" - "-h,--help display this help and exit\n" - "-v,--verbose print status messages to stdout\n" - "\n", - PROGRAM_NAME, SIG_DEFAULT, GRPRL_DEFAULT, PUBKEYFILE_DEFAULT, - HASHALG_DEFAULT, CACERT_DEFAULT); -} - -/// Main entrypoint -int main(int argc, char* argv[]) { - // intermediate return value for C style functions - int ret_value = EXIT_SUCCESS; - // intermediate return value for EPID functions - EpidStatus result = kEpidErr; - // Temp option pointer - char const* opt_str = 0; - - // User Settings - - // Signature file name parameter - char const* sig_file = SIG_DEFAULT; - - // Message string parameter - char const* msg_str = NULL; - size_t msg_size = 0; - - // Basename string parameter - char const* basename_str = NULL; - size_t basename_size = 0; - - // PrivRl file name parameter - char const* privrl_file = PRIVRL_DEFAULT; - - // SigRl file name parameter - char const* sigrl_file = SIGRL_DEFAULT; - - // GrpRl file name parameter - char const* grprl_file = GRPRL_DEFAULT; - - // VerRl file name parameter - char const* verrl_file = VERIFIERRL_DEFAULT; - - // Group public key file name parameter - char const* pubkey_file = PUBKEYFILE_DEFAULT; - - // Verifier pre-computed settings input file name parameter - char const* vprecmpi_file = VPRECMPI_DEFAULT; - - // Verifier pre-computed settings output file name parameter - char const* vprecmpo_file = VPRECMPO_DEFAULT; - - // Hash algorithm name parameter - char const* hashalg_str = HASHALG_DEFAULT; - - // CA certificate file name parameter - char const* cacert_file_name = CACERT_DEFAULT; - - // Verbose flag parameter - bool verbose = false; - - // Buffers and computed values - - // Signature buffer - EpidSignature* sig = NULL; - size_t sig_size = 0; - - // PrivRl buffer - void* signed_priv_rl = NULL; - size_t signed_priv_rl_size = 0; - - // SigRl buffer - void* signed_sig_rl = NULL; - size_t signed_sig_rl_size = 0; - - // GrpRl buffer - void* signed_grp_rl = NULL; - size_t signed_grp_rl_size = 0; - - // VerRl buffer - VerifierRl* ver_rl = NULL; - size_t ver_rl_size = 0; - - // Group public key buffer - void* signed_pubkey = NULL; - size_t signed_pubkey_size = 0; - - // Verifier pre-computed settings - VerifierPrecomp verifier_precmp = {0}; - - // Flag that Verifier pre-computed settings input is valid - bool use_precmp_in; - - // Hash algorithm - HashAlg hashalg; - - // CA certificate - EpidCaCertificate cacert = {0}; - - // set program name for logging - set_prog_name(PROGRAM_NAME); - do { - // Read command line args - - if (argc < 1) { - PrintUsage(); - ret_value = EXIT_FAILURE; - break; - } - - if (CmdOptionExists(argc, argv, "--help") || - CmdOptionExists(argc, argv, "-h")) { - PrintUsage(); - ret_value = EXIT_SUCCESS; - break; - } - - if (CmdOptionExists(argc, argv, "--verbose") || - CmdOptionExists(argc, argv, "-v")) { - verbose = ToggleVerbosity(); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--sig"))) { - sig_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--msg"))) { - msg_str = opt_str; - msg_size = strlen(msg_str); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--bsn"))) { - basename_str = opt_str; - basename_size = strlen(basename_str); - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--privrl"))) { - privrl_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--sigrl"))) { - sigrl_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--grprl"))) { - grprl_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--verifierrl"))) { - verrl_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--gpubkey"))) { - pubkey_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--vprecmpi"))) { - vprecmpi_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--vprecmpo"))) { - vprecmpo_file = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--hashalg"))) { - hashalg_str = opt_str; - } - - if (0 != (opt_str = GetCmdOption(argc, argv, "--capubkey"))) { - cacert_file_name = opt_str; - } - - // convert command line args to usable formats - - // Signature - sig = NewBufferFromFile(sig_file, &sig_size); - if (!sig) { - ret_value = EXIT_FAILURE; - break; - } - - // PrivRl - if (privrl_file) { - signed_priv_rl = NewBufferFromFile(privrl_file, &signed_priv_rl_size); - if (!signed_priv_rl) { - ret_value = EXIT_FAILURE; - break; - } - } - - // SigRl - if (sigrl_file) { - signed_sig_rl = NewBufferFromFile(sigrl_file, &signed_sig_rl_size); - if (!signed_sig_rl) { - ret_value = EXIT_FAILURE; - break; - } - } - - // GrpRl - signed_grp_rl = NewBufferFromFile(grprl_file, &signed_grp_rl_size); - if (!signed_grp_rl) { - ret_value = EXIT_FAILURE; - break; - } - // VerRl - if (verrl_file) { - ver_rl = (VerifierRl*)NewBufferFromFile(verrl_file, &ver_rl_size); - if (!ver_rl) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Group public key - signed_pubkey = NewBufferFromFile(pubkey_file, &signed_pubkey_size); - if (!signed_pubkey) { - ret_value = EXIT_FAILURE; - break; - } - - // CA certificate - if (0 != ReadLoud(cacert_file_name, &cacert, sizeof(cacert))) { - ret_value = EXIT_FAILURE; - break; - } - - // Security note: - // Application must confirm that IoT EPID Issuing CA certificate is - // authorized by IoT EPID Root CA, e.g., signed by IoT EPID Root CA. - if (!IsCaCertAuthorizedByRootCa(&cacert, sizeof(cacert))) { - log_error("CA certificate is not authorized"); - ret_value = EXIT_FAILURE; - break; - } - - // Load Verifier pre-computed settings - use_precmp_in = false; - if (vprecmpi_file) { - if (sizeof(verifier_precmp) != GetFileSize(vprecmpi_file)) { - log_error("incorrect input precomp size"); - ret_value = EXIT_FAILURE; - break; - } - use_precmp_in = true; - - if (0 != - ReadLoud(vprecmpi_file, &verifier_precmp, sizeof(verifier_precmp))) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Hash algorithm - if (!StringToHashAlg(hashalg_str, &hashalg)) { - ret_value = EXIT_FAILURE; - break; - } - - if (hashalg != kSha256 && hashalg != kSha384 && hashalg != kSha512) { - log_error("unsupported hash algorithm %s", HashAlgToString(hashalg)); - ret_value = EXIT_FAILURE; - break; - } - - // Report Settings - if (verbose) { - log_msg("=============================================="); - log_msg("Verifying Message:"); - log_msg(""); - log_msg(" [in] Signature Len: %d", (int)sig_size); - log_msg(" [in] Signature: "); - PrintBuffer(sig, sig_size); - log_msg(""); - log_msg(" [in] Message Len: %d", (int)msg_size); - log_msg(" [in] Message: "); - PrintBuffer(msg_str, msg_size); - log_msg(""); - log_msg(" [in] BaseName Len: %d", (int)basename_size); - log_msg(" [in] BaseName: "); - PrintBuffer(basename_str, basename_size); - log_msg(""); - log_msg(" [in] PrivRl Len: %d", (int)signed_priv_rl_size); - log_msg(" [in] PrivRl: "); - PrintBuffer(signed_priv_rl, signed_priv_rl_size); - log_msg(""); - log_msg(" [in] SigRl Len: %d", (int)signed_sig_rl_size); - log_msg(" [in] SigRl: "); - PrintBuffer(signed_sig_rl, signed_sig_rl_size); - log_msg(""); - log_msg(" [in] GrpRl Len: %d", (int)signed_grp_rl_size); - log_msg(" [in] GrpRl: "); - PrintBuffer(signed_grp_rl, signed_grp_rl_size); - log_msg(""); - log_msg(" [in] VerRl Len: %d", (int)ver_rl_size); - log_msg(" [in] VerRl: "); - PrintBuffer(ver_rl, ver_rl_size); - log_msg(""); - log_msg(" [in] Group Public Key: "); - PrintBuffer(signed_pubkey, sizeof(signed_pubkey_size)); - log_msg(""); - log_msg(" [in] Hash Algorithm: %s", HashAlgToString(hashalg)); - if (use_precmp_in) { - log_msg(""); - log_msg(" [in] Verifier PreComp: "); - PrintBuffer(&verifier_precmp, sizeof(verifier_precmp)); - } - log_msg("=============================================="); - } - - // Verify - result = Verify( - sig, sig_size, msg_str, msg_size, basename_str, basename_size, - signed_priv_rl, signed_priv_rl_size, signed_sig_rl, signed_sig_rl_size, - signed_grp_rl, signed_grp_rl_size, ver_rl, ver_rl_size, signed_pubkey, - signed_pubkey_size, &cacert, hashalg, &verifier_precmp, use_precmp_in); - - // Report Result - if (kEpidNoErr == result) { - log_msg("signature verified successfully"); - } else { - log_error("signature verification failed: %s", - EpidStatusToString(result)); - ret_value = result; - break; - } - - // Store Verifier pre-computed settings - if (vprecmpo_file) { - if (0 != - WriteLoud(&verifier_precmp, sizeof(verifier_precmp), vprecmpo_file)) { - ret_value = EXIT_FAILURE; - break; - } - } - - // Success - ret_value = EXIT_SUCCESS; - } while (0); - - // Free allocated buffers - if (sig) free(sig); - if (signed_priv_rl) free(signed_priv_rl); - if (signed_sig_rl) free(signed_sig_rl); - if (signed_grp_rl) free(signed_grp_rl); - if (ver_rl) free(ver_rl); - if (signed_pubkey) free(signed_pubkey); - - return ret_value; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.c b/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.c deleted file mode 100644 index a49b72085d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.c +++ /dev/null @@ -1,233 +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 Signature verification implementation. - */ - -#include "src/verifysig.h" - -#include - -#include "util/buffutil.h" -#include "util/envutil.h" - -bool IsCaCertAuthorizedByRootCa(void const* data, size_t size) { - // Implementation of this function is out of scope of the sample. - // In an actual implementation Issuing CA certificate must be validated - // with CA Root certificate before using it in parse functions. - (void)data; - (void)size; - return true; -} - -/// Authenticate and allocate revocation list -/*! Utility function to authenticate revocation list and allocate a - buffer to contain the parsed result - \note caller is responsible for freeing free the memory allocated - */ -EpidStatus AuthenticateAndAllocateRl(void const* buf, size_t len, - EpidCaCertificate const* cert, - EpidFileType file_type, const char* name, - void** new_rl, size_t* rl_len); - -EpidStatus Verify(EpidSignature const* sig, size_t sig_len, void const* msg, - size_t msg_len, void const* basename, size_t basename_len, - void const* signed_priv_rl, size_t signed_priv_rl_size, - void const* signed_sig_rl, size_t signed_sig_rl_size, - void const* signed_grp_rl, size_t signed_grp_rl_size, - VerifierRl const* ver_rl, size_t ver_rl_size, - void const* signed_pub_key, size_t signed_pub_key_size, - EpidCaCertificate const* cacert, HashAlg hash_alg, - VerifierPrecomp* precomp, bool is_precomp_init) { - EpidStatus result = kEpidErr; - VerifierCtx* ctx = NULL; - - PrivRl* priv_rl = NULL; - size_t priv_rl_size = 0; - SigRl* sig_rl = NULL; - size_t sig_rl_size = 0; - GroupRl* grp_rl = NULL; - size_t grp_rl_size = 0; - - do { - GroupPubKey pub_key = {0}; - // authenticate and extract group public key - result = EpidParseGroupPubKeyFile(signed_pub_key, signed_pub_key_size, - cacert, &pub_key); - if (kEpidNoErr != result) { - break; - } - - if (is_precomp_init && precomp) { - // create verifier - result = EpidVerifierCreate(&pub_key, precomp, &ctx); - if (kEpidNoErr != result) { - break; - } - } else { - // create verifier - result = EpidVerifierCreate(&pub_key, NULL, &ctx); - if (kEpidNoErr != result) { - break; - } - - // initialize pre-computation blob - result = EpidVerifierWritePrecomp(ctx, precomp); - if (kEpidNoErr != result) { - break; - } - } - - // set hash algorithm used for signing - result = EpidVerifierSetHashAlg(ctx, hash_alg); - if (kEpidNoErr != result) { - break; - } - - if (signed_priv_rl) { - result = AuthenticateAndAllocateRl(signed_priv_rl, signed_priv_rl_size, - cacert, kPrivRlFile, "PrivRl", - (void**)&priv_rl, &priv_rl_size); - if (kEpidNoErr != result) { - break; - } - // set private key based revocation list - result = EpidVerifierSetPrivRl(ctx, priv_rl, priv_rl_size); - if (kEpidNoErr != result) { - break; - } - } - - if (signed_sig_rl) { - result = AuthenticateAndAllocateRl(signed_sig_rl, signed_sig_rl_size, - cacert, kSigRlFile, "SigRl", - (void**)&sig_rl, &sig_rl_size); - if (kEpidNoErr != result) { - break; - } - // set signature based revocation list - result = EpidVerifierSetSigRl(ctx, sig_rl, sig_rl_size); - if (kEpidNoErr != result) { - break; - } - } - - if (signed_grp_rl) { - result = AuthenticateAndAllocateRl(signed_grp_rl, signed_grp_rl_size, - cacert, kGroupRlFile, "GroupRl", - (void**)&grp_rl, &grp_rl_size); - if (kEpidNoErr != result) { - break; - } - // set group based revocation list - result = EpidVerifierSetGroupRl(ctx, grp_rl, grp_rl_size); - if (kEpidNoErr != result) { - break; - } - } - - if (ver_rl) { - // set verifier based revocation list - result = EpidVerifierSetVerifierRl(ctx, ver_rl, ver_rl_size); - if (kEpidNoErr != result) { - break; - } - } - - // verify signature - result = - EpidVerify(ctx, sig, sig_len, msg, msg_len, basename, basename_len); - if (kEpidNoErr != result) { - break; - } - } while (0); - - // delete verifier - EpidVerifierDelete(&ctx); - - if (priv_rl) free(priv_rl); - if (sig_rl) free(sig_rl); - if (grp_rl) free(grp_rl); - - return result; -} - -EpidStatus AuthenticateAndAllocateRl(void const* buf, size_t len, - EpidCaCertificate const* cert, - EpidFileType file_type, const char* name, - void** new_rl, size_t* rl_len) { - typedef EpidStatus (*ParseFuncType)(void const* buf, size_t len, - EpidCaCertificate const* cert, - unsigned char* rl, size_t* rl_len); - EpidStatus result = kEpidErr; - void* parsed_rl = NULL; - ParseFuncType ParseFunc = NULL; - - if (!buf || !cert || !new_rl || !rl_len || !name) { - return kEpidBadArgErr; - } - - switch (file_type) { - case kPrivRlFile: - ParseFunc = (ParseFuncType)&EpidParsePrivRlFile; - break; - case kSigRlFile: - ParseFunc = (ParseFuncType)&EpidParseSigRlFile; - break; - case kGroupRlFile: - ParseFunc = (ParseFuncType)&EpidParseGroupRlFile; - break; - default: - return kEpidBadArgErr; - } - - do { - size_t parsed_len = 0; - - // authenticate and determine space needed for RL - result = ParseFunc(buf, len, cert, NULL, &parsed_len); - if (kEpidSigInvalid == result) { - // authentication failure - break; - } - if (kEpidNoErr != result) { - break; - } - parsed_rl = AllocBuffer(parsed_len); - if (!parsed_rl) { - result = kEpidMemAllocErr; - break; - } - - // fill the rl - result = ParseFunc(buf, len, cert, parsed_rl, &parsed_len); - - if (kEpidNoErr != result) { - break; - } - - *rl_len = parsed_len; - *new_rl = parsed_rl; - } while (0); - - if (kEpidNoErr != result) { - if (parsed_rl) free(parsed_rl); - } - - return result; -} diff --git a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.h b/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.h deleted file mode 100644 index 8bbc4c4c2d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/verifysig/src/verifysig.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 Signature verification interface. - */ -#ifndef EXAMPLE_VERIFYSIG_SRC_VERIFYSIG_H_ -#define EXAMPLE_VERIFYSIG_SRC_VERIFYSIG_H_ - -#include "epid/verifier/api.h" -#include "epid/common/file_parser.h" - -/// Check if opaque data blob containing CA certificate is authorized -bool IsCaCertAuthorizedByRootCa(void const* data, size_t size); - -/// verify signature -EpidStatus Verify(EpidSignature const* sig, size_t sig_len, void const* msg, - size_t msg_len, void const* basename, size_t basename_len, - void const* signed_priv_rl, size_t signed_priv_rl_size, - void const* signed_sig_rl, size_t signed_sig_rl_size, - void const* signed_grp_rl, size_t signed_grp_rl_size, - VerifierRl const* ver_rl, size_t ver_rl_size, - void const* signed_pub_key, size_t signed_pub_key_size, - EpidCaCertificate const* cacert, HashAlg hash_alg, - VerifierPrecomp* precomp, bool is_precomp_init); - -#endif // EXAMPLE_VERIFYSIG_SRC_VERIFYSIG_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/example/verifysig/verifysig.parts b/sgx-jvm/linux-sgx/external/epid/example/verifysig/verifysig.parts deleted file mode 100644 index 84f17c6887..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/example/verifysig/verifysig.parts +++ /dev/null @@ -1,52 +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("verifysig") - -src_files = Pattern(src_dir='src/', - includes=['*.c'], - recursive=True).files() - -inc_files = Pattern(src_dir='src/', - includes=['*.h'], - recursive=True).files() - -parts_file = ['verifysig.parts'] - -if 'install_package' in env['MODE']: - env.InstallTopLevel(src_files + inc_files, sub_dir='example/${PART_SHORT_NAME}/src') - env.InstallTopLevel(parts_file, sub_dir='example/${PART_SHORT_NAME}') - -else: - env.DependsOn([ - Component('verifier'), - Component('util') - ]) - - env.Append(CPPPATH='#/example/verifysig') - - if env['TARGET_PLATFORM']['OS'] == 'win32': - if env.isConfigBasedOn('debug'): - env['PDB'] = '${PART_NAME}.pdb' - - outputs = env.Program('${PART_NAME}', src_files, - no_import_lib=True) - - env.InstallBin(outputs, - no_pkg=False, - INSTALL_BIN='${INSTALL_SAMPLE_BIN}') diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippbase.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippbase.h deleted file mode 100644 index 532f151c46..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippbase.h +++ /dev/null @@ -1,188 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Basic Types and Macro Definitions -// -// -*/ - - -#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/epid/ext/ipp/include/ippcp.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcp.h deleted file mode 100644 index a571c229a2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcp.h +++ /dev/null @@ -1,860 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippCP) -// -// -*/ - -#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 - -#if !defined( _IPP_NO_DEFAULT_LIB ) - #if defined( _IPP_SEQUENTIAL_DYNAMIC ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcp" ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcore" ) - #elif defined( _IPP_SEQUENTIAL_STATIC ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcpmt" ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "ippcoremt" ) - #elif defined( _IPP_PARALLEL_DYNAMIC ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcp" ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcore" ) - #elif defined( _IPP_PARALLEL_STATIC ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcpmt" ) - #pragma comment( lib, __FILE__ "/../../lib/" _INTEL_PLATFORM "threaded/ippcoremt" ) - #endif -#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) ) - - - -/* -// ========================================================= -// Symmetric Ciphers -// ========================================================= -*/ - -/* TDES */ -IPPAPI(IppStatus, ippsDESGetSize,(int *size)) -IPPAPI(IppStatus, ippsDESInit,(const Ipp8u* pKey, IppsDESSpec* pCtx)) - -IPPAPI(IppStatus, ippsDESPack,(const IppsDESSpec* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsDESUnpack,(const Ipp8u* pBuffer, IppsDESSpec* pCtx)) - -IPPAPI(IppStatus, ippsTDESEncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - IppsCPPadding padding)) -IPPAPI(IppStatus, ippsTDESDecryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - IppsCPPadding padding)) - -IPPAPI(IppStatus, ippsTDESEncryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int length, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - const Ipp8u* pIV, - IppsCPPadding padding)) -IPPAPI(IppStatus, ippsTDESDecryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int length, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - const Ipp8u* pIV, - IppsCPPadding padding)) - -IPPAPI(IppStatus, ippsTDESEncryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, int cfbBlkSize, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - const Ipp8u* pIV, - IppsCPPadding padding)) -IPPAPI(IppStatus, ippsTDESDecryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int length, int cfbBlkSize, - const IppsDESSpec* pCtx1, const IppsDESSpec* pCtx2, const IppsDESSpec* pCtx3, - const Ipp8u* pIV, - IppsCPPadding padding)) - -IPPAPI(IppStatus, ippsTDESEncryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsDESSpec* pCtx1, - const IppsDESSpec* pCtx2, - const IppsDESSpec* pCtx3, - Ipp8u* pIV)) -IPPAPI(IppStatus, ippsTDESDecryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsDESSpec* pCtx1, - const IppsDESSpec* pCtx2, - const IppsDESSpec* pCtx3, - Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsTDESEncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsDESSpec* pCtx1, - const IppsDESSpec* pCtx2, - const IppsDESSpec* pCtx3, - Ipp8u* pCtrValue, int ctrNumBitSize)) -IPPAPI(IppStatus, ippsTDESDecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsDESSpec* pCtx1, - const IppsDESSpec* pCtx2, - const IppsDESSpec* pCtx3, - Ipp8u* pCtrValue, int ctrNumBitSize)) - -/* AES */ -IPPAPI(IppStatus, ippsAESGetSize,(int *pSize)) -IPPAPI(IppStatus, ippsAESInit,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx, int ctxSize)) -IPPAPI(IppStatus, ippsAESSetKey,(const Ipp8u* pKey, int keyLen, IppsAESSpec* pCtx)) - -IPPAPI(IppStatus, ippsAESPack,(const IppsAESSpec* pCtx, Ipp8u* pBuffer, int buffSize)) -IPPAPI(IppStatus, ippsAESUnpack,(const Ipp8u* pBuffer, IppsAESSpec* pCtx, int ctxSize)) - -IPPAPI(IppStatus, ippsAESEncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsAESSpec* pCtx)) -IPPAPI(IppStatus, ippsAESDecryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsAESSpec* pCtx)) - -IPPAPI(IppStatus, ippsAESEncryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsAESSpec* pCtx, - const Ipp8u* pIV)) -IPPAPI(IppStatus, ippsAESDecryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsAESSpec* pCtx, - const Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsAESEncryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize, - const IppsAESSpec* pCtx, - const Ipp8u* pIV)) -IPPAPI(IppStatus, ippsAESDecryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize, - const IppsAESSpec* pCtx, - const Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsAESEncryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsAESSpec* pCtx, - Ipp8u* pIV)) -IPPAPI(IppStatus, ippsAESDecryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsAESSpec* pCtx, - Ipp8u* pIV)) - -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)) - -/* SMS4 */ -IPPAPI(IppStatus, ippsSMS4GetSize,(int *pSize)) -IPPAPI(IppStatus, ippsSMS4Init,(const Ipp8u* pKey, int keyLen, IppsSMS4Spec* pCtx, int ctxSize)) -IPPAPI(IppStatus, ippsSMS4SetKey,(const Ipp8u* pKey, int keyLen, IppsSMS4Spec* pCtx)) - -IPPAPI(IppStatus, ippsSMS4EncryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx)) -IPPAPI(IppStatus, ippsSMS4DecryptECB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx)) - -IPPAPI(IppStatus, ippsSMS4EncryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx, - const Ipp8u* pIV)) -IPPAPI(IppStatus, ippsSMS4DecryptCBC,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx, - const Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsSMS4EncryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize, - const IppsSMS4Spec* pCtx, - const Ipp8u* pIV)) -IPPAPI(IppStatus, ippsSMS4DecryptCFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int cfbBlkSize, - const IppsSMS4Spec* pCtx, - const Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsSMS4EncryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsSMS4Spec* pCtx, - Ipp8u* pIV)) -IPPAPI(IppStatus, ippsSMS4DecryptOFB,(const Ipp8u* pSrc, Ipp8u* pDst, int len, int ofbBlkSize, - const IppsSMS4Spec* pCtx, - Ipp8u* pIV)) - -IPPAPI(IppStatus, ippsSMS4EncryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx, - Ipp8u* pCtrValue, int ctrNumBitSize)) -IPPAPI(IppStatus, ippsSMS4DecryptCTR,(const Ipp8u* pSrc, Ipp8u* pDst, int len, - const IppsSMS4Spec* pCtx, - Ipp8u* pCtrValue, int ctrNumBitSize)) - - -/* -// ========================================================= -// AES based authentication & confidence Primitives -// ========================================================= -*/ - -/* -// AES-CCM -*/ -IPPAPI(IppStatus, ippsAES_CCMGetSize,(int* pSize)) -IPPAPI(IppStatus, ippsAES_CCMInit,(const Ipp8u* pKey, int keyLen, IppsAES_CCMState* pCtx, int ctxSize)) - -IPPAPI(IppStatus, ippsAES_CCMMessageLen,(Ipp64u msgLen, IppsAES_CCMState* pCtx)) -IPPAPI(IppStatus, ippsAES_CCMTagLen,(int tagLen, IppsAES_CCMState* pCtx)) - -IPPAPI(IppStatus, ippsAES_CCMStart,(const Ipp8u* pIV, int ivLen, const Ipp8u* pAD, int adLen, IppsAES_CCMState* pCtx)) -IPPAPI(IppStatus, ippsAES_CCMEncrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pCtx)) -IPPAPI(IppStatus, ippsAES_CCMDecrypt,(const Ipp8u* pSrc, Ipp8u* pDst, int len, IppsAES_CCMState* pCtx)) -IPPAPI(IppStatus, ippsAES_CCMGetTag,(Ipp8u* pTag, int tagLen, const IppsAES_CCMState* pCtx)) - -/* -// 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)) - -/* -// ========================================================= -// RC4 Stream Ciphers -// ========================================================= -*/ -IPPAPI(IppStatus, ippsARCFourCheckKey, (const Ipp8u *pKey, int keyLen, IppBool* pIsWeak)) - -IPPAPI(IppStatus, ippsARCFourGetSize, (int* pSize)) -IPPAPI(IppStatus, ippsARCFourInit, (const Ipp8u *pKey, int keyLen, IppsARCFourState *pCtx)) -IPPAPI(IppStatus, ippsARCFourReset, (IppsARCFourState* pCtx)) - -IPPAPI(IppStatus, ippsARCFourPack,(const IppsARCFourState* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsARCFourUnpack,(const Ipp8u* pBuffer, IppsARCFourState* pCtx)) - -IPPAPI(IppStatus, ippsARCFourEncrypt, (const Ipp8u *pSrc, Ipp8u *pDst, int length, IppsARCFourState *pCtx)) -IPPAPI(IppStatus, ippsARCFourDecrypt, (const Ipp8u *pSrc, Ipp8u *pDst, int length, IppsARCFourState *pCtx)) - - -/* -// ========================================================= -// One-Way Hash Functions -// ========================================================= -*/ -/* SHA1 Hash Primitives */ -IPPAPI(IppStatus, ippsSHA1GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSHA1Init,(IppsSHA1State* pCtx)) -IPPAPI(IppStatus, ippsSHA1Duplicate,(const IppsSHA1State* pSrcCtx, IppsSHA1State* pDstCtx)) - -IPPAPI(IppStatus, ippsSHA1Pack,(const IppsSHA1State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSHA1Unpack,(const Ipp8u* pBuffer, IppsSHA1State* pCtx)) - -IPPAPI(IppStatus, ippsSHA1Update,(const Ipp8u* pSrc, int len, IppsSHA1State* pCtx)) -IPPAPI(IppStatus, ippsSHA1GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA1State* pCtx)) -IPPAPI(IppStatus, ippsSHA1Final,(Ipp8u* pMD, IppsSHA1State* pCtx)) -IPPAPI(IppStatus, ippsSHA1MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* SHA224 Hash Primitives */ -IPPAPI(IppStatus, ippsSHA224GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSHA224Init,(IppsSHA224State* pCtx)) -IPPAPI(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcCtx, IppsSHA224State* pDstCtx)) - -IPPAPI(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pCtx)) - -IPPAPI(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pCtx)) -IPPAPI(IppStatus, ippsSHA224GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA224State* pCtx)) -IPPAPI(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pCtx)) -IPPAPI(IppStatus, ippsSHA224MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* SHA256 Hash Primitives */ -IPPAPI(IppStatus, ippsSHA256GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSHA256Init,(IppsSHA256State* pCtx)) -IPPAPI(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcCtx, IppsSHA256State* pDstCtx)) - -IPPAPI(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pCtx)) - -IPPAPI(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pCtx)) -IPPAPI(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pCtx)) -IPPAPI(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pCtx)) -IPPAPI(IppStatus, ippsSHA256MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* SHA384 Hash Primitives */ -IPPAPI(IppStatus, ippsSHA384GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSHA384Init,(IppsSHA384State* pCtx)) -IPPAPI(IppStatus, ippsSHA384Duplicate,(const IppsSHA384State* pSrcCtx, IppsSHA384State* pDstCtx)) - -IPPAPI(IppStatus, ippsSHA384Pack,(const IppsSHA384State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSHA384Unpack,(const Ipp8u* pBuffer, IppsSHA384State* pCtx)) - -IPPAPI(IppStatus, ippsSHA384Update,(const Ipp8u* pSrc, int len, IppsSHA384State* pCtx)) -IPPAPI(IppStatus, ippsSHA384GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA384State* pCtx)) -IPPAPI(IppStatus, ippsSHA384Final,(Ipp8u* pMD, IppsSHA384State* pCtx)) -IPPAPI(IppStatus, ippsSHA384MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* SHA512 Hash Primitives */ -IPPAPI(IppStatus, ippsSHA512GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSHA512Init,(IppsSHA512State* pCtx)) -IPPAPI(IppStatus, ippsSHA512Duplicate,(const IppsSHA512State* pSrcCtx, IppsSHA512State* pDstCtx)) - -IPPAPI(IppStatus, ippsSHA512Pack,(const IppsSHA512State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSHA512Unpack,(const Ipp8u* pBuffer, IppsSHA512State* pCtx)) - -IPPAPI(IppStatus, ippsSHA512Update,(const Ipp8u* pSrc, int len, IppsSHA512State* pCtx)) -IPPAPI(IppStatus, ippsSHA512GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA512State* pCtx)) -IPPAPI(IppStatus, ippsSHA512Final,(Ipp8u* pMD, IppsSHA512State* pCtx)) -IPPAPI(IppStatus, ippsSHA512MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* MD5 Hash Primitives */ -IPPAPI(IppStatus, ippsMD5GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsMD5Init,(IppsMD5State* pCtx)) -IPPAPI(IppStatus, ippsMD5Duplicate,(const IppsMD5State* pSrcCtx, IppsMD5State* pDstCtx)) - -IPPAPI(IppStatus, ippsMD5Pack,(const IppsMD5State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsMD5Unpack,(const Ipp8u* pBuffer, IppsMD5State* pCtx)) - -IPPAPI(IppStatus, ippsMD5Update,(const Ipp8u* pSrc, int len, IppsMD5State* pCtx)) -IPPAPI(IppStatus, ippsMD5GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsMD5State* pCtx)) -IPPAPI(IppStatus, ippsMD5Final,(Ipp8u* pMD, IppsMD5State* pCtx)) -IPPAPI(IppStatus, ippsMD5MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* SM3 Hash Primitives */ -IPPAPI(IppStatus, ippsSM3GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsSM3Init,(IppsSM3State* pCtx)) -IPPAPI(IppStatus, ippsSM3Duplicate,(const IppsSM3State* pSrcCtx, IppsSM3State* pDstCtx)) - -IPPAPI(IppStatus, ippsSM3Pack,(const IppsSM3State* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsSM3Unpack,(const Ipp8u* pBuffer, IppsSM3State* pCtx)) - -IPPAPI(IppStatus, ippsSM3Update,(const Ipp8u* pSrc, int len, IppsSM3State* pCtx)) -IPPAPI(IppStatus, ippsSM3GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSM3State* pCtx)) -IPPAPI(IppStatus, ippsSM3Final,(Ipp8u* pMD, IppsSM3State* pCtx)) -IPPAPI(IppStatus, ippsSM3MessageDigest,(const Ipp8u* pMsg, int len, Ipp8u* pMD)) - -/* generalized Hash Primitives */ -IPPAPI(IppStatus, ippsHashGetSize,(int* pSize)) -IPPAPI(IppStatus, ippsHashInit,(IppsHashState* pCtx, IppHashAlgId hashAlg)) - -IPPAPI(IppStatus, ippsHashPack,(const IppsHashState* pCtx, Ipp8u* pBuffer, int bufSize)) -IPPAPI(IppStatus, ippsHashUnpack,(const Ipp8u* pBuffer, IppsHashState* pCtx)) -IPPAPI(IppStatus, ippsHashDuplicate,(const IppsHashState* pSrcCtx, IppsHashState* pDstCtx)) - -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)) - -/* general MGF Primitives*/ -IPPAPI(IppStatus, ippsMGF,(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen, IppHashAlgId hashAlg)) - - -/* -// ========================================================= -// Keyed-Hash Message Authentication Codes -// ========================================================= -*/ -IPPAPI(IppStatus, ippsHMAC_GetSize,(int* pSize)) -IPPAPI(IppStatus, ippsHMAC_Init,(const Ipp8u* pKey, int keyLen, IppsHMACState* pCtx, IppHashAlgId hashAlg)) - -IPPAPI(IppStatus, ippsHMAC_Pack,(const IppsHMACState* pCtx, Ipp8u* pBuffer, int bufSize)) -IPPAPI(IppStatus, ippsHMAC_Unpack,(const Ipp8u* pBuffer, IppsHMACState* pCtx)) -IPPAPI(IppStatus, ippsHMAC_Duplicate,(const IppsHMACState* pSrcCtx, IppsHMACState* pDstCtx)) - -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 -// ========================================================= -*/ - -/* Signed BigNum Operations */ -IPPAPI(IppStatus, ippsBigNumGetSize,(int length, int* pSize)) -IPPAPI(IppStatus, ippsBigNumInit,(int length, IppsBigNumState* pBN)) - -IPPAPI(IppStatus, ippsCmpZero_BN,(const IppsBigNumState* pBN, Ipp32u* pResult)) -IPPAPI(IppStatus, ippsCmp_BN,(const IppsBigNumState* pA, const IppsBigNumState* pB, Ipp32u* pResult)) - -IPPAPI(IppStatus, ippsGetSize_BN,(const IppsBigNumState* pBN, int* pSize)) -IPPAPI(IppStatus, ippsSet_BN,(IppsBigNumSGN sgn, - int length, const Ipp32u* pData, - IppsBigNumState* pBN)) -IPPAPI(IppStatus, ippsGet_BN,(IppsBigNumSGN* pSgn, - int* pLength, Ipp32u* pData, - const IppsBigNumState* pBN)) -IPPAPI(IppStatus, ippsRef_BN,(IppsBigNumSGN* pSgn, int* bitSize, Ipp32u** const ppData, - const IppsBigNumState* pBN)) -IPPAPI(IppStatus, ippsExtGet_BN,(IppsBigNumSGN* pSgn, - int* pBitSize, Ipp32u* pData, - 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, ippsMul_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsMAC_BN_I, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsDiv_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pQ, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsMod_BN, (IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsGcd_BN, (IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pGCD)) -IPPAPI(IppStatus, ippsModInv_BN,(IppsBigNumState* pA, IppsBigNumState* pM, IppsBigNumState* pInv)) - -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, ippsMontGet,(Ipp32u* pModulo, int* pSize, const IppsMontState* pCtx)) - -IPPAPI(IppStatus, ippsMontForm,(const IppsBigNumState* pA, IppsMontState* pCtx, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsMontMul, (const IppsBigNumState* pA, const IppsBigNumState* pB, IppsMontState* m, IppsBigNumState* pR)) -IPPAPI(IppStatus, ippsMontExp, (const IppsBigNumState* pA, const IppsBigNumState* pE, IppsMontState* m, IppsBigNumState* pR)) - -/* Pseudo-Random Number Generation */ -IPPAPI(IppStatus, ippsPRNGGetSize,(int* pSize)) -IPPAPI(IppStatus, ippsPRNGInit, (int seedBits, IppsPRNGState* pCtx)) - -IPPAPI(IppStatus, ippsPRNGSetModulus,(const IppsBigNumState* pMod, IppsPRNGState* pCtx)) -IPPAPI(IppStatus, ippsPRNGSetH0, (const IppsBigNumState* pH0, IppsPRNGState* pCtx)) -IPPAPI(IppStatus, ippsPRNGSetAugment,(const IppsBigNumState* pAug, IppsPRNGState* pCtx)) -IPPAPI(IppStatus, ippsPRNGSetSeed, (const IppsBigNumState* pSeed,IppsPRNGState* pCtx)) -IPPAPI(IppStatus, ippsPRNGGetSeed, (const IppsPRNGState* pCtx,IppsBigNumState* pSeed)) - -IPPAPI(IppStatus, ippsPRNGen, (Ipp32u* pRand, int nBits, void* pCtx)) -IPPAPI(IppStatus, ippsPRNGen_BN, (IppsBigNumState* pRand, int nBits, void* pCtx)) -IPPAPI(IppStatus, ippsPRNGenRDRAND, (Ipp32u* pRand, int nBits, void* pCtx)) -IPPAPI(IppStatus, ippsPRNGenRDRAND_BN,(IppsBigNumState* pRand, int nBits, void* pCtx)) -IPPAPI(IppStatus, ippsTRNGenRDSEED, (Ipp32u* pRand, int nBits, void* pCtx)) -IPPAPI(IppStatus, ippsTRNGenRDSEED_BN,(IppsBigNumState* pRand, int nBits, void* pCtx)) - -/* Probable Prime Number Generation */ -IPPAPI(IppStatus, ippsPrimeGetSize,(int nMaxBits, int* pSize)) -IPPAPI(IppStatus, ippsPrimeInit, (int nMaxBits, IppsPrimeState* pCtx)) - -IPPAPI(IppStatus, ippsPrimeGen, (int nBits, int nTrials, IppsPrimeState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsPrimeTest,(int nTrials, Ipp32u* pResult, IppsPrimeState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsPrimeGen_BN,(IppsBigNumState* pPrime, int nBits, int nTrials, IppsPrimeState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsPrimeTest_BN,(const IppsBigNumState* pPrime, int nTrials, Ipp32u* pResult, IppsPrimeState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) - -IPPAPI(IppStatus, ippsPrimeGet, (Ipp32u* pPrime, int* pLen, const IppsPrimeState* pCtx)) -IPPAPI(IppStatus, ippsPrimeGet_BN,(IppsBigNumState* pPrime, const IppsPrimeState* pCtx)) - -IPPAPI(IppStatus, ippsPrimeSet, (const Ipp32u* pPrime, int nBits, IppsPrimeState* pCtx)) -IPPAPI(IppStatus, ippsPrimeSet_BN,(const IppsBigNumState* pPrime, IppsPrimeState* pCtx)) - - -/* -// ========================================================= -// RSA Cryptography -// ========================================================= -*/ -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_GetPrivateKeyType1,(IppsBigNumState* pModulus, - IppsBigNumState* pPrivateExp, - const 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_GetPrivateKeyType2,(IppsBigNumState* pFactorP, - IppsBigNumState* pFactorQ, - IppsBigNumState* pCrtExpP, - IppsBigNumState* pCrtExpQ, - IppsBigNumState* pInverseQ, - const 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_GenerateKeys,(const IppsBigNumState* pSrcPublicExp, - IppsBigNumState* pModulus, - IppsBigNumState* pPublicExp, - IppsBigNumState* pPrivateExp, - IppsRSAPrivateKeyState* pPrivateKeyType2, - Ipp8u* pScratchBuffer, - int nTrials, - IppsPrimeState* pPrimeGen, - IppBitSupplier rndFunc, void* pRndParam)) - -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, ippsRSADecrypt_OAEP,(const Ipp8u* pSrc, - const Ipp8u* pLab, int labLen, - Ipp8u* pDst, int* pDstLen, - const IppsRSAPrivateKeyState* pKey, - IppHashAlgId hashAlg, - Ipp8u* pBuffer)) - -/* encryption scheme: RSAES-PKCS_v1_5 */ -IPPAPI(IppStatus, ippsRSAEncrypt_PKCSv15,(const Ipp8u* pSrc, int srcLen, - const Ipp8u* pRndPS, - Ipp8u* pDst, - const IppsRSAPublicKeyState* pKey, - Ipp8u* pBuffer)) - -IPPAPI(IppStatus, ippsRSADecrypt_PKCSv15,(const Ipp8u* pSrc, - Ipp8u* pDst, int* pDstLen, - const IppsRSAPrivateKeyState* pKey, - Ipp8u* pBuffer)) - - -/* signature scheme : RSA-SSA-PSS */ -IPPAPI(IppStatus, ippsRSASign_PSS,(const Ipp8u* pMsg, int msgLen, - const Ipp8u* pSalt, int saltLen, - Ipp8u* pSign, - const IppsRSAPrivateKeyState* pPrvKey, - const IppsRSAPublicKeyState* pPubKey, - IppHashAlgId hashAlg, - Ipp8u* pBuffer)) - -IPPAPI(IppStatus, ippsRSAVerify_PSS,(const Ipp8u* pMsg, int msgLen, - const Ipp8u* pSign, - int* pIsValid, - const IppsRSAPublicKeyState* pKey, - IppHashAlgId hashAlg, - 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)) - -/* -// ========================================================= -// DL Cryptography -// ========================================================= -*/ -IPPAPI( const char*, ippsDLGetResultString, (IppDLResult code)) - -/* Initialization */ -IPPAPI(IppStatus, ippsDLPGetSize,(int bitSizeP, int bitSizeR, int* pSize)) -IPPAPI(IppStatus, ippsDLPInit, (int bitSizeP, int bitSizeR, IppsDLPState* pCtx)) - -IPPAPI(IppStatus, ippsDLPPack,(const IppsDLPState* pCtx, Ipp8u* pBuffer)) -IPPAPI(IppStatus, ippsDLPUnpack,(const Ipp8u* pBuffer, IppsDLPState* pCtx)) - -/* Set Up and Retrieve Domain Parameters */ -IPPAPI(IppStatus, ippsDLPSet,(const IppsBigNumState* pP, - const IppsBigNumState* pR, - const IppsBigNumState* pG, - IppsDLPState* pCtx)) -IPPAPI(IppStatus, ippsDLPGet,(IppsBigNumState* pP, - IppsBigNumState* pR, - IppsBigNumState* pG, - IppsDLPState* pCtx)) -IPPAPI(IppStatus, ippsDLPSetDP,(const IppsBigNumState* pDP, IppDLPKeyTag tag, IppsDLPState* pCtx)) -IPPAPI(IppStatus, ippsDLPGetDP,(IppsBigNumState* pDP, IppDLPKeyTag tag, const IppsDLPState* pCtx)) - -/* Key Generation, Validation and Set Up */ -IPPAPI(IppStatus, ippsDLPGenKeyPair,(IppsBigNumState* pPrvKey, IppsBigNumState* pPubKey, - IppsDLPState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsDLPPublicKey, (const IppsBigNumState* pPrvKey, - IppsBigNumState* pPubKey, - IppsDLPState* pCtx)) -IPPAPI(IppStatus, ippsDLPValidateKeyPair,(const IppsBigNumState* pPrvKey, - const IppsBigNumState* pPubKey, - IppDLResult* pResult, - IppsDLPState* pCtx)) - -IPPAPI(IppStatus, ippsDLPSetKeyPair,(const IppsBigNumState* pPrvKey, - const IppsBigNumState* pPubKey, - IppsDLPState* pCtx)) - -/* Singing/Verifying (DSA version) */ -IPPAPI(IppStatus, ippsDLPSignDSA, (const IppsBigNumState* pMsgDigest, - const IppsBigNumState* pPrvKey, - IppsBigNumState* pSignR, IppsBigNumState* pSignS, - IppsDLPState* pCtx)) -IPPAPI(IppStatus, ippsDLPVerifyDSA,(const IppsBigNumState* pMsgDigest, - const IppsBigNumState* pSignR, const IppsBigNumState* pSignS, - IppDLResult* pResult, - IppsDLPState* pCtx)) - -/* Shared Secret Element (DH version) */ -IPPAPI(IppStatus, ippsDLPSharedSecretDH,(const IppsBigNumState* pPrvKeyA, - const IppsBigNumState* pPubKeyB, - IppsBigNumState* pShare, - IppsDLPState* pCtx)) - -/* DSA's parameter Generation and Validation */ -IPPAPI(IppStatus, ippsDLPGenerateDSA,(const IppsBigNumState* pSeedIn, - int nTrials, IppsDLPState* pCtx, - IppsBigNumState* pSeedOut, int* pCounter, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsDLPValidateDSA,(int nTrials, IppDLResult* pResult, IppsDLPState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) - -/* DH parameter's Generation and Validation */ -IPPAPI(IppStatus, ippsDLPGenerateDH,(const IppsBigNumState* pSeedIn, - int nTrials, IppsDLPState* pCtx, - IppsBigNumState* pSeedOut, int* pCounter, - IppBitSupplier rndFunc, void* pRndParam)) -IPPAPI(IppStatus, ippsDLPValidateDH,(int nTrials, IppDLResult* pResult, IppsDLPState* pCtx, - IppBitSupplier rndFunc, void* pRndParam)) - - -/* -// ========================================================= -// EC Cryptography -// ========================================================= -*/ -IPPAPI( const char*, ippsECCGetResultString, (IppECResult code)) - -/* -// EC over Prime Fields -*/ -/* general EC initialization */ -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)) - -/* standard EC initialization */ -IPPAPI(IppStatus, ippsECCPGetSizeStd128r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd128r2,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd192r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd224r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd256r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd384r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStd521r1,(int* pSize)) -IPPAPI(IppStatus, ippsECCPGetSizeStdSM2,(int* pSize)) - -IPPAPI(IppStatus, ippsECCPInitStd128r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd128r2,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd192r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd224r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd256r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd384r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStd521r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPInitStdSM2,(IppsECCPState* pECC)) - -IPPAPI(IppStatus, ippsECCPSetStd128r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd128r2,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd192r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd224r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd256r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd384r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStd521r1,(IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetStdSM2,(IppsECCPState* pECC)) - -IPPAPI(IppStatus, ippsECCPSetStd,(IppECCType flag, IppsECCPState* pECC)) - -IPPAPI(IppStatus, ippsECCPGet,(IppsBigNumState* pPrime, - IppsBigNumState* pA, IppsBigNumState* pB, - IppsBigNumState* pGX,IppsBigNumState* pGY,IppsBigNumState* pOrder, - int* cofactor, - IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pECC)) - -IPPAPI(IppStatus, ippsECCPValidate,(int nTrials, IppECResult* pResult, IppsECCPState* pECC, - IppBitSupplier rndFunc, void* pRndParam)) - -/* EC Point */ -IPPAPI(IppStatus, ippsECCPPointGetSize,(int feBitSize, int* pSize)) - -IPPAPI(IppStatus, ippsECCPPointInit,(int feBitSize, IppsECCPPointState* pPoint)) - -/* Setup/retrieve point's coordinates */ -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)) - -/* EC Point Operations */ -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)) - -/* Key Generation, Setup and Validation */ -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, ippsECCPValidateKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic, - IppECResult* pResult, - IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSetKeyPair,(const IppsBigNumState* pPrivate, const IppsECCPPointState* pPublic, - IppBool regular, - IppsECCPState* pECC)) - -/* Shared Secret (DH scheme ) */ -IPPAPI(IppStatus, ippsECCPSharedSecretDH,(const IppsBigNumState* pPrivateA, - const IppsECCPPointState* pPublicB, - IppsBigNumState* pShare, - IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPSharedSecretDHC,(const IppsBigNumState* pPrivateA, - const IppsECCPPointState* pPublicB, - IppsBigNumState* pShare, - IppsECCPState* pECC)) - -/* Sing/Verify */ -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)) - -IPPAPI(IppStatus, ippsECCPSignNR,(const IppsBigNumState* pMsgDigest, - const IppsBigNumState* pPrivate, - IppsBigNumState* pSignX, IppsBigNumState* pSignY, - IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPVerifyNR,(const IppsBigNumState* pMsgDigest, - const IppsBigNumState* pSignX, const IppsBigNumState* pSignY, - IppECResult* pResult, - IppsECCPState* pECC)) - -IPPAPI(IppStatus, ippsECCPSignSM2,(const IppsBigNumState* pMsgDigest, - const IppsBigNumState* pRegPrivate, - const IppsBigNumState* pEphPrivate, - IppsBigNumState* pSignR, IppsBigNumState* pSignS, - IppsECCPState* pECC)) -IPPAPI(IppStatus, ippsECCPVerifySM2,(const IppsBigNumState* pMsgDigest, - const IppsECCPPointState* pRegPublic, - const IppsBigNumState* pSignR, const IppsBigNumState* pSignS, - 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/epid/ext/ipp/include/ippcpdefs.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcpdefs.h deleted file mode 100644 index aa306221e8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcpdefs.h +++ /dev/null @@ -1,371 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippCP) definitions. -// -// -*/ - - -#ifndef __IPPCPDEFS_H__ -#define __IPPCPDEFS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined( _OWN_BLDPCS ) - -typedef Ipp32u IppAlgId; - -/* -// ========================================================= -// Symmetric Ciphers -// ========================================================= -*/ -typedef enum { - ippPaddingNONE = 0, /*NONE = 0,*/ IppsCPPaddingNONE = 0, - ippPaddingPKCS7 = 1, /*PKCS7 = 1,*/ IppsCPPaddingPKCS7 = 1, - ippPaddingZEROS = 2, /*ZEROS = 2,*/ IppsCPPaddingZEROS = 2 -} IppsPadding, IppsCPPadding; - -typedef struct _cpDES IppsDESSpec; -typedef struct _cpRijndael128 IppsAESSpec; -typedef struct _cpRijndael128 IppsRijndael128Spec; -typedef struct _cpSMS4 IppsSMS4Spec; - -/* TDES */ -#define DES_BLOCKSIZE (64) /* cipher blocksize (bits) */ -#define TDES_BLOCKSIZE DES_BLOCKSIZE - -#define DES_KEYSIZE (64) /* cipher keysize (bits) */ -#define TDES_KEYSIZE DES_KEYSIZE - -/* AES */ -#define IPP_AES_BLOCK_BITSIZE (128) /* cipher blocksizes (bits) */ - -/* Rijndael */ -typedef enum { - ippRijndaelKey128 = 128, IppsRijndaelKey128 = 128, /* 128-bit key */ - ippRijndaelKey192 = 192, IppsRijndaelKey192 = 192, /* 192-bit key */ - ippRijndaelKey256 = 256, IppsRijndaelKey256 = 256 /* 256-bit key */ -} IppsRijndaelKeyLength; - -/* AES based authentication & confidence */ -typedef struct _cpRijndael128GCM IppsRijndael128GCMState; -typedef struct _cpAES_CCM IppsAES_CCMState; -typedef struct _cpRijndael128GCM IppsAES_GCMState; - -/* -// ========================================================= -// ARCFOUR Stream Cipher -// ========================================================= -*/ -typedef struct _cpARCfour IppsARCFourState; - -#define IPP_ARCFOUR_KEYMAX_SIZE (256) /* max key length (bytes) */ -#define MAX_ARCFOUR_KEY_LEN IPP_ARCFOUR_KEYMAX_SIZE /* obsolete */ - -/* -// ========================================================= -// One-Way Hash Functions -// ========================================================= -*/ -typedef enum { - ippHashAlg_Unknown, - ippHashAlg_SHA1, - ippHashAlg_SHA256, - ippHashAlg_SHA224, - ippHashAlg_SHA512, - ippHashAlg_SHA384, - ippHashAlg_MD5, - ippHashAlg_SM3, - 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_SM3 (ippHashAlg_SM3) /* SM3 */ -#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*/ - -typedef struct _cpSHA1 IppsSHA1State; -typedef struct _cpSHA256 IppsSHA256State; -typedef struct _cpSHA256 IppsSHA224State; -typedef struct _cpSHA512 IppsSHA512State; -typedef struct _cpSHA512 IppsSHA384State; -typedef struct _cpMD5 IppsMD5State; -typedef struct _cpSM3 IppsSM3State; -typedef struct _cpHashCtx IppsHashState; - - -/* MGF */ -typedef IppStatus (__STDCALL *IppMGF)(const Ipp8u* pSeed, int seedLen, Ipp8u* pMask, int maskLen); -/* HASH function */ -typedef IppStatus (__STDCALL *IppHASH)(const Ipp8u* pMsg, int len, Ipp8u* pMD); - -#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_SM3_DIGEST_BITSIZE 256 -#define IPP_SHA512_224_DIGEST_BITSIZE 224 -#define IPP_SHA512_256_DIGEST_BITSIZE 256 - -/* -// ========================================================= -// Keyed-Hash Message Authentication Codes -// ========================================================= -*/ -typedef struct _cpHMAC IppsHMACState; -typedef struct _cpHMAC IppsHMACSHA1State; -typedef struct _cpHMAC IppsHMACSHA256State; -typedef struct _cpHMAC IppsHMACSHA224State; -typedef struct _cpHMAC IppsHMACSHA384State; -typedef struct _cpHMAC IppsHMACSHA512State; -typedef struct _cpHMAC IppsHMACMD5State; - -/* -// ========================================================= -// Data Authentication Codes -// ========================================================= -*/ -typedef struct _cpAES_CMAC IppsAES_CMACState; - -/* -// ========================================================= -// Big Number Integer Arithmetic -// ========================================================= -*/ -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); - -#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 - -/* -// ========================================================= -// RSA Cryptography -// ========================================================= -*/ -typedef struct _cpRSA IppsRSAState; - -/* key types */ -typedef enum { - ippRSApublic = 0x20000000, IppRSApublic = 0x20000000, - ippRSAprivate = 0x40000000, IppRSAprivate = 0x40000000 -} IppRSAKeyType; - -/* key component's tag */ -typedef enum { - ippRSAkeyN = 0x01, IppRSAkeyN = 0x01, - ippRSAkeyE = 0x02, IppRSAkeyE = 0x02, - ippRSAkeyD = 0x04, IppRSAkeyD = 0x04, - ippRSAkeyP = 0x08, IppRSAkeyP = 0x08, - ippRSAkeyQ = 0x10, IppRSAkeyQ = 0x10, - ippRSAkeyDp = 0x20, IppRSAkeyDp = 0x20, - ippRSAkeyDq = 0x40, IppRSAkeyDq = 0x40, - ippRSAkeyQinv = 0x80, IppRSAkeyQinv = 0x80 -} IppRSAKeyTag; - -typedef struct _cpRSA_public_key IppsRSAPublicKeyState; -typedef struct _cpRSA_private_key IppsRSAPrivateKeyState; - -#define MIN_RSA_SIZE (8) -#define MAX_RSA_SIZE (4096) - -/* -// ========================================================= -// DL Cryptography -// ========================================================= -*/ -typedef struct _cpDLP IppsDLPState; - -/* domain parameter tags */ -typedef enum { - ippDLPkeyP = 0x01, IppDLPkeyP = 0x01, - ippDLPkeyR = 0x02, IppDLPkeyR = 0x02, - ippDLPkeyG = 0x04, IppDLPkeyG = 0x04 -} IppDLPKeyTag; - -typedef enum { - ippDLValid, /* validation pass successfully */ - - ippDLBaseIsEven, /* !(P is odd) */ - ippDLOrderIsEven, /* !(R is odd) */ - ippDLInvalidBaseRange, /* !(2^(L-1) < P < 2^L) */ - ippDLInvalidOrderRange, /* !(2^(M-1) < R < 2^M) */ - ippDLCompositeBase, - ippDLCompositeOrder, - ippDLInvalidCofactor, /* !( R|(P-1) ) */ - ippDLInvalidGenerator, /* !( G^R == 1 (mod P) ) */ - /* !(1 < G < (P-1)) */ - ippDLInvalidPrivateKey, /* !(1 < private < (R-1)) */ - ippDLInvalidPublicKey, /* !(1 < public <=(P-1)) */ - ippDLInvalidKeyPair, /* !(G^private == public */ - - ippDLInvalidSignature /* invalid signature */ -} IppDLResult; - -#define MIN_DLP_BITSIZE (512) -#define MIN_DLP_BITSIZER (160) - -#define MIN_DLPDH_BITSIZE (512) -#define MIN_DLPDH_BITSIZER (160) -#define DEF_DLPDH_BITSIZER (160) - -#define MIN_DLPDSA_BITSIZE (512) -#define MAX_DLPDSA_BITSIZE (1024) -#define MIN_DLPDSA_BITSIZER (160) -#define DEF_DLPDSA_BITSIZER (160) -#define MAX_DLPDSA_BITSIZER (160) -#define MIN_DLPDSA_SEEDSIZE (160) - -/* -// ========================================================= -// EC Cryptography -// ========================================================= -*/ -typedef struct _cpECCP IppsECCPState; -typedef struct _cpECCB IppsECCBState; -typedef struct _cpECCPPoint IppsECCPPointState; -typedef struct _cpECCBPoint IppsECCBPointState; - -/* 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; - -/* domain parameter set/get flags */ -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 */ - ippECPstdSM2 = ippECPstd+11, IppECCPStdSM2 = IppECCPStd+11, /* TMP SM2 curve */ - ippEC_TPM_SM2_P256= ippECPstd+11, - ippEC_TPM_BN_P256 = ippECPstd+12, /* TPM BN_P256 curve */ - - /* curves over binary finit fields are not supported in IPP 9.0 */ - IppECCBStd = 0x20000, /* random (recommended) EC over FG(2^m): */ - IppECCBStd113r1 = IppECCBStd, /* sect113r1 curve */ - IppECCBStd113r2 = IppECCBStd+1, /* sect113r2 curve */ - IppECCBStd131r1 = IppECCBStd+2, /* sect131r1 curve */ - IppECCBStd131r2 = IppECCBStd+3, /* sect131r2 curve */ - IppECCBStd163r1 = IppECCBStd+4, /* sect163r1 curve */ - IppECCBStd163r2 = IppECCBStd+5, /* sect163r2 curve */ - IppECCBStd193r1 = IppECCBStd+6, /* sect193r1 curve */ - IppECCBStd193r2 = IppECCBStd+7, /* sect193r2 curve */ - IppECCBStd233r1 = IppECCBStd+8, /* sect233r1 curve */ - IppECCBStd283r1 = IppECCBStd+9, /* sect283r1 curve */ - IppECCBStd409r1 = IppECCBStd+10, /* sect409r1 curve */ - IppECCBStd571r1 = IppECCBStd+11, /* sect571r1 curve */ - - IppECCKStd = 0x40000, /* Koblitz (recommended) EC over FG(2^m): */ - IppECCBStd163k1 = IppECCKStd, /* Koblitz 163 curve */ - IppECCBStd233k1 = IppECCKStd+1, /* Koblitz 233 curve */ - IppECCBStd239k1 = IppECCKStd+2, /* Koblitz 239 curve */ - IppECCBStd283k1 = IppECCKStd+3, /* Koblitz 283 curve */ - IppECCBStd409k1 = IppECCKStd+4, /* Koblitz 409 curve */ - IppECCBStd571k1 = IppECCKStd+5 /* Koblitz 571 curve */ -} IppsECType, IppECCType; - -#endif /* _OWN_BLDPCS */ - -#ifdef __cplusplus -} -#endif - -#endif /* __IPPCPDEFS_H__ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcpepid.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcpepid.h deleted file mode 100644 index d36661bfde..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippcpepid.h +++ /dev/null @@ -1,218 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// ippCP Intel(R) EPID functionality -// -// -*/ - - -#if !defined( __IPPCPEPID_H__ ) || defined( _OWN_BLDPCS ) -#define __IPPCPEPID_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 - -#if !defined( _IPP_NO_DEFAULT_LIB ) - #if defined( _IPP_PARALLEL_DYNAMIC ) || defined( _IPP_SEQUENTIAL_DYNAMIC ) - #pragma comment( lib, "ippcpepid" ) - #pragma comment( lib, "ippcp" ) - #pragma comment( lib, "ippcore" ) - #elif defined( _IPP_PARALLEL_STATIC ) || defined( _IPP_SEQUENTIAL_STATIC ) - #pragma comment( lib, "ippcpepidmt" ) - #pragma comment( lib, "ippcpmt" ) - #pragma comment( lib, "ippcoremt" ) - #endif -#endif - - -/* ///////////////////////////////////////////////////////////////////////////// -// Name: ippcpepidGetLibVersion -// Purpose: getting of the library version -// Returns: the structure of information about version of ippCP EPID library -// Parameters: -// -// Notes: not necessary to release the returned structure -*/ -IPPAPI( const IppLibraryVersion*, ippcpepidGetLibVersion, (void) ) - - -/* -// Finite Field Low Level Math -*/ -#define IPP_MIN_GF_BITSIZE (2) /* min bitsize for GF element */ -#define IPP_MAX_GF_BITSIZE (4096) /* max bitsize for GF element */ - -//#define IPP_IS_EQ IS_ZERO //(0) -//#define IPP_IS_NE (1) -//#define IPP_IS_GT GREATER_THAN_ZERO //(2) -//#define IPP_IS_LT LESS_THAN_ZERO // (3) -//#define IPP_IS_NA (4) - -#if !defined( _OWN_BLDPCS ) -typedef struct _cpGFp IppsGFpState; -typedef struct _cpElementGFp IppsGFpElement; - -typedef struct { - const IppsGFpState* pBasicGF; - const IppsGFpState* pGroundGF; - int basicGFdegree; - int groundGFdegree; - int elementLen; -} IppsGFpInfo; -#endif - -#if !defined( _OWN_BLDPCS ) -typedef enum { - ippMD5 = 0x00, - ippSHA1 = 0x01, - ippSHA256 = 0x02, ippSHA224 = 0x12, - ippSHA512 = 0x03, ippSHA384 = 0x13 -} IppHashID; -#endif /* _OWN_BLDPCS */ - - -IPPAPI(IppStatus, ippsGFpGetSize, (int bitSize, int* pStateSizeInBytes)) -IPPAPI(IppStatus, ippsGFpInit, (const Ipp32u* pPime, int bitSize, IppsGFpState* pGFp)) - -IPPAPI(IppStatus, ippsGFpxGetSize,(const IppsGFpState* pGroundGF, int degree, int* pStateSizeInBytes)) -IPPAPI(IppStatus, ippsGFpxInit, (const IppsGFpState* pGroundGF, const Ipp32u* pIrrPolynomial, int degree, IppsGFpState* pGFpx)) -IPPAPI(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, const IppsGFpElement* pGroundElm, int degree, IppsGFpState* pGFpx)) - -IPPAPI(IppStatus, ippsGFpGetInfo,(const IppsGFpState* pGFp, IppsGFpInfo* pInfo)) -IPPAPI(IppStatus, ippsGFpGetModulus,(const IppsGFpState* pGFp, Ipp32u* pModulus)) - -IPPAPI(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGF, int* pBufferSize)) - -//IPPAPI(IppStatus, ippsBasicGFpRef,(const IppsGFpState* pGFp, IppsGFpState** ppBasicGF)) -//IPPAPI(IppStatus, ippsGroundGFpRef,(const IppsGFpState* pGFp, IppsGFpState** ppGroundGF)) -//IPPAPI(IppStatus, ippsGFpGetDegree,(const IppsGFpState* pGFp, int* pDegree)) -//IPPAPI(IppStatus, ippsGFpGetElementLen,(const IppsGFpState* pGFp, int* pElmLen)) -//IPPAPI(IppStatus, ippsGFpCmp, (const IppsGFpState* pGFp1, const IppsGFpState* pGFp2, IppGFpResult* pCmpResult)) - -IPPAPI(IppStatus, ippsGFpElementGetSize,(const IppsGFpState* pGFp, int* pElementSize)) -IPPAPI(IppStatus, ippsGFpElementInit, (const Ipp32u* pA, int lenA, IppsGFpElement* pR, IppsGFpState* pGFp)) - -IPPAPI(IppStatus, ippsGFpSetElement, (const Ipp32u* pA, int nsA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSetElementOctString,(const Ipp8u* pStr, int strSize, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSetElementRandom,(IppBitSupplier rndFunc, void* pRndParam, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSetElementHash,(const Ipp8u* pMsg, int msgLen, IppHashID hashID, IppsGFpElement* pElm, IppsGFpState* pGF)) -IPPAPI(IppStatus, ippsGFpCpyElement,(const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpGetElement,(const IppsGFpElement* pA, Ipp32u* pDataA, int nsA, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpGetElementOctString,(const IppsGFpElement* pA, Ipp8u* pStr, int strSize, IppsGFpState* pGFp)) - -IPPAPI(IppStatus, ippsGFpCmpElement,(const IppsGFpElement* pA, const IppsGFpElement* pB, int* pResult, const IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpIsZeroElement,(const IppsGFpElement* pA, int* pResult, const IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpIsUnityElement,(const IppsGFpElement* pA, int* pResult, const IppsGFpState* pGFp)) - -//IPPAPI(IppStatus, ippsGFpSetPolyTerm, (const Ipp32u* pTerm, int nsT, int termDegree, IppsGFpElement* pElm, IppsGFpState* pGF)) -//IPPAPI(IppStatus, ippsGFpGetPolyTerm, (const IppsGFpElement* pElm, int termDegree, Ipp32u* pTerm, int nsT, IppsGFpState* pGF)) - -IPPAPI(IppStatus, ippsGFpConj,(const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpNeg, (const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpInv, (const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSqrt,(const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpAdd, (const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSub, (const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpMul, (const IppsGFpElement* pA, const IppsGFpElement* pB, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSqr, (const IppsGFpElement* pA, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpExp, (const IppsGFpElement* pA, const IppsBigNumState* pE, IppsGFpElement* pR, IppsGFpState* pGFp, Ipp8u* pScratchBuffer)) -IPPAPI(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems, IppsGFpElement* pElmR, IppsGFpState* pGF, Ipp8u* pScratchBuffer)) - -IPPAPI(IppStatus, ippsGFpAdd_GFpE,(const IppsGFpElement* pA, const IppsGFpElement* pGroundB, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpSub_GFpE,(const IppsGFpElement* pA, const IppsGFpElement* pGroundB, IppsGFpElement* pR, IppsGFpState* pGFp)) -IPPAPI(IppStatus, ippsGFpMul_GFpE,(const IppsGFpElement* pA, const IppsGFpElement* pGroundB, IppsGFpElement* pR, IppsGFpState* pGFp)) - - -#if !defined( _OWN_BLDPCS ) -typedef struct _cpGFpEC IppsGFpECState; -typedef struct _cpGFpECPoint IppsGFpECPoint; -#endif - -IPPAPI(IppStatus, ippsGFpECGetSize,(const IppsGFpState* pGF, int* pCtxSizeInBytes)) -IPPAPI(IppStatus, ippsGFpECInit, (const IppsGFpElement* pA, const IppsGFpElement* pB, - const IppsGFpElement* pX, const IppsGFpElement* pY, - const Ipp32u* pOrder, int orderLen, - const Ipp32u* pCofactor, int cofactorLen, - IppsGFpState* pGF, IppsGFpECState* pEC)) - -IPPAPI(IppStatus, ippsGFpECScratchBufferSize,(int nScalars, const IppsGFpECState* pEC, int* pBufferSize)) - -IPPAPI(IppStatus, ippsGFpECSet,(const IppsGFpElement* pA, const IppsGFpElement* pB, - const IppsGFpElement* pX, const IppsGFpElement* pY, - const Ipp32u* pOrder, int orderLen, - const Ipp32u* pCofactor, int cofactorLen, - IppsGFpECState* pEC)) - -IPPAPI(IppStatus, ippsGFpECGet,(const IppsGFpECState* pEC, - const IppsGFpState** ppGF, - IppsGFpElement* pA, IppsGFpElement* pB, - IppsGFpElement* pX, IppsGFpElement* pY, - const Ipp32u** ppOrder, int* pOrderLen, - const Ipp32u** ppCofactor, int* pCoFactorLen)) - -IPPAPI(IppStatus, ippsGFpECVerify,(IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) - -IPPAPI(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSizeInBytes)) -IPPAPI(IppStatus, ippsGFpECPointInit, (const IppsGFpElement* pX, const IppsGFpElement* pY, IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) - -IPPAPI(IppStatus, ippsGFpECSetPointAtInfinity,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECSetPoint,(const IppsGFpElement* pX, const IppsGFpElement* pY, IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECSetPointRandom,(IppBitSupplier rndFunc, void* pRndParam, IppsGFpECPoint* pPoint, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) -IPPAPI(IppStatus, ippsGFpECMakePoint,(const IppsGFpElement* pX, IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECSetPointHash,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppHashID hashID, IppsGFpECPoint* pPoint, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) - -IPPAPI(IppStatus, ippsGFpECCpyPoint,(const IppsGFpECPoint* pA, IppsGFpECPoint* pR, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECCmpPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppECResult* pResult, IppsGFpECState* pEC)) - -IPPAPI(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP, IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) -IPPAPI(IppStatus, ippsGFpECGetPoint,(const IppsGFpECPoint* pPoint, IppsGFpElement* pX, IppsGFpElement* pY, IppsGFpECState* pEC)) - -IPPAPI(IppStatus, ippsGFpECNegPoint,(const IppsGFpECPoint* pP, IppsGFpECPoint* pR, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECAddPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECPoint* pR, IppsGFpECState* pEC)) -IPPAPI(IppStatus, ippsGFpECMulPoint,(const IppsGFpECPoint* pP, const IppsBigNumState* pN, IppsGFpECPoint* pR, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) - -#ifdef __cplusplus -} -#endif - - -#if defined (_IPP_STDCALL_CDECL) - #undef _IPP_STDCALL_CDECL - #define __stdcall __cdecl -#endif - - -#endif /* __IPPCPEPID_H__ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippdefs.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippdefs.h deleted file mode 100644 index f3b5248787..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ippdefs.h +++ /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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Common Types and Macro Definitions -// -// -*/ - - -#ifndef __IPPDEFS_H__ -#define __IPPDEFS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#if defined( _IPP_PARALLEL_STATIC ) || defined( _IPP_PARALLEL_DYNAMIC ) - #pragma message("Threaded versions of IPP libraries are deprecated and will be removed in one of the future IPP releases. Use the following link for details: https://software.intel.com/sites/products/ipp-deprecated-features-feedback/") -#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/epid/ext/ipp/include/ipptypes.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ipptypes.h deleted file mode 100644 index 3f6961f559..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/include/ipptypes.h +++ /dev/null @@ -1,1100 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Derivative Types and Macro Definitions -// -// The main purpose of this header file is -// to support compatibility with the legacy -// domains until their end of life. -// -*/ - - -#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. */ - - 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/epid/ext/ipp/ippcommon.parts b/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcommon.parts deleted file mode 100644 index 62b601cf0f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcommon.parts +++ /dev/null @@ -1,56 +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.PartVersion("9.0.1") -env.PartName("ippcommon") -env.DependsOn([]) - -#prebuild installs prebuild headers instead of src headers. -#internal ipp includes src/primitives/ipp/ -env.Append(CPPPATH=[AbsDir('sources/include/')]) - -# env.Append(CPPDEFINES = '_IPP_BE') #only for BE targets - -#includes to install -install_headers = Pattern(src_dir='include/', - includes=['ippdefs.h', - 'ippversion.h', - 'ippcore.h', - 'ippbase.h', - 'ipptypes.h' - ], - excludes=[], - recursive=True) - -source_headers = Pattern(src_dir='sources/include/', - includes=['*'], - excludes=[], - recursive=True) -parts_file = Pattern(src_dir='.', - includes=['ippcommon.parts'], - excludes=[], - recursive=True) - -env.ExportCPPPATH([AbsDir('sources/include/')]) - -if 'install_package' in env['MODE']: - # All files at /ext/ipp/include - env.InstallTopLevel(install_headers, sub_dir='ext/ipp/include') - env.InstallTopLevel(source_headers, sub_dir='ext/ipp/sources/include') - env.InstallTopLevel(parts_file, sub_dir='ext/ipp/') -#else - env.SdkInclude(install_headers) diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcp.parts b/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcp.parts deleted file mode 100644 index 69e4560c93..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcp.parts +++ /dev/null @@ -1,82 +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.PartVersion("9.0.1") -env.PartName("ippcp") -env.DependsOn([Component('ippcommon')]) -ipp_libname = '${PART_SHORT_NAME}' - -ipp_src_install_loc = 'epid/src/primitives/${IPP_DIR}/' - -env.ExportCPPPATH([AbsDir('sources/ippcp/src/')]) #ippcpepid needs this - -#includes to install -install_headers = Pattern(src_dir='include/', - includes=[ - 'ippcp.h', - 'ippcpdefs.h', - ], - excludes=[], - recursive=True) -# common headers, for SdkInclude -common_headers = Pattern(src_dir='include/', - includes=['ippdefs.h', - 'ippversion.h', - 'ippcore.h', - 'ippbase.h', - 'ipptypes.h'], - excludes=[], - recursive=True) -#files -ippcp_files = Pattern(src_dir='sources/ippcp/src/', - includes=[ - 'pcp*.c', - ], - excludes=[], - recursive=True) - -ippdir = '' -#internal ipp includes src/primitives/ipp/ -env.Append(CPPPATH=[AbsDir('include/')]) -env.Append(CPPPATH=[AbsDir('sources/ippcp/src/')]) -#ipp defines -env.Append(CPPDEFINES='_IPP_v50_') #required for all ippcp - -env.Append(CPPDEFINES='_IPP_DEBUG') #enable function sanity checking - -if 'install_package' in env['MODE']: - # All files at /ext/ipp/source/include - env.InstallTopLevel(install_headers, sub_dir='ext/ipp/include') - src_files = Pattern(src_dir='sources/ippcp/src/', - includes=['*'], - excludes=[''], - recursive=True) - env.InstallTopLevel(src_files, sub_dir='ext/ipp/sources/ippcp/src') - this_file = Pattern(src_dir='.', - includes=['ippcp.parts'], - excludes=[], - recursive=True) - env.InstallTopLevel(this_file, sub_dir='ext/ipp/') -else: - all_c_files = ippcp_files.files() - outputs = env.Library(ipp_libname, all_c_files) - - env.SdkLib(outputs) - env.SdkInclude(install_headers) - env.SdkInclude(common_headers) - if 'install_lib' in env['MODE']: - env.InstallLib(outputs) diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcpepid.parts b/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcpepid.parts deleted file mode 100644 index c2698e2cd8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/ippcpepid.parts +++ /dev/null @@ -1,85 +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.PartVersion("9.0.1") -env.PartName("ippcpepid") -env.DependsOn([ - Component('ippcommon'), - Component('ippcp'), -]) - -IPP_LIBNAME = '${PART_SHORT_NAME}' - -env.ExportCPPPATH([AbsDir('sources/ippcp/src/')]) #ippcpepid needs this - -#includes to install -install_headers = Pattern(src_dir='include/', - includes=[ - 'ippcpepid.h', - ], - excludes=[], - recursive=True) -# common headers, for SdkInclude -common_headers = Pattern(src_dir='include/', - includes=['ippdefs.h', - 'ippversion.h', - 'ippcore.h', - 'ippbase.h', - 'ipptypes.h'], - excludes=[], - recursive=True) -#files -ippcp_files = Pattern(src_dir='sources/ippcpepid/src/', - includes=[ - 'pcp*.c', - ], - excludes=['pcpepidmain.c'], - recursive=True) - -ippdir = '' -#internal ipp includes src/primitives/ipp/ -env.Append(CPPPATH=[AbsDir('include/')]) -env.Append(CPPPATH=[AbsDir('sources/ippcp/src/')]) -env.Append(CPPPATH=[AbsDir('sources/ippcpepid/src/')]) -#ipp defines -env.Append(CPPDEFINES='_IPP_v50_') #required for all ippcp - -env.Append(CPPDEFINES='_IPP_DEBUG') #enable function sanity checking - -if 'install_package' in env['MODE']: - # All files at /ext/ipp/source/include - env.InstallTopLevel(install_headers, sub_dir='ext/ipp/include') - src_files = Pattern(src_dir='sources/ippcpepid/src/', - includes=['*'], - excludes=['pcpepidmain.c'], - recursive=True) - env.InstallTopLevel(src_files, sub_dir='ext/ipp/sources/ippcpepid/src') - this_file = Pattern(src_dir='.', - includes=['ippcpepid.parts'], - excludes=[], - recursive=True) - env.InstallTopLevel(this_file, sub_dir='ext/ipp/') -else: - - all_c_files = ippcp_files.files() - outputs = env.Library(IPP_LIBNAME, all_c_files) - - env.SdkLib(outputs) - env.SdkInclude(install_headers) - env.SdkInclude(common_headers) - if 'install_lib' in env['MODE']: - env.InstallLib(outputs) diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/include/owndefs.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/include/owndefs.h deleted file mode 100644 index 1cd2e95d83..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/include/owndefs.h +++ /dev/null @@ -1,934 +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. - ############################################################################*/ - -/* -// Author(s): Alexey Korchuganov -// Anatoly Pluzhnikov -// Igor Astakhov -// Dmitry Kozhaev -// -// Created: 27-Jul-1999 20:27 -// -*/ - -#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)) -#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/epid/ext/ipp/sources/ippcp/src/owncp.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/owncp.h deleted file mode 100644 index 6bf81b2300..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/owncp.h +++ /dev/null @@ -1,171 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -// -*/ - -#ifndef __OWNCP_H__ -#define __OWNCP_H__ - -#ifndef __OWNDEFS_H__ - #include "owndefs.h" -#endif - -#ifndef __IPPCP_H__ - #include "ippcp.h" -#endif - -#if defined(_TXT_ACM_) - //#pragma message ("cogifuration: TXT ACM") - #include "pcpvariant_txt_acm.h" -#else - //#pragma message ("cogifuration: STANDARD") - #include "pcpvariant.h" -#endif - - -#pragma warning( disable : 4996 4324 4206) - -/* ippCP length */ -typedef int cpSize; - -/* -// Common ippCP Macros -*/ - -/* size of cache line (bytes) */ -#if (_IPP==_IPP_M5) -#define CACHE_LINE_SIZE (16) -#define LOG_CACHE_LINE_SIZE (4) -#else -#define CACHE_LINE_SIZE (64) -#define LOG_CACHE_LINE_SIZE (6) -#endif - -/* 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 - - -/* crypto NI */ -#define AES_NI_ENABLED (ippCPUID_AES) -#define CLMUL_NI_ENABLED (ippCPUID_CLMUL) -#define AES_CLMUL_NI_ENABLED (ippCPUID_AES|ippCPUID_CLMUL) -#define ADCOX_ENABLED (ippCPUID_ADCOX) -#define SHA_NI_ENABLED (ippCPUID_SHA) -#define RDRAND_NI_ENABLED (ippCPUID_RDRAND) -#define RDSEED_NI_ENABLED (ippCPUID_RDSEED) - -/* test CPU crypto features */ -__INLINE Ipp32u IsFeatureEnabled(Ipp64u niMmask) -{ - return ownGetFeature(niMmask); -} - -/* 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/epid/ext/ipp/sources/ippcp/src/pcpbn.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbn.h deleted file mode 100644 index 5912211c93..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbn.h +++ /dev/null @@ -1,203 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -// -// -*/ - -#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 00 */ -__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/epid/ext/ipp/sources/ippcp/src/pcpbnca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnca.c deleted file mode 100644 index 1ccfd5736e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnca.c +++ /dev/null @@ -1,1286 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -// Contents: -// ippsBigNumGetSize() -// ippsBigNumInit() -// -// ippsSet_BN() -// ippsGet_BN() -// ippsGetSize_BN() -// ippsExtGet_BN() -// ippsRef_BN() -// -// ippsCmpZero_BN() -// ippsCmp_BN() -// -// ippsAdd_BN() -// ippsSub_BN() -// ippsMul_BN() -// ippsMAC_BN_I() -// ippsDiv_BN() -// ippsMod_BN() -// ippsGcd_BN() -// ippsModInv_BN() -// -// cpPackBigNumCtx(), cpUnpackBigNumCtx() -// -// -*/ - -#include "precomp.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 -// 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, ippStsLengthErr); - - { - /* convert length to the number of BNU_CHUNK_T */ - cpSize len = INTERNAL_BNU_LENGTH(len32); - /* reserve one BNU_CHUNK_T above for cpDiv_BNU, multiplication, mont exponentiation */ - 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 -// 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, 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) = idCtxBigNum; - 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 above for cpDiv_BNU, multiplication, mont exponentiation */ - 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 zero */ - ZEXPAND_BNU(BN_NUMBER(pBN), 0, len); - - return ippStsNoErr; - } -} - -/* -// Serialize / Deserialize bigNum context -*/ -void cpPackBigNumCtx(const IppsBigNumState* pBN, Ipp8u* pBuffer) -{ - IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT)); - CopyBlock(pBN, pAlignedBuffer, sizeof(IppsBigNumState)); - BN_NUMBER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_NUMBER(pBN))-IPP_UINT_PTR(pBN)); - BN_BUFFER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(BN_BUFFER(pBN))-IPP_UINT_PTR(pBN)); - CopyBlock(BN_NUMBER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)); - CopyBlock(BN_BUFFER(pBN), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)); -} - -void cpUnpackBigNumCtx(const Ipp8u* pBuffer, IppsBigNumState* pBN) -{ - IppsBigNumState* pAlignedBuffer = (IppsBigNumState*)(IPP_ALIGNED_PTR((pBuffer), BN_ALIGNMENT)); - CopyBlock(pBuffer, pBN, sizeof(IppsBigNumState)); - BN_NUMBER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer))); - BN_BUFFER(pBN) = (BNU_CHUNK_T*)((Ipp8u*)pBN + IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer))); - CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_NUMBER(pAlignedBuffer)), BN_NUMBER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)); - CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(BN_BUFFER(pAlignedBuffer)), BN_BUFFER(pBN), BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)); -} - - -/*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: ippsGetSize_BN -// -// Purpose: Returns BigNum room. -// -// Returns: Reason: -// ippStsNullPtrErr pBN == NULL -// pSize == NULL -// ippStsContextMatchErr BN_VALID_ID(pBN) -// ippStsNoErr no errors -// -// Parameters: -// pBN BigNum ctx -// pSize max BigNum length (in Ipp32u chunks) -// -*F*/ -IPPFUN(IppStatus, ippsGetSize_BN, (const IppsBigNumState* pBN, cpSize* pSize)) -{ - IPP_BAD_PTR2_RET(pBN, pSize); - - pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); - - *pSize = BN_ROOM(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u); - - 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: ippsGet_BN -// -// Purpose: Get BigNum. -// -// Returns: Reason: -// ippStsNullPtrErr pBN == NULL -// pData == NULL -// pSgn == NULL -// pLen32 ==NULL -// ippStsContextMatchErr !BN_VALID_ID(pBN) -// ippStsNoErr no errors -// -// Parameters: -// pSgn pointer to the sign -// pLen32 pointer to the data size (in Ipp32u chunks) -// pData pointer to the data buffer -// pBN BigNum ctx -// -*F*/ -IPPFUN(IppStatus, ippsGet_BN, (IppsBigNumSGN* pSgn, cpSize* pLen32, Ipp32u* pData, - const IppsBigNumState* pBN)) -{ - IPP_BAD_PTR4_RET(pSgn, pLen32, pData, pBN); - - pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); - - { - cpSize len32 = BN_SIZE(pBN)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u); - Ipp32u* bnData = (Ipp32u*)BN_NUMBER(pBN); - - FIX_BNU(bnData, len32); - COPY_BNU(pData, bnData, len32); - - *pSgn = BN_SIGN(pBN); - *pLen32 = len32; - - 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; -} - - -IPPFUN(IppStatus, ippsExtGet_BN, (IppsBigNumSGN* pSgn, cpSize* pBitSize, Ipp32u* pData, - const IppsBigNumState* pBN)) -{ - IPP_BAD_PTR1_RET(pBN); - - pBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pBN, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pBN), ippStsContextMatchErr); - - { - cpSize bitSize = BITSIZE_BNU(BN_NUMBER(pBN), BN_SIZE(pBN)); - if(pData) - COPY_BNU(pData, (Ipp32u*)BN_NUMBER(pBN), BITS2WORD32_SIZE(bitSize)); - if(pSgn) - *pSgn = BN_SIGN(pBN); - if(pBitSize) - *pBitSize = bitSize? bitSize : 1; - - 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); - - if(pA==pB) - cpSqr_BNU_school(pDataR, aData, nsA); - else - 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: ippsMAC_BN_I -// -// Purpose: Multiply and Accumulate 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 fit result -// ippStsNoErr no errors -// -// Parameters: -// pA source BigNum -// pB source BigNum -// pR resultant BigNum -// -*F*/ -IPPFUN(IppStatus, ippsMAC_BN_I, (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); - - cpSize nsA = BN_SIZE(pA); - cpSize nsB = BN_SIZE(pB); - - cpSize bitSizeA = BITSIZE_BNU(pDataA, nsA); - cpSize bitSizeB = BITSIZE_BNU(pDataB, nsB); - /* size of temporary pruduct */ - cpSize nsP = BITS_BNU_CHUNK(bitSizeA+bitSizeB); - - /* test if multiplicant/multiplier is zero */ - if(!nsP) return ippStsNoErr; - /* test if product can't fit to the result */ - IPP_BADARG_RET(BN_ROOM(pR)cmpRes) { - SWAP_PTR(BNU_CHUNK_T, pTmp, pDataP); - } - cpSub_BNU(pDataR, pTmp, pDataP, room); - - BN_SIGN(pR) = cmpRes>0? sgnR : INVERSE_SIGN(sgnR); - } - - FIX_BNU(pDataR, room); - BN_SIZE(pR) = room; - - 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/epid/ext/ipp/sources/ippcp/src/pcpbnresource.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnresource.h deleted file mode 100644 index 6e46c95096..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnresource.h +++ /dev/null @@ -1,48 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal BN Resource Definitions & Function Prototypes -// -// Created: Sun 29-Jun-2003 12:16 -// Author(s): Sergey Kirillov -// -// -*/ - -#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/epid/ext/ipp/sources/ippcp/src/pcpbnresourceca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnresourceca.c deleted file mode 100644 index 8e475205ee..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnresourceca.c +++ /dev/null @@ -1,87 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal ECC (prime) Resource List Function -// -// -*/ - -#include "precomp.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 = (*ppList)->pNext; - return ret; - } - else - return NULL; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnsetca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnsetca.c deleted file mode 100644 index 0afc468d3b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnsetca.c +++ /dev/null @@ -1,117 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Big Number Operations -// -// Contents: -// ippsSetOctString_BN() -// ippsGetOctString_BN() -// -// -*/ - -#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/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.c deleted file mode 100644 index 1bf70f0a0a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.c +++ /dev/null @@ -1,366 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Internal BNU32 arithmetic. -// -// Contents: -// -// cpAdd_BNU32() -// cpSub_BNU32() -// -// cpMulDgt_BNU32() -// cpSubMulDgt_BNU32() -// -// cpDiv_BNU32() -// -// -*/ - -#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 + extension; - *pR++ = LODWORD(r); - extension = HIDWORD(r); - } - return extension; -} -#endif - -/* -// BNU32 mul_by_digit_subtract -*/ -#if !((_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -Ipp32u cpSubMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, Ipp32u val) -{ - Ipp32u carry = 0; - for(; nsA>0; nsA--) { - Ipp64u r = (Ipp64u)*pR - (Ipp64u)(*pA++) * val - carry; - *pR++ = LODWORD(r); - carry = 0-HIDWORD(r); - } - return carry; -} -#endif - -/* -// BNU32 division -*/ -#if !((_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -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(; (q>=CONST_64(0x100000000)) || (Ipp64u)q*pY[sizeY-2] > MAKEDWORD(pX[i+sizeY-2],r); ) { - 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; - } -} -#endif - -#define FE_MUL(R,A,B,LEN) { \ - int aidx, bidx; \ - \ - for(aidx=0; aidx<(LEN); aidx++) (R)[aidx] = 0; \ - \ - for(bidx=0; bidx<(LEN); bidx++) { \ - Ipp64u b = (B)[bidx]; \ - Ipp32u c = 0; \ - for(aidx=0; aidx<(LEN); aidx++) { \ - Ipp64u t = (R)[bidx+aidx] + (A)[aidx] * b + c; \ - (R)[bidx+aidx] = LODWORD(t); \ - c = HIDWORD(t); \ - } \ - (R)[bidx+aidx] = c; \ - } \ -} - -#if 0 -#if !((_IPP==_IPP_W7) || \ - (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || \ - (_IPP==_IPP_P8) || \ - (_IPP>=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -void cpMul_BNU8(const Ipp32u* pA, const Ipp32u* pB, Ipp32u* pR) -{ - FE_MUL(pR, pA, pB, 8) -} -#endif -#endif - -#if 0 -#if !((_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -void cpMul_BNU4(const Ipp32u* pA, const Ipp32u* pB, Ipp32u* pR) -{ - FE_MUL(pR, pA, pB, 4) -} -#endif -#endif - -#if 0 -#if !((_IPP==_IPP_W7) || \ - (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || \ - (_IPP==_IPP_P8) || \ - (_IPP>=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -void cpSqr_BNU8(const Ipp32u* pA, Ipp32u* pR) -{ - FE_MUL(pR, pA, pA, 8) -} -#endif -#endif - -#if 0 -#if !((_IPP==_IPP_W7) || \ - (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || \ - (_IPP==_IPP_P8) || \ - (_IPP>=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -void cpSqr_BNU4(const Ipp32u* pA, Ipp32u* pR) -{ - FE_MUL(pR, pA, pA, 4) -} -#endif -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.h deleted file mode 100644 index 39ce622d2e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32arith.h +++ /dev/null @@ -1,50 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. -// Internal BNU32 arithmetic -// -// -*/ - -#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); -#if 0 -Ipp32u cpAddMulDgt_BNU32(Ipp32u* pR, const Ipp32u* pA, int nsA, Ipp32u val); -#endif - -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)) - -int cpFromOS_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, int strLen); -int cpToOS_BNU32(Ipp8u* pStr, int strLen, const Ipp32u* pBNU, int bnuSize); - -void cpMul_BNU8(const Ipp32u* pA, const Ipp32u* pB, Ipp32u* pR); -void cpMul_BNU4(const Ipp32u* pA, const Ipp32u* pB, Ipp32u* pR); -void cpSqr_BNU8(const Ipp32u* pA, Ipp32u* pR); -void cpSqr_BNU4(const Ipp32u* pA, Ipp32u* pR); - -#endif /* _CP_BNU32_ARITH_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.c deleted file mode 100644 index 36e777f264..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.c +++ /dev/null @@ -1,229 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Unsigned internal BNU32 misc functionality -// -// Contents: -// cpNLZ_BNU32() -// cpNTZ_BNU32() -// -// cpLSL_BNU32() -// cpLSR_BNU32() -// -// cpFromOctStr_BNU32() -// cpToOctStr_BNU32() -// -// -*/ - -#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; -} - -/* -// number of trailing zeros -*/ -#if 0 -cpSize cpNTZ_BNU32(Ipp32u x) -{ - cpSize ntz = BITSIZE(Ipp32u); - if(x) { - ntz = 0; - 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++; } - } - return ntz; -} -#endif - -/* -// Logical shift left (including inplace) -// -// Returns new length -*/ -#if 0 -cpSize cpLSL_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, cpSize nBits) -{ - cpSize nlz = cpNLZ_BNU32(pA[nsA-1]); - cpSize nw = nBits/BNU_CHUNK_32BIT; - cpSize n; - - pR += nw; - - nBits %= BNU_CHUNK_32BIT; - if(nBits) { - Ipp32u hi,lo; - - if(nlz < nBits ) - hi = 0; - else - hi = pA[--nsA]; - - for(n=nsA; n>0; n--) { - lo = pA[n-1]; - pR[n] = (hi<>(BNU_CHUNK_32BIT-nBits)); - hi = lo; - } - pR[0] = (hi<0; n--) - pR[n-1] = pA[n-1]; - } - - pR--; - for(n=0; n>nBits) | (hi<<(BNU_CHUNK_32BIT-nBits)); - lo = hi; - } - if(cnz > nBits) - pR[nsA-1] = (lo>>nBits); - else - nsA--; - } - - else { - for(n=0; n=4; bnuSize++,strLen-=4) { - /* pack 4 bytes into single Ipp32u value*/ - *pBNU++ = ( pOctStr[strLen-4]<<(8*3) ) - +( pOctStr[strLen-3]<<(8*2) ) - +( pOctStr[strLen-2]<<(8*1) ) - + pOctStr[strLen-1]; - } - - /* convert the beginning of the string */ - if(strLen) { - Ipp32u x; - for(x=0; strLen>0; strLen--) { - Ipp32u d = *pOctStr++; - x = x*256 + d; - } - *pBNU++ = x; - bnuSize++; - } - - return bnuSize? bnuSize : 1; -} - - -/* -// Convert BNU into Octet String representation -// -// Returns strLen or 0 if no success -*/ -cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize) -{ - FIX_BNU(pBNU, bnuSize); - { - int bnuBitSize = BITSIZE_BNU32(pBNU, bnuSize); - if(bnuBitSize <= strLen*BYTESIZE) { - Ipp32u x = pBNU[bnuSize-1]; - - ZEXPAND_BNU(pStr, 0, strLen); - pStr += strLen - BITS2WORD8_SIZE(bnuBitSize); - - if(x) { - int nb; - for(nb=cpNLZ_BNU32(x)/BYTESIZE; nb<4; nb++) - *pStr++ = EBYTE(x,3-nb); - - for(--bnuSize; bnuSize>0; bnuSize--) { - x = pBNU[bnuSize-1]; - *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/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.h deleted file mode 100644 index 228b965221..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnu32misc.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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Internal Miscellaneous BNU 32 bit Definitions & Function Prototypes -// -// -*/ - -#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); -#if 0 -cpSize cpNTZ_BNU32(Ipp32u x); -#endif - -/* 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; -} - - -__INLINE int cpCmp_BNU32(const Ipp32u* pA, cpSize nsA, const Ipp32u* 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; - } -} - -/* logical shift left/right */ -#if 0 -cpSize cpLSL_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, cpSize nBits); -cpSize cpLSR_BNU32(Ipp32u* pR, const Ipp32u* pA, cpSize nsA, cpSize nBits); -#endif - -/* to/from oct string conversion */ -cpSize cpToOctStr_BNU32(Ipp8u* pStr, cpSize strLen, const Ipp32u* pBNU, cpSize bnuSize); -cpSize cpFromOctStr_BNU32(Ipp32u* pBNU, const Ipp8u* pOctStr, cpSize strLen); - -#endif /* _CP_BNU32_MISC_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.c deleted file mode 100644 index d224a5622b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.c +++ /dev/null @@ -1,537 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Internal Unsigned arithmetic -// -// Contents: -// cpAdd_BNU() -// cpSub_BNU() -// cpInc_BNU() -// cpDec_BNU() -// -// cpAddAdd_BNU() -// cpAddSub_BNU() -// -// cpMuldgt_BNU() -// cpAddMulDgt_BNU() -// cpSubMulDgt_BNU() -// -// cpMulAdc_BNU_school() -// cpSqrAdc_BNU_school() -// -// cpDiv_BNU() -// cpMod_BNU() -// cpGcd_BNU() -// cpModInv_BNU() -// -// -*/ - -#include "owncp.h" -#include "pcpbnuarith.h" -#include "pcpbnumisc.h" - - -/* Function cpAdd_BNU - addition of 2 BigNumbers */ -#if !((_IPP==_IPP_W7) || \ - (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || \ - (_IPP==_IPP_P8) || \ - (_IPP>=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8) || \ - (_IPPLRB>=_IPPLRB_B1)) -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=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8) || \ - (_IPPLRB>=_IPPLRB_B1)) -BNU_CHUNK_T cpSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns) -{ - BNU_CHUNK_T borrow = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpInc_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val) -{ - cpSize i; - for(i=0; i=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpDec_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val) -{ - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpAddAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize ns) -{ - BNU_CHUNK_T carry1 = 0; - BNU_CHUNK_T carry2 = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpAddSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize ns) -{ - BNU_CHUNK_T carry = 0; - BNU_CHUNK_T borrow = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val) -{ - BNU_CHUNK_T extension = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) -BNU_CHUNK_T cpAddMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val) -{ - BNU_CHUNK_T extension = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8) || \ - (_IPPLRB >= _IPPLRB_B1)) -BNU_CHUNK_T cpSubMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val) -{ - BNU_CHUNK_T extension = 0; - cpSize i; - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8) ) -// || (_IPPLRB >= _IPPLRB_B1)) //dlaptev: is it renaming? -//BNU_CHUNK_T cpMul_BNU_school(BNU_CHUNK_T* pR, -// const BNU_CHUNK_T* pA, cpSize nsA, -// const BNU_CHUNK_T* pB, cpSize nsB) -BNU_CHUNK_T cpMulAdc_BNU_school(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pB, cpSize nsB) -{ - const BNU_CHUNK_T* pa = (BNU_CHUNK_T*)pA; - const BNU_CHUNK_T* pb = (BNU_CHUNK_T*)pB; - BNU_CHUNK_T* pr = (BNU_CHUNK_T*)pR; - - BNU_CHUNK_T extension = 0; - cpSize i, j; - - ZEXPAND_BNU(pr, 0, nsA+nsB); - - for(i=0; i=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8) ) -//|| (_IPPLRB >= _IPPLRB_B1)) //dlaptev: is it renaming? -//BNU_CHUNK_T cpSqr_BNU_school(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA) -BNU_CHUNK_T cpSqrAdc_BNU_school(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA) -{ - cpSize i; - - BNU_CHUNK_T extension; - BNU_CHUNK_T rH, rL; - - /* init result */ - pR[0] = 0; - for(i=1, extension=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); - //nsR = IPP_MAX(nsR, nsA+nsB); - - { - BNU_CHUNK_T expansion = 0; - cpSize i; - for(i=0; i -static void Print_BNU(const char* note, const BNU_CHUNK_T* pData, int len) -{ - if(note) - printf("%s", note); - { - int n; - Ipp32u* pDataT = (Ipp32u*)pData; - len *= (sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)); - for(n=len; n>0; n--) { - Ipp32u x = pDataT[n-1]; - printf("%08x ", x); - } - printf("\n"); - } -} -#endif - -int cpModInv_BNU(BNU_CHUNK_T* pInv, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pM, cpSize nsM, - BNU_CHUNK_T* bufInv, BNU_CHUNK_T* bufA, BNU_CHUNK_T* bufM) -{ - FIX_BNU(pA, nsA); - FIX_BNU(pM, nsM); - - /* inv(1) = 1 */ - if(nsA==1 && pA[0]==1) { - pInv[0] = 1; - return 1; - } - - { - cpSize moduloSize = nsM; - - BNU_CHUNK_T* X1 = pInv; - BNU_CHUNK_T* X2 = bufM; - BNU_CHUNK_T* Q = bufInv; - cpSize nsX1 = 1; - cpSize nsX2 = 1; - cpSize nsQ; - - COPY_BNU(bufA, pA, nsA); - - ZEXPAND_BNU(X1, 0, moduloSize); - ZEXPAND_BNU(X2, 0, moduloSize); - X2[0] = 1; - - //printf("\n"); - for(;;) { - nsM = cpDiv_BNU(Q, &nsQ, (BNU_CHUNK_T*)pM, nsM, bufA, nsA); - //Print_BNU(" q: ", Q, nsQ); - //Print_BNU(" m: ", pM, nsM); - nsX1 = cpMac_BNU(X1,moduloSize, Q,nsQ, X2,nsX2); - //Print_BNU("X1: ", X1, nsX1); - - if (nsM==1 && pM[0]==1) { - ////ZEXPAND_BNU(X2, nsX2, moduloSize); - nsX2 = cpMac_BNU(X2,moduloSize, X1,nsX1, bufA, nsA); - COPY_BNU((BNU_CHUNK_T*)pM, X2, moduloSize); - cpSub_BNU(pInv, pM, X1, moduloSize); - FIX_BNU(pInv, moduloSize); - return moduloSize; - } - else if (nsM==1 && pM[0]==0) { - cpMul_BNU_school((BNU_CHUNK_T*)pM, X1,nsX1, bufA, nsA); - /* gcd = buf_a */ - return 0; - } - - nsA = cpDiv_BNU(Q, &nsQ, bufA, nsA, (BNU_CHUNK_T*)pM, nsM); - //Print_BNU(" q: ", Q, nsQ); - //Print_BNU(" a: ", bufA, nsA); - nsX2 = cpMac_BNU(X2,moduloSize, Q,nsQ, X1,nsX1); - //Print_BNU("X2: ", X2, nsX2); - - if(nsA==1 && bufA[0]==1) { - ////ZEXPAND_BNU(X1, nsX1, moduloSize); - nsX1 = cpMac_BNU(X1, moduloSize, X2, nsX2, pM, nsM); - COPY_BNU((BNU_CHUNK_T*)pM, X1, moduloSize); - COPY_BNU(pInv, X2, nsX2); - return nsX2; - } - else if (nsA==1 && bufA[0]==0) { - /* gcd = m */ - COPY_BNU(X1, pM, nsM); - cpMul_BNU_school((BNU_CHUNK_T*)pM, X2, nsX2, X1, nsM); - return 0; - } - } - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.h deleted file mode 100644 index 9481317d23..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnuarith.h +++ /dev/null @@ -1,169 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. -// Internal Unsigned internal arithmetic -// -// -*/ - -#if !defined(_CP_BNU_ARITH_H) -#define _CP_BNU_ARITH_H - -#include "pcpbnuimpl.h" -#include "pcpbnu32arith.h" -#include "pcpmulbnukara.h" - -BNU_CHUNK_T cpAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns); -BNU_CHUNK_T cpSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, cpSize ns); -BNU_CHUNK_T cpInc_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val); -BNU_CHUNK_T cpDec_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val); - -#if defined(_USE_KARATSUBA_) -BNU_CHUNK_T cpAddAdd_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize size); -BNU_CHUNK_T cpAddSub_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pC, cpSize size); -#endif - -BNU_CHUNK_T cpAddMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val); -#if 0 -BNU_CHUNK_T cpMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val); -BNU_CHUNK_T cpSubMulDgt_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize ns, BNU_CHUNK_T val); -#endif - - -BNU_CHUNK_T cpMulAdc_BNU_school(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pB, cpSize nsB); -BNU_CHUNK_T cpMulAdx_BNU_school(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pB, cpSize nsB); - -__INLINE BNU_CHUNK_T cpMul_BNU_school(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pB, cpSize nsB) -{ -#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_) - return cpMulAdx_BNU_school(pR, pA,nsA, pB,nsB); -#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_) - return IsFeatureEnabled(ADCOX_ENABLED)? cpMulAdx_BNU_school(pR, pA,nsA, pB,nsB) - : cpMulAdc_BNU_school(pR, pA,nsA, pB,nsB); -#else - return cpMulAdc_BNU_school(pR, pA,nsA, pB,nsB); -#endif -} - -BNU_CHUNK_T cpSqrAdc_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize nsA); -BNU_CHUNK_T cpSqrAdx_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize nsA); - -__INLINE BNU_CHUNK_T cpSqr_BNU_school(BNU_CHUNK_T * pR, const BNU_CHUNK_T * pA, cpSize nsA) -{ -#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_) - return cpSqrAdx_BNU_school(pR, pA,nsA); -#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_) - return IsFeatureEnabled(ADCOX_ENABLED)? cpSqrAdx_BNU_school(pR, pA,nsA) - : cpSqrAdc_BNU_school(pR, pA,nsA); -#else - return cpSqrAdc_BNU_school(pR, pA,nsA); -#endif -} - -#if(_IPP_ARCH==_IPP_ARCH_EM64T) -BNU_CHUNK_T* gf256_add(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pModulus); -BNU_CHUNK_T* gf256_sub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pModulus); -BNU_CHUNK_T* gf256_neg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pModulus); -BNU_CHUNK_T* gf256_mulm(BNU_CHUNK_T* pR,const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, const BNU_CHUNK_T* pModulus, BNU_CHUNK_T m0); -BNU_CHUNK_T* gf256_sqrm(BNU_CHUNK_T* pR,const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pModulus, BNU_CHUNK_T m0); -BNU_CHUNK_T* gf256_div2(BNU_CHUNK_T* pR,const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pModulus); -#endif - -BNU_CHUNK_T cpGcd_BNU(BNU_CHUNK_T a, BNU_CHUNK_T b); - -int cpModInv_BNU(BNU_CHUNK_T* pInv, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pM, cpSize nsM, - BNU_CHUNK_T* bufInv, BNU_CHUNK_T* bufA, BNU_CHUNK_T* bufM); - - -/* -// multiplication/squaring wrappers -*/ -__INLINE cpSize cpMul_BNU_BufferSize(cpSize opLen) -{ -#if !defined (_USE_KARATSUBA_) - UNREFERENCED_PARAMETER(opLen); - return 0; -#else - return cpKaratsubaBufferSize(opLen); -#endif -} -__INLINE BNU_CHUNK_T cpMul_BNU(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, cpSize nsA, - const BNU_CHUNK_T* pB, cpSize nsB, - BNU_CHUNK_T* pBuffer) -{ -#if !defined(_USE_KARATSUBA_) - UNREFERENCED_PARAMETER(pBuffer); - return cpMul_BNU_school(pR, pA,nsA, pB,nsB); -#else - if(nsA!=nsB || nsA> (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/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.c deleted file mode 100644 index 47bfcffd14..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.c +++ /dev/null @@ -1,294 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Internal Unsigned BNU misc functionality -// -// Contents: -// cpNLZ_BNU() -// cpNTZ_BNU() -// -// cpLSL_BNU() -// cpLSR_BNU() -// -// cpLSBit_BNU() -// cpMSBit_BNU() -// -// cpFromOctStr_BNU() -// cpToOctStrS_BNU() -// -// -*/ - -#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 left (including inplace) -// -// Returns new length -// -*/ -#if 0 -cpSize cpLSL_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits) -{ - cpSize nlz = cpNLZ_BNU(pA[nsA-1]); - cpSize nw = nBits/BNU_CHUNK_BITS; - cpSize n; - - pR += nw; - - nBits %= BNU_CHUNK_BITS; - if(nBits) { - BNU_CHUNK_T hi,lo; - - if(nlz < nBits ) - hi = 0; - else - hi = pA[--nsA]; - - for(n=nsA; n>0; n--) { - lo = pA[n-1]; - pR[n] = (hi<>(BNU_CHUNK_BITS-nBits)); - hi = lo; - } - pR[0] = (hi<0; n--) - pR[n-1] = pA[n-1]; - } - - pR--; - for(n=0; n>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/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.h deleted file mode 100644 index 313471d772..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpbnumisc.h +++ /dev/null @@ -1,160 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptography Primitives. -// Internal Miscellaneous BNU Definitions & Function Prototypes -// -// -*/ - -#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; \ -} - -/* compare */ -#if 0 -#define CMP_BNU(sign, pA, pB, len) \ -{ \ - for((sign)=(len); (sign)>0; (sign)--) { \ - if( (pA)[(sign)-1] != (pB)[(sign)-1] ) \ - break; \ - } \ - (sign) = (sign)? ((pA)[(sign)-1] > (pB)[(sign)-1])? 1:-1 : 0; \ -} -#endif - -/* 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); -#if 0 -int cpLSL_BNU(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, cpSize nsA, cpSize nBits); -#endif - -/* least and most significant BNU bit */ -#if 0 -int cpLSBit_BNU(const BNU_CHUNK_T* pA, cpSize nsA); -#endif -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/epid/ext/ipp/sources/ippcp/src/pcpeccp.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccp.h deleted file mode 100644 index ae7ac556c9..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccp.h +++ /dev/null @@ -1,260 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal ECC (prime) basic Definitions & Function Prototypes -// -// -*/ - -#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) */ - - #if defined(_USE_NN_VERSION_) - Ipp32u randMask; /* mask of high bits random */ - IppsBigNumState* pRandCnt; /* random engine content */ - IppsPRNGState* pRandGen; /* random generator engine */ - #endif - - IppsPrimeState* pPrimary; /* prime engine */ - -#if defined (_USE_ECCP_SSCM_) - Ipp8u* pSscmBuffer;/* pointer to sscm buffer */ -#endif - - BigNumNode* pBnList; /* list of big numbers */ - /*BigNumNode* pBnListExt;*//* 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) - -#if defined(_USE_NN_VERSION_) -#define ECP_RANDMASK(ctx) ((ctx)->randMask) -#define ECP_RANDCNT(ctx) ((ctx)->pRandCnt) -#define ECP_RAND(ctx) ((ctx)->pRandGen) -#endif - -#define ECP_PRIMARY(ctx) ((ctx)->pPrimary) -#if defined (_USE_ECCP_SSCM_) -# define ECP_SCCMBUFF(ctx) ((ctx)->pSscmBuffer) -#endif -#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; - -extern const Ipp32u tpmBN_p256p_p[]; // TPM BN_P256 -extern const Ipp32u tpmBN_p256p_a[]; -extern const Ipp32u tpmBN_p256p_b[]; -extern const Ipp32u tpmBN_p256p_gx[]; -extern const Ipp32u tpmBN_p256p_gy[]; -extern const Ipp32u tpmBN_p256p_r[]; -extern Ipp32u tpmBN_p256p_h; - -extern const Ipp32u tpmSM2_p256_p[]; // TPM SM2_P256 -extern const Ipp32u tpmSM2_p256_a[]; -extern const Ipp32u tpmSM2_p256_b[]; -extern const Ipp32u tpmSM2_p256_gx[]; -extern const Ipp32u tpmSM2_p256_gy[]; -extern const Ipp32u tpmSM2_p256_r[]; -extern Ipp32u tpmSM2_p256_h; - -extern const Ipp32u* tpmSM2_p256_p_mx[]; - -/* 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[]; -extern const Ipp32u h_tpmSM2_p256_p[]; - -#endif /* _PCP_ECCP_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpdpca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpdpca.c deleted file mode 100644 index b3e09a9b7f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpdpca.c +++ /dev/null @@ -1,801 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (setup/retrieve domain parameters) -// -// Contents: -// ippsECCPSet() -// ippsECCPSetStd() -// ippsECCPSetStd128r1() -// ippsECCPSetStd128r2() -// ippsECCPSetStd192r1() -// ippsECCPSetStd224r1() -// ippsECCPSetStd256r1() -// ippsECCPSetStd384r1() -// ippsECCPSetStd521r1() -// ippsECCPSetStdSM2() -// -// ippsECCPGet() -// ippsECCPGetBitSizeOrder() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpeccp.h" -#include "pcpeccppoint.h" -#include "pcpbnresource.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcppma.h" - -#if (_ECP_128_==_ECP_IMPL_SPECIFIC_) -# include "pcpeccpmethod128.h" -#endif -#if (_ECP_192_==_ECP_IMPL_SPECIFIC_) || (_ECP_192_==_ECP_IMPL_MFM_) -# include "pcpeccpmethod192.h" -#endif -#if (_ECP_224_==_ECP_IMPL_SPECIFIC_) || (_ECP_224_==_ECP_IMPL_MFM_) -# include "pcpeccpmethod224.h" -#endif -#if (_ECP_256_==_ECP_IMPL_SPECIFIC_) || (_ECP_256_==_ECP_IMPL_MFM_) -# include "pcpeccpmethod256.h" -#endif -#if (_ECP_384_==_ECP_IMPL_SPECIFIC_) || (_ECP_384_==_ECP_IMPL_MFM_) -# include "pcpeccpmethod384.h" -#endif -#if (_ECP_521_==_ECP_IMPL_SPECIFIC_) || (_ECP_521_==_ECP_IMPL_MFM_) -# include "pcpeccpmethod521.h" -#endif -#if (_ECP_SM2_==_ECP_IMPL_SPECIFIC_) || (_ECP_SM2_==_ECP_IMPL_MFM_) -# include "pcpeccpmethodsm2.h" -#endif - -/*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)); - - #if defined(_USE_NN_VERSION_) - /* set up randomizer */ - //gres 05/14/05: ECP_RANDMASK(pECC) = 0xFFFFFFFF >> ((32 -(ECP_ORDBITS(pECC)&0x1F)) &0x1F); - ECP_RANDMASK(pECC) = MAKEMASK32(ECP_ORDBITS(pECC)); - ECP_RANDMASK(pECC) &= ~pOrder[orderSize-1]; - /* reinit randomizer */ - ippsPRNGInit(ECP_ORDBITS(pECC), ECP_RAND(pECC)); - /* default randomizer settings */ - { - Ipp32u seed[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - ippsPRNGSetSeed(seed, ECP_RAND(pECC)); - ippsSet_BN(ippBigNumPOS, RAND_CONTENT_LEN, seed, ECP_RANDCNT(pECC)); - } - #endif - - /* 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());//ECCPcom; - - 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: - #if (_ECP_128_==_ECP_IMPL_SPECIFIC_) - *(ECP_METHOD(pECC)) = *(ECCP128_Methods());//ECCP128; - #endif - 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: - #if (_ECP_128_==_ECP_IMPL_SPECIFIC_) - *(ECP_METHOD(pECC)) = *(ECCP128_Methods());//ECCP128; - #endif - 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: - #if (_ECP_192_==_ECP_IMPL_SPECIFIC_) || (_ECP_192_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP192_Methods());//ECCP192; - #endif - 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: - #if (_ECP_224_==_ECP_IMPL_SPECIFIC_) || (_ECP_224_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP224_Methods());//ECCP224; - #endif - 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: - #if (_ECP_256_==_ECP_IMPL_SPECIFIC_) || (_ECP_256_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP256_Methods());//ECCP256; - #endif - 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: - #if (_ECP_384_==_ECP_IMPL_SPECIFIC_) || (_ECP_384_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP384_Methods());//ECCP384; - #endif - 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: - #if (_ECP_521_==_ECP_IMPL_SPECIFIC_) || (_ECP_521_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP521_Methods());//ECCP521; - #endif - 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; - case ippEC_TPM_BN_P256: - ECCPSetDP(ippEC_TPM_BN_P256, - BITS2WORD32_SIZE(256), tpmBN_p256p_p, - BITS2WORD32_SIZE(32), tpmBN_p256p_a, - BITS2WORD32_SIZE(32), tpmBN_p256p_b, - BITS2WORD32_SIZE(32), tpmBN_p256p_gx, - BITS2WORD32_SIZE(32), tpmBN_p256p_gy, - BITS2WORD32_SIZE(256), tpmBN_p256p_r, - tpmBN_p256p_h, pECC); - break; - case ippECPstdSM2: - #if (_ECP_SM2_==_ECP_IMPL_SPECIFIC_) || (_ECP_SM2_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP_SM2_Methods()); - #endif - ECCPSetDP(ippEC_TPM_SM2_P256, - BITS2WORD32_SIZE(256), tpmSM2_p256_p, - BITS2WORD32_SIZE(256), tpmSM2_p256_a, - BITS2WORD32_SIZE(256), tpmSM2_p256_b, - BITS2WORD32_SIZE(256), tpmSM2_p256_gx, - BITS2WORD32_SIZE(256), tpmSM2_p256_gy, - BITS2WORD32_SIZE(256), tpmSM2_p256_r, - tpmSM2_p256_h, pECC); - break; - default: - return ippStsECCInvalidFlagErr; - } - - return ippStsNoErr; -} - -/*F* -// Name: ippsECCPSetStd128r1 -// ippsECCPSetStd128r2 -// ippsECCPSetStd192r1 -// ippsECCPSetStd224r1 -// ippsECCPSetStd256r1 -// ippsECCPSetStd384r1 -// ippsECCPSetStd521r1 -// ippsECCPSetStdSM2 -*F*/ -IPPFUN(IppStatus, ippsECCPSetStd128r1, (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); - - #if (_ECP_128_==_ECP_IMPL_SPECIFIC_) - *(ECP_METHOD(pECC)) = *(ECCP128_Methods()); // ECCP128; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd128r2, (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); - - #if (_ECP_128_==_ECP_IMPL_SPECIFIC_) - *(ECP_METHOD(pECC)) = *(ECCP128_Methods()); // ECCP128; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd192r1, (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); - - #if (_ECP_192_==_ECP_IMPL_SPECIFIC_) || (_ECP_192_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP192_Methods()); // ECCP192; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd224r1, (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); - - #if (_ECP_224_==_ECP_IMPL_SPECIFIC_) || (_ECP_224_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP224_Methods()); // ECCP224; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd256r1, (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); - - #if (_ECP_256_==_ECP_IMPL_SPECIFIC_) || (_ECP_256_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP256_Methods()); // ECCP256; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd384r1, (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); - - #if (_ECP_384_==_ECP_IMPL_SPECIFIC_) || (_ECP_384_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP384_Methods()); // ECCP384; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStd521r1, (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); - - #if (_ECP_521_==_ECP_IMPL_SPECIFIC_) || (_ECP_521_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP521_Methods()); // ECCP521; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - 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); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsECCPSetStdSM2, (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); - - #if (_ECP_SM2_==_ECP_IMPL_SPECIFIC_) || (_ECP_SM2_==_ECP_IMPL_MFM_) - *(ECP_METHOD(pECC)) = *(ECCP_SM2_Methods()); // ECCSM2; - #else - *(ECP_METHOD(pECC)) = *(ECCPcom_Methods()); // ECCPcom; - #endif - ECCPSetDP(ippEC_TPM_SM2_P256, - BITS2WORD32_SIZE(256), tpmSM2_p256_p, - BITS2WORD32_SIZE(256), tpmSM2_p256_a, - BITS2WORD32_SIZE(256), tpmSM2_p256_b, - BITS2WORD32_SIZE(256), tpmSM2_p256_gx, - BITS2WORD32_SIZE(256), tpmSM2_p256_gy, - BITS2WORD32_SIZE(256), tpmSM2_p256_r, - tpmSM2_p256_h, pECC); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsECCPGet -// -// Purpose: Retrieve ECC Domain Parameter. -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pPrime -// NULL == pA -// NULL == pB -// NULL == pGX -// NULL == pGY -// NULL == pOrder -// NULL == cofactor -// 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 -// -// ippStsNoErr no errors -// -// Parameters: -// pPrime pointer to the retrieval prime (specify FG(p)) -// pA pointer to the retrieval A coefficient of EC equation -// pB pointer to the retrieval B coefficient of EC equation -// pGX,pGY pointer to the retrieval Base Point (x and y coordinates) of EC -// pOrder pointer to the retrieval Base Point order -// cofactor pointer to the retrieval cofactor value -// pECC pointer to the ECC context -// -*F*/ -IPPFUN(IppStatus, ippsECCPGet, (IppsBigNumState* pPrime, - IppsBigNumState* pA, IppsBigNumState* pB, - IppsBigNumState* pGX,IppsBigNumState* pGY,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((BN_ROOM(pPrime)*BITSIZE(BNU_CHUNK_T)idCtx -// -// ippStsNoErr no errors -// -// Parameters: -// pBitSize pointer to the size of base point order -// pECC pointer to the ECC context -// -*F*/ -IPPFUN(IppStatus, ippsECCPGetOrderBitSize,(int* pBitSize, IppsECCPState* pECC)) -{ - /* test pECC */ - IPP_BAD_PTR1_RET(pECC); - /* use 4-byte aligned EC context */ - pECC = (IppsECCPState*)( IPP_ALIGNED_PTR(pECC, 4) ); - /* test ID */ - IPP_BADARG_RET(!ECP_VALID_ID(pECC), ippStsContextMatchErr); - - /* test pBitSize*/ - IPP_BAD_PTR1_RET(pBitSize); - - *pBitSize = ECP_ORDBITS(pECC); - - return ippStsNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c deleted file mode 100644 index ec3d785d4f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpgenkeyca.c +++ /dev/null @@ -1,105 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (EC Key Generation) -// -// Contents: -// ippsECCPGenKeyPair() -// -// -*/ - -#include "precomp.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)MulPoint(ECP_GENC(pECC), pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); - ECP_METHOD(pECC)->MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); - - return ippStsNoErr; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpinitca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpinitca.c deleted file mode 100644 index bf16403487..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpinitca.c +++ /dev/null @@ -1,454 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (initialization) -// -// Contents: -// ippsECCPGetSize() -// ippsECCPGetSizeStd128r1() -// ippsECCPGetSizeStd128r2() -// ippsECCPGetSizeStd192r1() -// ippsECCPGetSizeStd224r1() -// ippsECCPGetSizeStd256r1() -// ippsECCPGetSizeStd384r1() -// ippsECCPGetSizeStd521r1() -// ippsECCPGetSizeStdSM2() -// -// ippsECCPInit() -// ippsECCPInitStd128r1() -// ippsECCPInitStd128r2() -// ippsECCPInitStd192r1() -// ippsECCPInitStd224r1() -// ippsECCPInitStd256r1() -// ippsECCPInitStd384r1() -// ippsECCPInitStd521r1() -// ippsECCPInitStdSM2() -// -// -*/ - -#include "precomp.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), ippStsSizeErr); - - { - int bn1Size; - int bn2Size; - int pointSize; - int mont1Size; - int mont2Size; - #if defined(_USE_NN_VERSION_) - int randSize; - int randCntSize; - #endif - int primeSize; - int listSize; - - /* size of field element */ - int gfeSize = BITS2WORD32_SIZE(feBitSize); - /* size of order */ - int ordSize = BITS2WORD32_SIZE(feBitSize+1); - - #if defined (_USE_ECCP_SSCM_) - /* 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), 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; - #if defined(_USE_NN_VERSION_) - int randSize; - int randCntSize; - #endif - int primeSize; - //int listSize; - - /* size of field element */ - int gfeSize = BITS2WORD32_SIZE(feBitSize); - /* size of order */ - int ordSize = BITS2WORD32_SIZE(feBitSize+1); - - #if defined (_USE_ECCP_SSCM_) - /* 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 ECCP128_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA128_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA128_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA128_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA128_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA128_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA128_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA128_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA128_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP128_NegPoint -// -// Negative point -*/ -void ECCP128_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P128; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp128r1_p, pPy, LEN_P128); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP128_DblPoint -// -// Double point -*/ -void ECCP128_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA128_sqr(bnU, ECP_POINT_X(pP)); - PMA128_add(bnM, bnU, bnU); - PMA128_add(bnM, bnM, bnU); - PMA128_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA128_sqr(bnU, ECP_POINT_Z(pP)); - PMA128_add(bnS, ECP_POINT_X(pP), bnU); - PMA128_sub(bnT, ECP_POINT_X(pP), bnU); - PMA128_mul(bnM, bnS, bnT); - PMA128_add(bnU, bnM, bnM); - PMA128_add(bnM, bnU, bnM); - } - else { - PMA128_sqr(bnU, ECP_POINT_X(pP)); - PMA128_add(bnM, bnU, bnU); - PMA128_add(bnM, bnM, bnU); - PMA128_sqr(bnU, ECP_POINT_Z(pP)); - PMA128_sqr(bnU, bnU); - PMA128_mul(bnU, bnU, ECP_A(pECC)); - PMA128_add(bnM, bnM, bnU); - } - - PMA128_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA128_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA128_sqr(bnT, bnV); - PMA128_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA128_sqr(bnU, bnM); - PMA128_sub(bnU, bnU, bnS); - PMA128_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA128_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA128_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA128_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA128_mul(bnS, bnS, bnM); - PMA128_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP128_AddPoint -// -// Add points -*/ -void ECCP128_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP128_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA128_sqr(bnW, ECP_POINT_Z(pQ)); - PMA128_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA128_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA128_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA128_sqr(bnW, ECP_POINT_Z(pP)); - PMA128_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA128_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA128_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA128_sub(bnW, bnU0, bnU1); - PMA128_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P128, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P128, 0)) { - ECCP128_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA128_add(bnT, bnU0, bnU1); - PMA128_add(bnM, bnS0, bnS1); - - /* 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 { - PMA128_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA128_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA128_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA128_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA128_sqr(ECP_POINT_X(pR), bnR); - PMA128_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA128_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA128_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA128_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA128_mul(bnU1, bnU1, bnW); - PMA128_mul(bnU1, bnU1, bnM); - PMA128_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA128_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP128_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP128_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP128_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP128_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP128_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP128_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP128_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP128_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP128_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP128_MulPoint: SCCM version") - -void ECCP128_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 */ - ECCP128_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP128_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP128_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP128_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP128_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP128_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP128_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP128_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP128_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP128_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP128_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP128_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP128_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP128_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP128_ProdPoint: SCCM version") - -void ECCP128_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); - - ECCP128_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP128_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP128_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_128_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192.h deleted file mode 100644 index 747173c30f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192.h +++ /dev/null @@ -1,117 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over GF(P192) -// -// -*/ - -#if !defined(_PCP_ECCPMETHOD192_H) -#define _PCP_ECCPMETHOD192_H - -#include "pcpeccp.h" - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP192_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP192_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP192_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP192_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP192_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP192_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP192_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP192_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP192_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP192_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP192_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP192_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP192_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHOD192_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192ca.c deleted file mode 100644 index 39b1b63146..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod192ca.c +++ /dev/null @@ -1,880 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P192) -// -// Contents: -// ECCP192_SetPointProjective() -// ECCP192_SetPointAffine() -// ECCP192_GetPointAffine() -// -// ECCP192_IsPointOnCurve() -// -// ECCP192_ComparePoint() -// ECCP192_NegPoint() -// ECCP192_DblPoint() -// ECCP192_AddPoint() -// ECCP192_MulPoint() -// ECCP192_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_192_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethod192.h" -#include "pcppma192.h" - -/* - NOTE: - ECCP192 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP192 = { - ECCP192_SetPointProjective, - ECCP192_SetPointAffine, - ECCP192_GetPointAffine, - - ECCP192_IsPointOnCurve, - - ECCP192_ComparePoint, - ECCP192_NegPoint, - ECCP192_DblPoint, - ECCP192_AddPoint, - ECCP192_MulPoint, - ECCP192_MulBasePoint, - ECCP192_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP192_Methods(void) -{ - return &ECCP192; -} - -/* -// ECCP192_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP192_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP192_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP192_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP192_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP192_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP192_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP192_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP192_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMA192_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMA192_sqr(pT, pU); - - if(pX) { - PMA192_mul(pX,pT, ECP_POINT_X(pPoint)); - cpBN_fix(pX); - } - if(pY) { - /* U = 1/(Z^3) */ - PMA192_mul(pU, pU, pT); - PMA192_mul(pY,pU, ECP_POINT_Y(pPoint)); - cpBN_fix(pY); - } - } -} - -/* -// ECCP192_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP192_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMA192_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMA192_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA192_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMA192_sqr(pZ4, pT); // Z^4 - PMA192_mul(pZ6, pZ4, pT); // Z^6 - - PMA192_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA192_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMA192_add(pU, pU, pT); - PMA192_sub(pR, pR, pU); - } - else { - PMA192_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMA192_add(pR, pR, pT); - } - PMA192_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA192_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA192_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMA192_add(pT, pT, ECP_POINT_X(pPoint)); - PMA192_sub(pR, pR, pT); - } - else { - PMA192_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMA192_add(pR, pR, pT); - } - PMA192_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMA192_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP192_ComparePoint -// -// Compare two points: -// returns 0 => 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 ECCP192_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA192_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA192_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA192_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA192_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA192_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA192_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA192_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA192_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP192_NegPoint -// -// Negative point -*/ -void ECCP192_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P192; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp192r1_p, pPy, LEN_P192); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP192_DblPoint -// -// Double point -*/ -void ECCP192_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA192_sqr(bnU, ECP_POINT_X(pP)); - PMA192_add(bnM, bnU, bnU); - PMA192_add(bnM, bnM, bnU); - PMA192_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA192_sqr(bnU, ECP_POINT_Z(pP)); - PMA192_add(bnS, ECP_POINT_X(pP), bnU); - PMA192_sub(bnT, ECP_POINT_X(pP), bnU); - PMA192_mul(bnM, bnS, bnT); - PMA192_add(bnU, bnM, bnM); - PMA192_add(bnM, bnU, bnM); - } - else { - PMA192_sqr(bnU, ECP_POINT_X(pP)); - PMA192_add(bnM, bnU, bnU); - PMA192_add(bnM, bnM, bnU); - PMA192_sqr(bnU, ECP_POINT_Z(pP)); - PMA192_sqr(bnU, bnU); - PMA192_mul(bnU, bnU, ECP_A(pECC)); - PMA192_add(bnM, bnM, bnU); - } - - PMA192_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA192_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA192_sqr(bnT, bnV); - PMA192_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA192_sqr(bnU, bnM); - PMA192_sub(bnU, bnU, bnS); - PMA192_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA192_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA192_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA192_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA192_mul(bnS, bnS, bnM); - PMA192_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP192_AddPoint -// -// Add points -*/ -void ECCP192_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP192_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA192_sqr(bnW, ECP_POINT_Z(pQ)); - PMA192_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA192_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA192_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA192_sqr(bnW, ECP_POINT_Z(pP)); - PMA192_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA192_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA192_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA192_sub(bnW, bnU0, bnU1); - PMA192_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P192, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P192, 0)) { - ECCP192_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA192_add(bnT, bnU0, bnU1); - PMA192_add(bnM, bnS0, bnS1); - - /* 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 { - PMA192_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA192_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA192_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA192_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA192_sqr(ECP_POINT_X(pR), bnR); - PMA192_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA192_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA192_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA192_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA192_mul(bnU1, bnU1, bnW); - PMA192_mul(bnU1, bnU1, bnM); - PMA192_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA192_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP192_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP192_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP192_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP192_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP192_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - //ECCP192_NegPoint(&T, &U, pECC); - ECCP_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP192_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP192_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP192_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP192_MulPoint: SCCM version") - -void ECCP192_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 */ - ECCP192_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP192_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP192_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP192_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP192_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP192_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP192_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP192_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP192_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP192_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP192_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP192_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP192_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP192_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP192_ProdPoint: SCCM version") - -void ECCP192_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); - - ECCP192_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP192_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP192_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_192_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224.h deleted file mode 100644 index 97d910c2ee..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224.h +++ /dev/null @@ -1,118 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over GF(P224) -// -// -*/ - -#if !defined(_PCP_ECCPMETHOD224_H) -#define _PCP_ECCPMETHOD224_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP224_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP224_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP224_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP224_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP224_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP224_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP224_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP224_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP224_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP224_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP224_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP224_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP224_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHOD224_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224ca.c deleted file mode 100644 index dbd0462dcb..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod224ca.c +++ /dev/null @@ -1,877 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P224) -// -// Contents: -// ECCP224_SetPointProjective() -// ECCP224_SetPointAffine() -// ECCP224_GetPointAffine() -// -// ECCP224_IsPointOnCurve() -// -// ECCP224_ComparePoint() -// ECCP224_NegPoint() -// ECCP224_DblPoint() -// ECCP224_AddPoint() -// ECCP224_MulPoint() -// ECCP224_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_224_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethod224.h" -#include "pcppma224.h" - -/* - NOTE: - ECCP224 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP224 = { - ECCP224_SetPointProjective, - ECCP224_SetPointAffine, - ECCP224_GetPointAffine, - - ECCP224_IsPointOnCurve, - - ECCP224_ComparePoint, - ECCP224_NegPoint, - ECCP224_DblPoint, - ECCP224_AddPoint, - ECCP224_MulPoint, - ECCP224_MulBasePoint, - ECCP224_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP224_Methods(void) -{ - return &ECCP224; -} - -/* -// ECCP224_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP224_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP224_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP224_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP224_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP224_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP224_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP224_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP224_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMA224_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMA224_sqr(pT, pU); - - if(pX) { - PMA224_mul(pX,pT, ECP_POINT_X(pPoint)); - } - if(pY) { - /* U = 1/(Z^3) */ - PMA224_mul(pU, pU, pT); - PMA224_mul(pY,pU, ECP_POINT_Y(pPoint)); - } - } -} - -/* -// ECCP224_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP224_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMA224_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMA224_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA224_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMA224_sqr(pZ4, pT); // Z^4 - PMA224_mul(pZ6, pZ4, pT); // Z^6 - - PMA224_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA224_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMA224_add(pU, pU, pT); - PMA224_sub(pR, pR, pU); - } - else { - PMA224_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMA224_add(pR, pR, pT); - } - PMA224_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA224_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA224_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMA224_add(pT, pT, ECP_POINT_X(pPoint)); - PMA224_sub(pR, pR, pT); - } - else { - PMA224_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMA224_add(pR, pR, pT); - } - PMA224_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMA224_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP224_ComparePoint -// -// Compare two points: -// returns 0 => 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 ECCP224_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA224_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA224_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA224_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA224_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA224_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA224_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA224_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA224_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP224_NegPoint -// -// Negative point -*/ -void ECCP224_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P224; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp224r1_p, pPy, LEN_P224); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP224_DblPoint -// -// Double point -*/ -void ECCP224_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA224_sqr(bnU, ECP_POINT_X(pP)); - PMA224_add(bnM, bnU, bnU); - PMA224_add(bnM, bnM, bnU); - PMA224_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA224_sqr(bnU, ECP_POINT_Z(pP)); - PMA224_add(bnS, ECP_POINT_X(pP), bnU); - PMA224_sub(bnT, ECP_POINT_X(pP), bnU); - PMA224_mul(bnM, bnS, bnT); - PMA224_add(bnU, bnM, bnM); - PMA224_add(bnM, bnU, bnM); - } - else { - PMA224_sqr(bnU, ECP_POINT_X(pP)); - PMA224_add(bnM, bnU, bnU); - PMA224_add(bnM, bnM, bnU); - PMA224_sqr(bnU, ECP_POINT_Z(pP)); - PMA224_sqr(bnU, bnU); - PMA224_mul(bnU, bnU, ECP_A(pECC)); - PMA224_add(bnM, bnM, bnU); - } - - PMA224_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA224_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA224_sqr(bnT, bnV); - PMA224_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA224_sqr(bnU, bnM); - PMA224_sub(bnU, bnU, bnS); - PMA224_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA224_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA224_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA224_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA224_mul(bnS, bnS, bnM); - PMA224_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP224_AddPoint -// -// Add points -*/ -void ECCP224_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP224_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA224_sqr(bnW, ECP_POINT_Z(pQ)); - PMA224_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA224_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA224_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA224_sqr(bnW, ECP_POINT_Z(pP)); - PMA224_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA224_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA224_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA224_sub(bnW, bnU0, bnU1); - PMA224_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P224, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P224, 0)) { - ECCP224_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA224_add(bnT, bnU0, bnU1); - PMA224_add(bnM, bnS0, bnS1); - - /* 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 { - PMA224_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA224_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA224_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA224_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA224_sqr(ECP_POINT_X(pR), bnR); - PMA224_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA224_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA224_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA224_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA224_mul(bnU1, bnU1, bnW); - PMA224_mul(bnU1, bnU1, bnM); - PMA224_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA224_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP224_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP224_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP224_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP224_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP224_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP224_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP224_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP224_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP224_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP224_MulPoint: SCCM version") - -void ECCP224_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 */ - ECCP224_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP224_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP224_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP224_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP224_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP224_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP224_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP224_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP224_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP224_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP224_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP224_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP224_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP224_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP224_ProdPoint: SCCM version") - -void ECCP224_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); - - ECCP224_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP224_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP224_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_224_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256.h deleted file mode 100644 index 3d85a85d23..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256.h +++ /dev/null @@ -1,118 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over GF(P256) -// -// -*/ - -#if !defined(_PCP_ECCPMETHOD256_H) -#define _PCP_ECCPMETHOD256_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP256_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP256_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP256_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP256_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP256_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP256_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP256_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP256_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP256_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP256_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP256_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP256_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP256_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHOD256_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256ca.c deleted file mode 100644 index b1bb0d4b08..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod256ca.c +++ /dev/null @@ -1,879 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P256) -// -// Contents: -// ECCP256_SetPointProjective() -// ECCP256_SetPointAffine() -// ECCP256_GetPointAffine() -// -// ECCP256_IsPointOnCurve() -// -// ECCP256_ComparePoint() -// ECCP256_NegPoint() -// ECCP256_DblPoint() -// ECCP256_AddPoint() -// ECCP256_MulPoint() -// ECCP256_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_256_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethod256.h" -#include "pcppma256.h" - -/* - NOTE: - ECCP256 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP256 = { - ECCP256_SetPointProjective, - ECCP256_SetPointAffine, - ECCP256_GetPointAffine, - - ECCP256_IsPointOnCurve, - - ECCP256_ComparePoint, - ECCP256_NegPoint, - ECCP256_DblPoint, - ECCP256_AddPoint, - ECCP256_MulPoint, - ECCP256_MulBasePoint, - ECCP256_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP256_Methods(void) -{ - return &ECCP256; -} - -/* -// ECCP256_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP256_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP256_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP256_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP256_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP256_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP256_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP256_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP256_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMA256_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMA256_sqr(pT, pU); - - if(pX) { - PMA256_mul(pX,pT, ECP_POINT_X(pPoint)); - cpBN_fix(pX); - } - if(pY) { - /* U = 1/(Z^3) */ - PMA256_mul(pU, pU, pT); - PMA256_mul(pY,pU, ECP_POINT_Y(pPoint)); - cpBN_fix(pY); - } - } -} - -/* -// ECCP256_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP256_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMA256_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMA256_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA256_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMA256_sqr(pZ4, pT); // Z^4 - PMA256_mul(pZ6, pZ4, pT); // Z^6 - - PMA256_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA256_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMA256_add(pU, pU, pT); - PMA256_sub(pR, pR, pU); - } - else { - PMA256_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMA256_add(pR, pR, pT); - } - PMA256_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA256_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA256_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMA256_add(pT, pT, ECP_POINT_X(pPoint)); - PMA256_sub(pR, pR, pT); - } - else { - PMA256_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMA256_add(pR, pR, pT); - } - PMA256_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMA256_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP256_ComparePoint -// -// Compare two points: -// returns 0 => 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 ECCP256_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA256_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA256_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA256_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA256_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA256_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA256_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA256_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA256_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP256_NegPoint -// -// Negative point -*/ -void ECCP256_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P256; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp256r1_p, pPy, LEN_P256); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP256_DblPoint -// -// Double point -*/ -void ECCP256_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA256_sqr(bnU, ECP_POINT_X(pP)); - PMA256_add(bnM, bnU, bnU); - PMA256_add(bnM, bnM, bnU); - PMA256_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA256_sqr(bnU, ECP_POINT_Z(pP)); - PMA256_add(bnS, ECP_POINT_X(pP), bnU); - PMA256_sub(bnT, ECP_POINT_X(pP), bnU); - PMA256_mul(bnM, bnS, bnT); - PMA256_add(bnU, bnM, bnM); - PMA256_add(bnM, bnU, bnM); - } - else { - PMA256_sqr(bnU, ECP_POINT_X(pP)); - PMA256_add(bnM, bnU, bnU); - PMA256_add(bnM, bnM, bnU); - PMA256_sqr(bnU, ECP_POINT_Z(pP)); - PMA256_sqr(bnU, bnU); - PMA256_mul(bnU, bnU, ECP_A(pECC)); - PMA256_add(bnM, bnM, bnU); - } - - PMA256_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA256_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA256_sqr(bnT, bnV); - PMA256_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA256_sqr(bnU, bnM); - PMA256_sub(bnU, bnU, bnS); - PMA256_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA256_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA256_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA256_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA256_mul(bnS, bnS, bnM); - PMA256_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP256_AddPoint -// -// Add points -*/ -void ECCP256_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP256_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA256_sqr(bnW, ECP_POINT_Z(pQ)); - PMA256_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA256_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA256_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA256_sqr(bnW, ECP_POINT_Z(pP)); - PMA256_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA256_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA256_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA256_sub(bnW, bnU0, bnU1); - PMA256_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P256, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P256, 0)) { - ECCP256_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA256_add(bnT, bnU0, bnU1); - PMA256_add(bnM, bnS0, bnS1); - - /* 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 { - PMA256_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA256_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA256_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA256_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA256_sqr(ECP_POINT_X(pR), bnR); - PMA256_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA256_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA256_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA256_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA256_mul(bnU1, bnU1, bnW); - PMA256_mul(bnU1, bnU1, bnM); - PMA256_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA256_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP256_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP256_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP256_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP256_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP256_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP256_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP256_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP256_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP256_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP256_MulPoint: SCCM version") - -void ECCP256_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 */ - ECCP256_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP256_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP256_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP256_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP256_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP256_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP256_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP256_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP256_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP256_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP256_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP256_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP256_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP256_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP256_ProdPoint: SCCM version") - -void ECCP256_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); - - ECCP256_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP256_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP256_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_256_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384.h deleted file mode 100644 index 6fab894565..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384.h +++ /dev/null @@ -1,118 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over GF(P384) -// -// -*/ - -#if !defined(_PCP_ECCPMETHOD384_H) -#define _PCP_ECCPMETHOD384_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP384_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP384_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP384_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP384_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP384_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP384_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP384_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP384_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP384_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP384_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP384_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP384_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP384_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHOD384_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384ca.c deleted file mode 100644 index 72252e8bdf..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod384ca.c +++ /dev/null @@ -1,879 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P384) -// -// Contents: -// ECCP384_SetPointProjective() -// ECCP384_SetPointAffine() -// ECCP384_GetPointAffine() -// -// ECCP384_IsPointOnCurve() -// -// ECCP384_ComparePoint() -// ECCP384_NegPoint() -// ECCP384_DblPoint() -// ECCP384_AddPoint() -// ECCP384_MulPoint() -// ECCP384_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_384_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethod384.h" -#include "pcppma384.h" - -/* - NOTE: - ECCP384 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP384 = { - ECCP384_SetPointProjective, - ECCP384_SetPointAffine, - ECCP384_GetPointAffine, - - ECCP384_IsPointOnCurve, - - ECCP384_ComparePoint, - ECCP384_NegPoint, - ECCP384_DblPoint, - ECCP384_AddPoint, - ECCP384_MulPoint, - ECCP384_MulBasePoint, - ECCP384_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP384_Methods(void) -{ - return &ECCP384; -} - -/* -// ECCP384_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP384_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP384_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP384_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP384_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP384_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP384_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP384_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP384_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMA384_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMA384_sqr(pT, pU); - - if(pX) { - PMA384_mul(pX,pT, ECP_POINT_X(pPoint)); - cpBN_fix(pX); - } - if(pY) { - /* U = 1/(Z^3) */ - PMA384_mul(pU, pU, pT); - PMA384_mul(pY,pU, ECP_POINT_Y(pPoint)); - cpBN_fix(pY); - } - } -} - -/* -// ECCP384_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP384_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMA384_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMA384_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA384_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMA384_sqr(pZ4, pT); // Z^4 - PMA384_mul(pZ6, pZ4, pT); // Z^6 - - PMA384_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA384_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMA384_add(pU, pU, pT); - PMA384_sub(pR, pR, pU); - } - else { - PMA384_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMA384_add(pR, pR, pT); - } - PMA384_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA384_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA384_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMA384_add(pT, pT, ECP_POINT_X(pPoint)); - PMA384_sub(pR, pR, pT); - } - else { - PMA384_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMA384_add(pR, pR, pT); - } - PMA384_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMA384_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP384_ComparePoint -// -// Compare two points: -// returns 0 => 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 ECCP384_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA384_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA384_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA384_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA384_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA384_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA384_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA384_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA384_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP384_NegPoint -// -// Negative point -*/ -void ECCP384_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P384; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp384r1_p, pPy, LEN_P384); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP384_DblPoint -// -// Double point -*/ -void ECCP384_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA384_sqr(bnU, ECP_POINT_X(pP)); - PMA384_add(bnM, bnU, bnU); - PMA384_add(bnM, bnM, bnU); - PMA384_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA384_sqr(bnU, ECP_POINT_Z(pP)); - PMA384_add(bnS, ECP_POINT_X(pP), bnU); - PMA384_sub(bnT, ECP_POINT_X(pP), bnU); - PMA384_mul(bnM, bnS, bnT); - PMA384_add(bnU, bnM, bnM); - PMA384_add(bnM, bnU, bnM); - } - else { - PMA384_sqr(bnU, ECP_POINT_X(pP)); - PMA384_add(bnM, bnU, bnU); - PMA384_add(bnM, bnM, bnU); - PMA384_sqr(bnU, ECP_POINT_Z(pP)); - PMA384_sqr(bnU, bnU); - PMA384_mul(bnU, bnU, ECP_A(pECC)); - PMA384_add(bnM, bnM, bnU); - } - - PMA384_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA384_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA384_sqr(bnT, bnV); - PMA384_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA384_sqr(bnU, bnM); - PMA384_sub(bnU, bnU, bnS); - PMA384_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA384_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA384_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA384_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA384_mul(bnS, bnS, bnM); - PMA384_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP384_AddPoint -// -// Add points -*/ -void ECCP384_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP384_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA384_sqr(bnW, ECP_POINT_Z(pQ)); - PMA384_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA384_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA384_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA384_sqr(bnW, ECP_POINT_Z(pP)); - PMA384_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA384_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA384_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA384_sub(bnW, bnU0, bnU1); - PMA384_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P384, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P384, 0)) { - ECCP384_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA384_add(bnT, bnU0, bnU1); - PMA384_add(bnM, bnS0, bnS1); - - /* 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 { - PMA384_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA384_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA384_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA384_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA384_sqr(ECP_POINT_X(pR), bnR); - PMA384_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA384_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA384_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA384_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA384_mul(bnU1, bnU1, bnW); - PMA384_mul(bnU1, bnU1, bnM); - PMA384_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA384_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP384_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP384_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP384_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP384_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP384_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP384_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP384_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP384_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP384_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP384_MulPoint: SCCM version") - -void ECCP384_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 */ - ECCP384_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP384_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP384_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP384_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP384_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP384_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP384_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP384_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP384_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP384_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP384_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP384_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP384_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP384_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP384_ProdPoint: SCCM version") - -void ECCP384_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); - - ECCP384_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP384_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP384_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_384_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521.h deleted file mode 100644 index d931bc6d17..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521.h +++ /dev/null @@ -1,118 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over GF(P521) -// -// -*/ - -#if !defined(_PCP_ECCPMETHOD521_H) -#define _PCP_ECCPMETHOD521_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP521_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP521_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP521_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP521_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP521_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP521_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP521_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP521_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP521_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP521_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP521_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP521_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP521_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHOD521_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521ca.c deleted file mode 100644 index 0bc7c59c96..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethod521ca.c +++ /dev/null @@ -1,879 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P521) -// -// Contents: -// ECCP521_SetPointProjective() -// ECCP521_SetPointAffine() -// ECCP521_GetPointAffine() -// -// ECCP521_IsPointOnCurve() -// -// ECCP521_ComparePoint() -// ECCP521_NegPoint() -// ECCP521_DblPoint() -// ECCP521_AddPoint() -// ECCP521_MulPoint() -// ECCP521_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_521_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethod521.h" -#include "pcppma521.h" - -/* - NOTE: - ECCP521 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP521 = { - ECCP521_SetPointProjective, - ECCP521_SetPointAffine, - ECCP521_GetPointAffine, - - ECCP521_IsPointOnCurve, - - ECCP521_ComparePoint, - ECCP521_NegPoint, - ECCP521_DblPoint, - ECCP521_AddPoint, - ECCP521_MulPoint, - ECCP521_MulBasePoint, - ECCP521_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP521_Methods(void) -{ - return &ECCP521; -} - -/* -// ECCP521_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP521_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP521_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP521_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP521_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP521_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP521_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP521_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP521_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMA521_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMA521_sqr(pT, pU); - - if(pX) { - PMA521_mul(pX,pT, ECP_POINT_X(pPoint)); - cpBN_fix(pX); - } - if(pY) { - /* U = 1/(Z^3) */ - PMA521_mul(pU, pU, pT); - PMA521_mul(pY,pU, ECP_POINT_Y(pPoint)); - cpBN_fix(pY); - } - } -} - -/* -// ECCP521_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP521_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMA521_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMA521_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA521_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMA521_sqr(pZ4, pT); // Z^4 - PMA521_mul(pZ6, pZ4, pT); // Z^6 - - PMA521_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA521_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMA521_add(pU, pU, pT); - PMA521_sub(pR, pR, pU); - } - else { - PMA521_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMA521_add(pR, pR, pT); - } - PMA521_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA521_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA521_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMA521_add(pT, pT, ECP_POINT_X(pPoint)); - PMA521_sub(pR, pR, pT); - } - else { - PMA521_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMA521_add(pR, pR, pT); - } - PMA521_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMA521_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP521_ComparePoint -// -// Compare two points: -// returns 0 => 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 ECCP521_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMA521_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMA521_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA521_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMA521_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMA521_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMA521_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMA521_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMA521_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP521_NegPoint -// -// Negative point -*/ -void ECCP521_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P521; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)secp521r1_p, pPy, LEN_P521); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP521_DblPoint -// -// Double point -*/ -void ECCP521_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMA521_sqr(bnU, ECP_POINT_X(pP)); - PMA521_add(bnM, bnU, bnU); - PMA521_add(bnM, bnM, bnU); - PMA521_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMA521_sqr(bnU, ECP_POINT_Z(pP)); - PMA521_add(bnS, ECP_POINT_X(pP), bnU); - PMA521_sub(bnT, ECP_POINT_X(pP), bnU); - PMA521_mul(bnM, bnS, bnT); - PMA521_add(bnU, bnM, bnM); - PMA521_add(bnM, bnU, bnM); - } - else { - PMA521_sqr(bnU, ECP_POINT_X(pP)); - PMA521_add(bnM, bnU, bnU); - PMA521_add(bnM, bnM, bnU); - PMA521_sqr(bnU, ECP_POINT_Z(pP)); - PMA521_sqr(bnU, bnU); - PMA521_mul(bnU, bnU, ECP_A(pECC)); - PMA521_add(bnM, bnM, bnU); - } - - PMA521_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMA521_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMA521_sqr(bnT, bnV); - PMA521_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMA521_sqr(bnU, bnM); - PMA521_sub(bnU, bnU, bnS); - PMA521_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMA521_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMA521_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMA521_sub(bnS, bnS, ECP_POINT_X(pR)); - PMA521_mul(bnS, bnS, bnM); - PMA521_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP521_AddPoint -// -// Add points -*/ -void ECCP521_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP521_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMA521_sqr(bnW, ECP_POINT_Z(pQ)); - PMA521_mul(bnU0,ECP_POINT_X(pP), bnW); - PMA521_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMA521_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMA521_sqr(bnW, ECP_POINT_Z(pP)); - PMA521_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMA521_mul(bnW, ECP_POINT_Z(pP), bnW); - PMA521_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMA521_sub(bnW, bnU0, bnU1); - PMA521_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P521, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P521, 0)) { - ECCP521_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMA521_add(bnT, bnU0, bnU1); - PMA521_add(bnM, bnS0, bnS1); - - /* 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 { - PMA521_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMA521_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMA521_sqr(bnU1, bnW); /* U1 = W^2 */ - PMA521_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMA521_sqr(ECP_POINT_X(pR), bnR); - PMA521_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMA521_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMA521_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMA521_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMA521_mul(bnU1, bnU1, bnW); - PMA521_mul(bnU1, bnU1, bnM); - PMA521_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMA521_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP521_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP521_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP521_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP521_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP521_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP521_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP521_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP521_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP521_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP521_MulPoint: SCCM version") - -void ECCP521_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 */ - ECCP521_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP521_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP521_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP521_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP521_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP521_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP521_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP521_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP521_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP521_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP521_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP521_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP521_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP521_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP521_ProdPoint: SCCM version") - -void ECCP521_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); - - ECCP521_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP521_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP521_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_521_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcom.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcom.h deleted file mode 100644 index 57057f1bd5..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcom.h +++ /dev/null @@ -1,133 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of EC methods over common GF(p) -// -// -*/ - -#if !defined(_PCP_ECCPMETHODCOM_H) -#define _PCP_ECCPMETHODCOM_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCPcom_Methods(void); - -/* -// Copy -*/ -void ECCP_CopyPoint(const IppsECCPPointState* pSrc, IppsECCPPointState* pDst); - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Set To Infinity -*/ -void ECCP_SetPointToInfinity(IppsECCPPointState* pPoint); -void ECCP_SetPointToAffineInfinity0(IppsBigNumState* pX, IppsBigNumState* pY); -void ECCP_SetPointToAffineInfinity1(IppsBigNumState* pX, IppsBigNumState* pY); - -/* -// Test Is At Infinity -// Test is On EC -*/ -int ECCP_IsPointAtInfinity(const IppsECCPPointState* pPoint); -int ECCP_IsPointAtAffineInfinity0(const IppsBigNumState* pX, const IppsBigNumState* pY); -int ECCP_IsPointAtAffineInfinity1(const IppsBigNumState* pX, const IppsBigNumState* pY); -int ECCP_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -#endif /* _PCP_ECCPMETHODCOM_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcomca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcomca.c deleted file mode 100644 index 396e01b754..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodcomca.c +++ /dev/null @@ -1,1025 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over common GF(p) -// -// Contents: -// ECCP_CopyPoint() -// ECCP_SetPointProjective() -// ECCP_SetPointAffine() -// -// ECCP_GetPointProjective() -// ECCP_GetPointAffine() -// -// ECCP_SetPointToInfinity() -// ECCP_SetPointToAffineInfinity0() -// ECCP_SetPointToAffineInfinity1() -// -// ECCP_IsPointAtInfinity() -// ECCP_IsPointAtAffineInfinity0() -// ECCP_IsPointAtAffineInfinity1() -// -// ECCP_IsPointOnCurve() -// -// ECCP_ComparePoint() -// ECCP_NegPoint() -// ECCP_DblPoint() -// ECCP_AddPoint() -// ECCP_MulPoint() -// ECCP_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcppma.h" -#include "pcpeccpsscm.h" - - -/* - NOTE: - ECCPcom methods are used representation of point coordinates - in Montgomery domain, because of Montgomery mul/sqr operations inside -*/ -static -ECCP_METHOD ECCPcom = { - ECCP_SetPointProjective, - ECCP_SetPointAffine, - ECCP_GetPointAffine, - - ECCP_IsPointOnCurve, - - ECCP_ComparePoint, - ECCP_NegPoint, - ECCP_DblPoint, - ECCP_AddPoint, - ECCP_MulPoint, - ECCP_MulBasePoint, - ECCP_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCPcom_Methods(void) -{ - return &ECCPcom; -} - - -/* -// Copy Point -*/ -void ECCP_CopyPoint(const IppsECCPPointState* pSrc, IppsECCPPointState* pDst) -{ - cpBN_copy(ECP_POINT_X(pDst), ECP_POINT_X(pSrc)); - cpBN_copy(ECP_POINT_Y(pDst), ECP_POINT_Y(pSrc)); - cpBN_copy(ECP_POINT_Z(pDst), ECP_POINT_Z(pSrc)); - ECP_POINT_AFFINE(pDst) = ECP_POINT_AFFINE(pSrc); -} - -/* -// ECCP_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - IppsMontState* pMont = ECP_PMONT(pECC); - - PMA_enc(ECP_POINT_X(pPoint), (IppsBigNumState*)pX, pMont); - PMA_enc(ECP_POINT_Y(pPoint), (IppsBigNumState*)pY, pMont); - PMA_enc(ECP_POINT_Z(pPoint), (IppsBigNumState*)pZ, pMont); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - IppsMontState* pMont = ECP_PMONT(pECC); - PMA_enc(ECP_POINT_X(pPoint), (IppsBigNumState*)pX, pMont); - PMA_enc(ECP_POINT_Y(pPoint), (IppsBigNumState*)pY, pMont); - PMA_enc(ECP_POINT_Z(pPoint), (IppsBigNumState*)cpBN_OneRef(), pMont); - ECP_POINT_AFFINE(pPoint) = 1; -} - -/* -// ECCP_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - IppsMontState* pMont = ECP_PMONT(pECC); - - PMA_dec(pX, ECP_POINT_X(pPoint), pMont); - PMA_dec(pY, ECP_POINT_Y(pPoint), pMont); - PMA_dec(pZ, ECP_POINT_Z(pPoint), pMont); -} -#endif - -/* -// ECCP_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - IppsMontState* pMont = ECP_PMONT(pECC); - - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - PMA_dec(pX, ECP_POINT_X(pPoint), pMont); - } - if(pY) { - PMA_dec(pY, ECP_POINT_Y(pPoint), pMont); - } - } - - /* case Z != 1 */ - else { - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - /* decode Z */ - PMA_dec(pU, ECP_POINT_Z(pPoint), pMont); - /* regular T = Z^-1 */ - PMA_inv(pT, pU, pModulo); - /* montgomery U = Z^-1 */ - PMA_enc(pU, pT, pMont); - /* regular T = Z^-2 */ - PMA_mule(pT, pU, pT, pMont); - - if(pX) { - PMA_mule(pX,pT, ECP_POINT_X(pPoint), pMont); - } - if(pY) { - /* regular U = Z^-3 */ - PMA_mule(pU, pU, pT, pMont); - PMA_mule(pY,pU, ECP_POINT_Y(pPoint), pMont); - } - } -} - -/* -// ECCP_SetPointToInfinity -// ECCP_SetPointToAffineInfinity0 -// ECCP_SetPointToAffineInfinity1 -// -// Set point to Infinity -*/ -void ECCP_SetPointToInfinity(IppsECCPPointState* pPoint) -{ - cpBN_zero(ECP_POINT_X(pPoint)); - cpBN_zero(ECP_POINT_Y(pPoint)); - cpBN_zero(ECP_POINT_Z(pPoint)); - ECP_POINT_AFFINE(pPoint) = 0; -} - -void ECCP_SetPointToAffineInfinity0(IppsBigNumState* pX, IppsBigNumState* pY) -{ - if(pX) cpBN_zero(pX); - if(pY) cpBN_zero(pY); -} - -void ECCP_SetPointToAffineInfinity1(IppsBigNumState* pX, IppsBigNumState* pY) -{ - if(pX) cpBN_zero(pX); - if(pY) BN_Word(pY,1); -} - -/* -// ECCP_IsPointAtInfinity -// ECCP_IsPointAtAffineInfinity0 -// ECCP_IsPointAtAffineInfinity1 -// -// Test point is at Infinity -*/ -int ECCP_IsPointAtInfinity(const IppsECCPPointState* pPoint) -{ - return IsZero_BN( ECP_POINT_Z(pPoint) ); -} - -int ECCP_IsPointAtAffineInfinity0(const IppsBigNumState* pX, const IppsBigNumState* pY) -{ - return IsZero_BN(pX) && IsZero_BN(pY); -} - -int ECCP_IsPointAtAffineInfinity1(const IppsBigNumState* pX, const IppsBigNumState* pY) -{ - return IsZero_BN(pX) && !IsZero_BN(pY); -} - -/* -// ECCP_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - PMA_sqre(pR, ECP_POINT_X(pPoint), pMont); // R = X^3 - PMA_mule(pR, pR, ECP_POINT_X(pPoint), pMont); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMA_sqre(pT, ECP_POINT_Z(pPoint), pMont); // Z^2 - PMA_sqre(pZ4, pT, pMont); // Z^4 - PMA_mule(pZ6, pZ4, pT, pMont); // Z^6 - - PMA_mule(pT, pZ4, ECP_POINT_X(pPoint), pMont); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMA_add(pU, pT, pT, pModulo); // R = X^3 +a*X*Z^4 - PMA_add(pU, pU, pT, pModulo); - PMA_sub(pR, pR, pU, pModulo); - } - else { - PMA_mule(pT, pT, ECP_AENC(pECC), pMont); // R = X^3 +a*X*Z^4 - PMA_add(pR, pR, pT, pModulo); - } - PMA_mule(pT, pZ6, ECP_BENC(pECC), pMont); // R = X^3 +a*X*Z^4 + b*Z^6 - PMA_add(pR, pR, pT, pModulo); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMA_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint), pModulo); // R = X^3 +a*X - PMA_add(pT, pT, ECP_POINT_X(pPoint), pModulo); - PMA_sub(pR, pR, pT, pModulo); - } - else { - PMA_mule(pT, ECP_POINT_X(pPoint), ECP_AENC(pECC), pMont); // R = X^3 +a*X - PMA_add(pR, pR, pT, pModulo); - } - PMA_add(pR, pR, ECP_BENC(pECC), pModulo); // R = X^3 +a*X + b - } - PMA_sqre(pT, ECP_POINT_Y(pPoint), pMont); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP_ComparePoint -// -// Compare two points: -// returns 0 => 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) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 -*/ -#if !defined (_USE_ECCP_SSCM_) -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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP_MulPoint: SCCM version") - -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); - } - } - } -} -#endif - -#if 0 -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 { - int n; - - IppsECCPPointState tmpPoint[15]; - IppsBigNumState* pX = cpBigNumListGet(&pList); - IppsBigNumState* pY = cpBigNumListGet(&pList); - - /* allocate temporary points */ - { - for(n=0; n<15; n++) { - ECP_POINT_X(&tmpPoint[n]) = cpBigNumListGet(&pList); - ECP_POINT_Y(&tmpPoint[n]) = cpBigNumListGet(&pList); - ECP_POINT_Z(&tmpPoint[n]) = cpBigNumListGet(&pList); - } - } - - /* precomputation */ - if( ippBigNumPOS == BN_SIGN(bnN) ) - ECCP_CopyPoint(pP, &tmpPoint[0]); - else - ECCP_NegPoint(pP, &tmpPoint[0], pECC); - - ECCP_GetPointAffine(pX, pY, &tmpPoint[0], pECC, pList); - ECCP_SetPointAffine(pX, pY, &tmpPoint[0], pECC); - - for(n=1; n<15; n+=2) { - ECCP_DblPoint(&tmpPoint[n/2], &tmpPoint[n], pECC, pList); - ECCP_GetPointAffine(pX, pY, &tmpPoint[n], pECC, pList); - ECCP_SetPointAffine(pX, pY, &tmpPoint[n], pECC); - - ECCP_AddPoint(&tmpPoint[n], &tmpPoint[0], &tmpPoint[n+1], pECC, pList); - ECCP_GetPointAffine(pX, pY, &tmpPoint[n+1], pECC, pList); - ECCP_SetPointAffine(pX, pY, &tmpPoint[n+1], pECC); - } - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=BN_SIZE(bnN); n>0; n--) { - Ipp32u scalar = BN_NUMBER(bnN)[n-1]; - - int shift; - for(shift=(32-4); shift>=0; shift-=4) { - int m; - int tblIdx = (scalar>>shift) & 0xF; - - if( !ECCP_IsPointAtInfinity(pR) ) { - for(m=0; m<4; m++) - ECCP_DblPoint(pR, pR, pECC, pList); - } - if( tblIdx ) - ECCP_AddPoint(pR, &tmpPoint[tblIdx-1], pR, pECC, pList); - } - } - } -} -#endif - -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 -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} -#else -#pragma message ("ECCP_ProdPoint: SCCM version") -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); -} -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2.h deleted file mode 100644 index 12b59bccdb..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2.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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Definitions of methods over SM2 curve -// -// -*/ - -#if !defined(_PCP_ECCP_SM2_METHOD_H) -#define _PCP_ECCP_SM2_METHOD_H - -#include "pcpeccp.h" - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP_SM2_Methods(void); - - -/* -// Point Set. These operations implies -// transformation of regular coordinates into internal format -*/ -void ECCP_SM2_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -void ECCP_SM2_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC); - -/* -// Get Point. These operations implies -// transformation of internal format coordinates into regular -*/ -//void ECCP256_GetPointProjective(IppsBigNumState* pX, -// IppsBigNumState* pY, -// IppsBigNumState* pZ, -// const IppsECCPPointState* pPoint, -// const IppsECCPState* pECC); - -void ECCP_SM2_GetPointAffine(IppsBigNumState* pX, - IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Test is On EC -*/ -int ECCP_SM2_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList); - -/* -// Operations -*/ -int ECCP_SM2_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_SM2_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC); - -void ECCP_SM2_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_SM2_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_SM2_MulPoint(const IppsECCPPointState* pP, - const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_SM2_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - -void ECCP_SM2_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList); - - - -#endif /* _PCP_ECCP_SM2_METHOD_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2ca.c deleted file mode 100644 index 04d17a5bf4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpmethodsm2ca.c +++ /dev/null @@ -1,879 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC methods over GF(P256) SM2 -// -// Contents: -// ECCP_SM2_SetPointProjective() -// ECCP_SM2_SetPointAffine() -// ECCP_SM2_GetPointAffine() -// -// ECCP_SM2_IsPointOnCurve() -// -// ECCP_SM2_ComparePoint() -// ECCP_SM2_NegPoint() -// ECCP_SM2_DblPoint() -// ECCP_SM2_AddPoint() -// ECCP_SM2_MulPoint() -// ECCP_SM2_ProdPoint() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_SM2_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccppoint.h" -#include "pcpeccpmethod.h" -#include "pcpeccpmethodcom.h" -#include "pcpeccpmethodsm2.h" -#include "pcppmasm2.h" - -/* - NOTE: - ECCP256 methods are used representation of point coordinates - in regular (usual residue) domain, because of special modular reduction -*/ -static -ECCP_METHOD ECCP_SM2 = { - ECCP_SM2_SetPointProjective, - ECCP_SM2_SetPointAffine, - ECCP_SM2_GetPointAffine, - - ECCP_SM2_IsPointOnCurve, - - ECCP_SM2_ComparePoint, - ECCP_SM2_NegPoint, - ECCP_SM2_DblPoint, - ECCP_SM2_AddPoint, - ECCP_SM2_MulPoint, - ECCP_SM2_MulBasePoint, - ECCP_SM2_ProdPoint -}; - - -/* -// Returns reference -*/ -ECCP_METHOD* ECCP_SM2_Methods(void) -{ - return &ECCP_SM2; -} - -/* -// ECCP_SM2_PoinSettProjective -// Converts regular projective triplet (pX,pY,pZ) into pPoint -// (see note above) -*/ -void ECCP_SM2_SetPointProjective(const IppsBigNumState* pX, - const IppsBigNumState* pY, - const IppsBigNumState* pZ, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(ECP_POINT_X(pPoint), pX); - cpBN_copy(ECP_POINT_Y(pPoint), pY); - cpBN_copy(ECP_POINT_Z(pPoint), pZ); - ECP_POINT_AFFINE(pPoint) = cpBN_cmp(pZ, BN_ONE_REF())==0; -} - -/* -// ECCP_SM2_PointAffineSet -// Converts regular affine pair (pX,pY) into pPoint -*/ -void ECCP_SM2_SetPointAffine(const IppsBigNumState* pX, - const IppsBigNumState* pY, - IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - ECCP_SM2_SetPointProjective(pX, pY, BN_ONE_REF(), pPoint, pECC); -} - -/* -// ECCP_SM2_GetPointProjective -// Converts pPoint into regular projective triplet (pX,pY,pZ) -*/ -#if 0 -void ECCP_SM2_GetPointProjective(IppsBigNumState* pX, - IppsBigNumState* pY, - IppsBigNumState* pZ, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - cpBN_copy(pX, ECP_POINT_X(pPoint)); - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - cpBN_copy(pZ, ECP_POINT_Z(pPoint)); -} -#endif - -/* -// ECCP_SM2_GetPointAffine -// -// Converts pPoint into regular affine pair (pX,pY) -// -// Note: -// pPoint is not point at Infinity -// transform (X, Y, Z) into (x, y) = (X/Z^2, Y/Z^3) -*/ -void ECCP_SM2_GetPointAffine(IppsBigNumState* pX, IppsBigNumState* pY, - const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* case Z == 1 */ - if( ECP_POINT_AFFINE(pPoint) ) { - if(pX) { - cpBN_copy(pX, ECP_POINT_X(pPoint)); - } - if(pY) { - cpBN_copy(pY, ECP_POINT_Y(pPoint)); - } - } - - /* case Z != 1 */ - else { - //IppsMontState* pMont = ECP_PMONT(pECC); - IppsBigNumState* pModulo = ECP_PRIME(pECC); - - IppsBigNumState* pT = cpBigNumListGet(&pList); - IppsBigNumState* pU = cpBigNumListGet(&pList); - //IppsBigNumState* pModulo = cpBigNumListGet(&pList); - //BN_Set(MNT_MODULUS(pMont), MNT_SIZE(pMont), pModulo); - - /* U = 1/Z */ - PMAsm2_inv(pU, ECP_POINT_Z(pPoint), pModulo); - /* T = 1/(Z^2) */ - PMAsm2_sqr(pT, pU); - - if(pX) { - PMAsm2_mul(pX,pT, ECP_POINT_X(pPoint)); - cpBN_fix(pX); - } - if(pY) { - /* U = 1/(Z^3) */ - PMAsm2_mul(pU, pU, pT); - PMAsm2_mul(pY,pU, ECP_POINT_Y(pPoint)); - cpBN_fix(pY); - } - } -} - -/* -// ECCP_SM2_IsPointOnCurve -// -// Test point is lie on curve -// -// Note -// We deal with equation: y^2 = x^3 + A*x + B. -// Or in projective coordinates: Y^2 = X^3 + a*X*Z^4 + b*Z^6. -// The point under test is given by projective triplet (X,Y,Z), -// which represents actually (x,y) = (X/Z^2,Y/Z^3). -*/ -int ECCP_SM2_IsPointOnCurve(const IppsECCPPointState* pPoint, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* let think Infinity point is on the curve */ - if( ECCP_IsPointAtInfinity(pPoint) ) - return 1; - - else { - IppsBigNumState* pR = cpBigNumListGet(&pList); - IppsBigNumState* pT = cpBigNumListGet(&pList); - - PMAsm2_sqr(pR, ECP_POINT_X(pPoint)); // R = X^3 - PMAsm2_mul(pR, pR, ECP_POINT_X(pPoint)); - - /* case Z != 1 */ - if( !ECP_POINT_AFFINE(pPoint) ) { - IppsBigNumState* pZ4 = cpBigNumListGet(&pList); - IppsBigNumState* pZ6 = cpBigNumListGet(&pList); - PMAsm2_sqr(pT, ECP_POINT_Z(pPoint)); // Z^2 - PMAsm2_sqr(pZ4, pT); // Z^4 - PMAsm2_mul(pZ6, pZ4, pT); // Z^6 - - PMAsm2_mul(pT, pZ4, ECP_POINT_X(pPoint)); // T = X*Z^4 - if( ECP_AMI3(pECC) ) { - IppsBigNumState* pU = cpBigNumListGet(&pList); - PMAsm2_add(pU, pT, pT); // R = X^3 +a*X*Z^4 - PMAsm2_add(pU, pU, pT); - PMAsm2_sub(pR, pR, pU); - } - else { - PMAsm2_mul(pT, pT, ECP_A(pECC)); // R = X^3 +a*X*Z^4 - PMAsm2_add(pR, pR, pT); - } - PMAsm2_mul(pT, pZ6, ECP_B(pECC)); // R = X^3 +a*X*Z^4 + b*Z^6 - PMAsm2_add(pR, pR, pT); - - } - /* case Z == 1 */ - else { - if( ECP_AMI3(pECC) ) { - PMAsm2_add(pT, ECP_POINT_X(pPoint), ECP_POINT_X(pPoint)); // R = X^3 +a*X - PMAsm2_add(pT, pT, ECP_POINT_X(pPoint)); - PMAsm2_sub(pR, pR, pT); - } - else { - PMAsm2_mul(pT, ECP_POINT_X(pPoint), ECP_A(pECC)); // R = X^3 +a*X - PMAsm2_add(pR, pR, pT); - } - PMAsm2_add(pR, pR, ECP_B(pECC)); // R = X^3 +a*X + b - } - PMAsm2_sqr(pT, ECP_POINT_Y(pPoint)); // T = Y^2 - return 0==cpBN_cmp(pR, pT); - } -} - -/* -// ECCP_SM2_ComparePoint -// -// Compare two points: -// returns 0 => 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_SM2_ComparePoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - UNREFERENCED_PARAMETER(pECC); - - /* 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; - - { - 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) ) { - PMAsm2_sqr(pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_X*Q_Z^2 */ - PMAsm2_mul(pPtmp, ECP_POINT_X(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_X(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMAsm2_sqr(pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_X*P_Z^2 */ - PMAsm2_mul(pQtmp, ECP_POINT_X(pQ), pPZ); - } - 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) ) { - PMAsm2_mul(pQZ, pQZ, ECP_POINT_Z(pQ)); /* Ptmp = P_Y*Q_Z^3 */ - PMAsm2_mul(pPtmp, ECP_POINT_Y(pP), pQZ); - } - else { - PMA_set(pPtmp, ECP_POINT_Y(pP)); - } - if( !ECP_POINT_AFFINE(pP) ) { - PMAsm2_mul(pPZ, pPZ, ECP_POINT_Z(pP)); /* Qtmp = Q_Y*P_Z^3 */ - PMAsm2_mul(pQtmp, ECP_POINT_Y(pQ), pPZ); - } - else { - PMA_set(pQtmp, ECP_POINT_Y(pQ)); - } - return cpBN_cmp(pPtmp, pQtmp)? 1:0; - } -} - -/* -// ECCP_SM2_NegPoint -// -// Negative point -*/ -void ECCP_SM2_NegPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC) -{ - UNREFERENCED_PARAMETER(pECC); - - /* test point at Infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - BNU_CHUNK_T* pRy = BN_NUMBER(ECP_POINT_Y(pR)); - BNU_CHUNK_T* pPy = BN_NUMBER(ECP_POINT_Y(pP)); - int size = LEN_P256; - - if( pP!=pR ) { - PMA_set(ECP_POINT_X(pR), ECP_POINT_X(pP)); - PMA_set(ECP_POINT_Z(pR), ECP_POINT_Z(pP)); - ECP_POINT_AFFINE(pR) = ECP_POINT_AFFINE(pP); - } - cpSub_BNU(pRy, (BNU_CHUNK_T*)tpmSM2_p256_p, pPy, LEN_P256); - FIX_BNU(pRy,size); - BN_SIZE(ECP_POINT_Y(pR)) = size; - BN_SIGN(ECP_POINT_Y(pR)) = ippBigNumPOS; - } -} - -/* -// ECCP_SM2_DblPoint -// -// Double point -*/ -void ECCP_SM2_DblPoint(const IppsECCPPointState* pP, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* P at infinity */ - if( ECCP_IsPointAtInfinity(pP) ) - ECCP_SetPointToInfinity(pR); - - else { - IppsBigNumState* bnV = cpBigNumListGet(&pList); - IppsBigNumState* bnU = cpBigNumListGet(&pList); - IppsBigNumState* bnM = cpBigNumListGet(&pList); - IppsBigNumState* bnS = cpBigNumListGet(&pList); - IppsBigNumState* bnT = cpBigNumListGet(&pList); - - /* M = 3*X^2 + A*Z^4 */ - if( ECP_POINT_AFFINE(pP) ) { - PMAsm2_sqr(bnU, ECP_POINT_X(pP)); - PMAsm2_add(bnM, bnU, bnU); - PMAsm2_add(bnM, bnM, bnU); - PMAsm2_add(bnM, bnM, ECP_A(pECC)); - } - else if( ECP_AMI3(pECC) ) { - PMAsm2_sqr(bnU, ECP_POINT_Z(pP)); - PMAsm2_add(bnS, ECP_POINT_X(pP), bnU); - PMAsm2_sub(bnT, ECP_POINT_X(pP), bnU); - PMAsm2_mul(bnM, bnS, bnT); - PMAsm2_add(bnU, bnM, bnM); - PMAsm2_add(bnM, bnU, bnM); - } - else { - PMAsm2_sqr(bnU, ECP_POINT_X(pP)); - PMAsm2_add(bnM, bnU, bnU); - PMAsm2_add(bnM, bnM, bnU); - PMAsm2_sqr(bnU, ECP_POINT_Z(pP)); - PMAsm2_sqr(bnU, bnU); - PMAsm2_mul(bnU, bnU, ECP_A(pECC)); - PMAsm2_add(bnM, bnM, bnU); - } - - PMAsm2_add(bnV, ECP_POINT_Y(pP), ECP_POINT_Y(pP)); - - /* R_Z = 2*Y*Z */ - if( ECP_POINT_AFFINE(pP) ) { - PMA_set(ECP_POINT_Z(pR), bnV); - } - else { - PMAsm2_mul(ECP_POINT_Z(pR), bnV, ECP_POINT_Z(pP)); - } - - /* S = 4*X*Y^2 */ - PMAsm2_sqr(bnT, bnV); - PMAsm2_mul(bnS, bnT, ECP_POINT_X(pP)); - - /* R_X = M^2 - 2*S */ - PMAsm2_sqr(bnU, bnM); - PMAsm2_sub(bnU, bnU, bnS); - PMAsm2_sub(ECP_POINT_X(pR), bnU, bnS); - - /* T = 8*Y^4 */ - PMAsm2_mul(bnV, bnV, ECP_POINT_Y(pP)); - PMAsm2_mul(bnT, bnT, bnV); - - /* R_Y = M*(S - R_X) - T */ - PMAsm2_sub(bnS, bnS, ECP_POINT_X(pR)); - PMAsm2_mul(bnS, bnS, bnM); - PMAsm2_sub(ECP_POINT_Y(pR), bnS, bnT); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP_SM2_AddPoint -// -// Add points -*/ -void ECCP_SM2_AddPoint(const IppsECCPPointState* pP, - const IppsECCPPointState* pQ, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ -#if 0 - /* test stupid call */ - if( pP == pQ ) { - ECCP_SM2_DblPoint(pP, pR, pECC, pList); - return; - } -#endif - - /* 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 - */ - { - 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; - - /* 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 { - PMAsm2_sqr(bnW, ECP_POINT_Z(pQ)); - PMAsm2_mul(bnU0,ECP_POINT_X(pP), bnW); - PMAsm2_mul(bnW, ECP_POINT_Z(pQ), bnW); - PMAsm2_mul(bnS0,ECP_POINT_Y(pP), bnW); - } - - /* 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 { - PMAsm2_sqr(bnW, ECP_POINT_Z(pP)); - PMAsm2_mul(bnU1,ECP_POINT_X(pQ), bnW); - PMAsm2_mul(bnW, ECP_POINT_Z(pP), bnW); - PMAsm2_mul(bnS1,ECP_POINT_Y(pQ), bnW); - } - - /* W = U0-U1 */ - /* R = S0-S1 */ - PMAsm2_sub(bnW, bnU0, bnU1); - PMAsm2_sub(bnR, bnS0, bnS1); - - //if( IsZero_BN(bnW) ) { - //if( IsZero_BN(bnR) ) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnW), LEN_P256, 0)) { - if(cpEqu_BNU_CHUNK(BN_NUMBER(bnR), LEN_P256, 0)) { - ECCP_SM2_DblPoint(pP, pR, pECC, pList); - return; - } - else { - ECCP_SetPointToInfinity(pR); - return; - } - } - - /* T = U0+U1 */ - /* M = S0+S1 */ - PMAsm2_add(bnT, bnU0, bnU1); - PMAsm2_add(bnM, bnS0, bnS1); - - /* 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 { - PMAsm2_mul(bnU1, ECP_POINT_Z(pP), ECP_POINT_Z(pQ)); - } - PMAsm2_mul(ECP_POINT_Z(pR), bnU1, bnW); - } - - PMAsm2_sqr(bnU1, bnW); /* U1 = W^2 */ - PMAsm2_mul(bnS1, bnT, bnU1); /* S1 = T * W^2 */ - - /* R_X = R^2 - T * W^2 */ - PMAsm2_sqr(ECP_POINT_X(pR), bnR); - PMAsm2_sub(ECP_POINT_X(pR), ECP_POINT_X(pR), bnS1); - - /* V = T * W^2 - 2 * R_X (S1) */ - PMAsm2_sub(bnS1, bnS1, ECP_POINT_X(pR)); - PMAsm2_sub(bnS1, bnS1, ECP_POINT_X(pR)); - - /* R_Y = (V * R - M * W^3) /2 */ - PMAsm2_mul(ECP_POINT_Y(pR), bnS1, bnR); - PMAsm2_mul(bnU1, bnU1, bnW); - PMAsm2_mul(bnU1, bnU1, bnM); - PMAsm2_sub(bnU1, ECP_POINT_Y(pR), bnU1); - PMAsm2_div2(ECP_POINT_Y(pR), bnU1); - - ECP_POINT_AFFINE(pR) = 0; - } -} - -/* -// ECCP_SM2_MulPoint -// -// Multiply point by scalar -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP_SM2_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 { - IppsECCPPointState T; - IppsECCPPointState U; - IppsBigNumState* bnKH = cpBigNumListGet(&pList); - Ipp32u* pK; - Ipp32u* pH; - Ipp32u carry; - int lenKH; - int bitH; - - /* init result */ - ECCP_CopyPoint(pP, pR); - - /* if scalar is negative */ - if( ippBigNumNEG == BN_SIGN(bnN) ) { - /* negative R */ - ECCP_SM2_NegPoint(pR, pR, pECC); - } - - /* copy K = N and compute H=3*K */ - lenKH = BN_SIZE(bnN)+1; - pK = BN_NUMBER(bnKH); - pH = BN_BUFFER(bnKH); - Cpy_BNU(BN_NUMBER(bnN), pK, BN_SIZE(bnN)); - pK[lenKH-1] = 0; - carry = cpAdd_BNU(pH, pK, pK, lenKH); - carry = cpAdd_BNU(pH, pK, pH, lenKH); - - /* init temporary T = (X/Z^2, Y/Z^3, 1) */ - ECP_POINT_X(&T) = cpBigNumListGet(&pList); - ECP_POINT_Y(&T) = cpBigNumListGet(&pList); - ECP_POINT_Z(&T) = cpBigNumListGet(&pList); - ECCP_SM2_GetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), pR, pECC, pList); - ECCP_SM2_SetPointAffine(ECP_POINT_X(&T), ECP_POINT_Y(&T), &T, pECC); - - /* temporary point U =-T */ - ECP_POINT_X(&U) = cpBigNumListGet(&pList); - ECP_POINT_Y(&U) = cpBigNumListGet(&pList); - ECP_POINT_Z(&U) = cpBigNumListGet(&pList); - ECCP_SM2_NegPoint(&T, &U, pECC); - - for(bitH=MSB_BNU(pH, lenKH)-1; bitH>0; bitH--) { - int hBit = TST_BIT(pH, bitH); - int kBit = TST_BIT(pK, bitH); - ECCP_SM2_DblPoint(pR, pR, pECC, pList); - if( hBit && !kBit ) - ECCP_SM2_AddPoint(pR, &T, pR, pECC, pList); - if(!hBit && kBit ) - ECCP_SM2_AddPoint(pR, &U, pR, pECC, pList); - } - } -} - -#else -#pragma message ("ECCP_SM2_MulPoint: SCCM version") - -void ECCP_SM2_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_SM2_AddPoint(pR, &T, pR, pECC, pList); - } - } - } -} -#endif - -void ECCP_SM2_MulBasePoint(const IppsBigNumState* pK, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - ECCP_SM2_MulPoint(ECP_GENC(pECC), pK, pR, pECC, pList); -} - -/* -// ECCP_SM2_ProdPoint -// -// Point product -*/ -#if !defined (_USE_ECCP_SSCM_) -void ECCP_SM2_ProdPoint(const IppsECCPPointState* pP, - const IppsBigNumState* bnPscalar, - const IppsECCPPointState* pQ, - const IppsBigNumState* bnQscalar, - IppsECCPPointState* pR, - const IppsECCPState* pECC, - BigNumNode* pList) -{ - /* test zero scalars */ - if( IsZero_BN(bnPscalar) ) { - ECCP_SM2_MulPoint(pQ, bnQscalar, pR, pECC, pList); - return; - } - if( IsZero_BN(bnQscalar) ) { - ECCP_SM2_MulPoint(pP, bnPscalar, pR, pECC, pList); - return; - } - - /* - // point product - */ - else { - int n; - Ipp32u* pbnPscalar = BN_NUMBER(bnPscalar); - int bnPscalarSize = BN_SIZE(bnPscalar); - Ipp32u* pbnQscalar = BN_NUMBER(bnQscalar); - int bnQscalarSize = BN_SIZE(bnQscalar); - - int size = bnPscalarSize>bnQscalarSize? bnPscalarSize : bnQscalarSize; - - IppsECCPPointState* pPointPQ[4] = {NULL, NULL, NULL, NULL}; - - /* allocate temporary PQ point */ - IppsECCPPointState PQ; - ECP_POINT_X(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Y(&PQ) = cpBigNumListGet(&pList); - ECP_POINT_Z(&PQ) = cpBigNumListGet(&pList); - - /* init temporary point array */ - if(ippBigNumPOS == BN_SIGN(bnPscalar)) - pPointPQ[1] = (IppsECCPPointState*)pP; - else { - IppsECCPPointState P; - ECP_POINT_X(&P) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P) = cpBigNumListGet(&pList); - ECCP_SM2_NegPoint(pP, &P, pECC); - pPointPQ[1] = &P; - } - if(ippBigNumPOS == BN_SIGN(bnQscalar)) - pPointPQ[2] = (IppsECCPPointState*)pQ; - else { - IppsECCPPointState Q; - ECP_POINT_X(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Y(&Q) = cpBigNumListGet(&pList); - ECP_POINT_Z(&Q) = cpBigNumListGet(&pList); - ECCP_SM2_NegPoint(pQ, &Q, pECC); - pPointPQ[2] = &Q; - } - - ECCP_SM2_AddPoint(pPointPQ[1], pPointPQ[2], &PQ, pECC, pList); - ECCP_SM2_GetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC, pList); - ECCP_SM2_SetPointAffine(ECP_POINT_X(pR), ECP_POINT_Y(pR), &PQ, pECC); - pPointPQ[3] = &PQ; - - /* pad scalars by zeros */ - ZEXPAND_BNU(pbnPscalar,bnPscalarSize, size); - ZEXPAND_BNU(pbnQscalar,bnQscalarSize, size); - - /* init result */ - ECCP_SetPointToInfinity(pR); - - for(n=size; n>0; n--) { - Ipp32u scalarPn = pbnPscalar[n-1]; - Ipp32u scalarQn = pbnQscalar[n-1]; - - int nBit; - for(nBit=31; nBit>=0; nBit--) { - int - PnQnBits = scalarPn&0x80000000? 1:0; - PnQnBits+= scalarQn&0x80000000? 2:0; - - if( !ECCP_IsPointAtInfinity(pR) ) - ECCP_SM2_DblPoint(pR, pR, pECC, pList); - if( PnQnBits ) - ECCP_SM2_AddPoint(pR, pPointPQ[PnQnBits], pR, pECC, pList); - - scalarPn <<= 1; - scalarQn <<= 1; - } - } - } -} - -#else -#pragma message ("ECCP_SM2_ProdPoint: SCCM version") - -void ECCP_SM2_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_SM2_MulPoint(pP, bnPscalar, &T, (IppsECCPState*)pECC, pList); - ECCP_SM2_MulPoint(pQ, bnQscalar, &U, (IppsECCPState*)pECC, pList); - ECCP_SM2_AddPoint(&T, &U, pR, pECC, pList); -} -#endif - -#endif /* _ECP_SM2_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppoint.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppoint.h deleted file mode 100644 index bf13c8e02b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppoint.h +++ /dev/null @@ -1,54 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal EC Point Definitions & Function Prototypes -// -// -*/ - -#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/epid/ext/ipp/sources/ippcp/src/pcpeccppointca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppointca.c deleted file mode 100644 index 4df8d1e810..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppointca.c +++ /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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC (prime) Point -// -// Contents: -// ippsECCPPointGetSize() -// ippsECCPPointInit() -// -// -*/ - -#include "precomp.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/epid/ext/ipp/sources/ippcp/src/pcpeccppointopca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppointopca.c deleted file mode 100644 index 02188f92f4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppointopca.c +++ /dev/null @@ -1,482 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (EC Point operations) -// -// Contents: -// ippsECCPSetPoint() -// ippsECCPSetPointAtInfinity() -// ippsECCPGetPoint() -// -// ippsECCPCheckPoint() -// ippsECCPComparePoint() -// -// ippsECCPNegativePoint() -// ippsECCPAddPoint() -// ippsECCPMulPointScalar() -// -// -*/ - -#include "precomp.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/epid/ext/ipp/sources/ippcp/src/pcpeccppublickeyca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppublickeyca.c deleted file mode 100644 index d2455d25f4..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccppublickeyca.c +++ /dev/null @@ -1,87 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (EC Key Generation) -// -// Contents: -// ippsECCPPublicKey() -// -// -*/ - -#include "precomp.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)->MulPoint(ECP_GENC(pECC), pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); - ECP_METHOD(pECC)->MulBasePoint(pPrivate, pPublic, pECC, ECP_BNCTX(pECC)); - - return ippStsNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c deleted file mode 100644 index dabce4dd4e..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsetkeyca.c +++ /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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (EC Key Generation) -// -// Contents: -// ippsECCPSetKeyPair() -// -// -*/ - -#include "precomp.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/epid/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c deleted file mode 100644 index 182d505b20..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsigndsaca.c +++ /dev/null @@ -1,146 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// EC over Prime Finite Field (Sign, DSA version) -// -// Contents: -// ippsECCPSignDSA() -// -// -*/ - -#include "precomp.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/epid/ext/ipp/sources/ippcp/src/pcpeccpsscm.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsscm.c deleted file mode 100644 index 6978a0a8ff..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpeccpsscm.c +++ /dev/null @@ -1,160 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// ECCP SSCM stuff -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpbn.h" -#include "pcpeccppoint.h" - -#if defined (_USE_ECCP_SSCM_) -#pragma message ("ECCP SCCM version") - -//#define LOG2_CACHE_LINE_SIZE (6) /* LOG2(CACHE_LINE_SIZE) */ -#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) */ -#if 0 - /* compute h1*BasePoint + h2*publicKey */ - if(ippEC_TPM_SM2_P256 == ECP_TYPE(pECC)) { - IppsECCPPointState P0; - ECP_POINT_X(&P0) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P0) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P0) = cpBigNumListGet(&pList); - ECP_METHOD(pECC)->MulBasePoint(pH1, &P0, pECC, pList); - ECP_METHOD(pECC)->MulPoint(ECP_PUBLIC(pECC), pH2, &P1, pECC, pList); - ECP_METHOD(pECC)->AddPoint(&P1, &P0, &P1, pECC, pList); - } - else - ECP_METHOD(pECC)->ProdPoint(ECP_GENC(pECC), pH1, - ECP_PUBLIC(pECC), pH2, - &P1, pECC, pList); -#endif - /* compute h1*BasePoint + h2*publicKey */ - if((IppECCPStd128r1 == ECP_TYPE(pECC)) || (IppECCPStd128r2 == ECP_TYPE(pECC)) - ||(IppECCPStd192r1 == ECP_TYPE(pECC)) - ||(IppECCPStd224r1 == ECP_TYPE(pECC)) - ||(IppECCPStd256r1 == ECP_TYPE(pECC)) - ||(IppECCPStd384r1 == ECP_TYPE(pECC)) - ||(IppECCPStd521r1 == ECP_TYPE(pECC)) - ||(IppECCPStdSM2 == ECP_TYPE(pECC))) { - IppsECCPPointState P0; - ECP_POINT_X(&P0) = cpBigNumListGet(&pList); - ECP_POINT_Y(&P0) = cpBigNumListGet(&pList); - ECP_POINT_Z(&P0) = cpBigNumListGet(&pList); - ECP_METHOD(pECC)->MulBasePoint(pH1, &P0, pECC, pList); - ECP_METHOD(pECC)->MulPoint(ECP_PUBLIC(pECC), pH2, &P1, pECC, pList); - ECP_METHOD(pECC)->AddPoint(&P1, &P0, &P1, pECC, pList); - } - else - 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/epid/ext/ipp/sources/ippcp/src/pcphash.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphash.h deleted file mode 100644 index 6ffd67a3e6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphash.h +++ /dev/null @@ -1,239 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Security Hash Standard -// Internal Definitions and Internal Functions Prototypes -// -// -*/ - -#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_SM3 (64) /* SM3 */ -#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) */ - -/* hold some old definition for a purpose */ -typedef Ipp32u DigestSHA1[5]; /* SHA1 digest */ -typedef Ipp32u DigestSHA224[7]; /* SHA224 digest */ -typedef Ipp32u DigestSHA256[8]; /* SHA256 digest */ -typedef Ipp64u DigestSHA384[6]; /* SHA384 digest */ -typedef Ipp64u DigestSHA512[8]; /* SHA512 digest */ -typedef Ipp32u DigestMD5[4]; /* MD5 digest */ -typedef Ipp32u DigestSM3[8]; /* SM3 digest */ - -#define SHA1_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define SHA224_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define SHA256_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define SHA384_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define SHA512_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define MD5_ALIGNMENT ((int)(sizeof(Ipp32u))) -#define SM3_ALIGNMENT ((int)(sizeof(Ipp32u))) - - -#if defined(_ENABLE_ALG_SHA1_) -struct _cpSHA1 { - IppCtxId idCtx; /* SHA1 identifier */ - int index; /* internal buffer entry (free) */ - Ipp64u msgLenLo; /* message length (bytes) */ - Ipp8u msgBuffer[MBS_SHA1]; /* buffer */ - DigestSHA1 msgHash; /* intermediate digest */ -}; -#endif - -#if defined(_ENABLE_ALG_SHA256_) || defined(_ENABLE_ALG_SHA224_) -struct _cpSHA256 { - IppCtxId idCtx; /* SHA224 identifier */ - int index; /* internal buffer entry (free) */ - Ipp64u msgLenLo; /* message length (bytes) */ - Ipp8u msgBuffer[MBS_SHA256]; /* buffer */ - DigestSHA256 msgHash; /* intermediate digest */ -}; -#endif - -#if defined(_ENABLE_ALG_SHA512_) || defined(_ENABLE_ALG_SHA384_) || defined(_ENABLE_ALG_SHA512_224_) || defined(_ENABLE_ALG_SHA512_256_) -struct _cpSHA512 { - IppCtxId idCtx; /* SHA384 identifier */ - int index; /* internal buffer entry (free) */ - Ipp64u msgLenLo; /* message length (bytes) */ - Ipp64u msgLenHi; /* message length (bytes) */ - Ipp8u msgBuffer[MBS_SHA512]; /* buffer */ - DigestSHA512 msgHash; /* intermediate digest */ -}; -#endif - -#if defined(_ENABLE_ALG_MD5_) -struct _cpMD5 { - IppCtxId idCtx; /* MD5 identifier */ - int index; /* internal buffer entry (free) */ - Ipp64u msgLenLo; /* message length (bytes) */ - Ipp8u msgBuffer[MBS_MD5]; /* buffer */ - DigestMD5 msgHash; /* intermediate digest */ -}; -#endif - -#if defined(_ENABLE_ALG_SM3_) -struct _cpSM3 { - IppCtxId idCtx; /* SM3 identifier */ - int index; /* internal buffer entry (free) */ - Ipp64u msgLenLo; /* message length (bits) */ - Ipp8u msgBuffer[MBS_SM3]; /* buffer */ - DigestSM3 msgHash; /* intermediate digest */ -}; -#endif - -/* -// 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 Ipp32u SM3_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[]; -extern __ALIGN16 const Ipp32u SM3_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) -/* old some old accessors */ -//#define SHS_DGST(stt) HASH_VALUE((stt)) -//#define SHS_BUFF(stt) HASH_BUFF((stt)) - - -/* 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); -void UpdateSM3 (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); - -#if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) -void UpdateSHA1ni (void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); -void UpdateSHA256ni(void* pHash, const Ipp8u* mblk, int mlen, const void* pParam); -#endif - -/* general methods */ -//void cpHashUpdate(const Ipp8u* pSrc, int len, IppsHashState* pCtx, cpHashProc hashFunc, const void* pParam, int mbs); -int cpReInitHash(IppsHashState* pCtx, IppHashAlgId algID); - -#endif /* _PCP_HASH_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashcnt.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashcnt.c deleted file mode 100644 index 1202f37197..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashcnt.c +++ /dev/null @@ -1,434 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Security Hash Standard -// Constants -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" - -#if defined( _IPP_DATA ) - -/* -// enabled hash alg IDs -*/ -const IppHashAlgId cpEnabledHashAlgID[] = { - IPP_ALG_HASH_UNKNOWN, - -#if defined(_ENABLE_ALG_SHA1_) - IPP_ALG_HASH_SHA1, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA256_) - IPP_ALG_HASH_SHA256, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA224_) - IPP_ALG_HASH_SHA224, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA512_) - IPP_ALG_HASH_SHA512, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA384_) - IPP_ALG_HASH_SHA384, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_MD5_) - IPP_ALG_HASH_MD5, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SM3_) - IPP_ALG_HASH_SM3, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA512_224_) - IPP_ALG_HASH_SHA512_224, -#else - IPP_ALG_HASH_UNKNOWN, -#endif - -#if defined(_ENABLE_ALG_SHA512_256_) - IPP_ALG_HASH_SHA512_256 -#else - IPP_ALG_HASH_UNKNOWN -#endif -}; -//////////////////////////////////////////////////////////// - -/* -// hash init values -*/ -const Ipp32u UnknownHash_IV[] = { - 0}; - -#if defined(_ENABLE_ALG_SHA1_) -const Ipp32u SHA1_IV[] = { - 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0}; -#endif - -#if defined(_ENABLE_ALG_SHA256_) -const Ipp32u SHA256_IV[] = { - 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, - 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19}; -#endif - -#if defined(_ENABLE_ALG_SHA224_) -const Ipp32u SHA224_IV[] = { - 0xC1059ED8, 0x367CD507, 0x3070DD17, 0xF70E5939, - 0xFFC00B31, 0x68581511, 0x64F98FA7, 0xBEFA4FA4}; -#endif - -#if defined(_ENABLE_ALG_SHA512_) -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)}; -#endif - -#if defined(_ENABLE_ALG_SHA384_) -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)}; -#endif - -#if defined(_ENABLE_ALG_MD5_) -const Ipp32u MD5_IV[] = { - 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476}; -#endif - -#if defined(_ENABLE_ALG_SM3_) -const Ipp32u SM3_IV[] = { - 0x7380166F, 0x4914B2B9, 0x172442D7, 0xDA8A0600, - 0xA96F30BC, 0x163138AA, 0xE38DEE4D, 0xB0FB0E4E}; -#endif - -#if defined(_ENABLE_ALG_SHA512_224_) -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)}; -#endif - -#if defined(_ENABLE_ALG_SHA512_256_) -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)}; -#endif - -const Ipp8u* cpHashIV[] = { - (Ipp8u*)UnknownHash_IV, - - #if defined(_ENABLE_ALG_SHA1_) - (Ipp8u*)SHA1_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA256_) - (Ipp8u*)SHA256_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA224_) - (Ipp8u*)SHA224_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA512_) - (Ipp8u*)SHA512_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA384_) - (Ipp8u*)SHA384_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_MD5_) - (Ipp8u*)MD5_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SM3_) - (Ipp8u*)SM3_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA512_224_) - (Ipp8u*)SHA512_224_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif - - #if defined(_ENABLE_ALG_SHA512_256_) - (Ipp8u*)SHA512_256_IV, - #else - (Ipp8u*)UnknownHash_IV, - #endif -}; - -//////////////////////////////////////////////////////////// - -/* -// additive constatns -*/ -#if defined(_ENABLE_ALG_SHA1_) -__ALIGN16 const Ipp32u SHA1_cnt[] = { - 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 -}; -#endif - -#if defined(_ENABLE_ALG_SHA256_) || defined(_ENABLE_ALG_SHA224_) -__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 -}; -#endif - -#if defined(_ENABLE_ALG_SHA512_) || defined(_ENABLE_ALG_SHA384_) || defined(_ENABLE_ALG_SHA512_224_) || defined(_ENABLE_ALG_SHA512_256_) -__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) -}; -#endif - -#if defined(_ENABLE_ALG_MD5_) -__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 -}; -#endif - -#if defined(_ENABLE_ALG_SM3_) -__ALIGN16 const Ipp32u SM3_cnt[] = { - 0x79CC4519,0xF3988A32,0xE7311465,0xCE6228CB,0x9CC45197,0x3988A32F,0x7311465E,0xE6228CBC, - 0xCC451979,0x988A32F3,0x311465E7,0x6228CBCE,0xC451979C,0x88A32F39,0x11465E73,0x228CBCE6, - 0x9D8A7A87,0x3B14F50F,0x7629EA1E,0xEC53D43C,0xD8A7A879,0xB14F50F3,0x629EA1E7,0xC53D43CE, - 0x8A7A879D,0x14F50F3B,0x29EA1E76,0x53D43CEC,0xA7A879D8,0x4F50F3B1,0x9EA1E762,0x3D43CEC5, - 0x7A879D8A,0xF50F3B14,0xEA1E7629,0xD43CEC53,0xA879D8A7,0x50F3B14F,0xA1E7629E,0x43CEC53D, - 0x879D8A7A,0x0F3B14F5,0x1E7629EA,0x3CEC53D4,0x79D8A7A8,0xF3B14F50,0xE7629EA1,0xCEC53D43, - 0x9D8A7A87,0x3B14F50F,0x7629EA1E,0xEC53D43C,0xD8A7A879,0xB14F50F3,0x629EA1E7,0xC53D43CE, - 0x8A7A879D,0x14F50F3B,0x29EA1E76,0x53D43CEC,0xA7A879D8,0x4F50F3B1,0x9EA1E762,0x3D43CEC5 -}; -#endif - -/* -// hash alg default processing opt argument -*/ -const void* cpHashProcFuncOpt[] = { - NULL, - - #if defined(_ENABLE_ALG_SHA1_) - SHA1_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA256_) - SHA256_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA224_) - SHA256_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA512_) - SHA512_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA384_) - SHA512_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_MD5_) - MD5_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SM3_) - SM3_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA512_224_) - SHA512_cnt, - #else - NULL, - #endif - - #if defined(_ENABLE_ALG_SHA512_256_) - SHA512_cnt, - #else - NULL, - #endif -}; -//////////////////////////////////////////////////////////// - -/* hash alg attributes */ -const cpHashAttr cpHashAlgAttr[] = { - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, /* unknown */ - -#if defined(_ENABLE_ALG_SHA1_) /* sha1 / unknown */ - {IPP_SHA1_DIGEST_BITSIZE/8, IPP_SHA1_DIGEST_BITSIZE/8, MBS_SHA1, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA256_) /* sha256 / unknown */ - {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA256_DIGEST_BITSIZE/8, MBS_SHA256, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA224_) /* sha224 / unknown */ - {IPP_SHA256_DIGEST_BITSIZE/8,IPP_SHA224_DIGEST_BITSIZE/8, MBS_SHA224, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA512_) /* sha512 / unknown */ - {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA384_) /* sha384 / unknown */ - {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA384_DIGEST_BITSIZE/8, MBS_SHA384, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_MD5_) /* md5 / unknown */ - {IPP_MD5_DIGEST_BITSIZE/8,IPP_MD5_DIGEST_BITSIZE/8, MBS_MD5, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SM3_) /* sm3 / unknown */ - {IPP_SM3_DIGEST_BITSIZE/8,IPP_SM3_DIGEST_BITSIZE/8, MBS_SM3, sizeof(Ipp64u), {CONST_64(0x2000000000000000-1),CONST_64(0)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA512_224_) /* sha512/224 / unknown */ - {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_224_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}}, -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}}, -#endif - -#if defined(_ENABLE_ALG_SHA512_256_) /* sha512/256 / unknown */ - {IPP_SHA512_DIGEST_BITSIZE/8,IPP_SHA512_256_DIGEST_BITSIZE/8, MBS_SHA512, sizeof(Ipp64u)*2, {CONST_64(0xFFFFFFFFFFFFFFFF),CONST_64(0x2000000000000000-1)}} -#else - {0, 0, 0, 0, {CONST_64(0),CONST_64(0)}} -#endif -}; - -#endif /* _IPP_DATA */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashmd5px.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashmd5px.c deleted file mode 100644 index 6eea795096..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashmd5px.c +++ /dev/null @@ -1,211 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Message block processing according to MD5 -// -// Contents: -// UpdateMD5() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - -#if !defined(_ENABLE_ALG_MD5_) -#pragma message("IPP_ALG_HASH_MD5 disabled") - -#else -#pragma message("IPP_ALG_HASH_MD5 enabled") - -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_M5) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) - - -/* -// 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; - } -} - -#endif -#endif /* IPP_ALG_HASH_MD5 */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha1px.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha1px.c deleted file mode 100644 index ab0d68f3b1..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha1px.c +++ /dev/null @@ -1,189 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Message block processing according to SHA1 -// -// Contents: -// UpdateSHA1() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - -//#if !defined(_ENABLE_ALG_SHA1_) -//#pragma message("IPP_ALG_HASH_SHA1 disabled") - -//#else -//#pragma message("IPP_ALG_HASH_SHA1 enabled") - -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_M5) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) - -/* -// 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; - } - } -} - -#endif -//#endif /* IPP_ALG_HASH_SHA1 */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha256px.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha256px.c deleted file mode 100644 index e355de3c90..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha256px.c +++ /dev/null @@ -1,214 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Message block processing according to SHA256 -// -// Contents: -// UpdateSHA256() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - -#if !defined(_ENABLE_ALG_SHA256_) && !defined(_ENABLE_ALG_SHA224_) -#pragma message("IPP_ALG_HASH_SHA256 disabled") - -#else -#pragma message("IPP_ALG_HASH_SHA256 enabled") - -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_M5) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) - -/* -// 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 - -#endif -#endif /* IPP_ALG_HASH_SHA256 */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha512px.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha512px.c deleted file mode 100644 index 9e6d5fcb37..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcphashsha512px.c +++ /dev/null @@ -1,221 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Message block processing according to SHA512 -// -// Contents: -// UpdateSHA512() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - -#if !defined(_ENABLE_ALG_SHA512_) && !defined(_ENABLE_ALG_SHA_SHA384_) && !defined(_ENABLE_ALG_SHA512_224_) && !defined(_ENABLE_ALG_SHA512_256_) -#pragma message("IPP_ALG_HASH_SHA512 disabled") - -#else -#pragma message("IPP_ALG_HASH_SHA512 enabled") - -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) - -/* -// 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 - -#endif -#endif /* IPP_ALG_HASH_SHA512 */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmd5ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmd5ca.c deleted file mode 100644 index 91c44e88c2..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmd5ca.c +++ /dev/null @@ -1,485 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Digesting message according to MD5 -// (derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm) -// -// Equivalent code is available from RFC 1321. -// -// Contents: -// ippsMD5GetSize() -// ippsMD5Init() -// ippsMD5Pack() -// ippsMD5Unpack() -// ippsMD5Duplicate() -// ippsMD5Update() -// ippsMD5GetTag() -// ippsMD5Final() -// ippsMD5MessageDigest() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - - -#if !defined (_ENABLE_ALG_MD5_) -#pragma message("IPP_ALG_HASH_MD5 disabled") -#else -#pragma message("IPP_ALG_HASH_MD5 enabled") - -/* -// Init MD5 digest -*/ -IppStatus InitMD5(IppsMD5State* pState) -{ - /* test state pointer */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsMD5State*)( IPP_ALIGNED_PTR(pState, MD5_ALIGNMENT) ); - - /* set state ID */ - SHS_ID(pState) = idCtxMD5; - - /* zeros message length */ - SHS_LENL(pState) = 0; - - /* message buffer is free */ - SHS_INDX(pState) = 0; - - /* setup initial digest */ - SHS_HASH(pState)[0] = MD5_IV[0]; - SHS_HASH(pState)[1] = MD5_IV[1]; - SHS_HASH(pState)[2] = MD5_IV[2]; - SHS_HASH(pState)[3] = MD5_IV[3]; - - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5GetSize -// -// Purpose: Returns size (bytes) of IppsMD5State state. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// ippStsNoErr no errors -// -// Parameters: -// pSize pointer to size -// -*F*/ -IPPFUN(IppStatus, ippsMD5GetSize,(int* pSize)) -{ - /* test pointer */ - IPP_BAD_PTR1_RET(pSize); - - *pSize = sizeof(IppsMD5State) +(MD5_ALIGNMENT-1); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5Init -// -// Purpose: Init MD5 state. -// -// Returns: Reason: -// ippStsNullPtrErr pState == NULL -// ippStsNoErr no errors -// -// Parameters: -// pState pointer to the MD5 state -// -*F*/ -IPPFUN(IppStatus, ippsMD5Init,(IppsMD5State* pState)) -{ - return InitMD5(pState); -} - - -/*F* -// Name: ippsMD5Pack -// -// Purpose: Copy initialized context to the buffer. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -IPPFUN(IppStatus, ippsMD5Pack,(const IppsMD5State* pCtx, Ipp8u* pBuffer)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsMD5State*)( IPP_ALIGNED_PTR(pCtx, MD5_ALIGNMENT) ); - /* test the context */ - IPP_BADARG_RET(idCtxMD5 !=SHS_ID(pCtx), ippStsContextMatchErr); - - CopyBlock(pCtx, pBuffer, sizeof(IppsMD5State)); - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5Unpack -// -// Purpose: Unpack buffer content into the initialized context. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -IPPFUN(IppStatus, ippsMD5Unpack,(const Ipp8u* pBuffer, IppsMD5State* pCtx)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsMD5State*)( IPP_ALIGNED_PTR(pCtx, MD5_ALIGNMENT) ); - - CopyBlock(pBuffer, pCtx, sizeof(IppsMD5State)); - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5Duplicate -// -// Purpose: Clone MD5 state. -// -// Returns: Reason: -// ippStsNullPtrErr pSrcState == NULL -// pDstState == NULL -// ippStsContextMatchErr pSrcState->idCtx != idCtxMD5 -// pDstState->idCtx != idCtxMD5 -// ippStsNoErr no errors -// -// Parameters: -// pSrcState pointer to the source MD5 state -// pDstState pointer to the target MD5 state -// -// Note: -// pDstState may to be uninitialized by ippsMD5Init() -// -*F*/ -IPPFUN(IppStatus, ippsMD5Duplicate,(const IppsMD5State* pSrcState, IppsMD5State* pDstState)) -{ - /* test state pointers */ - IPP_BAD_PTR2_RET(pSrcState, pDstState); - /* use aligned context */ - pSrcState = (IppsMD5State*)( IPP_ALIGNED_PTR(pSrcState, MD5_ALIGNMENT) ); - pDstState = (IppsMD5State*)( IPP_ALIGNED_PTR(pDstState, MD5_ALIGNMENT) ); - /* test states ID */ - IPP_BADARG_RET(idCtxMD5 !=SHS_ID(pSrcState), ippStsContextMatchErr); - - /* copy state */ - CopyBlock(pSrcState, pDstState, sizeof(IppsMD5State)); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5Update -// -// Purpose: Updates intermadiate digest based on input stream. -// -// Returns: Reason: -// ippStsNullPtrErr pSrc == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxMD5 -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pSrc pointer to the input stream -// len input stream length -// pState pointer to the MD5 state -// -*F*/ -IPPFUN(IppStatus, ippsMD5Update,(const Ipp8u* pSrc, int len, IppsMD5State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsMD5State*)( IPP_ALIGNED_PTR(pState, MD5_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxMD5 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test input length */ - IPP_BADARG_RET((len<0), ippStsLengthErr); - /* test source pointer */ - IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); - - /* - // handle non empty message - */ - if(len) { - int processingLen; - - int n = SHS_INDX(pState); - Ipp8u* pBuffer = SHS_BUFF(pState); - Ipp8u* pHash = (Ipp8u*)SHS_HASH(pState); - - Ipp64u lenLo = SHS_LENL(pState); - lenLo += len; - - /* if non empty internal buffer filling */ - if(n) { - /* copy from input stream to the internal buffer as match as possible */ - processingLen = IPP_MIN(len, (MBS_MD5 - SHS_INDX(pState))); - CopyBlock(pSrc, pBuffer+n, processingLen); - - pSrc += processingLen; - len -= processingLen; - SHS_INDX(pState) = n += processingLen; - - /* update digest if buffer full */ - if( MBS_MD5 == n) { - UpdateMD5(pHash, pBuffer, MBS_MD5, MD5_cnt); - SHS_INDX(pState) = 0; - } - } - - /* main message part processing */ - processingLen = len & ~(MBS_MD5-1); - if(processingLen) { - UpdateMD5(pHash, pSrc, processingLen, MD5_cnt); - pSrc += processingLen; - len -= processingLen; - } - - /* store rest of message into the internal buffer */ - if(len) { - CopyBlock(pSrc, pBuffer, len); - SHS_INDX(pState) += len; - } - - SHS_LENL(pState) = lenLo; - } - - return ippStsNoErr; -} - - -/* -// Compute digest -*/ -void ComputeDigestMD5(Ipp32u* pHash, const IppsMD5State* pState) -{ - const Ipp8u* stateBuff = SHS_BUFF(pState); - int stateBuffLen = SHS_INDX(pState); - - /* local buffer and it length */ - Ipp8u buffer[MBS_MD5*2]; - int bufferLen = stateBuffLen < (MBS_MD5-(int)sizeof(Ipp64u))? MBS_MD5 : MBS_MD5*2; - - /* copy rest of message into internal buffer */ - CopyBlock(stateBuff, buffer, stateBuffLen); - - /* padd message */ - buffer[stateBuffLen++] = 0x80; - PaddBlock(0, buffer+stateBuffLen, bufferLen-stateBuffLen-sizeof(Ipp64u)); - - /* message length representation */ - { - Ipp64u lo = SHS_LENL(pState); /* message length in bytes */ - lo = LSL64(lo,3); /* message length in bits */ - ((Ipp64u*)(buffer+bufferLen))[-1] = lo; - } - - /* copmplete hash computation */ - UpdateMD5(pHash, buffer, bufferLen, MD5_cnt); - - /* convert hash into big endian */ - /* is not necessary if little endian */ -} - - -/*F* -// Name: ippsMD5GetTag -// -// Purpose: Compute digest based on current state. -// Note, that futher digest update is possible -// -// Returns: Reason: -// ippStsNullPtrErr pTag == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxMD5 -// ippStsLengthErr max_MD5_digestLen < tagLen <1 -// ippStsNoErr no errors -// -// Parameters: -// pTag address of the output digest -// tagLen length of digest -// pState pointer to the MD5 state -// -*F*/ -IPPFUN(IppStatus, ippsMD5GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsMD5State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsMD5State*)( IPP_ALIGNED_PTR(pState, MD5_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxMD5 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pTag); - IPP_BADARG_RET((tagLen<1)||(sizeof(DigestMD5)idCtx != idCtxMD5 -// ippStsNoErr no errors -// -// Parameters: -// pMD address of the output digest -// pState pointer to the MD5 state -// -*F*/ -IPPFUN(IppStatus, ippsMD5Final,(Ipp8u* pMD, IppsMD5State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsMD5State*)( IPP_ALIGNED_PTR(pState, MD5_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxMD5 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestMD5(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestMD5)); - InitMD5(pState); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsMD5MessageDigest -// -// Purpose: Ddigest of the whole message. -// -// Returns: Reason: -// ippStsNullPtrErr pMsg == NULL -// pDigest == NULL -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pMsg pointer to the input message -// len input message length -// pMD address of the output digest -// -*F*/ -IPPFUN(IppStatus, ippsMD5MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* 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); - - { - /* message length in the multiple MBS and the rest */ - int msgLenBlks = msgLen & (-MBS_MD5); - int msgLenRest = msgLen - msgLenBlks; - - /* init hash value */ - DigestMD5 hash = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476}; - - /* process main part of the message */ - if(msgLenBlks) - UpdateMD5(hash, pMsg, msgLenBlks, MD5_cnt); - - /* process message padding */ - { - #define MREP_SIZE_MD5 (sizeof(Ipp64u)) - Ipp8u buffer[MBS_MD5*2]; - int bufferLen = msgLenRest < (int)(MBS_MD5-MREP_SIZE_MD5)? (int)MBS_MD5 : (int)(MBS_MD5*2); - - /* message bitlength representation */ - Ipp64u msgLenBits = (Ipp64u)msgLen*8; - - /* 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-MREP_SIZE_MD5); - /* copy message bitlength representation */ - ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits; - - UpdateMD5(hash, buffer, bufferLen, MD5_cnt); - #undef MREP_SIZE_MD5 - } - - /* copy hash bytes */ - ((Ipp32u*)pMD)[0] = hash[0]; - ((Ipp32u*)pMD)[1] = hash[1]; - ((Ipp32u*)pMD)[2] = hash[2]; - ((Ipp32u*)pMD)[3] = hash[3]; - - return ippStsNoErr; - } -} - -#endif /* _ENABLE_ALG_MD5_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontexpbinca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontexpbinca.c deleted file mode 100644 index 37a7352c5b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontexpbinca.c +++ /dev/null @@ -1,562 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Modular Exponentiation (binary version) -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpbn.h" -#include "pcpmontgomery.h" - - -#if 0 -/* -// Exponentiation -// Y = X^e -// X and Y belongs Montgomery Domain -*/ -void cpMontExp_32u(IppsBigNumState* pY, - const IppsBigNumState* pX, Ipp32u e, - IppsMontState* pMont) -{ - if(pY!=pX) /* copy base */ - BN_copy(pX, pY); - - { - int j, back_step; - - /* Montgomery engine data */ - Ipp32u* pModulus = BN_NUMBER(MNT_MODULO(pMont)); - int mSize = BN_SIZE(MNT_MODULO(pMont)); - Ipp32u* pHelper = MNT_HELPER(pMont); - - /* result and base of exponent */ - Ipp32u* dataY = BN_NUMBER(pY); - Ipp32u* dataX = BN_BUFFER(pY); - int ySize = BN_SIZE(pY); - - /* temporary buffers */ - Ipp32u* dataT = BN_NUMBER(MNT_PRODUCT(pMont)); - Ipp32u* pBuffer = BN_BUFFER(MNT_PRODUCT(pMont)); - - /* expand result */ - ZEXPAND_BNU(dataY,ySize, mSize); - /* copy base */ - COPY_BNU(dataY,dataX, mSize); - - j = 32-NLZ32u(e)-1; - - back_step = 0; - for(j-=1; j>=0; j--) { - int i; - Ipp32u mask_pattern = (Ipp32u)(back_step-1); - - /* T = (Y[] and mask_pattern) or (X[] and ~mask_pattern) */ - for(i=0; i>j) & 0x01) & (back_step^1); - j += back_step; - } - - BN_SIZE(pY) = ySize; - } -} -#endif - -/* -// Binary method of Exponentiation -*/ -#if !defined(_USE_ERNIE_CBA_MITIGATION_) && !defined(_USE_GRES_CBA_MITIGATION_) // unsafe version -void cpSafeMontExp_Binary(IppsBigNumState* pY, - const IppsBigNumState* pX, const IppsBigNumState* pE, - IppsMontState* pMont) -{ - int k; - - /* if E==0 then Y=R mod m */ - if (pE->size == 1 && pE->number[0] == 0) { - int len = IPP_MULTIPLE_OF(pMont->n->size, BNUBASE_TYPE_SIZE); - cpMemset32u(pMont->wb->number, 0, len); - pMont->wb->number[len] = 1; - - cpMod_BNU(pMont->wb->number, len + 1, pMont->n->number, pMont->n->size, &pY->size); - - cpMemcpy32u(pY->number, pMont->wb->number, pY->size); - pY->sgn = ippBigNumPOS; - return; - } - - else { - Ipp32u* r_number = pY->workBuffer; - int r_size = pY->size; - - int flag=1; - Ipp32u power = pE->number[pE->size-1]; - - for( k = 31; k >= 0; k-- ) { - Ipp32u powd = power & 0x80000000;/* from top to bottom*/ - power <<= 1; - - if((flag == 1) && (powd == 0)) - continue; - - else if (flag == 0) { - #if defined(_USE_NN_MONTMUL_) - cpMontMul(r_number, r_size, r_number,r_size, - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number); - #else - cpMontMul(r_number, r_size, r_number,r_size, - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number, pMont->pBuffer); - #endif - if (powd) - #if defined(_USE_NN_MONTMUL_) - cpMontMul(r_number, r_size, pX->number,pX->size, - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number); - #else - cpMontMul(r_number, r_size, pX->number,pX->size, - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number, pMont->pBuffer); - #endif - } - - else { - int i; - flag = 0; - r_size = pMont->n->size; - if( pX->size < pMont->n->size ) - for(i = r_size - 1; i >= pX->size; i-- ) - r_number[i] = 0; - - for( i = pX->size - 1; i >= 0; i-- ) - r_number[i] = pX->number[i]; - } - } - - if (pE->size > 1) { - struct BNU { - Ipp32u *number; - int *size; - } BNUs[2]; - BNUs[0].number = r_number; - BNUs[0].size = &r_size; - BNUs[1].number = pX->number; - BNUs[1].size = &(((IppsBigNumState*)pX)->size); - - for( k = pE->size - 2; k >= 0; k-- ) { - int j; - Ipp32u powd = 0; - power = pE->number[k]; - - for( j = 31; j >= 0; j-- ) { - #if defined(_USE_NN_MONTMUL_) - cpMontMul(r_number, r_size, BNUs[powd].number, *(BNUs[powd].size), - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number); - #else - cpMontMul(r_number, r_size, BNUs[powd].number, *(BNUs[powd].size), - pMont->n->number, pMont->n->size, - r_number,&r_size, pMont->n0, pMont->wb->number, pMont->pBuffer); - #endif - //gres: powd = ((power >> j) & 0x1) * (powd ^ 1); - powd = ((power >> j) & 0x1) & (powd ^ 1); - j += powd; - } - } - } - - for(k=r_size-1; k>= 0; k--) - pY->number[k] = r_number[k]; - - pY->sgn = ippBigNumPOS; - pY->size = r_size; - - while((pY->size > 1) && (pY->number[pY->size-1] == 0)) - pY->size--; - - return; - } -} -#endif /* _xUSE_ERNIE_CBA_MITIGATION_, _xUSE_GRES_CBA_MITIGATION_ */ - - -#if defined(_USE_ERNIE_CBA_MITIGATION_) -/* -// The version below was designed according to recommendation -// from Ernie Brickell and Mattew Wood. -// The reason was to mitigate "cache monitoring" attack on RSA -// Note: this version slower than pre-mitigated version ~ 30-40% -*/ -#define SET_BNU(dst,val,len) \ -{ \ - int n; \ - for(n=0; n<(len); n++) (dst)[n] = (val); \ -} - -#define AND_BNU(dst,src1,src2,len) \ -{ \ - int n; \ - for(n=0; n<(len); n++) (dst)[n] = (src1)[n] & (src2)[n]; \ -} - -void cpSafeMontExp_Binary(IppsBigNumState* pY, - const IppsBigNumState* pX, const IppsBigNumState* pE, - IppsMontState* pMont) -{ - Ipp32u* eData = BN_NUMBER(pE); - int eSize = BN_SIZE(pE); - - /* - // if e==0 then r=R mod m (i.e MontEnc(1)) - */ - if (eSize == 1 && eData[0] == 0) { - cpBN_copy(MNT_1(pMont), pY); - return; - } - - /* - // modulo exponentiation - */ - if(pY!=pX) /* init result */ - cpBN_copy(pX, pY); - - { - Ipp32u eValue; - int nBits; - - Ipp32u* pModulus = BN_NUMBER(MNT_MODULO(pMont)); - int mSize = BN_SIZE(MNT_MODULO(pMont)); - Ipp32u* pHelper = MNT_HELPER(pMont); - - Ipp32u* yData = BN_NUMBER(pY); - Ipp32u* xData = BN_BUFFER(pY); - int ySize = BN_SIZE(pY); - - Ipp32u* tData = BN_NUMBER(MNT_PRODUCT(pMont)); - Ipp32u* pBuffer = BN_BUFFER(MNT_PRODUCT(pMont)); - Ipp32u* pMontOne= BN_NUMBER(MNT_1(pMont)); - - /* expand Mont(1) */ - ZEXPAND_BNU(pMontOne, BN_SIZE(MNT_1(pMont)), mSize); - - /* copy base */ - ZEXPAND_COPY_BNU(yData,ySize, xData,mSize); - - - /* execute most significant part pE */ - eValue = eData[eSize-1]; - nBits = 32-NLZ32u(eValue); - eValue <<= (32-nBits); - - nBits--; - eValue <<=1; - for(; nBits>0; nBits--, eValue<<=1) { - Ipp32u carry; - - /* squaring: R^2 mod Modulus */ - #if defined(_USE_NN_MONTMUL_) - cpMontMul(yData, ySize, - yData, ySize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer); - #else - cpMontMul(yData, ySize, - yData, ySize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer, MNT_BUFFER(pMont)); - #endif - - /* T = (X-1)*bitof(E,j) + 1 */ - SET_BNU(pBuffer, ((Ipp32s)eValue)>>31, mSize); - carry = cpSub_BNU(tData, xData, pMontOne, mSize); - AND_BNU(tData, tData, pBuffer, mSize); - carry = cpAdd_BNU(tData, tData, pMontOne, mSize); - - /* multiply: Y*T mod Modulus */ - #if defined(_USE_NN_MONTMUL_) - cpMontMul(yData, ySize, - tData, mSize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer); - #else - cpMontMul(yData, ySize, - tData, mSize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer, MNT_BUFFER(pMont)); - #endif - } - - /* execute rest bits of E */ - eSize--; - for(; eSize>0; eSize--) { - eValue = eData[eSize-1]; - - for(nBits=32; nBits>0; nBits--, eValue<<=1) { - Ipp32u carry; - - /* squaring: R^2 mod Modulus */ - #if defined(_USE_NN_MONTMUL_) - cpMontMul(yData, ySize, - yData, ySize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer); - #else - cpMontMul(yData, ySize, - yData, ySize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer, MNT_BUFFER(pMont)); - #endif - - /* T = (X-1)*bitof(E,j) + 1 */ - SET_BNU(pBuffer, ((Ipp32s)eValue)>>31, mSize); - carry = cpSub_BNU(tData, xData, pMontOne, mSize); - AND_BNU(tData, tData, pBuffer, mSize); - carry = cpAdd_BNU(tData, tData, pMontOne, mSize); - - /* multiply: R*T mod Modulus */ - #if defined(_USE_NN_MONTMUL_) - cpMontMul(yData, ySize, - tData, mSize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer); - #else - cpMontMul(yData, ySize, - tData, mSize, - pModulus, mSize, - yData, &ySize, - pHelper, pBuffer, MNT_BUFFER(pMont)); - #endif - } - } - - BN_SIZE(pY) = ySize; - } -} -#endif /* _USE_ERNIE_CBA_MITIGATION_ */ - - -#if defined(_USE_GRES_CBA_MITIGATION_) -/* -// The reason was to mitigate "cache monitoring" attack on RSA -// -// This is improved version of modular exponentiation. -// Current version provide both either mitigation and perrformance. -// This version in comparison with previous (IPP 4.1.3) one ~30-40% faster, -// i.e the the performance stayed as was for pre-mitigated version -// -*/ -cpSize cpMontExpBin_BNU_sscm(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); - BNU_CHUNK_T* sscmBuffer = MNT_SBUFFER(pMont); - - cpSize i; - BNU_CHUNK_T mask_pattern; - - /* execute most significant part pE */ - BNU_CHUNK_T eValue = dataE[nsE-1]; - int j = BNU_CHUNK_BITS - cpNLZ_BNU(eValue)-1; - - int back_step = 0; - - /* expand base and init result */ - ZEXPAND_COPY_BNU(dataT, nsM, dataX, nsX); - COPY_BNU(dataY, dataT, nsM); - - for(j-=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; - } - - /* 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; -} -#endif /* _USE_GRES_CBA_MITIGATION_ */ - - -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 cpMontRed_BNU(BNU_CHUNK_T* pR, -// BNU_CHUNK_T* pProduct, -// const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0); -void cpMontRedAdc_BNU(BNU_CHUNK_T* pR, - BNU_CHUNK_T* pProduct, - const BNU_CHUNK_T* pModulus, cpSize nsM, BNU_CHUNK_T m0); -void cpMontRedAdx_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) -{ -#if 0 -#if(_IPP32E < _IPP32E_L9) - cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0); -#else - IsFeatureEnabled(ADCOX_ENABLED)? cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0) - : cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0); -#endif -#endif - -#if(_ADCOX_NI_ENABLING_==_FEATURE_ON_) - cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0); -#elif(_ADCOX_NI_ENABLING_==_FEATURE_TICKTOCK_) - IsFeatureEnabled(ADCOX_ENABLED)? cpMontRedAdx_BNU(pR, pProduct, pModulus, nsM, m0) - : cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0); -#else - cpMontRedAdc_BNU(pR, pProduct, pModulus, nsM, m0); -#endif -} - -__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; -} - -#if 0 -/* -// Size of scratch buffer, involved in MontExp operation -*/ -cpSize cpMontExpScratchBufferSize(cpSize modulusBitSize, - cpSize expBitSize, - cpSize nExponents); -#endif - -/* -// Montgomery exponentiation (binary) "fast" and "safe" versions -*/ -cpSize cpMontExpBin_BNU_sscm(BNU_CHUNK_T* pY, - const BNU_CHUNK_T* pX, cpSize nsX, - const BNU_CHUNK_T* pE, cpSize nsE, - IppsMontState* pMont); - -cpSize cpMontExpBin_BNU(BNU_CHUNK_T* pY, - const BNU_CHUNK_T* pX, cpSize nsX, - const BNU_CHUNK_T* pE, cpSize nsE, - IppsMontState* pMont); - -__INLINE void cpMontExpBin_BN_sscm(IppsBigNumState* pYbn, - const IppsBigNumState* pXbn, - const IppsBigNumState* pEbn, - IppsMontState* pMont) -{ - BNU_CHUNK_T* pX = BN_NUMBER(pXbn); - cpSize nsX = BN_SIZE(pXbn); - BNU_CHUNK_T* pE = BN_NUMBER(pEbn); - cpSize nsE = BN_SIZE(pEbn); - BNU_CHUNK_T* pY = BN_NUMBER(pYbn); - cpSize nsY = cpMontExpBin_BNU_sscm(pY, pX,nsX, pE,nsE, pMont); - FIX_BNU(pY, nsY); - BN_SIZE(pYbn) = nsY; - BN_SIGN(pYbn) = ippBigNumPOS; -} - -__INLINE void cpMontExpBin_BN(IppsBigNumState* pYbn, - const IppsBigNumState* pXbn, - const IppsBigNumState* pEbn, - IppsMontState* pMont) -{ - BNU_CHUNK_T* pX = BN_NUMBER(pXbn); - cpSize nsX = BN_SIZE(pXbn); - BNU_CHUNK_T* pE = BN_NUMBER(pEbn); - cpSize nsE = BN_SIZE(pEbn); - BNU_CHUNK_T* pY = BN_NUMBER(pYbn); - cpSize nsY = cpMontExpBin_BNU(pY, pX,nsX, pE,nsE, pMont); - FIX_BNU(pY, nsY); - BN_SIZE(pYbn) = nsY; - BN_SIGN(pYbn) = ippBigNumPOS; -} - - -/* -// Montgomery exponentiation (fixed window) -*/ -cpSize cpMontExp_WinSize(int bitsize); - -#if defined(_USE_WINDOW_EXP_) -void cpMontExpWin_BN_sscm(IppsBigNumState* pY, - const IppsBigNumState* pX, const IppsBigNumState* pE, - IppsMontState* pMont, - BNU_CHUNK_T* pPrecompResource); - -void cpMontExpWin_BN(IppsBigNumState* pY, - const IppsBigNumState* pX, const IppsBigNumState* pE, - IppsMontState* pMont, - BNU_CHUNK_T* pPrecompResource); -#endif - -/* -// Montgomery multi-exponentiation -*/ -/* precompute table for multi-exponentiation */ -void cpMontMultiExpInitArray(BNU_CHUNK_T* pPrecomTbl, - const BNU_CHUNK_T** ppX, cpSize xItemBitSize, cpSize numItems, - IppsMontState* pMont); - -/* multi-exponentiation */ -void cpFastMontMultiExp(BNU_CHUNK_T* pY, - const BNU_CHUNK_T* pPrecomTbl, - const Ipp8u** ppE, cpSize eItemBitSize, cpSize numItems, - IppsMontState* pMont); - -#endif /* _CP_MONTGOMETRY_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c deleted file mode 100644 index afa5e97878..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontgomeryca.c +++ /dev/null @@ -1,479 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -// Contents: -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpbn.h" -#include "pcpmontgomery.h" -#include "pcpmulbnukara.h" -#include "pcptool.h" - -/*F* -// Name: ippsMontGetSize -// -// Purpose: Specifies size of buffer in bytes. -// -// Returns: Reason: -// ippStsNullPtrErr pCtxSize==NULL -// ippStsLengthErr maxLen32 < 1 -// 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, ippStsLengthErr); - - UNREFERENCED_PARAMETER(method); - - { - /* convert modulus length to the number of BNU_CHUNK_T */ - cpSize modSize = INTERNAL_BNU_LENGTH(maxLen32); - - /* size of Karatsuba buffer */ - cpSize buffSize = 0; - #if defined(_USE_KARATSUBA_) - buffSize = cpKaratsubaBufferSize(modSize); - #if defined( _OPENMP ) - buffSize <<=1; /* double buffer size if OpenMP used */ - #endif - #else - buffSize = 0; - #endif - - *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 */ - + buffSize /* K-mul buffer */ - + 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 -// 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, ippStsLengthErr); - - IPP_BAD_PTR1_RET(pMont); - pMont = (IppsMontState*)( IPP_ALIGNED_PTR(pMont, MONT_ALIGNMENT) ); - - UNREFERENCED_PARAMETER(method); - - MNT_ID(pMont) = idCtxMontgomery; - 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); - - /* size of buffer */ - cpSize buffSize = 0; - #if defined(_USE_KARATSUBA_) - buffSize = cpKaratsubaBufferSize(modSize); - #if defined( _OPENMP ) - buffSize <<=1; /* double buffer size if OpenMP used */ - #endif - #else - buffSize = 0; - #endif - - /* 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) = (buffSize)? (BNU_CHUNK_T*)( ptr += modSize*sizeof(BNU_CHUNK_T)*2 ) : 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); - - return ippStsNoErr; - } -} - -void cpPackMontCtx(const IppsMontState* pCtx, Ipp8u* pBuffer) -{ - IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT)); - - /* max modulus length */ - int modSize = MNT_ROOM(pCtx); - /* size of context (bytes) without product and Karatsuba buffers */ - int ctxSize = sizeof(IppsMontState) - +sizeof(BNU_CHUNK_T)*(modSize*4); - - CopyBlock(pCtx, pAlignedBuffer, ctxSize); - MNT_MODULUS(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_MODULUS(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_1(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_1(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_SQUARE_R(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_SQUARE_R(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_CUBE_R(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_CUBE_R(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_PRODUCT(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_PRODUCT(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_TBUFFER(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_TBUFFER(pCtx))-IPP_UINT_PTR(pCtx)); - MNT_KBUFFER(pAlignedBuffer) = MNT_KBUFFER(pCtx)? (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(MNT_KBUFFER(pCtx))-IPP_UINT_PTR(pCtx)) : NULL; -} - -void cpUnpackMontCtx(const Ipp8u* pBuffer, IppsMontState* pCtx) -{ - IppsMontState* pAlignedBuffer = (IppsMontState*)(IPP_ALIGNED_PTR((pBuffer), MONT_ALIGNMENT)); - - /* max modulus length */ - int modSize = MNT_ROOM(pAlignedBuffer); - /* size of context (bytes) without product and Karatsuba buffers */ - int ctxSize = sizeof(IppsMontState) - +sizeof(BNU_CHUNK_T)*(modSize*4); - - CopyBlock(pAlignedBuffer, pCtx, ctxSize); - MNT_MODULUS(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_MODULUS(pAlignedBuffer))); - MNT_1(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_1(pAlignedBuffer))); - MNT_SQUARE_R(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_SQUARE_R(pAlignedBuffer))); - MNT_CUBE_R(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_CUBE_R(pAlignedBuffer))); - MNT_PRODUCT(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_PRODUCT(pAlignedBuffer))); - MNT_TBUFFER(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(MNT_TBUFFER(pAlignedBuffer))); - MNT_KBUFFER(pCtx) = MNT_KBUFFER(pCtx)? (BNU_CHUNK_T*)((Ipp8u*)pCtx + IPP_UINT_PTR(MNT_KBUFFER(pAlignedBuffer))) : NULL; -} - -/*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*/ - -/* -// See Dusse & Kaliski "A cryptographic library for the Motorola DSP56000" -// Unfortunately there is a misprint in the paper above -*/ -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: ippsMontGet -// -// Purpose: Extracts modulus. -// -// Returns: Reason: -// ippStsNullPtrErr pMont==NULL -// pModulus==NULL -// pLen32==NULL -// ippStsContextMatchErr !MNT_VALID_ID() -// ippStsNoErr no errors -// -// Parameters: -// pModulus pointer to the modulus buffer -// pLen32 pointer to the modulus length (in Ipp32u chunks). -// pMont pointer to the context -*F*/ -IPPFUN(IppStatus, ippsMontGet,(Ipp32u* pModulus, cpSize* pLen32, const IppsMontState* pMont)) -{ - IPP_BAD_PTR3_RET(pMont, pModulus, pLen32); - - pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT)); - IPP_BADARG_RET(!MNT_VALID_ID(pMont), ippStsContextMatchErr); - - { - cpSize len32 = MNT_SIZE(pMont)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u); - Ipp32u* bnData = (Ipp32u*)MNT_MODULUS(pMont); - - FIX_BNU(bnData, len32); - COPY_BNU(pModulus, bnData, len32); - *pLen32 = len32; - - return ippStsNoErr; - } -} - -/*F* -// Name: ippsMontForm -// -// Purpose: Converts input into Montgomery domain. -// -// Returns: Reason: -// ippStsNullPtrErr pMont==NULL -// pA==NULL -// pR==NULL -// ippStsContextMatchErr !MNT_VALID_ID() -// !BN_VALID_ID(pA) -// !BN_VALID_ID(pR) -// ippStsBadArgErr A < 0. -// ippStsScaleRangeErr A >= Modulus. -// ippStsOutOfRangeErr R can't hold result -// ippStsNoErr no errors -// -// Parameters: -// pA pointer to the input [0, modulus-1] -// pMont Montgomery context -// pR pointer to the output (A*R mod modulus) -*F*/ -IPPFUN(IppStatus, ippsMontForm,(const IppsBigNumState* pA, IppsMontState* pMont, IppsBigNumState* pR)) -{ - IPP_BAD_PTR3_RET(pMont, pA, pR); - - pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT)); - pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, 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(pR), ippStsContextMatchErr); - - IPP_BADARG_RET(BN_SIGN(pA) != ippBigNumPOS, ippStsBadArgErr); - IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr); - IPP_BADARG_RET(BN_ROOM(pR) < MNT_SIZE(pMont), ippStsOutOfRangeErr); - - cpMontEnc_BN(pR, pA, pMont); - - 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; - } -} - - -/******************************************************************************* -// Name: ippsMontExp -// Description: ippsMontExp() computes the Montgomery exponentiation with exponent -// IppsBigNumState *e to the given big number integer of Montgomery form -// IppsBigNumState *a with respect to the modulus IppsMontState *m. -// Input Arguments: a - big number integer of Montgomery form within the -// range [0,m-1] -// e - big number exponent -// m - Montgomery modulus of IppsMontState. -// Output Arguments: r - the Montgomery exponentiation result. -// Returns: IPPC_STATUS_OK - No Error -// IPPC_STATUS_MONT_BAD_MODULUS - If a>m or b>m or m>R or P_MONT *m has -// not been initialized by the primitive -// function ippsMontInit( ). -// IPPC_STATUS_BAD_ARG - Bad Arguments -// Notes: IppsBigNumState *r should possess enough memory space as to hold the result -// of the operation. i.e. both pointers r->d and r->buffer should possess -// no less than (m->n->length) number of 32-bit words. -*******************************************************************************/ -IPPFUN(IppStatus, ippsMontExp, (const IppsBigNumState* pA, const IppsBigNumState* pE, IppsMontState* pMont, IppsBigNumState* pR)) -{ - IPP_BAD_PTR4_RET(pA, pE, pMont, pR); - - pMont = (IppsMontState*)(IPP_ALIGNED_PTR((pMont), MONT_ALIGNMENT)); - pA = (IppsBigNumState*)( IPP_ALIGNED_PTR(pA, BN_ALIGNMENT) ); - pE = (IppsBigNumState*)( IPP_ALIGNED_PTR(pE, 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(pE), ippStsContextMatchErr); - IPP_BADARG_RET(!BN_VALID_ID(pR), ippStsContextMatchErr); - - IPP_BADARG_RET(BN_ROOM(pR) < MNT_SIZE(pMont), ippStsOutOfRangeErr); - /* check a */ - IPP_BADARG_RET(BN_NEGATIVE(pA), ippStsBadArgErr); - IPP_BADARG_RET(cpCmp_BNU(BN_NUMBER(pA), BN_SIZE(pA), MNT_MODULUS(pMont), MNT_SIZE(pMont)) >= 0, ippStsScaleRangeErr); - /* check e */ - IPP_BADARG_RET(BN_NEGATIVE(pE), ippStsBadArgErr); - - cpMontExpBin_BN(pR, pA, pE, pMont); - - return ippStsNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontred.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontred.c deleted file mode 100644 index cd5fca484f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpmontred.c +++ /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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -*/ - -#include "owncp.h" -#include "pcpbnuarith.h" - - -#if !((_IPP==_IPP_W7) || \ - (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || \ - (_IPP==_IPP_P8) || \ - (_IPP>=_IPP_G9) || \ - (_IPPLP32==_IPPLP32_S8) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E>=_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) - -#if 0 -#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 - -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 = t=_IPP_H9)) - #define CP_KARATSUBA_MUL_THRESHOLD 32 - #define CP_KARATSUBA_SQR_THRESHOLD 32 - -#elif ((_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || \ - (_IPP32E==_IPP32E_Y8) || \ - (_IPP32E==_IPP32E_E9) || \ - (_IPPLP64==_IPPLP64_N8)) - #define CP_KARATSUBA_MUL_THRESHOLD 16 - #define CP_KARATSUBA_SQR_THRESHOLD 40 -#elif ((_IPP32E>=_IPP32E_L9)) - #define CP_KARATSUBA_MUL_THRESHOLD 20 - #define CP_KARATSUBA_SQR_THRESHOLD 48 - -#else - #define CP_KARATSUBA_MUL_THRESHOLD 12 - #define CP_KARATSUBA_SQR_THRESHOLD 16 -#endif - - -cpSize cpKaratsubaBufferSize(cpSize len); - -BNU_CHUNK_T cpMul_BNU_karatsuba(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY, cpSize ns, - BNU_CHUNK_T* pBuffer); -BNU_CHUNK_T cpSqr_BNU_karatsuba(BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pX, cpSize ns, - BNU_CHUNK_T* pBuffer); - - -#else - #define CP_KARATSUBA_MUL_THRESHOLD 0 - #define CP_KARATSUBA_SQR_THRESHOLD 0 -#endif /* _USE_KARATSUBA_ */ - -#endif /* _KARATSUBA_MUL_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma.h deleted file mode 100644 index 2a0c65f60f..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma.h +++ /dev/null @@ -1,106 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA_H) -#define _PCP_PMA_H - - -#include "pcpbn.h" -#include "pcpmontgomery.h" - - -/* -// unsigned BN set/get -*/ -#define SET_BN(pBN,bnu,len) \ - BN_SIGN((pBN)) = ippBigNumPOS; \ - BN_SIZE((pBN)) = ((len)); \ - Cpy_BNU((bnu), BN_NUMBER((pBN)), (len)) - -#define GET_BN(pBN,bnu,len) \ - Set_BNU(0, (bnu), (len)); \ - Cpy_BNU(BN_NUMBER((pBN)), (bnu), BN_SIZE((pBN))) - - -/* -// 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_neg(r,a,modulo) \ - ippsSub_BN((modulo),(a),(r)) - -#define PMA_lsr(r,a,modulo) \ - BN_SIZE((r)) = cpLSR_BNU(BN_NUMBER((a)), BN_NUMBER((r)), (int)BN_SIZE((a)), 1) - -#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_sqr(r,a,modulo) \ - PMA_mul(r,a,a,modulo) - -#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_mul(r,a,b,modulo) \ - ippsMul_BN((a),(b),(r)); \ - if( cpCmp_BNU(BN_NUMBER((r)),BN_SIZE((r)),BN_NUMBER((modulo)),BN_SIZE(modulo)) >= 0 ) \ - ippsMod_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/epid/ext/ipp/sources/ippcp/src/pcppma128.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma128.c deleted file mode 100644 index 80061d5909..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma128.c +++ /dev/null @@ -1,169 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// Contents: -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_128_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccp.h" -#include "pcppma128.h" - - -/* -// Specific Modulo Arithmetic -// P128 = 2^128 -2^97 -1 -// (reference secp128r1_p) -*/ - -/* -// Reduce modulo: -// -// x = c7|c6|c5|c4|c3|c2|c1|c0 -// -// s1 = c3| c2| c1| c0 -// s2 = 2c4| 00| 00| c4 -// s3 = 4c5| 00| c5|2c5 -// s4 = 8c6| c6|2c6|4c6 -// s5 =17c7|2c7|4c7|8c7 -// -// r = (s1+s2+s3+s4+s5) (mod P) -*/ -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) -void Reduce_P128r1(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u c7x2 = (Ipp64u)pR[7] + (Ipp64u)pR[7]; - Ipp64u c7x4 = c7x2 + c7x2; - Ipp64u c7x8 = c7x4 + c7x4; - - Ipp64u c6x2 = (Ipp64u)pR[6] + (Ipp64u)pR[6]; - Ipp64u c6x4 = c6x2 + c6x2; - Ipp64u c6x8 = c6x4 + c6x4; - - Ipp64u c5x2 = (Ipp64u)pR[5] + (Ipp64u)pR[5]; - Ipp64u c5x4 = c5x2 + c5x2; - - Ipp64u c4x2 = (Ipp64u)pR[4] + (Ipp64u)pR[4]; - - Ipp64u - sum = (Ipp64u)pR[0] + (Ipp64u)pR[4] + c5x2 + c6x4 + c7x8; - pR[0] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[1] + (Ipp64u)pR[5] + c6x2 + c7x4; - pR[1] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[2] + (Ipp64u)pR[6] + c7x2; - pR[2] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[3] + c4x2 + c5x4 + c6x8 + c7x8+c7x8+(Ipp64u)pR[7]; - pR[3] = LODWORD(sum); - pProduct[LEN_P128] = (BNU_CHUNK_T)(HIDWORD(sum)); - - if(pProduct[LEN_P128]) - cpSub_BNU(pProduct, pProduct, ((BNU_CHUNK_T**)secp128_mx)[pProduct[LEN_P128]], LEN_P128+1); - - while((BNS_CHUNK_T)pProduct[LEN_P128] <0) - cpAdd_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp128r1_p, LEN_P128+1); - - while(0 <= cpCmp_BNU(pProduct, LEN_P128+1, (BNU_CHUNK_T*)secp128r1_p, LEN_P128+1)) - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp128r1_p, LEN_P128+1); -} -#endif - -void cpAdde_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P128); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P128, (BNU_CHUNK_T*)secp128r1_p, LEN_P128))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp128r1_p, LEN_P128); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P128; -} - -void cpSube_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P128); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp128r1_p, LEN_P128); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P128; -} - -void cpSqre_128r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P128]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P128); - - Reduce_P128r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P128); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P128; -} - -void cpMule_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P128]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P128, bPtr, LEN_P128); - - Reduce_P128r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P128); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P128; -} - -#endif /* _ECP_128_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma128.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma128.h deleted file mode 100644 index 54b71f42dc..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma128.h +++ /dev/null @@ -1,79 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA128_H) -#define _PCP_PMA128_H - -#include "pcpbn.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (128) -#define LEN_P128 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - -/* -// Modular Arithmetic for secp128r1 ECC -*/ -void Reduce_P128r1(BNU_CHUNK_T* pR); -void cpAdde_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_128r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_128r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA128_add(r,a,b) \ - cpAdde_128r1((a),(b), (r)) - -#define PMA128_sub(r,a,b) \ - cpSube_128r1((a),(b), (r)) - -#define PMA128_sqr(r,a) \ - cpSqre_128r1((a),(r)) - -#define PMA128_mul(r,a,b) \ - cpMule_128r1((a),(b), (r)) - -#define PMA128_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P128, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P128, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp128r1_p, LEN_P128); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P128, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P128; \ -} - -#define PMA128_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P128); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P128; \ -} - -#endif /* _PCP_PMA128_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.c deleted file mode 100644 index 4cc1a69a1b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.c +++ /dev/null @@ -1,153 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_192_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccp.h" -#include "pcppma192.h" - -/* -// Specific Modulo Arithmetic -// P192 = 2^192 -2^64 -1 -// (reference secp192r1_p) -*/ - -/* -// Reduce modulo: -// -// x = c11|c10|c9|c8|c7|c6|c5|c4|c3|c2|c1|c0 -// -// s1 = c05|c04|c03|c02|c01|c00 -// s2 = 000|000|c07|c06|c07|c06 -// s3 = c09|c08|c09|c08|000|000 -// -// r = (s1+s2+s3+s4) (mod P) -*/ -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) -void Reduce_P192r1(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u - sum = (Ipp64u)pR[0*2+0]+(Ipp64u)pR[3*2+0]+(Ipp64u)pR[5*2+0]; - pR[0] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[0*2+1]+(Ipp64u)pR[3*2+1]+(Ipp64u)pR[5*2+1]; - pR[1] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[1*2+0]+(Ipp64u)pR[3*2+0]+(Ipp64u)pR[4*2+0]+(Ipp64u)pR[5*2+0]; - pR[2] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[1*2+1]+(Ipp64u)pR[3*2+1]+(Ipp64u)pR[4*2+1]+(Ipp64u)pR[5*2+1]; - pR[3] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[2*2+0]+(Ipp64u)pR[4*2+0]+(Ipp64u)pR[5*2+0]; - pR[4] = LODWORD(sum); - sum = HIDWORD(sum); - - sum += (Ipp64u)pR[2*2+1]+(Ipp64u)pR[4*2+1]+(Ipp64u)pR[5*2+1]; - pR[5] = LODWORD(sum); - pProduct[LEN_P192] = (BNU_CHUNK_T)(HIDWORD(sum)); - - while(0<=cpCmp_BNU(pProduct, LEN_P192+1, (BNU_CHUNK_T*)secp192r1_p, LEN_P192+1)) - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp192r1_p, LEN_P192+1); -} -#endif - -void cpAdde_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P192); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P192, (BNU_CHUNK_T*)secp192r1_p, LEN_P192))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp192r1_p, LEN_P192); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P192; -} - -void cpSube_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P192); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp192r1_p, LEN_P192); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P192; -} - -void cpSqre_192r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P192]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P192); - - Reduce_P192r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P192); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P192; -} - -void cpMule_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P192]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P192, bPtr, LEN_P192); - - Reduce_P192r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P192); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P192; -} - -#endif /* _ECP_192_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.h deleted file mode 100644 index c2da25a5ef..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma192.h +++ /dev/null @@ -1,84 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if (_ECP_192_==_ECP_IMPL_SPECIFIC_) - -#if !defined(_PCP_PMA192_H) -#define _PCP_PMA192_H - - -#include "pcpbn.h" -//#include "pcppmafix.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (192) -#define LEN_P192 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - -/* -// Modular Arithmetic for secp192r1 ECC -*/ -void Reduce_P192r1(BNU_CHUNK_T* pR); -void cpAdde_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_192r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_192r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA192_add(r,a,b) \ - cpAdde_192r1((a),(b), (r)) - -#define PMA192_sub(r,a,b) \ - cpSube_192r1((a),(b), (r)) - -#define PMA192_sqr(r,a) \ - cpSqre_192r1((a),(r)) - -#define PMA192_mul(r,a,b) \ - cpMule_192r1((a),(b), (r)) - -#define PMA192_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P192, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P192, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp192r1_p, LEN_P192); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P192, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P192; \ -} - -#define PMA192_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P192); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P192; \ -} - -#endif /* _PCP_PMA192_H */ -#endif /* _ECP_192_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.c deleted file mode 100644 index 404a9d75bf..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.c +++ /dev/null @@ -1,169 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_224_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccp.h" -#include "pcppma224.h" - - -/* -// Specific Modulo Arithmetic -// P224 = 2^224 -2^96 +1 -// (reference secp224r1_p) -*/ - -/* -// Reduce modulo: -// -// x = c13|c12|c11|c10|c09|c08|c07|c06|c05|c04|c03|c02|c01|c00 - 32-bits values -// -// s1 = c06|c05|c04|c03|c02|c01|c00 -// s2 = c10|c09|c08|c07|000|000|000 -// s3 = 000|c13|c12|c11|000|000|000 -// -// s4 = c13|c12|c11|c10|c09|c08|c07 -// s5 = 000|000|000|000|c13|c12|c11 -// -// r = (s1+s2+s3-s4-s5) (mod P) -*/ -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) -void Reduce_P224r1(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u c7c11 = (Ipp64u)pR[ 7] + (Ipp64u)pR[11]; - Ipp64u c8c12 = (Ipp64u)pR[ 8] + (Ipp64u)pR[12]; - Ipp64u c9c13 = (Ipp64u)pR[ 9] + (Ipp64u)pR[13]; - - Ipp64s - sum = (Ipp64u)pR[ 0] - c7c11; - pR[0] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 1] - c8c12; - pR[1] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 2] - c9c13; - pR[2] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 3] + c7c11 - (Ipp64u)pR[10]; - pR[3] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 4] + c8c12 - (Ipp64u)pR[11]; - pR[4] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 5] + c9c13 - (Ipp64u)pR[12]; - pR[5] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 6] + (Ipp64u)pR[10] - (Ipp64u)pR[13]; - pR[6] = LODWORD(sum); - pR[7] = (Ipp32u)(sum>>32); - - while(((BNS_CHUNK_T)pProduct[BITS_BNU_CHUNK(OPERAND_BITSIZE+1)-1]) <0) { - cpAdd_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp224r1_p, BITS_BNU_CHUNK(OPERAND_BITSIZE+1)); - } - while(0 <= cpCmp_BNU(pProduct, BITS_BNU_CHUNK(OPERAND_BITSIZE+1), (BNU_CHUNK_T*)secp224r1_p, BITS_BNU_CHUNK(OPERAND_BITSIZE+1))) { - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp224r1_p, BITS_BNU_CHUNK(OPERAND_BITSIZE+1)); - } -} -#endif - -void cpAdde_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P224); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P224, (BNU_CHUNK_T*)secp224r1_p, LEN_P224))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp224r1_p, LEN_P224); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P224; -} - -void cpSube_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P224); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp224r1_p, LEN_P224); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P224; -} - -void cpSqre_224r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P224]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P224); - - Reduce_P224r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P224); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P224; -} - -void cpMule_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P224]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P224, bPtr, LEN_P224); - - Reduce_P224r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P224); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P224; -} - -#endif /* _ECP_224_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.h deleted file mode 100644 index 3ddab5611a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma224.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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA224_H) -#define _PCP_PMA224_H - - -#include "pcpbn.h" -//#include "pcppmafix.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (224) -#define LEN_P224 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - -/* -// Modular Arithmetic for secp224r1 ECC -*/ -void Reduce_P224r1(BNU_CHUNK_T* pR); -void cpAdde_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_224r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_224r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA224_add(r,a,b) \ - cpAdde_224r1((a),(b), (r)) - -#define PMA224_sub(r,a,b) \ - cpSube_224r1((a),(b), (r)) - -#define PMA224_sqr(r,a) \ - cpSqre_224r1((a),(r)) - -#define PMA224_mul(r,a,b) \ - cpMule_224r1((a),(b), (r)) - -#define PMA224_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P224, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P224, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp224r1_p, LEN_P224); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P224, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P224; \ -} - -#define PMA224_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P224); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P224; \ -} - -#endif /* _PCP_PMA224_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.c deleted file mode 100644 index cc6a515d2d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.c +++ /dev/null @@ -1,181 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_256_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccp.h" -#include "pcppma256.h" - - -/* -// Specific Modulo Arithmetic -// P256 = 2^256 -2^224 +2^192 +2^96 -1 -// (reference secp256r1_p) -*/ - -/* -// Reduce modulo: -// -// x = c15|c14|c13|c12|c11|c10|c09|c08|c07|c06|c05|c04|c03|c02|c01|c00 - 32-bits values -// -// s1 = c07|c06|c05|c04|c03|c02|c01|c00 -// s2 = c15|c14|c13|c12|c11|000|000|000 -// s3 = 000|c15|c14|c13|c12|000|000|000 -// s4 = c15|c14|000|000|000|c10|c09|c08 -// s5 = c08|c13|c15|c14|c13|c11|c10|c09 -// -// s6 = c10|c08|000|000|000|c13|c12|c11 -// s7 = c11|c09|000|000|c15|c14|c13|c12 -// s8 = c12|000|c10|c09|c08|c15|c14|c13 -// s9 = c13|000|c11|c10|c09|000|c15|c14 -// -// r = (s1+2*s2+2*s3+s4+s5-s6-s7-s8-s9) (mod P) -*/ -#if !((_IPPXSC==_IPPXSC_S1) || (_IPPXSC==_IPPXSC_S2) || (_IPPXSC==_IPPXSC_C2) || \ - (_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ - (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ - (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) || \ - (_IPP32E==_IPP32E_M7) || \ - (_IPP32E==_IPP32E_U8) || (_IPP32E==_IPP32E_Y8) || \ - (_IPPLP64==_IPPLP64_N8) || (_IPP32E>=_IPP32E_E9) || \ - (_IPP64==_IPP64_I7) ) -void Reduce_P256r1(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u c8c9 = (Ipp64u)pR[ 8] + (Ipp64u)pR[ 9]; - Ipp64u c9c10= (Ipp64u)pR[ 9] + (Ipp64u)pR[10]; - Ipp64u c10c11= (Ipp64u)pR[10] + (Ipp64u)pR[11]; - Ipp64u c11c12= (Ipp64u)pR[11] + (Ipp64u)pR[12]; - Ipp64u c12c13= (Ipp64u)pR[12] + (Ipp64u)pR[13]; - Ipp64u c13c14= (Ipp64u)pR[13] + (Ipp64u)pR[14]; - Ipp64u c14c15= (Ipp64u)pR[14] + (Ipp64u)pR[15]; - - Ipp64s - sum = (Ipp64u)pR[ 0] + c8c9 - c11c12 - c13c14; - pR[0] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 1] + c9c10 - c12c13 - c14c15; - pR[1] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 2] + c10c11- c13c14 - (Ipp64u)pR[15]; - pR[2] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 3] + c11c12 + c11c12 + c13c14 - c14c15 - c8c9; - pR[3] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 4] + c12c13 + c12c13 + (Ipp64u)pR[14] - c9c10; - pR[4] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 5] + c13c14 + c13c14 + (Ipp64u)pR[15] - c10c11; - pR[5] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 6] + c14c15 +c14c15 +c13c14 - c8c9; - pR[6] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 7] + (Ipp64u)pR[ 8] + (Ipp64u)pR[15] + (Ipp64u)pR[15] + (Ipp64u)pR[15] - c10c11 -c12c13; - pR[7] = LODWORD(sum); - sum >>= 32; - pProduct[LEN_P256] = (BNU_CHUNK_T)(sum); - - while(((BNS_CHUNK_T)pProduct[LEN_P256]) <0) - cpAdd_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp256r1_p, LEN_P256+1); - - while(0 <= cpCmp_BNU(pProduct, LEN_P256+1, (BNU_CHUNK_T*)secp256r1_p, LEN_P256+1)) - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp256r1_p, LEN_P256+1); -} -#endif - -void cpAdde_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P256); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P256, (BNU_CHUNK_T*)secp256r1_p, LEN_P256))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp256r1_p, LEN_P256); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P256; -} - -void cpSube_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P256); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp256r1_p, LEN_P256); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P256; -} - -void cpSqre_256r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P256]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P256); - - Reduce_P256r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P256); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P256; -} - -void cpMule_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P256]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P256, bPtr, LEN_P256); - - Reduce_P256r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P256); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P256; -} - -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.h deleted file mode 100644 index 5137c0493a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma256.h +++ /dev/null @@ -1,82 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA256_H) -#define _PCP_PMA256_H - - -#include "pcpbn.h" -//#include "pcppmafix.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (256) -#define LEN_P256 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - - -/* -// Modular Arithmetic for secp256r1 ECC -*/ -void Reduce_P256r1(BNU_CHUNK_T* pR); -void cpAdde_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_256r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_256r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA256_add(r,a,b) \ - cpAdde_256r1((a),(b), (r)) - -#define PMA256_sub(r,a,b) \ - cpSube_256r1((a),(b), (r)) - -#define PMA256_sqr(r,a) \ - cpSqre_256r1((a),(r)) - -#define PMA256_mul(r,a,b) \ - cpMule_256r1((a),(b), (r)) - -#define PMA256_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P256, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P256, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp256r1_p, LEN_P256); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P256, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P256; \ -} - -#define PMA256_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P256); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P256; \ -} - -#endif /* _PCP_PMA256_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.c deleted file mode 100644 index f2042f6965..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.c +++ /dev/null @@ -1,191 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_384_==_ECP_IMPL_SPECIFIC_) || (_ECP_384_==_ECP_IMPL_MFM_) -#include "pcpeccp.h" -#include "pcppma384.h" - - -/* -// Specific Modulo Arithmetic -// P384 = 2^384 -2^128 -2^96 +2^32 -1 -// (reference secp384r1_p) -*/ - -/* -// Reduce modulo: -// -// x = c23|c22|c21|c20|c19|c18|c17|c16|c15|c14|c13|c12|c11|c10|c09|c08|c07|c06|c05|c04|c03|c02|c01|c00 - 32-bits values -// -// s1 = c11|c10|c09|c08|c07|c06|c05|c04|c03|c02|c01|c00 -// s2 = 000|000|000|000|000|c23|c22|c21|000|000|000|000 -// s3 = c23|c22|c21|c20|c19|c18|c17|c16|c15|c14|c13|c12 -// s4 = c20|c19|c18|c17|c16|c15|c14|c13|c12|c23|c22|c21 -// s5 = c19|c18|c17|c16|c15|c14|c13|c12|c20|000|c23|000 -// s6 = 000|000|000|000|c23|c22|c21|c20|000|000|000|000 -// s7 = 000|000|000|000|000|000|c23|c22|c21|000|000|c20 -// -// s8 = c22|c21|c20|c19|c18|c17|c16|c15|c14|c13|c12|c23 -// s9 = 000|000|000|000|000|000|000|c23|c22|c21|c20|000 -// s10= 000|000|000|000|000|000|000|c23|c23|000|000|000 -// -// r = (s1+2*s2+s3+s4+s5+s6+s7-s8-s9-10) (mod P) -*/ - -//static -void Reduce_P384r1(BNU_CHUNK_T* pProduct) -{ - #define CHUNK_LEN_P384 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u c12c21 = (Ipp64u)pR[12] + (Ipp64u)pR[21]; - Ipp64u c13c22 = (Ipp64u)pR[13] + (Ipp64u)pR[22]; - Ipp64u c14c23 = (Ipp64u)pR[14] + (Ipp64u)pR[23]; - - Ipp64s - sum = (Ipp64u)pR[ 0] + c12c21 + (Ipp64u)pR[20] - (Ipp64u)pR[23]; - pR[ 0]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 1] + c13c22 + (Ipp64u)pR[23] - (Ipp64u)pR[12] - (Ipp64u)pR[20]; - pR[ 1]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 2] + c14c23 - (Ipp64u)pR[13] - (Ipp64u)pR[21]; - pR[ 2]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 3] + c12c21 + (Ipp64u)pR[15] + (Ipp64u)pR[20] - c14c23 - (Ipp64u)pR[22]; - pR[ 3]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 4] + (Ipp64u)pR[21] + c12c21 + c13c22 + (Ipp64u)pR[16] + (Ipp64u)pR[20] - (Ipp64u)pR[15] - (Ipp64u)pR[23] - (Ipp64u)pR[23]; - pR[ 4]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 5] + (Ipp64u)pR[22] + c13c22 + c14c23 + (Ipp64u)pR[17] + (Ipp64u)pR[21] - (Ipp64u)pR[16]; - pR[ 5]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 6] + (Ipp64u)pR[23] + c14c23 + (Ipp64u)pR[15] + (Ipp64u)pR[18] + (Ipp64u)pR[22] - (Ipp64u)pR[17]; - pR[ 6]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 7] + (Ipp64u)pR[15] + (Ipp64u)pR[16] + (Ipp64u)pR[19] + (Ipp64u)pR[23] - (Ipp64u)pR[18]; - pR[ 7]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 8] + (Ipp64u)pR[16] + (Ipp64u)pR[17] + (Ipp64u)pR[20] - (Ipp64u)pR[19]; - pR[ 8]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 9] + (Ipp64u)pR[17] + (Ipp64u)pR[18] + (Ipp64u)pR[21] - (Ipp64u)pR[20]; - pR[ 9]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[10] + (Ipp64u)pR[18] + (Ipp64u)pR[19] + (Ipp64u)pR[22] - (Ipp64u)pR[21]; - pR[10]= LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[11] + (Ipp64u)pR[19] + (Ipp64u)pR[20] + (Ipp64u)pR[23] - (Ipp64u)pR[22]; - pR[11]= LODWORD(sum); - sum >>= 32; - pProduct[LEN_P384] = (BNU_CHUNK_T)sum; - - while(((BNS_CHUNK_T)pProduct[LEN_P384]) <0) - cpAdd_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp384r1_p, LEN_P384+1); - - while(0 <= cpCmp_BNU(pProduct, LEN_P384+1, (BNU_CHUNK_T*)secp384r1_p, LEN_P384+1)) - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)secp384r1_p, LEN_P384+1); -} - - -void cpSqre_384r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P384]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P384); - - Reduce_P384r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P384); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P384; -} - -void cpMule_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P384]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P384, bPtr, LEN_P384); - - Reduce_P384r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P384); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P384; -} -#endif /* (_ECP_384_==_ECP_IMPL_SPECIFIC_) || (_ECP_384_==_ECP_IMPL_MFM_) */ - -#if (_ECP_384_==_ECP_IMPL_SPECIFIC_) -void cpAdde_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P384); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P384, (BNU_CHUNK_T*)secp384r1_p, LEN_P384))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp384r1_p, LEN_P384); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P384; -} - -void cpSube_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P384); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp384r1_p, LEN_P384); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P384; -} -#endif /* _ECP_384_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.h deleted file mode 100644 index 688e49fa67..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma384.h +++ /dev/null @@ -1,82 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA384_H) -#define _PCP_PMA384_H - - -#include "pcpbn.h" -//#include "pcppmafix.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (384) -#define LEN_P384 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - -/* -// Modular Arithmetic for secp384r1 ECC -*/ -void Reduce_P384r1(BNU_CHUNK_T* pProduct); - -void cpAdde_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_384r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_384r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA384_add(r,a,b) \ - cpAdde_384r1((a),(b), (r)) - -#define PMA384_sub(r,a,b) \ - cpSube_384r1((a),(b), (r)) - -#define PMA384_sqr(r,a) \ - cpSqre_384r1((a),(r)) - -#define PMA384_mul(r,a,b) \ - cpMule_384r1((a),(b), (r)) - -#define PMA384_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P384, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P384, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp384r1_p, LEN_P384); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P384, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P384; \ -} - -#define PMA384_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P384); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P384; \ -} - -#endif /* _PCP_PMA384_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.c deleted file mode 100644 index 6366285c94..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.c +++ /dev/null @@ -1,124 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcpeccp.h" -#include "pcppma521.h" - -#if (_ECP_521_==_ECP_IMPL_SPECIFIC_) || (_ECP_521_==_ECP_IMPL_MFM_) - - -/* -// Specific Modulo Arithmetic -// P521 = 2^521 -1 -// (reference secp521r1_p) -*/ - -/* -// Reduce modulo: -// -// x = a1*2^521 + a0 - 521-bits values -// -// r = (s1+a0) (mod P) -*/ -static -void Reduce_P521r1(BNU_CHUNK_T* pProduct) -{ - BNU_CHUNK_T TT[LEN_P521]; - BNU_CHUNK_T* pR = pProduct; - - cpLSR_BNU(TT, pR+LEN_P521-1, LEN_P521, OPERAND_BITSIZE%BITSIZE(BNU_CHUNK_T)); - pR[LEN_P521-1] &= MASK_BNU_CHUNK(OPERAND_BITSIZE % BITSIZE(BNU_CHUNK_T)); - TT[LEN_P521-1] &= MASK_BNU_CHUNK(OPERAND_BITSIZE % BITSIZE(BNU_CHUNK_T)); - cpAdd_BNU(pR, pR, TT, LEN_P521); - - while(0 <= cpCmp_BNU(pR, LEN_P521, (BNU_CHUNK_T*)secp521r1_p, LEN_P521)) - cpSub_BNU(pR, pR, (BNU_CHUNK_T*)secp521r1_p, LEN_P521); -} - -void cpSqre_521r1(IppsBigNumState* pA, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P521]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpSqr_BNU_school(tmpR, aPtr, LEN_P521); - - Reduce_P521r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P521); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P521; -} - -void cpMule_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T tmpR[2*LEN_P521]; - - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - cpMul_BNU_school(tmpR, aPtr, LEN_P521, bPtr, LEN_P521); - - Reduce_P521r1(tmpR); - COPY_BNU(rPtr, tmpR, LEN_P521); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P521; -} -#endif /* (_ECP_521_==_ECP_IMPL_SPECIFIC_) || (_ECP_521_==_ECP_IMPL_MFM_) */ - -#if (_ECP_521_==_ECP_IMPL_SPECIFIC_) -void cpAdde_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T carry = cpAdd_BNU(rPtr, aPtr, bPtr, LEN_P521); - if(carry || (0<=cpCmp_BNU(rPtr, LEN_P521, (BNU_CHUNK_T*)secp521r1_p, LEN_P521))) - cpSub_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp521r1_p, LEN_P521); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P521; -} - -void cpSube_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR) -{ - BNU_CHUNK_T* aPtr = BN_NUMBER(pA); - BNU_CHUNK_T* bPtr = BN_NUMBER(pB); - BNU_CHUNK_T* rPtr = BN_NUMBER(pR); - - BNU_CHUNK_T borrow = cpSub_BNU(rPtr, aPtr, bPtr, LEN_P521); - if(borrow) - cpAdd_BNU(rPtr, rPtr, (BNU_CHUNK_T*)secp521r1_p, LEN_P521); - - BN_SIGN(pR) = ippBigNumPOS; - BN_SIZE(pR) = LEN_P521; -} -#endif /* _ECP_521_==_ECP_IMPL_SPECIFIC_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.h deleted file mode 100644 index 8dacdcfe2d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppma521.h +++ /dev/null @@ -1,80 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Prime Modulo Arithmetic Function Prototypes -// -// -*/ - -#if !defined(_PCP_PMA521_H) -#define _PCP_PMA521_H - - -#include "pcpbn.h" -//#include "pcppmafix.h" - - -/* length of operand in bits and BNU32_CHUNK_T */ -#define OPERAND_BITSIZE (521) -#define LEN_P521 (BITS_BNU_CHUNK(OPERAND_BITSIZE)) - -/* -// Modular Arithmetic for secp521r1 ECC -*/ -void cpAdde_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSube_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); -void cpSqre_521r1(IppsBigNumState* pA, IppsBigNumState* pR); -void cpMule_521r1(IppsBigNumState* pA, IppsBigNumState* pB, IppsBigNumState* pR); - -#define PMA521_add(r,a,b) \ - cpAdde_521r1((a),(b), (r)) - -#define PMA521_sub(r,a,b) \ - cpSube_521r1((a),(b), (r)) - -#define PMA521_sqr(r,a) \ - cpSqre_521r1((a),(r)) - -#define PMA521_mul(r,a,b) \ - cpMule_521r1((a),(b), (r)) - -#define PMA521_div2(r,a) \ -{ \ - if( IsOdd_BN((a)) ) { \ - cpInc_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P521, 1); \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((r)), LEN_P521, 1); \ - cpAdd_BNU(BN_NUMBER((r)), BN_NUMBER((r)), (BNU_CHUNK_T*)h_secp521r1_p, LEN_P521); \ - } \ - else \ - cpLSR_BNU(BN_NUMBER((r)), BN_NUMBER((a)), LEN_P521, 1); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P521; \ -} - -#define PMA521_inv(r,a,modulo) \ -{ \ - ippsModInv_BN((a),(modulo),(r)); \ - ZEXPAND_BNU(BN_NUMBER((r)),BN_SIZE((r)), LEN_P521); \ - BN_SIGN((r)) = ippBigNumPOS; \ - BN_SIZE((r)) = LEN_P521; \ -} - -#endif /* _PCP_PMA521_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppmasm2.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppmasm2.c deleted file mode 100644 index 28ebf80f83..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcppmasm2.c +++ /dev/null @@ -1,311 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Prime Modulo Arithmetic Function -// -// -*/ - -#include "precomp.h" -#include "owncp.h" - -#if (_ECP_SM2_==_ECP_IMPL_SPECIFIC_) -#include "pcpeccp.h" -#include "pcppmasm2.h" - - -/* -// Specific Modulo Arithmetic -// P256 = 2^256 -2^224 -2^96 +2^64 -1 -// (reference tpmSM2_p256_p) -*/ - -/* -// Reduce modulo: -// -// x = c15|c14|c13|c12|c11|c10|c09|c08|c07|c06|c05|c04|c03|c02|c01|c00 - 32-bits values -// -// r7 r6 r5 r4 r3 r2 r1 r0 -// c08 deposit: | c08 | 000 | 000 | 000 | c08 |-c08 | 000 | c08 | -// c09 deposit: | c09 | 000 | 000 | c09 | 000 |-c09 | c09 | c09 | -// c10 deposit: | c10 | 000 | c10 | 000 | 000 | 000 | c10 | c10 | -// c11 deposit: | c11 | c11 | 000 | 000 | c11 | 000 | c11 | c11 | -// c12 deposit: |2*c12| 000 | 000 | c12 | c12 | 000 | c12 | c12 | -// c13 deposit: |2*c13| 000 | c13 | c13 |2*c13|-c13 | c13 |2*c13| -// c14 deposit: |2*c14| c14 | c14 |2*c14| c14 |-c14 |2*c14|2*c14| -// c15 deposit: |3*c15| c15 |2*c15| c15 | c15 | 000 |2*c15|2*c15| -// -*/ -//#if !((_IPP==_IPP_W7) || (_IPP==_IPP_T7) || \ -// (_IPP==_IPP_V8) || (_IPP==_IPP_P8) || \ -// (_IPPLP32==_IPPLP32_S8) || (_IPP>=_IPP_G9) ) -#if (_IPP < _IPP_W7) -void Reduce_SM2(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - Ipp64u t0 = (Ipp64u)pR[ 8] + pR[ 9] + pR[10] + pR[11] + pR[12]; - Ipp64u w0 = (Ipp64u)pR[13] +pR[14] + pR[15]; - Ipp64u u0 = w0<<1; - - Ipp64s - sum = (Ipp64u)pR[ 0] +t0 + u0; - pR[0] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 1] +(t0-pR[8]) +(u0-pR[13]); - pR[1] = LODWORD(sum); - sum >>= 32; - - //sum += (Ipp64u)pR[ 2] - (pR[8]+pR[9]) - (w0-pR[15]); - sum += (Ipp64u)pR[ 2] - pR[8] -pR[9] - (w0-pR[15]); - pR[2] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 3] +pR[ 8] +pR[11] +pR[12] +(w0+pR[13]); - pR[3] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 4] +pR[ 9] + pR[12] + (w0+pR[14]); - pR[4] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 5] +pR[10] +(w0+pR[15]); - pR[5] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 6] +pR[11] + (w0-pR[13]); - pR[6] = LODWORD(sum); - sum >>= 32; - - sum += (Ipp64u)pR[ 7] + (t0+pR[12]) + (u0+pR[15]); - pR[7] = LODWORD(sum); - sum >>= 32; - pProduct[LEN_P256] = (BNU_CHUNK_T)(sum); - - while(((BNS_CHUNK_T)pProduct[LEN_P256]) <0) - cpAdd_BNU(pProduct, pProduct, (BNU_CHUNK_T*)tpmSM2_p256_p, LEN_P256+1); - - while(0 <= cpCmp_BNU(pProduct, LEN_P256+1, (BNU_CHUNK_T*)tpmSM2_p256_p, LEN_P256+1)) - cpSub_BNU(pProduct, pProduct, (BNU_CHUNK_T*)tpmSM2_p256_p, LEN_P256+1); -} - -#else -#if 0 -void Reduce_SM2(BNU_CHUNK_T* pProduct) -{ - Ipp32u* pR = (Ipp32u*)pProduct; - - __m64 s8 = _mm_cvtsi32_si64((Ipp32s)pR[8]); - __m64 s9 = _mm_cvtsi32_si64((Ipp32s)pR[9]); - __m64 s10 = _mm_cvtsi32_si64((Ipp32s)pR[10]); - __m64 s11 = _mm_cvtsi32_si64((Ipp32s)pR[11]); - __m64 s12 = _mm_cvtsi32_si64((Ipp32s)pR[12]); - __m64 s13 = _mm_cvtsi32_si64((Ipp32s)pR[13]); - __m64 s14 = _mm_cvtsi32_si64((Ipp32s)pR[14]); - __m64 s15 = _mm_cvtsi32_si64((Ipp32s)pR[15]); - - __m64 w0 = _mm_add_si64(s13, - _mm_add_si64(s14, s15)); - __m64 t0 = _mm_add_si64(s8, - _mm_add_si64(s9, - _mm_add_si64(s10, - _mm_add_si64(s11, - _mm_add_si64(s12, - _mm_add_si64(w0, w0)))))); - - __m64 - // sum = pR[ 0] +t0 + u0 - sum = _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[0]), t0); - pR[0] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 1] +(t0-pR[8]) +(u0-pR[13]) - sum = _mm_sub_si64( - _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[1]), - _mm_add_si64(sum, t0)), - _mm_add_si64(s8, s13)); - pR[1] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 2] - pR[8] -pR[9] - (w0-pR[15]) - sum = _mm_sub_si64( - _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[2]), - _mm_add_si64(sum, s15)), - _mm_add_si64(s8, - _mm_add_si64(s9, w0))); - pR[2] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 3] +pR[ 8] +pR[11] +pR[12] +(w0+pR[13]); - sum = _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[3]), - _mm_add_si64(sum, - _mm_add_si64(s8, - _mm_add_si64(s11, - _mm_add_si64(s12, - _mm_add_si64(w0, s13)))))); - pR[3] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 4] +pR[ 9] + pR[12] + (w0+pR[14]); - sum = _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[4]), - _mm_add_si64(sum, - _mm_add_si64(s9, - _mm_add_si64(s12, - _mm_add_si64(w0, s14))))); - pR[4] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 5] +pR[10] +(w0+pR[15]); - sum = _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[5]), - _mm_add_si64(sum, - _mm_add_si64(s10, - _mm_add_si64(w0, s15)))); - pR[5] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 6] +pR[11] + (w0-pR[13]); - sum = _mm_sub_si64( - _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[6]), - _mm_add_si64(sum, - _mm_add_si64(s11, w0))), - s13); - pR[6] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - - // sum += pR[ 7] + (t0+pR[12]) + (u0+pR[15]); - sum = _mm_add_si64(_mm_cvtsi32_si64((Ipp32s)pR[7]), - _mm_add_si64(sum, - _mm_add_si64(t0, - _mm_add_si64(s12, s15)))); - pR[7] = (Ipp32u)( _mm_cvtsi64_si32(sum) ); - sum = _mm_shuffle_pi16(sum, 0xfe); - pProduct[LEN_P256] = (BNS_CHUNK_T)( _mm_cvtsi64_si32(sum) ); - - { - int n; - const Ipp32u* pMx; - - // reduce multiple modulus - if( pProduct[LEN_P256] ) { - pMx = tpmSM2_p256_p_mx[ pProduct[LEN_P256] ]; - sum = _mm_setzero_si64(); - for(n=0; nidCtx) -#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/epid/ext/ipp/sources/ippcp/src/pcpprimeginitca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprimeginitca.c deleted file mode 100644 index 9689d834d8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprimeginitca.c +++ /dev/null @@ -1,158 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives. Cryptographic Primitives (ippcp) -// Prime Number Primitives. -// -// Contents: -// ippsPrimeGetSize() -// ippsPrimeInit() -// -// -*/ - -#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; - } -} - - -void cpPackPrimeCtx(const IppsPrimeState* pCtx, Ipp8u* pBuffer) -{ - IppsPrimeState* pAlignedBuffer = (IppsPrimeState*)( IPP_ALIGNED_PTR(pBuffer, PRIME_ALIGNMENT) ); - - /* max length of prime */ - cpSize nsPrime = BITS_BNU_CHUNK(PRIME_MAXBITSIZE(pCtx)); - - CopyBlock(pCtx, pAlignedBuffer, sizeof(IppsPrimeState)); - PRIME_NUMBER(pAlignedBuffer)= (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(PRIME_NUMBER(pCtx))-IPP_UINT_PTR(pCtx)); - PRIME_TEMP1(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(PRIME_TEMP1(pCtx))-IPP_UINT_PTR(pCtx)); - PRIME_TEMP2(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(PRIME_TEMP2(pCtx))-IPP_UINT_PTR(pCtx)); - PRIME_TEMP3(pAlignedBuffer) = (BNU_CHUNK_T*)((Ipp8u*)NULL + IPP_UINT_PTR(PRIME_TEMP3(pCtx))-IPP_UINT_PTR(pCtx)); - PRIME_MONT(pAlignedBuffer) =(IppsMontState*)((Ipp8u*)NULL + IPP_UINT_PTR(PRIME_MONT(pCtx))-IPP_UINT_PTR(pCtx)); - - CopyBlock(PRIME_NUMBER(pCtx), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(PRIME_NUMBER(pAlignedBuffer)), nsPrime*sizeof(BNU_CHUNK_T)); - cpPackMontCtx(PRIME_MONT(pCtx), (Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(PRIME_MONT(pAlignedBuffer))); -} - -void cpUnpackPrimeCtx(const Ipp8u* pBuffer, IppsPrimeState* pCtx) -{ - IppsPrimeState* pAlignedBuffer = (IppsPrimeState*)( IPP_ALIGNED_PTR(pBuffer, PRIME_ALIGNMENT) ); - - /* max length of prime */ - cpSize nsPrime = BITS_BNU_CHUNK(PRIME_MAXBITSIZE(pAlignedBuffer)); - - CopyBlock(pAlignedBuffer, pCtx, sizeof(IppsPrimeState)); - PRIME_NUMBER(pCtx)= (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(PRIME_NUMBER(pAlignedBuffer))); - PRIME_TEMP1(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(PRIME_TEMP1(pAlignedBuffer))); - PRIME_TEMP2(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(PRIME_TEMP2(pAlignedBuffer))); - PRIME_TEMP3(pCtx) = (BNU_CHUNK_T*)((Ipp8u*)pCtx+ IPP_UINT_PTR(PRIME_TEMP3(pAlignedBuffer))); - PRIME_MONT(pCtx) = (IppsMontState*)((Ipp8u*)pCtx+ IPP_UINT_PTR(PRIME_MONT(pAlignedBuffer))); - - CopyBlock((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(PRIME_NUMBER(pAlignedBuffer)), PRIME_NUMBER(pCtx), nsPrime*sizeof(BNU_CHUNK_T)); - cpUnpackMontCtx((Ipp8u*)pAlignedBuffer+IPP_UINT_PTR(PRIME_MONT(pAlignedBuffer)), PRIME_MONT(pCtx)); -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprng.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprng.h deleted file mode 100644 index 4d236ae39d..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprng.h +++ /dev/null @@ -1,59 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions and -// Internal Pseudo Random Generator Function Prototypes -// -*/ - -#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/epid/ext/ipp/sources/ippcp/src/pcpprngenca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprngenca.c deleted file mode 100644 index e3204f7221..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprngenca.c +++ /dev/null @@ -1,251 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// PRNG Functions -// -// Contents: -// ippsPRNGen() -// ippsPRNGen_BN() -// -// -*/ - -#include "precomp.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 */ -#if 0 - cpHashProc updateFunc = UpdateSHA1; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA1ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - else - #endif - updateFunc = UpdateSHA1; - #endif - - /* 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; - } -} - - -/*F* -// Name: ippsPRNGen_BN -// -// Purpose: Generates a pseudorandom big number of the specified nBits length. -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pRandBN -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pRandBN->idCtx -// -// ippStsLengthErr 1 > nBits -// nBits > BN_ROOM(pRandBN) -// -// ippStsNoErr no error -// -// Parameters: -// pRandBN pointer to the BN random -// nBits number of bits be requested -// pRndCtx pointer to the context -*F*/ -IPPFUN(IppStatus, ippsPRNGen_BN,(IppsBigNumState* pRandBN, int nBits, void* pRnd)) -{ - IppsPRNGState* pRndCtx; - - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRndCtx = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRndCtx), ippStsContextMatchErr); - - /* test random BN */ - IPP_BAD_PTR1_RET(pRandBN); - pRandBN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pRandBN, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pRandBN), ippStsContextMatchErr); - - /* test sizes */ - IPP_BADARG_RET(nBits< 1, ippStsLengthErr); - IPP_BADARG_RET(nBits> BN_ROOM(pRandBN)*BNU_CHUNK_BITS, ippStsLengthErr); - - - { - BNU_CHUNK_T* pRand = BN_NUMBER(pRandBN); - cpSize rndSize = BITS_BNU_CHUNK(nBits); - BNU_CHUNK_T rndMask = MASK_BNU_CHUNK(nBits); - - cpPRNGen((Ipp32u*)pRand, nBits, pRndCtx); - pRand[rndSize-1] &= rndMask; - - FIX_BNU(pRand, rndSize); - BN_SIZE(pRandBN) = rndSize; - BN_SIGN(pRandBN) = ippBigNumPOS; - - return ippStsNoErr; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprnginitca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprnginitca.c deleted file mode 100644 index cf52eb0d48..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprnginitca.c +++ /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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// PRNG Functions -// -// Contents: -// ippsPRNGGetSize() -// ippsPRNGInit() -// -// -*/ - -#include "precomp.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/epid/ext/ipp/sources/ippcp/src/pcpprngsetca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprngsetca.c deleted file mode 100644 index f57c2e20b6..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpprngsetca.c +++ /dev/null @@ -1,239 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// PRNG Functions -// -// Contents: -// ippsPRNGSetModulus() -// ippsPRNGSetSeed() -// ippsPRNGSetAugment() -// ippsPRNGSetH0() -// -// -*/ - -#include "precomp.h" - -#include "owncp.h" -#include "pcpbn.h" -#include "pcpprng.h" - - -/*F* -// Name: ippsPRNGSetModulus -// -// Purpose: Sets 160-bit modulus Q. -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pMod -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pMod->idCtx -// -// ippStsBadArgErr 160 != bitsize(pMOd) -// -// ippStsNoErr no error -// -// Parameters: -// pMod pointer to the 160-bit modulus -// pRnd pointer to the context -*F*/ -IPPFUN(IppStatus, ippsPRNGSetModulus, (const IppsBigNumState* pMod, IppsPRNGState* pRnd)) -{ - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr); - - /* test modulus */ - IPP_BAD_PTR1_RET(pMod); - pMod = (IppsBigNumState*)( IPP_ALIGNED_PTR(pMod, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pMod), ippStsContextMatchErr); - IPP_BADARG_RET(160 != BITSIZE_BNU(BN_NUMBER(pMod),BN_SIZE(pMod)), ippStsBadArgErr); - - ZEXPAND_COPY_BNU(RAND_Q(pRnd), (int)(sizeof(RAND_Q(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pMod), BN_SIZE(pMod)); - return ippStsNoErr; -} - - -/*F* -// Name: ippsPRNGSetH0 -// -// Purpose: Sets 160-bit parameter of G() function. -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pH0 -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pH0->idCtx -// -// ippStsNoErr no error -// -// Parameters: -// pH0 pointer to the parameter used into G() function -// pRnd pointer to the context -*F*/ -IPPFUN(IppStatus, ippsPRNGSetH0,(const IppsBigNumState* pH0, IppsPRNGState* pRnd)) -{ - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr); - - /* test H0 */ - IPP_BAD_PTR1_RET(pH0); - pH0 = (IppsBigNumState*)( IPP_ALIGNED_PTR(pH0, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pH0), ippStsContextMatchErr); - - { - cpSize len = IPP_MIN(5, BN_SIZE(pH0)*(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u))); - ZEXPAND_BNU(RAND_T(pRnd), 0, (int)(sizeof(RAND_T(pRnd))/sizeof(BNU_CHUNK_T))); - ZEXPAND_COPY_BNU((Ipp32u*)RAND_T(pRnd), (int)(sizeof(RAND_T(pRnd))/sizeof(Ipp32u)), - (Ipp32u*)BN_NUMBER(pH0), len); - return ippStsNoErr; - } -} - - -/*F* -// Name: ippsPRNGSetSeed -// -// Purpose: Sets the initial state with the SEED value -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pSeed -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pSeed->idCtx -// -// ippStsNoErr no error -// -// Parameters: -// pSeed pointer to the SEED -// pRnd pointer to the context -*F*/ -IPPFUN(IppStatus, ippsPRNGSetSeed, (const IppsBigNumState* pSeed, IppsPRNGState* pRnd)) -{ - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr); - - /* test seed */ - IPP_BAD_PTR1_RET(pSeed); - pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr); - - { - cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pRnd) ); - BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd)); - cpSize size = IPP_MIN(BN_SIZE(pSeed), argSize); - - ZEXPAND_COPY_BNU(RAND_XKEY(pRnd), (cpSize)(sizeof(RAND_XKEY(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pSeed), size); - RAND_XKEY(pRnd)[argSize-1] &= mask; - - return ippStsNoErr; - } -} - - -/*F* -// Name: ippsPRNGSetAugment -// -// Purpose: Sets the Entropy Augmentation -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pAug -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pAug->idCtx -// -// ippStsLengthErr nBits < 1 -// nBits > MAX_XKEY_SIZE -// ippStsNoErr no error -// -// Parameters: -// pAug pointer to the entropy eugmentation -// pRnd pointer to the context -*F*/ -IPPFUN(IppStatus, ippsPRNGSetAugment, (const IppsBigNumState* pAug, IppsPRNGState* pRnd)) -{ - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr); - - /* test augmentation */ - IPP_BAD_PTR1_RET(pAug); - pAug = (IppsBigNumState*)( IPP_ALIGNED_PTR(pAug, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pAug), ippStsContextMatchErr); - - { - cpSize argSize = BITS_BNU_CHUNK( RAND_SEEDBITS(pRnd) ); - BNU_CHUNK_T mask = MASK_BNU_CHUNK(RAND_SEEDBITS(pRnd)); - cpSize size = IPP_MIN(BN_SIZE(pAug), argSize); - - ZEXPAND_COPY_BNU(RAND_XAUGMENT(pRnd), (cpSize)(sizeof(RAND_XAUGMENT(pRnd))/sizeof(BNU_CHUNK_T)), BN_NUMBER(pAug), size); - RAND_XAUGMENT(pRnd)[argSize-1] &= mask; - - return ippStsNoErr; - } -} - -/*F* -// Name: ippsPRNGGetSeed -// -// Purpose: Get current SEED value from the state -// -// Returns: Reason: -// ippStsNullPtrErr NULL == pRnd -// NULL == pSeed -// -// ippStsContextMatchErr illegal pRnd->idCtx -// illegal pSeed->idCtx -// ippStsOutOfRangeErr lengtrh of the actual SEED > length SEED destination -// -// ippStsNoErr no error -// -// Parameters: -// pRnd pointer to the context -// pSeed pointer to the SEED -*F*/ -IPPFUN(IppStatus, ippsPRNGGetSeed, (const IppsPRNGState* pRnd, IppsBigNumState* pSeed)) -{ - /* test PRNG context */ - IPP_BAD_PTR1_RET(pRnd); - pRnd = (IppsPRNGState*)( IPP_ALIGNED_PTR(pRnd, PRNG_ALIGNMENT) ); - IPP_BADARG_RET(!RAND_VALID_ID(pRnd), ippStsContextMatchErr); - - /* test seed */ - IPP_BAD_PTR1_RET(pSeed); - pSeed = (IppsBigNumState*)( IPP_ALIGNED_PTR(pSeed, BN_ALIGNMENT) ); - IPP_BADARG_RET(!BN_VALID_ID(pSeed), ippStsContextMatchErr); - - return ippsSet_BN(ippBigNumPOS, - BITS2WORD32_SIZE(RAND_SEEDBITS(pRnd)), - (Ipp32u*)RAND_XKEY(pRnd), - pSeed); -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha1ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha1ca.c deleted file mode 100644 index 81d28a1f31..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha1ca.c +++ /dev/null @@ -1,551 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Digesting message according to SHA1 -// -// Contents: -// - ippsSHA1GetSize() -// - ippsSHA1Init() -// - ippsSHA1Pack() -// - ippsSHA1Unpack() -// - ippsSHA1Duplicate() -// - ippsSHA1Update() -// - ippsSHA1GetTag() -// - ippsSHA1Final() -// ippsSHA1MessageDigest() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - - -#if !defined (_ENABLE_ALG_SHA1_) -#pragma message("IPP_ALG_HASH_SHA1 disabled") -#else -#pragma message("IPP_ALG_HASH_SHA1 enabled") - -/* -// Init SHA1 digest -*/ -IppStatus InitSHA1(IppsSHA1State* pState) -{ - /* test state pointer */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) ); - - /* set state ID */ - SHS_ID(pState) = idCtxSHA1; - - /* zeros message length */ - SHS_LENL(pState) = 0; - - /* message buffer is free */ - SHS_INDX(pState) = 0; - - /* setup initial digest */ - SHS_HASH(pState)[0] = SHA1_IV[0]; - SHS_HASH(pState)[1] = SHA1_IV[1]; - SHS_HASH(pState)[2] = SHA1_IV[2]; - SHS_HASH(pState)[3] = SHA1_IV[3]; - SHS_HASH(pState)[4] = SHA1_IV[4]; - - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1GetSize -// -// Purpose: Returns size (bytes) of IppsSHA1State state. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// ippStsNoErr no errors -// -// Parameters: -// pSize pointer to state size -// -*F*/ -IPPFUN(IppStatus, ippsSHA1GetSize,(int* pSize)) -{ - /* test pointer */ - IPP_BAD_PTR1_RET(pSize); - - *pSize = sizeof(IppsSHA1State) +(SHA1_ALIGNMENT-1); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1Init -// -// Purpose: Init SHA1 state. -// -// Returns: Reason: -// ippStsNullPtrErr pState == NULL -// ippStsNoErr no errors -// -// Parameters: -// pState pointer to the SHA1 state -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Init,(IppsSHA1State* pState)) -{ - return InitSHA1(pState); -} - - -/*F* -// Name: ippsSHA1Pack -// -// Purpose: Copy initialized context to the buffer. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hach state -// pSize pointer to the packed spec size -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Pack,(const IppsSHA1State* pCtx, Ipp8u* pBuffer)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA1State*)( IPP_ALIGNED_PTR(pCtx, SHA1_ALIGNMENT) ); - /* test the context */ - IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pCtx), ippStsContextMatchErr); - - CopyBlock(pCtx, pBuffer, sizeof(IppsSHA1State)); - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1Unpack -// -// Purpose: Unpack buffer content into the initialized context. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Unpack,(const Ipp8u* pBuffer, IppsSHA1State* pCtx)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA1State*)( IPP_ALIGNED_PTR(pCtx, SHA1_ALIGNMENT) ); - - CopyBlock(pBuffer, pCtx, sizeof(IppsSHA1State)); - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1Duplicate -// -// Purpose: Clone SHA1 state. -// -// Returns: Reason: -// ippStsNullPtrErr pSrcState == NULL -// pDstState == NULL -// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA1 -// pDstState->idCtx != idCtxSHA1 -// ippStsNoErr no errors -// -// Parameters: -// pSrcState pointer to the source SHA1 state -// pDstState pointer to the target SHA1 state -// -// Note: -// pDstState may to be uninitialized by ippsSHA1Init() -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Duplicate,(const IppsSHA1State* pSrcState, IppsSHA1State* pDstState)) -{ - /* test state pointers */ - IPP_BAD_PTR2_RET(pSrcState, pDstState); - /* use aligned context */ - pSrcState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pSrcState, SHA1_ALIGNMENT) ); - pDstState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pDstState, SHA1_ALIGNMENT) ); - /* test states ID */ - IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pSrcState), ippStsContextMatchErr); - //IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pDstState), ippStsContextMatchErr); - - /* copy state */ - CopyBlock(pSrcState, pDstState, sizeof(IppsSHA1State)); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1Update -// -// Purpose: Updates intermadiate digest based on input stream. -// -// Returns: Reason: -// ippStsNullPtrErr pSrc == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA1 -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pSrc pointer to the input stream -// len input stream length -// pState pointer to the SHA1 state -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Update,(const Ipp8u* pSrc, int len, IppsSHA1State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test input length */ - IPP_BADARG_RET((len<0), ippStsLengthErr); - /* test source pointer */ - IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); - - /* - // handle non empty message - */ - if(len) { - int processingLen; - - int n = SHS_INDX(pState); - Ipp8u* pBuffer = SHS_BUFF(pState); - Ipp8u* pHash = (Ipp8u*)SHS_HASH(pState); - - Ipp64u lenLo = SHS_LENL(pState); - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA1; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA1ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - else - #endif - updateFunc = UpdateSHA1; - #endif - - lenLo += len; - - /* if non empty internal buffer filling */ - if(n) { - /* copy from input stream to the internal buffer as match as possible */ - processingLen = IPP_MIN(len, (MBS_SHA1-n)); - CopyBlock(pSrc, pBuffer+n, processingLen); - - pSrc += processingLen; - len -= processingLen; - SHS_INDX(pState) = n += processingLen; - - /* update digest if buffer full */ - if( MBS_SHA1 == n) { - updateFunc(pHash, pBuffer, MBS_SHA1, SHA1_cnt); - SHS_INDX(pState) = 0; - } - } - - /* main message part processing */ - processingLen = len & ~(MBS_SHA1-1); - if(processingLen) { - updateFunc(pHash, pSrc, processingLen, SHA1_cnt); - pSrc += processingLen; - len -= processingLen; - } - - /* store rest of message into the internal buffer */ - if(len) { - CopyBlock(pSrc, pBuffer, len); - SHS_INDX(pState) += len; - } - - SHS_LENL(pState) = lenLo; - } - - return ippStsNoErr; -} - - -/* -// Compute digest -*/ -void ComputeDigestSHA1(Ipp32u* pHash, const IppsSHA1State* pState) -{ - const Ipp8u* stateBuff = SHS_BUFF(pState); - int stateBuffLen = SHS_INDX(pState); - - /* local buffer and it length */ - Ipp8u buffer[MBS_SHA1*2]; - int bufferLen = stateBuffLen < (MBS_SHA1-(int)sizeof(Ipp64u))? MBS_SHA1 : MBS_SHA1*2; - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA1; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA1ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - else - #endif - updateFunc = UpdateSHA1; - #endif - - /* copy rest of message into internal buffer */ - CopyBlock(stateBuff, buffer, stateBuffLen); - - /* padd message */ - buffer[stateBuffLen++] = 0x80; - PaddBlock(0, buffer+stateBuffLen, bufferLen-stateBuffLen-sizeof(Ipp64u)); - - /* message length representation */ - { - Ipp64u lo = SHS_LENL(pState); /* message length in bytes */ - lo = LSL64(lo,3); /* message length in bits */ - ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo); - } - - /* copmplete hash computation */ - updateFunc(pHash, buffer, bufferLen, SHA1_cnt); - - /* convert hash into big endian */ - pHash[0] = ENDIANNESS32(pHash[0]); - pHash[1] = ENDIANNESS32(pHash[1]); - pHash[2] = ENDIANNESS32(pHash[2]); - pHash[3] = ENDIANNESS32(pHash[3]); - pHash[4] = ENDIANNESS32(pHash[4]); -} - - -/*F* -// Name: ippsSHA1GetTag -// -// Purpose: Compute digest based on current state. -// Note, that futher digest update is possible -// -// Returns: Reason: -// ippStsNullPtrErr pTag == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA1 -// ippStsLengthErr max_SHA_digestLen < tagLen <1 -// ippStsNoErr no errors -// -// Parameters: -// pTag address of the output digest -// tagLen length of digest -// pState pointer to the SHS state -// -*F*/ -IPPFUN(IppStatus, ippsSHA1GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA1State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pTag); - IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA1)idCtx != idCtxSHA1 -// ippStsNoErr no errors -// -// Parameters: -// pMD address of the output digest -// pState pointer to the SHS state -// -*F*/ -IPPFUN(IppStatus, ippsSHA1Final,(Ipp8u* pMD, IppsSHA1State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA1State*)( IPP_ALIGNED_PTR(pState, SHA1_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA1 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestSHA1(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestSHA1)); - InitSHA1(pState); - - return ippStsNoErr; -} - - -/*F* -// Name: ippsSHA1MessageDigest -// -// Purpose: Digest of the whole message. -// -// Returns: Reason: -// ippStsNullPtrErr pMsg == NULL -// pMD == NULL -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pMsg pointer to the input message -// len input message length -// pMD address of the output digest -// -*F*/ -IPPFUN(IppStatus, ippsSHA1MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* 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); - - { - /* message length in the multiple MBS and the rest */ - int msgLenBlks = msgLen & (-MBS_SHA1); - int msgLenRest = msgLen - msgLenBlks; - - /* init hash value */ - DigestSHA1 hash = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0}; - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA1; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA1ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA1ni; - else - #endif - updateFunc = UpdateSHA1; - #endif - - /* process main part of the message */ - if(msgLenBlks) - updateFunc(hash, pMsg, msgLenBlks, SHA1_cnt); - - /* process message padding */ - { - #define MREP_SIZE_SHA1 (sizeof(Ipp64u)) - Ipp8u buffer[MBS_SHA1*2]; - int bufferLen = msgLenRest < (int)(MBS_SHA1-MREP_SIZE_SHA1)? MBS_SHA1 : MBS_SHA1*2; - - /* message bitlength representation */ - Ipp64u msgLenBits = (Ipp64u)msgLen*8; - msgLenBits = ENDIANNESS64(msgLenBits); - - /* 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-MREP_SIZE_SHA1); - /* copy message bitlength representation */ - ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits; - - updateFunc(hash, buffer, bufferLen, SHA1_cnt); - #undef MREP_SIZE_SHA1 - } - - /* swap hash bytes */ - ((Ipp32u*)pMD)[0] = ENDIANNESS32(hash[0]); - ((Ipp32u*)pMD)[1] = ENDIANNESS32(hash[1]); - ((Ipp32u*)pMD)[2] = ENDIANNESS32(hash[2]); - ((Ipp32u*)pMD)[3] = ENDIANNESS32(hash[3]); - ((Ipp32u*)pMD)[4] = ENDIANNESS32(hash[4]); - - return ippStsNoErr; - } -} - -#endif /* _ENABLE_ALG_SHA1_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha256ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha256ca.c deleted file mode 100644 index ae20f91d75..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha256ca.c +++ /dev/null @@ -1,728 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Digesting message according to SHA256 -// -// Contents: -// ippsSHA256GetSize() -// ippsSHA256Init() -// ippsSHA256Pack() -// ippsSHA256Unpack() -// ippsSHA256Duplicate() -// ippsSHA256Update() -// ippsSHA256GetTag() -// ippsSHA256Final() -// ippsSHA256MessageDigest() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - - -#if !defined(_ENABLE_ALG_SHA256_) -#pragma message("IPP_ALG_HASH_SHA256 disabled") -#else -#pragma message("IPP_ALG_HASH_SHA256 enabled") -#endif - -#if !defined(_ENABLE_ALG_SHA224_) -#pragma message("IPP_ALG_HASH_SHA224 disabled") -#else -#pragma message("IPP_ALG_HASH_SHA224 enabled") -#endif - - -/* -// SHA256 init context -*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IppStatus GetSizeSHA256(int* pSize) -{ - /* test pointer */ - IPP_BAD_PTR1_RET(pSize); - - *pSize = sizeof(IppsSHA256State) +(SHA256_ALIGNMENT-1); - - return ippStsNoErr; -} - -IppStatus InitSHA256(const DigestSHA256 IV, IppsSHA256State* pState) -{ - /* test state pointer */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) ); - - /* set state ID */ - SHS_ID(pState) = idCtxSHA256; - - /* zeros message length */ - SHS_LENL(pState) = 0; - - /* message buffer is free */ - SHS_INDX(pState) = 0; - - /* setup initial digest */ - SHS_HASH(pState)[0] = IV[0]; - SHS_HASH(pState)[1] = IV[1]; - SHS_HASH(pState)[2] = IV[2]; - SHS_HASH(pState)[3] = IV[3]; - SHS_HASH(pState)[4] = IV[4]; - SHS_HASH(pState)[5] = IV[5]; - SHS_HASH(pState)[6] = IV[6]; - SHS_HASH(pState)[7] = IV[7]; - - return ippStsNoErr; -} -#endif - -/*F* -// Name: ippsSHA256GetSize -// ippsSHA224GetSize -// -// Purpose: Returns size (bytes) of IppsSHA256State state. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// ippStsNoErr no errors -// -// Parameters: -// pSize pointer to state size -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) -IPPFUN(IppStatus, ippsSHA256GetSize,(int* pSize)) -{ - return GetSizeSHA256(pSize); -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224GetSize,(int* pSize)) -{ - return GetSizeSHA256(pSize); -} -#endif - - -/*F* -// Name: ippsSHA256Init -// ippsSHA224Init -// -// Purpose: Init SHA256 -// -// Returns: Reason: -// ippStsNullPtrErr pState == NULL -// ippStsNoErr no errors -// -// Parameters: -// pState pointer to the SHA512 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) -IPPFUN(IppStatus, ippsSHA256Init,(IppsSHA256State* pState)) -{ - return InitSHA256(SHA256_IV, pState); -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Init,(IppsSHA224State* pState)) -{ - return InitSHA256(SHA224_IV, pState); -} -#endif - - -/*F* -// Name: ippsSHA256Pack -// ippsSHA224Pack -// -// Purpose: Copy initialized context to the buffer. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA256Pack,(const IppsSHA256State* pCtx, Ipp8u* pBuffer)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA256State*)( IPP_ALIGNED_PTR(pCtx, SHA256_ALIGNMENT) ); - /* test the context */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pCtx), ippStsContextMatchErr); - - CopyBlock(pCtx, pBuffer, sizeof(IppsSHA256State)); - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Pack,(const IppsSHA224State* pCtx, Ipp8u* pBuffer)) -{ - return ippsSHA256Pack(pCtx, pBuffer); -} -#endif - -/*F* -// Name: ippsSHA256Unpack -// ippsSHA224Unpack -// -// Purpose: Unpack buffer content into the initialized context. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA256Unpack,(const Ipp8u* pBuffer, IppsSHA256State* pCtx)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA256State*)( IPP_ALIGNED_PTR(pCtx, SHA256_ALIGNMENT) ); - - CopyBlock(pBuffer, pCtx, sizeof(IppsSHA256State)); - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Unpack,(const Ipp8u* pBuffer, IppsSHA224State* pCtx)) -{ - return ippsSHA256Unpack(pBuffer, pCtx); -} -#endif - - -/*F* -// Name: ippsSHA256Duplicate -// ippsSHA224Duplicate -// -// Purpose: Clone SHA256 state. -// -// Returns: Reason: -// ippStsNullPtrErr pSrcState == NULL -// pDstState == NULL -// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA256 -// pDstState->idCtx != idCtxSHA256 -// ippStsNoErr no errors -// -// Parameters: -// pSrcState pointer to the source SHA256 state -// pDstState pointer to the target SHA256 state -// -// Note: -// pDstState may to be uninitialized by ippsSHA256Init() -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA256Duplicate,(const IppsSHA256State* pSrcState, IppsSHA256State* pDstState)) -{ - /* test state pointers */ - IPP_BAD_PTR2_RET(pSrcState, pDstState); - /* use aligned context */ - pSrcState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pSrcState, SHA256_ALIGNMENT) ); - pDstState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pDstState, SHA256_ALIGNMENT) ); - /* test states ID */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pSrcState), ippStsContextMatchErr); - //IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pDstState), ippStsContextMatchErr); - - /* copy state */ - CopyBlock(pSrcState, pDstState, sizeof(IppsSHA256State)); - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Duplicate,(const IppsSHA224State* pSrcState, IppsSHA224State* pDstState)) -{ - return ippsSHA256Duplicate(pSrcState, pDstState); -} -#endif - - -/*F* -// Name: ippsSHA256Update -// ippsSHA224Update -// -// Purpose: Updates intermadiate digest based on input stream. -// -// Returns: Reason: -// ippStsNullPtrErr pSrc == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA256 -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pSrc pointer to the input stream -// len input stream length -// pState pointer to the SHA256 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA256Update,(const Ipp8u* pSrc, int len, IppsSHA256State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test input length */ - IPP_BADARG_RET((len<0), ippStsLengthErr); - /* test source pointer */ - IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); - - /* - // handle non empty message - */ - if(len) { - int processingLen; - - int n = SHS_INDX(pState); - Ipp8u* pBuffer = SHS_BUFF(pState); - Ipp8u* pHash = (Ipp8u*)SHS_HASH(pState); - - Ipp64u lenLo = SHS_LENL(pState); - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA256; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA256ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - else - #endif - updateFunc = UpdateSHA256; - #endif - - lenLo += len; - - /* if non empty internal buffer filling */ - if(n) { - /* copy from input stream to the internal buffer as match as possible */ - processingLen = IPP_MIN(len, (MBS_SHA256 - SHS_INDX(pState))); - CopyBlock(pSrc, pBuffer+n, processingLen); - - pSrc += processingLen; - len -= processingLen; - SHS_INDX(pState) = n += processingLen; - - /* update digest if buffer full */ - if( MBS_SHA256 == n) { - updateFunc(pHash, pBuffer, MBS_SHA256, SHA256_cnt); - SHS_INDX(pState) = 0; - } - } - - /* main message part processing */ - processingLen = len & ~(MBS_SHA256-1); - if(processingLen) { - updateFunc(pHash, pSrc, processingLen, SHA256_cnt); - pSrc += processingLen; - len -= processingLen; - } - - /* store rest of message into the internal buffer */ - if(len) { - CopyBlock(pSrc, pBuffer, len); - SHS_INDX(pState) += len; - } - - SHS_LENL(pState) = lenLo; - } - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Update,(const Ipp8u* pSrc, int len, IppsSHA224State* pState)) -{ - return ippsSHA256Update(pSrc, len, pState); -} -#endif - - -/* -// Compute digest -*/ -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -void ComputeDigestSHA256(Ipp32u* pHash, const IppsSHA256State* pState) -{ - const Ipp8u* stateBuff = SHS_BUFF(pState); - int stateBuffLen = SHS_INDX(pState); - - /* local buffer and it length */ - Ipp8u buffer[MBS_SHA256*2]; - int bufferLen = stateBuffLen < (MBS_SHA1-(int)sizeof(Ipp64u))? MBS_SHA256 : MBS_SHA256*2; - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA256; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA256ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - else - #endif - updateFunc = UpdateSHA256; - #endif - - /* copy rest of message into internal buffer */ - CopyBlock(stateBuff, buffer, stateBuffLen); - - /* padd message */ - buffer[stateBuffLen++] = 0x80; - PaddBlock(0, buffer+stateBuffLen, bufferLen-stateBuffLen-sizeof(Ipp64u)); - - /* message length representation */ - { - Ipp64u lo = SHS_LENL(pState); /* message length in bytes */ - lo = LSL64(lo,3); /* message length in bits */ - ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo); - } - - /* copmplete hash computation */ - updateFunc(pHash, buffer, bufferLen, SHA256_cnt); - - /* convert hash into big endian */ - pHash[0] = ENDIANNESS32(pHash[0]); - pHash[1] = ENDIANNESS32(pHash[1]); - pHash[2] = ENDIANNESS32(pHash[2]); - pHash[3] = ENDIANNESS32(pHash[3]); - pHash[4] = ENDIANNESS32(pHash[4]); - pHash[5] = ENDIANNESS32(pHash[5]); - pHash[6] = ENDIANNESS32(pHash[6]); - pHash[7] = ENDIANNESS32(pHash[7]); -} -#endif - - -/*F* -// Name: ippsSHA256GetTag -// ippsSHA224GetTag -// -// Purpose: Compute digest based on current state. -// Note, that futher digest update is possible -// -// Returns: Reason: -// ippStsNullPtrErr pTag == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA256 -// ippStsLengthErr max_SHA_digestLen < tagLen <1 -// ippStsNoErr no errors -// -// Parameters: -// pTag address of the output digest -// tagLen length of digest -// pState pointer to the SHS state -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) -IPPFUN(IppStatus, ippsSHA256GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA256State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pTag); - IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA256)idCtx != idCtxSHA256 -// ippStsNoErr no errors -// -// Parameters: -// pMD address of the output digest -// pState pointer to the SHA256 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) -IPPFUN(IppStatus, ippsSHA256Final,(Ipp8u* pMD, IppsSHA256State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA256State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestSHA256(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestSHA256)); - InitSHA256(SHA256_IV, pState); - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224Final,(Ipp8u* pMD, IppsSHA224State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA224State*)( IPP_ALIGNED_PTR(pState, SHA256_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA256 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestSHA256(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestSHA224)); - InitSHA256(SHA224_IV, pState); - - return ippStsNoErr; -} -#endif - - -#if defined (_ENABLE_ALG_SHA256_) || defined (_ENABLE_ALG_SHA224_) -IppStatus cpSHA256MessageDigest(DigestSHA256 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA256 IV) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(hash); - /* test message length */ - IPP_BADARG_RET((msgLen<0), ippStsLengthErr); - /* test message pointer */ - IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr); - - { - /* message length in the multiple MBS and the rest */ - int msgLenBlks = msgLen & (-MBS_SHA256); - int msgLenRest = msgLen - msgLenBlks; - - /* select processing function */ -#if 0 - cpHashProc updateFunc = UpdateSHA256; - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - #endif -#endif - cpHashProc updateFunc; - #if (_SHA_NI_ENABLING_==_FEATURE_ON_) - updateFunc = UpdateSHA256ni; - #else - #if (_SHA_NI_ENABLING_==_FEATURE_TICKTOCK_) - if( IsFeatureEnabled(SHA_NI_ENABLED) ) - updateFunc = UpdateSHA256ni; - else - #endif - updateFunc = UpdateSHA256; - #endif - - /* setup initial digest */ - hash[0] = IV[0]; - hash[1] = IV[1]; - hash[2] = IV[2]; - hash[3] = IV[3]; - hash[4] = IV[4]; - hash[5] = IV[5]; - hash[6] = IV[6]; - hash[7] = IV[7]; - - /* process main part of the message */ - if(msgLenBlks) - updateFunc(hash, pMsg, msgLenBlks, SHA256_cnt); - - /* process message padding */ - { - #define MREP_SIZE_SHA256 (sizeof(Ipp64u)) - Ipp8u buffer[MBS_SHA256*2]; - int bufferLen = msgLenRest < (int)(MBS_SHA256-MREP_SIZE_SHA256)? MBS_SHA256 : MBS_SHA256*2; - - /* message bitlength representation */ - Ipp64u msgLenBits = (Ipp64u)msgLen*8; - msgLenBits = ENDIANNESS64(msgLenBits); - - /* 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-MREP_SIZE_SHA256); - /* copy message bitlength representation */ - ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits; - - updateFunc(hash, buffer, bufferLen, SHA256_cnt); - #undef MREP_SIZE_SHA256 - } - - /* swap hash bytes */ - hash[0] = ENDIANNESS32(hash[0]); - hash[1] = ENDIANNESS32(hash[1]); - hash[2] = ENDIANNESS32(hash[2]); - hash[3] = ENDIANNESS32(hash[3]); - hash[4] = ENDIANNESS32(hash[4]); - hash[5] = ENDIANNESS32(hash[5]); - hash[6] = ENDIANNESS32(hash[6]); - hash[7] = ENDIANNESS32(hash[7]); - - return ippStsNoErr; - } -} -#endif - -/*F* -// Name: ippsSHA256MessageDigest, -// ippsSHA224MessageDigest -// -// Purpose: Digest of the whole message. -// -// Returns: Reason: -// ippStsNullPtrErr pMsg == NULL -// pDigest == NULL -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pMsg pointer to the input message -// len input message length -// pMD address of the output digest -// -*F*/ -#if defined (_ENABLE_ALG_SHA256_) -IPPFUN(IppStatus, ippsSHA256MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - { - DigestSHA256 hash; - IppStatus sts = cpSHA256MessageDigest(hash, pMsg, msgLen, SHA256_IV); - if(ippStsNoErr==sts) - CopyBlock(hash, pMD, IPP_SHA256_DIGEST_BITSIZE/BYTESIZE); - return sts; - } -} -#endif - -#if defined (_ENABLE_ALG_SHA224_) -IPPFUN(IppStatus, ippsSHA224MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - { - DigestSHA256 hash; - IppStatus sts = cpSHA256MessageDigest(hash, pMsg, msgLen, SHA224_IV); - if(ippStsNoErr==sts) - CopyBlock(hash, pMD, IPP_SHA224_DIGEST_BITSIZE/BYTESIZE); - return sts; - } -} -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha512ca.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha512ca.c deleted file mode 100644 index 8dcaab973c..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpsha512ca.c +++ /dev/null @@ -1,674 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// SHA512 message digest -// -// Contents: -// ippsSHA512GetSize() -// ippsSHA512Init() -// ippsSHA512Pack() -// ippsSHA512Unpack() -// ippsSHA512Duplicate() -// ippsSHA512Update() -// ippsSHA512GetTag() -// ippsSHA512Final() -// ippsSHA512MessageDigest() -// -// -*/ - -#include "precomp.h" -#include "owncp.h" -#include "pcphash.h" -#include "pcptool.h" - - -#if !defined(_ENABLE_ALG_SHA512_) -#pragma message("IPP_ALG_HASH_SHA512 disabled") -#else -#pragma message("IPP_ALG_HASH_SHA512 enabled") -#endif - -#if !defined(_ENABLE_ALG_SHA384_) -#pragma message("IPP_ALG_HASH_SHA384 disabled") -#else -#pragma message("IPP_ALG_HASH_SHA384 enabled") -#endif - - -/* -// SHA512 init context -*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IppStatus GetSizeSHA512(int* pSize) -{ - /* test pointer */ - IPP_BAD_PTR1_RET(pSize); - - *pSize = sizeof(IppsSHA512State) +(SHA512_ALIGNMENT-1); - - return ippStsNoErr; -} - -IppStatus InitSHA512(const DigestSHA512 IV, IppsSHA512State* pState) -{ - /* test state pointer */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) ); - - /* set state ID */ - SHS_ID(pState) = idCtxSHA512; - - /* zeros message length */ - SHS_LENL(pState) = 0; - SHS_LENH(pState) = 0; - - /* message buffer is free */ - SHS_INDX(pState) = 0; - - /* setup initial digest */ - SHS_HASH(pState)[0] = IV[0]; - SHS_HASH(pState)[1] = IV[1]; - SHS_HASH(pState)[2] = IV[2]; - SHS_HASH(pState)[3] = IV[3]; - SHS_HASH(pState)[4] = IV[4]; - SHS_HASH(pState)[5] = IV[5]; - SHS_HASH(pState)[6] = IV[6]; - SHS_HASH(pState)[7] = IV[7]; - - return ippStsNoErr; -} -#endif - -/*F* -// Name: ippsSHA512GetSize -// ippsSHA384GetSize -// -// Purpose: Returns size (bytes) of IppsSHA512State state. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// ippStsNoErr no errors -// -// Parameters: -// pSize pointer to state size -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) -IPPFUN(IppStatus, ippsSHA512GetSize,(int* pSize)) -{ - return GetSizeSHA512(pSize); -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384GetSize,(int* pSize)) -{ - return GetSizeSHA512(pSize); -} -#endif - - -/*F* -// Name: ippsSHA512Init -// ippsSHA384Init -// -// Purpose: Init SHA512 -// -// Returns: Reason: -// ippStsNullPtrErr pState == NULL -// ippStsNoErr no errors -// -// Parameters: -// pState pointer to the SHA512 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) -IPPFUN(IppStatus, ippsSHA512Init,(IppsSHA512State* pState)) -{ - return InitSHA512(SHA512_IV, pState); -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Init,(IppsSHA384State* pState)) -{ - return InitSHA512(SHA384_IV, pState); -} -#endif - - -/*F* -// Name: ippsSHA512Pack -// ippsSHA384Pack -// -// Purpose: Copy initialized context to the buffer. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA512Pack,(const IppsSHA512State* pCtx, Ipp8u* pBuffer)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA512State*)( IPP_ALIGNED_PTR(pCtx, SHA512_ALIGNMENT) ); - /* test the context */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pCtx), ippStsContextMatchErr); - - CopyBlock(pCtx, pBuffer, sizeof(IppsSHA512State)); - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Pack,(const IppsSHA384State* pCtx, Ipp8u* pBuffer)) -{ - return ippsSHA512Pack(pCtx, pBuffer); -} -#endif - - -/*F* -// Name: ippsSHA512Unpack -// ippsSHA384Unpack -// -// Purpose: Unpack buffer content into the initialized context. -// -// Returns: Reason: -// ippStsNullPtrErr pSize == NULL -// pCtx == NULL -// ippStsNoErr no errors -// -// Parameters: -// pCtx pointer hash state -// pSize pointer to the packed spec size -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA512Unpack,(const Ipp8u* pBuffer, IppsSHA512State* pCtx)) -{ - /* test pointers */ - IPP_BAD_PTR2_RET(pCtx, pBuffer); - /* use aligned context */ - pCtx = (IppsSHA512State*)( IPP_ALIGNED_PTR(pCtx, SHA512_ALIGNMENT) ); - - CopyBlock(pBuffer, pCtx, sizeof(IppsSHA512State)); - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Unpack,(const Ipp8u* pBuffer, IppsSHA384State* pCtx)) -{ - return ippsSHA512Unpack(pBuffer, pCtx); -} -#endif - - -/*F* -// Name: ippsSHA512Duplicate -// ippsSHA384Duplicate -// -// Purpose: Clone SHA512 state. -// -// Returns: Reason: -// ippStsNullPtrErr pSrcState == NULL -// pDstState == NULL -// ippStsContextMatchErr pSrcState->idCtx != idCtxSHA512 -// pDstState->idCtx != idCtxSHA512 -// ippStsNoErr no errors -// -// Parameters: -// pSrcState pointer to the source SHA512 state -// pDstState pointer to the target SHA512 state -// Note: -// pDstState may to be uninitialized by ippsSHA512Init() -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA512Duplicate,(const IppsSHA512State* pSrcState, IppsSHA512State* pDstState)) -{ - /* test state pointers */ - IPP_BAD_PTR2_RET(pSrcState, pDstState); - /* use aligned context */ - pSrcState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pSrcState, SHA512_ALIGNMENT) ); - pDstState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pDstState, SHA512_ALIGNMENT) ); - /* test states ID */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pSrcState), ippStsContextMatchErr); - //IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pDstState), ippStsContextMatchErr); - - /* copy state */ - CopyBlock(pSrcState, pDstState, sizeof(IppsSHA512State)); - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Duplicate,(const IppsSHA384State* pSrcState, IppsSHA384State* pDstState)) -{ - return ippsSHA512Duplicate(pSrcState, pDstState); -} -#endif - - -/*F* -// Name: ippsSHA512Update -// ippsSHA384Update -// -// Purpose: Updates intermadiate digest based on input stream. -// -// Returns: Reason: -// ippStsNullPtrErr pSrc == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA512 -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pSrc pointer to the input stream -// len input stream length -// pState pointer to the SHA512 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA512Update,(const Ipp8u* pSrc, int len, IppsSHA512State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) ); - - /* test state ID */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pState), ippStsContextMatchErr); - /* test input length */ - IPP_BADARG_RET((len<0), ippStsLengthErr); - /* test source pointer */ - IPP_BADARG_RET((len && !pSrc), ippStsNullPtrErr); - - /* - // handle non empty message - */ - if(len) { - int processingLen; - - int n = SHS_INDX(pState); - Ipp8u* pBuffer = SHS_BUFF(pState); - Ipp8u* pHash = (Ipp8u*)SHS_HASH(pState); - - Ipp64u lenLo = SHS_LENL(pState); - Ipp64u lenHi = SHS_LENH(pState); - lenLo += len; - if(lenLo < SHS_LENL(pState)) lenHi++; - - /* if non empty internal buffer filling */ - if(n) { - /* copy from input stream to the internal buffer as match as possible */ - processingLen = IPP_MIN(len, (MBS_SHA512-n)); - CopyBlock(pSrc, pBuffer+n, processingLen); - - pSrc += processingLen; - len -= processingLen; - SHS_INDX(pState) = n += processingLen; - - /* update digest if buffer full */ - if(MBS_SHA512 == n) { - UpdateSHA512(pHash, pBuffer, MBS_SHA512, SHA512_cnt); - SHS_INDX(pState) = 0; - } - } - - /* main message part processing */ - processingLen = len & ~(MBS_SHA512-1); - if(processingLen) { - UpdateSHA512(pHash, pSrc, processingLen, SHA512_cnt); - pSrc += processingLen; - len -= processingLen; - } - - /* store rest of message into the internal buffer */ - if(len) { - CopyBlock(pSrc, pBuffer, len); - SHS_INDX(pState) += len; - } - - SHS_LENL(pState) = lenLo; - SHS_LENH(pState) = lenHi; - } - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Update,(const Ipp8u* pSrc, int len, IppsSHA384State* pState)) -{ - return ippsSHA512Update(pSrc, len, pState); -} -#endif - - -/* -// Compute digest -*/ -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -void ComputeDigestSHA512(Ipp64u* pHash, const IppsSHA512State* pState) -{ - const Ipp8u* stateBuff = SHS_BUFF(pState); - int stateBuffLen = SHS_INDX(pState); - - /* local buffer and it length */ - Ipp8u buffer[MBS_SHA512*2]; - int bufferLen = stateBuffLen < (MBS_SHA512-(int)sizeof(Ipp64u)*2)? MBS_SHA512 : MBS_SHA512*2; - - /* copy rest of message into internal buffer */ - CopyBlock(stateBuff, buffer, stateBuffLen); - - /* padd message */ - buffer[stateBuffLen++] = 0x80; - PaddBlock(0, buffer+stateBuffLen, bufferLen-stateBuffLen-sizeof(Ipp64u)*2); - - /* message length representation */ - { - Ipp64u lo = SHS_LENL(pState); /* message length in bytes */ - Ipp64u hi = SHS_LENH(pState); - hi = LSL64(hi,3) | LSR64(lo,63-3); /* message length in bits */ - lo = LSL64(lo,3); - ((Ipp64u*)(buffer+bufferLen))[-2] = ENDIANNESS64(hi); - ((Ipp64u*)(buffer+bufferLen))[-1] = ENDIANNESS64(lo); - } - - /* copmplete hash computation */ - UpdateSHA512(pHash, buffer, bufferLen, SHA512_cnt); - - /* convert hash into big endian */ - pHash[0] = ENDIANNESS64(pHash[0]); - pHash[1] = ENDIANNESS64(pHash[1]); - pHash[2] = ENDIANNESS64(pHash[2]); - pHash[3] = ENDIANNESS64(pHash[3]); - pHash[4] = ENDIANNESS64(pHash[4]); - pHash[5] = ENDIANNESS64(pHash[5]); - pHash[6] = ENDIANNESS64(pHash[6]); - pHash[7] = ENDIANNESS64(pHash[7]); -} -#endif - - -/*F* -// Name: ippsSHA512GetTag -// ippsSHA384GetTag -// -// Purpose: Compute digest based on current state. -// Note, that futher digest update is possible -// -// Returns: Reason: -// ippStsNullPtrErr pTag == NULL -// pState == NULL -// ippStsContextMatchErr pState->idCtx != idCtxSHA512 -// ippStsLengthErr max_SHA_digestLen < tagLen <1 -// ippStsNoErr no errors -// -// Parameters: -// pTag address of the output digest -// tagLen length of digest -// pState pointer to the SHS state -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) -IPPFUN(IppStatus, ippsSHA512GetTag,(Ipp8u* pTag, Ipp32u tagLen, const IppsSHA512State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pTag); - IPP_BADARG_RET((tagLen<1)||(sizeof(DigestSHA512)idCtx != idCtxSHA512 -// ippStsNoErr no errors -// -// Parameters: -// pMD address of the output digest -// pState pointer to the SHA512 state -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) -IPPFUN(IppStatus, ippsSHA512Final,(Ipp8u* pMD, IppsSHA512State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA512State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestSHA512(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestSHA512)); - InitSHA512(SHA512_IV, pState); - - return ippStsNoErr; -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384Final,(Ipp8u* pMD, IppsSHA384State* pState)) -{ - /* test state pointer and ID */ - IPP_BAD_PTR1_RET(pState); - /* use aligned context */ - pState = (IppsSHA384State*)( IPP_ALIGNED_PTR(pState, SHA512_ALIGNMENT) ); - /* test state ID */ - IPP_BADARG_RET(idCtxSHA512 !=SHS_ID(pState), ippStsContextMatchErr); - - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - ComputeDigestSHA512(SHS_HASH(pState), pState); - CopyBlock(SHS_HASH(pState), pMD, sizeof(DigestSHA384)); - InitSHA512(SHA384_IV, pState); - - return ippStsNoErr; -} -#endif - - -#if defined (_ENABLE_ALG_SHA512_) || defined (_ENABLE_ALG_SHA384_) -IppStatus cpSHA512MessageDigest(DigestSHA512 hash, const Ipp8u* pMsg, int msgLen, const DigestSHA512 IV) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(hash); - /* test message length */ - IPP_BADARG_RET((msgLen<0), ippStsLengthErr); - /* test message pointer */ - IPP_BADARG_RET((msgLen && !pMsg), ippStsNullPtrErr); - - { - /* message length in the multiple MBS and the rest */ - int msgLenBlks = msgLen & (-MBS_SHA512); - int msgLenRest = msgLen - msgLenBlks; - - /* setup initial digest */ - hash[0] = IV[0]; - hash[1] = IV[1]; - hash[2] = IV[2]; - hash[3] = IV[3]; - hash[4] = IV[4]; - hash[5] = IV[5]; - hash[6] = IV[6]; - hash[7] = IV[7]; - - /* process main part of the message */ - if(msgLenBlks) - UpdateSHA512(hash, pMsg, msgLenBlks, SHA512_cnt); - - /* process message padding */ - { - #define MREP_SIZE_SHA512 (2*sizeof(Ipp64u)) - Ipp8u buffer[MBS_SHA512*2]; - int bufferLen = msgLenRest < (int)(MBS_SHA512-MREP_SIZE_SHA512)? MBS_SHA512 : MBS_SHA512*2; - - /* message bitlength representation */ - Ipp64u msgLenBits = (Ipp64u)msgLen*8; - msgLenBits = ENDIANNESS64(msgLenBits); - - /* 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-MREP_SIZE_SHA512+sizeof(Ipp64u)); - /* copy message bitlength representation */ - ((Ipp64u*)(buffer+bufferLen))[-1] = msgLenBits; - - UpdateSHA512(hash, buffer, bufferLen, SHA512_cnt); - #undef MREP_SIZE_SHA512 - } - - /* swap hash bytes */ - 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]); - - return ippStsNoErr; - } -} -#endif - -/*F* -// Name: ippsSHA512MessageDigest -// ippsSHA384MessageDigest -// -// Purpose: Digest of the whole message. -// -// Returns: Reason: -// ippStsNullPtrErr pMsg == NULL -// pDigest == NULL -// ippStsLengthErr len <0 -// ippStsNoErr no errors -// -// Parameters: -// pMsg pointer to the input message -// len input message length -// pMD address of the output digest -// -*F*/ -#if defined (_ENABLE_ALG_SHA512_) -IPPFUN(IppStatus, ippsSHA512MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - { - DigestSHA512 hash; - IppStatus sts = cpSHA512MessageDigest(hash, pMsg, msgLen, SHA512_IV); - if(ippStsNoErr==sts) - CopyBlock(hash, pMD, IPP_SHA512_DIGEST_BITSIZE/BYTESIZE); - return sts; - } -} -#endif - -#if defined (_ENABLE_ALG_SHA384_) -IPPFUN(IppStatus, ippsSHA384MessageDigest,(const Ipp8u* pMsg, int msgLen, Ipp8u* pMD)) -{ - /* test digest pointer */ - IPP_BAD_PTR1_RET(pMD); - - { - DigestSHA512 hash; - IppStatus sts = cpSHA512MessageDigest(hash, pMsg, msgLen, SHA384_IV); - if(ippStsNoErr==sts) - CopyBlock(hash, pMD, IPP_SHA384_DIGEST_BITSIZE/BYTESIZE); - return sts; - } -} -#endif diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcptool.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcptool.h deleted file mode 100644 index df8c798da8..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcptool.h +++ /dev/null @@ -1,631 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Cryptography Primitive. -// Internal Definitions of Block Cipher Tools -// -// -*/ - -#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=_IPP_W7) || (_IPP32E>=_IPP32E_M7)) -__INLINE void PurgeBlock(void* pDst, int len) -{ - int n; - for(n=0; n> (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; -} - -/* vb */ -__INLINE void ompStdIncrement64( void* pInitCtrVal, void* pCurrCtrVal, - int ctrNumBitSize, int n ) -{ - int k; - Ipp64u cntr; - Ipp64u temp; - Ipp64s item; - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - ( ( Ipp8u* )&cntr )[k] = ( ( Ipp8u* )pInitCtrVal )[7 - k]; - #else - for( k = 0; k < 8; k++ ) - ( ( Ipp8u* )&cntr )[k] = ( ( Ipp8u* )pInitCtrVal )[k]; - #endif - - if( ctrNumBitSize == 64 ) - { - cntr += ( Ipp64u )n; - } - else - { - /* gres: Ipp64u mask = ( Ipp64u )0xFFFFFFFFFFFFFFFF >> ( 64 - ctrNumBitSize ); */ - Ipp64u mask = CONST_64(0xFFFFFFFFFFFFFFFF) >> ( 64 - ctrNumBitSize ); - Ipp64u save = cntr & ( ~mask ); - Ipp64u bndr = ( Ipp64u )1 << ctrNumBitSize; - - temp = cntr & mask; - cntr = temp + ( Ipp64u )n; - - if( cntr > bndr ) - { - item = ( Ipp64s )n - ( Ipp64s )( bndr - temp ); - - while( item > 0 ) - { - cntr = ( Ipp64u )item; - item -= ( Ipp64s )bndr; - } - } - - cntr = save | ( cntr & mask ); - } - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - ( ( Ipp8u* )pCurrCtrVal )[7 - k] = ( ( Ipp8u* )&cntr )[k]; - #else - for( k = 0; k < 8; k++ ) - ( ( Ipp8u* )pCurrCtrVal )[k] = ( ( Ipp8u* )&cntr )[k]; - #endif -} - - -/* vb */ -__INLINE void ompStdIncrement128( void* pInitCtrVal, void* pCurrCtrVal, - int ctrNumBitSize, int n ) -{ - int k; - Ipp64u low; - Ipp64u hgh; - Ipp64u flag; - Ipp64u mask = CONST_64(0xFFFFFFFFFFFFFFFF); - Ipp64u save; - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[15 - k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[7 - k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[8 + k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[k]; - } - #endif - - if( ctrNumBitSize == 64 ) - { - low += ( Ipp64u )n; - } - else if( ctrNumBitSize < 64 ) - { - Ipp64u bndr; - Ipp64u cntr; - Ipp64s item; - - mask >>= ( 64 - ctrNumBitSize ); - save = low & ( ~mask ); - cntr = ( low & mask ) + ( Ipp64u )n; - - if( ctrNumBitSize < 31 ) - { - bndr = ( Ipp64u )1 << ctrNumBitSize; - - if( cntr > bndr ) - { - item = ( Ipp64s )( ( Ipp64s )n - ( ( Ipp64s )bndr - - ( Ipp64s )( low & mask ) ) ); - - while( item > 0 ) - { - cntr = ( Ipp64u )item; - item -= ( Ipp64s )bndr; - } - } - } - - low = save | ( cntr & mask ); - } - else - { - flag = ( low >> 63 ); - - if( ctrNumBitSize != 128 ) - { - mask >>= ( 128 - ctrNumBitSize ); - save = hgh & ( ~mask ); - hgh &= mask; - } - - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) hgh++; - - if( ctrNumBitSize != 128 ) - { - hgh = save | ( hgh & mask ); - } - } - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[15 - k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[7 - k] = ( ( Ipp8u* )&hgh )[k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[8 + k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[k] = ( ( Ipp8u* )&hgh )[k]; - } - #endif -} - - -/* vb */ -__INLINE void ompStdIncrement192( void* pInitCtrVal, void* pCurrCtrVal, - int ctrNumBitSize, int n ) -{ - int k; - Ipp64u low; - Ipp64u mdl; - Ipp64u hgh; - Ipp64u flag; - Ipp64u mask = CONST_64(0xFFFFFFFFFFFFFFFF); - Ipp64u save; - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[23 - k]; - ( ( Ipp8u* )&mdl )[k] = ( ( Ipp8u* )pInitCtrVal )[15 - k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[7 - k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[16 + k]; - ( ( Ipp8u* )&mdl )[k] = ( ( Ipp8u* )pInitCtrVal )[8 + k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[k]; - } - #endif - - if( ctrNumBitSize == 64 ) - { - low += ( Ipp64u )n; - } - else if( ctrNumBitSize == 128 ) - { - flag = ( low >> 63 ); - low += ( Ipp64u )n; - if( flag != ( low >> 63 ) ) mdl++; - } - else if( ctrNumBitSize == 192 ) - { - flag = ( low >> 63 ); - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - if( flag != ( mdl >> 63 ) ) hgh++; - } - } - else if( ctrNumBitSize < 64 ) - { - Ipp64u bndr; - Ipp64u cntr; - Ipp64s item; - - mask >>= ( 64 - ctrNumBitSize ); - save = low & ( ~mask ); - cntr = ( low & mask ) + ( Ipp64u )n; - - if( ctrNumBitSize < 31 ) - { - bndr = ( Ipp64u )1 << ctrNumBitSize; - - if( cntr > bndr ) - { - item = ( Ipp64s )( ( Ipp64s )n - ( ( Ipp64s )bndr - - ( Ipp64s )( low & mask ) ) ); - - while( item > 0 ) - { - cntr = ( Ipp64u )item; - item -= ( Ipp64s )bndr; - } - } - } - - low = save | ( cntr & mask ); - } - else if( ctrNumBitSize < 128 ) - { - flag = ( low >> 63 ); - mask >>= ( 128 - ctrNumBitSize ); - save = mdl & ( ~mask ); - mdl &= mask; - low += ( Ipp64u )n; - if( flag != ( low >> 63 ) ) mdl++; - mdl = save | ( mdl & mask ); - } - else - { - flag = ( low >> 63 ); - mask >>= ( 192 - ctrNumBitSize ); - save = hgh & ( ~mask ); - hgh &= mask; - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - if( flag != ( mdl >> 63 ) ) hgh++; - } - - hgh = save | ( hgh & mask ); - } - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[23 - k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[15 - k] = ( ( Ipp8u* )&mdl )[k]; - ( ( Ipp8u* )pCurrCtrVal )[7 - k] = ( ( Ipp8u* )&hgh )[k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[16 + k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[8 + k] = ( ( Ipp8u* )&mdl )[k]; - ( ( Ipp8u* )pCurrCtrVal )[k] = ( ( Ipp8u* )&hgh )[k]; - } - #endif -} - - -/* vb */ -__INLINE void ompStdIncrement256( void* pInitCtrVal, void* pCurrCtrVal, - int ctrNumBitSize, int n ) -{ - int k; - Ipp64u low; - Ipp64u mdl; - Ipp64u mdm; - Ipp64u hgh; - Ipp64u flag; - Ipp64u mask = CONST_64(0xFFFFFFFFFFFFFFFF); - Ipp64u save; - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[31 - k]; - ( ( Ipp8u* )&mdl )[k] = ( ( Ipp8u* )pInitCtrVal )[23 - k]; - ( ( Ipp8u* )&mdm )[k] = ( ( Ipp8u* )pInitCtrVal )[15 - k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[7 - k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )&low )[k] = ( ( Ipp8u* )pInitCtrVal )[24 + k]; - ( ( Ipp8u* )&mdl )[k] = ( ( Ipp8u* )pInitCtrVal )[16 + k]; - ( ( Ipp8u* )&mdm )[k] = ( ( Ipp8u* )pInitCtrVal )[8 + k]; - ( ( Ipp8u* )&hgh )[k] = ( ( Ipp8u* )pInitCtrVal )[k]; - } - #endif - - if( ctrNumBitSize == 64 ) - { - low += ( Ipp64u )n; - } - else if( ctrNumBitSize == 128 ) - { - flag = ( low >> 63 ); - low += ( Ipp64u )n; - if( flag != ( low >> 63 ) ) mdl++; - } - else if( ctrNumBitSize == 192 ) - { - flag = ( low >> 63 ); - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - if( flag != ( mdl >> 63 ) ) hgh++; - } - } - else if( ctrNumBitSize == 256 ) - { - flag = ( low >> 63 ); - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - - if( flag != ( mdl >> 63 ) ) - { - flag = ( mdm >> 63 ); - mdm++; - if( flag != ( mdm >> 63 ) ) hgh++; - } - } - } - else if( ctrNumBitSize < 64 ) - { - Ipp64u bndr; - Ipp64u cntr; - Ipp64s item; - - mask >>= ( 64 - ctrNumBitSize ); - save = low & ( ~mask ); - cntr = ( low & mask ) + ( Ipp64u )n; - - if( ctrNumBitSize < 31 ) - { - bndr = ( Ipp64u )1 << ctrNumBitSize; - - if( cntr > bndr ) - { - item = ( Ipp64s )( ( Ipp64s )n - ( ( Ipp64s )bndr - - ( Ipp64s )( low & mask ) ) ); - - while( item > 0 ) - { - cntr = ( Ipp64u )item; - item -= ( Ipp64s )bndr; - } - } - } - - low = save | ( cntr & mask ); - } - else if( ctrNumBitSize < 128 ) - { - flag = ( low >> 63 ); - mask >>= ( 128 - ctrNumBitSize ); - save = mdl & ( ~mask ); - mdl &= mask; - low += ( Ipp64u )n; - if( flag != ( low >> 63 ) ) mdl++; - mdl = save | ( mdl & mask ); - } - else if( ctrNumBitSize < 192 ) - { - flag = ( low >> 63 ); - mask >>= ( 192 - ctrNumBitSize ); - save = mdm & ( ~mask ); - mdm &= mask; - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - if( flag != ( mdl >> 63 ) ) mdm++; - } - - mdm = save | ( mdm & mask ); - } - else - { - flag = ( low >> 63 ); - mask >>= ( 256 - ctrNumBitSize ); - save = hgh & ( ~mask ); - hgh &= mask; - low += ( Ipp64u )n; - - if( flag != ( low >> 63 ) ) - { - flag = ( mdl >> 63 ); - mdl++; - - if( flag != ( mdl >> 63 ) ) - { - flag = ( mdm >> 63 ); - mdm++; - if( flag != ( mdm >> 63 ) ) hgh++; - } - } - - hgh = save | ( hgh & mask ); - } - - #if( IPP_ENDIAN == IPP_LITTLE_ENDIAN ) - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[31 - k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[23 - k] = ( ( Ipp8u* )&mdl )[k]; - ( ( Ipp8u* )pCurrCtrVal )[15 - k] = ( ( Ipp8u* )&mdm )[k]; - ( ( Ipp8u* )pCurrCtrVal )[7 - k] = ( ( Ipp8u* )&hgh )[k]; - } - #else - for( k = 0; k < 8; k++ ) - { - ( ( Ipp8u* )pCurrCtrVal )[24 + k] = ( ( Ipp8u* )&low )[k]; - ( ( Ipp8u* )pCurrCtrVal )[16 + k] = ( ( Ipp8u* )&mdl )[k]; - ( ( Ipp8u* )pCurrCtrVal )[8 + k] = ( ( Ipp8u* )&mdm )[k]; - ( ( Ipp8u* )pCurrCtrVal )[k] = ( ( Ipp8u* )&hgh )[k]; - } - #endif -} - -#endif /* _CP_TOOL_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpvariant.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpvariant.h deleted file mode 100644 index aeda9c49f9..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/pcpvariant.h +++ /dev/null @@ -1,326 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippcp) -// -// Purpose: -// Define ippCP variant -// -// -*/ - -#if !defined(_CP_VARIANT_H) -#define _CP_VARIANT_H - -/* -// modes of the CPU feature -*/ -#define _FEATURE_OFF_ (0) /* feature is OFF a priori */ -#define _FEATURE_ON_ (1) /* feature is ON a priori */ -#define _FEATURE_TICKTOCK_ (2) /* dectect is feature OFF/ON */ - -/* -// set _AES_NI_ENABLING_ -*/ -#if defined _IPP_AES_NI_ - #if (_IPP_AES_NI_ == 0) - #define _AES_NI_ENABLING_ _FEATURE_OFF_ - #elif (_IPP_AES_NI_ == 1) - #define _AES_NI_ENABLING_ _FEATURE_ON_ - #else - #error Define _IPP_AES_NI_=0 or 1 or omit _IPP_AES_NI_ at all - #endif -#else - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - #define _AES_NI_ENABLING_ _FEATURE_TICKTOCK_ - #else - #define _AES_NI_ENABLING_ _FEATURE_OFF_ - #endif -#endif - -/* -// select AES safe implementation -*/ -#define _ALG_AES_SAFE_COMPACT_SBOX_ (1) -#define _ALG_AES_SAFE_COMPOSITE_GF_ (2) - -#if (_AES_NI_ENABLING_==_FEATURE_ON_) - #define _ALG_AES_SAFE_ _FEATURE_OFF_ -#else - #if (_IPP>=_IPP_V8) || (_IPP32E>=_IPP32E_U8) - #define _ALG_AES_SAFE_ _ALG_AES_SAFE_COMPOSITE_GF_ - #else - #define _ALG_AES_SAFE_ _ALG_AES_SAFE_COMPACT_SBOX_ - #endif -#endif - - -/* -// set _SHA_NI_ENABLING_ -*/ -#if defined _IPP_SHA_NI_ - #if (_IPP_SHA_NI_ == 0) - #define _SHA_NI_ENABLING_ _FEATURE_OFF_ - #elif (_IPP_SHA_NI_ == 1) - #define _SHA_NI_ENABLING_ _FEATURE_ON_ - #else - #error Define _IPP_SHA_NI_=0 or 1 or omit _IPP_SHA_NI_ at all - #endif -#else - #if (_IPP>=_IPP_P8) || (_IPP32E>=_IPP32E_Y8) - #define _SHA_NI_ENABLING_ _FEATURE_TICKTOCK_ - #else - #define _SHA_NI_ENABLING_ _FEATURE_OFF_ - #endif -#endif - -/* -// set _ADCOX_NI_ENABLING_ -*/ -#if defined _IPP_ADCX_NI_ - #if (_IPP_ADCX_NI_ == 0) - #define _ADCOX_NI_ENABLING_ _FEATURE_OFF_ - #elif (_IPP_ADCX_NI_ == 1) - #define _ADCOX_NI_ENABLING_ _FEATURE_ON_ - #else - #error Define _IPP_ADCX_NI_=0 or 1 or omit _IPP_ADCX_NI_ at all - #endif -#else - #if (_IPP32E>=_IPP32E_L9) - #define _ADCOX_NI_ENABLING_ _FEATURE_TICKTOCK_ - #else - #define _ADCOX_NI_ENABLING_ _FEATURE_OFF_ - #endif -#endif - - -/* -// IPP supports several hash algorithms by default: -// SHA-1 -// SHA-256 -// SHA-224 (or SHA256/224 by the FIPS180-4 classification) -// SHA-512 -// SHA-384 (or SHA512/384 by the FIPS180-4 classification) -// MD5 -// SM3 -// -// By default all hash algorithms are included in IPP Crypto. -// -// If one need excludes code of particular hash, just define -// suitable _DISABLE_ALG_XXX, where XXX name of the hash algorithm -// -*/ -#if !defined(_DISABLE_ALG_SHA1_) -#define _ENABLE_ALG_SHA1_ /* SHA1 on */ -#else -# undef _ENABLE_ALG_SHA1_ /* SHA1 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA256_) -# define _ENABLE_ALG_SHA256_ /* SHA256 on */ -#else -# undef _ENABLE_ALG_SHA256_ /* SHA256 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA224_) -# define _ENABLE_ALG_SHA224_ /* SHA224 on */ -#else -# undef _ENABLE_ALG_SHA224_ /* SHA224 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA512_) -# define _ENABLE_ALG_SHA512_ /* SHA512 on */ -#else -# undef _ENABLE_ALG_SHA512_ /* SHA512 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA384_) -# define _ENABLE_ALG_SHA384_ /* SHA384 on */ -#else -# undef _ENABLE_ALG_SHA384_ /* SHA384 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA512_224_) -# define _ENABLE_ALG_SHA512_224_ /* SHA512/224 on */ -#else -# undef _ENABLE_ALG_SHA512_224_ /* SHA512/224 off */ -#endif - -#if !defined(_DISABLE_ALG_SHA512_256_) -# define _ENABLE_ALG_SHA512_256_ /* SHA512/256 on */ -#else -# undef _ENABLE_ALG_SHA512_256_ /* SHA512/256 off */ -#endif - -#if !defined(_DISABLE_ALG_MD5_) -# define _ENABLE_ALG_MD5_ /* MD5 on */ -#else -# undef _ENABLE_ALG_MD5_ /* MD5 off */ -#endif - -#if !defined(_DISABLE_ALG_SM3_) -# define _ENABLE_ALG_SM3_ /* SM3 on */ -#else -# undef _ENABLE_ALG_SM3_ /* SM3 off */ -#endif - -/* -// SHA1 plays especial role in IPP. Thus IPP random generator -// and therefore prime number generator are based on SHA1. -// So, do no exclude SHA1 from the active list of hash algorithms -*/ -//#if !defined(_ENABLE_ALG_SHA1_) -//#define _ENABLE_ALG_SHA1_ -//#endif - -/* -// Because of performane reason hash algorithms are implemented in form -// of unroller cycle and therefore these implementations are big enough. -// IPP supports "compact" implementation of some basic hash algorithms: -// SHA-1 -// SHA-256 -// SHA-512 -// SM3 -// -// Define any -// _ALG_SHA1_COMPACT_ -// _ALG_SHA256_COMPACT_ -// _ALG_SHA512_COMPACT_ -// _ALG_SM3_COMPACT_ -// -// to select "compact" implementation of particular hash algorithm. -// IPP does not define "compact" implementation by default. -// -// Don't know what performance degradation leads "compact" -// in comparison with default IPP implementation. -// -// Note: the definition like _ALG_XXX_COMPACT_ has effect -// if and only if IPP instance is _PX or _MX -*/ -//#define _ALG_SHA1_COMPACT_ -//#define _ALG_SHA256_COMPACT_ -//#define _ALG_SHA512_COMPACT_ -//#define _ALG_SM3_COMPACT_ -//#undef _ALG_SHA1_COMPACT_ -//#undef _ALG_SHA256_COMPACT_ -//#undef _ALG_SHA512_COMPACT_ -//#undef _ALG_SM3_COMPACT_ - - -/* -// BN arithmetic: -// - do/don't use special implementation of sqr instead of usual multication -// - do/don't use Karatsuba multiplication alg -*/ -#define _USE_SQR_ /* use implementaton of sqr */ -#define xUSE_KARATSUBA_ /* not use Karatsuba method for multiplication */ -#define _USE_WINDOW_EXP_ /* use fixed window exponentiation */ - -/* -// RSA: -// - do/don't use Ernie's style mitigation of CBA -// - do/don't use Gres's style mitigation of CBA -// - do/don't use Foldinf technique for RSA-1204 implementation -*/ -#define xUSE_ERNIE_CBA_MITIGATION_ /* not use (Ernie) mitigation of CBA */ -#define _USE_GRES_CBA_MITIGATION_ /* use (Gres) mitigation of CBA */ -#define xUSE_FOLD_MONT512_ /* use foding technique in RSA-1024 case */ - -/* -// IPP supports different implementation of NIST's (standard) EC over GF(0): -// P-128 (IppECCPStd128r1, IppECCPStd128r2) -// P-192 (IppECCPStd192r1) -// P-224 (IppECCPStd224r1) -// P-256 (IppECCPStd256r1) -// P-384 (IppECCPStd384r1) -// P-521 (IppECCPStd521r1) -// -// If one need replace the particular implementation by abritrary one -// assign _ECP_IMP_ARBIRTRARY_ to suitable symbol -// -// _ECP_IMPL_ARBIRTRARY_ means that implementtaion does not use any curve specific, -// provide the same (single) code for any type curve -// -// _ECP_IMPL_SPECIFIC_ means that implementation uses specific modular reduction -// based on prime structure; -// most of NIST's cures (p128, p192, p224, p256, p384, p521) are uses -// such kind of reduction procedure; -// in contrast with _ECP_IMPL_ARBIRTRARY_ and _ECP_IMPL_MFM_ -// this type of implementation uses point representation in REGULAR residual -// (not Montgometry!!) domain -// -// _ECP_IMPL_MFM_ means that implementation uses "Montgomary Friendly Modulus" (primes); -// p256 and sm2 are using such kind of optimization -*/ -#define _ECP_IMPL_ARBIRTRARY_ 0 -#define _ECP_IMPL_SPECIFIC_ 1 -#define _ECP_IMPL_MFM_ 2 - -#define _ECP_128_ _ECP_IMPL_SPECIFIC_ -#define _ECP_192_ _ECP_IMPL_SPECIFIC_ -#define _ECP_224_ _ECP_IMPL_SPECIFIC_ -#define _ECP_256_ _ECP_IMPL_SPECIFIC_ -#define _ECP_384_ _ECP_IMPL_SPECIFIC_ -#define _ECP_521_ _ECP_IMPL_SPECIFIC_ -#define _ECP_SM2_ _ECP_IMPL_SPECIFIC_ -//#define _ECP_SM2_ _ECP_IMPL_ARBIRTRARY_ - -#if (_IPP32E >= _IPP32E_M7) -#undef _ECP_192_ -#undef _ECP_224_ -#undef _ECP_256_ -#undef _ECP_384_ -#undef _ECP_521_ -#undef _ECP_SM2_ - -#define _ECP_192_ _ECP_IMPL_MFM_ -#define _ECP_224_ _ECP_IMPL_MFM_ -#define _ECP_256_ _ECP_IMPL_MFM_ -#define _ECP_384_ _ECP_IMPL_MFM_ -#define _ECP_521_ _ECP_IMPL_MFM_ -#define _ECP_SM2_ _ECP_IMPL_MFM_ -#endif - - -/* -// EC over GF(p): -// - do/don't use mitigation of CBA -*/ -#define _USE_ECCP_SSCM_ /* use SSCM ECCP */ - - -#if defined ( _OPENMP ) -#define DEFAULT_CPU_NUM (8) - -#define BF_MIN_BLK_PER_THREAD (32) -#define TF_MIN_BLK_PER_THREAD (16) - -#define DES_MIN_BLK_PER_THREAD (32) -#define TDES_MIN_BLK_PER_THREAD (16) - -#define RC5_64_MIN_BLK_PER_THREAD (16) -#define RC5_128_MIN_BLK_PER_THREAD (32) - -#define RIJ128_MIN_BLK_PER_THREAD (32) -#define RIJ192_MIN_BLK_PER_THREAD (16) -#define RIJ256_MIN_BLK_PER_THREAD (16) - -#define AESNI128_MIN_BLK_PER_THREAD (256) -#endif - -#endif /* _CP_VARIANT_H */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/precomp.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/precomp.h deleted file mode 100644 index afc437309b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcp/src/precomp.h +++ /dev/null @@ -1,22 +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 __PRECOMP_H__ -#define __PRECOMP_H__ - -#include "owncp.h" - -#endif /* __PRECOMP_H__ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_p8.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_p8.h deleted file mode 100644 index 4026f91e4b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_p8.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 This file does renames to allow using of the lib with - * commercial merged ippcp - */ - - -#ifndef IPPEPID_P8_H_ -#define IPPEPID_P8_H_ - -# define cpDiv_BNU32 p8_##cpDiv_BNU32 -# define cpLSR_BNU p8_##cpLSR_BNU -# define cpNLZ_BNU p8_##cpNLZ_BNU -# define cpNLZ_BNU32 p8_##cpNLZ_BNU32 -# define cpToOctStr_BNU p8_##cpToOctStr_BNU -# define cpFromOctStr_BNU p8_##cpFromOctStr_BNU -# define cpMulAdc_BNU_school p8_##cpMulAdc_BNU_school -# define cpMontRedAdc_BNU p8_##cpMontRedAdc_BNU -# define cpSqrAdc_BNU_school p8_##cpSqrAdc_BNU_school -# define cpModInv_BNU p8_##cpModInv_BNU -# define cpAdd_BNU p8_##cpAdd_BNU -# define cpSub_BNU p8_##cpSub_BNU -# define cpDec_BNU32 p8_##cpDec_BNU32 -# define cpNTZ_BNU p8_##cpNTZ_BNU -# define cpMontExpBin_BNU p8_##cpMontExpBin_BNU - -#endif // IPPEPID_P8_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_y8.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_y8.h deleted file mode 100644 index 8576622e6b..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/ippcpepid_y8.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 This file does renames to allow using of the lib with - * commercial merged ippcp - */ - - -#ifndef IPPEPID_Y8_H_ -#define IPPEPID_Y8_H_ - -# define cpDiv_BNU32 y8_##cpDiv_BNU32 -# define cpLSR_BNU y8_##cpLSR_BNU -# define cpNLZ_BNU y8_##cpNLZ_BNU -# define cpNLZ_BNU32 y8_##cpNLZ_BNU32 -# define cpToOctStr_BNU y8_##cpToOctStr_BNU -# define cpFromOctStr_BNU y8_##cpFromOctStr_BNU -# define cpMulAdc_BNU_school y8_##cpMulAdc_BNU_school -# define cpMontRedAdc_BNU y8_##cpMontRedAdc_BNU -# define cpSqrAdc_BNU_school y8_##cpSqrAdc_BNU_school -# define cpModInv_BNU y8_##cpModInv_BNU -# define cpAdd_BNU y8_##cpAdd_BNU -# define cpSub_BNU y8_##cpSub_BNU -# define cpDec_BNU32 y8_##cpDec_BNU32 -# define cpNTZ_BNU y8_##cpNTZ_BNU -# define cpMontExpBin_BNU y8_##cpMontExpBin_BNU - -#endif // IPPEPID_Y8_H_ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/owncpepid.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/owncpepid.h deleted file mode 100644 index 4c270dfd83..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/owncpepid.h +++ /dev/null @@ -1,58 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Internal Cryptographic Primitives (Intel(R) EPID v2.0) -// -// -*/ - -#ifndef __OWNCP_EPID_H__ -#define __OWNCP_EPID_H__ - -#if defined (USE_P8_HEADER) - #include "ippcpepid_p8.h" -#elif defined (USE_Y8_HEADER) - #include "ippcpepid_y8.h" -#endif - -#ifndef __OWNDEFS_H__ - #include "owndefs.h" -#endif - -#ifndef __OWNCP_H__ - #include "owncp.h" -#endif - -#ifndef __IPPCP_EPID_H__ - #include "ippcpepid.h" -#endif - -#define LOG2_CACHE_LINE_SIZE (6) /* LOG2(CACHE_LINE_SIZE) */ - -/* convert bitsize nbits into the number of BNU_CHUNK_T */ -#define BITS_CHUNKSIZE(nbits) (((nbits)+BITSIZE(BNU_CHUNK_T)-1)/BITSIZE(BNU_CHUNK_T)) - -/* -// dst = (src1 & mask) | (src2 & ~mask) -*/ -#define MASKED_COPY(dst, mask, src1, src2, len) { \ - /*cpSize*/ int i; \ - for(i=0; i<(len); i++) (dst)[i] = ((mask) & (src1)[i]) | (~(mask) & (src2)[i]); \ -} - -#endif /* __OWNCP_EPID_H__ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfp.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfp.c deleted file mode 100644 index d764dae125..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfp.c +++ /dev/null @@ -1,846 +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. - ############################################################################*/ - -/* -// Intel(R) Performance Primitives. Cryptography Primitives. -// Operations over GF(p). -// -// Context: -// ippsGFpGetSize() -// ippsGFpInit() -// -// ippsGFpElementGetSize() -// ippsGFpElementInit() -// -// ippsGFpSetElement() -// ippsGFpSetElementOctString() -// ippsGFpSetElementRandom() -// ippsGFpSetElementHash() -// ippsGFpCpyElement() -// ippsGFpGetElement() -// ippsGFpGetElementOctString() -// -// ippsGFpCmpElement() -// ippsGFpIsZeroElement() -// ippsGFpIsUnityElement() -// -// ippsGFpSetPolyTerm() -// ippsGFpGetPolyTerm() -// -// ippsGFpConj() -// ippsGFpNeg() -// ippsGFpInv() -// ippsGFpSqrt() -// ippsGFpAdd() -// ippsGFpSub() -// ippsGFpMul() -// ippsGFpSqr() -// ippsGFpExp() -// ippsGFpMultiExp() -// -// ippsGFpAdd_GFpE() -// ippsGFpSub_GFpE() -// ippsGFpMul_GFpE() -// -// -*/ - -#include "owncpepid.h" - -#include "pcpgfpstuff.h" -#include "pcpgfpxstuff.h" -#include "pcpgfphashstuff.h" - - -IPPFUN(IppStatus, ippsGFpGetSize,(int bitSize, int* pSizeInBytes)) -{ - IPP_BAD_PTR1_RET(pSizeInBytes); - IPP_BADARG_RET((bitSize < 2) || (bitSize > GF_MAX_BITSIZE), ippStsSizeErr); - - { - int elemLen32 = BITS2WORD32_SIZE(bitSize); - int elemLen = BITS_BNU_CHUNK(bitSize); - int poolelemLen = elemLen + 1; - - int montgomeryCtxSize; - ippsMontGetSize(ippBinaryMethod, elemLen32, &montgomeryCtxSize); - - *pSizeInBytes = sizeof(IppsGFpState) /* sizeof(IppsGFPState)*/ - +elemLen*sizeof(BNU_CHUNK_T) /* modulus */ - +elemLen*sizeof(BNU_CHUNK_T) /* half of modulus */ - +elemLen*sizeof(BNU_CHUNK_T) /* quadratic non-residue */ - +montgomeryCtxSize /* montgomery engine */ - +poolelemLen*sizeof(BNU_CHUNK_T)*GF_POOL_SIZE /* pool */ - +CACHE_LINE_SIZE - +GFP_ALIGNMENT-1; - return ippStsNoErr; - } -} - - -static void gfpInitSqrt(IppsGFpState* pGF) -{ - int elemLen = GFP_FELEN(pGF); - BNU_CHUNK_T* e = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* t = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pMont1 = cpGFpGetPool(1, pGF); - - cpGFpElementCopyPadd(pMont1, elemLen, MNT_1(GFP_MONT(pGF)), elemLen); - - /* (modulus-1)/2 */ - cpLSR_BNU(e, GFP_MODULUS(pGF), elemLen, 1); - - /* find a non-square g, where g^{(modulus-1)/2} = -1 */ - cpGFpElementCopy(GFP_QNR(pGF), pMont1, elemLen); - do { - cpGFpAdd(GFP_QNR(pGF), pMont1, GFP_QNR(pGF), pGF); - cpGFpExp(t, GFP_QNR(pGF), e, elemLen, pGF); - cpGFpNeg(t, t, pGF); - } while( !GFP_EQ(pMont1, t, elemLen) ); - - cpGFpReleasePool(3, pGF); -} - -IPPFUN(IppStatus, ippsGFpInit,(const Ipp32u* pPrime, int primeBitSize, IppsGFpState* pGF)) -{ - IPP_BAD_PTR2_RET(pPrime, pGF); - IPP_BADARG_RET((primeBitSize< 2 ) || (primeBitSize> GF_MAX_BITSIZE), ippStsSizeErr); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - - { - Ipp8u* ptr = (Ipp8u*)pGF; - - int elemLen32 = BITS2WORD32_SIZE(primeBitSize); - int elemLen = BITS_BNU_CHUNK(primeBitSize); - int poolelemLen = elemLen + 1; - int montgomeryCtxSize; - ippsMontGetSize(ippBinaryMethod, elemLen32, &montgomeryCtxSize); - - GFP_ID(pGF) = idCtxGFP; - GFP_DEGREE(pGF) = 1; - GFP_FELEN(pGF) = elemLen; - GFP_FELEN32(pGF) = elemLen32; - GFP_PELEN(pGF) = poolelemLen; - FIELD_POLY_TYPE(pGF) = ARBITRARY; - - #if(_IPP_ARCH==_IPP_ARCH_EM64T) - /* 192 < primeBitSize <= 256 is considered as Intel(R) EPID param */ - EPID_PARAMS(pGF) = elemLen==4; - #else - EPID_PARAMS(pGF) = 0; - #endif - - GFP_GROUNDGF(pGF)= pGF; - - /* methods */ - pGF->add = cpGFpAdd; - pGF->sub = cpGFpSub; - pGF->neg = cpGFpNeg; - pGF->mul = cpGFpMul; - pGF->sqr = cpGFpSqr; - pGF->div2= cpGFpHalve; - - #if(_IPP32E >= _IPP32E_M7) - if(EPID_PARAMS(pGF)) { - pGF->add = cp256pAdd; - pGF->sub = cp256pSub; - pGF->neg = cp256pNeg; - pGF->mul = cp256pMul; - pGF->sqr = cp256pSqr; - pGF->div2= cp256pHalve; - } - #endif - - ptr += sizeof(IppsGFpState); - GFP_MODULUS(pGF) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T); - GFP_HMODULUS(pGF) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T); - GFP_QNR(pGF) = (BNU_CHUNK_T*)(ptr); ptr += elemLen*sizeof(BNU_CHUNK_T); - GFP_MONT(pGF) = (IppsMontState*)( IPP_ALIGNED_PTR((ptr), (MONT_ALIGNMENT)) ); ptr += montgomeryCtxSize; - GFP_POOL(pGF) = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(ptr, (int)sizeof(BNU_CHUNK_T))); - - ippsMontInit(ippBinaryMethod, elemLen32, GFP_MONT(pGF)); - ippsMontSet(pPrime, elemLen32, GFP_MONT(pGF)); - - /* modulus */ - cpGFpElementPadd(GFP_MODULUS(pGF), elemLen, 0); - COPY_BNU((Ipp32u*)GFP_MODULUS(pGF), pPrime, elemLen32); - /* half of modulus */ - cpGFpElementPadd(GFP_HMODULUS(pGF), elemLen, 0); - cpLSR_BNU(GFP_HMODULUS(pGF), GFP_MODULUS(pGF), elemLen, 1); - - /* do some additional initialization to make sqrt operation faster */ - cpGFpElementPadd(GFP_QNR(pGF), elemLen, 0); - gfpInitSqrt(pGF); - - return ippStsNoErr; - } -} - - -IPPFUN(IppStatus, ippsGFpScratchBufferSize,(int nExponents, int ExpBitSize, const IppsGFpState* pGF, int* pBufferSize)) -{ - IPP_BAD_PTR2_RET(pGF, pBufferSize); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - - IPP_BADARG_RET( (0>=nExponents)||(nExponents>LOG2_CACHE_LINE_SIZE), ippStsBadArgErr); - - { - int elmDataSize = GFP_FELEN(pGF)*sizeof(BNU_CHUNK_T); - - /* get window_size */ - int w = (nExponents==1)? cpGFpGetOptimalWinSize(ExpBitSize) : /* use optimal window size, if single-scalar operation */ - nExponents; /* or pseudo-oprimal if multi-scalar operation */ - - /* number of table entries */ - int nPrecomputed = 1<nsA, ippStsSizeErr); - - { - int elemLen = GFP_FELEN(pGF); - - Ipp8u* ptr = (Ipp8u*)pR; - - GFPE_ID(pR) = idCtxGFPE; - GFPE_ROOM(pR) = elemLen; - ptr += sizeof(IppsGFpElement); - GFPE_DATA(pR) = (BNU_CHUNK_T*)ptr; - - return ippsGFpSetElement(pA, nsA, pR, pGF); - } -} - -IPPFUN(IppStatus, ippsGFpSetElement,(const Ipp32u* pDataA, int nsA, IppsGFpElement* pElm, IppsGFpState* pGF)) -{ - IPP_BAD_PTR2_RET(pElm, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - - IPP_BADARG_RET( (pDataA && (nsA<0)), ippStsSizeErr ); - - { - IppStatus sts = ippStsNoErr; - - int elemLen32 = GFP_FELEN32(pGF); - if(pDataA) FIX_BNU(pDataA, nsA); - if(pDataA && (nsA>elemLen32)) IPP_ERROR_RET(ippStsOutOfRangeErr); - - { - BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGF); - int elemLen = GFP_FELEN(pGF); - ZEXPAND_BNU(pTmp, 0, elemLen); - if(pDataA) - cpGFpxCopyToChunk(pTmp, pDataA, nsA, pGF); - - if(!cpGFpxSet(GFPE_DATA(pElm), pTmp, elemLen, pGF, USE_MONT_SPACE_REPRESENTATION)) - sts = ippStsOutOfRangeErr; - - cpGFpReleasePool(1, pGF); - } - - return sts; - } -} - -IPPFUN(IppStatus, ippsGFpSetElementOctString,(const Ipp8u* pStr, int strSize, IppsGFpElement* pElm, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pStr, pElm, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - - { - IppsGFpState* pBasicGF = cpGFpBasic(pGF); - int basicDeg = cpGFpBasicDegreeExtension(pGF); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGF),GFP_FELEN(pBasicGF))); - - BNU_CHUNK_T* pDataElm = GFPE_DATA(pElm); - - int deg, error; - /* set element to zero */ - cpGFpElementPadd(pDataElm, GFP_FELEN(pGF), 0); - - /* convert oct string to element (from low to high) */ - for(deg=0, error=0; deg GF_POOL_SIZE*GFP_PESIZE(pGFp)*BITSIZE(ipp32u), ippStsBadArgErr); - - { - Ipp32u moduloBitSize = GFP_FESIZE32(pGFp)*BITSIZE(ipp32u) - NLZ32u(GFP_MODULUS(pGFp)[GFP_FESIZE32(pGFp)-1]); - if(moduloBitSize>power) { - gfpFFelementPadd(0, GFPE_DATA(pR), GFP_FELEN(pGFp)); - SET_BIT(GFPE_DATA(pR), power); - } - else { - Ipp32u dataLen = BITS2WORD32_SIZE(power+1); - Ipp32u* pData = GFP_POOL(pGFp); - gfpFFelementPadd(0, pData, dataLen); - SET_BIT(pData, power); - gfpReduce(pData, dataLen, GFPE_DATA(pR), pGFp); - } - return ippStsNoErr; - } -} -#endif - - -IPPFUN(IppStatus, ippsGFpSetElementRandom,(IppBitSupplier rndFunc, void* pRndParam, - IppsGFpElement* pElm, IppsGFpState* pGF)) -{ - IPP_BAD_PTR2_RET(pElm, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - - cpGFpxRand(GFPE_DATA(pElm), pGF, rndFunc, pRndParam, USE_MONT_SPACE_REPRESENTATION); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpCpyElement, (const IppsGFpElement* pElmA, IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - cpGFpElementCopy(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFP_FELEN(pGF)); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpGetElement, (const IppsGFpElement* pElm, Ipp32u* pDataA, int nsA, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElm, pDataA, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - IPP_BADARG_RET( 0>nsA, ippStsSizeErr ); - - { - int elemLen = GFP_FELEN(pGF); - BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGF); - - cpGFpxGet(pTmp, elemLen, GFPE_DATA(pElm), pGF, USE_MONT_SPACE_REPRESENTATION); - cpGFpxCopyFromChunk(pDataA, pTmp, pGF); - - cpGFpReleasePool(1, pGF); - return ippStsNoErr; - } -} - -IPPFUN(IppStatus, ippsGFpGetElementOctString,(const IppsGFpElement* pElm, Ipp8u* pStr, int strSize, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pStr, pElm, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - - { - IppsGFpState* pBasicGF = cpGFpBasic(pGF); - int basicDeg = cpGFpBasicDegreeExtension(pGF); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicSize = BITS2WORD8_SIZE(BITSIZE_BNU(GFP_MODULUS(pBasicGF),GFP_FELEN(pBasicGF))); - - BNU_CHUNK_T* pDataElm = GFPE_DATA(pElm); - - int deg; - for(deg=0; degnsT, ippStsSizeErr ); - - if(termDegree>=0 && termDegree * GFP_FELEN(pGF) < GFPE_ROOM(pElm) ) - cpGFpxSetPolyTerm(GFPE_DATA(pElm), termDegree, pTerm, nsT, pGF, USE_MONT_SPACE_REPRESENTATION); - return ippStsNoErr; -} -#endif - -#if 0 -IPPFUN(IppStatus, ippsGFpGetPolyTerm, (const IppsGFpElement* pElm, int termDegree, Ipp32u* pTerm, int nsT, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElm, pTerm, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElm), ippStsContextMatchErr ); - IPP_BADARG_RET( 0>nsT, ippStsSizeErr ); - - cpGFpElementPadd(pTerm, nsT, 0); - if(termDegree>=0 && termDegree * GFP_FELEN(pGF) < GFPE_ROOM(pElm) ) - cpGFpxGetPolyTerm(pTerm, nsT, GFPE_DATA(pElm), termDegree, pGF, USE_MONT_SPACE_REPRESENTATION); - return ippStsNoErr; -} -#endif - -IPPFUN(IppStatus, ippsGFpConj,(const IppsGFpElement* pElmA, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( 2!=GFP_DEGREE(pGF), ippStsBadArgErr ) - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - cpGFpxConj(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpNeg,(const IppsGFpElement* pElmA, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - pGF->neg(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGF); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpInv,(const IppsGFpElement* pElmA, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - IPP_BADARG_RET( GFP_IS_ZERO(GFPE_DATA(pElmA),GFP_FELEN(pGF)), ippStsDivByZeroErr ); - - return NULL != cpGFpxInv(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGF)? ippStsNoErr : ippStsBadArgErr; -} - - -IPPFUN(IppStatus, ippsGFpSqrt,(const IppsGFpElement* pElmA, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFP_IS_BASIC(pGF), ippStsBadArgErr ) - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - return cpGFpSqrt(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGF)? ippStsNoErr : ippStsQuadraticNonResidueErr; -} - - -IPPFUN(IppStatus, ippsGFpAdd,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - pGF->add(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB), pGF); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpSub,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - pGF->sub(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpMul,(const IppsGFpElement* pElmA, const IppsGFpElement* pElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - pGF->mul(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pElmB), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpSqr,(const IppsGFpElement* pElmA, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR3_RET(pElmA, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - pGF->sqr(GFPE_DATA(pElmR), GFPE_DATA(pElmA), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpAdd_GFpE,(const IppsGFpElement* pElmA, const IppsGFpElement* pGroundElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pGroundElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( GFP_IS_BASIC(pGF), ippStsBadArgErr ) - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pGroundElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - cpGFpxAdd_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pGroundElmB), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpSub_GFpE,(const IppsGFpElement* pElmA, const IppsGFpElement* pGroundElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pGroundElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( GFP_IS_BASIC(pGF), ippStsBadArgErr ) - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pGroundElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - cpGFpxSub_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pGroundElmB), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpMul_GFpE,(const IppsGFpElement* pElmA, const IppsGFpElement* pGroundElmB, - IppsGFpElement* pElmR, IppsGFpState* pGF)) -{ - IPP_BAD_PTR4_RET(pElmA, pGroundElmB, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( GFP_IS_BASIC(pGF), ippStsBadArgErr ) - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pGroundElmB), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - cpGFpxMul_GFE(GFPE_DATA(pElmR), GFPE_DATA(pElmA), GFPE_DATA(pGroundElmB), pGF); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpExp,(const IppsGFpElement* pElmA, const IppsBigNumState* pE, - IppsGFpElement* pElmR, IppsGFpState* pGF, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR4_RET(pElmA, pE, pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmA), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - IPP_BADARG_RET( !BN_VALID_ID(pE), ippStsContextMatchErr ); - IPP_BADARG_RET( BN_SIZE(pE) > GFP_FELEN(pGF), ippStsRangeErr ); - - cpGFpxExp(GFPE_DATA(pElmR), GFPE_DATA(pElmA), BN_NUMBER(pE), BN_SIZE(pE), pGF, pScratchBuffer); - - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpMultiExp,(const IppsGFpElement* const ppElmA[], const IppsBigNumState* const ppE[], int nItems, - IppsGFpElement* pElmR, IppsGFpState* pGF, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR2_RET(pElmR, pGF); - pGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGF), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pElmR), ippStsContextMatchErr ); - - IPP_BAD_PTR2_RET(ppElmA, ppE); - - if(nItems==1) - return ippsGFpExp(ppElmA[0], ppE[0], pElmR, pGF, pScratchBuffer); - - else { - int n; - for(n=0; n GFP_FELEN(pGF), ippStsRangeErr ); - } - - if(NULL==pScratchBuffer) { - BNU_CHUNK_T* pTmpR = cpGFpGetPool(1, pGF); - cpGFpxExp(GFPE_DATA(pElmR), GFPE_DATA(ppElmA[0]), BN_NUMBER(ppE[0]), BN_SIZE(ppE[0]), pGF, 0); - for(n=1; n=nScalars)||(nScalars>LOG2_CACHE_LINE_SIZE), ippStsBadArgErr); - - { - int pointDataSize = ECP_FELEN(pEC)*sizeof(BNU_CHUNK_T); - - /* get window_size */ - #if 0 - int w = (nScalars==1)? cpEcGFpGetOptimalWinSize(orderBitSize) : /* use optimal window size, if single-scalar operation */ - nScalars; /* or pseudo-oprimal if multi-scalar operation */ - #endif - int w = (nScalars==1)? 5 : nScalars; - - /* number of table entries */ - int nPrecomputed = 1<ECP_ORDBITSIZE(pEC), ippStsRangeErr) - - ECP_ORDBITSIZE(pEC) = inOrderBitSize; - ZEXPAND_COPY_BNU((Ipp32u*)ECP_R(pEC), BITS_BNU_CHUNK(inOrderBitSize)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pOrder,ordLen); - } - - if(pCofactor) { - int cofactorOrderBitSize; - FIX_BNU(pCofactor, cofactorLen); - cofactorOrderBitSize = BITSIZE_BNU32(pCofactor, cofactorLen); - IPP_BADARG_RET(cofactorOrderBitSize>elemLen*BITSIZE(BNU_CHUNK_T), ippStsRangeErr) - cofactorLen = BITS2WORD32_SIZE(cofactorOrderBitSize); - ZEXPAND_COPY_BNU((Ipp32u*)ECP_COFACTOR(pEC), BITS_BNU_CHUNK(cofactorOrderBitSize)*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pCofactor,cofactorLen); - } - - return ippStsNoErr; - } -} - -IPPFUN(IppStatus, ippsGFpECGet,(const IppsGFpECState* pEC, - const IppsGFpState** ppGF, - IppsGFpElement* pA, IppsGFpElement* pB, - IppsGFpElement* pX, IppsGFpElement* pY, - const Ipp32u** ppOrder, int* pOrderLen, - const Ipp32u** ppCofactor, int* pCofactorLen)) -{ - IPP_BAD_PTR1_RET(pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - - { - const IppsGFpState* pGF = ECP_GFP(pEC); - Ipp32u elementSize = GFP_FELEN(pGF); - - if(ppGF) { - *ppGF = pGF; - } - - if(pA) { - IPP_BADARG_RET( !GFPE_TEST_ID(pA), ippStsContextMatchErr ); - cpGFpElementCopy(GFPE_DATA(pA), ECP_A(pEC), elementSize); - } - if(pB) { - IPP_BADARG_RET( !GFPE_TEST_ID(pB), ippStsContextMatchErr ); - cpGFpElementCopy(GFPE_DATA(pB), ECP_B(pEC), elementSize); - } - - if(pX) { - IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr ); - cpGFpElementCopy(GFPE_DATA(pX), ECP_G(pEC), elementSize); - } - if(pY) { - IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr ); - cpGFpElementCopy(GFPE_DATA(pY), ECP_G(pEC)+elementSize, elementSize); - } - - if(ppOrder) { - *ppOrder = (Ipp32u*)ECP_R(pEC); - } - if(pOrderLen) { - *pOrderLen = BITS2WORD32_SIZE(ECP_ORDBITSIZE(pEC)); - } - - if(ppCofactor) { - *ppCofactor = (Ipp32u*)ECP_COFACTOR(pEC); - } - if(pCofactorLen) { - int cofactorLen = GFP_FELEN32(pGF); - FIX_BNU((Ipp32u*)ECP_COFACTOR(pEC), cofactorLen); - *pCofactorLen = cofactorLen; - } - - return ippStsNoErr; - } -} - -IPPFUN(IppStatus, ippsGFpECVerify,(IppECResult* pResult, IppsGFpECState* pEC, Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR2_RET(pEC, pResult); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - - *pResult = ippECValid; - - { - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* - // check discriminant ( 4*A^3 + 27*B^2 != 0 mod P) - */ - if(ippECValid == *pResult) { - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pU = cpGFpGetPool(1, pGF); - - if(EPID_PARAMS(pEC)) - cpGFpElementPadd(pT, elemLen, 0); /* T = 4*A^3 = 0 */ - else { - pGF->add(pT, ECP_A(pEC), ECP_A(pEC), pGF); /* T = 4*A^3 */ - pGF->sqr(pT, pT, pGF); - pGF->mul(pT, ECP_A(pEC), pT, pGF); - } - - pGF->add(pU, ECP_B(pEC), ECP_B(pEC), pGF); /* U = 9*B^2 */ - pGF->add(pU, pU, ECP_B(pEC), pGF); - pGF->sqr(pU, pU, pGF); - - pGF->add(pT, pU, pT, pGF); /* T += 3*U */ - pGF->add(pT, pU, pT, pGF); - pGF->add(pT, pU, pT, pGF); - - *pResult = GFP_IS_ZERO(pT, elemLen)? ippECIsZeroDiscriminant: ippECValid; - - cpGFpReleasePool(2, pGF); - } - - /* - // check base point and it order - */ - if(ippECValid == *pResult) { - IppsGFpECPoint G; - cpEcGFpInitPoint(&G, ECP_G(pEC), ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC); - - /* check G != infinity */ - *pResult = cpEcGFpIsProjectivePointAtInfinity(&G, elemLen)? ippECPointIsAtInfinite : ippECValid; - - /* check G lies on EC */ - if(ippECValid == *pResult) - *pResult = cpEcGFpIsPointOnCurve(&G, pEC)? ippECValid : ippECPointIsNotValid; - - /* check Gorder*G = infinity */ - if(ippECValid == *pResult) { - IppsGFpECPoint T; - cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC); - - cpEcGFpMulPoint(&T, &G, ECP_R(pEC), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer); - *pResult = cpEcGFpIsProjectivePointAtInfinity(&T, elemLen)? ippECValid : ippECInvalidOrder; - - cpEcGFpReleasePool(1, pEC); - } - } - - return ippStsNoErr; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpoint.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpoint.c deleted file mode 100644 index d1901b3372..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpoint.c +++ /dev/null @@ -1,426 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Intel(R) Performance Primitives. Cryptography Primitives. -// EC over GF(p) Operations -// -// Context: -// ippsGFpECPointGetSize() -// ippsGFpECPointInit() -// -// ippsGFpECSetPointAtInfinity() -// ippsGFpECSetPoint() -// ippsGFpECMakePoint() -// ippsGFpECSetPointRandom() -// ippsGFpECSetPointHash() -// ippsGFpECGetPoint() -// ippsGFpECCpyPoint() -// -// ippsGFpECCmpPoint() -// ippsGFpECTstPoint() -// ippsGFpECNegPoint() -// ippsGFpECAddPoint() -// ippsGFpECMulPoint() -// -// -*/ - -#include "owncpepid.h" - -#include "pcpgfpecstuff.h" -#include "pcpgfphashstuff.h" - - -IPPFUN(IppStatus, ippsGFpECPointGetSize,(const IppsGFpECState* pEC, int* pSizeInBytes)) -{ - IPP_BAD_PTR2_RET(pEC, pSizeInBytes); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - - { - int elemLen = GFP_FELEN(ECP_GFP(pEC)); - *pSizeInBytes = sizeof(IppsGFpECPoint) - +elemLen*sizeof(BNU_CHUNK_T) /* X */ - +elemLen*sizeof(BNU_CHUNK_T) /* Y */ - +elemLen*sizeof(BNU_CHUNK_T);/* Z */ - return ippStsNoErr; - } -} - - -IPPFUN(IppStatus, ippsGFpECPointInit,(const IppsGFpElement* pX, const IppsGFpElement* pY, - IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - - { - Ipp8u* ptr = (Ipp8u*)pPoint; - int elemLen = GFP_FELEN(ECP_GFP(pEC)); - - ECP_POINT_ID(pPoint) = idCtxGFPPoint; - ECP_POINT_FLAGS(pPoint) = 0; - ECP_POINT_FELEN(pPoint) = elemLen; - ptr += sizeof(IppsGFpECPoint); - ECP_POINT_DATA(pPoint) = (BNU_CHUNK_T*)(ptr); - - if(pX && pY) - return ippsGFpECSetPoint(pX, pY, pPoint, pEC); - else { - cpEcGFpSetProjectivePointAtInfinity(pPoint, elemLen); - return ippStsNoErr; - } - } -} - - -IPPFUN(IppStatus, ippsGFpECSetPointAtInfinity,(IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - - cpEcGFpSetProjectivePointAtInfinity(pPoint, GFP_FELEN(ECP_GFP(pEC))); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpECSetPoint,(const IppsGFpElement* pX, const IppsGFpElement* pY, - IppsGFpECPoint* pPoint, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - - IPP_BAD_PTR2_RET(pX, pY); - IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pY), ippStsContextMatchErr ); - - cpEcGFpSetAffinePoint(pPoint, GFPE_DATA(pX), GFPE_DATA(pY), pEC); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpECMakePoint,(const IppsGFpElement* pX, IppsGFpECPoint* pPoint, IppsGFpECState* pEC)) -{ - IPP_BAD_PTR3_RET(pX, pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFP_IS_BASIC(ECP_GFP(pEC)), ippStsBadArgErr ); - IPP_BADARG_RET( !GFPE_TEST_ID(pX), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - - return cpEcGFpMakePoint(pPoint, GFPE_DATA(pX), pEC)? ippStsNoErr : ippStsQuadraticNonResidueErr; -} - - -IPPFUN(IppStatus, ippsGFpECSetPointRandom,(IppBitSupplier rndFunc, void* pRndParam, - IppsGFpECPoint* pPoint, IppsGFpECState* pEC, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - - IPP_BAD_PTR1_RET(rndFunc); - - { - IppsGFpState* pGF = ECP_GFP(pEC); - - if( GFP_IS_BASIC(pGF) ) { - BNU_CHUNK_T* pElm = cpGFpGetPool(1, pGF); - - do { - /* get random X */ - cpGFpRand(pElm, pGF, rndFunc, pRndParam, USE_MONT_SPACE_REPRESENTATION); - } while( !cpEcGFpMakePoint(pPoint, pElm, pEC) ); - - cpGFpReleasePool(1, pGF); - - /* R = cofactor*R */ - cpEcGFpMulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGF), pEC, pScratchBuffer); - - return ippStsNoErr; - } - - else { - /* number of bits and dwords being begerated */ - int generatedBits = ECP_ORDBITSIZE(pEC) + GF_RAND_ADD_BITS; - int generatedLen = BITS_BNU_CHUNK(generatedBits); - - /* allocate random exponent */ - int poolElements = (generatedLen + GFP_PELEN(pGF) -1) / GFP_PELEN(pGF); - BNU_CHUNK_T* pExp = cpGFpGetPool(poolElements, pGF); - - int nsE; - - /* setup copy of the base point */ - IppsGFpECPoint G; - cpEcGFpInitPoint(&G, ECP_G(pEC),ECP_AFFINE_POINT|ECP_FINITE_POINT, pEC); - - /* get random bits */ - rndFunc((Ipp32u*)pExp, generatedBits, pRndParam); - /* reduce with respect to order value */ - nsE = cpMod_BNU(pExp, generatedLen, ECP_R(pEC), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC))); - - /* compute random point */ - cpEcGFpMulPoint(pPoint, &G, pExp, nsE, pEC, pScratchBuffer); - - cpGFpReleasePool(poolElements, pGF); - - return ippStsNoErr; - } - } -} - - -IPPFUN(IppStatus, ippsGFpECGetPoint,(const IppsGFpECPoint* pPoint, - IppsGFpElement* pX, IppsGFpElement* pY, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - - IPP_BADARG_RET( !IS_ECP_FINITE_POINT(pPoint), ippStsPointAtInfinity); - - IPP_BADARG_RET( pX && !GFPE_TEST_ID(pX), ippStsContextMatchErr ); - IPP_BADARG_RET( pY && !GFPE_TEST_ID(pY), ippStsContextMatchErr ); - - cpEcGFpGetAffinePoint((pX)? GFPE_DATA(pX):0, (pY)?GFPE_DATA(pY):0, pPoint, pEC); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpECCpyPoint,(const IppsGFpECPoint* pA, - IppsGFpECPoint* pR, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR3_RET(pA, pR, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pA), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr ); - - cpEcGFpCopyPoint(pR, pA, GFP_FELEN(ECP_GFP(pEC))); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpECCmpPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, - IppECResult* pResult, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR4_RET(pP, pQ, pResult, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr ); - - *pResult = cpEcGFpIsPointEquial(pP, pQ, pEC)? ippECPointIsEqual : ippECPointIsNotEqual; - return ippStsNoErr; -} - -#if 0 -IPPFUN(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP, - IppECResult* pResult, - IppsGFpECState* pEC, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR3_RET(pP, pResult, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - - { - Ipp32u elemLen = GFP_FELEN(ECP_GFP(pEC)); - - if( cpEcGFpIsProjectivePointAtInfinity(pP, elemLen) ) - *pResult = ippECPointIsAtInfinite; - else if( !cpEcGFpIsPointOnCurve(pP, pEC) ) - *pResult = ippECPointIsNotValid; - else { - IppsGFpECPoint T; - cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC); - cpEcGFpMulPoint(&T, pP, ECP_R(pEC), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer); - *pResult = cpEcGFpIsProjectivePointAtInfinity(&T, elemLen)? ippECValid : ippECPointOutOfGroup; - cpEcGFpReleasePool(1, pEC); - } - - return ippStsNoErr; - } -} -#endif - -/* -// Version below is based on observation has been done by Zhao Hui Du. -// See "Opportunity to improve Intel(R) EPID 2.0 performance" Gentry Mark e-mail 1/23/20015. -// -// Shortly: In case of Intel(R) EPID 2.0 EC parameters all EC points belongs to G1. -*/ -IPPFUN(IppStatus, ippsGFpECTstPoint,(const IppsGFpECPoint* pP, - IppECResult* pResult, - IppsGFpECState* pEC, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR3_RET(pP, pResult, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - - { - Ipp32u elemLen = GFP_FELEN(ECP_GFP(pEC)); - - if( cpEcGFpIsProjectivePointAtInfinity(pP, elemLen) ) - *pResult = ippECPointIsAtInfinite; - else if( !cpEcGFpIsPointOnCurve(pP, pEC) ) - *pResult = ippECPointIsNotValid; - else { - if(EPID_PARAMS(pEC)&&GFP_IS_BASIC(ECP_GFP(pEC))) - *pResult = ippECValid; - else { - IppsGFpECPoint T; - cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC); - cpEcGFpMulPoint(&T, pP, ECP_R(pEC), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC)), pEC, pScratchBuffer); - *pResult = cpEcGFpIsProjectivePointAtInfinity(&T, elemLen)? ippECValid : ippECPointOutOfGroup; - cpEcGFpReleasePool(1, pEC); - } - } - - return ippStsNoErr; - } -} - - -IPPFUN(IppStatus, ippsGFpECNegPoint,(const IppsGFpECPoint* pP, - IppsGFpECPoint* pR, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR3_RET(pP, pR, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr ); - - cpEcGFpNegPoint(pR, pP, pEC); - return ippStsNoErr; -} - - -IPPFUN(IppStatus, ippsGFpECAddPoint,(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECPoint* pR, - IppsGFpECState* pEC)) -{ - IPP_BAD_PTR4_RET(pP, pQ, pR, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pQ), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr ); - - cpEcGFpAddPoint(pR, pP, pQ, pEC); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpECMulPoint,(const IppsGFpECPoint* pP, - const IppsBigNumState* pN, - IppsGFpECPoint* pR, - IppsGFpECState* pEC, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR3_RET(pP, pR, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pP), ippStsContextMatchErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pR), ippStsContextMatchErr ); - - IPP_BAD_PTR1_RET(pN); - pN = (IppsBigNumState*)( IPP_ALIGNED_PTR(pN, BN_ALIGNMENT) ); - /* test if N >= order */ - IPP_BADARG_RET(0<=cpCmp_BNU(BN_NUMBER(pN), BN_SIZE(pN), ECP_R(pEC), BITS_BNU_CHUNK(ECP_ORDBITSIZE(pEC))), ippStsOutOfRangeErr); - - cpEcGFpMulPoint(pR, pP, BN_NUMBER(pN), BN_SIZE(pN), pEC, pScratchBuffer); - return ippStsNoErr; -} - -IPPFUN(IppStatus, ippsGFpECSetPointHash,(Ipp32u hdr, const Ipp8u* pMsg, int msgLen, IppHashID hashID, IppsGFpECPoint* pPoint, - IppsGFpECState* pEC, - Ipp8u* pScratchBuffer)) -{ - IPP_BAD_PTR2_RET(pPoint, pEC); - pEC = (IppsGFpECState*)( IPP_ALIGNED_PTR(pEC, ECGFP_ALIGNMENT) ); - IPP_BADARG_RET( !ECP_TEST_ID(pEC), ippStsContextMatchErr ); - IPP_BADARG_RET( !GFP_IS_BASIC(ECP_GFP(pEC)), ippStsBadArgErr ); - IPP_BADARG_RET( !ECP_POINT_TEST_ID(pPoint), ippStsContextMatchErr ); - IPP_BADARG_RET( !cpTestHashID(hashID), ippStsBadArgErr); - - { - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - - Ipp8u md[IPP_SHA512_DIGEST_BITSIZE/BYTESIZE]; - int hashLen = cpHashLength(hashID); - BNU_CHUNK_T hashVal[BITS_BNU_CHUNK(IPP_SHA512_DIGEST_BITSIZE)+1]; - int hashValLen; - - Ipp8u hashCtx[sizeof(IppsSHA512State)+SHA512_ALIGNMENT-1]; - cpHashInit(hashCtx, hashID); - - { - BNU_CHUNK_T* pPoolElm = cpGFpGetPool(1, pGF); - - /* convert hdr => hdrStr */ - BNU_CHUNK_T locHdr = (BNU_CHUNK_T)hdr; - Ipp8u hdrOctStr[sizeof(hdr/*locHdr*/)]; - cpToOctStr_BNU(hdrOctStr, sizeof(hdrOctStr), &locHdr, 1); - - /* compute md = hash(hrd||msg) */ - cpHashUpdate(hdrOctStr, sizeof(hdrOctStr), hashCtx, hashID); - cpHashUpdate(pMsg, msgLen, hashCtx, hashID); - cpHashFinal(md, hashCtx, hashID); - - /* convert hash into the integer */ - hashValLen = cpFromOctStr_BNU(hashVal, md, hashLen); - hashValLen = cpMod_BNU(hashVal, hashValLen, pModulus, elemLen); - cpGFpSet(pPoolElm, hashVal, hashValLen, pGF, USE_MONT_SPACE_REPRESENTATION); - - if( cpEcGFpMakePoint(pPoint, pPoolElm, pEC)) { - /* set y-coordinate of the point (positive or negative) */ - BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint); - if(pY[0] & 1) - cpGFpNeg(pY, pY, pGF); - - /* update point if cofactor>1 */ - cpEcGFpMulPoint(pPoint, pPoint, ECP_COFACTOR(pEC), GFP_FELEN(pGF), pEC, pScratchBuffer); - - cpGFpReleasePool(1, pGF); - return ippStsNoErr; - } - } - - cpGFpReleasePool(1, pGF); - return ippStsQuadraticNonResidueErr; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpointstuff.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpointstuff.c deleted file mode 100644 index 978da1b649..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecpointstuff.c +++ /dev/null @@ -1,1227 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Intel(R) Performance Primitives. Cryptography Primitives. -// Internal EC over GF(p^m) basic Definitions & Function Prototypes -// -// Context: -// cpEcGFpMakePoint() -// cpEcGFpGetAffinePoint -// -// cpEcGFpIsPointEquial() -// cpEcGFpIsPointOnCurve() -// -// cpEcGFpNegPoint() -// cpEcGFpDblPoint() -// cpEcGFpAddPoint() -// cpEcGFpMulPoint() -// -// -// -*/ - -#include "owncpepid.h" - -#include "pcpgfpecstuff.h" -//#include "pcptool.h" - - -int cpEcGFpMakePoint(IppsGFpECPoint* pPoint, const BNU_CHUNK_T* pElm, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - BNU_CHUNK_T* pX = ECP_POINT_X(pPoint); - BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint); - - /* set x-coordinate */ - cpGFpElementCopy(pX, pElm, elemLen); - - /* T = X^3 + A*X + B */ - cpGFpxSqr(pY, pX, pGF); - pGF->mul(pY, pY, pX, pGF); - if(!EPID_PARAMS(pEC)) { - pGF->mul(pZ, ECP_A(pEC), pX, pGF); - pGF->add(pY, pY, pZ, pGF); - } - pGF->add(pY, pY, ECP_B(pEC), pGF); - - /* set z-coordinate =1 */ - cpGFpElementCopyPadd(pZ, elemLen, MNT_1(GFP_MONT(pGF)), GFP_FELEN(pGF)); - - /* Y = sqrt(Y) */ - if( cpGFpSqrt(pY, pY, pGF) ) { - ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT; - return 1; - } - else { - cpEcGFpSetProjectivePointAtInfinity(pPoint, elemLen); - //ECP_POINT_FLAGS(pPoint) = 0; - return 0; - } -} - -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -int cpEcGFpGetAffinePoint(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, const IppsGFpECPoint* pPoint, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - if( !IS_ECP_FINITE_POINT(pPoint) ) { - //GFP_ZERO(pX, elemLen); - //if( GFP_IS_ZERO(ECP_B(pEC), elemLen) ) - // GFP_ONE(pY, elemLen); - //else - // GFP_ZERO(pY, elemLen); - //return; - return 0; - } - - /* case Z == 1 */ - if( IS_ECP_AFFINE_POINT(pPoint) ) { - if(pX) - cpGFpElementCopy(pX, ECP_POINT_X(pPoint), elemLen); - if(pY) - cpGFpElementCopy(pY, ECP_POINT_Y(pPoint), elemLen); - } - - /* case Z != 1 */ - else { - /* T = (1/Z)*(1/Z) */ - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pZinv = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pU = cpGFpGetPool(1, pGF); - cpGFpxInv(pZinv, ECP_POINT_Z(pPoint), pGF); - pGF->sqr(pT, pZinv, pGF); - - if(pX) { - pGF->mul(pU, ECP_POINT_X(pPoint), pT, pGF); - cpGFpElementCopy(pX, pU, elemLen); - } - if(pY) { - pGF->mul(pT, pZinv, pT, pGF); - pGF->mul(pU, ECP_POINT_Y(pPoint), pT, pGF); - cpGFpElementCopy(pY, pU, elemLen); - } - - cpGFpReleasePool(3, pGF); - } - - return 1; -} -#endif - -#if ( ECP_PROJECTIVE_COORD == HOMOGENEOUS ) -int cpEcGFpGetAffinePoint(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, const IppsGFpECPoint* pPoint, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - if( !IS_ECP_FINITE_POINT(pPoint) ) { - return 0; - } - - /* case Z == 1 */ - if( IS_ECP_AFFINE_POINT(pPoint) ) { - if(pX) - cpGFpElementCopy(pX, ECP_POINT_X(pPoint), elemLen); - if(pY) - cpGFpElementCopy(pY, ECP_POINT_Y(pPoint), elemLen); - } - - /* case Z != 1 */ - else { - /* T = (1/Z) */ - BNU_CHUNK_T* pZinv = cpGFpGetPool(1, pGF); - cpGFpxInv(pZinv, ECP_POINT_Z(pPoint), pGF); - - if(pX) { - pGF->mul(pX, ECP_POINT_X(pPoint), pZinv, pGF); - } - if(pY) { - pGF->mul(pY, ECP_POINT_Y(pPoint), pZinv, pGF); - } - - cpGFpReleasePool(1, pGF); - } - - return 1; -} -#endif - -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -int cpEcGFpIsPointEquial(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* P or/and Q at Infinity */ - if( !IS_ECP_FINITE_POINT(pP) ) - return !IS_ECP_FINITE_POINT(pQ)? 1:0; - if( !IS_ECP_FINITE_POINT(pQ) ) - return !IS_ECP_FINITE_POINT(pP)? 1:0; - - /* Px==Qx && Py==Qy && Pz==Qz */ - if( GFP_EQ(ECP_POINT_Z(pP), ECP_POINT_Z(pQ), elemLen) - &&GFP_EQ(ECP_POINT_X(pP), ECP_POINT_X(pQ), elemLen) - &&GFP_EQ(ECP_POINT_Y(pP), ECP_POINT_Y(pQ), elemLen)) - return 1; - - else { - int isEqu = 1; - - BNU_CHUNK_T* pPtmp = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pQtmp = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pPz = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pQz = cpGFpGetPool(1, pGF); - - if(isEqu) { - /* Px*Qz^2 ~ Qx*Pz^2 */ - if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Px * Qz^2 */ - cpGFpElementCopy(pPtmp, ECP_POINT_X(pP), elemLen); - else { - pGF->sqr(pQz, ECP_POINT_Z(pQ), pGF); - pGF->mul(pPtmp, ECP_POINT_X(pP), pQz, pGF); - } - if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qx * Pz^2 */ - cpGFpElementCopy(pQtmp, ECP_POINT_X(pQ), elemLen); - else { - pGF->sqr(pPz, ECP_POINT_Z(pP), pGF); - pGF->mul(pQtmp, ECP_POINT_X(pQ), pPz, pGF); - } - isEqu = GFP_EQ(pPtmp, pQtmp, elemLen); - } - - if(isEqu) { - /* Py*Qz^3 ~ Qy*Pz^3 */ - if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Py * Qz^3 */ - cpGFpElementCopy(pPtmp, ECP_POINT_Y(pP), elemLen); - else { - pGF->mul(pQz, ECP_POINT_Z(pQ), pQz, pGF); - pGF->mul(pPtmp, pQz, ECP_POINT_Y(pP), pGF); - } - if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qy * Pz^3 */ - cpGFpElementCopy(pQtmp, ECP_POINT_Y(pQ), elemLen); - else { - pGF->mul(pPz, ECP_POINT_Z(pP), pPz, pGF); - pGF->mul(pQtmp, pPz, ECP_POINT_Y(pQ), pGF); - } - isEqu = GFP_EQ(pPtmp, pQtmp, elemLen); - } - - cpGFpReleasePool(4, pGF); - return isEqu; - } -} -#endif - -#if ( ECP_PROJECTIVE_COORD == HOMOGENEOUS ) -int cpEcGFpIsPointEquial(const IppsGFpECPoint* pP, const IppsGFpECPoint* pQ, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* P or/and Q at Infinity */ - if( !IS_ECP_FINITE_POINT(pP) ) - return !IS_ECP_FINITE_POINT(pQ)? 1:0; - if( !IS_ECP_FINITE_POINT(pQ) ) - return !IS_ECP_FINITE_POINT(pP)? 1:0; - - /* Px==Qx && Py==Qy && Pz==Qz */ - if( GFP_EQ(ECP_POINT_Z(pP), ECP_POINT_Z(pQ), elemLen) - &&GFP_EQ(ECP_POINT_X(pP), ECP_POINT_X(pQ), elemLen) - &&GFP_EQ(ECP_POINT_Y(pP), ECP_POINT_Y(pQ), elemLen)) - return 1; - - else { - int isEqu = 1; - - BNU_CHUNK_T* pPtmp = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pQtmp = cpGFpGetPool(1, pGF); - - if(isEqu) { - /* Px*Qz ~ Qx*Pz */ - if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Px * Qz */ - cpGFpElementCopy(pPtmp, ECP_POINT_X(pP), elemLen); - else { - pGF->mul(pPtmp, ECP_POINT_X(pP), ECP_POINT_Z(pQ), pGF); - } - if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qx * Pz */ - cpGFpElementCopy(pQtmp, ECP_POINT_X(pQ), elemLen); - else { - pGF->mul(pQtmp, ECP_POINT_X(pQ), ECP_POINT_Z(pP), pGF); - } - isEqu = GFP_EQ(pPtmp, pQtmp, elemLen); - } - - if(isEqu) { - /* Py*Qz ~ Qy*Pz */ - if( IS_ECP_AFFINE_POINT(pQ) ) /* Ptmp = Py * Qz */ - cpGFpElementCopy(pPtmp, ECP_POINT_Y(pP), elemLen); - else { - pGF->mul(pPtmp, ECP_POINT_Y(pP), ECP_POINT_Z(pQ), pGF); - } - if( IS_ECP_AFFINE_POINT(pP) ) /* Qtmp = Qy * Pz */ - cpGFpElementCopy(pQtmp, ECP_POINT_Y(pQ), elemLen); - else { - pGF->mul(pQtmp, ECP_POINT_Y(pQ), ECP_POINT_Z(pP), pGF); - } - isEqu = GFP_EQ(pPtmp, pQtmp, elemLen); - } - - cpGFpReleasePool(2, pGF); - return isEqu; - } -} -#endif - -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -int cpEcGFpIsPointOnCurve(const IppsGFpECPoint* pPoint, IppsGFpECState* pEC) -{ - /* point at infinity belongs curve */ - if( !IS_ECP_FINITE_POINT(pPoint) ) - return 1; - - /* test that 0 == R = (Y^2) - (X^3 + A*X*(Z^4) + B*(Z^6)) */ - else { - int isOnCurve = 0; - - IppsGFpState* pGF = ECP_GFP(pEC); - - BNU_CHUNK_T* pX = ECP_POINT_X(pPoint); - BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint); - - BNU_CHUNK_T* pR = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - - pGF->sqr(pR, pY, pGF); /* R = Y^2 */ - pGF->sqr(pT, pX, pGF); /* T = X^3 */ - pGF->mul(pT, pX, pT, pGF); - pGF->sub(pR, pR, pT, pGF); /* R -= T */ - - if( IS_ECP_AFFINE_POINT(pPoint) ) { - pGF->mul(pT, pX, ECP_A(pEC), pGF); /* T = A*X */ - pGF->sub(pR, pR, pT, pGF); /* R -= T */ - pGF->sub(pR, pR, ECP_B(pEC), pGF); /* R -= B */ - } - else { - BNU_CHUNK_T* pZ4 = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pZ6 = cpGFpGetPool(1, pGF); - - pGF->sqr(pZ6, pZ, pGF); /* Z^2 */ - pGF->sqr(pZ4, pZ6, pGF); /* Z^4 */ - pGF->mul(pZ6, pZ6, pZ4, pGF); /* Z^6 */ - - pGF->mul(pZ4, pZ4, pX, pGF); /* X*(Z^4) */ - pGF->mul(pZ4, pZ4, ECP_A(pEC), pGF); /* A*X*(Z^4) */ - pGF->mul(pZ6, pZ6, ECP_B(pEC), pGF); /* B*(Z^4) */ - - pGF->sub(pR, pR, pZ4, pGF); /* R -= A*X*(Z^4) */ - pGF->sub(pR, pR, pZ6, pGF); /* R -= B*(Z^6) */ - - cpGFpReleasePool(2, pGF); - } - - isOnCurve = GFP_IS_ZERO(pR, GFP_FELEN(pGF)); - cpGFpReleasePool(2, pGF); - return isOnCurve; - } -} -#endif - -#if ( ECP_PROJECTIVE_COORD == HOMOGENEOUS ) -int cpEcGFpIsPointOnCurve(const IppsGFpECPoint* pPoint, IppsGFpECState* pEC) -{ - /* point at infinity belongs curve */ - if( !IS_ECP_FINITE_POINT(pPoint) ) - return 1; - - /* test that 0 == R = ((Y^2)*Z) - (X^3 + A*X*(Z^2) + B*(Z^3)) */ - else { - int isOnCurve = 0; - - IppsGFpState* pGF = ECP_GFP(pEC); - - BNU_CHUNK_T* pX = ECP_POINT_X(pPoint); - BNU_CHUNK_T* pY = ECP_POINT_Y(pPoint); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pPoint); - - BNU_CHUNK_T* pR = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pU = cpGFpGetPool(1, pGF); - - /* Right = X^3 + A*X*(Z^2) + B*(Z^3) = x^3 +(A*X + B*Z)*Z^2 */ - pGF->sqr(pR, pZ, pGF); /* R = Z^2 */ - pGF->mul(pT, pZ, ECP_B(pEC), pGF); /* T = Z*B */ - if(!EPID_PARAMS(pEC)) { - pGF->mul(pU, pX, ECP_A(pEC), pGF); /* U = X*A */ - pGF->add(pT, pT, pU, pGF); /* T = (A*X + B*Z) * Z^2 */ - } - pGF->mul(pT, pT, pR, pGF); - - pGF->sqr(pR, pX, pGF); /* R = X^3 */ - pGF->mul(pR, pR, pX, pGF); - - pGF->add(pR, pR, pT, pGF); /* R = X^3 + (A*X + B*Z) * Z^2 */ - - /* Left = (Y^2)*Z */ - pGF->sqr(pT, pY, pGF); - pGF->mul(pT, pT, pZ, pGF); - - pGF->sub(pR, pR, pT, pGF); /* Left - Right */ - - isOnCurve = GFP_IS_ZERO(pR, GFP_FELEN(pGF)); - - cpGFpReleasePool(3, pGF); - return isOnCurve; - } -} -#endif - -IppsGFpECPoint* cpEcGFpNegPoint (IppsGFpECPoint* pR, const IppsGFpECPoint* pP, IppsGFpECState* pEC) -{ - int elemLen = GFP_FELEN(ECP_GFP(pEC)); - IppsGFpState* pGF = ECP_GFP(pEC); - - if(pP!=pR) - cpEcGFpCopyPoint(pR, pP, elemLen); - - if( IS_ECP_FINITE_POINT(pR) ) - pGF->neg(ECP_POINT_Y(pR), ECP_POINT_Y(pR), pGF); - return pR; -} - -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -/* general complexity = 6s+4m - epid complexity = 4s+3m -*/ -IppsGFpECPoint* cpEcGFpDblPoint (IppsGFpECPoint* pR, const IppsGFpECPoint* pP, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - BNU_CHUNK_T* pX = ECP_POINT_X(pP); - BNU_CHUNK_T* pY = ECP_POINT_Y(pP); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pP); - - BNU_CHUNK_T* pU = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pM = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pS = cpGFpGetPool(1, pGF); - - /* M = 3*X^2 + A*Z^4 */ - pGF->sqr(pU, pX, pGF); /* s */ - pGF->add(pM, pU, pU, pGF); - pGF->add(pM, pU, pM, pGF); - if(!EPID_PARAMS(pEC)) { - if( IS_ECP_AFFINE_POINT(pP) ) - pGF->add(pM, ECP_A(pEC), pM, pGF); - else { - pGF->sqr(pU, pZ, pGF); /* s */ - pGF->sqr(pU, pU, pGF); /* s */ - pGF->mul(pU, ECP_A(pEC), pU, pGF); /* m */ - pGF->add(pM, pM, pU, pGF); - } - } - - /* U = 2*Y */ - pGF->add(pU, pY, pY, pGF); - - /* Rz = 2*Y*Z */ - if( IS_ECP_AFFINE_POINT(pP) ) - cpGFpElementCopy(ECP_POINT_Z(pR), pU, elemLen); - else - pGF->mul(ECP_POINT_Z(pR), pU, pZ, pGF); /* m */ - - /* S = X*(U^2) = 4*X*Y^2 */ - pGF->sqr(pU, pU, pGF); /* s */ - pGF->mul(pS, pX, pU, pGF); /* m */ - - /* Rx = M^2 - 2*S */ - pGF->sqr(ECP_POINT_X(pR),pM, pGF); /* s */ - pGF->sub(ECP_POINT_X(pR), ECP_POINT_X(pR), pS, pGF); - pGF->sub(ECP_POINT_X(pR), ECP_POINT_X(pR), pS, pGF); - - /* U = (U^2)/2 = (16*Y^4)/2 = 8*Y^4 */ - pGF->sqr(pU, pU, pGF); /* s */ - //cpGFpxHalve(pU, pU, pGF); - pGF->div2(pU, pU, pGF); - - /* Ry = M*(S - Rx) - U */ - pGF->sub(pS, pS, ECP_POINT_X(pR), pGF); - pGF->mul(pS, pM, pS, pGF); /* m */ - pGF->sub(ECP_POINT_Y(pR), pS, pU, pGF); - - //ECP_POINT_FLAGS(pR) = ECP_FINITE_POINT; - ECP_POINT_FLAGS(pR) = cpEcGFpIsProjectivePointAtInfinity(pR, elemLen)? 0 : ECP_FINITE_POINT; - - - cpGFpReleasePool(3, pGF); - - return pR; -} -#endif - -#if ( ECP_PROJECTIVE_COORD == HOMOGENEOUS ) -/* -// A = 3*X^2 + A*Z^2 -// B = Y*Z -// C = X*Y*B -// D = A^2 - 8*C -// new X = 2*B*D -// new Y = A*(4*C - D) - 8*(Y*B)^2 -// new Z = 8*B^3 -// -// general complexity = 5s+8m -// epid complexity = 4s+7m -*/ -IppsGFpECPoint* cpEcGFpDblPoint (IppsGFpECPoint* pR, const IppsGFpECPoint* pP, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* P at infinity => R at infinity */ - if( !IS_ECP_FINITE_POINT(pP) ) - cpEcGFpSetProjectivePointAtInfinity(pR, elemLen); - - else { - BNU_CHUNK_T* pA = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pB = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pC = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pD = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - - BNU_CHUNK_T* pX = ECP_POINT_X(pR); - BNU_CHUNK_T* pY = ECP_POINT_Y(pR); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pR); - if(pR!=pP) { - cpGFpElementCopy(pX, ECP_POINT_X(pP), elemLen); - cpGFpElementCopy(pY, ECP_POINT_Y(pP), elemLen); - cpGFpElementCopy(pZ, ECP_POINT_Z(pP), elemLen); - } - - /* A = 3*X^2 + A*Z^2 */ - pGF->sqr(pC, pX, pGF); /* s */ - pGF->add(pA, pC, pC, pGF); - pGF->add(pA, pA, pC, pGF); - if(!EPID_PARAMS(pEC)) { - pGF->sqr(pB, pZ, pGF); /* s */ - pGF->mul(pB, pB, ECP_A(pEC), pGF); /* m */ - pGF->add(pA, pA, pB, pGF); - } - - /* B = Y*Z */ - pGF->mul(pB, pY, pZ, pGF); /* m */ - - /* C = X*Y*B */ - pGF->mul(pC, pX, pY, pGF); /* m */ - pGF->mul(pC, pC, pB, pGF); /* m */ - - /* D = A^2 - 8*C */ - pGF->sqr(pT, pA, pGF); /* s */ - pGF->add(pD, pC, pC, pGF); - pGF->add(pD, pD, pD, pGF); - pGF->add(pD, pD, pD, pGF); - pGF->sub(pD, pT, pD, pGF); - - /* X = 2*B*D */ - pGF->mul(pX, pB, pD, pGF); /* m */ - pGF->add(pX, pX, pX, pGF); - - pGF->add(pB, pB, pB, pGF); /* B = 2*B */ - - /* Y = A*(4*C-D)-8(Y*B)^2 */ - pGF->mul(pT, pY, pB, pGF); /* m */ - pGF->sqr(pT, pT, pGF); /* s */ /* T = 4*(Y*B)^2 */ - pGF->add(pY, pC, pC, pGF); - pGF->add(pY, pY, pY, pGF); - pGF->sub(pY, pY, pD, pGF); - pGF->mul(pY, pY, pA, pGF); /* m */ - pGF->sub(pY, pY, pT, pGF); - pGF->sub(pY, pY, pT, pGF); - - /* Z = 8*B^3 = (2*B)^3 */ - pGF->sqr(pZ, pB, pGF); /* s */ - pGF->mul(pZ, pZ, pB, pGF); /* m */ - - ECP_POINT_FLAGS(pR) = ECP_FINITE_POINT; - - cpGFpReleasePool(5, pGF); - } - - return pR; -} -#endif - -#if 0 -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -/* -// initial k-Doubling routine: -// -// for(i=0; i R at infinity */ - if( !IS_ECP_FINITE_POINT(pP) ) - return cpEcGFpSetProjectivePointAtInfinity(pR, elemLen); - - else { - BNU_CHUNK_T* pW = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pM = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pS = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pT = cpGFpGetPool(1, pGF); - - BNU_CHUNK_T* pX = ECP_POINT_X(pR); - BNU_CHUNK_T* pY = ECP_POINT_Y(pR); - BNU_CHUNK_T* pZ = ECP_POINT_Z(pR); - if(pR!=pP) { - cpGFpElementCopy(pX, ECP_POINT_X(pP), elemLen); - cpGFpElementCopy(pY, ECP_POINT_Y(pP), elemLen); - cpGFpElementCopy(pZ, ECP_POINT_Z(pP), elemLen); - } - - /* M = 3*X^2 + A*Z^4 */ - pGF->sqr(pS, pX, pGF); /* s */ - pGF->add(pM, pS, pS, pGF); - pGF->add(pM, pM, pS, pGF); - if(!EPID_PARAMS(pEC)) { /* W = A*Z^4 */ - pGF->sqr(pW, pZ, pGF); /* s */ - pGF->sqr(pW, pW, pGF); /* s */ - pGF->mul(pW, pW, ECP_A(pEC), pGF); /* m */ - - pGF->add(pM, pM, pW, pGF); - } - - /* T = 2*Y */ - pGF->add(pT, pY, pY, pGF); - - /* new Z = 2*Y*Z */ - pGF->mul(pZ, pT, pZ, pGF); /* m */ - - /* S = X*(T^2) = 4*X*Y^2 */ - pGF->sqr(pT, pT, pGF); /* s */ - pGF->mul(pS, pX, pT, pGF); /* m */ - - /* T = (T^2)/2 = (16*Y^4)/2 = 8*Y^4 */ - pGF->sqr(pT, pT, pGF); /* s */ - //cpGFpxHalve(pT, pT, pGF); - cpGF->div2(pT, pT, pGF); - - /* new X = M^2 - 2*S */ - pGF->sqr(pX, pM, pGF); /* s */ - pGF->sub(pX, pX, pS, pGF); - pGF->sub(pX, pX, pS, pGF); - - /* new Y = M*(S - new X) - T */ - pGF->sub(pY, pS, pX, pGF); - pGF->mul(pY, pY, pM, pGF); /* m */ - pGF->sub(pY, pY, pT, pGF); - - for(k--; k>0; k--) { - /* new W = 2*T*W */ - if(!EPID_PARAMS(pEC)) { - pGF->mul(pW, pW, pT, pGF); /* m */ - pGF->add(pW, pW, pW, pGF); - } - - /* M = 3*X^2 + new W */ - pGF->sqr(pS, pX, pGF); /* s */ - pGF->add(pM, pS, pS, pGF); - pGF->add(pM, pM, pS, pGF); - if(!EPID_PARAMS(pEC)) { - pGF->add(pM, pM, pW, pGF); - } - - /* T = 2*Y */ - pGF->add(pT, pY, pY, pGF); - - /* new Z = 2*Y*Z */ - pGF->mul(pZ, pT, pZ, pGF); /* m */ - - /* S = X*(T^2) = 4*X*Y^2 */ - pGF->sqr(pT, pT, pGF); /* s */ - pGF->mul(pS, pX, pT, pGF); /* m */ - - /* T = (T^2)/2 = (16*Y^4)/2 = 8*Y^4 */ - pGF->sqr(pT, pT, pGF); /* s */ - //cpGFpxHalve(pT, pT, pGF); - cpGF->div2(pT, pT, pGF); - - /* new X = M^2 - 2*S */ - pGF->sqr(pX, pM, pGF); /* s */ - pGF->sub(pX, pX, pS, pGF); - pGF->sub(pX, pX, pS, pGF); - - /* new Y = M*(S - new X) - T */ - pGF->sub(pY, pS, pX, pGF); - pGF->mul(pY, pY, pM, pGF); /* m */ - pGF->sub(pY, pY, pT, pGF); - } - - ECP_POINT_FLAGS(pR) = ECP_FINITE_POINT; - - cpGFpReleasePool(4, pGF); - return pR; - } -} -#endif -#endif - - -IppsGFpECPoint* cpEcGFpDblPoint_k(IppsGFpECPoint* pR, const IppsGFpECPoint* pP,int k, IppsGFpECState* pEC) -{ - cpEcGFpDblPoint(pR, pP, pEC); - k--; - for(; k>0; k--) - cpEcGFpDblPoint(pR, pR, pEC); - - return pR; -} - - -#if ( ECP_PROJECTIVE_COORD == JACOBIAN ) -/* complexity = 4s+12m */ -IppsGFpECPoint* cpEcGFpAddPoint (IppsGFpECPoint* pPointR, const IppsGFpECPoint* pPointP, const IppsGFpECPoint* pPointQ, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - int inftyP = cpEcGFpIsProjectivePointAtInfinity(pPointP, elemLen); - int inftyQ = cpEcGFpIsProjectivePointAtInfinity(pPointQ, elemLen); - - /* - // addition - */ - BNU_CHUNK_T* pA = cpEcGFpGetPool(3, pEC); - BNU_CHUNK_T* pB = pA + elemLen; - BNU_CHUNK_T* pC = pB + elemLen; - BNU_CHUNK_T* pD = pC + elemLen; - BNU_CHUNK_T* pW = pD + elemLen; - BNU_CHUNK_T* pV = pW + elemLen; - - BNU_CHUNK_T* pRx = pV + elemLen; /* temporary result */ - BNU_CHUNK_T* pRy = pRx+ elemLen; - BNU_CHUNK_T* pRz = pRy+ elemLen; - - /* coordinates of P */ - BNU_CHUNK_T* px1 = ECP_POINT_X(pPointP); - BNU_CHUNK_T* py1 = ECP_POINT_Y(pPointP); - BNU_CHUNK_T* pz1 = ECP_POINT_Z(pPointP); - - /* coordinates of Q */ - BNU_CHUNK_T* px2 = ECP_POINT_X(pPointQ); - BNU_CHUNK_T* py2 = ECP_POINT_Y(pPointQ); - BNU_CHUNK_T* pz2 = ECP_POINT_Z(pPointQ); - - /* coordinates of R */ - //BNU_CHUNK_T* px3 = ECP_POINT_X(pPointR); - //BNU_CHUNK_T* py3 = ECP_POINT_Y(pPointR); - //BNU_CHUNK_T* pz3 = ECP_POINT_Z(pPointR); - - /* A = X1 * Z2^2 */ - /* C = Y1 * Z2^3 */ - if( IS_ECP_AFFINE_POINT(pPointQ) ) { - cpGFpElementCopy(pA, px1, elemLen); - cpGFpElementCopy(pC, py1, elemLen); - } - else { - pGF->sqr(pA, pz2, pGF); /* s */ - pGF->mul(pC, pz2, pA, pGF); /* m */ - pGF->mul(pA, pA, px1, pGF); /* m */ - pGF->mul(pC, pC, py1, pGF); /* m */ - } - - /* B = X2 * Z1^2 */ - /* D = Y2 * Z1^3 */ - if( IS_ECP_AFFINE_POINT(pPointP) ) { - cpGFpElementCopy(pB, px2, elemLen); - cpGFpElementCopy(pD, py2, elemLen); - } - else { - pGF->sqr(pB, pz1, pGF); /* s */ - pGF->mul(pD, pz1, pB, pGF); /* m */ - pGF->mul(pB, pB, px2, pGF); /* m */ - pGF->mul(pD, pD, py2, pGF); /* m */ - } - - /* W = B-A */ - /* V = D-C */ - pGF->sub(pW, pB, pA, pGF); - pGF->sub(pV, pD, pC, pGF); - - if( GFP_IS_ZERO(pW, elemLen) && !inftyP && !inftyQ ) { - cpEcGFpReleasePool(3, pEC); - if( GFP_IS_ZERO(pV, elemLen) ) - return cpEcGFpDblPoint(pPointR, pPointP, pEC); - else - return cpEcGFpSetProjectivePointAtInfinity(pPointR, elemLen); - } - - /* Z3 = Z1*Z2*W */ - if( IS_ECP_AFFINE_POINT(pPointP) && IS_ECP_AFFINE_POINT(pPointQ) ) - cpGFpElementCopy(pRz, pW, elemLen); - else { - if( IS_ECP_AFFINE_POINT(pPointQ) ) - cpGFpElementCopy(pB, pz1, elemLen); - else if ( IS_ECP_AFFINE_POINT(pPointP) ) - cpGFpElementCopy(pB, pz2, elemLen); - else - pGF->mul(pB, pz1, pz2, pGF); /* m */ - pGF->mul(pRz, pB, pW, pGF); /* m */ - } - - /* B = W^2 */ - pGF->sqr(pB, pW, pGF); /* s */ - /* A = A*W^2 */ - pGF->mul(pA, pB, pA, pGF); /* m */ - /* W = W^3 */ - pGF->mul(pW, pB, pW, pGF); /* m */ - - /* X3 = V^2 - W^3 -2*A*W^2 */ - pGF->sqr(pRx, pV, pGF); /* s */ - pGF->sub(pRx, pRx, pW, pGF); - pGF->sub(pRx, pRx, pA, pGF); - pGF->sub(pRx, pRx, pA, pGF); - - /* Y3 = V*(A*W^2 - X3) -C*W^3 */ - pGF->sub(pRy, pA, pRx, pGF); - pGF->mul(pC, pC, pW, pGF); /* m */ - pGF->mul(pRy, pRy, pV, pGF); /* m */ - pGF->sub(pRy, pRy, pC, pGF); - - cpMaskMove(pRx, px2, elemLen, inftyP); - cpMaskMove(pRy, py2, elemLen, inftyP); - cpMaskMove(pRz, pz2, elemLen, inftyP); - - cpMaskMove(pRx, px1, elemLen, inftyQ); - cpMaskMove(pRy, py1, elemLen, inftyQ); - cpMaskMove(pRz, pz1, elemLen, inftyQ); - - cpGFpElementCopy(ECP_POINT_DATA(pPointR), pRx, 3*elemLen); - ECP_POINT_FLAGS(pPointR) = cpEcGFpIsProjectivePointAtInfinity(pPointR, elemLen)? 0 : ECP_FINITE_POINT; - - cpEcGFpReleasePool(3, pEC); - return pPointR; -} -#endif - -#if ( ECP_PROJECTIVE_COORD == HOMOGENEOUS ) -/* -// A = Y2 * Z1 - Y1 * Z2 -// B = X2 * Z1 - X1 * Z2 -// C = A^2*Z1*Z2 -B^3 -2*B^2*X1*Z2 = A^2*Z1*Z2 -B^2*(B+2*X1*Z2) = A^2*Z1*Z2 -B^2*(X2*Z1+X1*Z2) -// new X = B*C -// new Y = A*(B^2*X1*Z2 -C) -B^3*Y1*Z2 -// new Z = B^3*Z1*Z2 -// -// note: Y1*Z2, X2*Z1, X1*Z2, Z1*Z2 are using several times -// (T1), (T2), (T3) (T4) -// -// complexity = 2s+13m -*/ -IppsGFpECPoint* cpEcGFpAddPoint (IppsGFpECPoint* pPointR, const IppsGFpECPoint* pP1, const IppsGFpECPoint* pP2, IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* test stupid call */ - if( pP1 == pP2) - return cpEcGFpDblPoint(pPointR, pP1, pEC); - - /* prevent operation with point at Infinity */ - if( !IS_ECP_FINITE_POINT(pP1) ) - return cpEcGFpCopyPoint(pPointR, pP2, elemLen); - if( !IS_ECP_FINITE_POINT(pP2) ) - return cpEcGFpCopyPoint(pPointR, pP1, elemLen); - - /* - // addition - */ - { - BNU_CHUNK_T* pT1 = cpEcGFpGetPool(3, pEC); - BNU_CHUNK_T* pT2 = pT1 + elemLen; - BNU_CHUNK_T* pT3 = pT2 + elemLen; - BNU_CHUNK_T* pT4 = pT3 + elemLen; - BNU_CHUNK_T* pA = pT4 + elemLen; - BNU_CHUNK_T* pB = pA + elemLen; - BNU_CHUNK_T* pC = pB + elemLen; - BNU_CHUNK_T* pB2 = pC + elemLen; - BNU_CHUNK_T* pB3 = pB2 + elemLen; - - /* coordinates of P1 */ - BNU_CHUNK_T* pX1 = ECP_POINT_X(pP1); - BNU_CHUNK_T* pY1 = ECP_POINT_Y(pP1); - BNU_CHUNK_T* pZ1 = ECP_POINT_Z(pP1); - - /* coordinates of P2 */ - BNU_CHUNK_T* pX2 = ECP_POINT_X(pP2); - BNU_CHUNK_T* pY2 = ECP_POINT_Y(pP2); - BNU_CHUNK_T* pZ2 = ECP_POINT_Z(pP2); - - /* A = Y2 * Z1 - Y1 * Z2 */ - pGF->mul(pA, pY2, pZ1, pGF); /* m */ - pGF->mul(pT1,pY1, pZ2, pGF); /* m */ - pGF->sub(pA, pA, pT1, pGF); - - /* B = X2 * Z1 - X1 * Z2 */ - pGF->mul(pT2,pX2, pZ1, pGF); /* m */ - pGF->mul(pT3,pX1, pZ2, pGF); /* m */ - pGF->sub(pB, pT2, pT3, pGF); - - if( GFP_IS_ZERO(pB, elemLen) ) { - cpEcGFpReleasePool(3, pEC); - if( GFP_IS_ZERO(pA, elemLen) ) - return cpEcGFpDblPoint(pPointR, pP1, pEC); - else - return cpEcGFpSetProjectivePointAtInfinity(pPointR, elemLen); - } - - /* C = A^2*Z1*Z2 -B^2*(X2*Z1+X1*Z2) */ - pGF->sqr(pB2, pB, pGF); /* s */ - pGF->add(pT2,pT2, pT3, pGF); - pGF->mul(pT2,pT2, pB2, pGF); /* m */ - pGF->mul(pT4,pZ1, pZ2, pGF); /* m */ - pGF->sqr(pC, pA, pGF); /* s */ - pGF->mul(pC, pC, pT4, pGF); /* m */ - pGF->sub(pC, pC, pT2, pGF); - - /* new X = B*C */ - pGF->mul(ECP_POINT_X(pPointR), pB, pC, pGF); /* m */ - - /* new Y = A*(B^2*X1*Z2 -C) -B^3*Y1*Z2 */ - pGF->mul(pT3, pT3, pB2, pGF); /* m */ /* T3 = (X1*Z2)*B^2 */ - pGF->sub(pT3, pT3, pC, pGF); - pGF->mul(pT3, pT3, pA, pGF); /* m */ /* T3 = A*(B^2*X1*Z2 -C) */ - pGF->mul(pB3, pB2, pB, pGF); /* m */ /* B3 = B^3 */ - pGF->mul(pT1, pT1, pB3, pGF); /* m */ /* T1 = B^3*Y1*Z2 */ - pGF->sub(ECP_POINT_Y(pPointR), pT3, pT1, pGF); - - /* new Z = B^3*Z1*Z2 */ - pGF->mul(ECP_POINT_Z(pPointR), pB3, pT4, pGF); /* m */ - - ECP_POINT_FLAGS(pPointR) = ECP_FINITE_POINT; - - cpEcGFpReleasePool(3, pEC); - return pPointR; - } -} -#endif - -#if 0 -/* non-sscm version */ -IppsGFpECPoint* cpEcGFpMulPoint(IppsGFpECPoint* pPointR, const IppsGFpECPoint* pPointP, const BNU_CHUNK_T* pN, int nsN, IppsGFpECState* pEC, Ipp8u* pScratchBuffer) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - UNREFERENCED_PARAMETER(pScratchBuffer); - - /* test scalar and input point */ - if( GFP_IS_ZERO(pN, nsN) || !IS_ECP_FINITE_POINT(pPointP) ) - return cpEcGFpSetProjectivePointAtInfinity(pPointR, elemLen); - - /* remove leding zeros */ - FIX_BNU(pN, nsN); - - /* case N==1 => R = P */ - if( GFP_IS_ONE(pN, nsN) ) { - cpEcGFpCopyPoint(pPointR, pPointP, elemLen); - return pPointR; - } - - /* - // scalar multiplication - */ - else { - int i; - - BNU_CHUNK_T* pH = cpGFpGetPool(1, pGF); - BNU_CHUNK_T* pK = cpGFpGetPool(1, pGF); - - IppsGFpECPoint T, U; - cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC); - cpEcGFpInitPoint(&U, cpEcGFpGetPool(1, pEC),0, pEC); - - /* H = 3*N */ - cpGFpElementCopy(pK, pN, nsN); - pK[nsN] = 0; - i = cpAdd_BNU(pH, pK, pK, nsN+1); - i = cpAdd_BNU(pH, pK, pH, nsN+1); - - /* T = affine(P) */ - if( IS_ECP_AFFINE_POINT(pPointP) ) - cpEcGFpCopyPoint(&T, pPointP, elemLen); - else { - cpEcGFpGetAffinePoint(ECP_POINT_X(&T), ECP_POINT_Y(&T), pPointP, pEC); - cpEcGFpSetAffinePoint(&T, ECP_POINT_X(&T), ECP_POINT_Y(&T), pEC); - } - /* U = affine(-P) */ - cpEcGFpNegPoint(&U, &T, pEC); - - /* R = T = affine(P) */ - cpEcGFpCopyPoint(pPointR, &T, elemLen); - - /* - // point multiplication - */ - for(i=MSB_BNU(pH, nsN+1)-1; i>0; i--) { - Ipp32u hBit = TST_BIT(pH, i); - Ipp32u kBit = TST_BIT(pK, i); - cpEcGFpDblPoint(pPointR, pPointR, pEC); - if( hBit && !kBit ) - cpEcGFpAddPoint(pPointR, &T, pPointR, pEC); - if(!hBit && kBit ) - cpEcGFpAddPoint(pPointR, &U, pPointR, pEC); - } - - cpEcGFpReleasePool(2, pEC); - cpGFpReleasePool(2, pGF); - - return pPointR; - } -} -#endif - -static int div_upper(int a, int d) -{ return (a+d-1)/d; } - -#if 0 -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 -} - -static int cpEcGFpConverRepresentation(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; -} -#endif - -/* sscm version */ -IppsGFpECPoint* cpEcGFpMulPoint(IppsGFpECPoint* pPointR, const IppsGFpECPoint* pPointP, const BNU_CHUNK_T* pN, int nsN, IppsGFpECState* pEC, Ipp8u* pScratchBuffer) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - - /* test scalar and input point */ - if( GFP_IS_ZERO(pN, nsN) || !IS_ECP_FINITE_POINT(pPointP) ) - return cpEcGFpSetProjectivePointAtInfinity(pPointR, elemLen); - - /* remove leding zeros */ - FIX_BNU(pN, nsN); - - /* case N==1 => R = P */ - if( GFP_IS_ONE(pN, nsN) ) { - cpEcGFpCopyPoint(pPointR, pPointP, elemLen); - return pPointR; - } - - { - Ipp8u* pScratchAligned; /* aligned scratch buffer */ - int nAllocation = 0; /* points from the pool */ - - /* size of point (dwords) */ - int pointDataSize = ECP_FELEN(pEC)*sizeof(BNU_CHUNK_T); - int pointDataSize32 = ECP_FELEN(pEC)*sizeof(BNU_CHUNK_T)/sizeof(Ipp32u); - - /* scalar bitsize */ - int scalarBitSize = BITSIZE_BNU(pN, nsN); - /* optimal size of window */ - int window_size = (NULL==pScratchBuffer)? 1 : 5; - /* number of table entries */ - int nPrecomputed = 1<<(window_size-1); - - IppsGFpECPoint T; - cpEcGFpInitPoint(&T, cpEcGFpGetPool(1, pEC),0, pEC); - cpEcGFpCopyPoint(&T, pPointP, elemLen); - - if(NULL==pScratchBuffer) { - nAllocation = 1 + div_upper(CACHE_LINE_SIZE, pointDataSize); - pScratchBuffer = (Ipp8u*)cpEcGFpGetPool(nAllocation, pEC); - } - pScratchAligned = IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE); - - /* pre-compute auxiliary table t[] = {1*P, 2*P, ..., nPrecomputed*P} */ - { - int n; - cpScatter32((Ipp32u*)pScratchAligned, nPrecomputed, 0, (Ipp32u*)ECP_POINT_DATA(&T), pointDataSize32); - for(n=1; n> ((bit-1)%8)) & dmask; - booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size); - - cpGather32((Ipp32u*)ECP_POINT_DATA(pPointR), pointDataSize32, (Ipp32u*)pScratchAligned, nPrecomputed, digit); - ECP_POINT_FLAGS(pPointR) = 0; - - for(bit-=window_size; bit>=window_size; bit-=window_size) { - /* window_size times doubling */ - cpEcGFpDblPoint_k(pPointR, pPointR, window_size, pEC); - - /* extract next window value */ - wvalue = *((Ipp16u*)&pScalar8[(bit-1)/8]); - wvalue = (wvalue>> ((bit-1)%8)) & dmask; - booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size); - - /* extract value from the pre-computed table */ - cpGather32((Ipp32u*)ECP_POINT_DATA(&T), pointDataSize32, (Ipp32u*)pScratchAligned, nPrecomputed, digit); - - pGF->neg(pNegY, ECP_POINT_Y(&T), pGF); - cpMaskMove(ECP_POINT_Y(&T), pNegY, elemLen, sign); - - /* and add it */ - cpEcGFpAddPoint(pPointR, pPointR, &T, pEC); - } - - /* last window */ - cpEcGFpDblPoint_k(pPointR, pPointR, window_size, pEC); - - wvalue = *((Ipp16u*)&pScalar8[0]); - wvalue = (wvalue <<1) & dmask; - booth_recode(&sign, &digit, (Ipp8u)wvalue, window_size); - - cpGather32((Ipp32u*)ECP_POINT_DATA(&T), pointDataSize32, (Ipp32u*)pScratchAligned, nPrecomputed, digit); - - pGF->neg(pNegY, ECP_POINT_Y(&T), pGF); - cpMaskMove(ECP_POINT_Y(&T), pNegY, elemLen, sign); - - cpEcGFpAddPoint(pPointR, pPointR, &T, pEC); - } - - cpGFpReleasePool(2+1, pGF); - } - - cpEcGFpReleasePool(nAllocation+1, pEC); - - return pPointR; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecstuff.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecstuff.h deleted file mode 100644 index f312e537fc..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpecstuff.h +++ /dev/null @@ -1,320 +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. - ############################################################################*/ - -/* -// -// Purpose: -// Intel(R) Performance Primitives. Cryptography Primitives. -// Internal EC over GF(p^m) basic Definitions & Function Prototypes -// -// -*/ - -#if !defined(_CP_ECGFP_H_) -#define _CP_ECGFP_H_ - -#include "pcpgfpstuff.h" -#include "pcpgfpxstuff.h" - - -/* -// EC over GF(p) Point context -*/ -typedef struct _cpGFpECPoint { - IppCtxId idCtx; /* EC Point identifier */ - int flags; /* flags: affine */ - int elementSize; /* size of each coordinate */ - BNU_CHUNK_T* pData; /* coordinatex X, Y, Z */ -} cpGFPECPoint; - -/* -// Contetx Access Macros -*/ -#define ECP_POINT_ID(ctx) ((ctx)->idCtx) -#define ECP_POINT_FLAGS(ctx) ((ctx)->flags) -#define ECP_POINT_FELEN(ctx) ((ctx)->elementSize) -#define ECP_POINT_DATA(ctx) ((ctx)->pData) -#define ECP_POINT_X(ctx) ((ctx)->pData) -#define ECP_POINT_Y(ctx) ((ctx)->pData+(ctx)->elementSize) -#define ECP_POINT_Z(ctx) ((ctx)->pData+(ctx)->elementSize*2) -#define ECP_POINT_TEST_ID(ctx) (ECP_POINT_ID((ctx))==idCtxGFPPoint) - -/* point flags */ -#define ECP_AFFINE_POINT (1) -#define ECP_FINITE_POINT (2) - -#define IS_ECP_AFFINE_POINT(ctx) (ECP_POINT_FLAGS((ctx))&ECP_AFFINE_POINT) -#define SET_ECP_AFFINE_POINT(ctx) (ECP_POINT_FLAGS((ctx))|ECP_AFFINE_POINT) -#define SET_ECP_PROJECTIVE_POINT(ctx) (ECP_POINT_FLAGS((ctx))&~ECP_AFFINE_POINT) - -#define IS_ECP_FINITE_POINT(ctx) (ECP_POINT_FLAGS((ctx))&ECP_FINITE_POINT) -#define SET_ECP_FINITE_POINT(ctx) (ECP_POINT_FLAGS((ctx))|ECP_FINITE_POINT) -#define SET_ECP_INFINITE_POINT(ctx) (ECP_POINT_FLAGS((ctx))&~ECP_FINITE_POINT) - -/* -// define using projective coordinates -*/ -#define JACOBIAN (0) -#define HOMOGENEOUS (1) -#define ECP_PROJECTIVE_COORD JACOBIAN -//#define ECP_PROJECTIVE_COORD HOMOGENEOUS - -#if (ECP_PROJECTIVE_COORD== JACOBIAN) - #pragma message ("ECP_PROJECTIVE_COORD = JACOBIAN") -#elif (ECP_PROJECTIVE_COORD== HOMOGENEOUS) - #pragma message ("ECP_PROJECTIVE_COORD = HOMOGENEOUS") -#else - #error ECP_PROJECTIVE_COORD should be either JACOBIAN or HOMOGENEOUS type -#endif - -#define _EPID20_EC_PARAM_SPECIFIC_ - -#if defined(_EPID20_EC_PARAM_SPECIFIC_) -#pragma message ("_EPID20_EC_PARAM_SPECIFIC_") -#endif - - -/* EC over GF(p) context */ -typedef struct _cpGFpEC { - IppCtxId idCtx; /* EC identifier */ - - IppsGFpState* pGF; /* arbitrary GF(p^d)*/ - - int elementSize; /* size of point's coordinate */ - int orderBitSize; /* base_point order bitsize */ -// int cofactor; /* cofactor = #E/base_point order */ - int epidParams; /* Intel(R) EPID 2.0 specific parameters */ - BNU_CHUNK_T* pA; /* EC parameter A */ - BNU_CHUNK_T* pB; /* B */ - BNU_CHUNK_T* pG; /* base_point */ - BNU_CHUNK_T* pR; /* base_point order */ - BNU_CHUNK_T* cofactor; /* cofactor = #E/base_point order */ - BNU_CHUNK_T* pPool; /* pool of points */ -} cpGFPEC; - -#define ECGFP_ALIGNMENT ((int)(sizeof(void*))) - -/* Local definitions */ -#define EC_POOL_SIZE (8) /* num of points into the pool */ - -#define ECP_ID(pCtx) ((pCtx)->idCtx) -#define ECP_GFP(pCtx) ((pCtx)->pGF) -#define ECP_FELEN(pCtx) ((pCtx)->elementSize) -#define ECP_ORDBITSIZE(pCtx) ((pCtx)->orderBitSize) -#define ECP_COFACTOR(pCtx) ((pCtx)->cofactor) -#define EPID_PARAMS(pCtx) ((pCtx)->epidParams) -#define ECP_A(pCtx) ((pCtx)->pA) -#define ECP_B(pCtx) ((pCtx)->pB) -#define ECP_G(pCtx) ((pCtx)->pG) -#define ECP_R(pCtx) ((pCtx)->pR) -#define ECP_POOL(pCtx) ((pCtx)->pPool) - -#define ECP_TEST_ID(pCtx) (ECP_ID((pCtx))==idCtxGFPEC) - -/* -// get/release n points from/to the pool -*/ -__INLINE BNU_CHUNK_T* cpEcGFpGetPool(int n, IppsGFpECState* pEC) -{ - BNU_CHUNK_T* pPool = ECP_POOL(pEC); - ECP_POOL(pEC) += n*GFP_FELEN(ECP_GFP(pEC))*3; - return pPool; -} -__INLINE void cpEcGFpReleasePool(int n, IppsGFpECState* pEC) -{ - ECP_POOL(pEC) -= n*GFP_FELEN(ECP_GFP(pEC))*3; -} - -__INLINE IppsGFpECPoint* cpEcGFpInitPoint(IppsGFpECPoint* pPoint, BNU_CHUNK_T* pData, int flags, const IppsGFpECState* pEC) -{ - ECP_POINT_ID(pPoint) = idCtxGFPPoint; - ECP_POINT_FLAGS(pPoint) = flags; - ECP_POINT_FELEN(pPoint) = GFP_FELEN(ECP_GFP(pEC)); - ECP_POINT_DATA(pPoint) = pData; - return pPoint; -} - -/* -// copy one point into another -*/ -__INLINE IppsGFpECPoint* cpEcGFpCopyPoint(IppsGFpECPoint* pPointR, const IppsGFpECPoint* pPointA, int elemLen) -{ - cpGFpElementCopy(ECP_POINT_DATA(pPointR), ECP_POINT_DATA(pPointA), 3*elemLen); - ECP_POINT_FLAGS(pPointR) = ECP_POINT_FLAGS(pPointA); - return pPointR; -} - -/* -// set point (convert into inside representation) -// SetProjectivePoint -// SetProjectivePointAtInfinity -// SetAffinePoint -*/ -__INLINE IppsGFpECPoint* cpEcGFpSetProjectivePoint(IppsGFpECPoint* pPoint, - const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY, const BNU_CHUNK_T* pZ, - IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - int elemLen = GFP_FELEN(pGF); - int pointFlag = 0; - - cpGFpxSet(ECP_POINT_X(pPoint), pX, elemLen, pGF, USE_MONT_SPACE_REPRESENTATION); - cpGFpxSet(ECP_POINT_Y(pPoint), pY, elemLen, pGF, USE_MONT_SPACE_REPRESENTATION); - cpGFpxSet(ECP_POINT_Z(pPoint), pZ, elemLen, pGF, USE_MONT_SPACE_REPRESENTATION); - - if(!GFP_IS_ZERO(pZ, elemLen)) pointFlag |= ECP_FINITE_POINT; - if(GFP_IS_ONE(pZ, elemLen)) pointFlag |= ECP_AFFINE_POINT; - ECP_POINT_FLAGS(pPoint) = pointFlag; - return pPoint; -} -__INLINE IppsGFpECPoint* cpEcGFpSetProjectivePointAtInfinity(IppsGFpECPoint* pPoint, int elemLen) -{ - cpGFpElementPadd(ECP_POINT_X(pPoint), elemLen, 0); - cpGFpElementPadd(ECP_POINT_Y(pPoint), elemLen, 0); - cpGFpElementPadd(ECP_POINT_Z(pPoint), elemLen, 0); - ECP_POINT_FLAGS(pPoint) = 0; - return pPoint; -} -__INLINE IppsGFpECPoint* cpEcGFpSetAffinePoint(IppsGFpECPoint* pPoint, - const BNU_CHUNK_T* pX, const BNU_CHUNK_T* pY, - IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - IppsGFpState* pBasicGF = cpGFpBasic(pGF); - - cpGFpElementCopy(ECP_POINT_X(pPoint), pX, GFP_FELEN(pGF)); - cpGFpElementCopy(ECP_POINT_Y(pPoint), pY, GFP_FELEN(pGF)); - cpGFpElementCopyPadd(ECP_POINT_Z(pPoint), GFP_FELEN(pGF), MNT_1(GFP_MONT(pBasicGF)), GFP_FELEN(pBasicGF)); - ECP_POINT_FLAGS(pPoint) = ECP_AFFINE_POINT | ECP_FINITE_POINT; - return pPoint; -} - -/* -// test infinity: -// IsProjectivePointAtInfinity -*/ -__INLINE int cpEcGFpIsProjectivePointAtInfinity(const IppsGFpECPoint* pPoint, Ipp32u elemLen) -{ - return GFP_IS_ZERO( ECP_POINT_Z(pPoint), elemLen ); -} - -/* -// get point (convert from inside representation) -// GetProjectivePoint -// GetAffinePointAtInfinity0 (B==0) -// GetAffinePointAtInfinity1 (B!=0) -// GetAffinePoint -*/ -__INLINE void cpEcGFpGetProjectivePoint(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, BNU_CHUNK_T* pZ, - const IppsGFpECPoint* pPoint, - IppsGFpECState* pEC) -{ - IppsGFpState* pGF = ECP_GFP(pEC); - cpGFpxGet(pX, GFP_FELEN(pGF), ECP_POINT_X(pPoint), pGF, USE_MONT_SPACE_REPRESENTATION); - cpGFpxGet(pY, GFP_FELEN(pGF), ECP_POINT_Y(pPoint), pGF, USE_MONT_SPACE_REPRESENTATION); - cpGFpxGet(pZ, GFP_FELEN(pGF), ECP_POINT_Z(pPoint), pGF, USE_MONT_SPACE_REPRESENTATION); -} -#if 0 -__INLINE void cpEcGFpGetAffinePointAtInfinity0(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, int elemLen) -{ - GFP_ZERO(pX, elemLen); - GFP_ONE(pY, elemLen); -} -__INLINE void cpEcGFpGetAffinePointAtInfinity1(BNU_CHUNK_T* pX, BNU_CHUNK_T* pY, int elemLen) -{ - GFP_ZERO(pX, elemLen); - GFP_ZERO(pY, elemLen); -} -#endif - - -/* signed encode */ -__INLINE void booth_recode(Ipp8u* sign, Ipp8u* digit, Ipp8u in, int w) -{ - Ipp8u s = ~((in >> w) - 1); - int d = (1 << (w+1)) - in - 1; - d = (d & s) | (in & ~s); - d = (d >> 1) + (d & 1); - *sign = s & 1; - *digit = (Ipp8u)d; -} - -/* mask of the argument: - if x==0 returns 0 - if x!=0 returns BNU_CHUNK_T(-1) -*/ -__INLINE BNU_CHUNK_T cpIsNonZeroMask(BNU_CHUNK_T x) -{ - #if(_IPP_ARCH==_IPP_ARCH_EM64T) - x |= x>>32; - #endif - x |= x>>16; - x |= x>>8; - x |= x>>4; - x |= x>>2; - x |= x>>1; - return 0-(x&1); -} - -/* dst[] = src[], iif moveFlag!=0 */ -__INLINE void cpMaskMove(BNU_CHUNK_T* dst, const BNU_CHUNK_T* src, int len, int moveFlag) -{ - BNU_CHUNK_T mask1 = cpIsNonZeroMask(moveFlag); - BNU_CHUNK_T mask2 = ~mask1; - int n; - for(n=0; n= _IPP32E_M7) -BNU_CHUNK_T* cp256pNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - return gf256_neg(pR, pA, GFP_MODULUS(pGF)); -} -#endif - - -BNU_CHUNK_T* cpGFpInv(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - int poolelementLen= GFP_PELEN(pGF); - - BNU_CHUNK_T* tmpM = cpGFpGetPool(4, pGF); - BNU_CHUNK_T* tmpX1= tmpM +poolelementLen; - BNU_CHUNK_T* tmpX2= tmpX1+poolelementLen; - BNU_CHUNK_T* tmpX3= tmpX2+poolelementLen; - int nsR; - - cpGFpElementCopy(tmpM, pModulus, elemLen); - nsR = cpModInv_BNU(pR, pA,elemLen, tmpM, elemLen, tmpX1,tmpX2,tmpX3); - cpGFpReleasePool(4, pGF); - - cpGFpElementPadd(pR+nsR, elemLen-nsR, 0); - return cpGFpMul(pR, pR, MNT_CUBE_R(GFP_MONT(pGF)), pGF); -} - - -/* sscm version */ -BNU_CHUNK_T* cpGFpHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - - BNU_CHUNK_T mask = 0 - (pA[0]&1); /* set mask iif A is odd */ - /* t = if(isOdd(A))? modulus : 0 */ - int i; - BNU_CHUNK_T* t = cpGFpGetPool(1, pGF); - for(i=0; i= _IPP32E_M7) -BNU_CHUNK_T* cp256pHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - return gf256_div2(pR, pA, GFP_MODULUS(pGF)); -} -#endif - - -/* sscm version */ -BNU_CHUNK_T* cpGFpAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pTmpR = cpGFpGetPool(1, pGF); - - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - - BNU_CHUNK_T e = cpAdd_BNU(pR, pA, pB, elemLen); - e -= cpSub_BNU(pTmpR, pR, pModulus, elemLen); - MASKED_COPY(pR, e, pR, pTmpR, elemLen); - - cpGFpReleasePool(1, pGF); - - return pR; -} - -#if(_IPP32E >= _IPP32E_M7) -BNU_CHUNK_T* cp256pAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - return gf256_add(pR, pA, pB, GFP_MODULUS(pGF)); -} -#endif - - -/* sscm version */ -BNU_CHUNK_T* cpGFpSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pTmpR = cpGFpGetPool(1, pGF); - - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - - BNU_CHUNK_T e = cpSub_BNU(pR, pA, pB, elemLen); - cpAdd_BNU(pTmpR, pR, pModulus, elemLen); - MASKED_COPY(pR, (0-e), pTmpR, pR, elemLen); - - cpGFpReleasePool(1, pGF); - - return pR; -} - -#if(_IPP32E >= _IPP32E_M7) -BNU_CHUNK_T* cp256pSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - return gf256_sub(pR, pA, pB, GFP_MODULUS(pGF)); -} -#endif - - -BNU_CHUNK_T* cpGFpMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - - IppsMontState* pMont = GFP_MONT(pGF); - BNU_CHUNK_T* pBuffer = MNT_PRODUCT(pMont); - BNU_CHUNK_T m0 = MNT_HELPER(pMont); - - cpMontMul_BNU(pR, pA,elemLen, pB,elemLen, pModulus,elemLen, m0, pBuffer, NULL); - return pR; -} - -#if(_IPP32E >= _IPP32E_M7) -BNU_CHUNK_T* cp256pMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - IppsMontState* pMont = GFP_MONT(pGF); - BNU_CHUNK_T m0 = MNT_HELPER(pMont); - return gf256_mulm(pR, pA, pB, pModulus, m0); -} -#endif - -BNU_CHUNK_T* cpGFpSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - int elemLen = GFP_FELEN(pGF); - - IppsMontState* pMont = GFP_MONT(pGF); - BNU_CHUNK_T* pBuffer = MNT_PRODUCT(pMont); - BNU_CHUNK_T m0 = MNT_HELPER(pMont); - - cpMontSqr_BNU(pR, pA,elemLen, pModulus,elemLen, m0, pBuffer, NULL); - return pR; -} - -#if(_IPP32E >= _IPP32E_M7) -BNU_CHUNK_T* cp256pSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pModulus = GFP_MODULUS(pGF); - IppsMontState* pMont = GFP_MONT(pGF); - BNU_CHUNK_T m0 = MNT_HELPER(pMont); - return gf256_sqrm(pR, pA, pModulus, m0); -} -#endif - - -BNU_CHUNK_T* cpGFpExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, IppsGFpState* pGF) -{ - IppsBigNumState A; - IppsBigNumState E; - IppsBigNumState R; - - BNU_CHUNK_T* pPool = cpGFpGetPool(3, pGF); - int poolElemLen = GFP_PELEN(pGF); - int elemLen = GFP_FELEN(pGF); - - cpGFpSetBigNum(&A, elemLen, pA, pPool+0*poolElemLen); - cpGFpSetBigNum(&E, nsE, pE, pPool+1*poolElemLen); - cpGFpInitBigNum(&R,elemLen, pR, pPool+2*poolElemLen); - - cpMontExpBin_BN(&R, &A, &E, GFP_MONT(pGF)); - - cpGFpReleasePool(3, pGF); - return pR; -} - - -static int factor2(BNU_CHUNK_T* pA, int nsA) -{ - int factor = 0; - int bits; - - int i; - for(i=0; i= BITSIZE(BNU_CHUNK_T)) { - int nchunk = bits/BITSIZE(BNU_CHUNK_T); - cpGFpElementCopyPadd(pA, nsA, pA+nchunk, nsA-nchunk); - bits %= BITSIZE(BNU_CHUNK_T); - } - if(bits) - cpLSR_BNU(pA, pA, nsA, bits); - - return factor; -} -static BNU_CHUNK_T* cpGFpExp2(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, int e, IppsGFpState* pGF) -{ - cpGFpElementCopy(pR, pA, GFP_FELEN(pGF)); - while(e--) { - pGF->sqr(pR, pR, pGF); - } - return pR; -} - -/* returns: - 0, if a - qnr - 1, if sqrt is found -*/ -int cpGFpSqrt(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF) -{ - int elemLen = GFP_FELEN(pGF); - int poolelementLen = GFP_PELEN(pGF); - int resultFlag = 1; - - /* case A==0 */ - if( GFP_IS_ZERO(pA, elemLen) ) - cpGFpElementPadd(pR, elemLen, 0); - - /* general case */ - else { - BNU_CHUNK_T* q = cpGFpGetPool(4, pGF); - BNU_CHUNK_T* x = q + poolelementLen; - BNU_CHUNK_T* y = x + poolelementLen; - BNU_CHUNK_T* z = y + poolelementLen; - - int s; - - /* z=1 */ - GFP_ONE(z, elemLen); - - /* (modulus-1) = 2^s*q */ - cpSub_BNU(q, GFP_MODULUS(pGF), z, elemLen); - s = factor2(q, elemLen); - - /* - // initialization - */ - - /* y = qnr^q */ - cpGFpExp(y, GFP_QNR(pGF), q,elemLen, pGF); - /* x = a^((q-1)/2) */ - cpSub_BNU(q, q, z, elemLen); - cpLSR_BNU(q, q, elemLen, 1); - cpGFpExp(x, pA, q, elemLen, pGF); - /* z = a*x^2 */ - pGF->mul(z, x, x, pGF); - pGF->mul(z, pA, z, pGF); - /* R = a*x */ - pGF->mul(pR, pA, x, pGF); - - while( !GFP_EQ(z, MNT_1(GFP_MONT(pGF)), elemLen) ) { - int m = 0; - cpGFpElementCopy(q, z, elemLen); - - for(m=1; mmul(q, q, q, pGF); - if( GFP_EQ(q, MNT_1(GFP_MONT(pGF)), elemLen) ) - break; - } - - if(m==s) { - /* A is quadratic non-residue */ - resultFlag = 0; - break; - } - else { - /* exponent reduction */ - cpGFpExp2(q, y, (s-m-1), pGF); /* q = y^(2^(s-m-1)) */ - pGF->mul(y, q, q, pGF); /* y = q^2 */ - pGF->mul(pR, q, pR, pGF); /* R = q*R */ - pGF->mul(z, y, z, pGF); /* z = z*y */ - s = m; - } - } - - /* choose smallest between R and (modulus-R) */ - cpGFpMontDecode(q, pR, elemLen, GFP_MONT(pGF)); - if(GFP_GT(q, GFP_HMODULUS(pGF), elemLen)) - pGF->neg(pR, pR, pGF); - - cpGFpReleasePool(4, pGF); - } - - return resultFlag; -} - - -BNU_CHUNK_T* cpGFpRand(BNU_CHUNK_T* pR, IppsGFpState* pGF, IppBitSupplier rndFunc, void* pRndParam, int montSpace) -{ - int elemLen = GFP_FELEN(pGF); - int reqBitSize = GFP_FEBITSIZE(pGF)+GF_RAND_ADD_BITS; - int nsR = (reqBitSize +BITSIZE(BNU_CHUNK_T)-1)/BITSIZE(BNU_CHUNK_T); - - BNU_CHUNK_T* pPool = cpGFpGetPool(2, pGF); - cpGFpElementPadd(pPool, nsR, 0); - rndFunc((Ipp32u*)pPool, reqBitSize, pRndParam); - - nsR = cpMod_BNU(pPool, nsR, GFP_MODULUS(pGF), elemLen); - cpGFpElementPadd(pPool+nsR, elemLen-nsR, 0); - if(montSpace) - cpGFpMontEncode(pR, pPool, elemLen, GFP_MONT(pGF)); - else - cpGFpElementCopy(pR, pPool, elemLen); - - cpGFpReleasePool(2, pGF); - return pR; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpstuff.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpstuff.h deleted file mode 100644 index d9b9d8b202..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpstuff.h +++ /dev/null @@ -1,212 +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. - ############################################################################*/ - -/* -// Purpose: -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives -// Internal GF(p) basic Definitions & Function Prototypes -// -// -*/ - -#if !defined(_PCP_GFP_H_) -#define _PCP_GFP_H_ - -#include "pcpbn.h" -#include "pcpmontgomery.h" - -/* GF element */ -typedef struct _cpElementGFp { - IppCtxId idCtx; /* GF() element ident */ - int length; /* length of element (in BNU_CHUNK_T) */ - BNU_CHUNK_T* pData; -} cpElementGFp; - -#define GFPE_ID(pCtx) ((pCtx)->idCtx) -#define GFPE_ROOM(pCtx) ((pCtx)->length) -#define GFPE_DATA(pCtx) ((pCtx)->pData) - -#define GFPE_TEST_ID(pCtx) (GFPE_ID((pCtx))==idCtxGFPE) - -/* basic GF arithmetic */ -typedef BNU_CHUNK_T* (*addm) (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -typedef BNU_CHUNK_T* (*subm) (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -typedef BNU_CHUNK_T* (*negm) (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -typedef BNU_CHUNK_T* (*mulm) (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -typedef BNU_CHUNK_T* (*sqrm) (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -typedef BNU_CHUNK_T* (*div2m)(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); - -/* GF(p) context */ -typedef struct _cpGFp cpGF_T; - -typedef struct _cpGFp { - IppCtxId idCtx; /* GFp spec ident */ - int gfdegree; /* degree of extension (==1 means basic GF(p)) */ - int elemLen; /* size of field element (in BNU_CHUNK_T) */ - int elemLen32; /* sizeof of field element (in Ipp32u) */ - int pelemLen; /* sizeof pool element (in BNU_CHUNK_T) */ - int modulusTypeSpc;/* modulus type specific */ - int epidParams; /* Intel(R) EPID 2.0 specific parameters */ - cpGF_T* pGroundGF; /* ground GF (refference on itself if basic GF(p)) */ - /* = methods: = */ - addm add; /* - gf add */ - subm sub; /* - gf sub */ - negm neg; /* - gf neg */ - mulm mul; /* - gf mul */ - sqrm sqr; /* - gf sqr */ - div2m div2; /* - gf div by 2 */ - /* ============ */ - BNU_CHUNK_T* pModulus; /* modulus or irreducible polypomial (without hight order term ==1) */ - BNU_CHUNK_T* pHalfModulus; /* modulus/2 if basic, NULL if extension */ - BNU_CHUNK_T* pQnr; /* quadratic non-residue if basic, NULL if extension */ - IppsMontState* pMontState; /* montgomery engine if basic, NULL if extension */ - BNU_CHUNK_T* pElemPool; /* pool of temporary field elements */ -} cpGFp; - -#define GFP_ALIGNMENT ((int)(sizeof(void*))) - -/* Local definitions */ -#define GF_MAX_BITSIZE (4096) /* max bitsize for GF element */ -#define GF_POOL_SIZE (8)//(10) /* num of elements into the pool */ -#define GF_RAND_ADD_BITS (128) /* parameter of random element generation */ - -#define GFP_ID(pCtx) ((pCtx)->idCtx) -#define GFP_DEGREE(pCtx) ((pCtx)->gfdegree) -#define GFP_FELEN(pCtx) ((pCtx)->elemLen) -#define GFP_FELEN32(pCtx) ((pCtx)->elemLen32) /////????!!!! -#define GFP_PELEN(pCtx) ((pCtx)->pelemLen) -#define FIELD_POLY_TYPE(pCtx) ((pCtx)->modulusTypeSpc) -#define EPID_PARAMS(pCtx) ((pCtx)->epidParams) -#define GFP_GROUNDGF(pCtx) ((pCtx)->pGroundGF) -#define GFP_MODULUS(pCtx) ((pCtx)->pModulus) -#define GFP_HMODULUS(pCtx) ((pCtx)->pHalfModulus) /* for Sqrt() function only */ -#define GFP_QNR(pCtx) ((pCtx)->pQnr) -#define GFP_POOL(pCtx) ((pCtx)->pElemPool) -#define GFP_MONT(pCtx) ((pCtx)->pMontState) - -/* type of field polynomial: */ -#define ARBITRARY (0) /* arbitrary */ -#define BINOMIAL (1) /* binomial */ - -#define GFP_FEBITSIZE(pCtx) (BITSIZE_BNU(GFP_MODULUS((pCtx)),GFP_FELEN((pCtx)))) -#define GFP_IS_BASIC(pCtx) (GFP_GROUNDGF((pCtx))==(pCtx)) -#define GFP_TEST_ID(pCtx) (GFP_ID((pCtx))==idCtxGFP) - -#define USE_MONT_SPACE_REPRESENTATION (1) - -/* -// get/release n element from/to the pool -*/ -__INLINE BNU_CHUNK_T* cpGFpGetPool(int n, IppsGFpState* pGF) -{ - BNU_CHUNK_T* pPool = GFP_POOL(pGF); - GFP_POOL(pGF) += n*GFP_PELEN(pGF); - return pPool; -} -__INLINE void cpGFpReleasePool(int n, IppsGFpState* pGF) -{ - GFP_POOL(pGF) -= n*GFP_PELEN(pGF); -} - - - -__INLINE int cpGFpElementLen(const BNU_CHUNK_T* pE, int nsE) -{ - for(; nsE>1 && 0==pE[nsE-1]; nsE--) ; - return nsE; -} -__INLINE BNU_CHUNK_T* cpGFpElementCopy(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pE, int nsE) -{ - int n; - for(n=0; n1 && pE[nsE-1]==pX[nsE-1]; nsE--) - ; - return pE[nsE-1]==pX[nsE-1]? 0 : pE[nsE-1]>pX[nsE-1]? 1:-1; -} -__INLINE int cpGFpElementIsEquChunk(const BNU_CHUNK_T* pE, int nsE, BNU_CHUNK_T x) -{ - int isEqu = (pE[0] == x); - return isEqu && (1==cpGFpElementLen(pE, nsE)); -} -__INLINE BNU_CHUNK_T* cpGFpElementSetChunk(BNU_CHUNK_T* pR, int nsR, BNU_CHUNK_T x) -{ - return cpGFpElementCopyPadd(pR, nsR, &x, 1); -} - - -#define GFP_LT(a,b,size) (-1==cpGFpElementCmp((a),(b),(size))) -#define GFP_EQ(a,b,size) ( 0==cpGFpElementCmp((a),(b),(size))) -#define GFP_GT(a,b,size) ( 1==cpGFpElementCmp((a),(b),(size))) - -#define GFP_IS_ZERO(a,size) cpGFpElementIsEquChunk((a),(size), 0) -#define GFP_IS_ONE(a,size) cpGFpElementIsEquChunk((a),(size), 1) - -#define GFP_ZERO(a,size) cpGFpElementSetChunk((a),(size), 0) -#define GFP_ONE(a,size) cpGFpElementSetChunk((a),(size), 1) - -#define GFP_IS_EVEN(a) (0==((a)[0]&1)) -#define GFP_IS_ODD(a) (1==((a)[0]&1)) - - -int cpGFpCompare(const IppsGFpState* pGFp1, const IppsGFpState* pGFp2); - -BNU_CHUNK_T* cpGFpRand(BNU_CHUNK_T* pR, IppsGFpState* pGF, IppBitSupplier rndFunc, void* pRndParam, int montSpace); -BNU_CHUNK_T* cpGFpSet (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pDataA, int nsA, IppsGFpState* pGF, int montSpace); -BNU_CHUNK_T* cpGFpGet (BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pR, IppsGFpState* pGF, int montSpace); -BNU_CHUNK_T* cpGFpSetOctString(BNU_CHUNK_T* pR, const Ipp8u* pStr, int strSize, IppsGFpState* pGF, int montSpace); -Ipp8u* cpGFpGetOctString(Ipp8u* pStr, int strSize, const BNU_CHUNK_T* pA, IppsGFpState* pGF, int montSpace); - -BNU_CHUNK_T* cpGFpNeg (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpInv (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpAdd (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpSub (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpMul (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpSqr (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cpGFpExp (BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, IppsGFpState* pGF); - int cpGFpSqrt(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); - -#if(_IPP32E >= _IPP32E_M7) -BNU_CHUNK_T* cp256pAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cp256pSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cp256pNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cp256pMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGF); -BNU_CHUNK_T* cp256pSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -BNU_CHUNK_T* cp256pHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGF); -#endif - -IppsBigNumState* cpGFpInitBigNum(IppsBigNumState* pBN, int len, BNU_CHUNK_T* pNumBuffer, BNU_CHUNK_T* pTmpBuffer); -IppsBigNumState* cpGFpSetBigNum(IppsBigNumState* pBN, int len, const BNU_CHUNK_T* pBNU, BNU_CHUNK_T* pTmpBuffer); - -#endif /* _PCP_GFP_H_ */ diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpx.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpx.c deleted file mode 100644 index be978bc148..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpx.c +++ /dev/null @@ -1,202 +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. - ############################################################################*/ - -/* -// Intel(R) Performance Primitives. Cryptography Primitives. -// Operations over GF(p) ectension. -// -// Context: -// ippsGFpxGetSize -// ippsGFpxInit -// ippsGFpGetInfo -// -*/ - -#include "owncpepid.h" - -#include "pcpgfpstuff.h" -#include "pcpgfpxstuff.h" - -/* Get context size */ -IPPFUN(IppStatus, ippsGFpxGetSize, (const IppsGFpState* pGroundGF, int deg, int* pSizeInBytes)) -{ - IPP_BAD_PTR2_RET(pGroundGF, pSizeInBytes); - IPP_BADARG_RET( deg<2, ippStsBadArgErr); - pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGroundGF), ippStsContextMatchErr ); - - { - int elemGroundLen = GFP_FELEN(pGroundGF); - int elemLen = elemGroundLen * deg; - *pSizeInBytes = sizeof(IppsGFpState) - +elemLen * sizeof(BNU_CHUNK_T) /* field polynomial coeff. excluding leading 1 */ - +elemLen * sizeof(BNU_CHUNK_T) * GFPX_POOL_SIZE /* pool of temporary variables */ - +GFP_ALIGNMENT-1; - return ippStsNoErr; - } -} - -static void InitGFpxCtx(const IppsGFpState* pGroundGF, int deg, IppsGFpState* pGFpx) -{ - int elemLen = deg * GFP_FELEN(pGroundGF); - int elemLen32 = deg* GFP_FELEN32(pGroundGF); - - Ipp8u* ptr = (Ipp8u*)pGFpx + sizeof(IppsGFpState); - - /* context identifier */ - GFP_ID(pGFpx) = idCtxGFP; - /* extension degree */ - GFP_DEGREE(pGFpx) = deg; - /* length of element */ - GFP_FELEN(pGFpx)= elemLen; - GFP_FELEN32(pGFpx) = elemLen32; - GFP_PELEN(pGFpx) = elemLen; - FIELD_POLY_TYPE(pGFpx) = ARBITRARY; - EPID_PARAMS(pGFpx) = 0; - - pGFpx->add = cpGFpxAdd; - pGFpx->sub = cpGFpxSub; - pGFpx->neg = cpGFpxNeg; - pGFpx->mul = cpGFpxMul; - pGFpx->sqr = cpGFpxSqr; - pGFpx->div2= cpGFpxHalve; - - /* save ground GF() context address */ - GFP_GROUNDGF(pGFpx) = (IppsGFpState*)pGroundGF; - /* coefficients of field polynomial */ - GFP_MODULUS(pGFpx) = (BNU_CHUNK_T*)(ptr); ptr += elemLen * sizeof(BNU_CHUNK_T); - /* 1/2 modulus: no matter */ - GFP_HMODULUS(pGFpx) = NULL; - /* quadratic non-residue: no matter */ - GFP_QNR(pGFpx) = NULL; - /* montgomery engine: no matter */ - GFP_MONT(pGFpx) = NULL; - /* pool addresses */ - GFP_POOL(pGFpx) = (BNU_CHUNK_T*)(IPP_ALIGNED_PTR(ptr, (int)sizeof(BNU_CHUNK_T))); - - cpGFpElementPadd(GFP_MODULUS(pGFpx), elemLen, 0); -} - - -/* Init context by arbitrary irreducible polynomial */ -IPPFUN(IppStatus, ippsGFpxInit, (const IppsGFpState* pGroundGF, - const Ipp32u* pIrrPolynomial, int deg, - IppsGFpState* pGFpx)) -{ - IPP_BAD_PTR3_RET(pGFpx, pGroundGF, pIrrPolynomial); - pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) ); - pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) ); - pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) ); - - /* init context */ - InitGFpxCtx(pGroundGF, deg, pGFpx); - - { - BNU_CHUNK_T* pTmp = cpGFpGetPool(1, pGFpx); - - /* copy coefficients of irresucible (except high-order 1) */ - COPY_BNU((Ipp32u*)pTmp, pIrrPolynomial, GFP_FELEN32(pGFpx)); - /* convert coefficients of irresucible into internal representation and store */ - cpGFpxSet(GFP_MODULUS(pGFpx), pTmp, GFP_FELEN(pGFpx), pGFpx, USE_MONT_SPACE_REPRESENTATION); - - cpGFpReleasePool(1, pGFpx); - return ippStsNoErr; - } -} - -/* Init context by arbitrary irreducible binimial */ -IPPFUN(IppStatus, ippsGFpxInitBinomial,(const IppsGFpState* pGroundGF, - const IppsGFpElement* pGroundElm, int deg, - IppsGFpState* pGFpx)) -{ - IPP_BAD_PTR3_RET(pGFpx, pGroundGF, pGroundElm); - pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) ); - pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) ); - pGroundGF = (IppsGFpState*)( IPP_ALIGNED_PTR(pGroundGF, GFP_ALIGNMENT) ); - - /* init context */ - InitGFpxCtx(pGroundGF, deg, pGFpx); - - /* store low-order coefficient of irresucible into the context */ - cpGFpElementCopy(GFP_MODULUS(pGFpx), GFPE_DATA(pGroundElm), GFP_FELEN(pGroundGF)); - FIELD_POLY_TYPE(pGFpx) = BINOMIAL; - - /* test if field polynomial is match to Intel(R) EPID specific */ - { - int isEpidParam = 0; - - BNU_CHUNK_T* g0 = cpGFpGetPool(1, (IppsGFpState*)pGroundGF); - int elmLen = GFP_FELEN(pGroundGF); - - int basicExt = cpGFpBasicDegreeExtension(pGFpx); - int basicTermLen = GFP_FELEN(cpGFpBasic(pGroundGF)); - - /* convert g0 into regular representation */ - cpGFpxGet(g0, elmLen, GFPE_DATA(pGroundElm), (IppsGFpState*)pGroundGF, USE_MONT_SPACE_REPRESENTATION); - - switch(basicExt) { - case 2: - /* expected polynomial is g() = t^2 + (-beta), - beta =q-1 */ - isEpidParam = cpGFpElementIsEquChunk(g0,basicTermLen, 1); - break; - case 6: - /* expected polynomial is g() = t^3 + (-xi), - xi = 2+1*t, coeffs belongs to Fq */ - cpGFpxNeg(g0, g0, (IppsGFpState*)pGroundGF); - isEpidParam = EPID_PARAMS(pGroundGF) - && cpGFpElementIsEquChunk(g0,basicTermLen, 2) - && cpGFpElementIsEquChunk(g0+basicTermLen,basicTermLen, 1); - break; - case 12: - /* expected polynomial is g() = t^2 + (-vi), - vi = (0+0*t) + (1*t^2+0*t^3) + (0*t^4+0*t^5), coeffs belongs to Fq */ - cpGFpxNeg(g0, g0, (IppsGFpState*)pGroundGF); - isEpidParam = EPID_PARAMS(pGroundGF) - && cpGFpElementIsEquChunk(g0,basicTermLen, 0) - && cpGFpElementIsEquChunk(g0+basicTermLen, basicTermLen, 0) - && cpGFpElementIsEquChunk(g0+basicTermLen*2,basicTermLen, 1) - && cpGFpElementIsEquChunk(g0+basicTermLen*3,basicTermLen, 0) - && cpGFpElementIsEquChunk(g0+basicTermLen*4,basicTermLen, 0) - && cpGFpElementIsEquChunk(g0+basicTermLen*5,basicTermLen, 0); - break; - default: - isEpidParam = 0; - break; - } - EPID_PARAMS(pGFpx) = isEpidParam; - - cpGFpReleasePool(1, (IppsGFpState*)pGroundGF); - } - - return ippStsNoErr; -} - -/* get general info */ -IPPFUN(IppStatus, ippsGFpGetInfo,(const IppsGFpState* pGFpx, IppsGFpInfo* pInfo)) -{ - IPP_BAD_PTR2_RET(pGFpx, pInfo); - pGFpx = (IppsGFpState*)( IPP_ALIGNED_PTR(pGFpx, GFP_ALIGNMENT) ); - IPP_BADARG_RET( !GFP_TEST_ID(pGFpx), ippStsContextMatchErr ); - - pInfo->pBasicGF = cpGFpBasic(pGFpx); - pInfo->pGroundGF = GFP_GROUNDGF(pGFpx); - pInfo->basicGFdegree = cpGFpBasicDegreeExtension(pGFpx); - pInfo->groundGFdegree = GFP_DEGREE(pGFpx); - pInfo->elementLen = GFP_FELEN32(pGFpx); - - return ippStsNoErr; -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.c b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.c deleted file mode 100644 index ae9a1f49b3..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.c +++ /dev/null @@ -1,1307 +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. - ############################################################################*/ - -/* -// Intel(R) Performance Primitives. Cryptography Primitives. -// Internal operations over GF(p) extension. -// -// Context: -// cpGFpxCmpare -// cpGFpxSet -// cpGFpxRand -// cpGFpxGet -// -// cpGFpxHalve -// cpGFpxAdd, cpGFpxAdd_GFE -// cpGFpxSub, cpGFpxSub_GFE -// cpGFpxMul, cpGFpxMul_GFE -// cpGFp2biMul, cpGFp3biMul, cpGFpxMul_G0 -// cpGFpxSqr -// cpGFp2biSqr, cpGFp3biSqr -// cpGFpxNeg -// cpGFpxInv -// cpGFpxExp -// cpGFpxMultiExp -// cpGFpxConj -// -// -*/ - -#include "owncpepid.h" - -#include "pcpgfpxstuff.h" -//#include "pcptool.h" - - -/* -// compare GF. -// returns: -// 0 - are equial -// 1 - are different -// 2 - different structure -*/ -int cpGFpxCompare(const IppsGFpState* pGFpx1, const IppsGFpState* pGFpx2) -{ - while( !GFP_IS_BASIC(pGFpx1) && !GFP_IS_BASIC(pGFpx2) ) { - if( GFP_DEGREE(pGFpx1) != GFP_DEGREE(pGFpx2) ) - return 2; - if( GFP_FELEN(pGFpx1) != GFP_FELEN(pGFpx2) ) - return 1; - if(0 != cpGFpElementCmp(GFP_MODULUS(pGFpx1), GFP_MODULUS(pGFpx1), GFP_FELEN(pGFpx1)) ) - return 1; - pGFpx1 = GFP_GROUNDGF(pGFpx1); - pGFpx2 = GFP_GROUNDGF(pGFpx2); - } - - return (GFP_IS_BASIC(pGFpx1) && GFP_IS_BASIC(pGFpx2))? cpGFpCompare(pGFpx1, pGFpx2) : 2; -} - -BNU_CHUNK_T* cpGFpxRand(BNU_CHUNK_T* pR, IppsGFpState* pGFpx, IppBitSupplier rndFunc, void* pRndParam, int montSpace) -{ - if( GFP_IS_BASIC(pGFpx) ) - return cpGFpRand(pR, pGFpx, rndFunc, pRndParam, montSpace); - - else { - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicDeg = cpGFpBasicDegreeExtension(pGFpx); - - BNU_CHUNK_T* pTmp = pR; - int deg; - for(deg=0; deg0; deg++) { - int pieceA = IPP_MIN(nsA, basicElemLen); - - cpGFpGet(pTmp, pieceA, pE, pBasicGF, montSpace); - pE += basicElemLen; - pTmp += pieceA; - nsA -= pieceA; - } - - return pDataA; - } -} - -BNU_CHUNK_T* cpGFpxGetPolyTerm(BNU_CHUNK_T* pDataA, int nsA, const BNU_CHUNK_T* pE, int deg, IppsGFpState* pGFpx, int montSpace) -{ - pE += deg * GFP_FELEN(pGFpx); - return cpGFpxGet(pDataA, nsA, pE, pGFpx, montSpace); -} - -BNU_CHUNK_T* cpGFpxHalve(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicDeg = cpGFpBasicDegreeExtension(pGFpx); - - BNU_CHUNK_T* pTmp = pR; - int deg; - for(deg=0; degdiv2(pTmp, pA, pBasicGF); - pTmp += basicElemLen; - pA += basicElemLen; - } - return pR; -} - -BNU_CHUNK_T* cpGFpxAdd(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicDeg = cpGFpBasicDegreeExtension(pGFpx); - - BNU_CHUNK_T* pTmp = pR; - int deg; - for(deg=0; degadd(pTmp, pA, pB, pBasicGF); - pTmp += basicElemLen; - pA += basicElemLen; - pB += basicElemLen; - } - return pR; -} - -BNU_CHUNK_T* cpGFpxSub(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicDeg = cpGFpBasicDegreeExtension(pGFpx); - - BNU_CHUNK_T* pTmp = pR; - int deg; - for(deg=0; degsub(pTmp, pA, pB, pBasicGF); - pTmp += basicElemLen; - pA += basicElemLen; - pB += basicElemLen; - } - return pR; -} - -BNU_CHUNK_T* cpGFpxConj(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int groundElemLen = GFP_FELEN(pGroundGF); - - if(pR != pA) - cpGFpElementCopy(pR, pA, groundElemLen); - //cpGFpxNeg(pR+groundElemLen, pA+groundElemLen, pGroundGF); - pGroundGF->neg(pR+groundElemLen, pA+groundElemLen, pGroundGF); - - return pR; -} - - -/* -// multiplication like GF(()^d).mul(a, g0), -// where: -// a, g0 belongs to ground GF() -// and g0 is low-order term of GF(()^d) generationg binominal g(t) = t^d + g0 -// is very important for Intel(R) EPID 2.0. -// -// Thus, this kind of multiplication is using -// 1) in iplementation of GF(p^2) multiplication -// 2) in iplementation of GF((p^6)^2) multiplication too -*/ -#if defined(_EPID20_GF_PARAM_SPECIFIC_) -#pragma message ("_EPID20_GF_PARAM_SPECIFIC_") - -__INLINE BNU_CHUNK_T* cpFqMul_beta(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - if(pR != pA) - cpGFpElementCopy(pR, pA, GFP_FELEN(pGFpx)); - return pR; -} - -__INLINE BNU_CHUNK_T* cpFq2Mul_xi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - BNU_CHUNK_T* t0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t1 = cpGFpGetPool(1, pGroundGF); - - int termLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+termLen; - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+termLen; - pGroundGF->add(t0, pA0, pA0, pGroundGF); - pGroundGF->add(t1, pA0, pA1, pGroundGF); - pGroundGF->sub(pR0, t0, pA1, pGroundGF); - pGroundGF->add(pR1, t1, pA1, pGroundGF); - - cpGFpReleasePool(2, pGroundGF); - return pR; -} - -__INLINE BNU_CHUNK_T* cpFq6Mul_vi(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int termLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+termLen; - const BNU_CHUNK_T* pA2 = pA+termLen*2; - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+termLen; - BNU_CHUNK_T* pR2 = pR+termLen*2; - - BNU_CHUNK_T* t = cpGFpGetPool(1, pGroundGF); - - cpFq2Mul_xi(t, pA2, pGroundGF); - cpGFpElementCopy(pR2, pA1, termLen); - cpGFpElementCopy(pR1, pA0, termLen); - cpGFpElementCopy(pR0, t, termLen); - - cpGFpReleasePool(1, pGroundGF); - - return pR; -} -#endif - -#if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) || defined(_EXTENSION_3_BINOMIAL_SUPPORT_) -static BNU_CHUNK_T* cpGFpxMul_G0(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFpx); /* g(x) = t^d + g0 */ - return pGroundGF->mul(pR, pA, pGFpolynomial, GFP_GROUNDGF(pGFpx)); -} -#endif - -/* -// field polynomial: g(x) = t^2 + beta - binominal -// extension degree: 2 -*/ -#if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) -static BNU_CHUNK_T* cpGFp2biMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+groundElemLen; - - const BNU_CHUNK_T* pB0 = pB; - const BNU_CHUNK_T* pB1 = pB+groundElemLen; - - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+groundElemLen; - - BNU_CHUNK_T* t0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t1 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t2 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t3 = cpGFpGetPool(1, pGroundGF); - - pGroundGF->mul(t0, pA0, pB0, pGroundGF); /* t0 = a[0]*b[0] */ - pGroundGF->mul(t1, pA1, pB1, pGroundGF); /* t1 = a[1]*b[1] */ - pGroundGF->add(t2, pA0, pA1,pGroundGF); /* t2 = a[0]+a[1] */ - pGroundGF->add(t3, pB0, pB1,pGroundGF); /* t3 = b[0]+b[1] */ - - pGroundGF->mul(pR1, t2, t3, pGroundGF); /* r[1] = (a[0]+a[1]) * (b[0]+b[1]) */ - pGroundGF->sub(pR1, pR1, t0, pGroundGF); /* r[1] -= a[0]*b[0]) + a[1]*b[1] */ - pGroundGF->sub(pR1, pR1, t1, pGroundGF); - - #if defined(_EPID20_GF_PARAM_SPECIFIC_) /* r[0] = t0 - t1*beta */ - { - int basicExtDegree = cpGFpBasicDegreeExtension(pGFpx); - if(basicExtDegree==2 && EPID_PARAMS(pGFpx)) { - //cpFqMul_beta(t1, t1, pGroundGF); - pGroundGF->sub(pR0, t0, t1, pGroundGF); - } - else if(basicExtDegree==12 && EPID_PARAMS(pGFpx)) { - cpFq6Mul_vi(t1, t1, pGroundGF); - pGroundGF->add(pR0, t0, t1, pGroundGF); - } - else { - cpGFpxMul_G0(t1, t1, pGFpx); - pGroundGF->sub(pR0, t0, t1, pGroundGF); - } - } - #else - cpGFpxMul_G0(t1, t1, pGFpx); - pGroundGF->sub(pR0, t0, t1, pGroundGF); - #endif - - cpGFpReleasePool(4, pGroundGF); - return pR; -} -#endif - -/* -// field polynomial: g(x) = t^3 + beta - binominal -// extension degree: 3 -*/ -#if defined(_EXTENSION_3_BINOMIAL_SUPPORT_) -static BNU_CHUNK_T* cpGFp3biMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+groundElemLen; - const BNU_CHUNK_T* pA2 = pA+groundElemLen*2; - - const BNU_CHUNK_T* pB0 = pB; - const BNU_CHUNK_T* pB1 = pB+groundElemLen; - const BNU_CHUNK_T* pB2 = pB+groundElemLen*2; - - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+groundElemLen; - BNU_CHUNK_T* pR2 = pR+groundElemLen*2; - - BNU_CHUNK_T* t0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t1 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t2 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* u0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* u1 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* u2 = cpGFpGetPool(1, pGroundGF); - - pGroundGF->add(u0 ,pA0, pA1, pGroundGF); /* u0 = a[0]+a[1] */ - pGroundGF->add(t0 ,pB0, pB1, pGroundGF); /* t0 = b[0]+b[1] */ - pGroundGF->mul(u0, u0, t0, pGroundGF); /* u0 = (a[0]+a[1])*(b[0]+b[1]) */ - pGroundGF->mul(t0, pA0, pB0, pGroundGF); /* t0 = a[0]*b[0] */ - - pGroundGF->add(u1 ,pA1, pA2, pGroundGF); /* u1 = a[1]+a[2] */ - pGroundGF->add(t1 ,pB1, pB2, pGroundGF); /* t1 = b[1]+b[2] */ - pGroundGF->mul(u1, u1, t1, pGroundGF); /* u1 = (a[1]+a[2])*(b[1]+b[2]) */ - pGroundGF->mul(t1, pA1, pB1, pGroundGF); /* t1 = a[1]*b[1] */ - - pGroundGF->add(u2 ,pA2, pA0, pGroundGF); /* u2 = a[2]+a[0] */ - pGroundGF->add(t2 ,pB2, pB0, pGroundGF); /* t2 = b[2]+b[0] */ - pGroundGF->mul(u2, u2, t2, pGroundGF); /* u2 = (a[2]+a[0])*(b[2]+b[0]) */ - pGroundGF->mul(t2, pA2, pB2, pGroundGF); /* t2 = a[2]*b[2] */ - - pGroundGF->sub(u0, u0, t0, pGroundGF); /* u0 = a[0]*b[1]+a[1]*b[0] */ - pGroundGF->sub(u0, u0, t1, pGroundGF); - pGroundGF->sub(u1, u1, t1, pGroundGF); /* u1 = a[1]*b[2]+a[2]*b[1] */ - pGroundGF->sub(u1, u1, t2, pGroundGF); - pGroundGF->sub(u2, u2, t2, pGroundGF); /* u2 = a[2]*b[0]+a[0]*b[2] */ - pGroundGF->sub(u2, u2, t0, pGroundGF); - - #if defined(_EPID20_GF_PARAM_SPECIFIC_) - { - int basicExtDegree = cpGFpBasicDegreeExtension(pGFpx); - if(basicExtDegree==6 && EPID_PARAMS(pGFpx)) { - cpFq2Mul_xi(u1, u1, pGroundGF); - cpFq2Mul_xi(t2, t2, pGroundGF); - pGroundGF->add(pR0, t0, u1, pGroundGF); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */ - pGroundGF->add(pR1, u0, t2, pGroundGF); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */ - } - else { - cpGFpxMul_G0(u1, u1, pGFpx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */ - cpGFpxMul_G0(t2, t2, pGFpx); /* t2 = a[2]*b[2] * beta */ - pGroundGF->sub(pR0, t0, u1, pGroundGF); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */ - pGroundGF->sub(pR1, u0, t2, pGroundGF); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */ - } - } - #else - cpGFpxMul_G0(u1, u1, pGFpx); /* u1 = (a[1]*b[2]+a[2]*b[1]) * beta */ - cpGFpxMul_G0(t2, t2, pGFpx); /* t2 = a[2]*b[2] * beta */ - - pGroundGF->sub(pR0, t0, u1, pGroundGF); /* r[0] = a[0]*b[0] - (a[2]*b[1]+a[1]*b[2])*beta */ - pGroundGF->sub(pR1, u0, t2, pGroundGF); /* r[1] = a[1]*b[0] + a[0]*b[1] - a[2]*b[2]*beta */ - #endif - - pGroundGF->add(pR2, u2, t1, pGroundGF); /* r[2] = a[2]*b[0] + a[1]*b[1] + a[0]*b[2] */ - - cpGFpReleasePool(6, pGroundGF); - return pR; -} -#endif - -BNU_CHUNK_T* cpGFpxMul(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pB, IppsGFpState* pGFpx) -{ - int extDegree = GFP_DEGREE(pGFpx); - - #if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) - #pragma message ("_EXTENSION_2_BINOMIAL_SUPPORT_") - if(BINOMIAL==FIELD_POLY_TYPE(pGFpx) && extDegree==2) - return cpGFp2biMul(pR, pA, pB, pGFpx); - #endif - - #if defined(_EXTENSION_3_BINOMIAL_SUPPORT_) - #pragma message ("_EXTENSION_3_BINOMIAL_SUPPORT_") - if(BINOMIAL==FIELD_POLY_TYPE(pGFpx) && extDegree==3) - return cpGFp3biMul(pR, pA, pB, pGFpx); - #endif - - { - BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFpx); - int degR = extDegree-1; - int elemLen= GFP_FELEN(pGFpx); - - int degB = degR; - BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFpx); - BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFpx); - - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGF); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pTmpB = GFPX_IDX_ELEMENT(pB, degB, groundElemLen); - - /* clear temporary */ - cpGFpElementPadd(pTmpProduct, elemLen, 0); - - /* R = A * B[degB-1] */ - cpGFpxMul_GFE(pTmpResult, pA, pTmpB, pGFpx); - - for(degB-=1; degB>=0; degB--) { - /* save R[degR-1] */ - cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen); - - { /* R = R * x */ - int j; - for (j=degR; j>=1; j--) - cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen); - cpGFpElementPadd(pTmpResult, groundElemLen, 0); - } - - cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFpx); - pGFpx->sub(pTmpResult, pTmpResult, pTmpProduct, pGFpx); - - /* B[degB-i] */ - pTmpB -= groundElemLen; - cpGFpxMul_GFE(pTmpProduct, pA, pTmpB, pGFpx); - pGFpx->add(pTmpResult, pTmpResult, pTmpProduct, pGFpx); - } - - /* copy result */ - cpGFpElementCopy(pR, pTmpResult, elemLen); - - /* release pools */ - cpGFpReleasePool(1, pGroundGF); - cpGFpReleasePool(2, pGFpx); - - return pR; - } -} - -/* -// field polynomial: binominal -// extension degree: 2 -*/ -#if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) -static BNU_CHUNK_T* cpGFp2biSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+groundElemLen; - - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+groundElemLen; - - BNU_CHUNK_T* t0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* t1 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* u0 = cpGFpGetPool(1, pGroundGF); - - pGroundGF->mul(u0, pA0, pA1, pGroundGF); /* u0 = a[0]*a[1] */ - - #if defined(_EPID20_GF_PARAM_SPECIFIC_) /* r[0] = t0 - t1*beta */ - { - int basicExtDegree = cpGFpBasicDegreeExtension(pGFpx); - if(basicExtDegree==2 && EPID_PARAMS(pGFpx)) { - pGroundGF->add(t0, pA0, pA1, pGroundGF); - pGroundGF->sub(t1, pA0, pA1, pGroundGF); - pGroundGF->mul(pR0, t0, t1, pGroundGF); - pGroundGF->add(pR1, u0, u0, pGroundGF); /* r[1] = 2*a[0]*a[1] */ - } - else if(basicExtDegree==12 && EPID_PARAMS(pGFpx)) { - pGroundGF->sub(t0, pA0, pA1, pGroundGF); - cpFq6Mul_vi(t1, pA1, pGroundGF); - pGroundGF->sub(t1, pA0, t1, pGroundGF); - pGroundGF->mul(t0, t0, t1, pGroundGF); - pGroundGF->add(t0, t0, u0, pGroundGF); - cpFq6Mul_vi(t1, u0, pGroundGF); - pGroundGF->add(pR0, t0, t1, pGroundGF); - pGroundGF->add(pR1, u0, u0, pGroundGF); - } - else { - pGroundGF->sqr(t0, pA0, pGroundGF); /* t0 = a[0]*a[0] */ - pGroundGF->sqr(t1, pA1, pGroundGF); /* t1 = a[1]*a[1] */ - cpGFpxMul_G0(t1, t1, pGFpx); - pGroundGF->sub(pR0, t0, t1, pGroundGF); - pGroundGF->add(pR1, u0, u0, pGroundGF); /* r[1] = 2*a[0]*a[1] */ - } - } - #else - pGroundGF->sqr(t0, pA0, pGroundGF); /* t0 = a[0]*a[0] */ - pGroundGF->sqr(t1, pA1, pGroundGF); /* t1 = a[1]*a[1] */ - cpGFpxMul_G0(t1, t1, pGFpx); - pGroundGF->sub(pR0, t0, t1, pGroundGF); - pGroundGF->add(pR1, u0, u0, pGroundGF); /* r[1] = 2*a[0]*a[1] */ - #endif - - cpGFpReleasePool(3, pGroundGF); - return pR; -} -#endif - -/* -// field polynomial: binominal -// extension degree: 3 -*/ -#if defined(_EXTENSION_3_BINOMIAL_SUPPORT_) -static BNU_CHUNK_T* cpGFp3biSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pA0 = pA; - const BNU_CHUNK_T* pA1 = pA+groundElemLen; - const BNU_CHUNK_T* pA2 = pA+groundElemLen*2; - - BNU_CHUNK_T* pR0 = pR; - BNU_CHUNK_T* pR1 = pR+groundElemLen; - BNU_CHUNK_T* pR2 = pR+groundElemLen*2; - - BNU_CHUNK_T* s0 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* s1 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* s2 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* s3 = cpGFpGetPool(1, pGroundGF); - BNU_CHUNK_T* s4 = cpGFpGetPool(1, pGroundGF); - - pGroundGF->add(s2, pA0, pA2, pGroundGF); - pGroundGF->sub(s2, s2, pA1, pGroundGF); - pGroundGF->sqr(s2, s2, pGroundGF); - pGroundGF->sqr(s0, pA0, pGroundGF); - pGroundGF->sqr(s4, pA2, pGroundGF); - pGroundGF->mul(s1, pA0, pA1, pGroundGF); - pGroundGF->mul(s3, pA1, pA2, pGroundGF); - pGroundGF->add(s1, s1, s1, pGroundGF); - pGroundGF->add(s3, s3, s3, pGroundGF); - - pGroundGF->add(pR2, s1, s2, pGroundGF); - pGroundGF->add(pR2, pR2, s3, pGroundGF); - pGroundGF->sub(pR2, pR2, s0, pGroundGF); - pGroundGF->sub(pR2, pR2, s4, pGroundGF); - - #if defined(_EPID20_GF_PARAM_SPECIFIC_) - { - int basicExtDegree = cpGFpBasicDegreeExtension(pGFpx); - if(basicExtDegree==6 && EPID_PARAMS(pGFpx)) { - cpFq2Mul_xi(s4, s4, pGroundGF); - cpFq2Mul_xi(s3, s3, pGroundGF); - pGroundGF->add(pR1, s1, s4, pGroundGF); - pGroundGF->add(pR0, s0, s3, pGroundGF); - } - else { - cpGFpxMul_G0(s4, s4, pGFpx); - cpGFpxMul_G0(s3, s3, pGFpx); - pGroundGF->sub(pR1, s1, s4, pGroundGF); - pGroundGF->sub(pR0, s0, s3, pGroundGF); - } - } - - #else - cpGFpxMul_G0(s4, s4, pGFpx); - pGroundGF->sub(pR1, s1, s4, pGroundGF); - - cpGFpxMul_G0(s3, s3, pGFpx); - pGroundGF->sub(pR0, s0, s3, pGroundGF); - #endif - - cpGFpReleasePool(5, pGroundGF); - return pR; -} -#endif - -BNU_CHUNK_T* cpGFpxSqr(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - int extDegree = GFP_DEGREE(pGFpx); - - #if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) - #pragma message ("_EXTENSION_2_BINOMIAL_SUPPORT_") - if(BINOMIAL==FIELD_POLY_TYPE(pGFpx) && extDegree==2) - return cpGFp2biSqr(pR, pA, pGFpx); - #endif - - #if defined(_EXTENSION_3_BINOMIAL_SUPPORT_) - #pragma message ("_EXTENSION_3_BINOMIAL_SUPPORT_") - if(BINOMIAL==FIELD_POLY_TYPE(pGFpx) && extDegree==3) - return cpGFp3biSqr(pR, pA, pGFpx); - #endif - - { - BNU_CHUNK_T* pGFpolynomial = GFP_MODULUS(pGFpx); - int degR = extDegree-1; - int elemLen= GFP_FELEN(pGFpx); - - int degA = degR; - BNU_CHUNK_T* pTmpProduct = cpGFpGetPool(2, pGFpx); - BNU_CHUNK_T* pTmpResult = pTmpProduct + GFP_PELEN(pGFpx); - - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - BNU_CHUNK_T* r = cpGFpGetPool(1, pGroundGF); - int groundElemLen = GFP_FELEN(pGroundGF); - - const BNU_CHUNK_T* pTmpA = GFPX_IDX_ELEMENT(pA, degA, groundElemLen); - - /* clear temporary */ - cpGFpElementPadd(pTmpProduct, elemLen, 0); - - /* R = A * A[degA-1] */ - cpGFpxMul_GFE(pTmpResult, pA, pTmpA, pGFpx); - - for(degA-=1; degA>=0; degA--) { - /* save R[degR-1] */ - cpGFpElementCopy(r, GFPX_IDX_ELEMENT(pTmpResult, degR, groundElemLen), groundElemLen); - - { /* R = R * x */ - int j; - for (j=degR; j>=1; j--) - cpGFpElementCopy(GFPX_IDX_ELEMENT(pTmpResult, j, groundElemLen), GFPX_IDX_ELEMENT(pTmpResult, j-1, groundElemLen), groundElemLen); - cpGFpElementPadd(pTmpResult, groundElemLen, 0); - } - - cpGFpxMul_GFE(pTmpProduct, pGFpolynomial, r, pGFpx); - pGFpx->sub(pTmpResult, pTmpResult, pTmpProduct, pGFpx); - - /* A[degA-i] */ - pTmpA -= groundElemLen; - cpGFpxMul_GFE(pTmpProduct, pA, pTmpA, pGFpx); - pGFpx->add(pTmpResult, pTmpResult, pTmpProduct, pGFpx); - } - - /* copy result */ - cpGFpElementCopy(pR, pTmpResult, elemLen); - - /* release pools */ - cpGFpReleasePool(1, pGroundGF); - cpGFpReleasePool(2, pGFpx); - - return pR; - } -} - -BNU_CHUNK_T* cpGFpxAdd_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - - if(pR != pA) { - int groundElemLen = GFP_FELEN(pGroundGF); - int deg = GFP_DEGREE(pGFpx); - cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1)); - } - return pGroundGF->add(pR, pA, pGroundB, pGroundGF); -} - -BNU_CHUNK_T* cpGFpxSub_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - - if(pR != pA) { - int groundElemLen = GFP_FELEN(pGroundGF); - int deg = GFP_DEGREE(pGFpx); - cpGFpElementCopy(pR+groundElemLen, pA+groundElemLen, groundElemLen*(deg-1)); - } - return pGroundGF->sub(pR, pA, pGroundB, pGroundGF); -} - -BNU_CHUNK_T* cpGFpxMul_GFE(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pGroundB, IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - int grounfElemLen = GFP_FELEN(pGroundGF); - - BNU_CHUNK_T* pTmp = pR; - - int deg; - for(deg=0; degmul(pTmp, pA, pGroundB, pGroundGF); - pTmp += grounfElemLen; - pA += grounfElemLen; - } - return pR; -} - -BNU_CHUNK_T* cpGFpxNeg(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicElemLen = GFP_FELEN(pBasicGF); - int basicDeg = cpGFpBasicDegreeExtension(pGFpx); - - BNU_CHUNK_T* pTmp = pR; - int deg; - for(deg=0; degneg(pTmp, pA, pBasicGF); - pTmp += basicElemLen; - pA += basicElemLen; - } - return pR; -} - -////////////////////////////////////////////////////////////////// -BNU_CHUNK_T* gfpolyDiv_v0(BNU_CHUNK_T* pQ, BNU_CHUNK_T* pR, - const BNU_CHUNK_T* pA, - const BNU_CHUNK_T* pB, - IppsGFpState* pGFpx) -{ - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFpx); - - if( GFP_IS_BASIC(pGroundGF) ) { - int elemLen = GFP_FELEN(pGFpx); - int termLen = GFP_FELEN(pGroundGF); - - int degA = degree(pA, pGFpx); - int degB = degree(pB, pGFpx); - - if(degB==0) { - if( GFP_IS_ZERO(pB, termLen) ) - return NULL; - else { - cpGFpInv(pR, pB, pGroundGF); - cpGFpElementPadd(pQ, elemLen, 0); - cpGFpxMul_GFE(pQ, pA, pR, pGFpx); - cpGFpElementPadd(pR, elemLen, 0); - return pR; - } - } - - if(degA < degB) { - cpGFpElementPadd(pQ, elemLen, 0); - cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen); - return pR; - } - - else { - int i, j; - BNU_CHUNK_T* pProduct = cpGFpGetPool(2, pGroundGF); - BNU_CHUNK_T* pInvB = pProduct + GFP_PELEN(pGroundGF); - - cpGFpElementCopyPadd(pR, elemLen, pA, (degA+1)*termLen); - cpGFpElementPadd(pQ, elemLen, 0); - - cpGFpInv(pInvB, GFPX_IDX_ELEMENT(pB, degB, termLen), pGroundGF); - - for(i=0; i<=degA-degB && !GFP_IS_ZERO(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen); i++) { - /* compute q term */ - cpGFpMul(GFPX_IDX_ELEMENT(pQ, degA-degB-i, termLen), - GFPX_IDX_ELEMENT(pR, degA-i, termLen), - pInvB, - pGroundGF); - - /* R -= B * q */ - cpGFpElementPadd(GFPX_IDX_ELEMENT(pR, degA-i, termLen), termLen, 0); - for(j=0; j 0) { - gfpxPolyDiv(quo, temp, lastrem, rem, pGFpx); - SWAP_PTR(BNU_CHUNK_T, rem, lastrem); // - SWAP_PTR(BNU_CHUNK_T, temp, rem); - - cpGFpxNeg(quo, quo, pGFpx); - cpGFpxMul(temp, quo, aux, pGFpx); - cpGFpxAdd(temp, lastaux, temp, pGFpx); - SWAP_PTR(BNU_CHUNK_T, aux, lastaux); - SWAP_PTR(BNU_CHUNK_T, temp, aux); - } - if (GFP_IS_ZERO(rem, elemLen)) { /* gcd != 1 */ - cpGFpReleasePool(pxVars, pGFpx); - return NULL; - } - - { - BNU_CHUNK_T* invRem = cpGFpGetPool(1, pGroundGF); - - cpGFpxInv(invRem, rem, pGroundGF); - cpGFpxMul_GFE(pR, aux, invRem, pGFpx); - - cpGFpReleasePool(1, pGroundGF); - } - - cpGFpReleasePool(pxVars, pGFpx); - - return pR; - } -} - - -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 -} - - -/* sscm version */ -BNU_CHUNK_T* cpGFpxExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* pA, const BNU_CHUNK_T* pE, int nsE, - IppsGFpState* pGFpx, Ipp8u* pScratchBuffer) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - - /* remove leding zeros */ - FIX_BNU(pE, nsE); - - { - Ipp8u* pScratchAligned; /* aligned scratch buffer */ - int nAllocation = 0; /* points from the pool */ - - /* size of element (bytes) */ - int elmDataSize = GFP_FELEN(pGFpx)*sizeof(BNU_CHUNK_T); - - /* exponent bitsize */ - int expBitSize = BITSIZE_BNU(pE, nsE); - /* optimal size of window */ - int w = (NULL==pScratchBuffer)? 1 : cpGFpGetOptimalWinSize(expBitSize); - /* number of table entries */ - int nPrecomputed = 1<mul(pTmp, pTmp, pA, pGFpx); - cpScramblePut(pScratchAligned+n, nPrecomputed, (Ipp8u*)pTmp, elmDataSize); - } - } - - { - /* copy exponent value */ - cpGFpElementCopy(pExpandedE, pE, nsE); - - /* expand exponent value */ - ((Ipp32u*)pExpandedE)[BITS2WORD32_SIZE(expBitSize)] = 0; - expBitSize = ((expBitSize+w-1)/w)*w; - - /* - // exponentiation - */ - { - /* digit mask */ - BNU_CHUNK_T dmask = nPrecomputed-1; - - /* position (bit number) of the leftmost window */ - int wPosition = expBitSize-w; - - /* extract leftmost window value */ - Ipp32u eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u))); - int shift = wPosition & 0xF; - Ipp32u windowVal = (eChunk>>shift) & dmask; - - /* initialize result */ - cpScrambleGet((Ipp8u*)pR, elmDataSize, pScratchAligned+windowVal, nPrecomputed); - - for(wPosition-=w; wPosition>=0; wPosition-=w) { - int k; - /* w times squaring */ - for(k=0; ksqr(pR, pR, pGFpx); - - /* extract next window value */ - eChunk = *((Ipp32u*)((Ipp16u*)pExpandedE+ wPosition/BITSIZE(Ipp16u))); - shift = wPosition & 0xF; - windowVal = (eChunk>>shift) & dmask; - - /* extract value from the pre-computed table */ - cpScrambleGet((Ipp8u*)pTmp, elmDataSize, pScratchAligned+windowVal, nPrecomputed); - - /* and multiply */ - pGFpx->mul(pR, pR, pTmp, pGFpx); - } - } - - } - - cpGFpReleasePool(nAllocation+2, pGFpx); - - return pR; - } -} - - -static void cpPrecomputeMultiExp(Ipp8u* pTable, const BNU_CHUNK_T* ppA[], int nItems, IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - - int nPrecomputed = 1<=0; k--) { - int tblIdx = baseIdx; - - int n; - for(n=0; nmul(pT, pT, ppA[k], pGFpx); - cpScramblePut(pTable+tblIdx+step, nPrecomputed, (Ipp8u*)pT, elmDataSize); - } - - nPasses *= 2; - step /= 2; - } - } - } - } - - /* release resourse */ - cpGFpReleasePool(1, pGFpx); -} - -static int cpGetMaxBitsizeExponent(const BNU_CHUNK_T* ppE[], int nsE[], int nItems) -{ - int n; - /* find out the longest exponent */ - int expBitSize = BITSIZE_BNU(ppE[0], nsE[0]); - for(n=1; n0; n--) { - const Ipp8u* pE = ((Ipp8u*)ppE[n-1]) + offset; - Ipp8u e = pE[0]; - index <<= 1; - index += (e>>shift) &1; - } - return index; -} - -/* sscm version */ -BNU_CHUNK_T* cpGFpxMultiExp(BNU_CHUNK_T* pR, const BNU_CHUNK_T* ppA[], const BNU_CHUNK_T* ppE[], int nsE[], int nItems, - IppsGFpState* pGFpx, Ipp8u* pScratchBuffer) -{ - /* align scratch buffer */ - Ipp8u* pScratchAligned = IPP_ALIGNED_PTR(pScratchBuffer, CACHE_LINE_SIZE); - /* pre-compute table */ - cpPrecomputeMultiExp(pScratchAligned, ppA, nItems, pGFpx); - - { - /* find out the longest exponent */ - int expBitSize = cpGetMaxBitsizeExponent(ppE, nsE, nItems); - - /* allocate resource and copy expanded exponents into */ - const BNU_CHUNK_T* ppExponent[LOG2_CACHE_LINE_SIZE]; - { - int n; - for(n=0; n=0; expBitSize--) { - pGFpx->sqr(pR, pR, pGFpx); - tblIdx = GetIndex(ppExponent, nItems, expBitSize); - cpScrambleGet((Ipp8u*)pT, elmDataSize, pScratchAligned+tblIdx, nPrecomputed); - pGFpx->mul(pR, pR, pT, pGFpx); - } - - /* release resourse */ - cpGFpReleasePool(1, pGFpx); - } - - /* release resourse */ - cpGFpReleasePool(nItems, pGFpx); - - return pR; - } -} diff --git a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.h b/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.h deleted file mode 100644 index e887034a7a..0000000000 --- a/sgx-jvm/linux-sgx/external/epid/ext/ipp/sources/ippcpepid/src/pcpgfpxstuff.h +++ /dev/null @@ -1,174 +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. - ############################################################################*/ - -/* -// Intel(R) Integrated Performance Primitives -// Cryptographic Primitives (ippCP) -// GF(p) extension internal -// -*/ - -#if !defined(_PCP_GFPEXT_H_) -#define _PCP_GFPEXT_H_ - -#include "pcpgfpstuff.h" - - -#define _EXTENSION_2_BINOMIAL_SUPPORT_ -#define _EXTENSION_3_BINOMIAL_SUPPORT_ - -#if defined(_EXTENSION_2_BINOMIAL_SUPPORT_) && defined(_EXTENSION_3_BINOMIAL_SUPPORT_) - /* Intel(R) EPID specific: - (Fq2) GF(q^2) generating polynomial is g(t) = t^2 + beta, beta = 1 - - */ - #define _EPID20_GF_PARAM_SPECIFIC_ -#endif - -/* GF(p^d) pool */ -#define GFPX_PESIZE(pGF) GFP_FELEN((pGF)) -#define GFPX_POOL_SIZE (14) //(8) /* Number of temporary variables in pool */ - -/* address of ground field element inside expanded field element */ -#define GFPX_IDX_ELEMENT(pxe, idx, eleSize) ((pxe)+(eleSize)*(idx)) - -#if 0 -/* internal function prototypes */ -__INLINE BNU_CHUNK_T* cpGFpxGetPool(int n, IppsGFpState* pGFpx) -{ - BNU_CHUNK_T* pPool = GFP_POOL(pGFpx); - GFP_POOL(pGFpx) += n*GFPX_PESIZE(pGFpx); - return pPool; -} -__INLINE void cpGFpxReleasePool(int n, IppsGFpState* pGFpx) -{ - GFP_POOL(pGFpx) -= n * GFPX_PESIZE(pGFpx); -} -#endif - -__INLINE int degree(const BNU_CHUNK_T* pE, const IppsGFpState* pGFpx) -{ - int groundElemLen = GFP_FELEN( (IppsGFpState*)GFP_GROUNDGF(pGFpx) ); - int deg; - for(deg=GFP_DEGREE(pGFpx)-1; deg>=0; deg-- ) { - if(!GFP_IS_ZERO(pE+groundElemLen*deg, groundElemLen)) break; - } - return deg; -} - -__INLINE IppsGFpState* cpGFpBasic(const IppsGFpState* pGFp) -{ - while( !GFP_IS_BASIC(pGFp) ) { - pGFp = GFP_GROUNDGF(pGFp); - } - return (IppsGFpState*)pGFp; -} -__INLINE int cpGFpBasicDegreeExtension(const IppsGFpState* pGFp) -{ - int degree = GFP_DEGREE(pGFp); - while( !GFP_IS_BASIC(pGFp) ) { - IppsGFpState* pGroundGF = GFP_GROUNDGF(pGFp); - degree *= GFP_DEGREE(pGroundGF); - pGFp = pGroundGF; - } - return degree; -} - -/* convert external data (Ipp32u) => internal element (BNU_CHUNK_T) representation - returns length of element (in BNU_CHUNK_T) -*/ -__INLINE int cpGFpxCopyToChunk(BNU_CHUNK_T* pElm, const Ipp32u* pA, int nsA, const IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicExtension = cpGFpBasicDegreeExtension(pGFpx); - int basicElmLen32 = GFP_FELEN32(pBasicGF); - int basicElmLen = GFP_FELEN(pBasicGF); - int deg; - for(deg=0; deg0; deg++, nsA -= basicElmLen32) { - int srcLen = IPP_MIN(nsA, basicElmLen32); - ZEXPAND_COPY_BNU((Ipp32u*)pElm, basicElmLen*(int)(sizeof(BNU_CHUNK_T)/sizeof(Ipp32u)), pA,srcLen); - pElm += basicElmLen; - pA += basicElmLen32; - } - return basicElmLen*deg; -} - -/* convert internal element (BNU_CHUNK_T) => external data (Ipp32u) representation - returns length of data (in Ipp32u) -*/ -__INLINE int cpGFpxCopyFromChunk(Ipp32u* pA, const BNU_CHUNK_T* pElm, const IppsGFpState* pGFpx) -{ - IppsGFpState* pBasicGF = cpGFpBasic(pGFpx); - int basicExtension = cpGFpBasicDegreeExtension(pGFpx); - int basicElmLen32 = GFP_FELEN32(pBasicGF); - int basicElmLen = GFP_FELEN(pBasicGF); - int deg; - for(deg=0; deg // yes, this one new style header, is in the Android SDK. -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -#else -# include -# include -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - // Microsoft Visual Studio, version 2005 and higher. Not WinCE. - /*int _snprintf_s( - char *buffer, - size_t sizeOfBuffer, - size_t count, - const char *format [, - argument] ... - );*/ - static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) - { - va_list va; - va_start( va, format ); - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - va_end( va ); - return result; - } - - static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va ) - { - int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); - return result; - } - - #define TIXML_VSCPRINTF _vscprintf - #define TIXML_SSCANF sscanf_s -#elif defined _MSC_VER - // Microsoft Visual Studio 2003 and earlier or WinCE - #define TIXML_SNPRINTF _snprintf - #define TIXML_VSNPRINTF _vsnprintf - #define TIXML_SSCANF sscanf - #if (_MSC_VER < 1400 ) && (!defined WINCE) - // Microsoft Visual Studio 2003 and not WinCE. - #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. - #else - // Microsoft Visual Studio 2003 and earlier or WinCE. - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = 512; - for (;;) { - len = len*2; - char* str = new char[len](); - const int required = _vsnprintf(str, len, format, va); - delete[] str; - if ( required != -1 ) { - TIXMLASSERT( required >= 0 ); - len = required; - break; - } - } - TIXMLASSERT( len >= 0 ); - return len; - } - #endif -#else - // GCC version 3 and higher - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_VSNPRINTF vsnprintf - static inline int TIXML_VSCPRINTF( const char* format, va_list va ) - { - int len = vsnprintf( 0, 0, format, va ); - TIXMLASSERT( len >= 0 ); - return len; - } - #define TIXML_SSCANF sscanf -#endif - - -static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF -static const char LF = LINE_FEED; -static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out -static const char CR = CARRIAGE_RETURN; -static const char SINGLE_QUOTE = '\''; -static const char DOUBLE_QUOTE = '\"'; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// ef bb bf (Microsoft "lead bytes") - designates UTF-8 - -static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -namespace tinyxml2 -{ - -struct Entity { - const char* pattern; - int length; - char value; -}; - -static const int NUM_ENTITIES = 5; -static const Entity entities[NUM_ENTITIES] = { - { "quot", 4, DOUBLE_QUOTE }, - { "amp", 3, '&' }, - { "apos", 4, SINGLE_QUOTE }, - { "lt", 2, '<' }, - { "gt", 2, '>' } -}; - - -StrPair::~StrPair() -{ - Reset(); -} - - -void StrPair::TransferTo( StrPair* other ) -{ - if ( this == other ) { - return; - } - // This in effect implements the assignment operator by "moving" - // ownership (as in auto_ptr). - - TIXMLASSERT( other->_flags == 0 ); - TIXMLASSERT( other->_start == 0 ); - TIXMLASSERT( other->_end == 0 ); - - other->Reset(); - - other->_flags = _flags; - other->_start = _start; - other->_end = _end; - - _flags = 0; - _start = 0; - _end = 0; -} - -void StrPair::Reset() -{ - if ( _flags & NEEDS_DELETE ) { - delete [] _start; - } - _flags = 0; - _start = 0; - _end = 0; -} - - -void StrPair::SetStr( const char* str, int flags ) -{ - TIXMLASSERT( str ); - Reset(); - size_t len = strlen( str ); - TIXMLASSERT( _start == 0 ); - _start = new char[ len+1 ]; - memcpy( _start, str, len+1 ); - _end = _start + len; - _flags = flags | NEEDS_DELETE; -} - - -char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) -{ - TIXMLASSERT( endTag && *endTag ); - - char* start = p; - char endChar = *endTag; - size_t length = strlen( endTag ); - - // Inner loop of text parsing. - while ( *p ) { - if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { - Set( start, p, strFlags ); - return p + length; - } - ++p; - } - return 0; -} - - -char* StrPair::ParseName( char* p ) -{ - if ( !p || !(*p) ) { - return 0; - } - if ( !XMLUtil::IsNameStartChar( *p ) ) { - return 0; - } - - char* const start = p; - ++p; - while ( *p && XMLUtil::IsNameChar( *p ) ) { - ++p; - } - - Set( start, p, 0 ); - return p; -} - - -void StrPair::CollapseWhitespace() -{ - // Adjusting _start would cause undefined behavior on delete[] - TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); - // Trim leading space. - _start = XMLUtil::SkipWhiteSpace( _start ); - - if ( *_start ) { - char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( *p ) { - if ( XMLUtil::IsWhiteSpace( *p )) { - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p == 0 ) { - break; // don't write to q; this trims the trailing space. - } - *q = ' '; - ++q; - } - *q = *p; - ++q; - ++p; - } - *q = 0; - } -} - - -const char* StrPair::GetStr() -{ - TIXMLASSERT( _start ); - TIXMLASSERT( _end ); - if ( _flags & NEEDS_FLUSH ) { - *_end = 0; - _flags ^= NEEDS_FLUSH; - - if ( _flags ) { - char* p = _start; // the read pointer - char* q = _start; // the write pointer - - while( p < _end ) { - if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { - // CR-LF pair becomes LF - // CR alone becomes LF - // LF-CR becomes LF - if ( *(p+1) == LF ) { - p += 2; - } - else { - ++p; - } - *q++ = LF; - } - else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { - if ( *(p+1) == CR ) { - p += 2; - } - else { - ++p; - } - *q++ = LF; - } - else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { - // Entities handled by tinyXML2: - // - special entities in the entity table [in/out] - // - numeric character reference [in] - // 中 or 中 - - if ( *(p+1) == '#' ) { - const int buflen = 10; - char buf[buflen] = { 0 }; - int len = 0; - char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); - if ( adjusted == 0 ) { - *q = *p; - ++p; - ++q; - } - else { - TIXMLASSERT( 0 <= len && len <= buflen ); - TIXMLASSERT( q + len <= adjusted ); - p = adjusted; - memcpy( q, buf, len ); - q += len; - } - } - else { - bool entityFound = false; - for( int i = 0; i < NUM_ENTITIES; ++i ) { - const Entity& entity = entities[i]; - if ( strncmp( p + 1, entity.pattern, entity.length ) == 0 - && *( p + entity.length + 1 ) == ';' ) { - // Found an entity - convert. - *q = entity.value; - ++q; - p += entity.length + 2; - entityFound = true; - break; - } - } - if ( !entityFound ) { - // fixme: treat as error? - ++p; - ++q; - } - } - } - else { - *q = *p; - ++p; - ++q; - } - } - *q = 0; - } - // The loop below has plenty going on, and this - // is a less useful mode. Break it out. - if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) { - CollapseWhitespace(); - } - _flags = (_flags & NEEDS_DELETE); - } - TIXMLASSERT( _start ); - return _start; -} - - - - -// --------- XMLUtil ----------- // - -const char* XMLUtil::ReadBOM( const char* p, bool* bom ) -{ - TIXMLASSERT( p ); - TIXMLASSERT( bom ); - *bom = false; - const unsigned char* pu = reinterpret_cast(p); - // Check for BOM: - if ( *(pu+0) == TIXML_UTF_LEAD_0 - && *(pu+1) == TIXML_UTF_LEAD_1 - && *(pu+2) == TIXML_UTF_LEAD_2 ) { - *bom = true; - p += 3; - } - TIXMLASSERT( p ); - return p; -} - - -void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) { - *length = 1; - } - else if ( input < 0x800 ) { - *length = 2; - } - else if ( input < 0x10000 ) { - *length = 3; - } - else if ( input < 0x200000 ) { - *length = 4; - } - else { - *length = 0; // This code won't convert this correctly anyway. - return; - } - - output += *length; - - // Scary scary fall throughs. - switch (*length) { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - /* fallthrough */ - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - /* fallthrough */ - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - /* fallthrough */ - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - break; - default: - TIXMLASSERT( false ); - } -} - - -const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) -{ - // Presume an entity, and pull it out. - *length = 0; - - if ( *(p+1) == '#' && *(p+2) ) { - unsigned long ucs = 0; - TIXMLASSERT( sizeof( ucs ) >= 4 ); - ptrdiff_t delta = 0; - unsigned mult = 1; - static const char SEMICOLON = ';'; - - if ( *(p+2) == 'x' ) { - // Hexadecimal. - const char* q = p+3; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != 'x' ) { - unsigned int digit = 0; - - if ( *q >= '0' && *q <= '9' ) { - digit = *q - '0'; - } - else if ( *q >= 'a' && *q <= 'f' ) { - digit = *q - 'a' + 10; - } - else if ( *q >= 'A' && *q <= 'F' ) { - digit = *q - 'A' + 10; - } - else { - return 0; - } - TIXMLASSERT( digit < 16 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - TIXMLASSERT( mult <= UINT_MAX / 16 ); - mult *= 16; - --q; - } - } - else { - // Decimal. - const char* q = p+2; - if ( !(*q) ) { - return 0; - } - - q = strchr( q, SEMICOLON ); - - if ( !q ) { - return 0; - } - TIXMLASSERT( *q == SEMICOLON ); - - delta = q-p; - --q; - - while ( *q != '#' ) { - if ( *q >= '0' && *q <= '9' ) { - const unsigned int digit = *q - '0'; - TIXMLASSERT( digit < 10 ); - TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); - const unsigned int digitScaled = mult * digit; - TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); - ucs += digitScaled; - } - else { - return 0; - } - TIXMLASSERT( mult <= UINT_MAX / 10 ); - mult *= 10; - --q; - } - } - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - return p + delta + 1; - } - return p+1; -} - - -void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); -} - - -void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); -} - - -void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); -} - -/* - ToStr() of a number is a very tricky topic. - https://github.com/leethomason/tinyxml2/issues/106 -*/ -void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); -} - - -void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) -{ - TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); -} - - -void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize) -{ - // horrible syntax trick to make the compiler happy about %lld - TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v); -} - - -bool XMLUtil::ToInt( const char* str, int* value ) -{ - if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) -{ - if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { - return true; - } - return false; -} - -bool XMLUtil::ToBool( const char* str, bool* value ) -{ - int ival = 0; - if ( ToInt( str, &ival )) { - *value = (ival==0) ? false : true; - return true; - } - if ( StringEqual( str, "true" ) ) { - *value = true; - return true; - } - else if ( StringEqual( str, "false" ) ) { - *value = false; - return true; - } - return false; -} - - -bool XMLUtil::ToFloat( const char* str, float* value ) -{ - if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToDouble( const char* str, double* value ) -{ - if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { - return true; - } - return false; -} - - -bool XMLUtil::ToInt64(const char* str, int64_t* value) -{ - long long v = 0; // horrible syntax trick to make the compiler happy about %lld - if (TIXML_SSCANF(str, "%lld", &v) == 1) { - *value = (int64_t)v; - return true; - } - return false; -} - - -char* XMLDocument::Identify( char* p, XMLNode** node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( p ); - char* const start = p; - p = XMLUtil::SkipWhiteSpace( p ); - if( !*p ) { - *node = 0; - TIXMLASSERT( p ); - return p; - } - - // These strings define the matching patterns: - static const char* xmlHeader = { "_memPool = &_commentPool; - p += xmlHeaderLen; - } - else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); - returnNode = new (_commentPool.Alloc()) XMLComment( this ); - returnNode->_memPool = &_commentPool; - p += commentHeaderLen; - } - else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - XMLText* text = new (_textPool.Alloc()) XMLText( this ); - returnNode = text; - returnNode->_memPool = &_textPool; - p += cdataHeaderLen; - text->SetCData( true ); - } - else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); - returnNode = new (_commentPool.Alloc()) XMLUnknown( this ); - returnNode->_memPool = &_commentPool; - p += dtdHeaderLen; - } - else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) { - TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); - returnNode = new (_elementPool.Alloc()) XMLElement( this ); - returnNode->_memPool = &_elementPool; - p += elementHeaderLen; - } - else { - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - returnNode = new (_textPool.Alloc()) XMLText( this ); - returnNode->_memPool = &_textPool; - p = start; // Back it up, all the text counts. - } - - TIXMLASSERT( returnNode ); - TIXMLASSERT( p ); - *node = returnNode; - return p; -} - - -bool XMLDocument::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLNode ----------- // - -XMLNode::XMLNode( XMLDocument* doc ) : - _document( doc ), - _parent( 0 ), - _firstChild( 0 ), _lastChild( 0 ), - _prev( 0 ), _next( 0 ), - _userData( 0 ), - _memPool( 0 ) -{ -} - - -XMLNode::~XMLNode() -{ - DeleteChildren(); - if ( _parent ) { - _parent->Unlink( this ); - } -} - -const char* XMLNode::Value() const -{ - // Catch an edge case: XMLDocuments don't have a a Value. Carefully return nullptr. - if ( this->ToDocument() ) - return 0; - return _value.GetStr(); -} - -void XMLNode::SetValue( const char* str, bool staticMem ) -{ - if ( staticMem ) { - _value.SetInternedStr( str ); - } - else { - _value.SetStr( str ); - } -} - - -void XMLNode::DeleteChildren() -{ - while( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_document == _document ); - XMLNode* node = _firstChild; - Unlink( node ); - - DeleteNode( node ); - } - _firstChild = _lastChild = 0; -} - - -void XMLNode::Unlink( XMLNode* child ) -{ - TIXMLASSERT( child ); - TIXMLASSERT( child->_document == _document ); - TIXMLASSERT( child->_parent == this ); - if ( child == _firstChild ) { - _firstChild = _firstChild->_next; - } - if ( child == _lastChild ) { - _lastChild = _lastChild->_prev; - } - - if ( child->_prev ) { - child->_prev->_next = child->_next; - } - if ( child->_next ) { - child->_next->_prev = child->_prev; - } - child->_parent = 0; -} - - -void XMLNode::DeleteChild( XMLNode* node ) -{ - TIXMLASSERT( node ); - TIXMLASSERT( node->_document == _document ); - TIXMLASSERT( node->_parent == this ); - Unlink( node ); - DeleteNode( node ); -} - - -XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _lastChild ) { - TIXMLASSERT( _firstChild ); - TIXMLASSERT( _lastChild->_next == 0 ); - _lastChild->_next = addThis; - addThis->_prev = _lastChild; - _lastChild = addThis; - - addThis->_next = 0; - } - else { - TIXMLASSERT( _firstChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - InsertChildPreamble( addThis ); - - if ( _firstChild ) { - TIXMLASSERT( _lastChild ); - TIXMLASSERT( _firstChild->_prev == 0 ); - - _firstChild->_prev = addThis; - addThis->_next = _firstChild; - _firstChild = addThis; - - addThis->_prev = 0; - } - else { - TIXMLASSERT( _lastChild == 0 ); - _firstChild = _lastChild = addThis; - - addThis->_prev = 0; - addThis->_next = 0; - } - addThis->_parent = this; - return addThis; -} - - -XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) -{ - TIXMLASSERT( addThis ); - if ( addThis->_document != _document ) { - TIXMLASSERT( false ); - return 0; - } - - TIXMLASSERT( afterThis ); - - if ( afterThis->_parent != this ) { - TIXMLASSERT( false ); - return 0; - } - - if ( afterThis->_next == 0 ) { - // The last node or the only node. - return InsertEndChild( addThis ); - } - InsertChildPreamble( addThis ); - addThis->_prev = afterThis; - addThis->_next = afterThis->_next; - afterThis->_next->_prev = addThis; - afterThis->_next = addThis; - addThis->_parent = this; - return addThis; -} - - - - -const XMLElement* XMLNode::FirstChildElement( const char* name ) const -{ - for( const XMLNode* node = _firstChild; node; node = node->_next ) { - const XMLElement* element = node->ToElement(); - if ( element ) { - if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { - return element; - } - } - } - return 0; -} - - -const XMLElement* XMLNode::LastChildElement( const char* name ) const -{ - for( const XMLNode* node = _lastChild; node; node = node->_prev ) { - const XMLElement* element = node->ToElement(); - if ( element ) { - if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { - return element; - } - } - } - return 0; -} - - -const XMLElement* XMLNode::NextSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _next; node; node = node->_next ) { - const XMLElement* element = node->ToElement(); - if ( element - && (!name || XMLUtil::StringEqual( name, element->Name() ))) { - return element; - } - } - return 0; -} - - -const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const -{ - for( const XMLNode* node = _prev; node; node = node->_prev ) { - const XMLElement* element = node->ToElement(); - if ( element - && (!name || XMLUtil::StringEqual( name, element->Name() ))) { - return element; - } - } - return 0; -} - - -char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) -{ - // This is a recursive method, but thinking about it "at the current level" - // it is a pretty simple flat list: - // - // - // - // With a special case: - // - // - // - // - // Where the closing element (/foo) *must* be the next thing after the opening - // element, and the names must match. BUT the tricky bit is that the closing - // element will be read by the child. - // - // 'endTag' is the end tag for this node, it is returned by a call to a child. - // 'parentEnd' is the end tag for the parent, which is filled in and returned. - - while( p && *p ) { - XMLNode* node = 0; - - p = _document->Identify( p, &node ); - if ( node == 0 ) { - break; - } - - StrPair endTag; - p = node->ParseDeep( p, &endTag ); - if ( !p ) { - DeleteNode( node ); - if ( !_document->Error() ) { - _document->SetError( XML_ERROR_PARSING, 0, 0 ); - } - break; - } - - XMLDeclaration* decl = node->ToDeclaration(); - if ( decl ) { - // A declaration can only be the first child of a document. - // Set error, if document already has children. - if ( !_document->NoChildren() ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0); - DeleteNode( decl ); - break; - } - } - - XMLElement* ele = node->ToElement(); - if ( ele ) { - // We read the end tag. Return it to the parent. - if ( ele->ClosingType() == XMLElement::CLOSING ) { - if ( parentEnd ) { - ele->_value.TransferTo( parentEnd ); - } - node->_memPool->SetTracked(); // created and then immediately deleted. - DeleteNode( node ); - return p; - } - - // Handle an end tag returned to this level. - // And handle a bunch of annoying errors. - bool mismatch = false; - if ( endTag.Empty() ) { - if ( ele->ClosingType() == XMLElement::OPEN ) { - mismatch = true; - } - } - else { - if ( ele->ClosingType() != XMLElement::OPEN ) { - mismatch = true; - } - else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) { - mismatch = true; - } - } - if ( mismatch ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0 ); - DeleteNode( node ); - break; - } - } - InsertEndChild( node ); - } - return 0; -} - -void XMLNode::DeleteNode( XMLNode* node ) -{ - if ( node == 0 ) { - return; - } - MemPool* pool = node->_memPool; - node->~XMLNode(); - pool->Free( node ); -} - -void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const -{ - TIXMLASSERT( insertThis ); - TIXMLASSERT( insertThis->_document == _document ); - - if ( insertThis->_parent ) - insertThis->_parent->Unlink( insertThis ); - else - insertThis->_memPool->SetTracked(); -} - -// --------- XMLText ---------- // -char* XMLText::ParseDeep( char* p, StrPair* ) -{ - const char* start = p; - if ( this->CData() ) { - p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 ); - } - return p; - } - else { - int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; - if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { - flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING; - } - - p = _value.ParseText( p, "<", flags ); - if ( p && *p ) { - return p-1; - } - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 ); - } - } - return 0; -} - - -XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? - text->SetCData( this->CData() ); - return text; -} - - -bool XMLText::ShallowEqual( const XMLNode* compare ) const -{ - const XMLText* text = compare->ToText(); - return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); -} - - -bool XMLText::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLComment ---------- // - -XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLComment::~XMLComment() -{ -} - - -char* XMLComment::ParseDeep( char* p, StrPair* ) -{ - // Comment parses as text. - const char* start = p; - p = _value.ParseText( p, "-->", StrPair::COMMENT ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 ); - } - return p; -} - - -XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? - return comment; -} - - -bool XMLComment::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLComment* comment = compare->ToComment(); - return ( comment && XMLUtil::StringEqual( comment->Value(), Value() )); -} - - -bool XMLComment::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - - -// --------- XMLDeclaration ---------- // - -XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLDeclaration::~XMLDeclaration() -{ - //printf( "~XMLDeclaration\n" ); -} - - -char* XMLDeclaration::ParseDeep( char* p, StrPair* ) -{ - // Declaration parses as text. - const char* start = p; - p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 ); - } - return p; -} - - -XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? - return dec; -} - - -bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLDeclaration* declaration = compare->ToDeclaration(); - return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() )); -} - - - -bool XMLDeclaration::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLUnknown ---------- // - -XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) -{ -} - - -XMLUnknown::~XMLUnknown() -{ -} - - -char* XMLUnknown::ParseDeep( char* p, StrPair* ) -{ - // Unknown parses as text. - const char* start = p; - - p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION ); - if ( !p ) { - _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 ); - } - return p; -} - - -XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? - return text; -} - - -bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLUnknown* unknown = compare->ToUnknown(); - return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); -} - - -bool XMLUnknown::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - return visitor->Visit( *this ); -} - -// --------- XMLAttribute ---------- // - -const char* XMLAttribute::Name() const -{ - return _name.GetStr(); -} - -const char* XMLAttribute::Value() const -{ - return _value.GetStr(); -} - -char* XMLAttribute::ParseDeep( char* p, bool processEntities ) -{ - // Parse using the name rules: bug fix, was using ParseText before - p = _name.ParseName( p ); - if ( !p || !*p ) { - return 0; - } - - // Skip white space before = - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p != '=' ) { - return 0; - } - - ++p; // move up to opening quote - p = XMLUtil::SkipWhiteSpace( p ); - if ( *p != '\"' && *p != '\'' ) { - return 0; - } - - char endTag[2] = { *p, 0 }; - ++p; // move past opening quote - - p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); - return p; -} - - -void XMLAttribute::SetName( const char* n ) -{ - _name.SetStr( n ); -} - - -XMLError XMLAttribute::QueryIntValue( int* value ) const -{ - if ( XMLUtil::ToInt( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const -{ - if ( XMLUtil::ToUnsigned( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryInt64Value(int64_t* value) const -{ - if (XMLUtil::ToInt64(Value(), value)) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryBoolValue( bool* value ) const -{ - if ( XMLUtil::ToBool( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryFloatValue( float* value ) const -{ - if ( XMLUtil::ToFloat( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -XMLError XMLAttribute::QueryDoubleValue( double* value ) const -{ - if ( XMLUtil::ToDouble( Value(), value )) { - return XML_SUCCESS; - } - return XML_WRONG_ATTRIBUTE_TYPE; -} - - -void XMLAttribute::SetAttribute( const char* v ) -{ - _value.SetStr( v ); -} - - -void XMLAttribute::SetAttribute( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -void XMLAttribute::SetAttribute(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - _value.SetStr(buf); -} - - - -void XMLAttribute::SetAttribute( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - -void XMLAttribute::SetAttribute( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - _value.SetStr( buf ); -} - - -// --------- XMLElement ---------- // -XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), - _closingType( 0 ), - _rootAttribute( 0 ) -{ -} - - -XMLElement::~XMLElement() -{ - while( _rootAttribute ) { - XMLAttribute* next = _rootAttribute->_next; - DeleteAttribute( _rootAttribute ); - _rootAttribute = next; - } -} - - -const XMLAttribute* XMLElement::FindAttribute( const char* name ) const -{ - for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { - if ( XMLUtil::StringEqual( a->Name(), name ) ) { - return a; - } - } - return 0; -} - - -const char* XMLElement::Attribute( const char* name, const char* value ) const -{ - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return 0; - } - if ( !value || XMLUtil::StringEqual( a->Value(), value )) { - return a->Value(); - } - return 0; -} - - -const char* XMLElement::GetText() const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - return FirstChild()->Value(); - } - return 0; -} - - -void XMLElement::SetText( const char* inText ) -{ - if ( FirstChild() && FirstChild()->ToText() ) - FirstChild()->SetValue( inText ); - else { - XMLText* theText = GetDocument()->NewText( inText ); - InsertFirstChild( theText ); - } -} - - -void XMLElement::SetText( int v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( unsigned v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText(int64_t v) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr(v, buf, BUF_SIZE); - SetText(buf); -} - - -void XMLElement::SetText( bool v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( float v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -void XMLElement::SetText( double v ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( v, buf, BUF_SIZE ); - SetText( buf ); -} - - -XMLError XMLElement::QueryIntText( int* ival ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToInt( t, ival ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToUnsigned( t, uval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryInt64Text(int64_t* ival) const -{ - if (FirstChild() && FirstChild()->ToText()) { - const char* t = FirstChild()->Value(); - if (XMLUtil::ToInt64(t, ival)) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryBoolText( bool* bval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToBool( t, bval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryDoubleText( double* dval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToDouble( t, dval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - -XMLError XMLElement::QueryFloatText( float* fval ) const -{ - if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->Value(); - if ( XMLUtil::ToFloat( t, fval ) ) { - return XML_SUCCESS; - } - return XML_CAN_NOT_CONVERT_TEXT; - } - return XML_NO_TEXT_NODE; -} - - - -XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) -{ - XMLAttribute* last = 0; - XMLAttribute* attrib = 0; - for( attrib = _rootAttribute; - attrib; - last = attrib, attrib = attrib->_next ) { - if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { - break; - } - } - if ( !attrib ) { - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); - attrib->_memPool = &_document->_attributePool; - if ( last ) { - last->_next = attrib; - } - else { - _rootAttribute = attrib; - } - attrib->SetName( name ); - attrib->_memPool->SetTracked(); // always created and linked. - } - return attrib; -} - - -void XMLElement::DeleteAttribute( const char* name ) -{ - XMLAttribute* prev = 0; - for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { - if ( XMLUtil::StringEqual( name, a->Name() ) ) { - if ( prev ) { - prev->_next = a->_next; - } - else { - _rootAttribute = a->_next; - } - DeleteAttribute( a ); - break; - } - prev = a; - } -} - - -char* XMLElement::ParseAttributes( char* p ) -{ - const char* start = p; - XMLAttribute* prevAttribute = 0; - - // Read the attributes. - while( p ) { - p = XMLUtil::SkipWhiteSpace( p ); - if ( !(*p) ) { - _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); - return 0; - } - - // attribute. - if (XMLUtil::IsNameStartChar( *p ) ) { - TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); - XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); - attrib->_memPool = &_document->_attributePool; - attrib->_memPool->SetTracked(); - - p = attrib->ParseDeep( p, _document->ProcessEntities() ); - if ( !p || Attribute( attrib->Name() ) ) { - DeleteAttribute( attrib ); - _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); - return 0; - } - // There is a minor bug here: if the attribute in the source xml - // document is duplicated, it will not be detected and the - // attribute will be doubly added. However, tracking the 'prevAttribute' - // avoids re-scanning the attribute list. Preferring performance for - // now, may reconsider in the future. - if ( prevAttribute ) { - prevAttribute->_next = attrib; - } - else { - _rootAttribute = attrib; - } - prevAttribute = attrib; - } - // end of the tag - else if ( *p == '>' ) { - ++p; - break; - } - // end of the tag - else if ( *p == '/' && *(p+1) == '>' ) { - _closingType = CLOSED; - return p+2; // done; sealed element. - } - else { - _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); - return 0; - } - } - return p; -} - -void XMLElement::DeleteAttribute( XMLAttribute* attribute ) -{ - if ( attribute == 0 ) { - return; - } - MemPool* pool = attribute->_memPool; - attribute->~XMLAttribute(); - pool->Free( attribute ); -} - -// -// -// foobar -// -char* XMLElement::ParseDeep( char* p, StrPair* strPair ) -{ - // Read the element name. - p = XMLUtil::SkipWhiteSpace( p ); - - // The closing element is the form. It is - // parsed just like a regular element then deleted from - // the DOM. - if ( *p == '/' ) { - _closingType = CLOSING; - ++p; - } - - p = _value.ParseName( p ); - if ( _value.Empty() ) { - return 0; - } - - p = ParseAttributes( p ); - if ( !p || !*p || _closingType ) { - return p; - } - - p = XMLNode::ParseDeep( p, strPair ); - return p; -} - - - -XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const -{ - if ( !doc ) { - doc = _document; - } - XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? - for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { - element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? - } - return element; -} - - -bool XMLElement::ShallowEqual( const XMLNode* compare ) const -{ - TIXMLASSERT( compare ); - const XMLElement* other = compare->ToElement(); - if ( other && XMLUtil::StringEqual( other->Name(), Name() )) { - - const XMLAttribute* a=FirstAttribute(); - const XMLAttribute* b=other->FirstAttribute(); - - while ( a && b ) { - if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { - return false; - } - a = a->Next(); - b = b->Next(); - } - if ( a || b ) { - // different count - return false; - } - return true; - } - return false; -} - - -bool XMLElement::Accept( XMLVisitor* visitor ) const -{ - TIXMLASSERT( visitor ); - if ( visitor->VisitEnter( *this, _rootAttribute ) ) { - for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { - if ( !node->Accept( visitor ) ) { - break; - } - } - } - return visitor->VisitExit( *this ); -} - - -// --------- XMLDocument ----------- // - -// Warning: List must match 'enum XMLError' -const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { - "XML_SUCCESS", - "XML_NO_ATTRIBUTE", - "XML_WRONG_ATTRIBUTE_TYPE", - "XML_ERROR_FILE_NOT_FOUND", - "XML_ERROR_FILE_COULD_NOT_BE_OPENED", - "XML_ERROR_FILE_READ_ERROR", - "XML_ERROR_ELEMENT_MISMATCH", - "XML_ERROR_PARSING_ELEMENT", - "XML_ERROR_PARSING_ATTRIBUTE", - "XML_ERROR_IDENTIFYING_TAG", - "XML_ERROR_PARSING_TEXT", - "XML_ERROR_PARSING_CDATA", - "XML_ERROR_PARSING_COMMENT", - "XML_ERROR_PARSING_DECLARATION", - "XML_ERROR_PARSING_UNKNOWN", - "XML_ERROR_EMPTY_DOCUMENT", - "XML_ERROR_MISMATCHED_ELEMENT", - "XML_ERROR_PARSING", - "XML_CAN_NOT_CONVERT_TEXT", - "XML_NO_TEXT_NODE" -}; - - -XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) : - XMLNode( 0 ), - _writeBOM( false ), - _processEntities( processEntities ), - _errorID(XML_SUCCESS), - _whitespace( whitespace ), - _errorStr1( 0 ), - _errorStr2( 0 ), - _charBuffer( 0 ) -{ - // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+) - _document = this; -} - - -XMLDocument::~XMLDocument() -{ - Clear(); -} - - -void XMLDocument::Clear() -{ - DeleteChildren(); - -#ifdef DEBUG - const bool hadError = Error(); -#endif - _errorID = XML_SUCCESS; - _errorStr1 = 0; - _errorStr2 = 0; - - delete [] _charBuffer; - _charBuffer = 0; - -#if 0 - _textPool.Trace( "text" ); - _elementPool.Trace( "element" ); - _commentPool.Trace( "comment" ); - _attributePool.Trace( "attribute" ); -#endif - -#ifdef DEBUG - if ( !hadError ) { - TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); - TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); - TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); - TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); - } -#endif -} - - -XMLElement* XMLDocument::NewElement( const char* name ) -{ - TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); - XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this ); - ele->_memPool = &_elementPool; - ele->SetName( name ); - return ele; -} - - -XMLComment* XMLDocument::NewComment( const char* str ) -{ - TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); - XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this ); - comment->_memPool = &_commentPool; - comment->SetValue( str ); - return comment; -} - - -XMLText* XMLDocument::NewText( const char* str ) -{ - TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); - XMLText* text = new (_textPool.Alloc()) XMLText( this ); - text->_memPool = &_textPool; - text->SetValue( str ); - return text; -} - - -XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) -{ - TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() ); - XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this ); - dec->_memPool = &_commentPool; - dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); - return dec; -} - - -XMLUnknown* XMLDocument::NewUnknown( const char* str ) -{ - TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); - XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); - unk->_memPool = &_commentPool; - unk->SetValue( str ); - return unk; -} - -static FILE* callfopen( const char* filepath, const char* mode ) -{ - TIXMLASSERT( filepath ); - TIXMLASSERT( mode ); -#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filepath, mode ); - if ( err ) { - return 0; - } -#else - FILE* fp = fopen( filepath, mode ); -#endif - return fp; -} - -void XMLDocument::DeleteNode( XMLNode* node ) { - TIXMLASSERT( node ); - TIXMLASSERT(node->_document == this ); - if (node->_parent) { - node->_parent->DeleteChild( node ); - } - else { - // Isn't in the tree. - // Use the parent delete. - // Also, we need to mark it tracked: we 'know' - // it was never used. - node->_memPool->SetTracked(); - // Call the static XMLNode version: - XMLNode::DeleteNode(node); - } -} - - -XMLError XMLDocument::LoadFile( const char* filename ) -{ - Clear(); - FILE* fp = callfopen( filename, "rb" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); - return _errorID; - } - LoadFile( fp ); - fclose( fp ); - return _errorID; -} - -// This is likely overengineered template art to have a check that unsigned long value incremented -// by one still fits into size_t. If size_t type is larger than unsigned long type -// (x86_64-w64-mingw32 target) then the check is redundant and gcc and clang emit -// -Wtype-limits warning. This piece makes the compiler select code with a check when a check -// is useful and code with no check when a check is redundant depending on how size_t and unsigned long -// types sizes relate to each other. -template -= sizeof(size_t))> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long value ) - { - return value < (size_t)-1; - } -}; - -template <> -struct LongFitsIntoSizeTMinusOne { - static bool Fits( unsigned long ) - { - return true; - } -}; - -XMLError XMLDocument::LoadFile( FILE* fp ) -{ - Clear(); - - fseek( fp, 0, SEEK_SET ); - if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - fseek( fp, 0, SEEK_END ); - const long filelength = ftell( fp ); - fseek( fp, 0, SEEK_SET ); - if ( filelength == -1L ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - TIXMLASSERT( filelength >= 0 ); - - if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { - // Cannot handle files which won't fit in buffer together with null terminator - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - if ( filelength == 0 ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - - const size_t size = filelength; - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[size+1]; - size_t read = fread( _charBuffer, 1, size, fp ); - if ( read != size ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); - return _errorID; - } - - _charBuffer[size] = 0; - - Parse(); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( const char* filename, bool compact ) -{ - FILE* fp = callfopen( filename, "w" ); - if ( !fp ) { - SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); - return _errorID; - } - SaveFile(fp, compact); - fclose( fp ); - return _errorID; -} - - -XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) -{ - // Clear any error from the last save, otherwise it will get reported - // for *this* call. - SetError(XML_SUCCESS, 0, 0); - XMLPrinter stream( fp, compact ); - Print( &stream ); - return _errorID; -} - - -XMLError XMLDocument::Parse( const char* p, size_t len ) -{ - Clear(); - - if ( len == 0 || !p || !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return _errorID; - } - if ( len == (size_t)(-1) ) { - len = strlen( p ); - } - TIXMLASSERT( _charBuffer == 0 ); - _charBuffer = new char[ len+1 ]; - memcpy( _charBuffer, p, len ); - _charBuffer[len] = 0; - - Parse(); - if ( Error() ) { - // clean up now essentially dangling memory. - // and the parse fail can put objects in the - // pools that are dead and inaccessible. - DeleteChildren(); - _elementPool.Clear(); - _attributePool.Clear(); - _textPool.Clear(); - _commentPool.Clear(); - } - return _errorID; -} - - -void XMLDocument::Print( XMLPrinter* streamer ) const -{ - if ( streamer ) { - Accept( streamer ); - } - else { - XMLPrinter stdoutStreamer( stdout ); - Accept( &stdoutStreamer ); - } -} - - -void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) -{ - TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); - _errorID = error; - _errorStr1 = str1; - _errorStr2 = str2; -} - -const char* XMLDocument::ErrorName() const -{ - TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT ); - const char* errorName = _errorNames[_errorID]; - TIXMLASSERT( errorName && errorName[0] ); - return errorName; -} - -void XMLDocument::PrintError() const -{ - if ( Error() ) { - static const int LEN = 20; - char buf1[LEN] = { 0 }; - char buf2[LEN] = { 0 }; - - if ( _errorStr1 ) { - TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 ); - } - if ( _errorStr2 ) { - TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 ); - } - - // Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that - // causes a clang "always true" -Wtautological-constant-out-of-range-compare warning - TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX ); - printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n", - static_cast( _errorID ), ErrorName(), buf1, buf2 ); - } -} - -void XMLDocument::Parse() -{ - TIXMLASSERT( NoChildren() ); // Clear() must have been called previously - TIXMLASSERT( _charBuffer ); - char* p = _charBuffer; - p = XMLUtil::SkipWhiteSpace( p ); - p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); - if ( !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); - return; - } - ParseDeep(p, 0 ); -} - -XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : - _elementJustOpened( false ), - _firstElement( true ), - _fp( file ), - _depth( depth ), - _textDepth( -1 ), - _processEntities( true ), - _compactMode( compact ) -{ - for( int i=0; i'] = true; // not required, but consistency is nice - _buffer.Push( 0 ); -} - - -void XMLPrinter::Print( const char* format, ... ) -{ - va_list va; - va_start( va, format ); - - if ( _fp ) { - vfprintf( _fp, format, va ); - } - else { - const int len = TIXML_VSCPRINTF( format, va ); - // Close out and re-start the va-args - va_end( va ); - TIXMLASSERT( len >= 0 ); - va_start( va, format ); - TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); - char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. - TIXML_VSNPRINTF( p, len+1, format, va ); - } - va_end( va ); -} - - -void XMLPrinter::PrintSpace( int depth ) -{ - for( int i=0; i 0 && *q < ENTITY_RANGE ) { - // Check for entities. If one is found, flush - // the stream up until the entity, write the - // entity, and keep looking. - if ( flag[(unsigned char)(*q)] ) { - while ( p < q ) { - const size_t delta = q - p; - // %.*s accepts type int as "precision" - const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta; - Print( "%.*s", toPrint, p ); - p += toPrint; - } - bool entityPatternPrinted = false; - for( int i=0; i" ); - } - else { - if ( _textDepth < 0 && !compactMode) { - Print( "\n" ); - PrintSpace( _depth ); - } - Print( "", name ); - } - - if ( _textDepth == _depth ) { - _textDepth = -1; - } - if ( _depth == 0 && !compactMode) { - Print( "\n" ); - } - _elementJustOpened = false; -} - - -void XMLPrinter::SealElementIfJustOpened() -{ - if ( !_elementJustOpened ) { - return; - } - _elementJustOpened = false; - Print( ">" ); -} - - -void XMLPrinter::PushText( const char* text, bool cdata ) -{ - _textDepth = _depth-1; - - SealElementIfJustOpened(); - if ( cdata ) { - Print( "", text ); - } - else { - PrintString( text, true ); - } -} - -void XMLPrinter::PushText( int value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( unsigned value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( bool value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( float value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushText( double value ) -{ - char buf[BUF_SIZE]; - XMLUtil::ToStr( value, buf, BUF_SIZE ); - PushText( buf, false ); -} - - -void XMLPrinter::PushComment( const char* comment ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); - } - _firstElement = false; - Print( "", comment ); -} - - -void XMLPrinter::PushDeclaration( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); - } - _firstElement = false; - Print( "", value ); -} - - -void XMLPrinter::PushUnknown( const char* value ) -{ - SealElementIfJustOpened(); - if ( _textDepth < 0 && !_firstElement && !_compactMode) { - Print( "\n" ); - PrintSpace( _depth ); - } - _firstElement = false; - Print( "", value ); -} - - -bool XMLPrinter::VisitEnter( const XMLDocument& doc ) -{ - _processEntities = doc.ProcessEntities(); - if ( doc.HasBOM() ) { - PushHeader( true, false ); - } - return true; -} - - -bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) -{ - const XMLElement* parentElem = 0; - if ( element.Parent() ) { - parentElem = element.Parent()->ToElement(); - } - const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode; - OpenElement( element.Name(), compactMode ); - while ( attribute ) { - PushAttribute( attribute->Name(), attribute->Value() ); - attribute = attribute->Next(); - } - return true; -} - - -bool XMLPrinter::VisitExit( const XMLElement& element ) -{ - CloseElement( CompactMode(element) ); - return true; -} - - -bool XMLPrinter::Visit( const XMLText& text ) -{ - PushText( text.Value(), text.CData() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLComment& comment ) -{ - PushComment( comment.Value() ); - return true; -} - -bool XMLPrinter::Visit( const XMLDeclaration& declaration ) -{ - PushDeclaration( declaration.Value() ); - return true; -} - - -bool XMLPrinter::Visit( const XMLUnknown& unknown ) -{ - PushUnknown( unknown.Value() ); - return true; -} - -} // namespace tinyxml2 - +/* +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "tinyxml2.h" + +#include // yes, this one new style header, is in the Android SDK. +#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) +# include +# include +#else +# include +# include +#endif + +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) + // Microsoft Visual Studio, version 2005 and higher. Not WinCE. + /*int _snprintf_s( + char *buffer, + size_t sizeOfBuffer, + size_t count, + const char *format [, + argument] ... + );*/ + static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) + { + va_list va; + va_start( va, format ); + int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); + va_end( va ); + return result; + } + + static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va ) + { + int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); + return result; + } + + #define TIXML_VSCPRINTF _vscprintf + #define TIXML_SSCANF sscanf_s +#elif defined _MSC_VER + // Microsoft Visual Studio 2003 and earlier or WinCE + #define TIXML_SNPRINTF _snprintf + #define TIXML_VSNPRINTF _vsnprintf + #define TIXML_SSCANF sscanf + #if (_MSC_VER < 1400 ) && (!defined WINCE) + // Microsoft Visual Studio 2003 and not WinCE. + #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have. + #else + // Microsoft Visual Studio 2003 and earlier or WinCE. + static inline int TIXML_VSCPRINTF( const char* format, va_list va ) + { + int len = 512; + for (;;) { + len = len*2; + char* str = new char[len](); + const int required = _vsnprintf(str, len, format, va); + delete[] str; + if ( required != -1 ) { + TIXMLASSERT( required >= 0 ); + len = required; + break; + } + } + TIXMLASSERT( len >= 0 ); + return len; + } + #endif +#else + // GCC version 3 and higher + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_VSNPRINTF vsnprintf + static inline int TIXML_VSCPRINTF( const char* format, va_list va ) + { + int len = vsnprintf( 0, 0, format, va ); + TIXMLASSERT( len >= 0 ); + return len; + } + #define TIXML_SSCANF sscanf +#endif + + +static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF +static const char LF = LINE_FEED; +static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out +static const char CR = CARRIAGE_RETURN; +static const char SINGLE_QUOTE = '\''; +static const char DOUBLE_QUOTE = '\"'; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// ef bb bf (Microsoft "lead bytes") - designates UTF-8 + +static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +namespace tinyxml2 +{ + +struct Entity { + const char* pattern; + int length; + char value; +}; + +static const int NUM_ENTITIES = 5; +static const Entity entities[NUM_ENTITIES] = { + { "quot", 4, DOUBLE_QUOTE }, + { "amp", 3, '&' }, + { "apos", 4, SINGLE_QUOTE }, + { "lt", 2, '<' }, + { "gt", 2, '>' } +}; + + +StrPair::~StrPair() +{ + Reset(); +} + + +void StrPair::TransferTo( StrPair* other ) +{ + if ( this == other ) { + return; + } + // This in effect implements the assignment operator by "moving" + // ownership (as in auto_ptr). + + TIXMLASSERT( other->_flags == 0 ); + TIXMLASSERT( other->_start == 0 ); + TIXMLASSERT( other->_end == 0 ); + + other->Reset(); + + other->_flags = _flags; + other->_start = _start; + other->_end = _end; + + _flags = 0; + _start = 0; + _end = 0; +} + +void StrPair::Reset() +{ + if ( _flags & NEEDS_DELETE ) { + delete [] _start; + } + _flags = 0; + _start = 0; + _end = 0; +} + + +void StrPair::SetStr( const char* str, int flags ) +{ + TIXMLASSERT( str ); + Reset(); + size_t len = strlen( str ); + TIXMLASSERT( _start == 0 ); + _start = new char[ len+1 ]; + memcpy( _start, str, len+1 ); + _end = _start + len; + _flags = flags | NEEDS_DELETE; +} + + +char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) +{ + TIXMLASSERT( endTag && *endTag ); + + char* start = p; + char endChar = *endTag; + size_t length = strlen( endTag ); + + // Inner loop of text parsing. + while ( *p ) { + if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { + Set( start, p, strFlags ); + return p + length; + } + ++p; + } + return 0; +} + + +char* StrPair::ParseName( char* p ) +{ + if ( !p || !(*p) ) { + return 0; + } + if ( !XMLUtil::IsNameStartChar( *p ) ) { + return 0; + } + + char* const start = p; + ++p; + while ( *p && XMLUtil::IsNameChar( *p ) ) { + ++p; + } + + Set( start, p, 0 ); + return p; +} + + +void StrPair::CollapseWhitespace() +{ + // Adjusting _start would cause undefined behavior on delete[] + TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); + // Trim leading space. + _start = XMLUtil::SkipWhiteSpace( _start ); + + if ( *_start ) { + char* p = _start; // the read pointer + char* q = _start; // the write pointer + + while( *p ) { + if ( XMLUtil::IsWhiteSpace( *p )) { + p = XMLUtil::SkipWhiteSpace( p ); + if ( *p == 0 ) { + break; // don't write to q; this trims the trailing space. + } + *q = ' '; + ++q; + } + *q = *p; + ++q; + ++p; + } + *q = 0; + } +} + + +const char* StrPair::GetStr() +{ + TIXMLASSERT( _start ); + TIXMLASSERT( _end ); + if ( _flags & NEEDS_FLUSH ) { + *_end = 0; + _flags ^= NEEDS_FLUSH; + + if ( _flags ) { + char* p = _start; // the read pointer + char* q = _start; // the write pointer + + while( p < _end ) { + if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { + // CR-LF pair becomes LF + // CR alone becomes LF + // LF-CR becomes LF + if ( *(p+1) == LF ) { + p += 2; + } + else { + ++p; + } + *q++ = LF; + } + else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { + if ( *(p+1) == CR ) { + p += 2; + } + else { + ++p; + } + *q++ = LF; + } + else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { + // Entities handled by tinyXML2: + // - special entities in the entity table [in/out] + // - numeric character reference [in] + // 中 or 中 + + if ( *(p+1) == '#' ) { + const int buflen = 10; + char buf[buflen] = { 0 }; + int len = 0; + char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); + if ( adjusted == 0 ) { + *q = *p; + ++p; + ++q; + } + else { + TIXMLASSERT( 0 <= len && len <= buflen ); + TIXMLASSERT( q + len <= adjusted ); + p = adjusted; + memcpy( q, buf, len ); + q += len; + } + } + else { + bool entityFound = false; + for( int i = 0; i < NUM_ENTITIES; ++i ) { + const Entity& entity = entities[i]; + if ( strncmp( p + 1, entity.pattern, entity.length ) == 0 + && *( p + entity.length + 1 ) == ';' ) { + // Found an entity - convert. + *q = entity.value; + ++q; + p += entity.length + 2; + entityFound = true; + break; + } + } + if ( !entityFound ) { + // fixme: treat as error? + ++p; + ++q; + } + } + } + else { + *q = *p; + ++p; + ++q; + } + } + *q = 0; + } + // The loop below has plenty going on, and this + // is a less useful mode. Break it out. + if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) { + CollapseWhitespace(); + } + _flags = (_flags & NEEDS_DELETE); + } + TIXMLASSERT( _start ); + return _start; +} + + + + +// --------- XMLUtil ----------- // + +const char* XMLUtil::ReadBOM( const char* p, bool* bom ) +{ + TIXMLASSERT( p ); + TIXMLASSERT( bom ); + *bom = false; + const unsigned char* pu = reinterpret_cast(p); + // Check for BOM: + if ( *(pu+0) == TIXML_UTF_LEAD_0 + && *(pu+1) == TIXML_UTF_LEAD_1 + && *(pu+2) == TIXML_UTF_LEAD_2 ) { + *bom = true; + p += 3; + } + TIXMLASSERT( p ); + return p; +} + + +void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) { + *length = 1; + } + else if ( input < 0x800 ) { + *length = 2; + } + else if ( input < 0x10000 ) { + *length = 3; + } + else if ( input < 0x200000 ) { + *length = 4; + } + else { + *length = 0; // This code won't convert this correctly anyway. + return; + } + + output += *length; + + // Scary scary fall throughs. + switch (*length) { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + /* fallthrough */ + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + /* fallthrough */ + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + /* fallthrough */ + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + break; + default: + TIXMLASSERT( false ); + } +} + + +const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) +{ + // Presume an entity, and pull it out. + *length = 0; + + if ( *(p+1) == '#' && *(p+2) ) { + unsigned long ucs = 0; + TIXMLASSERT( sizeof( ucs ) >= 4 ); + ptrdiff_t delta = 0; + unsigned mult = 1; + static const char SEMICOLON = ';'; + + if ( *(p+2) == 'x' ) { + // Hexadecimal. + const char* q = p+3; + if ( !(*q) ) { + return 0; + } + + q = strchr( q, SEMICOLON ); + + if ( !q ) { + return 0; + } + TIXMLASSERT( *q == SEMICOLON ); + + delta = q-p; + --q; + + while ( *q != 'x' ) { + unsigned int digit = 0; + + if ( *q >= '0' && *q <= '9' ) { + digit = *q - '0'; + } + else if ( *q >= 'a' && *q <= 'f' ) { + digit = *q - 'a' + 10; + } + else if ( *q >= 'A' && *q <= 'F' ) { + digit = *q - 'A' + 10; + } + else { + return 0; + } + TIXMLASSERT( digit < 16 ); + TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); + const unsigned int digitScaled = mult * digit; + TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); + ucs += digitScaled; + TIXMLASSERT( mult <= UINT_MAX / 16 ); + mult *= 16; + --q; + } + } + else { + // Decimal. + const char* q = p+2; + if ( !(*q) ) { + return 0; + } + + q = strchr( q, SEMICOLON ); + + if ( !q ) { + return 0; + } + TIXMLASSERT( *q == SEMICOLON ); + + delta = q-p; + --q; + + while ( *q != '#' ) { + if ( *q >= '0' && *q <= '9' ) { + const unsigned int digit = *q - '0'; + TIXMLASSERT( digit < 10 ); + TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); + const unsigned int digitScaled = mult * digit; + TIXMLASSERT( ucs <= ULONG_MAX - digitScaled ); + ucs += digitScaled; + } + else { + return 0; + } + TIXMLASSERT( mult <= UINT_MAX / 10 ); + mult *= 10; + --q; + } + } + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + return p + delta + 1; + } + return p+1; +} + + +void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); +} + + +void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); +} + + +void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); +} + +/* + ToStr() of a number is a very tricky topic. + https://github.com/leethomason/tinyxml2/issues/106 +*/ +void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); +} + + +void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); +} + + +void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize) +{ + // horrible syntax trick to make the compiler happy about %lld + TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v); +} + + +bool XMLUtil::ToInt( const char* str, int* value ) +{ + if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { + return true; + } + return false; +} + +bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) +{ + if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { + return true; + } + return false; +} + +bool XMLUtil::ToBool( const char* str, bool* value ) +{ + int ival = 0; + if ( ToInt( str, &ival )) { + *value = (ival==0) ? false : true; + return true; + } + if ( StringEqual( str, "true" ) ) { + *value = true; + return true; + } + else if ( StringEqual( str, "false" ) ) { + *value = false; + return true; + } + return false; +} + + +bool XMLUtil::ToFloat( const char* str, float* value ) +{ + if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { + return true; + } + return false; +} + + +bool XMLUtil::ToDouble( const char* str, double* value ) +{ + if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { + return true; + } + return false; +} + + +bool XMLUtil::ToInt64(const char* str, int64_t* value) +{ + long long v = 0; // horrible syntax trick to make the compiler happy about %lld + if (TIXML_SSCANF(str, "%lld", &v) == 1) { + *value = (int64_t)v; + return true; + } + return false; +} + + +char* XMLDocument::Identify( char* p, XMLNode** node ) +{ + TIXMLASSERT( node ); + TIXMLASSERT( p ); + char* const start = p; + p = XMLUtil::SkipWhiteSpace( p ); + if( !*p ) { + *node = 0; + TIXMLASSERT( p ); + return p; + } + + // These strings define the matching patterns: + static const char* xmlHeader = { "_memPool = &_commentPool; + p += xmlHeaderLen; + } + else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) { + TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); + returnNode = new (_commentPool.Alloc()) XMLComment( this ); + returnNode->_memPool = &_commentPool; + p += commentHeaderLen; + } + else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) { + TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); + XMLText* text = new (_textPool.Alloc()) XMLText( this ); + returnNode = text; + returnNode->_memPool = &_textPool; + p += cdataHeaderLen; + text->SetCData( true ); + } + else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) { + TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); + returnNode = new (_commentPool.Alloc()) XMLUnknown( this ); + returnNode->_memPool = &_commentPool; + p += dtdHeaderLen; + } + else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) { + TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); + returnNode = new (_elementPool.Alloc()) XMLElement( this ); + returnNode->_memPool = &_elementPool; + p += elementHeaderLen; + } + else { + TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); + returnNode = new (_textPool.Alloc()) XMLText( this ); + returnNode->_memPool = &_textPool; + p = start; // Back it up, all the text counts. + } + + TIXMLASSERT( returnNode ); + TIXMLASSERT( p ); + *node = returnNode; + return p; +} + + +bool XMLDocument::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + if ( visitor->VisitEnter( *this ) ) { + for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { + if ( !node->Accept( visitor ) ) { + break; + } + } + } + return visitor->VisitExit( *this ); +} + + +// --------- XMLNode ----------- // + +XMLNode::XMLNode( XMLDocument* doc ) : + _document( doc ), + _parent( 0 ), + _firstChild( 0 ), _lastChild( 0 ), + _prev( 0 ), _next( 0 ), + _userData( 0 ), + _memPool( 0 ) +{ +} + + +XMLNode::~XMLNode() +{ + DeleteChildren(); + if ( _parent ) { + _parent->Unlink( this ); + } +} + +const char* XMLNode::Value() const +{ + // Catch an edge case: XMLDocuments don't have a a Value. Carefully return nullptr. + if ( this->ToDocument() ) + return 0; + return _value.GetStr(); +} + +void XMLNode::SetValue( const char* str, bool staticMem ) +{ + if ( staticMem ) { + _value.SetInternedStr( str ); + } + else { + _value.SetStr( str ); + } +} + + +void XMLNode::DeleteChildren() +{ + while( _firstChild ) { + TIXMLASSERT( _lastChild ); + TIXMLASSERT( _firstChild->_document == _document ); + XMLNode* node = _firstChild; + Unlink( node ); + + DeleteNode( node ); + } + _firstChild = _lastChild = 0; +} + + +void XMLNode::Unlink( XMLNode* child ) +{ + TIXMLASSERT( child ); + TIXMLASSERT( child->_document == _document ); + TIXMLASSERT( child->_parent == this ); + if ( child == _firstChild ) { + _firstChild = _firstChild->_next; + } + if ( child == _lastChild ) { + _lastChild = _lastChild->_prev; + } + + if ( child->_prev ) { + child->_prev->_next = child->_next; + } + if ( child->_next ) { + child->_next->_prev = child->_prev; + } + child->_parent = 0; +} + + +void XMLNode::DeleteChild( XMLNode* node ) +{ + TIXMLASSERT( node ); + TIXMLASSERT( node->_document == _document ); + TIXMLASSERT( node->_parent == this ); + Unlink( node ); + DeleteNode( node ); +} + + +XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) +{ + TIXMLASSERT( addThis ); + if ( addThis->_document != _document ) { + TIXMLASSERT( false ); + return 0; + } + InsertChildPreamble( addThis ); + + if ( _lastChild ) { + TIXMLASSERT( _firstChild ); + TIXMLASSERT( _lastChild->_next == 0 ); + _lastChild->_next = addThis; + addThis->_prev = _lastChild; + _lastChild = addThis; + + addThis->_next = 0; + } + else { + TIXMLASSERT( _firstChild == 0 ); + _firstChild = _lastChild = addThis; + + addThis->_prev = 0; + addThis->_next = 0; + } + addThis->_parent = this; + return addThis; +} + + +XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) +{ + TIXMLASSERT( addThis ); + if ( addThis->_document != _document ) { + TIXMLASSERT( false ); + return 0; + } + InsertChildPreamble( addThis ); + + if ( _firstChild ) { + TIXMLASSERT( _lastChild ); + TIXMLASSERT( _firstChild->_prev == 0 ); + + _firstChild->_prev = addThis; + addThis->_next = _firstChild; + _firstChild = addThis; + + addThis->_prev = 0; + } + else { + TIXMLASSERT( _lastChild == 0 ); + _firstChild = _lastChild = addThis; + + addThis->_prev = 0; + addThis->_next = 0; + } + addThis->_parent = this; + return addThis; +} + + +XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) +{ + TIXMLASSERT( addThis ); + if ( addThis->_document != _document ) { + TIXMLASSERT( false ); + return 0; + } + + TIXMLASSERT( afterThis ); + + if ( afterThis->_parent != this ) { + TIXMLASSERT( false ); + return 0; + } + + if ( afterThis->_next == 0 ) { + // The last node or the only node. + return InsertEndChild( addThis ); + } + InsertChildPreamble( addThis ); + addThis->_prev = afterThis; + addThis->_next = afterThis->_next; + afterThis->_next->_prev = addThis; + afterThis->_next = addThis; + addThis->_parent = this; + return addThis; +} + + + + +const XMLElement* XMLNode::FirstChildElement( const char* name ) const +{ + for( const XMLNode* node = _firstChild; node; node = node->_next ) { + const XMLElement* element = node->ToElement(); + if ( element ) { + if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { + return element; + } + } + } + return 0; +} + + +const XMLElement* XMLNode::LastChildElement( const char* name ) const +{ + for( const XMLNode* node = _lastChild; node; node = node->_prev ) { + const XMLElement* element = node->ToElement(); + if ( element ) { + if ( !name || XMLUtil::StringEqual( element->Name(), name ) ) { + return element; + } + } + } + return 0; +} + + +const XMLElement* XMLNode::NextSiblingElement( const char* name ) const +{ + for( const XMLNode* node = _next; node; node = node->_next ) { + const XMLElement* element = node->ToElement(); + if ( element + && (!name || XMLUtil::StringEqual( name, element->Name() ))) { + return element; + } + } + return 0; +} + + +const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const +{ + for( const XMLNode* node = _prev; node; node = node->_prev ) { + const XMLElement* element = node->ToElement(); + if ( element + && (!name || XMLUtil::StringEqual( name, element->Name() ))) { + return element; + } + } + return 0; +} + + +char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) +{ + // This is a recursive method, but thinking about it "at the current level" + // it is a pretty simple flat list: + // + // + // + // With a special case: + // + // + // + // + // Where the closing element (/foo) *must* be the next thing after the opening + // element, and the names must match. BUT the tricky bit is that the closing + // element will be read by the child. + // + // 'endTag' is the end tag for this node, it is returned by a call to a child. + // 'parentEnd' is the end tag for the parent, which is filled in and returned. + + while( p && *p ) { + XMLNode* node = 0; + + p = _document->Identify( p, &node ); + if ( node == 0 ) { + break; + } + + StrPair endTag; + p = node->ParseDeep( p, &endTag ); + if ( !p ) { + DeleteNode( node ); + if ( !_document->Error() ) { + _document->SetError( XML_ERROR_PARSING, 0, 0 ); + } + break; + } + + XMLDeclaration* decl = node->ToDeclaration(); + if ( decl ) { + // A declaration can only be the first child of a document. + // Set error, if document already has children. + if ( !_document->NoChildren() ) { + _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0); + DeleteNode( decl ); + break; + } + } + + XMLElement* ele = node->ToElement(); + if ( ele ) { + // We read the end tag. Return it to the parent. + if ( ele->ClosingType() == XMLElement::CLOSING ) { + if ( parentEnd ) { + ele->_value.TransferTo( parentEnd ); + } + node->_memPool->SetTracked(); // created and then immediately deleted. + DeleteNode( node ); + return p; + } + + // Handle an end tag returned to this level. + // And handle a bunch of annoying errors. + bool mismatch = false; + if ( endTag.Empty() ) { + if ( ele->ClosingType() == XMLElement::OPEN ) { + mismatch = true; + } + } + else { + if ( ele->ClosingType() != XMLElement::OPEN ) { + mismatch = true; + } + else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) { + mismatch = true; + } + } + if ( mismatch ) { + _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0 ); + DeleteNode( node ); + break; + } + } + InsertEndChild( node ); + } + return 0; +} + +void XMLNode::DeleteNode( XMLNode* node ) +{ + if ( node == 0 ) { + return; + } + MemPool* pool = node->_memPool; + node->~XMLNode(); + pool->Free( node ); +} + +void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const +{ + TIXMLASSERT( insertThis ); + TIXMLASSERT( insertThis->_document == _document ); + + if ( insertThis->_parent ) + insertThis->_parent->Unlink( insertThis ); + else + insertThis->_memPool->SetTracked(); +} + +// --------- XMLText ---------- // +char* XMLText::ParseDeep( char* p, StrPair* ) +{ + const char* start = p; + if ( this->CData() ) { + p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 ); + } + return p; + } + else { + int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; + if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { + flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING; + } + + p = _value.ParseText( p, "<", flags ); + if ( p && *p ) { + return p-1; + } + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 ); + } + } + return 0; +} + + +XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? + text->SetCData( this->CData() ); + return text; +} + + +bool XMLText::ShallowEqual( const XMLNode* compare ) const +{ + const XMLText* text = compare->ToText(); + return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); +} + + +bool XMLText::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + return visitor->Visit( *this ); +} + + +// --------- XMLComment ---------- // + +XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLComment::~XMLComment() +{ +} + + +char* XMLComment::ParseDeep( char* p, StrPair* ) +{ + // Comment parses as text. + const char* start = p; + p = _value.ParseText( p, "-->", StrPair::COMMENT ); + if ( p == 0 ) { + _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 ); + } + return p; +} + + +XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? + return comment; +} + + +bool XMLComment::ShallowEqual( const XMLNode* compare ) const +{ + TIXMLASSERT( compare ); + const XMLComment* comment = compare->ToComment(); + return ( comment && XMLUtil::StringEqual( comment->Value(), Value() )); +} + + +bool XMLComment::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + return visitor->Visit( *this ); +} + + +// --------- XMLDeclaration ---------- // + +XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLDeclaration::~XMLDeclaration() +{ + //printf( "~XMLDeclaration\n" ); +} + + +char* XMLDeclaration::ParseDeep( char* p, StrPair* ) +{ + // Declaration parses as text. + const char* start = p; + p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( p == 0 ) { + _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 ); + } + return p; +} + + +XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? + return dec; +} + + +bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const +{ + TIXMLASSERT( compare ); + const XMLDeclaration* declaration = compare->ToDeclaration(); + return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() )); +} + + + +bool XMLDeclaration::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + return visitor->Visit( *this ); +} + +// --------- XMLUnknown ---------- // + +XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLUnknown::~XMLUnknown() +{ +} + + +char* XMLUnknown::ParseDeep( char* p, StrPair* ) +{ + // Unknown parses as text. + const char* start = p; + + p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 ); + } + return p; +} + + +XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? + return text; +} + + +bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const +{ + TIXMLASSERT( compare ); + const XMLUnknown* unknown = compare->ToUnknown(); + return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() )); +} + + +bool XMLUnknown::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + return visitor->Visit( *this ); +} + +// --------- XMLAttribute ---------- // + +const char* XMLAttribute::Name() const +{ + return _name.GetStr(); +} + +const char* XMLAttribute::Value() const +{ + return _value.GetStr(); +} + +char* XMLAttribute::ParseDeep( char* p, bool processEntities ) +{ + // Parse using the name rules: bug fix, was using ParseText before + p = _name.ParseName( p ); + if ( !p || !*p ) { + return 0; + } + + // Skip white space before = + p = XMLUtil::SkipWhiteSpace( p ); + if ( *p != '=' ) { + return 0; + } + + ++p; // move up to opening quote + p = XMLUtil::SkipWhiteSpace( p ); + if ( *p != '\"' && *p != '\'' ) { + return 0; + } + + char endTag[2] = { *p, 0 }; + ++p; // move past opening quote + + p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); + return p; +} + + +void XMLAttribute::SetName( const char* n ) +{ + _name.SetStr( n ); +} + + +XMLError XMLAttribute::QueryIntValue( int* value ) const +{ + if ( XMLUtil::ToInt( Value(), value )) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const +{ + if ( XMLUtil::ToUnsigned( Value(), value )) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryInt64Value(int64_t* value) const +{ + if (XMLUtil::ToInt64(Value(), value)) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryBoolValue( bool* value ) const +{ + if ( XMLUtil::ToBool( Value(), value )) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryFloatValue( float* value ) const +{ + if ( XMLUtil::ToFloat( Value(), value )) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryDoubleValue( double* value ) const +{ + if ( XMLUtil::ToDouble( Value(), value )) { + return XML_SUCCESS; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +void XMLAttribute::SetAttribute( const char* v ) +{ + _value.SetStr( v ); +} + + +void XMLAttribute::SetAttribute( int v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +void XMLAttribute::SetAttribute( unsigned v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +void XMLAttribute::SetAttribute(int64_t v) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr(v, buf, BUF_SIZE); + _value.SetStr(buf); +} + + + +void XMLAttribute::SetAttribute( bool v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + +void XMLAttribute::SetAttribute( double v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + +void XMLAttribute::SetAttribute( float v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +// --------- XMLElement ---------- // +XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), + _closingType( 0 ), + _rootAttribute( 0 ) +{ +} + + +XMLElement::~XMLElement() +{ + while( _rootAttribute ) { + XMLAttribute* next = _rootAttribute->_next; + DeleteAttribute( _rootAttribute ); + _rootAttribute = next; + } +} + + +const XMLAttribute* XMLElement::FindAttribute( const char* name ) const +{ + for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) { + if ( XMLUtil::StringEqual( a->Name(), name ) ) { + return a; + } + } + return 0; +} + + +const char* XMLElement::Attribute( const char* name, const char* value ) const +{ + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return 0; + } + if ( !value || XMLUtil::StringEqual( a->Value(), value )) { + return a->Value(); + } + return 0; +} + + +const char* XMLElement::GetText() const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + return FirstChild()->Value(); + } + return 0; +} + + +void XMLElement::SetText( const char* inText ) +{ + if ( FirstChild() && FirstChild()->ToText() ) + FirstChild()->SetValue( inText ); + else { + XMLText* theText = GetDocument()->NewText( inText ); + InsertFirstChild( theText ); + } +} + + +void XMLElement::SetText( int v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + SetText( buf ); +} + + +void XMLElement::SetText( unsigned v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + SetText( buf ); +} + + +void XMLElement::SetText(int64_t v) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr(v, buf, BUF_SIZE); + SetText(buf); +} + + +void XMLElement::SetText( bool v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + SetText( buf ); +} + + +void XMLElement::SetText( float v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + SetText( buf ); +} + + +void XMLElement::SetText( double v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + SetText( buf ); +} + + +XMLError XMLElement::QueryIntText( int* ival ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->Value(); + if ( XMLUtil::ToInt( t, ival ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->Value(); + if ( XMLUtil::ToUnsigned( t, uval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryInt64Text(int64_t* ival) const +{ + if (FirstChild() && FirstChild()->ToText()) { + const char* t = FirstChild()->Value(); + if (XMLUtil::ToInt64(t, ival)) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryBoolText( bool* bval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->Value(); + if ( XMLUtil::ToBool( t, bval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryDoubleText( double* dval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->Value(); + if ( XMLUtil::ToDouble( t, dval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryFloatText( float* fval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->Value(); + if ( XMLUtil::ToFloat( t, fval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + + +XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) +{ + XMLAttribute* last = 0; + XMLAttribute* attrib = 0; + for( attrib = _rootAttribute; + attrib; + last = attrib, attrib = attrib->_next ) { + if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { + break; + } + } + if ( !attrib ) { + TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); + attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + attrib->_memPool = &_document->_attributePool; + if ( last ) { + last->_next = attrib; + } + else { + _rootAttribute = attrib; + } + attrib->SetName( name ); + attrib->_memPool->SetTracked(); // always created and linked. + } + return attrib; +} + + +void XMLElement::DeleteAttribute( const char* name ) +{ + XMLAttribute* prev = 0; + for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { + if ( XMLUtil::StringEqual( name, a->Name() ) ) { + if ( prev ) { + prev->_next = a->_next; + } + else { + _rootAttribute = a->_next; + } + DeleteAttribute( a ); + break; + } + prev = a; + } +} + + +char* XMLElement::ParseAttributes( char* p ) +{ + const char* start = p; + XMLAttribute* prevAttribute = 0; + + // Read the attributes. + while( p ) { + p = XMLUtil::SkipWhiteSpace( p ); + if ( !(*p) ) { + _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); + return 0; + } + + // attribute. + if (XMLUtil::IsNameStartChar( *p ) ) { + TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() ); + XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + attrib->_memPool = &_document->_attributePool; + attrib->_memPool->SetTracked(); + + p = attrib->ParseDeep( p, _document->ProcessEntities() ); + if ( !p || Attribute( attrib->Name() ) ) { + DeleteAttribute( attrib ); + _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); + return 0; + } + // There is a minor bug here: if the attribute in the source xml + // document is duplicated, it will not be detected and the + // attribute will be doubly added. However, tracking the 'prevAttribute' + // avoids re-scanning the attribute list. Preferring performance for + // now, may reconsider in the future. + if ( prevAttribute ) { + prevAttribute->_next = attrib; + } + else { + _rootAttribute = attrib; + } + prevAttribute = attrib; + } + // end of the tag + else if ( *p == '>' ) { + ++p; + break; + } + // end of the tag + else if ( *p == '/' && *(p+1) == '>' ) { + _closingType = CLOSED; + return p+2; // done; sealed element. + } + else { + _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); + return 0; + } + } + return p; +} + +void XMLElement::DeleteAttribute( XMLAttribute* attribute ) +{ + if ( attribute == 0 ) { + return; + } + MemPool* pool = attribute->_memPool; + attribute->~XMLAttribute(); + pool->Free( attribute ); +} + +// +// +// foobar +// +char* XMLElement::ParseDeep( char* p, StrPair* strPair ) +{ + // Read the element name. + p = XMLUtil::SkipWhiteSpace( p ); + + // The closing element is the form. It is + // parsed just like a regular element then deleted from + // the DOM. + if ( *p == '/' ) { + _closingType = CLOSING; + ++p; + } + + p = _value.ParseName( p ); + if ( _value.Empty() ) { + return 0; + } + + p = ParseAttributes( p ); + if ( !p || !*p || _closingType ) { + return p; + } + + p = XMLNode::ParseDeep( p, strPair ); + return p; +} + + + +XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? + for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { + element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? + } + return element; +} + + +bool XMLElement::ShallowEqual( const XMLNode* compare ) const +{ + TIXMLASSERT( compare ); + const XMLElement* other = compare->ToElement(); + if ( other && XMLUtil::StringEqual( other->Name(), Name() )) { + + const XMLAttribute* a=FirstAttribute(); + const XMLAttribute* b=other->FirstAttribute(); + + while ( a && b ) { + if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { + return false; + } + a = a->Next(); + b = b->Next(); + } + if ( a || b ) { + // different count + return false; + } + return true; + } + return false; +} + + +bool XMLElement::Accept( XMLVisitor* visitor ) const +{ + TIXMLASSERT( visitor ); + if ( visitor->VisitEnter( *this, _rootAttribute ) ) { + for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { + if ( !node->Accept( visitor ) ) { + break; + } + } + } + return visitor->VisitExit( *this ); +} + + +// --------- XMLDocument ----------- // + +// Warning: List must match 'enum XMLError' +const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { + "XML_SUCCESS", + "XML_NO_ATTRIBUTE", + "XML_WRONG_ATTRIBUTE_TYPE", + "XML_ERROR_FILE_NOT_FOUND", + "XML_ERROR_FILE_COULD_NOT_BE_OPENED", + "XML_ERROR_FILE_READ_ERROR", + "XML_ERROR_ELEMENT_MISMATCH", + "XML_ERROR_PARSING_ELEMENT", + "XML_ERROR_PARSING_ATTRIBUTE", + "XML_ERROR_IDENTIFYING_TAG", + "XML_ERROR_PARSING_TEXT", + "XML_ERROR_PARSING_CDATA", + "XML_ERROR_PARSING_COMMENT", + "XML_ERROR_PARSING_DECLARATION", + "XML_ERROR_PARSING_UNKNOWN", + "XML_ERROR_EMPTY_DOCUMENT", + "XML_ERROR_MISMATCHED_ELEMENT", + "XML_ERROR_PARSING", + "XML_CAN_NOT_CONVERT_TEXT", + "XML_NO_TEXT_NODE" +}; + + +XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) : + XMLNode( 0 ), + _writeBOM( false ), + _processEntities( processEntities ), + _errorID(XML_SUCCESS), + _whitespace( whitespace ), + _errorStr1( 0 ), + _errorStr2( 0 ), + _charBuffer( 0 ) +{ + // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+) + _document = this; +} + + +XMLDocument::~XMLDocument() +{ + Clear(); +} + + +void XMLDocument::Clear() +{ + DeleteChildren(); + +#ifdef DEBUG + const bool hadError = Error(); +#endif + _errorID = XML_SUCCESS; + _errorStr1 = 0; + _errorStr2 = 0; + + delete [] _charBuffer; + _charBuffer = 0; + +#if 0 + _textPool.Trace( "text" ); + _elementPool.Trace( "element" ); + _commentPool.Trace( "comment" ); + _attributePool.Trace( "attribute" ); +#endif + +#ifdef DEBUG + if ( !hadError ) { + TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); + TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); + TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); + TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); + } +#endif +} + + +XMLElement* XMLDocument::NewElement( const char* name ) +{ + TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() ); + XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this ); + ele->_memPool = &_elementPool; + ele->SetName( name ); + return ele; +} + + +XMLComment* XMLDocument::NewComment( const char* str ) +{ + TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() ); + XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this ); + comment->_memPool = &_commentPool; + comment->SetValue( str ); + return comment; +} + + +XMLText* XMLDocument::NewText( const char* str ) +{ + TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() ); + XMLText* text = new (_textPool.Alloc()) XMLText( this ); + text->_memPool = &_textPool; + text->SetValue( str ); + return text; +} + + +XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) +{ + TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() ); + XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this ); + dec->_memPool = &_commentPool; + dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); + return dec; +} + + +XMLUnknown* XMLDocument::NewUnknown( const char* str ) +{ + TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() ); + XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); + unk->_memPool = &_commentPool; + unk->SetValue( str ); + return unk; +} + +static FILE* callfopen( const char* filepath, const char* mode ) +{ + TIXMLASSERT( filepath ); + TIXMLASSERT( mode ); +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filepath, mode ); + if ( err ) { + return 0; + } +#else + FILE* fp = fopen( filepath, mode ); +#endif + return fp; +} + +void XMLDocument::DeleteNode( XMLNode* node ) { + TIXMLASSERT( node ); + TIXMLASSERT(node->_document == this ); + if (node->_parent) { + node->_parent->DeleteChild( node ); + } + else { + // Isn't in the tree. + // Use the parent delete. + // Also, we need to mark it tracked: we 'know' + // it was never used. + node->_memPool->SetTracked(); + // Call the static XMLNode version: + XMLNode::DeleteNode(node); + } +} + + +XMLError XMLDocument::LoadFile( const char* filename ) +{ + Clear(); + FILE* fp = callfopen( filename, "rb" ); + if ( !fp ) { + SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); + return _errorID; + } + LoadFile( fp ); + fclose( fp ); + return _errorID; +} + +// This is likely overengineered template art to have a check that unsigned long value incremented +// by one still fits into size_t. If size_t type is larger than unsigned long type +// (x86_64-w64-mingw32 target) then the check is redundant and gcc and clang emit +// -Wtype-limits warning. This piece makes the compiler select code with a check when a check +// is useful and code with no check when a check is redundant depending on how size_t and unsigned long +// types sizes relate to each other. +template += sizeof(size_t))> +struct LongFitsIntoSizeTMinusOne { + static bool Fits( unsigned long value ) + { + return value < (size_t)-1; + } +}; + +template <> +struct LongFitsIntoSizeTMinusOne { + static bool Fits( unsigned long ) + { + return true; + } +}; + +XMLError XMLDocument::LoadFile( FILE* fp ) +{ + Clear(); + + fseek( fp, 0, SEEK_SET ); + if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + + fseek( fp, 0, SEEK_END ); + const long filelength = ftell( fp ); + fseek( fp, 0, SEEK_SET ); + if ( filelength == -1L ) { + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + TIXMLASSERT( filelength >= 0 ); + + if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { + // Cannot handle files which won't fit in buffer together with null terminator + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + + if ( filelength == 0 ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return _errorID; + } + + const size_t size = filelength; + TIXMLASSERT( _charBuffer == 0 ); + _charBuffer = new char[size+1]; + size_t read = fread( _charBuffer, 1, size, fp ); + if ( read != size ) { + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + + _charBuffer[size] = 0; + + Parse(); + return _errorID; +} + + +XMLError XMLDocument::SaveFile( const char* filename, bool compact ) +{ + FILE* fp = callfopen( filename, "w" ); + if ( !fp ) { + SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); + return _errorID; + } + SaveFile(fp, compact); + fclose( fp ); + return _errorID; +} + + +XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) +{ + // Clear any error from the last save, otherwise it will get reported + // for *this* call. + SetError(XML_SUCCESS, 0, 0); + XMLPrinter stream( fp, compact ); + Print( &stream ); + return _errorID; +} + + +XMLError XMLDocument::Parse( const char* p, size_t len ) +{ + Clear(); + + if ( len == 0 || !p || !*p ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return _errorID; + } + if ( len == (size_t)(-1) ) { + len = strlen( p ); + } + TIXMLASSERT( _charBuffer == 0 ); + _charBuffer = new char[ len+1 ]; + memcpy( _charBuffer, p, len ); + _charBuffer[len] = 0; + + Parse(); + if ( Error() ) { + // clean up now essentially dangling memory. + // and the parse fail can put objects in the + // pools that are dead and inaccessible. + DeleteChildren(); + _elementPool.Clear(); + _attributePool.Clear(); + _textPool.Clear(); + _commentPool.Clear(); + } + return _errorID; +} + + +void XMLDocument::Print( XMLPrinter* streamer ) const +{ + if ( streamer ) { + Accept( streamer ); + } + else { + XMLPrinter stdoutStreamer( stdout ); + Accept( &stdoutStreamer ); + } +} + + +void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) +{ + TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT ); + _errorID = error; + _errorStr1 = str1; + _errorStr2 = str2; +} + +const char* XMLDocument::ErrorName() const +{ + TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT ); + const char* errorName = _errorNames[_errorID]; + TIXMLASSERT( errorName && errorName[0] ); + return errorName; +} + +void XMLDocument::PrintError() const +{ + if ( Error() ) { + static const int LEN = 20; + char buf1[LEN] = { 0 }; + char buf2[LEN] = { 0 }; + + if ( _errorStr1 ) { + TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 ); + } + if ( _errorStr2 ) { + TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 ); + } + + // Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that + // causes a clang "always true" -Wtautological-constant-out-of-range-compare warning + TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX ); + printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n", + static_cast( _errorID ), ErrorName(), buf1, buf2 ); + } +} + +void XMLDocument::Parse() +{ + TIXMLASSERT( NoChildren() ); // Clear() must have been called previously + TIXMLASSERT( _charBuffer ); + char* p = _charBuffer; + p = XMLUtil::SkipWhiteSpace( p ); + p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); + if ( !*p ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return; + } + ParseDeep(p, 0 ); +} + +XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : + _elementJustOpened( false ), + _firstElement( true ), + _fp( file ), + _depth( depth ), + _textDepth( -1 ), + _processEntities( true ), + _compactMode( compact ) +{ + for( int i=0; i'] = true; // not required, but consistency is nice + _buffer.Push( 0 ); +} + + +void XMLPrinter::Print( const char* format, ... ) +{ + va_list va; + va_start( va, format ); + + if ( _fp ) { + vfprintf( _fp, format, va ); + } + else { + const int len = TIXML_VSCPRINTF( format, va ); + // Close out and re-start the va-args + va_end( va ); + TIXMLASSERT( len >= 0 ); + va_start( va, format ); + TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); + char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. + TIXML_VSNPRINTF( p, len+1, format, va ); + } + va_end( va ); +} + + +void XMLPrinter::PrintSpace( int depth ) +{ + for( int i=0; i 0 && *q < ENTITY_RANGE ) { + // Check for entities. If one is found, flush + // the stream up until the entity, write the + // entity, and keep looking. + if ( flag[(unsigned char)(*q)] ) { + while ( p < q ) { + const size_t delta = q - p; + // %.*s accepts type int as "precision" + const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta; + Print( "%.*s", toPrint, p ); + p += toPrint; + } + bool entityPatternPrinted = false; + for( int i=0; i" ); + } + else { + if ( _textDepth < 0 && !compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + Print( "", name ); + } + + if ( _textDepth == _depth ) { + _textDepth = -1; + } + if ( _depth == 0 && !compactMode) { + Print( "\n" ); + } + _elementJustOpened = false; +} + + +void XMLPrinter::SealElementIfJustOpened() +{ + if ( !_elementJustOpened ) { + return; + } + _elementJustOpened = false; + Print( ">" ); +} + + +void XMLPrinter::PushText( const char* text, bool cdata ) +{ + _textDepth = _depth-1; + + SealElementIfJustOpened(); + if ( cdata ) { + Print( "", text ); + } + else { + PrintString( text, true ); + } +} + +void XMLPrinter::PushText( int value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( unsigned value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( bool value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( float value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( double value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushComment( const char* comment ) +{ + SealElementIfJustOpened(); + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", comment ); +} + + +void XMLPrinter::PushDeclaration( const char* value ) +{ + SealElementIfJustOpened(); + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", value ); +} + + +void XMLPrinter::PushUnknown( const char* value ) +{ + SealElementIfJustOpened(); + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", value ); +} + + +bool XMLPrinter::VisitEnter( const XMLDocument& doc ) +{ + _processEntities = doc.ProcessEntities(); + if ( doc.HasBOM() ) { + PushHeader( true, false ); + } + return true; +} + + +bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) +{ + const XMLElement* parentElem = 0; + if ( element.Parent() ) { + parentElem = element.Parent()->ToElement(); + } + const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode; + OpenElement( element.Name(), compactMode ); + while ( attribute ) { + PushAttribute( attribute->Name(), attribute->Value() ); + attribute = attribute->Next(); + } + return true; +} + + +bool XMLPrinter::VisitExit( const XMLElement& element ) +{ + CloseElement( CompactMode(element) ); + return true; +} + + +bool XMLPrinter::Visit( const XMLText& text ) +{ + PushText( text.Value(), text.CData() ); + return true; +} + + +bool XMLPrinter::Visit( const XMLComment& comment ) +{ + PushComment( comment.Value() ); + return true; +} + +bool XMLPrinter::Visit( const XMLDeclaration& declaration ) +{ + PushDeclaration( declaration.Value() ); + return true; +} + + +bool XMLPrinter::Visit( const XMLUnknown& unknown ) +{ + PushUnknown( unknown.Value() ); + return true; +} + +} // namespace tinyxml2 + diff --git a/sgx-jvm/linux-sgx/external/tinyxml2/tinyxml2.h b/sgx-jvm/linux-sgx/external/tinyxml2/tinyxml2.h index fb4376d300..60280c06d2 100644 --- a/sgx-jvm/linux-sgx/external/tinyxml2/tinyxml2.h +++ b/sgx-jvm/linux-sgx/external/tinyxml2/tinyxml2.h @@ -1,2170 +1,2170 @@ -/* -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#ifndef TINYXML2_INCLUDED -#define TINYXML2_INCLUDED - -#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) -# include -# include -# include -# include -# include -# if defined(__PS3__) -# include -# endif -#else -# include -# include -# include -# include -# include -#endif -#include - -/* - TODO: intern strings instead of allocation. -*/ -/* - gcc: - g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe - - Formatting, Artistic Style: - AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h -*/ - -#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) -# ifndef DEBUG -# define DEBUG -# endif -#endif - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4251) -#endif - -#ifdef _WIN32 -# ifdef TINYXML2_EXPORT -# define TINYXML2_LIB __declspec(dllexport) -# elif defined(TINYXML2_IMPORT) -# define TINYXML2_LIB __declspec(dllimport) -# else -# define TINYXML2_LIB -# endif -#else -# define TINYXML2_LIB -#endif - - -#if defined(DEBUG) -# if defined(_MSC_VER) -# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like -# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } -# elif defined (ANDROID_NDK) -# include -# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } -# else -# include -# define TIXMLASSERT assert -# endif -#else -# define TIXMLASSERT( x ) {} -#endif - - -/* Versioning, past 1.0.14: - http://semver.org/ -*/ -static const int TIXML2_MAJOR_VERSION = 4; -static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 1; - -namespace tinyxml2 -{ -class XMLDocument; -class XMLElement; -class XMLAttribute; -class XMLComment; -class XMLText; -class XMLDeclaration; -class XMLUnknown; -class XMLPrinter; - -/* - A class that wraps strings. Normally stores the start and end - pointers into the XML file itself, and will apply normalization - and entity translation if actually read. Can also store (and memory - manage) a traditional char[] -*/ -class StrPair -{ -public: - enum { - NEEDS_ENTITY_PROCESSING = 0x01, - NEEDS_NEWLINE_NORMALIZATION = 0x02, - NEEDS_WHITESPACE_COLLAPSING = 0x04, - - TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_NAME = 0, - ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, - ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, - COMMENT = NEEDS_NEWLINE_NORMALIZATION - }; - - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} - ~StrPair(); - - void Set( char* start, char* end, int flags ) { - Reset(); - _start = start; - _end = end; - _flags = flags | NEEDS_FLUSH; - } - - const char* GetStr(); - - bool Empty() const { - return _start == _end; - } - - void SetInternedStr( const char* str ) { - Reset(); - _start = const_cast(str); - } - - void SetStr( const char* str, int flags=0 ); - - char* ParseText( char* in, const char* endTag, int strFlags ); - char* ParseName( char* in ); - - void TransferTo( StrPair* other ); - -private: - void Reset(); - void CollapseWhitespace(); - - enum { - NEEDS_FLUSH = 0x100, - NEEDS_DELETE = 0x200 - }; - - int _flags; - char* _start; - char* _end; - - StrPair( const StrPair& other ); // not supported - void operator=( StrPair& other ); // not supported, use TransferTo() -}; - - -/* - A dynamic array of Plain Old Data. Doesn't support constructors, etc. - Has a small initial memory pool, so that low or no usage will not - cause a call to new/delete -*/ -template -class DynArray -{ -public: - DynArray() { - _mem = _pool; - _allocated = INITIAL_SIZE; - _size = 0; - } - - ~DynArray() { - if ( _mem != _pool ) { - delete [] _mem; - } - } - - void Clear() { - _size = 0; - } - - void Push( T t ) { - TIXMLASSERT( _size < INT_MAX ); - EnsureCapacity( _size+1 ); - _mem[_size++] = t; - } - - T* PushArr( int count ) { - TIXMLASSERT( count >= 0 ); - TIXMLASSERT( _size <= INT_MAX - count ); - EnsureCapacity( _size+count ); - T* ret = &_mem[_size]; - _size += count; - return ret; - } - - T Pop() { - TIXMLASSERT( _size > 0 ); - return _mem[--_size]; - } - - void PopArr( int count ) { - TIXMLASSERT( _size >= count ); - _size -= count; - } - - bool Empty() const { - return _size == 0; - } - - T& operator[](int i) { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& operator[](int i) const { - TIXMLASSERT( i>= 0 && i < _size ); - return _mem[i]; - } - - const T& PeekTop() const { - TIXMLASSERT( _size > 0 ); - return _mem[ _size - 1]; - } - - int Size() const { - TIXMLASSERT( _size >= 0 ); - return _size; - } - - int Capacity() const { - TIXMLASSERT( _allocated >= INITIAL_SIZE ); - return _allocated; - } - - const T* Mem() const { - TIXMLASSERT( _mem ); - return _mem; - } - - T* Mem() { - TIXMLASSERT( _mem ); - return _mem; - } - -private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported - - void EnsureCapacity( int cap ) { - TIXMLASSERT( cap > 0 ); - if ( cap > _allocated ) { - TIXMLASSERT( cap <= INT_MAX / 2 ); - int newAllocated = cap * 2; - T* newMem = new T[newAllocated]; - memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs - if ( _mem != _pool ) { - delete [] _mem; - } - _mem = newMem; - _allocated = newAllocated; - } - } - - T* _mem; - T _pool[INITIAL_SIZE]; - int _allocated; // objects allocated - int _size; // number objects in use -}; - - -/* - Parent virtual class of a pool for fast allocation - and deallocation of objects. -*/ -class MemPool -{ -public: - MemPool() {} - virtual ~MemPool() {} - - virtual int ItemSize() const = 0; - virtual void* Alloc() = 0; - virtual void Free( void* ) = 0; - virtual void SetTracked() = 0; - virtual void Clear() = 0; -}; - - -/* - Template child class to create pools of the correct type. -*/ -template< int SIZE > -class MemPoolT : public MemPool -{ -public: - MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} - ~MemPoolT() { - Clear(); - } - - void Clear() { - // Delete the blocks. - while( !_blockPtrs.Empty()) { - Block* b = _blockPtrs.Pop(); - delete b; - } - _root = 0; - _currentAllocs = 0; - _nAllocs = 0; - _maxAllocs = 0; - _nUntracked = 0; - } - - virtual int ItemSize() const { - return SIZE; - } - int CurrentAllocs() const { - return _currentAllocs; - } - - virtual void* Alloc() { - if ( !_root ) { - // Need a new block. - Block* block = new Block(); - _blockPtrs.Push( block ); - - for( int i=0; ichunk[i].next = &block->chunk[i+1]; - } - block->chunk[COUNT-1].next = 0; - _root = block->chunk; - } - void* result = _root; - _root = _root->next; - - ++_currentAllocs; - if ( _currentAllocs > _maxAllocs ) { - _maxAllocs = _currentAllocs; - } - _nAllocs++; - _nUntracked++; - return result; - } - - virtual void Free( void* mem ) { - if ( !mem ) { - return; - } - --_currentAllocs; - Chunk* chunk = static_cast( mem ); -#ifdef DEBUG - memset( chunk, 0xfe, sizeof(Chunk) ); -#endif - chunk->next = _root; - _root = chunk; - } - void Trace( const char* name ) { - printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", - name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); - } - - void SetTracked() { - _nUntracked--; - } - - int Untracked() const { - return _nUntracked; - } - - // This number is perf sensitive. 4k seems like a good tradeoff on my machine. - // The test file is large, 170k. - // Release: VS2010 gcc(no opt) - // 1k: 4000 - // 2k: 4000 - // 4k: 3900 21000 - // 16k: 5200 - // 32k: 4300 - // 64k: 4000 21000 - enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private - -private: - MemPoolT( const MemPoolT& ); // not supported - void operator=( const MemPoolT& ); // not supported - - union Chunk { - Chunk* next; - char mem[SIZE]; - }; - struct Block { - Chunk chunk[COUNT]; - }; - DynArray< Block*, 10 > _blockPtrs; - Chunk* _root; - - int _currentAllocs; - int _nAllocs; - int _maxAllocs; - int _nUntracked; -}; - - - -/** - Implements the interface to the "Visitor pattern" (see the Accept() method.) - If you call the Accept() method, it requires being passed a XMLVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs - are simply called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its siblings will be visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the XMLDocument, although all nodes support visiting. - - You should never change the document from a callback. - - @sa XMLNode::Accept() -*/ -class TINYXML2_LIB XMLVisitor -{ -public: - virtual ~XMLVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { - return true; - } - /// Visit a document. - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - /// Visit an element. - virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { - return true; - } - /// Visit an element. - virtual bool VisitExit( const XMLElement& /*element*/ ) { - return true; - } - - /// Visit a declaration. - virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { - return true; - } - /// Visit a text node. - virtual bool Visit( const XMLText& /*text*/ ) { - return true; - } - /// Visit a comment node. - virtual bool Visit( const XMLComment& /*comment*/ ) { - return true; - } - /// Visit an unknown node. - virtual bool Visit( const XMLUnknown& /*unknown*/ ) { - return true; - } -}; - -// WARNING: must match XMLDocument::_errorNames[] -enum XMLError { - XML_SUCCESS = 0, - XML_NO_ATTRIBUTE, - XML_WRONG_ATTRIBUTE_TYPE, - XML_ERROR_FILE_NOT_FOUND, - XML_ERROR_FILE_COULD_NOT_BE_OPENED, - XML_ERROR_FILE_READ_ERROR, - XML_ERROR_ELEMENT_MISMATCH, - XML_ERROR_PARSING_ELEMENT, - XML_ERROR_PARSING_ATTRIBUTE, - XML_ERROR_IDENTIFYING_TAG, - XML_ERROR_PARSING_TEXT, - XML_ERROR_PARSING_CDATA, - XML_ERROR_PARSING_COMMENT, - XML_ERROR_PARSING_DECLARATION, - XML_ERROR_PARSING_UNKNOWN, - XML_ERROR_EMPTY_DOCUMENT, - XML_ERROR_MISMATCHED_ELEMENT, - XML_ERROR_PARSING, - XML_CAN_NOT_CONVERT_TEXT, - XML_NO_TEXT_NODE, - - XML_ERROR_COUNT -}; - - -/* - Utility functionality. -*/ -class XMLUtil -{ -public: - static const char* SkipWhiteSpace( const char* p ) { - TIXMLASSERT( p ); - while( IsWhiteSpace(*p) ) { - ++p; - } - TIXMLASSERT( p ); - return p; - } - static char* SkipWhiteSpace( char* p ) { - return const_cast( SkipWhiteSpace( const_cast(p) ) ); - } - - // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't - // correct, but simple, and usually works. - static bool IsWhiteSpace( char p ) { - return !IsUTF8Continuation(p) && isspace( static_cast(p) ); - } - - inline static bool IsNameStartChar( unsigned char ch ) { - if ( ch >= 128 ) { - // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() - return true; - } - if ( isalpha( ch ) ) { - return true; - } - return ch == ':' || ch == '_'; - } - - inline static bool IsNameChar( unsigned char ch ) { - return IsNameStartChar( ch ) - || isdigit( ch ) - || ch == '.' - || ch == '-'; - } - - inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { - if ( p == q ) { - return true; - } - return strncmp( p, q, nChar ) == 0; - } - - inline static bool IsUTF8Continuation( char p ) { - return ( p & 0x80 ) != 0; - } - - static const char* ReadBOM( const char* p, bool* hasBOM ); - // p is the starting location, - // the UTF-8 value of the entity will be placed in value, and length filled in. - static const char* GetCharacterRef( const char* p, char* value, int* length ); - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - - // converts primitive types to strings - static void ToStr( int v, char* buffer, int bufferSize ); - static void ToStr( unsigned v, char* buffer, int bufferSize ); - static void ToStr( bool v, char* buffer, int bufferSize ); - static void ToStr( float v, char* buffer, int bufferSize ); - static void ToStr( double v, char* buffer, int bufferSize ); - static void ToStr(int64_t v, char* buffer, int bufferSize); - - // converts strings to primitive types - static bool ToInt( const char* str, int* value ); - static bool ToUnsigned( const char* str, unsigned* value ); - static bool ToBool( const char* str, bool* value ); - static bool ToFloat( const char* str, float* value ); - static bool ToDouble( const char* str, double* value ); - static bool ToInt64(const char* str, int64_t* value); -}; - - -/** XMLNode is a base class for every object that is in the - XML Document Object Model (DOM), except XMLAttributes. - Nodes have siblings, a parent, and children which can - be navigated. A node is always in a XMLDocument. - The type of a XMLNode can be queried, and it can - be cast to its more defined type. - - A XMLDocument allocates memory for all its Nodes. - When the XMLDocument gets deleted, all its Nodes - will also be deleted. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - @endverbatim -*/ -class TINYXML2_LIB XMLNode -{ - friend class XMLDocument; - friend class XMLElement; -public: - - /// Get the XMLDocument that owns this XMLNode. - const XMLDocument* GetDocument() const { - TIXMLASSERT( _document ); - return _document; - } - /// Get the XMLDocument that owns this XMLNode. - XMLDocument* GetDocument() { - TIXMLASSERT( _document ); - return _document; - } - - /// Safely cast to an Element, or null. - virtual XMLElement* ToElement() { - return 0; - } - /// Safely cast to Text, or null. - virtual XMLText* ToText() { - return 0; - } - /// Safely cast to a Comment, or null. - virtual XMLComment* ToComment() { - return 0; - } - /// Safely cast to a Document, or null. - virtual XMLDocument* ToDocument() { - return 0; - } - /// Safely cast to a Declaration, or null. - virtual XMLDeclaration* ToDeclaration() { - return 0; - } - /// Safely cast to an Unknown, or null. - virtual XMLUnknown* ToUnknown() { - return 0; - } - - virtual const XMLElement* ToElement() const { - return 0; - } - virtual const XMLText* ToText() const { - return 0; - } - virtual const XMLComment* ToComment() const { - return 0; - } - virtual const XMLDocument* ToDocument() const { - return 0; - } - virtual const XMLDeclaration* ToDeclaration() const { - return 0; - } - virtual const XMLUnknown* ToUnknown() const { - return 0; - } - - /** The meaning of 'value' changes for the specific type. - @verbatim - Document: empty (NULL is returned, not an empty string) - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - const char* Value() const; - - /** Set the Value of an XML node. - @sa Value() - */ - void SetValue( const char* val, bool staticMem=false ); - - /// Get the parent of this node on the DOM. - const XMLNode* Parent() const { - return _parent; - } - - XMLNode* Parent() { - return _parent; - } - - /// Returns true if this node has no children. - bool NoChildren() const { - return !_firstChild; - } - - /// Get the first child node, or null if none exists. - const XMLNode* FirstChild() const { - return _firstChild; - } - - XMLNode* FirstChild() { - return _firstChild; - } - - /** Get the first child element, or optionally the first child - element with the specified name. - */ - const XMLElement* FirstChildElement( const char* name = 0 ) const; - - XMLElement* FirstChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->FirstChildElement( name )); - } - - /// Get the last child node, or null if none exists. - const XMLNode* LastChild() const { - return _lastChild; - } - - XMLNode* LastChild() { - return _lastChild; - } - - /** Get the last child element or optionally the last child - element with the specified name. - */ - const XMLElement* LastChildElement( const char* name = 0 ) const; - - XMLElement* LastChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->LastChildElement(name) ); - } - - /// Get the previous (left) sibling node of this node. - const XMLNode* PreviousSibling() const { - return _prev; - } - - XMLNode* PreviousSibling() { - return _prev; - } - - /// Get the previous (left) sibling element of this node, with an optionally supplied name. - const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; - - XMLElement* PreviousSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); - } - - /// Get the next (right) sibling node of this node. - const XMLNode* NextSibling() const { - return _next; - } - - XMLNode* NextSibling() { - return _next; - } - - /// Get the next (right) sibling element of this node, with an optionally supplied name. - const XMLElement* NextSiblingElement( const char* name = 0 ) const; - - XMLElement* NextSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->NextSiblingElement( name ) ); - } - - /** - Add a child node as the last (right) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertEndChild( XMLNode* addThis ); - - XMLNode* LinkEndChild( XMLNode* addThis ) { - return InsertEndChild( addThis ); - } - /** - Add a child node as the first (left) child. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the node does not - belong to the same document. - */ - XMLNode* InsertFirstChild( XMLNode* addThis ); - /** - Add a node after the specified child node. - If the child node is already part of the document, - it is moved from its old location to the new location. - Returns the addThis argument or 0 if the afterThis node - is not a child of this node, or if the node does not - belong to the same document. - */ - XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); - - /** - Delete all the children of this node. - */ - void DeleteChildren(); - - /** - Delete a child of this node. - */ - void DeleteChild( XMLNode* node ); - - /** - Make a copy of this node, but not its children. - You may pass in a Document pointer that will be - the owner of the new Node. If the 'document' is - null, then the node returned will be allocated - from the current Document. (this->GetDocument()) - - Note: if called on a XMLDocument, this will return null. - */ - virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; - - /** - Test if 2 nodes are the same, but don't test children. - The 2 nodes do not need to be in the same Document. - - Note: if called on a XMLDocument, this will return false. - */ - virtual bool ShallowEqual( const XMLNode* compare ) const = 0; - - /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the XMLVisitor interface. - - This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - XMLPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( XMLVisitor* visitor ) const = 0; - - /** - Set user data into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void SetUserData(void* userData) { _userData = userData; } - - /** - Get user data set into the XMLNode. TinyXML-2 in - no way processes or interprets user data. - It is initially 0. - */ - void* GetUserData() const { return _userData; } - -protected: - XMLNode( XMLDocument* ); - virtual ~XMLNode(); - - virtual char* ParseDeep( char*, StrPair* ); - - XMLDocument* _document; - XMLNode* _parent; - mutable StrPair _value; - - XMLNode* _firstChild; - XMLNode* _lastChild; - - XMLNode* _prev; - XMLNode* _next; - - void* _userData; - -private: - MemPool* _memPool; - void Unlink( XMLNode* child ); - static void DeleteNode( XMLNode* node ); - void InsertChildPreamble( XMLNode* insertThis ) const; - - XMLNode( const XMLNode& ); // not supported - XMLNode& operator=( const XMLNode& ); // not supported -}; - - -/** XML text. - - Note that a text node can have child element nodes, for example: - @verbatim - This is bold - @endverbatim - - A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCData() and query it with CData(). -*/ -class TINYXML2_LIB XMLText : public XMLNode -{ - friend class XMLDocument; -public: - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLText* ToText() { - return this; - } - virtual const XMLText* ToText() const { - return this; - } - - /// Declare whether this should be CDATA or standard text. - void SetCData( bool isCData ) { - _isCData = isCData; - } - /// Returns true if this is a CDATA text element. - bool CData() const { - return _isCData; - } - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} - virtual ~XMLText() {} - - char* ParseDeep( char*, StrPair* endTag ); - -private: - bool _isCData; - - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported -}; - - -/** An XML Comment. */ -class TINYXML2_LIB XMLComment : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLComment* ToComment() { - return this; - } - virtual const XMLComment* ToComment() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - XMLComment( XMLDocument* doc ); - virtual ~XMLComment(); - - char* ParseDeep( char*, StrPair* endTag ); - -private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXML-2 will happily read or write files without a declaration, - however. - - The text of the declaration isn't interpreted. It is parsed - and written as a string. -*/ -class TINYXML2_LIB XMLDeclaration : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLDeclaration* ToDeclaration() { - return this; - } - virtual const XMLDeclaration* ToDeclaration() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - XMLDeclaration( XMLDocument* doc ); - virtual ~XMLDeclaration(); - - char* ParseDeep( char*, StrPair* endTag ); - -private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported -}; - - -/** Any tag that TinyXML-2 doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into XMLUnknowns. -*/ -class TINYXML2_LIB XMLUnknown : public XMLNode -{ - friend class XMLDocument; -public: - virtual XMLUnknown* ToUnknown() { - return this; - } - virtual const XMLUnknown* ToUnknown() const { - return this; - } - - virtual bool Accept( XMLVisitor* visitor ) const; - - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - XMLUnknown( XMLDocument* doc ); - virtual ~XMLUnknown(); - - char* ParseDeep( char*, StrPair* endTag ); - -private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported -}; - - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not XMLNodes. You may only query the - Next() attribute in a list. -*/ -class TINYXML2_LIB XMLAttribute -{ - friend class XMLElement; -public: - /// The name of the attribute. - const char* Name() const; - - /// The value of the attribute. - const char* Value() const; - - /// The next attribute in the list. - const XMLAttribute* Next() const { - return _next; - } - - /** IntValue interprets the attribute as an integer, and returns the value. - If the value isn't an integer, 0 will be returned. There is no error checking; - use QueryIntValue() if you need error checking. - */ - int IntValue() const { - int i = 0; - QueryIntValue(&i); - return i; - } - - int64_t Int64Value() const { - int64_t i = 0; - QueryInt64Value(&i); - return i; - } - - /// Query as an unsigned integer. See IntValue() - unsigned UnsignedValue() const { - unsigned i=0; - QueryUnsignedValue( &i ); - return i; - } - /// Query as a boolean. See IntValue() - bool BoolValue() const { - bool b=false; - QueryBoolValue( &b ); - return b; - } - /// Query as a double. See IntValue() - double DoubleValue() const { - double d=0; - QueryDoubleValue( &d ); - return d; - } - /// Query as a float. See IntValue() - float FloatValue() const { - float f=0; - QueryFloatValue( &f ); - return f; - } - - /** QueryIntValue interprets the attribute as an integer, and returns the value - in the provided parameter. The function will return XML_NO_ERROR on success, - and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. - */ - XMLError QueryIntValue( int* value ) const; - /// See QueryIntValue - XMLError QueryUnsignedValue( unsigned int* value ) const; - /// See QueryIntValue - XMLError QueryInt64Value(int64_t* value) const; - /// See QueryIntValue - XMLError QueryBoolValue( bool* value ) const; - /// See QueryIntValue - XMLError QueryDoubleValue( double* value ) const; - /// See QueryIntValue - XMLError QueryFloatValue( float* value ) const; - - /// Set the attribute to a string value. - void SetAttribute( const char* value ); - /// Set the attribute to value. - void SetAttribute( int value ); - /// Set the attribute to value. - void SetAttribute( unsigned value ); - /// Set the attribute to value. - void SetAttribute(int64_t value); - /// Set the attribute to value. - void SetAttribute( bool value ); - /// Set the attribute to value. - void SetAttribute( double value ); - /// Set the attribute to value. - void SetAttribute( float value ); - -private: - enum { BUF_SIZE = 200 }; - - XMLAttribute() : _next( 0 ), _memPool( 0 ) {} - virtual ~XMLAttribute() {} - - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported - void SetName( const char* name ); - - char* ParseDeep( char* p, bool processEntities ); - - mutable StrPair _name; - mutable StrPair _value; - XMLAttribute* _next; - MemPool* _memPool; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TINYXML2_LIB XMLElement : public XMLNode -{ - friend class XMLDocument; -public: - /// Get the name of an element (which is the Value() of the node.) - const char* Name() const { - return Value(); - } - /// Set the name of the element. - void SetName( const char* str, bool staticMem=false ) { - SetValue( str, staticMem ); - } - - virtual XMLElement* ToElement() { - return this; - } - virtual const XMLElement* ToElement() const { - return this; - } - virtual bool Accept( XMLVisitor* visitor ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none - exists. For example: - - @verbatim - const char* value = ele->Attribute( "foo" ); - @endverbatim - - The 'value' parameter is normally null. However, if specified, - the attribute will only be returned if the 'name' and 'value' - match. This allow you to write code: - - @verbatim - if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); - @endverbatim - - rather than: - @verbatim - if ( ele->Attribute( "foo" ) ) { - if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); - } - @endverbatim - */ - const char* Attribute( const char* name, const char* value=0 ) const; - - /** Given an attribute name, IntAttribute() returns the value - of the attribute interpreted as an integer. 0 will be - returned if there is an error. For a method with error - checking, see QueryIntAttribute() - */ - int IntAttribute( const char* name ) const { - int i=0; - QueryIntAttribute( name, &i ); - return i; - } - - /// See IntAttribute() - unsigned UnsignedAttribute( const char* name ) const { - unsigned i=0; - QueryUnsignedAttribute( name, &i ); - return i; - } - - /// See IntAttribute() - int64_t Int64Attribute(const char* name) const { - int64_t i = 0; - QueryInt64Attribute(name, &i); - return i; - } - - /// See IntAttribute() - bool BoolAttribute( const char* name ) const { - bool b=false; - QueryBoolAttribute( name, &b ); - return b; - } - /// See IntAttribute() - double DoubleAttribute( const char* name ) const { - double d=0; - QueryDoubleAttribute( name, &d ); - return d; - } - /// See IntAttribute() - float FloatAttribute( const char* name ) const { - float f=0; - QueryFloatAttribute( name, &f ); - return f; - } - - /** Given an attribute name, QueryIntAttribute() returns - XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - XMLError QueryIntAttribute( const char* name, int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryIntValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryUnsignedValue( value ); - } - - /// See QueryIntAttribute() - XMLError QueryInt64Attribute(const char* name, int64_t* value) const { - const XMLAttribute* a = FindAttribute(name); - if (!a) { - return XML_NO_ATTRIBUTE; - } - return a->QueryInt64Value(value); - } - - /// See QueryIntAttribute() - XMLError QueryBoolAttribute( const char* name, bool* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryBoolValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryDoubleAttribute( const char* name, double* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryDoubleValue( value ); - } - /// See QueryIntAttribute() - XMLError QueryFloatAttribute( const char* name, float* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { - return XML_NO_ATTRIBUTE; - } - return a->QueryFloatValue( value ); - } - - - /** Given an attribute name, QueryAttribute() returns - XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion - can't be performed, or XML_NO_ATTRIBUTE if the attribute - doesn't exist. It is overloaded for the primitive types, - and is a generally more convenient replacement of - QueryIntAttribute() and related functions. - - If successful, the result of the conversion - will be written to 'value'. If not successful, nothing will - be written to 'value'. This allows you to provide default - value: - - @verbatim - int value = 10; - QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 - @endverbatim - */ - int QueryAttribute( const char* name, int* value ) const { - return QueryIntAttribute( name, value ); - } - - int QueryAttribute( const char* name, unsigned int* value ) const { - return QueryUnsignedAttribute( name, value ); - } - - int QueryAttribute(const char* name, int64_t* value) const { - return QueryInt64Attribute(name, value); - } - - int QueryAttribute( const char* name, bool* value ) const { - return QueryBoolAttribute( name, value ); - } - - int QueryAttribute( const char* name, double* value ) const { - return QueryDoubleAttribute( name, value ); - } - - int QueryAttribute( const char* name, float* value ) const { - return QueryFloatAttribute( name, value ); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, const char* value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, int value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, unsigned value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /// Sets the named attribute to value. - void SetAttribute(const char* name, int64_t value) { - XMLAttribute* a = FindOrCreateAttribute(name); - a->SetAttribute(value); - } - - /// Sets the named attribute to value. - void SetAttribute( const char* name, bool value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, double value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - /// Sets the named attribute to value. - void SetAttribute( const char* name, float value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); - } - - /** - Delete an attribute. - */ - void DeleteAttribute( const char* name ); - - /// Return the first attribute in the list. - const XMLAttribute* FirstAttribute() const { - return _rootAttribute; - } - /// Query a specific attribute in the list. - const XMLAttribute* FindAttribute( const char* name ) const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the XMLText child - and accessing it directly. - - If the first child of 'this' is a XMLText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - */ - const char* GetText() const; - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, SetText() is limited compared to creating an XMLText child - and mutating it directly. - - If the first child of 'this' is a XMLText, SetText() sets its value to - the given string, otherwise it will create a first child that is an XMLText. - - This is a convenient method for setting the text of simple contained text: - @verbatim - This is text - fooElement->SetText( "Hullaballoo!" ); - Hullaballoo! - @endverbatim - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then it will not change "This is text", but rather prefix it with a text element: - @verbatim - Hullaballoo!This is text - @endverbatim - - For this XML: - @verbatim - - @endverbatim - SetText() will generate - @verbatim - Hullaballoo! - @endverbatim - */ - void SetText( const char* inText ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( int value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( unsigned value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText(int64_t value); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( bool value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( double value ); - /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( float value ); - - /** - Convenience method to query the value of a child text node. This is probably best - shown by example. Given you have a document is this form: - @verbatim - - 1 - 1.4 - - @endverbatim - - The QueryIntText() and similar functions provide a safe and easier way to get to the - "value" of x and y. - - @verbatim - int x = 0; - float y = 0; // types of x and y are contrived for example - const XMLElement* xElement = pointElement->FirstChildElement( "x" ); - const XMLElement* yElement = pointElement->FirstChildElement( "y" ); - xElement->QueryIntText( &x ); - yElement->QueryFloatText( &y ); - @endverbatim - - @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted - to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. - - */ - XMLError QueryIntText( int* ival ) const; - /// See QueryIntText() - XMLError QueryUnsignedText( unsigned* uval ) const; - /// See QueryIntText() - XMLError QueryInt64Text(int64_t* uval) const; - /// See QueryIntText() - XMLError QueryBoolText( bool* bval ) const; - /// See QueryIntText() - XMLError QueryDoubleText( double* dval ) const; - /// See QueryIntText() - XMLError QueryFloatText( float* fval ) const; - - // internal: - enum { - OPEN, // - CLOSED, // - CLOSING // - }; - int ClosingType() const { - return _closingType; - } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; - -protected: - char* ParseDeep( char* p, StrPair* endTag ); - -private: - XMLElement( XMLDocument* doc ); - virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported - - XMLAttribute* FindAttribute( const char* name ) { - return const_cast(const_cast(this)->FindAttribute( name )); - } - XMLAttribute* FindOrCreateAttribute( const char* name ); - //void LinkAttribute( XMLAttribute* attrib ); - char* ParseAttributes( char* p ); - static void DeleteAttribute( XMLAttribute* attribute ); - - enum { BUF_SIZE = 200 }; - int _closingType; - // The attribute list is ordered; there is no 'lastAttribute' - // because the list needs to be scanned for dupes before adding - // a new attribute. - XMLAttribute* _rootAttribute; -}; - - -enum Whitespace { - PRESERVE_WHITESPACE, - COLLAPSE_WHITESPACE -}; - - -/** A Document binds together all the functionality. - It can be saved, loaded, and printed to the screen. - All Nodes are connected and allocated to a Document. - If the Document is deleted, all its Nodes are also deleted. -*/ -class TINYXML2_LIB XMLDocument : public XMLNode -{ - friend class XMLElement; -public: - /// constructor - XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); - ~XMLDocument(); - - virtual XMLDocument* ToDocument() { - TIXMLASSERT( this == _document ); - return this; - } - virtual const XMLDocument* ToDocument() const { - TIXMLASSERT( this == _document ); - return this; - } - - /** - Parse an XML file from a character string. - Returns XML_NO_ERROR (0) on success, or - an errorID. - - You may optionally pass in the 'nBytes', which is - the number of bytes which will be parsed. If not - specified, TinyXML-2 will assume 'xml' points to a - null terminated string. - */ - XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); - - /** - Load an XML file from disk. - Returns XML_NO_ERROR (0) on success, or - an errorID. - */ - XMLError LoadFile( const char* filename ); - - /** - Load an XML file from disk. You are responsible - for providing and closing the FILE*. - - NOTE: The file should be opened as binary ("rb") - not text in order for TinyXML-2 to correctly - do newline normalization. - - Returns XML_NO_ERROR (0) on success, or - an errorID. - */ - XMLError LoadFile( FILE* ); - - /** - Save the XML file to disk. - Returns XML_NO_ERROR (0) on success, or - an errorID. - */ - XMLError SaveFile( const char* filename, bool compact = false ); - - /** - Save the XML file to disk. You are responsible - for providing and closing the FILE*. - - Returns XML_NO_ERROR (0) on success, or - an errorID. - */ - XMLError SaveFile( FILE* fp, bool compact = false ); - - bool ProcessEntities() const { - return _processEntities; - } - Whitespace WhitespaceMode() const { - return _whitespace; - } - - /** - Returns true if this document has a leading Byte Order Mark of UTF8. - */ - bool HasBOM() const { - return _writeBOM; - } - /** Sets whether to write the BOM when writing the file. - */ - void SetBOM( bool useBOM ) { - _writeBOM = useBOM; - } - - /** Return the root element of DOM. Equivalent to FirstChildElement(). - To get the first node, use FirstChild(). - */ - XMLElement* RootElement() { - return FirstChildElement(); - } - const XMLElement* RootElement() const { - return FirstChildElement(); - } - - /** Print the Document. If the Printer is not provided, it will - print to stdout. If you provide Printer, this can print to a file: - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Or you can use a printer to print to memory: - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - // printer.CStr() has a const char* to the XML - @endverbatim - */ - void Print( XMLPrinter* streamer=0 ) const; - virtual bool Accept( XMLVisitor* visitor ) const; - - /** - Create a new Element associated with - this Document. The memory for the Element - is managed by the Document. - */ - XMLElement* NewElement( const char* name ); - /** - Create a new Comment associated with - this Document. The memory for the Comment - is managed by the Document. - */ - XMLComment* NewComment( const char* comment ); - /** - Create a new Text associated with - this Document. The memory for the Text - is managed by the Document. - */ - XMLText* NewText( const char* text ); - /** - Create a new Declaration associated with - this Document. The memory for the object - is managed by the Document. - - If the 'text' param is null, the standard - declaration is used.: - @verbatim - - @endverbatim - */ - XMLDeclaration* NewDeclaration( const char* text=0 ); - /** - Create a new Unknown associated with - this Document. The memory for the object - is managed by the Document. - */ - XMLUnknown* NewUnknown( const char* text ); - - /** - Delete a node associated with this document. - It will be unlinked from the DOM. - */ - void DeleteNode( XMLNode* node ); - - void SetError( XMLError error, const char* str1, const char* str2 ); - - /// Return true if there was an error parsing the document. - bool Error() const { - return _errorID != XML_SUCCESS; - } - /// Return the errorID. - XMLError ErrorID() const { - return _errorID; - } - const char* ErrorName() const; - - /// Return a possibly helpful diagnostic location or string. - const char* GetErrorStr1() const { - return _errorStr1; - } - /// Return a possibly helpful secondary diagnostic location or string. - const char* GetErrorStr2() const { - return _errorStr2; - } - /// If there is an error, print it to stdout. - void PrintError() const; - - /// Clear the document, resetting it to the initial state. - void Clear(); - - // internal - char* Identify( char* p, XMLNode** node ); - - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { - return 0; - } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { - return false; - } - -private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported - - bool _writeBOM; - bool _processEntities; - XMLError _errorID; - Whitespace _whitespace; - const char* _errorStr1; - const char* _errorStr2; - char* _charBuffer; - - MemPoolT< sizeof(XMLElement) > _elementPool; - MemPoolT< sizeof(XMLAttribute) > _attributePool; - MemPoolT< sizeof(XMLText) > _textPool; - MemPoolT< sizeof(XMLComment) > _commentPool; - - static const char* _errorNames[XML_ERROR_COUNT]; - - void Parse(); -}; - - -/** - A XMLHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - XMLElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - XMLElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - XMLElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - XMLElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. XMLHandle addresses the verbosity - of such code. A XMLHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - XMLHandle docHandle( &document ); - XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - XMLHandle handleCopy = handle; - @endverbatim - - See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. -*/ -class TINYXML2_LIB XMLHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - XMLHandle( XMLNode* node ) { - _node = node; - } - /// Create a handle from a node. - XMLHandle( XMLNode& node ) { - _node = &node; - } - /// Copy constructor - XMLHandle( const XMLHandle& ref ) { - _node = ref._node; - } - /// Assignment - XMLHandle& operator=( const XMLHandle& ref ) { - _node = ref._node; - return *this; - } - - /// Get the first child of this handle. - XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); - } - /// Get the first child element of this handle. - XMLHandle FirstChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - /// Get the last child of this handle. - XMLHandle LastChild() { - return XMLHandle( _node ? _node->LastChild() : 0 ); - } - /// Get the last child element of this handle. - XMLHandle LastChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - /// Get the previous sibling of this handle. - XMLHandle PreviousSibling() { - return XMLHandle( _node ? _node->PreviousSibling() : 0 ); - } - /// Get the previous sibling element of this handle. - XMLHandle PreviousSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - /// Get the next sibling of this handle. - XMLHandle NextSibling() { - return XMLHandle( _node ? _node->NextSibling() : 0 ); - } - /// Get the next sibling element of this handle. - XMLHandle NextSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - /// Safe cast to XMLNode. This can return null. - XMLNode* ToNode() { - return _node; - } - /// Safe cast to XMLElement. This can return null. - XMLElement* ToElement() { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); - } - /// Safe cast to XMLText. This can return null. - XMLText* ToText() { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); - } - /// Safe cast to XMLUnknown. This can return null. - XMLUnknown* ToUnknown() { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); - } - /// Safe cast to XMLDeclaration. This can return null. - XMLDeclaration* ToDeclaration() { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); - } - -private: - XMLNode* _node; -}; - - -/** - A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the - same in all regards, except for the 'const' qualifiers. See XMLHandle for API. -*/ -class TINYXML2_LIB XMLConstHandle -{ -public: - XMLConstHandle( const XMLNode* node ) { - _node = node; - } - XMLConstHandle( const XMLNode& node ) { - _node = &node; - } - XMLConstHandle( const XMLConstHandle& ref ) { - _node = ref._node; - } - - XMLConstHandle& operator=( const XMLConstHandle& ref ) { - _node = ref._node; - return *this; - } - - const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); - } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); - } - const XMLConstHandle LastChild() const { - return XMLConstHandle( _node ? _node->LastChild() : 0 ); - } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); - } - const XMLConstHandle PreviousSibling() const { - return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); - } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); - } - const XMLConstHandle NextSibling() const { - return XMLConstHandle( _node ? _node->NextSibling() : 0 ); - } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); - } - - - const XMLNode* ToNode() const { - return _node; - } - const XMLElement* ToElement() const { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); - } - const XMLText* ToText() const { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); - } - const XMLUnknown* ToUnknown() const { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); - } - const XMLDeclaration* ToDeclaration() const { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); - } - -private: - const XMLNode* _node; -}; - - -/** - Printing functionality. The XMLPrinter gives you more - options than the XMLDocument::Print() method. - - It can: - -# Print to memory. - -# Print to a file you provide. - -# Print XML without a XMLDocument. - - Print to Memory - - @verbatim - XMLPrinter printer; - doc.Print( &printer ); - SomeFunction( printer.CStr() ); - @endverbatim - - Print to a File - - You provide the file pointer. - @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); - @endverbatim - - Print without a XMLDocument - - When loading, an XML parser is very useful. However, sometimes - when saving, it just gets in the way. The code is often set up - for streaming, and constructing the DOM is just overhead. - - The Printer supports the streaming case. The following code - prints out a trivially simple XML file without ever creating - an XML document. - - @verbatim - XMLPrinter printer( fp ); - printer.OpenElement( "foo" ); - printer.PushAttribute( "foo", "bar" ); - printer.CloseElement(); - @endverbatim -*/ -class TINYXML2_LIB XMLPrinter : public XMLVisitor -{ -public: - /** Construct the printer. If the FILE* is specified, - this will print to the FILE. Else it will print - to memory, and the result is available in CStr(). - If 'compact' is set to true, then output is created - with only required whitespace and newlines. - */ - XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); - virtual ~XMLPrinter() {} - - /** If streaming, write the BOM and declaration. */ - void PushHeader( bool writeBOM, bool writeDeclaration ); - /** If streaming, start writing an element. - The element must be closed with CloseElement() - */ - void OpenElement( const char* name, bool compactMode=false ); - /// If streaming, add an attribute to an open element. - void PushAttribute( const char* name, const char* value ); - void PushAttribute( const char* name, int value ); - void PushAttribute( const char* name, unsigned value ); - void PushAttribute(const char* name, int64_t value); - void PushAttribute( const char* name, bool value ); - void PushAttribute( const char* name, double value ); - /// If streaming, close the Element. - virtual void CloseElement( bool compactMode=false ); - - /// Add a text node. - void PushText( const char* text, bool cdata=false ); - /// Add a text node from an integer. - void PushText( int value ); - /// Add a text node from an unsigned. - void PushText( unsigned value ); - /// Add a text node from an unsigned. - void PushText(int64_t value); - /// Add a text node from a bool. - void PushText( bool value ); - /// Add a text node from a float. - void PushText( float value ); - /// Add a text node from a double. - void PushText( double value ); - - /// Add a comment - void PushComment( const char* comment ); - - void PushDeclaration( const char* value ); - void PushUnknown( const char* value ); - - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { - return true; - } - - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); - - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); - - /** - If in print to memory mode, return a pointer to - the XML file in memory. - */ - const char* CStr() const { - return _buffer.Mem(); - } - /** - If in print to memory mode, return the size - of the XML file in memory. (Note the size returned - includes the terminating null.) - */ - int CStrSize() const { - return _buffer.Size(); - } - /** - If in print to memory mode, reset the buffer to the - beginning. - */ - void ClearBuffer() { - _buffer.Clear(); - _buffer.Push(0); - } - -protected: - virtual bool CompactMode( const XMLElement& ) { return _compactMode; } - - /** Prints out the space before an element. You may override to change - the space and tabs used. A PrintSpace() override should call Print(). - */ - virtual void PrintSpace( int depth ); - void Print( const char* format, ... ); - - void SealElementIfJustOpened(); - bool _elementJustOpened; - DynArray< const char*, 10 > _stack; - -private: - void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. - - bool _firstElement; - FILE* _fp; - int _depth; - int _textDepth; - bool _processEntities; - bool _compactMode; - - enum { - ENTITY_RANGE = 64, - BUF_SIZE = 200 - }; - bool _entityFlag[ENTITY_RANGE]; - bool _restrictedEntityFlag[ENTITY_RANGE]; - - DynArray< char, 20 > _buffer; -}; - - -} // tinyxml2 - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -#endif // TINYXML2_INCLUDED +/* +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#ifndef TINYXML2_INCLUDED +#define TINYXML2_INCLUDED + +#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) +# include +# include +# include +# include +# include +# if defined(__PS3__) +# include +# endif +#else +# include +# include +# include +# include +# include +#endif +#include + +/* + TODO: intern strings instead of allocation. +*/ +/* + gcc: + g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe + + Formatting, Artistic Style: + AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h +*/ + +#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) +# ifndef DEBUG +# define DEBUG +# endif +#endif + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif + +#ifdef _WIN32 +# ifdef TINYXML2_EXPORT +# define TINYXML2_LIB __declspec(dllexport) +# elif defined(TINYXML2_IMPORT) +# define TINYXML2_LIB __declspec(dllimport) +# else +# define TINYXML2_LIB +# endif +#else +# define TINYXML2_LIB +#endif + + +#if defined(DEBUG) +# if defined(_MSC_VER) +# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like +# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } +# elif defined (ANDROID_NDK) +# include +# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } +# else +# include +# define TIXMLASSERT assert +# endif +#else +# define TIXMLASSERT( x ) {} +#endif + + +/* Versioning, past 1.0.14: + http://semver.org/ +*/ +static const int TIXML2_MAJOR_VERSION = 4; +static const int TIXML2_MINOR_VERSION = 0; +static const int TIXML2_PATCH_VERSION = 1; + +namespace tinyxml2 +{ +class XMLDocument; +class XMLElement; +class XMLAttribute; +class XMLComment; +class XMLText; +class XMLDeclaration; +class XMLUnknown; +class XMLPrinter; + +/* + A class that wraps strings. Normally stores the start and end + pointers into the XML file itself, and will apply normalization + and entity translation if actually read. Can also store (and memory + manage) a traditional char[] +*/ +class StrPair +{ +public: + enum { + NEEDS_ENTITY_PROCESSING = 0x01, + NEEDS_NEWLINE_NORMALIZATION = 0x02, + NEEDS_WHITESPACE_COLLAPSING = 0x04, + + TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_NAME = 0, + ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + COMMENT = NEEDS_NEWLINE_NORMALIZATION + }; + + StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + ~StrPair(); + + void Set( char* start, char* end, int flags ) { + Reset(); + _start = start; + _end = end; + _flags = flags | NEEDS_FLUSH; + } + + const char* GetStr(); + + bool Empty() const { + return _start == _end; + } + + void SetInternedStr( const char* str ) { + Reset(); + _start = const_cast(str); + } + + void SetStr( const char* str, int flags=0 ); + + char* ParseText( char* in, const char* endTag, int strFlags ); + char* ParseName( char* in ); + + void TransferTo( StrPair* other ); + +private: + void Reset(); + void CollapseWhitespace(); + + enum { + NEEDS_FLUSH = 0x100, + NEEDS_DELETE = 0x200 + }; + + int _flags; + char* _start; + char* _end; + + StrPair( const StrPair& other ); // not supported + void operator=( StrPair& other ); // not supported, use TransferTo() +}; + + +/* + A dynamic array of Plain Old Data. Doesn't support constructors, etc. + Has a small initial memory pool, so that low or no usage will not + cause a call to new/delete +*/ +template +class DynArray +{ +public: + DynArray() { + _mem = _pool; + _allocated = INITIAL_SIZE; + _size = 0; + } + + ~DynArray() { + if ( _mem != _pool ) { + delete [] _mem; + } + } + + void Clear() { + _size = 0; + } + + void Push( T t ) { + TIXMLASSERT( _size < INT_MAX ); + EnsureCapacity( _size+1 ); + _mem[_size++] = t; + } + + T* PushArr( int count ) { + TIXMLASSERT( count >= 0 ); + TIXMLASSERT( _size <= INT_MAX - count ); + EnsureCapacity( _size+count ); + T* ret = &_mem[_size]; + _size += count; + return ret; + } + + T Pop() { + TIXMLASSERT( _size > 0 ); + return _mem[--_size]; + } + + void PopArr( int count ) { + TIXMLASSERT( _size >= count ); + _size -= count; + } + + bool Empty() const { + return _size == 0; + } + + T& operator[](int i) { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + const T& operator[](int i) const { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + const T& PeekTop() const { + TIXMLASSERT( _size > 0 ); + return _mem[ _size - 1]; + } + + int Size() const { + TIXMLASSERT( _size >= 0 ); + return _size; + } + + int Capacity() const { + TIXMLASSERT( _allocated >= INITIAL_SIZE ); + return _allocated; + } + + const T* Mem() const { + TIXMLASSERT( _mem ); + return _mem; + } + + T* Mem() { + TIXMLASSERT( _mem ); + return _mem; + } + +private: + DynArray( const DynArray& ); // not supported + void operator=( const DynArray& ); // not supported + + void EnsureCapacity( int cap ) { + TIXMLASSERT( cap > 0 ); + if ( cap > _allocated ) { + TIXMLASSERT( cap <= INT_MAX / 2 ); + int newAllocated = cap * 2; + T* newMem = new T[newAllocated]; + memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs + if ( _mem != _pool ) { + delete [] _mem; + } + _mem = newMem; + _allocated = newAllocated; + } + } + + T* _mem; + T _pool[INITIAL_SIZE]; + int _allocated; // objects allocated + int _size; // number objects in use +}; + + +/* + Parent virtual class of a pool for fast allocation + and deallocation of objects. +*/ +class MemPool +{ +public: + MemPool() {} + virtual ~MemPool() {} + + virtual int ItemSize() const = 0; + virtual void* Alloc() = 0; + virtual void Free( void* ) = 0; + virtual void SetTracked() = 0; + virtual void Clear() = 0; +}; + + +/* + Template child class to create pools of the correct type. +*/ +template< int SIZE > +class MemPoolT : public MemPool +{ +public: + MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} + ~MemPoolT() { + Clear(); + } + + void Clear() { + // Delete the blocks. + while( !_blockPtrs.Empty()) { + Block* b = _blockPtrs.Pop(); + delete b; + } + _root = 0; + _currentAllocs = 0; + _nAllocs = 0; + _maxAllocs = 0; + _nUntracked = 0; + } + + virtual int ItemSize() const { + return SIZE; + } + int CurrentAllocs() const { + return _currentAllocs; + } + + virtual void* Alloc() { + if ( !_root ) { + // Need a new block. + Block* block = new Block(); + _blockPtrs.Push( block ); + + for( int i=0; ichunk[i].next = &block->chunk[i+1]; + } + block->chunk[COUNT-1].next = 0; + _root = block->chunk; + } + void* result = _root; + _root = _root->next; + + ++_currentAllocs; + if ( _currentAllocs > _maxAllocs ) { + _maxAllocs = _currentAllocs; + } + _nAllocs++; + _nUntracked++; + return result; + } + + virtual void Free( void* mem ) { + if ( !mem ) { + return; + } + --_currentAllocs; + Chunk* chunk = static_cast( mem ); +#ifdef DEBUG + memset( chunk, 0xfe, sizeof(Chunk) ); +#endif + chunk->next = _root; + _root = chunk; + } + void Trace( const char* name ) { + printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", + name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); + } + + void SetTracked() { + _nUntracked--; + } + + int Untracked() const { + return _nUntracked; + } + + // This number is perf sensitive. 4k seems like a good tradeoff on my machine. + // The test file is large, 170k. + // Release: VS2010 gcc(no opt) + // 1k: 4000 + // 2k: 4000 + // 4k: 3900 21000 + // 16k: 5200 + // 32k: 4300 + // 64k: 4000 21000 + enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private + +private: + MemPoolT( const MemPoolT& ); // not supported + void operator=( const MemPoolT& ); // not supported + + union Chunk { + Chunk* next; + char mem[SIZE]; + }; + struct Block { + Chunk chunk[COUNT]; + }; + DynArray< Block*, 10 > _blockPtrs; + Chunk* _root; + + int _currentAllocs; + int _nAllocs; + int _maxAllocs; + int _nUntracked; +}; + + + +/** + Implements the interface to the "Visitor pattern" (see the Accept() method.) + If you call the Accept() method, it requires being passed a XMLVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs + are simply called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its siblings will be visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the XMLDocument, although all nodes support visiting. + + You should never change the document from a callback. + + @sa XMLNode::Accept() +*/ +class TINYXML2_LIB XMLVisitor +{ +public: + virtual ~XMLVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { + return true; + } + /// Visit a document. + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + /// Visit an element. + virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { + return true; + } + /// Visit an element. + virtual bool VisitExit( const XMLElement& /*element*/ ) { + return true; + } + + /// Visit a declaration. + virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { + return true; + } + /// Visit a text node. + virtual bool Visit( const XMLText& /*text*/ ) { + return true; + } + /// Visit a comment node. + virtual bool Visit( const XMLComment& /*comment*/ ) { + return true; + } + /// Visit an unknown node. + virtual bool Visit( const XMLUnknown& /*unknown*/ ) { + return true; + } +}; + +// WARNING: must match XMLDocument::_errorNames[] +enum XMLError { + XML_SUCCESS = 0, + XML_NO_ATTRIBUTE, + XML_WRONG_ATTRIBUTE_TYPE, + XML_ERROR_FILE_NOT_FOUND, + XML_ERROR_FILE_COULD_NOT_BE_OPENED, + XML_ERROR_FILE_READ_ERROR, + XML_ERROR_ELEMENT_MISMATCH, + XML_ERROR_PARSING_ELEMENT, + XML_ERROR_PARSING_ATTRIBUTE, + XML_ERROR_IDENTIFYING_TAG, + XML_ERROR_PARSING_TEXT, + XML_ERROR_PARSING_CDATA, + XML_ERROR_PARSING_COMMENT, + XML_ERROR_PARSING_DECLARATION, + XML_ERROR_PARSING_UNKNOWN, + XML_ERROR_EMPTY_DOCUMENT, + XML_ERROR_MISMATCHED_ELEMENT, + XML_ERROR_PARSING, + XML_CAN_NOT_CONVERT_TEXT, + XML_NO_TEXT_NODE, + + XML_ERROR_COUNT +}; + + +/* + Utility functionality. +*/ +class XMLUtil +{ +public: + static const char* SkipWhiteSpace( const char* p ) { + TIXMLASSERT( p ); + while( IsWhiteSpace(*p) ) { + ++p; + } + TIXMLASSERT( p ); + return p; + } + static char* SkipWhiteSpace( char* p ) { + return const_cast( SkipWhiteSpace( const_cast(p) ) ); + } + + // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't + // correct, but simple, and usually works. + static bool IsWhiteSpace( char p ) { + return !IsUTF8Continuation(p) && isspace( static_cast(p) ); + } + + inline static bool IsNameStartChar( unsigned char ch ) { + if ( ch >= 128 ) { + // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() + return true; + } + if ( isalpha( ch ) ) { + return true; + } + return ch == ':' || ch == '_'; + } + + inline static bool IsNameChar( unsigned char ch ) { + return IsNameStartChar( ch ) + || isdigit( ch ) + || ch == '.' + || ch == '-'; + } + + inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { + if ( p == q ) { + return true; + } + return strncmp( p, q, nChar ) == 0; + } + + inline static bool IsUTF8Continuation( char p ) { + return ( p & 0x80 ) != 0; + } + + static const char* ReadBOM( const char* p, bool* hasBOM ); + // p is the starting location, + // the UTF-8 value of the entity will be placed in value, and length filled in. + static const char* GetCharacterRef( const char* p, char* value, int* length ); + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + + // converts primitive types to strings + static void ToStr( int v, char* buffer, int bufferSize ); + static void ToStr( unsigned v, char* buffer, int bufferSize ); + static void ToStr( bool v, char* buffer, int bufferSize ); + static void ToStr( float v, char* buffer, int bufferSize ); + static void ToStr( double v, char* buffer, int bufferSize ); + static void ToStr(int64_t v, char* buffer, int bufferSize); + + // converts strings to primitive types + static bool ToInt( const char* str, int* value ); + static bool ToUnsigned( const char* str, unsigned* value ); + static bool ToBool( const char* str, bool* value ); + static bool ToFloat( const char* str, float* value ); + static bool ToDouble( const char* str, double* value ); + static bool ToInt64(const char* str, int64_t* value); +}; + + +/** XMLNode is a base class for every object that is in the + XML Document Object Model (DOM), except XMLAttributes. + Nodes have siblings, a parent, and children which can + be navigated. A node is always in a XMLDocument. + The type of a XMLNode can be queried, and it can + be cast to its more defined type. + + A XMLDocument allocates memory for all its Nodes. + When the XMLDocument gets deleted, all its Nodes + will also be deleted. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + @endverbatim +*/ +class TINYXML2_LIB XMLNode +{ + friend class XMLDocument; + friend class XMLElement; +public: + + /// Get the XMLDocument that owns this XMLNode. + const XMLDocument* GetDocument() const { + TIXMLASSERT( _document ); + return _document; + } + /// Get the XMLDocument that owns this XMLNode. + XMLDocument* GetDocument() { + TIXMLASSERT( _document ); + return _document; + } + + /// Safely cast to an Element, or null. + virtual XMLElement* ToElement() { + return 0; + } + /// Safely cast to Text, or null. + virtual XMLText* ToText() { + return 0; + } + /// Safely cast to a Comment, or null. + virtual XMLComment* ToComment() { + return 0; + } + /// Safely cast to a Document, or null. + virtual XMLDocument* ToDocument() { + return 0; + } + /// Safely cast to a Declaration, or null. + virtual XMLDeclaration* ToDeclaration() { + return 0; + } + /// Safely cast to an Unknown, or null. + virtual XMLUnknown* ToUnknown() { + return 0; + } + + virtual const XMLElement* ToElement() const { + return 0; + } + virtual const XMLText* ToText() const { + return 0; + } + virtual const XMLComment* ToComment() const { + return 0; + } + virtual const XMLDocument* ToDocument() const { + return 0; + } + virtual const XMLDeclaration* ToDeclaration() const { + return 0; + } + virtual const XMLUnknown* ToUnknown() const { + return 0; + } + + /** The meaning of 'value' changes for the specific type. + @verbatim + Document: empty (NULL is returned, not an empty string) + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + const char* Value() const; + + /** Set the Value of an XML node. + @sa Value() + */ + void SetValue( const char* val, bool staticMem=false ); + + /// Get the parent of this node on the DOM. + const XMLNode* Parent() const { + return _parent; + } + + XMLNode* Parent() { + return _parent; + } + + /// Returns true if this node has no children. + bool NoChildren() const { + return !_firstChild; + } + + /// Get the first child node, or null if none exists. + const XMLNode* FirstChild() const { + return _firstChild; + } + + XMLNode* FirstChild() { + return _firstChild; + } + + /** Get the first child element, or optionally the first child + element with the specified name. + */ + const XMLElement* FirstChildElement( const char* name = 0 ) const; + + XMLElement* FirstChildElement( const char* name = 0 ) { + return const_cast(const_cast(this)->FirstChildElement( name )); + } + + /// Get the last child node, or null if none exists. + const XMLNode* LastChild() const { + return _lastChild; + } + + XMLNode* LastChild() { + return _lastChild; + } + + /** Get the last child element or optionally the last child + element with the specified name. + */ + const XMLElement* LastChildElement( const char* name = 0 ) const; + + XMLElement* LastChildElement( const char* name = 0 ) { + return const_cast(const_cast(this)->LastChildElement(name) ); + } + + /// Get the previous (left) sibling node of this node. + const XMLNode* PreviousSibling() const { + return _prev; + } + + XMLNode* PreviousSibling() { + return _prev; + } + + /// Get the previous (left) sibling element of this node, with an optionally supplied name. + const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; + + XMLElement* PreviousSiblingElement( const char* name = 0 ) { + return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); + } + + /// Get the next (right) sibling node of this node. + const XMLNode* NextSibling() const { + return _next; + } + + XMLNode* NextSibling() { + return _next; + } + + /// Get the next (right) sibling element of this node, with an optionally supplied name. + const XMLElement* NextSiblingElement( const char* name = 0 ) const; + + XMLElement* NextSiblingElement( const char* name = 0 ) { + return const_cast(const_cast(this)->NextSiblingElement( name ) ); + } + + /** + Add a child node as the last (right) child. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the node does not + belong to the same document. + */ + XMLNode* InsertEndChild( XMLNode* addThis ); + + XMLNode* LinkEndChild( XMLNode* addThis ) { + return InsertEndChild( addThis ); + } + /** + Add a child node as the first (left) child. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the node does not + belong to the same document. + */ + XMLNode* InsertFirstChild( XMLNode* addThis ); + /** + Add a node after the specified child node. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the afterThis node + is not a child of this node, or if the node does not + belong to the same document. + */ + XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); + + /** + Delete all the children of this node. + */ + void DeleteChildren(); + + /** + Delete a child of this node. + */ + void DeleteChild( XMLNode* node ); + + /** + Make a copy of this node, but not its children. + You may pass in a Document pointer that will be + the owner of the new Node. If the 'document' is + null, then the node returned will be allocated + from the current Document. (this->GetDocument()) + + Note: if called on a XMLDocument, this will return null. + */ + virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; + + /** + Test if 2 nodes are the same, but don't test children. + The 2 nodes do not need to be in the same Document. + + Note: if called on a XMLDocument, this will return false. + */ + virtual bool ShallowEqual( const XMLNode* compare ) const = 0; + + /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the XMLVisitor interface. + + This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + XMLPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( XMLVisitor* visitor ) const = 0; + + /** + Set user data into the XMLNode. TinyXML-2 in + no way processes or interprets user data. + It is initially 0. + */ + void SetUserData(void* userData) { _userData = userData; } + + /** + Get user data set into the XMLNode. TinyXML-2 in + no way processes or interprets user data. + It is initially 0. + */ + void* GetUserData() const { return _userData; } + +protected: + XMLNode( XMLDocument* ); + virtual ~XMLNode(); + + virtual char* ParseDeep( char*, StrPair* ); + + XMLDocument* _document; + XMLNode* _parent; + mutable StrPair _value; + + XMLNode* _firstChild; + XMLNode* _lastChild; + + XMLNode* _prev; + XMLNode* _next; + + void* _userData; + +private: + MemPool* _memPool; + void Unlink( XMLNode* child ); + static void DeleteNode( XMLNode* node ); + void InsertChildPreamble( XMLNode* insertThis ) const; + + XMLNode( const XMLNode& ); // not supported + XMLNode& operator=( const XMLNode& ); // not supported +}; + + +/** XML text. + + Note that a text node can have child element nodes, for example: + @verbatim + This is bold + @endverbatim + + A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCData() and query it with CData(). +*/ +class TINYXML2_LIB XMLText : public XMLNode +{ + friend class XMLDocument; +public: + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLText* ToText() { + return this; + } + virtual const XMLText* ToText() const { + return this; + } + + /// Declare whether this should be CDATA or standard text. + void SetCData( bool isCData ) { + _isCData = isCData; + } + /// Returns true if this is a CDATA text element. + bool CData() const { + return _isCData; + } + + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} + virtual ~XMLText() {} + + char* ParseDeep( char*, StrPair* endTag ); + +private: + bool _isCData; + + XMLText( const XMLText& ); // not supported + XMLText& operator=( const XMLText& ); // not supported +}; + + +/** An XML Comment. */ +class TINYXML2_LIB XMLComment : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLComment* ToComment() { + return this; + } + virtual const XMLComment* ToComment() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLComment( XMLDocument* doc ); + virtual ~XMLComment(); + + char* ParseDeep( char*, StrPair* endTag ); + +private: + XMLComment( const XMLComment& ); // not supported + XMLComment& operator=( const XMLComment& ); // not supported +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXML-2 will happily read or write files without a declaration, + however. + + The text of the declaration isn't interpreted. It is parsed + and written as a string. +*/ +class TINYXML2_LIB XMLDeclaration : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLDeclaration* ToDeclaration() { + return this; + } + virtual const XMLDeclaration* ToDeclaration() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLDeclaration( XMLDocument* doc ); + virtual ~XMLDeclaration(); + + char* ParseDeep( char*, StrPair* endTag ); + +private: + XMLDeclaration( const XMLDeclaration& ); // not supported + XMLDeclaration& operator=( const XMLDeclaration& ); // not supported +}; + + +/** Any tag that TinyXML-2 doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into XMLUnknowns. +*/ +class TINYXML2_LIB XMLUnknown : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLUnknown* ToUnknown() { + return this; + } + virtual const XMLUnknown* ToUnknown() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLUnknown( XMLDocument* doc ); + virtual ~XMLUnknown(); + + char* ParseDeep( char*, StrPair* endTag ); + +private: + XMLUnknown( const XMLUnknown& ); // not supported + XMLUnknown& operator=( const XMLUnknown& ); // not supported +}; + + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not XMLNodes. You may only query the + Next() attribute in a list. +*/ +class TINYXML2_LIB XMLAttribute +{ + friend class XMLElement; +public: + /// The name of the attribute. + const char* Name() const; + + /// The value of the attribute. + const char* Value() const; + + /// The next attribute in the list. + const XMLAttribute* Next() const { + return _next; + } + + /** IntValue interprets the attribute as an integer, and returns the value. + If the value isn't an integer, 0 will be returned. There is no error checking; + use QueryIntValue() if you need error checking. + */ + int IntValue() const { + int i = 0; + QueryIntValue(&i); + return i; + } + + int64_t Int64Value() const { + int64_t i = 0; + QueryInt64Value(&i); + return i; + } + + /// Query as an unsigned integer. See IntValue() + unsigned UnsignedValue() const { + unsigned i=0; + QueryUnsignedValue( &i ); + return i; + } + /// Query as a boolean. See IntValue() + bool BoolValue() const { + bool b=false; + QueryBoolValue( &b ); + return b; + } + /// Query as a double. See IntValue() + double DoubleValue() const { + double d=0; + QueryDoubleValue( &d ); + return d; + } + /// Query as a float. See IntValue() + float FloatValue() const { + float f=0; + QueryFloatValue( &f ); + return f; + } + + /** QueryIntValue interprets the attribute as an integer, and returns the value + in the provided parameter. The function will return XML_NO_ERROR on success, + and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. + */ + XMLError QueryIntValue( int* value ) const; + /// See QueryIntValue + XMLError QueryUnsignedValue( unsigned int* value ) const; + /// See QueryIntValue + XMLError QueryInt64Value(int64_t* value) const; + /// See QueryIntValue + XMLError QueryBoolValue( bool* value ) const; + /// See QueryIntValue + XMLError QueryDoubleValue( double* value ) const; + /// See QueryIntValue + XMLError QueryFloatValue( float* value ) const; + + /// Set the attribute to a string value. + void SetAttribute( const char* value ); + /// Set the attribute to value. + void SetAttribute( int value ); + /// Set the attribute to value. + void SetAttribute( unsigned value ); + /// Set the attribute to value. + void SetAttribute(int64_t value); + /// Set the attribute to value. + void SetAttribute( bool value ); + /// Set the attribute to value. + void SetAttribute( double value ); + /// Set the attribute to value. + void SetAttribute( float value ); + +private: + enum { BUF_SIZE = 200 }; + + XMLAttribute() : _next( 0 ), _memPool( 0 ) {} + virtual ~XMLAttribute() {} + + XMLAttribute( const XMLAttribute& ); // not supported + void operator=( const XMLAttribute& ); // not supported + void SetName( const char* name ); + + char* ParseDeep( char* p, bool processEntities ); + + mutable StrPair _name; + mutable StrPair _value; + XMLAttribute* _next; + MemPool* _memPool; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TINYXML2_LIB XMLElement : public XMLNode +{ + friend class XMLDocument; +public: + /// Get the name of an element (which is the Value() of the node.) + const char* Name() const { + return Value(); + } + /// Set the name of the element. + void SetName( const char* str, bool staticMem=false ) { + SetValue( str, staticMem ); + } + + virtual XMLElement* ToElement() { + return this; + } + virtual const XMLElement* ToElement() const { + return this; + } + virtual bool Accept( XMLVisitor* visitor ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none + exists. For example: + + @verbatim + const char* value = ele->Attribute( "foo" ); + @endverbatim + + The 'value' parameter is normally null. However, if specified, + the attribute will only be returned if the 'name' and 'value' + match. This allow you to write code: + + @verbatim + if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); + @endverbatim + + rather than: + @verbatim + if ( ele->Attribute( "foo" ) ) { + if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); + } + @endverbatim + */ + const char* Attribute( const char* name, const char* value=0 ) const; + + /** Given an attribute name, IntAttribute() returns the value + of the attribute interpreted as an integer. 0 will be + returned if there is an error. For a method with error + checking, see QueryIntAttribute() + */ + int IntAttribute( const char* name ) const { + int i=0; + QueryIntAttribute( name, &i ); + return i; + } + + /// See IntAttribute() + unsigned UnsignedAttribute( const char* name ) const { + unsigned i=0; + QueryUnsignedAttribute( name, &i ); + return i; + } + + /// See IntAttribute() + int64_t Int64Attribute(const char* name) const { + int64_t i = 0; + QueryInt64Attribute(name, &i); + return i; + } + + /// See IntAttribute() + bool BoolAttribute( const char* name ) const { + bool b=false; + QueryBoolAttribute( name, &b ); + return b; + } + /// See IntAttribute() + double DoubleAttribute( const char* name ) const { + double d=0; + QueryDoubleAttribute( name, &d ); + return d; + } + /// See IntAttribute() + float FloatAttribute( const char* name ) const { + float f=0; + QueryFloatAttribute( name, &f ); + return f; + } + + /** Given an attribute name, QueryIntAttribute() returns + XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + can't be performed, or XML_NO_ATTRIBUTE if the attribute + doesn't exist. If successful, the result of the conversion + will be written to 'value'. If not successful, nothing will + be written to 'value'. This allows you to provide default + value: + + @verbatim + int value = 10; + QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + @endverbatim + */ + XMLError QueryIntAttribute( const char* name, int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryIntValue( value ); + } + + /// See QueryIntAttribute() + XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryUnsignedValue( value ); + } + + /// See QueryIntAttribute() + XMLError QueryInt64Attribute(const char* name, int64_t* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { + return XML_NO_ATTRIBUTE; + } + return a->QueryInt64Value(value); + } + + /// See QueryIntAttribute() + XMLError QueryBoolAttribute( const char* name, bool* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryBoolValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryDoubleAttribute( const char* name, double* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryDoubleValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryFloatAttribute( const char* name, float* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryFloatValue( value ); + } + + + /** Given an attribute name, QueryAttribute() returns + XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + can't be performed, or XML_NO_ATTRIBUTE if the attribute + doesn't exist. It is overloaded for the primitive types, + and is a generally more convenient replacement of + QueryIntAttribute() and related functions. + + If successful, the result of the conversion + will be written to 'value'. If not successful, nothing will + be written to 'value'. This allows you to provide default + value: + + @verbatim + int value = 10; + QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + @endverbatim + */ + int QueryAttribute( const char* name, int* value ) const { + return QueryIntAttribute( name, value ); + } + + int QueryAttribute( const char* name, unsigned int* value ) const { + return QueryUnsignedAttribute( name, value ); + } + + int QueryAttribute(const char* name, int64_t* value) const { + return QueryInt64Attribute(name, value); + } + + int QueryAttribute( const char* name, bool* value ) const { + return QueryBoolAttribute( name, value ); + } + + int QueryAttribute( const char* name, double* value ) const { + return QueryDoubleAttribute( name, value ); + } + + int QueryAttribute( const char* name, float* value ) const { + return QueryFloatAttribute( name, value ); + } + + /// Sets the named attribute to value. + void SetAttribute( const char* name, const char* value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, int value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, unsigned value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + + /// Sets the named attribute to value. + void SetAttribute(const char* name, int64_t value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); + } + + /// Sets the named attribute to value. + void SetAttribute( const char* name, bool value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, double value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, float value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + + /** + Delete an attribute. + */ + void DeleteAttribute( const char* name ); + + /// Return the first attribute in the list. + const XMLAttribute* FirstAttribute() const { + return _rootAttribute; + } + /// Query a specific attribute in the list. + const XMLAttribute* FindAttribute( const char* name ) const; + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the XMLText child + and accessing it directly. + + If the first child of 'this' is a XMLText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + */ + const char* GetText() const; + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, SetText() is limited compared to creating an XMLText child + and mutating it directly. + + If the first child of 'this' is a XMLText, SetText() sets its value to + the given string, otherwise it will create a first child that is an XMLText. + + This is a convenient method for setting the text of simple contained text: + @verbatim + This is text + fooElement->SetText( "Hullaballoo!" ); + Hullaballoo! + @endverbatim + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then it will not change "This is text", but rather prefix it with a text element: + @verbatim + Hullaballoo!This is text + @endverbatim + + For this XML: + @verbatim + + @endverbatim + SetText() will generate + @verbatim + Hullaballoo! + @endverbatim + */ + void SetText( const char* inText ); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText( int value ); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText( unsigned value ); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText(int64_t value); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText( bool value ); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText( double value ); + /// Convenience method for setting text inside an element. See SetText() for important limitations. + void SetText( float value ); + + /** + Convenience method to query the value of a child text node. This is probably best + shown by example. Given you have a document is this form: + @verbatim + + 1 + 1.4 + + @endverbatim + + The QueryIntText() and similar functions provide a safe and easier way to get to the + "value" of x and y. + + @verbatim + int x = 0; + float y = 0; // types of x and y are contrived for example + const XMLElement* xElement = pointElement->FirstChildElement( "x" ); + const XMLElement* yElement = pointElement->FirstChildElement( "y" ); + xElement->QueryIntText( &x ); + yElement->QueryFloatText( &y ); + @endverbatim + + @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted + to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. + + */ + XMLError QueryIntText( int* ival ) const; + /// See QueryIntText() + XMLError QueryUnsignedText( unsigned* uval ) const; + /// See QueryIntText() + XMLError QueryInt64Text(int64_t* uval) const; + /// See QueryIntText() + XMLError QueryBoolText( bool* bval ) const; + /// See QueryIntText() + XMLError QueryDoubleText( double* dval ) const; + /// See QueryIntText() + XMLError QueryFloatText( float* fval ) const; + + // internal: + enum { + OPEN, // + CLOSED, // + CLOSING // + }; + int ClosingType() const { + return _closingType; + } + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + char* ParseDeep( char* p, StrPair* endTag ); + +private: + XMLElement( XMLDocument* doc ); + virtual ~XMLElement(); + XMLElement( const XMLElement& ); // not supported + void operator=( const XMLElement& ); // not supported + + XMLAttribute* FindAttribute( const char* name ) { + return const_cast(const_cast(this)->FindAttribute( name )); + } + XMLAttribute* FindOrCreateAttribute( const char* name ); + //void LinkAttribute( XMLAttribute* attrib ); + char* ParseAttributes( char* p ); + static void DeleteAttribute( XMLAttribute* attribute ); + + enum { BUF_SIZE = 200 }; + int _closingType; + // The attribute list is ordered; there is no 'lastAttribute' + // because the list needs to be scanned for dupes before adding + // a new attribute. + XMLAttribute* _rootAttribute; +}; + + +enum Whitespace { + PRESERVE_WHITESPACE, + COLLAPSE_WHITESPACE +}; + + +/** A Document binds together all the functionality. + It can be saved, loaded, and printed to the screen. + All Nodes are connected and allocated to a Document. + If the Document is deleted, all its Nodes are also deleted. +*/ +class TINYXML2_LIB XMLDocument : public XMLNode +{ + friend class XMLElement; +public: + /// constructor + XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); + ~XMLDocument(); + + virtual XMLDocument* ToDocument() { + TIXMLASSERT( this == _document ); + return this; + } + virtual const XMLDocument* ToDocument() const { + TIXMLASSERT( this == _document ); + return this; + } + + /** + Parse an XML file from a character string. + Returns XML_NO_ERROR (0) on success, or + an errorID. + + You may optionally pass in the 'nBytes', which is + the number of bytes which will be parsed. If not + specified, TinyXML-2 will assume 'xml' points to a + null terminated string. + */ + XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); + + /** + Load an XML file from disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( const char* filename ); + + /** + Load an XML file from disk. You are responsible + for providing and closing the FILE*. + + NOTE: The file should be opened as binary ("rb") + not text in order for TinyXML-2 to correctly + do newline normalization. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( FILE* ); + + /** + Save the XML file to disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( const char* filename, bool compact = false ); + + /** + Save the XML file to disk. You are responsible + for providing and closing the FILE*. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( FILE* fp, bool compact = false ); + + bool ProcessEntities() const { + return _processEntities; + } + Whitespace WhitespaceMode() const { + return _whitespace; + } + + /** + Returns true if this document has a leading Byte Order Mark of UTF8. + */ + bool HasBOM() const { + return _writeBOM; + } + /** Sets whether to write the BOM when writing the file. + */ + void SetBOM( bool useBOM ) { + _writeBOM = useBOM; + } + + /** Return the root element of DOM. Equivalent to FirstChildElement(). + To get the first node, use FirstChild(). + */ + XMLElement* RootElement() { + return FirstChildElement(); + } + const XMLElement* RootElement() const { + return FirstChildElement(); + } + + /** Print the Document. If the Printer is not provided, it will + print to stdout. If you provide Printer, this can print to a file: + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Or you can use a printer to print to memory: + @verbatim + XMLPrinter printer; + doc.Print( &printer ); + // printer.CStr() has a const char* to the XML + @endverbatim + */ + void Print( XMLPrinter* streamer=0 ) const; + virtual bool Accept( XMLVisitor* visitor ) const; + + /** + Create a new Element associated with + this Document. The memory for the Element + is managed by the Document. + */ + XMLElement* NewElement( const char* name ); + /** + Create a new Comment associated with + this Document. The memory for the Comment + is managed by the Document. + */ + XMLComment* NewComment( const char* comment ); + /** + Create a new Text associated with + this Document. The memory for the Text + is managed by the Document. + */ + XMLText* NewText( const char* text ); + /** + Create a new Declaration associated with + this Document. The memory for the object + is managed by the Document. + + If the 'text' param is null, the standard + declaration is used.: + @verbatim + + @endverbatim + */ + XMLDeclaration* NewDeclaration( const char* text=0 ); + /** + Create a new Unknown associated with + this Document. The memory for the object + is managed by the Document. + */ + XMLUnknown* NewUnknown( const char* text ); + + /** + Delete a node associated with this document. + It will be unlinked from the DOM. + */ + void DeleteNode( XMLNode* node ); + + void SetError( XMLError error, const char* str1, const char* str2 ); + + /// Return true if there was an error parsing the document. + bool Error() const { + return _errorID != XML_SUCCESS; + } + /// Return the errorID. + XMLError ErrorID() const { + return _errorID; + } + const char* ErrorName() const; + + /// Return a possibly helpful diagnostic location or string. + const char* GetErrorStr1() const { + return _errorStr1; + } + /// Return a possibly helpful secondary diagnostic location or string. + const char* GetErrorStr2() const { + return _errorStr2; + } + /// If there is an error, print it to stdout. + void PrintError() const; + + /// Clear the document, resetting it to the initial state. + void Clear(); + + // internal + char* Identify( char* p, XMLNode** node ); + + virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { + return 0; + } + virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + return false; + } + +private: + XMLDocument( const XMLDocument& ); // not supported + void operator=( const XMLDocument& ); // not supported + + bool _writeBOM; + bool _processEntities; + XMLError _errorID; + Whitespace _whitespace; + const char* _errorStr1; + const char* _errorStr2; + char* _charBuffer; + + MemPoolT< sizeof(XMLElement) > _elementPool; + MemPoolT< sizeof(XMLAttribute) > _attributePool; + MemPoolT< sizeof(XMLText) > _textPool; + MemPoolT< sizeof(XMLComment) > _commentPool; + + static const char* _errorNames[XML_ERROR_COUNT]; + + void Parse(); +}; + + +/** + A XMLHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + XMLElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + XMLElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + XMLElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + XMLElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. XMLHandle addresses the verbosity + of such code. A XMLHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + XMLHandle docHandle( &document ); + XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + XMLHandle handleCopy = handle; + @endverbatim + + See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. +*/ +class TINYXML2_LIB XMLHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + XMLHandle( XMLNode* node ) { + _node = node; + } + /// Create a handle from a node. + XMLHandle( XMLNode& node ) { + _node = &node; + } + /// Copy constructor + XMLHandle( const XMLHandle& ref ) { + _node = ref._node; + } + /// Assignment + XMLHandle& operator=( const XMLHandle& ref ) { + _node = ref._node; + return *this; + } + + /// Get the first child of this handle. + XMLHandle FirstChild() { + return XMLHandle( _node ? _node->FirstChild() : 0 ); + } + /// Get the first child element of this handle. + XMLHandle FirstChildElement( const char* name = 0 ) { + return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 ); + } + /// Get the last child of this handle. + XMLHandle LastChild() { + return XMLHandle( _node ? _node->LastChild() : 0 ); + } + /// Get the last child element of this handle. + XMLHandle LastChildElement( const char* name = 0 ) { + return XMLHandle( _node ? _node->LastChildElement( name ) : 0 ); + } + /// Get the previous sibling of this handle. + XMLHandle PreviousSibling() { + return XMLHandle( _node ? _node->PreviousSibling() : 0 ); + } + /// Get the previous sibling element of this handle. + XMLHandle PreviousSiblingElement( const char* name = 0 ) { + return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); + } + /// Get the next sibling of this handle. + XMLHandle NextSibling() { + return XMLHandle( _node ? _node->NextSibling() : 0 ); + } + /// Get the next sibling element of this handle. + XMLHandle NextSiblingElement( const char* name = 0 ) { + return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + } + + /// Safe cast to XMLNode. This can return null. + XMLNode* ToNode() { + return _node; + } + /// Safe cast to XMLElement. This can return null. + XMLElement* ToElement() { + return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + } + /// Safe cast to XMLText. This can return null. + XMLText* ToText() { + return ( ( _node == 0 ) ? 0 : _node->ToText() ); + } + /// Safe cast to XMLUnknown. This can return null. + XMLUnknown* ToUnknown() { + return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + } + /// Safe cast to XMLDeclaration. This can return null. + XMLDeclaration* ToDeclaration() { + return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + } + +private: + XMLNode* _node; +}; + + +/** + A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the + same in all regards, except for the 'const' qualifiers. See XMLHandle for API. +*/ +class TINYXML2_LIB XMLConstHandle +{ +public: + XMLConstHandle( const XMLNode* node ) { + _node = node; + } + XMLConstHandle( const XMLNode& node ) { + _node = &node; + } + XMLConstHandle( const XMLConstHandle& ref ) { + _node = ref._node; + } + + XMLConstHandle& operator=( const XMLConstHandle& ref ) { + _node = ref._node; + return *this; + } + + const XMLConstHandle FirstChild() const { + return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + } + const XMLConstHandle FirstChildElement( const char* name = 0 ) const { + return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); + } + const XMLConstHandle LastChild() const { + return XMLConstHandle( _node ? _node->LastChild() : 0 ); + } + const XMLConstHandle LastChildElement( const char* name = 0 ) const { + return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); + } + const XMLConstHandle PreviousSibling() const { + return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); + } + const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { + return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); + } + const XMLConstHandle NextSibling() const { + return XMLConstHandle( _node ? _node->NextSibling() : 0 ); + } + const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { + return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + } + + + const XMLNode* ToNode() const { + return _node; + } + const XMLElement* ToElement() const { + return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + } + const XMLText* ToText() const { + return ( ( _node == 0 ) ? 0 : _node->ToText() ); + } + const XMLUnknown* ToUnknown() const { + return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + } + const XMLDeclaration* ToDeclaration() const { + return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + } + +private: + const XMLNode* _node; +}; + + +/** + Printing functionality. The XMLPrinter gives you more + options than the XMLDocument::Print() method. + + It can: + -# Print to memory. + -# Print to a file you provide. + -# Print XML without a XMLDocument. + + Print to Memory + + @verbatim + XMLPrinter printer; + doc.Print( &printer ); + SomeFunction( printer.CStr() ); + @endverbatim + + Print to a File + + You provide the file pointer. + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Print without a XMLDocument + + When loading, an XML parser is very useful. However, sometimes + when saving, it just gets in the way. The code is often set up + for streaming, and constructing the DOM is just overhead. + + The Printer supports the streaming case. The following code + prints out a trivially simple XML file without ever creating + an XML document. + + @verbatim + XMLPrinter printer( fp ); + printer.OpenElement( "foo" ); + printer.PushAttribute( "foo", "bar" ); + printer.CloseElement(); + @endverbatim +*/ +class TINYXML2_LIB XMLPrinter : public XMLVisitor +{ +public: + /** Construct the printer. If the FILE* is specified, + this will print to the FILE. Else it will print + to memory, and the result is available in CStr(). + If 'compact' is set to true, then output is created + with only required whitespace and newlines. + */ + XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); + virtual ~XMLPrinter() {} + + /** If streaming, write the BOM and declaration. */ + void PushHeader( bool writeBOM, bool writeDeclaration ); + /** If streaming, start writing an element. + The element must be closed with CloseElement() + */ + void OpenElement( const char* name, bool compactMode=false ); + /// If streaming, add an attribute to an open element. + void PushAttribute( const char* name, const char* value ); + void PushAttribute( const char* name, int value ); + void PushAttribute( const char* name, unsigned value ); + void PushAttribute(const char* name, int64_t value); + void PushAttribute( const char* name, bool value ); + void PushAttribute( const char* name, double value ); + /// If streaming, close the Element. + virtual void CloseElement( bool compactMode=false ); + + /// Add a text node. + void PushText( const char* text, bool cdata=false ); + /// Add a text node from an integer. + void PushText( int value ); + /// Add a text node from an unsigned. + void PushText( unsigned value ); + /// Add a text node from an unsigned. + void PushText(int64_t value); + /// Add a text node from a bool. + void PushText( bool value ); + /// Add a text node from a float. + void PushText( float value ); + /// Add a text node from a double. + void PushText( double value ); + + /// Add a comment + void PushComment( const char* comment ); + + void PushDeclaration( const char* value ); + void PushUnknown( const char* value ); + + virtual bool VisitEnter( const XMLDocument& /*doc*/ ); + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); + virtual bool VisitExit( const XMLElement& element ); + + virtual bool Visit( const XMLText& text ); + virtual bool Visit( const XMLComment& comment ); + virtual bool Visit( const XMLDeclaration& declaration ); + virtual bool Visit( const XMLUnknown& unknown ); + + /** + If in print to memory mode, return a pointer to + the XML file in memory. + */ + const char* CStr() const { + return _buffer.Mem(); + } + /** + If in print to memory mode, return the size + of the XML file in memory. (Note the size returned + includes the terminating null.) + */ + int CStrSize() const { + return _buffer.Size(); + } + /** + If in print to memory mode, reset the buffer to the + beginning. + */ + void ClearBuffer() { + _buffer.Clear(); + _buffer.Push(0); + } + +protected: + virtual bool CompactMode( const XMLElement& ) { return _compactMode; } + + /** Prints out the space before an element. You may override to change + the space and tabs used. A PrintSpace() override should call Print(). + */ + virtual void PrintSpace( int depth ); + void Print( const char* format, ... ); + + void SealElementIfJustOpened(); + bool _elementJustOpened; + DynArray< const char*, 10 > _stack; + +private: + void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. + + bool _firstElement; + FILE* _fp; + int _depth; + int _textDepth; + bool _processEntities; + bool _compactMode; + + enum { + ENTITY_RANGE = 64, + BUF_SIZE = 200 + }; + bool _entityFlag[ENTITY_RANGE]; + bool _restrictedEntityFlag[ENTITY_RANGE]; + + DynArray< char, 20 > _buffer; +}; + + +} // tinyxml2 + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#endif // TINYXML2_INCLUDED diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor-annotate.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor-annotate.h index 7d18dcbefd..f5ba448584 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor-annotate.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor-annotate.h @@ -1,528 +1,528 @@ -/* ======================================================================== - * - * SAMPLE SOURCE CODE - SUBJECT TO THE TERMS OF END-USER LICENSE AGREEMENT - * FOR INTEL(R) ADVISOR XE 2016. - * - * Copyright (c) 2009-2015 Intel Corporation. All rights reserved. - * - * THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTIES, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OF INTELLECTUAL - * PROPERTY RIGHTS. - * - * ======================================================================== - */ - -/* This file defines macros and inline functions used by - * the Intel(R) Advisor XE "Dependencies Modeling" and - * "Suitability Modeling" analysis, and are in described - * in the "Annotations" section of the help. - * - * Expansion Options - * - * There are several options you can used to control how advisor-annotate.h - * is included. To use these, define the option prior to including - * advisor-annotate.h. e.g. - * #define ANNOTATE_DECLARE - * #include "advisor-annotate.h" - * - * Controlling inclusion of windows.h - * - * windows.h is included for declarations for LoadLibrary, GetProcSymbol, - * but this can have interactions with user code, such as conflicting - * definitions of types. There are two general approaches to work around - * this if this triggers problems building your application: - * - * 1. Reduce the amount declared by windows.h by using the following: - * #define NOMINMAX - * #define WIN32_LEAN_AND_MEAN - * prior to including advisor-annotate.h in your code. - * The first avoids problems with STL min/max in particular - * This is sufficient in some cases, and may be the easiest. - * - * 2. Use a declaration/definition approach, where all uses of advisor-annotate.h - * other than one, generate a set of declarations, and windows.h is only - * needed in a single implementation module. In this model, all includes - * of advisor-annotate.h except one specify ANNOTATE_DECLARE, which causes - * advisor-annotate.h to declare an external routine, and not include - * windows.h. A final include of advisor-annotate.h than specifies - * ANNOTATE_DEFINE, to actually define the global routine to resolve - * the external reference. This one include is the only one that winds up - * using windows.h. If necessary, this can be placed in a file by itself. - * - * An example using this mechanism: - * - * ... - * // Some header(s) used in places in your system where you want - * // to be able to use annotations - * #define ANNOTATE_DECLARE - * #include "advisor-annotate.h" - * ... - * // annotation uses - * ANNOTATE_SITE_BEGIN(MySite1) - * ... - * ANNOTATE_SITE_END(MySite1) - * ... - * - * ... - * // A single implementation file (.cpp/.cxx) causes windows.h - * // to be included, and the support routine to be defined as a - * // global routine called from the various annotation uses. - * #define ANNOTATE_DEFINE - * #include "advisor-annotate.h" - * ... - * - * Null expansion of annotations - * - * Some people may find it useful to have no expansion for annotations, - * if you have a project that you want to build without any annotation - * effects at all. (e.g. if you have a project where you want to have - * some annotations in a shared source pool, but only particular - * developers are actually building with the annotations enabled.) - * Defining ANNOTATE_EXPAND_NULL avoids declaring comdat routines, - * and avoids any textual expansion for annotation macros. - */ - -#ifndef _ADVISOR_ANNOTATE_H_ -#define _ADVISOR_ANNOTATE_H_ - -/* Version of the annotations. - * The presence of this macro serves to idetify the annotation definition - * file and the form of annotations. - */ -#define INTEL_ADVISOR_ANNOTATION_VERSION 1.0 - -#ifdef ANNOTATE_EXPAND_NULL - -#define ANNOTATE_SITE_BEGIN(_SITE) -#define ANNOTATE_SITE_END(...) -#define ANNOTATE_TASK_BEGIN(_TASK) -#define ANNOTATE_TASK_END(...) -#define ANNOTATE_ITERATION_TASK(_TASK) -#define ANNOTATE_LOCK_ACQUIRE(_ADDR) -#define ANNOTATE_LOCK_RELEASE(_ADDR) -#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) -#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) -#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) -#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) -#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) -#define ANNOTATE_CLEAR_USES(_ADDR) -#define ANNOTATE_DISABLE_OBSERVATION_PUSH -#define ANNOTATE_DISABLE_OBSERVATION_POP -#define ANNOTATE_DISABLE_COLLECTION_PUSH -#define ANNOTATE_DISABLE_COLLECTION_POP -#define ANNOTATE_AGGREGATE_TASK(_COUNT) - -#else /* ANNOTATE_EXPAND_NULL */ - -#if defined(WIN32) || defined(_WIN32) - -#define ANNOTATEAPI __cdecl - -#ifndef ANNOTATE_DECLARE -#include - -typedef HMODULE lib_t; - -#define __itt_get_proc(lib, name) GetProcAddress(lib, name) -#define __itt_load_lib(name) LoadLibraryA(name) -#define __itt_unload_lib(handle) FreeLibrary(handle) -#define __itt_system_error() (int)GetLastError() -#endif /* ANNOTATE_DECLARE */ - -#else /* defined(WIN32) || defined(_WIN32) */ - -#if defined _M_IX86 || __i386__ -# define ANNOTATEAPI __attribute__ ((cdecl)) -#else -# define ANNOTATEAPI /* actual only on x86 platform */ -#endif - - -#ifndef ANNOTATE_DECLARE -#include -#include -#include - -typedef void* lib_t; - -#define __itt_get_proc(lib, name) dlsym(lib, name) -#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) -#define __itt_unload_lib(handle) dlclose(handle) -#define __itt_system_error() errno -#endif /* ANNOTATE_DECLARE */ - -#endif /* defined(WIN32) || defined(_WIN32) */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _ITTNOTIFY_H_ - -/* Handles for sites and tasks. - */ -typedef void* __itt_model_site; /* handle for lexical site */ -typedef void* __itt_model_site_instance; /* handle for dynamic instance */ -typedef void* __itt_model_task; /* handle for lexical site */ -typedef void* __itt_model_task_instance; /* handle for dynamic instance */ - -typedef enum { - __itt_model_disable_observation, - __itt_model_disable_collection -} __itt_model_disable; - -#endif /* _ITTNOTIFY_H_ */ - -/*** Use the routines in libittnotify.dll. ***/ - -/* Basic approach: - * For the case of calling the dll, there is an __annotate_routine function - * declared as a comdat in each compilation unit with annotations present. - * That routine in turn has an internal static structure that is initialized - * once to contain the address of functions occuring in libittnotify.dll. - * Each time an annotation macro is invoked, that causes a call to the - * __annotate_routine function to get addresses of the routines, followed - * by calling the specific routine, provided the address is non-null. - */ - -/* This set of macros generates calls that are part of application images, - * which call the __itt_model_xxx routines in the dynamically loaded - * libittnotify.dll. - */ -#ifndef _ITTNOTIFY_H_ -#define ITT_NOTIFY_DECL(_text) _text -#else -#define ITT_NOTIFY_DECL(_text) -#endif - -/* For C++, a static initialization is used */ -#if defined(__cplusplus) && defined(WIN32) -#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_s -#else -#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_init( __annotate_routines() ) -#endif /* __cplusplus */ - - -#define _ANNOTATE_DECLARE_0(_BASENAME) \ -typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ -static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { }; \ -ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) - -#define _ANNOTATE_DECLARE_0_INT(_BASENAME) \ -typedef int (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ -static __inline int ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { return 0; }; \ -ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) - -#define _ANNOTATE_CALL_0(_BASENAME) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(); } - -#define _ANNOTATE_DECLARE_1(_BASENAME, _P1TYPE) \ -typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1); \ -static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1) { (void)p1; }; \ -ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1); ) - -#define _ANNOTATE_CALL_1(_BASENAME, _P1) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(_P1); } - -#define _ANNOTATE_DECLARE_2(_BASENAME, _P1TYPE, _P2TYPE) \ -typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1, _P2TYPE p2); \ -static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1, _P2TYPE p2) { (void)p1; (void)p2; }; \ -ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1, _P2TYPE p2); ) - -#define _ANNOTATE_CALL_2(_BASENAME, _P1, _P2) { _ANNOTATE_ROUTINES_ADDR->_BASENAME((_P1), (_P2)); } - -/*** Declare routines appropriately based on usage style ***/ - -/* Depending on above, this will either expand to comdats that are - * used directly, or comdats that call routines in libittnotify.dll - */ -_ANNOTATE_DECLARE_1(site_beginA, const char *) -_ANNOTATE_DECLARE_0(site_end_2) -_ANNOTATE_DECLARE_1(task_beginA, const char *) -_ANNOTATE_DECLARE_0(task_end_2) -_ANNOTATE_DECLARE_1(iteration_taskA, const char *) -_ANNOTATE_DECLARE_1(lock_acquire_2, void *) -_ANNOTATE_DECLARE_1(lock_release_2, void *) -_ANNOTATE_DECLARE_2(record_allocation, void *, size_t) -_ANNOTATE_DECLARE_1(record_deallocation, void *) -_ANNOTATE_DECLARE_2(induction_uses, void *, size_t) -_ANNOTATE_DECLARE_2(reduction_uses, void *, size_t) -_ANNOTATE_DECLARE_2(observe_uses, void *, size_t) -_ANNOTATE_DECLARE_1(clear_uses, void *) -_ANNOTATE_DECLARE_1(disable_push, __itt_model_disable) -_ANNOTATE_DECLARE_0(disable_pop) -_ANNOTATE_DECLARE_1(aggregate_task, size_t) -_ANNOTATE_DECLARE_0_INT(is_collection_disabled) - -/* All of the symbols potentially in the library - */ -struct __annotate_routines { - volatile int initialized; - __annotate_site_beginA_t site_beginA; - __annotate_site_end_2_t site_end_2; - __annotate_task_beginA_t task_beginA; - __annotate_task_end_2_t task_end_2; - __annotate_iteration_taskA_t iteration_taskA; - __annotate_lock_acquire_2_t lock_acquire_2; - __annotate_lock_release_2_t lock_release_2; - __annotate_record_allocation_t record_allocation; - __annotate_record_deallocation_t record_deallocation; - __annotate_induction_uses_t induction_uses; - __annotate_reduction_uses_t reduction_uses; - __annotate_observe_uses_t observe_uses; - __annotate_clear_uses_t clear_uses; - __annotate_disable_push_t disable_push; - __annotate_disable_pop_t disable_pop; - __annotate_aggregate_task_t aggregate_task; - __annotate_is_collection_disabled_t is_collection_disabled; -}; - -/* This comdat-ed routine means there is a single instance of the function pointer - * structure per image - */ -static __inline struct __annotate_routines* __annotate_routines() -{ - static struct __annotate_routines __annotate_routines; - return &__annotate_routines; -} - -/* This routine is called to get the address of an initialized - * set of function pointers for the annotation routines. - */ - -#ifdef ANNOTATE_DECLARE -extern struct __annotate_routines* ANNOTATEAPI __annotate_routines_init(struct __annotate_routines* itt); -#else -#ifdef ANNOTATE_DEFINE - /* */ -#else - static __inline -#endif -struct __annotate_routines* -ANNOTATEAPI -__annotate_routines_init(struct __annotate_routines* itt) { - - if (itt->initialized) { - return itt; - } else { - - /* Initialized by first invocation - * This assumes that the code here can be executed successfully - * by multiple threads, should that ever happen. - */ - int do_disable_pop = 0; -#if !(defined(WIN32) || defined(_WIN32)) - char* lib_name = NULL; -#endif - - lib_t itt_notify = 0; - -#if defined(WIN32) || defined(_WIN32) - itt_notify = __itt_load_lib("libittnotify.dll"); -#else - if (sizeof(void*) > 4) { - lib_name = getenv("INTEL_LIBITTNOTIFY64"); - } else { - lib_name = getenv("INTEL_LIBITTNOTIFY32"); - } - if (lib_name) { - itt_notify = __itt_load_lib(lib_name); - } -#endif - if (itt_notify != NULL) { - - /* The static variables initialized and itt are reported as race conditions - * or inconsistent lock usage by Dependencies Modeling in some obscure cases - * involving multiple dlls. Ignoring this initialization phase gets rid of - * this problem. - */ - __annotate_disable_push_t disable_push; - __annotate_is_collection_disabled_t is_collection_disabled; - disable_push = (__annotate_disable_push_t) __itt_get_proc(itt_notify, "__itt_model_disable_push"); - is_collection_disabled = (__annotate_is_collection_disabled_t) __itt_get_proc(itt_notify, "__itt_model_is_collection_disabled"); - if (disable_push) { - if ( ! (is_collection_disabled && is_collection_disabled()) ) - { - // disable collection only if it is not disabled already (for example, started paused) - disable_push(__itt_model_disable_observation); - do_disable_pop = 1; - } - } - itt->site_beginA = (__annotate_site_beginA_t) __itt_get_proc(itt_notify, "__itt_model_site_beginA"); - itt->site_end_2 = (__annotate_site_end_2_t) __itt_get_proc(itt_notify, "__itt_model_site_end_2"); - itt->task_beginA = (__annotate_task_beginA_t) __itt_get_proc(itt_notify, "__itt_model_task_beginA"); - itt->task_end_2 = (__annotate_task_end_2_t) __itt_get_proc(itt_notify, "__itt_model_task_end_2"); - itt->iteration_taskA = (__annotate_iteration_taskA_t) __itt_get_proc(itt_notify, "__itt_model_iteration_taskA"); - itt->lock_acquire_2 = (__annotate_lock_acquire_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_acquire_2"); - itt->lock_release_2 = (__annotate_lock_release_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_release_2"); - itt->record_allocation = (__annotate_record_allocation_t) __itt_get_proc(itt_notify, "__itt_model_record_allocation"); - itt->record_deallocation = (__annotate_record_deallocation_t)__itt_get_proc(itt_notify, "__itt_model_record_deallocation"); - itt->induction_uses = (__annotate_induction_uses_t) __itt_get_proc(itt_notify, "__itt_model_induction_uses"); - itt->reduction_uses = (__annotate_reduction_uses_t) __itt_get_proc(itt_notify, "__itt_model_reduction_uses"); - itt->observe_uses = (__annotate_observe_uses_t) __itt_get_proc(itt_notify, "__itt_model_observe_uses"); - itt->clear_uses = (__annotate_clear_uses_t) __itt_get_proc(itt_notify, "__itt_model_clear_uses"); - itt->disable_push = disable_push; - itt->disable_pop = (__annotate_disable_pop_t) __itt_get_proc(itt_notify, "__itt_model_disable_pop"); - itt->aggregate_task = (__annotate_aggregate_task_t) __itt_get_proc(itt_notify, "__itt_model_aggregate_task"); - itt->is_collection_disabled = is_collection_disabled; - } - /* No-op routine for any that didn't get resolved */ - if (!itt->site_beginA) itt->site_beginA = __annotate_site_beginA_t_nop; - if (!itt->site_end_2) itt->site_end_2 = __annotate_site_end_2_t_nop; - if (!itt->task_beginA) itt->task_beginA = __annotate_task_beginA_t_nop; - if (!itt->task_end_2) itt->task_end_2 = __annotate_task_end_2_t_nop; - if (!itt->iteration_taskA) itt->iteration_taskA = __annotate_iteration_taskA_t_nop; - if (!itt->lock_acquire_2) itt->lock_acquire_2 = __annotate_lock_acquire_2_t_nop; - if (!itt->lock_release_2) itt->lock_release_2 = __annotate_lock_release_2_t_nop; - if (!itt->record_allocation) itt->record_allocation = __annotate_record_allocation_t_nop; - if (!itt->record_deallocation) itt->record_deallocation=__annotate_record_deallocation_t_nop; - if (!itt->induction_uses) itt->induction_uses = __annotate_induction_uses_t_nop; - if (!itt->reduction_uses) itt->reduction_uses = __annotate_reduction_uses_t_nop; - if (!itt->observe_uses) itt->observe_uses = __annotate_observe_uses_t_nop; - if (!itt->clear_uses) itt->clear_uses = __annotate_clear_uses_t_nop; - if (!itt->disable_push) itt->disable_push = __annotate_disable_push_t_nop; - if (!itt->disable_pop) itt->disable_pop = __annotate_disable_pop_t_nop; - if (!itt->aggregate_task) itt->aggregate_task = __annotate_aggregate_task_t_nop; - if (!itt->is_collection_disabled) itt->is_collection_disabled = __annotate_is_collection_disabled_t_nop; - - itt->initialized = 1; - - if (do_disable_pop) { - itt->disable_pop(); - } - } - return itt; -} -#endif /* ANNOTATE_DECLARE */ - -/* For C++ only, use a class to force initialization */ - -#if defined(__cplusplus) && defined(WIN32) -/* Force one-shot initialization so individual calls don't need it */ -static struct __annotate_routines* __annotate_routines_s = __annotate_routines_init( __annotate_routines() ); -#endif - -/* For C++, allow the Annotate::SiteBegin(x) form. For Windows CLR, this is the default - * expansion for the macros (with no-inline) to get the best call stacks in the tools. */ -#if defined(__cplusplus) -/* Ensure this code is managed and non-inlinable */ -#if defined(WIN32) && defined(__CLR_VER) -#pragma managed(push, on) -#define ANNOTATE_CLR_NOINLINE __declspec(noinline) -#else -#define ANNOTATE_CLR_NOINLINE -#endif -class Annotate { -public: - static ANNOTATE_CLR_NOINLINE void SiteBegin(const char* site) { _ANNOTATE_ROUTINES_ADDR->site_beginA(site); } - static ANNOTATE_CLR_NOINLINE void SiteEnd() { _ANNOTATE_ROUTINES_ADDR->site_end_2(); } - static ANNOTATE_CLR_NOINLINE void TaskBegin(const char* task) { _ANNOTATE_ROUTINES_ADDR->task_beginA(task); } - static ANNOTATE_CLR_NOINLINE void TaskEnd() { _ANNOTATE_ROUTINES_ADDR->task_end_2(); } - static ANNOTATE_CLR_NOINLINE void IterationTask(const char* task) { _ANNOTATE_ROUTINES_ADDR->iteration_taskA(task); } - static ANNOTATE_CLR_NOINLINE void LockAcquire(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_acquire_2(lockId); } - static ANNOTATE_CLR_NOINLINE void LockRelease(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_release_2(lockId); } - static ANNOTATE_CLR_NOINLINE void RecordAllocation(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->record_allocation(p, s); } - static ANNOTATE_CLR_NOINLINE void RecordDeallocation(void *p) { _ANNOTATE_ROUTINES_ADDR->record_deallocation(p); } - static ANNOTATE_CLR_NOINLINE void InductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->induction_uses(p, s); } - static ANNOTATE_CLR_NOINLINE void ReductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->reduction_uses(p, s); } - static ANNOTATE_CLR_NOINLINE void ObserveUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->observe_uses(p, s); } - static ANNOTATE_CLR_NOINLINE void ClearUses(void *p) { _ANNOTATE_ROUTINES_ADDR->clear_uses(p); } - static ANNOTATE_CLR_NOINLINE void DisablePush(__itt_model_disable d) { _ANNOTATE_ROUTINES_ADDR->disable_push(d); } - static ANNOTATE_CLR_NOINLINE void DisablePop() { _ANNOTATE_ROUTINES_ADDR->disable_pop(); } - static ANNOTATE_CLR_NOINLINE void AggregateTask(size_t c) { _ANNOTATE_ROUTINES_ADDR->aggregate_task(c); } -}; -#if defined(WIN32) && defined(__CLR_VER) -#pragma managed(pop) -#endif -#undef ANNOTATE_CLR_NOINLINE -#endif - -#if defined(__cplusplus) && defined(WIN32) && defined(__CLR_VER) - -#define ANNOTATE_SITE_BEGIN(_SITE) Annotate::SiteBegin(#_SITE) -#define ANNOTATE_SITE_END(...) Annotate::SiteEnd() -#define ANNOTATE_TASK_BEGIN(_TASK) Annotate::TaskBegin(#_TASK) -#define ANNOTATE_TASK_END(...) Annotate::TaskEnd() -#define ANNOTATE_ITERATION_TASK(_TASK) Annotate::IterationTask(#_TASK) -#define ANNOTATE_LOCK_ACQUIRE(_ADDR) Annotate::LockAcquire(_ADDR) -#define ANNOTATE_LOCK_RELEASE(_ADDR) Annotate::LockRelease(_ADDR) -#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) Annotate::RecordAllocation((_ADDR), (_SIZE)) -#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) Annotate::RecordDeallocation(_ADDR) -#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) Annotate::InductionUses((_ADDR), (_SIZE)) -#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) Annotate::ReductionUses((_ADDR), (_SIZE)) -#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) Annotate::ObserveUses((_ADDR), (_SIZE)) -#define ANNOTATE_CLEAR_USES(_ADDR) Annotate::ClearUses(_ADDR) -#define ANNOTATE_DISABLE_OBSERVATION_PUSH Annotate::DisablePush(itt_model_disable_observation) -#define ANNOTATE_DISABLE_OBSERVATION_POP Annotate::DisablePop() -#define ANNOTATE_DISABLE_COLLECTION_PUSH Annotate::DisablePush(__itt_model_disable_collection) -#define ANNOTATE_DISABLE_COLLECTION_POP Annotate::DisablePop() -#define ANNOTATE_AGGREGATE_TASK(_COUNT) Annotate::AggregateTask(_COUNT) - -#else - -/* Mark the start of a site (region) to be analyzed by the tool */ -#define ANNOTATE_SITE_BEGIN(_SITE) _ANNOTATE_CALL_1(site_beginA, #_SITE) - -/* Mark the end of a site (region) to be analyzed by the tool and - * indicate a WaitForAll task synchronization */ -#define ANNOTATE_SITE_END(...) _ANNOTATE_CALL_0(site_end_2) - -/* Mark the beginning of a region of code that constitutes a task */ -#define ANNOTATE_TASK_BEGIN(_TASK) _ANNOTATE_CALL_1(task_beginA, #_TASK) - -/* Mark the end of a region of code that constitutes a task */ -#define ANNOTATE_TASK_END(...) _ANNOTATE_CALL_0(task_end_2) - -/* Mark the break between one task and the next task (a "split" description model - * rather than a "begin/end" description model. */ -#define ANNOTATE_ITERATION_TASK(_TASK) _ANNOTATE_CALL_1(iteration_taskA, #_TASK) - -/* Acquire a lock identified by lockId */ -#define ANNOTATE_LOCK_ACQUIRE(_ADDR) _ANNOTATE_CALL_1(lock_acquire_2, (_ADDR)) - -/* Release a lock identified by lockId */ -#define ANNOTATE_LOCK_RELEASE(_ADDR) _ANNOTATE_CALL_1(lock_release_2, (_ADDR)) - -/* Record user allocation of memory */ -#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) _ANNOTATE_CALL_2(record_allocation, (_ADDR), (_SIZE)) - -/* Record user deallocation of memory */ -#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) _ANNOTATE_CALL_1(record_deallocation, (_ADDR)) - -/* Denote storage as an inductive value */ -#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(induction_uses, (_ADDR), (_SIZE)) - -/* Denote storage as a reduction */ -#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(reduction_uses, (_ADDR), (_SIZE)) - -/* Record all observations of uses */ -#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(observe_uses, (_ADDR), (_SIZE)) - -/* Clear handling of values */ -#define ANNOTATE_CLEAR_USES(_ADDR) _ANNOTATE_CALL_1(clear_uses, (_ADDR)) - -/* Push disable of observations */ -#define ANNOTATE_DISABLE_OBSERVATION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_observation) - -/* Pop disable of observations */ -#define ANNOTATE_DISABLE_OBSERVATION_POP _ANNOTATE_CALL_0(disable_pop) - -/* Push disable of collection */ -#define ANNOTATE_DISABLE_COLLECTION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_collection) - -/* Pop disable of collection */ -#define ANNOTATE_DISABLE_COLLECTION_POP _ANNOTATE_CALL_0(disable_pop) - -/* Task aggregation */ -#define ANNOTATE_AGGREGATE_TASK(_COUNT) _ANNOTATE_CALL_1(aggregate_task, (_COUNT)) - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ANNOTATE_EXPAND_NULL */ - -#endif /* _ADVISOR_ANNOTATE_H_ */ +/* ======================================================================== + * + * SAMPLE SOURCE CODE - SUBJECT TO THE TERMS OF END-USER LICENSE AGREEMENT + * FOR INTEL(R) ADVISOR XE 2016. + * + * Copyright (c) 2009-2015 Intel Corporation. All rights reserved. + * + * THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTIES, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OF INTELLECTUAL + * PROPERTY RIGHTS. + * + * ======================================================================== + */ + +/* This file defines macros and inline functions used by + * the Intel(R) Advisor XE "Dependencies Modeling" and + * "Suitability Modeling" analysis, and are in described + * in the "Annotations" section of the help. + * + * Expansion Options + * + * There are several options you can used to control how advisor-annotate.h + * is included. To use these, define the option prior to including + * advisor-annotate.h. e.g. + * #define ANNOTATE_DECLARE + * #include "advisor-annotate.h" + * + * Controlling inclusion of windows.h + * + * windows.h is included for declarations for LoadLibrary, GetProcSymbol, + * but this can have interactions with user code, such as conflicting + * definitions of types. There are two general approaches to work around + * this if this triggers problems building your application: + * + * 1. Reduce the amount declared by windows.h by using the following: + * #define NOMINMAX + * #define WIN32_LEAN_AND_MEAN + * prior to including advisor-annotate.h in your code. + * The first avoids problems with STL min/max in particular + * This is sufficient in some cases, and may be the easiest. + * + * 2. Use a declaration/definition approach, where all uses of advisor-annotate.h + * other than one, generate a set of declarations, and windows.h is only + * needed in a single implementation module. In this model, all includes + * of advisor-annotate.h except one specify ANNOTATE_DECLARE, which causes + * advisor-annotate.h to declare an external routine, and not include + * windows.h. A final include of advisor-annotate.h than specifies + * ANNOTATE_DEFINE, to actually define the global routine to resolve + * the external reference. This one include is the only one that winds up + * using windows.h. If necessary, this can be placed in a file by itself. + * + * An example using this mechanism: + * + * ... + * // Some header(s) used in places in your system where you want + * // to be able to use annotations + * #define ANNOTATE_DECLARE + * #include "advisor-annotate.h" + * ... + * // annotation uses + * ANNOTATE_SITE_BEGIN(MySite1) + * ... + * ANNOTATE_SITE_END(MySite1) + * ... + * + * ... + * // A single implementation file (.cpp/.cxx) causes windows.h + * // to be included, and the support routine to be defined as a + * // global routine called from the various annotation uses. + * #define ANNOTATE_DEFINE + * #include "advisor-annotate.h" + * ... + * + * Null expansion of annotations + * + * Some people may find it useful to have no expansion for annotations, + * if you have a project that you want to build without any annotation + * effects at all. (e.g. if you have a project where you want to have + * some annotations in a shared source pool, but only particular + * developers are actually building with the annotations enabled.) + * Defining ANNOTATE_EXPAND_NULL avoids declaring comdat routines, + * and avoids any textual expansion for annotation macros. + */ + +#ifndef _ADVISOR_ANNOTATE_H_ +#define _ADVISOR_ANNOTATE_H_ + +/* Version of the annotations. + * The presence of this macro serves to idetify the annotation definition + * file and the form of annotations. + */ +#define INTEL_ADVISOR_ANNOTATION_VERSION 1.0 + +#ifdef ANNOTATE_EXPAND_NULL + +#define ANNOTATE_SITE_BEGIN(_SITE) +#define ANNOTATE_SITE_END(...) +#define ANNOTATE_TASK_BEGIN(_TASK) +#define ANNOTATE_TASK_END(...) +#define ANNOTATE_ITERATION_TASK(_TASK) +#define ANNOTATE_LOCK_ACQUIRE(_ADDR) +#define ANNOTATE_LOCK_RELEASE(_ADDR) +#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) +#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) +#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) +#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) +#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) +#define ANNOTATE_CLEAR_USES(_ADDR) +#define ANNOTATE_DISABLE_OBSERVATION_PUSH +#define ANNOTATE_DISABLE_OBSERVATION_POP +#define ANNOTATE_DISABLE_COLLECTION_PUSH +#define ANNOTATE_DISABLE_COLLECTION_POP +#define ANNOTATE_AGGREGATE_TASK(_COUNT) + +#else /* ANNOTATE_EXPAND_NULL */ + +#if defined(WIN32) || defined(_WIN32) + +#define ANNOTATEAPI __cdecl + +#ifndef ANNOTATE_DECLARE +#include + +typedef HMODULE lib_t; + +#define __itt_get_proc(lib, name) GetProcAddress(lib, name) +#define __itt_load_lib(name) LoadLibraryA(name) +#define __itt_unload_lib(handle) FreeLibrary(handle) +#define __itt_system_error() (int)GetLastError() +#endif /* ANNOTATE_DECLARE */ + +#else /* defined(WIN32) || defined(_WIN32) */ + +#if defined _M_IX86 || __i386__ +# define ANNOTATEAPI __attribute__ ((cdecl)) +#else +# define ANNOTATEAPI /* actual only on x86 platform */ +#endif + + +#ifndef ANNOTATE_DECLARE +#include +#include +#include + +typedef void* lib_t; + +#define __itt_get_proc(lib, name) dlsym(lib, name) +#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) +#define __itt_unload_lib(handle) dlclose(handle) +#define __itt_system_error() errno +#endif /* ANNOTATE_DECLARE */ + +#endif /* defined(WIN32) || defined(_WIN32) */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef _ITTNOTIFY_H_ + +/* Handles for sites and tasks. + */ +typedef void* __itt_model_site; /* handle for lexical site */ +typedef void* __itt_model_site_instance; /* handle for dynamic instance */ +typedef void* __itt_model_task; /* handle for lexical site */ +typedef void* __itt_model_task_instance; /* handle for dynamic instance */ + +typedef enum { + __itt_model_disable_observation, + __itt_model_disable_collection +} __itt_model_disable; + +#endif /* _ITTNOTIFY_H_ */ + +/*** Use the routines in libittnotify.dll. ***/ + +/* Basic approach: + * For the case of calling the dll, there is an __annotate_routine function + * declared as a comdat in each compilation unit with annotations present. + * That routine in turn has an internal static structure that is initialized + * once to contain the address of functions occuring in libittnotify.dll. + * Each time an annotation macro is invoked, that causes a call to the + * __annotate_routine function to get addresses of the routines, followed + * by calling the specific routine, provided the address is non-null. + */ + +/* This set of macros generates calls that are part of application images, + * which call the __itt_model_xxx routines in the dynamically loaded + * libittnotify.dll. + */ +#ifndef _ITTNOTIFY_H_ +#define ITT_NOTIFY_DECL(_text) _text +#else +#define ITT_NOTIFY_DECL(_text) +#endif + +/* For C++, a static initialization is used */ +#if defined(__cplusplus) && defined(WIN32) +#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_s +#else +#define _ANNOTATE_ROUTINES_ADDR __annotate_routines_init( __annotate_routines() ) +#endif /* __cplusplus */ + + +#define _ANNOTATE_DECLARE_0(_BASENAME) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) + +#define _ANNOTATE_DECLARE_0_INT(_BASENAME) \ +typedef int (ANNOTATEAPI * __annotate_##_BASENAME##_t)(); \ +static __inline int ANNOTATEAPI __annotate_##_BASENAME##_t_nop() { return 0; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(); ) + +#define _ANNOTATE_CALL_0(_BASENAME) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(); } + +#define _ANNOTATE_DECLARE_1(_BASENAME, _P1TYPE) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1) { (void)p1; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1); ) + +#define _ANNOTATE_CALL_1(_BASENAME, _P1) { _ANNOTATE_ROUTINES_ADDR->_BASENAME(_P1); } + +#define _ANNOTATE_DECLARE_2(_BASENAME, _P1TYPE, _P2TYPE) \ +typedef void (ANNOTATEAPI * __annotate_##_BASENAME##_t)(_P1TYPE p1, _P2TYPE p2); \ +static __inline void ANNOTATEAPI __annotate_##_BASENAME##_t_nop(_P1TYPE p1, _P2TYPE p2) { (void)p1; (void)p2; }; \ +ITT_NOTIFY_DECL( extern void ANNOTATEAPI __itt_model_##_BASENAME(_P1TYPE p1, _P2TYPE p2); ) + +#define _ANNOTATE_CALL_2(_BASENAME, _P1, _P2) { _ANNOTATE_ROUTINES_ADDR->_BASENAME((_P1), (_P2)); } + +/*** Declare routines appropriately based on usage style ***/ + +/* Depending on above, this will either expand to comdats that are + * used directly, or comdats that call routines in libittnotify.dll + */ +_ANNOTATE_DECLARE_1(site_beginA, const char *) +_ANNOTATE_DECLARE_0(site_end_2) +_ANNOTATE_DECLARE_1(task_beginA, const char *) +_ANNOTATE_DECLARE_0(task_end_2) +_ANNOTATE_DECLARE_1(iteration_taskA, const char *) +_ANNOTATE_DECLARE_1(lock_acquire_2, void *) +_ANNOTATE_DECLARE_1(lock_release_2, void *) +_ANNOTATE_DECLARE_2(record_allocation, void *, size_t) +_ANNOTATE_DECLARE_1(record_deallocation, void *) +_ANNOTATE_DECLARE_2(induction_uses, void *, size_t) +_ANNOTATE_DECLARE_2(reduction_uses, void *, size_t) +_ANNOTATE_DECLARE_2(observe_uses, void *, size_t) +_ANNOTATE_DECLARE_1(clear_uses, void *) +_ANNOTATE_DECLARE_1(disable_push, __itt_model_disable) +_ANNOTATE_DECLARE_0(disable_pop) +_ANNOTATE_DECLARE_1(aggregate_task, size_t) +_ANNOTATE_DECLARE_0_INT(is_collection_disabled) + +/* All of the symbols potentially in the library + */ +struct __annotate_routines { + volatile int initialized; + __annotate_site_beginA_t site_beginA; + __annotate_site_end_2_t site_end_2; + __annotate_task_beginA_t task_beginA; + __annotate_task_end_2_t task_end_2; + __annotate_iteration_taskA_t iteration_taskA; + __annotate_lock_acquire_2_t lock_acquire_2; + __annotate_lock_release_2_t lock_release_2; + __annotate_record_allocation_t record_allocation; + __annotate_record_deallocation_t record_deallocation; + __annotate_induction_uses_t induction_uses; + __annotate_reduction_uses_t reduction_uses; + __annotate_observe_uses_t observe_uses; + __annotate_clear_uses_t clear_uses; + __annotate_disable_push_t disable_push; + __annotate_disable_pop_t disable_pop; + __annotate_aggregate_task_t aggregate_task; + __annotate_is_collection_disabled_t is_collection_disabled; +}; + +/* This comdat-ed routine means there is a single instance of the function pointer + * structure per image + */ +static __inline struct __annotate_routines* __annotate_routines() +{ + static struct __annotate_routines __annotate_routines; + return &__annotate_routines; +} + +/* This routine is called to get the address of an initialized + * set of function pointers for the annotation routines. + */ + +#ifdef ANNOTATE_DECLARE +extern struct __annotate_routines* ANNOTATEAPI __annotate_routines_init(struct __annotate_routines* itt); +#else +#ifdef ANNOTATE_DEFINE + /* */ +#else + static __inline +#endif +struct __annotate_routines* +ANNOTATEAPI +__annotate_routines_init(struct __annotate_routines* itt) { + + if (itt->initialized) { + return itt; + } else { + + /* Initialized by first invocation + * This assumes that the code here can be executed successfully + * by multiple threads, should that ever happen. + */ + int do_disable_pop = 0; +#if !(defined(WIN32) || defined(_WIN32)) + char* lib_name = NULL; +#endif + + lib_t itt_notify = 0; + +#if defined(WIN32) || defined(_WIN32) + itt_notify = __itt_load_lib("libittnotify.dll"); +#else + if (sizeof(void*) > 4) { + lib_name = getenv("INTEL_LIBITTNOTIFY64"); + } else { + lib_name = getenv("INTEL_LIBITTNOTIFY32"); + } + if (lib_name) { + itt_notify = __itt_load_lib(lib_name); + } +#endif + if (itt_notify != NULL) { + + /* The static variables initialized and itt are reported as race conditions + * or inconsistent lock usage by Dependencies Modeling in some obscure cases + * involving multiple dlls. Ignoring this initialization phase gets rid of + * this problem. + */ + __annotate_disable_push_t disable_push; + __annotate_is_collection_disabled_t is_collection_disabled; + disable_push = (__annotate_disable_push_t) __itt_get_proc(itt_notify, "__itt_model_disable_push"); + is_collection_disabled = (__annotate_is_collection_disabled_t) __itt_get_proc(itt_notify, "__itt_model_is_collection_disabled"); + if (disable_push) { + if ( ! (is_collection_disabled && is_collection_disabled()) ) + { + // disable collection only if it is not disabled already (for example, started paused) + disable_push(__itt_model_disable_observation); + do_disable_pop = 1; + } + } + itt->site_beginA = (__annotate_site_beginA_t) __itt_get_proc(itt_notify, "__itt_model_site_beginA"); + itt->site_end_2 = (__annotate_site_end_2_t) __itt_get_proc(itt_notify, "__itt_model_site_end_2"); + itt->task_beginA = (__annotate_task_beginA_t) __itt_get_proc(itt_notify, "__itt_model_task_beginA"); + itt->task_end_2 = (__annotate_task_end_2_t) __itt_get_proc(itt_notify, "__itt_model_task_end_2"); + itt->iteration_taskA = (__annotate_iteration_taskA_t) __itt_get_proc(itt_notify, "__itt_model_iteration_taskA"); + itt->lock_acquire_2 = (__annotate_lock_acquire_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_acquire_2"); + itt->lock_release_2 = (__annotate_lock_release_2_t) __itt_get_proc(itt_notify, "__itt_model_lock_release_2"); + itt->record_allocation = (__annotate_record_allocation_t) __itt_get_proc(itt_notify, "__itt_model_record_allocation"); + itt->record_deallocation = (__annotate_record_deallocation_t)__itt_get_proc(itt_notify, "__itt_model_record_deallocation"); + itt->induction_uses = (__annotate_induction_uses_t) __itt_get_proc(itt_notify, "__itt_model_induction_uses"); + itt->reduction_uses = (__annotate_reduction_uses_t) __itt_get_proc(itt_notify, "__itt_model_reduction_uses"); + itt->observe_uses = (__annotate_observe_uses_t) __itt_get_proc(itt_notify, "__itt_model_observe_uses"); + itt->clear_uses = (__annotate_clear_uses_t) __itt_get_proc(itt_notify, "__itt_model_clear_uses"); + itt->disable_push = disable_push; + itt->disable_pop = (__annotate_disable_pop_t) __itt_get_proc(itt_notify, "__itt_model_disable_pop"); + itt->aggregate_task = (__annotate_aggregate_task_t) __itt_get_proc(itt_notify, "__itt_model_aggregate_task"); + itt->is_collection_disabled = is_collection_disabled; + } + /* No-op routine for any that didn't get resolved */ + if (!itt->site_beginA) itt->site_beginA = __annotate_site_beginA_t_nop; + if (!itt->site_end_2) itt->site_end_2 = __annotate_site_end_2_t_nop; + if (!itt->task_beginA) itt->task_beginA = __annotate_task_beginA_t_nop; + if (!itt->task_end_2) itt->task_end_2 = __annotate_task_end_2_t_nop; + if (!itt->iteration_taskA) itt->iteration_taskA = __annotate_iteration_taskA_t_nop; + if (!itt->lock_acquire_2) itt->lock_acquire_2 = __annotate_lock_acquire_2_t_nop; + if (!itt->lock_release_2) itt->lock_release_2 = __annotate_lock_release_2_t_nop; + if (!itt->record_allocation) itt->record_allocation = __annotate_record_allocation_t_nop; + if (!itt->record_deallocation) itt->record_deallocation=__annotate_record_deallocation_t_nop; + if (!itt->induction_uses) itt->induction_uses = __annotate_induction_uses_t_nop; + if (!itt->reduction_uses) itt->reduction_uses = __annotate_reduction_uses_t_nop; + if (!itt->observe_uses) itt->observe_uses = __annotate_observe_uses_t_nop; + if (!itt->clear_uses) itt->clear_uses = __annotate_clear_uses_t_nop; + if (!itt->disable_push) itt->disable_push = __annotate_disable_push_t_nop; + if (!itt->disable_pop) itt->disable_pop = __annotate_disable_pop_t_nop; + if (!itt->aggregate_task) itt->aggregate_task = __annotate_aggregate_task_t_nop; + if (!itt->is_collection_disabled) itt->is_collection_disabled = __annotate_is_collection_disabled_t_nop; + + itt->initialized = 1; + + if (do_disable_pop) { + itt->disable_pop(); + } + } + return itt; +} +#endif /* ANNOTATE_DECLARE */ + +/* For C++ only, use a class to force initialization */ + +#if defined(__cplusplus) && defined(WIN32) +/* Force one-shot initialization so individual calls don't need it */ +static struct __annotate_routines* __annotate_routines_s = __annotate_routines_init( __annotate_routines() ); +#endif + +/* For C++, allow the Annotate::SiteBegin(x) form. For Windows CLR, this is the default + * expansion for the macros (with no-inline) to get the best call stacks in the tools. */ +#if defined(__cplusplus) +/* Ensure this code is managed and non-inlinable */ +#if defined(WIN32) && defined(__CLR_VER) +#pragma managed(push, on) +#define ANNOTATE_CLR_NOINLINE __declspec(noinline) +#else +#define ANNOTATE_CLR_NOINLINE +#endif +class Annotate { +public: + static ANNOTATE_CLR_NOINLINE void SiteBegin(const char* site) { _ANNOTATE_ROUTINES_ADDR->site_beginA(site); } + static ANNOTATE_CLR_NOINLINE void SiteEnd() { _ANNOTATE_ROUTINES_ADDR->site_end_2(); } + static ANNOTATE_CLR_NOINLINE void TaskBegin(const char* task) { _ANNOTATE_ROUTINES_ADDR->task_beginA(task); } + static ANNOTATE_CLR_NOINLINE void TaskEnd() { _ANNOTATE_ROUTINES_ADDR->task_end_2(); } + static ANNOTATE_CLR_NOINLINE void IterationTask(const char* task) { _ANNOTATE_ROUTINES_ADDR->iteration_taskA(task); } + static ANNOTATE_CLR_NOINLINE void LockAcquire(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_acquire_2(lockId); } + static ANNOTATE_CLR_NOINLINE void LockRelease(void* lockId) { _ANNOTATE_ROUTINES_ADDR->lock_release_2(lockId); } + static ANNOTATE_CLR_NOINLINE void RecordAllocation(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->record_allocation(p, s); } + static ANNOTATE_CLR_NOINLINE void RecordDeallocation(void *p) { _ANNOTATE_ROUTINES_ADDR->record_deallocation(p); } + static ANNOTATE_CLR_NOINLINE void InductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->induction_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ReductionUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->reduction_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ObserveUses(void *p, size_t s) { _ANNOTATE_ROUTINES_ADDR->observe_uses(p, s); } + static ANNOTATE_CLR_NOINLINE void ClearUses(void *p) { _ANNOTATE_ROUTINES_ADDR->clear_uses(p); } + static ANNOTATE_CLR_NOINLINE void DisablePush(__itt_model_disable d) { _ANNOTATE_ROUTINES_ADDR->disable_push(d); } + static ANNOTATE_CLR_NOINLINE void DisablePop() { _ANNOTATE_ROUTINES_ADDR->disable_pop(); } + static ANNOTATE_CLR_NOINLINE void AggregateTask(size_t c) { _ANNOTATE_ROUTINES_ADDR->aggregate_task(c); } +}; +#if defined(WIN32) && defined(__CLR_VER) +#pragma managed(pop) +#endif +#undef ANNOTATE_CLR_NOINLINE +#endif + +#if defined(__cplusplus) && defined(WIN32) && defined(__CLR_VER) + +#define ANNOTATE_SITE_BEGIN(_SITE) Annotate::SiteBegin(#_SITE) +#define ANNOTATE_SITE_END(...) Annotate::SiteEnd() +#define ANNOTATE_TASK_BEGIN(_TASK) Annotate::TaskBegin(#_TASK) +#define ANNOTATE_TASK_END(...) Annotate::TaskEnd() +#define ANNOTATE_ITERATION_TASK(_TASK) Annotate::IterationTask(#_TASK) +#define ANNOTATE_LOCK_ACQUIRE(_ADDR) Annotate::LockAcquire(_ADDR) +#define ANNOTATE_LOCK_RELEASE(_ADDR) Annotate::LockRelease(_ADDR) +#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) Annotate::RecordAllocation((_ADDR), (_SIZE)) +#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) Annotate::RecordDeallocation(_ADDR) +#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) Annotate::InductionUses((_ADDR), (_SIZE)) +#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) Annotate::ReductionUses((_ADDR), (_SIZE)) +#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) Annotate::ObserveUses((_ADDR), (_SIZE)) +#define ANNOTATE_CLEAR_USES(_ADDR) Annotate::ClearUses(_ADDR) +#define ANNOTATE_DISABLE_OBSERVATION_PUSH Annotate::DisablePush(itt_model_disable_observation) +#define ANNOTATE_DISABLE_OBSERVATION_POP Annotate::DisablePop() +#define ANNOTATE_DISABLE_COLLECTION_PUSH Annotate::DisablePush(__itt_model_disable_collection) +#define ANNOTATE_DISABLE_COLLECTION_POP Annotate::DisablePop() +#define ANNOTATE_AGGREGATE_TASK(_COUNT) Annotate::AggregateTask(_COUNT) + +#else + +/* Mark the start of a site (region) to be analyzed by the tool */ +#define ANNOTATE_SITE_BEGIN(_SITE) _ANNOTATE_CALL_1(site_beginA, #_SITE) + +/* Mark the end of a site (region) to be analyzed by the tool and + * indicate a WaitForAll task synchronization */ +#define ANNOTATE_SITE_END(...) _ANNOTATE_CALL_0(site_end_2) + +/* Mark the beginning of a region of code that constitutes a task */ +#define ANNOTATE_TASK_BEGIN(_TASK) _ANNOTATE_CALL_1(task_beginA, #_TASK) + +/* Mark the end of a region of code that constitutes a task */ +#define ANNOTATE_TASK_END(...) _ANNOTATE_CALL_0(task_end_2) + +/* Mark the break between one task and the next task (a "split" description model + * rather than a "begin/end" description model. */ +#define ANNOTATE_ITERATION_TASK(_TASK) _ANNOTATE_CALL_1(iteration_taskA, #_TASK) + +/* Acquire a lock identified by lockId */ +#define ANNOTATE_LOCK_ACQUIRE(_ADDR) _ANNOTATE_CALL_1(lock_acquire_2, (_ADDR)) + +/* Release a lock identified by lockId */ +#define ANNOTATE_LOCK_RELEASE(_ADDR) _ANNOTATE_CALL_1(lock_release_2, (_ADDR)) + +/* Record user allocation of memory */ +#define ANNOTATE_RECORD_ALLOCATION(_ADDR, _SIZE) _ANNOTATE_CALL_2(record_allocation, (_ADDR), (_SIZE)) + +/* Record user deallocation of memory */ +#define ANNOTATE_RECORD_DEALLOCATION(_ADDR) _ANNOTATE_CALL_1(record_deallocation, (_ADDR)) + +/* Denote storage as an inductive value */ +#define ANNOTATE_INDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(induction_uses, (_ADDR), (_SIZE)) + +/* Denote storage as a reduction */ +#define ANNOTATE_REDUCTION_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(reduction_uses, (_ADDR), (_SIZE)) + +/* Record all observations of uses */ +#define ANNOTATE_OBSERVE_USES(_ADDR, _SIZE) _ANNOTATE_CALL_2(observe_uses, (_ADDR), (_SIZE)) + +/* Clear handling of values */ +#define ANNOTATE_CLEAR_USES(_ADDR) _ANNOTATE_CALL_1(clear_uses, (_ADDR)) + +/* Push disable of observations */ +#define ANNOTATE_DISABLE_OBSERVATION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_observation) + +/* Pop disable of observations */ +#define ANNOTATE_DISABLE_OBSERVATION_POP _ANNOTATE_CALL_0(disable_pop) + +/* Push disable of collection */ +#define ANNOTATE_DISABLE_COLLECTION_PUSH _ANNOTATE_CALL_1(disable_push, __itt_model_disable_collection) + +/* Pop disable of collection */ +#define ANNOTATE_DISABLE_COLLECTION_POP _ANNOTATE_CALL_0(disable_pop) + +/* Task aggregation */ +#define ANNOTATE_AGGREGATE_TASK(_COUNT) _ANNOTATE_CALL_1(aggregate_task, (_COUNT)) + +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ANNOTATE_EXPAND_NULL */ + +#endif /* _ADVISOR_ANNOTATE_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor_annotate.f90 b/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor_annotate.f90 index d4d2d34d62..ec826dcb45 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor_annotate.f90 +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/advisor_annotate.f90 @@ -1,706 +1,706 @@ -! ======================================================================== -! -! SAMPLE SOURCE CODE - SUBJECT TO THE TERMS OF END-USER LICENSE AGREEMENT -! FOR INTEL(R) ADVISOR XE 2016. -! -! Copyright (c) 2012-2015 Intel Corporation. All rights reserved. -! -! THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTIES, EXPRESS OR IMPLIED, -! INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY, -! FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OF INTELLECTUAL -! PROPERTY RIGHTS. -! -! ======================================================================== -! - -!-------- -! -! This file defines functions used by the Intel(R) Advisor XE -! "Dependencies Modeling" and "Suitability Modeling" analysis, which -! are described in the "Annotations" section of the help. -! -! Version of the annotations. -! The presence of this macro serves to idetify the annotation definition -! file and the form of annotations. -! INTEL_ADVISOR_ANNOTATION_VERSION 1.0 -!-------- - -module advisor_annotate - use, intrinsic :: iso_c_binding, only: C_PTR, C_FUNPTR, C_INT, C_CHAR, C_NULL_CHAR, C_F_PROCPOINTER, C_LOC, C_ASSOCIATED - implicit none - - !-------- - ! - ! Public interface - ! - !-------- - - public :: annotate_site_begin - public :: annotate_site_end - public :: annotate_task_begin - public :: annotate_task_end - public :: annotate_iteration_task - public :: annotate_lock_acquire - public :: annotate_lock_release - public :: annotate_disable_observation_push - public :: annotate_disable_observation_pop - public :: annotate_disable_collection_push - public :: annotate_disable_collection_pop - public :: annotate_induction_uses - public :: annotate_reduction_uses - public :: annotate_observe_uses - public :: annotate_clear_uses - public :: annotate_aggregate_task - - interface annotate_induction_uses - module procedure annotate_induction_uses_i2 - module procedure annotate_induction_uses_i4 - module procedure annotate_induction_uses_i8 - module procedure annotate_induction_uses_r4 - module procedure annotate_induction_uses_r8 - module procedure annotate_induction_uses_c4 - module procedure annotate_induction_uses_c8 - end interface annotate_induction_uses - - interface annotate_reduction_uses - module procedure annotate_reduction_uses_i2 - module procedure annotate_reduction_uses_i4 - module procedure annotate_reduction_uses_i8 - module procedure annotate_reduction_uses_r4 - module procedure annotate_reduction_uses_r8 - module procedure annotate_reduction_uses_c4 - module procedure annotate_reduction_uses_c8 - end interface annotate_reduction_uses - - interface annotate_observe_uses - module procedure annotate_observe_uses_i2 - module procedure annotate_observe_uses_i4 - module procedure annotate_observe_uses_i8 - module procedure annotate_observe_uses_r4 - module procedure annotate_observe_uses_r8 - module procedure annotate_observe_uses_c4 - module procedure annotate_observe_uses_c8 - end interface annotate_observe_uses - - interface annotate_clear_uses - module procedure annotate_clear_uses_i2 - module procedure annotate_clear_uses_i4 - module procedure annotate_clear_uses_i8 - module procedure annotate_clear_uses_r4 - module procedure annotate_clear_uses_r8 - module procedure annotate_clear_uses_c4 - module procedure annotate_clear_uses_c8 - end interface annotate_clear_uses - - private - - !-------- - ! - ! Interfaces to the itt_notify entry points - ! - !-------- - - enum, bind(C) - enumerator :: disable_observation - enumerator :: disable_collection - end enum - - abstract interface - - subroutine itt_proc_noargs() bind(C) - end subroutine itt_proc_noargs - - subroutine itt_proc_with_name(name, len) bind(C) - import - character, dimension(*), intent(in) :: name - integer(kind=C_INT), intent(in), value :: len - end subroutine itt_proc_with_name - - subroutine itt_proc_with_int(intval) bind(C) - import - integer(kind=C_INT), intent(in), value :: intval - end subroutine itt_proc_with_int - - subroutine itt_proc_with_disable(disable_kind) bind(C) - import - integer(kind=C_INT), intent(in), value :: disable_kind - end subroutine itt_proc_with_disable - - subroutine itt_proc_with_addr_size(addr, size) bind(C) - import - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - end subroutine itt_proc_with_addr_size - - end interface - - !-------- - ! - ! Subroutine pointer variables to access the itt_notify entry points - ! - !-------- - -!dec$ if defined(use_initialized_proc_ptrs) - procedure(itt_proc_with_name), pointer :: site_begin => site_begin_load - procedure(itt_proc_noargs), pointer :: site_end_2 => site_end_2_load - procedure(itt_proc_with_name), pointer :: task_begin => task_begin_load - procedure(itt_proc_noargs), pointer :: task_end_2 => task_end_2_load - procedure(itt_proc_noargs), pointer :: iteration_task => iteration_task_load - procedure(itt_proc_with_int), pointer :: lock_acquire_2 => lock_acquire_2_load - procedure(itt_proc_with_int), pointer :: lock_release_2 => lock_release_2_load - procedure(itt_proc_with_disable), pointer :: disable_push => disable_push_load - procedure(itt_proc_noargs), pointer :: disable_pop => disable_pop_load - procedure(itt_proc_with_addr_size), pointer :: induction_uses => induction_uses_load - procedure(itt_proc_with_addr_size), pointer :: reduction_uses => reduction_uses_load - procedure(itt_proc_with_addr_size), pointer :: observe_uses => observe_uses_load - procedure(itt_proc_with_addr_size), pointer :: clear_uses => clear_uses_load - procedure(itt_proc_with_int), pointer :: aggregate_task => aggregate_task_load -!dec$ else - procedure(itt_proc_with_name), pointer :: site_begin - procedure(itt_proc_noargs), pointer :: site_end_2 - procedure(itt_proc_with_name), pointer :: task_begin - procedure(itt_proc_noargs), pointer :: task_end_2 - procedure(itt_proc_with_name), pointer :: iteration_task - procedure(itt_proc_with_int), pointer :: lock_acquire_2 - procedure(itt_proc_with_int), pointer :: lock_release_2 - procedure(itt_proc_with_disable), pointer :: disable_push - procedure(itt_proc_noargs), pointer :: disable_pop - procedure(itt_proc_with_addr_size), pointer :: induction_uses - procedure(itt_proc_with_addr_size), pointer :: reduction_uses - procedure(itt_proc_with_addr_size), pointer :: observe_uses - procedure(itt_proc_with_addr_size), pointer :: clear_uses - procedure(itt_proc_with_int), pointer :: aggregate_task - - logical :: initialized = .false. -!dec$ endif - - - !-------- - ! - ! Functions for loading dynamic libraries - ! - !-------- - - interface - - !dec$ if defined(_WIN32) - - !DEC$OBJCOMMENT LIB:"KERNEL32.LIB" - !DEC$OBJCOMMENT LIB:"advisor.lib" - - function load_library(file) - import - !dec$ attributes default, stdcall, decorate, alias : 'LoadLibraryA' :: load_library - type(C_PTR) :: load_library - character(kind=C_CHAR), dimension(*), intent(in) :: file - end function load_library - - function get_library_entry(library, proc_name) - import - !dec$ attributes default, stdcall, decorate, alias : 'GetProcAddress' :: get_library_entry - type(C_FUNPTR) :: get_library_entry - type(C_PTR), intent(in), value :: library - character(kind=C_CHAR), dimension(*), intent(in) :: proc_name - end function get_library_entry - - !dec$ else - - function load_library(file, mode) bind(C, name="dlopen") - import - type(C_PTR) :: load_library - character(kind=C_CHAR), dimension(*), intent(in) :: file - integer(kind=C_INT), intent(in), value :: mode - end function load_library - - function get_library_entry(library, proc_name) bind(C, name="dlsym") - import - type(C_FUNPTR) :: get_library_entry - type(C_PTR), intent(in), value :: library - character(kind=C_CHAR), dimension(*), intent(in) :: proc_name - end function get_library_entry - - !dec$ endif - - end interface - -contains - - !-------- - ! - ! The public interface subroutines just make sure the module has been initialized, - ! and then make an indirect call through the corresponding pointer variables. - ! Initializing the module tries to load the itt notify library. If the library - ! is loaded successfully, the variables are set to point to the corresponding - ! entries in the library. If the library load fails, the variables are set to point - ! to stub routines. - ! - !-------- - - subroutine annotate_site_begin(site_name) - !DEC$ ATTRIBUTES DEFAULT :: annotate_site_begin - character(len=*), intent(in) :: site_name - if (.not. initialized) call load_itt_library - call site_begin(site_name, len(site_name)) - end subroutine annotate_site_begin - - subroutine annotate_site_end - !DEC$ ATTRIBUTES DEFAULT :: annotate_site_end - if (.not. initialized) call load_itt_library - call site_end_2 - end subroutine annotate_site_end - - subroutine annotate_task_begin(task_name) - !DEC$ ATTRIBUTES DEFAULT :: annotate_task_begin - character(len=*), intent(in) :: task_name - if (.not. initialized) call load_itt_library - call task_begin(task_name, len(task_name)) - end subroutine annotate_task_begin - - subroutine annotate_task_end - !DEC$ ATTRIBUTES DEFAULT :: annotate_task_end - if (.not. initialized) call load_itt_library - call task_end_2 - end subroutine annotate_task_end - - subroutine annotate_iteration_task(task_name) - !DEC$ ATTRIBUTES DEFAULT :: annotate_iteration_task - character(len=*), intent(in) :: task_name - if (.not. initialized) call load_itt_library - call iteration_task(task_name, len(task_name)) - end subroutine annotate_iteration_task - - subroutine annotate_lock_acquire(lock_id) - !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_acquire - integer, intent(in) :: lock_id - if (.not. initialized) call load_itt_library - call lock_acquire_2(lock_id) - end subroutine annotate_lock_acquire - - subroutine annotate_lock_release(lock_id) - !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_release - integer, intent(in) :: lock_id - if (.not. initialized) call load_itt_library - call lock_release_2(lock_id) - end subroutine annotate_lock_release - - subroutine annotate_disable_observation_push - !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_push - if (.not. initialized) call load_itt_library - call disable_push(disable_observation) - end subroutine annotate_disable_observation_push - - subroutine annotate_disable_observation_pop - !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_pop - if (.not. initialized) call load_itt_library - call disable_pop - end subroutine annotate_disable_observation_pop - - subroutine annotate_disable_collection_push - !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_push - if (.not. initialized) call load_itt_library - call disable_push(disable_collection) - end subroutine annotate_disable_collection_push - - subroutine annotate_disable_collection_pop - !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_pop - if (.not. initialized) call load_itt_library - call disable_pop - end subroutine annotate_disable_collection_pop - - subroutine annotate_induction_uses_i2(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i2 - integer(kind=2), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 2) - end subroutine annotate_induction_uses_i2 - - subroutine annotate_induction_uses_i4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i4 - integer(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 4) - end subroutine annotate_induction_uses_i4 - - subroutine annotate_induction_uses_i8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i8 - integer(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 8) - end subroutine annotate_induction_uses_i8 - - subroutine annotate_induction_uses_r4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r4 - real(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 4) - end subroutine annotate_induction_uses_r4 - - subroutine annotate_induction_uses_r8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r8 - real(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 8) - end subroutine annotate_induction_uses_r8 - - subroutine annotate_induction_uses_c4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c4 - complex(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call induction_uses(C_LOC(x), 8) - end subroutine annotate_induction_uses_c4 - - subroutine annotate_induction_uses_c8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c8 - complex(kind=16), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 16) - end subroutine annotate_induction_uses_c8 - - subroutine annotate_reduction_uses_i2(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i2 - integer(kind=2), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 2) - end subroutine annotate_reduction_uses_i2 - - subroutine annotate_reduction_uses_i4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i4 - integer(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 4) - end subroutine annotate_reduction_uses_i4 - - subroutine annotate_reduction_uses_i8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i8 - integer(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 8) - end subroutine annotate_reduction_uses_i8 - - subroutine annotate_reduction_uses_r4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r4 - real(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 4) - end subroutine annotate_reduction_uses_r4 - - subroutine annotate_reduction_uses_r8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r8 - real(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 8) - end subroutine annotate_reduction_uses_r8 - - subroutine annotate_reduction_uses_c4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c4 - complex(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 8) - end subroutine annotate_reduction_uses_c4 - - subroutine annotate_reduction_uses_c8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c8 - complex(kind=16), intent(in) :: x - if (.not. initialized) call load_itt_library - call reduction_uses(C_LOC(x), 16) - end subroutine annotate_reduction_uses_c8 - - subroutine annotate_observe_uses_i2(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i2 - integer(kind=2), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 2) - end subroutine annotate_observe_uses_i2 - - subroutine annotate_observe_uses_i4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i4 - integer(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 4) - end subroutine annotate_observe_uses_i4 - - subroutine annotate_observe_uses_i8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i8 - integer(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 8) - end subroutine annotate_observe_uses_i8 - - subroutine annotate_observe_uses_r4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r4 - real(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 4) - end subroutine annotate_observe_uses_r4 - - subroutine annotate_observe_uses_r8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r8 - real(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 8) - end subroutine annotate_observe_uses_r8 - - subroutine annotate_observe_uses_c4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c4 - complex(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 8) - end subroutine annotate_observe_uses_c4 - - subroutine annotate_observe_uses_c8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c8 - complex(kind=16), intent(in) :: x - if (.not. initialized) call load_itt_library - call observe_uses(C_LOC(x), 16) - end subroutine annotate_observe_uses_c8 - - subroutine annotate_clear_uses_i2(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i2 - integer(kind=2), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 2) - end subroutine annotate_clear_uses_i2 - - subroutine annotate_clear_uses_i4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i4 - integer(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 4) - end subroutine annotate_clear_uses_i4 - - subroutine annotate_clear_uses_i8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i8 - integer(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 8) - end subroutine annotate_clear_uses_i8 - - subroutine annotate_clear_uses_r4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r4 - real(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 4) - end subroutine annotate_clear_uses_r4 - - subroutine annotate_clear_uses_r8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r8 - real(kind=8), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 8) - end subroutine annotate_clear_uses_r8 - - subroutine annotate_clear_uses_c4(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c4 - complex(kind=4), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 8) - end subroutine annotate_clear_uses_c4 - - subroutine annotate_clear_uses_c8(x) - !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c8 - complex(kind=16), intent(in) :: x - if (.not. initialized) call load_itt_library - call clear_uses(C_LOC(x), 16) - end subroutine annotate_clear_uses_c8 - - subroutine annotate_aggregate_task(count) - !DEC$ ATTRIBUTES DEFAULT :: annotate_aggregate_task - integer, intent(in) :: count - if (.not. initialized) call load_itt_library - call aggregate_task(count) - end subroutine annotate_aggregate_task - - - !-------- - ! - ! These are the load-library subroutines. - ! - !-------- - -!dec$ if defined(use_initialized_proc_ptrs) - - subroutine site_begin_load(name, len) bind(C) - character, dimension(*), intent(in) :: name - integer(kind=C_INT), intent(in), value :: len - call load_itt_library - call site_begin(name, len) - end subroutine site_begin_load - - subroutine site_end_2_load bind(C) - call load_itt_library - call site_end_2 - end subroutine site_end_2_load - - subroutine task_begin_load(name, len) bind(C) - character, dimension(*), intent(in) :: name - integer(kind=C_INT), intent(in), value :: len - call load_itt_library - call task_begin(name, len) - end subroutine task_begin_load - - subroutine task_end_2_load bind(C) - call load_itt_library - call task_end_2 - end subroutine task_end_2_load - - subroutine iteration_task_load(name, len) bind(C) - character, dimension(*), intent(in) :: name - integer(kind=C_INT), intent(in), value :: len - call load_itt_library - call iteration_task(name, len) - end subroutine iteration_task_load - - subroutine lock_acquire_2_load(lock_id) bind(C) - integer(kind=C_INT), intent(in), value :: lock_id - call load_itt_library - call lock_acquire_2(lock_id) - end subroutine lock_acquire_2_load - - subroutine lock_release_2_load(lock_id) bind(C) - integer(kind=C_INT), intent(in), value :: lock_id - call load_itt_library - call lock_release_2(lock_id) - end subroutine lock_release_2_load - - subroutine disable_push_load(disable_kind) bind(C) - integer(kind=C_INT), intent(in), value :: disable_kind - call load_itt_library - call disable_push(disable_kind) - end subroutine disable_push_load - - subroutine disable_pop_load bind(C) - call load_itt_library - call disable_pop - end subroutine disable_pop_load - - subroutine induction_uses_load(addr, size) bind(C) - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - call itt_load_library - call induction_uses(addr, size) - end subroutine induction_uses_load - - subroutine reduction_uses_load(addr, size) bind(C) - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - call itt_load_library - call reduction_uses(addr, size) - end subroutine reduction_uses_load - - subroutine observe_uses_load(addr, size) bind(C) - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - call itt_load_library - call observe_uses(addr, size) - end subroutine observe_uses_load - - subroutine clear_uses_load(addr, size) bind(C) - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - call itt_load_library - call clear_uses(addr, size) - end subroutine clear_uses_load - - subroutine annotate_task_load(count) bind(C) - integer(kind=C_INT), intent(in), value :: count - call load_itt_library - call annotate_task(count) - end subroutine annotate_task_load - -!dec$ endif - - !-------- - ! - ! These are the stub subroutines. - ! - !-------- - - subroutine itt_proc_stub() bind(C) - end subroutine itt_proc_stub - - subroutine itt_proc_with_name_stub(name, len) bind(C) - character, dimension(*), intent(in) :: name - integer(kind=C_INT), intent(in), value :: len - end subroutine itt_proc_with_name_stub - - subroutine itt_proc_with_int_stub(count) bind(C) - integer(kind=C_INT), intent(in), value :: count - end subroutine itt_proc_with_int_stub - - subroutine itt_proc_with_disable_stub(disable_kind) bind(C) - integer(kind=C_INT), value :: disable_kind - end subroutine itt_proc_with_disable_stub - - subroutine itt_proc_with_addr_size_stub(addr, size) bind(C) - type(C_PTR), intent(in), value :: addr - integer(kind=C_INT), intent(in), value :: size - end subroutine itt_proc_with_addr_size_stub - - !-------- - ! - ! Internal support code to load the itt notify library and get pointers - ! to its entry points. - ! - !-------- - - subroutine load_itt_library - type(C_PTR) :: library - character*1024 ittnotify_path - -!dec$ if defined(_WIN32) - library = load_library("libittnotify.dll"C) -!dec$ else if defined(__APPLE__) - library = load_library("libittnotify.dylib"C, 0) -!dec$ else -!dec$ if defined(__X86_64) .or. defined(_M_X64) - call getenv('INTEL_LIBITTNOTIFY64',ittnotify_path) -!dec$ else - call getenv('INTEL_LIBITTNOTIFY32',ittnotify_path) -!dec$ endif - if ( ittnotify_path /= '' ) then - ! print *,' libpath: "'//trim(ittnotify_path)//'"' - library = load_library(trim(ittnotify_path)//char(0), 1) ! 1 is RTLD_LAZY - else - ! print *,' libpath: "libittnotify.so"' - library = load_library("libittnotify.so"C, 1) ! 1 is RTLD_LAZY - endif -!dec$ endif - - if (C_ASSOCIATED(library)) then - ! print *, "Library loaded" - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_beginAL"C), site_begin) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_end_2"C), site_end_2) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_beginAL"C), task_begin) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_end_2"C), task_end_2) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_iteration_taskAL"C), iteration_task) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_acquire_2"C), lock_acquire_2) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_release_2"C), lock_release_2) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_push"C), disable_push) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_pop"C), disable_pop) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_induction_uses"C), induction_uses) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_reduction_uses"C), reduction_uses) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_observe_uses"C), observe_uses) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_clear_uses"C), clear_uses) - call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_aggregate_task"C), aggregate_task) - else - ! print *, "Library not found" - site_begin => itt_proc_with_name_stub - site_end_2 => itt_proc_stub - task_begin => itt_proc_with_name_stub - task_end_2 => itt_proc_stub - iteration_task => itt_proc_with_name_stub - lock_acquire_2 => itt_proc_with_int_stub - lock_release_2 => itt_proc_with_int_stub - disable_push => itt_proc_with_disable_stub - disable_pop => itt_proc_stub - induction_uses => itt_proc_with_addr_size_stub - reduction_uses => itt_proc_with_addr_size_stub - observe_uses => itt_proc_with_addr_size_stub - clear_uses => itt_proc_with_addr_size_stub - aggregate_task => itt_proc_with_int_stub - end if - - initialized = .true. - end subroutine - -end module advisor_annotate +! ======================================================================== +! +! SAMPLE SOURCE CODE - SUBJECT TO THE TERMS OF END-USER LICENSE AGREEMENT +! FOR INTEL(R) ADVISOR XE 2016. +! +! Copyright (c) 2012-2015 Intel Corporation. All rights reserved. +! +! THIS FILE IS PROVIDED "AS IS" WITH NO WARRANTIES, EXPRESS OR IMPLIED, +! INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY, +! FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT OF INTELLECTUAL +! PROPERTY RIGHTS. +! +! ======================================================================== +! + +!-------- +! +! This file defines functions used by the Intel(R) Advisor XE +! "Dependencies Modeling" and "Suitability Modeling" analysis, which +! are described in the "Annotations" section of the help. +! +! Version of the annotations. +! The presence of this macro serves to idetify the annotation definition +! file and the form of annotations. +! INTEL_ADVISOR_ANNOTATION_VERSION 1.0 +!-------- + +module advisor_annotate + use, intrinsic :: iso_c_binding, only: C_PTR, C_FUNPTR, C_INT, C_CHAR, C_NULL_CHAR, C_F_PROCPOINTER, C_LOC, C_ASSOCIATED + implicit none + + !-------- + ! + ! Public interface + ! + !-------- + + public :: annotate_site_begin + public :: annotate_site_end + public :: annotate_task_begin + public :: annotate_task_end + public :: annotate_iteration_task + public :: annotate_lock_acquire + public :: annotate_lock_release + public :: annotate_disable_observation_push + public :: annotate_disable_observation_pop + public :: annotate_disable_collection_push + public :: annotate_disable_collection_pop + public :: annotate_induction_uses + public :: annotate_reduction_uses + public :: annotate_observe_uses + public :: annotate_clear_uses + public :: annotate_aggregate_task + + interface annotate_induction_uses + module procedure annotate_induction_uses_i2 + module procedure annotate_induction_uses_i4 + module procedure annotate_induction_uses_i8 + module procedure annotate_induction_uses_r4 + module procedure annotate_induction_uses_r8 + module procedure annotate_induction_uses_c4 + module procedure annotate_induction_uses_c8 + end interface annotate_induction_uses + + interface annotate_reduction_uses + module procedure annotate_reduction_uses_i2 + module procedure annotate_reduction_uses_i4 + module procedure annotate_reduction_uses_i8 + module procedure annotate_reduction_uses_r4 + module procedure annotate_reduction_uses_r8 + module procedure annotate_reduction_uses_c4 + module procedure annotate_reduction_uses_c8 + end interface annotate_reduction_uses + + interface annotate_observe_uses + module procedure annotate_observe_uses_i2 + module procedure annotate_observe_uses_i4 + module procedure annotate_observe_uses_i8 + module procedure annotate_observe_uses_r4 + module procedure annotate_observe_uses_r8 + module procedure annotate_observe_uses_c4 + module procedure annotate_observe_uses_c8 + end interface annotate_observe_uses + + interface annotate_clear_uses + module procedure annotate_clear_uses_i2 + module procedure annotate_clear_uses_i4 + module procedure annotate_clear_uses_i8 + module procedure annotate_clear_uses_r4 + module procedure annotate_clear_uses_r8 + module procedure annotate_clear_uses_c4 + module procedure annotate_clear_uses_c8 + end interface annotate_clear_uses + + private + + !-------- + ! + ! Interfaces to the itt_notify entry points + ! + !-------- + + enum, bind(C) + enumerator :: disable_observation + enumerator :: disable_collection + end enum + + abstract interface + + subroutine itt_proc_noargs() bind(C) + end subroutine itt_proc_noargs + + subroutine itt_proc_with_name(name, len) bind(C) + import + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + end subroutine itt_proc_with_name + + subroutine itt_proc_with_int(intval) bind(C) + import + integer(kind=C_INT), intent(in), value :: intval + end subroutine itt_proc_with_int + + subroutine itt_proc_with_disable(disable_kind) bind(C) + import + integer(kind=C_INT), intent(in), value :: disable_kind + end subroutine itt_proc_with_disable + + subroutine itt_proc_with_addr_size(addr, size) bind(C) + import + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + end subroutine itt_proc_with_addr_size + + end interface + + !-------- + ! + ! Subroutine pointer variables to access the itt_notify entry points + ! + !-------- + +!dec$ if defined(use_initialized_proc_ptrs) + procedure(itt_proc_with_name), pointer :: site_begin => site_begin_load + procedure(itt_proc_noargs), pointer :: site_end_2 => site_end_2_load + procedure(itt_proc_with_name), pointer :: task_begin => task_begin_load + procedure(itt_proc_noargs), pointer :: task_end_2 => task_end_2_load + procedure(itt_proc_noargs), pointer :: iteration_task => iteration_task_load + procedure(itt_proc_with_int), pointer :: lock_acquire_2 => lock_acquire_2_load + procedure(itt_proc_with_int), pointer :: lock_release_2 => lock_release_2_load + procedure(itt_proc_with_disable), pointer :: disable_push => disable_push_load + procedure(itt_proc_noargs), pointer :: disable_pop => disable_pop_load + procedure(itt_proc_with_addr_size), pointer :: induction_uses => induction_uses_load + procedure(itt_proc_with_addr_size), pointer :: reduction_uses => reduction_uses_load + procedure(itt_proc_with_addr_size), pointer :: observe_uses => observe_uses_load + procedure(itt_proc_with_addr_size), pointer :: clear_uses => clear_uses_load + procedure(itt_proc_with_int), pointer :: aggregate_task => aggregate_task_load +!dec$ else + procedure(itt_proc_with_name), pointer :: site_begin + procedure(itt_proc_noargs), pointer :: site_end_2 + procedure(itt_proc_with_name), pointer :: task_begin + procedure(itt_proc_noargs), pointer :: task_end_2 + procedure(itt_proc_with_name), pointer :: iteration_task + procedure(itt_proc_with_int), pointer :: lock_acquire_2 + procedure(itt_proc_with_int), pointer :: lock_release_2 + procedure(itt_proc_with_disable), pointer :: disable_push + procedure(itt_proc_noargs), pointer :: disable_pop + procedure(itt_proc_with_addr_size), pointer :: induction_uses + procedure(itt_proc_with_addr_size), pointer :: reduction_uses + procedure(itt_proc_with_addr_size), pointer :: observe_uses + procedure(itt_proc_with_addr_size), pointer :: clear_uses + procedure(itt_proc_with_int), pointer :: aggregate_task + + logical :: initialized = .false. +!dec$ endif + + + !-------- + ! + ! Functions for loading dynamic libraries + ! + !-------- + + interface + + !dec$ if defined(_WIN32) + + !DEC$OBJCOMMENT LIB:"KERNEL32.LIB" + !DEC$OBJCOMMENT LIB:"advisor.lib" + + function load_library(file) + import + !dec$ attributes default, stdcall, decorate, alias : 'LoadLibraryA' :: load_library + type(C_PTR) :: load_library + character(kind=C_CHAR), dimension(*), intent(in) :: file + end function load_library + + function get_library_entry(library, proc_name) + import + !dec$ attributes default, stdcall, decorate, alias : 'GetProcAddress' :: get_library_entry + type(C_FUNPTR) :: get_library_entry + type(C_PTR), intent(in), value :: library + character(kind=C_CHAR), dimension(*), intent(in) :: proc_name + end function get_library_entry + + !dec$ else + + function load_library(file, mode) bind(C, name="dlopen") + import + type(C_PTR) :: load_library + character(kind=C_CHAR), dimension(*), intent(in) :: file + integer(kind=C_INT), intent(in), value :: mode + end function load_library + + function get_library_entry(library, proc_name) bind(C, name="dlsym") + import + type(C_FUNPTR) :: get_library_entry + type(C_PTR), intent(in), value :: library + character(kind=C_CHAR), dimension(*), intent(in) :: proc_name + end function get_library_entry + + !dec$ endif + + end interface + +contains + + !-------- + ! + ! The public interface subroutines just make sure the module has been initialized, + ! and then make an indirect call through the corresponding pointer variables. + ! Initializing the module tries to load the itt notify library. If the library + ! is loaded successfully, the variables are set to point to the corresponding + ! entries in the library. If the library load fails, the variables are set to point + ! to stub routines. + ! + !-------- + + subroutine annotate_site_begin(site_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_site_begin + character(len=*), intent(in) :: site_name + if (.not. initialized) call load_itt_library + call site_begin(site_name, len(site_name)) + end subroutine annotate_site_begin + + subroutine annotate_site_end + !DEC$ ATTRIBUTES DEFAULT :: annotate_site_end + if (.not. initialized) call load_itt_library + call site_end_2 + end subroutine annotate_site_end + + subroutine annotate_task_begin(task_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_task_begin + character(len=*), intent(in) :: task_name + if (.not. initialized) call load_itt_library + call task_begin(task_name, len(task_name)) + end subroutine annotate_task_begin + + subroutine annotate_task_end + !DEC$ ATTRIBUTES DEFAULT :: annotate_task_end + if (.not. initialized) call load_itt_library + call task_end_2 + end subroutine annotate_task_end + + subroutine annotate_iteration_task(task_name) + !DEC$ ATTRIBUTES DEFAULT :: annotate_iteration_task + character(len=*), intent(in) :: task_name + if (.not. initialized) call load_itt_library + call iteration_task(task_name, len(task_name)) + end subroutine annotate_iteration_task + + subroutine annotate_lock_acquire(lock_id) + !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_acquire + integer, intent(in) :: lock_id + if (.not. initialized) call load_itt_library + call lock_acquire_2(lock_id) + end subroutine annotate_lock_acquire + + subroutine annotate_lock_release(lock_id) + !DEC$ ATTRIBUTES DEFAULT :: annotate_lock_release + integer, intent(in) :: lock_id + if (.not. initialized) call load_itt_library + call lock_release_2(lock_id) + end subroutine annotate_lock_release + + subroutine annotate_disable_observation_push + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_push + if (.not. initialized) call load_itt_library + call disable_push(disable_observation) + end subroutine annotate_disable_observation_push + + subroutine annotate_disable_observation_pop + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_observation_pop + if (.not. initialized) call load_itt_library + call disable_pop + end subroutine annotate_disable_observation_pop + + subroutine annotate_disable_collection_push + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_push + if (.not. initialized) call load_itt_library + call disable_push(disable_collection) + end subroutine annotate_disable_collection_push + + subroutine annotate_disable_collection_pop + !DEC$ ATTRIBUTES DEFAULT :: annotate_disable_collection_pop + if (.not. initialized) call load_itt_library + call disable_pop + end subroutine annotate_disable_collection_pop + + subroutine annotate_induction_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 2) + end subroutine annotate_induction_uses_i2 + + subroutine annotate_induction_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 4) + end subroutine annotate_induction_uses_i4 + + subroutine annotate_induction_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_i8 + + subroutine annotate_induction_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 4) + end subroutine annotate_induction_uses_r4 + + subroutine annotate_induction_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_r8 + + subroutine annotate_induction_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call induction_uses(C_LOC(x), 8) + end subroutine annotate_induction_uses_c4 + + subroutine annotate_induction_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_induction_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 16) + end subroutine annotate_induction_uses_c8 + + subroutine annotate_reduction_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 2) + end subroutine annotate_reduction_uses_i2 + + subroutine annotate_reduction_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 4) + end subroutine annotate_reduction_uses_i4 + + subroutine annotate_reduction_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_i8 + + subroutine annotate_reduction_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 4) + end subroutine annotate_reduction_uses_r4 + + subroutine annotate_reduction_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_r8 + + subroutine annotate_reduction_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 8) + end subroutine annotate_reduction_uses_c4 + + subroutine annotate_reduction_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_reduction_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call reduction_uses(C_LOC(x), 16) + end subroutine annotate_reduction_uses_c8 + + subroutine annotate_observe_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 2) + end subroutine annotate_observe_uses_i2 + + subroutine annotate_observe_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 4) + end subroutine annotate_observe_uses_i4 + + subroutine annotate_observe_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_i8 + + subroutine annotate_observe_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 4) + end subroutine annotate_observe_uses_r4 + + subroutine annotate_observe_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_r8 + + subroutine annotate_observe_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 8) + end subroutine annotate_observe_uses_c4 + + subroutine annotate_observe_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_observe_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call observe_uses(C_LOC(x), 16) + end subroutine annotate_observe_uses_c8 + + subroutine annotate_clear_uses_i2(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i2 + integer(kind=2), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 2) + end subroutine annotate_clear_uses_i2 + + subroutine annotate_clear_uses_i4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i4 + integer(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 4) + end subroutine annotate_clear_uses_i4 + + subroutine annotate_clear_uses_i8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_i8 + integer(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_i8 + + subroutine annotate_clear_uses_r4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r4 + real(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 4) + end subroutine annotate_clear_uses_r4 + + subroutine annotate_clear_uses_r8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_r8 + real(kind=8), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_r8 + + subroutine annotate_clear_uses_c4(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c4 + complex(kind=4), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 8) + end subroutine annotate_clear_uses_c4 + + subroutine annotate_clear_uses_c8(x) + !DEC$ ATTRIBUTES DEFAULT :: annotate_clear_uses_c8 + complex(kind=16), intent(in) :: x + if (.not. initialized) call load_itt_library + call clear_uses(C_LOC(x), 16) + end subroutine annotate_clear_uses_c8 + + subroutine annotate_aggregate_task(count) + !DEC$ ATTRIBUTES DEFAULT :: annotate_aggregate_task + integer, intent(in) :: count + if (.not. initialized) call load_itt_library + call aggregate_task(count) + end subroutine annotate_aggregate_task + + + !-------- + ! + ! These are the load-library subroutines. + ! + !-------- + +!dec$ if defined(use_initialized_proc_ptrs) + + subroutine site_begin_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call site_begin(name, len) + end subroutine site_begin_load + + subroutine site_end_2_load bind(C) + call load_itt_library + call site_end_2 + end subroutine site_end_2_load + + subroutine task_begin_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call task_begin(name, len) + end subroutine task_begin_load + + subroutine task_end_2_load bind(C) + call load_itt_library + call task_end_2 + end subroutine task_end_2_load + + subroutine iteration_task_load(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + call load_itt_library + call iteration_task(name, len) + end subroutine iteration_task_load + + subroutine lock_acquire_2_load(lock_id) bind(C) + integer(kind=C_INT), intent(in), value :: lock_id + call load_itt_library + call lock_acquire_2(lock_id) + end subroutine lock_acquire_2_load + + subroutine lock_release_2_load(lock_id) bind(C) + integer(kind=C_INT), intent(in), value :: lock_id + call load_itt_library + call lock_release_2(lock_id) + end subroutine lock_release_2_load + + subroutine disable_push_load(disable_kind) bind(C) + integer(kind=C_INT), intent(in), value :: disable_kind + call load_itt_library + call disable_push(disable_kind) + end subroutine disable_push_load + + subroutine disable_pop_load bind(C) + call load_itt_library + call disable_pop + end subroutine disable_pop_load + + subroutine induction_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call induction_uses(addr, size) + end subroutine induction_uses_load + + subroutine reduction_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call reduction_uses(addr, size) + end subroutine reduction_uses_load + + subroutine observe_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call observe_uses(addr, size) + end subroutine observe_uses_load + + subroutine clear_uses_load(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + call itt_load_library + call clear_uses(addr, size) + end subroutine clear_uses_load + + subroutine annotate_task_load(count) bind(C) + integer(kind=C_INT), intent(in), value :: count + call load_itt_library + call annotate_task(count) + end subroutine annotate_task_load + +!dec$ endif + + !-------- + ! + ! These are the stub subroutines. + ! + !-------- + + subroutine itt_proc_stub() bind(C) + end subroutine itt_proc_stub + + subroutine itt_proc_with_name_stub(name, len) bind(C) + character, dimension(*), intent(in) :: name + integer(kind=C_INT), intent(in), value :: len + end subroutine itt_proc_with_name_stub + + subroutine itt_proc_with_int_stub(count) bind(C) + integer(kind=C_INT), intent(in), value :: count + end subroutine itt_proc_with_int_stub + + subroutine itt_proc_with_disable_stub(disable_kind) bind(C) + integer(kind=C_INT), value :: disable_kind + end subroutine itt_proc_with_disable_stub + + subroutine itt_proc_with_addr_size_stub(addr, size) bind(C) + type(C_PTR), intent(in), value :: addr + integer(kind=C_INT), intent(in), value :: size + end subroutine itt_proc_with_addr_size_stub + + !-------- + ! + ! Internal support code to load the itt notify library and get pointers + ! to its entry points. + ! + !-------- + + subroutine load_itt_library + type(C_PTR) :: library + character*1024 ittnotify_path + +!dec$ if defined(_WIN32) + library = load_library("libittnotify.dll"C) +!dec$ else if defined(__APPLE__) + library = load_library("libittnotify.dylib"C, 0) +!dec$ else +!dec$ if defined(__X86_64) .or. defined(_M_X64) + call getenv('INTEL_LIBITTNOTIFY64',ittnotify_path) +!dec$ else + call getenv('INTEL_LIBITTNOTIFY32',ittnotify_path) +!dec$ endif + if ( ittnotify_path /= '' ) then + ! print *,' libpath: "'//trim(ittnotify_path)//'"' + library = load_library(trim(ittnotify_path)//char(0), 1) ! 1 is RTLD_LAZY + else + ! print *,' libpath: "libittnotify.so"' + library = load_library("libittnotify.so"C, 1) ! 1 is RTLD_LAZY + endif +!dec$ endif + + if (C_ASSOCIATED(library)) then + ! print *, "Library loaded" + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_beginAL"C), site_begin) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_site_end_2"C), site_end_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_beginAL"C), task_begin) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_task_end_2"C), task_end_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_iteration_taskAL"C), iteration_task) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_acquire_2"C), lock_acquire_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_lock_release_2"C), lock_release_2) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_push"C), disable_push) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_disable_pop"C), disable_pop) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_induction_uses"C), induction_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_reduction_uses"C), reduction_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_observe_uses"C), observe_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_clear_uses"C), clear_uses) + call C_F_PROCPOINTER(get_library_entry(library, "__itt_model_aggregate_task"C), aggregate_task) + else + ! print *, "Library not found" + site_begin => itt_proc_with_name_stub + site_end_2 => itt_proc_stub + task_begin => itt_proc_with_name_stub + task_end_2 => itt_proc_stub + iteration_task => itt_proc_with_name_stub + lock_acquire_2 => itt_proc_with_int_stub + lock_release_2 => itt_proc_with_int_stub + disable_push => itt_proc_with_disable_stub + disable_pop => itt_proc_stub + induction_uses => itt_proc_with_addr_size_stub + reduction_uses => itt_proc_with_addr_size_stub + observe_uses => itt_proc_with_addr_size_stub + clear_uses => itt_proc_with_addr_size_stub + aggregate_task => itt_proc_with_int_stub + end if + + initialized = .true. + end subroutine + +end module advisor_annotate diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/internal/ittnotify.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/internal/ittnotify.h index 43f4f1f3ae..49fcbc2ec5 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/internal/ittnotify.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/internal/ittnotify.h @@ -1,260 +1,260 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _INTERNAL_ITTNOTIFY_H_ -#define _INTERNAL_ITTNOTIFY_H_ - -/** - * @file - * @brief Internal User API functions and types - */ - -/** @cond exclude_from_documentation */ -#ifndef ITT_OS_WIN -# define ITT_OS_WIN 1 -#endif /* ITT_OS_WIN */ - -#ifndef ITT_OS_LINUX -# define ITT_OS_LINUX 2 -#endif /* ITT_OS_LINUX */ - -#ifndef ITT_OS_MAC -# define ITT_OS_MAC 3 -#endif /* ITT_OS_MAC */ - -#ifndef ITT_OS_FREEBSD -# define ITT_OS_FREEBSD 4 -#endif /* ITT_OS_FREEBSD */ - -#ifndef ITT_OS -# if defined WIN32 || defined _WIN32 -# define ITT_OS ITT_OS_WIN -# elif defined( __APPLE__ ) && defined( __MACH__ ) -# define ITT_OS ITT_OS_MAC -# elif defined( __FreeBSD__ ) -# define ITT_OS ITT_OS_FREEBSD -# else -# define ITT_OS ITT_OS_LINUX -# endif -#endif /* ITT_OS */ - -#ifndef ITT_PLATFORM_WIN -# define ITT_PLATFORM_WIN 1 -#endif /* ITT_PLATFORM_WIN */ - -#ifndef ITT_PLATFORM_POSIX -# define ITT_PLATFORM_POSIX 2 -#endif /* ITT_PLATFORM_POSIX */ - -#ifndef ITT_PLATFORM_MAC -# define ITT_PLATFORM_MAC 3 -#endif /* ITT_PLATFORM_MAC */ - -#ifndef ITT_PLATFORM_FREEBSD -# define ITT_PLATFORM_FREEBSD 4 -#endif /* ITT_PLATFORM_FREEBSD */ - -#ifndef ITT_PLATFORM -# if ITT_OS==ITT_OS_WIN -# define ITT_PLATFORM ITT_PLATFORM_WIN -# elif ITT_OS==ITT_OS_MAC -# define ITT_PLATFORM ITT_PLATFORM_MAC -# elif ITT_OS==ITT_OS_FREEBSD -# define ITT_PLATFORM ITT_PLATFORM_FREEBSD -# else -# define ITT_PLATFORM ITT_PLATFORM_POSIX -# endif -#endif /* ITT_PLATFORM */ - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif - -#include -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE || _UNICODE */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef CDECL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define CDECL __cdecl -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* CDECL */ - -#ifndef STDCALL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define STDCALL __stdcall -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define STDCALL __attribute__ ((stdcall)) -# else /* _M_IX86 || __i386__ */ -# define STDCALL /* supported only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* STDCALL */ - -#define ITTAPI CDECL -#define LIBITTAPI CDECL - -/* TODO: Temporary for compatibility! */ -#define ITTAPI_CALL CDECL -#define LIBITTAPI_CALL CDECL - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -/* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline -#define ITT_INLINE_ATTRIBUTE /* nothing */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/* - * Generally, functions are not inlined unless optimization is specified. - * For functions declared inline, this attribute inlines the function even - * if no optimization level was specified. - */ -#ifdef __STRICT_ANSI__ -#define ITT_INLINE static -#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) -#else /* __STRICT_ANSI__ */ -#define ITT_INLINE static inline -#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) -#endif /* __STRICT_ANSI__ */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/** @endcond */ - -/** @cond exclude_from_documentation */ -/* Helper macro for joining tokens */ -#define ITT_JOIN_AUX(p,n) p##n -#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) - -#ifdef ITT_MAJOR -#undef ITT_MAJOR -#endif -#ifdef ITT_MINOR -#undef ITT_MINOR -#endif -#define ITT_MAJOR 3 -#define ITT_MINOR 0 - -/* Standard versioning of a token with major and minor version numbers */ -#define ITT_VERSIONIZE(x) \ - ITT_JOIN(x, \ - ITT_JOIN(_, \ - ITT_JOIN(ITT_MAJOR, \ - ITT_JOIN(_, ITT_MINOR)))) - -#ifndef INTEL_ITTNOTIFY_PREFIX -# define INTEL_ITTNOTIFY_PREFIX __itt_ -#endif /* INTEL_ITTNOTIFY_PREFIX */ -#ifndef INTEL_ITTNOTIFY_POSTFIX -# define INTEL_ITTNOTIFY_POSTFIX _ptr_ -#endif /* INTEL_ITTNOTIFY_POSTFIX */ - -#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) -#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) - -#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) -#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) - -#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) -#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) - -#ifdef ITT_STUB -#undef ITT_STUB -#endif -#ifdef ITT_STUBV -#undef ITT_STUBV -#endif -#define ITT_STUBV(api,type,name,args) \ - typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ - extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); -#define ITT_STUB ITT_STUBV -/** @endcond */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define INTEL_ITTNOTIFY_API_PRIVATE -#include "../ittnotify.h" - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _INTERNAL_ITTNOTIFY_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _INTERNAL_ITTNOTIFY_H_ +#define _INTERNAL_ITTNOTIFY_H_ + +/** + * @file + * @brief Internal User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define INTEL_ITTNOTIFY_API_PRIVATE +#include "../ittnotify.h" + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _INTERNAL_ITTNOTIFY_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/ittnotify.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/ittnotify.h index 1ce41c8260..6ed58b7356 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/ittnotify.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/ittnotify.h @@ -1,4123 +1,4123 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _ITTNOTIFY_H_ -#define _ITTNOTIFY_H_ - -/** -@file -@brief Public User API functions and types -@mainpage - -The ITT API is used to annotate a user's program with additional information -that can be used by correctness and performance tools. The user inserts -calls in their program. Those calls generate information that is collected -at runtime, and used by Intel(R) Threading Tools. - -@section API Concepts -The following general concepts are used throughout the API. - -@subsection Unicode Support -Many API functions take character string arguments. On Windows, there -are two versions of each such function. The function name is suffixed -by W if Unicode support is enabled, and by A otherwise. Any API function -that takes a character string argument adheres to this convention. - -@subsection Conditional Compilation -Many users prefer having an option to modify ITT API code when linking it -inside their runtimes. ITT API header file provides a mechanism to replace -ITT API function names inside your code with empty strings. To do this, -define the macros INTEL_NO_ITTNOTIFY_API during compilation and remove the -static library from the linker script. - -@subsection Domains -[see domains] -Domains provide a way to separate notification for different modules or -libraries in a program. Domains are specified by dotted character strings, -e.g. TBB.Internal.Control. - -A mechanism (to be specified) is provided to enable and disable -domains. By default, all domains are enabled. -@subsection Named Entities and Instances -Named entities (frames, regions, tasks, and markers) communicate -information about the program to the analysis tools. A named entity often -refers to a section of program code, or to some set of logical concepts -that the programmer wants to group together. - -Named entities relate to the programmer's static view of the program. When -the program actually executes, many instances of a given named entity -may be created. - -The API annotations denote instances of named entities. The actual -named entities are displayed using the analysis tools. In other words, -the named entities come into existence when instances are created. - -Instances of named entities may have instance identifiers (IDs). Some -API calls use instance identifiers to create relationships between -different instances of named entities. Other API calls associate data -with instances of named entities. - -Some named entities must always have instance IDs. In particular, regions -and frames always have IDs. Task and markers need IDs only if the ID is -needed in another API call (such as adding a relation or metadata). - -The lifetime of instance IDs is distinct from the lifetime of -instances. This allows various relationships to be specified separate -from the actual execution of instances. This flexibility comes at the -expense of extra API calls. - -The same ID may not be reused for different instances, unless a previous -[ref] __itt_id_destroy call for that ID has been issued. -*/ - -/** @cond exclude_from_documentation */ -#ifndef ITT_OS_WIN -# define ITT_OS_WIN 1 -#endif /* ITT_OS_WIN */ - -#ifndef ITT_OS_LINUX -# define ITT_OS_LINUX 2 -#endif /* ITT_OS_LINUX */ - -#ifndef ITT_OS_MAC -# define ITT_OS_MAC 3 -#endif /* ITT_OS_MAC */ - -#ifndef ITT_OS_FREEBSD -# define ITT_OS_FREEBSD 4 -#endif /* ITT_OS_FREEBSD */ - -#ifndef ITT_OS -# if defined WIN32 || defined _WIN32 -# define ITT_OS ITT_OS_WIN -# elif defined( __APPLE__ ) && defined( __MACH__ ) -# define ITT_OS ITT_OS_MAC -# elif defined( __FreeBSD__ ) -# define ITT_OS ITT_OS_FREEBSD -# else -# define ITT_OS ITT_OS_LINUX -# endif -#endif /* ITT_OS */ - -#ifndef ITT_PLATFORM_WIN -# define ITT_PLATFORM_WIN 1 -#endif /* ITT_PLATFORM_WIN */ - -#ifndef ITT_PLATFORM_POSIX -# define ITT_PLATFORM_POSIX 2 -#endif /* ITT_PLATFORM_POSIX */ - -#ifndef ITT_PLATFORM_MAC -# define ITT_PLATFORM_MAC 3 -#endif /* ITT_PLATFORM_MAC */ - -#ifndef ITT_PLATFORM_FREEBSD -# define ITT_PLATFORM_FREEBSD 4 -#endif /* ITT_PLATFORM_FREEBSD */ - -#ifndef ITT_PLATFORM -# if ITT_OS==ITT_OS_WIN -# define ITT_PLATFORM ITT_PLATFORM_WIN -# elif ITT_OS==ITT_OS_MAC -# define ITT_PLATFORM ITT_PLATFORM_MAC -# elif ITT_OS==ITT_OS_FREEBSD -# define ITT_PLATFORM ITT_PLATFORM_FREEBSD -# else -# define ITT_PLATFORM ITT_PLATFORM_POSIX -# endif -#endif /* ITT_PLATFORM */ - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif - -#include -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE || _UNICODE */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef CDECL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define CDECL __cdecl -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* CDECL */ - -#ifndef STDCALL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define STDCALL __stdcall -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define STDCALL __attribute__ ((stdcall)) -# else /* _M_IX86 || __i386__ */ -# define STDCALL /* supported only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* STDCALL */ - -#define ITTAPI CDECL -#define LIBITTAPI CDECL - -/* TODO: Temporary for compatibility! */ -#define ITTAPI_CALL CDECL -#define LIBITTAPI_CALL CDECL - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -/* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline -#define ITT_INLINE_ATTRIBUTE /* nothing */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/* - * Generally, functions are not inlined unless optimization is specified. - * For functions declared inline, this attribute inlines the function even - * if no optimization level was specified. - */ -#ifdef __STRICT_ANSI__ -#define ITT_INLINE static -#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) -#else /* __STRICT_ANSI__ */ -#define ITT_INLINE static inline -#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) -#endif /* __STRICT_ANSI__ */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/** @endcond */ - -#ifdef INTEL_ITTNOTIFY_ENABLE_LEGACY -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# pragma message("WARNING!!! Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro") -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# warning "Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro" -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# include "legacy/ittnotify.h" -#endif /* INTEL_ITTNOTIFY_ENABLE_LEGACY */ - -/** @cond exclude_from_documentation */ -/* Helper macro for joining tokens */ -#define ITT_JOIN_AUX(p,n) p##n -#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) - -#ifdef ITT_MAJOR -#undef ITT_MAJOR -#endif -#ifdef ITT_MINOR -#undef ITT_MINOR -#endif -#define ITT_MAJOR 3 -#define ITT_MINOR 0 - -/* Standard versioning of a token with major and minor version numbers */ -#define ITT_VERSIONIZE(x) \ - ITT_JOIN(x, \ - ITT_JOIN(_, \ - ITT_JOIN(ITT_MAJOR, \ - ITT_JOIN(_, ITT_MINOR)))) - -#ifndef INTEL_ITTNOTIFY_PREFIX -# define INTEL_ITTNOTIFY_PREFIX __itt_ -#endif /* INTEL_ITTNOTIFY_PREFIX */ -#ifndef INTEL_ITTNOTIFY_POSTFIX -# define INTEL_ITTNOTIFY_POSTFIX _ptr_ -#endif /* INTEL_ITTNOTIFY_POSTFIX */ - -#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) -#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) - -#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) -#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) - -#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) -#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) - -#ifdef ITT_STUB -#undef ITT_STUB -#endif -#ifdef ITT_STUBV -#undef ITT_STUBV -#endif -#define ITT_STUBV(api,type,name,args) \ - typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ - extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); -#define ITT_STUB ITT_STUBV -/** @endcond */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** @cond exclude_from_gpa_documentation */ -/** - * @defgroup public Public API - * @{ - * @} - */ - -/** - * @defgroup control Collection Control - * @ingroup public - * General behavior: application continues to run, but no profiling information is being collected - * - * Pausing occurs not only for the current thread but for all process as well as spawned processes - * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: - * - Does not analyze or report errors that involve memory access. - * - Other errors are reported as usual. Pausing data collection in - * Intel(R) Parallel Inspector and Intel(R) Inspector XE - * only pauses tracing and analyzing memory access. - * It does not pause tracing or analyzing threading APIs. - * . - * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: - * - Does continue to record when new threads are started. - * . - * - Other effects: - * - Possible reduction of runtime overhead. - * . - * @{ - */ -/** @brief Pause collection */ -void ITTAPI __itt_pause(void); -/** @brief Resume collection */ -void ITTAPI __itt_resume(void); -/** @brief Detach collection */ -void ITTAPI __itt_detach(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, pause, (void)) -ITT_STUBV(ITTAPI, void, resume, (void)) -ITT_STUBV(ITTAPI, void, detach, (void)) -#define __itt_pause ITTNOTIFY_VOID(pause) -#define __itt_pause_ptr ITTNOTIFY_NAME(pause) -#define __itt_resume ITTNOTIFY_VOID(resume) -#define __itt_resume_ptr ITTNOTIFY_NAME(resume) -#define __itt_detach ITTNOTIFY_VOID(detach) -#define __itt_detach_ptr ITTNOTIFY_NAME(detach) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_pause() -#define __itt_pause_ptr 0 -#define __itt_resume() -#define __itt_resume_ptr 0 -#define __itt_detach() -#define __itt_detach_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_pause_ptr 0 -#define __itt_resume_ptr 0 -#define __itt_detach_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} control group */ -/** @endcond */ - -/** - * @defgroup threads Threads - * @ingroup public - * Give names to threads - * @{ - */ -/** - * @brief Sets thread name of calling thread - * @param[in] name - name of thread - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_thread_set_nameA(const char *name); -void ITTAPI __itt_thread_set_nameW(const wchar_t *name); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_thread_set_name __itt_thread_set_nameW -# define __itt_thread_set_name_ptr __itt_thread_set_nameW_ptr -#else /* UNICODE */ -# define __itt_thread_set_name __itt_thread_set_nameA -# define __itt_thread_set_name_ptr __itt_thread_set_nameA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_thread_set_name(const char *name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name)) -ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thread_set_nameA ITTNOTIFY_VOID(thread_set_nameA) -#define __itt_thread_set_nameA_ptr ITTNOTIFY_NAME(thread_set_nameA) -#define __itt_thread_set_nameW ITTNOTIFY_VOID(thread_set_nameW) -#define __itt_thread_set_nameW_ptr ITTNOTIFY_NAME(thread_set_nameW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thread_set_name ITTNOTIFY_VOID(thread_set_name) -#define __itt_thread_set_name_ptr ITTNOTIFY_NAME(thread_set_name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thread_set_nameA(name) -#define __itt_thread_set_nameA_ptr 0 -#define __itt_thread_set_nameW(name) -#define __itt_thread_set_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thread_set_name(name) -#define __itt_thread_set_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thread_set_nameA_ptr 0 -#define __itt_thread_set_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thread_set_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @cond exclude_from_gpa_documentation */ - -/** - * @brief Mark current thread as ignored from this point on, for the duration of its existence. - */ -void ITTAPI __itt_thread_ignore(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, thread_ignore, (void)) -#define __itt_thread_ignore ITTNOTIFY_VOID(thread_ignore) -#define __itt_thread_ignore_ptr ITTNOTIFY_NAME(thread_ignore) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_thread_ignore() -#define __itt_thread_ignore_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_thread_ignore_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} threads group */ - -/** - * @defgroup suppress Error suppression - * @ingroup public - * General behavior: application continues to run, but errors are suppressed - * - * @{ - */ - -/*****************************************************************//** - * @name group of functions used for error suppression in correctness tools - *********************************************************************/ -/** @{ */ -/** - * @hideinitializer - * @brief possible value for suppression mask - */ -#define __itt_suppress_all_errors 0x7fffffff - -/** - * @hideinitializer - * @brief possible value for suppression mask (suppresses errors from threading analysis) - */ -#define __itt_suppress_threading_errors 0x000000ff - -/** - * @hideinitializer - * @brief possible value for suppression mask (suppresses errors from memory analysis) - */ -#define __itt_suppress_memory_errors 0x0000ff00 - -/** - * @brief Start suppressing errors identified in mask on this thread - */ -void ITTAPI __itt_suppress_push(unsigned int mask); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask)) -#define __itt_suppress_push ITTNOTIFY_VOID(suppress_push) -#define __itt_suppress_push_ptr ITTNOTIFY_NAME(suppress_push) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_suppress_push(mask) -#define __itt_suppress_push_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_suppress_push_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Undo the effects of the matching call to __itt_suppress_push - */ -void ITTAPI __itt_suppress_pop(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, suppress_pop, (void)) -#define __itt_suppress_pop ITTNOTIFY_VOID(suppress_pop) -#define __itt_suppress_pop_ptr ITTNOTIFY_NAME(suppress_pop) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_suppress_pop() -#define __itt_suppress_pop_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_suppress_pop_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @enum __itt_model_disable - * @brief Enumerator for the disable methods - */ -typedef enum __itt_suppress_mode { - __itt_unsuppress_range, - __itt_suppress_range -} __itt_suppress_mode_t; - -/** - * @brief Mark a range of memory for error suppression or unsuppression for error types included in mask - */ -void ITTAPI __itt_suppress_mark_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) -#define __itt_suppress_mark_range ITTNOTIFY_VOID(suppress_mark_range) -#define __itt_suppress_mark_range_ptr ITTNOTIFY_NAME(suppress_mark_range) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_suppress_mark_range(mask) -#define __itt_suppress_mark_range_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_suppress_mark_range_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Undo the effect of a matching call to __itt_suppress_mark_range. If not matching - * call is found, nothing is changed. - */ -void ITTAPI __itt_suppress_clear_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, suppress_clear_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) -#define __itt_suppress_clear_range ITTNOTIFY_VOID(suppress_clear_range) -#define __itt_suppress_clear_range_ptr ITTNOTIFY_NAME(suppress_clear_range) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_suppress_clear_range(mask) -#define __itt_suppress_clear_range_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_suppress_clear_range_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} */ -/** @} suppress group */ - -/** - * @defgroup sync Synchronization - * @ingroup public - * Indicate user-written synchronization code - * @{ - */ -/** - * @hideinitializer - * @brief possible value of attribute argument for sync object type - */ -#define __itt_attr_barrier 1 - -/** - * @hideinitializer - * @brief possible value of attribute argument for sync object type - */ -#define __itt_attr_mutex 2 - -/** -@brief Name a synchronization object -@param[in] addr Handle for the synchronization object. You should -use a real address to uniquely identify the synchronization object. -@param[in] objtype null-terminated object type string. If NULL is -passed, the name will be "User Synchronization". -@param[in] objname null-terminated object name string. If NULL, -no name will be assigned to the object. -@param[in] attribute one of [#__itt_attr_barrier, #__itt_attr_mutex] - */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_sync_createA(void *addr, const char *objtype, const char *objname, int attribute); -void ITTAPI __itt_sync_createW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_sync_create __itt_sync_createW -# define __itt_sync_create_ptr __itt_sync_createW_ptr -#else /* UNICODE */ -# define __itt_sync_create __itt_sync_createA -# define __itt_sync_create_ptr __itt_sync_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_sync_create (void *addr, const char *objtype, const char *objname, int attribute); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute)) -ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char* objtype, const char* objname, int attribute)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_createA ITTNOTIFY_VOID(sync_createA) -#define __itt_sync_createA_ptr ITTNOTIFY_NAME(sync_createA) -#define __itt_sync_createW ITTNOTIFY_VOID(sync_createW) -#define __itt_sync_createW_ptr ITTNOTIFY_NAME(sync_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_create ITTNOTIFY_VOID(sync_create) -#define __itt_sync_create_ptr ITTNOTIFY_NAME(sync_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_createA(addr, objtype, objname, attribute) -#define __itt_sync_createA_ptr 0 -#define __itt_sync_createW(addr, objtype, objname, attribute) -#define __itt_sync_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_create(addr, objtype, objname, attribute) -#define __itt_sync_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_createA_ptr 0 -#define __itt_sync_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** -@brief Rename a synchronization object - -You can use the rename call to assign or reassign a name to a given -synchronization object. -@param[in] addr handle for the synchronization object. -@param[in] name null-terminated object name string. -*/ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_sync_renameA(void *addr, const char *name); -void ITTAPI __itt_sync_renameW(void *addr, const wchar_t *name); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_sync_rename __itt_sync_renameW -# define __itt_sync_rename_ptr __itt_sync_renameW_ptr -#else /* UNICODE */ -# define __itt_sync_rename __itt_sync_renameA -# define __itt_sync_rename_ptr __itt_sync_renameA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_sync_rename(void *addr, const char *name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name)) -ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_renameA ITTNOTIFY_VOID(sync_renameA) -#define __itt_sync_renameA_ptr ITTNOTIFY_NAME(sync_renameA) -#define __itt_sync_renameW ITTNOTIFY_VOID(sync_renameW) -#define __itt_sync_renameW_ptr ITTNOTIFY_NAME(sync_renameW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_rename ITTNOTIFY_VOID(sync_rename) -#define __itt_sync_rename_ptr ITTNOTIFY_NAME(sync_rename) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_renameA(addr, name) -#define __itt_sync_renameA_ptr 0 -#define __itt_sync_renameW(addr, name) -#define __itt_sync_renameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_rename(addr, name) -#define __itt_sync_rename_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_renameA_ptr 0 -#define __itt_sync_renameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_rename_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - @brief Destroy a synchronization object. - @param addr Handle for the synchronization object. - */ -void ITTAPI __itt_sync_destroy(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr)) -#define __itt_sync_destroy ITTNOTIFY_VOID(sync_destroy) -#define __itt_sync_destroy_ptr ITTNOTIFY_NAME(sync_destroy) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_sync_destroy(addr) -#define __itt_sync_destroy_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_sync_destroy_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/*****************************************************************//** - * @name group of functions is used for performance measurement tools - *********************************************************************/ -/** @{ */ -/** - * @brief Enter spin loop on user-defined sync object - */ -void ITTAPI __itt_sync_prepare(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, sync_prepare, (void *addr)) -#define __itt_sync_prepare ITTNOTIFY_VOID(sync_prepare) -#define __itt_sync_prepare_ptr ITTNOTIFY_NAME(sync_prepare) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_sync_prepare(addr) -#define __itt_sync_prepare_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_sync_prepare_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Quit spin loop without acquiring spin object - */ -void ITTAPI __itt_sync_cancel(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr)) -#define __itt_sync_cancel ITTNOTIFY_VOID(sync_cancel) -#define __itt_sync_cancel_ptr ITTNOTIFY_NAME(sync_cancel) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_sync_cancel(addr) -#define __itt_sync_cancel_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_sync_cancel_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Successful spin loop completion (sync object acquired) - */ -void ITTAPI __itt_sync_acquired(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr)) -#define __itt_sync_acquired ITTNOTIFY_VOID(sync_acquired) -#define __itt_sync_acquired_ptr ITTNOTIFY_NAME(sync_acquired) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_sync_acquired(addr) -#define __itt_sync_acquired_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_sync_acquired_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Start sync object releasing code. Is called before the lock release call. - */ -void ITTAPI __itt_sync_releasing(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, sync_releasing, (void *addr)) -#define __itt_sync_releasing ITTNOTIFY_VOID(sync_releasing) -#define __itt_sync_releasing_ptr ITTNOTIFY_NAME(sync_releasing) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_sync_releasing(addr) -#define __itt_sync_releasing_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_sync_releasing_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} */ - -/** @} sync group */ - -/**************************************************************//** - * @name group of functions is used for correctness checking tools - ******************************************************************/ -/** @{ */ -/** - * @ingroup legacy - * @deprecated Legacy API - * @brief Fast synchronization which does no require spinning. - * - This special function is to be used by TBB and OpenMP libraries only when they know - * there is no spin but they need to suppress TC warnings about shared variable modifications. - * - It only has corresponding pointers in static library and does not have corresponding function - * in dynamic library. - * @see void __itt_sync_prepare(void* addr); - */ -void ITTAPI __itt_fsync_prepare(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, fsync_prepare, (void *addr)) -#define __itt_fsync_prepare ITTNOTIFY_VOID(fsync_prepare) -#define __itt_fsync_prepare_ptr ITTNOTIFY_NAME(fsync_prepare) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_fsync_prepare(addr) -#define __itt_fsync_prepare_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_fsync_prepare_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup legacy - * @deprecated Legacy API - * @brief Fast synchronization which does no require spinning. - * - This special function is to be used by TBB and OpenMP libraries only when they know - * there is no spin but they need to suppress TC warnings about shared variable modifications. - * - It only has corresponding pointers in static library and does not have corresponding function - * in dynamic library. - * @see void __itt_sync_cancel(void *addr); - */ -void ITTAPI __itt_fsync_cancel(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr)) -#define __itt_fsync_cancel ITTNOTIFY_VOID(fsync_cancel) -#define __itt_fsync_cancel_ptr ITTNOTIFY_NAME(fsync_cancel) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_fsync_cancel(addr) -#define __itt_fsync_cancel_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_fsync_cancel_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup legacy - * @deprecated Legacy API - * @brief Fast synchronization which does no require spinning. - * - This special function is to be used by TBB and OpenMP libraries only when they know - * there is no spin but they need to suppress TC warnings about shared variable modifications. - * - It only has corresponding pointers in static library and does not have corresponding function - * in dynamic library. - * @see void __itt_sync_acquired(void *addr); - */ -void ITTAPI __itt_fsync_acquired(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr)) -#define __itt_fsync_acquired ITTNOTIFY_VOID(fsync_acquired) -#define __itt_fsync_acquired_ptr ITTNOTIFY_NAME(fsync_acquired) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_fsync_acquired(addr) -#define __itt_fsync_acquired_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_fsync_acquired_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup legacy - * @deprecated Legacy API - * @brief Fast synchronization which does no require spinning. - * - This special function is to be used by TBB and OpenMP libraries only when they know - * there is no spin but they need to suppress TC warnings about shared variable modifications. - * - It only has corresponding pointers in static library and does not have corresponding function - * in dynamic library. - * @see void __itt_sync_releasing(void* addr); - */ -void ITTAPI __itt_fsync_releasing(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, fsync_releasing, (void *addr)) -#define __itt_fsync_releasing ITTNOTIFY_VOID(fsync_releasing) -#define __itt_fsync_releasing_ptr ITTNOTIFY_NAME(fsync_releasing) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_fsync_releasing(addr) -#define __itt_fsync_releasing_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_fsync_releasing_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} */ - -/** - * @defgroup model Modeling by Intel(R) Parallel Advisor - * @ingroup public - * This is the subset of itt used for modeling by Intel(R) Parallel Advisor. - * This API is called ONLY using annotate.h, by "Annotation" macros - * the user places in their sources during the parallelism modeling steps. - * - * site_begin/end and task_begin/end take the address of handle variables, - * which are writeable by the API. Handles must be 0 initialized prior - * to the first call to begin, or may cause a run-time failure. - * The handles are initialized in a multi-thread safe way by the API if - * the handle is 0. The commonly expected idiom is one static handle to - * identify a site or task. If a site or task of the same name has already - * been started during this collection, the same handle MAY be returned, - * but is not required to be - it is unspecified if data merging is done - * based on name. These routines also take an instance variable. Like - * the lexical instance, these must be 0 initialized. Unlike the lexical - * instance, this is used to track a single dynamic instance. - * - * API used by the Intel(R) Parallel Advisor to describe potential concurrency - * and related activities. User-added source annotations expand to calls - * to these procedures to enable modeling of a hypothetical concurrent - * execution serially. - * @{ - */ -#if !defined(_ADVISOR_ANNOTATE_H_) || defined(ANNOTATE_EXPAND_NULL) - -typedef void* __itt_model_site; /*!< @brief handle for lexical site */ -typedef void* __itt_model_site_instance; /*!< @brief handle for dynamic instance */ -typedef void* __itt_model_task; /*!< @brief handle for lexical site */ -typedef void* __itt_model_task_instance; /*!< @brief handle for dynamic instance */ - -/** - * @enum __itt_model_disable - * @brief Enumerator for the disable methods - */ -typedef enum { - __itt_model_disable_observation, - __itt_model_disable_collection -} __itt_model_disable; - -#endif /* !_ADVISOR_ANNOTATE_H_ || ANNOTATE_EXPAND_NULL */ - -/** - * @brief ANNOTATE_SITE_BEGIN/ANNOTATE_SITE_END support. - * - * site_begin/end model a potential concurrency site. - * site instances may be recursively nested with themselves. - * site_end exits the most recently started but unended site for the current - * thread. The handle passed to end may be used to validate structure. - * Instances of a site encountered on different threads concurrently - * are considered completely distinct. If the site name for two different - * lexical sites match, it is unspecified whether they are treated as the - * same or different for data presentation. - */ -void ITTAPI __itt_model_site_begin(__itt_model_site *site, __itt_model_site_instance *instance, const char *name); -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_model_site_beginW(const wchar_t *name); -#endif -void ITTAPI __itt_model_site_beginA(const char *name); -void ITTAPI __itt_model_site_beginAL(const char *name, size_t siteNameLen); -void ITTAPI __itt_model_site_end (__itt_model_site *site, __itt_model_site_instance *instance); -void ITTAPI __itt_model_site_end_2(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name)) -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name)) -#endif -ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name)) -ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t siteNameLen)) -ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance)) -ITT_STUBV(ITTAPI, void, model_site_end_2, (void)) -#define __itt_model_site_begin ITTNOTIFY_VOID(model_site_begin) -#define __itt_model_site_begin_ptr ITTNOTIFY_NAME(model_site_begin) -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_site_beginW ITTNOTIFY_VOID(model_site_beginW) -#define __itt_model_site_beginW_ptr ITTNOTIFY_NAME(model_site_beginW) -#endif -#define __itt_model_site_beginA ITTNOTIFY_VOID(model_site_beginA) -#define __itt_model_site_beginA_ptr ITTNOTIFY_NAME(model_site_beginA) -#define __itt_model_site_beginAL ITTNOTIFY_VOID(model_site_beginAL) -#define __itt_model_site_beginAL_ptr ITTNOTIFY_NAME(model_site_beginAL) -#define __itt_model_site_end ITTNOTIFY_VOID(model_site_end) -#define __itt_model_site_end_ptr ITTNOTIFY_NAME(model_site_end) -#define __itt_model_site_end_2 ITTNOTIFY_VOID(model_site_end_2) -#define __itt_model_site_end_2_ptr ITTNOTIFY_NAME(model_site_end_2) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_site_begin(site, instance, name) -#define __itt_model_site_begin_ptr 0 -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_site_beginW(name) -#define __itt_model_site_beginW_ptr 0 -#endif -#define __itt_model_site_beginA(name) -#define __itt_model_site_beginA_ptr 0 -#define __itt_model_site_beginAL(name, siteNameLen) -#define __itt_model_site_beginAL_ptr 0 -#define __itt_model_site_end(site, instance) -#define __itt_model_site_end_ptr 0 -#define __itt_model_site_end_2() -#define __itt_model_site_end_2_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_site_begin_ptr 0 -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_site_beginW_ptr 0 -#endif -#define __itt_model_site_beginA_ptr 0 -#define __itt_model_site_beginAL_ptr 0 -#define __itt_model_site_end_ptr 0 -#define __itt_model_site_end_2_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_TASK_BEGIN/ANNOTATE_TASK_END support - * - * task_begin/end model a potential task, which is contained within the most - * closely enclosing dynamic site. task_end exits the most recently started - * but unended task. The handle passed to end may be used to validate - * structure. It is unspecified if bad dynamic nesting is detected. If it - * is, it should be encoded in the resulting data collection. The collector - * should not fail due to construct nesting issues, nor attempt to directly - * indicate the problem. - */ -void ITTAPI __itt_model_task_begin(__itt_model_task *task, __itt_model_task_instance *instance, const char *name); -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_model_task_beginW(const wchar_t *name); -void ITTAPI __itt_model_iteration_taskW(const wchar_t *name); -#endif -void ITTAPI __itt_model_task_beginA(const char *name); -void ITTAPI __itt_model_task_beginAL(const char *name, size_t taskNameLen); -void ITTAPI __itt_model_iteration_taskA(const char *name); -void ITTAPI __itt_model_iteration_taskAL(const char *name, size_t taskNameLen); -void ITTAPI __itt_model_task_end (__itt_model_task *task, __itt_model_task_instance *instance); -void ITTAPI __itt_model_task_end_2(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name)) -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name)) -ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name)) -#endif -ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name)) -ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t taskNameLen)) -ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name)) -ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t taskNameLen)) -ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance)) -ITT_STUBV(ITTAPI, void, model_task_end_2, (void)) -#define __itt_model_task_begin ITTNOTIFY_VOID(model_task_begin) -#define __itt_model_task_begin_ptr ITTNOTIFY_NAME(model_task_begin) -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_task_beginW ITTNOTIFY_VOID(model_task_beginW) -#define __itt_model_task_beginW_ptr ITTNOTIFY_NAME(model_task_beginW) -#define __itt_model_iteration_taskW ITTNOTIFY_VOID(model_iteration_taskW) -#define __itt_model_iteration_taskW_ptr ITTNOTIFY_NAME(model_iteration_taskW) -#endif -#define __itt_model_task_beginA ITTNOTIFY_VOID(model_task_beginA) -#define __itt_model_task_beginA_ptr ITTNOTIFY_NAME(model_task_beginA) -#define __itt_model_task_beginAL ITTNOTIFY_VOID(model_task_beginAL) -#define __itt_model_task_beginAL_ptr ITTNOTIFY_NAME(model_task_beginAL) -#define __itt_model_iteration_taskA ITTNOTIFY_VOID(model_iteration_taskA) -#define __itt_model_iteration_taskA_ptr ITTNOTIFY_NAME(model_iteration_taskA) -#define __itt_model_iteration_taskAL ITTNOTIFY_VOID(model_iteration_taskAL) -#define __itt_model_iteration_taskAL_ptr ITTNOTIFY_NAME(model_iteration_taskAL) -#define __itt_model_task_end ITTNOTIFY_VOID(model_task_end) -#define __itt_model_task_end_ptr ITTNOTIFY_NAME(model_task_end) -#define __itt_model_task_end_2 ITTNOTIFY_VOID(model_task_end_2) -#define __itt_model_task_end_2_ptr ITTNOTIFY_NAME(model_task_end_2) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_task_begin(task, instance, name) -#define __itt_model_task_begin_ptr 0 -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_task_beginW(name) -#define __itt_model_task_beginW_ptr 0 -#endif -#define __itt_model_task_beginA(name) -#define __itt_model_task_beginA_ptr 0 -#define __itt_model_task_beginAL(name, siteNameLen) -#define __itt_model_task_beginAL_ptr 0 -#define __itt_model_iteration_taskA(name) -#define __itt_model_iteration_taskA_ptr 0 -#define __itt_model_iteration_taskAL(name, siteNameLen) -#define __itt_model_iteration_taskAL_ptr 0 -#define __itt_model_task_end(task, instance) -#define __itt_model_task_end_ptr 0 -#define __itt_model_task_end_2() -#define __itt_model_task_end_2_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_task_begin_ptr 0 -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_model_task_beginW_ptr 0 -#endif -#define __itt_model_task_beginA_ptr 0 -#define __itt_model_task_beginAL_ptr 0 -#define __itt_model_iteration_taskA_ptr 0 -#define __itt_model_iteration_taskAL_ptr 0 -#define __itt_model_task_end_ptr 0 -#define __itt_model_task_end_2_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_LOCK_ACQUIRE/ANNOTATE_LOCK_RELEASE support - * - * lock_acquire/release model a potential lock for both lockset and - * performance modeling. Each unique address is modeled as a separate - * lock, with invalid addresses being valid lock IDs. Specifically: - * no storage is accessed by the API at the specified address - it is only - * used for lock identification. Lock acquires may be self-nested and are - * unlocked by a corresponding number of releases. - * (These closely correspond to __itt_sync_acquired/__itt_sync_releasing, - * but may not have identical semantics.) - */ -void ITTAPI __itt_model_lock_acquire(void *lock); -void ITTAPI __itt_model_lock_acquire_2(void *lock); -void ITTAPI __itt_model_lock_release(void *lock); -void ITTAPI __itt_model_lock_release_2(void *lock); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock)) -ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock)) -ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock)) -ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock)) -#define __itt_model_lock_acquire ITTNOTIFY_VOID(model_lock_acquire) -#define __itt_model_lock_acquire_ptr ITTNOTIFY_NAME(model_lock_acquire) -#define __itt_model_lock_acquire_2 ITTNOTIFY_VOID(model_lock_acquire_2) -#define __itt_model_lock_acquire_2_ptr ITTNOTIFY_NAME(model_lock_acquire_2) -#define __itt_model_lock_release ITTNOTIFY_VOID(model_lock_release) -#define __itt_model_lock_release_ptr ITTNOTIFY_NAME(model_lock_release) -#define __itt_model_lock_release_2 ITTNOTIFY_VOID(model_lock_release_2) -#define __itt_model_lock_release_2_ptr ITTNOTIFY_NAME(model_lock_release_2) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_lock_acquire(lock) -#define __itt_model_lock_acquire_ptr 0 -#define __itt_model_lock_acquire_2(lock) -#define __itt_model_lock_acquire_2_ptr 0 -#define __itt_model_lock_release(lock) -#define __itt_model_lock_release_ptr 0 -#define __itt_model_lock_release_2(lock) -#define __itt_model_lock_release_2_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_lock_acquire_ptr 0 -#define __itt_model_lock_acquire_2_ptr 0 -#define __itt_model_lock_release_ptr 0 -#define __itt_model_lock_release_2_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_RECORD_ALLOCATION/ANNOTATE_RECORD_DEALLOCATION support - * - * record_allocation/deallocation describe user-defined memory allocator - * behavior, which may be required for correctness modeling to understand - * when storage is not expected to be actually reused across threads. - */ -void ITTAPI __itt_model_record_allocation (void *addr, size_t size); -void ITTAPI __itt_model_record_deallocation(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size)) -ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr)) -#define __itt_model_record_allocation ITTNOTIFY_VOID(model_record_allocation) -#define __itt_model_record_allocation_ptr ITTNOTIFY_NAME(model_record_allocation) -#define __itt_model_record_deallocation ITTNOTIFY_VOID(model_record_deallocation) -#define __itt_model_record_deallocation_ptr ITTNOTIFY_NAME(model_record_deallocation) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_record_allocation(addr, size) -#define __itt_model_record_allocation_ptr 0 -#define __itt_model_record_deallocation(addr) -#define __itt_model_record_deallocation_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_record_allocation_ptr 0 -#define __itt_model_record_deallocation_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_INDUCTION_USES support - * - * Note particular storage is inductive through the end of the current site - */ -void ITTAPI __itt_model_induction_uses(void* addr, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_induction_uses, (void *addr, size_t size)) -#define __itt_model_induction_uses ITTNOTIFY_VOID(model_induction_uses) -#define __itt_model_induction_uses_ptr ITTNOTIFY_NAME(model_induction_uses) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_induction_uses(addr, size) -#define __itt_model_induction_uses_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_induction_uses_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_REDUCTION_USES support - * - * Note particular storage is used for reduction through the end - * of the current site - */ -void ITTAPI __itt_model_reduction_uses(void* addr, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_reduction_uses, (void *addr, size_t size)) -#define __itt_model_reduction_uses ITTNOTIFY_VOID(model_reduction_uses) -#define __itt_model_reduction_uses_ptr ITTNOTIFY_NAME(model_reduction_uses) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_reduction_uses(addr, size) -#define __itt_model_reduction_uses_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_reduction_uses_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_OBSERVE_USES support - * - * Have correctness modeling record observations about uses of storage - * through the end of the current site - */ -void ITTAPI __itt_model_observe_uses(void* addr, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_observe_uses, (void *addr, size_t size)) -#define __itt_model_observe_uses ITTNOTIFY_VOID(model_observe_uses) -#define __itt_model_observe_uses_ptr ITTNOTIFY_NAME(model_observe_uses) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_observe_uses(addr, size) -#define __itt_model_observe_uses_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_observe_uses_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_CLEAR_USES support - * - * Clear the special handling of a piece of storage related to induction, - * reduction or observe_uses - */ -void ITTAPI __itt_model_clear_uses(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_clear_uses, (void *addr)) -#define __itt_model_clear_uses ITTNOTIFY_VOID(model_clear_uses) -#define __itt_model_clear_uses_ptr ITTNOTIFY_NAME(model_clear_uses) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_clear_uses(addr) -#define __itt_model_clear_uses_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_clear_uses_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief ANNOTATE_DISABLE_*_PUSH/ANNOTATE_DISABLE_*_POP support - * - * disable_push/disable_pop push and pop disabling based on a parameter. - * Disabling observations stops processing of memory references during - * correctness modeling, and all annotations that occur in the disabled - * region. This allows description of code that is expected to be handled - * specially during conversion to parallelism or that is not recognized - * by tools (e.g. some kinds of synchronization operations.) - * This mechanism causes all annotations in the disabled region, other - * than disable_push and disable_pop, to be ignored. (For example, this - * might validly be used to disable an entire parallel site and the contained - * tasks and locking in it for data collection purposes.) - * The disable for collection is a more expensive operation, but reduces - * collector overhead significantly. This applies to BOTH correctness data - * collection and performance data collection. For example, a site - * containing a task might only enable data collection for the first 10 - * iterations. Both performance and correctness data should reflect this, - * and the program should run as close to full speed as possible when - * collection is disabled. - */ -void ITTAPI __itt_model_disable_push(__itt_model_disable x); -void ITTAPI __itt_model_disable_pop(void); -void ITTAPI __itt_model_aggregate_task(size_t x); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x)) -ITT_STUBV(ITTAPI, void, model_disable_pop, (void)) -ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t x)) -#define __itt_model_disable_push ITTNOTIFY_VOID(model_disable_push) -#define __itt_model_disable_push_ptr ITTNOTIFY_NAME(model_disable_push) -#define __itt_model_disable_pop ITTNOTIFY_VOID(model_disable_pop) -#define __itt_model_disable_pop_ptr ITTNOTIFY_NAME(model_disable_pop) -#define __itt_model_aggregate_task ITTNOTIFY_VOID(model_aggregate_task) -#define __itt_model_aggregate_task_ptr ITTNOTIFY_NAME(model_aggregate_task) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_model_disable_push(x) -#define __itt_model_disable_push_ptr 0 -#define __itt_model_disable_pop() -#define __itt_model_disable_pop_ptr 0 -#define __itt_model_aggregate_task(x) -#define __itt_model_aggregate_task_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_model_disable_push_ptr 0 -#define __itt_model_disable_pop_ptr 0 -#define __itt_model_aggregate_task_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} model group */ - -/** - * @defgroup heap Heap - * @ingroup public - * Heap group - * @{ - */ - -typedef void* __itt_heap_function; - -/** - * @brief Create an identification for heap function - * @return non-zero identifier or NULL - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_heap_function ITTAPI __itt_heap_function_createA(const char* name, const char* domain); -__itt_heap_function ITTAPI __itt_heap_function_createW(const wchar_t* name, const wchar_t* domain); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_heap_function_create __itt_heap_function_createW -# define __itt_heap_function_create_ptr __itt_heap_function_createW_ptr -#else -# define __itt_heap_function_create __itt_heap_function_createA -# define __itt_heap_function_create_ptr __itt_heap_function_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_heap_function ITTAPI __itt_heap_function_create(const char* name, const char* domain); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char* name, const char* domain)) -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t* name, const wchar_t* domain)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char* name, const char* domain)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_heap_function_createA ITTNOTIFY_DATA(heap_function_createA) -#define __itt_heap_function_createA_ptr ITTNOTIFY_NAME(heap_function_createA) -#define __itt_heap_function_createW ITTNOTIFY_DATA(heap_function_createW) -#define __itt_heap_function_createW_ptr ITTNOTIFY_NAME(heap_function_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_heap_function_create ITTNOTIFY_DATA(heap_function_create) -#define __itt_heap_function_create_ptr ITTNOTIFY_NAME(heap_function_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_heap_function_createA(name, domain) (__itt_heap_function)0 -#define __itt_heap_function_createA_ptr 0 -#define __itt_heap_function_createW(name, domain) (__itt_heap_function)0 -#define __itt_heap_function_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_heap_function_create(name, domain) (__itt_heap_function)0 -#define __itt_heap_function_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_heap_function_createA_ptr 0 -#define __itt_heap_function_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_heap_function_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an allocation begin occurrence. - */ -void ITTAPI __itt_heap_allocate_begin(__itt_heap_function h, size_t size, int initialized); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized)) -#define __itt_heap_allocate_begin ITTNOTIFY_VOID(heap_allocate_begin) -#define __itt_heap_allocate_begin_ptr ITTNOTIFY_NAME(heap_allocate_begin) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_allocate_begin(h, size, initialized) -#define __itt_heap_allocate_begin_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_allocate_begin_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an allocation end occurrence. - */ -void ITTAPI __itt_heap_allocate_end(__itt_heap_function h, void** addr, size_t size, int initialized); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized)) -#define __itt_heap_allocate_end ITTNOTIFY_VOID(heap_allocate_end) -#define __itt_heap_allocate_end_ptr ITTNOTIFY_NAME(heap_allocate_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_allocate_end(h, addr, size, initialized) -#define __itt_heap_allocate_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_allocate_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an free begin occurrence. - */ -void ITTAPI __itt_heap_free_begin(__itt_heap_function h, void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr)) -#define __itt_heap_free_begin ITTNOTIFY_VOID(heap_free_begin) -#define __itt_heap_free_begin_ptr ITTNOTIFY_NAME(heap_free_begin) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_free_begin(h, addr) -#define __itt_heap_free_begin_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_free_begin_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an free end occurrence. - */ -void ITTAPI __itt_heap_free_end(__itt_heap_function h, void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr)) -#define __itt_heap_free_end ITTNOTIFY_VOID(heap_free_end) -#define __itt_heap_free_end_ptr ITTNOTIFY_NAME(heap_free_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_free_end(h, addr) -#define __itt_heap_free_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_free_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an reallocation begin occurrence. - */ -void ITTAPI __itt_heap_reallocate_begin(__itt_heap_function h, void* addr, size_t new_size, int initialized); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized)) -#define __itt_heap_reallocate_begin ITTNOTIFY_VOID(heap_reallocate_begin) -#define __itt_heap_reallocate_begin_ptr ITTNOTIFY_NAME(heap_reallocate_begin) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_reallocate_begin(h, addr, new_size, initialized) -#define __itt_heap_reallocate_begin_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_reallocate_begin_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an reallocation end occurrence. - */ -void ITTAPI __itt_heap_reallocate_end(__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized)) -#define __itt_heap_reallocate_end ITTNOTIFY_VOID(heap_reallocate_end) -#define __itt_heap_reallocate_end_ptr ITTNOTIFY_NAME(heap_reallocate_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_reallocate_end(h, addr, new_addr, new_size, initialized) -#define __itt_heap_reallocate_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_reallocate_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief internal access begin */ -void ITTAPI __itt_heap_internal_access_begin(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void)) -#define __itt_heap_internal_access_begin ITTNOTIFY_VOID(heap_internal_access_begin) -#define __itt_heap_internal_access_begin_ptr ITTNOTIFY_NAME(heap_internal_access_begin) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_internal_access_begin() -#define __itt_heap_internal_access_begin_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_internal_access_begin_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief internal access end */ -void ITTAPI __itt_heap_internal_access_end(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void)) -#define __itt_heap_internal_access_end ITTNOTIFY_VOID(heap_internal_access_end) -#define __itt_heap_internal_access_end_ptr ITTNOTIFY_NAME(heap_internal_access_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_internal_access_end() -#define __itt_heap_internal_access_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_internal_access_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief record memory growth begin */ -void ITTAPI __itt_heap_record_memory_growth_begin(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void)) -#define __itt_heap_record_memory_growth_begin ITTNOTIFY_VOID(heap_record_memory_growth_begin) -#define __itt_heap_record_memory_growth_begin_ptr ITTNOTIFY_NAME(heap_record_memory_growth_begin) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_record_memory_growth_begin() -#define __itt_heap_record_memory_growth_begin_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_record_memory_growth_begin_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief record memory growth end */ -void ITTAPI __itt_heap_record_memory_growth_end(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void)) -#define __itt_heap_record_memory_growth_end ITTNOTIFY_VOID(heap_record_memory_growth_end) -#define __itt_heap_record_memory_growth_end_ptr ITTNOTIFY_NAME(heap_record_memory_growth_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_record_memory_growth_end() -#define __itt_heap_record_memory_growth_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_record_memory_growth_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Specify the type of heap detection/reporting to modify. - */ -/** - * @hideinitializer - * @brief Report on memory leaks. - */ -#define __itt_heap_leaks 0x00000001 - -/** - * @hideinitializer - * @brief Report on memory growth. - */ -#define __itt_heap_growth 0x00000002 - - -/** @brief heap reset detection */ -void ITTAPI __itt_heap_reset_detection(unsigned int reset_mask); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask)) -#define __itt_heap_reset_detection ITTNOTIFY_VOID(heap_reset_detection) -#define __itt_heap_reset_detection_ptr ITTNOTIFY_NAME(heap_reset_detection) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_reset_detection() -#define __itt_heap_reset_detection_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_reset_detection_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief report */ -void ITTAPI __itt_heap_record(unsigned int record_mask); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask)) -#define __itt_heap_record ITTNOTIFY_VOID(heap_record) -#define __itt_heap_record_ptr ITTNOTIFY_NAME(heap_record) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_heap_record() -#define __itt_heap_record_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_heap_record_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @} heap group */ -/** @endcond */ -/* ========================================================================== */ - -/** - * @defgroup domains Domains - * @ingroup public - * Domains group - * @{ - */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_domain -{ - volatile int flags; /*!< Zero if disabled, non-zero if enabled. The meaning of different non-zero values is reserved to the runtime */ - const char* nameA; /*!< Copy of original name in ASCII. */ -#if defined(UNICODE) || defined(_UNICODE) - const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ -#else /* UNICODE || _UNICODE */ - void* nameW; -#endif /* UNICODE || _UNICODE */ - int extra1; /*!< Reserved to the runtime */ - void* extra2; /*!< Reserved to the runtime */ - struct ___itt_domain* next; -} __itt_domain; - -#pragma pack(pop) -/** @endcond */ - -/** - * @ingroup domains - * @brief Create a domain. - * Create domain using some domain name: the URI naming style is recommended. - * Because the set of domains is expected to be static over the application's - * execution time, there is no mechanism to destroy a domain. - * Any domain can be accessed by any thread in the process, regardless of - * which thread created the domain. This call is thread-safe. - * @param[in] name name of domain - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_domain* ITTAPI __itt_domain_createA(const char *name); -__itt_domain* ITTAPI __itt_domain_createW(const wchar_t *name); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_domain_create __itt_domain_createW -# define __itt_domain_create_ptr __itt_domain_createW_ptr -#else /* UNICODE */ -# define __itt_domain_create __itt_domain_createA -# define __itt_domain_create_ptr __itt_domain_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_domain* ITTAPI __itt_domain_create(const char *name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name)) -ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_domain_createA ITTNOTIFY_DATA(domain_createA) -#define __itt_domain_createA_ptr ITTNOTIFY_NAME(domain_createA) -#define __itt_domain_createW ITTNOTIFY_DATA(domain_createW) -#define __itt_domain_createW_ptr ITTNOTIFY_NAME(domain_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_domain_create ITTNOTIFY_DATA(domain_create) -#define __itt_domain_create_ptr ITTNOTIFY_NAME(domain_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_domain_createA(name) (__itt_domain*)0 -#define __itt_domain_createA_ptr 0 -#define __itt_domain_createW(name) (__itt_domain*)0 -#define __itt_domain_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_domain_create(name) (__itt_domain*)0 -#define __itt_domain_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_domain_createA_ptr 0 -#define __itt_domain_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_domain_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} domains group */ - -/** - * @defgroup ids IDs - * @ingroup public - * IDs group - * @{ - */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_id -{ - unsigned long long d1, d2, d3; -} __itt_id; - -#pragma pack(pop) -/** @endcond */ - -static const __itt_id __itt_null = { 0, 0, 0 }; - -/** - * @ingroup ids - * @brief A convenience function is provided to create an ID without domain control. - * @brief This is a convenience function to initialize an __itt_id structure. This function - * does not affect the collector runtime in any way. After you make the ID with this - * function, you still must create it with the __itt_id_create function before using the ID - * to identify a named entity. - * @param[in] addr The address of object; high QWORD of the ID value. - * @param[in] extra The extra data to unique identify object; low QWORD of the ID value. - */ - -ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) ITT_INLINE_ATTRIBUTE; -ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) -{ - __itt_id id = __itt_null; - id.d1 = (unsigned long long)((uintptr_t)addr); - id.d2 = (unsigned long long)extra; - id.d3 = (unsigned long long)0; /* Reserved. Must be zero */ - return id; -} - -/** - * @ingroup ids - * @brief Create an instance of identifier. - * This establishes the beginning of the lifetime of an instance of - * the given ID in the trace. Once this lifetime starts, the ID - * can be used to tag named entity instances in calls such as - * __itt_task_begin, and to specify relationships among - * identified named entity instances, using the \ref relations APIs. - * Instance IDs are not domain specific! - * @param[in] domain The domain controlling the execution of this call. - * @param[in] id The ID to create. - */ -void ITTAPI __itt_id_create(const __itt_domain *domain, __itt_id id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id)) -#define __itt_id_create(d,x) ITTNOTIFY_VOID_D1(id_create,d,x) -#define __itt_id_create_ptr ITTNOTIFY_NAME(id_create) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_id_create(domain,id) -#define __itt_id_create_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_id_create_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup ids - * @brief Destroy an instance of identifier. - * This ends the lifetime of the current instance of the given ID value in the trace. - * Any relationships that are established after this lifetime ends are invalid. - * This call must be performed before the given ID value can be reused for a different - * named entity instance. - * @param[in] domain The domain controlling the execution of this call. - * @param[in] id The ID to destroy. - */ -void ITTAPI __itt_id_destroy(const __itt_domain *domain, __itt_id id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id)) -#define __itt_id_destroy(d,x) ITTNOTIFY_VOID_D1(id_destroy,d,x) -#define __itt_id_destroy_ptr ITTNOTIFY_NAME(id_destroy) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_id_destroy(domain,id) -#define __itt_id_destroy_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_id_destroy_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} ids group */ - -/** - * @defgroup handless String Handles - * @ingroup public - * String Handles group - * @{ - */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_string_handle -{ - const char* strA; /*!< Copy of original string in ASCII. */ -#if defined(UNICODE) || defined(_UNICODE) - const wchar_t* strW; /*!< Copy of original string in UNICODE. */ -#else /* UNICODE || _UNICODE */ - void* strW; -#endif /* UNICODE || _UNICODE */ - int extra1; /*!< Reserved. Must be zero */ - void* extra2; /*!< Reserved. Must be zero */ - struct ___itt_string_handle* next; -} __itt_string_handle; - -#pragma pack(pop) -/** @endcond */ - -/** - * @ingroup handles - * @brief Create a string handle. - * Create and return handle value that can be associated with a string. - * Consecutive calls to __itt_string_handle_create with the same name - * return the same value. Because the set of string handles is expected to remain - * static during the application's execution time, there is no mechanism to destroy a string handle. - * Any string handle can be accessed by any thread in the process, regardless of which thread created - * the string handle. This call is thread-safe. - * @param[in] name The input string - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_string_handle* ITTAPI __itt_string_handle_createA(const char *name); -__itt_string_handle* ITTAPI __itt_string_handle_createW(const wchar_t *name); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_string_handle_create __itt_string_handle_createW -# define __itt_string_handle_create_ptr __itt_string_handle_createW_ptr -#else /* UNICODE */ -# define __itt_string_handle_create __itt_string_handle_createA -# define __itt_string_handle_create_ptr __itt_string_handle_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_string_handle* ITTAPI __itt_string_handle_create(const char *name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name)) -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_string_handle_createA ITTNOTIFY_DATA(string_handle_createA) -#define __itt_string_handle_createA_ptr ITTNOTIFY_NAME(string_handle_createA) -#define __itt_string_handle_createW ITTNOTIFY_DATA(string_handle_createW) -#define __itt_string_handle_createW_ptr ITTNOTIFY_NAME(string_handle_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_string_handle_create ITTNOTIFY_DATA(string_handle_create) -#define __itt_string_handle_create_ptr ITTNOTIFY_NAME(string_handle_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_string_handle_createA(name) (__itt_string_handle*)0 -#define __itt_string_handle_createA_ptr 0 -#define __itt_string_handle_createW(name) (__itt_string_handle*)0 -#define __itt_string_handle_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_string_handle_create(name) (__itt_string_handle*)0 -#define __itt_string_handle_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_string_handle_createA_ptr 0 -#define __itt_string_handle_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_string_handle_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} handles group */ - -/** @cond exclude_from_documentation */ -typedef unsigned long long __itt_timestamp; -/** @endcond */ - -#define __itt_timestamp_none ((__itt_timestamp)-1LL) - -/** @cond exclude_from_gpa_documentation */ - -/** - * @ingroup timestamps - * @brief Return timestamp corresponding to the current moment. - * This returns the timestamp in the format that is the most relevant for the current - * host or platform (RDTSC, QPC, and others). You can use the "<" operator to - * compare __itt_timestamp values. - */ -__itt_timestamp ITTAPI __itt_get_timestamp(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void)) -#define __itt_get_timestamp ITTNOTIFY_DATA(get_timestamp) -#define __itt_get_timestamp_ptr ITTNOTIFY_NAME(get_timestamp) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_get_timestamp() -#define __itt_get_timestamp_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_get_timestamp_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} timestamps */ -/** @endcond */ - -/** @cond exclude_from_gpa_documentation */ - -/** - * @defgroup regions Regions - * @ingroup public - * Regions group - * @{ - */ -/** - * @ingroup regions - * @brief Begin of region instance. - * Successive calls to __itt_region_begin with the same ID are ignored - * until a call to __itt_region_end with the same ID - * @param[in] domain The domain for this region instance - * @param[in] id The instance ID for this region instance. Must not be __itt_null - * @param[in] parentid The instance ID for the parent of this region instance, or __itt_null - * @param[in] name The name of this region - */ -void ITTAPI __itt_region_begin(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); - -/** - * @ingroup regions - * @brief End of region instance. - * The first call to __itt_region_end with a given ID ends the - * region. Successive calls with the same ID are ignored, as are - * calls that do not have a matching __itt_region_begin call. - * @param[in] domain The domain for this region instance - * @param[in] id The instance ID for this region instance - */ -void ITTAPI __itt_region_end(const __itt_domain *domain, __itt_id id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id)) -#define __itt_region_begin(d,x,y,z) ITTNOTIFY_VOID_D3(region_begin,d,x,y,z) -#define __itt_region_begin_ptr ITTNOTIFY_NAME(region_begin) -#define __itt_region_end(d,x) ITTNOTIFY_VOID_D1(region_end,d,x) -#define __itt_region_end_ptr ITTNOTIFY_NAME(region_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_region_begin(d,x,y,z) -#define __itt_region_begin_ptr 0 -#define __itt_region_end(d,x) -#define __itt_region_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_region_begin_ptr 0 -#define __itt_region_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} regions group */ - -/** - * @defgroup frames Frames - * @ingroup public - * Frames are similar to regions, but are intended to be easier to use and to implement. - * In particular: - * - Frames always represent periods of elapsed time - * - By default, frames have no nesting relationships - * @{ - */ - -/** - * @ingroup frames - * @brief Begin a frame instance. - * Successive calls to __itt_frame_begin with the - * same ID are ignored until a call to __itt_frame_end with the same ID. - * @param[in] domain The domain for this frame instance - * @param[in] id The instance ID for this frame instance or NULL - */ -void ITTAPI __itt_frame_begin_v3(const __itt_domain *domain, __itt_id *id); - -/** - * @ingroup frames - * @brief End a frame instance. - * The first call to __itt_frame_end with a given ID - * ends the frame. Successive calls with the same ID are ignored, as are - * calls that do not have a matching __itt_frame_begin call. - * @param[in] domain The domain for this frame instance - * @param[in] id The instance ID for this frame instance or NULL for current - */ -void ITTAPI __itt_frame_end_v3(const __itt_domain *domain, __itt_id *id); - -/** - * @ingroup frames - * @brief Submits a frame instance. - * Successive calls to __itt_frame_begin or __itt_frame_submit with the - * same ID are ignored until a call to __itt_frame_end or __itt_frame_submit - * with the same ID. - * Passing special __itt_timestamp_none value as "end" argument means - * take the current timestamp as the end timestamp. - * @param[in] domain The domain for this frame instance - * @param[in] id The instance ID for this frame instance or NULL - * @param[in] begin Timestamp of the beginning of the frame - * @param[in] end Timestamp of the end of the frame - */ -void ITTAPI __itt_frame_submit_v3(const __itt_domain *domain, __itt_id *id, - __itt_timestamp begin, __itt_timestamp end); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id)) -ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id)) -ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end)) -#define __itt_frame_begin_v3(d,x) ITTNOTIFY_VOID_D1(frame_begin_v3,d,x) -#define __itt_frame_begin_v3_ptr ITTNOTIFY_NAME(frame_begin_v3) -#define __itt_frame_end_v3(d,x) ITTNOTIFY_VOID_D1(frame_end_v3,d,x) -#define __itt_frame_end_v3_ptr ITTNOTIFY_NAME(frame_end_v3) -#define __itt_frame_submit_v3(d,x,b,e) ITTNOTIFY_VOID_D3(frame_submit_v3,d,x,b,e) -#define __itt_frame_submit_v3_ptr ITTNOTIFY_NAME(frame_submit_v3) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_frame_begin_v3(domain,id) -#define __itt_frame_begin_v3_ptr 0 -#define __itt_frame_end_v3(domain,id) -#define __itt_frame_end_v3_ptr 0 -#define __itt_frame_submit_v3(domain,id,begin,end) -#define __itt_frame_submit_v3_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_frame_begin_v3_ptr 0 -#define __itt_frame_end_v3_ptr 0 -#define __itt_frame_submit_v3_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} frames group */ -/** @endcond */ - -/** - * @defgroup taskgroup Task Group - * @ingroup public - * Task Group - * @{ - */ -/** - * @ingroup task_groups - * @brief Denotes a task_group instance. - * Successive calls to __itt_task_group with the same ID are ignored. - * @param[in] domain The domain for this task_group instance - * @param[in] id The instance ID for this task_group instance. Must not be __itt_null. - * @param[in] parentid The instance ID for the parent of this task_group instance, or __itt_null. - * @param[in] name The name of this task_group - */ -void ITTAPI __itt_task_group(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) -#define __itt_task_group(d,x,y,z) ITTNOTIFY_VOID_D3(task_group,d,x,y,z) -#define __itt_task_group_ptr ITTNOTIFY_NAME(task_group) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_task_group(d,x,y,z) -#define __itt_task_group_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_task_group_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} taskgroup group */ - -/** - * @defgroup tasks Tasks - * @ingroup public - * A task instance represents a piece of work performed by a particular - * thread for a period of time. A call to __itt_task_begin creates a - * task instance. This becomes the current instance for that task on that - * thread. A following call to __itt_task_end on the same thread ends the - * instance. There may be multiple simultaneous instances of tasks with the - * same name on different threads. If an ID is specified, the task instance - * receives that ID. Nested tasks are allowed. - * - * Note: The task is defined by the bracketing of __itt_task_begin and - * __itt_task_end on the same thread. If some scheduling mechanism causes - * task switching (the thread executes a different user task) or task - * switching (the user task switches to a different thread) then this breaks - * the notion of current instance. Additional API calls are required to - * deal with that possibility. - * @{ - */ - -/** - * @ingroup tasks - * @brief Begin a task instance. - * @param[in] domain The domain for this task - * @param[in] taskid The instance ID for this task instance, or __itt_null - * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null - * @param[in] name The name of this task - */ -void ITTAPI __itt_task_begin(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name); - -/** - * @ingroup tasks - * @brief Begin a task instance. - * @param[in] domain The domain for this task - * @param[in] taskid The identifier for this task instance (may be 0) - * @param[in] parentid The parent of this task (may be 0) - * @param[in] fn The pointer to the function you are tracing - */ -void ITTAPI __itt_task_begin_fn(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, void* fn); - -/** - * @ingroup tasks - * @brief End the current task instance. - * @param[in] domain The domain for this task - */ -void ITTAPI __itt_task_end(const __itt_domain *domain); - -/** - * @ingroup tasks - * @brief Begin an overlapped task instance. - * @param[in] domain The domain for this task. - * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. - * @param[in] parentid The parent of this task, or __itt_null. - * @param[in] name The name of this task. - */ -void ITTAPI __itt_task_begin_overlapped(const __itt_domain* domain, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); - -/** - * @ingroup tasks - * @brief End an overlapped task instance. - * @param[in] domain The domain for this task - * @param[in] taskid Explicit ID of finished task - */ -void ITTAPI __itt_task_end_overlapped(const __itt_domain *domain, __itt_id taskid); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parentid, void* fn)) -ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain)) -ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id taskid)) -#define __itt_task_begin(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin,d,x,y,z) -#define __itt_task_begin_ptr ITTNOTIFY_NAME(task_begin) -#define __itt_task_begin_fn(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_fn,d,x,y,z) -#define __itt_task_begin_fn_ptr ITTNOTIFY_NAME(task_begin_fn) -#define __itt_task_end(d) ITTNOTIFY_VOID_D0(task_end,d) -#define __itt_task_end_ptr ITTNOTIFY_NAME(task_end) -#define __itt_task_begin_overlapped(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_overlapped,d,x,y,z) -#define __itt_task_begin_overlapped_ptr ITTNOTIFY_NAME(task_begin_overlapped) -#define __itt_task_end_overlapped(d,x) ITTNOTIFY_VOID_D1(task_end_overlapped,d,x) -#define __itt_task_end_overlapped_ptr ITTNOTIFY_NAME(task_end_overlapped) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_task_begin(domain,id,parentid,name) -#define __itt_task_begin_ptr 0 -#define __itt_task_begin_fn(domain,id,parentid,fn) -#define __itt_task_begin_fn_ptr 0 -#define __itt_task_end(domain) -#define __itt_task_end_ptr 0 -#define __itt_task_begin_overlapped(domain,taskid,parentid,name) -#define __itt_task_begin_overlapped_ptr 0 -#define __itt_task_end_overlapped(domain,taskid) -#define __itt_task_end_overlapped_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_task_begin_ptr 0 -#define __itt_task_begin_fn_ptr 0 -#define __itt_task_end_ptr 0 -#define __itt_task_begin_overlapped_ptr 0 -#define __itt_task_end_overlapped_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} tasks group */ - - -/** - * @defgroup markers Markers - * Markers represent a single discreet event in time. Markers have a scope, - * described by an enumerated type __itt_scope. Markers are created by - * the API call __itt_marker. A marker instance can be given an ID for use in - * adding metadata. - * @{ - */ - -/** - * @brief Describes the scope of an event object in the trace. - */ -typedef enum -{ - __itt_scope_unknown = 0, - __itt_scope_global, - __itt_scope_track_group, - __itt_scope_track, - __itt_scope_task, - __itt_scope_marker -} __itt_scope; - -/** @cond exclude_from_documentation */ -#define __itt_marker_scope_unknown __itt_scope_unknown -#define __itt_marker_scope_global __itt_scope_global -#define __itt_marker_scope_process __itt_scope_track_group -#define __itt_marker_scope_thread __itt_scope_track -#define __itt_marker_scope_task __itt_scope_task -/** @endcond */ - -/** - * @ingroup markers - * @brief Create a marker instance - * @param[in] domain The domain for this marker - * @param[in] id The instance ID for this marker or __itt_null - * @param[in] name The name for this marker - * @param[in] scope The scope for this marker - */ -void ITTAPI __itt_marker(const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope)) -#define __itt_marker(d,x,y,z) ITTNOTIFY_VOID_D3(marker,d,x,y,z) -#define __itt_marker_ptr ITTNOTIFY_NAME(marker) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_marker(domain,id,name,scope) -#define __itt_marker_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_marker_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} markers group */ - -/** - * @defgroup metadata Metadata - * The metadata API is used to attach extra information to named - * entities. Metadata can be attached to an identified named entity by ID, - * or to the current entity (which is always a task). - * - * Conceptually metadata has a type (what kind of metadata), a key (the - * name of the metadata), and a value (the actual data). The encoding of - * the value depends on the type of the metadata. - * - * The type of metadata is specified by an enumerated type __itt_metdata_type. - * @{ - */ - -/** - * @ingroup parameters - * @brief describes the type of metadata - */ -typedef enum { - __itt_metadata_unknown = 0, - __itt_metadata_u64, /**< Unsigned 64-bit integer */ - __itt_metadata_s64, /**< Signed 64-bit integer */ - __itt_metadata_u32, /**< Unsigned 32-bit integer */ - __itt_metadata_s32, /**< Signed 32-bit integer */ - __itt_metadata_u16, /**< Unsigned 16-bit integer */ - __itt_metadata_s16, /**< Signed 16-bit integer */ - __itt_metadata_float, /**< Signed 32-bit floating-point */ - __itt_metadata_double /**< SIgned 64-bit floating-point */ -} __itt_metadata_type; - -/** - * @ingroup parameters - * @brief Add metadata to an instance of a named entity. - * @param[in] domain The domain controlling the call - * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task - * @param[in] key The name of the metadata - * @param[in] type The type of the metadata - * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. - * @param[in] data The metadata itself -*/ -void ITTAPI __itt_metadata_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) -#define __itt_metadata_add(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add,d,x,y,z,a,b) -#define __itt_metadata_add_ptr ITTNOTIFY_NAME(metadata_add) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_metadata_add(d,x,y,z,a,b) -#define __itt_metadata_add_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_metadata_add_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup parameters - * @brief Add string metadata to an instance of a named entity. - * @param[in] domain The domain controlling the call - * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task - * @param[in] key The name of the metadata - * @param[in] data The metadata itself - * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated -*/ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_metadata_str_addA(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); -void ITTAPI __itt_metadata_str_addW(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_metadata_str_add __itt_metadata_str_addW -# define __itt_metadata_str_add_ptr __itt_metadata_str_addW_ptr -#else /* UNICODE */ -# define __itt_metadata_str_add __itt_metadata_str_addA -# define __itt_metadata_str_add_ptr __itt_metadata_str_addA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_metadata_str_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); -#endif - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) -ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_addA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addA,d,x,y,z,a) -#define __itt_metadata_str_addA_ptr ITTNOTIFY_NAME(metadata_str_addA) -#define __itt_metadata_str_addW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addW,d,x,y,z,a) -#define __itt_metadata_str_addW_ptr ITTNOTIFY_NAME(metadata_str_addW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add,d,x,y,z,a) -#define __itt_metadata_str_add_ptr ITTNOTIFY_NAME(metadata_str_add) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_addA(d,x,y,z,a) -#define __itt_metadata_str_addA_ptr 0 -#define __itt_metadata_str_addW(d,x,y,z,a) -#define __itt_metadata_str_addW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add(d,x,y,z,a) -#define __itt_metadata_str_add_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_addA_ptr 0 -#define __itt_metadata_str_addW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup parameters - * @brief Add metadata to an instance of a named entity. - * @param[in] domain The domain controlling the call - * @param[in] scope The scope of the instance to which the metadata is to be added - - * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task - - * @param[in] key The name of the metadata - * @param[in] type The type of the metadata - * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. - * @param[in] data The metadata itself -*/ -void ITTAPI __itt_metadata_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) -#define __itt_metadata_add_with_scope(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add_with_scope,d,x,y,z,a,b) -#define __itt_metadata_add_with_scope_ptr ITTNOTIFY_NAME(metadata_add_with_scope) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_metadata_add_with_scope(d,x,y,z,a,b) -#define __itt_metadata_add_with_scope_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_metadata_add_with_scope_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup parameters - * @brief Add string metadata to an instance of a named entity. - * @param[in] domain The domain controlling the call - * @param[in] scope The scope of the instance to which the metadata is to be added - - * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task - - * @param[in] key The name of the metadata - * @param[in] data The metadata itself - * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated -*/ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_metadata_str_add_with_scopeA(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); -void ITTAPI __itt_metadata_str_add_with_scopeW(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeW -# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeW_ptr -#else /* UNICODE */ -# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeA -# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_metadata_str_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); -#endif - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeA,d,x,y,z,a) -#define __itt_metadata_str_add_with_scopeA_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeA) -#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeW,d,x,y,z,a) -#define __itt_metadata_str_add_with_scopeW_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add_with_scope(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scope,d,x,y,z,a) -#define __itt_metadata_str_add_with_scope_ptr ITTNOTIFY_NAME(metadata_str_add_with_scope) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) -#define __itt_metadata_str_add_with_scopeA_ptr 0 -#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) -#define __itt_metadata_str_add_with_scopeW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add_with_scope(d,x,y,z,a) -#define __itt_metadata_str_add_with_scope_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_metadata_str_add_with_scopeA_ptr 0 -#define __itt_metadata_str_add_with_scopeW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_metadata_str_add_with_scope_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @} metadata group */ - -/** - * @defgroup relations Relations - * Instances of named entities can be explicitly associated with other - * instances using instance IDs and the relationship API calls. - * - * @{ - */ - -/** - * @ingroup relations - * @brief The kind of relation between two instances is specified by the enumerated type __itt_relation. - * Relations between instances can be added with an API call. The relation - * API uses instance IDs. Relations can be added before or after the actual - * instances are created and persist independently of the instances. This - * is the motivation for having different lifetimes for instance IDs and - * the actual instances. - */ -typedef enum -{ - __itt_relation_is_unknown = 0, - __itt_relation_is_dependent_on, /**< "A is dependent on B" means that A cannot start until B completes */ - __itt_relation_is_sibling_of, /**< "A is sibling of B" means that A and B were created as a group */ - __itt_relation_is_parent_of, /**< "A is parent of B" means that A created B */ - __itt_relation_is_continuation_of, /**< "A is continuation of B" means that A assumes the dependencies of B */ - __itt_relation_is_child_of, /**< "A is child of B" means that A was created by B (inverse of is_parent_of) */ - __itt_relation_is_continued_by, /**< "A is continued by B" means that B assumes the dependencies of A (inverse of is_continuation_of) */ - __itt_relation_is_predecessor_to /**< "A is predecessor to B" means that B cannot start until A completes (inverse of is_dependent_on) */ -} __itt_relation; - -/** - * @ingroup relations - * @brief Add a relation to the current task instance. - * The current task instance is the head of the relation. - * @param[in] domain The domain controlling this call - * @param[in] relation The kind of relation - * @param[in] tail The ID for the tail of the relation - */ -void ITTAPI __itt_relation_add_to_current(const __itt_domain *domain, __itt_relation relation, __itt_id tail); - -/** - * @ingroup relations - * @brief Add a relation between two instance identifiers. - * @param[in] domain The domain controlling this call - * @param[in] head The ID for the head of the relation - * @param[in] relation The kind of relation - * @param[in] tail The ID for the tail of the relation - */ -void ITTAPI __itt_relation_add(const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail)) -ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail)) -#define __itt_relation_add_to_current(d,x,y) ITTNOTIFY_VOID_D2(relation_add_to_current,d,x,y) -#define __itt_relation_add_to_current_ptr ITTNOTIFY_NAME(relation_add_to_current) -#define __itt_relation_add(d,x,y,z) ITTNOTIFY_VOID_D3(relation_add,d,x,y,z) -#define __itt_relation_add_ptr ITTNOTIFY_NAME(relation_add) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_relation_add_to_current(d,x,y) -#define __itt_relation_add_to_current_ptr 0 -#define __itt_relation_add(d,x,y,z) -#define __itt_relation_add_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_relation_add_to_current_ptr 0 -#define __itt_relation_add_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} relations group */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_clock_info -{ - unsigned long long clock_freq; /*!< Clock domain frequency */ - unsigned long long clock_base; /*!< Clock domain base timestamp */ -} __itt_clock_info; - -#pragma pack(pop) -/** @endcond */ - -/** @cond exclude_from_documentation */ -typedef void (ITTAPI *__itt_get_clock_info_fn)(__itt_clock_info* clock_info, void* data); -/** @endcond */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_clock_domain -{ - __itt_clock_info info; /*!< Most recent clock domain info */ - __itt_get_clock_info_fn fn; /*!< Callback function pointer */ - void* fn_data; /*!< Input argument for the callback function */ - int extra1; /*!< Reserved. Must be zero */ - void* extra2; /*!< Reserved. Must be zero */ - struct ___itt_clock_domain* next; -} __itt_clock_domain; - -#pragma pack(pop) -/** @endcond */ - -/** - * @ingroup clockdomains - * @brief Create a clock domain. - * Certain applications require the capability to trace their application using - * a clock domain different than the CPU, for instance the instrumentation of events - * that occur on a GPU. - * Because the set of domains is expected to be static over the application's execution time, - * there is no mechanism to destroy a domain. - * Any domain can be accessed by any thread in the process, regardless of which thread created - * the domain. This call is thread-safe. - * @param[in] fn A pointer to a callback function which retrieves alternative CPU timestamps - * @param[in] fn_data Argument for a callback function; may be NULL - */ -__itt_clock_domain* ITTAPI __itt_clock_domain_create(__itt_get_clock_info_fn fn, void* fn_data); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data)) -#define __itt_clock_domain_create ITTNOTIFY_DATA(clock_domain_create) -#define __itt_clock_domain_create_ptr ITTNOTIFY_NAME(clock_domain_create) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_clock_domain_create(fn,fn_data) (__itt_clock_domain*)0 -#define __itt_clock_domain_create_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_clock_domain_create_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup clockdomains - * @brief Recalculate clock domains frequences and clock base timestamps. - */ -void ITTAPI __itt_clock_domain_reset(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, clock_domain_reset, (void)) -#define __itt_clock_domain_reset ITTNOTIFY_VOID(clock_domain_reset) -#define __itt_clock_domain_reset_ptr ITTNOTIFY_NAME(clock_domain_reset) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_clock_domain_reset() -#define __itt_clock_domain_reset_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_clock_domain_reset_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup clockdomain - * @brief Create an instance of identifier. This establishes the beginning of the lifetime of - * an instance of the given ID in the trace. Once this lifetime starts, the ID can be used to - * tag named entity instances in calls such as __itt_task_begin, and to specify relationships among - * identified named entity instances, using the \ref relations APIs. - * @param[in] domain The domain controlling the execution of this call. - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] id The ID to create. - */ -void ITTAPI __itt_id_create_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); - -/** - * @ingroup clockdomain - * @brief Destroy an instance of identifier. This ends the lifetime of the current instance of the - * given ID value in the trace. Any relationships that are established after this lifetime ends are - * invalid. This call must be performed before the given ID value can be reused for a different - * named entity instance. - * @param[in] domain The domain controlling the execution of this call. - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] id The ID to destroy. - */ -void ITTAPI __itt_id_destroy_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) -ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) -#define __itt_id_create_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_create_ex,d,x,y,z) -#define __itt_id_create_ex_ptr ITTNOTIFY_NAME(id_create_ex) -#define __itt_id_destroy_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_destroy_ex,d,x,y,z) -#define __itt_id_destroy_ex_ptr ITTNOTIFY_NAME(id_destroy_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_id_create_ex(domain,clock_domain,timestamp,id) -#define __itt_id_create_ex_ptr 0 -#define __itt_id_destroy_ex(domain,clock_domain,timestamp,id) -#define __itt_id_destroy_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_id_create_ex_ptr 0 -#define __itt_id_destroy_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup clockdomain - * @brief Begin a task instance. - * @param[in] domain The domain for this task - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] taskid The instance ID for this task instance, or __itt_null - * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null - * @param[in] name The name of this task - */ -void ITTAPI __itt_task_begin_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); - -/** - * @ingroup clockdomain - * @brief Begin a task instance. - * @param[in] domain The domain for this task - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] taskid The identifier for this task instance, or __itt_null - * @param[in] parentid The parent of this task, or __itt_null - * @param[in] fn The pointer to the function you are tracing - */ -void ITTAPI __itt_task_begin_fn_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, void* fn); - -/** - * @ingroup clockdomain - * @brief End the current task instance. - * @param[in] domain The domain for this task - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - */ -void ITTAPI __itt_task_end_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn)) -ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp)) -#define __itt_task_begin_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_ex,d,x,y,z,a,b) -#define __itt_task_begin_ex_ptr ITTNOTIFY_NAME(task_begin_ex) -#define __itt_task_begin_fn_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_fn_ex,d,x,y,z,a,b) -#define __itt_task_begin_fn_ex_ptr ITTNOTIFY_NAME(task_begin_fn_ex) -#define __itt_task_end_ex(d,x,y) ITTNOTIFY_VOID_D2(task_end_ex,d,x,y) -#define __itt_task_end_ex_ptr ITTNOTIFY_NAME(task_end_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_task_begin_ex(domain,clock_domain,timestamp,id,parentid,name) -#define __itt_task_begin_ex_ptr 0 -#define __itt_task_begin_fn_ex(domain,clock_domain,timestamp,id,parentid,fn) -#define __itt_task_begin_fn_ex_ptr 0 -#define __itt_task_end_ex(domain,clock_domain,timestamp) -#define __itt_task_end_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_task_begin_ex_ptr 0 -#define __itt_task_begin_fn_ex_ptr 0 -#define __itt_task_end_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @defgroup counters Counters - * @ingroup public - * Counters are user-defined objects with a monotonically increasing - * value. Counter values are 64-bit unsigned integers. - * Counters have names that can be displayed in - * the tools. - * @{ - */ - -/** - * @brief opaque structure for counter identification - */ -/** @cond exclude_from_documentation */ - -typedef struct ___itt_counter* __itt_counter; - -/** - * @brief Create an unsigned 64 bits integer counter with given name/domain - * - * After __itt_counter_create() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), - * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) - * can be used to change the value of the counter, where value_ptr is a pointer to an unsigned 64 bits integer - * - * The call is equal to __itt_counter_create_typed(name, domain, __itt_metadata_u64) - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_counter ITTAPI __itt_counter_createA(const char *name, const char *domain); -__itt_counter ITTAPI __itt_counter_createW(const wchar_t *name, const wchar_t *domain); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_counter_create __itt_counter_createW -# define __itt_counter_create_ptr __itt_counter_createW_ptr -#else /* UNICODE */ -# define __itt_counter_create __itt_counter_createA -# define __itt_counter_create_ptr __itt_counter_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_counter ITTAPI __itt_counter_create(const char *name, const char *domain); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain)) -ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_createA ITTNOTIFY_DATA(counter_createA) -#define __itt_counter_createA_ptr ITTNOTIFY_NAME(counter_createA) -#define __itt_counter_createW ITTNOTIFY_DATA(counter_createW) -#define __itt_counter_createW_ptr ITTNOTIFY_NAME(counter_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create ITTNOTIFY_DATA(counter_create) -#define __itt_counter_create_ptr ITTNOTIFY_NAME(counter_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_createA(name, domain) -#define __itt_counter_createA_ptr 0 -#define __itt_counter_createW(name, domain) -#define __itt_counter_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create(name, domain) -#define __itt_counter_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_createA_ptr 0 -#define __itt_counter_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Increment the unsigned 64 bits integer counter value - * - * Calling this function to non-unsigned 64 bits integer counters has no effect - */ -void ITTAPI __itt_counter_inc(__itt_counter id); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id)) -#define __itt_counter_inc ITTNOTIFY_VOID(counter_inc) -#define __itt_counter_inc_ptr ITTNOTIFY_NAME(counter_inc) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_inc(id) -#define __itt_counter_inc_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_inc_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** - * @brief Increment the unsigned 64 bits integer counter value with x - * - * Calling this function to non-unsigned 64 bits integer counters has no effect - */ -void ITTAPI __itt_counter_inc_delta(__itt_counter id, unsigned long long value); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value)) -#define __itt_counter_inc_delta ITTNOTIFY_VOID(counter_inc_delta) -#define __itt_counter_inc_delta_ptr ITTNOTIFY_NAME(counter_inc_delta) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_inc_delta(id, value) -#define __itt_counter_inc_delta_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_inc_delta_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Decrement the unsigned 64 bits integer counter value - * - * Calling this function to non-unsigned 64 bits integer counters has no effect - */ -void ITTAPI __itt_counter_dec(__itt_counter id); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_dec, (__itt_counter id)) -#define __itt_counter_dec ITTNOTIFY_VOID(counter_dec) -#define __itt_counter_dec_ptr ITTNOTIFY_NAME(counter_dec) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_dec(id) -#define __itt_counter_dec_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_dec_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** - * @brief Decrement the unsigned 64 bits integer counter value with x - * - * Calling this function to non-unsigned 64 bits integer counters has no effect - */ -void ITTAPI __itt_counter_dec_delta(__itt_counter id, unsigned long long value); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_dec_delta, (__itt_counter id, unsigned long long value)) -#define __itt_counter_dec_delta ITTNOTIFY_VOID(counter_dec_delta) -#define __itt_counter_dec_delta_ptr ITTNOTIFY_NAME(counter_dec_delta) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_dec_delta(id, value) -#define __itt_counter_dec_delta_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_dec_delta_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup counters - * @brief Increment a counter by one. - * The first call with a given name creates a counter by that name and sets its - * value to zero. Successive calls increment the counter value. - * @param[in] domain The domain controlling the call. Counter names are not domain specific. - * The domain argument is used only to enable or disable the API calls. - * @param[in] name The name of the counter - */ -void ITTAPI __itt_counter_inc_v3(const __itt_domain *domain, __itt_string_handle *name); - -/** - * @ingroup counters - * @brief Increment a counter by the value specified in delta. - * @param[in] domain The domain controlling the call. Counter names are not domain specific. - * The domain argument is used only to enable or disable the API calls. - * @param[in] name The name of the counter - * @param[in] delta The amount by which to increment the counter - */ -void ITTAPI __itt_counter_inc_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) -#define __itt_counter_inc_v3(d,x) ITTNOTIFY_VOID_D1(counter_inc_v3,d,x) -#define __itt_counter_inc_v3_ptr ITTNOTIFY_NAME(counter_inc_v3) -#define __itt_counter_inc_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_inc_delta_v3,d,x,y) -#define __itt_counter_inc_delta_v3_ptr ITTNOTIFY_NAME(counter_inc_delta_v3) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_inc_v3(domain,name) -#define __itt_counter_inc_v3_ptr 0 -#define __itt_counter_inc_delta_v3(domain,name,delta) -#define __itt_counter_inc_delta_v3_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_inc_v3_ptr 0 -#define __itt_counter_inc_delta_v3_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - - -/** - * @ingroup counters - * @brief Decrement a counter by one. - * The first call with a given name creates a counter by that name and sets its - * value to zero. Successive calls decrement the counter value. - * @param[in] domain The domain controlling the call. Counter names are not domain specific. - * The domain argument is used only to enable or disable the API calls. - * @param[in] name The name of the counter - */ -void ITTAPI __itt_counter_dec_v3(const __itt_domain *domain, __itt_string_handle *name); - -/** - * @ingroup counters - * @brief Decrement a counter by the value specified in delta. - * @param[in] domain The domain controlling the call. Counter names are not domain specific. - * The domain argument is used only to enable or disable the API calls. - * @param[in] name The name of the counter - * @param[in] delta The amount by which to decrement the counter - */ -void ITTAPI __itt_counter_dec_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_dec_v3, (const __itt_domain *domain, __itt_string_handle *name)) -ITT_STUBV(ITTAPI, void, counter_dec_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) -#define __itt_counter_dec_v3(d,x) ITTNOTIFY_VOID_D1(counter_dec_v3,d,x) -#define __itt_counter_dec_v3_ptr ITTNOTIFY_NAME(counter_dec_v3) -#define __itt_counter_dec_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_dec_delta_v3,d,x,y) -#define __itt_counter_dec_delta_v3_ptr ITTNOTIFY_NAME(counter_dec_delta_v3) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_dec_v3(domain,name) -#define __itt_counter_dec_v3_ptr 0 -#define __itt_counter_dec_delta_v3(domain,name,delta) -#define __itt_counter_dec_delta_v3_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_dec_v3_ptr 0 -#define __itt_counter_dec_delta_v3_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @} counters group */ - - -/** - * @brief Set the counter value - */ -void ITTAPI __itt_counter_set_value(__itt_counter id, void *value_ptr); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_set_value, (__itt_counter id, void *value_ptr)) -#define __itt_counter_set_value ITTNOTIFY_VOID(counter_set_value) -#define __itt_counter_set_value_ptr ITTNOTIFY_NAME(counter_set_value) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_set_value(id, value_ptr) -#define __itt_counter_set_value_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_set_value_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Set the counter value - */ -void ITTAPI __itt_counter_set_value_ex(__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_set_value_ex, (__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr)) -#define __itt_counter_set_value_ex ITTNOTIFY_VOID(counter_set_value_ex) -#define __itt_counter_set_value_ex_ptr ITTNOTIFY_NAME(counter_set_value_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) -#define __itt_counter_set_value_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_set_value_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Create a typed counter with given name/domain - * - * After __itt_counter_create_typed() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), - * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) - * can be used to change the value of the counter - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_counter ITTAPI __itt_counter_create_typedA(const char *name, const char *domain, __itt_metadata_type type); -__itt_counter ITTAPI __itt_counter_create_typedW(const wchar_t *name, const wchar_t *domain, __itt_metadata_type type); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_counter_create_typed __itt_counter_create_typedW -# define __itt_counter_create_typed_ptr __itt_counter_create_typedW_ptr -#else /* UNICODE */ -# define __itt_counter_create_typed __itt_counter_create_typedA -# define __itt_counter_create_typed_ptr __itt_counter_create_typedA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_counter ITTAPI __itt_counter_create_typed(const char *name, const char *domain, __itt_metadata_type type); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_counter, counter_create_typedA, (const char *name, const char *domain, __itt_metadata_type type)) -ITT_STUB(ITTAPI, __itt_counter, counter_create_typedW, (const wchar_t *name, const wchar_t *domain, __itt_metadata_type type)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_counter, counter_create_typed, (const char *name, const char *domain, __itt_metadata_type type)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_create_typedA ITTNOTIFY_DATA(counter_create_typedA) -#define __itt_counter_create_typedA_ptr ITTNOTIFY_NAME(counter_create_typedA) -#define __itt_counter_create_typedW ITTNOTIFY_DATA(counter_create_typedW) -#define __itt_counter_create_typedW_ptr ITTNOTIFY_NAME(counter_create_typedW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create_typed ITTNOTIFY_DATA(counter_create_typed) -#define __itt_counter_create_typed_ptr ITTNOTIFY_NAME(counter_create_typed) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_create_typedA(name, domain, type) -#define __itt_counter_create_typedA_ptr 0 -#define __itt_counter_create_typedW(name, domain, type) -#define __itt_counter_create_typedW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create_typed(name, domain, type) -#define __itt_counter_create_typed_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_counter_create_typedA_ptr 0 -#define __itt_counter_create_typedW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_counter_create_typed_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Destroy the counter identified by the pointer previously returned by __itt_counter_create() or - * __itt_counter_create_typed() - */ -void ITTAPI __itt_counter_destroy(__itt_counter id); - -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id)) -#define __itt_counter_destroy ITTNOTIFY_VOID(counter_destroy) -#define __itt_counter_destroy_ptr ITTNOTIFY_NAME(counter_destroy) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_counter_destroy(id) -#define __itt_counter_destroy_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_counter_destroy_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} counters group */ - -/** - * @ingroup markers - * @brief Create a marker instance. - * @param[in] domain The domain for this marker - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] id The instance ID for this marker, or __itt_null - * @param[in] name The name for this marker - * @param[in] scope The scope for this marker - */ -void ITTAPI __itt_marker_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope)) -#define __itt_marker_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(marker_ex,d,x,y,z,a,b) -#define __itt_marker_ex_ptr ITTNOTIFY_NAME(marker_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_marker_ex(domain,clock_domain,timestamp,id,name,scope) -#define __itt_marker_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_marker_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @ingroup clockdomain - * @brief Add a relation to the current task instance. - * The current task instance is the head of the relation. - * @param[in] domain The domain controlling this call - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] relation The kind of relation - * @param[in] tail The ID for the tail of the relation - */ -void ITTAPI __itt_relation_add_to_current_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail); - -/** - * @ingroup clockdomain - * @brief Add a relation between two instance identifiers. - * @param[in] domain The domain controlling this call - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] head The ID for the head of the relation - * @param[in] relation The kind of relation - * @param[in] tail The ID for the tail of the relation - */ -void ITTAPI __itt_relation_add_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail)) -ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail)) -#define __itt_relation_add_to_current_ex(d,x,y,z,a) ITTNOTIFY_VOID_D4(relation_add_to_current_ex,d,x,y,z,a) -#define __itt_relation_add_to_current_ex_ptr ITTNOTIFY_NAME(relation_add_to_current_ex) -#define __itt_relation_add_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(relation_add_ex,d,x,y,z,a,b) -#define __itt_relation_add_ex_ptr ITTNOTIFY_NAME(relation_add_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_relation_add_to_current_ex(domain,clock_domain,timestame,relation,tail) -#define __itt_relation_add_to_current_ex_ptr 0 -#define __itt_relation_add_ex(domain,clock_domain,timestamp,head,relation,tail) -#define __itt_relation_add_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_relation_add_to_current_ex_ptr 0 -#define __itt_relation_add_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @cond exclude_from_documentation */ -typedef enum ___itt_track_group_type -{ - __itt_track_group_type_normal = 0 -} __itt_track_group_type; -/** @endcond */ - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_track_group -{ - __itt_string_handle* name; /*!< Name of the track group */ - struct ___itt_track* track; /*!< List of child tracks */ - __itt_track_group_type tgtype; /*!< Type of the track group */ - int extra1; /*!< Reserved. Must be zero */ - void* extra2; /*!< Reserved. Must be zero */ - struct ___itt_track_group* next; -} __itt_track_group; - -#pragma pack(pop) -/** @endcond */ - -/** - * @brief Placeholder for custom track types. Currently, "normal" custom track - * is the only available track type. - */ -typedef enum ___itt_track_type -{ - __itt_track_type_normal = 0 -#ifdef INTEL_ITTNOTIFY_API_PRIVATE - , __itt_track_type_queue -#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ -} __itt_track_type; - -/** @cond exclude_from_documentation */ -#pragma pack(push, 8) - -typedef struct ___itt_track -{ - __itt_string_handle* name; /*!< Name of the track group */ - __itt_track_group* group; /*!< Parent group to a track */ - __itt_track_type ttype; /*!< Type of the track */ - int extra1; /*!< Reserved. Must be zero */ - void* extra2; /*!< Reserved. Must be zero */ - struct ___itt_track* next; -} __itt_track; - -#pragma pack(pop) -/** @endcond */ - -/** - * @brief Create logical track group. - */ -__itt_track_group* ITTAPI __itt_track_group_create(__itt_string_handle* name, __itt_track_group_type track_group_type); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type)) -#define __itt_track_group_create ITTNOTIFY_DATA(track_group_create) -#define __itt_track_group_create_ptr ITTNOTIFY_NAME(track_group_create) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_track_group_create(name) (__itt_track_group*)0 -#define __itt_track_group_create_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_track_group_create_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Create logical track. - */ -__itt_track* ITTAPI __itt_track_create(__itt_track_group* track_group, __itt_string_handle* name, __itt_track_type track_type); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type)) -#define __itt_track_create ITTNOTIFY_DATA(track_create) -#define __itt_track_create_ptr ITTNOTIFY_NAME(track_create) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_track_create(track_group,name,track_type) (__itt_track*)0 -#define __itt_track_create_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_track_create_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Set the logical track. - */ -void ITTAPI __itt_set_track(__itt_track* track); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track)) -#define __itt_set_track ITTNOTIFY_VOID(set_track) -#define __itt_set_track_ptr ITTNOTIFY_NAME(set_track) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_set_track(track) -#define __itt_set_track_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_set_track_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/* ========================================================================== */ -/** @cond exclude_from_gpa_documentation */ -/** - * @defgroup events Events - * @ingroup public - * Events group - * @{ - */ -/** @brief user event type */ -typedef int __itt_event; - -/** - * @brief Create an event notification - * @note name or namelen being null/name and namelen not matching, user event feature not enabled - * @return non-zero event identifier upon success and __itt_err otherwise - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); -__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_event_create __itt_event_createW -# define __itt_event_create_ptr __itt_event_createW_ptr -#else -# define __itt_event_create __itt_event_createA -# define __itt_event_create_ptr __itt_event_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) -ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA ITTNOTIFY_DATA(event_createA) -#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) -#define __itt_event_createW ITTNOTIFY_DATA(event_createW) -#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create ITTNOTIFY_DATA(event_create) -#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA(name, namelen) (__itt_event)0 -#define __itt_event_createA_ptr 0 -#define __itt_event_createW(name, namelen) (__itt_event)0 -#define __itt_event_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create(name, namelen) (__itt_event)0 -#define __itt_event_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA_ptr 0 -#define __itt_event_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an event occurrence. - * @return __itt_err upon failure (invalid event id/user event feature not enabled) - */ -int LIBITTAPI __itt_event_start(__itt_event event); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) -#define __itt_event_start ITTNOTIFY_DATA(event_start) -#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_event_start(event) (int)0 -#define __itt_event_start_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_event_start_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an event end occurrence. - * @note It is optional if events do not have durations. - * @return __itt_err upon failure (invalid event id/user event feature not enabled) - */ -int LIBITTAPI __itt_event_end(__itt_event event); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) -#define __itt_event_end ITTNOTIFY_DATA(event_end) -#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_event_end(event) (int)0 -#define __itt_event_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_event_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} events group */ - - -/** - * @defgroup arrays Arrays Visualizer - * @ingroup public - * Visualize arrays - * @{ - */ - -/** - * @enum __itt_av_data_type - * @brief Defines types of arrays data (for C/C++ intrinsic types) - */ -typedef enum -{ - __itt_e_first = 0, - __itt_e_char = 0, /* 1-byte integer */ - __itt_e_uchar, /* 1-byte unsigned integer */ - __itt_e_int16, /* 2-byte integer */ - __itt_e_uint16, /* 2-byte unsigned integer */ - __itt_e_int32, /* 4-byte integer */ - __itt_e_uint32, /* 4-byte unsigned integer */ - __itt_e_int64, /* 8-byte integer */ - __itt_e_uint64, /* 8-byte unsigned integer */ - __itt_e_float, /* 4-byte floating */ - __itt_e_double, /* 8-byte floating */ - __itt_e_last = __itt_e_double -} __itt_av_data_type; - -/** - * @brief Save an array data to a file. - * Output format is defined by the file extension. The csv and bmp formats are supported (bmp - for 2-dimensional array only). - * @param[in] data - pointer to the array data - * @param[in] rank - the rank of the array - * @param[in] dimensions - pointer to an array of integers, which specifies the array dimensions. - * The size of dimensions must be equal to the rank - * @param[in] type - the type of the array, specified as one of the __itt_av_data_type values (for intrinsic types) - * @param[in] filePath - the file path; the output format is defined by the file extension - * @param[in] columnOrder - defines how the array is stored in the linear memory. - * It should be 1 for column-major order (e.g. in FORTRAN) or 0 - for row-major order (e.g. in C). - */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -int ITTAPI __itt_av_saveA(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); -int ITTAPI __itt_av_saveW(void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_av_save __itt_av_saveW -# define __itt_av_save_ptr __itt_av_saveW_ptr -#else /* UNICODE */ -# define __itt_av_save __itt_av_saveA -# define __itt_av_save_ptr __itt_av_saveA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -int ITTAPI __itt_av_save(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) -ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_av_saveA ITTNOTIFY_DATA(av_saveA) -#define __itt_av_saveA_ptr ITTNOTIFY_NAME(av_saveA) -#define __itt_av_saveW ITTNOTIFY_DATA(av_saveW) -#define __itt_av_saveW_ptr ITTNOTIFY_NAME(av_saveW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_av_save ITTNOTIFY_DATA(av_save) -#define __itt_av_save_ptr ITTNOTIFY_NAME(av_save) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_av_saveA(name) -#define __itt_av_saveA_ptr 0 -#define __itt_av_saveW(name) -#define __itt_av_saveW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_av_save(name) -#define __itt_av_save_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_av_saveA_ptr 0 -#define __itt_av_saveW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_av_save_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -void ITTAPI __itt_enable_attach(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, enable_attach, (void)) -#define __itt_enable_attach ITTNOTIFY_VOID(enable_attach) -#define __itt_enable_attach_ptr ITTNOTIFY_NAME(enable_attach) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_enable_attach() -#define __itt_enable_attach_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_enable_attach_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @cond exclude_from_gpa_documentation */ - -/** @} arrays group */ - -/** @endcond */ - -/** - * @brief Module load info - * This API is used to report necessary information in case of module relocation - * @param[in] start_addr - relocated module start address - * @param[in] end_addr - relocated module end address - * @param[in] path - file system path to the module - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_module_loadA(void *start_addr, void *end_addr, const char *path); -void ITTAPI __itt_module_loadW(void *start_addr, void *end_addr, const wchar_t *path); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_module_load __itt_module_loadW -# define __itt_module_load_ptr __itt_module_loadW_ptr -#else /* UNICODE */ -# define __itt_module_load __itt_module_loadA -# define __itt_module_load_ptr __itt_module_loadA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_module_load(void *start_addr, void *end_addr, const char *path); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, void, module_loadA, (void *start_addr, void *end_addr, const char *path)) -ITT_STUB(ITTAPI, void, module_loadW, (void *start_addr, void *end_addr, const wchar_t *path)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_module_loadA ITTNOTIFY_VOID(module_loadA) -#define __itt_module_loadA_ptr ITTNOTIFY_NAME(module_loadA) -#define __itt_module_loadW ITTNOTIFY_VOID(module_loadW) -#define __itt_module_loadW_ptr ITTNOTIFY_NAME(module_loadW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_module_load ITTNOTIFY_VOID(module_load) -#define __itt_module_load_ptr ITTNOTIFY_NAME(module_load) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_module_loadA(start_addr, end_addr, path) -#define __itt_module_loadA_ptr 0 -#define __itt_module_loadW(start_addr, end_addr, path) -#define __itt_module_loadW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_module_load(start_addr, end_addr, path) -#define __itt_module_load_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_module_loadA_ptr 0 -#define __itt_module_loadW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_module_load_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _ITTNOTIFY_H_ */ - -#ifdef INTEL_ITTNOTIFY_API_PRIVATE - -#ifndef _ITTNOTIFY_PRIVATE_ -#define _ITTNOTIFY_PRIVATE_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @ingroup clockdomain - * @brief Begin an overlapped task instance. - * @param[in] domain The domain for this task - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. - * @param[in] parentid The parent of this task, or __itt_null. - * @param[in] name The name of this task. - */ -void ITTAPI __itt_task_begin_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); - -/** - * @ingroup clockdomain - * @brief End an overlapped task instance. - * @param[in] domain The domain for this task - * @param[in] clock_domain The clock domain controlling the execution of this call. - * @param[in] timestamp The user defined timestamp. - * @param[in] taskid Explicit ID of finished task - */ -void ITTAPI __itt_task_end_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name)) -ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid)) -#define __itt_task_begin_overlapped_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_overlapped_ex,d,x,y,z,a,b) -#define __itt_task_begin_overlapped_ex_ptr ITTNOTIFY_NAME(task_begin_overlapped_ex) -#define __itt_task_end_overlapped_ex(d,x,y,z) ITTNOTIFY_VOID_D3(task_end_overlapped_ex,d,x,y,z) -#define __itt_task_end_overlapped_ex_ptr ITTNOTIFY_NAME(task_end_overlapped_ex) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_task_begin_overlapped_ex(domain,clock_domain,timestamp,taskid,parentid,name) -#define __itt_task_begin_overlapped_ex_ptr 0 -#define __itt_task_end_overlapped_ex(domain,clock_domain,timestamp,taskid) -#define __itt_task_end_overlapped_ex_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_task_begin_overlapped_ex_ptr 0 -#define __itt_task_end_overlapped_ptr 0 -#define __itt_task_end_overlapped_ex_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @defgroup makrs_internal Marks - * @ingroup internal - * Marks group - * @warning Internal API: - * - It is not shipped to outside of Intel - * - It is delivered to internal Intel teams using e-mail or SVN access only - * @{ - */ -/** @brief user mark type */ -typedef int __itt_mark_type; - -/** - * @brief Creates a user mark type with the specified name using char or Unicode string. - * @param[in] name - name of mark to create - * @return Returns a handle to the mark type - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_mark_type ITTAPI __itt_mark_createA(const char *name); -__itt_mark_type ITTAPI __itt_mark_createW(const wchar_t *name); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_mark_create __itt_mark_createW -# define __itt_mark_create_ptr __itt_mark_createW_ptr -#else /* UNICODE */ -# define __itt_mark_create __itt_mark_createA -# define __itt_mark_create_ptr __itt_mark_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_mark_type ITTAPI __itt_mark_create(const char *name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name)) -ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_createA ITTNOTIFY_DATA(mark_createA) -#define __itt_mark_createA_ptr ITTNOTIFY_NAME(mark_createA) -#define __itt_mark_createW ITTNOTIFY_DATA(mark_createW) -#define __itt_mark_createW_ptr ITTNOTIFY_NAME(mark_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_create ITTNOTIFY_DATA(mark_create) -#define __itt_mark_create_ptr ITTNOTIFY_NAME(mark_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_createA(name) (__itt_mark_type)0 -#define __itt_mark_createA_ptr 0 -#define __itt_mark_createW(name) (__itt_mark_type)0 -#define __itt_mark_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_create(name) (__itt_mark_type)0 -#define __itt_mark_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_createA_ptr 0 -#define __itt_mark_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Creates a "discrete" user mark type of the specified type and an optional parameter using char or Unicode string. - * - * - The mark of "discrete" type is placed to collection results in case of success. It appears in overtime view(s) as a special tick sign. - * - The call is "synchronous" - function returns after mark is actually added to results. - * - This function is useful, for example, to mark different phases of application - * (beginning of the next mark automatically meand end of current region). - * - Can be used together with "continuous" marks (see below) at the same collection session - * @param[in] mt - mark, created by __itt_mark_create(const char* name) function - * @param[in] parameter - string parameter of mark - * @return Returns zero value in case of success, non-zero value otherwise. - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -int ITTAPI __itt_markA(__itt_mark_type mt, const char *parameter); -int ITTAPI __itt_markW(__itt_mark_type mt, const wchar_t *parameter); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_mark __itt_markW -# define __itt_mark_ptr __itt_markW_ptr -#else /* UNICODE */ -# define __itt_mark __itt_markA -# define __itt_mark_ptr __itt_markA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -int ITTAPI __itt_mark(__itt_mark_type mt, const char *parameter); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter)) -ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_markA ITTNOTIFY_DATA(markA) -#define __itt_markA_ptr ITTNOTIFY_NAME(markA) -#define __itt_markW ITTNOTIFY_DATA(markW) -#define __itt_markW_ptr ITTNOTIFY_NAME(markW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark ITTNOTIFY_DATA(mark) -#define __itt_mark_ptr ITTNOTIFY_NAME(mark) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_markA(mt, parameter) (int)0 -#define __itt_markA_ptr 0 -#define __itt_markW(mt, parameter) (int)0 -#define __itt_markW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark(mt, parameter) (int)0 -#define __itt_mark_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_markA_ptr 0 -#define __itt_markW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Use this if necessary to create a "discrete" user event type (mark) for process - * rather then for one thread - * @see int __itt_mark(__itt_mark_type mt, const char* parameter); - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -int ITTAPI __itt_mark_globalA(__itt_mark_type mt, const char *parameter); -int ITTAPI __itt_mark_globalW(__itt_mark_type mt, const wchar_t *parameter); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_mark_global __itt_mark_globalW -# define __itt_mark_global_ptr __itt_mark_globalW_ptr -#else /* UNICODE */ -# define __itt_mark_global __itt_mark_globalA -# define __itt_mark_global_ptr __itt_mark_globalA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -int ITTAPI __itt_mark_global(__itt_mark_type mt, const char *parameter); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter)) -ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_globalA ITTNOTIFY_DATA(mark_globalA) -#define __itt_mark_globalA_ptr ITTNOTIFY_NAME(mark_globalA) -#define __itt_mark_globalW ITTNOTIFY_DATA(mark_globalW) -#define __itt_mark_globalW_ptr ITTNOTIFY_NAME(mark_globalW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_global ITTNOTIFY_DATA(mark_global) -#define __itt_mark_global_ptr ITTNOTIFY_NAME(mark_global) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_globalA(mt, parameter) (int)0 -#define __itt_mark_globalA_ptr 0 -#define __itt_mark_globalW(mt, parameter) (int)0 -#define __itt_mark_globalW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_global(mt, parameter) (int)0 -#define __itt_mark_global_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_mark_globalA_ptr 0 -#define __itt_mark_globalW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_mark_global_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Creates an "end" point for "continuous" mark with specified name. - * - * - Returns zero value in case of success, non-zero value otherwise. - * Also returns non-zero value when preceding "begin" point for the - * mark with the same name failed to be created or not created. - * - The mark of "continuous" type is placed to collection results in - * case of success. It appears in overtime view(s) as a special tick - * sign (different from "discrete" mark) together with line from - * corresponding "begin" mark to "end" mark. - * @note Continuous marks can overlap and be nested inside each other. - * Discrete mark can be nested inside marked region - * @param[in] mt - mark, created by __itt_mark_create(const char* name) function - * @return Returns zero value in case of success, non-zero value otherwise. - */ -int ITTAPI __itt_mark_off(__itt_mark_type mt); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt)) -#define __itt_mark_off ITTNOTIFY_DATA(mark_off) -#define __itt_mark_off_ptr ITTNOTIFY_NAME(mark_off) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_mark_off(mt) (int)0 -#define __itt_mark_off_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_mark_off_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Use this if necessary to create an "end" point for mark of process - * @see int __itt_mark_off(__itt_mark_type mt); - */ -int ITTAPI __itt_mark_global_off(__itt_mark_type mt); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt)) -#define __itt_mark_global_off ITTNOTIFY_DATA(mark_global_off) -#define __itt_mark_global_off_ptr ITTNOTIFY_NAME(mark_global_off) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_mark_global_off(mt) (int)0 -#define __itt_mark_global_off_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_mark_global_off_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} marks group */ - -/** - * @defgroup counters_internal Counters - * @ingroup internal - * Counters group - * @{ - */ - - -/** - * @defgroup stitch Stack Stitching - * @ingroup internal - * Stack Stitching group - * @{ - */ -/** - * @brief opaque structure for counter identification - */ -typedef struct ___itt_caller *__itt_caller; - -/** - * @brief Create the stitch point e.g. a point in call stack where other stacks should be stitched to. - * The function returns a unique identifier which is used to match the cut points with corresponding stitch points. - */ -__itt_caller ITTAPI __itt_stack_caller_create(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void)) -#define __itt_stack_caller_create ITTNOTIFY_DATA(stack_caller_create) -#define __itt_stack_caller_create_ptr ITTNOTIFY_NAME(stack_caller_create) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_stack_caller_create() (__itt_caller)0 -#define __itt_stack_caller_create_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_stack_caller_create_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Destroy the inforamtion about stitch point identified by the pointer previously returned by __itt_stack_caller_create() - */ -void ITTAPI __itt_stack_caller_destroy(__itt_caller id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id)) -#define __itt_stack_caller_destroy ITTNOTIFY_VOID(stack_caller_destroy) -#define __itt_stack_caller_destroy_ptr ITTNOTIFY_NAME(stack_caller_destroy) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_stack_caller_destroy(id) -#define __itt_stack_caller_destroy_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_stack_caller_destroy_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Sets the cut point. Stack from each event which occurs after this call will be cut - * at the same stack level the function was called and stitched to the corresponding stitch point. - */ -void ITTAPI __itt_stack_callee_enter(__itt_caller id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id)) -#define __itt_stack_callee_enter ITTNOTIFY_VOID(stack_callee_enter) -#define __itt_stack_callee_enter_ptr ITTNOTIFY_NAME(stack_callee_enter) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_stack_callee_enter(id) -#define __itt_stack_callee_enter_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_stack_callee_enter_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief This function eliminates the cut point which was set by latest __itt_stack_callee_enter(). - */ -void ITTAPI __itt_stack_callee_leave(__itt_caller id); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id)) -#define __itt_stack_callee_leave ITTNOTIFY_VOID(stack_callee_leave) -#define __itt_stack_callee_leave_ptr ITTNOTIFY_NAME(stack_callee_leave) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_stack_callee_leave(id) -#define __itt_stack_callee_leave_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_stack_callee_leave_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @} stitch group */ - -/* ***************************************************************************************************************************** */ - -#include - -/** @cond exclude_from_documentation */ -typedef enum __itt_error_code -{ - __itt_error_success = 0, /*!< no error */ - __itt_error_no_module = 1, /*!< module can't be loaded */ - /* %1$s -- library name; win: %2$d -- system error code; unx: %2$s -- system error message. */ - __itt_error_no_symbol = 2, /*!< symbol not found */ - /* %1$s -- library name, %2$s -- symbol name. */ - __itt_error_unknown_group = 3, /*!< unknown group specified */ - /* %1$s -- env var name, %2$s -- group name. */ - __itt_error_cant_read_env = 4, /*!< GetEnvironmentVariable() failed */ - /* %1$s -- env var name, %2$d -- system error. */ - __itt_error_env_too_long = 5, /*!< variable value too long */ - /* %1$s -- env var name, %2$d -- actual length of the var, %3$d -- max allowed length. */ - __itt_error_system = 6 /*!< pthread_mutexattr_init or pthread_mutex_init failed */ - /* %1$s -- function name, %2$d -- errno. */ -} __itt_error_code; - -typedef void (__itt_error_handler_t)(__itt_error_code code, va_list); -__itt_error_handler_t* __itt_set_error_handler(__itt_error_handler_t*); - -const char* ITTAPI __itt_api_version(void); -/** @endcond */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#define __itt_error_handler ITT_JOIN(INTEL_ITTNOTIFY_PREFIX, error_handler) -void __itt_error_handler(__itt_error_code code, va_list args); -extern const int ITTNOTIFY_NAME(err); -#define __itt_err ITTNOTIFY_NAME(err) -ITT_STUB(ITTAPI, const char*, api_version, (void)) -#define __itt_api_version ITTNOTIFY_DATA(api_version) -#define __itt_api_version_ptr ITTNOTIFY_NAME(api_version) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_api_version() (const char*)0 -#define __itt_api_version_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_api_version_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _ITTNOTIFY_PRIVATE_ */ - -#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _ITTNOTIFY_H_ +#define _ITTNOTIFY_H_ + +/** +@file +@brief Public User API functions and types +@mainpage + +The ITT API is used to annotate a user's program with additional information +that can be used by correctness and performance tools. The user inserts +calls in their program. Those calls generate information that is collected +at runtime, and used by Intel(R) Threading Tools. + +@section API Concepts +The following general concepts are used throughout the API. + +@subsection Unicode Support +Many API functions take character string arguments. On Windows, there +are two versions of each such function. The function name is suffixed +by W if Unicode support is enabled, and by A otherwise. Any API function +that takes a character string argument adheres to this convention. + +@subsection Conditional Compilation +Many users prefer having an option to modify ITT API code when linking it +inside their runtimes. ITT API header file provides a mechanism to replace +ITT API function names inside your code with empty strings. To do this, +define the macros INTEL_NO_ITTNOTIFY_API during compilation and remove the +static library from the linker script. + +@subsection Domains +[see domains] +Domains provide a way to separate notification for different modules or +libraries in a program. Domains are specified by dotted character strings, +e.g. TBB.Internal.Control. + +A mechanism (to be specified) is provided to enable and disable +domains. By default, all domains are enabled. +@subsection Named Entities and Instances +Named entities (frames, regions, tasks, and markers) communicate +information about the program to the analysis tools. A named entity often +refers to a section of program code, or to some set of logical concepts +that the programmer wants to group together. + +Named entities relate to the programmer's static view of the program. When +the program actually executes, many instances of a given named entity +may be created. + +The API annotations denote instances of named entities. The actual +named entities are displayed using the analysis tools. In other words, +the named entities come into existence when instances are created. + +Instances of named entities may have instance identifiers (IDs). Some +API calls use instance identifiers to create relationships between +different instances of named entities. Other API calls associate data +with instances of named entities. + +Some named entities must always have instance IDs. In particular, regions +and frames always have IDs. Task and markers need IDs only if the ID is +needed in another API call (such as adding a relation or metadata). + +The lifetime of instance IDs is distinct from the lifetime of +instances. This allows various relationships to be specified separate +from the actual execution of instances. This flexibility comes at the +expense of extra API calls. + +The same ID may not be reused for different instances, unless a previous +[ref] __itt_id_destroy call for that ID has been issued. +*/ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +#ifdef INTEL_ITTNOTIFY_ENABLE_LEGACY +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# pragma message("WARNING!!! Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro") +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# warning "Deprecated API is used. Please undefine INTEL_ITTNOTIFY_ENABLE_LEGACY macro" +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# include "legacy/ittnotify.h" +#endif /* INTEL_ITTNOTIFY_ENABLE_LEGACY */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** @cond exclude_from_gpa_documentation */ +/** + * @defgroup public Public API + * @{ + * @} + */ + +/** + * @defgroup control Collection Control + * @ingroup public + * General behavior: application continues to run, but no profiling information is being collected + * + * Pausing occurs not only for the current thread but for all process as well as spawned processes + * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: + * - Does not analyze or report errors that involve memory access. + * - Other errors are reported as usual. Pausing data collection in + * Intel(R) Parallel Inspector and Intel(R) Inspector XE + * only pauses tracing and analyzing memory access. + * It does not pause tracing or analyzing threading APIs. + * . + * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: + * - Does continue to record when new threads are started. + * . + * - Other effects: + * - Possible reduction of runtime overhead. + * . + * @{ + */ +/** @brief Pause collection */ +void ITTAPI __itt_pause(void); +/** @brief Resume collection */ +void ITTAPI __itt_resume(void); +/** @brief Detach collection */ +void ITTAPI __itt_detach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, pause, (void)) +ITT_STUBV(ITTAPI, void, resume, (void)) +ITT_STUBV(ITTAPI, void, detach, (void)) +#define __itt_pause ITTNOTIFY_VOID(pause) +#define __itt_pause_ptr ITTNOTIFY_NAME(pause) +#define __itt_resume ITTNOTIFY_VOID(resume) +#define __itt_resume_ptr ITTNOTIFY_NAME(resume) +#define __itt_detach ITTNOTIFY_VOID(detach) +#define __itt_detach_ptr ITTNOTIFY_NAME(detach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_pause() +#define __itt_pause_ptr 0 +#define __itt_resume() +#define __itt_resume_ptr 0 +#define __itt_detach() +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_pause_ptr 0 +#define __itt_resume_ptr 0 +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} control group */ +/** @endcond */ + +/** + * @defgroup threads Threads + * @ingroup public + * Give names to threads + * @{ + */ +/** + * @brief Sets thread name of calling thread + * @param[in] name - name of thread + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_thread_set_nameA(const char *name); +void ITTAPI __itt_thread_set_nameW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_thread_set_name __itt_thread_set_nameW +# define __itt_thread_set_name_ptr __itt_thread_set_nameW_ptr +#else /* UNICODE */ +# define __itt_thread_set_name __itt_thread_set_nameA +# define __itt_thread_set_name_ptr __itt_thread_set_nameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_thread_set_name(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name)) +ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA ITTNOTIFY_VOID(thread_set_nameA) +#define __itt_thread_set_nameA_ptr ITTNOTIFY_NAME(thread_set_nameA) +#define __itt_thread_set_nameW ITTNOTIFY_VOID(thread_set_nameW) +#define __itt_thread_set_nameW_ptr ITTNOTIFY_NAME(thread_set_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name ITTNOTIFY_VOID(thread_set_name) +#define __itt_thread_set_name_ptr ITTNOTIFY_NAME(thread_set_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA(name) +#define __itt_thread_set_nameA_ptr 0 +#define __itt_thread_set_nameW(name) +#define __itt_thread_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name(name) +#define __itt_thread_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thread_set_nameA_ptr 0 +#define __itt_thread_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thread_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** + * @brief Mark current thread as ignored from this point on, for the duration of its existence. + */ +void ITTAPI __itt_thread_ignore(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, thread_ignore, (void)) +#define __itt_thread_ignore ITTNOTIFY_VOID(thread_ignore) +#define __itt_thread_ignore_ptr ITTNOTIFY_NAME(thread_ignore) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thread_ignore() +#define __itt_thread_ignore_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thread_ignore_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} threads group */ + +/** + * @defgroup suppress Error suppression + * @ingroup public + * General behavior: application continues to run, but errors are suppressed + * + * @{ + */ + +/*****************************************************************//** + * @name group of functions used for error suppression in correctness tools + *********************************************************************/ +/** @{ */ +/** + * @hideinitializer + * @brief possible value for suppression mask + */ +#define __itt_suppress_all_errors 0x7fffffff + +/** + * @hideinitializer + * @brief possible value for suppression mask (suppresses errors from threading analysis) + */ +#define __itt_suppress_threading_errors 0x000000ff + +/** + * @hideinitializer + * @brief possible value for suppression mask (suppresses errors from memory analysis) + */ +#define __itt_suppress_memory_errors 0x0000ff00 + +/** + * @brief Start suppressing errors identified in mask on this thread + */ +void ITTAPI __itt_suppress_push(unsigned int mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask)) +#define __itt_suppress_push ITTNOTIFY_VOID(suppress_push) +#define __itt_suppress_push_ptr ITTNOTIFY_NAME(suppress_push) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_push(mask) +#define __itt_suppress_push_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_push_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Undo the effects of the matching call to __itt_suppress_push + */ +void ITTAPI __itt_suppress_pop(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_pop, (void)) +#define __itt_suppress_pop ITTNOTIFY_VOID(suppress_pop) +#define __itt_suppress_pop_ptr ITTNOTIFY_NAME(suppress_pop) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_pop() +#define __itt_suppress_pop_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_pop_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @enum __itt_model_disable + * @brief Enumerator for the disable methods + */ +typedef enum __itt_suppress_mode { + __itt_unsuppress_range, + __itt_suppress_range +} __itt_suppress_mode_t; + +/** + * @brief Mark a range of memory for error suppression or unsuppression for error types included in mask + */ +void ITTAPI __itt_suppress_mark_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) +#define __itt_suppress_mark_range ITTNOTIFY_VOID(suppress_mark_range) +#define __itt_suppress_mark_range_ptr ITTNOTIFY_NAME(suppress_mark_range) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_mark_range(mask) +#define __itt_suppress_mark_range_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_mark_range_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Undo the effect of a matching call to __itt_suppress_mark_range. If not matching + * call is found, nothing is changed. + */ +void ITTAPI __itt_suppress_clear_range(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, suppress_clear_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size)) +#define __itt_suppress_clear_range ITTNOTIFY_VOID(suppress_clear_range) +#define __itt_suppress_clear_range_ptr ITTNOTIFY_NAME(suppress_clear_range) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_suppress_clear_range(mask) +#define __itt_suppress_clear_range_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_suppress_clear_range_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ +/** @} suppress group */ + +/** + * @defgroup sync Synchronization + * @ingroup public + * Indicate user-written synchronization code + * @{ + */ +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_barrier 1 + +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_mutex 2 + +/** +@brief Name a synchronization object +@param[in] addr Handle for the synchronization object. You should +use a real address to uniquely identify the synchronization object. +@param[in] objtype null-terminated object type string. If NULL is +passed, the name will be "User Synchronization". +@param[in] objname null-terminated object name string. If NULL, +no name will be assigned to the object. +@param[in] attribute one of [#__itt_attr_barrier, #__itt_attr_mutex] + */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_createA(void *addr, const char *objtype, const char *objname, int attribute); +void ITTAPI __itt_sync_createW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_create __itt_sync_createW +# define __itt_sync_create_ptr __itt_sync_createW_ptr +#else /* UNICODE */ +# define __itt_sync_create __itt_sync_createA +# define __itt_sync_create_ptr __itt_sync_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_create (void *addr, const char *objtype, const char *objname, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute)) +ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char* objtype, const char* objname, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA ITTNOTIFY_VOID(sync_createA) +#define __itt_sync_createA_ptr ITTNOTIFY_NAME(sync_createA) +#define __itt_sync_createW ITTNOTIFY_VOID(sync_createW) +#define __itt_sync_createW_ptr ITTNOTIFY_NAME(sync_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create ITTNOTIFY_VOID(sync_create) +#define __itt_sync_create_ptr ITTNOTIFY_NAME(sync_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA(addr, objtype, objname, attribute) +#define __itt_sync_createA_ptr 0 +#define __itt_sync_createW(addr, objtype, objname, attribute) +#define __itt_sync_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create(addr, objtype, objname, attribute) +#define __itt_sync_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_createA_ptr 0 +#define __itt_sync_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** +@brief Rename a synchronization object + +You can use the rename call to assign or reassign a name to a given +synchronization object. +@param[in] addr handle for the synchronization object. +@param[in] name null-terminated object name string. +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_renameA(void *addr, const char *name); +void ITTAPI __itt_sync_renameW(void *addr, const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_rename __itt_sync_renameW +# define __itt_sync_rename_ptr __itt_sync_renameW_ptr +#else /* UNICODE */ +# define __itt_sync_rename __itt_sync_renameA +# define __itt_sync_rename_ptr __itt_sync_renameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_rename(void *addr, const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name)) +ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA ITTNOTIFY_VOID(sync_renameA) +#define __itt_sync_renameA_ptr ITTNOTIFY_NAME(sync_renameA) +#define __itt_sync_renameW ITTNOTIFY_VOID(sync_renameW) +#define __itt_sync_renameW_ptr ITTNOTIFY_NAME(sync_renameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename ITTNOTIFY_VOID(sync_rename) +#define __itt_sync_rename_ptr ITTNOTIFY_NAME(sync_rename) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA(addr, name) +#define __itt_sync_renameA_ptr 0 +#define __itt_sync_renameW(addr, name) +#define __itt_sync_renameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename(addr, name) +#define __itt_sync_rename_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_renameA_ptr 0 +#define __itt_sync_renameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_rename_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + @brief Destroy a synchronization object. + @param addr Handle for the synchronization object. + */ +void ITTAPI __itt_sync_destroy(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr)) +#define __itt_sync_destroy ITTNOTIFY_VOID(sync_destroy) +#define __itt_sync_destroy_ptr ITTNOTIFY_NAME(sync_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_destroy(addr) +#define __itt_sync_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/*****************************************************************//** + * @name group of functions is used for performance measurement tools + *********************************************************************/ +/** @{ */ +/** + * @brief Enter spin loop on user-defined sync object + */ +void ITTAPI __itt_sync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_prepare, (void *addr)) +#define __itt_sync_prepare ITTNOTIFY_VOID(sync_prepare) +#define __itt_sync_prepare_ptr ITTNOTIFY_NAME(sync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_prepare(addr) +#define __itt_sync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Quit spin loop without acquiring spin object + */ +void ITTAPI __itt_sync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr)) +#define __itt_sync_cancel ITTNOTIFY_VOID(sync_cancel) +#define __itt_sync_cancel_ptr ITTNOTIFY_NAME(sync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_cancel(addr) +#define __itt_sync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Successful spin loop completion (sync object acquired) + */ +void ITTAPI __itt_sync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr)) +#define __itt_sync_acquired ITTNOTIFY_VOID(sync_acquired) +#define __itt_sync_acquired_ptr ITTNOTIFY_NAME(sync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_acquired(addr) +#define __itt_sync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Start sync object releasing code. Is called before the lock release call. + */ +void ITTAPI __itt_sync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, sync_releasing, (void *addr)) +#define __itt_sync_releasing ITTNOTIFY_VOID(sync_releasing) +#define __itt_sync_releasing_ptr ITTNOTIFY_NAME(sync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_sync_releasing(addr) +#define __itt_sync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_sync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ + +/** @} sync group */ + +/**************************************************************//** + * @name group of functions is used for correctness checking tools + ******************************************************************/ +/** @{ */ +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_prepare(void* addr); + */ +void ITTAPI __itt_fsync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_prepare, (void *addr)) +#define __itt_fsync_prepare ITTNOTIFY_VOID(fsync_prepare) +#define __itt_fsync_prepare_ptr ITTNOTIFY_NAME(fsync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_prepare(addr) +#define __itt_fsync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_cancel(void *addr); + */ +void ITTAPI __itt_fsync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr)) +#define __itt_fsync_cancel ITTNOTIFY_VOID(fsync_cancel) +#define __itt_fsync_cancel_ptr ITTNOTIFY_NAME(fsync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_cancel(addr) +#define __itt_fsync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_acquired(void *addr); + */ +void ITTAPI __itt_fsync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr)) +#define __itt_fsync_acquired ITTNOTIFY_VOID(fsync_acquired) +#define __itt_fsync_acquired_ptr ITTNOTIFY_NAME(fsync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_acquired(addr) +#define __itt_fsync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup legacy + * @deprecated Legacy API + * @brief Fast synchronization which does no require spinning. + * - This special function is to be used by TBB and OpenMP libraries only when they know + * there is no spin but they need to suppress TC warnings about shared variable modifications. + * - It only has corresponding pointers in static library and does not have corresponding function + * in dynamic library. + * @see void __itt_sync_releasing(void* addr); + */ +void ITTAPI __itt_fsync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, fsync_releasing, (void *addr)) +#define __itt_fsync_releasing ITTNOTIFY_VOID(fsync_releasing) +#define __itt_fsync_releasing_ptr ITTNOTIFY_NAME(fsync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_fsync_releasing(addr) +#define __itt_fsync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_fsync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} */ + +/** + * @defgroup model Modeling by Intel(R) Parallel Advisor + * @ingroup public + * This is the subset of itt used for modeling by Intel(R) Parallel Advisor. + * This API is called ONLY using annotate.h, by "Annotation" macros + * the user places in their sources during the parallelism modeling steps. + * + * site_begin/end and task_begin/end take the address of handle variables, + * which are writeable by the API. Handles must be 0 initialized prior + * to the first call to begin, or may cause a run-time failure. + * The handles are initialized in a multi-thread safe way by the API if + * the handle is 0. The commonly expected idiom is one static handle to + * identify a site or task. If a site or task of the same name has already + * been started during this collection, the same handle MAY be returned, + * but is not required to be - it is unspecified if data merging is done + * based on name. These routines also take an instance variable. Like + * the lexical instance, these must be 0 initialized. Unlike the lexical + * instance, this is used to track a single dynamic instance. + * + * API used by the Intel(R) Parallel Advisor to describe potential concurrency + * and related activities. User-added source annotations expand to calls + * to these procedures to enable modeling of a hypothetical concurrent + * execution serially. + * @{ + */ +#if !defined(_ADVISOR_ANNOTATE_H_) || defined(ANNOTATE_EXPAND_NULL) + +typedef void* __itt_model_site; /*!< @brief handle for lexical site */ +typedef void* __itt_model_site_instance; /*!< @brief handle for dynamic instance */ +typedef void* __itt_model_task; /*!< @brief handle for lexical site */ +typedef void* __itt_model_task_instance; /*!< @brief handle for dynamic instance */ + +/** + * @enum __itt_model_disable + * @brief Enumerator for the disable methods + */ +typedef enum { + __itt_model_disable_observation, + __itt_model_disable_collection +} __itt_model_disable; + +#endif /* !_ADVISOR_ANNOTATE_H_ || ANNOTATE_EXPAND_NULL */ + +/** + * @brief ANNOTATE_SITE_BEGIN/ANNOTATE_SITE_END support. + * + * site_begin/end model a potential concurrency site. + * site instances may be recursively nested with themselves. + * site_end exits the most recently started but unended site for the current + * thread. The handle passed to end may be used to validate structure. + * Instances of a site encountered on different threads concurrently + * are considered completely distinct. If the site name for two different + * lexical sites match, it is unspecified whether they are treated as the + * same or different for data presentation. + */ +void ITTAPI __itt_model_site_begin(__itt_model_site *site, __itt_model_site_instance *instance, const char *name); +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_model_site_beginW(const wchar_t *name); +#endif +void ITTAPI __itt_model_site_beginA(const char *name); +void ITTAPI __itt_model_site_beginAL(const char *name, size_t siteNameLen); +void ITTAPI __itt_model_site_end (__itt_model_site *site, __itt_model_site_instance *instance); +void ITTAPI __itt_model_site_end_2(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name)) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name)) +#endif +ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t siteNameLen)) +ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance)) +ITT_STUBV(ITTAPI, void, model_site_end_2, (void)) +#define __itt_model_site_begin ITTNOTIFY_VOID(model_site_begin) +#define __itt_model_site_begin_ptr ITTNOTIFY_NAME(model_site_begin) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW ITTNOTIFY_VOID(model_site_beginW) +#define __itt_model_site_beginW_ptr ITTNOTIFY_NAME(model_site_beginW) +#endif +#define __itt_model_site_beginA ITTNOTIFY_VOID(model_site_beginA) +#define __itt_model_site_beginA_ptr ITTNOTIFY_NAME(model_site_beginA) +#define __itt_model_site_beginAL ITTNOTIFY_VOID(model_site_beginAL) +#define __itt_model_site_beginAL_ptr ITTNOTIFY_NAME(model_site_beginAL) +#define __itt_model_site_end ITTNOTIFY_VOID(model_site_end) +#define __itt_model_site_end_ptr ITTNOTIFY_NAME(model_site_end) +#define __itt_model_site_end_2 ITTNOTIFY_VOID(model_site_end_2) +#define __itt_model_site_end_2_ptr ITTNOTIFY_NAME(model_site_end_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_site_begin(site, instance, name) +#define __itt_model_site_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW(name) +#define __itt_model_site_beginW_ptr 0 +#endif +#define __itt_model_site_beginA(name) +#define __itt_model_site_beginA_ptr 0 +#define __itt_model_site_beginAL(name, siteNameLen) +#define __itt_model_site_beginAL_ptr 0 +#define __itt_model_site_end(site, instance) +#define __itt_model_site_end_ptr 0 +#define __itt_model_site_end_2() +#define __itt_model_site_end_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_site_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_site_beginW_ptr 0 +#endif +#define __itt_model_site_beginA_ptr 0 +#define __itt_model_site_beginAL_ptr 0 +#define __itt_model_site_end_ptr 0 +#define __itt_model_site_end_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_TASK_BEGIN/ANNOTATE_TASK_END support + * + * task_begin/end model a potential task, which is contained within the most + * closely enclosing dynamic site. task_end exits the most recently started + * but unended task. The handle passed to end may be used to validate + * structure. It is unspecified if bad dynamic nesting is detected. If it + * is, it should be encoded in the resulting data collection. The collector + * should not fail due to construct nesting issues, nor attempt to directly + * indicate the problem. + */ +void ITTAPI __itt_model_task_begin(__itt_model_task *task, __itt_model_task_instance *instance, const char *name); +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_model_task_beginW(const wchar_t *name); +void ITTAPI __itt_model_iteration_taskW(const wchar_t *name); +#endif +void ITTAPI __itt_model_task_beginA(const char *name); +void ITTAPI __itt_model_task_beginAL(const char *name, size_t taskNameLen); +void ITTAPI __itt_model_iteration_taskA(const char *name); +void ITTAPI __itt_model_iteration_taskAL(const char *name, size_t taskNameLen); +void ITTAPI __itt_model_task_end (__itt_model_task *task, __itt_model_task_instance *instance); +void ITTAPI __itt_model_task_end_2(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name)) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name)) +ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name)) +#endif +ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t taskNameLen)) +ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name)) +ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t taskNameLen)) +ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance)) +ITT_STUBV(ITTAPI, void, model_task_end_2, (void)) +#define __itt_model_task_begin ITTNOTIFY_VOID(model_task_begin) +#define __itt_model_task_begin_ptr ITTNOTIFY_NAME(model_task_begin) +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW ITTNOTIFY_VOID(model_task_beginW) +#define __itt_model_task_beginW_ptr ITTNOTIFY_NAME(model_task_beginW) +#define __itt_model_iteration_taskW ITTNOTIFY_VOID(model_iteration_taskW) +#define __itt_model_iteration_taskW_ptr ITTNOTIFY_NAME(model_iteration_taskW) +#endif +#define __itt_model_task_beginA ITTNOTIFY_VOID(model_task_beginA) +#define __itt_model_task_beginA_ptr ITTNOTIFY_NAME(model_task_beginA) +#define __itt_model_task_beginAL ITTNOTIFY_VOID(model_task_beginAL) +#define __itt_model_task_beginAL_ptr ITTNOTIFY_NAME(model_task_beginAL) +#define __itt_model_iteration_taskA ITTNOTIFY_VOID(model_iteration_taskA) +#define __itt_model_iteration_taskA_ptr ITTNOTIFY_NAME(model_iteration_taskA) +#define __itt_model_iteration_taskAL ITTNOTIFY_VOID(model_iteration_taskAL) +#define __itt_model_iteration_taskAL_ptr ITTNOTIFY_NAME(model_iteration_taskAL) +#define __itt_model_task_end ITTNOTIFY_VOID(model_task_end) +#define __itt_model_task_end_ptr ITTNOTIFY_NAME(model_task_end) +#define __itt_model_task_end_2 ITTNOTIFY_VOID(model_task_end_2) +#define __itt_model_task_end_2_ptr ITTNOTIFY_NAME(model_task_end_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_task_begin(task, instance, name) +#define __itt_model_task_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW(name) +#define __itt_model_task_beginW_ptr 0 +#endif +#define __itt_model_task_beginA(name) +#define __itt_model_task_beginA_ptr 0 +#define __itt_model_task_beginAL(name, siteNameLen) +#define __itt_model_task_beginAL_ptr 0 +#define __itt_model_iteration_taskA(name) +#define __itt_model_iteration_taskA_ptr 0 +#define __itt_model_iteration_taskAL(name, siteNameLen) +#define __itt_model_iteration_taskAL_ptr 0 +#define __itt_model_task_end(task, instance) +#define __itt_model_task_end_ptr 0 +#define __itt_model_task_end_2() +#define __itt_model_task_end_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_task_begin_ptr 0 +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_model_task_beginW_ptr 0 +#endif +#define __itt_model_task_beginA_ptr 0 +#define __itt_model_task_beginAL_ptr 0 +#define __itt_model_iteration_taskA_ptr 0 +#define __itt_model_iteration_taskAL_ptr 0 +#define __itt_model_task_end_ptr 0 +#define __itt_model_task_end_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_LOCK_ACQUIRE/ANNOTATE_LOCK_RELEASE support + * + * lock_acquire/release model a potential lock for both lockset and + * performance modeling. Each unique address is modeled as a separate + * lock, with invalid addresses being valid lock IDs. Specifically: + * no storage is accessed by the API at the specified address - it is only + * used for lock identification. Lock acquires may be self-nested and are + * unlocked by a corresponding number of releases. + * (These closely correspond to __itt_sync_acquired/__itt_sync_releasing, + * but may not have identical semantics.) + */ +void ITTAPI __itt_model_lock_acquire(void *lock); +void ITTAPI __itt_model_lock_acquire_2(void *lock); +void ITTAPI __itt_model_lock_release(void *lock); +void ITTAPI __itt_model_lock_release_2(void *lock); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock)) +ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock)) +#define __itt_model_lock_acquire ITTNOTIFY_VOID(model_lock_acquire) +#define __itt_model_lock_acquire_ptr ITTNOTIFY_NAME(model_lock_acquire) +#define __itt_model_lock_acquire_2 ITTNOTIFY_VOID(model_lock_acquire_2) +#define __itt_model_lock_acquire_2_ptr ITTNOTIFY_NAME(model_lock_acquire_2) +#define __itt_model_lock_release ITTNOTIFY_VOID(model_lock_release) +#define __itt_model_lock_release_ptr ITTNOTIFY_NAME(model_lock_release) +#define __itt_model_lock_release_2 ITTNOTIFY_VOID(model_lock_release_2) +#define __itt_model_lock_release_2_ptr ITTNOTIFY_NAME(model_lock_release_2) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_lock_acquire(lock) +#define __itt_model_lock_acquire_ptr 0 +#define __itt_model_lock_acquire_2(lock) +#define __itt_model_lock_acquire_2_ptr 0 +#define __itt_model_lock_release(lock) +#define __itt_model_lock_release_ptr 0 +#define __itt_model_lock_release_2(lock) +#define __itt_model_lock_release_2_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_lock_acquire_ptr 0 +#define __itt_model_lock_acquire_2_ptr 0 +#define __itt_model_lock_release_ptr 0 +#define __itt_model_lock_release_2_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_RECORD_ALLOCATION/ANNOTATE_RECORD_DEALLOCATION support + * + * record_allocation/deallocation describe user-defined memory allocator + * behavior, which may be required for correctness modeling to understand + * when storage is not expected to be actually reused across threads. + */ +void ITTAPI __itt_model_record_allocation (void *addr, size_t size); +void ITTAPI __itt_model_record_deallocation(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size)) +ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr)) +#define __itt_model_record_allocation ITTNOTIFY_VOID(model_record_allocation) +#define __itt_model_record_allocation_ptr ITTNOTIFY_NAME(model_record_allocation) +#define __itt_model_record_deallocation ITTNOTIFY_VOID(model_record_deallocation) +#define __itt_model_record_deallocation_ptr ITTNOTIFY_NAME(model_record_deallocation) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_record_allocation(addr, size) +#define __itt_model_record_allocation_ptr 0 +#define __itt_model_record_deallocation(addr) +#define __itt_model_record_deallocation_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_record_allocation_ptr 0 +#define __itt_model_record_deallocation_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_INDUCTION_USES support + * + * Note particular storage is inductive through the end of the current site + */ +void ITTAPI __itt_model_induction_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_induction_uses, (void *addr, size_t size)) +#define __itt_model_induction_uses ITTNOTIFY_VOID(model_induction_uses) +#define __itt_model_induction_uses_ptr ITTNOTIFY_NAME(model_induction_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_induction_uses(addr, size) +#define __itt_model_induction_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_induction_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_REDUCTION_USES support + * + * Note particular storage is used for reduction through the end + * of the current site + */ +void ITTAPI __itt_model_reduction_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_reduction_uses, (void *addr, size_t size)) +#define __itt_model_reduction_uses ITTNOTIFY_VOID(model_reduction_uses) +#define __itt_model_reduction_uses_ptr ITTNOTIFY_NAME(model_reduction_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_reduction_uses(addr, size) +#define __itt_model_reduction_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_reduction_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_OBSERVE_USES support + * + * Have correctness modeling record observations about uses of storage + * through the end of the current site + */ +void ITTAPI __itt_model_observe_uses(void* addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_observe_uses, (void *addr, size_t size)) +#define __itt_model_observe_uses ITTNOTIFY_VOID(model_observe_uses) +#define __itt_model_observe_uses_ptr ITTNOTIFY_NAME(model_observe_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_observe_uses(addr, size) +#define __itt_model_observe_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_observe_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_CLEAR_USES support + * + * Clear the special handling of a piece of storage related to induction, + * reduction or observe_uses + */ +void ITTAPI __itt_model_clear_uses(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_clear_uses, (void *addr)) +#define __itt_model_clear_uses ITTNOTIFY_VOID(model_clear_uses) +#define __itt_model_clear_uses_ptr ITTNOTIFY_NAME(model_clear_uses) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_clear_uses(addr) +#define __itt_model_clear_uses_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_clear_uses_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief ANNOTATE_DISABLE_*_PUSH/ANNOTATE_DISABLE_*_POP support + * + * disable_push/disable_pop push and pop disabling based on a parameter. + * Disabling observations stops processing of memory references during + * correctness modeling, and all annotations that occur in the disabled + * region. This allows description of code that is expected to be handled + * specially during conversion to parallelism or that is not recognized + * by tools (e.g. some kinds of synchronization operations.) + * This mechanism causes all annotations in the disabled region, other + * than disable_push and disable_pop, to be ignored. (For example, this + * might validly be used to disable an entire parallel site and the contained + * tasks and locking in it for data collection purposes.) + * The disable for collection is a more expensive operation, but reduces + * collector overhead significantly. This applies to BOTH correctness data + * collection and performance data collection. For example, a site + * containing a task might only enable data collection for the first 10 + * iterations. Both performance and correctness data should reflect this, + * and the program should run as close to full speed as possible when + * collection is disabled. + */ +void ITTAPI __itt_model_disable_push(__itt_model_disable x); +void ITTAPI __itt_model_disable_pop(void); +void ITTAPI __itt_model_aggregate_task(size_t x); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x)) +ITT_STUBV(ITTAPI, void, model_disable_pop, (void)) +ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t x)) +#define __itt_model_disable_push ITTNOTIFY_VOID(model_disable_push) +#define __itt_model_disable_push_ptr ITTNOTIFY_NAME(model_disable_push) +#define __itt_model_disable_pop ITTNOTIFY_VOID(model_disable_pop) +#define __itt_model_disable_pop_ptr ITTNOTIFY_NAME(model_disable_pop) +#define __itt_model_aggregate_task ITTNOTIFY_VOID(model_aggregate_task) +#define __itt_model_aggregate_task_ptr ITTNOTIFY_NAME(model_aggregate_task) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_model_disable_push(x) +#define __itt_model_disable_push_ptr 0 +#define __itt_model_disable_pop() +#define __itt_model_disable_pop_ptr 0 +#define __itt_model_aggregate_task(x) +#define __itt_model_aggregate_task_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_model_disable_push_ptr 0 +#define __itt_model_disable_pop_ptr 0 +#define __itt_model_aggregate_task_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} model group */ + +/** + * @defgroup heap Heap + * @ingroup public + * Heap group + * @{ + */ + +typedef void* __itt_heap_function; + +/** + * @brief Create an identification for heap function + * @return non-zero identifier or NULL + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_heap_function ITTAPI __itt_heap_function_createA(const char* name, const char* domain); +__itt_heap_function ITTAPI __itt_heap_function_createW(const wchar_t* name, const wchar_t* domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_heap_function_create __itt_heap_function_createW +# define __itt_heap_function_create_ptr __itt_heap_function_createW_ptr +#else +# define __itt_heap_function_create __itt_heap_function_createA +# define __itt_heap_function_create_ptr __itt_heap_function_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_heap_function ITTAPI __itt_heap_function_create(const char* name, const char* domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char* name, const char* domain)) +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t* name, const wchar_t* domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char* name, const char* domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA ITTNOTIFY_DATA(heap_function_createA) +#define __itt_heap_function_createA_ptr ITTNOTIFY_NAME(heap_function_createA) +#define __itt_heap_function_createW ITTNOTIFY_DATA(heap_function_createW) +#define __itt_heap_function_createW_ptr ITTNOTIFY_NAME(heap_function_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create ITTNOTIFY_DATA(heap_function_create) +#define __itt_heap_function_create_ptr ITTNOTIFY_NAME(heap_function_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_createA_ptr 0 +#define __itt_heap_function_createW(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create(name, domain) (__itt_heap_function)0 +#define __itt_heap_function_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_heap_function_createA_ptr 0 +#define __itt_heap_function_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_heap_function_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an allocation begin occurrence. + */ +void ITTAPI __itt_heap_allocate_begin(__itt_heap_function h, size_t size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized)) +#define __itt_heap_allocate_begin ITTNOTIFY_VOID(heap_allocate_begin) +#define __itt_heap_allocate_begin_ptr ITTNOTIFY_NAME(heap_allocate_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_allocate_begin(h, size, initialized) +#define __itt_heap_allocate_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_allocate_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an allocation end occurrence. + */ +void ITTAPI __itt_heap_allocate_end(__itt_heap_function h, void** addr, size_t size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized)) +#define __itt_heap_allocate_end ITTNOTIFY_VOID(heap_allocate_end) +#define __itt_heap_allocate_end_ptr ITTNOTIFY_NAME(heap_allocate_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_allocate_end(h, addr, size, initialized) +#define __itt_heap_allocate_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_allocate_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an free begin occurrence. + */ +void ITTAPI __itt_heap_free_begin(__itt_heap_function h, void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr)) +#define __itt_heap_free_begin ITTNOTIFY_VOID(heap_free_begin) +#define __itt_heap_free_begin_ptr ITTNOTIFY_NAME(heap_free_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_free_begin(h, addr) +#define __itt_heap_free_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_free_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an free end occurrence. + */ +void ITTAPI __itt_heap_free_end(__itt_heap_function h, void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr)) +#define __itt_heap_free_end ITTNOTIFY_VOID(heap_free_end) +#define __itt_heap_free_end_ptr ITTNOTIFY_NAME(heap_free_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_free_end(h, addr) +#define __itt_heap_free_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_free_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an reallocation begin occurrence. + */ +void ITTAPI __itt_heap_reallocate_begin(__itt_heap_function h, void* addr, size_t new_size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized)) +#define __itt_heap_reallocate_begin ITTNOTIFY_VOID(heap_reallocate_begin) +#define __itt_heap_reallocate_begin_ptr ITTNOTIFY_NAME(heap_reallocate_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reallocate_begin(h, addr, new_size, initialized) +#define __itt_heap_reallocate_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reallocate_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an reallocation end occurrence. + */ +void ITTAPI __itt_heap_reallocate_end(__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized)) +#define __itt_heap_reallocate_end ITTNOTIFY_VOID(heap_reallocate_end) +#define __itt_heap_reallocate_end_ptr ITTNOTIFY_NAME(heap_reallocate_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reallocate_end(h, addr, new_addr, new_size, initialized) +#define __itt_heap_reallocate_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reallocate_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief internal access begin */ +void ITTAPI __itt_heap_internal_access_begin(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void)) +#define __itt_heap_internal_access_begin ITTNOTIFY_VOID(heap_internal_access_begin) +#define __itt_heap_internal_access_begin_ptr ITTNOTIFY_NAME(heap_internal_access_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_internal_access_begin() +#define __itt_heap_internal_access_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_internal_access_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief internal access end */ +void ITTAPI __itt_heap_internal_access_end(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void)) +#define __itt_heap_internal_access_end ITTNOTIFY_VOID(heap_internal_access_end) +#define __itt_heap_internal_access_end_ptr ITTNOTIFY_NAME(heap_internal_access_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_internal_access_end() +#define __itt_heap_internal_access_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_internal_access_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief record memory growth begin */ +void ITTAPI __itt_heap_record_memory_growth_begin(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void)) +#define __itt_heap_record_memory_growth_begin ITTNOTIFY_VOID(heap_record_memory_growth_begin) +#define __itt_heap_record_memory_growth_begin_ptr ITTNOTIFY_NAME(heap_record_memory_growth_begin) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record_memory_growth_begin() +#define __itt_heap_record_memory_growth_begin_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_memory_growth_begin_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief record memory growth end */ +void ITTAPI __itt_heap_record_memory_growth_end(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void)) +#define __itt_heap_record_memory_growth_end ITTNOTIFY_VOID(heap_record_memory_growth_end) +#define __itt_heap_record_memory_growth_end_ptr ITTNOTIFY_NAME(heap_record_memory_growth_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record_memory_growth_end() +#define __itt_heap_record_memory_growth_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_memory_growth_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Specify the type of heap detection/reporting to modify. + */ +/** + * @hideinitializer + * @brief Report on memory leaks. + */ +#define __itt_heap_leaks 0x00000001 + +/** + * @hideinitializer + * @brief Report on memory growth. + */ +#define __itt_heap_growth 0x00000002 + + +/** @brief heap reset detection */ +void ITTAPI __itt_heap_reset_detection(unsigned int reset_mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask)) +#define __itt_heap_reset_detection ITTNOTIFY_VOID(heap_reset_detection) +#define __itt_heap_reset_detection_ptr ITTNOTIFY_NAME(heap_reset_detection) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_reset_detection() +#define __itt_heap_reset_detection_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_reset_detection_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief report */ +void ITTAPI __itt_heap_record(unsigned int record_mask); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask)) +#define __itt_heap_record ITTNOTIFY_VOID(heap_record) +#define __itt_heap_record_ptr ITTNOTIFY_NAME(heap_record) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_heap_record() +#define __itt_heap_record_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_heap_record_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} heap group */ +/** @endcond */ +/* ========================================================================== */ + +/** + * @defgroup domains Domains + * @ingroup public + * Domains group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_domain +{ + volatile int flags; /*!< Zero if disabled, non-zero if enabled. The meaning of different non-zero values is reserved to the runtime */ + const char* nameA; /*!< Copy of original name in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* nameW; +#endif /* UNICODE || _UNICODE */ + int extra1; /*!< Reserved to the runtime */ + void* extra2; /*!< Reserved to the runtime */ + struct ___itt_domain* next; +} __itt_domain; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup domains + * @brief Create a domain. + * Create domain using some domain name: the URI naming style is recommended. + * Because the set of domains is expected to be static over the application's + * execution time, there is no mechanism to destroy a domain. + * Any domain can be accessed by any thread in the process, regardless of + * which thread created the domain. This call is thread-safe. + * @param[in] name name of domain + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_domain* ITTAPI __itt_domain_createA(const char *name); +__itt_domain* ITTAPI __itt_domain_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_domain_create __itt_domain_createW +# define __itt_domain_create_ptr __itt_domain_createW_ptr +#else /* UNICODE */ +# define __itt_domain_create __itt_domain_createA +# define __itt_domain_create_ptr __itt_domain_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_domain* ITTAPI __itt_domain_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA ITTNOTIFY_DATA(domain_createA) +#define __itt_domain_createA_ptr ITTNOTIFY_NAME(domain_createA) +#define __itt_domain_createW ITTNOTIFY_DATA(domain_createW) +#define __itt_domain_createW_ptr ITTNOTIFY_NAME(domain_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create ITTNOTIFY_DATA(domain_create) +#define __itt_domain_create_ptr ITTNOTIFY_NAME(domain_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA(name) (__itt_domain*)0 +#define __itt_domain_createA_ptr 0 +#define __itt_domain_createW(name) (__itt_domain*)0 +#define __itt_domain_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create(name) (__itt_domain*)0 +#define __itt_domain_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_domain_createA_ptr 0 +#define __itt_domain_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_domain_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} domains group */ + +/** + * @defgroup ids IDs + * @ingroup public + * IDs group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_id +{ + unsigned long long d1, d2, d3; +} __itt_id; + +#pragma pack(pop) +/** @endcond */ + +static const __itt_id __itt_null = { 0, 0, 0 }; + +/** + * @ingroup ids + * @brief A convenience function is provided to create an ID without domain control. + * @brief This is a convenience function to initialize an __itt_id structure. This function + * does not affect the collector runtime in any way. After you make the ID with this + * function, you still must create it with the __itt_id_create function before using the ID + * to identify a named entity. + * @param[in] addr The address of object; high QWORD of the ID value. + * @param[in] extra The extra data to unique identify object; low QWORD of the ID value. + */ + +ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) ITT_INLINE_ATTRIBUTE; +ITT_INLINE __itt_id ITTAPI __itt_id_make(void* addr, unsigned long long extra) +{ + __itt_id id = __itt_null; + id.d1 = (unsigned long long)((uintptr_t)addr); + id.d2 = (unsigned long long)extra; + id.d3 = (unsigned long long)0; /* Reserved. Must be zero */ + return id; +} + +/** + * @ingroup ids + * @brief Create an instance of identifier. + * This establishes the beginning of the lifetime of an instance of + * the given ID in the trace. Once this lifetime starts, the ID + * can be used to tag named entity instances in calls such as + * __itt_task_begin, and to specify relationships among + * identified named entity instances, using the \ref relations APIs. + * Instance IDs are not domain specific! + * @param[in] domain The domain controlling the execution of this call. + * @param[in] id The ID to create. + */ +void ITTAPI __itt_id_create(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id)) +#define __itt_id_create(d,x) ITTNOTIFY_VOID_D1(id_create,d,x) +#define __itt_id_create_ptr ITTNOTIFY_NAME(id_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_create(domain,id) +#define __itt_id_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup ids + * @brief Destroy an instance of identifier. + * This ends the lifetime of the current instance of the given ID value in the trace. + * Any relationships that are established after this lifetime ends are invalid. + * This call must be performed before the given ID value can be reused for a different + * named entity instance. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] id The ID to destroy. + */ +void ITTAPI __itt_id_destroy(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id)) +#define __itt_id_destroy(d,x) ITTNOTIFY_VOID_D1(id_destroy,d,x) +#define __itt_id_destroy_ptr ITTNOTIFY_NAME(id_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_destroy(domain,id) +#define __itt_id_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} ids group */ + +/** + * @defgroup handless String Handles + * @ingroup public + * String Handles group + * @{ + */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_string_handle +{ + const char* strA; /*!< Copy of original string in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* strW; /*!< Copy of original string in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* strW; +#endif /* UNICODE || _UNICODE */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_string_handle* next; +} __itt_string_handle; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup handles + * @brief Create a string handle. + * Create and return handle value that can be associated with a string. + * Consecutive calls to __itt_string_handle_create with the same name + * return the same value. Because the set of string handles is expected to remain + * static during the application's execution time, there is no mechanism to destroy a string handle. + * Any string handle can be accessed by any thread in the process, regardless of which thread created + * the string handle. This call is thread-safe. + * @param[in] name The input string + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_string_handle* ITTAPI __itt_string_handle_createA(const char *name); +__itt_string_handle* ITTAPI __itt_string_handle_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_string_handle_create __itt_string_handle_createW +# define __itt_string_handle_create_ptr __itt_string_handle_createW_ptr +#else /* UNICODE */ +# define __itt_string_handle_create __itt_string_handle_createA +# define __itt_string_handle_create_ptr __itt_string_handle_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_string_handle* ITTAPI __itt_string_handle_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA ITTNOTIFY_DATA(string_handle_createA) +#define __itt_string_handle_createA_ptr ITTNOTIFY_NAME(string_handle_createA) +#define __itt_string_handle_createW ITTNOTIFY_DATA(string_handle_createW) +#define __itt_string_handle_createW_ptr ITTNOTIFY_NAME(string_handle_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create ITTNOTIFY_DATA(string_handle_create) +#define __itt_string_handle_create_ptr ITTNOTIFY_NAME(string_handle_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA(name) (__itt_string_handle*)0 +#define __itt_string_handle_createA_ptr 0 +#define __itt_string_handle_createW(name) (__itt_string_handle*)0 +#define __itt_string_handle_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create(name) (__itt_string_handle*)0 +#define __itt_string_handle_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_string_handle_createA_ptr 0 +#define __itt_string_handle_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_string_handle_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} handles group */ + +/** @cond exclude_from_documentation */ +typedef unsigned long long __itt_timestamp; +/** @endcond */ + +#define __itt_timestamp_none ((__itt_timestamp)-1LL) + +/** @cond exclude_from_gpa_documentation */ + +/** + * @ingroup timestamps + * @brief Return timestamp corresponding to the current moment. + * This returns the timestamp in the format that is the most relevant for the current + * host or platform (RDTSC, QPC, and others). You can use the "<" operator to + * compare __itt_timestamp values. + */ +__itt_timestamp ITTAPI __itt_get_timestamp(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void)) +#define __itt_get_timestamp ITTNOTIFY_DATA(get_timestamp) +#define __itt_get_timestamp_ptr ITTNOTIFY_NAME(get_timestamp) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_get_timestamp() +#define __itt_get_timestamp_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_get_timestamp_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} timestamps */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** + * @defgroup regions Regions + * @ingroup public + * Regions group + * @{ + */ +/** + * @ingroup regions + * @brief Begin of region instance. + * Successive calls to __itt_region_begin with the same ID are ignored + * until a call to __itt_region_end with the same ID + * @param[in] domain The domain for this region instance + * @param[in] id The instance ID for this region instance. Must not be __itt_null + * @param[in] parentid The instance ID for the parent of this region instance, or __itt_null + * @param[in] name The name of this region + */ +void ITTAPI __itt_region_begin(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); + +/** + * @ingroup regions + * @brief End of region instance. + * The first call to __itt_region_end with a given ID ends the + * region. Successive calls with the same ID are ignored, as are + * calls that do not have a matching __itt_region_begin call. + * @param[in] domain The domain for this region instance + * @param[in] id The instance ID for this region instance + */ +void ITTAPI __itt_region_end(const __itt_domain *domain, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id)) +#define __itt_region_begin(d,x,y,z) ITTNOTIFY_VOID_D3(region_begin,d,x,y,z) +#define __itt_region_begin_ptr ITTNOTIFY_NAME(region_begin) +#define __itt_region_end(d,x) ITTNOTIFY_VOID_D1(region_end,d,x) +#define __itt_region_end_ptr ITTNOTIFY_NAME(region_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_region_begin(d,x,y,z) +#define __itt_region_begin_ptr 0 +#define __itt_region_end(d,x) +#define __itt_region_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_region_begin_ptr 0 +#define __itt_region_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} regions group */ + +/** + * @defgroup frames Frames + * @ingroup public + * Frames are similar to regions, but are intended to be easier to use and to implement. + * In particular: + * - Frames always represent periods of elapsed time + * - By default, frames have no nesting relationships + * @{ + */ + +/** + * @ingroup frames + * @brief Begin a frame instance. + * Successive calls to __itt_frame_begin with the + * same ID are ignored until a call to __itt_frame_end with the same ID. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL + */ +void ITTAPI __itt_frame_begin_v3(const __itt_domain *domain, __itt_id *id); + +/** + * @ingroup frames + * @brief End a frame instance. + * The first call to __itt_frame_end with a given ID + * ends the frame. Successive calls with the same ID are ignored, as are + * calls that do not have a matching __itt_frame_begin call. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL for current + */ +void ITTAPI __itt_frame_end_v3(const __itt_domain *domain, __itt_id *id); + +/** + * @ingroup frames + * @brief Submits a frame instance. + * Successive calls to __itt_frame_begin or __itt_frame_submit with the + * same ID are ignored until a call to __itt_frame_end or __itt_frame_submit + * with the same ID. + * Passing special __itt_timestamp_none value as "end" argument means + * take the current timestamp as the end timestamp. + * @param[in] domain The domain for this frame instance + * @param[in] id The instance ID for this frame instance or NULL + * @param[in] begin Timestamp of the beginning of the frame + * @param[in] end Timestamp of the end of the frame + */ +void ITTAPI __itt_frame_submit_v3(const __itt_domain *domain, __itt_id *id, + __itt_timestamp begin, __itt_timestamp end); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id)) +ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id)) +ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end)) +#define __itt_frame_begin_v3(d,x) ITTNOTIFY_VOID_D1(frame_begin_v3,d,x) +#define __itt_frame_begin_v3_ptr ITTNOTIFY_NAME(frame_begin_v3) +#define __itt_frame_end_v3(d,x) ITTNOTIFY_VOID_D1(frame_end_v3,d,x) +#define __itt_frame_end_v3_ptr ITTNOTIFY_NAME(frame_end_v3) +#define __itt_frame_submit_v3(d,x,b,e) ITTNOTIFY_VOID_D3(frame_submit_v3,d,x,b,e) +#define __itt_frame_submit_v3_ptr ITTNOTIFY_NAME(frame_submit_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_frame_begin_v3(domain,id) +#define __itt_frame_begin_v3_ptr 0 +#define __itt_frame_end_v3(domain,id) +#define __itt_frame_end_v3_ptr 0 +#define __itt_frame_submit_v3(domain,id,begin,end) +#define __itt_frame_submit_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_frame_begin_v3_ptr 0 +#define __itt_frame_end_v3_ptr 0 +#define __itt_frame_submit_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} frames group */ +/** @endcond */ + +/** + * @defgroup taskgroup Task Group + * @ingroup public + * Task Group + * @{ + */ +/** + * @ingroup task_groups + * @brief Denotes a task_group instance. + * Successive calls to __itt_task_group with the same ID are ignored. + * @param[in] domain The domain for this task_group instance + * @param[in] id The instance ID for this task_group instance. Must not be __itt_null. + * @param[in] parentid The instance ID for the parent of this task_group instance, or __itt_null. + * @param[in] name The name of this task_group + */ +void ITTAPI __itt_task_group(const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +#define __itt_task_group(d,x,y,z) ITTNOTIFY_VOID_D3(task_group,d,x,y,z) +#define __itt_task_group_ptr ITTNOTIFY_NAME(task_group) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_group(d,x,y,z) +#define __itt_task_group_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_group_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} taskgroup group */ + +/** + * @defgroup tasks Tasks + * @ingroup public + * A task instance represents a piece of work performed by a particular + * thread for a period of time. A call to __itt_task_begin creates a + * task instance. This becomes the current instance for that task on that + * thread. A following call to __itt_task_end on the same thread ends the + * instance. There may be multiple simultaneous instances of tasks with the + * same name on different threads. If an ID is specified, the task instance + * receives that ID. Nested tasks are allowed. + * + * Note: The task is defined by the bracketing of __itt_task_begin and + * __itt_task_end on the same thread. If some scheduling mechanism causes + * task switching (the thread executes a different user task) or task + * switching (the user task switches to a different thread) then this breaks + * the notion of current instance. Additional API calls are required to + * deal with that possibility. + * @{ + */ + +/** + * @ingroup tasks + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] taskid The instance ID for this task instance, or __itt_null + * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null + * @param[in] name The name of this task + */ +void ITTAPI __itt_task_begin(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name); + +/** + * @ingroup tasks + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] taskid The identifier for this task instance (may be 0) + * @param[in] parentid The parent of this task (may be 0) + * @param[in] fn The pointer to the function you are tracing + */ +void ITTAPI __itt_task_begin_fn(const __itt_domain *domain, __itt_id taskid, __itt_id parentid, void* fn); + +/** + * @ingroup tasks + * @brief End the current task instance. + * @param[in] domain The domain for this task + */ +void ITTAPI __itt_task_end(const __itt_domain *domain); + +/** + * @ingroup tasks + * @brief Begin an overlapped task instance. + * @param[in] domain The domain for this task. + * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. + * @param[in] parentid The parent of this task, or __itt_null. + * @param[in] name The name of this task. + */ +void ITTAPI __itt_task_begin_overlapped(const __itt_domain* domain, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup tasks + * @brief End an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] taskid Explicit ID of finished task + */ +void ITTAPI __itt_task_end_overlapped(const __itt_domain *domain, __itt_id taskid); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parentid, void* fn)) +ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain)) +ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id taskid, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id taskid)) +#define __itt_task_begin(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin,d,x,y,z) +#define __itt_task_begin_ptr ITTNOTIFY_NAME(task_begin) +#define __itt_task_begin_fn(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_fn,d,x,y,z) +#define __itt_task_begin_fn_ptr ITTNOTIFY_NAME(task_begin_fn) +#define __itt_task_end(d) ITTNOTIFY_VOID_D0(task_end,d) +#define __itt_task_end_ptr ITTNOTIFY_NAME(task_end) +#define __itt_task_begin_overlapped(d,x,y,z) ITTNOTIFY_VOID_D3(task_begin_overlapped,d,x,y,z) +#define __itt_task_begin_overlapped_ptr ITTNOTIFY_NAME(task_begin_overlapped) +#define __itt_task_end_overlapped(d,x) ITTNOTIFY_VOID_D1(task_end_overlapped,d,x) +#define __itt_task_end_overlapped_ptr ITTNOTIFY_NAME(task_end_overlapped) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin(domain,id,parentid,name) +#define __itt_task_begin_ptr 0 +#define __itt_task_begin_fn(domain,id,parentid,fn) +#define __itt_task_begin_fn_ptr 0 +#define __itt_task_end(domain) +#define __itt_task_end_ptr 0 +#define __itt_task_begin_overlapped(domain,taskid,parentid,name) +#define __itt_task_begin_overlapped_ptr 0 +#define __itt_task_end_overlapped(domain,taskid) +#define __itt_task_end_overlapped_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_ptr 0 +#define __itt_task_begin_fn_ptr 0 +#define __itt_task_end_ptr 0 +#define __itt_task_begin_overlapped_ptr 0 +#define __itt_task_end_overlapped_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} tasks group */ + + +/** + * @defgroup markers Markers + * Markers represent a single discreet event in time. Markers have a scope, + * described by an enumerated type __itt_scope. Markers are created by + * the API call __itt_marker. A marker instance can be given an ID for use in + * adding metadata. + * @{ + */ + +/** + * @brief Describes the scope of an event object in the trace. + */ +typedef enum +{ + __itt_scope_unknown = 0, + __itt_scope_global, + __itt_scope_track_group, + __itt_scope_track, + __itt_scope_task, + __itt_scope_marker +} __itt_scope; + +/** @cond exclude_from_documentation */ +#define __itt_marker_scope_unknown __itt_scope_unknown +#define __itt_marker_scope_global __itt_scope_global +#define __itt_marker_scope_process __itt_scope_track_group +#define __itt_marker_scope_thread __itt_scope_track +#define __itt_marker_scope_task __itt_scope_task +/** @endcond */ + +/** + * @ingroup markers + * @brief Create a marker instance + * @param[in] domain The domain for this marker + * @param[in] id The instance ID for this marker or __itt_null + * @param[in] name The name for this marker + * @param[in] scope The scope for this marker + */ +void ITTAPI __itt_marker(const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope)) +#define __itt_marker(d,x,y,z) ITTNOTIFY_VOID_D3(marker,d,x,y,z) +#define __itt_marker_ptr ITTNOTIFY_NAME(marker) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_marker(domain,id,name,scope) +#define __itt_marker_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_marker_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} markers group */ + +/** + * @defgroup metadata Metadata + * The metadata API is used to attach extra information to named + * entities. Metadata can be attached to an identified named entity by ID, + * or to the current entity (which is always a task). + * + * Conceptually metadata has a type (what kind of metadata), a key (the + * name of the metadata), and a value (the actual data). The encoding of + * the value depends on the type of the metadata. + * + * The type of metadata is specified by an enumerated type __itt_metdata_type. + * @{ + */ + +/** + * @ingroup parameters + * @brief describes the type of metadata + */ +typedef enum { + __itt_metadata_unknown = 0, + __itt_metadata_u64, /**< Unsigned 64-bit integer */ + __itt_metadata_s64, /**< Signed 64-bit integer */ + __itt_metadata_u32, /**< Unsigned 32-bit integer */ + __itt_metadata_s32, /**< Signed 32-bit integer */ + __itt_metadata_u16, /**< Unsigned 16-bit integer */ + __itt_metadata_s16, /**< Signed 16-bit integer */ + __itt_metadata_float, /**< Signed 32-bit floating-point */ + __itt_metadata_double /**< SIgned 64-bit floating-point */ +} __itt_metadata_type; + +/** + * @ingroup parameters + * @brief Add metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + * @param[in] key The name of the metadata + * @param[in] type The type of the metadata + * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. + * @param[in] data The metadata itself +*/ +void ITTAPI __itt_metadata_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) +#define __itt_metadata_add(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add,d,x,y,z,a,b) +#define __itt_metadata_add_ptr ITTNOTIFY_NAME(metadata_add) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_metadata_add(d,x,y,z,a,b) +#define __itt_metadata_add_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_metadata_add_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add string metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + * @param[in] key The name of the metadata + * @param[in] data The metadata itself + * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_metadata_str_addA(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); +void ITTAPI __itt_metadata_str_addW(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_metadata_str_add __itt_metadata_str_addW +# define __itt_metadata_str_add_ptr __itt_metadata_str_addW_ptr +#else /* UNICODE */ +# define __itt_metadata_str_add __itt_metadata_str_addA +# define __itt_metadata_str_add_ptr __itt_metadata_str_addA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_metadata_str_add(const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length); +#endif + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) +ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t *data, size_t length)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char *data, size_t length)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addA,d,x,y,z,a) +#define __itt_metadata_str_addA_ptr ITTNOTIFY_NAME(metadata_str_addA) +#define __itt_metadata_str_addW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_addW,d,x,y,z,a) +#define __itt_metadata_str_addW_ptr ITTNOTIFY_NAME(metadata_str_addW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add,d,x,y,z,a) +#define __itt_metadata_str_add_ptr ITTNOTIFY_NAME(metadata_str_add) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA(d,x,y,z,a) +#define __itt_metadata_str_addA_ptr 0 +#define __itt_metadata_str_addW(d,x,y,z,a) +#define __itt_metadata_str_addW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add(d,x,y,z,a) +#define __itt_metadata_str_add_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_addA_ptr 0 +#define __itt_metadata_str_addW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] scope The scope of the instance to which the metadata is to be added + + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + + * @param[in] key The name of the metadata + * @param[in] type The type of the metadata + * @param[in] count The number of elements of the given type. If count == 0, no metadata will be added. + * @param[in] data The metadata itself +*/ +void ITTAPI __itt_metadata_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data)) +#define __itt_metadata_add_with_scope(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(metadata_add_with_scope,d,x,y,z,a,b) +#define __itt_metadata_add_with_scope_ptr ITTNOTIFY_NAME(metadata_add_with_scope) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_metadata_add_with_scope(d,x,y,z,a,b) +#define __itt_metadata_add_with_scope_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_metadata_add_with_scope_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup parameters + * @brief Add string metadata to an instance of a named entity. + * @param[in] domain The domain controlling the call + * @param[in] scope The scope of the instance to which the metadata is to be added + + * @param[in] id The identifier of the instance to which the metadata is to be added, or __itt_null to add to the current task + + * @param[in] key The name of the metadata + * @param[in] data The metadata itself + * @param[in] length The number of characters in the string, or -1 if the length is unknown but the string is null-terminated +*/ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_metadata_str_add_with_scopeA(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); +void ITTAPI __itt_metadata_str_add_with_scopeW(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeW +# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeW_ptr +#else /* UNICODE */ +# define __itt_metadata_str_add_with_scope __itt_metadata_str_add_with_scopeA +# define __itt_metadata_str_add_with_scope_ptr __itt_metadata_str_add_with_scopeA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_metadata_str_add_with_scope(const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length); +#endif + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeA,d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeA_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeA) +#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scopeW,d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeW_ptr ITTNOTIFY_NAME(metadata_str_add_with_scopeW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope(d,x,y,z,a) ITTNOTIFY_VOID_D4(metadata_str_add_with_scope,d,x,y,z,a) +#define __itt_metadata_str_add_with_scope_ptr ITTNOTIFY_NAME(metadata_str_add_with_scope) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA(d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeA_ptr 0 +#define __itt_metadata_str_add_with_scopeW(d,x,y,z,a) +#define __itt_metadata_str_add_with_scopeW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope(d,x,y,z,a) +#define __itt_metadata_str_add_with_scope_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_metadata_str_add_with_scopeA_ptr 0 +#define __itt_metadata_str_add_with_scopeW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_metadata_str_add_with_scope_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} metadata group */ + +/** + * @defgroup relations Relations + * Instances of named entities can be explicitly associated with other + * instances using instance IDs and the relationship API calls. + * + * @{ + */ + +/** + * @ingroup relations + * @brief The kind of relation between two instances is specified by the enumerated type __itt_relation. + * Relations between instances can be added with an API call. The relation + * API uses instance IDs. Relations can be added before or after the actual + * instances are created and persist independently of the instances. This + * is the motivation for having different lifetimes for instance IDs and + * the actual instances. + */ +typedef enum +{ + __itt_relation_is_unknown = 0, + __itt_relation_is_dependent_on, /**< "A is dependent on B" means that A cannot start until B completes */ + __itt_relation_is_sibling_of, /**< "A is sibling of B" means that A and B were created as a group */ + __itt_relation_is_parent_of, /**< "A is parent of B" means that A created B */ + __itt_relation_is_continuation_of, /**< "A is continuation of B" means that A assumes the dependencies of B */ + __itt_relation_is_child_of, /**< "A is child of B" means that A was created by B (inverse of is_parent_of) */ + __itt_relation_is_continued_by, /**< "A is continued by B" means that B assumes the dependencies of A (inverse of is_continuation_of) */ + __itt_relation_is_predecessor_to /**< "A is predecessor to B" means that B cannot start until A completes (inverse of is_dependent_on) */ +} __itt_relation; + +/** + * @ingroup relations + * @brief Add a relation to the current task instance. + * The current task instance is the head of the relation. + * @param[in] domain The domain controlling this call + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_to_current(const __itt_domain *domain, __itt_relation relation, __itt_id tail); + +/** + * @ingroup relations + * @brief Add a relation between two instance identifiers. + * @param[in] domain The domain controlling this call + * @param[in] head The ID for the head of the relation + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add(const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail)) +ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail)) +#define __itt_relation_add_to_current(d,x,y) ITTNOTIFY_VOID_D2(relation_add_to_current,d,x,y) +#define __itt_relation_add_to_current_ptr ITTNOTIFY_NAME(relation_add_to_current) +#define __itt_relation_add(d,x,y,z) ITTNOTIFY_VOID_D3(relation_add,d,x,y,z) +#define __itt_relation_add_ptr ITTNOTIFY_NAME(relation_add) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_relation_add_to_current(d,x,y) +#define __itt_relation_add_to_current_ptr 0 +#define __itt_relation_add(d,x,y,z) +#define __itt_relation_add_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_relation_add_to_current_ptr 0 +#define __itt_relation_add_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} relations group */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_clock_info +{ + unsigned long long clock_freq; /*!< Clock domain frequency */ + unsigned long long clock_base; /*!< Clock domain base timestamp */ +} __itt_clock_info; + +#pragma pack(pop) +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef void (ITTAPI *__itt_get_clock_info_fn)(__itt_clock_info* clock_info, void* data); +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_clock_domain +{ + __itt_clock_info info; /*!< Most recent clock domain info */ + __itt_get_clock_info_fn fn; /*!< Callback function pointer */ + void* fn_data; /*!< Input argument for the callback function */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_clock_domain* next; +} __itt_clock_domain; + +#pragma pack(pop) +/** @endcond */ + +/** + * @ingroup clockdomains + * @brief Create a clock domain. + * Certain applications require the capability to trace their application using + * a clock domain different than the CPU, for instance the instrumentation of events + * that occur on a GPU. + * Because the set of domains is expected to be static over the application's execution time, + * there is no mechanism to destroy a domain. + * Any domain can be accessed by any thread in the process, regardless of which thread created + * the domain. This call is thread-safe. + * @param[in] fn A pointer to a callback function which retrieves alternative CPU timestamps + * @param[in] fn_data Argument for a callback function; may be NULL + */ +__itt_clock_domain* ITTAPI __itt_clock_domain_create(__itt_get_clock_info_fn fn, void* fn_data); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data)) +#define __itt_clock_domain_create ITTNOTIFY_DATA(clock_domain_create) +#define __itt_clock_domain_create_ptr ITTNOTIFY_NAME(clock_domain_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_clock_domain_create(fn,fn_data) (__itt_clock_domain*)0 +#define __itt_clock_domain_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_clock_domain_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomains + * @brief Recalculate clock domains frequences and clock base timestamps. + */ +void ITTAPI __itt_clock_domain_reset(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, clock_domain_reset, (void)) +#define __itt_clock_domain_reset ITTNOTIFY_VOID(clock_domain_reset) +#define __itt_clock_domain_reset_ptr ITTNOTIFY_NAME(clock_domain_reset) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_clock_domain_reset() +#define __itt_clock_domain_reset_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_clock_domain_reset_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Create an instance of identifier. This establishes the beginning of the lifetime of + * an instance of the given ID in the trace. Once this lifetime starts, the ID can be used to + * tag named entity instances in calls such as __itt_task_begin, and to specify relationships among + * identified named entity instances, using the \ref relations APIs. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The ID to create. + */ +void ITTAPI __itt_id_create_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); + +/** + * @ingroup clockdomain + * @brief Destroy an instance of identifier. This ends the lifetime of the current instance of the + * given ID value in the trace. Any relationships that are established after this lifetime ends are + * invalid. This call must be performed before the given ID value can be reused for a different + * named entity instance. + * @param[in] domain The domain controlling the execution of this call. + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The ID to destroy. + */ +void ITTAPI __itt_id_destroy_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) +ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id)) +#define __itt_id_create_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_create_ex,d,x,y,z) +#define __itt_id_create_ex_ptr ITTNOTIFY_NAME(id_create_ex) +#define __itt_id_destroy_ex(d,x,y,z) ITTNOTIFY_VOID_D3(id_destroy_ex,d,x,y,z) +#define __itt_id_destroy_ex_ptr ITTNOTIFY_NAME(id_destroy_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_id_create_ex(domain,clock_domain,timestamp,id) +#define __itt_id_create_ex_ptr 0 +#define __itt_id_destroy_ex(domain,clock_domain,timestamp,id) +#define __itt_id_destroy_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_id_create_ex_ptr 0 +#define __itt_id_destroy_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The instance ID for this task instance, or __itt_null + * @param[in] parentid The parent instance to which this task instance belongs, or __itt_null + * @param[in] name The name of this task + */ +void ITTAPI __itt_task_begin_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup clockdomain + * @brief Begin a task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The identifier for this task instance, or __itt_null + * @param[in] parentid The parent of this task, or __itt_null + * @param[in] fn The pointer to the function you are tracing + */ +void ITTAPI __itt_task_begin_fn_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, void* fn); + +/** + * @ingroup clockdomain + * @brief End the current task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + */ +void ITTAPI __itt_task_end_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn)) +ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp)) +#define __itt_task_begin_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_ex,d,x,y,z,a,b) +#define __itt_task_begin_ex_ptr ITTNOTIFY_NAME(task_begin_ex) +#define __itt_task_begin_fn_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_fn_ex,d,x,y,z,a,b) +#define __itt_task_begin_fn_ex_ptr ITTNOTIFY_NAME(task_begin_fn_ex) +#define __itt_task_end_ex(d,x,y) ITTNOTIFY_VOID_D2(task_end_ex,d,x,y) +#define __itt_task_end_ex_ptr ITTNOTIFY_NAME(task_end_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin_ex(domain,clock_domain,timestamp,id,parentid,name) +#define __itt_task_begin_ex_ptr 0 +#define __itt_task_begin_fn_ex(domain,clock_domain,timestamp,id,parentid,fn) +#define __itt_task_begin_fn_ex_ptr 0 +#define __itt_task_end_ex(domain,clock_domain,timestamp) +#define __itt_task_end_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_ex_ptr 0 +#define __itt_task_begin_fn_ex_ptr 0 +#define __itt_task_end_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @defgroup counters Counters + * @ingroup public + * Counters are user-defined objects with a monotonically increasing + * value. Counter values are 64-bit unsigned integers. + * Counters have names that can be displayed in + * the tools. + * @{ + */ + +/** + * @brief opaque structure for counter identification + */ +/** @cond exclude_from_documentation */ + +typedef struct ___itt_counter* __itt_counter; + +/** + * @brief Create an unsigned 64 bits integer counter with given name/domain + * + * After __itt_counter_create() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), + * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) + * can be used to change the value of the counter, where value_ptr is a pointer to an unsigned 64 bits integer + * + * The call is equal to __itt_counter_create_typed(name, domain, __itt_metadata_u64) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_counter ITTAPI __itt_counter_createA(const char *name, const char *domain); +__itt_counter ITTAPI __itt_counter_createW(const wchar_t *name, const wchar_t *domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_counter_create __itt_counter_createW +# define __itt_counter_create_ptr __itt_counter_createW_ptr +#else /* UNICODE */ +# define __itt_counter_create __itt_counter_createA +# define __itt_counter_create_ptr __itt_counter_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_counter ITTAPI __itt_counter_create(const char *name, const char *domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain)) +ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA ITTNOTIFY_DATA(counter_createA) +#define __itt_counter_createA_ptr ITTNOTIFY_NAME(counter_createA) +#define __itt_counter_createW ITTNOTIFY_DATA(counter_createW) +#define __itt_counter_createW_ptr ITTNOTIFY_NAME(counter_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create ITTNOTIFY_DATA(counter_create) +#define __itt_counter_create_ptr ITTNOTIFY_NAME(counter_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA(name, domain) +#define __itt_counter_createA_ptr 0 +#define __itt_counter_createW(name, domain) +#define __itt_counter_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create(name, domain) +#define __itt_counter_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_createA_ptr 0 +#define __itt_counter_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Increment the unsigned 64 bits integer counter value + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_inc(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id)) +#define __itt_counter_inc ITTNOTIFY_VOID(counter_inc) +#define __itt_counter_inc_ptr ITTNOTIFY_NAME(counter_inc) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc(id) +#define __itt_counter_inc_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** + * @brief Increment the unsigned 64 bits integer counter value with x + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_inc_delta(__itt_counter id, unsigned long long value); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value)) +#define __itt_counter_inc_delta ITTNOTIFY_VOID(counter_inc_delta) +#define __itt_counter_inc_delta_ptr ITTNOTIFY_NAME(counter_inc_delta) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc_delta(id, value) +#define __itt_counter_inc_delta_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_delta_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Decrement the unsigned 64 bits integer counter value + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_dec(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec, (__itt_counter id)) +#define __itt_counter_dec ITTNOTIFY_VOID(counter_dec) +#define __itt_counter_dec_ptr ITTNOTIFY_NAME(counter_dec) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec(id) +#define __itt_counter_dec_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** + * @brief Decrement the unsigned 64 bits integer counter value with x + * + * Calling this function to non-unsigned 64 bits integer counters has no effect + */ +void ITTAPI __itt_counter_dec_delta(__itt_counter id, unsigned long long value); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec_delta, (__itt_counter id, unsigned long long value)) +#define __itt_counter_dec_delta ITTNOTIFY_VOID(counter_dec_delta) +#define __itt_counter_dec_delta_ptr ITTNOTIFY_NAME(counter_dec_delta) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec_delta(id, value) +#define __itt_counter_dec_delta_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_delta_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup counters + * @brief Increment a counter by one. + * The first call with a given name creates a counter by that name and sets its + * value to zero. Successive calls increment the counter value. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + */ +void ITTAPI __itt_counter_inc_v3(const __itt_domain *domain, __itt_string_handle *name); + +/** + * @ingroup counters + * @brief Increment a counter by the value specified in delta. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + * @param[in] delta The amount by which to increment the counter + */ +void ITTAPI __itt_counter_inc_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) +#define __itt_counter_inc_v3(d,x) ITTNOTIFY_VOID_D1(counter_inc_v3,d,x) +#define __itt_counter_inc_v3_ptr ITTNOTIFY_NAME(counter_inc_v3) +#define __itt_counter_inc_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_inc_delta_v3,d,x,y) +#define __itt_counter_inc_delta_v3_ptr ITTNOTIFY_NAME(counter_inc_delta_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_inc_v3(domain,name) +#define __itt_counter_inc_v3_ptr 0 +#define __itt_counter_inc_delta_v3(domain,name,delta) +#define __itt_counter_inc_delta_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_inc_v3_ptr 0 +#define __itt_counter_inc_delta_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + + +/** + * @ingroup counters + * @brief Decrement a counter by one. + * The first call with a given name creates a counter by that name and sets its + * value to zero. Successive calls decrement the counter value. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + */ +void ITTAPI __itt_counter_dec_v3(const __itt_domain *domain, __itt_string_handle *name); + +/** + * @ingroup counters + * @brief Decrement a counter by the value specified in delta. + * @param[in] domain The domain controlling the call. Counter names are not domain specific. + * The domain argument is used only to enable or disable the API calls. + * @param[in] name The name of the counter + * @param[in] delta The amount by which to decrement the counter + */ +void ITTAPI __itt_counter_dec_delta_v3(const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_dec_v3, (const __itt_domain *domain, __itt_string_handle *name)) +ITT_STUBV(ITTAPI, void, counter_dec_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long delta)) +#define __itt_counter_dec_v3(d,x) ITTNOTIFY_VOID_D1(counter_dec_v3,d,x) +#define __itt_counter_dec_v3_ptr ITTNOTIFY_NAME(counter_dec_v3) +#define __itt_counter_dec_delta_v3(d,x,y) ITTNOTIFY_VOID_D2(counter_dec_delta_v3,d,x,y) +#define __itt_counter_dec_delta_v3_ptr ITTNOTIFY_NAME(counter_dec_delta_v3) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_dec_v3(domain,name) +#define __itt_counter_dec_v3_ptr 0 +#define __itt_counter_dec_delta_v3(domain,name,delta) +#define __itt_counter_dec_delta_v3_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_dec_v3_ptr 0 +#define __itt_counter_dec_delta_v3_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} counters group */ + + +/** + * @brief Set the counter value + */ +void ITTAPI __itt_counter_set_value(__itt_counter id, void *value_ptr); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_set_value, (__itt_counter id, void *value_ptr)) +#define __itt_counter_set_value ITTNOTIFY_VOID(counter_set_value) +#define __itt_counter_set_value_ptr ITTNOTIFY_NAME(counter_set_value) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_set_value(id, value_ptr) +#define __itt_counter_set_value_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_set_value_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Set the counter value + */ +void ITTAPI __itt_counter_set_value_ex(__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_set_value_ex, (__itt_counter id, __itt_clock_domain *clock_domain, unsigned long long timestamp, void *value_ptr)) +#define __itt_counter_set_value_ex ITTNOTIFY_VOID(counter_set_value_ex) +#define __itt_counter_set_value_ex_ptr ITTNOTIFY_NAME(counter_set_value_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) +#define __itt_counter_set_value_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_set_value_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Create a typed counter with given name/domain + * + * After __itt_counter_create_typed() is called, __itt_counter_inc(id), __itt_counter_inc_delta(id, delta), + * __itt_counter_set_value(id, value_ptr) or __itt_counter_set_value_ex(id, clock_domain, timestamp, value_ptr) + * can be used to change the value of the counter + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_counter ITTAPI __itt_counter_create_typedA(const char *name, const char *domain, __itt_metadata_type type); +__itt_counter ITTAPI __itt_counter_create_typedW(const wchar_t *name, const wchar_t *domain, __itt_metadata_type type); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_counter_create_typed __itt_counter_create_typedW +# define __itt_counter_create_typed_ptr __itt_counter_create_typedW_ptr +#else /* UNICODE */ +# define __itt_counter_create_typed __itt_counter_create_typedA +# define __itt_counter_create_typed_ptr __itt_counter_create_typedA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_counter ITTAPI __itt_counter_create_typed(const char *name, const char *domain, __itt_metadata_type type); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_create_typedA, (const char *name, const char *domain, __itt_metadata_type type)) +ITT_STUB(ITTAPI, __itt_counter, counter_create_typedW, (const wchar_t *name, const wchar_t *domain, __itt_metadata_type type)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create_typed, (const char *name, const char *domain, __itt_metadata_type type)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA ITTNOTIFY_DATA(counter_create_typedA) +#define __itt_counter_create_typedA_ptr ITTNOTIFY_NAME(counter_create_typedA) +#define __itt_counter_create_typedW ITTNOTIFY_DATA(counter_create_typedW) +#define __itt_counter_create_typedW_ptr ITTNOTIFY_NAME(counter_create_typedW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed ITTNOTIFY_DATA(counter_create_typed) +#define __itt_counter_create_typed_ptr ITTNOTIFY_NAME(counter_create_typed) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA(name, domain, type) +#define __itt_counter_create_typedA_ptr 0 +#define __itt_counter_create_typedW(name, domain, type) +#define __itt_counter_create_typedW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed(name, domain, type) +#define __itt_counter_create_typed_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_counter_create_typedA_ptr 0 +#define __itt_counter_create_typedW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_counter_create_typed_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Destroy the counter identified by the pointer previously returned by __itt_counter_create() or + * __itt_counter_create_typed() + */ +void ITTAPI __itt_counter_destroy(__itt_counter id); + +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id)) +#define __itt_counter_destroy ITTNOTIFY_VOID(counter_destroy) +#define __itt_counter_destroy_ptr ITTNOTIFY_NAME(counter_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_counter_destroy(id) +#define __itt_counter_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_counter_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} counters group */ + +/** + * @ingroup markers + * @brief Create a marker instance. + * @param[in] domain The domain for this marker + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] id The instance ID for this marker, or __itt_null + * @param[in] name The name for this marker + * @param[in] scope The scope for this marker + */ +void ITTAPI __itt_marker_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope)) +#define __itt_marker_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(marker_ex,d,x,y,z,a,b) +#define __itt_marker_ex_ptr ITTNOTIFY_NAME(marker_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_marker_ex(domain,clock_domain,timestamp,id,name,scope) +#define __itt_marker_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_marker_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @ingroup clockdomain + * @brief Add a relation to the current task instance. + * The current task instance is the head of the relation. + * @param[in] domain The domain controlling this call + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_to_current_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail); + +/** + * @ingroup clockdomain + * @brief Add a relation between two instance identifiers. + * @param[in] domain The domain controlling this call + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] head The ID for the head of the relation + * @param[in] relation The kind of relation + * @param[in] tail The ID for the tail of the relation + */ +void ITTAPI __itt_relation_add_ex(const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail)) +ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail)) +#define __itt_relation_add_to_current_ex(d,x,y,z,a) ITTNOTIFY_VOID_D4(relation_add_to_current_ex,d,x,y,z,a) +#define __itt_relation_add_to_current_ex_ptr ITTNOTIFY_NAME(relation_add_to_current_ex) +#define __itt_relation_add_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(relation_add_ex,d,x,y,z,a,b) +#define __itt_relation_add_ex_ptr ITTNOTIFY_NAME(relation_add_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_relation_add_to_current_ex(domain,clock_domain,timestame,relation,tail) +#define __itt_relation_add_to_current_ex_ptr 0 +#define __itt_relation_add_ex(domain,clock_domain,timestamp,head,relation,tail) +#define __itt_relation_add_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_relation_add_to_current_ex_ptr 0 +#define __itt_relation_add_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +typedef enum ___itt_track_group_type +{ + __itt_track_group_type_normal = 0 +} __itt_track_group_type; +/** @endcond */ + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_track_group +{ + __itt_string_handle* name; /*!< Name of the track group */ + struct ___itt_track* track; /*!< List of child tracks */ + __itt_track_group_type tgtype; /*!< Type of the track group */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_track_group* next; +} __itt_track_group; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Placeholder for custom track types. Currently, "normal" custom track + * is the only available track type. + */ +typedef enum ___itt_track_type +{ + __itt_track_type_normal = 0 +#ifdef INTEL_ITTNOTIFY_API_PRIVATE + , __itt_track_type_queue +#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ +} __itt_track_type; + +/** @cond exclude_from_documentation */ +#pragma pack(push, 8) + +typedef struct ___itt_track +{ + __itt_string_handle* name; /*!< Name of the track group */ + __itt_track_group* group; /*!< Parent group to a track */ + __itt_track_type ttype; /*!< Type of the track */ + int extra1; /*!< Reserved. Must be zero */ + void* extra2; /*!< Reserved. Must be zero */ + struct ___itt_track* next; +} __itt_track; + +#pragma pack(pop) +/** @endcond */ + +/** + * @brief Create logical track group. + */ +__itt_track_group* ITTAPI __itt_track_group_create(__itt_string_handle* name, __itt_track_group_type track_group_type); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type)) +#define __itt_track_group_create ITTNOTIFY_DATA(track_group_create) +#define __itt_track_group_create_ptr ITTNOTIFY_NAME(track_group_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_track_group_create(name) (__itt_track_group*)0 +#define __itt_track_group_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_track_group_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Create logical track. + */ +__itt_track* ITTAPI __itt_track_create(__itt_track_group* track_group, __itt_string_handle* name, __itt_track_type track_type); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type)) +#define __itt_track_create ITTNOTIFY_DATA(track_create) +#define __itt_track_create_ptr ITTNOTIFY_NAME(track_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_track_create(track_group,name,track_type) (__itt_track*)0 +#define __itt_track_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_track_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Set the logical track. + */ +void ITTAPI __itt_set_track(__itt_track* track); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track)) +#define __itt_set_track ITTNOTIFY_VOID(set_track) +#define __itt_set_track_ptr ITTNOTIFY_NAME(set_track) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_set_track(track) +#define __itt_set_track_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_set_track_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/* ========================================================================== */ +/** @cond exclude_from_gpa_documentation */ +/** + * @defgroup events Events + * @ingroup public + * Events group + * @{ + */ +/** @brief user event type */ +typedef int __itt_event; + +/** + * @brief Create an event notification + * @note name or namelen being null/name and namelen not matching, user event feature not enabled + * @return non-zero event identifier upon success and __itt_err otherwise + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); +__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_event_create __itt_event_createW +# define __itt_event_create_ptr __itt_event_createW_ptr +#else +# define __itt_event_create __itt_event_createA +# define __itt_event_create_ptr __itt_event_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA ITTNOTIFY_DATA(event_createA) +#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) +#define __itt_event_createW ITTNOTIFY_DATA(event_createW) +#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create ITTNOTIFY_DATA(event_create) +#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA(name, namelen) (__itt_event)0 +#define __itt_event_createA_ptr 0 +#define __itt_event_createW(name, namelen) (__itt_event)0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create(name, namelen) (__itt_event)0 +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA_ptr 0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event occurrence. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_start(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) +#define __itt_event_start ITTNOTIFY_DATA(event_start) +#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_start(event) (int)0 +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event end occurrence. + * @note It is optional if events do not have durations. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_end(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) +#define __itt_event_end ITTNOTIFY_DATA(event_end) +#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_end(event) (int)0 +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} events group */ + + +/** + * @defgroup arrays Arrays Visualizer + * @ingroup public + * Visualize arrays + * @{ + */ + +/** + * @enum __itt_av_data_type + * @brief Defines types of arrays data (for C/C++ intrinsic types) + */ +typedef enum +{ + __itt_e_first = 0, + __itt_e_char = 0, /* 1-byte integer */ + __itt_e_uchar, /* 1-byte unsigned integer */ + __itt_e_int16, /* 2-byte integer */ + __itt_e_uint16, /* 2-byte unsigned integer */ + __itt_e_int32, /* 4-byte integer */ + __itt_e_uint32, /* 4-byte unsigned integer */ + __itt_e_int64, /* 8-byte integer */ + __itt_e_uint64, /* 8-byte unsigned integer */ + __itt_e_float, /* 4-byte floating */ + __itt_e_double, /* 8-byte floating */ + __itt_e_last = __itt_e_double +} __itt_av_data_type; + +/** + * @brief Save an array data to a file. + * Output format is defined by the file extension. The csv and bmp formats are supported (bmp - for 2-dimensional array only). + * @param[in] data - pointer to the array data + * @param[in] rank - the rank of the array + * @param[in] dimensions - pointer to an array of integers, which specifies the array dimensions. + * The size of dimensions must be equal to the rank + * @param[in] type - the type of the array, specified as one of the __itt_av_data_type values (for intrinsic types) + * @param[in] filePath - the file path; the output format is defined by the file extension + * @param[in] columnOrder - defines how the array is stored in the linear memory. + * It should be 1 for column-major order (e.g. in FORTRAN) or 0 - for row-major order (e.g. in C). + */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_av_saveA(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); +int ITTAPI __itt_av_saveW(void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_av_save __itt_av_saveW +# define __itt_av_save_ptr __itt_av_saveW_ptr +#else /* UNICODE */ +# define __itt_av_save __itt_av_saveA +# define __itt_av_save_ptr __itt_av_saveA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_av_save(void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) +ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA ITTNOTIFY_DATA(av_saveA) +#define __itt_av_saveA_ptr ITTNOTIFY_NAME(av_saveA) +#define __itt_av_saveW ITTNOTIFY_DATA(av_saveW) +#define __itt_av_saveW_ptr ITTNOTIFY_NAME(av_saveW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save ITTNOTIFY_DATA(av_save) +#define __itt_av_save_ptr ITTNOTIFY_NAME(av_save) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA(name) +#define __itt_av_saveA_ptr 0 +#define __itt_av_saveW(name) +#define __itt_av_saveW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save(name) +#define __itt_av_save_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_av_saveA_ptr 0 +#define __itt_av_saveW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_av_save_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +void ITTAPI __itt_enable_attach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, enable_attach, (void)) +#define __itt_enable_attach ITTNOTIFY_VOID(enable_attach) +#define __itt_enable_attach_ptr ITTNOTIFY_NAME(enable_attach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_enable_attach() +#define __itt_enable_attach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_enable_attach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @cond exclude_from_gpa_documentation */ + +/** @} arrays group */ + +/** @endcond */ + +/** + * @brief Module load info + * This API is used to report necessary information in case of module relocation + * @param[in] start_addr - relocated module start address + * @param[in] end_addr - relocated module end address + * @param[in] path - file system path to the module + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_module_loadA(void *start_addr, void *end_addr, const char *path); +void ITTAPI __itt_module_loadW(void *start_addr, void *end_addr, const wchar_t *path); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_module_load __itt_module_loadW +# define __itt_module_load_ptr __itt_module_loadW_ptr +#else /* UNICODE */ +# define __itt_module_load __itt_module_loadA +# define __itt_module_load_ptr __itt_module_loadA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_module_load(void *start_addr, void *end_addr, const char *path); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, void, module_loadA, (void *start_addr, void *end_addr, const char *path)) +ITT_STUB(ITTAPI, void, module_loadW, (void *start_addr, void *end_addr, const wchar_t *path)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA ITTNOTIFY_VOID(module_loadA) +#define __itt_module_loadA_ptr ITTNOTIFY_NAME(module_loadA) +#define __itt_module_loadW ITTNOTIFY_VOID(module_loadW) +#define __itt_module_loadW_ptr ITTNOTIFY_NAME(module_loadW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load ITTNOTIFY_VOID(module_load) +#define __itt_module_load_ptr ITTNOTIFY_NAME(module_load) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA(start_addr, end_addr, path) +#define __itt_module_loadA_ptr 0 +#define __itt_module_loadW(start_addr, end_addr, path) +#define __itt_module_loadW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load(start_addr, end_addr, path) +#define __itt_module_load_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_module_loadA_ptr 0 +#define __itt_module_loadW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_module_load_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ITTNOTIFY_H_ */ + +#ifdef INTEL_ITTNOTIFY_API_PRIVATE + +#ifndef _ITTNOTIFY_PRIVATE_ +#define _ITTNOTIFY_PRIVATE_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @ingroup clockdomain + * @brief Begin an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid The identifier for this task instance, *cannot* be __itt_null. + * @param[in] parentid The parent of this task, or __itt_null. + * @param[in] name The name of this task. + */ +void ITTAPI __itt_task_begin_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name); + +/** + * @ingroup clockdomain + * @brief End an overlapped task instance. + * @param[in] domain The domain for this task + * @param[in] clock_domain The clock domain controlling the execution of this call. + * @param[in] timestamp The user defined timestamp. + * @param[in] taskid Explicit ID of finished task + */ +void ITTAPI __itt_task_end_overlapped_ex(const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid, __itt_id parentid, __itt_string_handle* name)) +ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain* domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id taskid)) +#define __itt_task_begin_overlapped_ex(d,x,y,z,a,b) ITTNOTIFY_VOID_D5(task_begin_overlapped_ex,d,x,y,z,a,b) +#define __itt_task_begin_overlapped_ex_ptr ITTNOTIFY_NAME(task_begin_overlapped_ex) +#define __itt_task_end_overlapped_ex(d,x,y,z) ITTNOTIFY_VOID_D3(task_end_overlapped_ex,d,x,y,z) +#define __itt_task_end_overlapped_ex_ptr ITTNOTIFY_NAME(task_end_overlapped_ex) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_task_begin_overlapped_ex(domain,clock_domain,timestamp,taskid,parentid,name) +#define __itt_task_begin_overlapped_ex_ptr 0 +#define __itt_task_end_overlapped_ex(domain,clock_domain,timestamp,taskid) +#define __itt_task_end_overlapped_ex_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_task_begin_overlapped_ex_ptr 0 +#define __itt_task_end_overlapped_ptr 0 +#define __itt_task_end_overlapped_ex_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @defgroup makrs_internal Marks + * @ingroup internal + * Marks group + * @warning Internal API: + * - It is not shipped to outside of Intel + * - It is delivered to internal Intel teams using e-mail or SVN access only + * @{ + */ +/** @brief user mark type */ +typedef int __itt_mark_type; + +/** + * @brief Creates a user mark type with the specified name using char or Unicode string. + * @param[in] name - name of mark to create + * @return Returns a handle to the mark type + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_mark_type ITTAPI __itt_mark_createA(const char *name); +__itt_mark_type ITTAPI __itt_mark_createW(const wchar_t *name); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark_create __itt_mark_createW +# define __itt_mark_create_ptr __itt_mark_createW_ptr +#else /* UNICODE */ +# define __itt_mark_create __itt_mark_createA +# define __itt_mark_create_ptr __itt_mark_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_mark_type ITTAPI __itt_mark_create(const char *name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name)) +ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA ITTNOTIFY_DATA(mark_createA) +#define __itt_mark_createA_ptr ITTNOTIFY_NAME(mark_createA) +#define __itt_mark_createW ITTNOTIFY_DATA(mark_createW) +#define __itt_mark_createW_ptr ITTNOTIFY_NAME(mark_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create ITTNOTIFY_DATA(mark_create) +#define __itt_mark_create_ptr ITTNOTIFY_NAME(mark_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA(name) (__itt_mark_type)0 +#define __itt_mark_createA_ptr 0 +#define __itt_mark_createW(name) (__itt_mark_type)0 +#define __itt_mark_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create(name) (__itt_mark_type)0 +#define __itt_mark_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_createA_ptr 0 +#define __itt_mark_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Creates a "discrete" user mark type of the specified type and an optional parameter using char or Unicode string. + * + * - The mark of "discrete" type is placed to collection results in case of success. It appears in overtime view(s) as a special tick sign. + * - The call is "synchronous" - function returns after mark is actually added to results. + * - This function is useful, for example, to mark different phases of application + * (beginning of the next mark automatically meand end of current region). + * - Can be used together with "continuous" marks (see below) at the same collection session + * @param[in] mt - mark, created by __itt_mark_create(const char* name) function + * @param[in] parameter - string parameter of mark + * @return Returns zero value in case of success, non-zero value otherwise. + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_markA(__itt_mark_type mt, const char *parameter); +int ITTAPI __itt_markW(__itt_mark_type mt, const wchar_t *parameter); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark __itt_markW +# define __itt_mark_ptr __itt_markW_ptr +#else /* UNICODE */ +# define __itt_mark __itt_markA +# define __itt_mark_ptr __itt_markA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_mark(__itt_mark_type mt, const char *parameter); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter)) +ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA ITTNOTIFY_DATA(markA) +#define __itt_markA_ptr ITTNOTIFY_NAME(markA) +#define __itt_markW ITTNOTIFY_DATA(markW) +#define __itt_markW_ptr ITTNOTIFY_NAME(markW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark ITTNOTIFY_DATA(mark) +#define __itt_mark_ptr ITTNOTIFY_NAME(mark) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA(mt, parameter) (int)0 +#define __itt_markA_ptr 0 +#define __itt_markW(mt, parameter) (int)0 +#define __itt_markW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark(mt, parameter) (int)0 +#define __itt_mark_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_markA_ptr 0 +#define __itt_markW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Use this if necessary to create a "discrete" user event type (mark) for process + * rather then for one thread + * @see int __itt_mark(__itt_mark_type mt, const char* parameter); + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int ITTAPI __itt_mark_globalA(__itt_mark_type mt, const char *parameter); +int ITTAPI __itt_mark_globalW(__itt_mark_type mt, const wchar_t *parameter); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_mark_global __itt_mark_globalW +# define __itt_mark_global_ptr __itt_mark_globalW_ptr +#else /* UNICODE */ +# define __itt_mark_global __itt_mark_globalA +# define __itt_mark_global_ptr __itt_mark_globalA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int ITTAPI __itt_mark_global(__itt_mark_type mt, const char *parameter); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter)) +ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA ITTNOTIFY_DATA(mark_globalA) +#define __itt_mark_globalA_ptr ITTNOTIFY_NAME(mark_globalA) +#define __itt_mark_globalW ITTNOTIFY_DATA(mark_globalW) +#define __itt_mark_globalW_ptr ITTNOTIFY_NAME(mark_globalW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global ITTNOTIFY_DATA(mark_global) +#define __itt_mark_global_ptr ITTNOTIFY_NAME(mark_global) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA(mt, parameter) (int)0 +#define __itt_mark_globalA_ptr 0 +#define __itt_mark_globalW(mt, parameter) (int)0 +#define __itt_mark_globalW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global(mt, parameter) (int)0 +#define __itt_mark_global_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_mark_globalA_ptr 0 +#define __itt_mark_globalW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_mark_global_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Creates an "end" point for "continuous" mark with specified name. + * + * - Returns zero value in case of success, non-zero value otherwise. + * Also returns non-zero value when preceding "begin" point for the + * mark with the same name failed to be created or not created. + * - The mark of "continuous" type is placed to collection results in + * case of success. It appears in overtime view(s) as a special tick + * sign (different from "discrete" mark) together with line from + * corresponding "begin" mark to "end" mark. + * @note Continuous marks can overlap and be nested inside each other. + * Discrete mark can be nested inside marked region + * @param[in] mt - mark, created by __itt_mark_create(const char* name) function + * @return Returns zero value in case of success, non-zero value otherwise. + */ +int ITTAPI __itt_mark_off(__itt_mark_type mt); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt)) +#define __itt_mark_off ITTNOTIFY_DATA(mark_off) +#define __itt_mark_off_ptr ITTNOTIFY_NAME(mark_off) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_mark_off(mt) (int)0 +#define __itt_mark_off_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_mark_off_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Use this if necessary to create an "end" point for mark of process + * @see int __itt_mark_off(__itt_mark_type mt); + */ +int ITTAPI __itt_mark_global_off(__itt_mark_type mt); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt)) +#define __itt_mark_global_off ITTNOTIFY_DATA(mark_global_off) +#define __itt_mark_global_off_ptr ITTNOTIFY_NAME(mark_global_off) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_mark_global_off(mt) (int)0 +#define __itt_mark_global_off_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_mark_global_off_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} marks group */ + +/** + * @defgroup counters_internal Counters + * @ingroup internal + * Counters group + * @{ + */ + + +/** + * @defgroup stitch Stack Stitching + * @ingroup internal + * Stack Stitching group + * @{ + */ +/** + * @brief opaque structure for counter identification + */ +typedef struct ___itt_caller *__itt_caller; + +/** + * @brief Create the stitch point e.g. a point in call stack where other stacks should be stitched to. + * The function returns a unique identifier which is used to match the cut points with corresponding stitch points. + */ +__itt_caller ITTAPI __itt_stack_caller_create(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void)) +#define __itt_stack_caller_create ITTNOTIFY_DATA(stack_caller_create) +#define __itt_stack_caller_create_ptr ITTNOTIFY_NAME(stack_caller_create) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_caller_create() (__itt_caller)0 +#define __itt_stack_caller_create_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_caller_create_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Destroy the inforamtion about stitch point identified by the pointer previously returned by __itt_stack_caller_create() + */ +void ITTAPI __itt_stack_caller_destroy(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id)) +#define __itt_stack_caller_destroy ITTNOTIFY_VOID(stack_caller_destroy) +#define __itt_stack_caller_destroy_ptr ITTNOTIFY_NAME(stack_caller_destroy) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_caller_destroy(id) +#define __itt_stack_caller_destroy_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_caller_destroy_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Sets the cut point. Stack from each event which occurs after this call will be cut + * at the same stack level the function was called and stitched to the corresponding stitch point. + */ +void ITTAPI __itt_stack_callee_enter(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id)) +#define __itt_stack_callee_enter ITTNOTIFY_VOID(stack_callee_enter) +#define __itt_stack_callee_enter_ptr ITTNOTIFY_NAME(stack_callee_enter) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_callee_enter(id) +#define __itt_stack_callee_enter_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_callee_enter_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief This function eliminates the cut point which was set by latest __itt_stack_callee_enter(). + */ +void ITTAPI __itt_stack_callee_leave(__itt_caller id); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id)) +#define __itt_stack_callee_leave ITTNOTIFY_VOID(stack_callee_leave) +#define __itt_stack_callee_leave_ptr ITTNOTIFY_NAME(stack_callee_leave) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_stack_callee_leave(id) +#define __itt_stack_callee_leave_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_stack_callee_leave_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @} stitch group */ + +/* ***************************************************************************************************************************** */ + +#include + +/** @cond exclude_from_documentation */ +typedef enum __itt_error_code +{ + __itt_error_success = 0, /*!< no error */ + __itt_error_no_module = 1, /*!< module can't be loaded */ + /* %1$s -- library name; win: %2$d -- system error code; unx: %2$s -- system error message. */ + __itt_error_no_symbol = 2, /*!< symbol not found */ + /* %1$s -- library name, %2$s -- symbol name. */ + __itt_error_unknown_group = 3, /*!< unknown group specified */ + /* %1$s -- env var name, %2$s -- group name. */ + __itt_error_cant_read_env = 4, /*!< GetEnvironmentVariable() failed */ + /* %1$s -- env var name, %2$d -- system error. */ + __itt_error_env_too_long = 5, /*!< variable value too long */ + /* %1$s -- env var name, %2$d -- actual length of the var, %3$d -- max allowed length. */ + __itt_error_system = 6 /*!< pthread_mutexattr_init or pthread_mutex_init failed */ + /* %1$s -- function name, %2$d -- errno. */ +} __itt_error_code; + +typedef void (__itt_error_handler_t)(__itt_error_code code, va_list); +__itt_error_handler_t* __itt_set_error_handler(__itt_error_handler_t*); + +const char* ITTAPI __itt_api_version(void); +/** @endcond */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#define __itt_error_handler ITT_JOIN(INTEL_ITTNOTIFY_PREFIX, error_handler) +void __itt_error_handler(__itt_error_code code, va_list args); +extern const int ITTNOTIFY_NAME(err); +#define __itt_err ITTNOTIFY_NAME(err) +ITT_STUB(ITTAPI, const char*, api_version, (void)) +#define __itt_api_version ITTNOTIFY_DATA(api_version) +#define __itt_api_version_ptr ITTNOTIFY_NAME(api_version) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_api_version() (const char*)0 +#define __itt_api_version_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_api_version_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ITTNOTIFY_PRIVATE_ */ + +#endif /* INTEL_ITTNOTIFY_API_PRIVATE */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/jitprofiling.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/jitprofiling.h index ef6557b4f2..6c656cc5e9 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/jitprofiling.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/jitprofiling.h @@ -1,694 +1,694 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 __JITPROFILING_H__ -#define __JITPROFILING_H__ - -/** - * @brief JIT Profiling APIs - * - * The JIT Profiling API is used to report information about just-in-time - * generated code that can be used by performance tools. The user inserts - * calls in the code generator to report information before JIT-compiled - * code goes to execution. This information is collected at runtime and used - * by tools like Intel(R) VTune(TM) Amplifier to display performance metrics - * associated with JIT-compiled code. - * - * These APIs can be used to\n - * - **Profile trace-based and method-based JIT-compiled - * code**. Some examples of environments that you can profile with these APIs: - * dynamic JIT compilation of JavaScript code traces, JIT execution in OpenCL(TM) - * software technology, Java/.NET managed execution environments, and custom - * ISV JIT engines. - * @code - * #include - * - * if (iJIT_IsProfilingActive != iJIT_SAMPLING_ON) { - * return; - * } - * - * iJIT_Method_Load jmethod = {0}; - * jmethod.method_id = iJIT_GetNewMethodID(); - * jmethod.method_name = "method_name"; - * jmethod.class_file_name = "class_name"; - * jmethod.source_file_name = "source_file_name"; - * jmethod.method_load_address = code_addr; - * jmethod.method_size = code_size; - * - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); - * @endcode - * - * * Expected behavior: - * * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an - * already reported method, then such a method becomes invalid and its - * memory region is treated as unloaded. VTune Amplifier displays the metrics - * collected by the method until it is overwritten. - * * If supplied line number information contains multiple source lines for - * the same assembly instruction (code location), then VTune Amplifier picks up - * the first line number. - * * Dynamically generated code can be associated with a module name. - * Use the iJIT_Method_Load_V2 structure.\n - * Clarification of some cases: - * * If you register a function with the same method ID multiple times, - * specifying different module names, then the VTune Amplifier picks up - * the module name registered first. If you want to distinguish the same - * function between different JIT engines, supply different method IDs for - * each function. Other symbolic information (for example, source file) - * can be identical. - * - * - **Analyze split functions** (multiple joint or disjoint code regions - * belonging to the same function) **including re-JIT** - * with potential overlapping of code regions in time, which is common in - * resource-limited environments. - * @code - * #include - * - * unsigned int method_id = iJIT_GetNewMethodID(); - * - * iJIT_Method_Load a = {0}; - * a.method_id = method_id; - * a.method_load_address = 0x100; - * a.method_size = 0x20; - * - * iJIT_Method_Load b = {0}; - * b.method_id = method_id; - * b.method_load_address = 0x200; - * b.method_size = 0x30; - * - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&b); - * @endcode - * - * * Expected behaviour: - * * If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an - * already reported method, then such a method becomes invalid and - * its memory region is treated as unloaded. - * * All code regions reported with the same method ID are considered as - * belonging to the same method. Symbolic information (method name, - * source file name) will be taken from the first notification, and all - * subsequent notifications with the same method ID will be processed - * only for line number table information. So, the VTune Amplifier will map - * samples to a source line using the line number table from the current - * notification while taking the source file name from the very first one.\n - * Clarification of some cases:\n - * * If you register a second code region with a different source file - * name and the same method ID, then this information will be saved and - * will not be considered as an extension of the first code region, but - * VTune Amplifier will use the source file of the first code region and map - * performance metrics incorrectly. - * * If you register a second code region with the same source file as - * for the first region and the same method ID, then the source file will be - * discarded but VTune Amplifier will map metrics to the source file correctly. - * * If you register a second code region with a null source file and - * the same method ID, then provided line number info will be associated - * with the source file of the first code region. - * - * - **Explore inline functions** including multi-level hierarchy of - * nested inline methods which shows how performance metrics are distributed through them. - * @code - * #include - * - * // method_id parent_id - * // [-- c --] 3000 2000 - * // [---- d -----] 2001 1000 - * // [---- b ----] 2000 1000 - * // [------------ a ----------------] 1000 n/a - * - * iJIT_Method_Load a = {0}; - * a.method_id = 1000; - * - * iJIT_Method_Inline_Load b = {0}; - * b.method_id = 2000; - * b.parent_method_id = 1000; - * - * iJIT_Method_Inline_Load c = {0}; - * c.method_id = 3000; - * c.parent_method_id = 2000; - * - * iJIT_Method_Inline_Load d = {0}; - * d.method_id = 2001; - * d.parent_method_id = 1000; - * - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&b); - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&c); - * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&d); - * @endcode - * - * * Requirements: - * * Each inline (iJIT_Method_Inline_Load) method should be associated - * with two method IDs: one for itself; one for its immediate parent. - * * Address regions of inline methods of the same parent method cannot - * overlap each other. - * * Execution of the parent method must not be started until it and all - * its inline methods are reported. - * * Expected behaviour: - * * In case of nested inline methods an order of - * iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important. - * * If any event overwrites either inline method or top parent method, - * then the parent, including inline methods, becomes invalid and its memory - * region is treated as unloaded. - * - * **Life time of allocated data**\n - * The client sends an event notification to the agent with event-specific - * data, which is a structure. The pointers in the structure refer to memory - * allocated by the client, which responsible for releasing it. The pointers are - * used by the iJIT_NotifyEvent method to copy client's data in a trace file, - * and they are not used after the iJIT_NotifyEvent method returns. - */ - -/** - * @defgroup jitapi JIT Profiling - * @ingroup internal - * @{ - */ - -/** - * @brief Enumerator for the types of notifications - */ -typedef enum iJIT_jvm_event -{ - iJVM_EVENT_TYPE_SHUTDOWN = 2, /**<\brief Send this to shutdown the agent. - * Use NULL for event data. */ - - iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED = 13, /**<\brief Send when dynamic code is - * JIT compiled and loaded into - * memory by the JIT engine, but - * before the code is executed. - * Use iJIT_Method_Load as event - * data. */ -/** @cond exclude_from_documentation */ - iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /**<\brief Send when compiled dynamic - * code is being unloaded from memory. - * Use iJIT_Method_Load as event data.*/ -/** @endcond */ - - iJVM_EVENT_TYPE_METHOD_UPDATE, /**<\brief Send to provide new content for - * a previously reported dynamic code. - * The previous content will be invalidated - * starting from the time of the notification. - * Use iJIT_Method_Load as event data but - * required fields are following: - * - method_id identify the code to update. - * - method_load_address specify start address - * within identified code range - * where update should be started. - * - method_size specify length of updated code - * range. */ - - - iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, /**<\brief Send when an inline dynamic - * code is JIT compiled and loaded - * into memory by the JIT engine, - * but before the parent code region - * starts executing. - * Use iJIT_Method_Inline_Load as event data.*/ - -/** @cond exclude_from_documentation */ - iJVM_EVENT_TYPE_METHOD_UPDATE_V2, -/** @endcond */ - - iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 = 21, /**<\brief Send when a dynamic code is - * JIT compiled and loaded into - * memory by the JIT engine, but - * before the code is executed. - * Use iJIT_Method_Load_V2 as event data. */ - - iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 /**<\brief Send when a dynamic code is - * JIT compiled and loaded into - * memory by the JIT engine, but - * before the code is executed. - * Use iJIT_Method_Load_V3 as event data. */ -} iJIT_JVM_EVENT; - -/** - * @brief Enumerator for the agent's mode - */ -typedef enum _iJIT_IsProfilingActiveFlags -{ - iJIT_NOTHING_RUNNING = 0x0000, /**<\brief The agent is not running; - * iJIT_NotifyEvent calls will - * not be processed. */ - iJIT_SAMPLING_ON = 0x0001, /**<\brief The agent is running and - * ready to process notifications. */ -} iJIT_IsProfilingActiveFlags; - -/** - * @brief Description of a single entry in the line number information of a code region. - * @details A table of line number entries gives information about how the reported code region - * is mapped to source file. - * Intel(R) VTune(TM) Amplifier uses line number information to attribute - * the samples (virtual address) to a line number. \n - * It is acceptable to report different code addresses for the same source line: - * @code - * Offset LineNumber - * 1 2 - * 12 4 - * 15 2 - * 18 1 - * 21 30 - * - * VTune Amplifier constructs the following table using the client data - * - * Code subrange Line number - * 0-1 2 - * 1-12 4 - * 12-15 2 - * 15-18 1 - * 18-21 30 - * @endcode - */ -typedef struct _LineNumberInfo -{ - unsigned int Offset; /**<\brief Offset from the begining of the code region. */ - unsigned int LineNumber; /**<\brief Matching source line number offset (from beginning of source file). */ - -} *pLineNumberInfo, LineNumberInfo; - -/** - * @brief Enumerator for the code architecture. - */ -typedef enum _iJIT_CodeArchitecture -{ - iJIT_CA_NATIVE = 0, /**<\brief Native to the process architecture that is calling it. */ - - iJIT_CA_32, /**<\brief 32-bit machine code. */ - - iJIT_CA_64 /**<\brief 64-bit machine code. */ - -} iJIT_CodeArchitecture; - -#pragma pack(push, 8) - -/** - * @brief Description of a JIT-compiled method - * @details When you use the iJIT_Method_Load structure to describe - * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED - * as an event type to report it. - */ -typedef struct _iJIT_Method_Load -{ - unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. - * You must either use the API function - * iJIT_GetNewMethodID to get a valid and unique - * method ID, or else manage ID uniqueness - * and correct range by yourself.\n - * You must use the same method ID for all code - * regions of the same method, otherwise different - * method IDs specify different methods. */ - - char* method_name; /**<\brief The name of the method. It can be optionally - * prefixed with its class name and appended with - * its complete signature. Can't be NULL. */ - - void* method_load_address; /**<\brief The start virtual address of the method code - * region. If NULL, data provided with - * event are not accepted. */ - - unsigned int method_size; /**<\brief The code size of the method in memory. - * If 0, then data provided with the event are not - * accepted. */ - - unsigned int line_number_size; /**<\brief The number of entries in the line number - * table.0 if none. */ - - pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info - * array. Can be NULL if - * line_number_size is 0. See - * LineNumberInfo Structure for a - * description of a single entry in - * the line number info array */ - - unsigned int class_id; /**<\brief This field is obsolete. */ - - char* class_file_name; /**<\brief Class name. Can be NULL.*/ - - char* source_file_name; /**<\brief Source file name. Can be NULL.*/ - -} *piJIT_Method_Load, iJIT_Method_Load; - -/** - * @brief Description of a JIT-compiled method - * @details When you use the iJIT_Method_Load_V2 structure to describe - * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 - * as an event type to report it. - */ -typedef struct _iJIT_Method_Load_V2 -{ - unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. - * You must either use the API function - * iJIT_GetNewMethodID to get a valid and unique - * method ID, or else manage ID uniqueness - * and correct range by yourself.\n - * You must use the same method ID for all code - * regions of the same method, otherwise different - * method IDs specify different methods. */ - - char* method_name; /**<\brief The name of the method. It can be optionally - * prefixed with its class name and appended with - * its complete signature. Can't be NULL. */ - - void* method_load_address; /**<\brief The start virtual address of the method code - * region. If NULL, then data provided with the - * event are not accepted. */ - - unsigned int method_size; /**<\brief The code size of the method in memory. - * If 0, then data provided with the event are not - * accepted. */ - - unsigned int line_number_size; /**<\brief The number of entries in the line number - * table. 0 if none. */ - - pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info - * array. Can be NULL if - * line_number_size is 0. See - * LineNumberInfo Structure for a - * description of a single entry in - * the line number info array. */ - - char* class_file_name; /**<\brief Class name. Can be NULL. */ - - char* source_file_name; /**<\brief Source file name. Can be NULL. */ - - char* module_name; /**<\brief Module name. Can be NULL. - The module name can be useful for distinguishing among - different JIT engines. VTune Amplifier will display - reported methods grouped by specific module. */ - -} *piJIT_Method_Load_V2, iJIT_Method_Load_V2; - -/** - * @brief Description of a JIT-compiled method - * @details The iJIT_Method_Load_V3 structure is the same as iJIT_Method_Load_V2 - * with a newly introduced 'arch' field that specifies architecture of the code region. - * When you use the iJIT_Method_Load_V3 structure to describe - * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 - * as an event type to report it. - */ -typedef struct _iJIT_Method_Load_V3 -{ - unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. - * You must either use the API function - * iJIT_GetNewMethodID to get a valid and unique - * method ID, or manage ID uniqueness - * and correct range by yourself.\n - * You must use the same method ID for all code - * regions of the same method, otherwise they are - * treated as regions of different methods. */ - - char* method_name; /**<\brief The name of the method. It can be optionally - * prefixed with its class name and appended with - * its complete signature. Cannot be NULL. */ - - void* method_load_address; /**<\brief The start virtual address of the method code - * region. If NULL, then data provided with the - * event are not accepted. */ - - unsigned int method_size; /**<\brief The code size of the method in memory. - * If 0, then data provided with the event are not - * accepted. */ - - unsigned int line_number_size; /**<\brief The number of entries in the line number - * table. 0 if none. */ - - pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info - * array. Can be NULL if - * line_number_size is 0. See - * LineNumberInfo Structure for a - * description of a single entry in - * the line number info array. */ - - char* class_file_name; /**<\brief Class name. Can be NULL. */ - - char* source_file_name; /**<\brief Source file name. Can be NULL. */ - - char* module_name; /**<\brief Module name. Can be NULL. - * The module name can be useful for distinguishing among - * different JIT engines. VTune Amplifier will display - * reported methods grouped by specific module. */ - - iJIT_CodeArchitecture module_arch; /**<\brief Architecture of the method's code region. - * By default, it is the same as the process - * architecture that is calling it. - * For example, you can use it if your 32-bit JIT - * engine generates 64-bit code. - * - * If JIT engine reports both 32-bit and 64-bit types - * of methods then VTune Amplifier splits the methods - * with the same module name but with different - * architectures in two different modules. VTune Amplifier - * modifies the original name provided with a 64-bit method - * version by ending it with '(64)' */ - -} *piJIT_Method_Load_V3, iJIT_Method_Load_V3; - -/** - * @brief Description of an inline JIT-compiled method - * @details When you use the_iJIT_Method_Inline_Load structure to describe - * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED - * as an event type to report it. - */ -typedef struct _iJIT_Method_Inline_Load -{ - unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. - * You must either use the API function - * iJIT_GetNewMethodID to get a valid and unique - * method ID, or else manage ID uniqueness - * and correct range by yourself. */ - - unsigned int parent_method_id; /**<\brief Unique immediate parent's method ID. - * Cannot be 0. - * You must either use the API function - * iJIT_GetNewMethodID to get a valid and unique - * method ID, or else manage ID uniqueness - * and correct range by yourself. */ - - char* method_name; /**<\brief The name of the method. It can be optionally - * prefixed with its class name and appended with - * its complete signature. Can't be NULL. */ - - void* method_load_address; /** <\brief The virtual address on which the method - * is inlined. If NULL, then data provided with - * the event are not accepted. */ - - unsigned int method_size; /**<\brief The code size of the method in memory. - * If 0, then data provided with the event are not - * accepted. */ - - unsigned int line_number_size; /**<\brief The number of entries in the line number - * table. 0 if none. */ - - pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info - * array. Can be NULL if - * line_number_size is 0. See - * LineNumberInfo Structure for a - * description of a single entry in - * the line number info array */ - - char* class_file_name; /**<\brief Class name. Can be NULL.*/ - - char* source_file_name; /**<\brief Source file name. Can be NULL.*/ - -} *piJIT_Method_Inline_Load, iJIT_Method_Inline_Load; - -/** @cond exclude_from_documentation */ -/** - * @brief Description of a segment type - * @details Use the segment type to specify a type of data supplied - * with the iJVM_EVENT_TYPE_METHOD_UPDATE_V2 event to be applied to - * a certain code trace. - */ -typedef enum _iJIT_SegmentType -{ - iJIT_CT_UNKNOWN = 0, - - iJIT_CT_CODE, /**<\brief Executable code. */ - - iJIT_CT_DATA, /**<\brief Data (not executable code). - * VTune Amplifier uses the format string - * (see iJIT_Method_Update) to represent - * this data in the VTune Amplifier GUI */ - - iJIT_CT_KEEP, /**<\brief Use the previous markup for the trace. - * Can be used for the following - * iJVM_EVENT_TYPE_METHOD_UPDATE_V2 events, - * if the type of the previously reported segment - * type is the same. */ - iJIT_CT_EOF -} iJIT_SegmentType; - -/** - * @brief Description of a dynamic update of the content within JIT-compiled method - * @details The JIT engine may generate the methods that are updated at runtime - * partially by mixed (data + executable code) content. When you use the iJIT_Method_Update - * structure to describe the update of the content within a JIT-compiled method, - * use iJVM_EVENT_TYPE_METHOD_UPDATE_V2 as an event type to report it. - * - * On the first Update event, VTune Amplifier copies the original code range reported by - * the iJVM_EVENT_TYPE_METHOD_LOAD event, then modifies it with the supplied bytes and - * adds the modified range to the original method. For next update events, VTune Amplifier - * does the same but it uses the latest modified version of a code region for update. - * Eventually, VTune Amplifier GUI displays multiple code ranges for the method reported by - * the iJVM_EVENT_TYPE_METHOD_LOAD event. - * Notes: - * - Multiple update events with different types for the same trace are allowed - * but they must be reported for the same code ranges. - * Example, - * @code - * [-- data---] Allowed - * [-- code --] Allowed - * [code] Ignored - * [-- data---] Allowed - * [-- code --] Allowed - * [------------ trace ---------] - * @endcode - * - The types of previously reported events can be changed but they must be reported - * for the same code ranges. - * Example, - * @code - * [-- data---] Allowed - * [-- code --] Allowed - * [-- data---] Allowed - * [-- code --] Allowed - * [------------ trace ---------] - * @endcode - */ - -typedef struct _iJIT_Method_Update -{ - void* load_address; /**<\brief Start address of the update within a method */ - - unsigned int size; /**<\brief The update size */ - - iJIT_SegmentType type; /**<\brief Type of the update */ - - const char* data_format; /**<\brief C string that contains a format string - * that follows the same specifications as format in printf. - * The format string is used for iJIT_CT_CODE only - * and cannot be NULL. - * Format can be changed on the fly. */ -} *piJIT_Method_Update, iJIT_Method_Update; - -/** @endcond */ - -#pragma pack(pop) - -/** @cond exclude_from_documentation */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef CDECL -# if defined WIN32 || defined _WIN32 -# define CDECL __cdecl -# else /* defined WIN32 || defined _WIN32 */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86_64 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* defined WIN32 || defined _WIN32 */ -#endif /* CDECL */ - -#define JITAPI CDECL -/** @endcond */ - -/** - * @brief Generates a new unique method ID. - * - * You must use this API to obtain unique and valid method IDs for methods or - * traces reported to the agent if you don't have your own mechanism to generate - * unique method IDs. - * - * @return a new unique method ID. When out of unique method IDs, this API - * returns 0, which is not an accepted value. - */ -unsigned int JITAPI iJIT_GetNewMethodID(void); - -/** - * @brief Returns the current mode of the agent. - * - * @return iJIT_SAMPLING_ON, indicating that agent is running, or - * iJIT_NOTHING_RUNNING if no agent is running. - */ -iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); - -/** - * @brief Reports infomation about JIT-compiled code to the agent. - * - * The reported information is used to attribute samples obtained from any - * Intel(R) VTune(TM) Amplifier collector. This API needs to be called - * after JIT compilation and before the first entry into the JIT-compiled - * code. - * - * @param[in] event_type - type of the data sent to the agent - * @param[in] EventSpecificData - pointer to event-specific data - * - * @returns 1 on success, otherwise 0. - */ -int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/** @endcond */ - -/** @} jitapi group */ - -#endif /* __JITPROFILING_H__ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 __JITPROFILING_H__ +#define __JITPROFILING_H__ + +/** + * @brief JIT Profiling APIs + * + * The JIT Profiling API is used to report information about just-in-time + * generated code that can be used by performance tools. The user inserts + * calls in the code generator to report information before JIT-compiled + * code goes to execution. This information is collected at runtime and used + * by tools like Intel(R) VTune(TM) Amplifier to display performance metrics + * associated with JIT-compiled code. + * + * These APIs can be used to\n + * - **Profile trace-based and method-based JIT-compiled + * code**. Some examples of environments that you can profile with these APIs: + * dynamic JIT compilation of JavaScript code traces, JIT execution in OpenCL(TM) + * software technology, Java/.NET managed execution environments, and custom + * ISV JIT engines. + * @code + * #include + * + * if (iJIT_IsProfilingActive != iJIT_SAMPLING_ON) { + * return; + * } + * + * iJIT_Method_Load jmethod = {0}; + * jmethod.method_id = iJIT_GetNewMethodID(); + * jmethod.method_name = "method_name"; + * jmethod.class_file_name = "class_name"; + * jmethod.source_file_name = "source_file_name"; + * jmethod.method_load_address = code_addr; + * jmethod.method_size = code_size; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); + * @endcode + * + * * Expected behavior: + * * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an + * already reported method, then such a method becomes invalid and its + * memory region is treated as unloaded. VTune Amplifier displays the metrics + * collected by the method until it is overwritten. + * * If supplied line number information contains multiple source lines for + * the same assembly instruction (code location), then VTune Amplifier picks up + * the first line number. + * * Dynamically generated code can be associated with a module name. + * Use the iJIT_Method_Load_V2 structure.\n + * Clarification of some cases: + * * If you register a function with the same method ID multiple times, + * specifying different module names, then the VTune Amplifier picks up + * the module name registered first. If you want to distinguish the same + * function between different JIT engines, supply different method IDs for + * each function. Other symbolic information (for example, source file) + * can be identical. + * + * - **Analyze split functions** (multiple joint or disjoint code regions + * belonging to the same function) **including re-JIT** + * with potential overlapping of code regions in time, which is common in + * resource-limited environments. + * @code + * #include + * + * unsigned int method_id = iJIT_GetNewMethodID(); + * + * iJIT_Method_Load a = {0}; + * a.method_id = method_id; + * a.method_load_address = 0x100; + * a.method_size = 0x20; + * + * iJIT_Method_Load b = {0}; + * b.method_id = method_id; + * b.method_load_address = 0x200; + * b.method_size = 0x30; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&b); + * @endcode + * + * * Expected behaviour: + * * If a iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an + * already reported method, then such a method becomes invalid and + * its memory region is treated as unloaded. + * * All code regions reported with the same method ID are considered as + * belonging to the same method. Symbolic information (method name, + * source file name) will be taken from the first notification, and all + * subsequent notifications with the same method ID will be processed + * only for line number table information. So, the VTune Amplifier will map + * samples to a source line using the line number table from the current + * notification while taking the source file name from the very first one.\n + * Clarification of some cases:\n + * * If you register a second code region with a different source file + * name and the same method ID, then this information will be saved and + * will not be considered as an extension of the first code region, but + * VTune Amplifier will use the source file of the first code region and map + * performance metrics incorrectly. + * * If you register a second code region with the same source file as + * for the first region and the same method ID, then the source file will be + * discarded but VTune Amplifier will map metrics to the source file correctly. + * * If you register a second code region with a null source file and + * the same method ID, then provided line number info will be associated + * with the source file of the first code region. + * + * - **Explore inline functions** including multi-level hierarchy of + * nested inline methods which shows how performance metrics are distributed through them. + * @code + * #include + * + * // method_id parent_id + * // [-- c --] 3000 2000 + * // [---- d -----] 2001 1000 + * // [---- b ----] 2000 1000 + * // [------------ a ----------------] 1000 n/a + * + * iJIT_Method_Load a = {0}; + * a.method_id = 1000; + * + * iJIT_Method_Inline_Load b = {0}; + * b.method_id = 2000; + * b.parent_method_id = 1000; + * + * iJIT_Method_Inline_Load c = {0}; + * c.method_id = 3000; + * c.parent_method_id = 2000; + * + * iJIT_Method_Inline_Load d = {0}; + * d.method_id = 2001; + * d.parent_method_id = 1000; + * + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&a); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&b); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&c); + * iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, (void*)&d); + * @endcode + * + * * Requirements: + * * Each inline (iJIT_Method_Inline_Load) method should be associated + * with two method IDs: one for itself; one for its immediate parent. + * * Address regions of inline methods of the same parent method cannot + * overlap each other. + * * Execution of the parent method must not be started until it and all + * its inline methods are reported. + * * Expected behaviour: + * * In case of nested inline methods an order of + * iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED events is not important. + * * If any event overwrites either inline method or top parent method, + * then the parent, including inline methods, becomes invalid and its memory + * region is treated as unloaded. + * + * **Life time of allocated data**\n + * The client sends an event notification to the agent with event-specific + * data, which is a structure. The pointers in the structure refer to memory + * allocated by the client, which responsible for releasing it. The pointers are + * used by the iJIT_NotifyEvent method to copy client's data in a trace file, + * and they are not used after the iJIT_NotifyEvent method returns. + */ + +/** + * @defgroup jitapi JIT Profiling + * @ingroup internal + * @{ + */ + +/** + * @brief Enumerator for the types of notifications + */ +typedef enum iJIT_jvm_event +{ + iJVM_EVENT_TYPE_SHUTDOWN = 2, /**<\brief Send this to shutdown the agent. + * Use NULL for event data. */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED = 13, /**<\brief Send when dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load as event + * data. */ +/** @cond exclude_from_documentation */ + iJVM_EVENT_TYPE_METHOD_UNLOAD_START, /**<\brief Send when compiled dynamic + * code is being unloaded from memory. + * Use iJIT_Method_Load as event data.*/ +/** @endcond */ + + iJVM_EVENT_TYPE_METHOD_UPDATE, /**<\brief Send to provide new content for + * a previously reported dynamic code. + * The previous content will be invalidated + * starting from the time of the notification. + * Use iJIT_Method_Load as event data but + * required fields are following: + * - method_id identify the code to update. + * - method_load_address specify start address + * within identified code range + * where update should be started. + * - method_size specify length of updated code + * range. */ + + + iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED, /**<\brief Send when an inline dynamic + * code is JIT compiled and loaded + * into memory by the JIT engine, + * but before the parent code region + * starts executing. + * Use iJIT_Method_Inline_Load as event data.*/ + +/** @cond exclude_from_documentation */ + iJVM_EVENT_TYPE_METHOD_UPDATE_V2, +/** @endcond */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 = 21, /**<\brief Send when a dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load_V2 as event data. */ + + iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 /**<\brief Send when a dynamic code is + * JIT compiled and loaded into + * memory by the JIT engine, but + * before the code is executed. + * Use iJIT_Method_Load_V3 as event data. */ +} iJIT_JVM_EVENT; + +/** + * @brief Enumerator for the agent's mode + */ +typedef enum _iJIT_IsProfilingActiveFlags +{ + iJIT_NOTHING_RUNNING = 0x0000, /**<\brief The agent is not running; + * iJIT_NotifyEvent calls will + * not be processed. */ + iJIT_SAMPLING_ON = 0x0001, /**<\brief The agent is running and + * ready to process notifications. */ +} iJIT_IsProfilingActiveFlags; + +/** + * @brief Description of a single entry in the line number information of a code region. + * @details A table of line number entries gives information about how the reported code region + * is mapped to source file. + * Intel(R) VTune(TM) Amplifier uses line number information to attribute + * the samples (virtual address) to a line number. \n + * It is acceptable to report different code addresses for the same source line: + * @code + * Offset LineNumber + * 1 2 + * 12 4 + * 15 2 + * 18 1 + * 21 30 + * + * VTune Amplifier constructs the following table using the client data + * + * Code subrange Line number + * 0-1 2 + * 1-12 4 + * 12-15 2 + * 15-18 1 + * 18-21 30 + * @endcode + */ +typedef struct _LineNumberInfo +{ + unsigned int Offset; /**<\brief Offset from the begining of the code region. */ + unsigned int LineNumber; /**<\brief Matching source line number offset (from beginning of source file). */ + +} *pLineNumberInfo, LineNumberInfo; + +/** + * @brief Enumerator for the code architecture. + */ +typedef enum _iJIT_CodeArchitecture +{ + iJIT_CA_NATIVE = 0, /**<\brief Native to the process architecture that is calling it. */ + + iJIT_CA_32, /**<\brief 32-bit machine code. */ + + iJIT_CA_64 /**<\brief 64-bit machine code. */ + +} iJIT_CodeArchitecture; + +#pragma pack(push, 8) + +/** + * @brief Description of a JIT-compiled method + * @details When you use the iJIT_Method_Load structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise different + * method IDs specify different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, data provided with + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table.0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array */ + + unsigned int class_id; /**<\brief This field is obsolete. */ + + char* class_file_name; /**<\brief Class name. Can be NULL.*/ + + char* source_file_name; /**<\brief Source file name. Can be NULL.*/ + +} *piJIT_Method_Load, iJIT_Method_Load; + +/** + * @brief Description of a JIT-compiled method + * @details When you use the iJIT_Method_Load_V2 structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2 + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load_V2 +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise different + * method IDs specify different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, then data provided with the + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array. */ + + char* class_file_name; /**<\brief Class name. Can be NULL. */ + + char* source_file_name; /**<\brief Source file name. Can be NULL. */ + + char* module_name; /**<\brief Module name. Can be NULL. + The module name can be useful for distinguishing among + different JIT engines. VTune Amplifier will display + reported methods grouped by specific module. */ + +} *piJIT_Method_Load_V2, iJIT_Method_Load_V2; + +/** + * @brief Description of a JIT-compiled method + * @details The iJIT_Method_Load_V3 structure is the same as iJIT_Method_Load_V2 + * with a newly introduced 'arch' field that specifies architecture of the code region. + * When you use the iJIT_Method_Load_V3 structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3 + * as an event type to report it. + */ +typedef struct _iJIT_Method_Load_V3 +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or manage ID uniqueness + * and correct range by yourself.\n + * You must use the same method ID for all code + * regions of the same method, otherwise they are + * treated as regions of different methods. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Cannot be NULL. */ + + void* method_load_address; /**<\brief The start virtual address of the method code + * region. If NULL, then data provided with the + * event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array. */ + + char* class_file_name; /**<\brief Class name. Can be NULL. */ + + char* source_file_name; /**<\brief Source file name. Can be NULL. */ + + char* module_name; /**<\brief Module name. Can be NULL. + * The module name can be useful for distinguishing among + * different JIT engines. VTune Amplifier will display + * reported methods grouped by specific module. */ + + iJIT_CodeArchitecture module_arch; /**<\brief Architecture of the method's code region. + * By default, it is the same as the process + * architecture that is calling it. + * For example, you can use it if your 32-bit JIT + * engine generates 64-bit code. + * + * If JIT engine reports both 32-bit and 64-bit types + * of methods then VTune Amplifier splits the methods + * with the same module name but with different + * architectures in two different modules. VTune Amplifier + * modifies the original name provided with a 64-bit method + * version by ending it with '(64)' */ + +} *piJIT_Method_Load_V3, iJIT_Method_Load_V3; + +/** + * @brief Description of an inline JIT-compiled method + * @details When you use the_iJIT_Method_Inline_Load structure to describe + * the JIT compiled method, use iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED + * as an event type to report it. + */ +typedef struct _iJIT_Method_Inline_Load +{ + unsigned int method_id; /**<\brief Unique method ID. Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself. */ + + unsigned int parent_method_id; /**<\brief Unique immediate parent's method ID. + * Cannot be 0. + * You must either use the API function + * iJIT_GetNewMethodID to get a valid and unique + * method ID, or else manage ID uniqueness + * and correct range by yourself. */ + + char* method_name; /**<\brief The name of the method. It can be optionally + * prefixed with its class name and appended with + * its complete signature. Can't be NULL. */ + + void* method_load_address; /** <\brief The virtual address on which the method + * is inlined. If NULL, then data provided with + * the event are not accepted. */ + + unsigned int method_size; /**<\brief The code size of the method in memory. + * If 0, then data provided with the event are not + * accepted. */ + + unsigned int line_number_size; /**<\brief The number of entries in the line number + * table. 0 if none. */ + + pLineNumberInfo line_number_table; /**<\brief Pointer to the line numbers info + * array. Can be NULL if + * line_number_size is 0. See + * LineNumberInfo Structure for a + * description of a single entry in + * the line number info array */ + + char* class_file_name; /**<\brief Class name. Can be NULL.*/ + + char* source_file_name; /**<\brief Source file name. Can be NULL.*/ + +} *piJIT_Method_Inline_Load, iJIT_Method_Inline_Load; + +/** @cond exclude_from_documentation */ +/** + * @brief Description of a segment type + * @details Use the segment type to specify a type of data supplied + * with the iJVM_EVENT_TYPE_METHOD_UPDATE_V2 event to be applied to + * a certain code trace. + */ +typedef enum _iJIT_SegmentType +{ + iJIT_CT_UNKNOWN = 0, + + iJIT_CT_CODE, /**<\brief Executable code. */ + + iJIT_CT_DATA, /**<\brief Data (not executable code). + * VTune Amplifier uses the format string + * (see iJIT_Method_Update) to represent + * this data in the VTune Amplifier GUI */ + + iJIT_CT_KEEP, /**<\brief Use the previous markup for the trace. + * Can be used for the following + * iJVM_EVENT_TYPE_METHOD_UPDATE_V2 events, + * if the type of the previously reported segment + * type is the same. */ + iJIT_CT_EOF +} iJIT_SegmentType; + +/** + * @brief Description of a dynamic update of the content within JIT-compiled method + * @details The JIT engine may generate the methods that are updated at runtime + * partially by mixed (data + executable code) content. When you use the iJIT_Method_Update + * structure to describe the update of the content within a JIT-compiled method, + * use iJVM_EVENT_TYPE_METHOD_UPDATE_V2 as an event type to report it. + * + * On the first Update event, VTune Amplifier copies the original code range reported by + * the iJVM_EVENT_TYPE_METHOD_LOAD event, then modifies it with the supplied bytes and + * adds the modified range to the original method. For next update events, VTune Amplifier + * does the same but it uses the latest modified version of a code region for update. + * Eventually, VTune Amplifier GUI displays multiple code ranges for the method reported by + * the iJVM_EVENT_TYPE_METHOD_LOAD event. + * Notes: + * - Multiple update events with different types for the same trace are allowed + * but they must be reported for the same code ranges. + * Example, + * @code + * [-- data---] Allowed + * [-- code --] Allowed + * [code] Ignored + * [-- data---] Allowed + * [-- code --] Allowed + * [------------ trace ---------] + * @endcode + * - The types of previously reported events can be changed but they must be reported + * for the same code ranges. + * Example, + * @code + * [-- data---] Allowed + * [-- code --] Allowed + * [-- data---] Allowed + * [-- code --] Allowed + * [------------ trace ---------] + * @endcode + */ + +typedef struct _iJIT_Method_Update +{ + void* load_address; /**<\brief Start address of the update within a method */ + + unsigned int size; /**<\brief The update size */ + + iJIT_SegmentType type; /**<\brief Type of the update */ + + const char* data_format; /**<\brief C string that contains a format string + * that follows the same specifications as format in printf. + * The format string is used for iJIT_CT_CODE only + * and cannot be NULL. + * Format can be changed on the fly. */ +} *piJIT_Method_Update, iJIT_Method_Update; + +/** @endcond */ + +#pragma pack(pop) + +/** @cond exclude_from_documentation */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef CDECL +# if defined WIN32 || defined _WIN32 +# define CDECL __cdecl +# else /* defined WIN32 || defined _WIN32 */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86_64 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* defined WIN32 || defined _WIN32 */ +#endif /* CDECL */ + +#define JITAPI CDECL +/** @endcond */ + +/** + * @brief Generates a new unique method ID. + * + * You must use this API to obtain unique and valid method IDs for methods or + * traces reported to the agent if you don't have your own mechanism to generate + * unique method IDs. + * + * @return a new unique method ID. When out of unique method IDs, this API + * returns 0, which is not an accepted value. + */ +unsigned int JITAPI iJIT_GetNewMethodID(void); + +/** + * @brief Returns the current mode of the agent. + * + * @return iJIT_SAMPLING_ON, indicating that agent is running, or + * iJIT_NOTHING_RUNNING if no agent is running. + */ +iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void); + +/** + * @brief Reports infomation about JIT-compiled code to the agent. + * + * The reported information is used to attribute samples obtained from any + * Intel(R) VTune(TM) Amplifier collector. This API needs to be called + * after JIT compilation and before the first entry into the JIT-compiled + * code. + * + * @param[in] event_type - type of the data sent to the agent + * @param[in] EventSpecificData - pointer to event-specific data + * + * @returns 1 on success, otherwise 0. + */ +int JITAPI iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/** @endcond */ + +/** @} jitapi group */ + +#endif /* __JITPROFILING_H__ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/legacy/ittnotify.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/legacy/ittnotify.h index b40a5f9244..0d873c9f26 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/legacy/ittnotify.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/legacy/ittnotify.h @@ -1,1039 +1,1039 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _LEGACY_ITTNOTIFY_H_ -#define _LEGACY_ITTNOTIFY_H_ - -/** - * @file - * @brief Legacy User API functions and types - */ - -/** @cond exclude_from_documentation */ -#ifndef ITT_OS_WIN -# define ITT_OS_WIN 1 -#endif /* ITT_OS_WIN */ - -#ifndef ITT_OS_LINUX -# define ITT_OS_LINUX 2 -#endif /* ITT_OS_LINUX */ - -#ifndef ITT_OS_MAC -# define ITT_OS_MAC 3 -#endif /* ITT_OS_MAC */ - -#ifndef ITT_OS_FREEBSD -# define ITT_OS_FREEBSD 4 -#endif /* ITT_OS_FREEBSD */ - -#ifndef ITT_OS -# if defined WIN32 || defined _WIN32 -# define ITT_OS ITT_OS_WIN -# elif defined( __APPLE__ ) && defined( __MACH__ ) -# define ITT_OS ITT_OS_MAC -# elif defined( __FreeBSD__ ) -# define ITT_OS ITT_OS_FREEBSD -# else -# define ITT_OS ITT_OS_LINUX -# endif -#endif /* ITT_OS */ - -#ifndef ITT_PLATFORM_WIN -# define ITT_PLATFORM_WIN 1 -#endif /* ITT_PLATFORM_WIN */ - -#ifndef ITT_PLATFORM_POSIX -# define ITT_PLATFORM_POSIX 2 -#endif /* ITT_PLATFORM_POSIX */ - -#ifndef ITT_PLATFORM_MAC -# define ITT_PLATFORM_MAC 3 -#endif /* ITT_PLATFORM_MAC */ - -#ifndef ITT_PLATFORM_FREEBSD -# define ITT_PLATFORM_FREEBSD 4 -#endif /* ITT_PLATFORM_FREEBSD */ - -#ifndef ITT_PLATFORM -# if ITT_OS==ITT_OS_WIN -# define ITT_PLATFORM ITT_PLATFORM_WIN -# elif ITT_OS==ITT_OS_MAC -# define ITT_PLATFORM ITT_PLATFORM_MAC -# elif ITT_OS==ITT_OS_FREEBSD -# define ITT_PLATFORM ITT_PLATFORM_FREEBSD -# else -# define ITT_PLATFORM ITT_PLATFORM_POSIX -# endif -#endif /* ITT_PLATFORM */ - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif - -#include -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE || _UNICODE */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef CDECL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define CDECL __cdecl -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* CDECL */ - -#ifndef STDCALL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define STDCALL __stdcall -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define STDCALL __attribute__ ((stdcall)) -# else /* _M_IX86 || __i386__ */ -# define STDCALL /* supported only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* STDCALL */ - -#define ITTAPI CDECL -#define LIBITTAPI CDECL - -/* TODO: Temporary for compatibility! */ -#define ITTAPI_CALL CDECL -#define LIBITTAPI_CALL CDECL - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -/* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline -#define ITT_INLINE_ATTRIBUTE /* nothing */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/* - * Generally, functions are not inlined unless optimization is specified. - * For functions declared inline, this attribute inlines the function even - * if no optimization level was specified. - */ -#ifdef __STRICT_ANSI__ -#define ITT_INLINE static -#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) -#else /* __STRICT_ANSI__ */ -#define ITT_INLINE static inline -#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) -#endif /* __STRICT_ANSI__ */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/** @endcond */ - -/** @cond exclude_from_documentation */ -/* Helper macro for joining tokens */ -#define ITT_JOIN_AUX(p,n) p##n -#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) - -#ifdef ITT_MAJOR -#undef ITT_MAJOR -#endif -#ifdef ITT_MINOR -#undef ITT_MINOR -#endif -#define ITT_MAJOR 3 -#define ITT_MINOR 0 - -/* Standard versioning of a token with major and minor version numbers */ -#define ITT_VERSIONIZE(x) \ - ITT_JOIN(x, \ - ITT_JOIN(_, \ - ITT_JOIN(ITT_MAJOR, \ - ITT_JOIN(_, ITT_MINOR)))) - -#ifndef INTEL_ITTNOTIFY_PREFIX -# define INTEL_ITTNOTIFY_PREFIX __itt_ -#endif /* INTEL_ITTNOTIFY_PREFIX */ -#ifndef INTEL_ITTNOTIFY_POSTFIX -# define INTEL_ITTNOTIFY_POSTFIX _ptr_ -#endif /* INTEL_ITTNOTIFY_POSTFIX */ - -#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) -#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) - -#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) -#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) - -#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) -#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) - -#ifdef ITT_STUB -#undef ITT_STUB -#endif -#ifdef ITT_STUBV -#undef ITT_STUBV -#endif -#define ITT_STUBV(api,type,name,args) \ - typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ - extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); -#define ITT_STUB ITT_STUBV -/** @endcond */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup legacy Legacy API - * @{ - * @} - */ - -/** - * @defgroup legacy_control Collection Control - * @ingroup legacy - * General behavior: application continues to run, but no profiling information is being collected - * - * Pausing occurs not only for the current thread but for all process as well as spawned processes - * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: - * - Does not analyze or report errors that involve memory access. - * - Other errors are reported as usual. Pausing data collection in - * Intel(R) Parallel Inspector and Intel(R) Inspector XE - * only pauses tracing and analyzing memory access. - * It does not pause tracing or analyzing threading APIs. - * . - * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: - * - Does continue to record when new threads are started. - * . - * - Other effects: - * - Possible reduction of runtime overhead. - * . - * @{ - */ -#ifndef _ITTNOTIFY_H_ -/** @brief Pause collection */ -void ITTAPI __itt_pause(void); -/** @brief Resume collection */ -void ITTAPI __itt_resume(void); -/** @brief Detach collection */ -void ITTAPI __itt_detach(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, pause, (void)) -ITT_STUBV(ITTAPI, void, resume, (void)) -ITT_STUBV(ITTAPI, void, detach, (void)) -#define __itt_pause ITTNOTIFY_VOID(pause) -#define __itt_pause_ptr ITTNOTIFY_NAME(pause) -#define __itt_resume ITTNOTIFY_VOID(resume) -#define __itt_resume_ptr ITTNOTIFY_NAME(resume) -#define __itt_detach ITTNOTIFY_VOID(detach) -#define __itt_detach_ptr ITTNOTIFY_NAME(detach) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_pause() -#define __itt_pause_ptr 0 -#define __itt_resume() -#define __itt_resume_ptr 0 -#define __itt_detach() -#define __itt_detach_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_pause_ptr 0 -#define __itt_resume_ptr 0 -#define __itt_detach_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -#endif /* _ITTNOTIFY_H_ */ -/** @} legacy_control group */ - -/** - * @defgroup legacy_threads Threads - * @ingroup legacy - * Threads group - * @warning Legacy API - * @{ - */ -/** - * @deprecated Legacy API - * @brief Set name to be associated with thread in analysis GUI. - * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -int LIBITTAPI __itt_thr_name_setA(const char *name, int namelen); -int LIBITTAPI __itt_thr_name_setW(const wchar_t *name, int namelen); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_thr_name_set __itt_thr_name_setW -# define __itt_thr_name_set_ptr __itt_thr_name_setW_ptr -#else -# define __itt_thr_name_set __itt_thr_name_setA -# define __itt_thr_name_set_ptr __itt_thr_name_setA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -int LIBITTAPI __itt_thr_name_set(const char *name, int namelen); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen)) -ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thr_name_setA ITTNOTIFY_DATA(thr_name_setA) -#define __itt_thr_name_setA_ptr ITTNOTIFY_NAME(thr_name_setA) -#define __itt_thr_name_setW ITTNOTIFY_DATA(thr_name_setW) -#define __itt_thr_name_setW_ptr ITTNOTIFY_NAME(thr_name_setW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thr_name_set ITTNOTIFY_DATA(thr_name_set) -#define __itt_thr_name_set_ptr ITTNOTIFY_NAME(thr_name_set) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thr_name_setA(name, namelen) -#define __itt_thr_name_setA_ptr 0 -#define __itt_thr_name_setW(name, namelen) -#define __itt_thr_name_setW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thr_name_set(name, namelen) -#define __itt_thr_name_set_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_thr_name_setA_ptr 0 -#define __itt_thr_name_setW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_thr_name_set_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Mark current thread as ignored from this point on, for the duration of its existence. - */ -void LIBITTAPI __itt_thr_ignore(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, thr_ignore, (void)) -#define __itt_thr_ignore ITTNOTIFY_VOID(thr_ignore) -#define __itt_thr_ignore_ptr ITTNOTIFY_NAME(thr_ignore) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_thr_ignore() -#define __itt_thr_ignore_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_thr_ignore_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} legacy_threads group */ - -/** - * @defgroup legacy_sync Synchronization - * @ingroup legacy - * Synchronization group - * @warning Legacy API - * @{ - */ -/** - * @hideinitializer - * @brief possible value of attribute argument for sync object type - */ -#define __itt_attr_barrier 1 - -/** - * @hideinitializer - * @brief possible value of attribute argument for sync object type - */ -#define __itt_attr_mutex 2 - -/** - * @deprecated Legacy API - * @brief Assign a name to a sync object using char or Unicode string - * @param[in] addr - pointer to the sync object. You should use a real pointer to your object - * to make sure that the values don't clash with other object addresses - * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will - * be assumed to be of generic "User Synchronization" type - * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned - * to the object -- you can use the __itt_sync_rename call later to assign - * the name - * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the - * exact semantics of how prepare/acquired/releasing calls work. - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -void ITTAPI __itt_sync_set_nameA(void *addr, const char *objtype, const char *objname, int attribute); -void ITTAPI __itt_sync_set_nameW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_sync_set_name __itt_sync_set_nameW -# define __itt_sync_set_name_ptr __itt_sync_set_nameW_ptr -#else /* UNICODE */ -# define __itt_sync_set_name __itt_sync_set_nameA -# define __itt_sync_set_name_ptr __itt_sync_set_nameA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -void ITTAPI __itt_sync_set_name(void *addr, const char* objtype, const char* objname, int attribute); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute)) -ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_set_nameA ITTNOTIFY_VOID(sync_set_nameA) -#define __itt_sync_set_nameA_ptr ITTNOTIFY_NAME(sync_set_nameA) -#define __itt_sync_set_nameW ITTNOTIFY_VOID(sync_set_nameW) -#define __itt_sync_set_nameW_ptr ITTNOTIFY_NAME(sync_set_nameW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_set_name ITTNOTIFY_VOID(sync_set_name) -#define __itt_sync_set_name_ptr ITTNOTIFY_NAME(sync_set_name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_set_nameA(addr, objtype, objname, attribute) -#define __itt_sync_set_nameA_ptr 0 -#define __itt_sync_set_nameW(addr, objtype, objname, attribute) -#define __itt_sync_set_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_set_name(addr, objtype, objname, attribute) -#define __itt_sync_set_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_sync_set_nameA_ptr 0 -#define __itt_sync_set_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_sync_set_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Assign a name and type to a sync object using char or Unicode string - * @param[in] addr - pointer to the sync object. You should use a real pointer to your object - * to make sure that the values don't clash with other object addresses - * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will - * be assumed to be of generic "User Synchronization" type - * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned - * to the object -- you can use the __itt_sync_rename call later to assign - * the name - * @param[in] typelen, namelen - a length of string for appropriate objtype and objname parameter - * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the - * exact semantics of how prepare/acquired/releasing calls work. - * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -int LIBITTAPI __itt_notify_sync_nameA(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); -int LIBITTAPI __itt_notify_sync_nameW(void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_notify_sync_name __itt_notify_sync_nameW -#else -# define __itt_notify_sync_name __itt_notify_sync_nameA -#endif -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -int LIBITTAPI __itt_notify_sync_name(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) -ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_notify_sync_nameA ITTNOTIFY_DATA(notify_sync_nameA) -#define __itt_notify_sync_nameA_ptr ITTNOTIFY_NAME(notify_sync_nameA) -#define __itt_notify_sync_nameW ITTNOTIFY_DATA(notify_sync_nameW) -#define __itt_notify_sync_nameW_ptr ITTNOTIFY_NAME(notify_sync_nameW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_notify_sync_name ITTNOTIFY_DATA(notify_sync_name) -#define __itt_notify_sync_name_ptr ITTNOTIFY_NAME(notify_sync_name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_notify_sync_nameA(addr, objtype, typelen, objname, namelen, attribute) -#define __itt_notify_sync_nameA_ptr 0 -#define __itt_notify_sync_nameW(addr, objtype, typelen, objname, namelen, attribute) -#define __itt_notify_sync_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_notify_sync_name(addr, objtype, typelen, objname, namelen, attribute) -#define __itt_notify_sync_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_notify_sync_nameA_ptr 0 -#define __itt_notify_sync_nameW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_notify_sync_name_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Enter spin loop on user-defined sync object - */ -void LIBITTAPI __itt_notify_sync_prepare(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *addr)) -#define __itt_notify_sync_prepare ITTNOTIFY_VOID(notify_sync_prepare) -#define __itt_notify_sync_prepare_ptr ITTNOTIFY_NAME(notify_sync_prepare) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_notify_sync_prepare(addr) -#define __itt_notify_sync_prepare_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_notify_sync_prepare_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Quit spin loop without acquiring spin object - */ -void LIBITTAPI __itt_notify_sync_cancel(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *addr)) -#define __itt_notify_sync_cancel ITTNOTIFY_VOID(notify_sync_cancel) -#define __itt_notify_sync_cancel_ptr ITTNOTIFY_NAME(notify_sync_cancel) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_notify_sync_cancel(addr) -#define __itt_notify_sync_cancel_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_notify_sync_cancel_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Successful spin loop completion (sync object acquired) - */ -void LIBITTAPI __itt_notify_sync_acquired(void *addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *addr)) -#define __itt_notify_sync_acquired ITTNOTIFY_VOID(notify_sync_acquired) -#define __itt_notify_sync_acquired_ptr ITTNOTIFY_NAME(notify_sync_acquired) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_notify_sync_acquired(addr) -#define __itt_notify_sync_acquired_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_notify_sync_acquired_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Start sync object releasing code. Is called before the lock release call. - */ -void LIBITTAPI __itt_notify_sync_releasing(void* addr); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *addr)) -#define __itt_notify_sync_releasing ITTNOTIFY_VOID(notify_sync_releasing) -#define __itt_notify_sync_releasing_ptr ITTNOTIFY_NAME(notify_sync_releasing) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_notify_sync_releasing(addr) -#define __itt_notify_sync_releasing_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_notify_sync_releasing_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} legacy_sync group */ - -#ifndef _ITTNOTIFY_H_ -/** - * @defgroup legacy_events Events - * @ingroup legacy - * Events group - * @{ - */ - -/** @brief user event type */ -typedef int __itt_event; - -/** - * @brief Create an event notification - * @note name or namelen being null/name and namelen not matching, user event feature not enabled - * @return non-zero event identifier upon success and __itt_err otherwise - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); -__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_event_create __itt_event_createW -# define __itt_event_create_ptr __itt_event_createW_ptr -#else -# define __itt_event_create __itt_event_createA -# define __itt_event_create_ptr __itt_event_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) -ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA ITTNOTIFY_DATA(event_createA) -#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) -#define __itt_event_createW ITTNOTIFY_DATA(event_createW) -#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create ITTNOTIFY_DATA(event_create) -#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA(name, namelen) (__itt_event)0 -#define __itt_event_createA_ptr 0 -#define __itt_event_createW(name, namelen) (__itt_event)0 -#define __itt_event_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create(name, namelen) (__itt_event)0 -#define __itt_event_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_event_createA_ptr 0 -#define __itt_event_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_event_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an event occurrence. - * @return __itt_err upon failure (invalid event id/user event feature not enabled) - */ -int LIBITTAPI __itt_event_start(__itt_event event); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) -#define __itt_event_start ITTNOTIFY_DATA(event_start) -#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_event_start(event) (int)0 -#define __itt_event_start_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_event_start_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @brief Record an event end occurrence. - * @note It is optional if events do not have durations. - * @return __itt_err upon failure (invalid event id/user event feature not enabled) - */ -int LIBITTAPI __itt_event_end(__itt_event event); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) -#define __itt_event_end ITTNOTIFY_DATA(event_end) -#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_event_end(event) (int)0 -#define __itt_event_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_event_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} legacy_events group */ -#endif /* _ITTNOTIFY_H_ */ - -/** - * @defgroup legacy_memory Memory Accesses - * @ingroup legacy - */ - -/** - * @deprecated Legacy API - * @brief Inform the tool of memory accesses on reading - */ -void LIBITTAPI __itt_memory_read(void *addr, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size)) -#define __itt_memory_read ITTNOTIFY_VOID(memory_read) -#define __itt_memory_read_ptr ITTNOTIFY_NAME(memory_read) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_memory_read(addr, size) -#define __itt_memory_read_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_memory_read_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Inform the tool of memory accesses on writing - */ -void LIBITTAPI __itt_memory_write(void *addr, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size)) -#define __itt_memory_write ITTNOTIFY_VOID(memory_write) -#define __itt_memory_write_ptr ITTNOTIFY_NAME(memory_write) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_memory_write(addr, size) -#define __itt_memory_write_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_memory_write_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief Inform the tool of memory accesses on updating - */ -void LIBITTAPI __itt_memory_update(void *address, size_t size); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size)) -#define __itt_memory_update ITTNOTIFY_VOID(memory_update) -#define __itt_memory_update_ptr ITTNOTIFY_NAME(memory_update) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_memory_update(addr, size) -#define __itt_memory_update_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_memory_update_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} legacy_memory group */ - -/** - * @defgroup legacy_state Thread and Object States - * @ingroup legacy - */ - -/** @brief state type */ -typedef int __itt_state_t; - -/** @cond exclude_from_documentation */ -typedef enum __itt_obj_state { - __itt_obj_state_err = 0, - __itt_obj_state_clr = 1, - __itt_obj_state_set = 2, - __itt_obj_state_use = 3 -} __itt_obj_state_t; - -typedef enum __itt_thr_state { - __itt_thr_state_err = 0, - __itt_thr_state_clr = 1, - __itt_thr_state_set = 2 -} __itt_thr_state_t; - -typedef enum __itt_obj_prop { - __itt_obj_prop_watch = 1, - __itt_obj_prop_ignore = 2, - __itt_obj_prop_sharable = 3 -} __itt_obj_prop_t; - -typedef enum __itt_thr_prop { - __itt_thr_prop_quiet = 1 -} __itt_thr_prop_t; -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief managing thread and object states - */ -__itt_state_t LIBITTAPI __itt_state_get(void); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_state_t, state_get, (void)) -#define __itt_state_get ITTNOTIFY_DATA(state_get) -#define __itt_state_get_ptr ITTNOTIFY_NAME(state_get) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_state_get(void) (__itt_state_t)0 -#define __itt_state_get_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_state_get_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief managing thread and object states - */ -__itt_state_t LIBITTAPI __itt_state_set(__itt_state_t s); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_state_t, state_set, (__itt_state_t s)) -#define __itt_state_set ITTNOTIFY_DATA(state_set) -#define __itt_state_set_ptr ITTNOTIFY_NAME(state_set) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_state_set(s) (__itt_state_t)0 -#define __itt_state_set_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_state_set_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief managing thread and object modes - */ -__itt_thr_state_t LIBITTAPI __itt_thr_mode_set(__itt_thr_prop_t p, __itt_thr_state_t s); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s)) -#define __itt_thr_mode_set ITTNOTIFY_DATA(thr_mode_set) -#define __itt_thr_mode_set_ptr ITTNOTIFY_NAME(thr_mode_set) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_thr_mode_set(p, s) (__itt_thr_state_t)0 -#define __itt_thr_mode_set_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_thr_mode_set_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** - * @deprecated Legacy API - * @brief managing thread and object modes - */ -__itt_obj_state_t LIBITTAPI __itt_obj_mode_set(__itt_obj_prop_t p, __itt_obj_state_t s); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUB(ITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s)) -#define __itt_obj_mode_set ITTNOTIFY_DATA(obj_mode_set) -#define __itt_obj_mode_set_ptr ITTNOTIFY_NAME(obj_mode_set) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_obj_mode_set(p, s) (__itt_obj_state_t)0 -#define __itt_obj_mode_set_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_obj_mode_set_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} legacy_state group */ - -/** - * @defgroup frames Frames - * @ingroup legacy - * Frames group - * @{ - */ -/** - * @brief opaque structure for frame identification - */ -typedef struct __itt_frame_t *__itt_frame; - -/** - * @brief Create a global frame with given domain - */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -__itt_frame ITTAPI __itt_frame_createA(const char *domain); -__itt_frame ITTAPI __itt_frame_createW(const wchar_t *domain); -#if defined(UNICODE) || defined(_UNICODE) -# define __itt_frame_create __itt_frame_createW -# define __itt_frame_create_ptr __itt_frame_createW_ptr -#else /* UNICODE */ -# define __itt_frame_create __itt_frame_createA -# define __itt_frame_create_ptr __itt_frame_createA_ptr -#endif /* UNICODE */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -__itt_frame ITTAPI __itt_frame_create(const char *domain); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain)) -ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain)) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain)) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_frame_createA ITTNOTIFY_DATA(frame_createA) -#define __itt_frame_createA_ptr ITTNOTIFY_NAME(frame_createA) -#define __itt_frame_createW ITTNOTIFY_DATA(frame_createW) -#define __itt_frame_createW_ptr ITTNOTIFY_NAME(frame_createW) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_frame_create ITTNOTIFY_DATA(frame_create) -#define __itt_frame_create_ptr ITTNOTIFY_NAME(frame_create) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#else /* INTEL_NO_ITTNOTIFY_API */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_frame_createA(domain) -#define __itt_frame_createA_ptr 0 -#define __itt_frame_createW(domain) -#define __itt_frame_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_frame_create(domain) -#define __itt_frame_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_frame_createA_ptr 0 -#define __itt_frame_createW_ptr 0 -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#define __itt_frame_create_ptr 0 -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ - -/** @brief Record an frame begin occurrence. */ -void ITTAPI __itt_frame_begin(__itt_frame frame); -/** @brief Record an frame end occurrence. */ -void ITTAPI __itt_frame_end (__itt_frame frame); - -/** @cond exclude_from_documentation */ -#ifndef INTEL_NO_MACRO_BODY -#ifndef INTEL_NO_ITTNOTIFY_API -ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame)) -ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame)) -#define __itt_frame_begin ITTNOTIFY_VOID(frame_begin) -#define __itt_frame_begin_ptr ITTNOTIFY_NAME(frame_begin) -#define __itt_frame_end ITTNOTIFY_VOID(frame_end) -#define __itt_frame_end_ptr ITTNOTIFY_NAME(frame_end) -#else /* INTEL_NO_ITTNOTIFY_API */ -#define __itt_frame_begin(frame) -#define __itt_frame_begin_ptr 0 -#define __itt_frame_end(frame) -#define __itt_frame_end_ptr 0 -#endif /* INTEL_NO_ITTNOTIFY_API */ -#else /* INTEL_NO_MACRO_BODY */ -#define __itt_frame_begin_ptr 0 -#define __itt_frame_end_ptr 0 -#endif /* INTEL_NO_MACRO_BODY */ -/** @endcond */ -/** @} frames group */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _LEGACY_ITTNOTIFY_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _LEGACY_ITTNOTIFY_H_ +#define _LEGACY_ITTNOTIFY_H_ + +/** + * @file + * @brief Legacy User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup legacy Legacy API + * @{ + * @} + */ + +/** + * @defgroup legacy_control Collection Control + * @ingroup legacy + * General behavior: application continues to run, but no profiling information is being collected + * + * Pausing occurs not only for the current thread but for all process as well as spawned processes + * - Intel(R) Parallel Inspector and Intel(R) Inspector XE: + * - Does not analyze or report errors that involve memory access. + * - Other errors are reported as usual. Pausing data collection in + * Intel(R) Parallel Inspector and Intel(R) Inspector XE + * only pauses tracing and analyzing memory access. + * It does not pause tracing or analyzing threading APIs. + * . + * - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE: + * - Does continue to record when new threads are started. + * . + * - Other effects: + * - Possible reduction of runtime overhead. + * . + * @{ + */ +#ifndef _ITTNOTIFY_H_ +/** @brief Pause collection */ +void ITTAPI __itt_pause(void); +/** @brief Resume collection */ +void ITTAPI __itt_resume(void); +/** @brief Detach collection */ +void ITTAPI __itt_detach(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, pause, (void)) +ITT_STUBV(ITTAPI, void, resume, (void)) +ITT_STUBV(ITTAPI, void, detach, (void)) +#define __itt_pause ITTNOTIFY_VOID(pause) +#define __itt_pause_ptr ITTNOTIFY_NAME(pause) +#define __itt_resume ITTNOTIFY_VOID(resume) +#define __itt_resume_ptr ITTNOTIFY_NAME(resume) +#define __itt_detach ITTNOTIFY_VOID(detach) +#define __itt_detach_ptr ITTNOTIFY_NAME(detach) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_pause() +#define __itt_pause_ptr 0 +#define __itt_resume() +#define __itt_resume_ptr 0 +#define __itt_detach() +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_pause_ptr 0 +#define __itt_resume_ptr 0 +#define __itt_detach_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +#endif /* _ITTNOTIFY_H_ */ +/** @} legacy_control group */ + +/** + * @defgroup legacy_threads Threads + * @ingroup legacy + * Threads group + * @warning Legacy API + * @{ + */ +/** + * @deprecated Legacy API + * @brief Set name to be associated with thread in analysis GUI. + * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int LIBITTAPI __itt_thr_name_setA(const char *name, int namelen); +int LIBITTAPI __itt_thr_name_setW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_thr_name_set __itt_thr_name_setW +# define __itt_thr_name_set_ptr __itt_thr_name_setW_ptr +#else +# define __itt_thr_name_set __itt_thr_name_setA +# define __itt_thr_name_set_ptr __itt_thr_name_setA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int LIBITTAPI __itt_thr_name_set(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA ITTNOTIFY_DATA(thr_name_setA) +#define __itt_thr_name_setA_ptr ITTNOTIFY_NAME(thr_name_setA) +#define __itt_thr_name_setW ITTNOTIFY_DATA(thr_name_setW) +#define __itt_thr_name_setW_ptr ITTNOTIFY_NAME(thr_name_setW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set ITTNOTIFY_DATA(thr_name_set) +#define __itt_thr_name_set_ptr ITTNOTIFY_NAME(thr_name_set) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA(name, namelen) +#define __itt_thr_name_setA_ptr 0 +#define __itt_thr_name_setW(name, namelen) +#define __itt_thr_name_setW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set(name, namelen) +#define __itt_thr_name_set_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_thr_name_setA_ptr 0 +#define __itt_thr_name_setW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_thr_name_set_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Mark current thread as ignored from this point on, for the duration of its existence. + */ +void LIBITTAPI __itt_thr_ignore(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, thr_ignore, (void)) +#define __itt_thr_ignore ITTNOTIFY_VOID(thr_ignore) +#define __itt_thr_ignore_ptr ITTNOTIFY_NAME(thr_ignore) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thr_ignore() +#define __itt_thr_ignore_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thr_ignore_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_threads group */ + +/** + * @defgroup legacy_sync Synchronization + * @ingroup legacy + * Synchronization group + * @warning Legacy API + * @{ + */ +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_barrier 1 + +/** + * @hideinitializer + * @brief possible value of attribute argument for sync object type + */ +#define __itt_attr_mutex 2 + +/** + * @deprecated Legacy API + * @brief Assign a name to a sync object using char or Unicode string + * @param[in] addr - pointer to the sync object. You should use a real pointer to your object + * to make sure that the values don't clash with other object addresses + * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will + * be assumed to be of generic "User Synchronization" type + * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned + * to the object -- you can use the __itt_sync_rename call later to assign + * the name + * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the + * exact semantics of how prepare/acquired/releasing calls work. + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +void ITTAPI __itt_sync_set_nameA(void *addr, const char *objtype, const char *objname, int attribute); +void ITTAPI __itt_sync_set_nameW(void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_sync_set_name __itt_sync_set_nameW +# define __itt_sync_set_name_ptr __itt_sync_set_nameW_ptr +#else /* UNICODE */ +# define __itt_sync_set_name __itt_sync_set_nameA +# define __itt_sync_set_name_ptr __itt_sync_set_nameA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +void ITTAPI __itt_sync_set_name(void *addr, const char* objtype, const char* objname, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute)) +ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA ITTNOTIFY_VOID(sync_set_nameA) +#define __itt_sync_set_nameA_ptr ITTNOTIFY_NAME(sync_set_nameA) +#define __itt_sync_set_nameW ITTNOTIFY_VOID(sync_set_nameW) +#define __itt_sync_set_nameW_ptr ITTNOTIFY_NAME(sync_set_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name ITTNOTIFY_VOID(sync_set_name) +#define __itt_sync_set_name_ptr ITTNOTIFY_NAME(sync_set_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA(addr, objtype, objname, attribute) +#define __itt_sync_set_nameA_ptr 0 +#define __itt_sync_set_nameW(addr, objtype, objname, attribute) +#define __itt_sync_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name(addr, objtype, objname, attribute) +#define __itt_sync_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_sync_set_nameA_ptr 0 +#define __itt_sync_set_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_sync_set_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Assign a name and type to a sync object using char or Unicode string + * @param[in] addr - pointer to the sync object. You should use a real pointer to your object + * to make sure that the values don't clash with other object addresses + * @param[in] objtype - null-terminated object type string. If NULL is passed, the object will + * be assumed to be of generic "User Synchronization" type + * @param[in] objname - null-terminated object name string. If NULL, no name will be assigned + * to the object -- you can use the __itt_sync_rename call later to assign + * the name + * @param[in] typelen, namelen - a length of string for appropriate objtype and objname parameter + * @param[in] attribute - one of [#__itt_attr_barrier, #__itt_attr_mutex] values which defines the + * exact semantics of how prepare/acquired/releasing calls work. + * @return __itt_err upon failure (name or namelen being null,name and namelen mismatched) + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +int LIBITTAPI __itt_notify_sync_nameA(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); +int LIBITTAPI __itt_notify_sync_nameW(void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_notify_sync_name __itt_notify_sync_nameW +#else +# define __itt_notify_sync_name __itt_notify_sync_nameA +#endif +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +int LIBITTAPI __itt_notify_sync_name(void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) +ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *addr, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *addr, const char *objtype, int typelen, const char *objname, int namelen, int attribute)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA ITTNOTIFY_DATA(notify_sync_nameA) +#define __itt_notify_sync_nameA_ptr ITTNOTIFY_NAME(notify_sync_nameA) +#define __itt_notify_sync_nameW ITTNOTIFY_DATA(notify_sync_nameW) +#define __itt_notify_sync_nameW_ptr ITTNOTIFY_NAME(notify_sync_nameW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name ITTNOTIFY_DATA(notify_sync_name) +#define __itt_notify_sync_name_ptr ITTNOTIFY_NAME(notify_sync_name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_nameA_ptr 0 +#define __itt_notify_sync_nameW(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name(addr, objtype, typelen, objname, namelen, attribute) +#define __itt_notify_sync_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_notify_sync_nameA_ptr 0 +#define __itt_notify_sync_nameW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_notify_sync_name_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Enter spin loop on user-defined sync object + */ +void LIBITTAPI __itt_notify_sync_prepare(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *addr)) +#define __itt_notify_sync_prepare ITTNOTIFY_VOID(notify_sync_prepare) +#define __itt_notify_sync_prepare_ptr ITTNOTIFY_NAME(notify_sync_prepare) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_prepare(addr) +#define __itt_notify_sync_prepare_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_prepare_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Quit spin loop without acquiring spin object + */ +void LIBITTAPI __itt_notify_sync_cancel(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *addr)) +#define __itt_notify_sync_cancel ITTNOTIFY_VOID(notify_sync_cancel) +#define __itt_notify_sync_cancel_ptr ITTNOTIFY_NAME(notify_sync_cancel) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_cancel(addr) +#define __itt_notify_sync_cancel_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_cancel_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Successful spin loop completion (sync object acquired) + */ +void LIBITTAPI __itt_notify_sync_acquired(void *addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *addr)) +#define __itt_notify_sync_acquired ITTNOTIFY_VOID(notify_sync_acquired) +#define __itt_notify_sync_acquired_ptr ITTNOTIFY_NAME(notify_sync_acquired) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_acquired(addr) +#define __itt_notify_sync_acquired_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_acquired_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Start sync object releasing code. Is called before the lock release call. + */ +void LIBITTAPI __itt_notify_sync_releasing(void* addr); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *addr)) +#define __itt_notify_sync_releasing ITTNOTIFY_VOID(notify_sync_releasing) +#define __itt_notify_sync_releasing_ptr ITTNOTIFY_NAME(notify_sync_releasing) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_notify_sync_releasing(addr) +#define __itt_notify_sync_releasing_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_notify_sync_releasing_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_sync group */ + +#ifndef _ITTNOTIFY_H_ +/** + * @defgroup legacy_events Events + * @ingroup legacy + * Events group + * @{ + */ + +/** @brief user event type */ +typedef int __itt_event; + +/** + * @brief Create an event notification + * @note name or namelen being null/name and namelen not matching, user event feature not enabled + * @return non-zero event identifier upon success and __itt_err otherwise + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_event LIBITTAPI __itt_event_createA(const char *name, int namelen); +__itt_event LIBITTAPI __itt_event_createW(const wchar_t *name, int namelen); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_event_create __itt_event_createW +# define __itt_event_create_ptr __itt_event_createW_ptr +#else +# define __itt_event_create __itt_event_createA +# define __itt_event_create_ptr __itt_event_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_event LIBITTAPI __itt_event_create(const char *name, int namelen); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen)) +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA ITTNOTIFY_DATA(event_createA) +#define __itt_event_createA_ptr ITTNOTIFY_NAME(event_createA) +#define __itt_event_createW ITTNOTIFY_DATA(event_createW) +#define __itt_event_createW_ptr ITTNOTIFY_NAME(event_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create ITTNOTIFY_DATA(event_create) +#define __itt_event_create_ptr ITTNOTIFY_NAME(event_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA(name, namelen) (__itt_event)0 +#define __itt_event_createA_ptr 0 +#define __itt_event_createW(name, namelen) (__itt_event)0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create(name, namelen) (__itt_event)0 +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_event_createA_ptr 0 +#define __itt_event_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_event_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event occurrence. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_start(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event)) +#define __itt_event_start ITTNOTIFY_DATA(event_start) +#define __itt_event_start_ptr ITTNOTIFY_NAME(event_start) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_start(event) (int)0 +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_start_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @brief Record an event end occurrence. + * @note It is optional if events do not have durations. + * @return __itt_err upon failure (invalid event id/user event feature not enabled) + */ +int LIBITTAPI __itt_event_end(__itt_event event); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event)) +#define __itt_event_end ITTNOTIFY_DATA(event_end) +#define __itt_event_end_ptr ITTNOTIFY_NAME(event_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_event_end(event) (int)0 +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_event_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_events group */ +#endif /* _ITTNOTIFY_H_ */ + +/** + * @defgroup legacy_memory Memory Accesses + * @ingroup legacy + */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on reading + */ +void LIBITTAPI __itt_memory_read(void *addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size)) +#define __itt_memory_read ITTNOTIFY_VOID(memory_read) +#define __itt_memory_read_ptr ITTNOTIFY_NAME(memory_read) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_read(addr, size) +#define __itt_memory_read_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_read_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on writing + */ +void LIBITTAPI __itt_memory_write(void *addr, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size)) +#define __itt_memory_write ITTNOTIFY_VOID(memory_write) +#define __itt_memory_write_ptr ITTNOTIFY_NAME(memory_write) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_write(addr, size) +#define __itt_memory_write_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_write_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief Inform the tool of memory accesses on updating + */ +void LIBITTAPI __itt_memory_update(void *address, size_t size); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size)) +#define __itt_memory_update ITTNOTIFY_VOID(memory_update) +#define __itt_memory_update_ptr ITTNOTIFY_NAME(memory_update) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_memory_update(addr, size) +#define __itt_memory_update_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_memory_update_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_memory group */ + +/** + * @defgroup legacy_state Thread and Object States + * @ingroup legacy + */ + +/** @brief state type */ +typedef int __itt_state_t; + +/** @cond exclude_from_documentation */ +typedef enum __itt_obj_state { + __itt_obj_state_err = 0, + __itt_obj_state_clr = 1, + __itt_obj_state_set = 2, + __itt_obj_state_use = 3 +} __itt_obj_state_t; + +typedef enum __itt_thr_state { + __itt_thr_state_err = 0, + __itt_thr_state_clr = 1, + __itt_thr_state_set = 2 +} __itt_thr_state_t; + +typedef enum __itt_obj_prop { + __itt_obj_prop_watch = 1, + __itt_obj_prop_ignore = 2, + __itt_obj_prop_sharable = 3 +} __itt_obj_prop_t; + +typedef enum __itt_thr_prop { + __itt_thr_prop_quiet = 1 +} __itt_thr_prop_t; +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object states + */ +__itt_state_t LIBITTAPI __itt_state_get(void); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_state_t, state_get, (void)) +#define __itt_state_get ITTNOTIFY_DATA(state_get) +#define __itt_state_get_ptr ITTNOTIFY_NAME(state_get) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_state_get(void) (__itt_state_t)0 +#define __itt_state_get_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_state_get_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object states + */ +__itt_state_t LIBITTAPI __itt_state_set(__itt_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_state_t, state_set, (__itt_state_t s)) +#define __itt_state_set ITTNOTIFY_DATA(state_set) +#define __itt_state_set_ptr ITTNOTIFY_NAME(state_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_state_set(s) (__itt_state_t)0 +#define __itt_state_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_state_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object modes + */ +__itt_thr_state_t LIBITTAPI __itt_thr_mode_set(__itt_thr_prop_t p, __itt_thr_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s)) +#define __itt_thr_mode_set ITTNOTIFY_DATA(thr_mode_set) +#define __itt_thr_mode_set_ptr ITTNOTIFY_NAME(thr_mode_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_thr_mode_set(p, s) (__itt_thr_state_t)0 +#define __itt_thr_mode_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_thr_mode_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** + * @deprecated Legacy API + * @brief managing thread and object modes + */ +__itt_obj_state_t LIBITTAPI __itt_obj_mode_set(__itt_obj_prop_t p, __itt_obj_state_t s); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUB(ITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s)) +#define __itt_obj_mode_set ITTNOTIFY_DATA(obj_mode_set) +#define __itt_obj_mode_set_ptr ITTNOTIFY_NAME(obj_mode_set) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_obj_mode_set(p, s) (__itt_obj_state_t)0 +#define __itt_obj_mode_set_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_obj_mode_set_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} legacy_state group */ + +/** + * @defgroup frames Frames + * @ingroup legacy + * Frames group + * @{ + */ +/** + * @brief opaque structure for frame identification + */ +typedef struct __itt_frame_t *__itt_frame; + +/** + * @brief Create a global frame with given domain + */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +__itt_frame ITTAPI __itt_frame_createA(const char *domain); +__itt_frame ITTAPI __itt_frame_createW(const wchar_t *domain); +#if defined(UNICODE) || defined(_UNICODE) +# define __itt_frame_create __itt_frame_createW +# define __itt_frame_create_ptr __itt_frame_createW_ptr +#else /* UNICODE */ +# define __itt_frame_create __itt_frame_createA +# define __itt_frame_create_ptr __itt_frame_createA_ptr +#endif /* UNICODE */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +__itt_frame ITTAPI __itt_frame_create(const char *domain); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain)) +ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain)) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain)) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA ITTNOTIFY_DATA(frame_createA) +#define __itt_frame_createA_ptr ITTNOTIFY_NAME(frame_createA) +#define __itt_frame_createW ITTNOTIFY_DATA(frame_createW) +#define __itt_frame_createW_ptr ITTNOTIFY_NAME(frame_createW) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create ITTNOTIFY_DATA(frame_create) +#define __itt_frame_create_ptr ITTNOTIFY_NAME(frame_create) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#else /* INTEL_NO_ITTNOTIFY_API */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA(domain) +#define __itt_frame_createA_ptr 0 +#define __itt_frame_createW(domain) +#define __itt_frame_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create(domain) +#define __itt_frame_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_frame_createA_ptr 0 +#define __itt_frame_createW_ptr 0 +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#define __itt_frame_create_ptr 0 +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ + +/** @brief Record an frame begin occurrence. */ +void ITTAPI __itt_frame_begin(__itt_frame frame); +/** @brief Record an frame end occurrence. */ +void ITTAPI __itt_frame_end (__itt_frame frame); + +/** @cond exclude_from_documentation */ +#ifndef INTEL_NO_MACRO_BODY +#ifndef INTEL_NO_ITTNOTIFY_API +ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame)) +ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame)) +#define __itt_frame_begin ITTNOTIFY_VOID(frame_begin) +#define __itt_frame_begin_ptr ITTNOTIFY_NAME(frame_begin) +#define __itt_frame_end ITTNOTIFY_VOID(frame_end) +#define __itt_frame_end_ptr ITTNOTIFY_NAME(frame_end) +#else /* INTEL_NO_ITTNOTIFY_API */ +#define __itt_frame_begin(frame) +#define __itt_frame_begin_ptr 0 +#define __itt_frame_end(frame) +#define __itt_frame_end_ptr 0 +#endif /* INTEL_NO_ITTNOTIFY_API */ +#else /* INTEL_NO_MACRO_BODY */ +#define __itt_frame_begin_ptr 0 +#define __itt_frame_end_ptr 0 +#endif /* INTEL_NO_MACRO_BODY */ +/** @endcond */ +/** @} frames group */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LEGACY_ITTNOTIFY_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/libittnotify.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/libittnotify.h index 15d8056a9d..2ac37d8c34 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/libittnotify.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/libittnotify.h @@ -1,71 +1,71 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _LIBITTNOTIFY_H_ -#define _LIBITTNOTIFY_H_ - -#ifndef __ITT_INTERNAL_INCLUDE -# if defined WIN32 || defined _WIN32 -# pragma message("WARNING!!! Include file libittnotify.h is deprecated and should not be included anymore") -# else /* WIN32 */ -# warning "Include file libittnotify.h is deprecated and should not be included anymore" -# endif /* WIN32 */ -#endif /* __ITT_INTERNAL_INCLUDE */ -#include "legacy/ittnotify.h" - -#endif /* _LIBITTNOTIFY_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _LIBITTNOTIFY_H_ +#define _LIBITTNOTIFY_H_ + +#ifndef __ITT_INTERNAL_INCLUDE +# if defined WIN32 || defined _WIN32 +# pragma message("WARNING!!! Include file libittnotify.h is deprecated and should not be included anymore") +# else /* WIN32 */ +# warning "Include file libittnotify.h is deprecated and should not be included anymore" +# endif /* WIN32 */ +#endif /* __ITT_INTERNAL_INCLUDE */ +#include "legacy/ittnotify.h" + +#endif /* _LIBITTNOTIFY_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/include/prototype/ittnotify.h b/sgx-jvm/linux-sgx/external/vtune/linux/include/prototype/ittnotify.h index 85aabe5806..54fdbb419e 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/include/prototype/ittnotify.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/include/prototype/ittnotify.h @@ -1,263 +1,263 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _PROTOTYPE_ITTNOTIFY_H_ -#define _PROTOTYPE_ITTNOTIFY_H_ - -/** - * @file - * @brief Prototype User API functions and types - */ - -/** @cond exclude_from_documentation */ -#ifndef ITT_OS_WIN -# define ITT_OS_WIN 1 -#endif /* ITT_OS_WIN */ - -#ifndef ITT_OS_LINUX -# define ITT_OS_LINUX 2 -#endif /* ITT_OS_LINUX */ - -#ifndef ITT_OS_MAC -# define ITT_OS_MAC 3 -#endif /* ITT_OS_MAC */ - -#ifndef ITT_OS_FREEBSD -# define ITT_OS_FREEBSD 4 -#endif /* ITT_OS_FREEBSD */ - -#ifndef ITT_OS -# if defined WIN32 || defined _WIN32 -# define ITT_OS ITT_OS_WIN -# elif defined( __APPLE__ ) && defined( __MACH__ ) -# define ITT_OS ITT_OS_MAC -# elif defined( __FreeBSD__ ) -# define ITT_OS ITT_OS_FREEBSD -# else -# define ITT_OS ITT_OS_LINUX -# endif -#endif /* ITT_OS */ - -#ifndef ITT_PLATFORM_WIN -# define ITT_PLATFORM_WIN 1 -#endif /* ITT_PLATFORM_WIN */ - -#ifndef ITT_PLATFORM_POSIX -# define ITT_PLATFORM_POSIX 2 -#endif /* ITT_PLATFORM_POSIX */ - -#ifndef ITT_PLATFORM_MAC -# define ITT_PLATFORM_MAC 3 -#endif /* ITT_PLATFORM_MAC */ - -#ifndef ITT_PLATFORM_FREEBSD -# define ITT_PLATFORM_FREEBSD 4 -#endif /* ITT_PLATFORM_FREEBSD */ - -#ifndef ITT_PLATFORM -# if ITT_OS==ITT_OS_WIN -# define ITT_PLATFORM ITT_PLATFORM_WIN -# elif ITT_OS==ITT_OS_MAC -# define ITT_PLATFORM ITT_PLATFORM_MAC -# elif ITT_OS==ITT_OS_FREEBSD -# define ITT_PLATFORM ITT_PLATFORM_FREEBSD -# else -# define ITT_PLATFORM ITT_PLATFORM_POSIX -# endif -#endif /* ITT_PLATFORM */ - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif - -#include -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE || _UNICODE */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef CDECL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define CDECL __cdecl -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* CDECL */ - -#ifndef STDCALL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define STDCALL __stdcall -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define STDCALL __attribute__ ((stdcall)) -# else /* _M_IX86 || __i386__ */ -# define STDCALL /* supported only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* STDCALL */ - -#define ITTAPI CDECL -#define LIBITTAPI CDECL - -/* TODO: Temporary for compatibility! */ -#define ITTAPI_CALL CDECL -#define LIBITTAPI_CALL CDECL - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -/* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline -#define ITT_INLINE_ATTRIBUTE /* nothing */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/* - * Generally, functions are not inlined unless optimization is specified. - * For functions declared inline, this attribute inlines the function even - * if no optimization level was specified. - */ -#ifdef __STRICT_ANSI__ -#define ITT_INLINE static -#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) -#else /* __STRICT_ANSI__ */ -#define ITT_INLINE static inline -#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) -#endif /* __STRICT_ANSI__ */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/** @endcond */ - -/** @cond exclude_from_documentation */ -/* Helper macro for joining tokens */ -#define ITT_JOIN_AUX(p,n) p##n -#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) - -#ifdef ITT_MAJOR -#undef ITT_MAJOR -#endif -#ifdef ITT_MINOR -#undef ITT_MINOR -#endif -#define ITT_MAJOR 3 -#define ITT_MINOR 0 - -/* Standard versioning of a token with major and minor version numbers */ -#define ITT_VERSIONIZE(x) \ - ITT_JOIN(x, \ - ITT_JOIN(_, \ - ITT_JOIN(ITT_MAJOR, \ - ITT_JOIN(_, ITT_MINOR)))) - -#ifndef INTEL_ITTNOTIFY_PREFIX -# define INTEL_ITTNOTIFY_PREFIX __itt_ -#endif /* INTEL_ITTNOTIFY_PREFIX */ -#ifndef INTEL_ITTNOTIFY_POSTFIX -# define INTEL_ITTNOTIFY_POSTFIX _ptr_ -#endif /* INTEL_ITTNOTIFY_POSTFIX */ - -#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) -#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) - -#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) -#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) - -#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) -#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) -#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) -#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) -#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) -#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) -#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) -#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) - -#ifdef ITT_STUB -#undef ITT_STUB -#endif -#ifdef ITT_STUBV -#undef ITT_STUBV -#endif -#define ITT_STUBV(api,type,name,args) \ - typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ - extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); -#define ITT_STUB ITT_STUBV -/** @endcond */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup prototype Prototype API - * @{ - * @} - */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _PROTOTYPE_ITTNOTIFY_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _PROTOTYPE_ITTNOTIFY_H_ +#define _PROTOTYPE_ITTNOTIFY_H_ + +/** + * @file + * @brief Prototype User API functions and types + */ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +/** @cond exclude_from_documentation */ +/* Helper macro for joining tokens */ +#define ITT_JOIN_AUX(p,n) p##n +#define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n) + +#ifdef ITT_MAJOR +#undef ITT_MAJOR +#endif +#ifdef ITT_MINOR +#undef ITT_MINOR +#endif +#define ITT_MAJOR 3 +#define ITT_MINOR 0 + +/* Standard versioning of a token with major and minor version numbers */ +#define ITT_VERSIONIZE(x) \ + ITT_JOIN(x, \ + ITT_JOIN(_, \ + ITT_JOIN(ITT_MAJOR, \ + ITT_JOIN(_, ITT_MINOR)))) + +#ifndef INTEL_ITTNOTIFY_PREFIX +# define INTEL_ITTNOTIFY_PREFIX __itt_ +#endif /* INTEL_ITTNOTIFY_PREFIX */ +#ifndef INTEL_ITTNOTIFY_POSTFIX +# define INTEL_ITTNOTIFY_POSTFIX _ptr_ +#endif /* INTEL_ITTNOTIFY_POSTFIX */ + +#define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) +#define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX))) + +#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n) +#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n) + +#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) +#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d) +#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x) +#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y) +#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z) +#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a) +#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b) +#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c) + +#ifdef ITT_STUB +#undef ITT_STUB +#endif +#ifdef ITT_STUBV +#undef ITT_STUBV +#endif +#define ITT_STUBV(api,type,name,args) \ + typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \ + extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name); +#define ITT_STUB ITT_STUBV +/** @endcond */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup prototype Prototype API + * @{ + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _PROTOTYPE_ITTNOTIFY_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h index 4210f86bfd..6dfe159c16 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/disable_warnings.h @@ -1,77 +1,77 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 "ittnotify_config.h" - -#if ITT_PLATFORM==ITT_PLATFORM_WIN - -#pragma warning (disable: 593) /* parameter "XXXX" was set but never used */ -#pragma warning (disable: 344) /* typedef name has already been declared (with same type) */ -#pragma warning (disable: 174) /* expression has no effect */ -#pragma warning (disable: 4127) /* conditional expression is constant */ -#pragma warning (disable: 4306) /* conversion from '?' to '?' of greater size */ - -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#if defined __INTEL_COMPILER - -#pragma warning (disable: 869) /* parameter "XXXXX" was never referenced */ -#pragma warning (disable: 1418) /* external function definition with no prior declaration */ -#pragma warning (disable: 1419) /* external declaration in primary source file */ - -#endif /* __INTEL_COMPILER */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + +#pragma warning (disable: 593) /* parameter "XXXX" was set but never used */ +#pragma warning (disable: 344) /* typedef name has already been declared (with same type) */ +#pragma warning (disable: 174) /* expression has no effect */ +#pragma warning (disable: 4127) /* conditional expression is constant */ +#pragma warning (disable: 4306) /* conversion from '?' to '?' of greater size */ + +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if defined __INTEL_COMPILER + +#pragma warning (disable: 869) /* parameter "XXXXX" was never referenced */ +#pragma warning (disable: 1418) /* external function definition with no prior declaration */ +#pragma warning (disable: 1419) /* external declaration in primary source file */ + +#endif /* __INTEL_COMPILER */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h index 2489297bd3..4c3d09fe21 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_config.h @@ -1,541 +1,541 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _ITTNOTIFY_CONFIG_H_ -#define _ITTNOTIFY_CONFIG_H_ - -/** @cond exclude_from_documentation */ -#ifndef ITT_OS_WIN -# define ITT_OS_WIN 1 -#endif /* ITT_OS_WIN */ - -#ifndef ITT_OS_LINUX -# define ITT_OS_LINUX 2 -#endif /* ITT_OS_LINUX */ - -#ifndef ITT_OS_MAC -# define ITT_OS_MAC 3 -#endif /* ITT_OS_MAC */ - -#ifndef ITT_OS_FREEBSD -# define ITT_OS_FREEBSD 4 -#endif /* ITT_OS_FREEBSD */ - -#ifndef ITT_OS -# if defined WIN32 || defined _WIN32 -# define ITT_OS ITT_OS_WIN -# elif defined( __APPLE__ ) && defined( __MACH__ ) -# define ITT_OS ITT_OS_MAC -# elif defined( __FreeBSD__ ) -# define ITT_OS ITT_OS_FREEBSD -# else -# define ITT_OS ITT_OS_LINUX -# endif -#endif /* ITT_OS */ - -#ifndef ITT_PLATFORM_WIN -# define ITT_PLATFORM_WIN 1 -#endif /* ITT_PLATFORM_WIN */ - -#ifndef ITT_PLATFORM_POSIX -# define ITT_PLATFORM_POSIX 2 -#endif /* ITT_PLATFORM_POSIX */ - -#ifndef ITT_PLATFORM_MAC -# define ITT_PLATFORM_MAC 3 -#endif /* ITT_PLATFORM_MAC */ - -#ifndef ITT_PLATFORM_FREEBSD -# define ITT_PLATFORM_FREEBSD 4 -#endif /* ITT_PLATFORM_FREEBSD */ - -#ifndef ITT_PLATFORM -# if ITT_OS==ITT_OS_WIN -# define ITT_PLATFORM ITT_PLATFORM_WIN -# elif ITT_OS==ITT_OS_MAC -# define ITT_PLATFORM ITT_PLATFORM_MAC -# elif ITT_OS==ITT_OS_FREEBSD -# define ITT_PLATFORM ITT_PLATFORM_FREEBSD -# else -# define ITT_PLATFORM ITT_PLATFORM_POSIX -# endif -#endif /* ITT_PLATFORM */ - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif - -#include -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE || _UNICODE */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#ifndef CDECL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define CDECL __cdecl -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define CDECL __attribute__ ((cdecl)) -# else /* _M_IX86 || __i386__ */ -# define CDECL /* actual only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* CDECL */ - -#ifndef STDCALL -# if ITT_PLATFORM==ITT_PLATFORM_WIN -# define STDCALL __stdcall -# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -# if defined _M_IX86 || defined __i386__ -# define STDCALL __attribute__ ((stdcall)) -# else /* _M_IX86 || __i386__ */ -# define STDCALL /* supported only on x86 platform */ -# endif /* _M_IX86 || __i386__ */ -# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* STDCALL */ - -#define ITTAPI CDECL -#define LIBITTAPI CDECL - -/* TODO: Temporary for compatibility! */ -#define ITTAPI_CALL CDECL -#define LIBITTAPI_CALL CDECL - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -/* use __forceinline (VC++ specific) */ -#define ITT_INLINE __forceinline -#define ITT_INLINE_ATTRIBUTE /* nothing */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/* - * Generally, functions are not inlined unless optimization is specified. - * For functions declared inline, this attribute inlines the function even - * if no optimization level was specified. - */ -#ifdef __STRICT_ANSI__ -#define ITT_INLINE static -#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) -#else /* __STRICT_ANSI__ */ -#define ITT_INLINE static inline -#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) -#endif /* __STRICT_ANSI__ */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -/** @endcond */ - -#ifndef ITT_ARCH_IA32 -# define ITT_ARCH_IA32 1 -#endif /* ITT_ARCH_IA32 */ - -#ifndef ITT_ARCH_IA32E -# define ITT_ARCH_IA32E 2 -#endif /* ITT_ARCH_IA32E */ - -#ifndef ITT_ARCH_ARM -# define ITT_ARCH_ARM 4 -#endif /* ITT_ARCH_ARM */ - -#ifndef ITT_ARCH_PPC64 -# define ITT_ARCH_PPC64 5 -#endif /* ITT_ARCH_PPC64 */ - -#ifndef ITT_ARCH -# if defined _M_IX86 || defined __i386__ -# define ITT_ARCH ITT_ARCH_IA32 -# elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__ -# define ITT_ARCH ITT_ARCH_IA32E -# elif defined _M_IA64 || defined __ia64__ -# define ITT_ARCH ITT_ARCH_IA64 -# elif defined _M_ARM || defined __arm__ -# define ITT_ARCH ITT_ARCH_ARM -# elif defined __powerpc64__ -# define ITT_ARCH ITT_ARCH_PPC64 -# endif -#endif - -#ifdef __cplusplus -# define ITT_EXTERN_C extern "C" -# define ITT_EXTERN_C_BEGIN extern "C" { -# define ITT_EXTERN_C_END } -#else -# define ITT_EXTERN_C /* nothing */ -# define ITT_EXTERN_C_BEGIN /* nothing */ -# define ITT_EXTERN_C_END /* nothing */ -#endif /* __cplusplus */ - -#define ITT_TO_STR_AUX(x) #x -#define ITT_TO_STR(x) ITT_TO_STR_AUX(x) - -#define __ITT_BUILD_ASSERT(expr, suffix) do { \ - static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \ - __itt_build_check_##suffix[0] = 0; \ -} while(0) -#define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix) -#define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__) - -#define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } - -/* Replace with snapshot date YYYYMMDD for promotion build. */ -#define API_VERSION_BUILD 20111111 - -#ifndef API_VERSION_NUM -#define API_VERSION_NUM 0.0.0 -#endif /* API_VERSION_NUM */ - -#define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \ - " (" ITT_TO_STR(API_VERSION_BUILD) ")" - -/* OS communication functions */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -typedef HMODULE lib_t; -typedef DWORD TIDT; -typedef CRITICAL_SECTION mutex_t; -#define MUTEX_INITIALIZER { 0 } -#define strong_alias(name, aliasname) /* empty for Windows */ -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#if defined(UNICODE) || defined(_UNICODE) -#include -#endif /* UNICODE */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */ -#endif /* _GNU_SOURCE */ -#ifndef __USE_UNIX98 -#define __USE_UNIX98 1 /* need for PTHREAD_MUTEX_RECURSIVE, on SLES11.1 with gcc 4.3.4 wherein pthread.h missing dependency on __USE_XOPEN2K8 */ -#endif /*__USE_UNIX98*/ -#include -typedef void* lib_t; -typedef pthread_t TIDT; -typedef pthread_mutex_t mutex_t; -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define _strong_alias(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((alias (#name))); -#define strong_alias(name, aliasname) _strong_alias(name, aliasname) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define __itt_get_proc(lib, name) GetProcAddress(lib, name) -#define __itt_mutex_init(mutex) InitializeCriticalSection(mutex) -#define __itt_mutex_lock(mutex) EnterCriticalSection(mutex) -#define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex) -#define __itt_load_lib(name) LoadLibraryA(name) -#define __itt_unload_lib(handle) FreeLibrary(handle) -#define __itt_system_error() (int)GetLastError() -#define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2) -#define __itt_fstrnlen(s, l) strnlen_s(s, l) -#define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l) -#define __itt_fstrdup(s) _strdup(s) -#define __itt_thread_id() GetCurrentThreadId() -#define __itt_thread_yield() SwitchToThread() -#ifndef ITT_SIMPLE_INIT -ITT_INLINE long -__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; -ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) -{ - return InterlockedIncrement(ptr); -} -#endif /* ITT_SIMPLE_INIT */ -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -#define __itt_get_proc(lib, name) dlsym(lib, name) -#define __itt_mutex_init(mutex) {\ - pthread_mutexattr_t mutex_attr; \ - int error_code = pthread_mutexattr_init(&mutex_attr); \ - if (error_code) \ - __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \ - error_code); \ - error_code = pthread_mutexattr_settype(&mutex_attr, \ - PTHREAD_MUTEX_RECURSIVE); \ - if (error_code) \ - __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \ - error_code); \ - error_code = pthread_mutex_init(mutex, &mutex_attr); \ - if (error_code) \ - __itt_report_error(__itt_error_system, "pthread_mutex_init", \ - error_code); \ - error_code = pthread_mutexattr_destroy(&mutex_attr); \ - if (error_code) \ - __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \ - error_code); \ -} -#define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex) -#define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex) -#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) -#define __itt_unload_lib(handle) dlclose(handle) -#define __itt_system_error() errno -#define __itt_fstrcmp(s1, s2) strcmp(s1, s2) - -/* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */ -#ifdef SDL_STRNLEN_S -#define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l) -#else -#define __itt_fstrnlen(s, l) strlen(s) -#endif /* SDL_STRNLEN_S */ -#ifdef SDL_STRNCPY_S -#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) -#else -#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l) -#endif /* SDL_STRNCPY_S */ - -#define __itt_fstrdup(s) strdup(s) -#define __itt_thread_id() pthread_self() -#define __itt_thread_yield() sched_yield() -//#if ITT_ARCH==ITT_ARCH_IA64 -#if defined(ITT_ARCH_IA64) && ITT_ARCH==ITT_ARCH_IA64 -#ifdef __INTEL_COMPILER -#define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val) -#else /* __INTEL_COMPILER */ -/* TODO: Add Support for not Intel compilers for IA-64 architecture */ -#endif /* __INTEL_COMPILER */ -#elif ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */ -ITT_INLINE long -__TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE; -ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend) -{ - long result; - __asm__ __volatile__("lock\nxadd %0,%1" - : "=r"(result),"=m"(*(int*)ptr) - : "0"(addend), "m"(*(int*)ptr) - : "memory"); - return result; -} -#elif ITT_ARCH==ITT_ARCH_ARM || ITT_ARCH==ITT_ARCH_PPC64 -#define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) -#endif /* ITT_ARCH==ITT_ARCH_IA64 */ -#ifndef ITT_SIMPLE_INIT -ITT_INLINE long -__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; -ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) -{ - return __TBB_machine_fetchadd4(ptr, 1) + 1L; -} -#endif /* ITT_SIMPLE_INIT */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -typedef enum { - __itt_collection_normal = 0, - __itt_collection_paused = 1 -} __itt_collection_state; - -typedef enum { - __itt_thread_normal = 0, - __itt_thread_ignored = 1 -} __itt_thread_state; - -#pragma pack(push, 8) - -typedef struct ___itt_thread_info -{ - const char* nameA; /*!< Copy of original name in ASCII. */ -#if defined(UNICODE) || defined(_UNICODE) - const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ -#else /* UNICODE || _UNICODE */ - void* nameW; -#endif /* UNICODE || _UNICODE */ - TIDT tid; - __itt_thread_state state; /*!< Thread state (paused or normal) */ - int extra1; /*!< Reserved to the runtime */ - void* extra2; /*!< Reserved to the runtime */ - struct ___itt_thread_info* next; -} __itt_thread_info; - -#include "ittnotify_types.h" /* For __itt_group_id definition */ - -typedef struct ___itt_api_info_20101001 -{ - const char* name; - void** func_ptr; - void* init_func; - __itt_group_id group; -} __itt_api_info_20101001; - -typedef struct ___itt_api_info -{ - const char* name; - void** func_ptr; - void* init_func; - void* null_func; - __itt_group_id group; -} __itt_api_info; - -struct ___itt_domain; -struct ___itt_string_handle; - -typedef struct ___itt_global -{ - unsigned char magic[8]; - unsigned long version_major; - unsigned long version_minor; - unsigned long version_build; - volatile long api_initialized; - volatile long mutex_initialized; - volatile long atomic_counter; - mutex_t mutex; - lib_t lib; - void* error_handler; - const char** dll_path_ptr; - __itt_api_info* api_list_ptr; - struct ___itt_global* next; - /* Joinable structures below */ - __itt_thread_info* thread_list; - struct ___itt_domain* domain_list; - struct ___itt_string_handle* string_list; - __itt_collection_state state; -} __itt_global; - -#pragma pack(pop) - -#define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ - h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ - if (h != NULL) { \ - h->tid = t; \ - h->nameA = NULL; \ - h->nameW = n ? _wcsdup(n) : NULL; \ - h->state = s; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->thread_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ - h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ - if (h != NULL) { \ - h->tid = t; \ - h->nameA = n ? __itt_fstrdup(n) : NULL; \ - h->nameW = NULL; \ - h->state = s; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->thread_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ - h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ - if (h != NULL) { \ - h->flags = 1; /* domain is enabled by default */ \ - h->nameA = NULL; \ - h->nameW = name ? _wcsdup(name) : NULL; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->domain_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ - h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ - if (h != NULL) { \ - h->flags = 1; /* domain is enabled by default */ \ - h->nameA = name ? __itt_fstrdup(name) : NULL; \ - h->nameW = NULL; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->domain_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ - h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ - if (h != NULL) { \ - h->strA = NULL; \ - h->strW = name ? _wcsdup(name) : NULL; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->string_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ - h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ - if (h != NULL) { \ - h->strA = name ? __itt_fstrdup(name) : NULL; \ - h->strW = NULL; \ - h->extra1 = 0; /* reserved */ \ - h->extra2 = NULL; /* reserved */ \ - h->next = NULL; \ - if (h_tail == NULL) \ - (gptr)->string_list = h; \ - else \ - h_tail->next = h; \ - } \ -} - -#endif /* _ITTNOTIFY_CONFIG_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _ITTNOTIFY_CONFIG_H_ +#define _ITTNOTIFY_CONFIG_H_ + +/** @cond exclude_from_documentation */ +#ifndef ITT_OS_WIN +# define ITT_OS_WIN 1 +#endif /* ITT_OS_WIN */ + +#ifndef ITT_OS_LINUX +# define ITT_OS_LINUX 2 +#endif /* ITT_OS_LINUX */ + +#ifndef ITT_OS_MAC +# define ITT_OS_MAC 3 +#endif /* ITT_OS_MAC */ + +#ifndef ITT_OS_FREEBSD +# define ITT_OS_FREEBSD 4 +#endif /* ITT_OS_FREEBSD */ + +#ifndef ITT_OS +# if defined WIN32 || defined _WIN32 +# define ITT_OS ITT_OS_WIN +# elif defined( __APPLE__ ) && defined( __MACH__ ) +# define ITT_OS ITT_OS_MAC +# elif defined( __FreeBSD__ ) +# define ITT_OS ITT_OS_FREEBSD +# else +# define ITT_OS ITT_OS_LINUX +# endif +#endif /* ITT_OS */ + +#ifndef ITT_PLATFORM_WIN +# define ITT_PLATFORM_WIN 1 +#endif /* ITT_PLATFORM_WIN */ + +#ifndef ITT_PLATFORM_POSIX +# define ITT_PLATFORM_POSIX 2 +#endif /* ITT_PLATFORM_POSIX */ + +#ifndef ITT_PLATFORM_MAC +# define ITT_PLATFORM_MAC 3 +#endif /* ITT_PLATFORM_MAC */ + +#ifndef ITT_PLATFORM_FREEBSD +# define ITT_PLATFORM_FREEBSD 4 +#endif /* ITT_PLATFORM_FREEBSD */ + +#ifndef ITT_PLATFORM +# if ITT_OS==ITT_OS_WIN +# define ITT_PLATFORM ITT_PLATFORM_WIN +# elif ITT_OS==ITT_OS_MAC +# define ITT_PLATFORM ITT_PLATFORM_MAC +# elif ITT_OS==ITT_OS_FREEBSD +# define ITT_PLATFORM ITT_PLATFORM_FREEBSD +# else +# define ITT_PLATFORM ITT_PLATFORM_POSIX +# endif +#endif /* ITT_PLATFORM */ + +#if defined(_UNICODE) && !defined(UNICODE) +#define UNICODE +#endif + +#include +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE || _UNICODE */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#ifndef CDECL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define CDECL __cdecl +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define CDECL __attribute__ ((cdecl)) +# else /* _M_IX86 || __i386__ */ +# define CDECL /* actual only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* CDECL */ + +#ifndef STDCALL +# if ITT_PLATFORM==ITT_PLATFORM_WIN +# define STDCALL __stdcall +# else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +# if defined _M_IX86 || defined __i386__ +# define STDCALL __attribute__ ((stdcall)) +# else /* _M_IX86 || __i386__ */ +# define STDCALL /* supported only on x86 platform */ +# endif /* _M_IX86 || __i386__ */ +# endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* STDCALL */ + +#define ITTAPI CDECL +#define LIBITTAPI CDECL + +/* TODO: Temporary for compatibility! */ +#define ITTAPI_CALL CDECL +#define LIBITTAPI_CALL CDECL + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +/* use __forceinline (VC++ specific) */ +#define ITT_INLINE __forceinline +#define ITT_INLINE_ATTRIBUTE /* nothing */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/* + * Generally, functions are not inlined unless optimization is specified. + * For functions declared inline, this attribute inlines the function even + * if no optimization level was specified. + */ +#ifdef __STRICT_ANSI__ +#define ITT_INLINE static +#define ITT_INLINE_ATTRIBUTE __attribute__((unused)) +#else /* __STRICT_ANSI__ */ +#define ITT_INLINE static inline +#define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) +#endif /* __STRICT_ANSI__ */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +/** @endcond */ + +#ifndef ITT_ARCH_IA32 +# define ITT_ARCH_IA32 1 +#endif /* ITT_ARCH_IA32 */ + +#ifndef ITT_ARCH_IA32E +# define ITT_ARCH_IA32E 2 +#endif /* ITT_ARCH_IA32E */ + +#ifndef ITT_ARCH_ARM +# define ITT_ARCH_ARM 4 +#endif /* ITT_ARCH_ARM */ + +#ifndef ITT_ARCH_PPC64 +# define ITT_ARCH_PPC64 5 +#endif /* ITT_ARCH_PPC64 */ + +#ifndef ITT_ARCH +# if defined _M_IX86 || defined __i386__ +# define ITT_ARCH ITT_ARCH_IA32 +# elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__ +# define ITT_ARCH ITT_ARCH_IA32E +# elif defined _M_IA64 || defined __ia64__ +# define ITT_ARCH ITT_ARCH_IA64 +# elif defined _M_ARM || defined __arm__ +# define ITT_ARCH ITT_ARCH_ARM +# elif defined __powerpc64__ +# define ITT_ARCH ITT_ARCH_PPC64 +# endif +#endif + +#ifdef __cplusplus +# define ITT_EXTERN_C extern "C" +# define ITT_EXTERN_C_BEGIN extern "C" { +# define ITT_EXTERN_C_END } +#else +# define ITT_EXTERN_C /* nothing */ +# define ITT_EXTERN_C_BEGIN /* nothing */ +# define ITT_EXTERN_C_END /* nothing */ +#endif /* __cplusplus */ + +#define ITT_TO_STR_AUX(x) #x +#define ITT_TO_STR(x) ITT_TO_STR_AUX(x) + +#define __ITT_BUILD_ASSERT(expr, suffix) do { \ + static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \ + __itt_build_check_##suffix[0] = 0; \ +} while(0) +#define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix) +#define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__) + +#define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } + +/* Replace with snapshot date YYYYMMDD for promotion build. */ +#define API_VERSION_BUILD 20111111 + +#ifndef API_VERSION_NUM +#define API_VERSION_NUM 0.0.0 +#endif /* API_VERSION_NUM */ + +#define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \ + " (" ITT_TO_STR(API_VERSION_BUILD) ")" + +/* OS communication functions */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +typedef HMODULE lib_t; +typedef DWORD TIDT; +typedef CRITICAL_SECTION mutex_t; +#define MUTEX_INITIALIZER { 0 } +#define strong_alias(name, aliasname) /* empty for Windows */ +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#if defined(UNICODE) || defined(_UNICODE) +#include +#endif /* UNICODE */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */ +#endif /* _GNU_SOURCE */ +#ifndef __USE_UNIX98 +#define __USE_UNIX98 1 /* need for PTHREAD_MUTEX_RECURSIVE, on SLES11.1 with gcc 4.3.4 wherein pthread.h missing dependency on __USE_XOPEN2K8 */ +#endif /*__USE_UNIX98*/ +#include +typedef void* lib_t; +typedef pthread_t TIDT; +typedef pthread_mutex_t mutex_t; +#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +#define strong_alias(name, aliasname) _strong_alias(name, aliasname) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define __itt_get_proc(lib, name) GetProcAddress(lib, name) +#define __itt_mutex_init(mutex) InitializeCriticalSection(mutex) +#define __itt_mutex_lock(mutex) EnterCriticalSection(mutex) +#define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex) +#define __itt_load_lib(name) LoadLibraryA(name) +#define __itt_unload_lib(handle) FreeLibrary(handle) +#define __itt_system_error() (int)GetLastError() +#define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2) +#define __itt_fstrnlen(s, l) strnlen_s(s, l) +#define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l) +#define __itt_fstrdup(s) _strdup(s) +#define __itt_thread_id() GetCurrentThreadId() +#define __itt_thread_yield() SwitchToThread() +#ifndef ITT_SIMPLE_INIT +ITT_INLINE long +__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) +{ + return InterlockedIncrement(ptr); +} +#endif /* ITT_SIMPLE_INIT */ +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +#define __itt_get_proc(lib, name) dlsym(lib, name) +#define __itt_mutex_init(mutex) {\ + pthread_mutexattr_t mutex_attr; \ + int error_code = pthread_mutexattr_init(&mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \ + error_code); \ + error_code = pthread_mutexattr_settype(&mutex_attr, \ + PTHREAD_MUTEX_RECURSIVE); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \ + error_code); \ + error_code = pthread_mutex_init(mutex, &mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutex_init", \ + error_code); \ + error_code = pthread_mutexattr_destroy(&mutex_attr); \ + if (error_code) \ + __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \ + error_code); \ +} +#define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex) +#define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex) +#define __itt_load_lib(name) dlopen(name, RTLD_LAZY) +#define __itt_unload_lib(handle) dlclose(handle) +#define __itt_system_error() errno +#define __itt_fstrcmp(s1, s2) strcmp(s1, s2) + +/* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */ +#ifdef SDL_STRNLEN_S +#define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l) +#else +#define __itt_fstrnlen(s, l) strlen(s) +#endif /* SDL_STRNLEN_S */ +#ifdef SDL_STRNCPY_S +#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) +#else +#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l) +#endif /* SDL_STRNCPY_S */ + +#define __itt_fstrdup(s) strdup(s) +#define __itt_thread_id() pthread_self() +#define __itt_thread_yield() sched_yield() +//#if ITT_ARCH==ITT_ARCH_IA64 +#if defined(ITT_ARCH_IA64) && ITT_ARCH==ITT_ARCH_IA64 +#ifdef __INTEL_COMPILER +#define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val) +#else /* __INTEL_COMPILER */ +/* TODO: Add Support for not Intel compilers for IA-64 architecture */ +#endif /* __INTEL_COMPILER */ +#elif ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */ +ITT_INLINE long +__TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend) +{ + long result; + __asm__ __volatile__("lock\nxadd %0,%1" + : "=r"(result),"=m"(*(int*)ptr) + : "0"(addend), "m"(*(int*)ptr) + : "memory"); + return result; +} +#elif ITT_ARCH==ITT_ARCH_ARM || ITT_ARCH==ITT_ARCH_PPC64 +#define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) +#endif /* ITT_ARCH==ITT_ARCH_IA64 */ +#ifndef ITT_SIMPLE_INIT +ITT_INLINE long +__itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; +ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) +{ + return __TBB_machine_fetchadd4(ptr, 1) + 1L; +} +#endif /* ITT_SIMPLE_INIT */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +typedef enum { + __itt_collection_normal = 0, + __itt_collection_paused = 1 +} __itt_collection_state; + +typedef enum { + __itt_thread_normal = 0, + __itt_thread_ignored = 1 +} __itt_thread_state; + +#pragma pack(push, 8) + +typedef struct ___itt_thread_info +{ + const char* nameA; /*!< Copy of original name in ASCII. */ +#if defined(UNICODE) || defined(_UNICODE) + const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ +#else /* UNICODE || _UNICODE */ + void* nameW; +#endif /* UNICODE || _UNICODE */ + TIDT tid; + __itt_thread_state state; /*!< Thread state (paused or normal) */ + int extra1; /*!< Reserved to the runtime */ + void* extra2; /*!< Reserved to the runtime */ + struct ___itt_thread_info* next; +} __itt_thread_info; + +#include "ittnotify_types.h" /* For __itt_group_id definition */ + +typedef struct ___itt_api_info_20101001 +{ + const char* name; + void** func_ptr; + void* init_func; + __itt_group_id group; +} __itt_api_info_20101001; + +typedef struct ___itt_api_info +{ + const char* name; + void** func_ptr; + void* init_func; + void* null_func; + __itt_group_id group; +} __itt_api_info; + +struct ___itt_domain; +struct ___itt_string_handle; + +typedef struct ___itt_global +{ + unsigned char magic[8]; + unsigned long version_major; + unsigned long version_minor; + unsigned long version_build; + volatile long api_initialized; + volatile long mutex_initialized; + volatile long atomic_counter; + mutex_t mutex; + lib_t lib; + void* error_handler; + const char** dll_path_ptr; + __itt_api_info* api_list_ptr; + struct ___itt_global* next; + /* Joinable structures below */ + __itt_thread_info* thread_list; + struct ___itt_domain* domain_list; + struct ___itt_string_handle* string_list; + __itt_collection_state state; +} __itt_global; + +#pragma pack(pop) + +#define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ + h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ + if (h != NULL) { \ + h->tid = t; \ + h->nameA = NULL; \ + h->nameW = n ? _wcsdup(n) : NULL; \ + h->state = s; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->thread_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ + h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ + if (h != NULL) { \ + h->tid = t; \ + h->nameA = n ? __itt_fstrdup(n) : NULL; \ + h->nameW = NULL; \ + h->state = s; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->thread_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ + h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ + if (h != NULL) { \ + h->flags = 1; /* domain is enabled by default */ \ + h->nameA = NULL; \ + h->nameW = name ? _wcsdup(name) : NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->domain_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ + h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ + if (h != NULL) { \ + h->flags = 1; /* domain is enabled by default */ \ + h->nameA = name ? __itt_fstrdup(name) : NULL; \ + h->nameW = NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->domain_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ + h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ + if (h != NULL) { \ + h->strA = NULL; \ + h->strW = name ? _wcsdup(name) : NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->string_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ + h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ + if (h != NULL) { \ + h->strA = name ? __itt_fstrdup(name) : NULL; \ + h->strW = NULL; \ + h->extra1 = 0; /* reserved */ \ + h->extra2 = NULL; /* reserved */ \ + h->next = NULL; \ + if (h_tail == NULL) \ + (gptr)->string_list = h; \ + else \ + h_tail->next = h; \ + } \ +} + +#endif /* _ITTNOTIFY_CONFIG_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c index 325b39f978..2c189956d5 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.c @@ -1,1080 +1,1080 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 "ittnotify_config.h" - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define PATH_MAX 512 -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -#include -#include -#include -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#include -#include -#include -#include - -#define INTEL_NO_MACRO_BODY -#define INTEL_ITTNOTIFY_API_PRIVATE -#include "ittnotify.h" -#include "legacy/ittnotify.h" - -#include "disable_warnings.h" - -static const char api_version[] = API_VERSION "\0\n@(#) $Revision: 422936 $\n"; - -#define _N_(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) - -#if ITT_OS==ITT_OS_WIN -static const char* ittnotify_lib_name = "libittnotify.dll"; -#elif ITT_OS==ITT_OS_LINUX || ITT_OS==ITT_OS_FREEBSD -static const char* ittnotify_lib_name = "libittnotify.so"; -#elif ITT_OS==ITT_OS_MAC -static const char* ittnotify_lib_name = "libittnotify.dylib"; -#else -#error Unsupported or unknown OS. -#endif - -#ifdef __ANDROID__ -#include -#include -#include -#include -#include -#include -#include - -#ifdef ITT_ANDROID_LOG - #define ITT_ANDROID_LOG_TAG "INTEL_VTUNE_USERAPI" - #define ITT_ANDROID_LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) - #define ITT_ANDROID_LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) - #define ITT_ANDROID_LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) - #define ITT_ANDROID_LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) -#else - #define ITT_ANDROID_LOGI(...) - #define ITT_ANDROID_LOGW(...) - #define ITT_ANDROID_LOGE(...) - #define ITT_ANDROID_LOGD(...) -#endif - -/* default location of userapi collector on Android */ -#define ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(x) "/data/data/com.intel.vtune/perfrun/lib" \ - #x "/runtime/libittnotify.so" - -#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM -#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(32) -#else -#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(64) -#endif - -#endif - - -#ifndef LIB_VAR_NAME -#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM -#define LIB_VAR_NAME INTEL_LIBITTNOTIFY32 -#else -#define LIB_VAR_NAME INTEL_LIBITTNOTIFY64 -#endif -#endif /* LIB_VAR_NAME */ - -#define ITT_MUTEX_INIT_AND_LOCK(p) { \ - if (!p.mutex_initialized) \ - { \ - if (__itt_interlocked_increment(&p.atomic_counter) == 1) \ - { \ - __itt_mutex_init(&p.mutex); \ - p.mutex_initialized = 1; \ - } \ - else \ - while (!p.mutex_initialized) \ - __itt_thread_yield(); \ - } \ - __itt_mutex_lock(&p.mutex); \ -} - -const int _N_(err) = 0; - -typedef int (__itt_init_ittlib_t)(const char*, __itt_group_id); - -/* this define used to control initialization function name. */ -#ifndef __itt_init_ittlib_name -ITT_EXTERN_C int _N_(init_ittlib)(const char*, __itt_group_id); -static __itt_init_ittlib_t* __itt_init_ittlib_ptr = _N_(init_ittlib); -#define __itt_init_ittlib_name __itt_init_ittlib_ptr -#endif /* __itt_init_ittlib_name */ - -typedef void (__itt_fini_ittlib_t)(void); - -/* this define used to control finalization function name. */ -#ifndef __itt_fini_ittlib_name -ITT_EXTERN_C void _N_(fini_ittlib)(void); -static __itt_fini_ittlib_t* __itt_fini_ittlib_ptr = _N_(fini_ittlib); -#define __itt_fini_ittlib_name __itt_fini_ittlib_ptr -#endif /* __itt_fini_ittlib_name */ - -/* building pointers to imported funcs */ -#undef ITT_STUBV -#undef ITT_STUB -#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ -typedef type api ITT_JOIN(_N_(name),_t) args; \ -ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ -{ \ - __itt_init_ittlib_name(NULL, __itt_group_all); \ - if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ - return ITTNOTIFY_NAME(name) params; \ - else \ - return (type)0; \ -} - -#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ -typedef type api ITT_JOIN(_N_(name),_t) args; \ -ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ -{ \ - __itt_init_ittlib_name(NULL, __itt_group_all); \ - if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ - ITTNOTIFY_NAME(name) params; \ - else \ - return; \ -} - -#undef __ITT_INTERNAL_INIT -#include "ittnotify_static.h" - -#undef ITT_STUB -#undef ITT_STUBV -#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ -typedef type api ITT_JOIN(_N_(name),_t) args; \ -ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END - -#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ -static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ -typedef type api ITT_JOIN(_N_(name),_t) args; \ -ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END - -#define __ITT_INTERNAL_INIT -#include "ittnotify_static.h" -#undef __ITT_INTERNAL_INIT - -ITT_GROUP_LIST(group_list); - -#pragma pack(push, 8) - -typedef struct ___itt_group_alias -{ - const char* env_var; - __itt_group_id groups; -} __itt_group_alias; - -static __itt_group_alias group_alias[] = { - { "KMP_FOR_TPROFILE", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_mark) }, - { "KMP_FOR_TCHECK", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_fsync | __itt_group_mark | __itt_group_suppress) }, - { NULL, (__itt_group_none) }, - { api_version, (__itt_group_none) } /* !!! Just to avoid unused code elimination !!! */ -}; - -#pragma pack(pop) - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(push) -#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -static __itt_api_info api_list[] = { -/* Define functions with static implementation */ -#undef ITT_STUB -#undef ITT_STUBV -#define ITT_STUB(api,type,name,args,params,nameindll,group,format) { ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (__itt_group_id)(group)}, -#define ITT_STUBV ITT_STUB -#define __ITT_INTERNAL_INIT -#include "ittnotify_static.h" -#undef __ITT_INTERNAL_INIT -/* Define functions without static implementation */ -#undef ITT_STUB -#undef ITT_STUBV -#define ITT_STUB(api,type,name,args,params,nameindll,group,format) {ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), NULL, (__itt_group_id)(group)}, -#define ITT_STUBV ITT_STUB -#include "ittnotify_static.h" - {NULL, NULL, NULL, NULL, __itt_group_none} -}; - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(pop) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -static const char dll_path[PATH_MAX] = { 0 }; - -/* static part descriptor which handles. all notification api attributes. */ -__itt_global _N_(_ittapi_global) = { - ITT_MAGIC, /* identification info */ - ITT_MAJOR, ITT_MINOR, API_VERSION_BUILD, /* version info */ - 0, /* api_initialized */ - 0, /* mutex_initialized */ - 0, /* atomic_counter */ - MUTEX_INITIALIZER, /* mutex */ - NULL, /* dynamic library handle */ - NULL, /* error_handler */ - (const char**)&dll_path, /* dll_path_ptr */ - (__itt_api_info*)&api_list, /* api_list_ptr */ - NULL, /* next __itt_global */ - NULL, /* thread_list */ - NULL, /* domain_list */ - NULL, /* string_list */ - __itt_collection_normal /* collection state */ -}; - -ITT_EXTERN_C __itt_global* _N_(get_ittapi_global)(void) { return &_N_(_ittapi_global); } -typedef void (__itt_api_init_t)(__itt_global*, __itt_group_id); -typedef void (__itt_api_fini_t)(__itt_global*); - -/* ========================================================================= */ - -#ifdef ITT_NOTIFY_EXT_REPORT -ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); -#endif /* ITT_NOTIFY_EXT_REPORT */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(push) -#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -static void __itt_report_error(__itt_error_code code, ...) -{ - va_list args; - va_start(args, code); - if (_N_(_ittapi_global).error_handler != NULL) - { - __itt_error_handler_t* handler = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; - handler(code, args); - } -#ifdef ITT_NOTIFY_EXT_REPORT - _N_(error_handler)(code, args); -#endif /* ITT_NOTIFY_EXT_REPORT */ - va_end(args); -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(pop) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))(const wchar_t* name) -{ - __itt_domain *h_tail = NULL, *h = NULL; - - if (name == NULL) - { - return NULL; - } - - ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); - if (_N_(_ittapi_global).api_initialized) - { - if (ITTNOTIFY_NAME(domain_createW) && ITTNOTIFY_NAME(domain_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(domain_createW)(name); - } - } - for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) - { - if (h->nameW != NULL && !wcscmp(h->nameW, name)) break; - } - if (h == NULL) - { - NEW_DOMAIN_W(&_N_(_ittapi_global),h,h_tail,name); - } - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return h; -} - -static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))(const char* name) -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))(const char* name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -{ - __itt_domain *h_tail = NULL, *h = NULL; - - if (name == NULL) - { - return NULL; - } - - ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); - if (_N_(_ittapi_global).api_initialized) - { -#if ITT_PLATFORM==ITT_PLATFORM_WIN - if (ITTNOTIFY_NAME(domain_createA) && ITTNOTIFY_NAME(domain_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(domain_createA)(name); - } -#else - if (ITTNOTIFY_NAME(domain_create) && ITTNOTIFY_NAME(domain_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(domain_create)(name); - } -#endif - } - for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) - { - if (h->nameA != NULL && !__itt_fstrcmp(h->nameA, name)) break; - } - if (h == NULL) - { - NEW_DOMAIN_A(&_N_(_ittapi_global),h,h_tail,name); - } - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return h; -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))(const wchar_t* name) -{ - __itt_string_handle *h_tail = NULL, *h = NULL; - - if (name == NULL) - { - return NULL; - } - - ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); - if (_N_(_ittapi_global).api_initialized) - { - if (ITTNOTIFY_NAME(string_handle_createW) && ITTNOTIFY_NAME(string_handle_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(string_handle_createW)(name); - } - } - for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) - { - if (h->strW != NULL && !wcscmp(h->strW, name)) break; - } - if (h == NULL) - { - NEW_STRING_HANDLE_W(&_N_(_ittapi_global),h,h_tail,name); - } - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return h; -} - -static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))(const char* name) -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))(const char* name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -{ - __itt_string_handle *h_tail = NULL, *h = NULL; - - if (name == NULL) - { - return NULL; - } - - ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); - if (_N_(_ittapi_global).api_initialized) - { -#if ITT_PLATFORM==ITT_PLATFORM_WIN - if (ITTNOTIFY_NAME(string_handle_createA) && ITTNOTIFY_NAME(string_handle_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(string_handle_createA)(name); - } -#else - if (ITTNOTIFY_NAME(string_handle_create) && ITTNOTIFY_NAME(string_handle_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))) - { - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return ITTNOTIFY_NAME(string_handle_create)(name); - } -#endif - } - for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) - { - if (h->strA != NULL && !__itt_fstrcmp(h->strA, name)) break; - } - if (h == NULL) - { - NEW_STRING_HANDLE_A(&_N_(_ittapi_global),h,h_tail,name); - } - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - return h; -} - -/* -------------------------------------------------------------------------- */ - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))(void) -{ - if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) - { - __itt_init_ittlib_name(NULL, __itt_group_all); - } - if (ITTNOTIFY_NAME(pause) && ITTNOTIFY_NAME(pause) != ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))) - { - ITTNOTIFY_NAME(pause)(); - } - else - { - _N_(_ittapi_global).state = __itt_collection_paused; - } -} - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))(void) -{ - if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) - { - __itt_init_ittlib_name(NULL, __itt_group_all); - } - if (ITTNOTIFY_NAME(resume) && ITTNOTIFY_NAME(resume) != ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))) - { - ITTNOTIFY_NAME(resume)(); - } - else - { - _N_(_ittapi_global).state = __itt_collection_normal; - } -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(const wchar_t* name) -{ - if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) - { - __itt_init_ittlib_name(NULL, __itt_group_all); - } - if (ITTNOTIFY_NAME(thread_set_nameW) && ITTNOTIFY_NAME(thread_set_nameW) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))) - { - ITTNOTIFY_NAME(thread_set_nameW)(name); - } -} - -static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setW),_init))(const wchar_t* name, int namelen) -{ - (void)namelen; - ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(name); - return 0; -} - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(const char* name) -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(const char* name) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -{ - if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) - { - __itt_init_ittlib_name(NULL, __itt_group_all); - } -#if ITT_PLATFORM==ITT_PLATFORM_WIN - if (ITTNOTIFY_NAME(thread_set_nameA) && ITTNOTIFY_NAME(thread_set_nameA) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))) - { - ITTNOTIFY_NAME(thread_set_nameA)(name); - } -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - if (ITTNOTIFY_NAME(thread_set_name) && ITTNOTIFY_NAME(thread_set_name) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))) - { - ITTNOTIFY_NAME(thread_set_name)(name); - } -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setA),_init))(const char* name, int namelen) -{ - (void)namelen; - ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(name); - return 0; -} -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_set),_init))(const char* name, int namelen) -{ - (void)namelen; - ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(name); - return 0; -} -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(void) -{ - if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) - { - __itt_init_ittlib_name(NULL, __itt_group_all); - } - if (ITTNOTIFY_NAME(thread_ignore) && ITTNOTIFY_NAME(thread_ignore) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))) - { - ITTNOTIFY_NAME(thread_ignore)(); - } -} - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_ignore),_init))(void) -{ - ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(); -} - -static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(enable_attach),_init))(void) -{ -#ifdef __ANDROID__ - /* - * if LIB_VAR_NAME env variable were set before then stay previous value - * else set default path - */ - setenv(ITT_TO_STR(LIB_VAR_NAME), ANDROID_ITTNOTIFY_DEFAULT_PATH, 0); -#endif -} - -/* -------------------------------------------------------------------------- */ - -static const char* __itt_fsplit(const char* s, const char* sep, const char** out, int* len) -{ - int i; - int j; - - if (!s || !sep || !out || !len) - return NULL; - - for (i = 0; s[i]; i++) - { - int b = 0; - for (j = 0; sep[j]; j++) - if (s[i] == sep[j]) - { - b = 1; - break; - } - if (!b) - break; - } - - if (!s[i]) - return NULL; - - *len = 0; - *out = &s[i]; - - for (; s[i]; i++, (*len)++) - { - int b = 0; - for (j = 0; sep[j]; j++) - if (s[i] == sep[j]) - { - b = 1; - break; - } - if (b) - break; - } - - for (; s[i]; i++) - { - int b = 0; - for (j = 0; sep[j]; j++) - if (s[i] == sep[j]) - { - b = 1; - break; - } - if (!b) - break; - } - - return &s[i]; -} - -/* This function return value of env variable that placed into static buffer. - * !!! The same static buffer is used for subsequent calls. !!! - * This was done to aviod dynamic allocation for few calls. - * Actually we need this function only four times. - */ -static const char* __itt_get_env_var(const char* name) -{ -#define MAX_ENV_VALUE_SIZE 4086 - static char env_buff[MAX_ENV_VALUE_SIZE]; - static char* env_value = (char*)env_buff; - - if (name != NULL) - { -#if ITT_PLATFORM==ITT_PLATFORM_WIN - size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); - DWORD rc = GetEnvironmentVariableA(name, env_value, (DWORD)max_len); - if (rc >= max_len) - __itt_report_error(__itt_error_env_too_long, name, (size_t)rc - 1, (size_t)(max_len - 1)); - else if (rc > 0) - { - const char* ret = (const char*)env_value; - env_value += rc + 1; - return ret; - } - else - { - /* If environment variable is empty, GetEnvirornmentVariables() - * returns zero (number of characters (not including terminating null), - * and GetLastError() returns ERROR_SUCCESS. */ - DWORD err = GetLastError(); - if (err == ERROR_SUCCESS) - return env_value; - - if (err != ERROR_ENVVAR_NOT_FOUND) - __itt_report_error(__itt_error_cant_read_env, name, (int)err); - } -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ - char* env = getenv(name); - if (env != NULL) - { - size_t len = __itt_fstrnlen(env, MAX_ENV_VALUE_SIZE); - size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); - if (len < max_len) - { - const char* ret = (const char*)env_value; - __itt_fstrcpyn(env_value, max_len, env, len + 1); - env_value += len + 1; - return ret; - } else - __itt_report_error(__itt_error_env_too_long, name, (size_t)len, (size_t)(max_len - 1)); - } -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - } - return NULL; -} - -static const char* __itt_get_lib_name(void) -{ - const char* lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); - -#ifdef __ANDROID__ - if (lib_name == NULL) - { - -#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM - const char* const marker_filename = "com.intel.itt.collector_lib_32"; -#else - const char* const marker_filename = "com.intel.itt.collector_lib_64"; -#endif - - char system_wide_marker_filename[PATH_MAX] = {0}; - int itt_marker_file_fd = -1; - ssize_t res = 0; - - res = snprintf(system_wide_marker_filename, PATH_MAX - 1, "%s%s", "/data/local/tmp/", marker_filename); - if (res < 0) - { - ITT_ANDROID_LOGE("Unable to concatenate marker file string."); - return lib_name; - } - itt_marker_file_fd = open(system_wide_marker_filename, O_RDONLY); - - if (itt_marker_file_fd == -1) - { - const pid_t my_pid = getpid(); - char cmdline_path[PATH_MAX] = {0}; - char package_name[PATH_MAX] = {0}; - char app_sandbox_file[PATH_MAX] = {0}; - int cmdline_fd = 0; - - ITT_ANDROID_LOGI("Unable to open system-wide marker file."); - res = snprintf(cmdline_path, PATH_MAX - 1, "/proc/%d/cmdline", my_pid); - if (res < 0) - { - ITT_ANDROID_LOGE("Unable to get cmdline path string."); - return lib_name; - } - - ITT_ANDROID_LOGI("CMD file: %s\n", cmdline_path); - cmdline_fd = open(cmdline_path, O_RDONLY); - if (cmdline_fd == -1) - { - ITT_ANDROID_LOGE("Unable to open %s file!", cmdline_path); - return lib_name; - } - res = read(cmdline_fd, package_name, PATH_MAX - 1); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to read %s file!", cmdline_path); - res = close(cmdline_fd); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); - } - return lib_name; - } - res = close(cmdline_fd); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); - return lib_name; - } - ITT_ANDROID_LOGI("Package name: %s\n", package_name); - res = snprintf(app_sandbox_file, PATH_MAX - 1, "/data/data/%s/%s", package_name, marker_filename); - if (res < 0) - { - ITT_ANDROID_LOGE("Unable to concatenate marker file string."); - return lib_name; - } - - ITT_ANDROID_LOGI("Lib marker file name: %s\n", app_sandbox_file); - itt_marker_file_fd = open(app_sandbox_file, O_RDONLY); - if (itt_marker_file_fd == -1) - { - ITT_ANDROID_LOGE("Unable to open app marker file!"); - return lib_name; - } - } - - { - char itt_lib_name[PATH_MAX] = {0}; - - res = read(itt_marker_file_fd, itt_lib_name, PATH_MAX - 1); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to read %s file!", itt_marker_file_fd); - res = close(itt_marker_file_fd); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); - } - return lib_name; - } - ITT_ANDROID_LOGI("ITT Lib path: %s", itt_lib_name); - res = close(itt_marker_file_fd); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); - return lib_name; - } - ITT_ANDROID_LOGI("Set env %s to %s", ITT_TO_STR(LIB_VAR_NAME), itt_lib_name); - res = setenv(ITT_TO_STR(LIB_VAR_NAME), itt_lib_name, 0); - if (res == -1) - { - ITT_ANDROID_LOGE("Unable to set env var!"); - return lib_name; - } - lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); - ITT_ANDROID_LOGI("ITT Lib path from env: %s", lib_name); - } - } -#endif - - return lib_name; -} - -#ifndef min -#define min(a,b) (a) < (b) ? (a) : (b) -#endif /* min */ - -static __itt_group_id __itt_get_groups(void) -{ - register int i; - __itt_group_id res = __itt_group_none; - const char* var_name = "INTEL_ITTNOTIFY_GROUPS"; - const char* group_str = __itt_get_env_var(var_name); - - if (group_str != NULL) - { - unsigned int len; - char gr[255]; - const char* chunk; - while ((group_str = __itt_fsplit(group_str, ",; ", &chunk, (int *)&len)) != NULL) - { - unsigned int min_len = min(len, (int)(sizeof(gr) - 1)); - __itt_fstrcpyn(gr, sizeof(gr) - 1, chunk, min_len); - gr[min_len] = 0; - - for (i = 0; group_list[i].name != NULL; i++) - { - if (!__itt_fstrcmp(gr, group_list[i].name)) - { - res = (__itt_group_id)(res | group_list[i].id); - break; - } - } - } - /* TODO: !!! Workaround for bug with warning for unknown group !!! - * Should be fixed in new initialization scheme. - * Now the following groups should be set always. */ - for (i = 0; group_list[i].id != __itt_group_none; i++) - if (group_list[i].id != __itt_group_all && - group_list[i].id > __itt_group_splitter_min && - group_list[i].id < __itt_group_splitter_max) - res = (__itt_group_id)(res | group_list[i].id); - return res; - } - else - { - for (i = 0; group_alias[i].env_var != NULL; i++) - if (__itt_get_env_var(group_alias[i].env_var) != NULL) - return group_alias[i].groups; - } - - return res; -} - -static int __itt_lib_version(lib_t lib) -{ - if (lib == NULL) - return 0; - if (__itt_get_proc(lib, "__itt_api_init")) - return 2; - if (__itt_get_proc(lib, "__itt_api_version")) - return 1; - return 0; -} - -/* It's not used right now! Comment it out to avoid warnings. -static void __itt_reinit_all_pointers(void) -{ - register int i; - // Fill all pointers with initial stubs - for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].init_func; -} -*/ - -static void __itt_nullify_all_pointers(void) -{ - register int i; - /* Nulify all pointers except domain_create and string_handle_create */ - for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(push) -#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ -#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -ITT_EXTERN_C void _N_(fini_ittlib)(void) -{ - __itt_api_fini_t* __itt_api_fini_ptr = NULL; - static volatile TIDT current_thread = 0; - - if (_N_(_ittapi_global).api_initialized) - { - __itt_mutex_lock(&_N_(_ittapi_global).mutex); - if (_N_(_ittapi_global).api_initialized) - { - if (current_thread == 0) - { - current_thread = __itt_thread_id(); - if (_N_(_ittapi_global).lib != NULL) - { - __itt_api_fini_ptr = (__itt_api_fini_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_fini"); - } - if (__itt_api_fini_ptr) - { - __itt_api_fini_ptr(&_N_(_ittapi_global)); - } - - __itt_nullify_all_pointers(); - - /* TODO: !!! not safe !!! don't support unload so far. - * if (_N_(_ittapi_global).lib != NULL) - * __itt_unload_lib(_N_(_ittapi_global).lib); - * _N_(_ittapi_global).lib = NULL; - */ - _N_(_ittapi_global).api_initialized = 0; - current_thread = 0; - } - } - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); - } -} - -ITT_EXTERN_C int _N_(init_ittlib)(const char* lib_name, __itt_group_id init_groups) -{ - register int i; - __itt_group_id groups; -#ifdef ITT_COMPLETE_GROUP - __itt_group_id zero_group = __itt_group_none; -#endif /* ITT_COMPLETE_GROUP */ - static volatile TIDT current_thread = 0; - - if (!_N_(_ittapi_global).api_initialized) - { -#ifndef ITT_SIMPLE_INIT - ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); -#endif /* ITT_SIMPLE_INIT */ - - if (!_N_(_ittapi_global).api_initialized) - { - if (current_thread == 0) - { - current_thread = __itt_thread_id(); - if (lib_name == NULL) - { - lib_name = __itt_get_lib_name(); - } - groups = __itt_get_groups(); - if (groups != __itt_group_none || lib_name != NULL) - { - _N_(_ittapi_global).lib = __itt_load_lib((lib_name == NULL) ? ittnotify_lib_name : lib_name); - - if (_N_(_ittapi_global).lib != NULL) - { - __itt_api_init_t* __itt_api_init_ptr; - int lib_version = __itt_lib_version(_N_(_ittapi_global).lib); - - switch (lib_version) { - case 0: - groups = __itt_group_legacy; - case 1: - /* Fill all pointers from dynamic library */ - for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) - { - if (_N_(_ittapi_global).api_list_ptr[i].group & groups & init_groups) - { - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = (void*)__itt_get_proc(_N_(_ittapi_global).lib, _N_(_ittapi_global).api_list_ptr[i].name); - if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr == NULL) - { - /* Restore pointers for function with static implementation */ - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; - __itt_report_error(__itt_error_no_symbol, lib_name, _N_(_ittapi_global).api_list_ptr[i].name); -#ifdef ITT_COMPLETE_GROUP - zero_group = (__itt_group_id)(zero_group | _N_(_ittapi_global).api_list_ptr[i].group); -#endif /* ITT_COMPLETE_GROUP */ - } - } - else - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; - } - - if (groups == __itt_group_legacy) - { - /* Compatibility with legacy tools */ - ITTNOTIFY_NAME(thread_ignore) = ITTNOTIFY_NAME(thr_ignore); -#if ITT_PLATFORM==ITT_PLATFORM_WIN - ITTNOTIFY_NAME(sync_createA) = ITTNOTIFY_NAME(sync_set_nameA); - ITTNOTIFY_NAME(sync_createW) = ITTNOTIFY_NAME(sync_set_nameW); -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ - ITTNOTIFY_NAME(sync_create) = ITTNOTIFY_NAME(sync_set_name); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - ITTNOTIFY_NAME(sync_prepare) = ITTNOTIFY_NAME(notify_sync_prepare); - ITTNOTIFY_NAME(sync_cancel) = ITTNOTIFY_NAME(notify_sync_cancel); - ITTNOTIFY_NAME(sync_acquired) = ITTNOTIFY_NAME(notify_sync_acquired); - ITTNOTIFY_NAME(sync_releasing) = ITTNOTIFY_NAME(notify_sync_releasing); - } - -#ifdef ITT_COMPLETE_GROUP - for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) - if (_N_(_ittapi_global).api_list_ptr[i].group & zero_group) - *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; -#endif /* ITT_COMPLETE_GROUP */ - break; - case 2: - __itt_api_init_ptr = (__itt_api_init_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_init"); - if (__itt_api_init_ptr) - __itt_api_init_ptr(&_N_(_ittapi_global), init_groups); - break; - } - } - else - { - __itt_nullify_all_pointers(); - - __itt_report_error(__itt_error_no_module, lib_name, -#if ITT_PLATFORM==ITT_PLATFORM_WIN - __itt_system_error() -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - dlerror() -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - ); - } - } - else - { - __itt_nullify_all_pointers(); - } - _N_(_ittapi_global).api_initialized = 1; - current_thread = 0; - /* !!! Just to avoid unused code elimination !!! */ - if (__itt_fini_ittlib_ptr == _N_(fini_ittlib)) current_thread = 0; - } - } - -#ifndef ITT_SIMPLE_INIT - __itt_mutex_unlock(&_N_(_ittapi_global).mutex); -#endif /* ITT_SIMPLE_INIT */ - } - - /* Evaluating if any function ptr is non empty and it's in init_groups */ - for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) - { - if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr != _N_(_ittapi_global).api_list_ptr[i].null_func && - _N_(_ittapi_global).api_list_ptr[i].group & init_groups) - { - return 1; - } - } - return 0; -} - -ITT_EXTERN_C __itt_error_handler_t* _N_(set_error_handler)(__itt_error_handler_t* handler) -{ - __itt_error_handler_t* prev = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; - _N_(_ittapi_global).error_handler = (void*)(size_t)handler; - return prev; -} - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#pragma warning(pop) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define PATH_MAX 512 +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +#include +#include +#include +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#include +#include +#include +#include + +#define INTEL_NO_MACRO_BODY +#define INTEL_ITTNOTIFY_API_PRIVATE +#include "ittnotify.h" +#include "legacy/ittnotify.h" + +#include "disable_warnings.h" + +static const char api_version[] = API_VERSION "\0\n@(#) $Revision: 422936 $\n"; + +#define _N_(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n) + +#if ITT_OS==ITT_OS_WIN +static const char* ittnotify_lib_name = "libittnotify.dll"; +#elif ITT_OS==ITT_OS_LINUX || ITT_OS==ITT_OS_FREEBSD +static const char* ittnotify_lib_name = "libittnotify.so"; +#elif ITT_OS==ITT_OS_MAC +static const char* ittnotify_lib_name = "libittnotify.dylib"; +#else +#error Unsupported or unknown OS. +#endif + +#ifdef __ANDROID__ +#include +#include +#include +#include +#include +#include +#include + +#ifdef ITT_ANDROID_LOG + #define ITT_ANDROID_LOG_TAG "INTEL_VTUNE_USERAPI" + #define ITT_ANDROID_LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) + #define ITT_ANDROID_LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG,ITT_ANDROID_LOG_TAG, __VA_ARGS__)) +#else + #define ITT_ANDROID_LOGI(...) + #define ITT_ANDROID_LOGW(...) + #define ITT_ANDROID_LOGE(...) + #define ITT_ANDROID_LOGD(...) +#endif + +/* default location of userapi collector on Android */ +#define ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(x) "/data/data/com.intel.vtune/perfrun/lib" \ + #x "/runtime/libittnotify.so" + +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM +#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(32) +#else +#define ANDROID_ITTNOTIFY_DEFAULT_PATH ANDROID_ITTNOTIFY_DEFAULT_PATH_MASK(64) +#endif + +#endif + + +#ifndef LIB_VAR_NAME +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM +#define LIB_VAR_NAME INTEL_LIBITTNOTIFY32 +#else +#define LIB_VAR_NAME INTEL_LIBITTNOTIFY64 +#endif +#endif /* LIB_VAR_NAME */ + +#define ITT_MUTEX_INIT_AND_LOCK(p) { \ + if (!p.mutex_initialized) \ + { \ + if (__itt_interlocked_increment(&p.atomic_counter) == 1) \ + { \ + __itt_mutex_init(&p.mutex); \ + p.mutex_initialized = 1; \ + } \ + else \ + while (!p.mutex_initialized) \ + __itt_thread_yield(); \ + } \ + __itt_mutex_lock(&p.mutex); \ +} + +const int _N_(err) = 0; + +typedef int (__itt_init_ittlib_t)(const char*, __itt_group_id); + +/* this define used to control initialization function name. */ +#ifndef __itt_init_ittlib_name +ITT_EXTERN_C int _N_(init_ittlib)(const char*, __itt_group_id); +static __itt_init_ittlib_t* __itt_init_ittlib_ptr = _N_(init_ittlib); +#define __itt_init_ittlib_name __itt_init_ittlib_ptr +#endif /* __itt_init_ittlib_name */ + +typedef void (__itt_fini_ittlib_t)(void); + +/* this define used to control finalization function name. */ +#ifndef __itt_fini_ittlib_name +ITT_EXTERN_C void _N_(fini_ittlib)(void); +static __itt_fini_ittlib_t* __itt_fini_ittlib_ptr = _N_(fini_ittlib); +#define __itt_fini_ittlib_name __itt_fini_ittlib_ptr +#endif /* __itt_fini_ittlib_name */ + +/* building pointers to imported funcs */ +#undef ITT_STUBV +#undef ITT_STUB +#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ +{ \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ + return ITTNOTIFY_NAME(name) params; \ + else \ + return (type)0; \ +} + +#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args \ +{ \ + __itt_init_ittlib_name(NULL, __itt_group_all); \ + if (ITTNOTIFY_NAME(name) && ITTNOTIFY_NAME(name) != ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init))) \ + ITTNOTIFY_NAME(name) params; \ + else \ + return; \ +} + +#undef __ITT_INTERNAL_INIT +#include "ittnotify_static.h" + +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END + +#define ITT_STUBV(api,type,name,args,params,ptr,group,format) \ +static type api ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)) args;\ +typedef type api ITT_JOIN(_N_(name),_t) args; \ +ITT_EXTERN_C_BEGIN ITT_JOIN(_N_(name),_t)* ITTNOTIFY_NAME(name) = ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)); ITT_EXTERN_C_END + +#define __ITT_INTERNAL_INIT +#include "ittnotify_static.h" +#undef __ITT_INTERNAL_INIT + +ITT_GROUP_LIST(group_list); + +#pragma pack(push, 8) + +typedef struct ___itt_group_alias +{ + const char* env_var; + __itt_group_id groups; +} __itt_group_alias; + +static __itt_group_alias group_alias[] = { + { "KMP_FOR_TPROFILE", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_mark) }, + { "KMP_FOR_TCHECK", (__itt_group_id)(__itt_group_control | __itt_group_thread | __itt_group_sync | __itt_group_fsync | __itt_group_mark | __itt_group_suppress) }, + { NULL, (__itt_group_none) }, + { api_version, (__itt_group_none) } /* !!! Just to avoid unused code elimination !!! */ +}; + +#pragma pack(pop) + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static __itt_api_info api_list[] = { +/* Define functions with static implementation */ +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,nameindll,group,format) { ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), (__itt_group_id)(group)}, +#define ITT_STUBV ITT_STUB +#define __ITT_INTERNAL_INIT +#include "ittnotify_static.h" +#undef __ITT_INTERNAL_INIT +/* Define functions without static implementation */ +#undef ITT_STUB +#undef ITT_STUBV +#define ITT_STUB(api,type,name,args,params,nameindll,group,format) {ITT_TO_STR(ITT_JOIN(__itt_,nameindll)), (void**)(void*)&ITTNOTIFY_NAME(name), (void*)(size_t)&ITT_VERSIONIZE(ITT_JOIN(_N_(name),_init)), NULL, (__itt_group_id)(group)}, +#define ITT_STUBV ITT_STUB +#include "ittnotify_static.h" + {NULL, NULL, NULL, NULL, __itt_group_none} +}; + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static const char dll_path[PATH_MAX] = { 0 }; + +/* static part descriptor which handles. all notification api attributes. */ +__itt_global _N_(_ittapi_global) = { + ITT_MAGIC, /* identification info */ + ITT_MAJOR, ITT_MINOR, API_VERSION_BUILD, /* version info */ + 0, /* api_initialized */ + 0, /* mutex_initialized */ + 0, /* atomic_counter */ + MUTEX_INITIALIZER, /* mutex */ + NULL, /* dynamic library handle */ + NULL, /* error_handler */ + (const char**)&dll_path, /* dll_path_ptr */ + (__itt_api_info*)&api_list, /* api_list_ptr */ + NULL, /* next __itt_global */ + NULL, /* thread_list */ + NULL, /* domain_list */ + NULL, /* string_list */ + __itt_collection_normal /* collection state */ +}; + +ITT_EXTERN_C __itt_global* _N_(get_ittapi_global)(void) { return &_N_(_ittapi_global); } +typedef void (__itt_api_init_t)(__itt_global*, __itt_group_id); +typedef void (__itt_api_fini_t)(__itt_global*); + +/* ========================================================================= */ + +#ifdef ITT_NOTIFY_EXT_REPORT +ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); +#endif /* ITT_NOTIFY_EXT_REPORT */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static void __itt_report_error(__itt_error_code code, ...) +{ + va_list args; + va_start(args, code); + if (_N_(_ittapi_global).error_handler != NULL) + { + __itt_error_handler_t* handler = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; + handler(code, args); + } +#ifdef ITT_NOTIFY_EXT_REPORT + _N_(error_handler)(code, args); +#endif /* ITT_NOTIFY_EXT_REPORT */ + va_end(args); +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))(const wchar_t* name) +{ + __itt_domain *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { + if (ITTNOTIFY_NAME(domain_createW) && ITTNOTIFY_NAME(domain_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createW),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_createW)(name); + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) + { + if (h->nameW != NULL && !wcscmp(h->nameW, name)) break; + } + if (h == NULL) + { + NEW_DOMAIN_W(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))(const char* name) +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +static __itt_domain* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + __itt_domain *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(domain_createA) && ITTNOTIFY_NAME(domain_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_createA),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_createA)(name); + } +#else + if (ITTNOTIFY_NAME(domain_create) && ITTNOTIFY_NAME(domain_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(domain_create),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(domain_create)(name); + } +#endif + } + for (h_tail = NULL, h = _N_(_ittapi_global).domain_list; h != NULL; h_tail = h, h = h->next) + { + if (h->nameA != NULL && !__itt_fstrcmp(h->nameA, name)) break; + } + if (h == NULL) + { + NEW_DOMAIN_A(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))(const wchar_t* name) +{ + __itt_string_handle *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { + if (ITTNOTIFY_NAME(string_handle_createW) && ITTNOTIFY_NAME(string_handle_createW) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createW),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_createW)(name); + } + } + for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) + { + if (h->strW != NULL && !wcscmp(h->strW, name)) break; + } + if (h == NULL) + { + NEW_STRING_HANDLE_W(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))(const char* name) +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +static __itt_string_handle* ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + __itt_string_handle *h_tail = NULL, *h = NULL; + + if (name == NULL) + { + return NULL; + } + + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); + if (_N_(_ittapi_global).api_initialized) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(string_handle_createA) && ITTNOTIFY_NAME(string_handle_createA) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_createA),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_createA)(name); + } +#else + if (ITTNOTIFY_NAME(string_handle_create) && ITTNOTIFY_NAME(string_handle_create) != ITT_VERSIONIZE(ITT_JOIN(_N_(string_handle_create),_init))) + { + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return ITTNOTIFY_NAME(string_handle_create)(name); + } +#endif + } + for (h_tail = NULL, h = _N_(_ittapi_global).string_list; h != NULL; h_tail = h, h = h->next) + { + if (h->strA != NULL && !__itt_fstrcmp(h->strA, name)) break; + } + if (h == NULL) + { + NEW_STRING_HANDLE_A(&_N_(_ittapi_global),h,h_tail,name); + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + return h; +} + +/* -------------------------------------------------------------------------- */ + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(pause) && ITTNOTIFY_NAME(pause) != ITT_VERSIONIZE(ITT_JOIN(_N_(pause),_init))) + { + ITTNOTIFY_NAME(pause)(); + } + else + { + _N_(_ittapi_global).state = __itt_collection_paused; + } +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(resume) && ITTNOTIFY_NAME(resume) != ITT_VERSIONIZE(ITT_JOIN(_N_(resume),_init))) + { + ITTNOTIFY_NAME(resume)(); + } + else + { + _N_(_ittapi_global).state = __itt_collection_normal; + } +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(const wchar_t* name) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(thread_set_nameW) && ITTNOTIFY_NAME(thread_set_nameW) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))) + { + ITTNOTIFY_NAME(thread_set_nameW)(name); + } +} + +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setW),_init))(const wchar_t* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameW),_init))(name); + return 0; +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(const char* name) +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(const char* name) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } +#if ITT_PLATFORM==ITT_PLATFORM_WIN + if (ITTNOTIFY_NAME(thread_set_nameA) && ITTNOTIFY_NAME(thread_set_nameA) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))) + { + ITTNOTIFY_NAME(thread_set_nameA)(name); + } +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (ITTNOTIFY_NAME(thread_set_name) && ITTNOTIFY_NAME(thread_set_name) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))) + { + ITTNOTIFY_NAME(thread_set_name)(name); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_setA),_init))(const char* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_nameA),_init))(name); + return 0; +} +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +static int ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_name_set),_init))(const char* name, int namelen) +{ + (void)namelen; + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_set_name),_init))(name); + return 0; +} +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(void) +{ + if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL) + { + __itt_init_ittlib_name(NULL, __itt_group_all); + } + if (ITTNOTIFY_NAME(thread_ignore) && ITTNOTIFY_NAME(thread_ignore) != ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))) + { + ITTNOTIFY_NAME(thread_ignore)(); + } +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(thr_ignore),_init))(void) +{ + ITT_VERSIONIZE(ITT_JOIN(_N_(thread_ignore),_init))(); +} + +static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(enable_attach),_init))(void) +{ +#ifdef __ANDROID__ + /* + * if LIB_VAR_NAME env variable were set before then stay previous value + * else set default path + */ + setenv(ITT_TO_STR(LIB_VAR_NAME), ANDROID_ITTNOTIFY_DEFAULT_PATH, 0); +#endif +} + +/* -------------------------------------------------------------------------- */ + +static const char* __itt_fsplit(const char* s, const char* sep, const char** out, int* len) +{ + int i; + int j; + + if (!s || !sep || !out || !len) + return NULL; + + for (i = 0; s[i]; i++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (!b) + break; + } + + if (!s[i]) + return NULL; + + *len = 0; + *out = &s[i]; + + for (; s[i]; i++, (*len)++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (b) + break; + } + + for (; s[i]; i++) + { + int b = 0; + for (j = 0; sep[j]; j++) + if (s[i] == sep[j]) + { + b = 1; + break; + } + if (!b) + break; + } + + return &s[i]; +} + +/* This function return value of env variable that placed into static buffer. + * !!! The same static buffer is used for subsequent calls. !!! + * This was done to aviod dynamic allocation for few calls. + * Actually we need this function only four times. + */ +static const char* __itt_get_env_var(const char* name) +{ +#define MAX_ENV_VALUE_SIZE 4086 + static char env_buff[MAX_ENV_VALUE_SIZE]; + static char* env_value = (char*)env_buff; + + if (name != NULL) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); + DWORD rc = GetEnvironmentVariableA(name, env_value, (DWORD)max_len); + if (rc >= max_len) + __itt_report_error(__itt_error_env_too_long, name, (size_t)rc - 1, (size_t)(max_len - 1)); + else if (rc > 0) + { + const char* ret = (const char*)env_value; + env_value += rc + 1; + return ret; + } + else + { + /* If environment variable is empty, GetEnvirornmentVariables() + * returns zero (number of characters (not including terminating null), + * and GetLastError() returns ERROR_SUCCESS. */ + DWORD err = GetLastError(); + if (err == ERROR_SUCCESS) + return env_value; + + if (err != ERROR_ENVVAR_NOT_FOUND) + __itt_report_error(__itt_error_cant_read_env, name, (int)err); + } +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ + char* env = getenv(name); + if (env != NULL) + { + size_t len = __itt_fstrnlen(env, MAX_ENV_VALUE_SIZE); + size_t max_len = MAX_ENV_VALUE_SIZE - (size_t)(env_value - env_buff); + if (len < max_len) + { + const char* ret = (const char*)env_value; + __itt_fstrcpyn(env_value, max_len, env, len + 1); + env_value += len + 1; + return ret; + } else + __itt_report_error(__itt_error_env_too_long, name, (size_t)len, (size_t)(max_len - 1)); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + } + return NULL; +} + +static const char* __itt_get_lib_name(void) +{ + const char* lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); + +#ifdef __ANDROID__ + if (lib_name == NULL) + { + +#if ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_ARM + const char* const marker_filename = "com.intel.itt.collector_lib_32"; +#else + const char* const marker_filename = "com.intel.itt.collector_lib_64"; +#endif + + char system_wide_marker_filename[PATH_MAX] = {0}; + int itt_marker_file_fd = -1; + ssize_t res = 0; + + res = snprintf(system_wide_marker_filename, PATH_MAX - 1, "%s%s", "/data/local/tmp/", marker_filename); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to concatenate marker file string."); + return lib_name; + } + itt_marker_file_fd = open(system_wide_marker_filename, O_RDONLY); + + if (itt_marker_file_fd == -1) + { + const pid_t my_pid = getpid(); + char cmdline_path[PATH_MAX] = {0}; + char package_name[PATH_MAX] = {0}; + char app_sandbox_file[PATH_MAX] = {0}; + int cmdline_fd = 0; + + ITT_ANDROID_LOGI("Unable to open system-wide marker file."); + res = snprintf(cmdline_path, PATH_MAX - 1, "/proc/%d/cmdline", my_pid); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to get cmdline path string."); + return lib_name; + } + + ITT_ANDROID_LOGI("CMD file: %s\n", cmdline_path); + cmdline_fd = open(cmdline_path, O_RDONLY); + if (cmdline_fd == -1) + { + ITT_ANDROID_LOGE("Unable to open %s file!", cmdline_path); + return lib_name; + } + res = read(cmdline_fd, package_name, PATH_MAX - 1); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to read %s file!", cmdline_path); + res = close(cmdline_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); + } + return lib_name; + } + res = close(cmdline_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", cmdline_path); + return lib_name; + } + ITT_ANDROID_LOGI("Package name: %s\n", package_name); + res = snprintf(app_sandbox_file, PATH_MAX - 1, "/data/data/%s/%s", package_name, marker_filename); + if (res < 0) + { + ITT_ANDROID_LOGE("Unable to concatenate marker file string."); + return lib_name; + } + + ITT_ANDROID_LOGI("Lib marker file name: %s\n", app_sandbox_file); + itt_marker_file_fd = open(app_sandbox_file, O_RDONLY); + if (itt_marker_file_fd == -1) + { + ITT_ANDROID_LOGE("Unable to open app marker file!"); + return lib_name; + } + } + + { + char itt_lib_name[PATH_MAX] = {0}; + + res = read(itt_marker_file_fd, itt_lib_name, PATH_MAX - 1); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to read %s file!", itt_marker_file_fd); + res = close(itt_marker_file_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); + } + return lib_name; + } + ITT_ANDROID_LOGI("ITT Lib path: %s", itt_lib_name); + res = close(itt_marker_file_fd); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to close %s file!", itt_marker_file_fd); + return lib_name; + } + ITT_ANDROID_LOGI("Set env %s to %s", ITT_TO_STR(LIB_VAR_NAME), itt_lib_name); + res = setenv(ITT_TO_STR(LIB_VAR_NAME), itt_lib_name, 0); + if (res == -1) + { + ITT_ANDROID_LOGE("Unable to set env var!"); + return lib_name; + } + lib_name = __itt_get_env_var(ITT_TO_STR(LIB_VAR_NAME)); + ITT_ANDROID_LOGI("ITT Lib path from env: %s", lib_name); + } + } +#endif + + return lib_name; +} + +#ifndef min +#define min(a,b) (a) < (b) ? (a) : (b) +#endif /* min */ + +static __itt_group_id __itt_get_groups(void) +{ + register int i; + __itt_group_id res = __itt_group_none; + const char* var_name = "INTEL_ITTNOTIFY_GROUPS"; + const char* group_str = __itt_get_env_var(var_name); + + if (group_str != NULL) + { + unsigned int len; + char gr[255]; + const char* chunk; + while ((group_str = __itt_fsplit(group_str, ",; ", &chunk, (int *)&len)) != NULL) + { + unsigned int min_len = min(len, (int)(sizeof(gr) - 1)); + __itt_fstrcpyn(gr, sizeof(gr) - 1, chunk, min_len); + gr[min_len] = 0; + + for (i = 0; group_list[i].name != NULL; i++) + { + if (!__itt_fstrcmp(gr, group_list[i].name)) + { + res = (__itt_group_id)(res | group_list[i].id); + break; + } + } + } + /* TODO: !!! Workaround for bug with warning for unknown group !!! + * Should be fixed in new initialization scheme. + * Now the following groups should be set always. */ + for (i = 0; group_list[i].id != __itt_group_none; i++) + if (group_list[i].id != __itt_group_all && + group_list[i].id > __itt_group_splitter_min && + group_list[i].id < __itt_group_splitter_max) + res = (__itt_group_id)(res | group_list[i].id); + return res; + } + else + { + for (i = 0; group_alias[i].env_var != NULL; i++) + if (__itt_get_env_var(group_alias[i].env_var) != NULL) + return group_alias[i].groups; + } + + return res; +} + +static int __itt_lib_version(lib_t lib) +{ + if (lib == NULL) + return 0; + if (__itt_get_proc(lib, "__itt_api_init")) + return 2; + if (__itt_get_proc(lib, "__itt_api_version")) + return 1; + return 0; +} + +/* It's not used right now! Comment it out to avoid warnings. +static void __itt_reinit_all_pointers(void) +{ + register int i; + // Fill all pointers with initial stubs + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].init_func; +} +*/ + +static void __itt_nullify_all_pointers(void) +{ + register int i; + /* Nulify all pointers except domain_create and string_handle_create */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(push) +#pragma warning(disable: 4054) /* warning C4054: 'type cast' : from function pointer 'XXX' to data pointer 'void *' */ +#pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_EXTERN_C void _N_(fini_ittlib)(void) +{ + __itt_api_fini_t* __itt_api_fini_ptr = NULL; + static volatile TIDT current_thread = 0; + + if (_N_(_ittapi_global).api_initialized) + { + __itt_mutex_lock(&_N_(_ittapi_global).mutex); + if (_N_(_ittapi_global).api_initialized) + { + if (current_thread == 0) + { + current_thread = __itt_thread_id(); + if (_N_(_ittapi_global).lib != NULL) + { + __itt_api_fini_ptr = (__itt_api_fini_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_fini"); + } + if (__itt_api_fini_ptr) + { + __itt_api_fini_ptr(&_N_(_ittapi_global)); + } + + __itt_nullify_all_pointers(); + + /* TODO: !!! not safe !!! don't support unload so far. + * if (_N_(_ittapi_global).lib != NULL) + * __itt_unload_lib(_N_(_ittapi_global).lib); + * _N_(_ittapi_global).lib = NULL; + */ + _N_(_ittapi_global).api_initialized = 0; + current_thread = 0; + } + } + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); + } +} + +ITT_EXTERN_C int _N_(init_ittlib)(const char* lib_name, __itt_group_id init_groups) +{ + register int i; + __itt_group_id groups; +#ifdef ITT_COMPLETE_GROUP + __itt_group_id zero_group = __itt_group_none; +#endif /* ITT_COMPLETE_GROUP */ + static volatile TIDT current_thread = 0; + + if (!_N_(_ittapi_global).api_initialized) + { +#ifndef ITT_SIMPLE_INIT + ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global)); +#endif /* ITT_SIMPLE_INIT */ + + if (!_N_(_ittapi_global).api_initialized) + { + if (current_thread == 0) + { + current_thread = __itt_thread_id(); + if (lib_name == NULL) + { + lib_name = __itt_get_lib_name(); + } + groups = __itt_get_groups(); + if (groups != __itt_group_none || lib_name != NULL) + { + _N_(_ittapi_global).lib = __itt_load_lib((lib_name == NULL) ? ittnotify_lib_name : lib_name); + + if (_N_(_ittapi_global).lib != NULL) + { + __itt_api_init_t* __itt_api_init_ptr; + int lib_version = __itt_lib_version(_N_(_ittapi_global).lib); + + switch (lib_version) { + case 0: + groups = __itt_group_legacy; + case 1: + /* Fill all pointers from dynamic library */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + { + if (_N_(_ittapi_global).api_list_ptr[i].group & groups & init_groups) + { + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = (void*)__itt_get_proc(_N_(_ittapi_global).lib, _N_(_ittapi_global).api_list_ptr[i].name); + if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr == NULL) + { + /* Restore pointers for function with static implementation */ + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; + __itt_report_error(__itt_error_no_symbol, lib_name, _N_(_ittapi_global).api_list_ptr[i].name); +#ifdef ITT_COMPLETE_GROUP + zero_group = (__itt_group_id)(zero_group | _N_(_ittapi_global).api_list_ptr[i].group); +#endif /* ITT_COMPLETE_GROUP */ + } + } + else + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; + } + + if (groups == __itt_group_legacy) + { + /* Compatibility with legacy tools */ + ITTNOTIFY_NAME(thread_ignore) = ITTNOTIFY_NAME(thr_ignore); +#if ITT_PLATFORM==ITT_PLATFORM_WIN + ITTNOTIFY_NAME(sync_createA) = ITTNOTIFY_NAME(sync_set_nameA); + ITTNOTIFY_NAME(sync_createW) = ITTNOTIFY_NAME(sync_set_nameW); +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ + ITTNOTIFY_NAME(sync_create) = ITTNOTIFY_NAME(sync_set_name); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + ITTNOTIFY_NAME(sync_prepare) = ITTNOTIFY_NAME(notify_sync_prepare); + ITTNOTIFY_NAME(sync_cancel) = ITTNOTIFY_NAME(notify_sync_cancel); + ITTNOTIFY_NAME(sync_acquired) = ITTNOTIFY_NAME(notify_sync_acquired); + ITTNOTIFY_NAME(sync_releasing) = ITTNOTIFY_NAME(notify_sync_releasing); + } + +#ifdef ITT_COMPLETE_GROUP + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + if (_N_(_ittapi_global).api_list_ptr[i].group & zero_group) + *_N_(_ittapi_global).api_list_ptr[i].func_ptr = _N_(_ittapi_global).api_list_ptr[i].null_func; +#endif /* ITT_COMPLETE_GROUP */ + break; + case 2: + __itt_api_init_ptr = (__itt_api_init_t*)(size_t)__itt_get_proc(_N_(_ittapi_global).lib, "__itt_api_init"); + if (__itt_api_init_ptr) + __itt_api_init_ptr(&_N_(_ittapi_global), init_groups); + break; + } + } + else + { + __itt_nullify_all_pointers(); + + __itt_report_error(__itt_error_no_module, lib_name, +#if ITT_PLATFORM==ITT_PLATFORM_WIN + __itt_system_error() +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dlerror() +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + ); + } + } + else + { + __itt_nullify_all_pointers(); + } + _N_(_ittapi_global).api_initialized = 1; + current_thread = 0; + /* !!! Just to avoid unused code elimination !!! */ + if (__itt_fini_ittlib_ptr == _N_(fini_ittlib)) current_thread = 0; + } + } + +#ifndef ITT_SIMPLE_INIT + __itt_mutex_unlock(&_N_(_ittapi_global).mutex); +#endif /* ITT_SIMPLE_INIT */ + } + + /* Evaluating if any function ptr is non empty and it's in init_groups */ + for (i = 0; _N_(_ittapi_global).api_list_ptr[i].name != NULL; i++) + { + if (*_N_(_ittapi_global).api_list_ptr[i].func_ptr != _N_(_ittapi_global).api_list_ptr[i].null_func && + _N_(_ittapi_global).api_list_ptr[i].group & init_groups) + { + return 1; + } + } + return 0; +} + +ITT_EXTERN_C __itt_error_handler_t* _N_(set_error_handler)(__itt_error_handler_t* handler) +{ + __itt_error_handler_t* prev = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; + _N_(_ittapi_global).error_handler = (void*)(size_t)handler; + return prev; +} + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#pragma warning(pop) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h index e728f8b154..a710a542ae 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_static.h @@ -1,376 +1,376 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 "ittnotify_config.h" - -#ifndef ITT_FORMAT_DEFINED -# ifndef ITT_FORMAT -# define ITT_FORMAT -# endif /* ITT_FORMAT */ -# ifndef ITT_NO_PARAMS -# define ITT_NO_PARAMS -# endif /* ITT_NO_PARAMS */ -#endif /* ITT_FORMAT_DEFINED */ - -/* - * parameters for macro expected: - * ITT_STUB(api, type, func_name, arguments, params, func_name_in_dll, group, printf_fmt) - */ -#ifdef __ITT_INTERNAL_INIT - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name), (ITT_FORMAT name), domain_createA, __itt_group_structure, "\"%s\"") -ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name), (ITT_FORMAT name), domain_createW, __itt_group_structure, "\"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name), (ITT_FORMAT name), domain_create, __itt_group_structure, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name), (ITT_FORMAT name), string_handle_createA, __itt_group_structure, "\"%s\"") -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name), (ITT_FORMAT name), string_handle_createW, __itt_group_structure, "\"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name), (ITT_FORMAT name), string_handle_create, __itt_group_structure, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -ITT_STUBV(ITTAPI, void, pause, (void), (ITT_NO_PARAMS), pause, __itt_group_control | __itt_group_legacy, "no args") -ITT_STUBV(ITTAPI, void, resume, (void), (ITT_NO_PARAMS), resume, __itt_group_control | __itt_group_legacy, "no args") - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name), (ITT_FORMAT name), thread_set_nameA, __itt_group_thread, "\"%s\"") -ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name), (ITT_FORMAT name), thread_set_nameW, __itt_group_thread, "\"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name), (ITT_FORMAT name), thread_set_name, __itt_group_thread, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, thread_ignore, (void), (ITT_NO_PARAMS), thread_ignore, __itt_group_thread, "no args") - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setA, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") -ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setW, __itt_group_thread | __itt_group_legacy, "\"%S\", %d") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_set, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(LIBITTAPI, void, thr_ignore, (void), (ITT_NO_PARAMS), thr_ignore, __itt_group_thread | __itt_group_legacy, "no args") -#endif /* __ITT_INTERNAL_BODY */ - -ITT_STUBV(ITTAPI, void, enable_attach, (void), (ITT_NO_PARAMS), enable_attach, __itt_group_all, "no args") - -#else /* __ITT_INTERNAL_INIT */ - -ITT_STUBV(ITTAPI, void, detach, (void), (ITT_NO_PARAMS), detach, __itt_group_control | __itt_group_legacy, "no args") - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") -ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\", \"%S\", %x") -ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_renameA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") -ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name), (ITT_FORMAT addr, name), sync_renameW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_create, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") -ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_rename, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr), (ITT_FORMAT addr), sync_destroy, __itt_group_sync | __itt_group_fsync, "%p") - -ITT_STUBV(ITTAPI, void, sync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_sync, "%p") -ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_sync, "%p") -ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_sync, "%p") -ITT_STUBV(ITTAPI, void, sync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_sync, "%p") - -ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask), (ITT_FORMAT mask), suppress_push, __itt_group_suppress, "%p") -ITT_STUBV(ITTAPI, void, suppress_pop, (void), (ITT_NO_PARAMS), suppress_pop, __itt_group_suppress, "no args") -ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_mark_range, __itt_group_suppress, "%d, %p, %p, %d") -ITT_STUBV(ITTAPI, void, suppress_clear_range,(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_clear_range,__itt_group_suppress, "%d, %p, %p, %d") - -ITT_STUBV(ITTAPI, void, fsync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_fsync, "%p") -ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_fsync, "%p") -ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_fsync, "%p") -ITT_STUBV(ITTAPI, void, fsync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_fsync, "%p") - -ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name), (ITT_FORMAT site, instance, name), model_site_begin, __itt_group_model, "%p, %p, \"%s\"") -ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance), (ITT_FORMAT site, instance), model_site_end, __itt_group_model, "%p, %p") -ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name), (ITT_FORMAT task, instance, name), model_task_begin, __itt_group_model, "%p, %p, \"%s\"") -ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance), (ITT_FORMAT task, instance), model_task_end, __itt_group_model, "%p, %p") -ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock), (ITT_FORMAT lock), model_lock_acquire, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock), (ITT_FORMAT lock), model_lock_release, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size), (ITT_FORMAT addr, size), model_record_allocation, __itt_group_model, "%p, %d") -ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr), (ITT_FORMAT addr), model_record_deallocation, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_induction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_induction_uses, __itt_group_model, "%p, %d") -ITT_STUBV(ITTAPI, void, model_reduction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_reduction_uses, __itt_group_model, "%p, %d") -ITT_STUBV(ITTAPI, void, model_observe_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_observe_uses, __itt_group_model, "%p, %d") -ITT_STUBV(ITTAPI, void, model_clear_uses, (void* addr), (ITT_FORMAT addr), model_clear_uses, __itt_group_model, "%p") - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name), (ITT_FORMAT name), model_site_beginW, __itt_group_model, "\"%s\"") -ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name), (ITT_FORMAT name), model_task_beginW, __itt_group_model, "\"%s\"") -ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name), (ITT_FORMAT name), model_iteration_taskW, __itt_group_model, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name), (ITT_FORMAT name), model_site_beginA, __itt_group_model, "\"%s\"") -ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_site_beginAL, __itt_group_model, "\"%s\", %d") -ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name), (ITT_FORMAT name), model_task_beginA, __itt_group_model, "\"%s\"") -ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_task_beginAL, __itt_group_model, "\"%s\", %d") -ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name), (ITT_FORMAT name), model_iteration_taskA, __itt_group_model, "\"%s\"") -ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_iteration_taskAL, __itt_group_model, "\"%s\", %d") -ITT_STUBV(ITTAPI, void, model_site_end_2, (void), (ITT_NO_PARAMS), model_site_end_2, __itt_group_model, "no args") -ITT_STUBV(ITTAPI, void, model_task_end_2, (void), (ITT_NO_PARAMS), model_task_end_2, __itt_group_model, "no args") -ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock), (ITT_FORMAT lock), model_lock_acquire_2, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock), (ITT_FORMAT lock), model_lock_release_2, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t count), (ITT_FORMAT count), model_aggregate_task, __itt_group_model, "%d") -ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x), (ITT_FORMAT x), model_disable_push, __itt_group_model, "%p") -ITT_STUBV(ITTAPI, void, model_disable_pop, (void), (ITT_NO_PARAMS), model_disable_pop, __itt_group_model, "no args") -#endif /* __ITT_INTERNAL_BODY */ - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_createA, __itt_group_heap, "\"%s\", \"%s\"") -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), heap_function_createW, __itt_group_heap, "\"%s\", \"%s\"") -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_create, __itt_group_heap, "\"%s\", \"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ -ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized), (ITT_FORMAT h, size, initialized), heap_allocate_begin, __itt_group_heap, "%p, %lu, %d") -ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized), (ITT_FORMAT h, addr, size, initialized), heap_allocate_end, __itt_group_heap, "%p, %p, %lu, %d") -ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_begin, __itt_group_heap, "%p, %p") -ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_end, __itt_group_heap, "%p, %p") -ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_size, initialized), heap_reallocate_begin, __itt_group_heap, "%p, %p, %lu, %d") -ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_addr, new_size, initialized), heap_reallocate_end, __itt_group_heap, "%p, %p, %p, %lu, %d") -ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void), (ITT_NO_PARAMS), heap_internal_access_begin, __itt_group_heap, "no args") -ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void), (ITT_NO_PARAMS), heap_internal_access_end, __itt_group_heap, "no args") -ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void), (ITT_NO_PARAMS), heap_record_memory_growth_begin, __itt_group_heap, "no args") -ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void), (ITT_NO_PARAMS), heap_record_memory_growth_end, __itt_group_heap, "no args") -ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask), (ITT_FORMAT reset_mask), heap_reset_detection, __itt_group_heap, "%u") -ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask), (ITT_FORMAT record_mask), heap_record, __itt_group_heap, "%u") - -ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_create, __itt_group_structure, "%p, %lu") -ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_destroy, __itt_group_structure, "%p, %lu") - -ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void), (ITT_NO_PARAMS), get_timestamp, __itt_group_structure, "no args") - -ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), region_begin, __itt_group_structure, "%p, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), region_end, __itt_group_structure, "%p, %lu") - -#ifndef __ITT_INTERNAL_BODY -ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_begin_v3, __itt_group_structure, "%p, %p") -ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_end_v3, __itt_group_structure, "%p, %p") -ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end), (ITT_FORMAT domain, id, begin, end), frame_submit_v3, __itt_group_structure, "%p, %p, %lu, %lu") -#endif /* __ITT_INTERNAL_BODY */ - -ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_group, __itt_group_structure, "%p, %lu, %lu, %p") - -ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin, __itt_group_structure, "%p, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parent, void* fn), (ITT_FORMAT domain, id, parent, fn), task_begin_fn, __itt_group_structure, "%p, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain), (ITT_FORMAT domain), task_end, __itt_group_structure, "%p") - -ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name), (ITT_FORMAT domain, name), counter_inc_v3, __itt_group_structure, "%p, %p") -ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long value), (ITT_FORMAT domain, name, value), counter_inc_delta_v3, __itt_group_structure, "%p, %p, %lu") - -ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, id, name, scope), marker, __itt_group_structure, "%p, %lu, %p, %d") - -ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, id, key, type, count, data), metadata_add, __itt_group_structure, "%p, %lu, %p, %d, %lu, %p") -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addA, __itt_group_structure, "%p, %lu, %p, %p, %lu") -ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addW, __itt_group_structure, "%p, %lu, %p, %p, %lu") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_add, __itt_group_structure, "%p, %lu, %p, %p, %lu") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, relation, tail), relation_add_to_current, __itt_group_structure, "%p, %lu, %p") -ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, head, relation, tail), relation_add, __itt_group_structure, "%p, %p, %lu, %p") - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_createA, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") -ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), event_createW, __itt_group_mark | __itt_group_legacy, "\"%S\", %d") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_create, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event), (ITT_FORMAT event), event_start, __itt_group_mark | __itt_group_legacy, "%d") -ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event), (ITT_FORMAT event), event_end, __itt_group_mark | __itt_group_legacy, "%d") -#endif /* __ITT_INTERNAL_BODY */ - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", \"%s\", %x") -ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", \"%S\", %x") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "p, \"%s\", \"%s\", %x") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") -ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *p, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", %d, \"%S\", %d, %x") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *p), (ITT_FORMAT p), notify_sync_prepare, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") -ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *p), (ITT_FORMAT p), notify_sync_cancel, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") -ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *p), (ITT_FORMAT p), notify_sync_acquired, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") -ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *p), (ITT_FORMAT p), notify_sync_releasing, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") -#endif /* __ITT_INTERNAL_BODY */ - -ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_read, __itt_group_legacy, "%p, %lu") -ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_write, __itt_group_legacy, "%p, %lu") -ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_update, __itt_group_legacy, "%p, %lu") - -ITT_STUB(LIBITTAPI, __itt_state_t, state_get, (void), (ITT_NO_PARAMS), state_get, __itt_group_legacy, "no args") -ITT_STUB(LIBITTAPI, __itt_state_t, state_set, (__itt_state_t s), (ITT_FORMAT s), state_set, __itt_group_legacy, "%d") -ITT_STUB(LIBITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s), (ITT_FORMAT p, s), obj_mode_set, __itt_group_legacy, "%d, %d") -ITT_STUB(LIBITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s), (ITT_FORMAT p, s), thr_mode_set, __itt_group_legacy, "%d, %d") - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain), (ITT_FORMAT domain), frame_createA, __itt_group_frame, "\"%s\"") -ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain), (ITT_FORMAT domain), frame_createW, __itt_group_frame, "\"%s\"") -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain), (ITT_FORMAT domain), frame_create, __itt_group_frame, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ -ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame), (ITT_FORMAT frame), frame_begin, __itt_group_frame, "%p") -ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame), (ITT_FORMAT frame), frame_end, __itt_group_frame, "%p") - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_createA, __itt_group_counter, "\"%s\", \"%s\"") -ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), counter_createW, __itt_group_counter, "\"%s\", \"%s\"") -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_create, __itt_group_counter, "\"%s\", \"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ -ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id), (ITT_FORMAT id), counter_destroy, __itt_group_counter, "%p") -ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id), (ITT_FORMAT id), counter_inc, __itt_group_counter, "%p") -ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value), (ITT_FORMAT id, value), counter_inc_delta, __itt_group_counter, "%p, %lu") - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name), (ITT_FORMAT name), mark_createA, __itt_group_mark, "\"%s\"") -ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name), (ITT_FORMAT name), mark_createW, __itt_group_mark, "\"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name), (ITT_FORMAT name), mark_create, __itt_group_mark, "\"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), markA, __itt_group_mark, "%d, \"%s\"") -ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), markW, __itt_group_mark, "%d, \"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark, __itt_group_mark, "%d, \"%s\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_off, __itt_group_mark, "%d") -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_globalA, __itt_group_mark, "%d, \"%s\"") -ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), mark_globalW, __itt_group_mark, "%d, \"%S\"") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_global, __itt_group_mark, "%d, \"%S\"") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_global_off, __itt_group_mark, "%d") - -#ifndef __ITT_INTERNAL_BODY -ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void), (ITT_NO_PARAMS), stack_caller_create, __itt_group_stitch, "no args") -#endif /* __ITT_INTERNAL_BODY */ -ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id), (ITT_FORMAT id), stack_caller_destroy, __itt_group_stitch, "%p") -ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id), (ITT_FORMAT id), stack_callee_enter, __itt_group_stitch, "%p") -ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id), (ITT_FORMAT id), stack_callee_leave, __itt_group_stitch, "%p") - -ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data), (ITT_FORMAT fn, fn_data), clock_domain_create, __itt_group_structure, "%p, %p") -ITT_STUBV(ITTAPI, void, clock_domain_reset, (void), (ITT_NO_PARAMS), clock_domain_reset, __itt_group_structure, "no args") -ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_create_ex, __itt_group_structure, "%p, %p, %lu, %lu") -ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_destroy_ex, __itt_group_structure, "%p, %p, %lu, %lu") -ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, fn), task_begin_fn_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp), (ITT_FORMAT domain, clock_domain, timestamp), task_end_ex, __itt_group_structure, "%p, %p, %lu") -ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin_overlapped, __itt_group_structure, "%p, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") -ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), task_end_overlapped, __itt_group_structure, "%p, %lu") -ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), task_end_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu") -ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, clock_domain, timestamp, id, name, scope), marker_ex, __itt_group_structure, "%p, %p, %lu, %lu, %p, %d") -ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, scope, key, type, count, data), metadata_add_with_scope, __itt_group_structure, "%p, %d, %p, %d, %lu, %p") -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeA, __itt_group_structure, "%p, %d, %p, %p, %lu") -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeW, __itt_group_structure, "%p, %d, %p, %p, %lu") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scope, __itt_group_structure, "%p, %d, %p, %p, %lu") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, relation, tail), relation_add_to_current_ex, __itt_group_structure, "%p, %p, %lu, %d, %lu") -ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, head, relation, tail), relation_add_ex, __itt_group_structure, "%p, %p, %lu, %lu, %d, %lu") -ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type), (ITT_FORMAT name, track_group_type), track_group_create, __itt_group_structure, "%p, %d") -ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type), (ITT_FORMAT track_group, name, track_type), track_create, __itt_group_structure, "%p, %p, %d") -ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track), (ITT_FORMAT track), set_track, __itt_group_structure, "%p") - -#ifndef __ITT_INTERNAL_BODY -ITT_STUB(ITTAPI, const char*, api_version, (void), (ITT_NO_PARAMS), api_version, __itt_group_all & ~__itt_group_legacy, "no args") -#endif /* __ITT_INTERNAL_BODY */ - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveA, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") -ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveW, __itt_group_arrays, "%p, %d, %p, %d, \"%S\", %d") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_save, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ - -#ifndef __ITT_INTERNAL_BODY -#if ITT_PLATFORM==ITT_PLATFORM_WIN -ITT_STUBV(ITTAPI, void, module_loadA, (void *start_addr, void* end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_loadA, __itt_group_none, "%p, %p, %p") -ITT_STUBV(ITTAPI, void, module_loadW, (void *start_addr, void* end_addr, const wchar_t *path), (ITT_FORMAT start_addr, end_addr, path), module_loadW, __itt_group_none, "%p, %p, %p") -#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ -ITT_STUBV(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_load, __itt_group_none, "%p, %p, %p") -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#endif /* __ITT_INTERNAL_BODY */ - - -#endif /* __ITT_INTERNAL_INIT */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 "ittnotify_config.h" + +#ifndef ITT_FORMAT_DEFINED +# ifndef ITT_FORMAT +# define ITT_FORMAT +# endif /* ITT_FORMAT */ +# ifndef ITT_NO_PARAMS +# define ITT_NO_PARAMS +# endif /* ITT_NO_PARAMS */ +#endif /* ITT_FORMAT_DEFINED */ + +/* + * parameters for macro expected: + * ITT_STUB(api, type, func_name, arguments, params, func_name_in_dll, group, printf_fmt) + */ +#ifdef __ITT_INTERNAL_INIT + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_domain*, domain_createA, (const char *name), (ITT_FORMAT name), domain_createA, __itt_group_structure, "\"%s\"") +ITT_STUB(ITTAPI, __itt_domain*, domain_createW, (const wchar_t *name), (ITT_FORMAT name), domain_createW, __itt_group_structure, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_domain*, domain_create, (const char *name), (ITT_FORMAT name), domain_create, __itt_group_structure, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createA, (const char *name), (ITT_FORMAT name), string_handle_createA, __itt_group_structure, "\"%s\"") +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_createW, (const wchar_t *name), (ITT_FORMAT name), string_handle_createW, __itt_group_structure, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_string_handle*, string_handle_create, (const char *name), (ITT_FORMAT name), string_handle_create, __itt_group_structure, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(ITTAPI, void, pause, (void), (ITT_NO_PARAMS), pause, __itt_group_control | __itt_group_legacy, "no args") +ITT_STUBV(ITTAPI, void, resume, (void), (ITT_NO_PARAMS), resume, __itt_group_control | __itt_group_legacy, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, thread_set_nameA, (const char *name), (ITT_FORMAT name), thread_set_nameA, __itt_group_thread, "\"%s\"") +ITT_STUBV(ITTAPI, void, thread_set_nameW, (const wchar_t *name), (ITT_FORMAT name), thread_set_nameW, __itt_group_thread, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_set_name, (const char *name), (ITT_FORMAT name), thread_set_name, __itt_group_thread, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, thread_ignore, (void), (ITT_NO_PARAMS), thread_ignore, __itt_group_thread, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, thr_name_setA, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setA, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") +ITT_STUB(LIBITTAPI, int, thr_name_setW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), thr_name_setW, __itt_group_thread | __itt_group_legacy, "\"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, thr_name_set, (const char *name, int namelen), (ITT_FORMAT name, namelen), thr_name_set, __itt_group_thread | __itt_group_legacy, "\"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(LIBITTAPI, void, thr_ignore, (void), (ITT_NO_PARAMS), thr_ignore, __itt_group_thread | __itt_group_legacy, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(ITTAPI, void, enable_attach, (void), (ITT_NO_PARAMS), enable_attach, __itt_group_all, "no args") + +#else /* __ITT_INTERNAL_INIT */ + +ITT_STUBV(ITTAPI, void, detach, (void), (ITT_NO_PARAMS), detach, __itt_group_control | __itt_group_legacy, "no args") + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_createA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_createW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_createW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\", \"%S\", %x") +ITT_STUBV(ITTAPI, void, sync_renameA, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_renameA, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") +ITT_STUBV(ITTAPI, void, sync_renameW, (void *addr, const wchar_t *name), (ITT_FORMAT addr, name), sync_renameW, __itt_group_sync | __itt_group_fsync, "%p, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_create, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_create, __itt_group_sync | __itt_group_fsync, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_rename, (void *addr, const char *name), (ITT_FORMAT addr, name), sync_rename, __itt_group_sync | __itt_group_fsync, "%p, \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_destroy, (void *addr), (ITT_FORMAT addr), sync_destroy, __itt_group_sync | __itt_group_fsync, "%p") + +ITT_STUBV(ITTAPI, void, sync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_sync, "%p") +ITT_STUBV(ITTAPI, void, sync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_sync, "%p") + +ITT_STUBV(ITTAPI, void, suppress_push, (unsigned int mask), (ITT_FORMAT mask), suppress_push, __itt_group_suppress, "%p") +ITT_STUBV(ITTAPI, void, suppress_pop, (void), (ITT_NO_PARAMS), suppress_pop, __itt_group_suppress, "no args") +ITT_STUBV(ITTAPI, void, suppress_mark_range, (__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_mark_range, __itt_group_suppress, "%d, %p, %p, %d") +ITT_STUBV(ITTAPI, void, suppress_clear_range,(__itt_suppress_mode_t mode, unsigned int mask, void * address, size_t size),(ITT_FORMAT mode, mask, address, size), suppress_clear_range,__itt_group_suppress, "%d, %p, %p, %d") + +ITT_STUBV(ITTAPI, void, fsync_prepare, (void* addr), (ITT_FORMAT addr), sync_prepare, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_cancel, (void *addr), (ITT_FORMAT addr), sync_cancel, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_acquired, (void *addr), (ITT_FORMAT addr), sync_acquired, __itt_group_fsync, "%p") +ITT_STUBV(ITTAPI, void, fsync_releasing, (void* addr), (ITT_FORMAT addr), sync_releasing, __itt_group_fsync, "%p") + +ITT_STUBV(ITTAPI, void, model_site_begin, (__itt_model_site *site, __itt_model_site_instance *instance, const char *name), (ITT_FORMAT site, instance, name), model_site_begin, __itt_group_model, "%p, %p, \"%s\"") +ITT_STUBV(ITTAPI, void, model_site_end, (__itt_model_site *site, __itt_model_site_instance *instance), (ITT_FORMAT site, instance), model_site_end, __itt_group_model, "%p, %p") +ITT_STUBV(ITTAPI, void, model_task_begin, (__itt_model_task *task, __itt_model_task_instance *instance, const char *name), (ITT_FORMAT task, instance, name), model_task_begin, __itt_group_model, "%p, %p, \"%s\"") +ITT_STUBV(ITTAPI, void, model_task_end, (__itt_model_task *task, __itt_model_task_instance *instance), (ITT_FORMAT task, instance), model_task_end, __itt_group_model, "%p, %p") +ITT_STUBV(ITTAPI, void, model_lock_acquire, (void *lock), (ITT_FORMAT lock), model_lock_acquire, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_lock_release, (void *lock), (ITT_FORMAT lock), model_lock_release, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_record_allocation, (void *addr, size_t size), (ITT_FORMAT addr, size), model_record_allocation, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_record_deallocation, (void *addr), (ITT_FORMAT addr), model_record_deallocation, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_induction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_induction_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_reduction_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_reduction_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_observe_uses, (void* addr, size_t size), (ITT_FORMAT addr, size), model_observe_uses, __itt_group_model, "%p, %d") +ITT_STUBV(ITTAPI, void, model_clear_uses, (void* addr), (ITT_FORMAT addr), model_clear_uses, __itt_group_model, "%p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, model_site_beginW, (const wchar_t *name), (ITT_FORMAT name), model_site_beginW, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_task_beginW, (const wchar_t *name), (ITT_FORMAT name), model_task_beginW, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_iteration_taskW, (const wchar_t *name), (ITT_FORMAT name), model_iteration_taskW, __itt_group_model, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, model_site_beginA, (const char *name), (ITT_FORMAT name), model_site_beginA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_site_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_site_beginAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_task_beginA, (const char *name), (ITT_FORMAT name), model_task_beginA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_task_beginAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_task_beginAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_iteration_taskA, (const char *name), (ITT_FORMAT name), model_iteration_taskA, __itt_group_model, "\"%s\"") +ITT_STUBV(ITTAPI, void, model_iteration_taskAL, (const char *name, size_t len), (ITT_FORMAT name, len), model_iteration_taskAL, __itt_group_model, "\"%s\", %d") +ITT_STUBV(ITTAPI, void, model_site_end_2, (void), (ITT_NO_PARAMS), model_site_end_2, __itt_group_model, "no args") +ITT_STUBV(ITTAPI, void, model_task_end_2, (void), (ITT_NO_PARAMS), model_task_end_2, __itt_group_model, "no args") +ITT_STUBV(ITTAPI, void, model_lock_acquire_2, (void *lock), (ITT_FORMAT lock), model_lock_acquire_2, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_lock_release_2, (void *lock), (ITT_FORMAT lock), model_lock_release_2, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_aggregate_task, (size_t count), (ITT_FORMAT count), model_aggregate_task, __itt_group_model, "%d") +ITT_STUBV(ITTAPI, void, model_disable_push, (__itt_model_disable x), (ITT_FORMAT x), model_disable_push, __itt_group_model, "%p") +ITT_STUBV(ITTAPI, void, model_disable_pop, (void), (ITT_NO_PARAMS), model_disable_pop, __itt_group_model, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_createA, __itt_group_heap, "\"%s\", \"%s\"") +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), heap_function_createW, __itt_group_heap, "\"%s\", \"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_heap_function, heap_function_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), heap_function_create, __itt_group_heap, "\"%s\", \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, heap_allocate_begin, (__itt_heap_function h, size_t size, int initialized), (ITT_FORMAT h, size, initialized), heap_allocate_begin, __itt_group_heap, "%p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr, size_t size, int initialized), (ITT_FORMAT h, addr, size, initialized), heap_allocate_end, __itt_group_heap, "%p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_begin, __itt_group_heap, "%p, %p") +ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr), (ITT_FORMAT h, addr), heap_free_end, __itt_group_heap, "%p, %p") +ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_size, initialized), heap_reallocate_begin, __itt_group_heap, "%p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_reallocate_end, (__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized), (ITT_FORMAT h, addr, new_addr, new_size, initialized), heap_reallocate_end, __itt_group_heap, "%p, %p, %p, %lu, %d") +ITT_STUBV(ITTAPI, void, heap_internal_access_begin, (void), (ITT_NO_PARAMS), heap_internal_access_begin, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_internal_access_end, (void), (ITT_NO_PARAMS), heap_internal_access_end, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_begin, (void), (ITT_NO_PARAMS), heap_record_memory_growth_begin, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_record_memory_growth_end, (void), (ITT_NO_PARAMS), heap_record_memory_growth_end, __itt_group_heap, "no args") +ITT_STUBV(ITTAPI, void, heap_reset_detection, (unsigned int reset_mask), (ITT_FORMAT reset_mask), heap_reset_detection, __itt_group_heap, "%u") +ITT_STUBV(ITTAPI, void, heap_record, (unsigned int record_mask), (ITT_FORMAT record_mask), heap_record, __itt_group_heap, "%u") + +ITT_STUBV(ITTAPI, void, id_create, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_create, __itt_group_structure, "%p, %lu") +ITT_STUBV(ITTAPI, void, id_destroy, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), id_destroy, __itt_group_structure, "%p, %lu") + +ITT_STUB(ITTAPI, __itt_timestamp, get_timestamp, (void), (ITT_NO_PARAMS), get_timestamp, __itt_group_structure, "no args") + +ITT_STUBV(ITTAPI, void, region_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), region_begin, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, region_end, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), region_end, __itt_group_structure, "%p, %lu") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUBV(ITTAPI, void, frame_begin_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_begin_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, frame_end_v3, (const __itt_domain *domain, __itt_id *id), (ITT_FORMAT domain, id), frame_end_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, frame_submit_v3, (const __itt_domain *domain, __itt_id *id, __itt_timestamp begin, __itt_timestamp end), (ITT_FORMAT domain, id, begin, end), frame_submit_v3, __itt_group_structure, "%p, %p, %lu, %lu") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(ITTAPI, void, task_group, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_group, __itt_group_structure, "%p, %lu, %lu, %p") + +ITT_STUBV(ITTAPI, void, task_begin, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_fn, (const __itt_domain *domain, __itt_id id, __itt_id parent, void* fn), (ITT_FORMAT domain, id, parent, fn), task_begin_fn, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end, (const __itt_domain *domain), (ITT_FORMAT domain), task_end, __itt_group_structure, "%p") + +ITT_STUBV(ITTAPI, void, counter_inc_v3, (const __itt_domain *domain, __itt_string_handle *name), (ITT_FORMAT domain, name), counter_inc_v3, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, counter_inc_delta_v3, (const __itt_domain *domain, __itt_string_handle *name, unsigned long long value), (ITT_FORMAT domain, name, value), counter_inc_delta_v3, __itt_group_structure, "%p, %p, %lu") + +ITT_STUBV(ITTAPI, void, marker, (const __itt_domain *domain, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, id, name, scope), marker, __itt_group_structure, "%p, %lu, %p, %d") + +ITT_STUBV(ITTAPI, void, metadata_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, id, key, type, count, data), metadata_add, __itt_group_structure, "%p, %lu, %p, %d, %lu, %p") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_addA, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addA, __itt_group_structure, "%p, %lu, %p, %p, %lu") +ITT_STUBV(ITTAPI, void, metadata_str_addW, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const wchar_t* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_addW, __itt_group_structure, "%p, %lu, %p, %p, %lu") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add, (const __itt_domain *domain, __itt_id id, __itt_string_handle *key, const char* data, size_t length), (ITT_FORMAT domain, id, key, data, length), metadata_str_add, __itt_group_structure, "%p, %lu, %p, %p, %lu") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(ITTAPI, void, relation_add_to_current, (const __itt_domain *domain, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, relation, tail), relation_add_to_current, __itt_group_structure, "%p, %lu, %p") +ITT_STUBV(ITTAPI, void, relation_add, (const __itt_domain *domain, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, head, relation, tail), relation_add, __itt_group_structure, "%p, %p, %lu, %p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, __itt_event, event_createA, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_createA, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") +ITT_STUB(LIBITTAPI, __itt_event, event_createW, (const wchar_t *name, int namelen), (ITT_FORMAT name, namelen), event_createW, __itt_group_mark | __itt_group_legacy, "\"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, __itt_event, event_create, (const char *name, int namelen), (ITT_FORMAT name, namelen), event_create, __itt_group_mark | __itt_group_legacy, "\"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, event_start, (__itt_event event), (ITT_FORMAT event), event_start, __itt_group_mark | __itt_group_legacy, "%d") +ITT_STUB(LIBITTAPI, int, event_end, (__itt_event event), (ITT_FORMAT event), event_end, __itt_group_mark | __itt_group_legacy, "%d") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, sync_set_nameA, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", \"%s\", %x") +ITT_STUBV(ITTAPI, void, sync_set_nameW, (void *addr, const wchar_t *objtype, const wchar_t *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", \"%S\", %x") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, sync_set_name, (void *addr, const char *objtype, const char *objname, int attribute), (ITT_FORMAT addr, objtype, objname, attribute), sync_set_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "p, \"%s\", \"%s\", %x") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(LIBITTAPI, int, notify_sync_nameA, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameA, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") +ITT_STUB(LIBITTAPI, int, notify_sync_nameW, (void *p, const wchar_t *objtype, int typelen, const wchar_t *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_nameW, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%S\", %d, \"%S\", %d, %x") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(LIBITTAPI, int, notify_sync_name, (void *p, const char *objtype, int typelen, const char *objname, int namelen, int attribute), (ITT_FORMAT p, objtype, typelen, objname, namelen, attribute), notify_sync_name, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p, \"%s\", %d, \"%s\", %d, %x") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +ITT_STUBV(LIBITTAPI, void, notify_sync_prepare, (void *p), (ITT_FORMAT p), notify_sync_prepare, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_cancel, (void *p), (ITT_FORMAT p), notify_sync_cancel, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_acquired, (void *p), (ITT_FORMAT p), notify_sync_acquired, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +ITT_STUBV(LIBITTAPI, void, notify_sync_releasing, (void *p), (ITT_FORMAT p), notify_sync_releasing, __itt_group_sync | __itt_group_fsync | __itt_group_legacy, "%p") +#endif /* __ITT_INTERNAL_BODY */ + +ITT_STUBV(LIBITTAPI, void, memory_read, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_read, __itt_group_legacy, "%p, %lu") +ITT_STUBV(LIBITTAPI, void, memory_write, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_write, __itt_group_legacy, "%p, %lu") +ITT_STUBV(LIBITTAPI, void, memory_update, (void *addr, size_t size), (ITT_FORMAT addr, size), memory_update, __itt_group_legacy, "%p, %lu") + +ITT_STUB(LIBITTAPI, __itt_state_t, state_get, (void), (ITT_NO_PARAMS), state_get, __itt_group_legacy, "no args") +ITT_STUB(LIBITTAPI, __itt_state_t, state_set, (__itt_state_t s), (ITT_FORMAT s), state_set, __itt_group_legacy, "%d") +ITT_STUB(LIBITTAPI, __itt_obj_state_t, obj_mode_set, (__itt_obj_prop_t p, __itt_obj_state_t s), (ITT_FORMAT p, s), obj_mode_set, __itt_group_legacy, "%d, %d") +ITT_STUB(LIBITTAPI, __itt_thr_state_t, thr_mode_set, (__itt_thr_prop_t p, __itt_thr_state_t s), (ITT_FORMAT p, s), thr_mode_set, __itt_group_legacy, "%d, %d") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_frame, frame_createA, (const char *domain), (ITT_FORMAT domain), frame_createA, __itt_group_frame, "\"%s\"") +ITT_STUB(ITTAPI, __itt_frame, frame_createW, (const wchar_t *domain), (ITT_FORMAT domain), frame_createW, __itt_group_frame, "\"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain), (ITT_FORMAT domain), frame_create, __itt_group_frame, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, frame_begin, (__itt_frame frame), (ITT_FORMAT frame), frame_begin, __itt_group_frame, "%p") +ITT_STUBV(ITTAPI, void, frame_end, (__itt_frame frame), (ITT_FORMAT frame), frame_end, __itt_group_frame, "%p") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_counter, counter_createA, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_createA, __itt_group_counter, "\"%s\", \"%s\"") +ITT_STUB(ITTAPI, __itt_counter, counter_createW, (const wchar_t *name, const wchar_t *domain), (ITT_FORMAT name, domain), counter_createW, __itt_group_counter, "\"%s\", \"%s\"") +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_counter, counter_create, (const char *name, const char *domain), (ITT_FORMAT name, domain), counter_create, __itt_group_counter, "\"%s\", \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, counter_destroy, (__itt_counter id), (ITT_FORMAT id), counter_destroy, __itt_group_counter, "%p") +ITT_STUBV(ITTAPI, void, counter_inc, (__itt_counter id), (ITT_FORMAT id), counter_inc, __itt_group_counter, "%p") +ITT_STUBV(ITTAPI, void, counter_inc_delta, (__itt_counter id, unsigned long long value), (ITT_FORMAT id, value), counter_inc_delta, __itt_group_counter, "%p, %lu") + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, __itt_mark_type, mark_createA, (const char *name), (ITT_FORMAT name), mark_createA, __itt_group_mark, "\"%s\"") +ITT_STUB(ITTAPI, __itt_mark_type, mark_createW, (const wchar_t *name), (ITT_FORMAT name), mark_createW, __itt_group_mark, "\"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, __itt_mark_type, mark_create, (const char *name), (ITT_FORMAT name), mark_create, __itt_group_mark, "\"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, markA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), markA, __itt_group_mark, "%d, \"%s\"") +ITT_STUB(ITTAPI, int, markW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), markW, __itt_group_mark, "%d, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark, __itt_group_mark, "%d, \"%s\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_off, __itt_group_mark, "%d") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, mark_globalA, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_globalA, __itt_group_mark, "%d, \"%s\"") +ITT_STUB(ITTAPI, int, mark_globalW, (__itt_mark_type mt, const wchar_t *parameter), (ITT_FORMAT mt, parameter), mark_globalW, __itt_group_mark, "%d, \"%S\"") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global, (__itt_mark_type mt, const char *parameter), (ITT_FORMAT mt, parameter), mark_global, __itt_group_mark, "%d, \"%S\"") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, mark_global_off, (__itt_mark_type mt), (ITT_FORMAT mt), mark_global_off, __itt_group_mark, "%d") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void), (ITT_NO_PARAMS), stack_caller_create, __itt_group_stitch, "no args") +#endif /* __ITT_INTERNAL_BODY */ +ITT_STUBV(ITTAPI, void, stack_caller_destroy, (__itt_caller id), (ITT_FORMAT id), stack_caller_destroy, __itt_group_stitch, "%p") +ITT_STUBV(ITTAPI, void, stack_callee_enter, (__itt_caller id), (ITT_FORMAT id), stack_callee_enter, __itt_group_stitch, "%p") +ITT_STUBV(ITTAPI, void, stack_callee_leave, (__itt_caller id), (ITT_FORMAT id), stack_callee_leave, __itt_group_stitch, "%p") + +ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info_fn fn, void* fn_data), (ITT_FORMAT fn, fn_data), clock_domain_create, __itt_group_structure, "%p, %p") +ITT_STUBV(ITTAPI, void, clock_domain_reset, (void), (ITT_NO_PARAMS), clock_domain_reset, __itt_group_structure, "no args") +ITT_STUBV(ITTAPI, void, id_create_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_create_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, id_destroy_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), id_destroy_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, task_begin_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_fn_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, void* fn), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, fn), task_begin_fn_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp), (ITT_FORMAT domain, clock_domain, timestamp), task_end_ex, __itt_group_structure, "%p, %p, %lu") +ITT_STUBV(ITTAPI, void, task_begin_overlapped, (const __itt_domain *domain, __itt_id id, __itt_id parent, __itt_string_handle *name), (ITT_FORMAT domain, id, parent, name), task_begin_overlapped, __itt_group_structure, "%p, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_begin_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_id parentid, __itt_string_handle *name), (ITT_FORMAT domain, clock_domain, timestamp, id, parentid, name), task_begin_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu, %lu, %p") +ITT_STUBV(ITTAPI, void, task_end_overlapped, (const __itt_domain *domain, __itt_id id), (ITT_FORMAT domain, id), task_end_overlapped, __itt_group_structure, "%p, %lu") +ITT_STUBV(ITTAPI, void, task_end_overlapped_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id), (ITT_FORMAT domain, clock_domain, timestamp, id), task_end_overlapped_ex, __itt_group_structure, "%p, %p, %lu, %lu") +ITT_STUBV(ITTAPI, void, marker_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id id, __itt_string_handle *name, __itt_scope scope), (ITT_FORMAT domain, clock_domain, timestamp, id, name, scope), marker_ex, __itt_group_structure, "%p, %p, %lu, %lu, %p, %d") +ITT_STUBV(ITTAPI, void, metadata_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, __itt_metadata_type type, size_t count, void *data), (ITT_FORMAT domain, scope, key, type, count, data), metadata_add_with_scope, __itt_group_structure, "%p, %d, %p, %d, %lu, %p") +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeA, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeA, __itt_group_structure, "%p, %d, %p, %p, %lu") +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scopeW, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const wchar_t *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scopeW, __itt_group_structure, "%p, %d, %p, %p, %lu") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, metadata_str_add_with_scope, (const __itt_domain *domain, __itt_scope scope, __itt_string_handle *key, const char *data, size_t length), (ITT_FORMAT domain, scope, key, data, length), metadata_str_add_with_scope, __itt_group_structure, "%p, %d, %p, %p, %lu") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, relation_add_to_current_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, relation, tail), relation_add_to_current_ex, __itt_group_structure, "%p, %p, %lu, %d, %lu") +ITT_STUBV(ITTAPI, void, relation_add_ex, (const __itt_domain *domain, __itt_clock_domain* clock_domain, unsigned long long timestamp, __itt_id head, __itt_relation relation, __itt_id tail), (ITT_FORMAT domain, clock_domain, timestamp, head, relation, tail), relation_add_ex, __itt_group_structure, "%p, %p, %lu, %lu, %d, %lu") +ITT_STUB(ITTAPI, __itt_track_group*, track_group_create, (__itt_string_handle* name, __itt_track_group_type track_group_type), (ITT_FORMAT name, track_group_type), track_group_create, __itt_group_structure, "%p, %d") +ITT_STUB(ITTAPI, __itt_track*, track_create, (__itt_track_group* track_group,__itt_string_handle* name, __itt_track_type track_type), (ITT_FORMAT track_group, name, track_type), track_create, __itt_group_structure, "%p, %p, %d") +ITT_STUBV(ITTAPI, void, set_track, (__itt_track *track), (ITT_FORMAT track), set_track, __itt_group_structure, "%p") + +#ifndef __ITT_INTERNAL_BODY +ITT_STUB(ITTAPI, const char*, api_version, (void), (ITT_NO_PARAMS), api_version, __itt_group_all & ~__itt_group_legacy, "no args") +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUB(ITTAPI, int, av_saveA, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveA, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") +ITT_STUB(ITTAPI, int, av_saveW, (void *data, int rank, const int *dimensions, int type, const wchar_t *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_saveW, __itt_group_arrays, "%p, %d, %p, %d, \"%S\", %d") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUB(ITTAPI, int, av_save, (void *data, int rank, const int *dimensions, int type, const char *filePath, int columnOrder), (ITT_FORMAT data, rank, dimensions, type, filePath, columnOrder), av_save, __itt_group_arrays, "%p, %d, %p, %d, \"%s\", %d") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ + +#ifndef __ITT_INTERNAL_BODY +#if ITT_PLATFORM==ITT_PLATFORM_WIN +ITT_STUBV(ITTAPI, void, module_loadA, (void *start_addr, void* end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_loadA, __itt_group_none, "%p, %p, %p") +ITT_STUBV(ITTAPI, void, module_loadW, (void *start_addr, void* end_addr, const wchar_t *path), (ITT_FORMAT start_addr, end_addr, path), module_loadW, __itt_group_none, "%p, %p, %p") +#else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ +ITT_STUBV(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const char *path), (ITT_FORMAT start_addr, end_addr, path), module_load, __itt_group_none, "%p, %p, %p") +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#endif /* __ITT_INTERNAL_BODY */ + + +#endif /* __ITT_INTERNAL_INIT */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h index d6320d2b4a..e10250bd63 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/ittnotify_types.h @@ -1,115 +1,115 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 _ITTNOTIFY_TYPES_H_ -#define _ITTNOTIFY_TYPES_H_ - -typedef enum ___itt_group_id -{ - __itt_group_none = 0, - __itt_group_legacy = 1<<0, - __itt_group_control = 1<<1, - __itt_group_thread = 1<<2, - __itt_group_mark = 1<<3, - __itt_group_sync = 1<<4, - __itt_group_fsync = 1<<5, - __itt_group_jit = 1<<6, - __itt_group_model = 1<<7, - __itt_group_splitter_min = 1<<7, - __itt_group_counter = 1<<8, - __itt_group_frame = 1<<9, - __itt_group_stitch = 1<<10, - __itt_group_heap = 1<<11, - __itt_group_splitter_max = 1<<12, - __itt_group_structure = 1<<12, - __itt_group_suppress = 1<<13, - __itt_group_arrays = 1<<14, - __itt_group_all = -1 -} __itt_group_id; - -#pragma pack(push, 8) - -typedef struct ___itt_group_list -{ - __itt_group_id id; - const char* name; -} __itt_group_list; - -#pragma pack(pop) - -#define ITT_GROUP_LIST(varname) \ - static __itt_group_list varname[] = { \ - { __itt_group_all, "all" }, \ - { __itt_group_control, "control" }, \ - { __itt_group_thread, "thread" }, \ - { __itt_group_mark, "mark" }, \ - { __itt_group_sync, "sync" }, \ - { __itt_group_fsync, "fsync" }, \ - { __itt_group_jit, "jit" }, \ - { __itt_group_model, "model" }, \ - { __itt_group_counter, "counter" }, \ - { __itt_group_frame, "frame" }, \ - { __itt_group_stitch, "stitch" }, \ - { __itt_group_heap, "heap" }, \ - { __itt_group_structure, "structure" }, \ - { __itt_group_suppress, "suppress" }, \ - { __itt_group_arrays, "arrays" }, \ - { __itt_group_none, NULL } \ - } - -#endif /* _ITTNOTIFY_TYPES_H_ */ +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 _ITTNOTIFY_TYPES_H_ +#define _ITTNOTIFY_TYPES_H_ + +typedef enum ___itt_group_id +{ + __itt_group_none = 0, + __itt_group_legacy = 1<<0, + __itt_group_control = 1<<1, + __itt_group_thread = 1<<2, + __itt_group_mark = 1<<3, + __itt_group_sync = 1<<4, + __itt_group_fsync = 1<<5, + __itt_group_jit = 1<<6, + __itt_group_model = 1<<7, + __itt_group_splitter_min = 1<<7, + __itt_group_counter = 1<<8, + __itt_group_frame = 1<<9, + __itt_group_stitch = 1<<10, + __itt_group_heap = 1<<11, + __itt_group_splitter_max = 1<<12, + __itt_group_structure = 1<<12, + __itt_group_suppress = 1<<13, + __itt_group_arrays = 1<<14, + __itt_group_all = -1 +} __itt_group_id; + +#pragma pack(push, 8) + +typedef struct ___itt_group_list +{ + __itt_group_id id; + const char* name; +} __itt_group_list; + +#pragma pack(pop) + +#define ITT_GROUP_LIST(varname) \ + static __itt_group_list varname[] = { \ + { __itt_group_all, "all" }, \ + { __itt_group_control, "control" }, \ + { __itt_group_thread, "thread" }, \ + { __itt_group_mark, "mark" }, \ + { __itt_group_sync, "sync" }, \ + { __itt_group_fsync, "fsync" }, \ + { __itt_group_jit, "jit" }, \ + { __itt_group_model, "model" }, \ + { __itt_group_counter, "counter" }, \ + { __itt_group_frame, "frame" }, \ + { __itt_group_stitch, "stitch" }, \ + { __itt_group_heap, "heap" }, \ + { __itt_group_structure, "structure" }, \ + { __itt_group_suppress, "suppress" }, \ + { __itt_group_arrays, "arrays" }, \ + { __itt_group_none, NULL } \ + } + +#endif /* _ITTNOTIFY_TYPES_H_ */ diff --git a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c index 647aac1193..7993af39fb 100644 --- a/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c +++ b/sgx-jvm/linux-sgx/external/vtune/linux/sdk/src/ittnotify/jitprofiling.c @@ -1,315 +1,315 @@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - The full GNU General Public License is included in this distribution - in the file called LICENSE.GPL. - - Contact Information: - http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ - - BSD LICENSE - - Copyright (c) 2005-2014 Intel Corporation. All rights reserved. - 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 "ittnotify_config.h" - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#include -#pragma optimize("", off) -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -#if ITT_PLATFORM != ITT_PLATFORM_MAC && ITT_PLATFORM != ITT_PLATFORM_FREEBSD -#include -#endif -#include - -#include "jitprofiling.h" - -static const char rcsid[] = "\n@(#) $Revision: 398909 $\n"; - -#define DLL_ENVIRONMENT_VAR "VS_PROFILER" - -#ifndef NEW_DLL_ENVIRONMENT_VAR -#if ITT_ARCH==ITT_ARCH_IA32 -#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER32" -#else -#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER64" -#endif -#endif /* NEW_DLL_ENVIRONMENT_VAR */ - -#if ITT_PLATFORM==ITT_PLATFORM_WIN -#define DEFAULT_DLLNAME "JitPI.dll" -HINSTANCE m_libHandle = NULL; -#elif ITT_PLATFORM==ITT_PLATFORM_MAC -#define DEFAULT_DLLNAME "libJitPI.dylib" -void* m_libHandle = NULL; -#else -#define DEFAULT_DLLNAME "libJitPI.so" -void* m_libHandle = NULL; -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - -/* default location of JIT profiling agent on Android */ -#define ANDROID_JIT_AGENT_PATH "/data/intel/libittnotify.so" - -/* the function pointers */ -typedef unsigned int(*TPInitialize)(void); -static TPInitialize FUNC_Initialize=NULL; - -typedef unsigned int(*TPNotify)(unsigned int, void*); -static TPNotify FUNC_NotifyEvent=NULL; - -static iJIT_IsProfilingActiveFlags executionMode = iJIT_NOTHING_RUNNING; - -/* end collector dll part. */ - -/* loadiJIT_Funcs() : this function is called just in the beginning - * and is responsible to load the functions from BistroJavaCollector.dll - * result: - * on success: the functions loads, iJIT_DLL_is_missing=0, return value = 1 - * on failure: the functions are NULL, iJIT_DLL_is_missing=1, return value = 0 - */ -static int loadiJIT_Funcs(void); - -/* global representing whether the collector can't be loaded */ -static int iJIT_DLL_is_missing = 0; - -ITT_EXTERN_C int JITAPI -iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData) -{ - int ReturnValue; - - /* initialization part - the collector has not been loaded yet. */ - if (!FUNC_NotifyEvent) - { - if (iJIT_DLL_is_missing) - return 0; - - if (!loadiJIT_Funcs()) - return 0; - } - - if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED || - event_type == iJVM_EVENT_TYPE_METHOD_UPDATE) - { - if (((piJIT_Method_Load)EventSpecificData)->method_id == 0) - return 0; - } - else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2) - { - if (((piJIT_Method_Load_V2)EventSpecificData)->method_id == 0) - return 0; - } - else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3) - { - if (((piJIT_Method_Load_V3)EventSpecificData)->method_id == 0) - return 0; - } - else if (event_type == iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED) - { - if (((piJIT_Method_Inline_Load)EventSpecificData)->method_id == 0 || - ((piJIT_Method_Inline_Load)EventSpecificData)->parent_method_id == 0) - return 0; - } - - ReturnValue = (int)FUNC_NotifyEvent(event_type, EventSpecificData); - - return ReturnValue; -} - -ITT_EXTERN_C iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive() -{ - if (!iJIT_DLL_is_missing) - { - loadiJIT_Funcs(); - } - - return executionMode; -} - -/* This function loads the collector dll and the relevant functions. - * on success: all functions load, iJIT_DLL_is_missing = 0, return value = 1 - * on failure: all functions are NULL, iJIT_DLL_is_missing = 1, return value = 0 - */ -static int loadiJIT_Funcs() -{ - static int bDllWasLoaded = 0; - char *dllName = (char*)rcsid; /* !! Just to avoid unused code elimination */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN - DWORD dNameLength = 0; -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - - if(bDllWasLoaded) - { - /* dll was already loaded, no need to do it for the second time */ - return 1; - } - - /* Assumes that the DLL will not be found */ - iJIT_DLL_is_missing = 1; - FUNC_NotifyEvent = NULL; - - if (m_libHandle) - { -#if ITT_PLATFORM==ITT_PLATFORM_WIN - FreeLibrary(m_libHandle); -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - dlclose(m_libHandle); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - m_libHandle = NULL; - } - - /* Try to get the dll name from the environment */ -#if ITT_PLATFORM==ITT_PLATFORM_WIN - dNameLength = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, NULL, 0); - if (dNameLength) - { - DWORD envret = 0; - dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); - if(dllName != NULL) - { - envret = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, - dllName, dNameLength); - if (envret) - { - /* Try to load the dll from the PATH... */ - m_libHandle = LoadLibraryExA(dllName, - NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - } - free(dllName); - } - } else { - /* Try to use old VS_PROFILER variable */ - dNameLength = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, NULL, 0); - if (dNameLength) - { - DWORD envret = 0; - dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); - if(dllName != NULL) - { - envret = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, - dllName, dNameLength); - if (envret) - { - /* Try to load the dll from the PATH... */ - m_libHandle = LoadLibraryA(dllName); - } - free(dllName); - } - } - } -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - dllName = getenv(NEW_DLL_ENVIRONMENT_VAR); - if (!dllName) - dllName = getenv(DLL_ENVIRONMENT_VAR); -#if defined(__ANDROID__) || defined(ANDROID) - if (!dllName) - dllName = ANDROID_JIT_AGENT_PATH; -#endif - if (dllName) - { - /* Try to load the dll from the PATH... */ - m_libHandle = dlopen(dllName, RTLD_LAZY); - } -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - - if (!m_libHandle) - { -#if ITT_PLATFORM==ITT_PLATFORM_WIN - m_libHandle = LoadLibraryA(DEFAULT_DLLNAME); -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - m_libHandle = dlopen(DEFAULT_DLLNAME, RTLD_LAZY); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - } - - /* if the dll wasn't loaded - exit. */ - if (!m_libHandle) - { - iJIT_DLL_is_missing = 1; /* don't try to initialize - * JIT agent the second time - */ - return 0; - } - -#if ITT_PLATFORM==ITT_PLATFORM_WIN - FUNC_NotifyEvent = (TPNotify)GetProcAddress(m_libHandle, "NotifyEvent"); -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - FUNC_NotifyEvent = (TPNotify)dlsym(m_libHandle, "NotifyEvent"); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - if (!FUNC_NotifyEvent) - { - FUNC_Initialize = NULL; - return 0; - } - -#if ITT_PLATFORM==ITT_PLATFORM_WIN - FUNC_Initialize = (TPInitialize)GetProcAddress(m_libHandle, "Initialize"); -#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - FUNC_Initialize = (TPInitialize)dlsym(m_libHandle, "Initialize"); -#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ - if (!FUNC_Initialize) - { - FUNC_NotifyEvent = NULL; - return 0; - } - - executionMode = (iJIT_IsProfilingActiveFlags)FUNC_Initialize(); - - bDllWasLoaded = 1; - iJIT_DLL_is_missing = 0; /* DLL is ok. */ - - return 1; -} - -ITT_EXTERN_C unsigned int JITAPI iJIT_GetNewMethodID() -{ - static unsigned int methodID = 1; - - if (methodID == 0) - return 0; /* ERROR : this is not a valid value */ - - return methodID++; -} +/* + This file is provided under a dual BSD/GPLv2 license. When using or + redistributing this file, you may do so under either license. + + GPL LICENSE SUMMARY + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + The full GNU General Public License is included in this distribution + in the file called LICENSE.GPL. + + Contact Information: + http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/ + + BSD LICENSE + + Copyright (c) 2005-2014 Intel Corporation. All rights reserved. + 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 "ittnotify_config.h" + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#include +#pragma optimize("", off) +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ +#if ITT_PLATFORM != ITT_PLATFORM_MAC && ITT_PLATFORM != ITT_PLATFORM_FREEBSD +#include +#endif +#include + +#include "jitprofiling.h" + +static const char rcsid[] = "\n@(#) $Revision: 398909 $\n"; + +#define DLL_ENVIRONMENT_VAR "VS_PROFILER" + +#ifndef NEW_DLL_ENVIRONMENT_VAR +#if ITT_ARCH==ITT_ARCH_IA32 +#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER32" +#else +#define NEW_DLL_ENVIRONMENT_VAR "INTEL_JIT_PROFILER64" +#endif +#endif /* NEW_DLL_ENVIRONMENT_VAR */ + +#if ITT_PLATFORM==ITT_PLATFORM_WIN +#define DEFAULT_DLLNAME "JitPI.dll" +HINSTANCE m_libHandle = NULL; +#elif ITT_PLATFORM==ITT_PLATFORM_MAC +#define DEFAULT_DLLNAME "libJitPI.dylib" +void* m_libHandle = NULL; +#else +#define DEFAULT_DLLNAME "libJitPI.so" +void* m_libHandle = NULL; +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + +/* default location of JIT profiling agent on Android */ +#define ANDROID_JIT_AGENT_PATH "/data/intel/libittnotify.so" + +/* the function pointers */ +typedef unsigned int(*TPInitialize)(void); +static TPInitialize FUNC_Initialize=NULL; + +typedef unsigned int(*TPNotify)(unsigned int, void*); +static TPNotify FUNC_NotifyEvent=NULL; + +static iJIT_IsProfilingActiveFlags executionMode = iJIT_NOTHING_RUNNING; + +/* end collector dll part. */ + +/* loadiJIT_Funcs() : this function is called just in the beginning + * and is responsible to load the functions from BistroJavaCollector.dll + * result: + * on success: the functions loads, iJIT_DLL_is_missing=0, return value = 1 + * on failure: the functions are NULL, iJIT_DLL_is_missing=1, return value = 0 + */ +static int loadiJIT_Funcs(void); + +/* global representing whether the collector can't be loaded */ +static int iJIT_DLL_is_missing = 0; + +ITT_EXTERN_C int JITAPI +iJIT_NotifyEvent(iJIT_JVM_EVENT event_type, void *EventSpecificData) +{ + int ReturnValue; + + /* initialization part - the collector has not been loaded yet. */ + if (!FUNC_NotifyEvent) + { + if (iJIT_DLL_is_missing) + return 0; + + if (!loadiJIT_Funcs()) + return 0; + } + + if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED || + event_type == iJVM_EVENT_TYPE_METHOD_UPDATE) + { + if (((piJIT_Method_Load)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2) + { + if (((piJIT_Method_Load_V2)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V3) + { + if (((piJIT_Method_Load_V3)EventSpecificData)->method_id == 0) + return 0; + } + else if (event_type == iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED) + { + if (((piJIT_Method_Inline_Load)EventSpecificData)->method_id == 0 || + ((piJIT_Method_Inline_Load)EventSpecificData)->parent_method_id == 0) + return 0; + } + + ReturnValue = (int)FUNC_NotifyEvent(event_type, EventSpecificData); + + return ReturnValue; +} + +ITT_EXTERN_C iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive() +{ + if (!iJIT_DLL_is_missing) + { + loadiJIT_Funcs(); + } + + return executionMode; +} + +/* This function loads the collector dll and the relevant functions. + * on success: all functions load, iJIT_DLL_is_missing = 0, return value = 1 + * on failure: all functions are NULL, iJIT_DLL_is_missing = 1, return value = 0 + */ +static int loadiJIT_Funcs() +{ + static int bDllWasLoaded = 0; + char *dllName = (char*)rcsid; /* !! Just to avoid unused code elimination */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN + DWORD dNameLength = 0; +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + + if(bDllWasLoaded) + { + /* dll was already loaded, no need to do it for the second time */ + return 1; + } + + /* Assumes that the DLL will not be found */ + iJIT_DLL_is_missing = 1; + FUNC_NotifyEvent = NULL; + + if (m_libHandle) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FreeLibrary(m_libHandle); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dlclose(m_libHandle); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + m_libHandle = NULL; + } + + /* Try to get the dll name from the environment */ +#if ITT_PLATFORM==ITT_PLATFORM_WIN + dNameLength = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, NULL, 0); + if (dNameLength) + { + DWORD envret = 0; + dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); + if(dllName != NULL) + { + envret = GetEnvironmentVariableA(NEW_DLL_ENVIRONMENT_VAR, + dllName, dNameLength); + if (envret) + { + /* Try to load the dll from the PATH... */ + m_libHandle = LoadLibraryExA(dllName, + NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + free(dllName); + } + } else { + /* Try to use old VS_PROFILER variable */ + dNameLength = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, NULL, 0); + if (dNameLength) + { + DWORD envret = 0; + dllName = (char*)malloc(sizeof(char) * (dNameLength + 1)); + if(dllName != NULL) + { + envret = GetEnvironmentVariableA(DLL_ENVIRONMENT_VAR, + dllName, dNameLength); + if (envret) + { + /* Try to load the dll from the PATH... */ + m_libHandle = LoadLibraryA(dllName); + } + free(dllName); + } + } + } +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + dllName = getenv(NEW_DLL_ENVIRONMENT_VAR); + if (!dllName) + dllName = getenv(DLL_ENVIRONMENT_VAR); +#if defined(__ANDROID__) || defined(ANDROID) + if (!dllName) + dllName = ANDROID_JIT_AGENT_PATH; +#endif + if (dllName) + { + /* Try to load the dll from the PATH... */ + m_libHandle = dlopen(dllName, RTLD_LAZY); + } +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + + if (!m_libHandle) + { +#if ITT_PLATFORM==ITT_PLATFORM_WIN + m_libHandle = LoadLibraryA(DEFAULT_DLLNAME); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + m_libHandle = dlopen(DEFAULT_DLLNAME, RTLD_LAZY); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + } + + /* if the dll wasn't loaded - exit. */ + if (!m_libHandle) + { + iJIT_DLL_is_missing = 1; /* don't try to initialize + * JIT agent the second time + */ + return 0; + } + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FUNC_NotifyEvent = (TPNotify)GetProcAddress(m_libHandle, "NotifyEvent"); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + FUNC_NotifyEvent = (TPNotify)dlsym(m_libHandle, "NotifyEvent"); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (!FUNC_NotifyEvent) + { + FUNC_Initialize = NULL; + return 0; + } + +#if ITT_PLATFORM==ITT_PLATFORM_WIN + FUNC_Initialize = (TPInitialize)GetProcAddress(m_libHandle, "Initialize"); +#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + FUNC_Initialize = (TPInitialize)dlsym(m_libHandle, "Initialize"); +#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ + if (!FUNC_Initialize) + { + FUNC_NotifyEvent = NULL; + return 0; + } + + executionMode = (iJIT_IsProfilingActiveFlags)FUNC_Initialize(); + + bDllWasLoaded = 1; + iJIT_DLL_is_missing = 0; /* DLL is ok. */ + + return 1; +} + +ITT_EXTERN_C unsigned int JITAPI iJIT_GetNewMethodID() +{ + static unsigned int methodID = 1; + + if (methodID == 0) + return 0; /* ERROR : this is not a valid value */ + + return methodID++; +} diff --git a/sgx-jvm/linux-sgx/linux/installer/bin/install-sgx-psw.bin.tmpl b/sgx-jvm/linux-sgx/linux/installer/bin/install-sgx-psw.bin.tmpl index e4b7cb471c..10a8952d30 100755 --- a/sgx-jvm/linux-sgx/linux/installer/bin/install-sgx-psw.bin.tmpl +++ b/sgx-jvm/linux-sgx/linux/installer/bin/install-sgx-psw.bin.tmpl @@ -30,15 +30,18 @@ # # -modinfo isgx &> /dev/null +grep intel_sgx /lib/modules/$(uname -r)/modules.builtin &> /dev/null if [[ $? != "0" ]]; then - lsmod | grep isgx &> /dev/null - if [[ $? = "0" ]]; then - echo "Warning: You did not follow the document to install the driver package" - echo - else - echo "Please install the driver package before the PSW package" - exit 4 + modinfo isgx &> /dev/null + if [[ $? != "0" ]]; then + lsmod | grep isgx &> /dev/null + if [[ $? = "0" ]]; then + echo "Warning: You did not follow the document to install the driver package" + echo + else + echo "Please install the driver package before the PSW package" + exit 4 + fi fi fi diff --git a/sgx-jvm/linux-sgx/linux/installer/common/psw/install.sh b/sgx-jvm/linux-sgx/linux/installer/common/psw/install.sh index 65f23c3647..04952c93d5 100755 --- a/sgx-jvm/linux-sgx/linux/installer/common/psw/install.sh +++ b/sgx-jvm/linux-sgx/linux/installer/common/psw/install.sh @@ -108,6 +108,37 @@ echo " done." cat > $PSW_DST_PATH/uninstall.sh < $AESM_PATH/linksgx.sh </common/inc/tlibc/wchar.h /package/include/tlibc/wchar.h 0 main STP /common/inc/tlibc/wctype.h /package/include/tlibc/wctype.h 0 main STP /common/inc/tlibc/setjmp.h /package/include/tlibc/setjmp.h 0 main STP +/common/inc/tlibc/mbusafecrt.h /package/include/tlibc/mbusafecrt.h 0 main STP /common/src/se_memory.c /package/ptrace/se_memory.c 0 main STP /common/src/se_trace.c /package/ptrace/se_trace.c 0 main STP /linux/installer/common/sdk/install.sh /scripts/install.sh 0 main STP diff --git a/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x64.txt b/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x64.txt index aac1fd7ddb..cb4dadfe82 100644 --- a/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x64.txt +++ b/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x64.txt @@ -14,7 +14,6 @@ DeliveryName InstallName FileCheckSum FileFeature FileOwner /build/linux/libsgx_tstdc.a /package/lib64/libsgx_tstdc.a 0 main STP /build/linux/libsgx_tstdcxx.a /package/lib64/libsgx_tstdcxx.a 0 main STP /build/linux/libsgx_tcxx.a /package/lib64/libsgx_tcxx.a 0 main STP -/build/linux/libsgx_tsetjmp.a /package/lib64/libsgx_tsetjmp.a 0 main STP /build/linux/libsgx_tcmalloc.a /package/lib64/libsgx_tcmalloc.a 0 main STP /build/linux/libsgx_uae_service_deploy.so /package/lib64/libsgx_uae_service.so 0 main STP /build/linux/libsgx_uae_service_sim.so /package/lib64/libsgx_uae_service_sim.so 0 main STP diff --git a/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x86.txt b/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x86.txt index 4f5a3edce0..2689442a17 100644 --- a/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x86.txt +++ b/sgx-jvm/linux-sgx/linux/installer/common/sdk/BOMs/sdk_x86.txt @@ -14,7 +14,6 @@ DeliveryName InstallName FileCheckSum FileFeature FileOwner /build/linux/libsgx_tstdc.a /package/lib/libsgx_tstdc.a 0 main STP /build/linux/libsgx_tstdcxx.a /package/lib/libsgx_tstdcxx.a 0 main STP /build/linux/libsgx_tcxx.a /package/lib/libsgx_tcxx.a 0 main STP -/build/linux/libsgx_tsetjmp.a /package/lib/libsgx_tsetjmp.a 0 main STP /build/linux/libsgx_tcmalloc.a /package/lib/libsgx_tcmalloc.a 0 main STP /build/linux/libsgx_uae_service_deploy.so /package/lib/libsgx_uae_service.so 0 main STP /build/linux/libsgx_uae_service_sim.so /package/lib/libsgx_uae_service_sim.so 0 main STP diff --git a/sgx-jvm/linux-sgx/linux/installer/common/sdk/install.sh b/sgx-jvm/linux-sgx/linux/installer/common/sdk/install.sh index 058a6e8303..4458d20bfe 100755 --- a/sgx-jvm/linux-sgx/linux/installer/common/sdk/install.sh +++ b/sgx-jvm/linux-sgx/linux/installer/common/sdk/install.sh @@ -51,19 +51,35 @@ generate_gdb_script() cat > $GDB_SCRIPT < $SDK_DST_PATH/uninstall.sh < $SDK_DST_PATH/uninstall.sh < /dev/null diff --git a/sgx-jvm/linux-sgx/psw/ae/Makefile b/sgx-jvm/linux-sgx/psw/ae/Makefile index 8c14041e2c..bec63a2d32 100644 --- a/sgx-jvm/linux-sgx/psw/ae/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/Makefile @@ -39,9 +39,18 @@ else CURL_RESULT := endif +ifneq ($(USE_OPT_LIBS), 1) +.PHONY: all +all: + $(info ***NOTE***: SDK is not built based on prebuilt optimized libs. SKIP the build for aesm_service.) + +else + .PHONY: all all: $(CURL_RESULT) AESM COPY_AES CSE| $(BUILD_DIR) +endif #!($(USE_OPT_LIBS), 1) + # COPY_AES: currently copy le, qe, pve, pce, pse_op, pse_pr .PHONY: COPY_AES COPY_AES: | $(BUILD_DIR) diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/Makefile b/sgx-jvm/linux-sgx/psw/ae/aesm_service/Makefile index 2bbe753ab2..229ca62c57 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/Makefile @@ -75,7 +75,7 @@ INCLUDE += -I$(LINUX_PSW_DIR)/ae/inc \ INCLUDE += -I$(LINUX_PSW_DIR)/ae/pve \ -I$(LINUX_PSW_DIR)/ae/pse/pse_op -INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid \ +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0 \ -I$(LINUX_EXTERNAL_DIR)/sqlite/src \ -I$(LINUX_EXTERNAL_DIR)/DALSdk/JHI/linux @@ -89,10 +89,7 @@ INCLUDE += -I$(SGX_IPP_INC) \ EDGER8R := $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native -# Disable cxx11 abi -CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0 - -SQLITECFLAGS := -fPIC -Wall -Wno-unused-const-variable -Werror +SQLITECFLAGS := -fpie -Wall -Wno-unused-const-variable -Werror ifeq ($(CC_BELOW_4_9), 1) SQLITECFLAGS += -fstack-protector else @@ -102,7 +99,7 @@ endif ifdef DEBUG SQLITECFLAGS += -ggdb -DDEBUG -UNDEBUG else - SQLITECFLAGS += -O2 -UDEBUG -DNDEBUG + SQLITECFLAGS += -O2 -UDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 endif ifeq ($(ARCH), x86) SQLITECFLAGS += -m32 @@ -115,8 +112,9 @@ ifdef PROFILE CFLAGS += -D_PROFILE_ endif -CXXFLAGS += -fPIC -CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS)) +CXXFLAGS += -fpie +CFLAGS += -fpie +CFLAGS := $(filter-out -Werror, $(CFLAGS)) LINUX_SE_WRAPPER = $(COMMON_DIR)/se_wrapper ifdef DEBUG @@ -280,7 +278,8 @@ OBJ := $(IPC_SRC:.cpp=.o) \ OBJ += $(SQLITESRC:.c=.o) -LDUFLAGS := -pthread -L$(BUILD_DIR) $(URTSLIB) +LDUFLAGS := -pthread -L$(BUILD_DIR) $(URTSLIB) +LDUFLAGS += -pie $(COMMON_LDFLAGS) APPNAME := aesm_service APPNAME_DEBUG := aesm_service.debug @@ -313,7 +312,7 @@ messages.pb.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc $(CXX) $(filter-out -Wshadow, $(CXXFLAGS)) $(INCLUDE) -c $< -o $@ consttime_memequal.o :consttime_memequal.c - $(CC) $(filter-out -O2,$(CFLAGS)) -fPIC -O1 $(INCLUDE) -c $< -o $@ + $(CC) $(filter-out -O2,$(CFLAGS)) -O1 $(INCLUDE) -c $< -o $@ sqlite3.o :sqlite3.c $(CC) $(SQLITECFLAGS) $(INCLUDE) -c $< -o $@ diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/config/aesmd_service/aesmd.service b/sgx-jvm/linux-sgx/psw/ae/aesm_service/config/aesmd_service/aesmd.service index 9fd5d0c6e2..5c77697dd9 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/config/aesmd_service/aesmd.service +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/config/aesmd_service/aesmd.service @@ -9,6 +9,7 @@ Type=forking Environment=NAME=aesm_service Environment=AESM_PATH=@aesm_folder@ PermissionsStartOnly=true +ExecStartPre=@aesm_folder@/linksgx.sh ExecStartPre=/bin/mkdir -p /var/run/aesmd/ ExecStartPre=/bin/chown -R aesmd:aesmd /var/run/aesmd/ ExecStartPre=/bin/chmod 0755 /var/run/aesmd/ diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp index d5a657ad25..0575ec79d7 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.cpp @@ -190,8 +190,8 @@ IppStatus get_provision_server_rsa_pub_key_in_ipp_format(const signed_pek_t& pek //@param xid: The transaction id (XID) of the ES Protocol //@return AE_SUCCESS if signature verification success and passed //@return PVE_MSG_ERROR if signature verification failed or message error -//other kinds of error code could be returned too due to corresponding error situation -ae_error_t EndpointSelectionInfo::verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[PVE_RSA_KEY_BYTES], uint16_t provision_ttl) +//other kinds of error code could be returned too due to corresponding error situation +ae_error_t EndpointSelectionInfo::verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[RSA_3072_KEY_BYTES], uint16_t provision_ttl) { //Do signature verification here ae_error_t ae_err = AE_SUCCESS; @@ -259,7 +259,7 @@ ae_error_t EndpointSelectionInfo::verify_signature(const endpoint_selection_info } ret_point: if(NULL != rsa_pub_key){ - secure_free_rsa_pub_key(PVE_RSA_KEY_BYTES, sizeof(uint32_t), rsa_pub_key); + secure_free_rsa_pub_key(RSA_3072_KEY_BYTES, sizeof(uint32_t), rsa_pub_key); } if(NULL != buffer){ free(buffer); @@ -280,7 +280,7 @@ ae_error_t EndpointSelectionInfo::start_protocol(endpoint_selection_infos_t& es_ uint32_t resp_size = 0; uint16_t provision_ttl = 0; uint8_t *msg = NULL; - uint8_t rsa_signature[PVE_RSA_KEY_BYTES]; + uint8_t rsa_signature[RSA_3072_KEY_BYTES]; gen_endpoint_selection_output_t enclave_output; ae_error_t ae_ret = AE_SUCCESS; uint32_t enclave_lost_count = 0; diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h index def1278e6e..dd1db74912 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/aesm/extension/endpoint_select_info.h @@ -87,7 +87,7 @@ private: bool _is_white_list_url_valid; /*Set it to true after reading _config_urls*/ static ae_error_t read_pek(endpoint_selection_infos_t& es_info); /*read _es_info from persistent storage*/ static ae_error_t write_pek(const endpoint_selection_infos_t& es_info); /*save _es_info to persistent storage*/ - ae_error_t verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[PVE_RSA_KEY_BYTES], uint16_t ttl); /*verify rsa signature in ES protocol result*/ + ae_error_t verify_signature(const endpoint_selection_infos_t& es_info, uint8_t xid[XID_SIZE], uint8_t rsa_signature[RSA_3072_KEY_BYTES], uint16_t ttl); //verify rsa signature in ES protocol result public: EndpointSelectionInfo(){ memset(&_server_urls, 0, sizeof(_server_urls)); diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp index f5433895af..711187edc3 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_endpoint_selection.cpp @@ -51,7 +51,7 @@ static ae_error_t prov_es_gen_header(provision_request_header_t *es_header, //initialize ES Msg1 Header es_header->protocol = ENDPOINT_SELECTION; es_header->type = TYPE_ES_MSG1; - es_header->version = TLV_VERSION_1; + es_header->version = TLV_VERSION_2; if(0!=memcpy_s(es_header->xid, sizeof(es_header->xid), xid, XID_SIZE)){ AESM_DBG_FATAL("memcpy error"); return PVE_UNEXPECTED_ERROR; @@ -112,7 +112,7 @@ uint32_t CPVEClass::proc_es_msg2( char server_url[MAX_PATH], uint16_t& ttl, const uint8_t xid[XID_SIZE], - uint8_t rsa_signature[PVE_RSA_KEY_BYTES], + uint8_t rsa_signature[RSA_3072_KEY_BYTES], signed_pek_t& pek) { uint32_t ae_ret = PVE_MSG_ERROR; @@ -127,7 +127,7 @@ uint32_t CPVEClass::proc_es_msg2( goto final_point; } //first checking resp header for protocol, version and type - if(resp_header->protocol != ENDPOINT_SELECTION || resp_header->version!=TLV_VERSION_1 || resp_header->type != TYPE_ES_MSG2){ + if(resp_header->protocol != ENDPOINT_SELECTION || resp_header->version!=TLV_VERSION_2 || resp_header->type != TYPE_ES_MSG2){ AESM_DBG_ERROR("ES Msg2 header error"); goto final_point; } @@ -170,24 +170,24 @@ uint32_t CPVEClass::proc_es_msg2( goto final_point; } if(tlvs_msg[1].type != TLV_SIGNATURE || tlvs_msg[1].version != TLV_VERSION_1 || - tlvs_msg[1].header_size!=SMALL_TLV_HEADER_SIZE||tlvs_msg[1].size != PVE_RSA_KEY_BYTES+1 || - tlvs_msg[1].payload[0] != PEK_PRIV){ + tlvs_msg[1].header_size!=SMALL_TLV_HEADER_SIZE||tlvs_msg[1].size != RSA_3072_KEY_BYTES+1 || + tlvs_msg[1].payload[0] != PEK_3072_PRIV){ ae_ret = PVE_MSG_ERROR; - AESM_DBG_ERROR("Invalid Signature TLV: type (tlv%d), version %d, size %d while expected value is (tlv%d,) %d, %d", + AESM_DBG_ERROR("Invalid Signature TLV: type (tlv%d), version %d, size %d while expected value is (tlv%d,) %d, %d", tlvs_msg[1].type, tlvs_msg[1].version, tlvs_msg[1].size, - TLV_SIGNATURE, TLV_VERSION_1, PVE_RSA_KEY_BYTES); + TLV_SIGNATURE, TLV_VERSION_1, RSA_3072_KEY_BYTES); goto final_point; } - if(tlvs_msg[2].type != TLV_PEK || tlvs_msg[2].version != TLV_VERSION_1 || + if(tlvs_msg[2].type != TLV_PEK || tlvs_msg[2].version != TLV_VERSION_2 || tlvs_msg[2].header_size!=SMALL_TLV_HEADER_SIZE||tlvs_msg[2].size != sizeof(signed_pek_t)){ ae_ret = PVE_MSG_ERROR; - AESM_DBG_ERROR("Invalid PEK TLV: type (tlv%d), version %d, size %d while expected value is (tlv%d), %d, %d", + AESM_DBG_ERROR("Invalid PEK TLV: type (tlv%d), version %d, size %d while expected value is (tlv%d), %d, %d", tlvs_msg[2].type, tlvs_msg[2].version, tlvs_msg[2].size, - TLV_PEK, TLV_VERSION_1, sizeof(signed_pek_t)); + TLV_PEK, TLV_VERSION_2, sizeof(signed_pek_t)); goto final_point; } //skip the byte for KEY_ID - if(memcpy_s(rsa_signature, PVE_RSA_KEY_BYTES, tlvs_msg[1].payload+1, tlvs_msg[1].size-1)!=0){ + if(memcpy_s(rsa_signature, RSA_3072_KEY_BYTES, tlvs_msg[1].payload+1, tlvs_msg[1].size-1)!=0){//skip key id ae_ret = AE_FAILURE; AESM_DBG_ERROR("memcpy failed"); goto final_point; diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp index 43723e7a27..87c9a081e3 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg1.cpp @@ -75,7 +75,7 @@ static ae_error_t prov_msg1_gen_header(provision_request_header_t *msg1_header, uint32_t total_size = 0; //platform info tlv size uint32_t field1_data_size = PLATFORM_INFO_TLV_SIZE(); - field1_data_size += CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES); + field1_data_size += CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES); //add flag tlv if needed if(use_flags){ field1_data_size += FLAGS_TLV_SIZE(); @@ -85,7 +85,7 @@ static ae_error_t prov_msg1_gen_header(provision_request_header_t *msg1_header, AESM_DBG_ERROR("Too small ProvMsg1 buffer size"); return PVE_INSUFFICIENT_MEMORY_ERROR; } - total_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES) + BLOCK_CIPHER_TEXT_TLV_SIZE(field1_data_size) +MAC_TLV_SIZE(MAC_SIZE); + total_size = CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES) + BLOCK_CIPHER_TEXT_TLV_SIZE(field1_data_size) +MAC_TLV_SIZE(MAC_SIZE); //initialize Msg1 Header msg1_header->protocol = SE_EPID_PROVISIONING; msg1_header->type = TYPE_PROV_MSG1; @@ -111,8 +111,8 @@ static ae_error_t prov_msg1_gen_header(provision_request_header_t *msg1_header, } //This function will do the rsa oaep encryption with input src[0:src_len] and put the output to buffer dst -//The function will assume that buffer src_len is no more than PVE_RSAOAEP_ENCRYPT_MAXLEN and the buffer size of dst is at least PVE_RSA_KEY_BITS -static ae_error_t aesm_rsa_oaep_encrypt(const uint8_t *src, uint32_t src_len, const IppsRSAPublicKeyState *rsa, uint8_t dst[PVE_RSA_KEY_BYTES]) +//The function will assume that buffer src_len is no more than PVE_RSAOAEP_ENCRYPT_MAXLEN and the buffer size of dst is at least RSA_3072_KEY_BITS +static ae_error_t aesm_rsa_oaep_encrypt(const uint8_t *src, uint32_t src_len, const IppsRSAPublicKeyState *rsa, uint8_t dst[RSA_3072_KEY_BYTES]) { const int hashsize = SHA_SIZE_BIT; Ipp8u seeds[hashsize]; @@ -175,7 +175,7 @@ ret_point: uint8_t *field2 = NULL; uint8_t field2_iv[IV_SIZE]; uint8_t field2_mac[MAC_SIZE]; - uint8_t encrypted_ppid[PVE_RSA_KEY_BYTES]; + uint8_t encrypted_ppid[RSA_3072_KEY_BYTES]; //msg1 header will be in the beginning part of the output msg provision_request_header_t *msg1_header = reinterpret_cast(msg1); memset(&pek_report, 0, sizeof(pek_report)); @@ -271,15 +271,15 @@ ret_point: AESM_DBG_ERROR("Fail to decode PEK:%d",ippStatus); return AE_FAILURE; } - uint8_t field0[PVE_RSA_KEY_BYTES]; + uint8_t field0[RSA_3072_KEY_BYTES]; ret = aesm_rsa_oaep_encrypt(tlvs_msg1_sub.get_tlv_msg(), tlvs_msg1_sub.get_tlv_msg_size(), rsa_pub_key, field0); - secure_free_rsa_pub_key(PVE_RSA_KEY_BYTES, sizeof(uint32_t), rsa_pub_key); + secure_free_rsa_pub_key(RSA_3072_KEY_BYTES, sizeof(uint32_t), rsa_pub_key); if(AE_SUCCESS!=ret){ AESM_DBG_ERROR("Fail to in RSA_OAEP for ProvMsg1:(ae%d)",ret); return ret; } TLVsMsg tlvs_msg1; - tlv_status= tlvs_msg1.add_cipher_text(field0, PVE_RSA_KEY_BYTES, PEK_PUB); + tlv_status= tlvs_msg1.add_cipher_text(field0, RSA_3072_KEY_BYTES, PEK_3072_PUB); ret = tlv_error_2_pve_error(tlv_status); if(AE_SUCCESS!=ret){ AESM_DBG_ERROR("Fail to generate field0 TLV of ProvMsg1( ae%d)",ret); @@ -287,7 +287,7 @@ ret_point: } TLVsMsg tlvs_msg2_sub; - tlv_status = tlvs_msg2_sub.add_cipher_text(encrypted_ppid, PVE_RSA_KEY_BYTES, PEK_PUB); + tlv_status = tlvs_msg2_sub.add_cipher_text(encrypted_ppid, RSA_3072_KEY_BYTES, PEK_3072_PUB); ret = tlv_error_2_pve_error(tlv_status); if(AE_SUCCESS!=ret){ return ret; diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp index 8a842c25ed..bb64c8e8ee 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/epid_provision/epid_provision_msg2.cpp @@ -222,7 +222,7 @@ static ae_error_t gen_msg3_header(const gen_prov_msg3_output_t& msg3_output, con // BLOCK_CIPHER_TEXT_TLV_SIZE(0) is needed because IV need to be included for the following MAC tlv field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(0)+MAC_TLV_SIZE(MAC_SIZE); } - field1_size+=NONCE_TLV_SIZE(NONCE_2_SIZE)+CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES)+SE_REPORT_TLV_SIZE(); + field1_size+=NONCE_TLV_SIZE(NONCE_2_SIZE)+CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES)+SE_REPORT_TLV_SIZE(); size_t total_body_size = NONCE_TLV_SIZE(NONCE_SIZE) + BLOCK_CIPHER_TEXT_TLV_SIZE(field1_size)+MAC_TLV_SIZE(MAC_SIZE); if(msg3_output.is_epid_sig_generated){ total_body_size += BLOCK_CIPHER_TEXT_TLV_SIZE(msg3_output.epid_sig_output_size)+MAC_TLV_SIZE(MAC_SIZE); @@ -525,7 +525,7 @@ uint32_t CPVEClass::proc_prov_msg2( AESM_DBG_ERROR("Fail to generate Field3.3 NONCE TLV N2 in ProvMsg3:(ae %d)",ret); break; } - tlv_status = tlvs_m3field1.add_cipher_text(msg3_fixed_output.encrypted_pwk2, PVE_RSA_KEY_BYTES, PEK_PUB); + tlv_status = tlvs_m3field1.add_cipher_text(msg3_fixed_output.encrypted_pwk2, RSA_3072_KEY_BYTES, PEK_3072_PUB); ret = tlv_error_2_pve_error(tlv_status); if(AE_SUCCESS != ret){ AESM_DBG_ERROR("Fail to generate Field3.4 SE Report TLV in ProvMsg3:(ae %d)",ret); diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pce/PCEClass.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pce/PCEClass.cpp index f8106cc57c..14da06b208 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pce/PCEClass.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pce/PCEClass.cpp @@ -85,13 +85,13 @@ uint32_t CPCEClass::get_pce_info(const sgx_report_t& report, const signed_pek_t& return AE_FAILURE; } - status = ::get_pc_info(m_enclave_id, &ret_val, &report, (uint8_t*)&pek, static_cast(PEK_MOD_SIZE + sizeof(pek.e)), ALG_RSA_OAEP_2048, encrypted_ppid, PEK_MOD_SIZE, &ret_size, &pce_info, &signature_scheme); + status = ::get_pc_info(m_enclave_id, &ret_val, &report, (uint8_t*)&pek, static_cast(PEK_MOD_SIZE + sizeof(pek.e)), ALG_RSA_OAEP_3072, encrypted_ppid, PEK_MOD_SIZE, &ret_size, &pce_info, &signature_scheme); for(; status == SGX_ERROR_ENCLAVE_LOST && retry < AESM_RETRY_COUNT; retry++) { unload_enclave(); if(AE_SUCCESS != load_enclave()) return AE_FAILURE; - status = ::get_pc_info(m_enclave_id, &ret_val, &report, (uint8_t*)&pek, static_cast(PEK_MOD_SIZE + sizeof(pek.e)), ALG_RSA_OAEP_2048, encrypted_ppid, PEK_MOD_SIZE, &ret_size, &pce_info, &signature_scheme); + status = ::get_pc_info(m_enclave_id, &ret_val, &report, (uint8_t*)&pek, static_cast(PEK_MOD_SIZE + sizeof(pek.e)), ALG_RSA_OAEP_3072, encrypted_ppid, PEK_MOD_SIZE, &ret_size, &pce_info, &signature_scheme); } if(status != SGX_SUCCESS) return AE_FAILURE; diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pse_op/PSEClass.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pse_op/PSEClass.cpp index 08164e4458..fede902b77 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pse_op/PSEClass.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pse_op/PSEClass.cpp @@ -54,11 +54,8 @@ #include "interface_psda.h" #define PSDA_CAP_PRTC 0x1 -#define PSDA_CAP_PROTECTED_OUTPUT 0x4 #define PSDA_CAP_RPDATA 0x8 -#define PS_CAP_PROTECTED_OUTPUT 0x4 - #define CHECK_ECALL_RET(status,ret) \ if((status) == SGX_ERROR_ENCLAVE_LOST) \ {retry++;continue;} \ @@ -378,8 +375,6 @@ ae_error_t CPSEClass::get_ps_cap(uint64_t* ps_cap) uint32_t psda_cap0 = _ntohl(psda_cap_result_msg.cap_descriptor0); if (psda_cap0 & PSDA_CAP_PRTC) m_ps_cap |= PS_CAP_TRUSTED_TIME; // Trusted time service - if (psda_cap0 & PSDA_CAP_PROTECTED_OUTPUT) - m_ps_cap |= PS_CAP_PROTECTED_OUTPUT; // Trusted display key exchange if (psda_cap0 & PSDA_CAP_RPDATA) // RPDATA capbility is available m_ps_cap |= PS_CAP_MONOTONIC_COUNTER; // Monotonic counter service diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/PVEClass.h b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/PVEClass.h index c473d29a5e..0f370e0f70 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/PVEClass.h +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/PVEClass.h @@ -100,7 +100,7 @@ public: char server_url[MAX_PATH], uint16_t& ttl, const uint8_t xid[XID_SIZE], - uint8_t rsa_signature[PVE_RSA_KEY_BYTES], + uint8_t rsa_signature[RSA_3072_KEY_BYTES], signed_pek_t& pek); }; #endif diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/prov_msg_size.h b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/prov_msg_size.h index c99f4b7b70..2cbb96d41a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/prov_msg_size.h +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/prov_msg_size.h @@ -41,8 +41,8 @@ TLV_CIPHER_TEXT(SK, PSID): E+MAC(CIPHER_TLV:PLATFORM_INFO_TLV[:FLAG_TLV])*/ inline uint32_t estimate_msg1_size(bool performance_rekey) { - size_t field0_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES); - size_t field1_0_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES); + size_t field0_size = CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES); + size_t field1_0_size = CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES); size_t field1_1_size = PLATFORM_INFO_TLV_SIZE(); size_t field1_2_size = performance_rekey? FLAGS_TLV_SIZE():0; size_t field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field1_0_size+field1_1_size+field1_2_size); @@ -58,7 +58,7 @@ inline uint32_t calc_msg3_size_by_sigrl_count(uint32_t sigrl_count) size_t field1_0_size = BLOCK_CIPHER_TEXT_TLV_SIZE(EPID_JOIN_PROOF_TLV_SIZE()); size_t field1_1_size = MAC_TLV_SIZE(MAC_SIZE); size_t field1_2_size = NONCE_TLV_SIZE(NONCE_2_SIZE); - size_t field1_3_size = CIPHER_TEXT_TLV_SIZE(PVE_RSA_KEY_BYTES); + size_t field1_3_size = CIPHER_TEXT_TLV_SIZE(RSA_3072_KEY_BYTES); size_t field1_4_size = SE_REPORT_TLV_SIZE(); size_t field3_0_size = EPID_SIGNATURE_TLV_SIZE(sigrl_count); size_t field1_size = BLOCK_CIPHER_TEXT_TLV_SIZE(field1_0_size+field1_1_size+field1_2_size+field1_3_size+field1_4_size); diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/pve_logic.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/pve_logic.cpp index aee5c5b77a..3db9631b6d 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/pve_logic.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/pve/pve_logic.cpp @@ -250,8 +250,9 @@ aesm_error_t PvEAESMLogic::pve_error_postprocess(ae_error_t ae_error) case PVE_EPIDBLOB_ERROR: return AESM_EPIDBLOB_ERROR; case AE_ENCLAVE_LOST: - case AE_SERVER_NOT_AVAILABLE: return AESM_NO_DEVICE_ERROR; + case AE_SERVER_NOT_AVAILABLE: + return AESM_SERVICE_UNAVAILABLE; case PVE_INTEGRITY_CHECK_ERROR: { AESM_LOG_FATAL("%s", g_event_string_table[SGX_EVENT_EPID_PROV_INTEGRITY_ERROR]); diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/CertificateProvisioningProtocol.h b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/CertificateProvisioningProtocol.h index 7d28fca17d..f36f4d8e9a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/CertificateProvisioningProtocol.h +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/CertificateProvisioningProtocol.h @@ -40,6 +40,7 @@ #include "epid/common/types.h" #include "tlv_common.h" + #include "platform_info_blob.h" struct _cpRSA_public_key; @@ -49,7 +50,7 @@ class TLVsMsg; typedef struct _public_key { - uint8_t n[256]; + uint8_t n[RSA_3072_KEY_BYTES]; uint32_t e; } public_key_t; @@ -119,7 +120,7 @@ private: ae_error_t msg1_create_header(uint32_t cipherTextSize, uint32_t epidGidSize, const upse::Buffer& transactionID, _provision_request_header_t& header); ae_error_t msg1_create_seq2_0(const TLVsMsg& seq2_1_tlv_block_cipher_info, TLVsMsg& seq2_0_tlv_cipher_text); ae_error_t msg1_create_seq2_1(TLVsMsg& seq2_1_tlv_block_cipher_info); - ae_error_t msg1_create_seq3_0(const TLVsMsg& seq3_1_tlv_epid_gid, const _provision_request_header_t& serializedHeader, + ae_error_t msg1_create_seq3_0(const TLVsMsg& seq3_1_tlv_epid_gid, const _provision_request_header_t& serializedHeader, const upse::Buffer& ek1, TLVsMsg& seq3_0_tlv_block_cipher_text, upse::Buffer& mac); ae_error_t msg2_process(const upse::Buffer& serializedMsg2, upse::Buffer& nonce, upse::Buffer& sigRLBuffer); @@ -129,7 +130,7 @@ private: ae_error_t msg3_generate(const upse::Buffer& csrBuffer, const upse::Buffer& quoteBuffer, upse::Buffer& serializedMsg3); ae_error_t msg3_create_header(const upse::Buffer& transactionID, uint32_t nonceSize, uint32_t quoteSize, uint32_t epidSigSize, uint32_t csrSize, _provision_request_header_t& header); - ae_error_t msg3_seq3_0_create_block_cipher_text_tlv(const TLVsMsg& quote, const TLVsMsg& epidSigTLV, const TLVsMsg& csrTLV, const TLVsMsg& nonceTLV, + ae_error_t msg3_seq3_0_create_block_cipher_text_tlv(const TLVsMsg& quote, const TLVsMsg& epidSigTLV, const TLVsMsg& csrTLV, const TLVsMsg& nonceTLV, const _provision_request_header_t& requestHeader, const upse::Buffer& ek2, TLVsMsg& blockCipherTextTLV, upse::Buffer& mac); ae_error_t msg3_seq3_1_create_quote_tlv(const upse::Buffer& quoteBuffer, TLVsMsg& quoteTLV); @@ -140,9 +141,9 @@ private: ae_error_t msg4_verify_mac(const _provision_response_header_t& header, const TLVsMsg& tlvs); ae_error_t msg4_get_certificates(const TLVsMsg& tlvs, std::list< upse::Buffer >& certificateChainList, platform_info_blob_wrapper_t& piBlobWrapper); - ae_error_t aesGCMEncrypt(const upse::Buffer& iv, const upse::Buffer& keyReader, const upse::Buffer& plainText, + ae_error_t aesGCMEncrypt(const upse::Buffer& iv, const upse::Buffer& keyReader, const upse::Buffer& plainText, const upse::Buffer& aad, upse::Buffer& encryptedText, upse::Buffer& mac); - ae_error_t aesGCMDecrypt(const upse::Buffer& iv, const upse::Buffer& key, const upse::Buffer& cipherText, + ae_error_t aesGCMDecrypt(const upse::Buffer& iv, const upse::Buffer& key, const upse::Buffer& cipherText, const upse::Buffer& aad, const upse::Buffer& mac, upse::Buffer& plainText); ae_error_t aesCMAC(const upse::Buffer& key, const upse::Buffer& message, upse::Buffer& cmac); diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_crypto_helper.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_crypto_helper.cpp index 37342b9e6e..626b8a476d 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_crypto_helper.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_crypto_helper.cpp @@ -85,7 +85,7 @@ const public_key_t& CertificateProvisioningProtocol::get_intel_pek() //The output rsa_pub_key should be released by function free_rsa_key static IppStatus get_intel_rsa_pub_key_in_ipp_format(const public_key_t& publicKey, IppsRSAPublicKeyState **rsa_pub_key) { - if (sizeof(publicKey.n) != PVE_RSA_KEY_BYTES) + if (sizeof(publicKey.n) != RSA_3072_KEY_BYTES) return ippStsSizeErr; if (NULL == rsa_pub_key) diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_provisioning_msg1.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_provisioning_msg1.cpp index 2ac9259751..6a26db71cc 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_provisioning_msg1.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/BackendInterface/pse_provisioning_msg1.cpp @@ -86,7 +86,7 @@ ae_error_t CertificateProvisioningProtocol::msg1_generate(const GroupId gid, ups // Prepare sequence 3.1 -- EPID GID TLV tlv_status = seq3_1_tlv_epid_gid.add_epid_gid(be_gid); - status = tlv_error_2_pve_error(tlv_status); + status = tlv_error_2_pve_error(tlv_status); if (AE_FAILED(status)) break; @@ -102,14 +102,14 @@ ae_error_t CertificateProvisioningProtocol::msg1_generate(const GroupId gid, ups break; // Prepare sequence 3.0 -- Block Cipher Text TLV with IV and encrypted 3.1 - upse::Buffer mac; + upse::Buffer mac; status = msg1_create_seq3_0(seq3_1_tlv_epid_gid, header, EK1, seq3_0_tlv_block_cipher_text, mac); if (AE_FAILED(status)) break; // Prepare sequence 4.0 -- MAC TLV tlv_status = seq4_0_tlv_mac.add_mac(mac.getData()); - status = tlv_error_2_pve_error(tlv_status); + status = tlv_error_2_pve_error(tlv_status); if (AE_FAILED(status)) break; @@ -206,15 +206,15 @@ ae_error_t CertificateProvisioningProtocol::msg1_create_seq2_0(const TLVsMsg& se status = blockCipherInfo.Alloc(seq2_1_tlv_block_cipher_info.get_tlv_msg(), seq2_1_tlv_block_cipher_info.get_tlv_msg_size()); if (AE_FAILED(status)) break; - + upse::BufferReader blockCipherInfoReader(blockCipherInfo); status = encryptRSA_OAEP_SHA256(public_key, blockCipherInfoReader, encryptedBlockCipherInfo); if (AE_FAILED(status)) break; - tlv_status = seq2_0_tlv_cipher_text.add_cipher_text(encryptedBlockCipherInfo.getData(), encryptedBlockCipherInfo.getSize(), PEK_PUB); - status = tlv_error_2_pve_error(tlv_status); + tlv_status = seq2_0_tlv_cipher_text.add_cipher_text(encryptedBlockCipherInfo.getData(), encryptedBlockCipherInfo.getSize(), PEK_3072_PUB); + status = tlv_error_2_pve_error(tlv_status); if (AE_FAILED(status)) break; @@ -237,8 +237,8 @@ ae_error_t CertificateProvisioningProtocol::msg1_create_seq2_1(TLVsMsg& seq2_1_t if (AE_FAILED(status)) break; - tlv_status = seq2_1_tlv_block_cipher_info.add_block_cipher_info(M1SK.getData()); - status = tlv_error_2_pve_error(tlv_status); + tlv_status = seq2_1_tlv_block_cipher_info.add_block_cipher_info(M1SK.getData()); + status = tlv_error_2_pve_error(tlv_status); if (AE_FAILED(status)) break; @@ -248,7 +248,7 @@ ae_error_t CertificateProvisioningProtocol::msg1_create_seq2_1(TLVsMsg& seq2_1_t return status; } -ae_error_t CertificateProvisioningProtocol::msg1_create_seq3_0(const TLVsMsg& seq3_1_tlv_epid_gid, const provision_request_header_t& serializedHeader, +ae_error_t CertificateProvisioningProtocol::msg1_create_seq3_0(const TLVsMsg& seq3_1_tlv_epid_gid, const provision_request_header_t& serializedHeader, const upse::Buffer& ek1, TLVsMsg& seq3_0_tlv_block_cipher_text, upse::Buffer& mac) { //* 3.0 Block Cipher Text TLV (TLV Type, Type, Version, Size, [IV, EncryptedPayload is 3.1]) @@ -282,7 +282,7 @@ ae_error_t CertificateProvisioningProtocol::msg1_create_seq3_0(const TLVsMsg& se break; tlv_status = seq3_0_tlv_block_cipher_text.add_block_cipher_text(M1IV.getData(), encryptedPayload.getData(), encryptedPayload.getSize()); - status = tlv_error_2_pve_error(tlv_status); + status = tlv_error_2_pve_error(tlv_status); if (AE_FAILED(status)) break; diff --git a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/interface_ocsp.cpp b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/interface_ocsp.cpp index ea53a97cf3..2a91dda00c 100644 --- a/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/interface_ocsp.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/aesm_service/source/upse/interface_ocsp.cpp @@ -75,8 +75,9 @@ void OpenSSL_init() #else OPENSSL_malloc_init(); // OpenSSL 1.1 - Initialize malloc, free, etc for OpenSSL's use #endif - + #if defined(_OPENSSL_FULL_INIT) + SSL_library_init(); // Initialize OpenSSL's SSL libraries SSL_load_error_strings(); // Load SSL error strings ERR_load_BIO_strings(); // Load BIO error strings diff --git a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEMessage.h b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEMessage.h index 6bd07c285a..29fd640e7a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEMessage.h +++ b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEMessage.h @@ -37,7 +37,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wconversion" -#include +#include "messages.pb.h" #pragma GCC diagnostic pop struct AEMessage{ diff --git a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAERequest.h b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAERequest.h index 449e85bbaf..bc73b708af 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAERequest.h +++ b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAERequest.h @@ -33,7 +33,7 @@ #include #include -class AEMessage; +struct AEMessage; class IAEResponse; class IAESMLogic; diff --git a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEResponse.h b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEResponse.h index fdea6fcaf6..91ad880a54 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEResponse.h +++ b/sgx-jvm/linux-sgx/psw/ae/common/inc/IAEResponse.h @@ -32,7 +32,7 @@ #define __AE_RESPONSE_H #include -class AEMessage; +struct AEMessage; class IAEResponse { diff --git a/sgx-jvm/linux-sgx/psw/ae/common/pek_pub_key.cpp b/sgx-jvm/linux-sgx/psw/ae/common/pek_pub_key.cpp index 65ee14aeec..2fc5087443 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/pek_pub_key.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/common/pek_pub_key.cpp @@ -113,7 +113,7 @@ sgx_status_t verify_xegb_with_default(const extended_epid_group_blob_t& xegb, ui memcpy(out_xegb.epid_sk, &g_sgx_isk_pubkey, 2*ECDSA_SIGN_SIZE); memcpy(out_xegb.pek_sk, &g_pek_pub_key_little_endian, 2 * ECDSA_SIGN_SIZE); memcpy(out_xegb.qsdk_exp, g_qsdk_pub_key_e, sizeof(g_qsdk_pub_key_e)); - memcpy(out_xegb.qsdk_mod, g_qsdk_pub_key_n, PVE_RSA_KEY_BYTES); + memcpy(out_xegb.qsdk_mod, g_qsdk_pub_key_n, RSA_2048_KEY_BYTES); *result = SGX_EC_VALID; return SGX_SUCCESS; } diff --git a/sgx-jvm/linux-sgx/psw/ae/common/pve_pub_key.cpp b/sgx-jvm/linux-sgx/psw/ae/common/pve_pub_key.cpp index ab4d61683b..eb32fea025 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/pve_pub_key.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/common/pve_pub_key.cpp @@ -54,7 +54,7 @@ IppStatus get_provision_server_rsa_pub_key_in_ipp_format(const signed_pek_t& pek { signed_pek_t little_endian_key; get_provision_server_rsa_key_little_endian_order(pek, little_endian_key); - return create_rsa_pub_key(PVE_RSA_KEY_BYTES, + return create_rsa_pub_key(RSA_3072_KEY_BYTES, sizeof(little_endian_key.e), reinterpret_cast(little_endian_key.n), reinterpret_cast(&little_endian_key.e), diff --git a/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListRequest.cpp b/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListRequest.cpp index 9160cc2fbf..6f010c7925 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListRequest.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListRequest.cpp @@ -49,6 +49,7 @@ AEGetWhiteListRequest::AEGetWhiteListRequest(uint32_t whiteListSize, uint32_t ti :m_request(NULL) { + m_request = new aesm::message::Request::GetWhiteListRequest(); m_request->set_white_list_size(whiteListSize); m_request->set_timeout(timeout); } diff --git a/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListSizeRequest.cpp b/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListSizeRequest.cpp index 3b862fc669..219cd10eaa 100644 --- a/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListSizeRequest.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/common/src/AEGetWhiteListSizeRequest.cpp @@ -46,6 +46,7 @@ AEGetWhiteListSizeRequest::AEGetWhiteListSizeRequest(const aesm::message::Reques AEGetWhiteListSizeRequest::AEGetWhiteListSizeRequest(uint32_t timeout) :m_request(NULL) { + m_request = new aesm::message::Request::GetWhiteListSizeRequest(); m_request->set_timeout(timeout); } diff --git a/sgx-jvm/linux-sgx/psw/ae/cse_provision_tool/Makefile b/sgx-jvm/linux-sgx/psw/ae/cse_provision_tool/Makefile index 25de622505..794f8d3827 100644 --- a/sgx-jvm/linux-sgx/psw/ae/cse_provision_tool/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/cse_provision_tool/Makefile @@ -32,10 +32,12 @@ TOP_DIR = ../../.. include $(TOP_DIR)/buildenv.mk +CXXFLAGS += -fpie -pie + all: cse_provision_tool cse_provision_tool: cse_provision_tool.o - $(CXX) $(CXXFLAGS) -o $@ $< -ldl + $(CXX) $(CXXFLAGS) -o $@ $< -ldl $(COMMON_LDFLAGS) %.o :%.cpp $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@ diff --git a/sgx-jvm/linux-sgx/psw/ae/inc/internal/epid_pve_type.h b/sgx-jvm/linux-sgx/psw/ae/inc/internal/epid_pve_type.h index c03d09606d..5d3ceed17c 100644 --- a/sgx-jvm/linux-sgx/psw/ae/inc/internal/epid_pve_type.h +++ b/sgx-jvm/linux-sgx/psw/ae/inc/internal/epid_pve_type.h @@ -38,6 +38,7 @@ #define _EPID_PVE_TYPE_H_ #include "epid/common/types.h" +#include "epid/member/api.h" #include "se_types.h" #include "sgx_key.h" @@ -53,21 +54,21 @@ #define NONCE_SIZE 8 /*length in bytes of Nonce R in ProvMsg*/ #define NONCE_2_SIZE 16 /*length in bytes of Nonce in ProvMsg3*/ #define CHALLENGE_NONCE_SIZE 32 /*length in bytes of Challenge nonce in ProvMsg2*/ -#define PPID_SIZE sizeof(ppid_t) /*16*/ #define PSVN_SIZE sizeof(psvn_t) /*18*/ -#define FMSP_SIZE sizeof(fmsp_t) /*4*/ #define FLAGS_SIZE sizeof(flags_t) /*256*/ #define MAC_SIZE 16 /*length in bytes of the tag in output of AES-GCM*/ -#define PSID_SIZE sizeof(psid_t) /*64*/ -#define JOIN_PROOF_SIZE sizeof(JoinRequest) +#define JOIN_PROOF_SIZE sizeof(JoinRequest) #define BLIND_ESCROW_SIZE sizeof(blind_escrow_data_t) #define PEK_PUB ((uint8_t)0) #define PEK_PRIV ((uint8_t)1) -#define PWK_KEY ((uint8_t)2) +#define PEK_3072_PUB ((uint8_t)3) +#define PEK_3072_PRIV ((uint8_t)4) #define ECDSA_SIGN_SIZE 32 /*This is the size of biginteger for ECDSA signature appended at the end of SIG-RL and the total signature size is size of two such kind of integer*/ -#define PVE_RSA_KEY_BITS 2048 -#define PVE_RSA_KEY_BYTES (PVE_RSA_KEY_BITS/8) +#define RSA_3072_KEY_BITS 3072 +#define RSA_3072_KEY_BYTES (RSA_3072_KEY_BITS/8) +#define RSA_2048_KEY_BITS 2048 +#define RSA_2048_KEY_BYTES (RSA_2048_KEY_BITS/8) #define PVE_RSA_SEED_SIZE 32 #define XEGB_SIZE 456 /*hardcoded size of extended_epid_group_blob_t*/ @@ -125,7 +126,7 @@ typedef struct _signed_epid_group_cert_t{ uint8_t ecdsa_signature[2*ECDSA_SIGN_SIZE]; }signed_epid_group_cert_t; -#define PEK_MOD_SIZE 256 +#define PEK_MOD_SIZE 384 typedef struct _signed_pek_t{ uint8_t n[PEK_MOD_SIZE]; uint8_t e[4]; @@ -185,7 +186,7 @@ typedef struct _se_plaintext_epid_data_sik_t { Epid2Params epid_param_cert; GroupPubKey epid_group_cert; uint8_t qsdk_exp[4]; /*little endian*/ - uint8_t qsdk_mod[PVE_RSA_KEY_BYTES];/*little endian*/ + uint8_t qsdk_mod[RSA_2048_KEY_BYTES];/*little endian*/ uint8_t epid_sk[2*ECDSA_SIGN_SIZE]; /*little endian*/ uint32_t xeid; /*ExtEPIDGroup ID, little endian*/ }se_plaintext_epid_data_sik_t; @@ -197,7 +198,7 @@ typedef struct _se_plaintext_epid_data_sdk_t{ sgx_isv_svn_t equiv_pve_isv_svn; GroupPubKey epid_group_cert; uint8_t qsdk_exp[4]; /*little endian*/ - uint8_t qsdk_mod[PVE_RSA_KEY_BYTES];/*little endian*/ + uint8_t qsdk_mod[RSA_2048_KEY_BYTES];/*little endian*/ uint8_t epid_sk[2*ECDSA_SIGN_SIZE]; /*little endian*/ uint32_t xeid; /*ExtEPIDGroup ID, little endian*/ }se_plaintext_epid_data_sdk_t; @@ -209,11 +210,11 @@ typedef struct _extended_epid_group_blob_t{ uint8_t epid_sk[2*ECDSA_SIGN_SIZE]; /*ecdsa public key for EPID sign Key in little endian*/ uint8_t pek_sk[2*ECDSA_SIGN_SIZE]; /*ecdsa public key for PEKSK in little endian*/ uint8_t qsdk_exp[4]; /*exponient of RSA key for QSDK, little endian*/ - uint8_t qsdk_mod[PVE_RSA_KEY_BYTES]; /*Modulus of RSA key for QSDK. current it is 2048 bits, little endian*/ + uint8_t qsdk_mod[RSA_2048_KEY_BYTES]; /*Modulus of RSA key for QSDK. current it is 2048 bits, little endian*/ uint8_t signature[2*ECDSA_SIGN_SIZE];/*ECDSA signature of the data, big endian*/ }extended_epid_group_blob_t; -#define EXTENDED_EPID_GROUP_BLOB_DATA_LEN ((uint32_t)(sizeof(uint32_t)+4*(ECDSA_SIGN_SIZE)+4+(PVE_RSA_KEY_BYTES))) +#define EXTENDED_EPID_GROUP_BLOB_DATA_LEN ((uint32_t)(sizeof(uint32_t)+4*(ECDSA_SIGN_SIZE)+4+(RSA_2048_KEY_BYTES))) #define SGX_TRUSTED_EPID_BLOB_SIZE_SIK ((uint32_t)(sizeof(sgx_sealed_data_t)+sizeof(se_secret_epid_data_sik_t)+sizeof(se_plaintext_epid_data_sik_t))) #define SGX_TRUSTED_EPID_BLOB_SIZE_SDK ((uint32_t)(sizeof(sgx_sealed_data_t)+sizeof(se_secret_epid_data_sdk_t)+sizeof(se_plaintext_epid_data_sdk_t))) diff --git a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pairing_blob.h b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pairing_blob.h index a28f100aa7..eae06b42a9 100644 --- a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pairing_blob.h +++ b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pairing_blob.h @@ -33,6 +33,7 @@ #define _PAIRING_BLOB_H_ #include "sgx_tseal.h" +#include "pse_pr_types.h" #include "aeerror.h" #include @@ -40,11 +41,6 @@ typedef uint8_t UINT8; typedef uint32_t UINT32; -typedef UINT8 Nonce128_t[16]; -typedef UINT32 SHA256_HASH[8]; - -typedef UINT8 EcDsaPrivKey[32]; -typedef UINT8 EcDsaPubKey[64]; typedef UINT8 SIGMA_ID[32]; typedef UINT8 SIGMA_MAC_KEY[16]; typedef UINT8 SIGMA_SECRET_KEY[16]; diff --git a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pce_cert.h b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pce_cert.h index 418c2de4e6..d855851d66 100644 --- a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pce_cert.h +++ b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pce_cert.h @@ -37,6 +37,7 @@ const uint16_t CUR_PCE_ID = 0; /*crypto_suite*/ #define ALG_RSA_OAEP_2048 0 +#define ALG_RSA_OAEP_3072 1 /*signature_scheme*/ #define NIST_P256_ECDSA_SHA256 0 diff --git a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_sigma_1_1_defs.h b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_sigma_1_1_defs.h index e20e14f5ab..68f932176a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_sigma_1_1_defs.h +++ b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_sigma_1_1_defs.h @@ -171,6 +171,6 @@ typedef struct _SIGMA_S3_MESSAGE #pragma pack() // This is the constant size portion of the S2 message that is part of the ICV -#define SIGMA_S2_ICV_CONSTANT_BUFFER_SIZE sizeof(EphemeralPublicKey) + sizeof(SIGMA_BASENAME) + sizeof(OCSP_REQ) +#define SIGMA_S2_ICV_CONSTANT_BUFFER_SIZE (sizeof(EphemeralPublicKey) + sizeof(SIGMA_BASENAME) + sizeof(OCSP_REQ)) #endif diff --git a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_types.h b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_types.h index 71536e1959..74cf80780e 100644 --- a/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_types.h +++ b/sgx-jvm/linux-sgx/psw/ae/inc/internal/pse_pr_types.h @@ -34,9 +34,6 @@ #include - -#define MAX_PCH_TYPE 2 - #ifndef UINT64 #define UINT64 uint64_t #endif @@ -135,17 +132,4 @@ typedef struct _SAFEID_CRYPTO_CONTEXT #pragma pack(pop) - -extern void swap(void * pBuf, UINT32 buflen); -extern void InitRSAKey(UINT8 PlatformKeyId); -extern STATUS ClsProvisionEpid_1_1(); -extern STATUS ClsMeCreatePermitRequest(); -extern STATUS ClsExchangeEpidRequest(); -extern STATUS ClsPsCreatePermitResponse(); - -extern UINT16 CurrentClassId; -extern UINT16 CurrentSubClass; - - - #endif diff --git a/sgx-jvm/linux-sgx/psw/ae/le/config_linux.xml b/sgx-jvm/linux-sgx/psw/ae/le/config_linux.xml index f19a9a32b3..847c901733 100644 --- a/sgx-jvm/linux-sgx/psw/ae/le/config_linux.xml +++ b/sgx-jvm/linux-sgx/psw/ae/le/config_linux.xml @@ -5,9 +5,11 @@ 0x20 1 1 + 0 1 0x2000 0x20000 + 0x20000 0x1 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/pce/Makefile b/sgx-jvm/linux-sgx/psw/ae/pce/Makefile index 6225915e2b..65707f6b52 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pce/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/pce/Makefile @@ -37,18 +37,17 @@ CFLAGS += -Werror AENAME = pce -LINUX_EPID := $(LINUX_EXTERNAL_DIR)/epid/ -lepid +LINUX_EPID := $(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0/ INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ -I$(SGX_IPP_INC)/ \ - -I$(LINUX_EXTERNAL_DIR)/epid \ + -I$(LINUX_EPID)/ \ -I$(LINUX_SDK_DIR)/tseal \ -I$(LINUX_PSW_DIR)/ae/common \ -I$(LINUX_PSW_DIR)/ae/inc/internal TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto -EPID_LIBDIR := $(LINUX_EPID) EXTERNAL_LIB += -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto diff --git a/sgx-jvm/linux-sgx/psw/ae/pce/config.xml b/sgx-jvm/linux-sgx/psw/ae/pce/config.xml index e1726b6974..7f0e92757b 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pce/config.xml +++ b/sgx-jvm/linux-sgx/psw/ae/pce/config.xml @@ -5,8 +5,10 @@ 0x1 4 1 + 0 1 0x2000 0x8000 + 0x8000 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/pce/pce.cpp b/sgx-jvm/linux-sgx/psw/ae/pce/pce.cpp index 0c10a352fe..5e1db1cf01 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pce/pce.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pce/pce.cpp @@ -43,7 +43,7 @@ ae_error_t get_ppid(ppid_t* ppid); ae_error_t get_pce_priv_key(const psvn_t* psvn, sgx_ec256_private_t* wrap_key); #define PCE_RSA_SEED_SIZE 32 -#define RSA_MOD_SIZE 256 //hardcode n size to be 256 +#define RSA_MOD_SIZE 384 //hardcode n size to be 384 #define RSA_E_SIZE 4 //hardcode e size to be 4 se_static_assert(RSA_MOD_SIZE == PEK_MOD_SIZE); @@ -82,7 +82,7 @@ uint32_t get_pc_info(const sgx_report_t* report, signature_scheme == NULL){ return AE_INVALID_PARAMETER; } - if(ALG_RSA_OAEP_2048!=crypto_suite){//The only crypto suite supported in RSA 2048 where 256 bytes module n is used + if(ALG_RSA_OAEP_3072!=crypto_suite){//The only crypto suite supported in RSA 3072 where 384 bytes module n is used return AE_INVALID_PARAMETER; } @@ -164,7 +164,7 @@ uint32_t get_pc_info(const sgx_report_t* report, } ipp_ret = create_rsa_pub_key(RSA_MOD_SIZE, RSA_E_SIZE, - reinterpret_cast(le_n), + reinterpret_cast(le_n), &little_endian_e, &pub_key); free(le_n); @@ -185,13 +185,13 @@ uint32_t get_pc_info(const sgx_report_t* report, ae_ret = AE_READ_RAND_ERROR; goto RETURN_POINT; } - + pub_key_buffer = (uint8_t *)malloc(pub_key_size); if (pub_key_buffer == NULL){ ae_ret = AE_OUT_OF_MEMORY_ERROR; goto RETURN_POINT; } - ipp_ret = ippsRSAEncrypt_OAEP(reinterpret_cast(&ppid_buf), sizeof(ppid_buf), NULL, 0, seeds, + ipp_ret = ippsRSAEncrypt_OAEP(reinterpret_cast(&ppid_buf), sizeof(ppid_buf), NULL, 0, seeds, encrypted_ppid, pub_key, IPP_ALG_HASH_SHA256, pub_key_buffer); if (ipp_ret != ippStsNoErr){ ae_ret = AE_FAILURE; diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/config.xml b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/config.xml index a50ca46336..d947c85a89 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/config.xml +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/config.xml @@ -5,8 +5,10 @@ 0x2 4 1 + 0 1 0x10000 0x100000 + 0x100000 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/monotonic_counter_database_sqlite_cache.h b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/monotonic_counter_database_sqlite_cache.h index fb0b08575d..c8ed25129f 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/monotonic_counter_database_sqlite_cache.h +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/monotonic_counter_database_sqlite_cache.h @@ -57,7 +57,6 @@ typedef struct _leaf_cache_t uint32_t size; // list length, should never exceed MAX_LEAF_CACHE_NUM } leaf_cache_t; -void initialize_hash_tree_cache(); void flush_hash_tree_cache(); pse_op_error_t access_hash_tree_cache(const rpdb_op_t rpdb_op, // vmc operation type const cache_op_t cache_op, // read/update cache diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/session_mgr.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/session_mgr.cpp index cb854ddf5e..ea9b128e7b 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/session_mgr.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_op/session_mgr.cpp @@ -528,25 +528,6 @@ pse_op_error_t ephemeral_session_m2m3( sgx_isv_svn_t sealed_isv_svn; sgx_cpu_svn_t* p_sealed_cpu_svn = NULL; - // If the pairing blob was sealed by a different ISV SVN, we need to - // tell AESM to redo long term pairing - memset_s(&report, sizeof(report), 0, sizeof(report)); - se_ret = sgx_create_report(NULL, NULL, &report); - if(SGX_SUCCESS != se_ret) - { - return OP_ERROR_INTERNAL; - } - - sealed_isv_svn = ((sgx_sealed_data_t*)sealed_blob)->key_request.isv_svn; - p_sealed_cpu_svn = &((sgx_sealed_data_t*)sealed_blob)->key_request.cpu_svn; - if (sealed_isv_svn != report.body.isv_svn || memcmp(p_sealed_cpu_svn, &report.body.cpu_svn, sizeof(sgx_cpu_svn_t)) != 0) - { - return OP_ERROR_LTPB_SEALING_OUT_OF_DATE; - } - - // Reset ephemeral session - memset(&g_eph_session, 0 , sizeof(eph_session_t)); - // decrypt sealed blob if (UnsealPairingBlob(sealed_blob, &g_pairing_data) != AE_SUCCESS) { @@ -555,6 +536,27 @@ pse_op_error_t ephemeral_session_m2m3( goto error; } + // If the pairing blob was sealed by a different ISV SVN, we need to + // tell AESM to redo long term pairing + memset_s(&report, sizeof(report), 0, sizeof(report)); + se_ret = sgx_create_report(NULL, NULL, &report); + if(SGX_SUCCESS != se_ret) + { + op_ret = OP_ERROR_INTERNAL; + goto error; + } + + sealed_isv_svn = ((sgx_sealed_data_t*)sealed_blob)->key_request.isv_svn; + p_sealed_cpu_svn = &((sgx_sealed_data_t*)sealed_blob)->key_request.cpu_svn; + if (sealed_isv_svn != report.body.isv_svn || memcmp(p_sealed_cpu_svn, &report.body.cpu_svn, sizeof(sgx_cpu_svn_t)) != 0) + { + op_ret = OP_ERROR_LTPB_SEALING_OUT_OF_DATE; + goto error; + } + + // Reset ephemeral session + memset(&g_eph_session, 0 , sizeof(eph_session_t)); + // verify pairingNonce, must be non-zero. memset(&zero_nonce, 0, sizeof(zero_nonce)); if(0 == memcmp(&g_pairing_data.secret_data.pairingNonce, &zero_nonce, sizeof(Nonce128_t))) diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.cpp index 98d49d067e..ede0120695 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.cpp @@ -37,7 +37,7 @@ const uint8_t** Keys::EpidVerifyKeys() return pEpidVerifyKeys; } -const uint32_t Keys::EpidVerifyKeyNum() +uint32_t Keys::EpidVerifyKeyNum() { - return sizeof(pEpidVerifyKeys) / sizeof(pEpidVerifyKeys[0]); + return static_cast(sizeof(pEpidVerifyKeys) / sizeof(pEpidVerifyKeys[0])); } diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.h b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.h index 0e855789b9..4b8eba7518 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.h +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Keys.h @@ -41,7 +41,7 @@ public: static const uint8_t* EpidParamsCert(size_t& nBytes); static const uint8_t** EpidVerifyKeys(); - static const uint32_t EpidVerifyKeyNum(); + static uint32_t EpidVerifyKeyNum(); private: diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Makefile b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Makefile index eb5131d7f7..784324eeb4 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/Makefile @@ -37,7 +37,6 @@ CFLAGS += -Werror EPID_SDK_DIR := $(TOP_DIR)/external/epid-sdk-3.0.0/ - INCLUDE += -I. \ -I./include \ -I$(TOP_DIR)/sdk/tlibstdcxx/stlport \ @@ -54,7 +53,6 @@ EXTERNAL_LIB += -lsgx_tstdcxx -lsgx_tcrypto \ -L$(EPID_SDK_DIR)/epid/common -lcommon \ -L$(EPID_SDK_DIR)/ext/ipp/sources/ippcpepid/src -lippcpepid - SRC := $(wildcard *.cpp) $(wildcard ./X509_Parser/*.cpp) SRC += pse_pr_common.cpp \ t_pairing_blob.cpp \ @@ -66,12 +64,12 @@ OBJS := $(sort $(OBJ) version.o) .PHONY: all all: $(SONAME) -.PHONY: EPID_SDK -EPID_SDK: +.PHONY: EPID +EPID: cd $(EPID_SDK_DIR) && ./configure prefix=/usr/local - $(MAKE) -C $(EPID_SDK_DIR) - -$(SONAME): $(OBJS) EPID_SDK + $(MAKE) -C $(EPID_SDK_DIR) 2> /dev/null + +$(SONAME): $(OBJS) EPID $(CXX) $(CXXFLAGS) -o $@ $(OBJS) -nostdlib -nodefaultlibs -nostartfiles $(LDTFLAGS) $(STRIP) --strip-unneeded $(SONAME) @@ -88,7 +86,9 @@ clean: @$(RM) *.so @$(RM) *.map @$(RM) *_t.* +ifeq ("$(shell test -f $(EPID_SDK_DIR)/Makefile && echo Makefile exists)", "Makefile exists") -$(MAKE) -C $(EPID_SDK_DIR) clean +endif @$(RM) -r $(EPID_SDK_DIR)/Makefile $(EPID_SDK_DIR)/config.log $(EPID_SDK_DIR)/config.status .PHONY: rebuild diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509Parser.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509Parser.cpp index cad7fd0c57..ad910cc092 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509Parser.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509Parser.cpp @@ -50,9 +50,9 @@ X509Parser::~X509Parser(void) UINT32 X509Parser::ParseGroupCertificate ( /*in */ const EcDsaPubKey* pSerializedPublicKey, - /*in */ const X509_GROUP_CERTIFICATE_VLR* pGroupCertVlr, - /*out*/ UINT32* pGID, - /*out*/ Epid11GroupPubKey* pGroupPubKey + /*in */ const X509_GROUP_CERTIFICATE_VLR* pGroupCertVlr, + /*out*/ UINT32* pGID, + /*out*/ Epid11GroupPubKey* pGroupPubKey ) { STATUS status = X509_GENERAL_ERROR; @@ -82,7 +82,7 @@ UINT32 X509Parser::ParseGroupCertificate // // this is "functional", not buffer overflow check // - (pGroupCertVlr->VlrHeader.PaddedBytes > 3) || + (pGroupCertVlr->VlrHeader.PaddedBytes > 3) || // // buffer overflow check: Length can be anything, sizeof is a constant... // @@ -90,8 +90,8 @@ UINT32 X509Parser::ParseGroupCertificate ) { break; } - UINT32 X509GroupCertificateSize = pGroupCertVlr->VlrHeader.Length - - sizeof(pGroupCertVlr->VlrHeader) - pGroupCertVlr->VlrHeader.PaddedBytes; + UINT32 X509GroupCertificateSize = static_cast(pGroupCertVlr->VlrHeader.Length - + sizeof(pGroupCertVlr->VlrHeader) - pGroupCertVlr->VlrHeader.PaddedBytes); #ifdef DUMP_OCTETS OutputOctets("X509GroupCertificate", X509GroupCertificate, X509GroupCertificateSize); @@ -101,12 +101,12 @@ UINT32 X509Parser::ParseGroupCertificate // EpidGroupCertificate = 0, // VerifierCertificate, // OcspResponderCertificate, - // Others, // OMA DRM + // Others, // OMA DRM //}CertificateType; ISSUER_INFO* pRootPublicKey = NULL; status = ParseCertificateChain( - X509GroupCertificate, X509GroupCertificateSize, + X509GroupCertificate, X509GroupCertificateSize, certificateFields, certWorkBuffer, certWorkBufferLength, pRootPublicKey, 0, NULL, certType, FALSE); if (X509_STATUS_SUCCESS != status) @@ -116,7 +116,7 @@ UINT32 X509Parser::ParseGroupCertificate if (certificateFields->serialNumber.length > sizeof(gidArray)) break; - int index = sizeof(gidArray)-certificateFields->serialNumber.length; + int index = static_cast(sizeof(gidArray)-certificateFields->serialNumber.length); memcpy(&gidArray[index], certificateFields->serialNumber.buffer, certificateFields->serialNumber.length); if(certificateFields->algorithmIdentifierForSubjectPublicKey != X509_intel_sigma_epidGroupPublicKey_epid11)//Only Epid Group Public Key Epid1.1 are permitted to be subject key diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Interface.h b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Interface.h index 911a4a7587..4f31a92b82 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Interface.h +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Interface.h @@ -37,17 +37,4 @@ STATUS SetPublicEcDsaKey ( const EcDsaPubKey* pPublicKey ); -STATUS ParseCertificateChain - ( UINT8 *pCertChain, - UINT32 CertChainLength, - SessMgrCertificateFields *certificateFields, - UINT8 *CertWorkBuffer, - UINT32 CertWorkBufferLength, - ISSUER_INFO *RootPublicKey, - UINT8 NumberOfSingleResponses, - OCSP_CERT_STATUS_TABLE *OcspCertStatusTable, - CertificateType CertType, - BOOL UseFacsimileEpid - ); - #endif diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Parser.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Parser.cpp index d8d89f2662..3b71221064 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Parser.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/X509_Parser/X509_Parser.cpp @@ -71,8 +71,8 @@ extern HANDLE hConsole; #ifdef X509_FOR_PSE_PR STATUS CreateSha1Hash ( - /*in */ SessMgrDataBuffer *pSrcBuffer, - /*out*/ SessMgrDataBuffer *pDigest + /*in */ SessMgrDataBuffer *pSrcBuffer, + /*out*/ SessMgrDataBuffer *pDigest ) { PrepareHashSHA1 hash; @@ -100,13 +100,13 @@ crypto_status_t EcDsa_VerifySignature do { - if (SGX_SUCCESS != sgx_ecc256_open_context(&ecc_handle)) break; + if (SGX_SUCCESS != sgx_ecc256_open_context(&ecc_handle)) break; uint8_t result; - if ((SGX_SUCCESS == sgx_ecdsa_verify(pMsg, nMsg, - (sgx_ec256_public_t *)pPublicKey, - (sgx_ec256_signature_t *)pSignature, + if ((SGX_SUCCESS == sgx_ecdsa_verify(pMsg, nMsg, + (sgx_ec256_public_t *)pPublicKey, + (sgx_ec256_signature_t *)pSignature, &result, ecc_handle)) && (result == SGX_EC_VALID )) *fValid = true; @@ -274,9 +274,9 @@ const UINT8 OcspResponseTypeOid[][9] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x01} }; -const UINT8 ExtendedKeyUsageOcspSignOid[][8] = +const UINT8 ExtendedKeyUsageOcspSignOid[][8] = { - 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09 + 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09 }; #endif @@ -285,7 +285,7 @@ const UINT8 ExtendedKeyUsageOcspSignOid[][8] = ParseOcspResponseChain - Decodes a DER encoded X.509 OCSP response and makes a list of the serial numbers and hashes from the OCSP response. @param OcspRespBuffer - If not NULL, contains the OCSP response. OCSP response contains a list of certificates with their current status (good/revoked) -@param OcspRespBufferLength - Total Length of the OCSP response +@param OcspRespBufferLength - Total Length of the OCSP response @param OcspCertRootPublicKey - Public key used to sign the first certificate in the chain. This is the root of trust. If NULL, Intel public key is used. @param OcspCertStatusTable - Table containing interesting fields in the OCSP response which will be used to compare against the verifier certificate. @param NumberOfSingleResponses - Number of single responses that the OCSP response has returned to us. @@ -380,7 +380,7 @@ STATUS ParseOcspResponseChain( UINT8* OcspRespBuffer, DBG_ASSERT(SingleResponse->issuerNameHash.length <= 255); OcspCertStatusTable[TableIndex].issuerNameHashSize = (UINT8)SingleResponse->issuerNameHash.length; - OcspCertStatusTable[TableIndex].HashAlgo = SingleResponse->issuerIdentifierHashType; + OcspCertStatusTable[TableIndex].HashAlgo = SingleResponse->issuerIdentifierHashType; TableIndex++; } } @@ -400,10 +400,10 @@ STATUS ParseOcspResponseChain( UINT8* OcspRespBuffer, /* -ParseCertificateChain - This function can +ParseCertificateChain - This function can - parse a certificate chain and return the CertificateFields of all the last certificate (usually the certificate of interest) - optionally take in root public key that was used to sign first certificate in the chain. If NULL, Intel public Key is used. -- optionally take in ocspRespBuffer. If ocspRespBuffer is not NULL, this function will parse the ocsp response cert, make a list of +- optionally take in ocspRespBuffer. If ocspRespBuffer is not NULL, this function will parse the ocsp response cert, make a list of certificates authenticated by OCSP responder, and use this list to verify if each certificate in the chain has been authenticated. - optionally takes in the root public key used to sign the first certifcate in the OCSP responders certificate. @@ -421,13 +421,13 @@ certificates authenticated by OCSP responder, and use this list to verify if eac @retval X509_STATUS_SUCCESS - The operation completed successfully. */ -/* Input: +/* Input: pointer to buffer containing a chain of certificates Total Length Assumes the first certificate in the chain is signed by Intel */ -STATUS ParseCertificateChain(UINT8 *pCertChain, +STATUS ParseCertificateChain(UINT8 *pCertChain, UINT32 CertChainLength, SessMgrCertificateFields *certificateFields, UINT8 *CertWorkBuffer, @@ -443,8 +443,8 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, UINT8 CertCount = 0; SessMgrEcdsaPublicKey ecdsa_pub_key; - // This is the temp buffer used to store the issuer signing key to verify the next certificate in the chain. - // This size of this buffer should be equal to the Max possible key size + // This is the temp buffer used to store the issuer signing key to verify the next certificate in the chain. + // This size of this buffer should be equal to the Max possible key size UINT8 TempSignKeyBuffer[200]; SessMgrDataBuffer TempDataBuffer; UINT8 *pCert; @@ -577,14 +577,14 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, return Status; } - // First Certificate is always intel signed + // First Certificate is always intel signed Status = VerifyBasicCertificateAttributes(pCert, CertWorkBuffer, certificateFields, &IssuerInfo, CertType, CertLevel, UseFacsimileEpid); if(Status != X509_STATUS_SUCCESS){ DBG_ASSERT(0); return Status; } - // Verifiation is required if OCSP table exists (even if empty), make sure the certificate has not been revoked + // Verifiation is required if OCSP table exists (even if empty), make sure the certificate has not been revoked if(OcspCertStatusTable){ BOOL IntelSelfSignedRoot = false; #ifdef X509_FOR_PSE_PR @@ -592,9 +592,9 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, IntelSelfSignedRoot = true; #else if(CertLevel == root && memcmp(certificateFields->EncodedSubjectPublicKey.buffer+1, INTEL_ECDSA_PUBKEY_PROD_BE, sizeof(INTEL_ECDSA_PUBKEY_PROD_BE)) == 0) - IntelSelfSignedRoot = true; + IntelSelfSignedRoot = true; else if(gSessmgrCtx.FuseGidZero && CertLevel == root && memcmp(certificateFields->EncodedSubjectPublicKey.buffer+1, INTEL_ECDSA_PUBKEY_DBG_BE, sizeof(INTEL_ECDSA_PUBKEY_DBG_BE)) == 0) - IntelSelfSignedRoot = true; + IntelSelfSignedRoot = true; #endif // Skip revocation status check for Intel self-signed root certificate @@ -609,7 +609,7 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, } } - // Certificate has been verified. Everything is good. + // Certificate has been verified. Everything is good. // if this is not the leaf, store the public key and algorithm type to use in next certificate signature verification if(CertLevel != leaf){ @@ -647,7 +647,7 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, // If PathLen constraint set by this CA is more constrained than the one enforced by the previous CA, update MaxChainLength if(certificateFields->basicConstraint.isBasicConstraintPresent && certificateFields->basicConstraint.pathLenConstraint < (UINT32)MaxChainLengthAllowed) MaxChainLengthAllowed = certificateFields->basicConstraint.pathLenConstraint; - else + else MaxChainLengthAllowed--; IssuerInfo.CommonNameBuf.buffer = (UINT8 *)certificateFields->subject.commonName; IssuerInfo.CommonNameBuf.length = certificateFields->subject.commonNameSize; @@ -669,9 +669,9 @@ STATUS ParseCertificateChain(UINT8 *pCertChain, } #ifndef X509_FOR_PSE_PR -/* -This function compares the serial number of the certificate with the list of certificates that the OCSP responder sent us. -If found, Make sure the status of the certificate is not revoked. +/* +This function compares the serial number of the certificate with the list of certificates that the OCSP responder sent us. +If found, Make sure the status of the certificate is not revoked. */ STATUS VerifyOcspRevocationStatus(SessMgrCertificateFields* certificateFields, UINT8 NumberofSingleResponses, @@ -856,12 +856,12 @@ STATUS VerifySignature(const ISSUER_INFO *IssuerInfo, const SessMgrDataBuffer *M } if(VerifRes == FALSE) { DBG_ASSERT(0); - return X509_INVALID_SIGNATURE; + return X509_INVALID_SIGNATURE; } } #else if(VerifRes == FALSE) { - return X509_INVALID_SIGNATURE; + return X509_INVALID_SIGNATURE; } #endif @@ -872,12 +872,12 @@ STATUS VerifySignature(const ISSUER_INFO *IssuerInfo, const SessMgrDataBuffer *M SwapEndian_32B((reinterpret_cast(SignBuffer->buffer))->x); SwapEndian_32B((reinterpret_cast(SignBuffer->buffer))->y); #else - Cstatus = MessageVerify( (unsigned char *)&EcdsaKey, - sizeof(EcdsaKey), + Cstatus = MessageVerify( (unsigned char *)&EcdsaKey, + sizeof(EcdsaKey), MsgBuffer->buffer, - MsgBuffer->length, - SignBuffer->buffer, - SignBuffer->length, + MsgBuffer->length, + SignBuffer->buffer, + SignBuffer->length, &CResult); #ifdef TEMP_DISABLE_ECDSA_CHECK Status = X509_STATUS_SUCCESS; @@ -885,14 +885,14 @@ STATUS VerifySignature(const ISSUER_INFO *IssuerInfo, const SessMgrDataBuffer *M if(CResult != CdgValid) { DBG_ASSERT(0); - return X509_INVALID_SIGNATURE; + return X509_INVALID_SIGNATURE; } Status = X509_STATUS_SUCCESS; #endif - SetConsoleTextAttribute(hConsole, 11); + SetConsoleTextAttribute(hConsole, 11); printf("\n Signature Verified "); - SetConsoleTextAttribute(hConsole, 8); + SetConsoleTextAttribute(hConsole, 8); #endif break; @@ -954,7 +954,7 @@ STATUS VerifySignature(const ISSUER_INFO *IssuerInfo, const SessMgrDataBuffer *M if ((Status != STATUS_SUCCESS) || (IsSignatureValid != TRUE)){ DBG_ASSERT(0); - return X509_INVALID_SIGNATURE; + return X509_INVALID_SIGNATURE; } #else @@ -996,9 +996,9 @@ STATUS VerifySignature(const ISSUER_INFO *IssuerInfo, const SessMgrDataBuffer *M RsaKey->e= BN_bin2bn((UINT8*)RsaKeyFromCert->e.buffer,RsaKeyFromCert->e.length,RsaKey->e); RsaKey->n= BN_bin2bn((UINT8*)RsaKeyFromCert->n.buffer,RsaKeyFromCert->n.length, RsaKey->n); - Status = RSA_verify(HashType, - Hash, hashSize, - SignBuffer->buffer, SignBuffer->length, + Status = RSA_verify(HashType, + Hash, hashSize, + SignBuffer->buffer, SignBuffer->length, RsaKey); if(Status != 1){ DBG_ASSERT(0); @@ -1046,17 +1046,17 @@ STATUS VerifyOcspResponseAttributes(Uint8* OcspRespBuffer, SessMgrOcspResponseFi return X509_STATUS_OCSP_FAILURE; } - // parse the ocsp certificate + // parse the ocsp certificate SESSMGR_MEM_ALLOC_BUFFER(workBuffer, MM_DATA_HEAP_SHARED_RW, sizeof(UINT32), workBufferSize, TX_WAIT_FOREVER); do { Status = ParseCertificateChain(ocspResponseFields->responderCertificate.buffer, - ocspResponseFields->responderCertificate.length, + ocspResponseFields->responderCertificate.length, &certificateFields, workBuffer, workBufferSize, NULL, - 0, + 0, NULL, OcspResponderCertificate, UseFacsimileEpid); @@ -1079,7 +1079,7 @@ STATUS VerifyOcspResponseAttributes(Uint8* OcspRespBuffer, SessMgrOcspResponseFi } // Verify Nonce only on Signed FW. -#ifndef _WIN32_DEVPLATFORM +#ifndef _WIN32_DEVPLATFORM #ifndef WIN_TEST #ifndef X509_FOR_PSE_PR if(!(gManifestDataPtr->ManifestHeader.manifestFlags.r.debugManifest)){ @@ -1166,9 +1166,9 @@ STATUS VerifyOcspResponseAttributes(Uint8* OcspRespBuffer, SessMgrOcspResponseFi #ifdef PRINT printf("\nOcsp response signature verified "); - SetConsoleTextAttribute(hConsole, 2); + SetConsoleTextAttribute(hConsole, 2); printf("\n \n *************** VerifyOcspResponseAttributes complete ***************** \n \n"); - SetConsoleTextAttribute(hConsole, 8); + SetConsoleTextAttribute(hConsole, 8); #endif Status = X509_STATUS_SUCCESS; @@ -1180,7 +1180,7 @@ STATUS VerifyOcspResponseAttributes(Uint8* OcspRespBuffer, SessMgrOcspResponseFi } #endif // #ifndef X509_FOR_PSE_PR -STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, const Uint8* workBuffer, const SessMgrCertificateFields* certificateFields, +STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, const Uint8* workBuffer, const SessMgrCertificateFields* certificateFields, const ISSUER_INFO *IssuerInfo, const CertificateType CertType, CertificateLevel CertLevel, BOOL UseFacsimileEpid) { @@ -1272,7 +1272,7 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons return X509_STATUS_ENCODING_ERROR; } - // Basic constraints extension should be present. + // Basic constraints extension should be present. if(!certificateFields->basicConstraint.isBasicConstraintPresent){ DBG_ASSERT(0); return X509_STATUS_ENCODING_ERROR; @@ -1293,7 +1293,7 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons } // Make sure leaf certs dont have isCA set and intermediate Certs have isCa deasserted. - if( (CertLevel == leaf && certificateFields->basicConstraint.isCa == DER_ENCODING_TRUE) || + if( (CertLevel == leaf && certificateFields->basicConstraint.isCa == DER_ENCODING_TRUE) || (CertLevel != leaf && certificateFields->basicConstraint.isCa == DER_ENCODING_FALSE)){ DBG_ASSERT(0); return X509_STATUS_ENCODING_ERROR; @@ -1334,13 +1334,13 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons } } - // Every verifier cert should have an authority key id + // Every verifier cert should have an authority key id if(!certificateFields->AuthorityKeyId.buffer || (certificateFields->AuthorityKeyId.length != IssuerInfo->EncodedPublicKeyHashBuffer.length) ){ DBG_ASSERT(0); return X509_STATUS_ENCODING_ERROR; } - // Verify Authority Key Id. Spec says Authority Key ID of current cert should be equal to the SubjectKeyId of the upper cert. SubjectKeyId is nothing but the hash of the upper certs public key. + // Verify Authority Key Id. Spec says Authority Key ID of current cert should be equal to the SubjectKeyId of the upper cert. SubjectKeyId is nothing but the hash of the upper certs public key. // we have that available in this function. So compare Authority Key with that. if(certificateFields->AuthorityKeyId.length != IssuerInfo->EncodedPublicKeyHashBuffer.length || memcmp(certificateFields->AuthorityKeyId.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.length) != 0){ @@ -1365,7 +1365,7 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons return X509_STATUS_INTERNAL_ERROR; } if (certificateFields->AuthorityKeyId.length != IssuerInfo->EncodedPublicKeyHashBuffer.length || - memcmp(certificateFields->AuthorityKeyId.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.length) != 0){ + memcmp(certificateFields->AuthorityKeyId.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.buffer, IssuerInfo->EncodedPublicKeyHashBuffer.length) != 0){ DBG_ASSERT(0); return X509_STATUS_ENCODING_ERROR; } @@ -1384,7 +1384,7 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons return X509_STATUS_ENCODING_ERROR; } - // If issuer certificate product type exists, ensure it matches current cert + // If issuer certificate product type exists, ensure it matches current cert if ((IssuerInfo->productType != invalidProductType) && (IssuerInfo->productType != certificateFields->productType)) { DBG_ASSERT(0); return X509_STATUS_ENCODING_ERROR; @@ -1395,9 +1395,9 @@ STATUS VerifyBasicCertificateAttributes(const Uint8* certificateDerEncoded, cons #endif #ifdef PRINT - SetConsoleTextAttribute(hConsole, 4); + SetConsoleTextAttribute(hConsole, 4); printf("\n \n *************** VerifyBasicCertificateAttributes complete ***************** \n \n"); - SetConsoleTextAttribute(hConsole, 8); + SetConsoleTextAttribute(hConsole, 8); #endif return X509_STATUS_SUCCESS; @@ -1622,14 +1622,14 @@ static STATUS sessMgrParseDerCert /**** End Early Signature Verification *****/ - // Next Field : Version (Optional field with explicit tagging) + // Next Field : Version (Optional field with explicit tagging) Status = ParseIdAndLength(¤t_ptr, pCertEnd, EXPLICIT_TAG_0_ID_VALUE, &length, &EncodingBytes, TRUE); if( (Status != X509_STATUS_SUCCESS) && Status != X509_STATUS_NOT_FOUND) break; if(Status != X509_STATUS_NOT_FOUND){ - // We have a version number. Note: Not using ParseInteger function because certificateVersion is defined as a UINT32 and not a DataBuffer + // We have a version number. Note: Not using ParseInteger function because certificateVersion is defined as a UINT32 and not a DataBuffer Status = ParseIdAndLength(¤t_ptr, pCertEnd, DER_ENCODING_INTEGER_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS || length > MAX_VERSION_LENGTH_SIZE_BYTES){ Status = X509_STATUS_ENCODING_ERROR; @@ -1651,7 +1651,7 @@ static STATUS sessMgrParseDerCert break; } - // Next Field : Certificate Serial Number Format : Integer Identifier + Length + Value (Max 20 bytes) + // Next Field : Certificate Serial Number Format : Integer Identifier + Length + Value (Max 20 bytes) Status = ParseInteger(¤t_ptr, pCertEnd, &certificateFields->serialNumber, FALSE, TRUE, &padding); if ((Status != X509_STATUS_SUCCESS) || (certificateFields->serialNumber.length + padding > MAX_HASH_LEN)) { DBG_ASSERT(0); @@ -1673,7 +1673,7 @@ static STATUS sessMgrParseDerCert break; } - // Next Field : issuer + // Next Field : issuer Status = ParseName(¤t_ptr, pCertEnd, &certificateFields->issuer); if(Status != X509_STATUS_SUCCESS){ DBG_ASSERT(0); @@ -1686,7 +1686,7 @@ static STATUS sessMgrParseDerCert if(Status != X509_STATUS_SUCCESS) break; - // Parse notBefore, notAfter, Subject, SubjectPublic key info + // Parse notBefore, notAfter, Subject, SubjectPublic key info Status = ParseTime(¤t_ptr, pCertEnd, &certificateFields->notValidBeforeTime); if(Status != X509_STATUS_SUCCESS) @@ -1706,7 +1706,7 @@ static STATUS sessMgrParseDerCert // Next Field: IssuerUniqueId [optional] Implicit TAG Number is 1 Type : UniqueIdentifier (BIT STRING) Status = ParseIdAndLength(¤t_ptr, pCertEnd, IMPLICIT_TAG_ID + TAG_NUMBER_ISSUER_UNIQUE_ID, &length, &EncodingBytes, TRUE); - if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) + if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; if(Status != X509_STATUS_NOT_FOUND){ @@ -1717,7 +1717,7 @@ static STATUS sessMgrParseDerCert // Next Field: SubjectUniqueId [optional] Implicit TAG Number is 2 Type : UniqueIdentifier (BIT STRING) Status = ParseIdAndLength(¤t_ptr, pCertEnd, IMPLICIT_TAG_ID + TAG_NUMBER_SUBJECT_UNIQUE_ID, &length, &EncodingBytes, TRUE); - if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) + if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; if(Status != X509_STATUS_NOT_FOUND){ @@ -1726,9 +1726,9 @@ static STATUS sessMgrParseDerCert current_ptr += length; } - // Next Field: Extensions [optional] + // Next Field: Extensions [optional] Status = ParseIdAndLength(¤t_ptr, pCertEnd, EXPLICIT_TAG_ID + TAG_NUMBER_EXTENSIONS, &length, &EncodingBytes, TRUE); - if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) + if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; @@ -1753,7 +1753,7 @@ static STATUS sessMgrParseDerCert break; } - // Next field : SignatureValue + // Next field : SignatureValue Status = ParseSignatureValue(¤t_ptr, pCertEnd, &workBuffer, workBufferSize - (int)(workBuffer - workBufferStart), &certificateFields->signatureBuffer, certificateFields->algorithmIdentifierForSignature); if(Status != X509_STATUS_SUCCESS){ DBG_ASSERT(0); @@ -1795,9 +1795,9 @@ STATUS sessMgrParseOcspResponse UINT32 padding; #ifdef WIN_TEST - SetConsoleTextAttribute(hConsole, 4); + SetConsoleTextAttribute(hConsole, 4); printf("\n \n *************** Parsing OCSP response ***************** \n \n"); - SetConsoleTextAttribute(hConsole, 8); + SetConsoleTextAttribute(hConsole, 8); #endif /* Ocsp response is a SEQ { responseStatus, response bytes }*/ @@ -1807,10 +1807,10 @@ STATUS sessMgrParseOcspResponse if(Status != X509_STATUS_SUCCESS) break; - // Next Field: response status response status is a enumerated type + // Next Field: response status response status is a enumerated type Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, DER_ENCODING_ENUMERATED_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS || length != 1){ - // Note: currently we support only 7 bits. So error out if length is more than 1 byte + // Note: currently we support only 7 bits. So error out if length is more than 1 byte Status = X509_STATUS_ENCODING_ERROR; break; } @@ -1835,7 +1835,7 @@ STATUS sessMgrParseOcspResponse if(Status != X509_STATUS_SUCCESS) break; - // Next Field: responseType Type : Object ID + // Next Field: responseType Type : Object ID Status = ParseOID(¤t_ptr, OcspResponseEnd, &temp, &OcspResponseTypeOid[0][0], sizeof(OcspResponseTypeOid)/sizeof(OcspResponseTypeOid[0]), sizeof(OcspResponseTypeOid[0])); @@ -1845,7 +1845,7 @@ STATUS sessMgrParseOcspResponse break; } - // Next Field: response Type : OCTET STRING + // Next Field: response Type : OCTET STRING Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -1870,11 +1870,11 @@ STATUS sessMgrParseOcspResponse break; if(Status != X509_STATUS_NOT_FOUND){ - // we have version. Just parse over it + // we have version. Just parse over it current_ptr += length; } - // Next Field : ResponderId ResponderId can be a choice of either Name or KeyHash. We distinguish them using the tags + // Next Field : ResponderId ResponderId can be a choice of either Name or KeyHash. We distinguish them using the tags Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, EXPLICIT_TAG_ID + TAG_NUMBER_RESPONDER_NAME, &length, &EncodingBytes, TRUE); if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; @@ -1891,7 +1891,7 @@ STATUS sessMgrParseOcspResponse break; } - // KeyHash is a octet String + // KeyHash is a octet String Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -1910,7 +1910,7 @@ STATUS sessMgrParseOcspResponse PrintValidity(&OcspResponseFields->producedAt); #endif - // Next Field : response Format : responses is a SEQ { single Responses } + // Next Field : response Format : responses is a SEQ { single Responses } Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -2004,7 +2004,7 @@ STATUS sessMgrParseOcspResponse SingleResponse->ocspCertificateStatus = revoked; /* This will be followed by a revoked time and reason. - We parse but ignore those fields + We parse but ignore those fields */ current_ptr++; @@ -2031,7 +2031,7 @@ STATUS sessMgrParseOcspResponse if(Status != X509_STATUS_SUCCESS) break; - // Next Field : ThisUpdate type: GeneralizedTime + // Next Field : ThisUpdate type: GeneralizedTime Status = ParseTime(¤t_ptr, end_of_single_responses, &SingleResponse->thisUpdate); if(Status != X509_STATUS_SUCCESS) break; @@ -2066,7 +2066,7 @@ STATUS sessMgrParseOcspResponse } SingleResponse = (SessMgrOcspSingleResponse *)((UINT8 *)SingleResponse + sizeof(SessMgrOcspSingleResponse)); - OcspResponseFields->numberOfSingleReponses++; + OcspResponseFields->numberOfSingleReponses++; Status = X509_STATUS_SUCCESS; } @@ -2092,7 +2092,7 @@ STATUS sessMgrParseOcspResponse #endif - // Next Field : Response Extensions [optional] + // Next Field : Response Extensions [optional] Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, EXPLICIT_TAG_ID + TAG_NUMBER_RESPONSE_EXTENSIONS, &length, &EncodingBytes, TRUE); if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; @@ -2115,7 +2115,7 @@ STATUS sessMgrParseOcspResponse break; // Next field : Certificate of the OCSP responder. This can be a chain */ - // ??? why is this optional + // ??? why is this optional Status = ParseIdAndLength(¤t_ptr, OcspResponseEnd, EXPLICIT_TAG_ID + TAG_NUMBER_CERTS, &length, &EncodingBytes, TRUE); if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) @@ -2178,7 +2178,7 @@ static STATUS ParseBoolean(UINT8 **ppCurrent, UINT8 *pEnd, BOOL* Value, BOOL opt } #endif -/* ParseInteger will strip out the integer encoding part. If parsing is successful, ParseInteger +/* ParseInteger will strip out the integer encoding part. If parsing is successful, ParseInteger will update the current pointer and length Returns X509_ENCODING_ERROR on failure @@ -2231,7 +2231,7 @@ STATUS ParseOcspExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrOcspResponseFi UINT8 EncodingBytes; do{ - // Extensions = SEQ { extension } Each extension is associated with a Object ID. We support the extensions listed in ExtensionOID array. + // Extensions = SEQ { extension } Each extension is associated with a Object ID. We support the extensions listed in ExtensionOID array. Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) @@ -2239,7 +2239,7 @@ STATUS ParseOcspExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrOcspResponseFi while(current_ptr < pEnd){ - // Each extension is a SEQ { extid (OID) , critical (BOOLEAN), extnValue (OCTET STRING) } + // Each extension is a SEQ { extid (OID) , critical (BOOLEAN), extnValue (OCTET STRING) } Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -2255,13 +2255,13 @@ STATUS ParseOcspExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrOcspResponseFi break; } - // Next field is "Critical". This indicates whether it is mandatory for the parser to understand the extension. This is an optinal field. default is false + // Next field is "Critical". This indicates whether it is mandatory for the parser to understand the extension. This is an optinal field. default is false Status = ParseBoolean(¤t_ptr, pEnd, &critical, TRUE); if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; if(Status == X509_STATUS_NOT_FOUND) - critical = DER_ENCODING_FALSE; + critical = DER_ENCODING_FALSE; // Next Field: Extn Value This is a OCTET STRING Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); @@ -2287,8 +2287,8 @@ STATUS ParseOcspExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrOcspResponseFi break; default: - /* unsupported extension. - Check if it marked as critical. If so, return error else ignore this extension + /* unsupported extension. + Check if it marked as critical. If so, return error else ignore this extension */ if(critical == DER_ENCODING_TRUE){ @@ -2311,7 +2311,7 @@ STATUS ParseOcspExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrOcspResponseFi Status = X509_STATUS_SUCCESS; - } // WHILE end of extensions + } // WHILE end of extensions }while(0); // do_while *ppCurrent = current_ptr; @@ -2336,7 +2336,7 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie do{ - // Extensions = SEQ { extension } Each extension is associated with a Object ID. We support the extensions listed in ExtensionOID array. + // Extensions = SEQ { extension } Each extension is associated with a Object ID. We support the extensions listed in ExtensionOID array. Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) @@ -2344,7 +2344,7 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie while(current_ptr < pEnd){ - // Each extension is a SEQ { extid (OID) , critical (BOOLEAN), extnValue (OCTET STRING) } + // Each extension is a SEQ { extid (OID) , critical (BOOLEAN), extnValue (OCTET STRING) } Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -2360,13 +2360,13 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie break; } - // Next field is "Critical". This indicates whether it is mandatory for the parser to understand the extension. This is an optinal field. default is false + // Next field is "Critical". This indicates whether it is mandatory for the parser to understand the extension. This is an optinal field. default is false Status = ParseBoolean(¤t_ptr, pEnd, &critical, TRUE); if(Status != X509_STATUS_SUCCESS && Status != X509_STATUS_NOT_FOUND) break; if(Status == X509_STATUS_NOT_FOUND) - critical = DER_ENCODING_FALSE; + critical = DER_ENCODING_FALSE; // Next Field: Extn Value This is a OCTET STRING Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); @@ -2497,7 +2497,7 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie if(Status != X509_STATUS_SUCCESS) break; - // KeyPurposeId is a object identifier + // KeyPurposeId is a object identifier Status = ParseOID(¤t_ptr, pEnd, &ExtendedKeyUsageOcspType, &ExtendedKeyUsageOcspSignOid[0][0], sizeof(ExtendedKeyUsageOcspSignOid)/sizeof(ExtendedKeyUsageOcspSignOid[0]), sizeof(ExtendedKeyUsageOcspSignOid[0])); @@ -2530,7 +2530,7 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie break; if(Status == X509_STATUS_NOT_FOUND) - certificateFields->basicConstraint.isCa = DER_ENCODING_FALSE; + certificateFields->basicConstraint.isCa = DER_ENCODING_FALSE; // Next field is PathLenConstraint [Integer optional] Status = ParseInteger(¤t_ptr, pEnd, &DataBuf, TRUE, FALSE, NULL); @@ -2569,8 +2569,8 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie current_ptr++; break; default: - /* unsupported extension. - Check if it marked as critical. If so, return error else ignore this extension + /* unsupported extension. + Check if it marked as critical. If so, return error else ignore this extension */ if(critical == DER_ENCODING_TRUE){ @@ -2593,7 +2593,7 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie Status = X509_STATUS_SUCCESS; - } // WHILE end of extensions + } // WHILE end of extensions }while(0); DBG_ASSERT(Status == X509_STATUS_SUCCESS); @@ -2606,10 +2606,10 @@ STATUS ParseCertExtensions(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrCertificateFie /* Certificate Policy is a SEQ of Policy Information. Policy information is Seq of {Policy Identifier, Policy Qualifier [optional] } -Policy Identifier is a Object ID +Policy Identifier is a Object ID Policy Qualifier Info is Seq {PolicyqualifierId, qualifier } -PolicyqualifierId is a known Object id +PolicyqualifierId is a known Object id Qualifier is a CHOICE{cPSuri, UserNotice} we only support cpSuri which is a IA5string @@ -2639,7 +2639,7 @@ static STATUS ParseCertificatePolicy(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrData if(Status != X509_STATUS_SUCCESS) break; - // Policy Identifier is a Object ID + // Policy Identifier is a Object ID Status = ParseOID(¤t_ptr, end_of_PolicyInformation, &temp, &CertificatePolicyOid[0][0], sizeof(CertificatePolicyOid)/sizeof(CertificatePolicyOid[0]), sizeof(CertificatePolicyOid[0])); @@ -2674,7 +2674,7 @@ static STATUS ParseCertificatePolicy(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrData break; } - // we have a supported policy qualifier id. Qualifier can be a CHOICE{cPSuri, UserNotice}. Note : Parser only supports cPSuri + // we have a supported policy qualifier id. Qualifier can be a CHOICE{cPSuri, UserNotice}. Note : Parser only supports cPSuri Status = ParseIdAndLength(¤t_ptr, end_of_PolicyInformation, DER_ENCODING_IA5_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; @@ -2727,8 +2727,8 @@ static STATUS ParseSubjectPublicKeyInfo(UINT8 **ppCurrent, UINT8 *pEnd, UINT8 ** /* current_ptr is over the number of padding bits for the BIT string . We expect this to always be zero since we are not dealing with bit level data */ if(*current_ptr != 0x00){ - DBG_ASSERT(0); - return X509_STATUS_ENCODING_ERROR; + DBG_ASSERT(0); + return X509_STATUS_ENCODING_ERROR; } current_ptr++; @@ -2742,19 +2742,19 @@ static STATUS ParseSubjectPublicKeyInfo(UINT8 **ppCurrent, UINT8 *pEnd, UINT8 ** case X509_ecdsaPublicKey: // for ecdsa we know the length should be 66 bytes. - if(length != 66){ - Status = X509_STATUS_ENCODING_ERROR; + if(length != 66){ + Status = X509_STATUS_ENCODING_ERROR; break; } - Key->buffer = workbuffer_ptr; + Key->buffer = workbuffer_ptr; Key->length = sizeof(SessMgrEcdsaPublicKey); workbuffer_ptr += sizeof(SessMgrEcdsaPublicKey); Status = ParseEcdsaPublicKey(¤t_ptr, pEnd, (SessMgrEcdsaPublicKey * )(Key->buffer), (SessMgrEllipticCurveParameter)params); break; case X509_intel_sigma_epidGroupPublicKey_epid11: - Key->buffer = workbuffer_ptr; + Key->buffer = workbuffer_ptr; Key->length = sizeof(SessMgrEpidGroupPublicKey); workbuffer_ptr += sizeof(SessMgrEpidGroupPublicKey); Status = ParseEpidPublicKey(¤t_ptr, pEnd, (SessMgrEpidGroupPublicKey * )(Key->buffer)); @@ -2764,7 +2764,7 @@ static STATUS ParseSubjectPublicKeyInfo(UINT8 **ppCurrent, UINT8 *pEnd, UINT8 ** break; case X509_rsaPublicKey: - Key->buffer = workbuffer_ptr; + Key->buffer = workbuffer_ptr; Key->length = sizeof(SessMgrRsaKey); workbuffer_ptr += sizeof(SessMgrRsaKey); Status = ParseRsaPublicKey(¤t_ptr, pEnd, (SessMgrRsaKey * )(Key->buffer)); @@ -2797,8 +2797,8 @@ static STATUS ParseRsaPublicKey(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrRsaKey * /* The data portion of the BIT string contains a sequence of Seq { n , e} where n and e are integers */ Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_SEQUENCE_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS){ - DBG_ASSERT(0); - return X509_STATUS_ENCODING_ERROR; + DBG_ASSERT(0); + return X509_STATUS_ENCODING_ERROR; } Status = ParseInteger(¤t_ptr, pEnd, &RsaKey->n, FALSE, FALSE, NULL); @@ -2838,48 +2838,48 @@ static STATUS ParseEpidPublicKey(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrEpidGrou if(Status != X509_STATUS_SUCCESS) break; - // Next Field : h1 [octet string] This is a ECPoint which is a octet string + // Next Field : h1 [octet string] This is a ECPoint which is a octet string Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; /* Make sure it has the first bype as 0x04 indicating key is uncompressed */ - if(*current_ptr != 0x04){ - Status = X509_STATUS_ENCODING_ERROR; + if(*current_ptr != 0x04){ + Status = X509_STATUS_ENCODING_ERROR; break; - } + } current_ptr++; EpidKey->h1x = current_ptr; EpidKey->h1y = current_ptr + 32; current_ptr += 64; - // Next Field : h2 [octet string] This is a ECPoint which is a octet string + // Next Field : h2 [octet string] This is a ECPoint which is a octet string Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; /* Make sure it has the first bype as 0x04 indicating key is uncompressed */ - if(*current_ptr != 0x04){ - Status = X509_STATUS_ENCODING_ERROR; + if(*current_ptr != 0x04){ + Status = X509_STATUS_ENCODING_ERROR; break; - } + } current_ptr++; EpidKey->h2x = current_ptr; EpidKey->h2y = current_ptr + 32; current_ptr += 64; - // Next Field : w [octet string] This is a ECPoint which is a octet string + // Next Field : w [octet string] This is a ECPoint which is a octet string Status = ParseIdAndLength(¤t_ptr, pEnd, DER_ENCODING_OCTET_STRING_ID, &length, &EncodingBytes, FALSE); if(Status != X509_STATUS_SUCCESS) break; /* Make sure it has the first bype as 0x04 indicating key is uncompressed */ - if(*current_ptr != 0x04){ - Status = X509_STATUS_ENCODING_ERROR; + if(*current_ptr != 0x04){ + Status = X509_STATUS_ENCODING_ERROR; break; - } + } current_ptr++; EpidKey->wx0 = current_ptr; @@ -2914,10 +2914,10 @@ static STATUS ParseEcdsaPublicKey(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrEcdsaPu /* First octet of bit string is 0x04 indicating key is uncompressed. Note: The Key is in OCTET String form and we convert it to BIT STRING. Format : 0x04 | 64-bytes of keys */ - if(*current_ptr != 0x04){ - Status = X509_STATUS_ENCODING_ERROR; + if(*current_ptr != 0x04){ + Status = X509_STATUS_ENCODING_ERROR; break; - } + } current_ptr++; EcDsaKey->px = current_ptr; @@ -3088,7 +3088,7 @@ static STATUS ParseSignatureValue(UINT8 **ppCurrent, UINT8 *pEnd, UINT8 **pworkb static STATUS ParseAlgoIdentifier(UINT8 **ppCurrent, UINT8 *pEnd, UINT32* algoId, AlgorithmTypes Type, SessMgrEllipticCurveParameter *params) { - /***** + /***** Format : Sequence Id + length + Object Id + length + OID value + parameters (optional) *****/ @@ -3109,19 +3109,19 @@ static STATUS ParseAlgoIdentifier(UINT8 **ppCurrent, UINT8 *pEnd, UINT32* algoId switch(Type){ case signature_algo: Status = ParseOID(¤t_ptr, pEnd, algoId, &HardCodedSignatureAlgorithmOid[0][0], - sizeof(HardCodedSignatureAlgorithmOid)/sizeof(HardCodedSignatureAlgorithmOid[0]), + static_cast(sizeof(HardCodedSignatureAlgorithmOid)/sizeof(HardCodedSignatureAlgorithmOid[0])), sizeof(HardCodedSignatureAlgorithmOid[0])); break; case PublicKey_algo: Status = ParseOID(¤t_ptr, pEnd, algoId, &HardCodedPublicKeyAlgorithmOid[0][0], - sizeof(HardCodedPublicKeyAlgorithmOid)/sizeof(HardCodedPublicKeyAlgorithmOid[0]), + static_cast(sizeof(HardCodedPublicKeyAlgorithmOid)/sizeof(HardCodedPublicKeyAlgorithmOid[0])), sizeof(HardCodedPublicKeyAlgorithmOid[0])); break; case Hash_algo: Status = ParseOID(¤t_ptr, pEnd, algoId, &HashAlgorithmOid[0][0], - sizeof(HashAlgorithmOid)/sizeof(HashAlgorithmOid[0]), + static_cast(sizeof(HashAlgorithmOid)/sizeof(HashAlgorithmOid[0])), sizeof(HashAlgorithmOid[0])); break; @@ -3228,7 +3228,7 @@ static STATUS ParseAlgoParameters(UINT8 **ppCurrent, UINT8 *pEnd, UINT32* param) static STATUS ParseName(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrX509Name* Name) { - UINT8* end_of_sequence = NULL; + UINT8* end_of_sequence = NULL; UINT8 *current_ptr = *ppCurrent; UINT32 length; STATUS Status; @@ -3265,7 +3265,7 @@ static STATUS ParseName(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrX509Name* Name) /* Expected value : Attribute type (OID) and value (Can be anything) */ Status = ParseOID(¤t_ptr, end_of_sequence, &NameType, &HardCodedNameOid[0][0], - sizeof(HardCodedNameOid)/sizeof(HardCodedNameOid[0]), + static_cast(sizeof(HardCodedNameOid)/sizeof(HardCodedNameOid[0])), sizeof(HardCodedNameOid[0])); // We might have some cases where we are getting an Unknown OID which we just ignore. @@ -3320,7 +3320,7 @@ static STATUS ParseName(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrX509Name* Name) case organizationUnit: Name->organizationUnit = (char *)current_ptr; Name->organizationUnitSize = length; - break; + break; case UserId: Name->UserId = (char *)current_ptr; Name->UserIdSize = length; @@ -3329,7 +3329,7 @@ static STATUS ParseName(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrX509Name* Name) default: // Dont support this NameType. Just continue. break; - } + } current_ptr += length; } }while(0); @@ -3338,18 +3338,16 @@ static STATUS ParseName(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrX509Name* Name) return Status; } -#define DecodeTime_FourBytes(current_ptr) (1000*( (*current_ptr) - 0x30)) + \ +#define DecodeTime_FourBytes(current_ptr) ((1000*( (*current_ptr) - 0x30)) + \ (100*( *(current_ptr+1) - 0x30)) + \ (10*( *(current_ptr+2) - 0x30)) + \ - (*(current_ptr + 3) - 0x30); \ - current_ptr+=4; + (*(current_ptr + 3) - 0x30)) \ -#define DecodeTime_TwoBytes(current_ptr) (10*( (*current_ptr) - 0x30)) + \ - (*(current_ptr + 1) - 0x30); \ - current_ptr+=2; +#define DecodeTime_TwoBytes(current_ptr) ((10*( (*current_ptr) - 0x30)) + \ + (*(current_ptr + 1) - 0x30)) \ -#if 0 +#if 0 UINT32 DecodeTime(UINT8 *current_ptr, UINT8 length) { UINT32 value = 0; @@ -3370,7 +3368,7 @@ UINT32 DecodeTime(UINT8 *current_ptr, UINT8 length) static STATUS ParseTime(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrDateTime* DateTime) -{ +{ /* Id : Either UTC Time or Generalized Time */ /***** Supported UTC formats : YYMMDDhhmmZ @@ -3417,27 +3415,34 @@ static STATUS ParseTime(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrDateTime* DateTim current_ptr += EncodingBytes; date_start_ptr = current_ptr; - /* Only difference between generalized and UTC is number of digits for the years. + /* Only difference between generalized and UTC is number of digits for the years. UTC has 2 digits and Generalized has 4 digits */ if(!isUTC){ - DateTime->date.yearMonthDay.year = DecodeTime_FourBytes(current_ptr); + DateTime->date.yearMonthDay.year = static_cast(DecodeTime_FourBytes(current_ptr)); + current_ptr += 4; }else{ // per rfc3280, if XX >= 50 then 19XX, otherwise 20XX. However, here we always use 20XX. - DateTime->date.yearMonthDay.year = DecodeTime_TwoBytes(current_ptr); - DateTime->date.yearMonthDay.year += 2000; + DateTime->date.yearMonthDay.year = static_cast(DecodeTime_TwoBytes(current_ptr)); + current_ptr += 2; + DateTime->date.yearMonthDay.year = static_cast(DateTime->date.yearMonthDay.year + 2000); } /* The next 8 bytes are common for both UTC and Generalized time */ - DateTime->date.yearMonthDay.month = DecodeTime_TwoBytes(current_ptr); - DateTime->date.yearMonthDay.day = DecodeTime_TwoBytes(current_ptr); - DateTime->time.hourMinuteSecond.hour = DecodeTime_TwoBytes(current_ptr); - DateTime->time.hourMinuteSecond.minute = DecodeTime_TwoBytes(current_ptr); + DateTime->date.yearMonthDay.month = DecodeTime_TwoBytes(current_ptr) & 0xF; + current_ptr += 2; + DateTime->date.yearMonthDay.day = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; + DateTime->time.hourMinuteSecond.hour = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; + DateTime->time.hourMinuteSecond.minute = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; /* Next character can be a numeral(incase we have seconds), +, - or Z */ if(isdigit(*current_ptr)){ /* we have second. Get the next two bytes as seconds. */ - DateTime->time.hourMinuteSecond.second = DecodeTime_TwoBytes(current_ptr); + DateTime->time.hourMinuteSecond.second = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; } /* Next character has to be +, - or Z */ @@ -3445,10 +3450,13 @@ static STATUS ParseTime(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrDateTime* DateTim { case '-': DateTime->time.hourMinuteSecond.timezone_is_neg = true; + /* fallthrough */ case '+': current_ptr++; - DateTime->time.hourMinuteSecond.timezone_hour = DecodeTime_TwoBytes(current_ptr); - DateTime->time.hourMinuteSecond.timezone_minute = DecodeTime_TwoBytes(current_ptr); + DateTime->time.hourMinuteSecond.timezone_hour = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; + DateTime->time.hourMinuteSecond.timezone_minute = DecodeTime_TwoBytes(current_ptr) & 0x3F; + current_ptr += 2; break; case 'Z': @@ -3492,7 +3500,7 @@ static STATUS ParseTime(UINT8 **ppCurrent, UINT8 *pEnd, SessMgrDateTime* DateTim \param[out] Length Length of the Asn DER encoded type in bytes \param[out] EncodingBytes Number of bytes used for the encoding of the length -\retval X509_STATUS_SUCCESS +\retval X509_STATUS_SUCCESS \retval STATUS_INVALID_PARAMS THere was some error in parsing the ASN Der encoded buffer. @brief Return length of the ASN DER encoded type @@ -3530,7 +3538,7 @@ static STATUS DecodeLength(UINT8* Buffer, UINT8* BufferEnd, UINT32* Length, UINT return X509_STATUS_ENCODING_ERROR; } - return X509_STATUS_SUCCESS; + return X509_STATUS_SUCCESS; } static void SwapEndian(UINT8* ptr, int length) @@ -3580,17 +3588,17 @@ static STATUS swapendian_memcpy(UINT8 *DestPtr, UINT32 DestLen, UINT8 *SrcPtr, U /** @brief ASN DER encoding follows the TLV format : Type Identifier || Length || Value -1. This function will parse the Type ID and Length, validate it with Expected Id and some encoding rules. +1. This function will parse the Type ID and Length, validate it with Expected Id and some encoding rules. 2. If no errors, function will move the current ptr to the value. \param[in] pCurrentPtr This is a pointer to the current pointer. The function will move the current pointer after parsing the ID and length -\param[in] ExpectedId Expected Type identifier -\param[out] Length Length in Bytes of the "Value" +\param[in] ExpectedId Expected Type identifier +\param[out] Length Length in Bytes of the "Value" \param[out] EncodingBytes Number of Bytes used to encode the length field. \param[in] Optional Is the ExpectedIdOptional @retval X509_STATUS_SUCCESS ID and length were parsed and verified successfully. -@retval X509_STATUS_NOT_FOUND This value is only returned +@retval X509_STATUS_NOT_FOUND This value is only returned @retval STATUS_ENCODING_ERROR Some error in the encoding of the certificate. */ diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/config.xml b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/config.xml index f236e16819..a13ecbed28 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/config.xml +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/config.xml @@ -5,8 +5,10 @@ 0x2 4 1 + 0 1 0x4000 0x30000 + 0x30000 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/prepare_hmac_sha256.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/prepare_hmac_sha256.cpp index c990ef37d0..454368a4a5 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/prepare_hmac_sha256.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/prepare_hmac_sha256.cpp @@ -58,7 +58,11 @@ PrepareHMACSHA256::PrepareHMACSHA256(const Ipp8u* key, size_t keyLength) } if (keyLength > INT32_MAX) + { + free(m_pCtx); + m_pCtx = NULL; break; + } m_ippstatus = ippsHMAC_Init(key, (int)keyLength, m_pCtx, IPP_ALG_HASH_SHA256); if (m_ippstatus != ippStsNoErr) diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/pse_pr.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/pse_pr.cpp index 08fa709481..57ffd7280a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/pse_pr.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/pse_pr.cpp @@ -51,7 +51,7 @@ static TEpidSigma11Verifier* s_pVerifier = NULL; - +//length to copy into enclave size_t get_sigRL_size(const EPID11_SIG_RL* pSigRL) { uint32_t nEntries = 0; @@ -59,11 +59,12 @@ size_t get_sigRL_size(const EPID11_SIG_RL* pSigRL) if (TEpidSigma11Verifier::get_sigRL_info(pSigRL, nEntries, nSize)) return nSize; - - return 0; + else + //invalid sigRL + return sizeof(EPID11_SIG_RL); } - +//length to copy into enclave size_t get_privRL_size(const EPID11_PRIV_RL* pPrivRL) { uint32_t nEntries = 0; @@ -71,8 +72,9 @@ size_t get_privRL_size(const EPID11_PRIV_RL* pPrivRL) if (TEpidSigma11Verifier::get_privRL_info(pPrivRL, nEntries, nSize)) return nSize; - - return 0; + else + //invalid privRL + return sizeof(EPID11_PRIV_RL); } diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sigma_crypto_layer.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sigma_crypto_layer.cpp index 31dc688cbb..1d6974dcec 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sigma_crypto_layer.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sigma_crypto_layer.cpp @@ -28,9 +28,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - - + + #include "sigma_crypto_layer.h" +#include "sgx_ecc256_internal.h" #include "pse_pr_inc.h" #include "pse_pr_types.h" #include "safe_id.h" @@ -113,15 +114,15 @@ ae_error_t SigmaCryptoLayer::DeriveSkMk(/* In */ sgx_ecc_state_handle_t ecc_han do { // Watch for null pointers - if (ecc_handle == NULL) + if (ecc_handle == NULL) { ae_status = PSE_PR_PARAMETER_ERROR; break; } - sgx_status_t sgx_status = sgx_ecc256_compute_shared_dhkey512((sgx_ec256_private_t *)m_local_private_key_b_little_endian, + sgx_status_t sgx_status = sgx_ecc256_compute_shared_point((sgx_ec256_private_t *)m_local_private_key_b_little_endian, (sgx_ec256_public_t *)public_key_little_endian, - (sgx_ec256_dh_shared512_t *)Gab, + (sgx_ec256_shared_point_t *)Gab, ecc_handle); if (SGX_SUCCESS != sgx_status) { @@ -187,7 +188,7 @@ ae_error_t SigmaCryptoLayer::calc_s2_hmac( p.Update(&s2->OcspReq, sizeof(s2->OcspReq)); p.Update(s2->Data, nS2VLDataLen); - //NRG: SIGMA_HMAC - HMAC_SHA256 of [Gb || Basename || OCSP Req || + //NRG: SIGMA_HMAC - HMAC_SHA256 of [Gb || Basename || OCSP Req || // Verifier Cert || Sig-RL List ], using SMK return p.Finalize(hmac); @@ -202,7 +203,7 @@ ae_error_t SigmaCryptoLayer::calc_s3_hmac( p.Update(s3->Ga, sizeof(s3->Ga)); p.Update(s3->Data, nS3VLDataLen); - //NRG: SIGMA_HMAC -- HMAC_SHA256 of [TaskInfo || g^a || + //NRG: SIGMA_HMAC -- HMAC_SHA256 of [TaskInfo || g^a || // EPIDCertprvr || EPIDSig(g^a || g^b)], using SMK return p.Finalize(hmac); @@ -222,8 +223,8 @@ ae_error_t SigmaCryptoLayer::ComputePR(SIGMA_SECRET_KEY* oldSK, Ipp8u byteToAdd, Sk_Wth_Added_Byte[SIGMA_SK_LENGTH] = byteToAdd; //Compute hmac - IppStatus ippstatus = ippsHMAC_Message(Sk_Wth_Added_Byte, - SIGMA_SK_LENGTH+1, (Ipp8u*)m_MK, SIGMA_MK_LENGTH, + IppStatus ippstatus = ippsHMAC_Message(Sk_Wth_Added_Byte, + SIGMA_SK_LENGTH+1, (Ipp8u*)m_MK, SIGMA_MK_LENGTH, (Ipp8u*)hmac, SIGMA_HMAC_LENGTH, IPP_ALG_HASH_SHA256); // defense-in-depth, clear secret data @@ -244,7 +245,7 @@ ae_error_t SigmaCryptoLayer::ComputePR(SIGMA_SECRET_KEY* oldSK, Ipp8u byteToAdd, } -ae_error_t SigmaCryptoLayer::ComputeId(Ipp8u byteToAdd, +ae_error_t SigmaCryptoLayer::ComputeId(Ipp8u byteToAdd, SHA256_HASH* hash) { memset(hash, 0, sizeof(*hash)); @@ -254,23 +255,23 @@ ae_error_t SigmaCryptoLayer::ComputeId(Ipp8u byteToAdd, p.Update(m_SK, sizeof(SIGMA_SIGN_KEY)); p.Update(m_MK, sizeof(SIGMA_MAC_KEY)); p.Update(&byteToAdd, sizeof(Ipp8u)); - + return p.Finalize(hash); } -ae_error_t SigmaCryptoLayer::MsgVerifyPch(Ipp8u* PubKeyPch, int PubKeyPchLen, - Ipp8u* EpidParamsCert, Ipp8u* Msg, int MsgLen, - Ipp8u* Bsn, int BsnLen, Ipp8u* Signature, +ae_error_t SigmaCryptoLayer::MsgVerifyPch(Ipp8u* PubKeyPch, int PubKeyPchLen, + Ipp8u* EpidParamsCert, Ipp8u* Msg, int MsgLen, + Ipp8u* Bsn, int BsnLen, Ipp8u* Signature, int SignatureLen, Ipp8u* PrivRevList, int PrivRL_Len, Ipp8u* SigRevList, int SigRL_Len, - Ipp8u* GrpRevList, int GrpRL_Len) + Ipp8u* GrpRevList, int GrpRL_Len) { ae_error_t status = AE_FAILURE; EpidStatus SafeIdRes = kEpidNoErr; Epid11Signature Epid11Sig; Epid11Signature *SigPointer = NULL; memset_s(&Epid11Sig, sizeof(Epid11Sig), 0, sizeof(Epid11Sig)); - + UNUSED(EpidParamsCert); UNUSED(Bsn); UNUSED(BsnLen); @@ -286,7 +287,7 @@ ae_error_t SigmaCryptoLayer::MsgVerifyPch(Ipp8u* PubKeyPch, int PubKeyPchLen, } // Verify the length of public key and signature buffers - if (((size_t)PubKeyPchLen < (SAFEID_CERT_LEN - ECDSA_SIGNATURE_LEN)) || + if (((size_t)PubKeyPchLen < (SAFEID_CERT_LEN - ECDSA_SIGNATURE_LEN)) || (SignatureLen < SAFEID_SIG_LEN)) { status = PSE_PR_PARAMETER_ERROR; @@ -323,17 +324,17 @@ ae_error_t SigmaCryptoLayer::MsgVerifyPch(Ipp8u* PubKeyPch, int PubKeyPchLen, //So we must use bigger buffer add 8 bytes to the length if(SignatureLen == sizeof(Epid11BasicSignature)){ memcpy(&Epid11Sig, Signature, SignatureLen); - SignatureLen += (2 * sizeof(OctStr32)); + SignatureLen = static_cast(SignatureLen + sizeof(Epid11Sig.rl_ver) + sizeof(Epid11Sig.n2)); SigPointer = &Epid11Sig; } else { SigPointer = (Epid11Signature *)Signature; } - - SafeIdRes = Epid11Verify(ctx, - SigPointer, SignatureLen, + + SafeIdRes = Epid11Verify(ctx, + SigPointer, SignatureLen, Msg, MsgLen); status = MapEpidResultToAEError(SafeIdRes); if (AE_FAILED(status)){ diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sign_csr.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sign_csr.cpp index 9fc8652c48..3946cdf20e 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sign_csr.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/sign_csr.cpp @@ -47,9 +47,9 @@ static uint8_t CertificateSigningRequestTemplate[] = { - /*0000h:*/ 0x30, 0x82, 0x01, 0xB9, + /*0000h:*/ 0x30, 0x82, 0x01, 0xB9, /* BEGIN -- Certificate Request Info (to be signed) */ - 0x30, 0x82, 0x01, 0x5E, + 0x30, 0x82, 0x01, 0x5E, 0x02, 0x01, 0x00, 0x30, 0x81, 0xB7, 0x31, 0x0B, /*0010h:*/ 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x0C, 0x02, 0x55, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, /*0020h:*/ 0x03, 0x55, 0x04, 0x08, 0x0C, 0x02, 0x43, 0x41, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, @@ -57,12 +57,12 @@ static uint8_t CertificateSigningRequestTemplate[] = /*0040h:*/ 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x11, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x20, 0x43, /*0050h:*/ 0x6F, 0x72, 0x70, 0x6F, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x37, 0x30, 0x35, 0x06, 0x03, /*0060h:*/ 0x55, 0x04, 0x0B, 0x0C, 0x2E, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x20, 0x50, 0x53, 0x45, 0x20, - /* BEGIN -- organizationalUnitName GUID */ + /* BEGIN -- organizationalUnitName GUID */ 0x65, /*0070h:*/ 0x66, 0x65, 0x66, 0x65, 0x66, 0x65, 0x66, 0x2D, 0x65, 0x66, 0x65, 0x66, 0x2D, 0x65, 0x66, 0x65, /*0080h:*/ 0x66, 0x2D, 0x65, 0x66, 0x65, 0x66, 0x2D, 0x65, 0x66, 0x65, 0x66, 0x65, 0x66, 0x65, 0x66, 0x65, /*0090h:*/ 0x66, 0x65, 0x66, - /* END -- organizationalUnitName GUID */ + /* END -- organizationalUnitName GUID */ 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0D, 0x77, 0x77, /*00A0h:*/ 0x77, 0x2E, 0x69, 0x6E, 0x74, 0x65, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x18, 0x30, 0x16, 0x06, /*00B0h:*/ 0x0A, 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x01, 0x0C, 0x08, 0x46, 0x46, 0x46, @@ -78,29 +78,29 @@ static uint8_t CertificateSigningRequestTemplate[] = /*0130h:*/ 0x35, 0x30, 0x33, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, /*0140h:*/ 0x02, 0x06, 0xC0, 0x30, 0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x02, 0x30, /*0150h:*/ 0x00, 0x30, 0x13, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF8, 0x4D, 0x01, 0x09, 0x02, 0x01, 0x01, - /*0160h:*/ 0xFF, 0x04, 0x03, 0x0A, 0x01, + /*0160h:*/ 0xFF, 0x04, 0x03, 0x0A, 0x01, #if !defined(PRODUCT_TYPE) #error PRODUCT_TYPE not #defined #endif - PRODUCT_TYPE, /* product ID */ + PRODUCT_TYPE, /* product ID */ /* END -- Certificate Request Info (to be signed) */ - + /* ecdsaWithSHA256 (1.2.840.10045.4.3.2) */ 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, /*0170h:*/ 0x03, 0x02, - + /* BEGIN -- Signature data (max 75 bytes) */ /* 0x03 || MM || 0x00 || 0x30 || NN || 0x02 || XX || sigX || 0x02 || YY || sigY */ - 0x03, 0x49, 0x00, - 0x30, 0x46, + 0x03, 0x49, 0x00, + 0x30, 0x46, /* Signature X ( 0x02 || XX || Sx (max 33bytes, See X.690 8.3 Encoding of an integer value) */ 0x02, 0x21, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, /*0180h:*/ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - /*0190h:*/ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + /*0190h:*/ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, /* Signature Y ( 0x02 || YY || Sy (max 33bytes, See X.690 8.3 Encoding of an integer value) */ - 0x02, 0x21, + 0x02, 0x21, 0x00, 0xaa, 0xaa, 0xaa, /*01A0h:*/ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, /*01B0h:*/ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa @@ -221,8 +221,8 @@ ae_error_t SignCSR::GetSignedTemplate( /*in */ EcDsaPrivKey* pPrivateKey, /*in */ EcDsaPubKey* pPublicKey, /*in */ sgx_ecc_state_handle_t csr_ecc_handle, - /*out*/ Ipp8u* pSignedTemplate, - /*i/o*/ uint16_t* pnBytes) + /*out*/ Ipp8u* pSignedTemplate, + /*i/o*/ uint16_t* pnBytes) { ae_error_t aeStatus = PSE_PR_INSUFFICIENT_MEMORY_ERROR; @@ -252,9 +252,9 @@ ae_error_t SignCSR::GetSignedTemplate( aeStatus = PSE_PR_INTERNAL_ERROR; break; } - if (SGX_SUCCESS == sgx_ecdsa_sign(&pSignedTemplate[nOffset_CSRInfo], nSize_CSRInfo, - (sgx_ec256_private_t *)pPrivateKey, - (sgx_ec256_signature_t *)SerializedSignature, + if (SGX_SUCCESS == sgx_ecdsa_sign(&pSignedTemplate[nOffset_CSRInfo], nSize_CSRInfo, + (sgx_ec256_private_t *)pPrivateKey, + (sgx_ec256_signature_t *)SerializedSignature, csr_ecc_handle)) { /* Convert the signature to big endian format */ @@ -281,7 +281,7 @@ ae_error_t SignCSR::GetSignedTemplate( SigBuffer[i++] = LEN_ECDSA_SIG_COMP + 1; SigBuffer[i++] = 0x00; memcpy(&SigBuffer[i], &SerializedSignature[offset], LEN_ECDSA_SIG_COMP); - i += LEN_ECDSA_SIG_COMP; + i = static_cast(i + LEN_ECDSA_SIG_COMP); } else { @@ -296,9 +296,9 @@ ae_error_t SignCSR::GetSignedTemplate( goto exit; } - SigBuffer[i++] = LEN_ECDSA_SIG_COMP - j; + SigBuffer[i++] = static_cast(LEN_ECDSA_SIG_COMP - j); memcpy(&SigBuffer[i], &SerializedSignature[offset + j], LEN_ECDSA_SIG_COMP - j); - i += LEN_ECDSA_SIG_COMP - j; + i = static_cast(i + LEN_ECDSA_SIG_COMP - j); } } @@ -328,15 +328,15 @@ exit: aeStatus = PSE_PR_SIGNING_CSR_ERROR; } #if 0 //for debugging to verify signature was generated correctly - else + else { uint8_t result; - // Convert the signature back to little endian, for verification API + // Convert the signature back to little endian, for verification API SwapEndian_32B(SerializedSignature); SwapEndian_32B(&(SerializedSignature[32])); - if ((SGX_SUCCESS != sgx_ecdsa_verify(&pSignedTemplate[nOffset_CSRInfo], nSize_CSRInfo, - (sgx_ec256_public_t *)pPublicKey, (sgx_ec256_signature_t *)SerializedSignature, + if ((SGX_SUCCESS != sgx_ecdsa_verify(&pSignedTemplate[nOffset_CSRInfo], nSize_CSRInfo, + (sgx_ec256_public_t *)pPublicKey, (sgx_ec256_signature_t *)SerializedSignature, &result, csr_ecc_handle)) || (result != SGX_EC_VALID )) { aeStatus = PSE_PR_SIGNING_CSR_ERROR; diff --git a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/t_long_term_pairing.cpp b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/t_long_term_pairing.cpp index ed00a662d8..e0e04e4852 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/t_long_term_pairing.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pse/pse_pr/t_long_term_pairing.cpp @@ -99,7 +99,7 @@ static ae_error_t map_VerifyM8_error_for_return(ae_error_t status) { case AE_SUCCESS: break; case PSE_PR_INSUFFICIENT_MEMORY_ERROR: break; - case PSE_PR_PCH_EPID_NO_MEMORY_ERR: + case PSE_PR_PCH_EPID_NO_MEMORY_ERR: status = PSE_PR_INSUFFICIENT_MEMORY_ERROR; break; case PSE_PR_PCH_EPID_SIG_REVOKED_IN_GROUPRL: break; @@ -110,7 +110,7 @@ static ae_error_t map_VerifyM8_error_for_return(ae_error_t status) #else switch (status) { - case PSE_PR_PCH_EPID_OUTOFMEMORY: + case PSE_PR_PCH_EPID_OUTOFMEMORY: status = PSE_PR_INSUFFICIENT_MEMORY_ERROR; break; } @@ -163,7 +163,7 @@ TEpidSigma11Verifier::~TEpidSigma11Verifier(void) bool TEpidSigma11Verifier::get_sigRL_info(const EPID11_SIG_RL* pSigRL, uint32_t& sigRL_entries, uint32_t& sigRL_size) { - if (NULL == pSigRL) + if (NULL == pSigRL) { // null sigRL is acceptable sigRL_entries = 0; @@ -171,7 +171,8 @@ bool TEpidSigma11Verifier::get_sigRL_info(const EPID11_SIG_RL* pSigRL, uint32_t& return true; } - uint32_t entries = *(uint32_t*)pSigRL->entries; + uint32_t entries = 0; + memcpy(&entries, pSigRL->entries, sizeof(entries)); entries = SwapEndian_DW(entries); if (entries > MAX_SIGRL_ENTRIES) // invalid sigRL return false; @@ -192,7 +193,8 @@ bool TEpidSigma11Verifier::get_privRL_info(const EPID11_PRIV_RL* pPrivRL, uint32 return true; } - uint32_t entries = *(uint32_t*)pPrivRL->entries; + uint32_t entries = 0; + memcpy(&entries, pPrivRL->entries, sizeof(entries)); entries = SwapEndian_DW(entries); if (entries > MAX_PRIVRL_ENTRIES) // invalid privRL return false; @@ -224,13 +226,13 @@ bool TEpidSigma11Verifier::get_privRL_info(const EPID11_PRIV_RL* pPrivRL, uint32 // |<-M6: OCSPResp-----------------------| // uCheckOCSPResponseForExpiration | | | // | | | -// tGenM7 (enclave call) Send S1, Receive S2 +// tGenM7 (enclave call) Send S1, Receive S2 // | | | // uExchangeS2AndS3WithME |--M7: SIGMA S2------>| | // |<-M8: SIGMA S3-------| | // uGetGroupIdFromME | | | // | | | -// tVerifyM8 (enclave call) Send S3, Receive updated pairing blob +// tVerifyM8 (enclave call) Send S3, Receive updated pairing blob // | | | // uSavePairingBlob | | | @@ -238,14 +240,14 @@ bool TEpidSigma11Verifier::get_privRL_info(const EPID11_PRIV_RL* pPrivRL, uint32 ae_error_t TEpidSigma11Verifier::GenM7 ( /*in */ const SIGMA_S1_MESSAGE* pS1, - /*in */ const EPID11_SIG_RL* pSigRL, - /*in */ const UINT8* pOcspResp, + /*in */ const EPID11_SIG_RL* pSigRL, + /*in */ const UINT8* pOcspResp, /*in */ UINT32 nLen_OcspResp, /*in */ const UINT8* pVerifierCert, /*in */ UINT32 nLen_VerifierCert, /*in */ const pairing_blob_t* pPairingBlob, /*in */ UINT32 nMax_S2, - /*out*/ SIGMA_S2_MESSAGE* pS2, + /*out*/ SIGMA_S2_MESSAGE* pS2, /*out*/ UINT32* pnLen_S2 ) { @@ -319,17 +321,17 @@ ae_error_t TEpidSigma11Verifier::GenM7 uint8_t Publickey_little_endian[SIGMA_SESSION_PUBKEY_LENGTH]; uint8_t Privatekey_b_little_endian[SIGMA_SESSION_PRIVKEY_LENGTH]; if (SGX_SUCCESS != sgx_ecc256_create_key_pair((sgx_ec256_private_t *)Privatekey_b_little_endian, - (sgx_ec256_public_t*)Publickey_little_endian, sigma_ecc_handle)) - { - break; + (sgx_ec256_public_t*)Publickey_little_endian, sigma_ecc_handle)) + { + break; } - m_sigmaAlg.set_prv_key_b_le(Privatekey_b_little_endian); + m_sigmaAlg.set_prv_key_b_le(Privatekey_b_little_endian); // clear buffer containing secrets memset_s(Privatekey_b_little_endian, sizeof(Privatekey_b_little_endian), 0, sizeof(Privatekey_b_little_endian)); /* Convert to big endian for m_localPublicKey_gb_big_endian */ SwapEndian_32B(&(Publickey_little_endian[0])); - SwapEndian_32B(&(Publickey_little_endian[32])); + SwapEndian_32B(&(Publickey_little_endian[32])); m_sigmaAlg.set_pub_key_gb_be(Publickey_little_endian); // OutputOctets("::GenM7:: g^a (BE)", m_remotePublicKey_ga_big_endian, SIGMA_SESSION_PUBKEY_LENGTH); @@ -342,7 +344,7 @@ ae_error_t TEpidSigma11Verifier::GenM7 // SMK := HMAC-SHA256(0x00, g^(ab) || 0x00) with the HMAC key being // 32 bytes of 0x00 and the data element being g^(ab) little endian // Derive SK and MK - // a) Compute HMAC-SHA256(0x00, g^(ab) || 0x01) + // a) Compute HMAC-SHA256(0x00, g^(ab) || 0x01) // with the HMAC key being 32 bytes of 0x00, g^(ab) in little endian // b) SK is taken as the first 128 bits of the HMAC result // c) MK is taken as the second 128 bits of the HMAC result @@ -381,7 +383,7 @@ ae_error_t TEpidSigma11Verifier::GenM7 //********************************************************************* memset(pS2, 0, nMax_S2); - // Copy Gb in big endian to S2 + // Copy Gb in big endian to S2 memcpy(pS2->Gb, m_sigmaAlg.get_pub_key_gb_be(), SIGMA_SESSION_PUBKEY_LENGTH); // Copy OCSP request sent in S1 @@ -390,7 +392,7 @@ ae_error_t TEpidSigma11Verifier::GenM7 // Basename is always set to 0 memset(pS2->Basename, 0, SIGMA_BASENAME_LENGTH); - // Location within pS2->Data where data gets added + // Location within pS2->Data where data gets added size_t index = 0; //********************************************************************* @@ -453,15 +455,15 @@ ae_error_t TEpidSigma11Verifier::GenM7 // Sig_pse(g^a || g^b) //********************************************************************* uint8_t combined_pubkeys[SIGMA_SESSION_PUBKEY_LENGTH * 2]; - uint8_t ecc_sig[ECDSA_SIG_LENGTH] = {0}; + uint8_t ecc_sig[ECDSA_SIG_LENGTH] = {0}; /* GaGb in big endian format */ memcpy(combined_pubkeys, m_sigmaAlg.get_remote_pub_key_ga_be(), SIGMA_SESSION_PUBKEY_LENGTH); memcpy(combined_pubkeys + SIGMA_SESSION_PUBKEY_LENGTH, m_sigmaAlg.get_pub_key_gb_be(), SIGMA_SESSION_PUBKEY_LENGTH); - if (SGX_SUCCESS == sgx_ecdsa_sign(combined_pubkeys, - sizeof(combined_pubkeys), - (sgx_ec256_private_t *)pairing_data.secret_data.VerifierPrivateKey, - (sgx_ec256_signature_t *)ecc_sig, + if (SGX_SUCCESS == sgx_ecdsa_sign(combined_pubkeys, + sizeof(combined_pubkeys), + (sgx_ec256_private_t *)pairing_data.secret_data.VerifierPrivateKey, + (sgx_ec256_signature_t *)ecc_sig, sigma_ecc_handle)) { /* Convert the signature to big endian format for pS2->SigGaGb */ @@ -504,13 +506,13 @@ ae_error_t TEpidSigma11Verifier::GenM7 } #define RL_OFFSET 4 -/* -This function will check if the S3 ICV is correct. -Then it will verify the EPID signature +/* +This function will check if the S3 ICV is correct. +Then it will verify the EPID signature */ ae_error_t TEpidSigma11Verifier::VerifyM8 ( - /*in */ const SIGMA_S3_MESSAGE* pS3, + /*in */ const SIGMA_S3_MESSAGE* pS3, /*in */ UINT32 nLen_S3, /*in */ const EPID11_PRIV_RL* pPrivRL, /*in, out*/ pairing_blob_t* pPairingBlob, @@ -650,8 +652,8 @@ ae_error_t TEpidSigma11Verifier::VerifyM8 uint8_t* pEpid11PrivRL = (pPrivRL == NULL)? NULL:(uint8_t*)pPrivRL+RL_OFFSET; uint32_t nEpid11PrivRLSize = (pPrivRL == NULL)? 0:privRL_size-RL_OFFSET-ECDSA_SIG_LENGTH; uint8_t* pEpid11SigRL = (m_pSigRL == NULL)? NULL:m_pSigRL+RL_OFFSET; - uint32_t nEpid11SigRLSize = (m_pSigRL == NULL)? 0:m_nSigRL-RL_OFFSET-ECDSA_SIG_LENGTH; - + uint32_t nEpid11SigRLSize = (m_pSigRL == NULL)? 0:static_cast(m_nSigRL-RL_OFFSET-ECDSA_SIG_LENGTH); + tmp_status = m_sigmaAlg.MsgVerifyPch((UINT8 *)&groupPubKey, (uint32_t)(sizeof(EpidCert) - ECDSA_SIG_LENGTH), NULL, // not required for EPID SDK 3.0 @@ -660,7 +662,7 @@ ae_error_t TEpidSigma11Verifier::VerifyM8 NULL, // Bsn 0, // BsnLen (UINT8 *)EpidSigVlr->EpidSig, - VLR_UNPADDED_PAYLOAD_SIZE(EpidSigVlr->VlrHeader), + static_cast(VLR_UNPADDED_PAYLOAD_SIZE(EpidSigVlr->VlrHeader)), pEpid11PrivRL, nEpid11PrivRLSize, // PrivRL pEpid11SigRL, nEpid11SigRLSize, // SigRL NULL, 0); // GroupRL @@ -710,9 +712,9 @@ ae_error_t TEpidSigma11Verifier::VerifyM8 memcpy(&m_pairingID, m_sigmaAlg.get_SK(), sizeof(m_pairingID)); sgx_status_t seStatus = sgx_read_rand((uint8_t*)&m_pairingNonce, sizeof(m_pairingNonce)); BREAK_IF_TRUE(SGX_SUCCESS != seStatus, status, PSE_PR_READ_RAND_ERROR); - // LTPBlob.pairingNonce = 0 is used to indicate invalid pairing Info in the LTP blob. - // Under the rare situation of a random number of 0 is returned for pairingNonce generation, - // PSE-Pr declares pairing or re-pairing attempt failure. The next pairing/re-pairing attempt + // LTPBlob.pairingNonce = 0 is used to indicate invalid pairing Info in the LTP blob. + // Under the rare situation of a random number of 0 is returned for pairingNonce generation, + // PSE-Pr declares pairing or re-pairing attempt failure. The next pairing/re-pairing attempt // most likely will generate a non-zero pairingNonce BREAK_IF_TRUE(memcmp(&m_pairingNonce, &zeroNonce, sizeof(Nonce128_t)) == 0, status, PSE_PR_READ_RAND_ERROR); // OutputOctets("VerifyM8 - new pairing", NULL, 0); @@ -724,7 +726,7 @@ ae_error_t TEpidSigma11Verifier::VerifyM8 //********************************************************************* // Update the unsealed pairing data - // [VerifierPrivateKey, id_pse || id_cse || sk || mk || + // [VerifierPrivateKey, id_pse || id_cse || sk || mk || // PairingNonce || SigRLVersion_cse || PrvRLVersion_cse || // DalAppletVersion] //********************************************************************* @@ -757,8 +759,8 @@ ae_error_t TEpidSigma11Verifier::VerifyM8 //NRG: // keep instance id - memcpy(pairing_data.plaintext.pse_instance_id, - pPairingBlob->plaintext.pse_instance_id, + memcpy(pairing_data.plaintext.pse_instance_id, + pPairingBlob->plaintext.pse_instance_id, sizeof(pairing_data.plaintext.pse_instance_id)); //********************************************************************* @@ -801,7 +803,7 @@ bool TEpidSigma11Verifier::TaskInfoIsValid( const ME_TASK_INFO& taskInfo) if (taskInfo.TaskId != JOM_TASK_ID) return false; /* Check the first 16 bytes of RsvdforApp matches the hardcoded PSDA Applet ID */ - if (memcmp(taskInfo.RsvdforApp, PSDA_APPLET_ID, DAL_APPLET_ID_LEN)) + if (memcmp(taskInfo.RsvdforApp, PSDA_APPLET_ID, DAL_APPLET_ID_LEN)) { return false; } @@ -809,7 +811,7 @@ bool TEpidSigma11Verifier::TaskInfoIsValid( const ME_TASK_INFO& taskInfo) /* retrieve the PSDA SVN */ memcpy(&m_nDalAppletVersion, (const_cast(taskInfo.RsvdforApp) + DAL_APPLET_ID_LEN), DAL_APPLET_SVN_LEN); - return true; + return true; } @@ -846,7 +848,7 @@ ae_error_t TEpidSigma11Verifier::ValidateS3DataBlock(const SIGMA_S3_MESSAGE* pS3 } -ae_error_t TEpidSigma11Verifier::AddCertificateChain(SIGMA_S2_MESSAGE* pS2, +ae_error_t TEpidSigma11Verifier::AddCertificateChain(SIGMA_S2_MESSAGE* pS2, size_t& index, size_t nMaxS2, const UINT8* pCertChain, size_t nCertChain) { ae_error_t status = PSE_PR_INTERNAL_ERROR; @@ -868,7 +870,7 @@ ae_error_t TEpidSigma11Verifier::AddCertificateChain(SIGMA_S2_MESSAGE* pS2, } -ae_error_t TEpidSigma11Verifier::AddRevocationList(SIGMA_S2_MESSAGE* pS2, +ae_error_t TEpidSigma11Verifier::AddRevocationList(SIGMA_S2_MESSAGE* pS2, size_t& index, size_t nMaxS2, const EPID11_SIG_RL* pRL, uint32_t nSigRL) { ae_error_t status = PSE_PR_INTERNAL_ERROR; @@ -885,10 +887,10 @@ ae_error_t TEpidSigma11Verifier::AddRevocationList(SIGMA_S2_MESSAGE* pS2, m_nSigRL = nSigRL; m_pSigRL = new (std::nothrow) UINT8[m_nSigRL]; - BREAK_IF_TRUE( (NULL == m_pSigRL), status, + BREAK_IF_TRUE( (NULL == m_pSigRL), status, PSE_PR_INSUFFICIENT_MEMORY_ERROR); - int nPaddedBytes = REQUIRED_PADDING_DWORD_ALIGNMENT(m_nSigRL); + int nPaddedBytes = static_cast(REQUIRED_PADDING_DWORD_ALIGNMENT(m_nSigRL)); memcpy(m_pSigRL, pRL , m_nSigRL); SIGNATURE_REV_LIST_VLR sigRL_VLR; @@ -905,6 +907,8 @@ ae_error_t TEpidSigma11Verifier::AddRevocationList(SIGMA_S2_MESSAGE* pS2, index += sizeof(SIGNATURE_REV_LIST_VLR); memcpy((pS2->Data + index), m_pSigRL, m_nSigRL); index += m_nSigRL; + // must skip nPaddedBytes for alignment + index += nPaddedBytes; } status = AE_SUCCESS; @@ -915,7 +919,7 @@ ae_error_t TEpidSigma11Verifier::AddRevocationList(SIGMA_S2_MESSAGE* pS2, } -ae_error_t TEpidSigma11Verifier::AddOcspResponses(SIGMA_S2_MESSAGE* pS2, +ae_error_t TEpidSigma11Verifier::AddOcspResponses(SIGMA_S2_MESSAGE* pS2, size_t& index, size_t nMaxS2, const UINT8* pOcspResp, size_t nOcspResp) { ae_error_t status = PSE_PR_INTERNAL_ERROR; @@ -928,7 +932,7 @@ ae_error_t TEpidSigma11Verifier::AddOcspResponses(SIGMA_S2_MESSAGE* pS2, break; } - BREAK_IF_TRUE( (0 == nOcspResp), status , + BREAK_IF_TRUE( (0 == nOcspResp), status , PSE_PR_NO_OCSP_RESPONSE_ERROR); if (nMaxS2 < ((pS2->Data - (uint8_t*)pS2) + index + nOcspResp)) @@ -949,7 +953,7 @@ ae_error_t TEpidSigma11Verifier::AddOcspResponses(SIGMA_S2_MESSAGE* pS2, ae_error_t TEpidSigma11Verifier::ValidateSigRL(const EPID11_SIG_RL* pSigRL, uint32_t sigRL_entries, uint32_t sigRL_size, uint32_t* pVersion) { sgx_ecc_state_handle_t ivk_ecc_handle = NULL; - uint8_t result; + uint8_t result; ae_error_t status = PSE_PR_MSG_COMPARE_ERROR; if (NULL == pVersion) diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/Makefile b/sgx-jvm/linux-sgx/psw/ae/pve/Makefile index e3eb9dcb67..c4d0365547 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/pve/Makefile @@ -33,33 +33,35 @@ TOP_DIR := ../../.. include ../buildenv.mk CXXFLAGS += -Werror -CFLAGS += -Werror +CFLAGS += -Werror AENAME = provision_enclave -LINUX_EPID := $(LINUX_EXTERNAL_DIR)/epid/ +EPID_SDK_DIR := $(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0/ INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ - -I$(SGX_IPP_INC)/ \ - -I$(LINUX_EXTERNAL_DIR)/epid \ - -I$(LINUX_SDK_DIR)/tseal \ - -I$(LINUX_PSW_DIR)/ae/common \ - -I$(LINUX_PSW_DIR)/ae/pve \ - -I$(LINUX_PSW_DIR)/ae/inc/internal + -I$(SGX_IPP_INC)/ \ + -I$(EPID_SDK_DIR) \ + -I$(LINUX_SDK_DIR)/tseal \ + -I$(LINUX_PSW_DIR)/ae/common \ + -I$(LINUX_PSW_DIR)/ae/pve \ + -I$(LINUX_PSW_DIR)/ae/inc/internal TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto -EPID_LIBDIR := $(LINUX_EPID) +EPID_LIBDIR := $(EPID_SDK_DIR) -EXTERNAL_LIB += -L$(EPID_LIBDIR) -lepid \ - -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto +EXTERNAL_LIB += -L$(EPID_LIBDIR)/epid/member -lmember \ + -L$(EPID_LIBDIR)/epid/common -lcommon \ + -L$(EPID_LIBDIR)/ext/ipp/sources/ippcpepid/src -lippcpepid \ + -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto SRC := $(wildcard *.cpp) SRC += ipp_bn.cpp \ - ipp_rsa_pub_key.cpp \ - se_ecdsa_verify_internal.cpp \ - pve_qe_common.cpp \ - pve_pub_key.cpp \ - pek_pub_key.cpp + ipp_rsa_pub_key.cpp \ + se_ecdsa_verify_internal.cpp \ + pve_qe_common.cpp \ + pve_pub_key.cpp \ + pek_pub_key.cpp OBJ := $(SRC:.cpp=.o) OBJS := $(sort $(OBJ) version.o) @@ -71,8 +73,9 @@ AENAME_OUT := $(AENAME).so all: $(SONAME) .PHONY: EPID -EPID: - $(MAKE) -C $(EPID_LIBDIR) +EPID: + cd $(EPID_SDK_DIR) && ./configure prefix=/usr/local + $(MAKE) -C $(EPID_SDK_DIR) 2> /dev/null $(SONAME): $(OBJS) EPID $(CXX) $(CXXFLAGS) -o $@ $(OBJS) -nostdlib -nodefaultlibs -nostartfiles $(LDTFLAGS) -fno-exceptions -fno-rtti $(EXTERNAL_LIB) @@ -92,6 +95,10 @@ clean: @$(RM) *.so @$(RM) *.map @$(RM) *_t.* +ifeq ("$(shell test -f $(EPID_SDK_DIR)/Makefile && echo Makefile exists)", "Makefile exists") + -$(MAKE) -C $(EPID_SDK_DIR) clean +endif + @$(RM) -r $(EPID_SDK_DIR)/Makefile $(EPID_SDK_DIR)/config.log $(EPID_SDK_DIR)/config.status .PHONY: rebuild rebuild: diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/config.xml b/sgx-jvm/linux-sgx/psw/ae/pve/config.xml index 24512b5736..08e38dac68 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/config.xml +++ b/sgx-jvm/linux-sgx/psw/ae/pve/config.xml @@ -3,10 +3,12 @@ 1 0 0x1 - 4 + 5 1 + 0 1 0x4000 0x14000 + 0x14000 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/helper.cpp b/sgx-jvm/linux-sgx/psw/ae/pve/helper.cpp index 535b1b2cdb..cf97a8aebc 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/helper.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pve/helper.cpp @@ -97,6 +97,7 @@ pve_status_t get_ppid(ppid_t* ppid) uint8_t content[16]; memset(&content, 0, sizeof(content)); + //generate the mac as PPID se_static_assert(sizeof(sgx_cmac_128bit_key_t) == sizeof(sgx_key_128bit_t)); /*size of sgx_cmac_128bit_key_t and sgx_key_128bit_t should be same*/ se_static_assert(sizeof(sgx_cmac_128bit_tag_t) == sizeof(ppid_t)); /*size of sgx_cmac_128bit_tag_t and ppit_t should be same*/ diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg.h b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg.h index 440974e6de..08c41f7e24 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg.h +++ b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg.h @@ -80,7 +80,7 @@ typedef enum _prov_stage_t /*macro definition for RSA-OAEP algorithm SHA-256 will be used for the hash generation*/ -#define PVE_RSAOAEP_ENCRYPT_MAXLEN (PVE_RSA_KEY_BYTES - 2*SHA_SIZE_BIT/8 - 2) /*190 bytes at most*/ +#define PVE_RSAOAEP_ENCRYPT_MAXLEN (RSA_3072_KEY_BYTES - 2*SHA_SIZE_BIT/8 - 2) /*190 bytes at most*/ #define SHA_SIZE_BIT 256 diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg1.cpp b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg1.cpp index 71768e08e1..5341c2ccc5 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg1.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg1.cpp @@ -70,8 +70,9 @@ pve_status_t gen_prov_msg1_data(const sgx_target_info_t& pce_target_info, sgx_report_data_t report_data = {0}; extended_epid_group_blob_t local_xegb; sgx_sha_state_handle_t sha_handle = NULL; - uint8_t crypto_suite = ALG_RSA_OAEP_2048; + uint8_t crypto_suite = ALG_RSA_OAEP_3072; + static_assert(sizeof(pek.n) == 384, "pek.n should be 384 bytes"); sgx_status = verify_xegb_with_default(xegb, &pek_result, local_xegb); if(SGX_SUCCESS != sgx_status){ ret = sgx_error_to_pve_error(sgx_status); diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg3.cpp b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg3.cpp index c1fdff2477..76dc3a94f8 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg3.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg3.cpp @@ -190,7 +190,7 @@ static pve_status_t gen_msg3_signature(const proc_prov_msg2_blob_input_t *msg2_b &temp1, //B and K in sigrl entry &temp3); //output one NrProof if(kEpidNoErr != epid_ret){ - if(kEpidSigRevokedinSigRl == epid_ret){ + if(kEpidSigRevokedInSigRl == epid_ret){ revoked = true;//if revoked, we could not return revoked status immediately until integrity checking passed }else{ ret = epid_error_to_pve_error(epid_ret); @@ -362,6 +362,7 @@ pve_status_t gen_prov_msg3_data(const proc_prov_msg2_blob_input_t *msg2_blob_inp uint32_t le_e; int i; uint8_t le_n[sizeof(pek.n)]; + static_assert(sizeof(pek.n)==384, "pek.n should be 384 bytes"); device_id_t *device_id_in_aad= (device_id_t *)(aad+sizeof(GroupId)); join_proof_with_escrow_t* join_proof_with_escrow=reinterpret_cast(temp_buf+JOIN_PROOF_TLV_HEADER_SIZE); se_static_assert(sizeof(join_proof_with_escrow_t)+JOIN_PROOF_TLV_HEADER_SIZE==JOIN_PROOF_TLV_TOTAL_SIZE); /*unmatched hardcoded size*/ diff --git a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg4.cpp b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg4.cpp index b6ad9d23a8..c020271387 100644 --- a/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg4.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/pve/provision_msg4.cpp @@ -227,8 +227,10 @@ pve_status_t proc_prov_msg4_data(const proc_prov_msg4_input_t *msg4_input, memcpy(&device_id_in_aad->psvn, &msg4_input->equivalent_psvn, sizeof(psvn_t)); memset(&device_id_in_aad->ppid, 0 ,sizeof(ppid_t)); + se_static_assert(sizeof(sgx_aes_gcm_128bit_key_t)==sizeof(pwk2)); /*SK_SIZE should be same as that of sgx_aes_gcm_128bit_key_t*/ se_static_assert(sizeof(sgx_aes_gcm_128bit_tag_t)==sizeof(msg4_input->member_credential_mac)); /*member_credential_mac size should be same as that of sgx_aes_gcm_128bit_tag_t*/ + se_static_assert(HARD_CODED_EPID_MEMBER_WITH_ESCROW_TLV_SIZE == MEMBERSHIP_CREDENTIAL_TLV_TOTAL_SIZE); /*hardcoded size should be matched*/ sgx_status = sgx_rijndael128GCM_decrypt(reinterpret_cast(&pwk2), diff --git a/sgx-jvm/linux-sgx/psw/ae/qe/Makefile b/sgx-jvm/linux-sgx/psw/ae/qe/Makefile index c6546962d3..0f7807fbed 100644 --- a/sgx-jvm/linux-sgx/psw/ae/qe/Makefile +++ b/sgx-jvm/linux-sgx/psw/ae/qe/Makefile @@ -33,21 +33,26 @@ TOP_DIR := ../../.. include ../buildenv.mk CXXFLAGS += -Werror -CFLAGS += -Werror -EXTERNAL_LIB += -L$(LINUX_EXTERNAL_DIR)/epid/ -lepid +CFLAGS += -Werror + +EPID_SDK_DIR = $(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0 +EXTERNAL_LIB += -L$(EPID_SDK_DIR)/epid/member -lmember \ + -L$(EPID_SDK_DIR)/epid/common -lcommon \ + -L$(EPID_SDK_DIR)/ext/ipp/sources/ippcpepid/src -lippcpepid + INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux \ - -I$(SGX_IPP_INC)/ \ - -I$(LINUX_EXTERNAL_DIR)/epid \ - -I$(LINUX_PSW_DIR)/ae/common \ - -I$(COMMON_DIR)/inc/tlibc \ - -I$(LINUX_PSW_DIR)/ae/inc/internal + -I$(SGX_IPP_INC)/ \ + -I$(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0 \ + -I$(LINUX_PSW_DIR)/ae/common \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(LINUX_PSW_DIR)/ae/inc/internal SRC := $(wildcard *.cpp) SRC += ipp_bn.cpp \ - ipp_rsa_pub_key.cpp \ - se_ecdsa_verify_internal.cpp \ - se_sig_rl.cpp \ - pve_qe_common.cpp + ipp_rsa_pub_key.cpp \ + se_ecdsa_verify_internal.cpp \ + se_sig_rl.cpp \ + pve_qe_common.cpp OBJ := $(SRC:.cpp=.o) OBJS := $(sort $(OBJ) version.o) @@ -55,8 +60,10 @@ OBJS := $(sort $(OBJ) version.o) .PHONY: all all: $(SONAME) +.PHONY: EPID EPID: - $(MAKE) -C $(LINUX_EXTERNAL_DIR)/epid/ + cd $(EPID_SDK_DIR) && ./configure prefix=/usr/local + $(MAKE) -C $(EPID_SDK_DIR) 2> /dev/null $(SONAME): $(OBJS) EPID $(CC) $(CFLAGS) -o $@ $(OBJS) -nostdlib -nodefaultlibs -nostartfiles $(LDTFLAGS) @@ -75,6 +82,10 @@ clean: @$(RM) *.so @$(RM) *.map @$(RM) *_t.* +ifeq ("$(shell test -f $(EPID_SDK_DIR)/Makefile && echo Makefile exists)", "Makefile exists") + -$(MAKE) -C $(EPID_SDK_DIR) clean +endif + @$(RM) -r $(EPID_SDK_DIR)/Makefile $(EPID_SDK_DIR)/config.log $(EPID_SDK_DIR)/config.status .PHONY: rebuild rebuild: diff --git a/sgx-jvm/linux-sgx/psw/ae/qe/config.xml b/sgx-jvm/linux-sgx/psw/ae/qe/config.xml index 23af1f1899..9a8083ec0a 100644 --- a/sgx-jvm/linux-sgx/psw/ae/qe/config.xml +++ b/sgx-jvm/linux-sgx/psw/ae/qe/config.xml @@ -3,11 +3,13 @@ 0 0 0x1 - 4 + 5 1 + 0 1 0 0x5000 0x10000 + 0x10000 1 diff --git a/sgx-jvm/linux-sgx/psw/ae/qe/quoting_enclave.cpp b/sgx-jvm/linux-sgx/psw/ae/qe/quoting_enclave.cpp index 6ee1b3d2ac..e780e056ce 100644 --- a/sgx-jvm/linux-sgx/psw/ae/qe/quoting_enclave.cpp +++ b/sgx-jvm/linux-sgx/psw/ae/qe/quoting_enclave.cpp @@ -690,7 +690,7 @@ static ae_error_t qe_epid_sign( &temp_nr); // The generated non-revoked proof if(kEpidNoErr != epid_ret) { - if(kEpidSigRevokedinSigRl == epid_ret) + if(kEpidSigRevokedInSigRl == epid_ret) match = TRUE; else { diff --git a/sgx-jvm/linux-sgx/psw/uae_service/linux/Makefile b/sgx-jvm/linux-sgx/psw/uae_service/linux/Makefile index 5bf0e5c898..17b11c2d19 100644 --- a/sgx-jvm/linux-sgx/psw/uae_service/linux/Makefile +++ b/sgx-jvm/linux-sgx/psw/uae_service/linux/Makefile @@ -51,25 +51,13 @@ INCLUDE += -I$(LINUX_PSW_DIR)/ae/common \ -I$(LINUX_PSW_DIR)/ae/inc/internal \ -I$(LINUX_SDK_DIR)/tseal -INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid \ +INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0 \ -I$(IPC_COMMON_INC_DIR) \ -I$(UAE_INC_DIR) \ -I$(IPC_COMMON_PROTO_DIR) \ -I$(LINUX_PSW_DIR)/ae/aesm_service/source CXXFLAGS += -fPIC -Werror -g -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -PROTPBUF_CXXFLAGS := -fstack-protector -fPIC -Wall -Werror -ifdef DEBUG - PROTPBUF_CXXFLAGS += -ggdb -DDEBUG -UNDEBUG -else - PROTPBUF_CXXFLAGS += -O2 -UDEBUG -DNDEBUG -endif -ifeq ($(ARCH), x86) - PROTPBUF_CXXFLAGS += -m32 -else - PROTPBUF_CXXFLAGS += -m64 -endif -PROTPBUF_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0 EXTERNAL_LIB += -lprotobuf @@ -125,7 +113,7 @@ SRC := AEServicesImpl.cpp \ OBJ := $(C_SRC:.c=.o) $(SRC:.cpp=.o) $(IPC_SRC:.cpp=.o) $(PROTOBUF_SRC:.cc=.o) -LDUFLAGS:= -pthread -L$(BUILD_DIR) +LDUFLAGS:= -pthread $(COMMON_LDFLAGS) LDUFLAGS += -Wl,--version-script=uae_service.lds -Wl,--gc-sections LIBNAME = libsgx_uae_service.so diff --git a/sgx-jvm/linux-sgx/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp b/sgx-jvm/linux-sgx/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp index 495b1508dd..960b230aff 100644 --- a/sgx-jvm/linux-sgx/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp +++ b/sgx-jvm/linux-sgx/psw/uae_service/uae_wrapper/src/tae_ocall_api.cpp @@ -52,7 +52,7 @@ try{ \ block; \ } \ - catch(std::bad_alloc& e) \ + catch(const std::bad_alloc& e) \ { \ *result = AESM_OUT_OF_MEMORY_ERROR; \ return UAE_OAL_SUCCESS; \ diff --git a/sgx-jvm/linux-sgx/psw/urts/create_param.h b/sgx-jvm/linux-sgx/psw/urts/create_param.h index 7a6848a805..2585855fc5 100644 --- a/sgx-jvm/linux-sgx/psw/urts/create_param.h +++ b/sgx-jvm/linux-sgx/psw/urts/create_param.h @@ -38,16 +38,22 @@ typedef struct _create_param_t { uint64_t enclave_size; uint64_t stack_max_size; + uint64_t stack_min_size; uint64_t stack_limit_addr; uint64_t stack_base_addr; + size_t ssa_base_addr; uint64_t heap_max_size; + uint64_t heap_min_size; + uint64_t heap_init_size; uint64_t heap_offset; uint64_t first_ssa_gpr; uint64_t td_addr; uint64_t tls_addr; + uint32_t tcs_num; uint32_t tcs_max_num; + uint32_t tcs_min_pool; uint32_t tcs_policy; - uint32_t ssa_frame_size; + uint32_t xsave_size; } create_param_t; #endif diff --git a/sgx-jvm/linux-sgx/psw/urts/enclave.cpp b/sgx-jvm/linux-sgx/psw/urts/enclave.cpp index a0f4558dde..3d5f8dd2d6 100644 --- a/sgx-jvm/linux-sgx/psw/urts/enclave.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/enclave.cpp @@ -38,12 +38,16 @@ #include "se_error_internal.h" #include "debugger_support.h" #include "se_memory.h" +#include "urts_trim.h" +#include "urts_emodpr.h" #include +#include "rts.h" + using namespace std; int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); -int do_ocall(const bridge_fn_t bridge, sgx_enclave_id_t enclave_id, void *ms); +int do_ocall(const bridge_fn_t bridge, void *ms); CEnclave::CEnclave(CLoader &ldr) : m_loader(ldr) @@ -56,13 +60,18 @@ CEnclave::CEnclave(CLoader &ldr) , m_thread_pool(NULL) , m_dbg_flag(false) , m_destroyed(false) + , m_version(0) + , m_ocall_table(NULL) + , m_pthread_is_valid(false) + , m_new_thread_event(NULL) { memset(&m_enclave_info, 0, sizeof(debug_enclave_info_t)); se_init_rwlock(&m_rwlock); } -sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy) +sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, + const uint32_t tcs_policy, const uint32_t enclave_version, const uint32_t tcs_min_pool) { uint32_t name_len = file.name_len; if (file.unicode) @@ -84,15 +93,24 @@ sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t m_enclave_id = enclave_id; m_start_addr = start_addr; m_size = enclave_size; + m_version = enclave_version; + + m_new_thread_event = se_event_init(); + if(m_new_thread_event == NULL) + { + free(m_enclave_info.lpFileName); + m_enclave_info.lpFileName = NULL; + return SGX_ERROR_OUT_OF_MEMORY; + } if(TCS_POLICY_BIND == tcs_policy) { - m_thread_pool = new CThreadPoolBindMode(); + m_thread_pool = new CThreadPoolBindMode(tcs_min_pool); } else if(TCS_POLICY_UNBIND == tcs_policy) { //we also set it as bind mode. - m_thread_pool = new CThreadPoolUnBindMode(); + m_thread_pool = new CThreadPoolUnBindMode(tcs_min_pool); } else { @@ -102,6 +120,7 @@ sgx_status_t CEnclave::initialize(const se_file_t& file, const sgx_enclave_id_t m_enclave_info.lpFileName = NULL; return SGX_ERROR_INVALID_PARAMETER; } + return SGX_SUCCESS; } @@ -113,8 +132,13 @@ CEnclave::~CEnclave() m_thread_pool = NULL; } + m_ocall_table = NULL; + destory_debug_info(&m_enclave_info); se_fini_rwlock(&m_rwlock); + + se_event_destroy(m_new_thread_event); + m_new_thread_event = NULL; } void * CEnclave::get_symbol_address(const char * const symbol) @@ -127,6 +151,24 @@ sgx_enclave_id_t CEnclave::get_enclave_id() return m_enclave_id; } +uint32_t CEnclave::get_enclave_version() +{ + return m_version; +} + +size_t CEnclave::get_dynamic_tcs_list_size() +{ + std::vector> tcs_list = m_loader.get_tcs_list(); + size_t count = 0; + for (size_t idx = 0; idx < tcs_list.size(); ++idx) + { + if(tcs_list[idx].second == true) + { + count++; + } + } + return count; +} sgx_status_t CEnclave::error_trts2urts(unsigned int trts_error) { @@ -157,25 +199,61 @@ sgx_status_t CEnclave::ecall(const int proc, const void *ocall_table, void *ms) } //do sgx_ecall - CTrustThread *trust_thread = get_tcs(); + CTrustThread *trust_thread = get_tcs(proc == ECMD_INIT_ENCLAVE); unsigned ret = SGX_ERROR_OUT_OF_TCS; + if(NULL != trust_thread) { - if(NULL != trust_thread) { - ret = do_ecall(proc, ocall_table, ms, trust_thread); - } - } - { - put_tcs(trust_thread); - - //release the read/write lock, the only exception is enclave already be removed in ocall - if(AbnormalTermination() || ret != SE_ERROR_READ_LOCK_FAIL) + if (NULL == m_ocall_table) { - se_rdunlock(&m_rwlock); + m_ocall_table = (sgx_ocall_table_t *)ocall_table; } + + if (proc == ECMD_UNINIT_ENCLAVE) + { + if(m_pthread_is_valid == true) + { + m_pthread_is_valid = false; + se_event_wake(m_new_thread_event); + pthread_join(m_pthread_tid, NULL); + } + ocall_table = m_ocall_table; + + std::vector threads = m_thread_pool->get_thread_list(); + for (unsigned idx = 0; idx < threads.size(); ++idx) + { + if (trust_thread->get_tcs() == threads[idx]->get_tcs()) + { + continue; + } + + uint64_t start = (uint64_t)(threads[idx]->get_tcs()); + uint64_t end = start + (1 << SE_PAGE_SHIFT); + + if (get_enclave_creator()->is_EDMM_supported(CEnclave::get_enclave_id())) + { + if (SGX_SUCCESS != (ret = get_enclave_creator()->trim_range(start, end))) + { + se_rdunlock(&m_rwlock); + return (sgx_status_t)ret; + } + } + } + } + + ret = do_ecall(proc, ocall_table, ms, trust_thread); + } + put_tcs(trust_thread); + + //release the read/write lock, the only exception is enclave already be removed in ocall + if(AbnormalTermination() || ret != SE_ERROR_READ_LOCK_FAIL) + { + se_rdunlock(&m_rwlock); } return error_trts2urts(ret); - } else { + } + else + { return SGX_ERROR_ENCLAVE_LOST; } } @@ -184,16 +262,29 @@ int CEnclave::ocall(const unsigned int proc, const sgx_ocall_table_t *ocall_tabl { int error = SGX_ERROR_UNEXPECTED; - //validate the proc is within ocall_table; - if(NULL == ocall_table - || proc >= ocall_table->count) + if ((int)proc == EDMM_TRIM || (int)proc == EDMM_TRIM_COMMIT || (int)proc == EDMM_MODPR) { - return SGX_ERROR_INVALID_FUNCTION; + se_rdunlock(&m_rwlock); + if((int)proc == EDMM_TRIM) + error = ocall_trim_range(ms); + else if ((int)proc == EDMM_TRIM_COMMIT) + error = ocall_trim_accept(ms); + else if ((int)proc == EDMM_MODPR) + error = ocall_emodpr(ms); } + else + { + //validate the proc is within ocall_table; + if(NULL == ocall_table || + (proc >= ocall_table->count)) + { + return SGX_ERROR_INVALID_FUNCTION; + } - se_rdunlock(&m_rwlock); - bridge_fn_t bridge = reinterpret_cast(ocall_table->ocall[proc]); - error = do_ocall(bridge, m_enclave_id, ms); + se_rdunlock(&m_rwlock); + bridge_fn_t bridge = reinterpret_cast(ocall_table->ocall[proc]); + error = do_ocall(bridge, ms); + } if (!se_try_rdlock(&m_rwlock)) { @@ -216,13 +307,79 @@ const debug_enclave_info_t* CEnclave::get_debug_info() } -CTrustThread * CEnclave::get_tcs() + +CTrustThread * CEnclave::get_tcs(bool is_initialize_ecall) { - CTrustThread *trust_thread = m_thread_pool->acquire_thread(); + CTrustThread *trust_thread = m_thread_pool->acquire_thread(is_initialize_ecall); return trust_thread; } +void *fill_tcs_mini_pool_func(void *args) +{ + CEnclave *it = (CEnclave*)(args); + if(it != NULL) + { + it->fill_tcs_mini_pool(); + } + return NULL; +} + +sgx_status_t CEnclave::fill_tcs_mini_pool_fn() +{ + pthread_t tid; + if(m_pthread_is_valid == false) + { + m_pthread_is_valid = true; + int ret = pthread_create(&tid, NULL, fill_tcs_mini_pool_func, (void *)(this)); + if(ret != 0) + { + m_pthread_is_valid = false; + return SGX_ERROR_UNEXPECTED; + } + m_pthread_tid = tid; + } + else if(m_pthread_is_valid == true) + { + if(se_event_wake(m_new_thread_event) != SE_MUTEX_SUCCESS) + { + return SGX_ERROR_UNEXPECTED; + } + } + + + return SGX_SUCCESS; +} + +sgx_status_t CEnclave::fill_tcs_mini_pool() +{ + do + { + if(se_try_rdlock(&m_rwlock)) + { + //Maybe the enclave has been destroyed after acquire/release m_rwlock. See CEnclave::destroy() + if(m_destroyed) + { + se_rdunlock(&m_rwlock); + return SGX_ERROR_ENCLAVE_LOST; + } + if(m_pthread_is_valid == false) + { + se_rdunlock(&m_rwlock); + return SGX_SUCCESS; + } + m_thread_pool->fill_tcs_mini_pool(); + se_rdunlock(&m_rwlock); + } + else + { + return SGX_ERROR_ENCLAVE_LOST; + } + }while(se_event_wait(m_new_thread_event) == SE_MUTEX_SUCCESS); + return SGX_ERROR_UNEXPECTED; + +} + void CEnclave::put_tcs(CTrustThread *trust_thread) { if(NULL == trust_thread) @@ -236,9 +393,6 @@ void CEnclave::put_tcs(CTrustThread *trust_thread) void CEnclave::destroy() { se_wtlock(&m_rwlock); - //send debug event to debugger when enclave is debug mode or release mode - debug_enclave_info_t *debug_info = const_cast(get_debug_info()); - generate_enclave_debug_event(URTS_EXCEPTION_PREREMOVEENCLAVE, debug_info); get_enclave_creator()->destroy_enclave(ENCLAVE_ID_IOCTL, m_size); @@ -251,12 +405,21 @@ void CEnclave::destroy() //m_loader.destroy_enclave(); } -void CEnclave::add_thread(tcs_t * const tcs) +void CEnclave::add_thread(tcs_t * const tcs, bool is_unallocated) +{ + CTrustThread *trust_thread = m_thread_pool->add_thread(tcs, this, is_unallocated); + if(!is_unallocated) + { + insert_debug_tcs_info_head(&m_enclave_info, trust_thread->get_debug_info()); + } +} + +void CEnclave::add_thread(CTrustThread * const trust_thread) { - CTrustThread *trust_thread = m_thread_pool->add_thread(tcs, this); insert_debug_tcs_info_head(&m_enclave_info, trust_thread->get_debug_info()); } + int CEnclave::set_extra_debug_info(secs_t& secs) { void *g_peak_heap_used_addr = get_symbol_address("g_peak_heap_used"); @@ -478,7 +641,7 @@ bool CEnclave::update_trust_thread_debug_flag(void* tcs_address, uint8_t debug_f if(debug_info->enclave_type == ET_DEBUG) { - + if(!se_write_process_mem(pid, reinterpret_cast(tcs_address) + sizeof(uint64_t), &debug_flag2, sizeof(uint64_t), NULL)) return FALSE; @@ -490,13 +653,13 @@ bool CEnclave::update_trust_thread_debug_flag(void* tcs_address, uint8_t debug_f bool CEnclave::update_debug_flag(uint8_t debug_flag) { debug_tcs_info_t* tcs_list_entry = m_enclave_info.tcs_list; - + while(tcs_list_entry) { if(!update_trust_thread_debug_flag(tcs_list_entry->TCS_address, debug_flag)) return FALSE; - tcs_list_entry = tcs_list_entry->next_tcs_info; + tcs_list_entry = tcs_list_entry->next_tcs_info; } return TRUE; diff --git a/sgx-jvm/linux-sgx/psw/urts/enclave.h b/sgx-jvm/linux-sgx/psw/urts/enclave.h index 187512c378..d3a3576bc9 100644 --- a/sgx-jvm/linux-sgx/psw/urts/enclave.h +++ b/sgx-jvm/linux-sgx/psw/urts/enclave.h @@ -53,6 +53,8 @@ public: void* get_start_address(){ return m_start_addr;}; void * get_symbol_address(const char * const symbol); sgx_enclave_id_t get_enclave_id(); + uint32_t get_enclave_version(); + size_t get_dynamic_tcs_list_size(); CTrustThreadPool * get_thread_pool() { return m_thread_pool; } uint64_t get_size() { return m_size; }; sgx_status_t ecall(const int proc, const void *ocall_table, void *ms); @@ -63,8 +65,9 @@ public: uint32_t get_ref() { return m_ref; } void mark_zombie() { m_zombie = true; } bool is_zombie() { return m_zombie; } - sgx_status_t initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy); - void add_thread(tcs_t * const tcs); + sgx_status_t initialize(const se_file_t& file, const sgx_enclave_id_t enclave_id, void * const start_addr, const uint64_t enclave_size, const uint32_t tcs_policy, const uint32_t enclave_version, const uint32_t tcs_min_pool); + void add_thread(tcs_t * const tcs, bool is_unallocated); + void add_thread(CTrustThread * const trust_thread); const debug_enclave_info_t* get_debug_info(); void set_dbg_flag(bool dbg_flag) { m_dbg_flag = dbg_flag; } bool get_dbg_flag() { return m_dbg_flag; } @@ -75,8 +78,10 @@ public: void pop_ocall_frame(CTrustThread *trust_thread); bool update_trust_thread_debug_flag(void*, uint8_t); bool update_debug_flag(uint8_t); + sgx_status_t fill_tcs_mini_pool(); + sgx_status_t fill_tcs_mini_pool_fn(); private: - CTrustThread * get_tcs(); + CTrustThread * get_tcs(bool is_initialize_ecall = false); void put_tcs(CTrustThread *trust_thread); sgx_status_t error_trts2urts(unsigned int trts_error); @@ -92,6 +97,11 @@ private: debug_enclave_info_t m_enclave_info; bool m_dbg_flag; bool m_destroyed; + uint32_t m_version; + sgx_ocall_table_t *m_ocall_table; + pthread_t m_pthread_tid; + bool m_pthread_is_valid; + se_handle_t m_new_thread_event; }; class CEnclavePool: private Uncopyable diff --git a/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw.h b/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw.h index 9fe871a39e..aa7987a611 100644 --- a/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw.h +++ b/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw.h @@ -55,11 +55,20 @@ public: int destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t enclave_size); int initialize(sgx_enclave_id_t enclave_id); bool use_se_hw() const; + bool is_EDMM_supported(sgx_enclave_id_t enclave_id); + bool is_cpu_edmm() const; + bool is_driver_compatible(); int get_misc_attr(sgx_misc_attribute_t *sgx_misc_attr, metadata_t *metadata, SGXLaunchToken * const lc, uint32_t flag); bool get_plat_cap(sgx_misc_attribute_t *se_attr); + int emodpr(uint64_t addr, uint64_t size, uint64_t flag); + int mktcs(uint64_t tcs_addr); + int trim_range(uint64_t fromaddr, uint64_t toaddr); + int trim_accept(uint64_t addr); + int remove_range(uint64_t fromaddr, uint64_t numpages); private: virtual bool open_se_device(); virtual void close_se_device(); + bool driver_support_edmm(); int try_init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *enclave_css, token_t *launch); int error_driver2urts(int driver_error); se_file_handle_t m_hdevice; diff --git a/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw_com.cpp b/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw_com.cpp index 31efec065f..1b1c12dba4 100644 --- a/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw_com.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/enclave_creator_hw_com.cpp @@ -40,6 +40,8 @@ #include "prd_css_util.h" #include "se_memcpy.h" +#define EDMM_ENABLE_BIT 0x1ULL + bool EnclaveCreatorHW::use_se_hw() const { return true; @@ -47,7 +49,8 @@ bool EnclaveCreatorHW::use_se_hw() const int EnclaveCreatorHW::initialize(sgx_enclave_id_t enclave_id) { - cpu_sdk_info_t info; + system_features_t info; + info.system_feature_set[0] = (uint64_t)1 << SYS_FEATURE_MSb; CEnclave *enclave= CEnclavePool::instance()->get_enclave(enclave_id); @@ -57,7 +60,10 @@ int EnclaveCreatorHW::initialize(sgx_enclave_id_t enclave_id) //Since CPUID instruction is NOT supported within enclave, we enumerate the cpu features here and send to tRTS. info.cpu_features = 0; get_cpu_features(&info.cpu_features); - info.version = SDK_VERSION_1_5; + info.version = (sdk_version_t)MIN((uint32_t)SDK_VERSION_2_0, enclave->get_enclave_version()); + if (is_EDMM_supported(enclave_id)) + info.system_feature_set[0] |= EDMM_ENABLE_BIT; + int status = enclave->ecall(ECMD_INIT_ENCLAVE, NULL, reinterpret_cast(&info)); //free the tcs used by initialization; diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/Makefile b/sgx-jvm/linux-sgx/psw/urts/linux/Makefile index de33b87b28..fc9d5fbb31 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/Makefile +++ b/sgx-jvm/linux-sgx/psw/urts/linux/Makefile @@ -54,8 +54,7 @@ INC += -I$(COMMON_DIR)/inc \ -I$(VTUNE_DIR)/sdk/src/ittnotify LDFLAGS := -lwrapper -LDFLAGS += -Wl,-Bdynamic -lsgx_uae_service - +LDFLAGS += $(COMMON_LDFLAGS) -Wl,-Bdynamic -lsgx_uae_service LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify -littnotify -ldl LDFLAGS += -Wl,--version-script=urts.lds -Wl,--gc-sections @@ -63,6 +62,7 @@ DIR1 := $(LINUX_PSW_DIR)/urts/linux DIR2 := $(LINUX_PSW_DIR)/urts DIR3 := $(LINUX_PSW_DIR)/urts/parser DIR4 := $(LINUX_PSW_DIR)/urts/parser/linux +DIR5 := $(LINUX_PSW_DIR)/../common/src/linux LIB += -L$(COMMON_DIR)/se_wrapper \ -L$(BUILD_DIR) @@ -87,9 +87,12 @@ OBJ2 := urts.o \ sig_handler.o \ debugger_support.o \ get_thread_id.o \ - prd_css_util.o + prd_css_util.o \ + urts_emodpr.o \ + urts_trim.o -OBJ3 := enter_enclave.o +OBJ3 := enter_enclave.o \ + xsave_gnu.o OBJ4 := section.o \ elfparser.o @@ -102,6 +105,7 @@ INTERNAL_OBJ := $(OBJ3) $(CPP_OBJ) vpath %.cpp $(DIR1):$(DIR2):$(DIR3):$(DIR4) +vpath %.S $(DIR1):$(DIR5) LIBWRAPPER := libwrapper.a LIBURTS := libsgx_urts.so diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/enclave_creator_hw.cpp b/sgx-jvm/linux-sgx/psw/urts/linux/enclave_creator_hw.cpp index 86366eedce..e9e9bc6696 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/enclave_creator_hw.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/linux/enclave_creator_hw.cpp @@ -29,7 +29,8 @@ * */ - + +#include "enclave.h" #include "enclave_creator_hw.h" #include "se_trace.h" #include "se_page_attr.h" @@ -40,6 +41,7 @@ #include "se_atomic.h" #include "se_detect.h" #include "cpuid.h" +#include "rts.h" #include #include #include @@ -48,7 +50,8 @@ #include #include #include - + +#define SGX_CPUID 0x12 static EnclaveCreatorHW g_enclave_creator_hw; @@ -74,81 +77,68 @@ int EnclaveCreatorHW::error_driver2urts(int driver_error) switch(driver_error) { -#if 0 - case SGX_ERROR: - if(ENOMEM == errno) - ret = SGX_ERROR_OUT_OF_MEMORY; - else - ret = SGX_ERROR_NO_DEVICE; - break; -#endif - case SGX_INVALID_ATTRIBUTE: - ret = SGX_ERROR_INVALID_ATTRIBUTE; - break; - case SGX_INVALID_MEASUREMENT: - ret = SE_ERROR_INVALID_MEASUREMENT; - break; - case SGX_INVALID_SIG_STRUCT: - case SGX_INVALID_SIGNATURE: - ret = SGX_ERROR_INVALID_SIGNATURE; - break; - case SGX_INVALID_CPUSVN: - ret = SGX_ERROR_INVALID_CPUSVN; - break; - case SGX_INVALID_ISVSVN: - ret = SGX_ERROR_INVALID_ISVSVN; - break; - case SGX_UNMASKED_EVENT: - ret = SGX_ERROR_DEVICE_BUSY; - break; - case (int)SGX_POWER_LOST_ENCLAVE: // [-Wc++11-narrowing] - ret = SGX_ERROR_ENCLAVE_LOST; - break; - default: - SE_TRACE(SE_TRACE_WARNING, "unexpected error %#x from driver, should be uRTS/driver bug\n", driver_error); - ret = SGX_ERROR_UNEXPECTED; - break; - } - - return ret; -} - + case SGX_INVALID_ATTRIBUTE: + ret = SGX_ERROR_INVALID_ATTRIBUTE; + break; + case SGX_INVALID_MEASUREMENT: + ret = SE_ERROR_INVALID_MEASUREMENT; + break; + case SGX_INVALID_SIG_STRUCT: + case SGX_INVALID_SIGNATURE: + ret = SGX_ERROR_INVALID_SIGNATURE; + break; + case SGX_INVALID_LICENSE: + ret = SE_ERROR_INVALID_LAUNCH_TOKEN; + break; + case SGX_INVALID_CPUSVN: + ret = SGX_ERROR_INVALID_CPUSVN; + break; + case SGX_INVALID_ISVSVN: + ret = SGX_ERROR_INVALID_ISVSVN; + break; + case SGX_UNMASKED_EVENT: + ret = SGX_ERROR_DEVICE_BUSY; + break; + case (int)SGX_POWER_LOST_ENCLAVE: // [-Wc++11-narrowing] + ret = SGX_ERROR_ENCLAVE_LOST; + break; + default: + SE_TRACE(SE_TRACE_WARNING, "unexpected error %#x from driver, should be uRTS/driver bug\n", driver_error); + ret = SGX_ERROR_UNEXPECTED; + break; + } + + return ret; + } + int EnclaveCreatorHW::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) { assert(secs != NULL && enclave_id != NULL && start_addr != NULL); UNUSED(ae); - int ret = 0; if (false == open_se_device()) return SGX_ERROR_NO_DEVICE; SE_TRACE(SE_TRACE_DEBUG, "\n secs.attibutes.flags = %llx, secs.attributes.xfrm = %llx \n" - , secs->attributes.flags, secs->attributes.xfrm); + , secs->attributes.flags, secs->attributes.xfrm); //SECS:BASEADDR must be naturally aligned on an SECS.SIZE boundary - //This alignment is guaranteed by driver, at linux-sgx-driver/sgx_main.c:141 to 146 - //141 addr = current->mm->get_unmapped_area(file, addr, 2 * len, pgoff, - //142 flags); - //143 if (IS_ERR_VALUE(addr)) - //144 return addr; - //145 - //146 addr = (addr + (len - 1)) & ~(len - 1); - //147 - //148 return addr; - //Thus the only thing to do is to let the kernel driver align the memory. - void* enclave_base = mmap(NULL, (size_t)secs->size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_SHARED, m_hdevice, 0); + //This alignment is guaranteed by driver + void* enclave_base = mmap(NULL, (size_t)secs->size, PROT_NONE, MAP_SHARED, m_hdevice, 0); if(enclave_base == MAP_FAILED) { - SE_TRACE(SE_TRACE_WARNING, "\nISGX_IOCTL_ENCLAVE_CREATE failed: mmap failed, errno = %d\n", errno); + SE_TRACE(SE_TRACE_WARNING, "\ncreate enclave: mmap failed, errno = %d\n", errno); return SGX_ERROR_OUT_OF_MEMORY; } - secs->base = (void*)enclave_base; - + + secs->base = enclave_base; + struct sgx_enclave_create param = {0}; - param.src = (uintptr_t)(secs); - ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_CREATE, ¶m); - if(ret) { - SE_TRACE(SE_TRACE_WARNING, "\nISGX_IOCTL_ENCLAVE_CREATE failed: errno = %d\n", errno); + param.src = reinterpret_cast<__u64>(secs); + int ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_CREATE, ¶m); + if(ret) + { + SE_TRACE(SE_TRACE_WARNING, "\nSGX_IOC_ENCLAVE_CREATE failed: errno = %d\n", errno); return error_driver2urts(ret); } *enclave_id = se_atomic_inc64(&g_eid); @@ -156,8 +146,7 @@ int EnclaveCreatorHW::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, return SGX_SUCCESS; } - - + int EnclaveCreatorHW::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, uint64_t rva, const sec_info_t &sinfo, uint32_t attr) { assert((rva & ((1<(source); - addp.secinfo = reinterpret_cast(const_cast(&sinfo)); + addp.addr = enclave_id + rva; + addp.src = reinterpret_cast<__u64>(source); + addp.secinfo = reinterpret_cast<__u64>(const_cast(&sinfo)); if(((1<(enclave_css); - //launch should NOT be NULL, because it has been checked in urts_com.h::_create_enclave(...) + initp.addr = enclave_id; + initp.sigstruct = reinterpret_cast<__u64>(enclave_css); + //license should NOT be NULL, because it has been checked in urts_com.h::_create_enclave(...) assert(launch != NULL); - initp.einittoken = reinterpret_cast(launch); + initp.einittoken = reinterpret_cast<__u64>(launch); ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_INIT, &initp); if (ret) { - SE_TRACE(SE_TRACE_WARNING, "\nISGX_IOCTL_ENCLAVE_INIT failed error = %d\n", ret); + SE_TRACE(SE_TRACE_WARNING, "\nSGX_IOC_ENCLAVE_INIT failed error = %d\n", ret); return error_driver2urts(ret); } @@ -214,11 +202,10 @@ int EnclaveCreatorHW::try_init_enclave(sgx_enclave_id_t enclave_id, enclave_css_ return SGX_SUCCESS; } - -//for linux hw mode, enclave_id is actually start address here + int EnclaveCreatorHW::destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t enclave_size) { - int ret = 0; + int ret = SGX_SUCCESS; ret = munmap((void*)enclave_id, (size_t)enclave_size); @@ -226,21 +213,16 @@ int EnclaveCreatorHW::destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t encl SE_TRACE(SE_TRACE_WARNING, "destroy SGX enclave failed, error = %d\n", errno); ret = SGX_ERROR_UNEXPECTED; } - else - { - ret = SGX_SUCCESS; - } return ret; } - + bool EnclaveCreatorHW::get_plat_cap(sgx_misc_attribute_t *misc_attr) { + // need to update code to support HyperV ECO return get_plat_cap_by_cpuid(misc_attr); } - - - + bool EnclaveCreatorHW::open_se_device() { LockGuard lock(&m_dev_mutex); @@ -256,11 +238,12 @@ bool EnclaveCreatorHW::open_se_device() SE_TRACE(SE_TRACE_WARNING, "open isgx device failed\n"); return false; } + m_hdevice = fd; return true; } - + void EnclaveCreatorHW::close_se_device() { LockGuard lock(&m_dev_mutex); @@ -271,3 +254,165 @@ void EnclaveCreatorHW::close_se_device() m_hdevice = -1; } } + +int EnclaveCreatorHW::emodpr(uint64_t addr, uint64_t size, uint64_t flag) +{ + sgx_modification_param params; + memset(¶ms, 0 ,sizeof(sgx_modification_param)); + params.range.start_addr = (unsigned long)addr; + params.range.nr_pages = (unsigned int)(size/SE_PAGE_SIZE); + params.flags = (unsigned long)flag; + + int ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_EMODPR, ¶ms); + if (ret) + { + SE_TRACE(SE_TRACE_ERROR, "SGX_IOC_ENCLAVE_EMODPR failed %d\n", errno); + return error_driver2urts(ret); + } + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::mktcs(uint64_t tcs_addr) +{ + sgx_range params; + memset(¶ms, 0 ,sizeof(sgx_range)); + params.start_addr = (unsigned long)tcs_addr; + params.nr_pages = 1; + + int ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_MKTCS, ¶ms); + if (ret) + { + SE_TRACE(SE_TRACE_ERROR, "MODIFY_TYPE failed %d\n", errno); + return error_driver2urts(ret); + } + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::trim_range(uint64_t fromaddr, uint64_t toaddr) +{ + sgx_range params; + memset(¶ms, 0 ,sizeof(sgx_range)); + params.start_addr = (unsigned long)fromaddr; + params.nr_pages = (unsigned int)((toaddr - fromaddr)/SE_PAGE_SIZE); + + int ret= ioctl(m_hdevice, SGX_IOC_ENCLAVE_TRIM, ¶ms); + if (ret) + { + SE_TRACE(SE_TRACE_ERROR, "SGX_IOC_ENCLAVE_TRIM failed %d\n", errno); + return error_driver2urts(ret); + } + + return SGX_SUCCESS; + +} + +int EnclaveCreatorHW::trim_accept(uint64_t addr) +{ + sgx_range params; + memset(¶ms, 0 ,sizeof(sgx_range)); + params.start_addr = (unsigned long)addr; + params.nr_pages = 1; + + int ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_NOTIFY_ACCEPT, ¶ms); + + + if (ret) + { + SE_TRACE(SE_TRACE_ERROR, "TRIM_RANGE_COMMIT failed %d\n", errno); + return error_driver2urts(ret); + } + + return SGX_SUCCESS; +} + +int EnclaveCreatorHW::remove_range(uint64_t fromaddr, uint64_t numpages) +{ + int ret = -1; + uint64_t i; + unsigned long start; + + for (i = 0; i < numpages; i++) + { + start = (unsigned long)fromaddr + (unsigned long)(i << SE_PAGE_SHIFT); + ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_PAGE_REMOVE, &start); + if (ret) + { + SE_TRACE(SE_TRACE_ERROR, "PAGE_REMOVE failed %d\n", errno); + return error_driver2urts(ret); + } + } + + return SGX_SUCCESS; +} + +//EDMM is supported if and only if all of the following requirements are met: +//1. We operate in HW mode +//2. CPU has EDMM support +//3. Driver has EDMM support +//4. Both the uRTS version and enclave (metadata) version are higher than 1.5 +bool EnclaveCreatorHW::is_EDMM_supported(sgx_enclave_id_t enclave_id) +{ + bool supported = false, driver_supported = false, cpu_edmm = false; + + CEnclave *enclave = CEnclavePool::instance()->get_enclave(enclave_id); + if (enclave == NULL) + return false; + + cpu_edmm = is_cpu_edmm(); + driver_supported = is_driver_compatible(); + + //return value of get_enclave_version() considers the version of uRTS and enclave metadata + supported = use_se_hw() && cpu_edmm && driver_supported && (enclave->get_enclave_version() >= SDK_VERSION_2_0); + + return supported; +} + +bool EnclaveCreatorHW::is_cpu_edmm() const +{ + bool cpu_edmm = false; + int a[4] = {0,0,0,0}; + + //Check CPU EDMM capability by CPUID + __cpuid(a, 0); + if (a[0] < SGX_CPUID) + return false; + + __cpuidex(a, SGX_CPUID, 0); + if (!(a[0] & 1)) + return false; + + cpu_edmm = (a[0] & 2) != 0; + return cpu_edmm; +} + +bool EnclaveCreatorHW::is_driver_compatible() +{ + static bool ret = driver_support_edmm(); + return ret; +} + +bool EnclaveCreatorHW::driver_support_edmm() +{ + int ret; + sgx_modification_param p; + p.flags = 0; + p.range.start_addr = 0; + p.range.nr_pages = 0; + + if (false == open_se_device()) + { + return false; + } + + ret = ioctl(m_hdevice, SGX_IOC_ENCLAVE_EMODPR, &p); + if ((ret == -1) && (errno == ENOTTY)) + { + return false; + } + else + { + return true; + } +} diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.S b/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.S index a9f838cdf9..5ad1fb7d3c 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.S +++ b/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.S @@ -35,10 +35,27 @@ /* int __morestack(const tcs_t *tcs, const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); */ .file "enter_enclave.S" +.data +g_xsave_size: .long 0 +g_clean_ymm: .long 0 .text +DECLARE_GLOBAL_FUNC set_xsave_info +#if defined(LINUX32) + mov SE_WORDSIZE*1(%esp), %ecx + mov SE_WORDSIZE*2(%esp), %edx +#else + mov %rdi, %rcx + mov %rsi, %rdx +#endif + lea_symbol g_xsave_size, %xax + movl %ecx, (%xax) + lea_symbol g_clean_ymm, %xax + movl %edx, (%xax) + ret + DECLARE_GLOBAL_FUNC __morestack -__morestack: +//__morestack: EENTER_PROLOG movl frame_arg1, %edi /* fn */ #if defined(__x86_64__) @@ -48,6 +65,13 @@ EENTER_PROLOG mov frame_arg3, %xsi /* ms */ .Ldo_eenter: + # clean the upper bits of YMM registers + lea_symbol g_clean_ymm, %xbx + movl (%xbx), %ecx + cmpl $0, %ecx + je 1f + vzeroupper +1: mov frame_arg0, %xbx /* tcs addr */ lea_pic .Lasync_exit_pointer, %xcx /* aep addr */ mov $SE_EENTER, %xax /* EENTER leaf */ @@ -95,15 +119,16 @@ EENTER_PROLOG #endif call stack_sticker - cmp $SE_ERROR_READ_LOCK_FAIL, %eax + xor %xsi, %xsi + mov %eax, %esi + cmp $SE_ERROR_READ_LOCK_FAIL, %esi je .Loret mov $ECMD_ORET, %xdi /* oret */ - mov %xax, %xsi /* the result of ocall */ jmp .Ldo_eenter /* never return here */ ud2 .Leret: - mov %xsi, %xax + .Loret: EENTER_EPILOG diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.h b/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.h index 18c706fc6c..d82a32354e 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.h +++ b/sgx-jvm/linux-sgx/psw/urts/linux/enter_enclave.h @@ -41,6 +41,15 @@ #include "linux-regs.h" #include "rts_cmd.h" + +.macro lea_symbol symbol, reg +#ifdef __x86_64__ +mov \symbol@GOTPCREL(%rip), \reg +#else +lea \symbol, \reg +#endif +.endm + /* macro for enter_enclave * There is no .cfi_xxx to describe unwind information, because we want c++ exception can't across enclave boundary */ @@ -48,66 +57,72 @@ push %xbp mov %xsp, %xbp -#if defined(__i386__) -push %ebx -push %esi -push %edi - -/* These 3 wordsize buffer are used for paddings, so that the - * stack-boundary can be kept 16-byte aligned. - * - * Note that, by default GCC assumes - * -mpreferred-stack-boundary=4 - * which results to 16 (2^4) byte alignment of stack boundary. - * - * | parameters | <- previous frame - * ==+================+====== - * | return address | ^ - * +----------------+ | - * | ebp | | - * +----------------+ 16 bytes <- current frame - * | ebx | | - * +----------------+ | - * | esi | v - * +----------------+ ---- - * | edi | 4 bytes - * +----------------+ - * | paddings | 3*4 bytes - * ==+================+====== - * | ENCLU | - */ -sub $(3 * SE_WORDSIZE), %esp - -#elif defined(__x86_64__) -push %rbx -push %r12 -push %r13 -push %r14 -push %r15 -/*save 5 parameter*/ -push %r8 -push %rcx -push %rdx -push %rsi -push %rdi -#else -# error unknown platform +/* save GPRs */ +#ifdef __i386__ +sub $(4 * SE_WORDSIZE), %xsp /* for xsave, xbx, xdi, xsi */ +mov %xbx, -2 * SE_WORDSIZE(%xbp) +mov %xsi, -3 * SE_WORDSIZE(%xbp) +mov %xdi, -4 * SE_WORDSIZE(%xbp) +#else /* __x86_64__ */ +sub $(12 * SE_WORDSIZE), %xsp /* for xsave, params, and non-volatile GPRs */ +mov %xdi, -10 * SE_WORDSIZE(%xbp) +mov %xsi, -9 * SE_WORDSIZE(%xbp) +mov %rdx, -8 * SE_WORDSIZE(%xbp) +mov %rcx, -7 * SE_WORDSIZE(%xbp) +mov %r8, -6 * SE_WORDSIZE(%xbp) +mov %xbx, -11 * SE_WORDSIZE(%xbp) +mov %r12, -5 * SE_WORDSIZE(%xbp) +mov %r13, -4 * SE_WORDSIZE(%xbp) +mov %r14, -3 * SE_WORDSIZE(%xbp) +mov %r15, -2 * SE_WORDSIZE(%xbp) #endif + +lea_symbol g_xsave_size, %xdi +xor %xax, %xax +movl (%xdi), %eax +sub %xax, %xsp +mov %xax, %xcx /* xsave size */ +mov $0x3f, %xax +not %xax +and %xax, %xsp /* xsave requires 64 byte aligned */ +mov %xsp, -1 * SE_WORDSIZE(%xbp) /* xsave pointer */ + +/* shadow space for arguments */ +sub $(4 * SE_WORDSIZE), %xsp + +/* save extended xfeature registers */ +shr $2, %xcx +xor %xax, %xax +mov -1 * SE_WORDSIZE(%xbp), %xdi +cld +rep stos %eax, %es:(%xdi) + +mov -1 * SE_WORDSIZE(%xbp), %xdi +mov %xdi, (%xsp) +call save_xregs .endm .macro EENTER_EPILOG -#if defined(__i386__) -mov -SE_WORDSIZE*1(%ebp), %ebx -mov -SE_WORDSIZE*2(%ebp), %esi -mov -SE_WORDSIZE*3(%ebp), %edi -#elif defined(__x86_64__) -mov -SE_WORDSIZE*1(%rbp), %rbx -mov -SE_WORDSIZE*2(%rbp), %r12 -mov -SE_WORDSIZE*3(%rbp), %r13 -mov -SE_WORDSIZE*4(%rbp), %r14 -mov -SE_WORDSIZE*5(%rbp), %r15 +/* restore extended xfeature registers */ +mov -SE_WORDSIZE*1(%xbp), %xdi +mov %xdi, (%xsp) +call restore_xregs +mov %xsi, %xax + +/* restore GPRs */ +#ifdef __i386__ +mov -SE_WORDSIZE*2(%xbp), %xbx +mov -SE_WORDSIZE*3(%xbp), %xsi +mov -SE_WORDSIZE*4(%xbp), %xdi #else -# error unknown platform +mov -SE_WORDSIZE*11(%xbp), %xbx +mov -SE_WORDSIZE*10(%xbp), %xdi +mov -SE_WORDSIZE*9(%xbp), %xsi +mov -SE_WORDSIZE*5(%rbp), %r12 +mov -SE_WORDSIZE*4(%rbp), %r13 +mov -SE_WORDSIZE*3(%rbp), %r14 +mov -SE_WORDSIZE*2(%rbp), %r15 + #endif /* don't need recover rdi, rsi, rdx, rcx */ mov %xbp, %xsp diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/isgx_user.h b/sgx-jvm/linux-sgx/psw/urts/linux/isgx_user.h index 280c116996..3524188aaa 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/isgx_user.h +++ b/sgx-jvm/linux-sgx/psw/urts/linux/isgx_user.h @@ -28,66 +28,118 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + #ifndef _UAPI_ASM_X86_SGX_H #define _UAPI_ASM_X86_SGX_H - + #include #include - -#define SGX_MAGIC 0xA4 - -#define SGX_IOC_ENCLAVE_CREATE \ - _IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create) -#define SGX_IOC_ENCLAVE_ADD_PAGE \ - _IOW(SGX_MAGIC, 0x01, struct sgx_enclave_add_page) -#define SGX_IOC_ENCLAVE_INIT \ - _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init) - - /* SGX leaf instruction return values */ -#define SGX_SUCCESS 0 -#define SGX_INVALID_SIG_STRUCT 1 -#define SGX_INVALID_ATTRIBUTE 2 -#define SGX_BLKSTATE 3 -#define SGX_INVALID_MEASUREMENT 4 -#define SGX_NOTBLOCKABLE 5 -#define SGX_PG_INVLD 6 -#define SGX_LOCKFAIL 7 -#define SGX_INVALID_SIGNATURE 8 -#define SGX_MAC_COMPARE_FAIL 9 -#define SGX_PAGE_NOT_BLOCKED 10 -#define SGX_NOT_TRACKED 11 -#define SGX_VA_SLOT_OCCUPIED 12 -#define SGX_CHILD_PRESENT 13 -#define SGX_ENCLAVE_ACT 14 -#define SGX_ENTRYEPOCH_LOCKED 15 -#define SGX_INVALID_LICENSE 16 -#define SGX_PREV_TRK_INCMPL 17 -#define SGX_PG_IS_SECS 18 -#define SGX_INVALID_CPUSVN 32 -#define SGX_INVALID_ISVSVN 64 -#define SGX_UNMASKED_EVENT 128 -#define SGX_INVALID_KEYNAME 256 - - /* IOCTL return values */ -#define SGX_POWER_LOST_ENCLAVE 0x40000000 -#define SGX_LE_ROLLBACK 0x40000001 - - struct sgx_enclave_create { - __u64 src; - } __attribute__((packed)); - - struct sgx_enclave_add_page { - __u64 addr; - __u64 src; - __u64 secinfo; - __u16 mrmask; - } __attribute__((packed)); - - struct sgx_enclave_init { - __u64 addr; - __u64 sigstruct; - __u64 einittoken; - } __attribute__((packed)); - -#endif /* _UAPI_ASM_X86_SGX_H */ +#define SGX_MAGIC 0xA4 + +#define SGX_IOC_ENCLAVE_CREATE \ + _IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create) +#define SGX_IOC_ENCLAVE_ADD_PAGE \ + _IOW(SGX_MAGIC, 0x01, struct sgx_enclave_add_page) +#define SGX_IOC_ENCLAVE_INIT \ + _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init) +#define SGX_IOC_ENCLAVE_EMODPR \ + _IOW(SGX_MAGIC, 0x09, struct sgx_modification_param) +#define SGX_IOC_ENCLAVE_MKTCS \ + _IOW(SGX_MAGIC, 0x0a, struct sgx_range) +#define SGX_IOC_ENCLAVE_TRIM \ + _IOW(SGX_MAGIC, 0x0b, struct sgx_range) +#define SGX_IOC_ENCLAVE_NOTIFY_ACCEPT \ + _IOW(SGX_MAGIC, 0x0c, struct sgx_range) +#define SGX_IOC_ENCLAVE_PAGE_REMOVE \ + _IOW(SGX_MAGIC, 0x0d, unsigned long) + +/* SGX leaf instruction return values */ +#define SGX_INVALID_SIG_STRUCT 1 +#define SGX_INVALID_ATTRIBUTE 2 +#define SGX_BLKSTATE 3 +#define SGX_INVALID_MEASUREMENT 4 +#define SGX_NOTBLOCKABLE 5 +#define SGX_PG_INVLD 6 +#define SGX_LOCKFAIL 7 +#define SGX_INVALID_SIGNATURE 8 +#define SGX_MAC_COMPARE_FAIL 9 +#define SGX_PAGE_NOT_BLOCKED 10 +#define SGX_NOT_TRACKED 11 +#define SGX_VA_SLOT_OCCUPIED 12 +#define SGX_CHILD_PRESENT 13 +#define SGX_ENCLAVE_ACT 14 +#define SGX_ENTRYEPOCH_LOCKED 15 +#define SGX_INVALID_LICENSE 16 +#define SGX_PREV_TRK_INCMPL 17 +#define SGX_PG_IS_SECS 18 +#define SGX_PAGE_NOT_MODIFIABLE 20 +#define SGX_INVALID_CPUSVN 32 +#define SGX_INVALID_ISVSVN 64 +#define SGX_UNMASKED_EVENT 128 +#define SGX_INVALID_KEYNAME 256 + +/* IOCTL return values */ +#define SGX_POWER_LOST_ENCLAVE 0x40000000 +#define SGX_LE_ROLLBACK 0x40000001 + +/** + * struct sgx_enclave_create - parameter structure for the + * %SGX_IOC_ENCLAVE_CREATE ioctl + * @src: address for the SECS page data + */ +struct sgx_enclave_create { + __u64 src; +} __attribute__((packed)); + +/** + * struct sgx_enclave_add_page - parameter structure for the + * %SGX_IOC_ENCLAVE_ADD_PAGE ioctl + * @addr: address in the ELRANGE + * @src: address for the page data + * @secinfo: address for the SECINFO data + * @mrmask: bitmask for the 256 byte chunks that are to be measured + */ +struct sgx_enclave_add_page { + __u64 addr; + __u64 src; + __u64 secinfo; + __u16 mrmask; +} __attribute__((packed)); + +/** + * struct sgx_enclave_init - parameter structure for the + * %SGX_IOC_ENCLAVE_INIT ioctl + * @addr: address in the ELRANGE + * @sigstruct: address for the page data + * @einittoken: address for the SECINFO data + */ +struct sgx_enclave_init { + __u64 addr; + __u64 sigstruct; + __u64 einittoken; +} __attribute__((packed)); + +struct sgx_enclave_destroy { + __u64 addr; +} __attribute__((packed)); + + +/* + * SGX2.0 definitions + */ + +#define SGX_GROW_UP_FLAG 1 +#define SGX_GROW_DOWN_FLAG 2 + +struct sgx_range { + unsigned long start_addr; + unsigned int nr_pages; +}; + +struct sgx_modification_param { + struct sgx_range range; + unsigned long flags; +}; + +#endif /* _UAPI_ASM_X86_SGX_H */ diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/sig_handler.cpp b/sgx-jvm/linux-sgx/psw/urts/linux/sig_handler.cpp index e991a021db..a717fbe2df 100644 --- a/sgx-jvm/linux-sgx/psw/urts/linux/sig_handler.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/linux/sig_handler.cpp @@ -34,7 +34,6 @@ #include "sgx_error.h" #include "tcs.h" #include "se_trace.h" -#include "xsave.h" #include "rts.h" #include "enclave.h" #include @@ -130,7 +129,7 @@ void sig_handler(int signum, siginfo_t* siginfo, void *priv) } //If we can't fix the exception within enclave, then give the handle to other signal hanlder. //Call the previous signal handler. The default signal handler should terminate the application. - + enclave->rdunlock(); CEnclavePool::instance()->unref_enclave(enclave); } @@ -223,6 +222,7 @@ void reg_sig_handler() extern "C" int enter_enclave(const tcs_t *tcs, const long fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); + int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread) { int status = SGX_ERROR_UNEXPECTED; @@ -236,25 +236,17 @@ int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread #endif tcs_t *tcs = trust_thread->get_tcs(); - //seh_handler.cpp have the same code to save and restore pf register. - //put the save register code here, because we want remind maintainer we should do it near EENTER - uint8_t buffer[FXSAVE_SIZE]; - save_and_clean_xfeature_regs(buffer); status = enter_enclave(tcs, fn, ocall_table, ms, trust_thread); - restore_xfeature_regs(buffer); - return status; } -int do_ocall(const bridge_fn_t bridge, sgx_enclave_id_t enclave_id, void *ms) +int do_ocall(const bridge_fn_t bridge, void *ms) { int error = SGX_ERROR_UNEXPECTED; - error = bridge(enclave_id, ms); - - save_and_clean_xfeature_regs(NULL); + error = bridge(ms); return error; } diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.cpp b/sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.cpp new file mode 100644 index 0000000000..ef17d74aa0 --- /dev/null +++ b/sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.cpp @@ -0,0 +1,70 @@ +/* + * 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 "urts_emodpr.h" +#include "enclave_creator.h" +#include + +typedef struct ms_emodpr_ocall_t { + size_t ms_addr; + size_t ms_size; + uint64_t ms_epcm_perms; +} ms_trim_emodpr_ocall_t; + + + +sgx_status_t ocall_emodpr(void* pms) +{ + int ret = 0; + ms_trim_emodpr_ocall_t* ms = SGX_CAST(ms_trim_emodpr_ocall_t*, pms); + + if(ms->ms_epcm_perms < (SI_FLAG_R|SI_FLAG_W|SI_FLAG_X)) + { + EnclaveCreator *enclave_creator = get_enclave_creator(); + if(NULL == enclave_creator) + { + return SGX_ERROR_UNEXPECTED; + } + ret = enclave_creator->emodpr(ms->ms_addr, ms->ms_size, ms->ms_epcm_perms); + if(0 != ret) + { + return (sgx_status_t)ret; + } + } + + ret = mprotect((void*)ms->ms_addr, ms->ms_size, (int)ms->ms_epcm_perms); + if(ret != 0) + { + return SGX_ERROR_UNEXPECTED; + } + + return SGX_SUCCESS; +} diff --git a/sgx-jvm/linux-sgx/common/inc/internal/linux/xsave_gnu.h b/sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.h similarity index 56% rename from sgx-jvm/linux-sgx/common/inc/internal/linux/xsave_gnu.h rename to sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.h index c653f0c867..9d4e2f3c69 100644 --- a/sgx-jvm/linux-sgx/common/inc/internal/linux/xsave_gnu.h +++ b/sgx-jvm/linux-sgx/psw/urts/linux/urts_emodpr.h @@ -29,64 +29,30 @@ * */ -#ifndef _XSAVE_GNU_H_ -#define _XSAVE_GNU_H_ +#ifndef _URTS_EMODPR_H_ +#define _URTS_EMODPR_H_ -#include "se_types.h" +#include +#include +#include +#include "sgx_urts.h" -#ifdef __x86_64__ -# define ASM_FXSAVE "rex64/fxsave" -# define ASM_FXRSTR "rex64/fxrstor" -# define ASM_XSAVE ".byte 0x48,0x0f,0xae,0x21" -# define ASM_XRSTR ".byte 0x48,0x0f,0xae,0x2f" -#else -# define ASM_FXSAVE "fxsave" -# define ASM_FXRSTR "fxrstor" -# define ASM_XSAVE ".byte 0x0f,0xae,0x21" -# define ASM_XRSTR ".byte 0x0f,0xae,0x2f" + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { #endif -static inline void do_fwait(void) -{ - asm volatile("fwait"); -} -static inline void do_fxsave(void *buffer) -{ - asm volatile(ASM_FXSAVE" (%0)" : : "r"(buffer) : "memory"); -} -static inline void do_fxrstor(const void *buffer) -{ - asm volatile(ASM_FXRSTR" (%0)" : : "r"(buffer)); -} +sgx_status_t SGX_CDECL ocall_emodpr(void* pms); -static inline void do_xsave(void *buffer) -{ - asm volatile(ASM_XSAVE - : - : "D" (buffer), "a" (-1), "d" (-1) - : "memory"); -} -static inline void _do_xrstor(const void *buffer, uint64_t mask) -{ - uint32_t lmask = (uint32_t)mask; - uint32_t hmask = (uint32_t)(mask >> 32); - asm volatile(ASM_XRSTR - : - : "D" (buffer), "a" (lmask), "d" (hmask)); -} - -static inline void do_xrstor(const void *buffer) -{ - _do_xrstor(buffer, 0xffffffffffffffffULL); -} - -static inline void do_vzeroupper() -{ - asm volatile("vzeroupper"); +#ifdef __cplusplus } +#endif /* __cplusplus */ #endif + diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.cpp b/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.cpp new file mode 100644 index 0000000000..c7c3bea2f1 --- /dev/null +++ b/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.cpp @@ -0,0 +1,76 @@ +/* + * 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 "urts_trim.h" +#include "enclave_creator.h" + +typedef struct ms_trim_range_ocall_t { + size_t ms_fromaddr; + size_t ms_toaddr; +} ms_trim_range_ocall_t; + +typedef struct ms_trim_accept_ocall_t { + size_t ms_addr; +} ms_trim_accept_ocall_t; + +sgx_status_t ocall_trim_range(void* pms) +{ + int ret = 0; + ms_trim_range_ocall_t* ms = SGX_CAST(ms_trim_range_ocall_t*, pms); + + EnclaveCreator *enclave_creator = get_enclave_creator(); + if(NULL == enclave_creator) + { + return SGX_ERROR_UNEXPECTED; + } + ret = enclave_creator->trim_range(ms->ms_fromaddr, ms->ms_toaddr); + + return (sgx_status_t)ret; +} + +sgx_status_t ocall_trim_accept(void* pms) +{ + int ret = 0; + ms_trim_accept_ocall_t* ms = SGX_CAST(ms_trim_accept_ocall_t*, pms); + + EnclaveCreator *enclave_creator = get_enclave_creator(); + if(NULL == enclave_creator) + { + return SGX_ERROR_UNEXPECTED; + } + + ret = enclave_creator->trim_accept(ms->ms_addr); + + return (sgx_status_t)ret; + +} + + diff --git a/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.h b/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.h new file mode 100644 index 0000000000..b5b757c6e8 --- /dev/null +++ b/sgx-jvm/linux-sgx/psw/urts/linux/urts_trim.h @@ -0,0 +1,58 @@ +/* + * 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 _URTS_TRIM_H_ +#define _URTS_TRIM_H_ + +#include +#include +#include +#include "sgx_urts.h" + + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + + + +sgx_status_t SGX_CDECL ocall_trim_range(void* pms); + +sgx_status_t SGX_CDECL ocall_trim_accept(void* pms); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/sgx-jvm/linux-sgx/psw/urts/loader.cpp b/sgx-jvm/linux-sgx/psw/urts/loader.cpp index cb1e0346eb..80a848c702 100644 --- a/sgx-jvm/linux-sgx/psw/urts/loader.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/loader.cpp @@ -83,7 +83,7 @@ const void* CLoader::get_start_addr() const return m_start_addr; } -const std::vector& CLoader::get_tcs_list() const +const std::vector>& CLoader::get_tcs_list() const { return m_tcs_list; } @@ -133,8 +133,22 @@ int CLoader::build_mem_region(const section_info_t &sec_info) uint64_t size = MIN((SE_PAGE_SIZE - PAGE_OFFSET(rva)), (sec_info.raw_data_size - offset)); sinfo.flags = sec_info.flag; - if(is_relocation_page(rva, sec_info.bitmap)) + if(is_relocation_page(rva, sec_info.bitmap) && !(sec_info.flag & SI_FLAG_W)) + { sinfo.flags = sec_info.flag | SI_FLAG_W; + assert(g_enclave_creator != NULL); + if(g_enclave_creator->use_se_hw() == true) + { + ret = mprotect((void*)(TRIM_TO_PAGE(rva) + (uint64_t)m_start_addr), SE_PAGE_SIZE, + (int)(sinfo.flags & SI_MASK_MEM_ATTRIBUTE)); + if(ret != 0) + { + SE_TRACE(SE_TRACE_WARNING, "mprotect(rva=0x%llx, len=%d, flags=%d) failed\n", + rva, SE_PAGE_SIZE, int(sinfo.flags & SI_MASK_MEM_ATTRIBUTE)); + return SGX_ERROR_UNEXPECTED; + } + } + } if (size == SE_PAGE_SIZE) ret = build_pages(rva, size, sec_info.raw_data + offset, sinfo, ADD_EXTEND_PAGE); @@ -263,61 +277,148 @@ int CLoader::build_pages(const uint64_t start_rva, const uint64_t size, const vo return SGX_SUCCESS; } + +int CLoader::post_init_action(layout_t *layout_start, layout_t *layout_end, uint64_t delta) +{ + int ret = SGX_SUCCESS; + + for(layout_t *layout = layout_start; layout < layout_end; layout++) + { + if (!IS_GROUP_ID(layout->group.id) && (layout->entry.attributes & PAGE_ATTR_POST_REMOVE)) + { + uint64_t start_addr = layout->entry.rva + delta + (uint64_t)get_start_addr(); + uint64_t page_count = (uint64_t)layout->entry.page_count; + if (SGX_SUCCESS != (ret = get_enclave_creator()->trim_range(start_addr, start_addr + (page_count << SE_PAGE_SHIFT)))) + return ret; + + } + else if (IS_GROUP_ID(layout->group.id)) + { + uint64_t step = 0; + for(uint32_t j = 0; j < layout->group.load_times; j++) + { + step += layout->group.load_step; + if(SGX_SUCCESS != (ret = post_init_action(&layout[-layout->group.entry_count], layout, step))) + return ret; + } + } + } + return SGX_SUCCESS; +} + +int CLoader::post_init_action_commit(layout_t *layout_start, layout_t *layout_end, uint64_t delta) +{ + int ret = SGX_SUCCESS; + + for(layout_t *layout = layout_start; layout < layout_end; layout++) + { + if (!IS_GROUP_ID(layout->group.id) && (layout->entry.attributes & PAGE_ATTR_POST_REMOVE)) + { + uint64_t start_addr = layout->entry.rva + delta + (uint64_t)get_start_addr(); + uint64_t page_count = (uint64_t)layout->entry.page_count; + + for (uint64_t i = 0; i < page_count; i++) + { + if (SGX_SUCCESS != (ret = get_enclave_creator()->trim_accept(start_addr + (i << SE_PAGE_SHIFT)))) + return ret; + } + } + else if (IS_GROUP_ID(layout->group.id)) + { + uint64_t step = 0; + for(uint32_t j = 0; j < layout->group.load_times; j++) + { + step += layout->group.load_step; + if(SGX_SUCCESS != (ret = post_init_action_commit(&layout[-layout->group.entry_count], layout, step))) + return ret; + } + } + } + return SGX_SUCCESS; +} + int CLoader::build_context(const uint64_t start_rva, layout_entry_t *layout) { int ret = SGX_ERROR_UNEXPECTED; uint8_t added_page[SE_PAGE_SIZE]; sec_info_t sinfo; + memset(added_page, 0, SE_PAGE_SIZE); memset(&sinfo, 0, sizeof(sinfo)); uint64_t rva = start_rva + layout->rva; + //uint64_t start_addr = (uint64_t)get_start_addr(); + + assert(IS_PAGE_ALIGNED(rva)); - if (layout->content_offset) + if (layout->attributes & PAGE_ATTR_EADD) { - // assume TCS is only 1 page - if(layout->si_flags == SI_FLAGS_TCS) - { - memset(added_page, 0, SE_PAGE_SIZE); - memcpy_s(added_page, SE_PAGE_SIZE, GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size); + uint16_t attributes = layout->attributes; +#ifdef SE_SIM + attributes = attributes & (uint16_t)(~PAGE_ATTR_EREMOVE); +#endif - tcs_t *ptcs = reinterpret_cast(added_page); - ptcs->ossa += rva; - ptcs->ofs_base += rva; - ptcs->ogs_base += rva; - m_tcs_list.push_back(GET_PTR(tcs_t, m_start_addr, rva)); - sinfo.flags = layout->si_flags; - if(SGX_SUCCESS != (ret = build_pages(rva, (uint64_t)layout->page_count << SE_PAGE_SHIFT, added_page, sinfo, layout->attributes))) + if (layout->content_offset) + { + if(layout->si_flags == SI_FLAGS_TCS) { - return ret; + memset(added_page, 0, SE_PAGE_SIZE); + memcpy_s(added_page, SE_PAGE_SIZE, GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size); + + tcs_t *ptcs = reinterpret_cast(added_page); + ptcs->ossa += rva; + ptcs->ofs_base += rva; + ptcs->ogs_base += rva; + if(!(attributes & PAGE_ATTR_EREMOVE)) + { + m_tcs_list.push_back(make_pair(GET_PTR(tcs_t, m_start_addr, rva), false)); + } + sinfo.flags = layout->si_flags; + if(SGX_SUCCESS != (ret = build_pages(rva, ((uint64_t)layout->page_count) << SE_PAGE_SHIFT, added_page, sinfo, attributes))) + { + return ret; + } + } + else // guard page should not have content_offset != 0 + { + + section_info_t sec_info = {GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size, rva, ((uint64_t)layout->page_count) << SE_PAGE_SHIFT, layout->si_flags, NULL}; + if(SGX_SUCCESS != (ret = build_mem_region(sec_info))) + { + return ret; + } } } - else // guard page should not have content_offset != 0 + else if (layout->si_flags != SI_FLAG_NONE) { - section_info_t sec_info = {GET_PTR(uint8_t, m_metadata, layout->content_offset), layout->content_size, rva, (uint64_t)layout->page_count << SE_PAGE_SHIFT, layout->si_flags, NULL}; - if(SGX_SUCCESS != (ret = build_mem_region(sec_info))) + sinfo.flags = layout->si_flags; + + void *source = NULL; + if(layout->content_size) + { + for(uint32_t *p = (uint32_t *)added_page; p < GET_PTR(uint32_t, added_page, SE_PAGE_SIZE); p++) + { + *p = layout->content_size; + } + source = added_page; + } + + if(SGX_SUCCESS != (ret = build_pages(rva, ((uint64_t)layout->page_count) << SE_PAGE_SHIFT, source, sinfo, layout->attributes))) { return ret; } + } } - else if (layout->si_flags != SI_FLAG_NONE) - { - sinfo.flags = layout->si_flags; - void *source = NULL; - if(layout->content_size) + if(layout->attributes & PAGE_ATTR_POST_ADD) + { +#ifndef SE_SIM + if(layout->id == LAYOUT_ID_TCS_DYN) { - for(uint32_t *p = (uint32_t *)added_page; p < GET_PTR(uint32_t, added_page, SE_PAGE_SIZE); p++) - { - *p = layout->content_size; - } - source = added_page; - } - if(SGX_SUCCESS != (ret = build_pages(rva, (uint64_t)layout->page_count << SE_PAGE_SHIFT, source, sinfo, layout->attributes))) - { - return ret; + m_tcs_list.push_back(make_pair(GET_PTR(tcs_t, m_start_addr, rva), true)); } +#endif } return SGX_SUCCESS; } @@ -365,7 +466,11 @@ int CLoader::build_secs(sgx_attributes_t * const secs_attr, sgx_misc_attribute_t int ret = enclave_creator->create_enclave(&m_secs, &m_enclave_id, &m_start_addr, is_ae(&m_metadata->enclave_css)); if(SGX_SUCCESS == ret) { - SE_TRACE(SE_TRACE_NOTICE, "enclave start address = %p, size = 0x%x\n", m_start_addr, m_metadata->enclave_size); + SE_TRACE(SE_TRACE_NOTICE, "enclave start address = %p, size = 0x%llx\n", m_start_addr, m_metadata->enclave_size); + if(enclave_creator->use_se_hw() == true) + { + set_memory_protection(); + } } return ret; } @@ -373,11 +478,13 @@ int CLoader::build_image(SGXLaunchToken * const lc, sgx_attributes_t * const sec { int ret = SGX_SUCCESS; + if(SGX_SUCCESS != (ret = build_secs(secs_attr, misc_attr))) { SE_TRACE(SE_TRACE_WARNING, "build secs failed\n"); return ret; }; + // read reloc bitmap before patch the enclave file // If load_enclave_ex try to load the enclave for the 2nd time, // the enclave image is already patched, and parser cannot read the information. @@ -418,6 +525,7 @@ int CLoader::build_image(SGXLaunchToken * const lc, sgx_attributes_t * const sec goto fail; } + return SGX_SUCCESS; fail: @@ -460,7 +568,7 @@ int CLoader::validate_layout_table() { if(!IS_GROUP_ID(layout->entry.id)) // layout entry { - rva_vector.push_back(make_pair(layout->entry.rva, (uint64_t)layout->entry.page_count << SE_PAGE_SHIFT)); + rva_vector.push_back(make_pair(layout->entry.rva, ((uint64_t)layout->entry.page_count) << SE_PAGE_SHIFT)); if(layout->entry.content_offset) { if(false == is_metadata_buffer(layout->entry.content_offset, layout->entry.content_size)) @@ -489,7 +597,7 @@ int CLoader::validate_layout_table() { return SGX_ERROR_INVALID_METADATA; } - rva_vector.push_back(make_pair(entry->rva + load_step, (uint64_t)entry->page_count << SE_PAGE_SHIFT)); + rva_vector.push_back(make_pair(entry->rva + load_step, ((uint64_t)entry->page_count) << SE_PAGE_SHIFT)); // no need to check integer overflow for entry->rva + load_step, because // entry->rva and load_step are less than enclave_size, whose size is no more than 37 bit } @@ -539,18 +647,20 @@ int CLoader::validate_metadata() { if(!m_metadata) return SGX_ERROR_INVALID_METADATA; - uint64_t version2 = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ); - uint64_t version1 = META_DATA_MAKE_VERSION(SGX_1_5_MAJOR_VERSION,SGX_1_5_MINOR_VERSION ); + uint64_t versions[] = { + META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ), + META_DATA_MAKE_VERSION(SGX_1_9_MAJOR_VERSION,SGX_1_9_MINOR_VERSION ), + META_DATA_MAKE_VERSION(SGX_1_5_MAJOR_VERSION,SGX_1_5_MINOR_VERSION ) + }; //if the version of metadata does NOT match the version of metadata in urts, we should NOT launch enclave. - if((m_metadata->version != version1) && (m_metadata->version != version2)) + uint32_t idx; + for(idx = 0; idx < (uint32_t)(sizeof(versions)/sizeof(versions[0])) && m_metadata->version != versions[idx]; idx ++); + if(idx >= (uint32_t)(sizeof(versions)/sizeof(versions[0]))) { SE_TRACE(SE_TRACE_WARNING, "Mismatch between the metadata urts required and the metadata in use.\n"); - return SGX_ERROR_INVALID_VERSION; - } - if(m_metadata->size > sizeof(metadata_t)) - { - return SGX_ERROR_INVALID_METADATA; + return SGX_ERROR_INVALID_VERSION; } + if(m_metadata->tcs_policy > TCS_POLICY_UNBIND) return SGX_ERROR_INVALID_METADATA; if(m_metadata->ssa_frame_size < SSA_FRAME_SIZE_MIN || m_metadata->ssa_frame_size > SSA_FRAME_SIZE_MAX) @@ -734,7 +844,6 @@ int CLoader::set_memory_protection() } last_section_end = rva + len; } - ret = set_context_protection(GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset), GET_PTR(layout_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size), 0); @@ -762,6 +871,19 @@ int CLoader::set_context_protection(layout_t *layout_start, layout_t *layout_end else { prot = SI_FLAGS_RWX & SI_MASK_MEM_ATTRIBUTE; +#ifndef SE_SIM + + //when a page is eremoved when loading, we should set this page to none access. + //if this page is accessed, a sigbus exception will be raised. + uint16_t attributes = layout->entry.attributes; + if(attributes & PAGE_ATTR_EADD && attributes & PAGE_ATTR_EREMOVE) + { + if(attributes & PAGE_ATTR_EREMOVE) + { + prot = SI_FLAG_NONE & SI_MASK_MEM_ATTRIBUTE; + } + } +#endif } ret = mprotect(GET_PTR(void, m_start_addr, layout->entry.rva + delta), diff --git a/sgx-jvm/linux-sgx/psw/urts/loader.h b/sgx-jvm/linux-sgx/psw/urts/loader.h index b8f5cd4d99..74cc82dba8 100644 --- a/sgx-jvm/linux-sgx/psw/urts/loader.h +++ b/sgx-jvm/linux-sgx/psw/urts/loader.h @@ -63,9 +63,11 @@ public: sgx_enclave_id_t get_enclave_id() const; const void* get_start_addr() const; const secs_t& get_secs() const; - const std::vector& get_tcs_list() const; + const std::vector>& get_tcs_list() const; void* get_symbol_address(const char* const sym); int set_memory_protection(); + int post_init_action(layout_t *start, layout_t *end, uint64_t delta); + int post_init_action_commit(layout_t *start, layout_t *end, uint64_t delta); private: int build_mem_region(const section_info_t &sec_info); @@ -92,7 +94,7 @@ private: void *m_start_addr; // the TCS list - std::vector m_tcs_list; + std::vector> m_tcs_list; // the enclave creation parameters const metadata_t *m_metadata; secs_t m_secs; diff --git a/sgx-jvm/linux-sgx/psw/urts/parser/binparser.h b/sgx-jvm/linux-sgx/psw/urts/parser/binparser.h index 664cf3559d..4500fffa7d 100644 --- a/sgx-jvm/linux-sgx/psw/urts/parser/binparser.h +++ b/sgx-jvm/linux-sgx/psw/urts/parser/binparser.h @@ -89,17 +89,19 @@ public: virtual void get_reloc_entry_offset(const char* sec_name, vector& offsets) = 0; - // We need to put this method into BinParser class since - // the `global_data_t' is platform-dependent as the parser. - // c.f. global_data.h for more information. - // - // Unfortunately, although the implementation is the same, - // we can't put them here but into the subclasses - - // ElfParsr and PEParser, since the `global_data_t' for - // them are different in terms of size and layout. - virtual bool update_global_data(const create_param_t* const create_param, + // !We need to put this method into BinParser class since + // !the `global_data_t' is platform-dependent as the parser. + // !c.f. global_data.h for more information. + // ! + // !Unfortunately, although the implementation is the same, + // !we can't put them here but into the subclasses - + // !ElfParsr and PEParser, since the `global_data_t' for + // !them are different in terms of size and layout. + virtual bool update_global_data(const metadata_t *const metadata, + const create_param_t* const create_param, uint8_t *data, uint32_t *data_size) = 0; + virtual uint32_t get_global_data_size() = 0; virtual sgx_status_t modify_info(enclave_diff_info_t *enclave_diff_info) = 0; diff --git a/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.cpp b/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.cpp index 9111089e59..09f81228b2 100644 --- a/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.cpp @@ -434,7 +434,7 @@ bool validate_segment(const ElfW(Ehdr) *elf_hdr, uint64_t len) // Verify the overlap of segment. we don't verify here, because a well compiled file has no overlapped segment. load_seg[k].first = prg_hdr->p_vaddr; - load_seg[k].second = prg_hdr->p_vaddr + ROUND_TO(prg_hdr->p_memsz, prg_hdr->p_align) - 1; + load_seg[k].second = ROUND_TO(prg_hdr->p_vaddr + prg_hdr->p_memsz, prg_hdr->p_align) - 1; for (int j = 0; j < k; j++) { @@ -814,9 +814,15 @@ void ElfParser::get_reloc_entry_offset(const char* sec_name, vector& o } } +#include "se_page_attr.h" #include "update_global_data.hxx" -bool ElfParser::update_global_data(const create_param_t* const create_param, +uint32_t ElfParser::get_global_data_size() +{ + return (uint32_t)sizeof(global_data_t); +} +bool ElfParser::update_global_data(const metadata_t *const metadata, + const create_param_t* const create_param, uint8_t *data, uint32_t *data_size) { @@ -825,9 +831,8 @@ bool ElfParser::update_global_data(const create_param_t* const create_param, *data_size = sizeof(global_data_t); return false; } - do_update_global_data(create_param, (global_data_t *)data); *data_size = sizeof(global_data_t); - return true; + return do_update_global_data(metadata, create_param, (global_data_t *)data); } sgx_status_t ElfParser::modify_info(enclave_diff_info_t *enclave_diff_info) diff --git a/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.h b/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.h index d617c4e419..0a78e6aae6 100644 --- a/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.h +++ b/sgx-jvm/linux-sgx/psw/urts/parser/elfparser.h @@ -68,7 +68,9 @@ public: uint64_t get_symbol_rva(const char* name) const; bool get_reloc_bitmap(vector &bitmap); - bool update_global_data(const create_param_t* const create_param, + uint32_t get_global_data_size(); + bool update_global_data(const metadata_t *const metadata, + const create_param_t* const create_param, uint8_t *data, uint32_t *data_size); diff --git a/sgx-jvm/linux-sgx/psw/urts/parser/update_global_data.hxx b/sgx-jvm/linux-sgx/psw/urts/parser/update_global_data.hxx index 84bb0a9229..08b363da3d 100644 --- a/sgx-jvm/linux-sgx/psw/urts/parser/update_global_data.hxx +++ b/sgx-jvm/linux-sgx/psw/urts/parser/update_global_data.hxx @@ -30,22 +30,63 @@ */ namespace { - void do_update_global_data(const create_param_t* const create_param, + layout_entry_t *get_entry_by_id(const metadata_t *const metadata, uint16_t id) + { + layout_entry_t *layout_start = GET_PTR(layout_entry_t, metadata, metadata->dirs[DIR_LAYOUT].offset); + layout_entry_t *layout_end = GET_PTR(layout_entry_t, metadata, metadata->dirs[DIR_LAYOUT].offset + metadata->dirs[DIR_LAYOUT].size); + for (layout_entry_t *layout = layout_start; layout < layout_end; layout++) + { + if(layout->id == id) + return layout; + } + assert(false); + return NULL; + } + bool do_update_global_data(const metadata_t *const metadata, + const create_param_t* const create_param, global_data_t* global_data) { - global_data->enclave_size = (sys_word_t)create_param->enclave_size; - global_data->heap_offset = (sys_word_t)create_param->heap_offset; - global_data->heap_size = (sys_word_t)create_param->heap_max_size; - global_data->thread_policy = (uint32_t)create_param->tcs_policy; + layout_entry_t *layout_heap = get_entry_by_id(metadata, LAYOUT_ID_HEAP_MIN); + + global_data->enclave_size = (sys_word_t)metadata->enclave_size; + global_data->heap_offset = (sys_word_t)layout_heap->rva; + global_data->heap_size = (sys_word_t)(create_param->heap_init_size); + global_data->thread_policy = (sys_word_t)metadata->tcs_policy; thread_data_t *thread_data = &global_data->td_template; - thread_data->stack_base_addr = (sys_word_t)create_param->stack_base_addr; + thread_data->stack_limit_addr = (sys_word_t)create_param->stack_limit_addr; + thread_data->stack_base_addr = (sys_word_t)create_param->stack_base_addr; thread_data->last_sp = thread_data->stack_base_addr; - thread_data->ssa_frame_size = create_param->ssa_frame_size; - thread_data->first_ssa_gpr = (sys_word_t)create_param->first_ssa_gpr; + thread_data->xsave_size = create_param->xsave_size; + thread_data->first_ssa_gpr = (sys_word_t)create_param->ssa_base_addr + metadata->ssa_frame_size * SE_PAGE_SIZE - (uint32_t)sizeof(ssa_gpr_t); // TD address relative to TCS - thread_data->self_addr = (sys_word_t)create_param->td_addr; thread_data->tls_addr = (sys_word_t)create_param->tls_addr; + thread_data->self_addr = (sys_word_t)create_param->td_addr; thread_data->tls_array = thread_data->self_addr + (sys_word_t)offsetof(thread_data_t, tls_addr); + + // TCS template + if(0 != memcpy_s(&global_data->tcs_template, sizeof(global_data->tcs_template), + GET_PTR(void, metadata, get_entry_by_id(metadata, LAYOUT_ID_TCS)->content_offset), + get_entry_by_id(metadata, LAYOUT_ID_TCS)->content_size)) + { + return false; + } + + // layout table: dynamic heap + dynamic thread group + layout_entry_t *layout_start = GET_PTR(layout_entry_t, metadata, metadata->dirs[DIR_LAYOUT].offset); + layout_entry_t *layout_end = GET_PTR(layout_entry_t, metadata, metadata->dirs[DIR_LAYOUT].offset + metadata->dirs[DIR_LAYOUT].size); + global_data->layout_entry_num = 0; + for (layout_entry_t *layout = layout_start; layout < layout_end; layout++) + { + if(0 != memcpy_s(&global_data->layout_table[global_data->layout_entry_num], + sizeof(global_data->layout_table) - global_data->layout_entry_num * sizeof(layout_t), + layout, + sizeof(layout_t))) + { + return false; + } + global_data->layout_entry_num++; + } + return true; } } diff --git a/sgx-jvm/linux-sgx/psw/urts/se_detect.cpp b/sgx-jvm/linux-sgx/psw/urts/se_detect.cpp index 25b5e2dc1f..2f50ca3f37 100644 --- a/sgx-jvm/linux-sgx/psw/urts/se_detect.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/se_detect.cpp @@ -50,12 +50,23 @@ bool is_se_supported() #include "read_xcr0.h" bool try_read_xcr0(uint64_t *value) { + // set to default value + *value = SGX_XFRM_LEGACY; + //check if xgetbv instruction is supported int cpu_info[4] = {0, 0, 0, 0}; __cpuid(cpu_info, 1); if(!(cpu_info[2] & (1<secs_attr.xfrm)) { + // if XSAVE is supported, while XSAVEC is not supported, + // set secs_attr.xfrm to legacy, because XSAVEC cannot be executed within enclave. se_misc_attr->secs_attr.xfrm = SGX_XFRM_LEGACY; } //If x-feature is supported and enabled by OS, we need make sure it is also supported in se. diff --git a/sgx-jvm/linux-sgx/psw/urts/se_detect.h b/sgx-jvm/linux-sgx/psw/urts/se_detect.h index 62b1c2abf8..12c2e854a2 100644 --- a/sgx-jvm/linux-sgx/psw/urts/se_detect.h +++ b/sgx-jvm/linux-sgx/psw/urts/se_detect.h @@ -41,9 +41,16 @@ #define SE_FEATURE_SHIFT 2 #define SE1_SHIFT 0 +// CPUID function 1 +// ECX[26] enums general support for XSAVE +// ECX[27] enums XSAVE is enabled or not #define XSAVE_SHIFT 26 #define OSXSAVE_SHIFT 27 +// CPUID function 0DH, sub-function 1 +// EAX[1] enums support for compaction extensions to XSAVE +#define XSAVEC_SHIFT 1 + bool try_read_xcr0(uint64_t *value); //bool is_se_debug_supported(); bool get_plat_cap_by_cpuid(sgx_misc_attribute_t *se_misc_attr); diff --git a/sgx-jvm/linux-sgx/psw/urts/tcs.cpp b/sgx-jvm/linux-sgx/psw/urts/tcs.cpp index dcd0324220..132ac2878c 100644 --- a/sgx-jvm/linux-sgx/psw/urts/tcs.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/tcs.cpp @@ -36,8 +36,14 @@ #include "se_memory.h" #include "se_thread.h" #include +#include "routine.h" +#include "enclave_creator.h" +#include "rts.h" +#include "enclave.h" extern se_thread_id_t get_thread_id(); +int do_ecall(const int fn, const void *ocall_table, const void *ms, CTrustThread *trust_thread); + CTrustThread::CTrustThread(tcs_t *tcs, CEnclave* enclave) @@ -84,9 +90,12 @@ void CTrustThread::pop_ocall_frame() } -CTrustThreadPool::CTrustThreadPool() +CTrustThreadPool::CTrustThreadPool(uint32_t tcs_min_pool) { m_thread_list = NULL; + m_utility_thread = NULL; + m_tcs_min_pool = tcs_min_pool; + m_need_to_wait_for_new_thread = false; } CTrustThreadPool::~CTrustThreadPool() @@ -98,6 +107,13 @@ CTrustThreadPool::~CTrustThreadPool() delete *it; } m_free_thread_vector.clear(); + //destroy unallocated tcs list + for(vector::iterator it=m_unallocated_threads.begin(); it!=m_unallocated_threads.end(); it++) + { + delete *it; + } + m_unallocated_threads.clear(); + //destroy thread cache Node* it = m_thread_list, *tmp = NULL; while (it != NULL) @@ -108,6 +124,13 @@ CTrustThreadPool::~CTrustThreadPool() delete tmp; } m_thread_list = NULL; + + if (m_utility_thread) + { + delete m_utility_thread; + m_utility_thread = NULL; + } + } void get_thread_set(vector &thread_vector); @@ -121,10 +144,12 @@ inline int CTrustThreadPool::find_thread(vector &thread_vector, inline CTrustThread * CTrustThreadPool::get_free_thread() { + LockGuard lock(&m_free_thread_mutex); if(true == m_free_thread_vector.empty()) { return NULL; } + //if there is free tcs, remove it from free list CTrustThread *thread_node = m_free_thread_vector.back(); m_free_thread_vector.pop_back(); @@ -162,12 +187,22 @@ CTrustThread * CTrustThreadPool::get_bound_thread(const se_thread_id_t thread_id return trust_thread; } -CTrustThread * CTrustThreadPool::add_thread(tcs_t * const tcs, CEnclave * const enclave) +CTrustThread * CTrustThreadPool::add_thread(tcs_t * const tcs, CEnclave * const enclave, bool is_unallocated) { CTrustThread *trust_thread = new CTrustThread(tcs, enclave); LockGuard lock(&m_thread_mutex); //add tcs to free list - m_free_thread_vector.push_back(trust_thread); + if(!is_unallocated) + { + if (g_enclave_creator->is_EDMM_supported(enclave->get_enclave_id()) && !m_utility_thread && (enclave->get_dynamic_tcs_list_size() != 0)) + m_utility_thread = trust_thread; + else + m_free_thread_vector.push_back(trust_thread); + } + else + { + m_unallocated_threads.push_back(trust_thread); + } return trust_thread; } @@ -191,6 +226,26 @@ CTrustThread *CTrustThreadPool::get_bound_thread(const tcs_t *tcs) return NULL; } +std::vector CTrustThreadPool::get_thread_list() +{ + LockGuard lock(&m_thread_mutex); + + vector threads; + + for(vector::iterator it = m_free_thread_vector.begin(); it != m_free_thread_vector.end(); it++) + { + threads.push_back(*it); + } + + Node* it = m_thread_list; + while (it != NULL) { + threads.push_back(it->value); + it = it->next; + } + + return threads; +} + void CTrustThreadPool::reset() { //get lock at the begin of list walk. @@ -207,7 +262,7 @@ void CTrustThreadPool::reset() //remove from thread cache delete tmp; trust_thread->reset_ref(); - m_free_thread_vector.push_back(trust_thread); + add_to_free_thread_vector(trust_thread); } m_thread_list = NULL; @@ -232,7 +287,7 @@ CTrustThread * CTrustThreadPool::_acquire_thread() //try to get tcs from thread cache se_thread_id_t thread_id = get_thread_id(); CTrustThread *trust_thread = get_bound_thread(thread_id); - if(NULL != trust_thread) + if(NULL != trust_thread && m_utility_thread != trust_thread) { return trust_thread; } @@ -252,15 +307,52 @@ CTrustThread * CTrustThreadPool::_acquire_thread() return trust_thread; } -CTrustThread * CTrustThreadPool::acquire_thread() +CTrustThread * CTrustThreadPool::acquire_thread(bool is_initialize_ecall) { LockGuard lock(&m_thread_mutex); CTrustThread *trust_thread = NULL; - trust_thread = _acquire_thread(); + if(is_initialize_ecall == true) + { + if (m_utility_thread) + { + trust_thread = m_utility_thread; + assert(trust_thread != NULL); + } + else + { + trust_thread = _acquire_thread(); + } + } + else + { + trust_thread = _acquire_thread(); + // for edmm feature, we don't support simulation mode yet + // m_utility_thread will be NULL in simulation mode + if(NULL == trust_thread && NULL != m_utility_thread) + { + m_need_to_wait_for_new_thread_cond.lock(); + m_utility_thread->get_enclave()->fill_tcs_mini_pool_fn(); + m_need_to_wait_for_new_thread = true; + while(m_need_to_wait_for_new_thread != false) + { + m_need_to_wait_for_new_thread_cond.wait(); + } + m_need_to_wait_for_new_thread_cond.unlock(); + trust_thread = _acquire_thread(); + } + } + if(trust_thread) + { trust_thread->increase_ref(); + } + if(is_initialize_ecall != true && + need_to_new_thread() == true) + { + m_utility_thread->get_enclave()->fill_tcs_mini_pool_fn(); + } return trust_thread; } @@ -272,6 +364,136 @@ void CTrustThreadPool::release_thread(CTrustThread * const trust_thread) return; } + +bool CTrustThreadPool::is_dynamic_thread_exist() +{ + if (m_unallocated_threads.empty()) + { + return false; + } + else + { + return true; + } +} + +bool CTrustThreadPool::need_to_new_thread() +{ + LockGuard lock(&m_free_thread_mutex); + if (m_unallocated_threads.empty()) + { + return false; + } + + if(m_tcs_min_pool == 0 && m_free_thread_vector.size() > m_tcs_min_pool) + { + return false; + } + + if(m_tcs_min_pool != 0 && m_free_thread_vector.size() >= m_tcs_min_pool) + { + return false; + } + + return true; +} + + +static int make_tcs(size_t tcs) +{ + return g_enclave_creator->mktcs(tcs); +} + +struct ms_str +{ + void * ms; +}; + +#define fastcall __attribute__((regparm(3),noinline,visibility("default"))) +//this function is used to notify GDB scripts +//GDB is supposed to have a breakpoint on urts_add_tcs to receive debug interupt +//once the breakpoint has been hit, GDB extracts the address of tcs and sets DBGOPTIN for the tcs +extern "C" void fastcall urts_add_tcs(tcs_t * const tcs) +{ + UNUSED(tcs); + SE_TRACE(SE_TRACE_WARNING, "urts_add_tcs %x\n", tcs); +} + +sgx_status_t CTrustThreadPool::new_thread() +{ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + if(!m_utility_thread) + { + return ret; + } + if (m_unallocated_threads.empty()) + { + return SGX_SUCCESS; + } + + size_t octbl_buf[ROUND_TO(sizeof(sgx_ocall_table_t) + sizeof(void*), sizeof(size_t)) / sizeof(size_t)]; + sgx_ocall_table_t *octbl = reinterpret_cast(octbl_buf); + octbl->count = 1; + void **ocalls = octbl->ocall; + *ocalls = reinterpret_cast(make_tcs); + CTrustThread *trust_thread = m_unallocated_threads.back(); + tcs_t *tcsp = trust_thread->get_tcs(); + struct ms_str ms1; + ms1.ms = tcsp; + ret = (sgx_status_t)do_ecall(ECMD_MKTCS, octbl, &ms1, m_utility_thread); + if (SGX_SUCCESS == ret ) + { + //add tcs to debug tcs info list + trust_thread->get_enclave()->add_thread(trust_thread); + add_to_free_thread_vector(trust_thread); + m_unallocated_threads.pop_back(); + + urts_add_tcs(tcsp); + } + + return ret; +} + + +void CTrustThreadPool::add_to_free_thread_vector(CTrustThread* it) +{ + LockGuard lock(&m_free_thread_mutex); + m_free_thread_vector.push_back(it); +} + +sgx_status_t CTrustThreadPool::fill_tcs_mini_pool() +{ + sgx_status_t ret = SGX_SUCCESS; + bool stop = false; + + while(stop != true) + { + if(need_to_new_thread() == true) + { + ret = new_thread(); + if(ret != SGX_SUCCESS) + { + stop= true; + } + } + else + { + stop = true; + } + + m_need_to_wait_for_new_thread_cond.lock(); + if(m_need_to_wait_for_new_thread == true) + { + m_need_to_wait_for_new_thread = false; + m_need_to_wait_for_new_thread_cond.signal(); + } + m_need_to_wait_for_new_thread_cond.unlock(); + } + + return ret; +} + + //The return value stand for the number of free trust thread. int CThreadPoolBindMode::garbage_collect() { @@ -294,7 +516,7 @@ int CThreadPoolBindMode::garbage_collect() //return to free_tcs list if(0 == it->value->get_reference()) { - m_free_thread_vector.push_back(it->value); + add_to_free_thread_vector(it->value); nr_free++; } else @@ -332,7 +554,7 @@ int CThreadPoolUnBindMode::garbage_collect() //if the reference is 0, then the trust thread is not in use, so return to free_tcs list if(0 == it->value->get_reference()) { - m_free_thread_vector.push_back(it->value); + add_to_free_thread_vector(it->value); nr_free++; tmp = it; diff --git a/sgx-jvm/linux-sgx/psw/urts/tcs.h b/sgx-jvm/linux-sgx/psw/urts/tcs.h index e954d1fc50..3cc3ec355d 100644 --- a/sgx-jvm/linux-sgx/psw/urts/tcs.h +++ b/sgx-jvm/linux-sgx/psw/urts/tcs.h @@ -36,7 +36,6 @@ #include "se_wrapper.h" #include "util.h" #include "sgx_error.h" -#include "sgx_eid.h" #include "se_debugger_lib.h" #include "se_lock.hpp" #include @@ -44,7 +43,7 @@ using namespace std; -typedef int (*bridge_fn_t)(sgx_enclave_id_t enclave_id, const void*); +typedef int (*bridge_fn_t)(const void*); class CEnclave; @@ -74,33 +73,45 @@ private: class CTrustThreadPool: private Uncopyable { public: - CTrustThreadPool(); + CTrustThreadPool(uint32_t tcs_min_pool); virtual ~CTrustThreadPool(); - CTrustThread * acquire_thread(); + CTrustThread * acquire_thread(bool is_initialize_ecall = false); void release_thread(CTrustThread * const trust_thread); - CTrustThread *add_thread(tcs_t * const tcs, CEnclave * const enclave); + CTrustThread *add_thread(tcs_t * const tcs, CEnclave * const enclave, bool is_unallocated); CTrustThread *get_bound_thread(const tcs_t *tcs); + std::vector get_thread_list(); void reset(); void wake_threads(); + sgx_status_t new_thread(); + sgx_status_t fill_tcs_mini_pool(); + bool need_to_new_thread(); + bool is_dynamic_thread_exist(); protected: virtual int garbage_collect() = 0; inline int find_thread(vector &thread_vector, se_thread_id_t thread_id); inline CTrustThread * get_free_thread(); int bind_thread(const se_thread_id_t thread_id, CTrustThread * const trust_thread); CTrustThread * get_bound_thread(const se_thread_id_t thread_id); - + void add_to_free_thread_vector(CTrustThread* it); + vector m_free_thread_vector; + vector m_unallocated_threads; Node *m_thread_list; - Mutex m_thread_mutex; //protect both thread_cache list and fress tcs list. The mutex is recursive. - //Thread can operate the two list when it get the mutex + Mutex m_thread_mutex; //protect thread_cache list. The mutex is recursive. + //Thread can operate the list when it get the mutex + Mutex m_free_thread_mutex; //protect free threads. + Cond m_need_to_wait_for_new_thread_cond; private: CTrustThread * _acquire_thread(); + CTrustThread *m_utility_thread; + uint64_t m_tcs_min_pool; + bool m_need_to_wait_for_new_thread; }; class CThreadPoolBindMode : public CTrustThreadPool { public: - CThreadPoolBindMode():CTrustThreadPool(){} + CThreadPoolBindMode(uint32_t tcs_min_pool):CTrustThreadPool(tcs_min_pool){} private: virtual int garbage_collect(); }; @@ -108,7 +119,7 @@ private: class CThreadPoolUnBindMode : public CTrustThreadPool { public: - CThreadPoolUnBindMode():CTrustThreadPool(){} + CThreadPoolUnBindMode(uint32_t tcs_min_pool):CTrustThreadPool(tcs_min_pool){} private: virtual int garbage_collect(); }; diff --git a/sgx-jvm/linux-sgx/psw/urts/urts_com.h b/sgx-jvm/linux-sgx/psw/urts/urts_com.h index f531b02ab1..45935bd10f 100644 --- a/sgx-jvm/linux-sgx/psw/urts/urts_com.h +++ b/sgx-jvm/linux-sgx/psw/urts/urts_com.h @@ -48,11 +48,14 @@ #include "se_macro.h" #include "prd_css_util.h" #include "se_detect.h" - +#include "rts.h" +#include "enclave_creator_hw.h" +#include #ifndef PARSER #include "elfparser.h" #define PARSER ElfParser #endif +#include "xsave.h" #include "ittnotify.h" #include "ittnotify_config.h" @@ -102,23 +105,41 @@ static sgx_status_t get_metadata(BinParser *parser, const int debug, metadata_t const uint8_t *base_addr = parser->get_start_addr(); uint64_t supported_metadata_version_list[] = { - META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ), - META_DATA_MAKE_VERSION(SGX_1_5_MAJOR_VERSION,SGX_1_5_MINOR_VERSION ) + META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ), + META_DATA_MAKE_VERSION(SGX_1_9_MAJOR_VERSION,SGX_1_9_MINOR_VERSION ), + META_DATA_MAKE_VERSION(SGX_1_5_MAJOR_VERSION,SGX_1_5_MINOR_VERSION ), + 0 }; - uint32_t loop_idx; + uint64_t *pmetadata_version = &supported_metadata_version_list[0]; + +#ifndef SE_SIM + EnclaveCreatorHW *enclave_creator = static_cast(get_enclave_creator()); + if (!(enclave_creator->is_cpu_edmm()) || !(enclave_creator->is_driver_compatible())) + { + // cannot support EDMM, adjust the possibly highest metadata version supported + pmetadata_version = &supported_metadata_version_list[1]; + } +#else + //for simulation, use the metadata of 1.9 + pmetadata_version = &supported_metadata_version_list[1]; +#endif //scan multiple metadata list in sgx_metadata section - for (loop_idx = 0; loop_idx < (uint32_t)(sizeof(supported_metadata_version_list)/sizeof(supported_metadata_version_list[0])); loop_idx ++) + for (; *pmetadata_version != 0; pmetadata_version++) { meta_rva = parser->get_metadata_offset(); //scan multiple metadata list in sgx_metadata section do { *metadata = GET_PTR(metadata_t, base_addr, meta_rva); + if(metadata == NULL) + { + return SGX_ERROR_INVALID_METADATA; + } if((*metadata)->magic_num != METADATA_MAGIC) break; //check metadata version - if(supported_metadata_version_list[loop_idx] == (*metadata)->version) + if(*pmetadata_version == (*metadata)->version) goto find_metadata; //find metadata if(0 == (*metadata)->size) @@ -130,13 +151,35 @@ static sgx_status_t get_metadata(BinParser *parser, const int debug, metadata_t }while(1); } - if(loop_idx >= (uint32_t)(sizeof(supported_metadata_version_list)/sizeof(supported_metadata_version_list[0]))) + if(*pmetadata_version == 0) return SGX_ERROR_INVALID_METADATA; find_metadata: return (sgx_status_t)get_enclave_creator()->get_misc_attr(sgx_misc_attr, *metadata, NULL, debug); } + +#define MAX_LEN 256 +static bool is_SGX_DBG_OPTIN_variable_set() +{ + const char sgx_dbg_optin[] = "SGX_DBG_OPTIN"; + const char sgx_dbg_optin_expect_val[] = "1"; + char *sgx_dbg_optin_val = getenv(sgx_dbg_optin); + + if(sgx_dbg_optin_val == NULL) + { + return false; + } + size_t expect_len = strnlen_s(sgx_dbg_optin_expect_val, MAX_LEN); + size_t len = strnlen_s(sgx_dbg_optin_val, MAX_LEN); + if(len != expect_len || strncmp(sgx_dbg_optin_expect_val, sgx_dbg_optin_val, expect_len) != 0) + { + return false; + } + return true; +} + + static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadata_t *metadata, se_file_t& file, const bool debug, SGXLaunchToken *lc, le_prd_css_file_t *prd_css_file, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr) { // The "parser" will be registered into "loader" and "loader" will be registered into "enclave". @@ -152,13 +195,21 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat } CEnclave* enclave = new CEnclave(loader); + uint32_t enclave_version = SDK_VERSION_1_5; + // metadata->version has already been validated during load_encalve_ex() + if (metadata->version == META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION)) + enclave_version = SDK_VERSION_2_0; + else if (metadata->version == META_DATA_MAKE_VERSION(SGX_1_5_MAJOR_VERSION,SGX_1_5_MINOR_VERSION)) + enclave_version = SDK_VERSION_1_5; // initialize the enclave object ret = enclave->initialize(file, loader.get_enclave_id(), const_cast(loader.get_start_addr()), metadata->enclave_size, - metadata->tcs_policy); + metadata->tcs_policy, + enclave_version, + metadata->tcs_min_pool); if (ret != SGX_SUCCESS) { @@ -167,12 +218,6 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat return ret; } - std::vector tcs_list = loader.get_tcs_list(); - for (unsigned idx = 0; idx < tcs_list.size(); ++idx) - { - enclave->add_thread(tcs_list[idx]); - SE_TRACE(SE_TRACE_DEBUG, "add tcs %p\n", tcs_list[idx]); - } // It is accurate to get debug flag from secs enclave->set_dbg_flag(!!(loader.get_secs().attributes.flags & SGX_FLAGS_DEBUG)); @@ -185,31 +230,39 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat //mode init_enclave will rely on CEnclavePool to get Enclave instance. if (FALSE == CEnclavePool::instance()->add_enclave(enclave)) { - ret = SGX_ERROR_UNEXPECTED; - goto fail; + loader.destroy_enclave(); + delete enclave; + return SGX_ERROR_UNEXPECTED; } + std::vector> tcs_list = loader.get_tcs_list(); + for (unsigned idx = 0; idx < tcs_list.size(); ++idx) + { + enclave->add_thread(tcs_list[idx].first, tcs_list[idx].second); + SE_TRACE(SE_TRACE_DEBUG, "add tcs %p\n", tcs_list[idx].first); + } + if(debug) debug_info->enclave_type |= ET_DEBUG; if (!(get_enclave_creator()->use_se_hw())) debug_info->enclave_type |= ET_SIM; - bool isVTuneProfiling; - if(debug || !(get_enclave_creator()->use_se_hw())) { - SE_TRACE(SE_TRACE_DEBUG, "Debug enclave. Checking if VTune is profiling\n"); + SE_TRACE(SE_TRACE_DEBUG, "Debug enclave. Checking if VTune is profiling or SGX_DBG_OPTIN is set\n"); __itt_init_ittlib(NULL, __itt_group_none); - + bool isVTuneProfiling; if(__itt_get_ittapi_global()->api_initialized && __itt_get_ittapi_global()->lib) isVTuneProfiling = true; else isVTuneProfiling = false; - if(isVTuneProfiling) + bool is_SGX_DBG_OPTIN_set = false; + is_SGX_DBG_OPTIN_set = is_SGX_DBG_OPTIN_variable_set(); + if (isVTuneProfiling || is_SGX_DBG_OPTIN_set) { - SE_TRACE(SE_TRACE_DEBUG, "VTune is profiling\n"); + SE_TRACE(SE_TRACE_DEBUG, "VTune is profiling or SGX_DBG_OPTIN is set\n"); bool thread_updated; thread_updated = enclave->update_debug_flag(1); @@ -223,23 +276,26 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat SE_TRACE(SE_TRACE_DEBUG, "Updated debug OPTIN bit\n"); } - uint64_t enclave_start_addr; - uint64_t enclave_end_addr; - const char* enclave_path; - enclave_start_addr = (uint64_t) loader.get_start_addr(); - enclave_end_addr = enclave_start_addr + (uint64_t) metadata->enclave_size; + if (isVTuneProfiling) + { + uint64_t enclave_start_addr; + uint64_t enclave_end_addr; + const char* enclave_path; + enclave_start_addr = (uint64_t) loader.get_start_addr(); + enclave_end_addr = enclave_start_addr + (uint64_t) metadata->enclave_size; - SE_TRACE(SE_TRACE_DEBUG, "Invoking VTune's module mapping API __itt_module_load \n"); - SE_TRACE(SE_TRACE_DEBUG, "Enclave_start_addr==0x%llx\n", enclave_start_addr); - SE_TRACE(SE_TRACE_DEBUG, "Enclave_end_addr==0x%llx\n", enclave_end_addr); + SE_TRACE(SE_TRACE_DEBUG, "Invoking VTune's module mapping API __itt_module_load \n"); + SE_TRACE(SE_TRACE_DEBUG, "Enclave_start_addr==0x%llx\n", enclave_start_addr); + SE_TRACE(SE_TRACE_DEBUG, "Enclave_end_addr==0x%llx\n", enclave_end_addr); - enclave_path = (const char*)file.name; - SE_TRACE(SE_TRACE_DEBUG, "Enclave_path==%s\n", enclave_path); - __itt_module_load((void*)enclave_start_addr, (void*) enclave_end_addr, enclave_path); + enclave_path = (const char*)file.name; + SE_TRACE(SE_TRACE_DEBUG, "Enclave_path==%s\n", enclave_path); + __itt_module_load((void*)enclave_start_addr, (void*) enclave_end_addr, enclave_path); + } } else { - SE_TRACE(SE_TRACE_DEBUG, "VTune is not profiling. Debug OPTIN bit not set and API to do module mapping not invoked\n"); + SE_TRACE(SE_TRACE_DEBUG, "VTune is not profiling and SGX_DBG_OPTIN is not set. TCS Debug OPTIN bit not set and API to do module mapping not invoked\n"); } } @@ -249,6 +305,18 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat //generate load debug event after EINIT generate_enclave_debug_event(URTS_EXCEPTION_POSTINITENCLAVE, debug_info); + if (get_enclave_creator()->is_EDMM_supported(loader.get_enclave_id())) + { + layout_t *layout_start = GET_PTR(layout_t, metadata, metadata->dirs[DIR_LAYOUT].offset); + layout_t *layout_end = GET_PTR(layout_t, metadata, metadata->dirs[DIR_LAYOUT].offset + metadata->dirs[DIR_LAYOUT].size); + if (SGX_SUCCESS != (ret = loader.post_init_action(layout_start, layout_end, 0))) + { + SE_TRACE(SE_TRACE_ERROR, "trim range error.\n"); + sgx_status_t status = SGX_SUCCESS; + CEnclavePool::instance()->remove_enclave(loader.get_enclave_id(), status); + goto fail; + } + } //call trts to do some intialization if(SGX_SUCCESS != (ret = get_enclave_creator()->initialize(loader.get_enclave_id()))) @@ -258,7 +326,33 @@ static int __create_enclave(BinParser &parser, uint8_t* base_addr, const metadat goto fail; } + if (get_enclave_creator()->is_EDMM_supported(loader.get_enclave_id())) + { + + layout_t *layout_start = GET_PTR(layout_t, metadata, metadata->dirs[DIR_LAYOUT].offset); + layout_t *layout_end = GET_PTR(layout_t, metadata, metadata->dirs[DIR_LAYOUT].offset + metadata->dirs[DIR_LAYOUT].size); + if (SGX_SUCCESS != (ret = loader.post_init_action_commit(layout_start, layout_end, 0))) + { + SE_TRACE(SE_TRACE_ERROR, "trim page commit error.\n"); + sgx_status_t status = SGX_SUCCESS; + CEnclavePool::instance()->remove_enclave(loader.get_enclave_id(), status); + goto fail; + } + } + //fill tcs mini pool + if (get_enclave_creator()->is_EDMM_supported(loader.get_enclave_id())) + { + ret = enclave->fill_tcs_mini_pool_fn(); + if (ret != SGX_SUCCESS) + { + SE_TRACE(SE_TRACE_ERROR, "fill_tcs_mini_pool error.\n"); + sgx_status_t status = SGX_SUCCESS; + CEnclavePool::instance()->remove_enclave(loader.get_enclave_id(), status); + goto fail; + } + } + if(SGX_SUCCESS != (ret = loader.set_memory_protection())) { sgx_status_t status = SGX_SUCCESS; @@ -335,6 +429,10 @@ sgx_status_t _create_enclave(const bool debug, se_file_handle_t pfile, se_file_t } #endif + // init xave global variables for xsave/xrstor + init_xsave_info(); + + //Need to set the whole misc_attr instead of just secs_attr. do { ret = __create_enclave(parser, mh->base_addr, metadata, file, debug, lc, prd_css_file, enclave_id, @@ -342,9 +440,12 @@ sgx_status_t _create_enclave(const bool debug, se_file_handle_t pfile, se_file_t //SGX_ERROR_ENCLAVE_LOST caused by initializing enclave while power transition occurs } while(SGX_ERROR_ENCLAVE_LOST == ret); - if(SE_ERROR_INVALID_LAUNCH_TOKEN == ret || SGX_ERROR_INVALID_CPUSVN == ret) + if(SGX_ERROR_INVALID_CPUSVN == ret) ret = SGX_ERROR_UNEXPECTED; + if(SE_ERROR_INVALID_LAUNCH_TOKEN == ret) + ret = SGX_ERROR_INVALID_LAUNCH_TOKEN; + // The launch token is updated, so the SE_INVALID_MEASUREMENT is only caused by signature. if(SE_ERROR_INVALID_MEASUREMENT == ret) ret = SGX_ERROR_INVALID_SIGNATURE; @@ -372,6 +473,18 @@ clean_return: extern "C" sgx_status_t sgx_destroy_enclave(const sgx_enclave_id_t enclave_id) { + { + CEnclave* enclave = CEnclavePool::instance()->ref_enclave(enclave_id); + + if(enclave) + { + debug_enclave_info_t *debug_info = const_cast(enclave->get_debug_info()); + generate_enclave_debug_event(URTS_EXCEPTION_PREREMOVEENCLAVE, debug_info); + enclave->ecall(ECMD_UNINIT_ENCLAVE, NULL, NULL); + CEnclavePool::instance()->unref_enclave(enclave); + } + } + sgx_status_t status = SGX_SUCCESS; CEnclave* enclave = CEnclavePool::instance()->remove_enclave(enclave_id, status); diff --git a/sgx-jvm/linux-sgx/psw/urts/urts_xsave.cpp b/sgx-jvm/linux-sgx/psw/urts/urts_xsave.cpp index 50cd315dea..7c1937ecb4 100644 --- a/sgx-jvm/linux-sgx/psw/urts/urts_xsave.cpp +++ b/sgx-jvm/linux-sgx/psw/urts/urts_xsave.cpp @@ -33,16 +33,14 @@ #include "xsave.h" #include "util.h" #include "se_detect.h" -#include "sgx_attributes.h" +#include "cpuid.h" + #define XFRM_YMM_BITMASK 0x00000004 -// save_and_clean_xfeature_regs() -// do fwait, fxsave, and then clear the upper bits of YMM regs before executing EENTER. -// Parameters: -// buffer - if the pointer is not NULL, save the CPU state to the buffer -// Return Value: -// none +uint32_t g_xsave_enabled = 0; + +extern "C" void set_xsave_info(int xsave_size, int flag); @@ -51,41 +49,22 @@ -void save_and_clean_xfeature_regs(uint8_t *buffer) + + +// init_xsave_info +void init_xsave_info() { - // XCR0 is not supposed to be changed. So query it once. - static uint64_t xcr0 = 0; - if(xcr0 == 0) + int xsave_size = FXSAVE_SIZE; + uint64_t xcr0 = 0; + if(try_read_xcr0(&xcr0)) { - if(false == try_read_xcr0(&xcr0)) - { - xcr0 = SGX_XFRM_LEGACY; - } - } - - // do fwait to flush the float-point exceptions - do_fwait(); - - // do fxsave to save the CPU state before ecall - // no need to save the CPU state before oret - if(buffer != 0) - { - uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); - do_fxsave(buf); - } - - // clean the upper bits of the YMM regs - if(xcr0 & XFRM_YMM_BITMASK) - { - do_vzeroupper(); + // CPUID function 0DH, sub-function 0 + // EBX enums the size (in bytes) required by XSAVE for all the components currently set in XCR0 + int cpu_info[4] = {0}; + __cpuid(cpu_info, 0xD); + xsave_size = cpu_info[1]; + g_xsave_enabled = 1; } + set_xsave_info(xsave_size, (xcr0 & XFRM_YMM_BITMASK) ? 1 : 0); } -void restore_xfeature_regs(const uint8_t *buffer) -{ - if (buffer) - { - uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); - do_fxrstor(buf); - } -} diff --git a/sgx-jvm/linux-sgx/sdk/Makefile b/sgx-jvm/linux-sgx/sdk/Makefile index c7aa57f6c0..48ff368e18 100644 --- a/sgx-jvm/linux-sgx/sdk/Makefile +++ b/sgx-jvm/linux-sgx/sdk/Makefile @@ -36,6 +36,22 @@ else include Makefile.source endif +# SDK requires prebuilt IPP libraries. +CHECK_OPT := +ifeq ("$(wildcard $(LINUX_EXTERNAL_DIR)/ippcp_internal/inc)", "") +CHECK_OPT := opt_check_failed +endif + +.PHONY: opt_check_failed +opt_check_failed: + @echo "ERROR: Please run 'download_prebuilt.sh' to download the prebuilt optimized libraries before compiling." + @echo "Exiting......" + @exit -2 + +.PHONY: all +all: $(CHECK_OPT) + $(MAKE) components + .PHONY: rebuild rebuild: $(MAKE) clean diff --git a/sgx-jvm/linux-sgx/sdk/Makefile.opt_lib b/sgx-jvm/linux-sgx/sdk/Makefile.opt_lib index 5a979f320b..531cdf7026 100644 --- a/sgx-jvm/linux-sgx/sdk/Makefile.opt_lib +++ b/sgx-jvm/linux-sgx/sdk/Makefile.opt_lib @@ -40,7 +40,6 @@ # - tcrypto: libsgx_tcrypto.a # - tkey_exchange: libsgx_tkey_exchange.a # - tprotected_fs: libsgx_tprotected_fs.a -# - tsetjmp: libsgx_tsetjmp.a # - tcmalloc: libsgx_tcmalloc.a # - Untrtusted libraries # - ukey_exchange: libsgx_ukey_exchange.a @@ -53,7 +52,7 @@ # - signtool: sgx_sign # - edger8r: sgx_edger8r # - Simulation libraries and tools -# - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.a, libsgx_uae_service_sim.a, sgx_config_cpusvn +# - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.so, libsgx_uae_service_sim.so, sgx_config_cpusvn # include ../buildenv.mk @@ -62,28 +61,12 @@ LIBTLIBCXX := $(BUILD_DIR)/libsgx_tstdcxx.a LIBTCXX := $(BUILD_DIR)/libsgx_tcxx.a LIBTSE := $(BUILD_DIR)/libsgx_tservice.a -CHECK_OPT := -ifeq ("$(wildcard $(LINUX_EXTERNAL_DIR)/ippcp_internal/inc)", "") -CHECK_OPT := opt_check_failed -endif - -.PHONY: opt_check_failed -opt_check_failed: - @echo "ERROR: Please run 'download_prebuilt.sh' to download the prebuilt optimized libraries before compiling." - @echo "Exiting......" - @exit -2 - - -.PHONY: all -all: $(CHECK_OPT) - $(MAKE) components - .PHONY: components -components: tstdc tstdcxx tcxx tservice trts tcrypto tkey_exchange ukey_exchange tprotected_fs uprotected_fs ptrace sample_crypto libcapable simulation signtool edger8r tsetjmp tcmalloc +components: tstdc tstdcxx tcxx tservice trts tcrypto tkey_exchange ukey_exchange tprotected_fs uprotected_fs ptrace sample_crypto libcapable simulation signtool edger8r tcmalloc # --------------------------------------------------- # tstdc -# includes: tlibc, tlibthread, compiler-rt +# includes: tlibc, tlibthread, compiler-rt, tsafecrt # libimf, libirc, libsvml, etc. # --------------------------------------------------- .PHONY: tstdc @@ -101,27 +84,41 @@ endif LIBIRC_NAME := libirc.a -$(LIBTLIBC): tlibthread compiler-rt $(LIBM_PATH)/libimf.a $(LIBIRC_PATH)/$(LIBIRC_NAME) $(SVML_PATH)/libsvml.a +$(LIBTLIBC): tlibthread compiler-rt tsafecrt tsetjmp $(LIBM_PATH)/libimf.a $(LIBIRC_PATH)/$(LIBIRC_NAME) $(SVML_PATH)/libsvml.a $(MAKE) -C tlibc/ -j4 2> /dev/null - @$(MKDIR) $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread - @$(RM) -f $(BUILD_DIR)/.libimf/* $(BUILD_DIR)/.libirc/* $(BUILD_DIR)/.libsvml/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/* + @$(MKDIR) $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc \ + $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp + @$(RM) -f $(BUILD_DIR)/.libimf/* $(BUILD_DIR)/.libirc/* $(BUILD_DIR)/.libsvml/* $(BUILD_DIR)/.tlibc/* \ + $(BUILD_DIR)/.tlibthread/* $(BUILD_DIR)/.tsafecrt/* $(BUILD_DIR)/.tsetjmp/* @cd $(BUILD_DIR)/.libimf && $(AR) x $(LIBM_PATH)/libimf.a @cd $(BUILD_DIR)/.libirc && $(AR) x $(LIBIRC_PATH)/$(LIBIRC_NAME) @cd $(BUILD_DIR)/.libsvml && $(AR) x $(SVML_PATH)/libsvml.a @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a + @cd $(BUILD_DIR)/.tsafecrt && $(AR) x $(LINUX_SDK_DIR)/tsafecrt/libsgx_tsafecrt.a + @cd $(BUILD_DIR)/.tsetjmp && $(AR) x $(LINUX_SDK_DIR)/tsetjmp/libsgx_tsetjmp.a $(CP) compiler-rt/libcompiler-rt.a $@ - $(AR) rsD $@ $(BUILD_DIR)/.libimf/*.o $(BUILD_DIR)/.libirc/*.o $(BUILD_DIR)/.libsvml/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o - @$(RM) -rf $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread + $(AR) rsD $@ $(BUILD_DIR)/.libimf/*.o $(BUILD_DIR)/.libirc/*.o $(BUILD_DIR)/.libsvml/*.o $(BUILD_DIR)/.tlibc/*.o \ + $(BUILD_DIR)/.tlibthread/*.o $(BUILD_DIR)/.tsafecrt/*.o $(BUILD_DIR)/.tsetjmp/*.o + @$(RM) -rf $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc \ + $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp .PHONY: tlibthread tlibthread: $(MAKE) -C tlibthread/ +.PHONY: tsafecrt +tsafecrt: + $(MAKE) -C tsafecrt/ + .PHONY: compiler-rt compiler-rt: $(MAKE) -C compiler-rt/ 2> /dev/null +.PHONY: tsetjmp +tsetjmp: + $(MAKE) -C tsetjmp/ + # --------------------------------------------------- # tstdcxx # includes: cpprt, tlibstdcxx @@ -208,10 +205,6 @@ tcrypto: tkey_exchange: edger8r $(MAKE) -C tkey_exchange -.PHONY: tsetjmp -tsetjmp: - $(MAKE) -C tsetjmp/ - .PHONY: tcmalloc tcmalloc: $(MAKE) -C gperftools/ @@ -280,6 +273,7 @@ clean: $(MAKE) -C tae_service/ clean $(MAKE) -C trts/ clean $(MAKE) -C tsetjmp/ clean + $(MAKE) -C tsafecrt/ clean $(MAKE) -C gperftools/ clean $(MAKE) -C tlibcrypto/ clean $(MAKE) -C tkey_exchange/ clean diff --git a/sgx-jvm/linux-sgx/sdk/Makefile.source b/sgx-jvm/linux-sgx/sdk/Makefile.source index 1140f3afee..e85e693166 100644 --- a/sgx-jvm/linux-sgx/sdk/Makefile.source +++ b/sgx-jvm/linux-sgx/sdk/Makefile.source @@ -40,7 +40,6 @@ # - tcrypto: libsgx_tcrypto.a # - tkey_exchange: libsgx_tkey_exchange.a # - tprotected_fs: libsgx_tprotected_fs.a -# - tsetjmp: libsgx_tsetjmp.a # - tcmalloc: libsgx_tcmalloc.a # - Untrtusted libraries # - ukey_exchange: libsgx_ukey_exchange.a @@ -53,7 +52,7 @@ # - signtool: sgx_sign # - edger8r: sgx_edger8r # - Simulation libraries and tools -# - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.a, libsgx_uae_service_sim.a, sgx_config_cpusvn +# - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.so, libsgx_uae_service_sim.so, sgx_config_cpusvn # include ../buildenv.mk @@ -62,31 +61,36 @@ LIBTLIBCXX := $(BUILD_DIR)/libsgx_tstdcxx.a LIBTCXX := $(BUILD_DIR)/libsgx_tcxx.a LIBTSE := $(BUILD_DIR)/libsgx_tservice.a -.PHONY: all -all: tstdc tstdcxx tcxx tservice trts tcrypto tkey_exchange ukey_exchange tprotected_fs uprotected_fs ptrace sample_crypto libcapable simulation signtool edger8r tsetjmp tcmalloc +.PHONY: components +components: tstdc tstdcxx tcxx tservice trts tcrypto tkey_exchange ukey_exchange tprotected_fs uprotected_fs ptrace sample_crypto libcapable simulation signtool edger8r tcmalloc # --------------------------------------------------- # tstdc -# includes: tlibc, libm, tlibthread, compiler-rt +# includes: tlibc, libm, tlibthread, compiler-rt, tsafecrt # --------------------------------------------------- .PHONY: tstdc tstdc: $(LIBTLIBC) -$(LIBTLIBC): tlibthread compiler-rt sgx_libm +$(LIBTLIBC): tlibthread compiler-rt tsafecrt sgx_libm tsetjmp $(MAKE) -C tlibc/ -j4 2> /dev/null - @$(MKDIR) $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread - @$(RM) -f $(BUILD_DIR)/.libm/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/* + @$(MKDIR) $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp + @$(RM) -f $(BUILD_DIR)/.libm/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/* $(BUILD_DIR)/.tsafecrt/* $(BUILD_DIR)/.tsetjmp/*.o @cd $(BUILD_DIR)/.libm && $(AR) x $(LINUX_EXTERNAL_DIR)/sgx_libm/libm.a @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a + @cd $(BUILD_DIR)/.tsafecrt && $(AR) x $(LINUX_SDK_DIR)/tsafecrt/libsgx_tsafecrt.a + @cd $(BUILD_DIR)/.tsetjmp && $(AR) x $(LINUX_SDK_DIR)/tsetjmp/libsgx_tsetjmp.a $(CP) compiler-rt/libcompiler-rt.a $@ - $(AR) rsD $@ $(BUILD_DIR)/.libm/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o - @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread - + $(AR) rsD $@ $(BUILD_DIR)/.libm/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o $(BUILD_DIR)/.tsafecrt/*.o $(BUILD_DIR)/.tsetjmp/*.o + @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp .PHONY: tlibthread tlibthread: $(MAKE) -C tlibthread/ +.PHONY: tsafecrt +tsafecrt: + $(MAKE) -C tsafecrt/ + .PHONY: compiler-rt compiler-rt: $(MAKE) -C compiler-rt/ 2> /dev/null @@ -102,6 +106,10 @@ endif sgx_libm: $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 2> /dev/null +.PHONY: tsetjmp +tsetjmp: + $(MAKE) -C tsetjmp/ + # --------------------------------------------------- # tstdcxx # includes: cpprt, tlibstdcxx @@ -189,10 +197,6 @@ tcrypto: tkey_exchange: edger8r $(MAKE) -C tkey_exchange -.PHONY: tsetjmp -tsetjmp: - $(MAKE) -C tsetjmp/ - .PHONY: tcmalloc tcmalloc: $(MAKE) -C gperftools/ @@ -223,7 +227,6 @@ sample_crypto: # --------------------------------------------------- # standalone, untrusted libraries # --------------------------------------------------- - .PHONY: libcapable libcapable: $(MAKE) -C libcapable/linux/ @@ -263,6 +266,7 @@ clean: $(MAKE) -C tae_service/ clean $(MAKE) -C trts/ clean $(MAKE) -C tsetjmp/ clean + $(MAKE) -C tsafecrt/ clean $(MAKE) -C gperftools/ clean $(MAKE) -C tlibcrypto/ clean $(MAKE) -C tkey_exchange/ clean diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/Makefile b/sgx-jvm/linux-sgx/sdk/cpprt/Makefile index 51e525c762..ff5efd9466 100644 --- a/sgx-jvm/linux-sgx/sdk/cpprt/Makefile +++ b/sgx-jvm/linux-sgx/sdk/cpprt/Makefile @@ -86,8 +86,10 @@ libunwind: .PHONY: clean clean: - @-$(MAKE) -C linux/libunwind distclean @$(RM) $(OBJS) $(CPPRT) +ifeq ("$(shell test -f linux/libunwind/Makefile && echo Makefile exists)", "Makefile exists") + @-$(MAKE) -C linux/libunwind distclean +endif @$(RM) -r linux/libunwind/INSTALL \ linux/libunwind/Makefile.in \ linux/libunwind/aclocal.m4 \ diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/linux/atomic.h b/sgx-jvm/linux-sgx/sdk/cpprt/linux/atomic.h index 8086e66889..c4faaf28ec 100644 --- a/sgx-jvm/linux-sgx/sdk/cpprt/linux/atomic.h +++ b/sgx-jvm/linux-sgx/sdk/cpprt/linux/atomic.h @@ -10,7 +10,7 @@ */ #if __has_feature(cxx_atomic) #define ATOMIC_SWAP(addr, val)\ - __atomic_exchange(addr, val, __ATOMIC_ACQ_REL) + __atomic_exchange_n(addr, val, __ATOMIC_ACQ_REL) #elif __has_builtin(__sync_swap) #define ATOMIC_SWAP(addr, val)\ __sync_swap(addr, val) @@ -21,7 +21,7 @@ #if __has_feature(cxx_atomic) #define ATOMIC_LOAD(addr)\ - __atomic_load(addr, __ATOMIC_ACQUIRE) + __atomic_load_n(addr, __ATOMIC_ACQUIRE) #else #define ATOMIC_LOAD(addr)\ (__sync_synchronize(), *addr) diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/linux/cxa_finalize.c b/sgx-jvm/linux-sgx/sdk/cpprt/linux/cxa_finalize.c deleted file mode 100644 index d6681c3763..0000000000 --- a/sgx-jvm/linux-sgx/sdk/cpprt/linux/cxa_finalize.c +++ /dev/null @@ -1,8 +0,0 @@ -void __cxa_finalize(void *d ) { (void)d; }; - -extern void* __dso_handle; - -__attribute((destructor)) -static void cleanup(void) { - __cxa_finalize(&__dso_handle); -} diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete1.cpp b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete1.cpp index da8927ab94..65f9a48f93 100644 --- a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete1.cpp +++ b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete1.cpp @@ -37,7 +37,7 @@ #include "internal/se_cdefs.h" //deallocate the memory block pointed by ptr (if not-null) -SGX_WEAK void SGXAPI operator delete (void* ptr) throw () +SGX_WEAK void SGXAPI operator delete (void* ptr) { free(ptr); } diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete4.cpp b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete4.cpp index 2b729ad3a0..b1d7261464 100644 --- a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete4.cpp +++ b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/delete4.cpp @@ -37,7 +37,7 @@ #include "internal/se_cdefs.h" //Deallocate storage space of array -SGX_WEAK void SGXAPI operator delete[] (void* ptr) +SGX_WEAK void SGXAPI operator delete[] (void* ptr) { operator delete(ptr); } diff --git a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/new2.cpp b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/new2.cpp index 793b92a1db..21847c5346 100644 --- a/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/new2.cpp +++ b/sgx-jvm/linux-sgx/sdk/cpprt/memory_manage/new2.cpp @@ -37,7 +37,7 @@ //nothrow version. //on failure it returns a null pointer instead of throwing an exception. -SGX_WEAK void* SGXAPI operator new (size_t dwBytes, const std::nothrow_t& nothrow_constant) +SGX_WEAK void* SGXAPI operator new (size_t dwBytes, const std::nothrow_t& nothrow_constant) { UNUSED(nothrow_constant); diff --git a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/Makefile b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/Makefile index e0951f2fbd..0c1bfb4d6b 100644 --- a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/Makefile @@ -46,7 +46,9 @@ endif LDLIBS += -ldl ifdef DEBUG - CFLAGS += -g -DSE_DEBUG=1 + CFLAGS += -g -DSE_DEBUG=1 -ffunction-sections -fdata-sections +else + CFLAGS += -O2 -D_FORTIFY_SOURCE=2 -ffunction-sections -fdata-sections endif OBJ1 := se_memory.o se_trace.o @@ -74,7 +76,7 @@ install: $(TARGET) | $(GDB_OUT_DIR) $(GDB_PLUGINS_FILES) $(CP) $(TARGET) $(BUILD_DIR) $(TARGET): $(OBJS) - $(CC) -shared -o $@ $^ $(LDLIBS) $(CFLAGS) -Wl,--gc-sections + $(CC) -shared -o $@ $^ $(LDLIBS) $(CFLAGS) $(COMMON_LDFLAGS) -Wl,--gc-sections $(OBJ1): %.o: $(COMMON_DIR)/src/%.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ diff --git a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py index d606ea4dd3..b31c373643 100755 --- a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py +++ b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py @@ -37,6 +37,7 @@ import os.path from ctypes import create_string_buffer import load_symbol_cmd import sgx_emmt +import ctypes # Calculate the bit mode of current debuggee project SIZE = gdb.parse_and_eval("sizeof(long)") @@ -216,27 +217,51 @@ class enclave_info(object): high = mid -1 return page_index - def get_peak_stack_used(self): """Get the peak value of the stack used""" peak_stack_used = 0 - gen = (addr for addr in self.stack_addr_list if addr != 0) - for stack_addr in gen: - page_index = self.find_boundary_page_index(stack_addr, self.stack_size) - if page_index == (self.stack_size)/PAGE_SIZE - 1: - continue - elif page_index == -2: + for tcs_addr in self.tcs_addr_list: + tcs_str = read_from_memory(tcs_addr, ENCLAVE_TCS_INFO_SIZE) + if tcs_str == None: return -1 - else: - string = read_from_memory(stack_addr + (page_index+1) * PAGE_SIZE, PAGE_SIZE) - if string == None: + tcs_tuple = struct.unpack_from(TCS_INFO_FMT, tcs_str) + offset = tcs_tuple[7] + if SIZE == 4: + td_fmt = '20I' + elif SIZE == 8: + td_fmt = '20Q' + td_str = read_from_memory(self.start_addr+offset, (20*SIZE)) + if td_str == None: + return -1 + td_tuple = struct.unpack_from(td_fmt, td_str) + + stack_commit_addr = td_tuple[19] + stack_base_addr = td_tuple[2] + stack_limit_addr = td_tuple[3] + + stack_usage = 0 + if stack_commit_addr > stack_limit_addr: + stack_base_addr_page_align = (stack_base_addr + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1) + stack_usage = stack_base_addr_page_align - stack_commit_addr + elif stack_limit_addr != 0: + page_index = self.find_boundary_page_index(stack_limit_addr, self.stack_size) + if page_index == (self.stack_size)/PAGE_SIZE - 1: + continue + elif page_index == -2: return -1 - for i in range(0, len(string)): - temp = struct.unpack_from("B", string, i)[0] - if (self.internal_compare(temp, 0xcc)) != 0: - if peak_stack_used < (self.stack_size - (page_index+1) * PAGE_SIZE - i): - peak_stack_used = self.stack_size- (page_index+1) * PAGE_SIZE - i - break # go to the top for loop + else: + string = read_from_memory(stack_limit_addr + (page_index+1) * PAGE_SIZE, PAGE_SIZE) + if string == None: + return -1 + for i in range(0, len(string)): + temp = struct.unpack_from("B", string, i)[0] + if (self.internal_compare(temp, 0xcc)) != 0: + stack_usage = self.stack_size - (page_index+1) * PAGE_SIZE - i + break + + if peak_stack_used < stack_usage: + peak_stack_used = stack_usage + return peak_stack_used def show_emmt(self): @@ -295,6 +320,13 @@ class enclave_info(object): except: return -1 + def append_tcs_list(self, tcs_addr): + for tcs_tmp in self.tcs_addr_list: + if tcs_tmp == tcs_addr: + return 0 + self.tcs_addr_list.append(tcs_addr) + return 0 + def retrieve_enclave_info(info_addr = 0): """retrieve one enclave info""" # Step 1: find the enclave info address @@ -333,7 +365,6 @@ def retrieve_enclave_info(info_addr = 0): print ("Error: tcs info address = {0:x}".format(tcs_info_addr)) return None - stacksize = 0; while tcs_info_addr is not 0: tcs_info_str = read_from_memory(tcs_info_addr, 3*SIZE) if tcs_info_str == None: @@ -360,10 +391,9 @@ def retrieve_enclave_info(info_addr = 0): #print ("thread_info:%#x, last_sp:%#x, stack_base_addr:%#x, stack_limit_addr:%#x" \ # % (td_tuple[0], td_tuple[1], td_tuple[2], td_tuple[3])); - if td_tuple[2] != td_tuple[3]: - #stack size = ROUND_TO_PAGE(stack_base_addr - stack_limit_addr) since we have - #a static stack whose size is smaller than PAGE_SIZE - stacksize = (td_tuple[2] - td_tuple[3] + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1) + #stack size = ROUND_TO_PAGE(stack_base_addr - stack_limit_addr) since we have + #a static stack whose size is smaller than PAGE_SIZE + stacksize = (td_tuple[2] - td_tuple[3] + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1) stack_addr_list.append(td_tuple[3]) #use stack limit addr as stack base address tcs_addr_list.append(tcs_info_tuple[1]) tcs_info_addr = tcs_info_tuple[0] @@ -394,8 +424,10 @@ def retrieve_enclave_info(info_addr = 0): while last_trusted_ocall_frame != td_tuple[2]: if SIZE == 4: oc_fmt = '20I' + ret_addr_of_fmt = 'I' elif SIZE == 8: oc_fmt = '20Q' + ret_addr_of_fmt = 'Q' oc_str = read_from_memory(last_trusted_ocall_frame, 20*SIZE) if oc_str == None: @@ -413,11 +445,16 @@ def retrieve_enclave_info(info_addr = 0): #ocall_frame.pre_last_frame = 0 #ocall_frame.ret = ocall_context.ocall_ret #ocall_frame.xbp = ocall_context.xbp - gdb_cmd = "set *(uintptr_t *)%#x = 0" %(last_ocall_frame) + xbp = oc_tuple[11] + ret_addr_str = read_from_memory(xbp + SIZE, SIZE) + if ret_addr_str == None: + return None + ret_addr_tuple = struct.unpack_from(ret_addr_of_fmt, ret_addr_str) + gdb_cmd = "set *(uintptr_t *)%#x = 0" %(int(last_ocall_frame)) gdb.execute(gdb_cmd, False, True) - gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(last_ocall_frame+(2*SIZE), oc_tuple[11]) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(last_ocall_frame+(2*SIZE)), xbp) gdb.execute(gdb_cmd, False, True) - gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(last_ocall_frame+(3*SIZE), oc_tuple[19]) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(last_ocall_frame+(3*SIZE)), ret_addr_tuple[0]) gdb.execute(gdb_cmd, False, True) break @@ -529,8 +566,10 @@ class UpdateOcallFrame(gdb.Breakpoint): if SIZE == 4: trusted_of_fmt = '20I' + ret_addr_of_fmt = 'I' elif SIZE == 8: trusted_of_fmt = '20Q' + ret_addr_of_fmt = 'Q' last_sp = td_tuple[1] @@ -539,11 +578,18 @@ class UpdateOcallFrame(gdb.Breakpoint): return False trusted_ocall_frame_tuple = struct.unpack_from(trusted_of_fmt, trusted_ocall_frame) + xbp = trusted_ocall_frame_tuple[11] + + ret_addr_str = read_from_memory(xbp + SIZE, SIZE) + if ret_addr_str == None: + return False + ret_addr_tuple = struct.unpack_from(ret_addr_of_fmt, ret_addr_str) + gdb_cmd = "set *(uintptr_t *)%#x = 0" %(int(ocall_frame)) gdb.execute(gdb_cmd, False, True) - gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(2*SIZE)), trusted_ocall_frame_tuple[11]) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(2*SIZE)), xbp) gdb.execute(gdb_cmd, False, True) - gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(3*SIZE)), trusted_ocall_frame_tuple[19]) + gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(3*SIZE)), ret_addr_tuple[0]) gdb.execute(gdb_cmd, False, True) return False @@ -569,7 +615,37 @@ class UnloadEventBreakpoint(gdb.Breakpoint): if bp_in_urts == True: handle_unload_event() return False + +class GetTCSBreakpoint(gdb.Breakpoint): + def __init__(self): + gdb.Breakpoint.__init__ (self, spec="urts_add_tcs", internal=1) # sgx_add_tcs should be fastcall + def stop(self): + bp_in_urts = is_bp_in_urts() + + if bp_in_urts == True: + if SIZE == 4: + tcs_addr_1 = gdb.parse_and_eval("$eax") + tcs_addr = ctypes.c_uint32(tcs_addr_1).value + elif SIZE == 8: + tcs_addr_1 = gdb.parse_and_eval("$rdi") + tcs_addr = ctypes.c_uint64(tcs_addr_1).value + enclave_info_addr = gdb.parse_and_eval("*(void **)&g_debug_enclave_info_list") + if enclave_info_addr != 0: + node = retrieve_enclave_info(enclave_info_addr) + else: + return False + if node != None: + node.append_tcs_list(tcs_addr) + string = read_from_memory(tcs_addr + 8, 4) + if string == None: + return False + flag = struct.unpack('I', string)[0] + flag |= 1 + gdb_cmd = "set *(unsigned int *)%#x = %#x" %(tcs_addr + 8, flag) + gdb.execute(gdb_cmd, False, True) + return False + def sgx_debugger_init(): print ("detect urts is loaded, initializing") global SIZE @@ -587,6 +663,7 @@ def sgx_debugger_init(): UpdateOcallFrame() LoadEventBreakpoint() UnloadEventBreakpoint() + GetTCSBreakpoint() gdb.events.exited.connect(exit_handler) init_enclaves_debug() diff --git a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/se_ptrace.c b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/se_ptrace.c index 832d186cbd..4d4e869af0 100644 --- a/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/se_ptrace.c +++ b/sgx-jvm/linux-sgx/sdk/debugger_interface/linux/se_ptrace.c @@ -149,7 +149,7 @@ static int get_exec_class(pid_t pid) static inline uint32_t get_ssa_frame_size(pid_t pid, thread_data_t* td) { - uint32_t ssa_frame_size = td->ssa_frame_size; + uint32_t ssa_frame_size = ROUND_TO_PAGE(td->xsave_size) >> SE_PAGE_SHIFT; #ifdef __x86_64__ //on x64, we may debug elf32 enclave, we need refer to different offset in td field. if(ELFCLASS32 == get_exec_class(pid)) diff --git a/sgx-jvm/linux-sgx/sdk/edger8r/linux/Ast.ml b/sgx-jvm/linux-sgx/sdk/edger8r/linux/Ast.ml index 98f650992d..084659c689 100644 --- a/sgx-jvm/linux-sgx/sdk/edger8r/linux/Ast.ml +++ b/sgx-jvm/linux-sgx/sdk/edger8r/linux/Ast.ml @@ -86,15 +86,10 @@ type ptr_attr = { pa_chkptr : bool; (* Whether to generate code to check pointer *) } -type non_ptr_attr = { - npa_enclave_id : bool; -} -let default_non_ptr_attr = { npa_enclave_id = false; } - (* parameter type *) type parameter_type = - | PTVal of atype * non_ptr_attr (* Passed by value *) - | PTPtr of atype * ptr_attr (* Passed by address *) + | PTVal of atype (* Passed by value *) + | PTPtr of atype * ptr_attr (* Passed by address *) type call_conv = CC_CDECL | CC_STDCALL | CC_FASTCALL | CC_NONE @@ -246,7 +241,7 @@ let rec get_tystr (ty: atype) = (* Get the plain `atype' from a `parameter_type'. *) let get_param_atype (pt: parameter_type) = match pt with - | PTVal (t, _) -> t + | PTVal t -> t | PTPtr (t, _) -> t (* Convert attr_value to string *) diff --git a/sgx-jvm/linux-sgx/sdk/edger8r/linux/CodeGen.ml b/sgx-jvm/linux-sgx/sdk/edger8r/linux/CodeGen.ml index 225c3f054a..c4a62ced00 100644 --- a/sgx-jvm/linux-sgx/sdk/edger8r/linux/CodeGen.ml +++ b/sgx-jvm/linux-sgx/sdk/edger8r/linux/CodeGen.ml @@ -31,7 +31,6 @@ open Printf open Util (* for failwithf *) -open List (* -------------------------------------------------------------------- * We first introduce a `parse_enclave_ast' function (see below) to @@ -140,7 +139,7 @@ let is_foreign_array (pt: Ast.parameter_type) = let is_naked_func (fd: Ast.func_decl) = fd.Ast.rtype = Ast.Void && fd.Ast.plist = [] -(* +(* * If user only defined a trusted function w/o neither parameter nor * return value, the generated trusted bridge will not call any tRTS * routines. If the real trusted function doesn't call tRTS function @@ -193,7 +192,6 @@ let conv_array_to_ptr (pd: Ast.pdecl): Ast.pdecl = let retval_name = "retval" let retval_declr = { Ast.identifier = retval_name; Ast.array_dims = []; } let eid_name = "eid" -let enclave_id_name = "enclave_id" let ms_ptr_name = "pms" let ms_struct_val = "ms" let mk_ms_member_name (pname: string) = "ms_" ^ pname @@ -211,8 +209,8 @@ let mk_ubridge_name (file_shortnm: string) (funcname: string) = sprintf "%s_%s" file_shortnm funcname let mk_ubridge_proto (file_shortnm: string) (funcname: string) = - sprintf "static sgx_status_t SGX_CDECL %s(sgx_enclave_id_t %s, void* %s)" - (mk_ubridge_name file_shortnm funcname) enclave_id_name ms_ptr_name + sprintf "static sgx_status_t SGX_CDECL %s(void* %s)" + (mk_ubridge_name file_shortnm funcname) ms_ptr_name (* Common macro definitions. *) let common_macros = "#include /* for size_t */\n\n\ @@ -239,13 +237,6 @@ let get_theader_name (file_shortnm: string) = let get_tsource_name (file_shortnm: string) = !g_trusted_dir ^ separator_str ^ file_shortnm ^ "_t.c" -let filter_non_enclave_id_params (params: Ast.pdecl list) = - filter (fun (p,_) -> - match p with - Ast.PTVal(_, npattr) -> not npattr.Ast.npa_enclave_id - | _ -> true - ) params - (* Construct the string of structure definition *) let mk_struct_decl (fs: string) (name: string) = sprintf "typedef struct %s {\n%s} %s;\n" name fs name @@ -326,7 +317,7 @@ let get_param_tystr (pt: Ast.parameter_type) = (* Generate marshaling structure definition *) let gen_marshal_struct (fd: Ast.func_decl) (errno: string) = let member_list_str = errno ^ - let new_param_list = filter_non_enclave_id_params (List.map conv_array_to_ptr fd.Ast.plist) in + let new_param_list = List.map conv_array_to_ptr fd.Ast.plist in List.fold_left (fun acc (pt, declr) -> acc ^ mk_ms_member_decl pt declr) "" new_param_list in let struct_name = mk_ms_struct_name fd.Ast.fname in @@ -335,7 +326,7 @@ let gen_marshal_struct (fd: Ast.func_decl) (errno: string) = a marshaling struct. *) Ast.Void -> if fd.Ast.plist = [] && errno = "" then "" else mk_struct_decl member_list_str struct_name - | _ -> let rv_str = mk_ms_member_decl (Ast.PTVal(fd.Ast.rtype, Ast.default_non_ptr_attr)) retval_declr + | _ -> let rv_str = mk_ms_member_decl (Ast.PTVal fd.Ast.rtype) retval_declr in mk_struct_decl (rv_str ^ member_list_str) struct_name let gen_ecall_marshal_struct (tf: Ast.trusted_func) = @@ -466,7 +457,7 @@ let gen_entry_table (ec: enclave_content) = *) let gen_tproxy_proto (fd: Ast.func_decl) = let parm_list = - match filter_non_enclave_id_params fd.Ast.plist with + match fd.Ast.plist with [] -> "" | x :: xs -> List.fold_left (fun acc pd -> @@ -543,8 +534,13 @@ let gen_uheader_preemble (guard: string) (inclist: string)= let ms_writer out_chan ec = let ms_struct_ecall = List.map gen_ecall_marshal_struct ec.tfunc_decls in let ms_struct_ocall = List.map gen_ocall_marshal_struct ec.ufunc_decls in - List.iter (fun s -> output_string out_chan (s ^ "\n")) ms_struct_ecall; - List.iter (fun s -> output_string out_chan (s ^ "\n")) ms_struct_ocall + let output_struct s = + match s with + "" -> s + | _ -> sprintf "%s\n" s + in + List.iter (fun s -> output_string out_chan (output_struct s)) ms_struct_ecall; + List.iter (fun s -> output_string out_chan (output_struct s)) ms_struct_ocall (* Generate untrusted header for enclave *) @@ -663,9 +659,7 @@ let add_foreign_array_ptrref else arg let mk_parm_name_ubridge (pt: Ast.parameter_type) (declr: Ast.declarator) = - match pt with - Ast.PTVal(_, attr) when attr.Ast.npa_enclave_id -> enclave_id_name - | _ -> add_foreign_array_ptrref mk_parm_name_raw pt declr + add_foreign_array_ptrref mk_parm_name_raw pt declr let mk_parm_name_ext (pt: Ast.parameter_type) (declr: Ast.declarator) = let name = declr.Ast.identifier in @@ -734,7 +728,7 @@ let fill_ms_field (isptr: bool) (pd: Ast.pdecl) = in if declr.Ast.array_dims = [] then match pt with - Ast.PTVal(aty, npattr) -> assignment_str false aty + Ast.PTVal(aty) -> assignment_str false aty | Ast.PTPtr(aty, pattr) -> if pattr.Ast.pa_isary then gen_setup_foreign_array aty @@ -855,7 +849,7 @@ let gen_check_tbridge_length_overflow (plist: Ast.pdecl list) = let gen_check_length (ty: Ast.atype) (attr: Ast.ptr_attr) (declr: Ast.declarator) = let name = declr.Ast.identifier in let tmp_ptr_name= mk_tmp_var name in - + let mk_len_size v = match v with Ast.AString s -> mk_tmp_var s @@ -866,8 +860,8 @@ let gen_check_tbridge_length_overflow (plist: Ast.pdecl list) = let gen_check_overflow cnt size_str = let if_statement = match cnt with - Ast.AString s -> sprintf "\tif ((size_t)%s > (SIZE_MAX / %s)) {\n" (mk_tmp_var s) size_str - | Ast.ANumber n -> sprintf "\tif (%d > (SIZE_MAX / %s)) {\n" n size_str + Ast.AString s -> sprintf "\tif (%s != 0 &&\n\t\t(size_t)%s > (SIZE_MAX / %s)) {\n" size_str (mk_tmp_var s) size_str + | Ast.ANumber n -> sprintf "\tif (%s != 0 &&\n\t\t%d > (SIZE_MAX / %s)) {\n" size_str n size_str in sprintf "%s\t\tstatus = SGX_ERROR_INVALID_PARAMETER;\n\t\tgoto err;\n\t}" if_statement in @@ -881,7 +875,7 @@ let gen_check_tbridge_length_overflow (plist: Ast.pdecl list) = in match attr.Ast.pa_size.Ast.ps_count with None -> "" - | Some a -> sprintf "%s\n\n" (gen_check_overflow a size_str) + | Some a -> sprintf "%s\n\n" (gen_check_overflow a size_str) in List.fold_left (fun acc (pty, declr) -> @@ -927,18 +921,26 @@ let gen_parm_ptr_direction_pre (plist: Ast.pdecl list) = let in_ptr_dst_name = mk_in_ptr_dst_name attr.Ast.pa_rdonly in_ptr_name in let tmp_ptr_name= mk_tmp_var name in - let check_sizefunc_ptr (fn: string) = + let mk_len_count v = + match v with + None -> "" + |Some a -> + match a with + Ast.AString s -> sprintf "_tmp_%s * " s + | Ast.ANumber n -> sprintf "%d * " n + in + let check_sizefunc_with_cnt_ptr v fn = sprintf "\t\t/* check whether the pointer is modified. */\n\ -\t\tif (%s(%s) != %s) {\n\ +\t\tif (%s%s(%s) != %s) {\n\ \t\t\tstatus = SGX_ERROR_INVALID_PARAMETER;\n\ \t\t\tgoto err;\n\ -\t\t}" fn in_ptr_name len_var +\t\t}" (mk_len_count v) fn in_ptr_name len_var in let malloc_and_copy pre_indent = match attr.Ast.pa_direction with Ast.PtrIn | Ast.PtrInOut -> let code_template = [ - sprintf "if (%s != NULL) {" tmp_ptr_name; + sprintf "if (%s != NULL && %s != 0) {" tmp_ptr_name len_var; sprintf "\t%s = (%s)malloc(%s);" in_ptr_name in_ptr_type len_var; sprintf "\tif (%s == NULL) {" in_ptr_name; "\t\tstatus = SGX_ERROR_OUT_OF_MEMORY;"; @@ -957,11 +959,11 @@ let gen_parm_ptr_direction_pre (plist: Ast.pdecl list) = let s3 = match attr.Ast.pa_size.Ast.ps_sizefunc with None -> s2 - | Some s -> sprintf "%s\n%s\n" s2 (check_sizefunc_ptr(s)) + | Some s -> sprintf "%s\n%s\n" s2 (check_sizefunc_with_cnt_ptr attr.Ast.pa_size.Ast.ps_count s) in sprintf "%s\t}\n" s3 | Ast.PtrOut -> let code_template = [ - sprintf "if (%s != NULL) {" tmp_ptr_name; + sprintf "if (%s != NULL && %s != 0) {" tmp_ptr_name len_var; sprintf "\tif ((%s = (%s)malloc(%s)) == NULL) {" in_ptr_name in_ptr_type len_var; "\t\tstatus = SGX_ERROR_OUT_OF_MEMORY;"; "\t\tgoto err;"; @@ -1252,7 +1254,7 @@ let gen_ocalloc_block (fname: string) (plist: Ast.pdecl list) = in let s1 = List.fold_left (fun acc pd -> acc ^ do_count_ocalloc_size pd) local_vars_block new_param_list in List.fold_left (fun acc s -> acc ^ s) s1 do_gen_ocalloc_block - + (* Generate trusted proxy code for a given untrusted function. *) let gen_func_tproxy (ufunc: Ast.untrusted_func) (idx: int) = let fd = ufunc.Ast.uf_fdecl in @@ -1293,7 +1295,7 @@ let gen_func_tproxy (ufunc: Ast.untrusted_func) (idx: int) = begin func_body := local_vars :: !func_body; func_body := ocalloc_ms_struct:: !func_body; - List.iter (fun pd -> func_body := tproxy_fill_ms_field pd :: !func_body) (filter_non_enclave_id_params fd.Ast.plist); + List.iter (fun pd -> func_body := tproxy_fill_ms_field pd :: !func_body) fd.Ast.plist; func_body := ocall_with_ms :: !func_body; if fd.Ast.rtype <> Ast.Void then func_body := update_retval :: !func_body; List.fold_left (fun acc s -> acc ^ "\t" ^ s ^ "\n") func_open (List.rev !func_body) ^ func_close @@ -1407,9 +1409,9 @@ let start_parsing (fname: string) : Ast.enclave = let fullpath = Util.get_file_path fname in let preprocessed = save_file fullpath; Preprocessor.processor_macro(fullpath) in - let lexbuf = + let lexbuf = match preprocessed with - | None -> + | None -> let chan = open_in fullpath in Lexing.from_channel chan | Some(preprocessed_string) -> Lexing.from_string preprocessed_string @@ -1493,7 +1495,7 @@ let check_priv_funcs (ec: enclave_content) = * `ec' is the toplevel `enclave_content' record. * Here, a tree reduce algorithm is used. `ec' is the root-node, each - * `import' expression is considerred as a children. + * `import' expression is considered as a children. *) let reduce_import (ec: enclave_content) = let combine (ec1: enclave_content) (ec2: enclave_content) = diff --git a/sgx-jvm/linux-sgx/sdk/edger8r/linux/Parser.mly b/sgx-jvm/linux-sgx/sdk/edger8r/linux/Parser.mly index 3023986193..ca54789afe 100644 --- a/sgx-jvm/linux-sgx/sdk/edger8r/linux/Parser.mly +++ b/sgx-jvm/linux-sgx/sdk/edger8r/linux/Parser.mly @@ -175,22 +175,6 @@ let get_ptr_attr (attr_list: (string * Ast.attr_value) list) = then check_invalid_ary_attr pattr else check_invalid_ptr_size pattr |> check_ptr_dir -let get_non_ptr_attr (attr_list: (string * Ast.attr_value) list) = - let update_attr (key: string) (value: Ast.attr_value) (ores: Ast.non_ptr_attr option) = - match ores with - None -> None - | Some res -> match key with - "enclave_id" -> Some { res with Ast.npa_enclave_id = true; } - | _ -> Some res - in - let rec do_get_non_ptr_attr alist res_attr = - match alist with - [] -> res_attr - | (k,v) :: xs -> do_get_non_ptr_attr xs (update_attr k v res_attr) - in do_get_non_ptr_attr attr_list (Some Ast.default_non_ptr_attr) - - - (* Untrusted functions can have these attributes: * * a. 3 mutual exclusive calling convention specifier: @@ -382,26 +366,23 @@ param_type: attr_block all_type { Ast.Ptr _ -> fun x -> Ast.PTPtr($2, get_ptr_attr $1) | _ -> if $1 <> [] then + let attr = get_ptr_attr $1 in match $2 with Ast.Foreign s -> - let attr = get_ptr_attr $1 in - if attr.Ast.pa_isptr || attr.Ast.pa_isary then fun x -> Ast.PTPtr($2, attr) - else - (* thinking about 'user_defined_type var[4]' *) - fun is_ary -> - if is_ary then Ast.PTPtr($2, attr) - else failwithf "`%s' is considered a plain type but decorated with pointer attributes" s + if attr.Ast.pa_isptr || attr.Ast.pa_isary then fun x -> Ast.PTPtr($2, attr) + else + (* thinking about 'user_defined_type var[4]' *) + fun is_ary -> + if is_ary then Ast.PTPtr($2, attr) + else failwithf "`%s' is considered plain type but decorated with pointer attributes" s | _ -> - fun is_ary -> - if is_ary then Ast.PTPtr($2, get_ptr_attr $1) - else - match get_non_ptr_attr $1 with - Some attr -> Ast.PTVal($2, attr) - | None -> failwithf "unexpected pointer attributes for `%s'" (Ast.get_tystr $2) + fun is_ary -> + if is_ary then Ast.PTPtr($2, attr) + else failwithf "unexpected pointer attributes for `%s'" (Ast.get_tystr $2) else fun is_ary -> if is_ary then Ast.PTPtr($2, get_ptr_attr []) - else Ast.PTVal($2, Ast.default_non_ptr_attr) + else Ast.PTVal $2 } | all_type { match $1 with @@ -409,7 +390,7 @@ param_type: attr_block all_type { | _ -> fun is_ary -> if is_ary then Ast.PTPtr($1, get_ptr_attr []) - else Ast.PTVal($1, Ast.default_non_ptr_attr) + else Ast.PTVal $1 } | attr_block Tconst type_spec pointer { let attr = get_ptr_attr $1 @@ -570,7 +551,7 @@ parameter_def: param_type declarator { let pt = $1 (Ast.is_array $2) in let is_void = match pt with - Ast.PTVal(v, _) -> v = Ast.Void + Ast.PTVal v -> v = Ast.Void | _ -> false in if is_void then diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/Makefile b/sgx-jvm/linux-sgx/sdk/gperftools/Makefile index 59f93e1e7a..3092c52ef4 100644 --- a/sgx-jvm/linux-sgx/sdk/gperftools/Makefile +++ b/sgx-jvm/linux-sgx/sdk/gperftools/Makefile @@ -34,9 +34,18 @@ include ../../buildenv.mk TCMALLOC := libsgx_tcmalloc.a SRCDIR := gperftools-2.5 -DEBUG_FLAG := ifdef DEBUG - DEBUG_FLAG += DEBUG + DEBUG_FLAG := DEBUG +else + DEBUG_FLAG := NDEBUG +endif + +# turn on stack protector for TCMALLOC +CC_BELOW_4_9 := $(shell expr "`$(CC) -dumpversion`" \< "4.9") +ifeq ($(CC_BELOW_4_9), 1) + COMMON_FLAG := -fstack-protector +else + COMMON_FLAG := -fstack-protector-strong endif .PHONY: all @@ -45,7 +54,7 @@ all: $(TCMALLOC) | $(BUILD_DIR) .PHONY: libtcmalloc libtcmalloc: - cd $(SRCDIR) && ( test -f Makefile || ./autogen-linux.sh $(DEBUG_FLAG)) && $(MAKE) + cd $(SRCDIR) && ( test -f Makefile || ./autogen-linux.sh $(DEBUG_FLAG) $(COMMON_FLAG)) && $(MAKE) $(TCMALLOC): libtcmalloc $(CP) $(SRCDIR)/.libs/libtcmalloc_minimal.a $(TCMALLOC) diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/README b/sgx-jvm/linux-sgx/sdk/gperftools/README index 4d5611f5d7..25dc757ac3 100644 --- a/sgx-jvm/linux-sgx/sdk/gperftools/README +++ b/sgx-jvm/linux-sgx/sdk/gperftools/README @@ -19,12 +19,11 @@ Do the following to enable tcmalloc in Intel(R) SGX: 3. Set the enclave HeapMaxSize equal or larger than 0x900000 in Enclave.config.xml. For example: 0x900000 - -Intel(R) SGX includes two C++ libs - C++ 11 and C++ stlport. -Intel(R) SGX tcmalloc build uses one of the C++ libs and can be configured by editing "./gperftools-2.5/autogen-linux.sh". -1. Build with C++ 11: + +Intel(R) SGX SDK includes a C++ library based on STLPort (sgx_tstdcxx) and a modern one based on libcxx (sgx_tcxx). +By default, the trusted TCMalloc library uses sgx_tcxx. However, you may change that by editing "./gperftools-2.5/autogen-linux.sh". +From: CPPFLAGS="-I../../../common/inc -I../../../common/inc/tlibc -I../../../common/inc/internal/ -I../../../sdk/tlibcxx/include -I../../../sdk/trts/" -2. Build with C++ stlport: +To: CPPFLAGS="-I../../../common/inc -I../../../common/inc/tlibc -I../../../common/inc/internal/ -I../../../sdk/tlibstdcxx/stlport -I../../../sdk/trts/" - - NOTE: The target Enclave project's link C++ lib must the same as Intel(R) SGX tcmalloc build C++ lib. Otherwise, the target enclave build will fail. +Note that if your enclave links with sgx_tcmalloc, you must use the same C++ library you choose to build tcmalloc with. Otherwise, the target enclave build will fail. diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.am b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.am index 89392436db..b81607922b 100755 --- a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.am +++ b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.am @@ -48,9 +48,9 @@ endif GCC if HAVE_W_NO_UNUSED_RESULT AM_CXXFLAGS += -Wno-unused-result endif HAVE_W_NO_UNUSED_RESULT -if HAVE_SIZED_DEALLOCATION -AM_CXXFLAGS += -fsized-deallocation -endif HAVE_SIZED_DEALLOCATION +#if HAVE_SIZED_DEALLOCATION +#AM_CXXFLAGS += -fsized-deallocation +#endif HAVE_SIZED_DEALLOCATION # The -no-undefined flag allows libtool to generate shared libraries for # Cygwin and MinGW. LIBSTDCXX_LA_LINKER_FLAG is used to fix a Solaris bug. diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.in b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.in index dc68ceb726..b6441af005 100644 --- a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.in +++ b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/Makefile.in @@ -119,7 +119,7 @@ host_triplet = @host@ # by default. @GCC_TRUE@@I386_TRUE@am__append_4 = -mmmx -fno-omit-frame-pointer @HAVE_W_NO_UNUSED_RESULT_TRUE@am__append_5 = -Wno-unused-result -@HAVE_SIZED_DEALLOCATION_TRUE@am__append_6 = -fsized-deallocation +#@HAVE_SIZED_DEALLOCATION_TRUE@am__append_6 = -fsized-deallocation # These are x86-specific, having to do with frame-pointers. In # particular, some x86_64 systems do not insert frame pointers by diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/autogen-linux.sh b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/autogen-linux.sh index 86036abb1b..9f9a985631 100755 --- a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/autogen-linux.sh +++ b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/autogen-linux.sh @@ -46,13 +46,13 @@ if [ "$1" = "DEBUG" ] then COMMON_FLAGS="-ggdb -Og" else - COMMON_FLAGS="-g -O2" + COMMON_FLAGS="-g -O2 -D_FORTIFY_SOURCE=2" fi -COMMON_FLAGS="$COMMON_FLAGS -DNO_HEAP_CHECK -DTCMALLOC_SGX -DTCMALLOC_NO_ALIASES -fstack-protector" +COMMON_FLAGS="$COMMON_FLAGS -DNO_HEAP_CHECK -DTCMALLOC_SGX -DTCMALLOC_NO_ALIASES $2" ENCLAVE_CFLAGS="$COMMON_FLAGS -ffreestanding -nostdinc -fvisibility=hidden -fPIC" -ENCLAVE_CXXFLAGS="$ENCLAVE_CFLAGS -nostdinc++" +ENCLAVE_CXXFLAGS="$ENCLAVE_CFLAGS -nostdinc++ -std=c++11" CFLAGS="$CFLAGS $ENCLAVE_CFLAGS" CXXFLAGS="$CXXFLAGS $ENCLAVE_CXXFLAGS" CPPFLAGS="-I../../../common/inc -I../../../common/inc/tlibc -I../../../common/inc/internal/ -I../../../sdk/tlibcxx/include -I../../../sdk/trts/" diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/configure b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/configure index ce299c6855..9f4da864c3 100755 --- a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/configure +++ b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/configure @@ -4858,7 +4858,7 @@ CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + && (test "$am_cv_CXX_dependencies_compiler_type" = gcc3 || test "$am_cv_CXX_dependencies_compiler_type" = clang); then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else diff --git a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/depcomp b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/depcomp index fc98710e2a..8ff21ec18c 100755 --- a/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/depcomp +++ b/sgx-jvm/linux-sgx/sdk/gperftools/gperftools-2.5/depcomp @@ -197,6 +197,32 @@ gcc3) mv "$tmpdepfile" "$depfile" ;; +clang) +## clang implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + -std*) set fnord "$@" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. diff --git a/sgx-jvm/linux-sgx/sdk/libcapable/linux/Makefile b/sgx-jvm/linux-sgx/sdk/libcapable/linux/Makefile index 72141cce09..e7cff1a2d4 100644 --- a/sgx-jvm/linux-sgx/sdk/libcapable/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/libcapable/linux/Makefile @@ -31,11 +31,15 @@ include ../../../buildenv.mk -CXXFLAGS += -fPIC -Werror -g -CXXFLAGS += $(ADDED_INC) +ifndef DEBUG +CXXFLAGS += -DDISABLE_TRACE +CFLAGS += -DDISABLE_TRACE +endif -CFLAGS += -fPIC -Werror -g -CFLAGS += $(ADDED_INC) +CXXFLAGS += -fPIC -Werror + +CFLAGS += -fPIC -Werror +LDFLAGS += $(COMMON_LDFLAGS) INC += -I$(COMMON_DIR)/inc \ -I$(COMMON_DIR)/inc/internal \ @@ -46,7 +50,7 @@ LIB += -L$(BUILD_DIR) LIBCAPABLE := libsgx_capable.so LIBCAPABLE_STATIC := libsgx_capable.a -OBJ := sgx_capable.o +OBJ := sgx_capable.o sgx_capable_version.o .PHONY: all all: $(LIBCAPABLE) $(LIBCAPABLE_STATIC) | $(BUILD_DIR) diff --git a/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable.cpp b/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable.cpp index ccfdc09e44..7ba400d3e7 100644 --- a/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable.cpp +++ b/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable.cpp @@ -1,46 +1,54 @@ /* -* 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. + * + */ #include #include #include +#include #include #include #include #include +#include "se_cdefs.h" +SGX_ACCESS_VERSION(capable, 1); + /* __cpuid(unsinged int info[4], unsigned int leaf, unsigned int subleaf); */ /* Because gcc's __get_cpuid() intrinsic is difficult to work with */ #define __cpuid(x,y,z) asm volatile("cpuid":"=a"(x[0]),"=b"(x[1]),"=c"(x[2]),"=d"(x[3]):"a"(y),"c"(z)) +#define Genu 0x756e6547 +#define ineI 0x49656e69 +#define ntel 0x6c65746e + #define EFIFS_PATH "/sys/firmware/efi/" #define EFIVARS_PATH EFIFS_PATH"efivars/" #define EFIVAR_EPCBIOS EFIVARS_PATH"EPCBIOS-c60aa7f6-e8d6-4956-8ba1-fe26298f5e87" @@ -52,6 +60,7 @@ static int _is_cpu_supported(); sgx_status_t sgx_is_capable (int *sgx_capable) { struct stat sb; + memset(&sb, 0, sizeof(struct stat)); if ( sgx_capable == NULL ) return SGX_ERROR_INVALID_PARAMETER; @@ -81,6 +90,7 @@ sgx_status_t sgx_cap_get_status (sgx_device_status_t *sgx_device_status) { struct stat sb; int has_efifs= 0; + memset(&sb, 0, sizeof(struct stat)); if ( sgx_device_status == NULL ) return SGX_ERROR_INVALID_PARAMETER; @@ -199,7 +209,7 @@ sgx_status_t sgx_cap_get_status (sgx_device_status_t *sgx_device_status) static int _is_cpu_supported() { - unsigned int info[4]; + unsigned int info[4] = {0, 0, 0, 0}; unsigned int *ebx, *ecx, *edx; ebx= &info[1]; @@ -209,7 +219,7 @@ static int _is_cpu_supported() /* Is this an Intel CPU? */ __cpuid (info, 0x00, 0); - if ( *ebx != 0x756e6547 || *ecx != 0x6c65746e || *edx != 0x49656e69 ) + if ( *ebx != Genu || *ecx != ntel || *edx != ineI ) return 0; /* Does the CPU support Intel SGX? */ @@ -223,7 +233,7 @@ static int _is_cpu_supported() static int _is_sgx_available () { - unsigned int info[4]; + unsigned int info[4] = {0, 0, 0, 0}; unsigned int *eax, *ebx, *ecx, *edx; unsigned int subleaf= 2; unsigned int flag; @@ -329,7 +339,9 @@ sgx_status_t sgx_cap_enable_device (sgx_device_status_t *sgx_device_status) return SGX_ERROR_UNEXPECTED; } - fclose(fefivar); + if ( fclose(fefivar)) { + return SGX_ERROR_UNEXPECTED; + } /* * Now create the EPCSW EFI variable. The variable data is a @@ -354,7 +366,9 @@ sgx_status_t sgx_cap_enable_device (sgx_device_status_t *sgx_device_status) return SGX_ERROR_UNEXPECTED; } - fclose(fefivar); + if ( fclose(fefivar)) { + return SGX_ERROR_UNEXPECTED; + } *sgx_device_status= SGX_DISABLED_REBOOT_REQUIRED; diff --git a/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable_version.cpp b/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable_version.cpp new file mode 100644 index 0000000000..ada9d77f09 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/libcapable/linux/sgx_capable_version.cpp @@ -0,0 +1,48 @@ +/* + * 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 "se_version.h" + +#define __CONCAT(x, y) x/**/y + +#define SGX_CAPABLE_VERSION_STR __CONCAT("SGX_CAPABLE_VERSION_", STRFILEVER) + +#ifdef __cplusplus +extern "C" { +#endif + +__attribute__((visibility("default"))) +const char * sgx_capable_version = SGX_CAPABLE_VERSION_STR; + +#ifdef __cplusplus +} +#endif diff --git a/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_tprotected_fs/Makefile b/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_tprotected_fs/Makefile index ddcab12904..2d679c0bb6 100644 --- a/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_tprotected_fs/Makefile +++ b/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_tprotected_fs/Makefile @@ -38,8 +38,7 @@ INCLUDE += -I$(COMMON_DIR)/inc/tlibc \ INCLUDE += -I$(LINUX_SDK_DIR)/tlibcxx/include - -CXXFLAGS += $(ENCLAVE_CXXFLAGS) -U__STRICT_ANSI__ -Werror +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -U__STRICT_ANSI__ -Werror #CXXFLAGS += -Wno-unused-local-typedefs -Wno-shadow -Wno-missing-field-initializers -Wno-unused-parameter SRC := $(wildcard *.cpp) @@ -55,7 +54,7 @@ all: $(LIBNAME) | $(BUILD_DIR) @$(CP) $< $| $(LIBNAME): sgx_tprotected_fs_t.h $(OBJ) - $(AR) rcsD $@ $^ + $(AR) rcsD $@ $(OBJ) sgx_tprotected_fs_t.h: $(EDGER8R) $(EDGER8R) --header-only --trusted $(COMMON_DIR)/inc/sgx_tprotected_fs.edl --search-path $(COMMON_DIR)/inc diff --git a/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_uprotected_fs/Makefile b/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_uprotected_fs/Makefile index e83d689412..d83f3e9646 100644 --- a/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_uprotected_fs/Makefile +++ b/sgx-jvm/linux-sgx/sdk/protected_fs/sgx_uprotected_fs/Makefile @@ -50,7 +50,7 @@ all: $(LIBNAME) | $(BUILD_DIR) $(CP) $< $| $(LIBNAME): sgx_tprotected_fs_u.h $(OBJ) - $(AR) rcsD $@ $^ + $(AR) rcsD $@ $(OBJ) sgx_tprotected_fs_u.h: $(EDGER8R) $(EDGER8R) --header-only --untrusted $(COMMON_DIR)/inc/sgx_tprotected_fs.edl --search-path $(COMMON_DIR)/inc diff --git a/sgx-jvm/linux-sgx/sdk/sample_libcrypto/Makefile b/sgx-jvm/linux-sgx/sdk/sample_libcrypto/Makefile index d4560e7065..40b1e67725 100644 --- a/sgx-jvm/linux-sgx/sdk/sample_libcrypto/Makefile +++ b/sgx-jvm/linux-sgx/sdk/sample_libcrypto/Makefile @@ -39,7 +39,7 @@ CPPFLAGS := -isystem $(SGX_IPP_INC) \ -I$(COMMON_DIR)/inc/internal/ LDFLAGS := -Bdynamic -L$(IPP_LIBS_DIR) $(LD_IPP) -LDFLAGS += -Wl,--version-script,sample_libcrypto.lds -Wl,--gc-sections +LDFLAGS += $(COMMON_LDFLAGS) -Wl,--version-script,sample_libcrypto.lds -Wl,--gc-sections OBJS := sample_libcrypto.o @@ -52,26 +52,14 @@ $(BUILD_DIR): all: $(LIBSAMPLECRYPTO) | $(BUILD_DIR) @$(CP) $< $| -ifneq ($(USE_OPT_LIBS), 0) $(LIBSAMPLECRYPTO): $(OBJS) $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(LIBSAMPLECRYPTO) $< -o $@ $(LDFLAGS) -else -libcrypto_px: - $(MAKE) -C $(SGX_IPP_DIR) - -$(LIBSAMPLECRYPTO): $(OBJS) libcrypto_px - $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(LIBSAMPLECRYPTO) $< -o $@ $(LDFLAGS) -endif - $(OBJS): %.o: %.cpp $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ .PHONY: clean clean: -ifeq ($(USE_OPT_LIBS), 0) - $(MAKE) -C $(SGX_IPP_DIR) clean -endif @$(RM) $(OBJS) $(LIBSAMPLECRYPTO) $(BUILD_DIR)/$(LIBSAMPLECRYPTO) .PHONY: rebuild diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/Makefile b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/Makefile index 42b78ecf88..7ac7aaa681 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/Makefile +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/Makefile @@ -34,6 +34,10 @@ include ../../../buildenv.mk CXXFLAGS += -Werror CFLAGS += -Werror +CFLAGS += -fpie +CXXFLAGS += -fpie +LDFLAGS := -pie $(COMMON_LDFLAGS) + INC += $(ADDED_INC) INC += -I$(COMMON_DIR)/inc \ -I$(COMMON_DIR)/inc/internal \ @@ -41,12 +45,8 @@ INC += -I$(COMMON_DIR)/inc \ -I$(LINUX_PSW_DIR)/urts \ -I$(LINUX_PSW_DIR)/urts/linux \ -I$(LINUX_EXTERNAL_DIR)/tinyxml2 \ - -I$(SGX_IPP_INC) \ -I$(LINUX_PSW_DIR)/urts/parser -IPP_LIBS := $(LD_IPP) -IPP_PATH := $(IPP_LIBS_DIR) - DIR1 := $(LINUX_EXTERNAL_DIR)/tinyxml2/ DIR2 := $(COMMON_DIR)/src/ DIR3 := $(LINUX_PSW_DIR)/urts/ @@ -60,7 +60,7 @@ OBJ1 := manage_metadata.o \ parse_key_file.o \ util_st.o -OBJ2 := ipp_bn.o ipp_rsa_key.o ipp_rsa_pub_key.o sgx_memset_s.o +OBJ2 := sgx_memset_s.o crypto_evp_digest.o OBJ3 := tinyxml2.o @@ -80,20 +80,11 @@ all: sgx_sign | $(BUILD_DIR) $(BUILD_DIR): @$(MKDIR) $@ -sgx_sign: PRIVATE_LDLIBS := $(IPP_LIBS) -lpthread -lenclaveparser -sgx_sign: PRIVATE_LDFLAGS := -L$(IPP_PATH) -L$(LINUX_PSW_DIR)/urts/parser +sgx_sign: PRIVATE_LDLIBS := -lpthread -lenclaveparser -lcrypto +sgx_sign: PRIVATE_LDFLAGS := -L$(LINUX_PSW_DIR)/urts/parser $(LDFLAGS) -ifneq ($(USE_OPT_LIBS), 0) sgx_sign: $(OBJS) enclaveparser $(CXX) $(CXXFLAGS) $(OBJS) $(PRIVATE_LDFLAGS) $(PRIVATE_LDLIBS) -o $@ -else -.PHONY: libcrypto_px -libcrypto_px: - $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px/ - -sgx_sign: $(OBJS) enclaveparser libcrypto_px - $(CXX) $(CXXFLAGS) $(OBJS) $(PRIVATE_LDFLAGS) $(PRIVATE_LDLIBS) -o $@ -endif $(CPP_OBJS): %.o: %.cpp $(CXX) $(CXXFLAGS) $(INC) -c $< -o $@ @@ -105,9 +96,6 @@ $(C_OBJS): %.o: $(DIR2)%.c clean: $(RM) *~ *.o sgx_sign $(BUILD_DIR)/sgx_sign $(MAKE) -C $(LINUX_PSW_DIR)/urts/parser/ clean -ifeq ($(USE_OPT_LIBS), 0) - $(MAKE) -C $(LINUX_EXTERNAL_DIR)/crypto_px/ clean -endif .PHONY: enclaveparser enclaveparser: diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/README.txt b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/README.txt deleted file mode 100644 index 09f441d78a..0000000000 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/README.txt +++ /dev/null @@ -1,31 +0,0 @@ -The sgx_sign generates the enclave signature and meta-data, and inserts the -information into the enclave file. -Meanwhile, the sgx_sign checks the enclave compatibility and provides the detail -information to users. - -Usage: - sgx_sign [options] file... - Commands: - sign Sign the enclave using the private key. - gendata Generate enclave signing material to be signed. - catsig Generate the signed enclave with the input signature - file, the public key and the enclave signing material. - Options: - -enclave Specify the enclave file to be signed. - It is a required option for the listed sgx_sign commands. - -key Specify the key file. - It is a required option for the sign and catsig commands. - -config Specify the configuration for the enclave. - -out Specify the output file. - It is a required option for the listed sgx_sign commands. - -sig Specify the signature file for the enclave signing - material. - It is a required option for the catsig command. - -unsigned Specify the enclave signing material generated by the - gendata command. - It is a required option for the catsig command. - -ignore-rel-error By default, sgx_sign provides an error for enclaves with - text relocations. You can ignore the error and continue signing - by providing this option. But it is recommended you eliminate the - text relocations instead of bypassing the error with this option. - diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.cpp b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.cpp index c49f3966d9..0feaf9be23 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.cpp +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.cpp @@ -40,7 +40,6 @@ #include "enclave_creator.h" #include "sgx_eid.h" #include "enclave_creator_sign.h" -#include "ipp_wrapper.h" #include "se_trace.h" #include "sgx_error.h" #include "util_st.h" @@ -50,6 +49,7 @@ #include #include #include +#include #define DATA_BLOCK_SIZE 64 #define EID 0x44444444 @@ -65,7 +65,8 @@ EnclaveCreatorST::EnclaveCreatorST() EnclaveCreatorST::~EnclaveCreatorST() { - SAFE_FREE_MM(m_ctx); + if(m_ctx) + EVP_MD_CTX_destroy(m_ctx); } int EnclaveCreatorST::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) @@ -77,27 +78,19 @@ int EnclaveCreatorST::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, } UNUSED(ae); - + memset(m_enclave_hash, 0, SGX_HASH_SIZE); - int size_in_byte = 0; - IppStatus error_code = ippsHashGetSize(&size_in_byte); - if(error_code != ippStsNoErr) + if((m_ctx = EVP_MD_CTX_create()) == NULL) { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashGetSize() failed in the enclave measurement process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_MD_CTX_create: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } - m_ctx = (IppsHashState *)malloc(size_in_byte); - if(m_ctx == NULL) + if(EVP_DigestInit_ex(m_ctx, EVP_sha256(), NULL) != 1) { - se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); - return SGX_ERROR_OUT_OF_MEMORY; - } - error_code = ippsHashInit(m_ctx, IPP_ALG_HASH_SHA256); - if(error_code != ippStsNoErr) - { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashInit() failed in the enclave measurement process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_DigestInit_ex: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } + uint8_t ecreat_val[SIZE_NAMED_VALUE] = "ECREATE"; uint8_t data_block[DATA_BLOCK_SIZE]; @@ -108,10 +101,10 @@ int EnclaveCreatorST::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, memcpy_s(&data_block[offset], sizeof(data_block)-offset, &secs->ssa_frame_size, sizeof(secs->ssa_frame_size)); offset += sizeof(secs->ssa_frame_size); memcpy_s(&data_block[offset], sizeof(data_block)-offset, &secs->size, sizeof(secs->size)); - error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); - if(error_code != ippStsNoErr) + + if(EVP_DigestUpdate(m_ctx, &data_block, DATA_BLOCK_SIZE) != 1) { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(ECREATE) process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_DigestUpdate: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } @@ -143,10 +136,10 @@ int EnclaveCreatorST::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, u return SGX_ERROR_UNEXPECTED; } - /* Check the page attributes: must be ADD only or ADD+EXTEND */ - if (!(attr & (ADD_PAGE_ONLY)) || (attr & (~(ADD_EXTEND_PAGE)))) + //check the page attributes + if (!(attr & PAGE_ATTR_EADD)) { - return SGX_ERROR_UNEXPECTED; + return SGX_SUCCESS; } uint64_t page_offset = (uint64_t)offset; @@ -160,10 +153,9 @@ int EnclaveCreatorST::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, u memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &page_offset, sizeof(page_offset)); db_offset += sizeof(page_offset); memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &sinfo, sizeof(data_block)-db_offset); - IppStatus error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); - if(error_code != ippStsNoErr) + if(EVP_DigestUpdate(m_ctx, data_block, DATA_BLOCK_SIZE) != 1) { - se_trace(SE_TRACE_DEBUG, "ERROR::ippsHashUpdate() failed in the enclave measurement(EADD) process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_digestUpdate: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } @@ -181,21 +173,18 @@ int EnclaveCreatorST::add_enclave_page(sgx_enclave_id_t enclave_id, void *src, u memcpy_s(data_block, sizeof(data_block), eextend_val, SIZE_NAMED_VALUE); db_offset += SIZE_NAMED_VALUE; memcpy_s(data_block+db_offset, sizeof(data_block)-db_offset, &page_offset, sizeof(page_offset)); - - error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); - if(error_code != ippStsNoErr) + if(EVP_DigestUpdate(m_ctx, data_block, DATA_BLOCK_SIZE) != 1) { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(EEXTEND) process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_digestUpdate: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } for(int j = 0; j < EEXTEND_TIME; j++) { memcpy_s(data_block, sizeof(data_block), pdata, DATA_BLOCK_SIZE); - error_code = ippsHashUpdate((Ipp8u *)&data_block, DATA_BLOCK_SIZE, m_ctx); - if(error_code != ippStsNoErr) + if(EVP_DigestUpdate(m_ctx, data_block, DATA_BLOCK_SIZE) != 1) { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashUpdate() failed in the enclave measurement(EEXTEND) process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_digestUpdate: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } pdata += DATA_BLOCK_SIZE; @@ -215,12 +204,12 @@ int EnclaveCreatorST::init_enclave(sgx_enclave_id_t enclave_id, enclave_css_t *e uint8_t temp_hash[SGX_HASH_SIZE]; memset(temp_hash, 0, SGX_HASH_SIZE); + unsigned int hash_len; /* Complete computation of the SHA256 digest and store the result into the hash. */ - IppStatus error_code = ippsHashFinal((Ipp8u *)temp_hash, m_ctx); - if(error_code != ippStsNoErr) + if(EVP_DigestFinal_ex(m_ctx, temp_hash, &hash_len) != 1) { - se_trace(SE_TRACE_DEBUG, "ERROR:ippsHashFinal() failed in the enclave measurement process.\n"); + se_trace(SE_TRACE_DEBUG, "ERROR - EVP_digestFinal_ex: %s.\n", ERR_error_string(ERR_get_error(), NULL)); return SGX_ERROR_UNEXPECTED; } @@ -243,7 +232,10 @@ int EnclaveCreatorST::destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t encl { UNUSED(enclave_id); UNUSED(enclave_size); - SAFE_FREE_MM(m_ctx); + if(m_ctx){ + EVP_MD_CTX_destroy(m_ctx); + m_ctx = NULL; + } return SGX_SUCCESS; } @@ -264,6 +256,17 @@ bool EnclaveCreatorST::use_se_hw() const return false; } +bool EnclaveCreatorST::is_EDMM_supported(sgx_enclave_id_t enclave_id) +{ + UNUSED(enclave_id); + return false; +} + +bool EnclaveCreatorST::is_driver_compatible() +{ + return true; +} + int EnclaveCreatorST::get_enclave_info(uint8_t *hash, int size, uint64_t *quota) { if(hash == NULL || size != SGX_HASH_SIZE || m_hash_valid_flag == false) @@ -279,5 +282,45 @@ int EnclaveCreatorST::get_enclave_info(uint8_t *hash, int size, uint64_t *quota) return SGX_SUCCESS; } +int EnclaveCreatorST::emodpr(uint64_t addr, uint64_t size, uint64_t flag) +{ + UNUSED(addr); + UNUSED(size); + UNUSED(flag); + + return SGX_SUCCESS; +} + +int EnclaveCreatorST::mktcs(uint64_t tcs_addr) +{ + UNUSED(tcs_addr); + + return SGX_SUCCESS; +} + +int EnclaveCreatorST::trim_range(uint64_t fromaddr, uint64_t toaddr) +{ + UNUSED(fromaddr); + UNUSED(toaddr); + + return SGX_SUCCESS; + +} + +int EnclaveCreatorST::trim_accept(uint64_t addr) +{ + UNUSED(addr); + + return SGX_SUCCESS; +} + +int EnclaveCreatorST::remove_range(uint64_t fromaddr, uint64_t numpages) +{ + UNUSED(fromaddr); + UNUSED(numpages); + + return SGX_SUCCESS; +} + static EnclaveCreatorST g_enclave_creator_st; EnclaveCreator* g_enclave_creator = &g_enclave_creator_st; diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.h b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.h index bfba61f174..0ffd49ab90 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.h +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/enclave_creator_sign.h @@ -32,7 +32,8 @@ #ifndef _ENCLAVE_CREATOR_SIGN_H_ #define _ENCLAVE_CREATOR_SIGN_H_ -#include "ippcp.h" +#include + #include "enclave_creator.h" #include "sgx_eid.h" @@ -52,12 +53,17 @@ public: int destroy_enclave(sgx_enclave_id_t enclave_id, uint64_t enclave_size); int initialize(sgx_enclave_id_t enclave_id); bool use_se_hw() const; - + bool is_EDMM_supported(sgx_enclave_id_t enclave_id); + bool is_driver_compatible(); int get_enclave_info(uint8_t *hash, int size, uint64_t *quota); - + int emodpr(uint64_t addr, uint64_t size, uint64_t flag); + int mktcs(uint64_t tcs_addr); + int trim_range(uint64_t fromaddr, uint64_t toaddr); + int trim_accept(uint64_t addr); + int remove_range(uint64_t fromaddr, uint64_t numpages); private: uint8_t m_enclave_hash[SGX_HASH_SIZE]; - IppsHashState *m_ctx; + EVP_MD_CTX *m_ctx; bool m_hash_valid_flag; sgx_enclave_id_t m_eid; uint64_t m_quota; diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.cpp b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.cpp index 4d1d291eb2..8e62e14e42 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.cpp +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.cpp @@ -177,7 +177,7 @@ bool parse_metadata_file(const char *xmlpath, xml_parameter_t *parameter, int pa CMetadata::CMetadata(metadata_t *metadata, BinParser *parser) : m_metadata(metadata) - , m_parser(parser) + , m_parser(parser), m_rva(0), m_gd_size(0), m_gd_template(NULL) , m_heap_executable(false) { memset(m_metadata, 0, sizeof(metadata_t)); @@ -202,26 +202,176 @@ bool CMetadata::build_metadata(const xml_parameter_t *parameter) { return false; } + if(!build_layout_entries()) + { + return false; + } + if(!build_gd_template(m_gd_template, &m_gd_size)) + { + return false; + } + return true; } + +#include +#include +bool CMetadata::get_time(uint32_t *date) +{ + assert(date != NULL); + + time_t rawtime = 0; + if(time( &rawtime) == -1) + return false; + struct tm *timeinfo = gmtime(&rawtime); + if(timeinfo == NULL) + return false; + uint32_t tmp_date = (timeinfo->tm_year+1900)*10000 + (timeinfo->tm_mon+1)*100 + timeinfo->tm_mday; + stringstream ss; + ss<<"0x"<>hex>>tmp_date; + *date = tmp_date; + return true; +} + +bool CMetadata::fill_enclave_css(const xml_parameter_t *para) +{ + assert(para != NULL); + uint32_t date = 0; + if(false == get_time(&date)) + return false; + + //*****fill the header******************* + uint8_t header[12] = {6, 0, 0, 0, 0xE1, 0, 0, 0, 0, 0, 1, 0}; + uint8_t header2[16] = {1, 1, 0, 0, 0x60, 0, 0, 0, 0x60, 0, 0, 0, 1, 0, 0, 0}; + memcpy_s(&m_metadata->enclave_css.header.header, sizeof(m_metadata->enclave_css.header.header), &header, sizeof(header)); + memcpy_s(&m_metadata->enclave_css.header.header2, sizeof(m_metadata->enclave_css.header.header2), &header2, sizeof(header2)); + + // For 'type', signing tool clears the bit 31 for product enclaves + // and set the bit 31 for debug enclaves + m_metadata->enclave_css.header.type = (para[RELEASETYPE].value & 0x01) ? (1<<31) : 0; + m_metadata->enclave_css.header.module_vendor = (para[INTELSIGNED].value&0x01) ? 0x8086 : 0; + m_metadata->enclave_css.header.date = date; + + //hardware version + m_metadata->enclave_css.header.hw_version = (uint32_t)para[HW].value; + + + // Misc_select/Misc_mask + m_metadata->enclave_css.body.misc_select = (uint32_t)para[MISCSELECT].value; + m_metadata->enclave_css.body.misc_mask = (uint32_t)para[MISCMASK].value; + //low 64 bit + m_metadata->enclave_css.body.attributes.flags = 0; + m_metadata->enclave_css.body.attribute_mask.flags = ~SGX_FLAGS_DEBUG; + if(para[DISABLEDEBUG].value == 1) + { + m_metadata->enclave_css.body.attributes.flags &= ~SGX_FLAGS_DEBUG; + m_metadata->enclave_css.body.attribute_mask.flags |= SGX_FLAGS_DEBUG; + } + if(para[PROVISIONKEY].value == 1) + { + m_metadata->enclave_css.body.attributes.flags |= SGX_FLAGS_PROVISION_KEY; + m_metadata->enclave_css.body.attribute_mask.flags |= SGX_FLAGS_PROVISION_KEY; + } + if(para[LAUNCHKEY].value == 1) + { + m_metadata->enclave_css.body.attributes.flags |= SGX_FLAGS_EINITTOKEN_KEY; + m_metadata->enclave_css.body.attribute_mask.flags |= SGX_FLAGS_EINITTOKEN_KEY; + } + bin_fmt_t bf = m_parser->get_bin_format(); + if(bf == BF_PE64 || bf == BF_ELF64) + { + m_metadata->enclave_css.body.attributes.flags |= SGX_FLAGS_MODE64BIT; + m_metadata->enclave_css.body.attribute_mask.flags |= SGX_FLAGS_MODE64BIT; + } + // high 64 bit + //default setting + m_metadata->enclave_css.body.attributes.xfrm = SGX_XFRM_LEGACY; + m_metadata->enclave_css.body.attribute_mask.xfrm = SGX_XFRM_LEGACY | SGX_XFRM_RESERVED; // LEGACY and reservied bits would be checked. + + m_metadata->enclave_css.body.isv_prod_id = (uint16_t)para[PRODID].value; + m_metadata->enclave_css.body.isv_svn = (uint16_t)para[ISVSVN].value; + return true; +} + bool CMetadata::modify_metadata(const xml_parameter_t *parameter) { assert(parameter != NULL); + if(!check_xml_parameter(parameter)) + return false; + if(!fill_enclave_css(parameter)) + return false; + m_metadata->version = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION ); m_metadata->size = offsetof(metadata_t, data); m_metadata->tcs_policy = (uint32_t)parameter[TCSPOLICY].value; m_metadata->ssa_frame_size = SSA_FRAME_SIZE; + m_metadata->max_save_buffer_size = MAX_SAVE_BUF_SIZE; + m_metadata->magic_num = METADATA_MAGIC; + m_metadata->desired_misc_select = 0; + m_metadata->tcs_min_pool = (uint32_t)parameter[TCSMINPOOL].value; + m_metadata->enclave_css.body.misc_select = (uint32_t)parameter[MISCSELECT].value; + m_metadata->enclave_css.body.misc_mask = (uint32_t)parameter[MISCMASK].value; + + //set metadata.attributes + //low 64 bit: it's the same as enclave_css + memset(&m_metadata->attributes, 0, sizeof(sgx_attributes_t)); + m_metadata->attributes.flags = m_metadata->enclave_css.body.attributes.flags; + //high 64 bit + //set bits that will not be checked + m_metadata->attributes.xfrm = ~m_metadata->enclave_css.body.attribute_mask.xfrm; + //set bits that have been set '1' and need to be checked + m_metadata->attributes.xfrm |= (m_metadata->enclave_css.body.attributes.xfrm & m_metadata->enclave_css.body.attribute_mask.xfrm); + + return true; +} + +bool CMetadata::check_xml_parameter(const xml_parameter_t *parameter) +{ + //stack/heap must be page-align - if(parameter[STACKMAXSIZE].value % ALIGN_SIZE) + if( (parameter[STACKMAXSIZE].value % ALIGN_SIZE) + || (parameter[STACKMINSIZE].value % ALIGN_SIZE) ) { se_trace(SE_TRACE_ERROR, SET_STACK_SIZE_ERROR); return false; } - if(parameter[HEAPMAXSIZE].value % ALIGN_SIZE) + if(parameter[STACKMINSIZE].value > parameter[STACKMAXSIZE].value) { - se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_ERROR); + se_trace(SE_TRACE_ERROR, SET_STACK_SIZE_ERROR); return false; } + + if( (parameter[HEAPMAXSIZE].value % ALIGN_SIZE) + || (parameter[HEAPMINSIZE].value % ALIGN_SIZE) + || (parameter[HEAPINITSIZE].value % ALIGN_SIZE) ) + { + se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_ALIGN_ERROR); + return false; + } + + if (parameter[HEAPINITSIZE].flag != 0) + { + if (parameter[HEAPINITSIZE].value > parameter[HEAPMAXSIZE].value) + { + se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_INIT_MAX_ERROR); + return false; + } + if (parameter[HEAPMINSIZE].value > parameter[HEAPINITSIZE].value) + { + se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_INIT_MIN_ERROR); + return false; + } + } + else + { + if (parameter[HEAPMINSIZE].value > parameter[HEAPMAXSIZE].value) + { + se_trace(SE_TRACE_ERROR, SET_HEAP_SIZE_MAX_MIN_ERROR); + return false; + } + } + // LE setting: HW != 0, Licensekey = 1 // Other enclave setting: HW = 0, Licensekey = 0 if((parameter[HW].value == 0 && parameter[LAUNCHKEY].value != 0) || @@ -231,17 +381,39 @@ bool CMetadata::modify_metadata(const xml_parameter_t *parameter) return false; } - m_metadata->max_save_buffer_size = MAX_SAVE_BUF_SIZE; - m_metadata->magic_num = METADATA_MAGIC; - m_metadata->desired_misc_select = 0; - m_metadata->enclave_css.body.misc_select = (uint32_t)parameter[MISCSELECT].value; - m_metadata->enclave_css.body.misc_mask = (uint32_t)parameter[MISCMASK].value; + if (parameter[TCSMAXNUM].flag != 0) + { + if (parameter[TCSMAXNUM].value < parameter[TCSNUM].value) + { + se_trace(SE_TRACE_ERROR, SET_TCS_MAX_NUM_ERROR); + return false; + } + if ((parameter[TCSMINPOOL].flag != 0) + && (parameter[TCSMINPOOL].value > parameter[TCSMAXNUM].value)) + { + se_trace(SE_TRACE_ERROR, SET_TCS_MIN_POOL_ERROR); + return false; + } + } + else if ((parameter[TCSMINPOOL].flag != 0) + && (parameter[TCSMINPOOL].value > parameter[TCSNUM].value)) + { + se_trace(SE_TRACE_ERROR, SET_TCS_MIN_POOL_ERROR); + return false; + } + + m_create_param.heap_init_size = parameter[HEAPINITSIZE].flag ? parameter[HEAPINITSIZE].value : parameter[HEAPMAXSIZE].value; + m_create_param.heap_min_size = parameter[HEAPMINSIZE].value; m_create_param.heap_max_size = parameter[HEAPMAXSIZE].value; - m_create_param.ssa_frame_size = SSA_FRAME_SIZE; m_create_param.stack_max_size = parameter[STACKMAXSIZE].value; - m_create_param.tcs_max_num = (uint32_t)parameter[TCSNUM].value; - m_create_param.tcs_policy = m_metadata->tcs_policy; + m_create_param.stack_min_size = parameter[STACKMINSIZE].value; + m_create_param.tcs_num = (uint32_t)parameter[TCSNUM].value; + m_create_param.tcs_max_num = (uint32_t)(parameter[TCSMAXNUM].flag ? parameter[TCSMAXNUM].value : parameter[TCSNUM].value); + m_create_param.tcs_min_pool = (uint32_t)parameter[TCSMINPOOL].value; + m_create_param.tcs_policy = (uint32_t)parameter[TCSPOLICY].value; + + se_trace(SE_TRACE_ERROR, "tcs_num %d, tcs_max_num %d, tcs_min_pool %d\n", m_create_param.tcs_num, m_create_param.tcs_max_num, m_create_param.tcs_min_pool); m_heap_executable = parameter[HEAPEXECUTABLE].value; return true; @@ -258,9 +430,42 @@ void *CMetadata::alloc_buffer_from_metadata(uint32_t size) return addr; } -bool CMetadata::build_layout_entries(vector &layouts) +/* +* Called within build_layout_table(), used to assign the rva to entry layout +* and load_step to group layout. +*/ +bool CMetadata::update_layout_entries() { - uint32_t size = (uint32_t)(layouts.size() * sizeof(layout_t)); + m_rva = calculate_sections_size(); + if(m_rva == 0) + { + se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); + return false; + } + + for(uint32_t i = 0; i < m_layouts.size(); i++) + { + if(!IS_GROUP_ID(m_layouts[i].entry.id)) + { + m_layouts[i].entry.rva = m_rva; + m_rva += (((uint64_t)m_layouts[i].entry.page_count) << SE_PAGE_SHIFT); + } + else + { + for (uint32_t j = 0; j < m_layouts[i].group.entry_count; j++) + { + m_layouts[i].group.load_step += ((uint64_t)(m_layouts[i-j-1].entry.page_count)) << SE_PAGE_SHIFT; + } + m_rva += m_layouts[i].group.load_times * m_layouts[i].group.load_step; + } + } + return true; +} + +bool CMetadata::build_layout_entries() +{ + uint32_t size = (uint32_t)(m_layouts.size() * sizeof(layout_t)); + layout_t *layout_table = (layout_t *) alloc_buffer_from_metadata(size); if(layout_table == NULL) { @@ -270,40 +475,20 @@ bool CMetadata::build_layout_entries(vector &layouts) m_metadata->dirs[DIR_LAYOUT].offset = (uint32_t)PTR_DIFF(layout_table, m_metadata); m_metadata->dirs[DIR_LAYOUT].size = size; - uint64_t rva = calculate_sections_size(); - if(rva == 0) + + for(uint32_t i = 0; i < m_layouts.size(); i++, layout_table++) { - se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); - return false; - } - for(uint32_t i = 0; i < layouts.size(); i++) - { - memcpy_s(layout_table, sizeof(layout_t), &layouts[i], sizeof(layout_t)); - - if(!IS_GROUP_ID(layouts[i].entry.id)) - { - layout_table->entry.rva = rva; - rva += (uint64_t)layouts[i].entry.page_count << SE_PAGE_SHIFT; - } - else - { - for (uint32_t j = 0; j < layouts[i].group.entry_count; j++) - { - layout_table->group.load_step += (uint64_t)layouts[i-j-1].entry.page_count << SE_PAGE_SHIFT; - } - rva += layouts[i].group.load_times * layout_table->group.load_step; - } - layout_table++; + memcpy_s(layout_table, sizeof(layout_t), &m_layouts[i], sizeof(layout_t)); } // enclave virtual size - m_metadata->enclave_size = calculate_enclave_size(rva); + m_metadata->enclave_size = calculate_enclave_size(m_rva); if(m_metadata->enclave_size == (uint64_t)-1) { se_trace(SE_TRACE_ERROR, OUT_OF_EPC_ERROR); return false; } // the last guard page entry to round the enclave size to power of 2 - if(m_metadata->enclave_size - rva > 0) + if(m_metadata->enclave_size - m_rva > 0) { layout_table = (layout_t *)alloc_buffer_from_metadata(sizeof(layout_t)); if(layout_table == NULL) @@ -312,8 +497,8 @@ bool CMetadata::build_layout_entries(vector &layouts) return false; } layout_table->entry.id = LAYOUT_ID_GUARD; - layout_table->entry.rva = rva; - layout_table->entry.page_count = (uint32_t)((m_metadata->enclave_size - rva) >> SE_PAGE_SHIFT); + layout_table->entry.rva = m_rva; + layout_table->entry.page_count = (uint32_t)((m_metadata->enclave_size - m_rva) >> SE_PAGE_SHIFT); m_metadata->dirs[DIR_LAYOUT].size += (uint32_t)sizeof(layout_t); } return true; @@ -321,7 +506,6 @@ bool CMetadata::build_layout_entries(vector &layouts) bool CMetadata::build_layout_table() { - vector layouts; layout_t layout; memset(&layout, 0, sizeof(layout)); @@ -329,35 +513,66 @@ bool CMetadata::build_layout_table() memset(&guard_page, 0, sizeof(guard_page)); guard_page.entry.id = LAYOUT_ID_GUARD; guard_page.entry.page_count = SE_GUARD_PAGE_SIZE >> SE_PAGE_SHIFT; - + + size_t thread_start; + size_t thread_end; // heap - layout.entry.id = LAYOUT_ID_HEAP; - layout.entry.page_count = (uint32_t)(m_create_param.heap_max_size >> SE_PAGE_SHIFT); - layout.entry.attributes = ADD_PAGE_ONLY; + layout.entry.id = LAYOUT_ID_HEAP_MIN; + layout.entry.page_count = (uint32_t)(m_create_param.heap_min_size >> SE_PAGE_SHIFT); + layout.entry.attributes = PAGE_ATTR_EADD; layout.entry.si_flags = m_heap_executable ? SI_FLAGS_RWX : SI_FLAGS_RW; - layouts.push_back(layout); + m_layouts.push_back(layout); + + if(m_create_param.heap_init_size > m_create_param.heap_min_size) + { + layout.entry.id = LAYOUT_ID_HEAP_INIT; + layout.entry.page_count = (uint32_t)((m_create_param.heap_init_size - m_create_param.heap_min_size) >> SE_PAGE_SHIFT); + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_POST_REMOVE | PAGE_ATTR_POST_ADD; + layout.entry.si_flags = m_heap_executable ? SI_FLAGS_RWX : SI_FLAGS_RW; + m_layouts.push_back(layout); + } + + if(m_create_param.heap_max_size > m_create_param.heap_init_size) + { + layout.entry.id = LAYOUT_ID_HEAP_MAX; + layout.entry.page_count = (uint32_t)((m_create_param.heap_max_size - m_create_param.heap_init_size) >> SE_PAGE_SHIFT); + layout.entry.attributes = PAGE_ATTR_POST_ADD; + layout.entry.si_flags = m_heap_executable ? SI_FLAGS_RWX : SI_FLAGS_RW; + m_layouts.push_back(layout); + } + // thread context memory layout // guard page | stack | TCS | SSA | guard page | TLS - + thread_start = m_layouts.size(); + //ulitity tcs // guard page - layouts.push_back(guard_page); + m_layouts.push_back(guard_page); - // stack - layout.entry.id = LAYOUT_ID_STACK; - layout.entry.page_count = (uint32_t)(m_create_param.stack_max_size >> SE_PAGE_SHIFT); - layout.entry.attributes = ADD_EXTEND_PAGE; + // stack + if(m_create_param.stack_max_size > m_create_param.stack_min_size) + { + layout.entry.id = LAYOUT_ID_STACK_MAX; + layout.entry.page_count = (uint32_t)((m_create_param.stack_max_size - m_create_param.stack_min_size) >> SE_PAGE_SHIFT); + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_EEXTEND | PAGE_DIR_GROW_DOWN; // | PAGE_ATTR_POST_ADD | PAGE_ATTR_POST_REMOVE; + layout.entry.si_flags = SI_FLAGS_RW; + layout.entry.content_size = 0xCCCCCCCC; + m_layouts.push_back(layout); + } + layout.entry.id = LAYOUT_ID_STACK_MIN; + layout.entry.page_count = (uint32_t)(m_create_param.stack_min_size >> SE_PAGE_SHIFT); + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_EEXTEND; layout.entry.si_flags = SI_FLAGS_RW; layout.entry.content_size = 0xCCCCCCCC; - layouts.push_back(layout); + m_layouts.push_back(layout); // guard page - layouts.push_back(guard_page); + m_layouts.push_back(guard_page); // tcs layout.entry.id = LAYOUT_ID_TCS; layout.entry.page_count = TCS_SIZE >> SE_PAGE_SHIFT; - layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_EEXTEND; layout.entry.si_flags = SI_FLAGS_TCS; tcs_t *tcs_template = (tcs_t *) alloc_buffer_from_metadata(TCS_TEMPLATE_SIZE); if(tcs_template == NULL) @@ -367,18 +582,18 @@ bool CMetadata::build_layout_table() } layout.entry.content_offset = (uint32_t)PTR_DIFF(tcs_template, m_metadata), layout.entry.content_size = TCS_TEMPLATE_SIZE; - layouts.push_back(layout); + m_layouts.push_back(layout); memset(&layout, 0, sizeof(layout)); // ssa layout.entry.id = LAYOUT_ID_SSA; layout.entry.page_count = SSA_FRAME_SIZE * SSA_NUM; - layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_EEXTEND; layout.entry.si_flags = SI_FLAGS_RW; - layouts.push_back(layout); + m_layouts.push_back(layout); // guard page - layouts.push_back(guard_page); + m_layouts.push_back(guard_page); // td layout.entry.id = LAYOUT_ID_TD; @@ -388,21 +603,89 @@ bool CMetadata::build_layout_table() { layout.entry.page_count += (uint32_t)(ROUND_TO_PAGE(section->virtual_size()) >> SE_PAGE_SHIFT); } - layout.entry.attributes = ADD_EXTEND_PAGE; + layout.entry.attributes = PAGE_ATTR_EADD | PAGE_ATTR_EEXTEND; layout.entry.si_flags = SI_FLAGS_RW; - layouts.push_back(layout); + m_layouts.push_back(layout); - // group for thread context - if (m_create_param.tcs_max_num > 1) + thread_end = m_layouts.size(); + + uint32_t tcs_min_pool = 0; + uint32_t tcs_eremove = 0; + if(m_create_param.tcs_min_pool > m_create_param.tcs_num - 1) { + tcs_min_pool = m_create_param.tcs_num - 1; + tcs_eremove = 0; + } + else + { + tcs_min_pool = m_create_param.tcs_min_pool; + tcs_eremove = m_create_param.tcs_num -1 - m_create_param.tcs_min_pool; + } + + //tcs to fill the tcs mini pool + if (tcs_min_pool > 0) + { + // group for static thread contexts memset(&layout, 0, sizeof(layout)); layout.group.id = LAYOUT_ID_THREAD_GROUP; - layout.group.entry_count = (uint16_t) (layouts.size() - 1); - layout.group.load_times = m_create_param.tcs_max_num-1; - layouts.push_back(layout); + layout.group.entry_count = (uint16_t)(thread_end - thread_start); + layout.group.load_times = tcs_min_pool; + m_layouts.push_back(layout); } - // build layout table - if(false == build_layout_entries(layouts)) + + //tcs will be eremoved + if (tcs_eremove > 0) + { + for(size_t i = thread_start; i < thread_end; i++) + { + layout = m_layouts[i]; + if(layout.entry.id != LAYOUT_ID_GUARD) + { + layout.entry.attributes |= PAGE_ATTR_EREMOVE; + } + m_layouts.push_back(layout); + } + + if (tcs_eremove > 1) + { + memset(&layout, 0, sizeof(layout)); + layout.group.id = LAYOUT_ID_THREAD_GROUP; + layout.group.entry_count = (uint16_t)(thread_end - thread_start); + layout.group.load_times = tcs_eremove-1; + m_layouts.push_back(layout); + } + } + // dynamic thread contexts + if (m_create_param.tcs_max_num > tcs_min_pool + 1) + { + for(size_t i = thread_start; i < thread_end; i++) + { + layout = m_layouts[i]; + if(layout.entry.id == LAYOUT_ID_STACK_MAX) + { + layout.entry.id = (uint16_t)(LAYOUT_ID_HEAP_DYN_MIN - LAYOUT_ID_HEAP_MIN + layout.entry.id); + layout.entry.attributes = PAGE_ATTR_POST_ADD | PAGE_DIR_GROW_DOWN; + } + else if(layout.entry.id != LAYOUT_ID_GUARD) + { + layout.entry.id = (uint16_t)(LAYOUT_ID_HEAP_DYN_MIN - LAYOUT_ID_HEAP_MIN + layout.entry.id); + layout.entry.attributes = PAGE_ATTR_POST_ADD | PAGE_ATTR_DYN_THREAD; + } + m_layouts.push_back(layout); + } + // dynamic thread group + if (m_create_param.tcs_max_num > m_create_param.tcs_min_pool) + { + memset(&layout, 0, sizeof(layout)); + layout.group.id = LAYOUT_ID_THREAD_GROUP_DYN; + layout.group.entry_count = (uint16_t)(thread_end - thread_start); + layout.group.load_times = m_create_param.tcs_max_num - tcs_min_pool - 1; + m_layouts.push_back(layout); + } + } + + // update layout entries + if(false == update_layout_entries()) { return false; } @@ -442,20 +725,12 @@ bool CMetadata::build_patch_table() memset(&patch, 0, sizeof(patch)); // td template - uint8_t buf[200]; - uint32_t size = 200; - memset(buf, 0, size); - if(false == build_gd_template(buf, &size)) + m_gd_size = m_parser->get_global_data_size(); + m_gd_template = (uint8_t *)alloc_buffer_from_metadata(m_gd_size); + if(m_gd_template == NULL) { return false; } - uint8_t *gd_template = (uint8_t *)alloc_buffer_from_metadata(size); - if(gd_template == NULL) - { - se_trace(SE_TRACE_ERROR, INVALID_ENCLAVE_ERROR); - return false; - } - memcpy_s(gd_template, size, buf, size); uint64_t rva = m_parser->get_symbol_rva("g_global_data"); if(0 == rva) @@ -465,8 +740,8 @@ bool CMetadata::build_patch_table() } patch.dst = (uint64_t)PTR_DIFF(get_rawdata_by_rva(rva), base_addr); - patch.src = (uint32_t)PTR_DIFF(gd_template, m_metadata); - patch.size = size; + patch.src = (uint32_t)PTR_DIFF(m_gd_template, m_metadata); + patch.size = m_gd_size; patches.push_back(patch); // patch the image header @@ -531,45 +806,79 @@ bool CMetadata::build_patch_table() } if(false == build_patch_entries(patches)) { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); return false; } return true; } layout_entry_t *CMetadata::get_entry_by_id(uint16_t id) { - layout_entry_t *layout_start = GET_PTR(layout_entry_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset); - layout_entry_t *layout_end = GET_PTR(layout_entry_t, m_metadata, m_metadata->dirs[DIR_LAYOUT].offset + m_metadata->dirs[DIR_LAYOUT].size); - for (layout_entry_t *layout = layout_start; layout < layout_end; layout++) + for (uint32_t i = 0; i < m_layouts.size(); i++) { - if(layout->id == id) - return layout; + if(m_layouts[i].entry.id == id) + return (layout_entry_t *)&m_layouts[i]; } assert(false); return NULL; } + +bool CMetadata::get_xsave_size(uint64_t xfrm, uint32_t *xsave_size) +{ + assert (xsave_size != NULL); + + struct { + uint64_t bits; + uint32_t size; + } xsave_size_table[] = { // Note that the xsave_size should be in ascending order + {SGX_XFRM_LEGACY, 512 + 64}, // 512 for legacy features, 64 for xsave header + {SGX_XFRM_AVX, 512 + 64 + 256}, // 256 for YMM0_H - YMM15_H registers + {SGX_XFRM_MPX, 512 + 64 + 256 + 80}, // 80? for BND0 - BND3, BNDCFGU, BNDCSR + {SGX_XFRM_AVX512, 512 + 64 + 256 + 80 + 1600}, // 1600? for k0 - k7, ZMM0_H - ZMM15_H, ZMM16 - ZMM31 +// PT, PKRU ... + }; + bool ret = true; + *xsave_size = 0; + if(!xfrm || (xfrm & SGX_XFRM_RESERVED)) + { + return false; + } + for(size_t i = 0; i < sizeof(xsave_size_table)/sizeof(xsave_size_table[0]); i++) + { + if((xfrm & xsave_size_table[i].bits) == xsave_size_table[i].bits) + { + *xsave_size = xsave_size_table[i].size; + } + } + return ret; +} + bool CMetadata::build_gd_template(uint8_t *data, uint32_t *data_size) { - m_create_param.stack_limit_addr = get_entry_by_id(LAYOUT_ID_STACK)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva; - m_create_param.stack_base_addr = ((uint64_t)get_entry_by_id(LAYOUT_ID_STACK)->page_count << SE_PAGE_SHIFT) + m_create_param.stack_limit_addr; - m_create_param.first_ssa_gpr = get_entry_by_id(LAYOUT_ID_SSA)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva - + SSA_FRAME_SIZE * SE_PAGE_SIZE - (uint64_t)sizeof(ssa_gpr_t); - m_create_param.enclave_size = m_metadata->enclave_size; - m_create_param.heap_offset = get_entry_by_id(LAYOUT_ID_HEAP)->rva; + if(false == get_xsave_size(m_metadata->attributes.xfrm, &m_create_param.xsave_size)) + { + return false; + } - uint64_t tmp_tls_addr = get_entry_by_id(LAYOUT_ID_TD)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva; - m_create_param.td_addr = tmp_tls_addr + (((uint64_t)get_entry_by_id(LAYOUT_ID_TD)->page_count - 1) << SE_PAGE_SHIFT); + m_create_param.stack_base_addr = (size_t)(get_entry_by_id(LAYOUT_ID_STACK_MIN)->rva + m_create_param.stack_min_size - get_entry_by_id(LAYOUT_ID_TCS)->rva); + m_create_param.stack_limit_addr = (size_t)(m_create_param.stack_base_addr - m_create_param.stack_max_size); + m_create_param.ssa_base_addr = (size_t)(get_entry_by_id(LAYOUT_ID_SSA)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva); + m_create_param.enclave_size = m_metadata->enclave_size; + m_create_param.heap_offset = (size_t)get_entry_by_id(LAYOUT_ID_HEAP_MIN)->rva; + + size_t tmp_tls_addr = (size_t)(get_entry_by_id(LAYOUT_ID_TD)->rva - get_entry_by_id(LAYOUT_ID_TCS)->rva); + m_create_param.td_addr = tmp_tls_addr + (size_t)((get_entry_by_id(LAYOUT_ID_TD)->page_count - 1) << SE_PAGE_SHIFT); const Section *section = m_parser->get_tls_section(); if(section) { /* adjust the tls_addr to be the pointer to the actual TLS data area */ - m_create_param.tls_addr = m_create_param.td_addr - section->virtual_size(); + m_create_param.tls_addr = (size_t)(m_create_param.td_addr - section->virtual_size()); assert(TRIM_TO_PAGE(m_create_param.tls_addr) == tmp_tls_addr); } else m_create_param.tls_addr = tmp_tls_addr; - if(false == m_parser->update_global_data(&m_create_param, data, data_size)) + if(false == m_parser->update_global_data(m_metadata, &m_create_param, data, data_size)) { se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); // metadata structure doesnot have enough memory for global_data template return false; @@ -630,8 +939,8 @@ uint64_t CMetadata::calculate_sections_size() } uint64_t size = (NULL == last_section) ? (0) : (last_section->get_rva() + last_section->virtual_size()); - size = ROUND_TO_PAGE(size); - + size = ROUND_TO_PAGE(size); + return size; } @@ -661,9 +970,10 @@ bool update_metadata(const char *path, const metadata_t *metadata, uint64_t meta assert(path != NULL && metadata != NULL); return write_data_to_file(path, std::ios::in | std::ios::binary| std::ios::out, - reinterpret_cast(const_cast( metadata)), metadata->size, (long)meta_offset); + reinterpret_cast(const_cast( metadata)), METADATA_SIZE, (long)meta_offset); } + #define PRINT_ELEMENT(stream, structure, element) \ do { \ (stream) << #structure << "->" << #element << ": " << std::hex << "0x" << structure->element << std::endl; \ @@ -680,6 +990,9 @@ bool update_metadata(const char *path, const metadata_t *metadata, uint64_t meta (stream) << std::endl; \ }while(0) +#define CONCAT(name, num) name##num +#define A(num) CONCAT(metadata, num) + bool print_metadata(const char *path, const metadata_t *metadata) { assert(path != NULL && metadata != NULL); @@ -690,7 +1003,9 @@ bool print_metadata(const char *path, const metadata_t *metadata) se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, path); return false; } - + + meta_ofs << "The metadata information:" << std::endl + << "=========================" << std::endl; PRINT_ELEMENT(meta_ofs, metadata, magic_num); PRINT_ELEMENT(meta_ofs, metadata, version); PRINT_ELEMENT(meta_ofs, metadata, size); @@ -730,6 +1045,54 @@ bool print_metadata(const char *path, const metadata_t *metadata) PRINT_ARRAY(meta_ofs, metadata, enclave_css.buffer.q1, SE_KEY_SIZE); PRINT_ARRAY(meta_ofs, metadata, enclave_css.buffer.q2, SE_KEY_SIZE); + metadata_t *metadata2 = GET_PTR(metadata_t, metadata, metadata->size); + if (metadata2->version == META_DATA_MAKE_VERSION(SGX_1_9_MAJOR_VERSION, SGX_1_9_MINOR_VERSION) && + metadata2->magic_num == METADATA_MAGIC) + { + // Print the compatible metadata info + meta_ofs << std::endl << std::endl + << "The compatible metadata information: " << std::endl + << "====================================" << std::endl; + PRINT_ELEMENT(meta_ofs, metadata2, magic_num); + PRINT_ELEMENT(meta_ofs, metadata2, version); + PRINT_ELEMENT(meta_ofs, metadata2, size); + PRINT_ELEMENT(meta_ofs, metadata2, tcs_policy); + PRINT_ELEMENT(meta_ofs, metadata2, ssa_frame_size); + PRINT_ELEMENT(meta_ofs, metadata2, max_save_buffer_size); + PRINT_ELEMENT(meta_ofs, metadata2, desired_misc_select); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_size); + PRINT_ELEMENT(meta_ofs, metadata2, attributes.flags); + PRINT_ELEMENT(meta_ofs, metadata2, attributes.xfrm); + + // css.header + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.header.header, 12); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.header.type); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.header.module_vendor); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.header.date); + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.header.header2, 16); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.header.hw_version); + + // css.key + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.key.modulus, SE_KEY_SIZE); + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.key.exponent, SE_EXPONENT_SIZE); + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.key.signature, SE_KEY_SIZE); + + // css.body + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.misc_select); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.misc_mask); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.attributes.flags); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.attributes.xfrm); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.attribute_mask.flags); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.attribute_mask.xfrm); + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.body.enclave_hash.m, SGX_HASH_SIZE); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.isv_prod_id); + PRINT_ELEMENT(meta_ofs, metadata2, enclave_css.body.isv_svn); + + // css.buffer + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.buffer.q1, SE_KEY_SIZE); + PRINT_ARRAY(meta_ofs, metadata2, enclave_css.buffer.q2, SE_KEY_SIZE); + } + meta_ofs.close(); return true; } diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.h b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.h index d43dff2347..a4ec1bb818 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.h +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/manage_metadata.h @@ -39,7 +39,6 @@ #include "binparser.h" #define MAX_BUFFER_SIZE 4096 -#define TCS_TEMPLATE_SIZE 72 #define STRCMP strcmp #define STRNCMP strncmp @@ -58,9 +57,14 @@ typedef enum _para_type_t DISABLEDEBUG, HW, TCSNUM, + TCSMAXNUM, + TCSMINPOOL, TCSPOLICY, STACKMAXSIZE, + STACKMINSIZE, HEAPMAXSIZE, + HEAPMINSIZE, + HEAPINITSIZE, HEAPEXECUTABLE, MISCSELECT, MISCMASK @@ -87,11 +91,16 @@ public: ~CMetadata(); bool build_metadata(const xml_parameter_t *parameter); private: + bool get_time(uint32_t *date); bool modify_metadata(const xml_parameter_t *parameter); + bool check_xml_parameter(const xml_parameter_t *parameter); + bool fill_enclave_css(const xml_parameter_t *parameter); void *alloc_buffer_from_metadata(uint32_t size); + bool get_xsave_size(uint64_t xfrm, uint32_t *xsave_size); bool build_layout_table(); bool build_patch_table(); - bool build_layout_entries(vector &layouts); + bool update_layout_entries(); + bool build_layout_entries(); bool build_patch_entries(vector &patches); layout_entry_t *get_entry_by_id(uint16_t id); @@ -105,6 +114,10 @@ private: metadata_t *m_metadata; BinParser *m_parser; create_param_t m_create_param; + vector m_layouts; + uint64_t m_rva; + uint32_t m_gd_size; + uint8_t *m_gd_template; bool m_heap_executable; }; #endif diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.cpp b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.cpp index e737cec117..4cb0d1069d 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.cpp +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.cpp @@ -34,468 +34,25 @@ * parse_key_file.cpp * Description: * Parse the RSA key file that user inputs -* to get the key type and rsa structure. +* to get the key type and RSA structure. */ #include "parse_key_file.h" #include "se_trace.h" -#include "arch.h" #include "util_st.h" #include #include #include #include -#include - -#include -#include -#include - - -//N_SIZE+E_SIZE+D_SIZE+P_SIZE+Q_SIZE+DMP1_SIZE+DMQ1_SIZE+sizeof(inverseQ) -#define PRI_COMPONENTS_SIZE (N_SIZE_IN_BYTES + E_SIZE_IN_BYTES + D_SIZE_IN_BYTES + P_SIZE_IN_BYTES *5) -#define PUB_CONPONENTS_SIZE (N_SIZE_IN_BYTES + E_SIZE_IN_BYTES) //N_SIZE+E_SIZE -#define SEQUENCE_TAG_VALUE 0x30 -#define INTEGER_TAG_VALUE 0x02 -#define BIT_STRING_TAG_VALUE 0x03 -#define NULL_TAG_VALUE 0x05 -#define OID_TAG_VALUE 0x06 - - -#define CHECK_RETRUN(value) {if(0 == (value)) return 0;} - - -//base64Decode -// to decode the base64 string and put it to the result. -//Parameters -// [IN] aSrc: the source string coded in base64 -// srcLen: length of the source string -// [OUT] result: point to the decoded string -//Return Value -// int---The length of the decoded string -static int base64_decode(const unsigned char* aSrc, size_t srcLen, unsigned char* result) -{ //two reason will cause the function return 0: 1- The input parameters are wrong, 2- srcLen<4 - static char index_64[256] = { - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 - }; - - CHECK_RETRUN(aSrc); - CHECK_RETRUN(srcLen); - CHECK_RETRUN(result); - - - unsigned char ch1 = 0, ch2 = 0, ch3 = 0, ch4 = 0; - unsigned char *ptr = result; - - for (unsigned int i = 0; i < srcLen; ++i) - { - ch1 = index_64[aSrc[i]]; - if(ch1 == 64) - continue; - ch2 = index_64[aSrc[++i]]; - if(ch2 == 64) - continue; - *(ptr++) = (unsigned char)(ch1<<2 | ch2>>4); - ch3 = index_64[aSrc[++i]]; - if(aSrc[i] == '=' || ch3 == 64) - continue; - *(ptr++) = (unsigned char)(ch2<<4 | ch3>>2); - ch4 = index_64[aSrc[++i]]; - if(aSrc[i] == '=' || ch4 == 64) - continue; - *(ptr++) = (unsigned char)(ch3<<6 | ch4); - } - return (int)(ptr - result); -} - -static void convert_string(unsigned char *str, int len) -{ - assert(str != NULL&&len>0); - char temp = 0; - for(int i=0; i tvb + tlb) - { - // In the input begin/end, the key_header/end has been removed. - // Therefore, we should not check the entire key length. - if (expect_tag != SEQUENCE_TAG_VALUE && lbegin + tvb + tlb > end) - return false; - else - { - *value_bytes = tvb; - *len_bytes = tlb + 1; // + size of tag - return true; - } - } - return false; -} - -static bool parse_tlv_integer(const unsigned char **begin, const unsigned char *end, unsigned int *values, size_t values_length) -{ - assert(NULL != begin && NULL != *begin && NULL != end && NULL != values && values_length > 0); - size_t value_bytes = 0, len_bytes = 0; - const unsigned char *psrc = *begin; - if (parse_tag_and_length(psrc, end, INTEGER_TAG_VALUE, &len_bytes, &value_bytes) == false) - return false; - psrc += len_bytes; - - if (value_bytes < values_length) - return false; - - else if (value_bytes > values_length) - { - for (unsigned int i = 0; i < value_bytes - values_length; i++) - { - if (*(psrc + i) != 0x00) - return false; - } - // There are some padding 0x00s which need to skip - psrc += value_bytes - values_length; - } - - if (values != NULL) - { - memcpy_s(values, values_length, psrc, values_length); - } - psrc += values_length; - *begin = psrc; - - return true; -} - -static bool convert_from_pri_key(const unsigned char *psrc, unsigned int slen, rsa_params_t *rsa) -{ - assert(NULL != psrc && NULL != rsa); - if(slenn, N_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->n, sizeof(rsa->n)); - - // E - if (parse_tlv_integer(&psrc, end, rsa->e, E_SIZE_IN_UINT) == false) - { - return false; - } - if (rsa->e[0] != 0x03) - { - se_trace(SE_TRACE_ERROR, "Only '3' is accepted as the Exponent value.\n"); - return false; - } - - // D - if (parse_tlv_integer(&psrc, end, rsa->d, D_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->d, sizeof(rsa->d)); - - // P - if (parse_tlv_integer(&psrc, end, rsa->p, P_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->p, sizeof(rsa->p)); - // Q - if (parse_tlv_integer(&psrc, end, rsa->q, Q_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->q, sizeof(rsa->q)); - // DMP1 - if (parse_tlv_integer(&psrc, end, rsa->dmp1, DMP1_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->dmp1, sizeof(rsa->dmp1)); - // DMQ1 - if (parse_tlv_integer(&psrc, end, rsa->dmq1, DMQ1_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->dmq1, sizeof(rsa->dmq1)); - // IQMP - if (parse_tlv_integer(&psrc, end, rsa->iqmp, IQMP_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->iqmp, sizeof(rsa->iqmp)); - return true; -} - -static bool convert_from_pub_key(const unsigned char *psrc, unsigned int slen, rsa_params_t *rsa) -{ - assert(NULL != psrc && NULL != rsa); - if(slenn, N_SIZE_IN_BYTES) == false) - { - return false; - } - convert_string((unsigned char *)rsa->n, sizeof(rsa->n)); - // E - if (parse_tlv_integer(&psrc, end, rsa->e, E_SIZE_IN_UINT) == false) - { - return false; - } - if (rsa->e[0] != 0x03) - { - se_trace(SE_TRACE_ERROR, "Only '3' is accepted as the Exponent value.\n"); - return false; - } - return true; -} - -static unsigned char* decode_key_body(unsigned char *buffer, size_t slen, int *key_type, int *rlen) -{ - assert(buffer!=NULL && key_type!=NULL && rlen!=NULL); - - const char pri_key_header[] = "-----BEGINRSAPRIVATEKEY-----" ; - const char pri_key_end[] = "-----ENDRSAPRIVATEKEY-----\n"; - const char pub_key_header[] = "-----BEGINPUBLICKEY-----"; - const char pub_key_end[] = "-----ENDPUBLICKEY-----\n"; - - int ktype = UNIDENTIFIABLE_KEY; - int offset_pri = (int)(slen - strlen(pri_key_end)); - int offset_pub = (int)(slen - strlen(pub_key_end)); - - if(offset_pub<=0 || offset_pri<=0) - { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); - *key_type = UNIDENTIFIABLE_KEY; - return NULL; - } - - //check the file header and footer to get the key type - if(!strncmp((const char *)buffer, pri_key_header, strlen(pri_key_header))) - { - //make sure the key file isn't an emcrypted PEM private key file. - if((!strncmp((const char *)(buffer+offset_pri), pri_key_end, strlen(pri_key_end))) && - !strstr((const char *)buffer, "Proc-Type: 4, ENCRYPTED")) - { - *(buffer+offset_pri-1) = '\0'; //remove the pri_key_end string - ktype = PRIVATE_KEY; - } - else - { - ktype = UNIDENTIFIABLE_KEY; - } - } - else if(!strncmp((const char *)buffer, pub_key_header, strlen(pub_key_header))) - { - if(!strncmp((const char *)(buffer+offset_pub), pub_key_end, strlen(pub_key_end))) - { - *(buffer + offset_pub-1) = '\0'; - ktype = PUBLIC_KEY; - } - else - { - ktype = UNIDENTIFIABLE_KEY; - } - } - else - { - ktype = UNIDENTIFIABLE_KEY; - } - //get the body contents of the key file - size_t body_size = 0, body_offset = 0; - if(ktype == PRIVATE_KEY) - { - body_size = strlen((const char *)buffer) - strlen(pri_key_header); - body_offset = strlen(pri_key_header)+1; - } - else if(ktype == PUBLIC_KEY) - { - body_size = strlen((const char *)buffer) - strlen(pub_key_header); - body_offset = strlen(pub_key_header)+1; - } - else - { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); - *key_type = ktype; - return NULL; - } - unsigned char *decoded_string = (unsigned char *)malloc(sizeof(char)*body_size); - if(!decoded_string) - { - se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); - *key_type = ktype; - return NULL; - } - memset(decoded_string, 0, body_size); - int retlen = base64_decode(buffer+body_offset, body_size, decoded_string); - if(retlen == 0) - { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); - *key_type = ktype; - free(decoded_string); - return NULL; - } - *key_type = ktype; - *rlen = retlen; - return decoded_string; -} - -//read_key_file -// read the input file line by line and trim the blank characters for each line -//Parameters -// [IN] key_path: the file required to be read -static std::string read_key_file(const char *key_path) -{ - assert(key_path != NULL); - - std::ifstream ifs(key_path, std::ios::in | std::ios::binary); - if(!ifs.good()) - { - se_trace(SE_TRACE_ERROR, READ_FILE_ERROR, key_path); - return ""; - } - std::string file_content; - std::string str; - while(std::getline(ifs, str)) - { - str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end()); - if(str.length() != 0) - { - file_content += str; - file_content += "\n"; // Add '\n' for each line - } - } - ifs.close(); - return file_content; -} +#include //parse_key_file(): // parse the RSA key file -//Parameters: -// [IN] key_path: the key file name user inputs -// [OUT] prsa: the rsa structure parsed from the key file -// pkey_type: the key type //Return Value: // true: success // false: fail -bool parse_key_file(const char *key_path, rsa_params_t *prsa, int *pkey_type) +bool parse_key_file(int mode, const char *key_path, RSA **prsa, int *pkey_type) { assert(prsa != NULL && pkey_type != NULL); @@ -504,50 +61,62 @@ bool parse_key_file(const char *key_path, rsa_params_t *prsa, int *pkey_type) *pkey_type = NO_KEY; return false; } - - //read and trim the file content - std::string file_content = read_key_file(key_path); - if(file_content.empty() == true) + FILE *fp = fopen(key_path, "rb"); + if(fp == NULL) { - *pkey_type = UNIDENTIFIABLE_KEY; + se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, key_path); return false; } - const unsigned char *buffer = (const unsigned char *)file_content.c_str(); - - //decode the buffer to decoded_string - size_t result = strlen((const char *)buffer); - int retlen = 0; int key_type = UNIDENTIFIABLE_KEY; - unsigned char *decoded_string = decode_key_body(const_cast(buffer), result, &key_type, &retlen); - if(!decoded_string) - { - *pkey_type = key_type; - return false; - } + RSA *rsa = NULL; - //get RSA from the decoded string - bool ret = false; - if(key_type == PRIVATE_KEY) + if(mode == SIGN) { - ret = convert_from_pri_key(decoded_string, retlen, prsa); + rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); + fclose(fp); + if(!rsa) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + return false; + } + key_type = PRIVATE_KEY; + } + else if(mode == CATSIG) + { + rsa = PEM_read_RSA_PUBKEY(fp, NULL, NULL, NULL); + fclose(fp); + if(!rsa) + { + se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); + return false; + } + key_type = PUBLIC_KEY; } else { - ret = convert_from_pub_key(decoded_string, retlen, prsa); - } - if(ret == false) - { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); - free(decoded_string); - *pkey_type = key_type; + se_trace(SE_TRACE_ERROR, "ERROR: Invalid command\n %s", USAGE_STRING); + fclose(fp); return false; } - else + + // Check the key size and exponent + if(BN_num_bytes(rsa->n) != N_SIZE_IN_BYTES) { - se_trace(SE_TRACE_DEBUG, "Parsing key file is OK.\n"); + se_trace(SE_TRACE_ERROR, INVALID_KEYSIZE_ERROR); + RSA_free(rsa); + return false; + } + char *p = BN_bn2dec(rsa->e); + if(memcmp(p, "3", 2)) + { + se_trace(SE_TRACE_ERROR, INVALID_EXPONENT_ERROR); + OPENSSL_free(p); + RSA_free(rsa); + return false; } + OPENSSL_free(p); + *prsa = rsa; *pkey_type = key_type; - free(decoded_string); return true; } diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.h b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.h index 99b2e81d54..06e97c992d 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.h +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/parse_key_file.h @@ -38,20 +38,6 @@ #define N_SIZE_IN_BYTES 384 #define E_SIZE_IN_BYTES 4 #define D_SIZE_IN_BYTES 384 -#define P_SIZE_IN_BYTES 192 -#define Q_SIZE_IN_BYTES 192 -#define DMP1_SIZE_IN_BYTES 192 -#define DMQ1_SIZE_IN_BYTES 192 -#define IQMP_SIZE_IN_BYTES 192 - -#define N_SIZE_IN_UINT N_SIZE_IN_BYTES/sizeof(unsigned int) -#define E_SIZE_IN_UINT E_SIZE_IN_BYTES/sizeof(unsigned int) -#define D_SIZE_IN_UINT D_SIZE_IN_BYTES/sizeof(unsigned int) -#define P_SIZE_IN_UINT P_SIZE_IN_BYTES/sizeof(unsigned int) -#define Q_SIZE_IN_UINT Q_SIZE_IN_BYTES/sizeof(unsigned int) -#define DMP1_SIZE_IN_UINT DMP1_SIZE_IN_BYTES/sizeof(unsigned int) -#define DMQ1_SIZE_IN_UINT DMQ1_SIZE_IN_BYTES/sizeof(unsigned int) -#define IQMP_SIZE_IN_UINT IQMP_SIZE_IN_BYTES/sizeof(unsigned int) typedef enum _key_type_t { @@ -61,19 +47,8 @@ typedef enum _key_type_t PUBLIC_KEY } key_type_t; -typedef struct _rsa_params_t -{ - unsigned int n[N_SIZE_IN_UINT]; - unsigned int e[E_SIZE_IN_UINT]; - unsigned int d[D_SIZE_IN_UINT]; - unsigned int p[P_SIZE_IN_UINT]; - unsigned int q[Q_SIZE_IN_UINT]; - unsigned int dmp1[DMP1_SIZE_IN_UINT]; - unsigned int dmq1[DMQ1_SIZE_IN_UINT]; - unsigned int iqmp[IQMP_SIZE_IN_UINT]; -}rsa_params_t; +#include - -bool parse_key_file(const char *key_path, rsa_params_t *prsa, int *pkey_type); +bool parse_key_file(int mode, const char *key_path, RSA **prsa, int *pkey_type); #endif diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/sign_tool.cpp b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/sign_tool.cpp index 3f431ea14b..455450fab5 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/sign_tool.cpp +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/sign_tool.cpp @@ -41,12 +41,15 @@ * */ -#include "ippcp.h" -#include "ippcore.h" +#include +#include +#include +#include +#include +#include #include "metadata.h" #include "manage_metadata.h" -#include "ipp_wrapper.h" #include "parse_key_file.h" #include "enclave_creator_sign.h" #include "util_st.h" @@ -58,12 +61,12 @@ #include "loader.h" #include "parserfactory.h" #include "elf_helper.h" +#include "crypto_wrapper.h" #include #include #include -#include #include #include @@ -72,15 +75,6 @@ #define SIGNATURE_SIZE 384 -typedef enum _command_mode_t -{ - SIGN = 0, - GENDATA, - CATSIG, - COMPARE, - DUMP -} command_mode_t; - typedef enum _file_path_t { DLL = 0, @@ -89,27 +83,9 @@ typedef enum _file_path_t OUTPUT, SIG, UNSIGNED, - REVIEW_ENCLAVE, DUMPFILE } file_path_t; -static bool get_time(uint32_t *date) -{ - assert(date != NULL); - - time_t rawtime = 0; - if(time( &rawtime) == -1) - return false; - struct tm *timeinfo = gmtime(&rawtime); - if(timeinfo == NULL) - return false; - uint32_t tmp_date = (timeinfo->tm_year+1900)*10000 + (timeinfo->tm_mon+1)*100 + timeinfo->tm_mday; - stringstream ss; - ss<<"0x"<>hex>>tmp_date; - *date = tmp_date; - return true; -} static int load_enclave(BinParser *parser, metadata_t *metadata) { @@ -155,12 +131,13 @@ static bool get_enclave_info(BinParser *parser, bin_fmt_t *bf, uint64_t * meta_o // measure_enclave(): // 1. Get the enclave hash by loading enclave // 2. Get the enclave info - metadata offset and enclave file format -static bool measure_enclave(uint8_t *hash, const char *dllpath, const xml_parameter_t *parameter, bool ignore_rel_error, metadata_t *metadata, bin_fmt_t *bin_fmt, uint64_t *meta_offset) +static bool measure_enclave(uint8_t *hash, const char *dllpath, const xml_parameter_t *parameter, bool ignore_rel_error, metadata_t *metadata, uint64_t *meta_offset) { - assert(hash && dllpath && metadata && bin_fmt && meta_offset); + assert(hash && dllpath && metadata && meta_offset); bool res = false; uint32_t file_size = 0; uint64_t quota = 0; + bin_fmt_t bin_fmt = BF_UNKNOWN; se_file_handle_t fh = open_file(dllpath); if (fh == THE_INVALID_HANDLE) @@ -197,18 +174,18 @@ static bool measure_enclave(uint8_t *hash, const char *dllpath, const xml_parame } // Collect enclave info - if(get_enclave_info(parser.get(), bin_fmt, meta_offset) == false) + if(get_enclave_info(parser.get(), &bin_fmt, meta_offset) == false) { close_handle(fh); return false; } bool no_rel = false; - if (*bin_fmt == BF_ELF64) + if (bin_fmt == BF_ELF64) { no_rel = ElfHelper<64>::dump_textrels(parser.get()); } else - { + { no_rel = ElfHelper<32>::dump_textrels(parser.get()); } if(no_rel == false && ignore_rel_error == false) @@ -254,121 +231,67 @@ static bool measure_enclave(uint8_t *hash, const char *dllpath, const xml_parame return res; } -static void set_meta_attributes(metadata_t *meta) -{ - assert(meta != NULL); - //set metadata.attributes - //low 64 bit: it's the same as enclave_css - memset(&meta->attributes, 0, sizeof(sgx_attributes_t)); - meta->attributes.flags = meta->enclave_css.body.attributes.flags; - //high 64 bit - //set bits that will not be checked - meta->attributes.xfrm = ~meta->enclave_css.body.attribute_mask.xfrm; - //set bits that have been set '1' and need to be checked - meta->attributes.xfrm |= (meta->enclave_css.body.attributes.xfrm & meta->enclave_css.body.attribute_mask.xfrm); - return; -} //fill_enclave_css() -// file the enclave_css_t structure with the parameter, enclave_hash -// If the RSA_key is not null, fill the key part -// If RSA_key == NULL, fill the header and body(GENDATA mode) +// fill the enclave_css_t structure with enclave_hash +// If the 'rsa' is not null, fill the key part // If the path[UNSIGNED] != NULL, update the header.date(CATSIG mode) -static bool fill_enclave_css(const IppsRSAPublicKeyState *pub_key, const xml_parameter_t *para, const uint8_t *enclave_hash, - const char **path, enclave_css_t *css, bin_fmt_t bf) +static bool fill_enclave_css(const RSA *rsa, const char **path, + const uint8_t *enclave_hash, enclave_css_t *css) { - assert(para != NULL && enclave_hash != NULL && path != NULL && css != NULL); + assert(enclave_hash != NULL && path != NULL && css != NULL); - enclave_css_t enclave_css; - memset(&enclave_css, 0, sizeof(enclave_css_t)); - - uint32_t date = 0; - if(false == get_time(&date)) - return false; - - //*****fill the header******************* - uint8_t header[12] = {6, 0, 0, 0, 0xE1, 0, 0, 0, 0, 0, 1, 0}; - uint8_t header2[16] = {1, 1, 0, 0, 0x60, 0, 0, 0, 0x60, 0, 0, 0, 1, 0, 0, 0}; - memcpy_s(&enclave_css.header.header, sizeof(enclave_css.header.header), &header, sizeof(header)); - memcpy_s(&enclave_css.header.header2, sizeof(enclave_css.header.header2), &header2, sizeof(header2)); - - // For 'type', signing tool clears the bit 31 for product enclaves - // and set the bit 31 for debug enclaves - enclave_css.header.type = (para[RELEASETYPE].value & 0x01) ? (1<<31) : 0; - enclave_css.header.module_vendor = (para[INTELSIGNED].value&0x01) ? 0x8086 : 0; - enclave_css.header.date = date; - - //if pub_key is not NULL, fill the key part - if(pub_key) + //if rsa is not NULL, fill the public key part + if(rsa) { - int exponent_size = 0; - int modulus_size = 0; - IppStatus error_code = get_pub_key(pub_key, &exponent_size, - (Ipp32u *)&enclave_css.key.exponent, - &modulus_size, - (Ipp32u *)&enclave_css.key.modulus); - if(error_code != ippStsNoErr) + int exponent_size = BN_num_bytes(rsa->e); + int modulus_size = BN_num_bytes(rsa->n); + + if(modulus_size > SE_KEY_SIZE) + return false; + unsigned char *modulus = (unsigned char *)malloc(SE_KEY_SIZE); + if(modulus == NULL) { return false; } - exponent_size = (uint32_t)(ROUND_TO(exponent_size, sizeof(Ipp32u)) / sizeof(Ipp32u)); - modulus_size = (uint32_t)(ROUND_TO(modulus_size, sizeof(Ipp32u)) / sizeof(Ipp32u)); - assert(enclave_css.key.exponent[0] == 0x03); + memset(modulus, 0, SE_KEY_SIZE); + + exponent_size = (uint32_t)(ROUND_TO(exponent_size, sizeof(uint32_t)) / sizeof(uint32_t)); + modulus_size = (uint32_t)(ROUND_TO(modulus_size, sizeof(uint32_t)) / sizeof(uint32_t)); + + if(BN_bn2bin(rsa->n, modulus) != SE_KEY_SIZE) + { + free(modulus); + return false; + } + if(BN_bn2bin(rsa->e, (unsigned char *)&css->key.exponent) != 1) + { + free(modulus); + return false; + } + for(unsigned int i = 0; i < SE_KEY_SIZE; i++) + { + css->key.modulus[i] = modulus[SE_KEY_SIZE -i - 1]; + } + free(modulus); + assert(css->key.exponent[0] == 0x03); assert(exponent_size == 0x1); assert(modulus_size == 0x60); } - //hardware version - enclave_css.header.hw_version = (uint32_t)para[HW].value; - - //****************************fill the body*********************** - // Misc_select/Misc_mask - enclave_css.body.misc_select = (uint32_t)para[MISCSELECT].value; - enclave_css.body.misc_mask = (uint32_t)para[MISCMASK].value; - //low 64 bit - enclave_css.body.attributes.flags = 0; - enclave_css.body.attribute_mask.flags = ~SGX_FLAGS_DEBUG; - if(para[DISABLEDEBUG].value == 1) - { - enclave_css.body.attributes.flags &= ~SGX_FLAGS_DEBUG; - enclave_css.body.attribute_mask.flags |= SGX_FLAGS_DEBUG; - } - if(para[PROVISIONKEY].value == 1) - { - enclave_css.body.attributes.flags |= SGX_FLAGS_PROVISION_KEY; - enclave_css.body.attribute_mask.flags |= SGX_FLAGS_PROVISION_KEY; - } - if(para[LAUNCHKEY].value == 1) - { - enclave_css.body.attributes.flags |= SGX_FLAGS_EINITTOKEN_KEY; - enclave_css.body.attribute_mask.flags |= SGX_FLAGS_EINITTOKEN_KEY; - } - if(bf == BF_PE64 || bf == BF_ELF64) - { - enclave_css.body.attributes.flags |= SGX_FLAGS_MODE64BIT; - enclave_css.body.attribute_mask.flags |= SGX_FLAGS_MODE64BIT; - } - // high 64 bit - //default setting - enclave_css.body.attributes.xfrm = SGX_XFRM_LEGACY; // SGX requires SSE and x87, so set legacy bits to be checked - enclave_css.body.attribute_mask.xfrm = SGX_XFRM_LEGACY | SGX_XFRM_RESERVED; // LEGACY and reserved bits would be checked. - - memcpy_s(&enclave_css.body.enclave_hash, sizeof(enclave_css.body.enclave_hash), enclave_hash, SGX_HASH_SIZE); - enclave_css.body.isv_prod_id = (uint16_t)para[PRODID].value; - enclave_css.body.isv_svn = (uint16_t)para[ISVSVN].value; - - //Copy the css to output css buffer - memcpy_s(css, sizeof(enclave_css_t), &enclave_css, sizeof(enclave_css_t)); + // fill the enclave hash + memcpy_s(&css->body.enclave_hash, sizeof(css->body.enclave_hash), enclave_hash, SGX_HASH_SIZE); if(path[UNSIGNED] != NULL) { // In catsig mode, update the header.date as the time when the unsigned file is generated. + enclave_css_t enclave_css; memset(&enclave_css, 0, sizeof(enclave_css)); size_t fsize = get_file_size(path[UNSIGNED]); if(fsize != sizeof(enclave_css.header) + sizeof(enclave_css.body)) { - se_trace(SE_TRACE_ERROR, UNSIGNED_FILE_ERROR, path[UNSIGNED]); - return false; + se_trace(SE_TRACE_ERROR, UNSIGNED_FILE_ERROR, path[UNSIGNED]); + return false; } uint8_t *buf = new uint8_t[fsize]; memset(buf, 0, fsize); @@ -392,116 +315,96 @@ static bool fill_enclave_css(const IppsRSAPublicKeyState *pub_key, const xml_par return true; } -static IppStatus calc_RSAq1q2(int length_s, const Ipp32u *data_s, int length_m, const Ipp32u *data_m, - int *length_q1, Ipp32u *data_q1, int *length_q2, Ipp32u *data_q2) +static bool calc_RSAq1q2(int length_s, const uint8_t *data_s, int length_m, const uint8_t *data_m, + uint8_t *data_q1, uint8_t *data_q2) { - IppStatus error_code = ippStsSAReservedErr1; - IppsBigNumState *pM=0, *pS=0, *pQ1=0, *pQ2=0, *ptemp1=0, *ptemp2=0; - IppsBigNumSGN sgn = IppsBigNumPOS; - int length_in_bit = 0; - Ipp32u *pdata = NULL; + assert(data_s && data_m && data_q1 && data_q2); + bool ret = false; + BIGNUM *ptemp1=NULL, *ptemp2=NULL, *pQ1=NULL, *pQ2=NULL, *pM=NULL, *pS = NULL; + unsigned char *q1 = NULL, *q2= NULL; + BN_CTX *ctx = NULL; + + do{ + if((ptemp1 = BN_new()) == NULL) + break; + if((ptemp2 = BN_new()) == NULL) + break; + if((pQ1 = BN_new()) == NULL) + break; + if((pQ2 = BN_new()) == NULL) + break; + if((pM = BN_new()) == NULL) + break; + if((pS = BN_new()) == NULL) + break; + + if(BN_bin2bn((const unsigned char *)data_m, length_m, pM) == NULL) + break; + if(BN_bin2bn((const unsigned char *)data_s, length_s, pS) == NULL) + break; + if((ctx = BN_CTX_new()) == NULL) + break; + + //q1 = floor(signature*signature/modulus) + //q2 = floor((signature*signature.signature - q1*signature*Modulus)/Modulus) + if(BN_mul(ptemp1, pS, pS, ctx) != 1) + break; + if(BN_div(pQ1, ptemp2, ptemp1, pM, ctx) !=1) + break; + if(BN_mul(ptemp1, pS, ptemp2, ctx) !=1) + break; + if(BN_div(pQ2, ptemp2, ptemp1, pM, ctx) !=1) + break; - //create 6 big number + int q1_len = BN_num_bytes(pQ1); + int q2_len = BN_num_bytes(pQ2); + if((q1 = (unsigned char *)malloc(q1_len)) == NULL) + break; + if((q2 = (unsigned char *)malloc(q2_len)) == NULL) + break; + if(q1_len != BN_bn2bin(pQ1, (unsigned char *)q1)) + break; + if(q2_len != BN_bn2bin(pQ2, (unsigned char *)q2)) + break; + int size_q1 = (q1_len < SE_KEY_SIZE) ? q1_len : SE_KEY_SIZE; + int size_q2 = (q2_len < SE_KEY_SIZE) ? q2_len : SE_KEY_SIZE; + for(int i = 0; i < size_q1; i++) + { + data_q1[i] = q1[size_q1 - i -1]; + } + for(int i = 0; i < size_q2; i++) + { + data_q2[i] = q2[size_q2 - i -1]; + } + ret = true; + }while(0); - if(!data_s || !data_m || !length_q1 || !data_q1 || !length_q2 - || !data_q2 || length_s <= 0 || length_m <= 0) - { - error_code = ippStsBadArgErr; - goto clean_return; - } - - error_code = newBN(data_s, length_s, &pS); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = newBN(data_m, length_m, &pM); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = newBN(0, length_m, &pQ1); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = newBN(0, length_m, &pQ2); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = newBN(0, length_m*2, &ptemp1); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = newBN(0, length_m, &ptemp2); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - - //signed big number operation - //multiplies pS and pS, ptemp1 is the multiplication result - error_code = ippsMul_BN(pS, pS, ptemp1); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - - //ptemp1: dividend, pM: divisor, pQ1: qutient, ptemp2: remainder - error_code = ippsDiv_BN(ptemp1, pM, pQ1, ptemp2); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = ippsMul_BN(pS, ptemp2, ptemp1); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - error_code = ippsDiv_BN(ptemp1, pM, pQ2, ptemp2); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - //extract the sign and value of the integer big number from the input structure(pQ1) - - error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, pQ1); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - *length_q1 = ROUND_TO(length_in_bit, 8)/8; - memset(data_q1, 0, *length_q1); - memcpy_s(data_q1, *length_q1, pdata, *length_q1); - - error_code = ippsRef_BN(&sgn, &length_in_bit, &pdata, pQ2); - if(error_code != ippStsNoErr) - { - goto clean_return; - } - *length_q2 = ROUND_TO(length_in_bit, 8)/8; - memset(data_q2, 0, *length_q2); - memcpy_s(data_q2, *length_q2, pdata, *length_q2); - goto clean_return; - -clean_return: - secure_free_BN(pM, length_m); - secure_free_BN(pS, length_s); - secure_free_BN(pQ1, length_m); - secure_free_BN(pQ2, length_m); - secure_free_BN(ptemp1, length_m*2); - secure_free_BN(ptemp2, length_m); - - return error_code; + if(q1) + free(q1); + if(q2) + free(q2); + if(ptemp1) + BN_clear_free(ptemp1); + if(ptemp2) + BN_clear_free(ptemp2); + if(pQ1) + BN_clear_free(pQ1); + if(pQ2) + BN_clear_free(pQ2); + if(pS) + BN_clear_free(pS); + if(pM) + BN_clear_free(pM); + if(ctx) + BN_CTX_free(ctx); + return ret; } -static bool create_signature(const IppsRSAPrivateKeyState *pri_key1, const char *sigpath, enclave_css_t *enclave_css) + +static bool create_signature(const RSA *rsa, const char *sigpath, enclave_css_t *enclave_css) { - IppStatus error_code = ippStsNoErr; assert(enclave_css != NULL); - assert(!(pri_key1 == NULL && sigpath == NULL) && !(pri_key1 != NULL && sigpath != NULL)); + assert(!(rsa == NULL && sigpath == NULL) && !(rsa != NULL && sigpath != NULL)); uint8_t signature[SIGNATURE_SIZE]; // keep the signature in big endian memset(signature, 0, SIGNATURE_SIZE); @@ -522,7 +425,7 @@ static bool create_signature(const IppsRSAPrivateKeyState *pri_key1, const char else //SIGN mode { size_t buffer_size = sizeof(enclave_css->header) + sizeof(enclave_css->body); - Ipp8u * temp_buffer = (Ipp8u *)malloc(buffer_size * sizeof(char)); + uint8_t * temp_buffer = (uint8_t *)malloc(buffer_size * sizeof(char)); if(NULL == temp_buffer) { se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); @@ -531,106 +434,74 @@ static bool create_signature(const IppsRSAPrivateKeyState *pri_key1, const char memcpy_s(temp_buffer, buffer_size, &enclave_css->header, sizeof(enclave_css->header)); memcpy_s(temp_buffer + sizeof(enclave_css->header), buffer_size - sizeof(enclave_css->header), &enclave_css->body, sizeof(enclave_css->body)); - int pri1_size = 0; - if(ippsRSA_GetBufferSizePrivateKey(&pri1_size, pri_key1) != ippStsNoErr) - { - free(temp_buffer); - return false; - } - Ipp8u *scratch_buf = (Ipp8u *)malloc(pri1_size); - if(NULL == scratch_buf) - { - se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); - free(temp_buffer); - return false; - } - memset(scratch_buf, 0, pri1_size); - error_code = ippsRSASign_PKCS1v15((const Ipp8u *)temp_buffer, (int)buffer_size, (Ipp8u *)signature, pri_key1, NULL, ippHashAlg_SHA256, scratch_buf); - free(scratch_buf); - free(temp_buffer); - if(error_code != ippStsNoErr) + uint8_t hash[SGX_HASH_SIZE] = {0}; + unsigned int hash_size = SGX_HASH_SIZE; + if(SGX_SUCCESS != sgx_EVP_Digest(EVP_sha256(), temp_buffer, (unsigned int)buffer_size, hash, &hash_size)) { + free(temp_buffer); return false; } + + size_t siglen; + int ret = RSA_sign(NID_sha256, hash, hash_size, signature, (unsigned int *)&siglen, const_cast(rsa)); + free(temp_buffer); + if(ret != 1) + return false; } for(int i = 0; ikey.signature)[i] = signature[SIGNATURE_SIZE-1-i]; } + //************************calculate q1 and q2********************* - int length_q1 = 0, length_q2 = 0; - error_code = calc_RSAq1q2(sizeof(enclave_css->key.signature), - (Ipp32u *)&enclave_css->key.signature, - sizeof(enclave_css->key.modulus), - (Ipp32u *)&enclave_css->key.modulus, - &length_q1, - (Ipp32u *)&enclave_css->buffer.q1, - &length_q2, - (Ipp32u *)&enclave_css->buffer.q2); - if(error_code != ippStsNoErr) + uint8_t modulus[SE_KEY_SIZE]; + for(int i = 0; ikey.modulus[SE_KEY_SIZE-1-i]; } - return true; + bool res = calc_RSAq1q2(sizeof(enclave_css->key.signature), + (const uint8_t *)signature, + sizeof(enclave_css->key.modulus), + (const uint8_t *)modulus, + (uint8_t *)enclave_css->buffer.q1, + (uint8_t *)enclave_css->buffer.q2); + return res; } -static bool verify_signature(const rsa_params_t *rsa, const enclave_css_t *enclave_css, int *signature_verified) +static bool verify_signature(const RSA *rsa, const enclave_css_t *enclave_css) { - assert(rsa != NULL && enclave_css != NULL && signature_verified != NULL); - IppsRSAPublicKeyState *pub_key = NULL; - IppStatus error_code = create_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->e, &pub_key); - if(error_code != ippStsNoErr) - { - return false; - } + assert(rsa != NULL && enclave_css != NULL); size_t buffer_size = sizeof(enclave_css->header) + sizeof(enclave_css->body); - Ipp8u * temp_buffer = (Ipp8u *)malloc(buffer_size * sizeof(char)); + uint8_t *temp_buffer = (uint8_t *)malloc(buffer_size * sizeof(char)); if(NULL == temp_buffer) { se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); return false; } memcpy_s(temp_buffer, buffer_size, &enclave_css->header, sizeof(enclave_css->header)); memcpy_s(temp_buffer + sizeof(enclave_css->header), buffer_size-sizeof(enclave_css->header), &enclave_css->body, sizeof(enclave_css->body)); + + uint8_t hash[SGX_HASH_SIZE] = {0}; + unsigned int hash_size = SGX_HASH_SIZE; + if(SGX_SUCCESS != sgx_EVP_Digest(EVP_sha256(), temp_buffer, (unsigned int)buffer_size, hash, &hash_size)) + { + free(temp_buffer); + return false; + } + free(temp_buffer); + uint8_t signature[SIGNATURE_SIZE]; for(int i=0; ikey.signature[SIGNATURE_SIZE-1-i]; } - int pub_size = 0; - if(ippsRSA_GetBufferSizePublicKey(&pub_size, pub_key) != ippStsNoErr) + if(1 != RSA_verify(NID_sha256, hash, hash_size, signature, SIGNATURE_SIZE, const_cast(rsa))) { - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - free(temp_buffer); return false; } - Ipp8u *scratch_buf = (Ipp8u *)malloc(pub_size); - if(NULL == scratch_buf) - { - se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - free(temp_buffer); - return false; - } - memset(scratch_buf, 0, pub_size); - error_code = ippsRSAVerify_PKCS1v15((const Ipp8u *)temp_buffer, (int)buffer_size, (Ipp8u *)signature, signature_verified, pub_key, ippHashAlg_SHA256, scratch_buf); - free(temp_buffer); - free(scratch_buf); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - - if(error_code != ippStsNoErr) - { - se_trace(SE_TRACE_DEBUG, "ippsRSASSAVerify_SHA256_PKCSv15() returns failure. The ipperrorCode is %d \n", error_code); - return false; - } - else - { - se_trace(SE_TRACE_DEBUG, "RSAVerify() returns success. The signature_verified is %d\n", *signature_verified); - return true; - } + return true; } static bool gen_enclave_signing_file(const enclave_css_t *enclave_css, const char *outpath) @@ -704,15 +575,6 @@ static bool cmdline_parse(unsigned int argc, char *argv[], int *mode, const char {"-unsigned", NULL, PAR_REQUIRED}, {"-review_enclave", NULL, PAR_INVALID}, {"-dumpfile", NULL, PAR_OPTIONAL}}; - param_struct_t params_compare[] = { - {"-enclave", NULL, PAR_REQUIRED}, - {"-config", NULL, PAR_OPTIONAL}, - {"-key", NULL, PAR_INVALID}, - {"-out", NULL, PAR_INVALID}, - {"-sig", NULL, PAR_INVALID}, - {"-unsigned", NULL, PAR_REQUIRED}, - {"-review_enclave", NULL, PAR_REQUIRED}, - {"-dumpfile", NULL, PAR_INVALID}}; param_struct_t params_dump[] = { {"-enclave", NULL, PAR_REQUIRED}, {"-config", NULL, PAR_INVALID}, @@ -724,8 +586,8 @@ static bool cmdline_parse(unsigned int argc, char *argv[], int *mode, const char {"-dumpfile", NULL, PAR_REQUIRED}}; - const char *mode_m[] ={"sign", "gendata","catsig", "compare", "dump"}; - param_struct_t *params[] = {params_sign, params_gendata, params_catsig, params_compare, params_dump}; + const char *mode_m[] ={"sign", "gendata","catsig", "dump"}; + param_struct_t *params[] = {params_sign, params_gendata, params_catsig, params_dump}; unsigned int tempidx=0; for(; tempidxenclave_css, bf)) - { - return false; - } - set_meta_attributes(metadata); - - return true; -} - //generate_output: // To generate the final output file // SIGN- need to fill the enclave_css_t(key part included), sign the header and body and @@ -843,59 +692,35 @@ static bool fill_meta_without_signature(const IppsRSAPublicKeyState *pub_key, co // and then write the whole out file with body+header+hash // CATSIG- need to fill the enclave_css_t(include key), read the signature from the sigpath, // and then update the metadata in the out file -static bool generate_output(int mode, int ktype, const uint8_t *enclave_hash, const xml_parameter_t *para, const rsa_params_t *rsa, metadata_t *metadata, - const char **path, bin_fmt_t bf, uint64_t meta_offset) +static bool generate_output(int mode, int ktype, const uint8_t *enclave_hash, const RSA *rsa, metadata_t *metadata, + const char **path) { - assert(enclave_hash != NULL && para != NULL && metadata != NULL && path != NULL && rsa != NULL); - IppsRSAPrivateKeyState *pri_key1 = NULL; - IppsRSAPublicKeyState *pub_key = NULL; - int validate_result = IS_INVALID_KEY; - IppStatus error_code = ippStsNoErr; + assert(enclave_hash != NULL && metadata != NULL && path != NULL); switch(mode) { case SIGN: { - if(ktype != PRIVATE_KEY) + if(ktype != PRIVATE_KEY || !rsa) { se_trace(SE_TRACE_ERROR, LACK_PRI_KEY_ERROR); return false; } - error_code = create_validate_rsa_key_pair(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->d, rsa->e, - rsa->p, rsa->q, rsa->dmp1, rsa->dmq1, rsa->iqmp, &pri_key1, &pub_key, &validate_result); - if(error_code != ippStsNoErr || validate_result != IS_VALID_KEY) + if(false == fill_enclave_css(rsa, path, enclave_hash, &(metadata->enclave_css))) + { + return false; + } + if(false == create_signature(rsa, NULL, &(metadata->enclave_css))) { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); - secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); return false; } - if(false == fill_meta_without_signature(pub_key, path, enclave_hash, para, metadata, bf)) - { - secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - return false; - } - if(false == create_signature(pri_key1, NULL, &(metadata->enclave_css))) - { - secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - return false; - } - secure_free_rsa_pri1_key(N_SIZE_IN_BYTES, D_SIZE_IN_BYTES, pri_key1); - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - - if(false == update_metadata(path[OUTPUT], metadata, meta_offset)) - { - return false; - } break; } case GENDATA: { - if(false == fill_meta_without_signature(NULL, path, enclave_hash, para, metadata, bf)) + if(false == fill_enclave_css(NULL, path, enclave_hash, &(metadata->enclave_css))) { return false; } @@ -907,32 +732,21 @@ static bool generate_output(int mode, int ktype, const uint8_t *enclave_hash, co } case CATSIG: { - if(ktype != PUBLIC_KEY) + if(ktype != PUBLIC_KEY || !rsa) { se_trace(SE_TRACE_ERROR, LACK_PUB_KEY_ERROR); return false; } - if(create_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, rsa->n, rsa->e, &pub_key) != ippStsNoErr) + if(false == fill_enclave_css(rsa, path, enclave_hash, &(metadata->enclave_css))) { - se_trace(SE_TRACE_ERROR, KEY_FORMAT_ERROR); return false; } - if(false == fill_meta_without_signature(pub_key, path, enclave_hash, para, metadata, bf)) - { - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); - return false; - } - secure_free_rsa_pub_key(N_SIZE_IN_BYTES, E_SIZE_IN_BYTES, pub_key); if(false == create_signature(NULL, path[SIG], &(metadata->enclave_css))) { return false; } - if(false == update_metadata(path[OUTPUT], metadata, meta_offset)) - { - return false; - } break; } default: @@ -942,178 +756,178 @@ static bool generate_output(int mode, int ktype, const uint8_t *enclave_hash, co } return true; } -//compare two enclaves -static bool compare_enclave(const char **path, const xml_parameter_t *para) + + + + +#include "se_page_attr.h" +static void metadata_cleanup(metadata_t *metadata, uint32_t size_to_reduce) { - assert(path != NULL && para != NULL); - bool res = false; - int ret = SGX_SUCCESS; - sgx_status_t status1 = SGX_SUCCESS, status2 = SGX_SUCCESS; - uint32_t file_size1 =0 , file_size2 = 0; - size_t file_size = 0; - bin_fmt_t bin_fmt1 = BF_UNKNOWN, bin_fmt2 = BF_UNKNOWN; - uint8_t enclave_hash[SGX_HASH_SIZE] = {0}; - uint8_t *buf = NULL; - uint64_t quota = 0; - CMetadata *meta = NULL; - metadata_t metadata; - enclave_diff_info_t enclave_diff_info1, enclave_diff_info2; - enclave_css_t enclave_css; - memset(&enclave_css, 0, sizeof(enclave_css_t)); - memset(&enclave_diff_info1, 0, sizeof(enclave_diff_info_t)); - memset(&enclave_diff_info2, 0, sizeof(enclave_diff_info_t)); - memset(&metadata, 0, sizeof(metadata_t)); + metadata->dirs[DIR_LAYOUT].size -= size_to_reduce; + metadata->size -= size_to_reduce; - se_file_handle_t fh1 = open_file(path[DLL]); - if (fh1 == THE_INVALID_HANDLE) + //if there exists LAYOUT_ID_HEAP_MAX, modify it so that it won't be included in the MRENCLAVE + layout_t *start = GET_PTR(layout_t, metadata, metadata->dirs[DIR_LAYOUT].offset); + layout_t *end = GET_PTR(layout_t, start, metadata->dirs[DIR_LAYOUT].size); + for (layout_t *l = start; l < end; l++) { - se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, path[DLL]); + if (l->entry.id == LAYOUT_ID_HEAP_MAX) + { + l->entry.si_flags = SI_FLAG_NONE; + l->entry.attributes &= (uint16_t)(~PAGE_ATTR_POST_ADD); + break; + } + } + //remove the PAGE_ATTR_POST_ADD attribute so that dynamic range won't be + //created during enclave loading time + for (layout_t *l = start; l < end; l++) + { + if (l->entry.id == LAYOUT_ID_HEAP_INIT) + { + l->entry.attributes &= (uint16_t)(~PAGE_ATTR_POST_ADD); + break; + } + } +} + +static bool append_compatible_metadata(metadata_t *compat_metadata, metadata_t *metadata) +{ + metadata_t *dest_meta = metadata; + uint32_t size = 0; + do{ + if(dest_meta->magic_num != METADATA_MAGIC || dest_meta->size == 0) + break; + + size += dest_meta->size; + if(size < dest_meta->size) + return false; + dest_meta = (metadata_t *)((size_t)dest_meta + dest_meta->size); + + } while(size < METADATA_SIZE); + + if(size + compat_metadata->size < size || + size + compat_metadata->size < compat_metadata->size || + size + compat_metadata->size > METADATA_SIZE) + return false; + + if(memcpy_s(dest_meta, METADATA_SIZE - size , compat_metadata, compat_metadata->size)) + return false; + return true; +} + +static bool generate_compatible_metadata(metadata_t *metadata) +{ + metadata_t *metadata2 = (metadata_t *)malloc(metadata->size); + if(!metadata2) + { + se_trace(SE_TRACE_ERROR, NO_MEMORY_ERROR); return false; } + memcpy(metadata2, metadata, metadata->size); + metadata2->version = META_DATA_MAKE_VERSION(SGX_1_9_MAJOR_VERSION,SGX_1_9_MINOR_VERSION ); + layout_t *start = GET_PTR(layout_t, metadata2, metadata2->dirs[DIR_LAYOUT].offset); + layout_t *end = GET_PTR(layout_t, start, metadata2->dirs[DIR_LAYOUT].size); + layout_t tmp_layout, *first_dyn_entry = NULL, *first = NULL, *utility_td = NULL; + uint32_t size_to_reduce = 0; + bool ret = false; - se_file_handle_t fh2 = open_file(path[REVIEW_ENCLAVE]); - if (fh2 == THE_INVALID_HANDLE) + for (layout_t *l = start; l < end; l++) { - se_trace(SE_TRACE_ERROR, OPEN_FILE_ERROR, path[REVIEW_ENCLAVE]); - close_handle(fh1); - return false; + if ((l->entry.id == LAYOUT_ID_STACK_DYN_MAX) || + (l->entry.id == LAYOUT_ID_STACK_DYN_MIN)) + { + first_dyn_entry = l; + break; + } } - - std::unique_ptr mh1(map_file(fh1, &file_size1), unmap_file); - if (!mh1) + if (first_dyn_entry == NULL) { - close_handle(fh1); - close_handle(fh2); - return false; - } - std::unique_ptr mh2(map_file(fh2, &file_size2), unmap_file); - if (!mh2) - { - close_handle(fh1); - close_handle(fh2); - return false; + ret = append_compatible_metadata(metadata2, metadata); + free(metadata2); + return ret; } - //check if file_size is the same - if(file_size1 != file_size2) + //sizeof(layout_t) for the guard page before LAYOUT_ID_STACK_DYN_MAX + size_to_reduce = (uint32_t)((size_t)end - (size_t)first_dyn_entry + sizeof(layout_t)); + + layout_t *last = &first_dyn_entry[-2]; + + for (layout_t *l = start; l <= last; l++) { - close_handle(fh1); - close_handle(fh2); - return false; + if (l->entry.id == LAYOUT_ID_TD) + { + utility_td = l; + break; + } + } + assert(utility_td != NULL); + + //Besides dynamic threads, there's only a single utility thread + if (utility_td == last) + { + metadata_cleanup(metadata2, size_to_reduce); + ret = append_compatible_metadata(metadata2, metadata); + free(metadata2); + return ret; } - // Parse enclave - std::unique_ptr parser1(binparser::get_parser(mh1->base_addr, (size_t)file_size1)); - assert(parser1 != NULL); - std::unique_ptr parser2(binparser::get_parser(mh2->base_addr, (size_t)file_size2)); - assert(parser2 != NULL); + //We have some static threads + first = &utility_td[1]; - status1 = parser1->run_parser(); - if (status1 != SGX_SUCCESS) + //utility thread | thread group for min pool + if (first == last) { - goto clear_return; + metadata_cleanup(metadata2, size_to_reduce); + ret = append_compatible_metadata(metadata2, metadata); + free(metadata2); + return ret; } - status2 = parser2->run_parser(); - if (status2 != SGX_SUCCESS) + if (first->group.id == LAYOUT_ID_THREAD_GROUP) { - goto clear_return; + //utility thread | thread group for min pool | eremove thread | eremove thread group + if (last->group.id == LAYOUT_ID_THREAD_GROUP) + { + first->group.load_times += last->group.load_times + 1; + } + //utility thread | thread group for min pool | eremove thread + else + { + first->group.load_times += 1; + } + size_to_reduce += (uint32_t)((size_t)last - (size_t)first); } + else + { + memset(&tmp_layout, 0, sizeof(tmp_layout)); + tmp_layout.group.id = LAYOUT_ID_THREAD_GROUP; - // Collect enclave info - bin_fmt1 = parser1->get_bin_format(); - bin_fmt2 = parser2->get_bin_format(); - //two enclave should have same format - if(bin_fmt1 != bin_fmt2) - { - goto clear_return; - } - - //modify some info of enclave: timestamp etc. - status1 = parser1->get_info(&enclave_diff_info1); - if(status1 != SGX_SUCCESS) - { - goto clear_return; - } - status2 = parser2->get_info(&enclave_diff_info2); - if(status2 != SGX_SUCCESS) - { - goto clear_return; - } - status2 = parser2->modify_info(&enclave_diff_info1); - if(status2 != SGX_SUCCESS) - { - goto clear_return; - } - - //get enclave hash from unsigned file - file_size = get_file_size(path[UNSIGNED]); - if (file_size != sizeof(enclave_css.header) + sizeof(enclave_css.body) && - file_size != sizeof(enclave_css.header) + sizeof(enclave_css.body) + sizeof(enclave_css.key)) - { - goto clear_return; - } + //utility thread | eremove thread | eremove thread group + if (last->group.id == LAYOUT_ID_THREAD_GROUP) + { + tmp_layout.group.entry_count = (uint16_t)(((size_t)last - (size_t)first) / sizeof(layout_t)); + tmp_layout.group.load_times = last->group.load_times + 1; + } + //utility thread | eremove thread + else + { + tmp_layout.group.entry_count = (uint16_t)(((size_t)last - (size_t)first) / sizeof(layout_t) + 1); + tmp_layout.group.load_times = 1; + } - buf = (uint8_t *)malloc(file_size); - if (buf == NULL) - { - goto clear_return; - } - memset(buf, 0, file_size); - if(read_file_to_buf(path[UNSIGNED], buf, file_size) == false) - { - free(buf); - goto clear_return; - } - memcpy_s(&enclave_css.header, sizeof(enclave_css.header), buf, sizeof(enclave_css.header)); - memcpy_s(&enclave_css.body, sizeof(enclave_css.body), buf + (file_size - sizeof(enclave_css.body)), sizeof(enclave_css.body)); - free(buf); - - // Load enclave to get enclave hash - meta = new CMetadata(&metadata, parser2.get()); - if(meta->build_metadata(para) == false) - { - delete meta; - goto clear_return; - } - delete meta; - - ret = load_enclave(parser2.release(), &metadata); - if(ret != SGX_SUCCESS) - { - goto clear_return; - } - ret = dynamic_cast(get_enclave_creator())->get_enclave_info(enclave_hash, SGX_HASH_SIZE, "a); - if(ret != SGX_SUCCESS) - { - goto clear_return; + for (uint32_t i = 0; i < tmp_layout.group.entry_count; i++) + { + tmp_layout.group.load_step += (((uint64_t)first[i].entry.page_count) << SE_PAGE_SHIFT); + } + memcpy_s(first, sizeof(layout_t), &tmp_layout, sizeof(layout_t)); + size_to_reduce += (uint32_t)((size_t)last - (size_t)first); } - //make path[UNSIGNED] = NULL, so fill_meta_without_signature won't treat it as catsig - path[UNSIGNED] = NULL; - if(false == fill_meta_without_signature(NULL, path, enclave_hash, para, &metadata, bin_fmt2)) - { - goto clear_return; - } - - //compare - metadata.enclave_css.header.date = 0; - enclave_css.header.date = 0; - if(memcmp(&metadata.enclave_css.header, &enclave_css.header, sizeof(enclave_css.header)) != 0) - { - goto clear_return; - } - if(memcmp(&metadata.enclave_css.body, &enclave_css.body, sizeof(enclave_css.body)) != 0) - { - goto clear_return; - } - - res = true; -clear_return: - close_handle(fh1); - close_handle(fh2); - return res; + metadata_cleanup(metadata2, size_to_reduce); + ret = append_compatible_metadata(metadata2, metadata); + free(metadata2); + return ret; } static bool dump_enclave_metadata(const char *enclave_path, const char *dumpfile_path) @@ -1166,7 +980,6 @@ static bool dump_enclave_metadata(const char *enclave_path, const char *dumpfile close_handle(fh); return true; } - int main(int argc, char* argv[]) { xml_parameter_t parameter[] = {{"ProdID", 0xFFFF, 0, 0, 0}, @@ -1177,27 +990,34 @@ int main(int argc, char* argv[]) {"LaunchKey",1,0,0,0}, {"DisableDebug",1,0,0,0}, {"HW", 0x10,0,0,0}, - {"TCSNum",0xFFFFFFFF,TCS_NUM_MIN,1,0}, + {"TCSNum",0xFFFFFFFF,TCS_NUM_MIN,TCS_NUM_MIN,0}, + {"TCSMaxNum",0xFFFFFFFF,TCS_NUM_MIN,TCS_NUM_MIN,0}, + {"TCSMinPool",0xFFFFFFFF,0,TCS_NUM_MIN,0}, {"TCSPolicy",TCS_POLICY_UNBIND,TCS_POLICY_BIND,TCS_POLICY_UNBIND,0}, - {"StackMaxSize",0x1FFFFFFFFF,STACK_SIZE_MIN,0x40000,0}, - {"HeapMaxSize",0x1FFFFFFFFF,HEAP_SIZE_MIN,0x100000,0}, + {"StackMaxSize",0x1FFFFFFFFF,STACK_SIZE_MIN,STACK_SIZE_MAX,0}, + {"StackMinSize",0x1FFFFFFFFF,STACK_SIZE_MIN,STACK_SIZE_MIN,0}, + {"HeapMaxSize",0x1FFFFFFFFF,0,HEAP_SIZE_MAX,0}, + {"HeapMinSize",0x1FFFFFFFFF,0,HEAP_SIZE_MIN,0}, + {"HeapInitSize",0x1FFFFFFFFF,0,HEAP_SIZE_MIN,0}, {"HeapExecutable",1,0,0,0}, {"MiscSelect", 0xFFFFFFFF, 0, DEFAULT_MISC_SELECT, 0}, {"MiscMask", 0xFFFFFFFF, 0, DEFAULT_MISC_MASK, 0}}; const char *path[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; uint8_t enclave_hash[SGX_HASH_SIZE] = {0}; - metadata_t metadata; + uint8_t metadata_raw[METADATA_SIZE]; + metadata_t *metadata = (metadata_t*)metadata_raw; int res = -1, mode = -1; int key_type = UNIDENTIFIABLE_KEY; //indicate the type of the input key file size_t parameter_count = sizeof(parameter)/sizeof(parameter[0]); - bin_fmt_t bin_fmt = BF_UNKNOWN; uint64_t meta_offset = 0; bool ignore_rel_error = false; - rsa_params_t rsa; + RSA *rsa = NULL; + memset(&metadata_raw, 0, sizeof(metadata_raw)); + + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); - memset(&rsa, 0, sizeof(rsa)); - memset(&metadata, 0, sizeof(metadata)); //Parse command line if(cmdline_parse(argc, argv, &mode, path, &ignore_rel_error) == false) @@ -1207,24 +1027,8 @@ int main(int argc, char* argv[]) } if(mode == -1) // User only wants to get the help info { - return 0; - } - else if(mode == COMPARE) - { - //compare two enclaves - - //Parse the xml file to get the metadata - if(parse_metadata_file(path[XML], parameter, (int)parameter_count) == false) - { - goto clear_return; - } - if(compare_enclave(path, parameter) == false) - { - se_trace(SE_TRACE_ERROR, "The two enclaves are not matched\n"); - return -1; - } - se_trace(SE_TRACE_ERROR, "The two enclaves are matched\n"); - return 0; + res = 0; + goto clear_return; } else if(mode == DUMP) { @@ -1232,12 +1036,13 @@ int main(int argc, char* argv[]) if(dump_enclave_metadata(path[DLL], path[DUMPFILE]) == false) { se_trace(SE_TRACE_ERROR, DUMP_METADATA_ERROR, path[DUMPFILE]); - return -1; + goto clear_return; } else { se_trace(SE_TRACE_ERROR, SUCCESS_EXIT); - return 0; + res = 0; + goto clear_return; } } @@ -1249,7 +1054,7 @@ int main(int argc, char* argv[]) goto clear_return; } //Parse the key file - if(parse_key_file(path[KEY], &rsa, &key_type) == false && key_type != NO_KEY) + if(parse_key_file(mode, path[KEY], &rsa, &key_type) == false && key_type != NO_KEY) { goto clear_return; } @@ -1259,13 +1064,13 @@ int main(int argc, char* argv[]) goto clear_return; } - if(measure_enclave(enclave_hash, path[OUTPUT], parameter, ignore_rel_error, &metadata, &bin_fmt, &meta_offset) == false) + ignore_rel_error = true; + if(measure_enclave(enclave_hash, path[OUTPUT], parameter, ignore_rel_error, metadata, &meta_offset) == false) { se_trace(SE_TRACE_ERROR, OVERALL_ERROR); goto clear_return; } - - if((generate_output(mode, key_type, enclave_hash, parameter, &rsa, &metadata, path, bin_fmt, meta_offset)) == false) + if((generate_output(mode, key_type, enclave_hash, rsa, metadata, path)) == false) { se_trace(SE_TRACE_ERROR, OVERALL_ERROR); goto clear_return; @@ -1274,8 +1079,17 @@ int main(int argc, char* argv[]) //to verify if(mode == SIGN || mode == CATSIG) { - int signature_verified = ippFalse; - if(verify_signature(&rsa, &(metadata.enclave_css), &signature_verified) == false || signature_verified != ippTrue) + if(verify_signature(rsa, &(metadata->enclave_css)) == false) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + if(false == generate_compatible_metadata(metadata)) + { + se_trace(SE_TRACE_ERROR, OVERALL_ERROR); + goto clear_return; + } + if(false == update_metadata(path[OUTPUT], metadata, meta_offset)) { se_trace(SE_TRACE_ERROR, OVERALL_ERROR); goto clear_return; @@ -1284,7 +1098,7 @@ int main(int argc, char* argv[]) if(path[DUMPFILE] != NULL) { - if(print_metadata(path[DUMPFILE], &metadata) == false) + if(print_metadata(path[DUMPFILE], metadata) == false) { se_trace(SE_TRACE_ERROR, DUMP_METADATA_ERROR, path[DUMPFILE]); goto clear_return; @@ -1294,9 +1108,17 @@ int main(int argc, char* argv[]) res = 0; clear_return: + if(rsa) + RSA_free(rsa); if(res == -1 && path[OUTPUT]) remove(path[OUTPUT]); if(res == -1 && path[DUMPFILE]) remove(path[DUMPFILE]); + + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_thread_state(NULL); + ERR_free_strings(); + return res; } diff --git a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/util_st.h b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/util_st.h index 01e80c4dd6..eedadd9184 100644 --- a/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/util_st.h +++ b/sgx-jvm/linux-sgx/sdk/sign_tool/SignTool/util_st.h @@ -62,7 +62,8 @@ " -ignore-rel-error By default, sgx_sign provides an error for enclaves with\n" \ " text relocations. You can ignore the error and continue signing\n" \ " by providing this option. But it is recommended you eliminate the\n" \ - " text relocations instead of bypassing the error with this option.\n" + " text relocations instead of bypassing the error with this option.\n\n" \ + "You can run \"sgx_sign -help\" to get this help and exit.\n" // General error message #define OVERALL_ERROR "Error happened while signing the enclave.\n" @@ -115,14 +116,33 @@ // error message for modify_metadata() #define SET_STACK_SIZE_ERROR "Stack size setting is not correct.\n" -#define SET_HEAP_SIZE_ERROR "Heap size setting is not correct.\n" +#define SET_HEAP_SIZE_ALIGN_ERROR "Heap size setting is not correct: size is not page aligned.\n" +#define SET_HEAP_SIZE_INIT_MAX_ERROR "Heap size setting is not correct: init value should not be larger than max value.\n" +#define SET_HEAP_SIZE_INIT_MIN_ERROR "Heap size setting is not correct: min value should not be larger than init value.\n" +#define SET_HEAP_SIZE_MAX_MIN_ERROR "Heap size setting is not correct: max value should not be smaller than min value.\n" #define SET_HW_LE_ERROR "Conflicting setting between the 'HW' and 'LaunchKey'.\n" +#define SET_TCS_MAX_NUM_ERROR "Maximum number of TCS is not correct.\n" +#define SET_TCS_MIN_POOL_ERROR "Minimum number of TCS Pool is not correct.\n" + + +// error message for parse_key_file() +#define INVALID_EXPONENT_ERROR "The exponent of the input key is invalid. Only '3' is accepted as the exponent.\n" +#define INVALID_KEYSIZE_ERROR "The required key size must be 3072 bits.\n" + -// error message for compare_enclave() -#define PDB_PATH_ERROR "The two enclaves' pdb path are not equal. The pdb path of \"%s\" is \"%s\", while the pdb path of \"%s\" is \"%s\".\n" #include #include + +typedef enum _command_mode_t +{ + SIGN = 0, + GENDATA, + CATSIG, + DUMP +} command_mode_t; + + #ifdef __cplusplus extern "C" { #endif diff --git a/sgx-jvm/linux-sgx/sdk/simulation/SEConfigureCPUSVN/linux/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/SEConfigureCPUSVN/linux/Makefile index b06802b6dd..39f59370cd 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/SEConfigureCPUSVN/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/SEConfigureCPUSVN/linux/Makefile @@ -46,6 +46,8 @@ OBJS := $(sort $(SRCS:.cpp=.o)) WRAPPER_LIB_DIR := $(COMMON_DIR)/se_wrapper LDFLAGS := -L$(WRAPPER_LIB_DIR) +CXXFLAGS += -fpie +LDFLAGS += -pie $(COMMON_LDFLAGS) LDLIBS := -lwrapper TARGET := sgx_config_cpusvn diff --git a/sgx-jvm/linux-sgx/sdk/simulation/assembly/linux/gnu_tls.h b/sgx-jvm/linux-sgx/sdk/simulation/assembly/linux/gnu_tls.h index fb581e792c..dbef7f9bb1 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/assembly/linux/gnu_tls.h +++ b/sgx-jvm/linux-sgx/sdk/simulation/assembly/linux/gnu_tls.h @@ -62,33 +62,33 @@ typedef struct /* x86_64 uses %fs as the thread register */ #define GET_DTV() \ ({ dtv_t* __dtv; \ - asm ("mov %%fs:%c1, %0" : "=r"(__dtv) \ + __asm__ ("mov %%fs:%c1, %0" : "=r"(__dtv) \ : "i" (offsetof (tcbhead_t, dtv))); \ __dtv; }) #define GET_FS_GS_0() \ ({ uintptr_t __orig; \ - asm volatile ("mov %%fs:0x0, %0" : "=r"(__orig)); \ + __asm__ volatile ("mov %%fs:0x0, %0" : "=r"(__orig)); \ __orig; }) #define SET_FS_GS_0(val) \ - ({ asm volatile ("mov %0, %%fs:0x0" : :"r"(val));}) + ({ __asm__ volatile ("mov %0, %%fs:0x0" : :"r"(val));}) #elif defined(__i386) || defined(__i386__) /* IA32 uses %gs as the thread register */ #define GET_DTV() \ ({ dtv_t* __dtv; \ - asm ("mov %%gs:%c1, %0" : "=r"(__dtv) \ + __asm__ ("mov %%gs:%c1, %0" : "=r"(__dtv) \ : "i" (offsetof (tcbhead_t, dtv))); \ __dtv; }) #define GET_FS_GS_0() \ ({ uintptr_t __orig; \ - asm volatile ("mov %%gs:0x0, %0" : "=r"(__orig)); \ - __orig; }) + __asm__ volatile ("mov %%gs:0x0, %0" : "=r"(__orig)); \ + __orig; }) #define SET_FS_GS_0(val) \ - ({ asm volatile ("mov %0, %%gs:0x0" : :"r"(val));}) + ({ __asm__ volatile ("mov %0, %%gs:0x0" : :"r"(val));}) #endif diff --git a/sgx-jvm/linux-sgx/sdk/simulation/driver_api/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/driver_api/Makefile index 1235ec98b1..660f088340 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/driver_api/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/driver_api/Makefile @@ -40,7 +40,8 @@ CPPFLAGS += -I$(COMMON_DIR)/inc/ \ -I$(SIM_DIR)/uinst \ -I$(SIM_DIR)/urtssim \ -I$(SIM_DIR)/tinst \ - -I$(LINUX_PSW_DIR)/urts + -I$(LINUX_PSW_DIR)/urts \ + -I$(LINUX_PSW_DIR)/urts/linux CXXFLAGS += -fPIC -Werror diff --git a/sgx-jvm/linux-sgx/sdk/simulation/tinst/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/tinst/Makefile index b77f2da6ad..42ca1c9ac9 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/tinst/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/tinst/Makefile @@ -40,6 +40,7 @@ CPPFLAGS += -I$(COMMON_DIR)/inc/ \ -I$(SIM_DIR)/assembly/ \ -I$(SIM_DIR)/assembly/linux \ -I$(SIM_DIR)/uinst/ \ + -I$(LINUX_PSW_DIR)/urts/linux \ -I$(LINUX_SDK_DIR)/selib CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti diff --git a/sgx-jvm/linux-sgx/sdk/simulation/trtssim/linux/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/trtssim/linux/Makefile index 064e94e70b..b4433d8e08 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/trtssim/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/trtssim/linux/Makefile @@ -55,6 +55,8 @@ TLS_DIR := $(SIM_DIR)/uinst/linux/ TLDR_DIR := $(LINUX_SDK_DIR)/trts/linux/ # Support for platform dependent 'setcontext' SC_DIR := $(LINUX_SDK_DIR)/trts/linux/$(ARCH)/ +# The source for xsave/xrstor +XSAVE_DIR := $(COMMON_DIR)/src/linux/ TRTS1_OBJS := init_enclave.o \ trts.o \ @@ -63,7 +65,9 @@ TRTS1_OBJS := init_enclave.o \ trts_util.o \ trts_veh.o \ trts_xsave.o \ - init_optimized_lib.o + init_optimized_lib.o \ + trts_emodpr.o \ + trts_add_trim.o TRTS2_OBJS := trts_nsp.o TRTS_OBJS := $(TRTS1_OBJS) $(TRTS2_OBJS) @@ -76,7 +80,8 @@ TLS_OBJS := get_tcs.o \ restore_tls.o TLDR_ASM_OBJS := trts_pic.o \ - metadata_sec.o + metadata_sec.o \ + xsave_gnu.o TLDR_C_OBJS := elf_parser.o \ global_init.o \ @@ -89,7 +94,7 @@ SC_OBJ := setcontext.o LIBTRTS := libsgx_trts_sim.a vpath %.cpp $(TRTS_DIR):$(TINST_DIR) -vpath %.S $(LOWLIB_DIR):$(TLDR_DIR):$(SC_DIR) +vpath %.S $(LOWLIB_DIR):$(TLDR_DIR):$(SC_DIR):$(XSAVE_DIR) vpath %.c $(TLS_DIR):$(TLDR_DIR) # ------------------------------------------------------------ diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/licensing_sim.cpp b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/licensing_sim.cpp index 18b6cbc746..5c14ac2547 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/licensing_sim.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/licensing_sim.cpp @@ -30,10 +30,10 @@ */ -#include "ae_ipp.h" #include "se_memcpy.h" #include "util.h" #include "uae_service_internal.h" +#include "crypto_wrapper.h" /* This hard code depends on enclaveSinger private key of PvE, an Intel Generic Enclave Signing Key currently: @@ -120,15 +120,18 @@ static sgx_status_t get_launch_token_internal( } p_token->attributes_le.flags = SGX_FLAGS_INITTED; p_token->attributes_le.xfrm = SGX_XFRM_LEGACY; - - IppStatus ipp_ret = ippsHashMessage((const Ipp8u *)&(p_signature->key.modulus), - sizeof(p_signature->key.modulus), - (Ipp8u *)&(p_token->body.mr_signer), IPP_ALG_HASH_SHA256); - if(ipp_ret != ippStsNoErr){ + + unsigned int signer_len = sizeof(p_token->body.mr_signer); + sgx_status_t ret = sgx_EVP_Digest(EVP_sha256(), (const uint8_t *)&(p_signature->key.modulus), + sizeof(p_signature->key.modulus), + (uint8_t *)&(p_token->body.mr_signer), + &signer_len); + if(ret != SGX_SUCCESS && ret != SGX_ERROR_OUT_OF_MEMORY) + { return SGX_ERROR_UNEXPECTED; } - return SGX_SUCCESS; + return ret; } sgx_status_t get_launch_token( diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/Makefile index cb8824f4cf..bf427ee576 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/Makefile @@ -38,8 +38,7 @@ INCLUDES := -I.. \ -I$(LINUX_SDK_DIR)/tseal \ -I$(LINUX_SDK_DIR)/simulation/tinst \ -I$(LINUX_SDK_DIR)/simulation/urtssim \ - -I$(SGX_IPP_INC) \ - -I$(LINUX_EXTERNAL_DIR)/epid \ + -I$(LINUX_EXTERNAL_DIR)/epid-sdk-3.0.0 \ -I$(LINUX_EXTERNAL_DIR)/rdrand/ \ -I$(LINUX_PSW_DIR)/ae/inc \ -I$(LINUX_PSW_DIR)/ae/inc/internal \ @@ -49,15 +48,14 @@ CXXFLAGS += -Wall -fPIC $(INCLUDES) -Werror -g CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS)) -Wall $(INCLUDES) VERSION_SCRIPT = $(shell pwd)/uae_service_sim.linux.version -LD_OPT_WITHVER = -Wl,--version-script=$(VERSION_SCRIPT) +LD_OPT = $(COMMON_LDFLAGS) -Wl,--version-script=$(VERSION_SCRIPT) RDRAND_LIBDIR := $(LINUX_EXTERNAL_DIR)/rdrand/src RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile -EXTERNAL_LIB += -L$(IPP_LIBS_DIR) $(LD_IPP) EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrt -EXTERNAL_LIB += -ldl +EXTERNAL_LIB += -ldl -lcrypto vpath %.cpp $(LINUX_PSW_DIR)/ae/common \ $(LINUX_SDK_DIR)/simulation/urtssim \ @@ -65,7 +63,8 @@ vpath %.cpp $(LINUX_PSW_DIR)/ae/common \ vpath %.c $(COMMON_DIR)/src -CPP_SRC := $(wildcard *.cpp ../*.cpp) se_sig_rl.cpp cpusvn_util.cpp sgx_read_rand.cpp +CPP_SRC := $(wildcard *.cpp ../*.cpp) se_sig_rl.cpp cpusvn_util.cpp sgx_read_rand.cpp +CPP_SRC += crypto_evp_digest.cpp crypto_cmac_128.cpp C_SRC := se_trace.c se_thread.c OBJ := $(sort $(CPP_SRC:.cpp=.o)) \ @@ -83,16 +82,8 @@ ifndef DEBUG $(CP) $(DLLNAME_DEBUG) $| endif -ifneq ($(USE_OPT_LIBS), 0) $(DLLNAME): $(OBJ) -lrdrand - $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT_WITHVER) -else --lcrypto_px: - $(MAKE) -C $(IPP_LIBS_DIR) - -$(DLLNAME): $(OBJ) -lrdrand -lcrypto_px - $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT_WITHVER) -endif + $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT) $(DLLNAME_DEBUG): $(DLLNAME) ifndef DEBUG @@ -132,9 +123,6 @@ clean: @$(RM) $(DLLNAME) $(BUILD_DIR)/$(DLLNAME) @$(RM) $(DLLNAME_DEBUG) $(BUILD_DIR)/$(DLLNAME_DEBUG) @$(RM) $(LIBUAE_SERVICE_DEPLOY) $(BUILD_DIR)/$(LIBUAE_SERVICE_DEPLOY) -ifeq ($(USE_OPT_LIBS), 0) - @$(MAKE) -C $(IPP_LIBS_DIR) clean -endif ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE))) @$(MAKE) distclean -C $(RDRAND_LIBDIR) endif diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp index 50009f183b..e7a37a4fca 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/linux/platform_service_sim.cpp @@ -39,20 +39,9 @@ #include #define __STDC_FORMAT_MACROS #include -#include "ae_ipp.h" static Mutex g_pse_sim_lock; -__attribute__((constructor)) -// Initializer of the uae_service_sim. -static void init_ipp(void) -{ -#ifdef SGX_USE_OPT_LIB - // The return value of ippInit is discarded. - ippInit(); -#endif -} - static char g_vmc_base_path[] = "/var/tmp/"; diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp index 6d93b58a39..a536566bf0 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/platform_service_sim_com.cpp @@ -353,7 +353,7 @@ sgx_status_t sgx_get_ps_cap( if (!p_sgx_ps_cap) return SGX_ERROR_INVALID_PARAMETER; - p_sgx_ps_cap->ps_cap0 = 0x7; + p_sgx_ps_cap->ps_cap0 = 0x3; p_sgx_ps_cap->ps_cap1 = 0; return SGX_SUCCESS; } diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/quoting_sim.cpp b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/quoting_sim.cpp index f9a34e0058..14f831df6e 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/quoting_sim.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/uae_service_sim/quoting_sim.cpp @@ -35,9 +35,9 @@ #include "epid/common/types.h" #include "se_sig_rl.h" #include "se_quote_internal.h" -#include "ippcp.h" #include "deriv.h" #include "cpusvn_util.h" +#include "crypto_wrapper.h" /* The EPID group certificate */ static const uint8_t EPID_GROUP_CERT[] = { @@ -153,138 +153,83 @@ static sgx_status_t create_qe_report(const sgx_report_t *p_report, return SGX_ERROR_UNEXPECTED; //QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE) - int sha256_size = 0; - IppsHashState *p_sha_state = NULL; sgx_status_t sgx_ret = SGX_ERROR_UNEXPECTED; - IppsAES_CMACState* p_cmac_state = NULL; - int ippStateSize = 0; //prepare reprot_data - do + size_t msg_size = sizeof(sgx_quote_nonce_t) + quote_size; + uint8_t * p_msg = (uint8_t *)malloc(msg_size); + if(!p_msg) + return SGX_ERROR_OUT_OF_MEMORY; + if(memcpy_s(p_msg, msg_size, p_quote_nonce, sizeof(sgx_quote_nonce_t))) { - IppStatus ret; - ret = ippsHashGetSize(&sha256_size); - if(ret)break; - // p_sha_state need to be freed when exit. - p_sha_state = (IppsHashState *)malloc(sha256_size); - if(!p_sha_state) - { - sgx_ret = SGX_ERROR_OUT_OF_MEMORY; - break; - } - ret = ippsHashInit(p_sha_state, IPP_ALG_HASH_SHA256); - if(ret)break; - ret = ippsHashUpdate((uint8_t *)const_cast(p_quote_nonce), - sizeof(sgx_quote_nonce_t), - p_sha_state); - if(ret)break; + free(p_msg); + return sgx_ret; + } + if(memcpy_s(p_msg + sizeof(sgx_quote_nonce_t), msg_size - sizeof(sgx_quote_nonce_t), p_quote, quote_size)) + { + free(p_msg); + return sgx_ret; + } - ret = ippsHashUpdate(p_quote, - quote_size, - p_sha_state); - if(ret)break; + unsigned int report_data_len = sizeof(temp_qe_report.body.report_data); - //sha256 final, QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE) - ret = ippsHashFinal((uint8_t*)&temp_qe_report.body.report_data, - p_sha_state); - if(ret)break; + if(SGX_SUCCESS != (sgx_ret = sgx_EVP_Digest(EVP_sha256(), p_msg, (unsigned int)msg_size, + (uint8_t *)&temp_qe_report.body.report_data, &report_data_len))) + { + if(sgx_ret != SGX_ERROR_OUT_OF_MEMORY) + sgx_ret = SGX_ERROR_UNEXPECTED; + free(p_msg); + return sgx_ret; + } + + free(p_msg); - /* calculate CMAC using the report key, same as BASE_REPORT_KEY in - sdk/simulation/tinst/deriv.cpp */ - derivation_data_t dd; - memset(&dd, 0, sizeof(dd)); - dd.size = sizeof(dd_report_key_t); + /* calculate CMAC using the report key, same as BASE_REPORT_KEY in + sdk/simulation/tinst/deriv.cpp */ + derivation_data_t dd; + memset(&dd, 0, sizeof(dd)); + dd.size = sizeof(dd_report_key_t); - dd.key_name = SGX_KEYSELECT_REPORT; - if(memcpy_s(&dd.ddrk.mrenclave,sizeof(dd.ddrk.mrenclave), - &p_report->body.mr_enclave, sizeof(sgx_measurement_t))) - break; - if(memcpy_s(&dd.ddrk.attributes, sizeof(dd.ddrk.attributes), - &p_report->body.attributes, sizeof(sgx_attributes_t))) - break; - if(memcpy_s(&dd.ddrk.csr_owner_epoch, sizeof(dd.ddrk.csr_owner_epoch), - SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t))) - break; - if(memcpy_s(&dd.ddrk.cpu_svn, sizeof(dd.ddrk.cpu_svn), - cpusvn, sizeof(sgx_cpu_svn_t))) - break; - if(memcpy_s(&dd.ddrk.key_id, sizeof(dd.ddrk.key_id), - &temp_qe_report.key_id, sizeof(sgx_key_id_t))) - break; + dd.key_name = SGX_KEYSELECT_REPORT; + if(memcpy_s(&dd.ddrk.mrenclave,sizeof(dd.ddrk.mrenclave), + &p_report->body.mr_enclave, sizeof(sgx_measurement_t))) + return SGX_ERROR_UNEXPECTED; + if(memcpy_s(&dd.ddrk.attributes, sizeof(dd.ddrk.attributes), + &p_report->body.attributes, sizeof(sgx_attributes_t))) + return SGX_ERROR_UNEXPECTED; + if(memcpy_s(&dd.ddrk.csr_owner_epoch, sizeof(dd.ddrk.csr_owner_epoch), + SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t))) + return SGX_ERROR_UNEXPECTED; + if(memcpy_s(&dd.ddrk.cpu_svn, sizeof(dd.ddrk.cpu_svn), + cpusvn, sizeof(sgx_cpu_svn_t))) + return SGX_ERROR_UNEXPECTED; + if(memcpy_s(&dd.ddrk.key_id, sizeof(dd.ddrk.key_id), + &temp_qe_report.key_id, sizeof(sgx_key_id_t))) + return SGX_ERROR_UNEXPECTED; + + sgx_key_128bit_t tmp_report_key; + if(SGX_SUCCESS != (sgx_ret = sgx_cmac128_msg(BASE_REPORT_KEY, dd.ddbuf, dd.size, &tmp_report_key))) + { + if(sgx_ret != SGX_ERROR_OUT_OF_MEMORY) + sgx_ret = SGX_ERROR_UNEXPECTED; + return sgx_ret; + } + + // call cryptographic CMAC function + // CMAC data are *NOT* including MAC and KEYID + if(SGX_SUCCESS != (sgx_ret = sgx_cmac128_msg(tmp_report_key, (const uint8_t *)&temp_qe_report.body, + sizeof(temp_qe_report.body), &temp_qe_report.mac))) + { + if(sgx_ret != SGX_ERROR_OUT_OF_MEMORY) + sgx_ret = SGX_ERROR_UNEXPECTED; + return sgx_ret; + } - ret = ippsAES_CMACGetSize(&ippStateSize); - if(ret != ippStsNoErr)break; - - p_cmac_state = (IppsAES_CMACState*)malloc(ippStateSize); - if(p_cmac_state == NULL) - { - sgx_ret = SGX_ERROR_OUT_OF_MEMORY; - break; - } - - // calculate the derived key - ret = ippsAES_CMACInit((const Ipp8u *)BASE_REPORT_KEY, 16, - p_cmac_state, ippStateSize); - if(ret != ippStsNoErr) - { - if(ret == ippStsMemAllocErr) - { - sgx_ret = SGX_ERROR_OUT_OF_MEMORY; - break; - } - else - { - sgx_ret = SGX_ERROR_UNEXPECTED; - break; - } - } - - ret = ippsAES_CMACUpdate((const Ipp8u *)dd.ddbuf, - dd.size, p_cmac_state); - if(ret != ippStsNoErr)break; - - sgx_key_128bit_t tmp_report_key; - memset(tmp_report_key, 0, sizeof(tmp_report_key)); - ret = ippsAES_CMACFinal((Ipp8u *)&tmp_report_key, - sizeof(tmp_report_key), p_cmac_state); - if(ret != ippStsNoErr)break; - - // call cryptographic CMAC function - // CMAC data are *NOT* including MAC and KEYID - ret = ippsAES_CMACInit((const Ipp8u *)tmp_report_key, 16, - p_cmac_state, ippStateSize); - if(ret != ippStsNoErr) - { - if(ret == ippStsMemAllocErr) - { - sgx_ret = SGX_ERROR_OUT_OF_MEMORY; - break; - } - else - { - sgx_ret = SGX_ERROR_UNEXPECTED; - break; - } - } - - ret = ippsAES_CMACUpdate((const Ipp8u *)&temp_qe_report.body, - sizeof(temp_qe_report.body), - p_cmac_state); - if(ret != ippStsNoErr)break; - - ret = ippsAES_CMACFinal((Ipp8u *)&temp_qe_report.mac, - sizeof(temp_qe_report.mac), p_cmac_state); - if(ret != ippStsNoErr)break; - - if(memcpy_s(p_qe_report, sizeof(*p_qe_report), - &temp_qe_report, sizeof(temp_qe_report))) - break; - sgx_ret = SGX_SUCCESS; - }while(0); - if (p_cmac_state) - free(p_cmac_state); - if(p_sha_state) - free(p_sha_state); + if(memcpy_s(p_qe_report, sizeof(*p_qe_report), + &temp_qe_report, sizeof(temp_qe_report))) + { + sgx_ret = SGX_ERROR_UNEXPECTED; + } return sgx_ret; } diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uinst/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/uinst/Makefile index 766740aade..fb4b09d6de 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uinst/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/uinst/Makefile @@ -44,7 +44,7 @@ CPPFLAGS += -I$(COMMON_DIR)/inc/ \ -I$(SIM_DIR)/assembly/ \ -I$(SIM_DIR)/assembly/linux \ -I$(LINUX_PSW_DIR)/urts \ - -I$(SGX_IPP_INC) + -I$(LINUX_PSW_DIR)/urts/linux CXXFLAGS += -Werror -fPIC diff --git a/sgx-jvm/linux-sgx/sdk/simulation/uinst/u_instructions.cpp b/sgx-jvm/linux-sgx/sdk/simulation/uinst/u_instructions.cpp index ba81895549..59175fa4c5 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/uinst/u_instructions.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/uinst/u_instructions.cpp @@ -50,8 +50,7 @@ #include "enclave_mngr.h" #include "u_instructions.h" -#include "ippcp.h" - +#include "crypto_wrapper.h" static uintptr_t _EINIT(secs_t* secs, enclave_css_t* css, token_t* launch); static uintptr_t _ECREATE (page_info_t* pi); @@ -105,8 +104,19 @@ uintptr_t _EINIT(secs_t* secs, enclave_css_t *css, token_t *launch) mcp_same_size(&this_secs->mr_enclave, &css->body.enclave_hash, sizeof(sgx_measurement_t)); this_secs->isv_prod_id = css->body.isv_prod_id; this_secs->isv_svn = css->body.isv_svn; + + uint8_t signer[SGX_HASH_SIZE] = {0}; + unsigned int signer_len = SGX_HASH_SIZE; + sgx_status_t ret = sgx_EVP_Digest(EVP_sha256(), css->key.modulus, SE_KEY_SIZE, signer, &signer_len); + if(ret != SGX_SUCCESS) + { + if(ret != SGX_ERROR_OUT_OF_MEMORY) + ret = SGX_ERROR_UNEXPECTED; + return ret; + } + assert(signer_len == SGX_HASH_SIZE); - ippsHashMessage(css->key.modulus, SE_KEY_SIZE, (Ipp8u*)&this_secs->mr_signer, IPP_ALG_HASH_SHA256); + mcp_same_size(&this_secs->mr_signer, signer, SGX_HASH_SIZE); } // Check launch token diff --git a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.cpp b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.cpp index 10aa0d03a8..659976dd75 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.cpp +++ b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.cpp @@ -45,6 +45,27 @@ #include #include +#include +#include + + +__attribute__((constructor)) +static void init_openssl(void) +{ + OpenSSL_add_all_algorithms(); + ERR_load_crypto_strings(); +} + +__attribute__((destructor)) +static void cleanup_openssl(void) +{ + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_thread_state(NULL); + ERR_free_strings(); +} + + EnclaveCreator* g_enclave_creator = new EnclaveCreatorSim(); int EnclaveCreatorSim::create_enclave(secs_t *secs, sgx_enclave_id_t *enclave_id, void **start_addr, bool ae) @@ -214,7 +235,7 @@ int EnclaveCreatorSim::initialize(sgx_enclave_id_t enclave_id) //Since CPUID instruction is NOT supported within enclave, we emuerate the cpu features here and send to tRTS. - cpu_sdk_info_t info; + system_features_t info; info.cpu_features = 0; get_cpu_features(&info.cpu_features); info.version = SDK_VERSION_1_5; @@ -237,8 +258,59 @@ bool EnclaveCreatorSim::use_se_hw() const return false; } -bool EnclaveCreatorSim::get_plat_cap(sgx_misc_attribute_t *se_attr) +bool EnclaveCreatorSim::is_EDMM_supported(sgx_enclave_id_t enclave_id) +{ + UNUSED(enclave_id); + return false; +} + +bool EnclaveCreatorSim::is_driver_compatible() +{ + return true; +} + +bool EnclaveCreatorSim::get_plat_cap(sgx_misc_attribute_t *se_attr) { UNUSED(se_attr); return false; } + +int EnclaveCreatorSim::emodpr(uint64_t addr, uint64_t size, uint64_t flag) +{ + UNUSED(addr); + UNUSED(size); + UNUSED(flag); + + return SGX_SUCCESS; +} + +int EnclaveCreatorSim::mktcs(uint64_t tcs_addr) +{ + UNUSED(tcs_addr); + + return SGX_SUCCESS; +} + +int EnclaveCreatorSim::trim_range(uint64_t fromaddr, uint64_t toaddr) +{ + UNUSED(fromaddr); + UNUSED(toaddr); + + return SGX_SUCCESS; + +} + +int EnclaveCreatorSim::trim_accept(uint64_t addr) +{ + UNUSED(addr); + + return SGX_SUCCESS; +} + +int EnclaveCreatorSim::remove_range(uint64_t fromaddr, uint64_t numpages) +{ + UNUSED(fromaddr); + UNUSED(numpages); + + return SGX_SUCCESS; +} diff --git a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.h b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.h index 22b2e9af52..15b400df5d 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.h +++ b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/enclave_creator_sim.h @@ -48,6 +48,13 @@ public: bool get_plat_cap(sgx_misc_attribute_t *se_attr); int initialize(sgx_enclave_id_t enclave_id); bool use_se_hw() const; + bool is_EDMM_supported(sgx_enclave_id_t enclave_id); + bool is_driver_compatible(); + int emodpr(uint64_t addr, uint64_t size, uint64_t flag); + int mktcs(uint64_t tcs_addr); + int trim_range(uint64_t fromaddr, uint64_t toaddr); + int trim_accept(uint64_t addr); + int remove_range(uint64_t fromaddr, uint64_t numpages); }; #endif diff --git a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/linux/Makefile b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/linux/Makefile index 33c92c722f..1953889ccf 100644 --- a/sgx-jvm/linux-sgx/sdk/simulation/urtssim/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/simulation/urtssim/linux/Makefile @@ -59,10 +59,11 @@ DIR1 := $(LINUX_PSW_DIR)/urts/ DIR2 := $(LINUX_PSW_DIR)/urts/linux/ DIR3 := $(LINUX_PSW_DIR)/urts/parser/ DIR4 := ../ +DIR5 := $(LINUX_PSW_DIR)/../common/src/linux +DIR6 := $(LINUX_PSW_DIR)/../common/src LDFLAGS += -L$(COMMON_DIR)/se_wrapper \ -L$(SIM_DIR)/uae_service_sim/linux - LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify/ -littnotify -ldl OBJ1 := enclave.o \ @@ -81,15 +82,19 @@ OBJ2 := urts.o \ misc.o \ sig_handler.o \ debugger_support.o \ - get_thread_id.o + get_thread_id.o \ + urts_trim.o \ + urts_emodpr.o OBJ3 := section.o \ elfparser.o -OBJ4 := enter_enclave.o +OBJ4 := enter_enclave.o \ + xsave_gnu.o OBJ5 := enclave_creator_sim.o \ - cpusvn_util.o + cpusvn_util.o \ + crypto_evp_digest.o OBJ6 := $(SIM_DIR)/driver_api/driver_api.o \ $(SIM_DIR)/assembly/linux/lowlib.o \ @@ -102,16 +107,16 @@ OBJ6 := $(SIM_DIR)/driver_api/driver_api.o \ CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ5) OBJ := $(CPP_OBJ) $(OBJ4) -vpath %.cpp .:$(DIR1):$(DIR2):$(DIR3):$(DIR4) +vpath %.cpp .:$(DIR1):$(DIR2):$(DIR3):$(DIR4):$(DIR6) +vpath %.S .:$(DIR2):$(DIR5) -LDFLAGS += -L$(IPP_LIBS_DIR) -LDFLAGS += -Wl,--version-script=$(LINUX_PSW_DIR)/urts/linux/urts.lds +LDFLAGS += $(COMMON_LDFLAGS) -Wl,--version-script=$(LINUX_PSW_DIR)/urts/linux/urts.lds LIBURTSSIM_SHARED := libsgx_urts_sim.so LIBURTSSIM_DEBUG := libsgx_urts_sim.so.debug LIBURTS_DEPLOY := libsgx_urts_deploy.so -LDLIBS += -lwrapper $(LD_IPP) -Wl,-Bdynamic -Wl,-Bsymbolic -lsgx_uae_service_sim +LDLIBS += -lwrapper -lcrypto -Wl,-Bdynamic -Wl,-Bsymbolic -lsgx_uae_service_sim SONAME = $(LIBURTSSIM_SHARED) .PHONY: all @@ -122,16 +127,8 @@ ifndef DEBUG $(CP) $(LIBURTSSIM_DEBUG) $| endif -ifneq ($(USE_OPT_LIBS), 0) $(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) ittnotify $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@ -else --lcrypto_px: - $(MAKE) -C $(IPP_LIBS_DIR) - -$(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) -lcrypto_px ittnotify - $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@ -endif $(LIBURTSSIM_DEBUG): $(LIBURTSSIM_SHARED) ifndef DEBUG @@ -144,7 +141,7 @@ endif $(BUILD_DIR): @$(MKDIR) $@ -$(OBJ4): %.o: $(DIR2)/%.S +$(OBJ4): %.o: %.S $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ $(CPP_OBJ): %.o: %.cpp @@ -186,7 +183,4 @@ clean:: $(MAKE) -C $(SIM_DIR)/assembly/ clean $(MAKE) -C $(SIM_DIR)/uinst/ clean $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux clean -ifeq ($(USE_OPT_LIBS), 0) - $(MAKE) -C $(IPP_LIBS_DIR) clean -endif $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/ clean diff --git a/sgx-jvm/linux-sgx/sdk/tkey_exchange/Makefile b/sgx-jvm/linux-sgx/sdk/tkey_exchange/Makefile index 92ba224921..fc65481902 100644 --- a/sgx-jvm/linux-sgx/sdk/tkey_exchange/Makefile +++ b/sgx-jvm/linux-sgx/sdk/tkey_exchange/Makefile @@ -44,8 +44,7 @@ INCLUDE += -I$(LINUX_PSW_DIR)/ae/inc \ -I$(LINUX_PSW_DIR)/ae/common \ -I$(LINUX_PSW_DIR)/ae/ -INCLUDE += -I$(SGX_IPP_INC) \ - -I$(LINUX_EXTERNAL_DIR)/epid +INCLUDE += -I$(SGX_IPP_INC) INCLUDE += -I$(LINUX_SDK_DIR)/tlibstdcxx/stlport diff --git a/sgx-jvm/linux-sgx/sdk/tlibc/gen/sbrk.c b/sgx-jvm/linux-sgx/sdk/tlibc/gen/sbrk.c index 973bca1d47..864a5fedae 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibc/gen/sbrk.c +++ b/sgx-jvm/linux-sgx/sdk/tlibc/gen/sbrk.c @@ -33,18 +33,51 @@ #include #include "trts_util.h" - +#include "rts.h" +#include "util.h" +#include "global_data.h" +#include "trts_inst.h" SE_DECLSPEC_EXPORT size_t g_peak_heap_used = 0; /* Please be aware of: sbrk is not thread safe by default. */ +static void *heap_base = NULL; +static size_t heap_size = 0; +static int is_edmm_supported = 0; +static size_t heap_min_size = 0; + +int heap_init(void *_heap_base, size_t _heap_size, size_t _heap_min_size, int _is_edmm_supported) +{ + if (heap_base != NULL) + return SGX_ERROR_UNEXPECTED; + + if ((_heap_base == NULL) || (((size_t) _heap_base) & (SE_PAGE_SIZE - 1))) + return SGX_ERROR_UNEXPECTED; + + if (_heap_size & (SE_PAGE_SIZE - 1)) + return SGX_ERROR_UNEXPECTED; + + if (_heap_min_size & (SE_PAGE_SIZE - 1)) + return SGX_ERROR_UNEXPECTED; + + if (_heap_size > SIZE_MAX - (size_t)heap_base) + return SGX_ERROR_UNEXPECTED; + + heap_base = _heap_base; + heap_size = _heap_size; + heap_min_size = _heap_min_size; + is_edmm_supported = _is_edmm_supported; + + return SGX_SUCCESS; +} + void* sbrk(intptr_t n) { static size_t heap_used; void *heap_ptr = NULL; - - void *heap_base = get_heap_base(); - size_t heap_size = get_heap_size(); + size_t prev_heap_used = heap_used; + void * start_addr; + size_t size = 0; if (!heap_base) return (void *)(~(size_t)0); @@ -52,24 +85,81 @@ void* sbrk(intptr_t n) /* shrink the heap */ if (n < 0) { - if (heap_used <= INTPTR_MAX && ((intptr_t)heap_used + n) < 0) + n *= -1; + if (heap_used < n) return (void *)(~(size_t)0); - heap_used += n; + heap_used -= n; + + /* heap_used is never larger than heap_size, and since heap_size <= SIZE_MAX - (size_t)heap_base, + there's no integer overflow here. + */ heap_ptr = (void *)((size_t)heap_base + (size_t)heap_used); + if (is_edmm_supported && (prev_heap_used > heap_min_size)) + { + assert((n & (SE_PAGE_SIZE - 1)) == 0); + + if (heap_used > heap_min_size) + { + start_addr = heap_ptr; + size = n; + } + else + { + /* heap_min_size is never larger than heap_size, and since heap_size <= SIZE_MAX - (size_t)heap_base, + there's no integer overflow here. + */ + start_addr = (void *)((size_t)(heap_base) + heap_min_size); + size = prev_heap_used - heap_min_size; + } + int ret = trim_EPC_pages(start_addr, size >> SE_PAGE_SHIFT); + if (ret != 0) + { + heap_used = prev_heap_used; + return (void *)(~(size_t)0); + } + } return heap_ptr; } /* extend the heap */ - if ((heap_used + n) > heap_size) + if((heap_used > (SIZE_MAX - n)) || ((heap_used + n) > heap_size)) return (void *)(~(size_t)0); + /* heap_used is never larger than heap_size, and since heap_size <= SIZE_MAX - (size_t)heap_base, + there's no integer overflow here. + */ heap_ptr = (void *)((size_t)heap_base + (size_t)heap_used); heap_used += n; /* update g_peak_heap_used */ g_peak_heap_used = (g_peak_heap_used < heap_used) ? heap_used : g_peak_heap_used; + if (is_edmm_supported && heap_used > heap_min_size) + { + assert((n & (SE_PAGE_SIZE - 1)) == 0); + + if (prev_heap_used > heap_min_size) + { + start_addr = heap_ptr; + size = n; + } + else + { + + /* heap_min_size is never larger than heap_size, and since heap_size <= SIZE_MAX - (size_t)heap_base, + there's no integer overflow here. + */ + start_addr = (void *)((size_t)(heap_base) + heap_min_size); + size = heap_used - heap_min_size; + } + int ret = apply_EPC_pages(start_addr, size >> SE_PAGE_SHIFT); + if (ret != 0) + { + heap_used = prev_heap_used; + return (void *)(~(size_t)0); + } + } return heap_ptr; } diff --git a/sgx-jvm/linux-sgx/sdk/tlibc/stdlib/malloc.c b/sgx-jvm/linux-sgx/sdk/tlibc/stdlib/malloc.c index 4d17838f1b..9893dfefd4 100755 --- a/sgx-jvm/linux-sgx/sdk/tlibc/stdlib/malloc.c +++ b/sgx-jvm/linux-sgx/sdk/tlibc/stdlib/malloc.c @@ -837,14 +837,14 @@ extern "C" { #if !ONLY_MSPACES /* ------------------- Declarations of public routines ------------------- */ - #ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlrealloc realloc -#define dlmallinfo mallinfo + #define ALIAS(tc_fn) __attribute__ ((alias (#tc_fn), used)) + void* __attribute__((weak)) malloc(size_t size) ALIAS(dlmalloc); + void __attribute__((weak)) free(void* ptr) ALIAS(dlfree); + void* __attribute__((weak)) realloc(void* ptr, size_t size) ALIAS(dlrealloc); + void* __attribute__((weak)) calloc(size_t n, size_t size) ALIAS(dlcalloc); + void* __attribute__((weak)) memalign(size_t align, size_t s) ALIAS(dlmemalign); + struct mallinfo __attribute__((weak)) mallinfo(void) ALIAS(dlmallinfo); #ifdef USE_MALLOC_DEPRECATED #define dlposix_memalign posix_memalign #define dlrealloc_in_place realloc_in_place @@ -879,10 +879,7 @@ extern "C" { maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ -DLMALLOC_EXPORT void* __tlibc_malloc(size_t); -DLMALLOC_EXPORT __attribute__((weak)) void* dlmalloc(size_t n) { - return __tlibc_malloc(n); -} +DLMALLOC_EXPORT void* dlmalloc(size_t); /* free(void* p) @@ -891,20 +888,14 @@ DLMALLOC_EXPORT __attribute__((weak)) void* dlmalloc(size_t n) { It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ -DLMALLOC_EXPORT void __tlibc_free(void *); -DLMALLOC_EXPORT __attribute__((weak)) void dlfree(void *p) { - __tlibc_free(p); -} +DLMALLOC_EXPORT void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ -DLMALLOC_EXPORT void* __tlibc_calloc(size_t n_elements, size_t element_size); -DLMALLOC_EXPORT __attribute__((weak)) void* dlcalloc(size_t n_elements, size_t element_size) { - return __tlibc_calloc(n_elements, element_size); -} +DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) @@ -928,10 +919,8 @@ DLMALLOC_EXPORT __attribute__((weak)) void* dlcalloc(size_t n_elements, size_t e The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ -DLMALLOC_EXPORT void* __tlibc_realloc(void* p, size_t n); -DLMALLOC_EXPORT __attribute__((weak)) void* dlrealloc(void* p, size_t n) { - return __tlibc_realloc(p, n); -} +DLMALLOC_EXPORT void* dlrealloc(void*, size_t); + #ifdef USE_MALLOC_DEPRECATED /* realloc_in_place(void* p, size_t n) @@ -961,10 +950,7 @@ DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); Overreliance on memalign is a sure way to fragment space. */ -DLMALLOC_EXPORT void* __tlibc_memalign(size_t alignment, size_t n); -DLMALLOC_EXPORT __attribute__((weak)) void* dlmemalign(size_t alignment, size_t n) { - return __tlibc_memalign(alignment, n); -} +DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); #ifdef USE_MALLOC_DEPRECATED /* @@ -4612,7 +4598,7 @@ static void* tmalloc_small(mstate m, size_t nb) { #if !ONLY_MSPACES -void* __tlibc_malloc(size_t bytes) { +void* dlmalloc(size_t bytes) { /* Basic algorithm: If a small request (< 256 bytes minus per-chunk overhead): @@ -4751,7 +4737,7 @@ void* __tlibc_malloc(size_t bytes) { /* ---------------------------- free --------------------------- */ -void __tlibc_free(void* mem) { +void dlfree(void* mem) { /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed @@ -4860,7 +4846,7 @@ void __tlibc_free(void* mem) { #endif /* FOOTERS */ } -void* __tlibc_calloc(size_t n_elements, size_t elem_size) { +void* dlcalloc(size_t n_elements, size_t elem_size) { void* mem; size_t req = 0; if (n_elements != 0) { @@ -5260,7 +5246,7 @@ static void internal_inspect_all(mstate m, #if !ONLY_MSPACES -void* __tlibc_realloc(void* oldmem, size_t bytes) { +void* dlrealloc(void* oldmem, size_t bytes) { void* mem = 0; if (oldmem == 0) { mem = dlmalloc(bytes); @@ -5342,7 +5328,7 @@ void* dlrealloc_in_place(void* oldmem, size_t bytes) { } #endif -void* __tlibc_memalign(size_t alignment, size_t bytes) { +void* dlmemalign(size_t alignment, size_t bytes) { if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/Makefile b/sgx-jvm/linux-sgx/sdk/tlibcrypto/Makefile index 2f769da35d..8d86c6b2e4 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/Makefile +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/Makefile @@ -31,39 +31,88 @@ include ../../buildenv.mk -CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti - CPPFLAGS := -I$(COMMON_DIR)/inc/internal \ -I$(COMMON_DIR)/inc \ - -I$(COMMON_DIR)/inc/tlibc \ - -I$(SGX_IPP_INC) + -I$(COMMON_DIR)/inc/tlibc -ifneq ($(USE_OPT_LIBS), 0) - CXXFLAGS += -DSGX_USE_OPT_LIB +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti + +OBJ = init_tcrypto_lib.o sgx_aes_ctr.o sgx_aes_gcm.o sgx_cmac128.o sgx_ecc256.o sgx_ecc256_ecdsa.o sgx_sha256.o sgx_sha256_msg.o sgx_ecc256_internal.o sgx_rsa3072.o +SHARED_OBJ = tcrypto_version.o + +ifneq ($(USE_OPT_LIBS), 1) + +# Added to build with SgxSSL libraries +ifeq ($(ARCH), x86_64) + OPENSSL_PACKAGE = $(LINUX_EXTERNAL_DIR)/sgxssl/package +else + $(error SGXSSL doesn't support 32bit) +endif #($(ARCH), x86_64) + +ifdef DEBUG + OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/debug +else + OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/release endif -OBJ = init_tcrypto_lib.o sgx_aes_ctr.o sgx_aes_gcm.o sgx_cmac128.o sgx_ecc256.o sgx_ecc256_common.o sgx_ecc256_ecdsa.o sgx_sha256.o sgx_sha256_msg.o tcrypto_version.o sgx_ecc512.o sgx_rsa3072.o +SGXSSL_Library_Name := sgx_tsgxssl +OpenSSL_Crypto_Library_Name := sgx_tsgxssl_crypto +PREPARE_SGXSSL := $(LINUX_EXTERNAL_DIR)/sgxssl/prepare_sgxssl.sh +PREPRARE_SGX_SSL: + chmod 755 $(PREPARE_SGXSSL) + test -f $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a || $(PREPARE_SGXSSL) + +CPPFLAGS += -I$(OPENSSL_PACKAGE)/include +CXXFLAGS += -DUSE_SGXSSL +SRCDIR := sgxssl + +LIB_NAME := libsgx_tcrypto_sgxssl.a + +else + +CPPFLAGS += -I$(SGX_IPP_INC) +OBJ += sgx_ecc256_common.o +SRCDIR := ipp + +LIB_NAME := libsgx_tcrypto_ipp.a + +endif #!($(USE_OPT_LIBS), 1) + +OBJ := $(addprefix $(SRCDIR)/, $(OBJ)) +LIB_NAME := $(addprefix $(SRCDIR)/, $(LIB_NAME)) TARGET := libsgx_tcrypto.a -ifneq ($(USE_OPT_LIBS), 0) -$(TARGET): $(OBJ) +ifneq ($(USE_OPT_LIBS), 1) + +$(TARGET): PREPRARE_SGX_SSL + $(MAKE) $(OBJ) + $(MAKE) $(SHARED_OBJ) + $(MKDIR) $(BUILD_DIR)/.libs + $(RM) $(BUILD_DIR)/.libs/* + cd $(BUILD_DIR)/.libs && \ + $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(OpenSSL_Crypto_Library_Name).a && \ + $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a + $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libs/*.o + $(CP) $(LIB_NAME) $@ + $(RM) -r $(BUILD_DIR)/.libs +else + +$(TARGET): $(OBJ) $(SHARED_OBJ) $(MKDIR) $(BUILD_DIR)/.libippcore $(RM) $(BUILD_DIR)/.libippcore/* cd $(BUILD_DIR)/.libippcore && $(AR) x $(IPP_LIBS_DIR)/libippcore.a - @$(CP) $(IPP_LIBS_DIR)/libippcp.a $@ - $(AR) rsD $@ $(OBJ) $(BUILD_DIR)/.libippcore/*.o + @$(CP) $(IPP_LIBS_DIR)/libippcp.a $(LIB_NAME) + $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libippcore/*.o + $(CP) $(LIB_NAME) $@ $(RM) -r $(BUILD_DIR)/.libippcore -else -libcrypto_px: - $(MAKE) -C $(SGX_IPP_DIR) -$(TARGET): $(OBJ) libcrypto_px - @$(CP) $(SGX_IPP_DIR)/libcrypto_px.a $@ - $(AR) rsD $@ $(OBJ) -endif +endif #!($(USE_OPT_LIBS), 1) -$(OBJ): %.o: %.cpp +$(SRCDIR)/%.o: $(SRCDIR)/%.cpp + $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + +$(SHARED_OBJ): %.o: %.cpp $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ $(BUILD_DIR): @@ -75,10 +124,7 @@ all: $(TARGET) | $(BUILD_DIR) .PHONY: clean clean: -ifeq ($(USE_OPT_LIBS), 0) - $(MAKE) -C $(SGX_IPP_DIR) clean -endif - @$(RM) *.o $(TARGET) $(BUILD_DIR)/$(TARGET) + @$(RM) *.o ipp/*.o sgxssl/*.o $(TARGET) $(BUILD_DIR)/$(TARGET) $(LIB_NAME) .PHONY: rebuild rebuild: diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/init_tcrypto_lib.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/init_tcrypto_lib.cpp similarity index 93% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/init_tcrypto_lib.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/init_tcrypto_lib.cpp index a0b87f8f5a..213d3984cd 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/init_tcrypto_lib.cpp +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/init_tcrypto_lib.cpp @@ -39,7 +39,6 @@ // add a version to tcrypto. SGX_ACCESS_VERSION(tcrypto, 1) -#ifdef SGX_USE_OPT_LIB /* Crypto Library Initialization * Parameters: @@ -109,10 +108,6 @@ extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator) { ippCpuFeatures |= ippCPUID_PREFETCHW; } - if ((cpu_feature_indicator & CPU_FEATURE_PCLMULQDQ) == CPU_FEATURE_PCLMULQDQ) - { - ippCpuFeatures |= ippCPUID_CLMUL; - } } else { @@ -131,12 +126,3 @@ extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator) return SGX_SUCCESS; } -#else - -extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator) -{ - (void) cpu_feature_indicator; - return SGX_SUCCESS; -} - -#endif diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_aes_ctr.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_aes_ctr.cpp similarity index 99% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_aes_ctr.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_aes_ctr.cpp index eaab229f6a..a0040bf117 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_aes_ctr.cpp +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_aes_ctr.cpp @@ -29,7 +29,6 @@ * */ - #include "sgx_tcrypto.h" #include "ippcp.h" #include "stdlib.h" diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_aes_gcm.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_aes_gcm.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_aes_gcm.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_aes_gcm.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_cmac128.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_cmac128.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_cmac128.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_cmac128.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_common.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_common.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_common.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_common.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_common.h b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_common.h similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_common.h rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_common.h diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_ecdsa.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_ecdsa.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc256_ecdsa.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_ecdsa.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc512.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_internal.cpp similarity index 83% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc512.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_internal.cpp index 9d9189520f..458496742e 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_ecc512.cpp +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_ecc256_internal.cpp @@ -33,18 +33,21 @@ #include "sgx_ecc256_common.h" +#include "sgx_ecc256_internal.h" -/* Computes 512-bit DH shared key based on private B key (local) and remote public Ga Key + + +/* 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 sgx_error.h - * Inputs: sgx_ecc_state_handle_t ecc_handle ?Handle to ECC crypto system + * Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system * sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN - * Output: sgx_ec256_dh_shared_t *p_shared_key ?Pointer to the shared DH key - LITTLE ENDIAN - x-coordinate of (privKeyB ?pubKeyA) */ -sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b, + * Output: sgx_ec256_shared_point_t *p_shared_key - Pointer to the target shared point - LITTLE ENDIAN + x-coordinate of (privKeyB - pubKeyA) */ +sgx_status_t sgx_ecc256_compute_shared_point(sgx_ec256_private_t *p_private_b, sgx_ec256_public_t *p_public_ga, - sgx_ec256_dh_shared512_t *p_shared_key, + sgx_ec256_shared_point_t *p_shared_key, sgx_ecc_state_handle_t ecc_handle) { if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) @@ -53,8 +56,8 @@ sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b } IppsBigNumState* BN_dh_privB = NULL; - IppsBigNumState* BN_dh_share512_x = NULL; - IppsBigNumState* BN_dh_share512_y = NULL; + IppsBigNumState* BN_dh_shared_x = NULL; + IppsBigNumState* BN_dh_shared_y = NULL; IppsBigNumState* pubA_gx = NULL; IppsBigNumState* pubA_gy = NULL; IppsECCPPointState* point_pubA = NULL; @@ -85,7 +88,7 @@ sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b ipp_ret = ippsECCPSetPoint(pubA_gx, pubA_gy, point_pubA, p_ecc_state); ERROR_BREAK(ipp_ret); - //defense in depth to verify that input publick key in ECC group + //defense in depth to verify that input public key in ECC group //a return value of ippECValid indicates the point is on the elliptic curve //and is not the point at infinity ipp_ret = ippsECCPCheckPoint(point_pubA, &ipp_result, p_ecc_state); @@ -106,9 +109,9 @@ sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b ipp_ret = ippsECCPPointInit(256, point_R); ERROR_BREAK(ipp_ret); - ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_share512_x); + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_shared_x); ERROR_BREAK(ipp_ret); - ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_share512_y); + ipp_ret = sgx_ipp_newBN(NULL, sizeof(sgx_ec256_dh_shared_t), &BN_dh_shared_y); ERROR_BREAK(ipp_ret); ipp_ret = ippsECCPMulPointScalar(point_pubA, BN_dh_privB, point_R, p_ecc_state); @@ -126,20 +129,20 @@ sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b break; } - ipp_ret = ippsECCPGetPoint(BN_dh_share512_x, BN_dh_share512_y, point_R, p_ecc_state); + ipp_ret = ippsECCPGetPoint(BN_dh_shared_x, BN_dh_shared_y, point_R, p_ecc_state); ERROR_BREAK(ipp_ret); IppsBigNumSGN sgn = IppsBigNumPOS; int length = 0; Ipp32u *pdata = NULL; - ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share512_x); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_shared_x); ERROR_BREAK(ipp_ret); memset(p_shared_key->x, 0, sizeof(p_shared_key->x)); memcpy(p_shared_key->x, pdata, ROUND_TO(length, 8)/8); // Clear memory securely memset_s(pdata, sizeof(p_shared_key->x), 0, ROUND_TO(length, 8)/8); - ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_share512_y); + ipp_ret = ippsRef_BN(&sgn, &length, &pdata, BN_dh_shared_y); ERROR_BREAK(ipp_ret); memset(p_shared_key->y, 0, sizeof(p_shared_key->y)); memcpy(p_shared_key->y, pdata, ROUND_TO(length, 8)/8); @@ -153,8 +156,8 @@ sgx_status_t sgx_ecc256_compute_shared_dhkey512(sgx_ec256_private_t *p_private_b sgx_ipp_secure_free_BN(pubA_gx, sizeof(p_public_ga->gx)); sgx_ipp_secure_free_BN(pubA_gy, sizeof(p_public_ga->gy)); sgx_ipp_secure_free_BN(BN_dh_privB, sizeof(sgx_ec256_private_t)); - sgx_ipp_secure_free_BN(BN_dh_share512_x, sizeof(sgx_ec256_dh_shared_t)); - sgx_ipp_secure_free_BN(BN_dh_share512_y, sizeof(sgx_ec256_dh_shared_t)); + sgx_ipp_secure_free_BN(BN_dh_shared_x, sizeof(sgx_ec256_dh_shared_t)); + sgx_ipp_secure_free_BN(BN_dh_shared_y, sizeof(sgx_ec256_dh_shared_t)); if (ipp_ret == ippStsNoMemErr || ipp_ret == ippStsMemAllocErr) { diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_rsa3072.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_rsa3072.cpp similarity index 88% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_rsa3072.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_rsa3072.cpp index 45906e9d17..579666f485 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_rsa3072.cpp +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_rsa3072.cpp @@ -33,12 +33,12 @@ #include "sgx_ecc256_common.h" -sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, - uint32_t data_size, - const sgx_rsa3072_private_key_t * p_private, +sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, + uint32_t data_size, + const sgx_rsa3072_key_t * p_key, sgx_rsa3072_signature_t * p_signature) { - if ((p_data == NULL) || (data_size < 1) || (p_private == NULL) || + if ((p_data == NULL) || (data_size < 1) || (p_key == NULL) || (p_signature == NULL) ) { return SGX_ERROR_INVALID_PARAMETER; @@ -50,15 +50,15 @@ sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, Ipp8u *temp_buff = NULL; IppsBigNumState* p_prikey_mod_bn = NULL; - IppsBigNumState* p_prikey_exp_bn = NULL; + IppsBigNumState* p_prikey_d_bn = NULL; do { - // Initializa IPP BN from the private key - ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_private->mod, sizeof(p_private->mod), &p_prikey_mod_bn); + // Initializa IPP BN from the private key + ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_key->mod, sizeof(p_key->mod), &p_prikey_mod_bn); ERROR_BREAK(ipp_ret); - ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_private->exp, sizeof(p_private->exp), &p_prikey_exp_bn); + ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_key->d, sizeof(p_key->d), &p_prikey_d_bn); ERROR_BREAK(ipp_ret); // allocate private key context @@ -79,10 +79,10 @@ sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, p_rsa_privatekey_ctx, private_key_ctx_size); ERROR_BREAK(ipp_ret); - ipp_ret = ippsRSA_SetPrivateKeyType1(p_prikey_mod_bn, p_prikey_exp_bn, p_rsa_privatekey_ctx); + ipp_ret = ippsRSA_SetPrivateKeyType1(p_prikey_mod_bn, p_prikey_d_bn, p_rsa_privatekey_ctx); ERROR_BREAK(ipp_ret); - // allocate temp buffer for RSA calculation + // allocate temp buffer for RSA calculation int private_key_buffer_size = 0; ipp_ret = ippsRSA_GetBufferSizePrivateKey(&private_key_buffer_size, p_rsa_privatekey_ctx); @@ -99,8 +99,8 @@ sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, } while (0); - sgx_ipp_secure_free_BN(p_prikey_mod_bn, sizeof(p_private->mod)); - sgx_ipp_secure_free_BN(p_prikey_exp_bn, sizeof(p_private->exp)); + sgx_ipp_secure_free_BN(p_prikey_mod_bn, sizeof(p_key->mod)); + sgx_ipp_secure_free_BN(p_prikey_d_bn, sizeof(p_key->d)); SAFE_FREE(p_rsa_privatekey_ctx); SAFE_FREE(temp_buff); @@ -144,7 +144,7 @@ sgx_status_t sgx_rsa3072_verify(const uint8_t *p_data, do { - // Initializa IPP BN from the public key + // Initializa IPP BN from the public key ipp_ret = sgx_ipp_newBN((const Ipp32u *)p_public->mod, sizeof(p_public->mod), &p_pubkey_mod_bn); ERROR_BREAK(ipp_ret); @@ -172,7 +172,7 @@ sgx_status_t sgx_rsa3072_verify(const uint8_t *p_data, ipp_ret = ippsRSA_SetPublicKey(p_pubkey_mod_bn, p_pubkey_exp_bn, p_rsa_publickey_ctx); ERROR_BREAK(ipp_ret); - // allocate temp buffer for RSA calculation + // allocate temp buffer for RSA calculation int public_key_buffer_size = 0; ipp_ret = ippsRSA_GetBufferSizePublicKey(&public_key_buffer_size, p_rsa_publickey_ctx); @@ -184,7 +184,7 @@ sgx_status_t sgx_rsa3072_verify(const uint8_t *p_data, break; } - // verify the signature + // verify the signature ipp_ret = ippsRSAVerify_PKCS1v15(p_data, data_size, *p_signature, &result, p_rsa_publickey_ctx, hash_alg, temp_buff); } while (0); diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_sha256.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_sha256.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_sha256.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_sha256.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_sha256_msg.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_sha256_msg.cpp similarity index 100% rename from sgx-jvm/linux-sgx/sdk/tlibcrypto/sgx_sha256_msg.cpp rename to sgx-jvm/linux-sgx/sdk/tlibcrypto/ipp/sgx_sha256_msg.cpp diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/init_tcrypto_lib.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/init_tcrypto_lib.cpp new file mode 100644 index 0000000000..431cd42be8 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/init_tcrypto_lib.cpp @@ -0,0 +1,64 @@ +/* + * 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 "se_tcrypto_common.h" +#include "sgx_tcrypto.h" +#include "se_cpu_feature.h" +#include "se_cdefs.h" + +// add a version to tcrypto. +SGX_ACCESS_VERSION(tcrypto, 1) + + +// SGXSSL's function. register and init cpuid exception handler. +// +extern "C" void init_exception_handler(void); +unsigned long openssl_last_err = 0; + +/* Crypto Library Initialization +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: uint64_t cpu_feature_indicator - Bit array of host CPU feature bits */ +extern "C" sgx_status_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator) +{ + (void)(cpu_feature_indicator); + + // prevent linker from optimizing init_exception_handler function. + // **DON'T REMOVE** + // + volatile int dead_code_flag = 0; + if (dead_code_flag == 1) { + init_exception_handler(); + } + + return SGX_SUCCESS; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_ctr.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_ctr.cpp new file mode 100644 index 0000000000..8f783a102b --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_ctr.cpp @@ -0,0 +1,221 @@ +/* + * 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 "stdlib.h" +#include "string.h" +#include "sgx_tcrypto.h" +#include "se_tcrypto_common.h" +#include "openssl/aes.h" +#include "openssl/evp.h" +#include "openssl/err.h" + +#define SGXSSL_CTR_BITS 128 +#define SHIFT_BYTE 8 + +/* +* code taken from OpenSSL project. +* increment counter (128-bit int) by 1 +*/ +static void ctr128_inc(unsigned char *counter) +{ + unsigned int n = 16, c = 1; + + do { + --n; + c += counter[n]; + counter[n] = (unsigned char)c; + c >>= SHIFT_BYTE; + } while (n); +} + +/* AES-CTR 128-bit + * Parameters: + * Return: + * sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h + * Inputs: + * sgx_aes_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 encrypted/decrypted + * uint32_t src_len - Length of the input stream to be encrypted/decrypted + * uint8_t *p_ctr - Pointer to the counter block + * uint32_t ctr_inc_bits - Number of bits in counter to be incremented + * Output: + * uint8_t *p_dst - Pointer to the cipher text. Size of buffer should be >= src_len. + */ +sgx_status_t sgx_aes_ctr_encrypt(const sgx_aes_ctr_128bit_key_t *p_key, const uint8_t *p_src, + const uint32_t src_len, uint8_t *p_ctr, const uint32_t ctr_inc_bits, + uint8_t *p_dst) +{ + + if ((src_len > INT_MAX) || (p_key == NULL) || (p_src == NULL) || (p_ctr == NULL) || (p_dst == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + /* SGXSSL based crypto implementation */ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int len = 0; + EVP_CIPHER_CTX* ptr_ctx = NULL; + + // OpenSSL assumes that the counter is in the x lower bits of the IV(ivec), and that the + // application has full control over overflow and the rest of the IV. This + // implementation takes NO responsibility for checking that the counter + // doesn't overflow into the rest of the IV when incremented. + // + if (ctr_inc_bits != SGXSSL_CTR_BITS) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // Create and init ctx + // + if (!(ptr_ctx = EVP_CIPHER_CTX_new())) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // Initialise encrypt, key + // + if (1 != EVP_EncryptInit_ex(ptr_ctx, EVP_aes_128_ctr(), NULL, (unsigned char*)p_key, p_ctr)) { + break; + } + + // Provide the message to be encrypted, and obtain the encrypted output. + // + if (1 != EVP_EncryptUpdate(ptr_ctx, p_dst, &len, p_src, src_len)) { + break; + } + + // Finalise the encryption + // + if (1 != EVP_EncryptFinal_ex(ptr_ctx, p_dst + len, &len)) { + break; + } + + // Encryption success, increment counter + // + len = src_len; + while (len >= 0) { + ctr128_inc(p_ctr); + len -= 16; + } + ret = SGX_SUCCESS; + } while (0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + //clean up ctx and return + // + if (ptr_ctx) { + EVP_CIPHER_CTX_free(ptr_ctx); + } + return ret; +} + + +sgx_status_t sgx_aes_ctr_decrypt(const sgx_aes_ctr_128bit_key_t *p_key, const uint8_t *p_src, + const uint32_t src_len, uint8_t *p_ctr, const uint32_t ctr_inc_bits, + uint8_t *p_dst) +{ + + if ((src_len > INT_MAX) || (p_key == NULL) || (p_src == NULL) || (p_ctr == NULL) || (p_dst == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + /* SGXSSL based crypto implementation */ + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int len = 0; + EVP_CIPHER_CTX* ptr_ctx = NULL; + + // OpenSSL assumes that the counter is in the x lower bits of the IV(ivec), and that the + // application has full control over overflow and the rest of the IV. This + // implementation takes NO responsibility for checking that the counter + // doesn't overflow into the rest of the IV when incremented. + // + if (ctr_inc_bits != SGXSSL_CTR_BITS) { + return SGX_ERROR_INVALID_PARAMETER; + } + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // Create and initialise the context + // + if (!(ptr_ctx = EVP_CIPHER_CTX_new())) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // Initialise decrypt, key and CTR + // + if (!EVP_DecryptInit_ex(ptr_ctx, EVP_aes_128_ctr(), NULL, (unsigned char*)p_key, p_ctr)) { + break; + } + + // Decrypt message, obtain the plaintext output + // + if (!EVP_DecryptUpdate(ptr_ctx, p_dst, &len, p_src, src_len)) { + break; + } + + // Finalise the decryption. A positive return value indicates success, + // anything else is a failure - the plaintext is not trustworthy. + // + if (EVP_DecryptFinal_ex(ptr_ctx, p_dst + len, &len) <= 0) { // same notes as above - you can't write beyond src_len + break; + } + // Success + // Increment counter + // + len = src_len; + while (len >= 0) { + ctr128_inc(p_ctr); + len -= 16; + } + ret = SGX_SUCCESS; + } while (0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + //cleanup ctx, and return + // + if (ptr_ctx) { + EVP_CIPHER_CTX_free(ptr_ctx); + } + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_gcm.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_gcm.cpp new file mode 100644 index 0000000000..8abf94bb43 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_aes_gcm.cpp @@ -0,0 +1,202 @@ +/* + * 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 "stdlib.h" +#include "string.h" +#include "sgx_tcrypto.h" +#include "se_tcrypto_common.h" +#include "openssl/aes.h" +#include "openssl/evp.h" +#include "openssl/err.h" +#define OPENSSL_DEFAULT_IV_LEN 12 + +/* Rijndael AES-GCM +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_aes_gcm_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be encrypted/decrypted +* uint32_t src_len - Length of input stream to be encrypted/decrypted +* uint8_t *p_iv - Pointer to initialization vector to use +* uint32_t iv_len - Length of initialization vector +* uint8_t *p_aad - Pointer to input stream of additional authentication data +* uint32_t aad_len - Length of additional authentication data stream +* sgx_aes_gcm_128bit_tag_t *p_in_mac - Pointer to expected MAC in decryption process +* Output: uint8_t *p_dst - Pointer to cipher text. Size of buffer should be >= src_len. +* sgx_aes_gcm_128bit_tag_t *p_out_mac - Pointer to MAC generated from encryption process +* NOTE: Wrapper is responsible for confirming decryption tag matches encryption tag */ +sgx_status_t sgx_rijndael128GCM_encrypt(const sgx_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, uint32_t src_len, + uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, const uint8_t *p_aad, uint32_t aad_len, + sgx_aes_gcm_128bit_tag_t *p_out_mac) +{ + if ((src_len > INT_MAX) || (aad_len > INT_MAX) || (p_key == NULL) || ((src_len > 0) && (p_dst == NULL)) || ((src_len > 0) && (p_src == NULL)) + || (p_out_mac == NULL) || (iv_len != SGX_AESGCM_IV_SIZE) || ((aad_len > 0) && (p_aad == NULL)) + || (p_iv == NULL) || ((p_src == NULL) && (p_aad == NULL))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + int len = 0; + EVP_CIPHER_CTX * pState = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // Create and init ctx + // + if (!(pState = EVP_CIPHER_CTX_new())) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // Initialise encrypt, key and IV + // + if (1 != EVP_EncryptInit_ex(pState, EVP_aes_128_gcm(), NULL, (unsigned char*)p_key, p_iv)) { + break; + } + + // Provide AAD data if exist + // + if (NULL != p_aad) { + if (1 != EVP_EncryptUpdate(pState, NULL, &len, p_aad, aad_len)) { + break; + } + } + + // Provide the message to be encrypted, and obtain the encrypted output. + // + if (1 != EVP_EncryptUpdate(pState, p_dst, &len, p_src, src_len)) { + break; + } + + // Finalise the encryption + // + if (1 != EVP_EncryptFinal_ex(pState, p_dst + len, &len)) { + break; + } + + // Get tag + // + if (1 != EVP_CIPHER_CTX_ctrl(pState, EVP_CTRL_GCM_GET_TAG, SGX_AESGCM_MAC_SIZE, p_out_mac)) { + break; + } + ret = SGX_SUCCESS; + } while (0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + // Clean up and return + // + if (pState) { + EVP_CIPHER_CTX_free(pState); + } + return ret; +} + +sgx_status_t sgx_rijndael128GCM_decrypt(const sgx_aes_gcm_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, uint8_t *p_dst, const uint8_t *p_iv, uint32_t iv_len, + const uint8_t *p_aad, uint32_t aad_len, const sgx_aes_gcm_128bit_tag_t *p_in_mac) +{ + uint8_t l_tag[SGX_AESGCM_MAC_SIZE]; + + if ((src_len > INT_MAX) || (aad_len > INT_MAX) || (p_key == NULL) || ((src_len > 0) && (p_dst == NULL)) || ((src_len > 0) && (p_src == NULL)) + || (p_in_mac == NULL) || (iv_len != SGX_AESGCM_IV_SIZE) || ((aad_len > 0) && (p_aad == NULL)) + || (p_iv == NULL) || ((p_src == NULL) && (p_aad == NULL))) + { + return SGX_ERROR_INVALID_PARAMETER; + } + int len = 0; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + EVP_CIPHER_CTX * pState = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + // Autenthication Tag returned by Decrypt to be compared with Tag created during seal + // + memset_s(&l_tag, SGX_AESGCM_MAC_SIZE, 0, SGX_AESGCM_MAC_SIZE); + memcpy(l_tag, p_in_mac, SGX_AESGCM_MAC_SIZE); + + do { + // Create and initialise the context + // + if (!(pState = EVP_CIPHER_CTX_new())) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // Initialise decrypt, key and IV + // + if (!EVP_DecryptInit_ex(pState, EVP_aes_128_gcm(), NULL, (unsigned char*)p_key, p_iv)) { + break; + } + + // Provide AAD data if exist + // + if (NULL != p_aad) { + if (!EVP_DecryptUpdate(pState, NULL, &len, p_aad, aad_len)) { + break; + } + } + + // Decrypt message, obtain the plaintext output + // + if (!EVP_DecryptUpdate(pState, p_dst, &len, p_src, src_len)) { + break; + } + + // Update expected tag value + // + if (!EVP_CIPHER_CTX_ctrl(pState, EVP_CTRL_GCM_SET_TAG, SGX_AESGCM_MAC_SIZE, l_tag)) { + break; + } + + // Finalise the decryption. A positive return value indicates success, + // anything else is a failure - the plaintext is not trustworthy. + // + if (EVP_DecryptFinal_ex(pState, p_dst + len, &len) <= 0) { + break; + } + ret = SGX_SUCCESS; + } while (0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + // Clean up and return + // + if (pState != NULL) { + EVP_CIPHER_CTX_free(pState); + } + memset_s(&l_tag, SGX_AESGCM_MAC_SIZE, 0, SGX_AESGCM_MAC_SIZE); + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_cmac128.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_cmac128.cpp new file mode 100644 index 0000000000..94217c97cf --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_cmac128.cpp @@ -0,0 +1,216 @@ +/* + * 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 "stdlib.h" +#include "string.h" +#include "sgx_tcrypto.h" +#include "se_tcrypto_common.h" +#include "openssl/cmac.h" +#include "openssl/err.h" + +/* Message Authentication - Rijndael 128 CMAC +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_cmac_128bit_key_t *p_key - Pointer to key used in encryption/decryption operation +* uint8_t *p_src - Pointer to input stream to be MACed +* uint32_t src_len - Length of input stream to be MACed +* Output: sgx_cmac_gcm_128bit_tag_t *p_mac - Pointer to resultant MAC */ +sgx_status_t sgx_rijndael128_cmac_msg(const sgx_cmac_128bit_key_t *p_key, const uint8_t *p_src, + uint32_t src_len, sgx_cmac_128bit_tag_t *p_mac) +{ + void* pState = NULL; + + if ((p_key == NULL) || (p_src == NULL) || (p_mac == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + size_t mactlen; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + //create a new ctx of CMAC + // + pState = CMAC_CTX_new(); + if (pState == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // init CMAC ctx with the corresponding size, key and AES alg. + // + if (!CMAC_Init((CMAC_CTX*)pState, (const void *)p_key, SGX_CMAC_KEY_SIZE, EVP_aes_128_cbc(), NULL)) { + break; + } + + // perform CMAC hash on p_src + // + if (!CMAC_Update((CMAC_CTX *)pState, p_src, src_len)) { + break; + } + + // finalize CMAC hashing + // + if (!CMAC_Final((CMAC_CTX*)pState, (unsigned char*)p_mac, &mactlen)) { + break; + } + + //validate mac size + // + if (mactlen != SGX_CMAC_MAC_SIZE) { + break; + } + + ret = SGX_SUCCESS; + } while (0); + + // in case of error in debug mode, update openssl last error variable. + // + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + // we're done, clear and free CMAC ctx + // + if (pState) { + CMAC_CTX_free((CMAC_CTX*)pState); + } + return ret; +} + +/* Allocates and initializes CMAC state +* 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 +* Output: sgx_cmac_state_handle_t *p_cmac_handle - Pointer to the handle of the CMAC state */ +sgx_status_t sgx_cmac128_init(const sgx_cmac_128bit_key_t *p_key, sgx_cmac_state_handle_t* p_cmac_handle) + +{ + if ((p_key == NULL) || (p_cmac_handle == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + void* pState = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // create CMAC ctx + // + pState = CMAC_CTX_new(); + if (pState == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + //init CMAC ctx + // + if (!CMAC_Init((CMAC_CTX*)pState, (const void *)p_key, SGX_CMAC_KEY_SIZE, EVP_aes_128_cbc(), NULL)) { + CMAC_CTX_free((CMAC_CTX*)pState); + break; + } + + *p_cmac_handle = pState; + ret = SGX_SUCCESS; + } while (0); + + // in case of error in debug mode, update openssl last error variable. + // + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + return ret; +} + +/* Updates CMAC has calculation based on the input message +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error. +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +sgx_status_t sgx_cmac128_update(const uint8_t *p_src, uint32_t src_len, sgx_cmac_state_handle_t cmac_handle) + +{ + if ((p_src == NULL) || (cmac_handle == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + CLEAR_OPENSSL_ERROR_QUEUE; + + if (!CMAC_Update((CMAC_CTX *)cmac_handle, p_src, src_len)) { + GET_LAST_OPENSSL_ERROR; + return SGX_ERROR_UNEXPECTED; + } + return SGX_SUCCESS; +} + +/* Returns Hash calculation +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state +* Output: sgx_cmac_128bit_tag_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_cmac128_final(sgx_cmac_state_handle_t cmac_handle, sgx_cmac_128bit_tag_t *p_hash) + +{ + if ((cmac_handle == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + size_t mactlen; + + CLEAR_OPENSSL_ERROR_QUEUE; + + if (!CMAC_Final((CMAC_CTX*)cmac_handle, (unsigned char*)p_hash, &mactlen)) { + GET_LAST_OPENSSL_ERROR; + return SGX_ERROR_UNEXPECTED; + } + return SGX_SUCCESS; +} + + +/* Clean up the CMAC state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_cmac_state_handle_t cmac_handle - Handle to the CMAC state */ +sgx_status_t sgx_cmac128_close(sgx_cmac_state_handle_t cmac_handle) +{ + if (cmac_handle == NULL) { + return SGX_ERROR_INVALID_PARAMETER; + } + + CMAC_CTX* pState = (CMAC_CTX*)cmac_handle; + CMAC_CTX_free(pState); + return SGX_SUCCESS; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256.cpp new file mode 100644 index 0000000000..30ae41dc93 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256.cpp @@ -0,0 +1,403 @@ +/* + * 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 "string.h" +#include "se_tcrypto_common.h" +#include +#include +#include +#include "sgx_tcrypto.h" + +#define POINT_NOT_ON_CURVE 0x1007c06b + +/* +* Elliptic Curve Cryptography - Based on GF(p), 256 bit +*/ +/* Allocates and initializes ecc context +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Output: sgx_ecc_state_handle_t *p_ecc_handle - Pointer to the handle of ECC crypto system */ +sgx_status_t sgx_ecc256_open_context(sgx_ecc_state_handle_t* p_ecc_handle) +{ + if (p_ecc_handle == NULL) { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_SUCCESS; + CLEAR_OPENSSL_ERROR_QUEUE; + + /* construct a curve p-256 */ + EC_GROUP* ec_group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1); + if (NULL == ec_group) { + GET_LAST_OPENSSL_ERROR; + retval = SGX_ERROR_UNEXPECTED; + } else { + *p_ecc_handle = (void*)ec_group; + } + return retval; +} + +/* Cleans up ecc context +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Output: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system */ +sgx_status_t sgx_ecc256_close_context(sgx_ecc_state_handle_t ecc_handle) +{ + if (ecc_handle == NULL) { + return SGX_ERROR_INVALID_PARAMETER; + } + + EC_GROUP_free((EC_GROUP*)ecc_handle); + + return SGX_SUCCESS; +} + +/* Populates private/public key pair - caller code allocates memory +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* Outputs: sgx_ec256_private_t *p_private - Pointer to the private key +* sgx_ec256_public_t *p_public - Pointer to the public key */ +sgx_status_t sgx_ecc256_create_key_pair(sgx_ec256_private_t *p_private, + sgx_ec256_public_t *p_public, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_public == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + EC_GROUP *ec_group = (EC_GROUP*) ecc_handle; + EC_KEY *ec_key = NULL; + BIGNUM *pub_k_x = NULL; + BIGNUM *pub_k_y = NULL; + const EC_POINT *public_k = NULL; + const BIGNUM *private_k = NULL; + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // create new EC key + // + ec_key = EC_KEY_new(); + if (NULL == ec_key) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // set key's group (curve) + // + if (0 == EC_KEY_set_group (ec_key, ec_group)) { + break; + } + + // generate key pair, based on the curve set + // + if (0 == EC_KEY_generate_key(ec_key)) { + break; + } + + pub_k_x = BN_new(); + pub_k_y = BN_new(); + if (NULL == pub_k_x || NULL == pub_k_y) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // This OPENSSL API doesn't validate user's parameters + // get public and private keys + // + public_k = EC_KEY_get0_public_key(ec_key); + if (NULL == ec_key) { + break; + } + + private_k = EC_KEY_get0_private_key(ec_key); + if (NULL == ec_key) { + break; + } + + // extract two BNs representing the public key + // + if (!EC_POINT_get_affine_coordinates_GFp(ec_group, public_k, pub_k_x, pub_k_y, NULL)) { + break; + } + + // convert private key BN to little-endian unsigned char form + // + if (-1 == BN_bn2lebinpad(private_k, (unsigned char*)p_private, SGX_ECP256_KEY_SIZE)) { + break; + } + + // convert public key BN to little-endian unsigned char form + // + if (-1 == BN_bn2lebinpad(pub_k_x, (unsigned char*)p_public->gx, SGX_ECP256_KEY_SIZE)) { + break; + } + // convert public key BN to little-endian unsigned char form + // + if (-1 == BN_bn2lebinpad(pub_k_y, (unsigned char*)p_public->gy, SGX_ECP256_KEY_SIZE)) { + break; + } + + ret = SGX_SUCCESS; + } while(0); + + if (SGX_SUCCESS != ret) { + GET_LAST_OPENSSL_ERROR; + // in case of error, clear output buffers + // + memset_s(p_private, sizeof(p_private), 0, sizeof(p_private)); + memset_s(p_public->gx, sizeof(p_public->gx), 0, sizeof(p_public->gx)); + memset_s(p_public->gy, sizeof(p_public->gy), 0, sizeof(p_public->gy)); + } + + //free temp data + // + EC_KEY_free(ec_key); + BN_clear_free(pub_k_x); + BN_clear_free(pub_k_y); + + return ret; +} + +/* 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 +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_public_t *p_point - Pointer to perform validity check on - LITTLE ENDIAN +* Output: int *p_valid - Return 0 if the point is an invalid point on ECC curve */ +sgx_status_t sgx_ecc256_check_point(const sgx_ec256_public_t *p_point, + const sgx_ecc_state_handle_t ecc_handle, + int *p_valid) +{ + if ((ecc_handle == NULL) || (p_point == NULL) || (p_valid == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + EC_POINT *ec_point = NULL; + BIGNUM *b_x = NULL; + BIGNUM *b_y = NULL; + int ret_point_on_curve = 0; + unsigned long internal_openssl_error = 0; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // converts the x value of the point, represented as positive integer in little-endian into a BIGNUM + // + b_x = BN_lebin2bn(p_point->gx, SGX_ECP256_KEY_SIZE, NULL); + if (NULL == b_x) { + break; + } + + // converts the y value of the point, represented as positive integer in little-endian into a BIGNUM + // + b_y = BN_lebin2bn(p_point->gy, SGX_ECP256_KEY_SIZE, NULL); + if (NULL == b_y) { + break; + } + + // creates new point and assigned the group object that the point relates to + // + ec_point = EC_POINT_new((const EC_GROUP*)ecc_handle); + if (NULL == ec_point) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets point based on x,y coordinates + // + if (1 != EC_POINT_set_affine_coordinates_GFp((const EC_GROUP*)ecc_handle, ec_point, b_x, b_y, NULL)) { + internal_openssl_error = ERR_get_error(); + if (internal_openssl_error == POINT_NOT_ON_CURVE) { + /* fails if point not on curve */ + *p_valid = 0; + retval = SGX_SUCCESS; + } else { + #ifdef DEBUG + openssl_last_err = internal_openssl_error; + #endif /* DEBUG */ + } + break; + } + + // checks if point is on curve + // + ret_point_on_curve = EC_POINT_is_on_curve((const EC_GROUP*)ecc_handle, ec_point, NULL); + if (-1 == ret_point_on_curve) { + break; + } + + *p_valid = ret_point_on_curve; + + retval = SGX_SUCCESS; + } while(0); + + #ifdef DEBUG + if (SGX_SUCCESS != retval && 0 != openssl_last_err) { + GET_LAST_OPENSSL_ERROR; + } + #endif /* DEBUG */ + + if (ec_point) + EC_POINT_clear_free(ec_point); + if (b_x) + BN_clear_free(b_x); + if (b_y) + BN_clear_free(b_y); + + return retval; +} + +/* Computes 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 sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN +* sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN +* Output: sgx_ec256_dh_shared_t *p_shared_key - Pointer to the shared DH key - LITTLE ENDIAN +x-coordinate of (privKeyB - pubKeyA) */ +sgx_status_t sgx_ecc256_compute_shared_dhkey(sgx_ec256_private_t *p_private_b, + sgx_ec256_public_t *p_public_ga, + sgx_ec256_dh_shared_t *p_shared_key, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + EC_GROUP *ec_group = (EC_GROUP*) ecc_handle; + EC_POINT *point_pubA = NULL; + EC_KEY* private_key = NULL; + BIGNUM *BN_dh_privB = NULL; + BIGNUM *pubA_gx = NULL; + BIGNUM *pubA_gy = NULL; + BIGNUM *tmp = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // get BN from public key and private key + // + BN_dh_privB = BN_lebin2bn((unsigned char*)p_private_b->r, sizeof(sgx_ec256_private_t), 0); + if (BN_dh_privB == NULL) { + break; + } + + pubA_gx = BN_lebin2bn((unsigned char*)p_public_ga->gx, sizeof(sgx_ec256_private_t), 0); + if (pubA_gx == NULL) { + break; + } + + pubA_gy = BN_lebin2bn((unsigned char*)p_public_ga->gy, sizeof(sgx_ec256_private_t), 0); + if (pubA_gy == NULL) { + break; + } + + // set point based on pub key x and y + // + point_pubA = EC_POINT_new(ec_group); + if (point_pubA == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // create point (public key) based on public key's x,y coordinates + // + if (EC_POINT_set_affine_coordinates_GFp(ec_group, point_pubA, pubA_gx, pubA_gy, NULL) != 1) { + break; + } + + // check point if valid, point is on curve + // + if (EC_POINT_is_on_curve(ec_group, point_pubA, NULL) != 1) { + break; + } + + // create empty shared key BN + // + private_key = EC_KEY_new(); + if (private_key == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // init private key group (set curve) + // + if (EC_KEY_set_group (private_key, ec_group) != 1) { + break; + } + + // init private key with BN value + // + if (EC_KEY_set_private_key(private_key, BN_dh_privB) != 1) { + break; + } + + // calculate shared dh key + // + size_t shared_key_len = sizeof(sgx_ec256_dh_shared_t); + shared_key_len = ECDH_compute_key(&(p_shared_key->s), shared_key_len, point_pubA, private_key, NULL); + if (shared_key_len <= 0) { + break; + } + + // convert big endian to little endian + // + tmp = BN_bin2bn((unsigned char*)&(p_shared_key->s), sizeof(sgx_ec256_dh_shared_t), 0); + if (tmp == NULL) { + break; + } + if (BN_bn2lebinpad(tmp, p_shared_key->s, sizeof(sgx_ec256_dh_shared_t)) == -1) { + break; + } + ret = SGX_SUCCESS; + } while(0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + memset_s(p_shared_key->s, sizeof(p_shared_key->s), 0, sizeof(p_shared_key->s)); + } + + // clear and free memory + // + EC_POINT_clear_free(point_pubA); + EC_KEY_free(private_key); + BN_clear_free(BN_dh_privB); + BN_clear_free(pubA_gx); + BN_clear_free(pubA_gy); + BN_clear_free(tmp); + + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_ecdsa.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_ecdsa.cpp new file mode 100644 index 0000000000..6c1177d3e3 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_ecdsa.cpp @@ -0,0 +1,339 @@ +/* + * 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 "se_tcrypto_common.h" +#include +#include +#include +#include +#include "sgx_tcrypto.h" + +/* Computes signature for data based on private key +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_private_t *p_private - Pointer to the private key - LITTLE ENDIAN +* sgx_uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* Output: sgx_ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN */ +sgx_status_t sgx_ecdsa_sign(const uint8_t *p_data, + uint32_t data_size, + sgx_ec256_private_t *p_private, + sgx_ec256_signature_t *p_signature, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_private == NULL) || (p_signature == NULL) || (p_data == NULL) || (data_size < 1)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + EC_KEY *private_key = NULL; + BIGNUM *bn_priv = NULL; + ECDSA_SIG *ecdsa_sig = NULL; + const BIGNUM *r = NULL; + const BIGNUM *s = NULL; + unsigned char digest[SGX_SHA256_HASH_SIZE] = { 0 }; + int written_bytes = 0; + int sig_size = 0; + int max_sig_size = 0; + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // converts the r value of private key, represented as positive integer in little-endian into a BIGNUM + // + bn_priv = BN_lebin2bn((unsigned char*)p_private->r, sizeof(p_private->r), 0); + if (NULL == bn_priv) { + break; + } + + // create empty ecc key + // + private_key = EC_KEY_new(); + if (NULL == private_key) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets ecc key group (set curve) + // + if (1 != EC_KEY_set_group(private_key, (EC_GROUP*)ecc_handle)) { + break; + } + + // uses bn_priv to set the ecc private key + // + if (1 != EC_KEY_set_private_key(private_key, bn_priv)) { + break; + } + + /* generates digest of p_data */ + if (NULL == SHA256((const unsigned char *)p_data, data_size, (unsigned char *)digest)) { + break; + } + + // computes a digital signature of the SGX_SHA256_HASH_SIZE bytes hash value dgst using the private EC key private_key. + // the signature is returned as a newly allocated ECDSA_SIG structure. + // + ecdsa_sig = ECDSA_do_sign(digest, SGX_SHA256_HASH_SIZE, private_key); + if (NULL == ecdsa_sig) { + break; + } + + // returns internal pointers the r and s values contained in ecdsa_sig. + ECDSA_SIG_get0(ecdsa_sig, &r, &s); + + // converts the r BIGNUM of the signature to little endian buffer, bounded with the len of out buffer + // + written_bytes = BN_bn2lebinpad(r, (unsigned char*)p_signature->x, SGX_ECP256_KEY_SIZE); + if (0 >= written_bytes) { + break; + } + sig_size = written_bytes; + + // converts the s BIGNUM of the signature to little endian buffer, bounded with the len of out buffer + // + written_bytes = BN_bn2lebinpad(s, (unsigned char*)p_signature->y, SGX_ECP256_KEY_SIZE); + if (0 >= written_bytes) { + break; + } + sig_size += written_bytes; + + // returns the maximum length of a DER encoded ECDSA signature created with the private EC key. + // + max_sig_size = ECDSA_size(private_key); + if (max_sig_size <= 0) { + break; + } + + // checks if the signature size not larger than the max len of valid signature + // this check if done for validity, not for overflow. + // + if (sig_size > max_sig_size) { + break; + } + + retval = SGX_SUCCESS; + } while(0); + + if (SGX_SUCCESS != retval) { + GET_LAST_OPENSSL_ERROR; + } + + if (bn_priv) + BN_clear_free(bn_priv); + if (ecdsa_sig) + ECDSA_SIG_free(ecdsa_sig); + if (private_key) + EC_KEY_free(private_key); + + return retval; +} + +/* Verifies the signature for the given data based on the public key +* +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system +* sgx_ec256_public_t *p_public - Pointer to the public key - LITTLE ENDIAN +* uint8_t *p_data - Pointer to the data to be signed +* uint32_t data_size - Size of the data to be signed +* sgx_ec256_signature_t *p_signature - Pointer to the signature - LITTLE ENDIAN +* Output: uint8_t *p_result - Pointer to the result of verification check */ +sgx_status_t sgx_ecdsa_verify(const uint8_t *p_data, + uint32_t data_size, + const sgx_ec256_public_t *p_public, + sgx_ec256_signature_t *p_signature, + uint8_t *p_result, + sgx_ecc_state_handle_t ecc_handle) +{ + if ((ecc_handle == NULL) || (p_public == NULL) || (p_signature == NULL) || + (p_data == NULL) || (data_size < 1) || (p_result == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + EC_KEY *public_key = NULL; + BIGNUM *bn_pub_x = NULL; + BIGNUM *bn_pub_y = NULL; + BIGNUM *bn_r = NULL; + BIGNUM *bn_s = NULL; + BIGNUM *prev_bn_r = NULL; + BIGNUM *prev_bn_s = NULL; + EC_POINT *public_point = NULL; + ECDSA_SIG *ecdsa_sig = NULL; + unsigned char digest[SGX_SHA256_HASH_SIZE] = { 0 }; + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + int valid = 0; + + *p_result = SGX_EC_INVALID_SIGNATURE; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // converts the x value of public key, represented as positive integer in little-endian into a BIGNUM + // + bn_pub_x = BN_lebin2bn((unsigned char*)p_public->gx, sizeof(p_public->gx), 0); + if (NULL == bn_pub_x) { + break; + } + + // converts the y value of public key, represented as positive integer in little-endian into a BIGNUM + // + bn_pub_y = BN_lebin2bn((unsigned char*)p_public->gy, sizeof(p_public->gy), 0); + if (NULL == bn_pub_y) { + break; + } + + // converts the x value of the signature, represented as positive integer in little-endian into a BIGNUM + // + bn_r = BN_lebin2bn((unsigned char*)p_signature->x, sizeof(p_signature->x), 0); + if (NULL == bn_r) { + break; + } + + // converts the y value of the signature, represented as positive integer in little-endian into a BIGNUM + // + bn_s = BN_lebin2bn((unsigned char*)p_signature->y, sizeof(p_signature->y), 0); + if (NULL == bn_s) { + break; + } + + // creates new point and assigned the group object that the point relates to + // + public_point = EC_POINT_new((EC_GROUP*)ecc_handle); + if (public_point == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets point based on public key's x,y coordinates + // + if (1 != EC_POINT_set_affine_coordinates_GFp((EC_GROUP*)ecc_handle, public_point, bn_pub_x, bn_pub_y, NULL)) { + break; + } + + // check point if the point is on curve + // + if (1 != EC_POINT_is_on_curve((EC_GROUP*)ecc_handle, public_point, NULL)) { + break; + } + + // create empty ecc key + // + public_key = EC_KEY_new(); + if (NULL == public_key) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets ecc key group (set curve) + // + if (1 != EC_KEY_set_group(public_key, (EC_GROUP*)ecc_handle)) { + break; + } + + // uses the created point to set the public key value + // + if (1 != EC_KEY_set_public_key(public_key, public_point)) { + break; + } + + /* generates digest of p_data */ + if (NULL == SHA256((const unsigned char *)p_data, data_size, (unsigned char *)digest)) { + break; + } + + // allocates a new ECDSA_SIG structure (note: this function also allocates the BIGNUMs) and initialize it + // + ecdsa_sig = ECDSA_SIG_new(); + if (NULL == ecdsa_sig) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // free internal allocated BIGBNUMs + ECDSA_SIG_get0(ecdsa_sig, (const BIGNUM **)&prev_bn_r, (const BIGNUM **)&prev_bn_s); + if (prev_bn_r) + BN_clear_free(prev_bn_r); + if (prev_bn_s) + BN_clear_free(prev_bn_s); + + // setes the r and s values of ecdsa_sig + // calling this function transfers the memory management of the values to the ECDSA_SIG object, + // and therefore the values that have been passed in should not be freed directly after this function has been called + // + if (1 != ECDSA_SIG_set0(ecdsa_sig, bn_r, bn_s)) { + ECDSA_SIG_free(ecdsa_sig); + ecdsa_sig = NULL; + break; + } + + // verifies that the signature ecdsa_sig is a valid ECDSA signature of the hash value digest of size SGX_SHA256_HASH_SIZE using the public key public_key + // + valid = ECDSA_do_verify(digest, SGX_SHA256_HASH_SIZE, ecdsa_sig, public_key); + if (-1 == valid) { + break; + } + + // sets the p_result based on ECDSA_do_verify result + // + if (valid) { + *p_result = SGX_EC_VALID; + } + + retval = SGX_SUCCESS; + } while(0); + + if (SGX_SUCCESS != retval) { + GET_LAST_OPENSSL_ERROR; + } + + if (bn_pub_x) + BN_clear_free(bn_pub_x); + if (bn_pub_y) + BN_clear_free(bn_pub_y); + if (public_point) + EC_POINT_clear_free(public_point); + if (ecdsa_sig) { + ECDSA_SIG_free(ecdsa_sig); + bn_r = NULL; + bn_s = NULL; + } + if (public_key) + EC_KEY_free(public_key); + if (bn_r) + BN_clear_free(bn_r); + if (bn_s) + BN_clear_free(bn_s); + + return retval; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_internal.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_internal.cpp new file mode 100644 index 0000000000..9b15152162 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_ecc256_internal.cpp @@ -0,0 +1,172 @@ +/* + * 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 "string.h" +#include "se_tcrypto_common.h" +#include "sgx_ecc256_internal.h" +#include +#include +#include +#include "sgx_tcrypto.h" + +/* 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 sgx_error.h + * Inputs: sgx_ecc_state_handle_t ecc_handle - Handle to ECC crypto system + * sgx_ec256_private_t *p_private_b - Pointer to the local private key - LITTLE ENDIAN + * sgx_ec256_public_t *p_public_ga - Pointer to the remote public key - LITTLE ENDIAN + * Output: sgx_ec256_shared_point_t *p_shared_key - Pointer to the target shared point - LITTLE ENDIAN + x-coordinate of (privKeyB - pubKeyA) */ +sgx_status_t 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) +{ + if ((ecc_handle == NULL) || (p_private_b == NULL) || (p_public_ga == NULL) || (p_shared_key == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t ret = SGX_ERROR_UNEXPECTED; + EC_GROUP *ec_group = (EC_GROUP*) ecc_handle; + EC_POINT *point_pubA = NULL; + EC_POINT *point_R = NULL; + BIGNUM *BN_dh_privB = NULL; + BIGNUM *pubA_gx = NULL; + BIGNUM *pubA_gy = NULL; + BIGNUM *BN_dh_shared_x = NULL; + BIGNUM *BN_dh_shared_y = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + //get BN from public key and private key + // + BN_dh_privB = BN_lebin2bn((unsigned char*)p_private_b->r, sizeof(sgx_ec256_private_t), 0); + if (BN_dh_privB == NULL) { + break; + } + + pubA_gx = BN_lebin2bn((unsigned char*)p_public_ga->gx, sizeof(p_public_ga->gx), 0); + if (pubA_gx == NULL) { + break; + } + + pubA_gy = BN_lebin2bn((unsigned char*)p_public_ga->gy, sizeof(p_public_ga->gy), 0); + if (pubA_gy == NULL) { + break; + } + + //set point based on pub key x and y + // + point_pubA = EC_POINT_new(ec_group); + if (point_pubA == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + //create point (public key) based on public key's x,y coordinates + // + if (EC_POINT_set_affine_coordinates_GFp(ec_group, point_pubA, pubA_gx, pubA_gy, NULL) != 1) { + break; + } + + //check point if valid, point is on curve + // + if (EC_POINT_is_on_curve(ec_group, point_pubA, NULL) != 1) { + break; + } + + //create new point R + // + point_R = EC_POINT_new(ec_group); + if (point_R == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + //multiply pointA with privateKey BN scalar, to get point R. + //after, R's x and y are the shred d key + // + if (EC_POINT_mul(ec_group, point_R, NULL, point_pubA, BN_dh_privB, NULL) != 1) { + break; + } + + //check point if valid, point is on curve + // + if (EC_POINT_is_on_curve(ec_group, point_R, NULL) != 1) { + break; + } + + BN_dh_shared_x = BN_new(); + if (BN_dh_shared_x == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + BN_dh_shared_y = BN_new(); + if (BN_dh_shared_y == NULL) { + ret = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + if (EC_POINT_get_affine_coordinates_GFp(ec_group, point_R, BN_dh_shared_x, BN_dh_shared_y, NULL) != 1) { + break; + } + + if (BN_bn2lebinpad(BN_dh_shared_x, (unsigned char*)p_shared_key->x, sizeof(p_shared_key->x)) == -1) { + break; + } + + if (BN_bn2lebinpad(BN_dh_shared_y, (unsigned char*)p_shared_key->y, sizeof(p_shared_key->y)) == -1) { + break; + } + + ret = SGX_SUCCESS; + } while(0); + + if (ret != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + memset_s(p_shared_key->x, sizeof(p_shared_key->x), 0, sizeof(p_shared_key->x)); + memset_s(p_shared_key->y, sizeof(p_shared_key->y), 0, sizeof(p_shared_key->y)); + } + + //Free and clean all memory + // + EC_POINT_clear_free(point_pubA); + EC_POINT_clear_free(point_R); + BN_clear_free(BN_dh_shared_x); + BN_clear_free(BN_dh_shared_y); + BN_clear_free(BN_dh_privB); + BN_clear_free(pubA_gx); + BN_clear_free(pubA_gy); + + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_rsa3072.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_rsa3072.cpp new file mode 100644 index 0000000000..58f4e900d2 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_rsa3072.cpp @@ -0,0 +1,323 @@ +/* + * 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 "sgx_tcrypto.h" +#include +#include +#include +#include +#include "se_tcrypto_common.h" + +sgx_status_t sgx_rsa3072_sign(const uint8_t * p_data, + uint32_t data_size, + const sgx_rsa3072_key_t * p_key, + sgx_rsa3072_signature_t * p_signature) +{ + if ((p_data == NULL) || (data_size < 1) || (p_key == NULL) || + (p_signature == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + RSA *priv_rsa_key = NULL; + EVP_PKEY* priv_pkey = NULL; + BIGNUM *n = NULL; + BIGNUM *d = NULL; + BIGNUM *e = NULL; + EVP_MD_CTX* ctx = NULL; + const EVP_MD* sha256_md = NULL; + size_t siglen = SGX_RSA3072_KEY_SIZE; + int ret = 0; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // converts the modulus value of rsa key, represented as positive integer in little-endian into a BIGNUM + // + n = BN_lebin2bn((const unsigned char *)p_key->mod, sizeof(p_key->mod), 0); + if (n == NULL) { + break; + } + + // converts the private exp value of rsa key, represented as positive integer in little-endian into a BIGNUM + // + d = BN_lebin2bn((const unsigned char *)p_key->d, sizeof(p_key->d), 0); + if (d == NULL) { + break; + } + + // converts the public exp value of rsa key, represented as positive integer in little-endian into a BIGNUM + // + e = BN_lebin2bn((const unsigned char *)p_key->e, sizeof(p_key->e), 0); + if (e == NULL) { + break; + } + + // allocates and initializes an RSA key structure + // + priv_rsa_key = RSA_new(); + if (priv_rsa_key == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets the modulus, private exp and public exp values of the RSA key + // + if (RSA_set0_key(priv_rsa_key, n, e, d) != 1) { + BN_clear_free(n); + BN_clear_free(d); + BN_clear_free(e); + break; + } + + // allocates an empty EVP_PKEY structure + // + priv_pkey = EVP_PKEY_new(); + if (priv_pkey == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // set the referenced key to pub_rsa_key, however these use the supplied key internally and so key will be freed when the parent pkey is freed + // + if (EVP_PKEY_assign_RSA(priv_pkey, priv_rsa_key) != 1) { + RSA_free(priv_rsa_key); + break; + } + + // allocates, initializes and returns a digest context + // + ctx = EVP_MD_CTX_new(); + if (NULL == ctx) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // return EVP_MD structures for SHA256 digest algorithm */ + // + sha256_md = EVP_sha256(); + if (sha256_md == NULL) { + break; + } + + // sets up signing context ctx to use digest type + // + if (EVP_DigestSignInit(ctx, NULL, sha256_md, NULL, priv_pkey) <= 0) { + break; + } + + // hashes data_size bytes of data at p_data into the signature context ctx + // + if (EVP_DigestSignUpdate(ctx, (const void *)p_data, data_size) <= 0) { + break; + } + + // signs the data in ctx places the signature in p_signature. + // + ret = EVP_DigestSignFinal(ctx, (unsigned char *)p_signature, &siglen);//fails + if (ret <= 0) { + break; + } + + // validates the signature size + // + if (SGX_RSA3072_KEY_SIZE != siglen) { + break; + } + + retval = SGX_SUCCESS; + } while (0); + + if (retval != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + if (ctx) + EVP_MD_CTX_free(ctx); + if (priv_pkey) { + EVP_PKEY_free(priv_pkey); + priv_rsa_key = NULL; + n = NULL; + d = NULL; + e = NULL; + } + if (priv_rsa_key) { + RSA_free(priv_rsa_key); + n = NULL; + d = NULL; + e = NULL; + } + if (n) + BN_clear_free(n); + if (d) + BN_clear_free(d); + if (e) + BN_clear_free(e); + + return retval; +} + +sgx_status_t sgx_rsa3072_verify(const uint8_t *p_data, + uint32_t data_size, + const sgx_rsa3072_public_key_t *p_public, + const sgx_rsa3072_signature_t *p_signature, + sgx_rsa_result_t *p_result) +{ + if ((p_data == NULL) || (data_size < 1) || (p_public == NULL) || + (p_signature == NULL) || (p_result == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + *p_result = SGX_RSA_INVALID_SIGNATURE; + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + int verified = 0; + RSA *pub_rsa_key = NULL; + EVP_PKEY *pub_pkey = NULL; + BIGNUM *n = NULL; + BIGNUM *e = NULL; + const EVP_MD* sha256_md = NULL; + EVP_MD_CTX *ctx = NULL; + + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + // converts the modulus value of rsa key, represented as positive integer in little-endian into a BIGNUM + // + n = BN_lebin2bn((const unsigned char *)p_public->mod, sizeof(p_public->mod), 0); + if (n == NULL) { + break; + } + + // converts the public exp value of rsa key, represented as positive integer in little-endian into a BIGNUM + // + e = BN_lebin2bn((const unsigned char *)p_public->exp, sizeof(p_public->exp), 0); + if (e == NULL) { + break; + } + + // allocates and initializes an RSA key structure + // + pub_rsa_key = RSA_new(); + if (pub_rsa_key == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // sets the modulus and public exp values of the RSA key + // + if (RSA_set0_key(pub_rsa_key, n, e, NULL) != 1) { + BN_clear_free(n); + BN_clear_free(e); + break; + } + + // allocates an empty EVP_PKEY structure + // + pub_pkey = EVP_PKEY_new(); + if (pub_pkey == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // set the referenced key to pub_rsa_key, however these use the supplied key internally and so key will be freed when the parent pkey is freed + // + if (EVP_PKEY_assign_RSA(pub_pkey, pub_rsa_key) != 1) { + RSA_free(pub_rsa_key); + break; + } + + // allocates, initializes and returns a digest context + // + ctx = EVP_MD_CTX_new(); + if (ctx == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + // return EVP_MD structures for SHA256 digest algorithm */ + // + sha256_md = EVP_sha256(); + if (sha256_md == NULL) { + break; + } + + // sets up verification context ctx to use digest type + // + if (EVP_DigestVerifyInit(ctx, NULL, sha256_md, NULL, pub_pkey) <= 0) { + break; + } + + // hashes data_size bytes of data at p_data into the verification context ctx. + // this function can be called several times on the same ctx to hash additional data + // + if (EVP_DigestVerifyUpdate(ctx, (const void *)p_data, data_size) <= 0) { + break; + } + + // verifies the data in ctx against the signature in p_signature of length SGX_RSA3072_KEY_SIZE + // + verified = EVP_DigestVerifyFinal(ctx, (const unsigned char *)p_signature, SGX_RSA3072_KEY_SIZE); + if (verified) { + *p_result = SGX_RSA_VALID; + } + else if (verified != 0) { + break; + } + + retval = SGX_SUCCESS; + } while (0); + + if (retval != SGX_SUCCESS) { + GET_LAST_OPENSSL_ERROR; + } + + if (ctx) + EVP_MD_CTX_free(ctx); + if (pub_pkey) { + EVP_PKEY_free(pub_pkey); + pub_rsa_key = NULL; + n = NULL; + e = NULL; + } + if (pub_rsa_key) { + RSA_free(pub_rsa_key); + n = NULL; + e = NULL; + } + if (n) + BN_clear_free(n); + if (e) + BN_clear_free(e); + + return retval; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256.cpp new file mode 100644 index 0000000000..c0665e8aee --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256.cpp @@ -0,0 +1,163 @@ +/* + * 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 "se_tcrypto_common.h" +#include +#include +#include "sgx_tcrypto.h" +#include "stdlib.h" + +/* Allocates and initializes sha256 state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Output: sgx_sha_state_handle_t *p_sha_handle - Pointer to the handle of the SHA256 state */ +sgx_status_t sgx_sha256_init(sgx_sha_state_handle_t* p_sha_handle) +{ + if (p_sha_handle == NULL) { + return SGX_ERROR_INVALID_PARAMETER; + } + + EVP_MD_CTX* evp_ctx = NULL; + const EVP_MD* sha256_md = NULL; + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + /* allocates, initializes and returns a digest context */ + evp_ctx = EVP_MD_CTX_new(); + if (evp_ctx == NULL) { + retval = SGX_ERROR_OUT_OF_MEMORY; + break; + } + + /* return EVP_MD structures for SHA256 digest algorithm */ + sha256_md = EVP_sha256(); + if (sha256_md == NULL) { + break; + } + + /* sets up digest context ctx to use a digest type, if impl is NULL then the default implementation of digest type is used */ + if (EVP_DigestInit_ex(evp_ctx, sha256_md, NULL) != 1) { + break; + } + + *p_sha_handle = evp_ctx; + retval = SGX_SUCCESS; + } while(0); + + if (SGX_SUCCESS != retval) { + GET_LAST_OPENSSL_ERROR; + if (evp_ctx != NULL) { + EVP_MD_CTX_free(evp_ctx); + } + } + + return retval; +} + +/* Updates sha256 has calculation based on the input message +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error. +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state +* uint8_t *p_src - Pointer to the input stream to be hashed +* uint32_t src_len - Length of the input stream to be hashed */ +sgx_status_t sgx_sha256_update(const uint8_t *p_src, uint32_t src_len, sgx_sha_state_handle_t sha_handle) +{ + if ((p_src == NULL) || (sha_handle == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + /* hashes src_len bytes of data at p_src into the digest context sha_handle */ + if(EVP_DigestUpdate((EVP_MD_CTX*)sha_handle, p_src, src_len) != 1) { + GET_LAST_OPENSSL_ERROR; + break; + } + + retval = SGX_SUCCESS; + } while (0); + + return retval; +} + +/* Returns Hash calculation +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state +* Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_sha256_get_hash(sgx_sha_state_handle_t sha_handle, sgx_sha256_hash_t *p_hash) +{ + if ((sha_handle == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + unsigned int hash_len = 0; + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + /* retrieves the digest value from sha_handle and places it in p_hash */ + if (EVP_DigestFinal_ex((EVP_MD_CTX*)sha_handle, (unsigned char *)p_hash, &hash_len) != 1) { + GET_LAST_OPENSSL_ERROR; + break; + } + + if (SGX_SHA256_HASH_SIZE != hash_len) { + break; + } + + retval = SGX_SUCCESS; + } while(0); + + return retval; +} + + +/* Cleans up sha state +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined in sgx_error.h +* Input: sgx_sha_state_handle_t sha_handle - Handle to the SHA256 state */ +sgx_status_t sgx_sha256_close(sgx_sha_state_handle_t sha_handle) +{ + if (sha_handle == NULL) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + EVP_MD_CTX_free((EVP_MD_CTX*)sha_handle); + + return SGX_SUCCESS; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256_msg.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256_msg.cpp new file mode 100644 index 0000000000..c400eb2398 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/sgxssl/sgx_sha256_msg.cpp @@ -0,0 +1,65 @@ +/* + * 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 "se_tcrypto_common.h" +#include +#include +#include "sgx_tcrypto.h" + +/* SHA Hashing functions +* Parameters: +* Return: sgx_status_t - SGX_SUCCESS or failure as defined sgx_error.h +* Inputs: uint8_t *p_src - Pointer to input stream to be hashed +* uint32_t src_len - Length of input stream to be hashed +* Output: sgx_sha256_hash_t *p_hash - Resultant hash from operation */ +sgx_status_t sgx_sha256_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_hash_t *p_hash) +{ + if ((p_src == NULL) || (p_hash == NULL)) + { + return SGX_ERROR_INVALID_PARAMETER; + } + + sgx_status_t retval = SGX_ERROR_UNEXPECTED; + CLEAR_OPENSSL_ERROR_QUEUE; + + do { + /* generates digest of p_src */ + if (SHA256((const unsigned char *)p_src, src_len, (unsigned char *)p_hash) == NULL) { + GET_LAST_OPENSSL_ERROR; + break; + } + + retval = SGX_SUCCESS; + } while(0); + + + return retval; +} diff --git a/sgx-jvm/linux-sgx/sdk/tlibcrypto/tcrypto_version.cpp b/sgx-jvm/linux-sgx/sdk/tlibcrypto/tcrypto_version.cpp index 114992069c..2a7d6570d8 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcrypto/tcrypto_version.cpp +++ b/sgx-jvm/linux-sgx/sdk/tlibcrypto/tcrypto_version.cpp @@ -29,7 +29,6 @@ * */ - #include "se_version.h" #define __CONCAT(x, y) x/**/y @@ -46,3 +45,4 @@ const char * sgx_tcrypto_version = SGX_TCRYPTO_VERSION_STR; #ifdef __cplusplus } #endif + diff --git a/sgx-jvm/linux-sgx/sdk/tlibcxx/README.sgx b/sgx-jvm/linux-sgx/sdk/tlibcxx/README.sgx index 4fe2aa6821..c3cfb597fa 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcxx/README.sgx +++ b/sgx-jvm/linux-sgx/sdk/tlibcxx/README.sgx @@ -1,18 +1,18 @@ Version: 3.9 Changes: - * Add __sgx to __config for Intel(R) Software Guard Extensions (Intel(R) SGX) specific configuration. + * Add __sgx to __config for SGX specific configuration. * Define _LIBCPP_HAS_NO_THREADS, _LIBCPP_HAS_NO_STDIN, _LIBCPP_HAS_NO_STDOUT, _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. - * Use Intel(R) SGX C++ runtime library (cpprt from libcxxrt project ) instead. + * Use SGX C++ runtime library (cpprt from libcxxrt project ) instead. * Disable unsupported data types and interfaces. * Disable features that depend on I/O operations. - * Use Intel(R) SGX mutex, condition variable and spinlock instead of libc++ implementation. + * Use SGX mutex, condition variable and spinlock instead of libc++ implementation. * Use sgx_read_rand for generating random numbers. * Disable randon until we determine whether it's used safely. * Do not include Windows/Linux system headers directly. * Fix MSVC and GCC warnings with unused parameters. TODO: - * Merge Intel(R) SGX mutex and condition variable into libc++'s mutex and and condition variable. + * Merge SGX mutex and condition variable into libc++'s mutex and and condition variable. * Merge atomic support for ICC. * Update cpprt (libcxxrt project) or replace with libcxxabi (component of LLVM project). diff --git a/sgx-jvm/linux-sgx/sdk/tlibcxx/include/__config b/sgx-jvm/linux-sgx/sdk/tlibcxx/include/__config index 42726d6e51..e98b3491ba 100644 --- a/sgx-jvm/linux-sgx/sdk/tlibcxx/include/__config +++ b/sgx-jvm/linux-sgx/sdk/tlibcxx/include/__config @@ -418,15 +418,7 @@ typedef __char32_t char32_t; #elif defined(__ANDROID__) #define _LIBCPP_HAS_QUICK_EXIT #elif defined(__linux__) -#if !defined(_LIBCPP_HAS_MUSL_LIBC) -# include -#if __GLIBC_PREREQ(2, 15) -#define _LIBCPP_HAS_QUICK_EXIT -#endif -#if __GLIBC_PREREQ(2, 17) -#define _LIBCPP_HAS_C11_FEATURES -#endif -#else // defined(_LIBCPP_HAS_MUSL_LIBC) +#if defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #endif @@ -464,6 +456,8 @@ namespace std { #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif +#include <__sgx> + #elif defined(__GNUC__) #include <__sgx> diff --git a/sgx-jvm/linux-sgx/sdk/tlibstdcxx/src/cxa.c b/sgx-jvm/linux-sgx/sdk/tlibstdcxx/src/cxa.c deleted file mode 100644 index 998170e0f1..0000000000 --- a/sgx-jvm/linux-sgx/sdk/tlibstdcxx/src/cxa.c +++ /dev/null @@ -1,198 +0,0 @@ -#include "stlport_prefix.h" - -#if defined(__unix) && defined(__GNUC__) - -#ifdef __FreeBSD__ -# include -#endif - -#if (defined(__FreeBSD__) && (__FreeBSD_version < 503001)) || defined(__sun) || defined (__hpux) -/* Note: __cxa_finalize and __cxa_atexit present in libc in FreeBSD 5.3 */ - -#include -#include -#include - -/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@" "STLPORT_5_0_0"); */ -/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */ - -/* Not atomic! */ -/* But we can use static mutexes here: I hope that performance issue isn't very - significant on unloading (for only few calls, ~10) - ptr */ - -/* -#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ - ({ __typeof (mem) __gmemp = (mem); \ - __typeof (*mem) __gnewval = (newval); \ - \ - *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) -*/ - -enum { - ef_free, /* `ef_free' MUST be zero! */ - ef_us, - ef_on, - ef_at, - ef_cxa -}; - -struct exit_function -{ - /* `flavour' should be of type of the `enum' above but since we need - this element in an atomic operation we have to use `long int'. */ - long int flavor; - union { - void (*at)(void); - struct { - void (*fn)(int status, void *arg); - void *arg; - } on; - struct { - void (*fn)(void *arg, int status); - void *arg; - void *dso_handle; - } cxa; - } func; -}; - -struct exit_function_list -{ - struct exit_function_list *next; - size_t idx; - struct exit_function fns[32]; -}; - -struct exit_function *__new_exitfn (void); - -/* Register a function to be called by exit or when a shared library - is unloaded. This function is only called from code generated by - the C++ compiler. */ -int __cxa_atexit(void (*func)(void *), void *arg, void *d) -{ - struct exit_function *new = __new_exitfn (); - - if ( new == NULL ) - return -1; - - new->flavor = ef_cxa; - new->func.cxa.fn = (void (*) (void *, int)) func; - new->func.cxa.arg = arg; - new->func.cxa.dso_handle = d; - return 0; -} - - -/* We change global data, so we need locking. */ -#ifdef __linux__ -static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -#endif -/* #ifdef __FreeBSD__ */ -#if 0 -static pthread_mutex_t lock = - { PTHREAD_MUTEX_RECURSIVE /* PTHREAD_MUTEX_DEFAULT */, PTHREAD_PRIO_NONE, {NULL,NULL}, - NULL, { NULL }, /* MUTEX_FLAGS_PRIVATE */ 0x1, 0, 0, 0, {NULL, NULL}, - { 0, 0, 0, 0 } }; -#endif -#ifdef __sun -static pthread_mutex_t lock = - {{0, 0, 0, PTHREAD_MUTEX_RECURSIVE, _MUTEX_MAGIC}, {{{0}}}, 0}; -#endif -#ifdef __hpux -static pthread_mutex_t lock = PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP; -# ifdef __ia64 -void *__dso_handle = (void *) &__dso_handle; -# endif -#endif - - -static struct exit_function_list initial; -struct exit_function_list *__exit_funcs = &initial; - -struct exit_function *__new_exitfn(void) -{ - struct exit_function_list *l; - size_t i = 0; - -#ifndef __FreeBSD__ - pthread_mutex_lock( &lock ); -#endif - - for (l = __exit_funcs; l != NULL; l = l->next) { - for (i = 0; i < l->idx; ++i) - if (l->fns[i].flavor == ef_free) - break; - if ( i < l->idx ) - break; - - if (l->idx < sizeof (l->fns) / sizeof (l->fns[0])) { - i = l->idx++; - break; - } - } - - if (l == NULL) { - l = (struct exit_function_list *)malloc( sizeof(struct exit_function_list) ); - if (l != NULL) { - l->next = __exit_funcs; - __exit_funcs = l; - - l->idx = 1; - i = 0; - } - } - - /* Mark entry as used, but we don't know the flavor now. */ - if ( l != NULL ) - l->fns[i].flavor = ef_us; - -#ifndef __FreeBSD__ - pthread_mutex_unlock( &lock ); -#endif - - return l == NULL ? NULL : &l->fns[i]; -} - -/* If D is non-NULL, call all functions registered with `__cxa_atexit' - with the same dso handle. Otherwise, if D is NULL, call all of the - registered handlers. */ - -/* - * Note, that original __cxa_finalize don't use lock, but use __exit_funcs - * i.e. global data. - */ -void __cxa_finalize(void *d) -{ - struct exit_function_list *funcs; - -#ifndef __FreeBSD__ - pthread_mutex_lock( &lock ); -#endif - - for (funcs = __exit_funcs; funcs; funcs = funcs->next) { - struct exit_function *f; - - for (f = &funcs->fns[funcs->idx - 1]; f >= &funcs->fns[0]; --f) { - if ( (d == NULL || d == f->func.cxa.dso_handle) && (f->flavor == ef_cxa) ) { - f->flavor = ef_free; - (*f->func.cxa.fn) (f->func.cxa.arg, 0); - } - } - } - - /* Remove the registered fork handlers. We do not have to - unregister anything if the program is going to terminate anyway. */ -#ifdef UNREGISTER_ATFORK - if (d != NULL) - UNREGISTER_ATFORK (d); -#endif -#ifndef __FreeBSD__ - pthread_mutex_unlock( &lock ); -#endif -} - -/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */ -/* void __cxa_finalize(void *d) __attribute__ ((weak)); */ - -#endif /* OS name */ -#endif /* __unix */ - diff --git a/sgx-jvm/linux-sgx/sdk/trts/Makefile b/sgx-jvm/linux-sgx/sdk/trts/Makefile index a9b12c1242..e334c1529c 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/Makefile +++ b/sgx-jvm/linux-sgx/sdk/trts/Makefile @@ -50,7 +50,10 @@ OBJS1 := init_enclave.o \ trts_veh.o \ trts_xsave.o \ init_optimized_lib.o \ - trts_version.o + trts_version.o \ + trts_trim.o \ + trts_emodpr.o \ + trts_add_trim.o OBJS2 := trts_nsp.o diff --git a/sgx-jvm/linux-sgx/sdk/trts/init_enclave.cpp b/sgx-jvm/linux-sgx/sdk/trts/init_enclave.cpp index 9b6d2eac24..6a9718db0b 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/init_enclave.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/init_enclave.cpp @@ -44,14 +44,18 @@ #include "sgx_trts.h" #include "init_optimized_lib.h" #include "trts_internal.h" -# include "linux/elf_parser.h" +#include "linux/elf_parser.h" #include "rts.h" +#include "trts_util.h" +#include "se_memcpy.h" // The global cpu feature bits from uRTS uint64_t g_cpu_feature_indicator = 0; +int EDMM_supported = 0; +sdk_version_t g_sdk_version = SDK_VERSION_1_5; -const volatile global_data_t g_global_data = {1, 2, 3, 4, 0, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}; +const volatile global_data_t g_global_data = {1, 2, 3, 4, + {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, {{{0, 0, 0, 0, 0, 0, 0}}}}; uint32_t g_enclave_state = ENCLAVE_INIT_NOT_STARTED; extern "C" { @@ -86,39 +90,52 @@ extern "C" int init_enclave(void *enclave_base, void *ms) // Check if the ms is outside the enclave. // sgx_is_outside_enclave() should be placed after relocate_enclave() - cpu_sdk_info_t *info = (cpu_sdk_info_t *)ms; - if(!sgx_is_outside_enclave(info, sizeof(cpu_sdk_info_t))) + system_features_t *info = (system_features_t *)ms; + if(!sgx_is_outside_enclave(info, sizeof(system_features_t))) { return -1; } - const sdk_version_t sdk_version = info->version; - const uint64_t cpu_features = info->cpu_features; - - if (sdk_version != SDK_VERSION_1_5) + + const system_features_t sys_features = *info; + g_sdk_version = sys_features.version; + if (g_sdk_version == SDK_VERSION_1_5) + { + EDMM_supported = 0; + } + else if (g_sdk_version == SDK_VERSION_2_0) + { + EDMM_supported = feature_supported((const uint64_t *)sys_features.system_feature_set, 0); + } + else + { + return -1; + } + + if (heap_init(get_heap_base(), get_heap_size(), get_heap_min_size(), EDMM_supported) != SGX_SUCCESS) return -1; // xsave uint64_t xfrm = get_xfeature_state(); // optimized libs - if(0 != init_optimized_libs(cpu_features, xfrm)) + if(0 != init_optimized_libs((const uint64_t)sys_features.cpu_features, xfrm)) { - CLEAN_XFEATURE_REGS return -1; } if(SGX_SUCCESS != sgx_read_rand((unsigned char*)&__stack_chk_guard, sizeof(__stack_chk_guard))) { - CLEAN_XFEATURE_REGS return -1; } - // clean extended registers, no need to save - CLEAN_XFEATURE_REGS return 0; } +#ifndef SE_SIM +int accept_post_remove(const volatile layout_t *layout_start, const volatile layout_t *layout_end, size_t offset); +#endif + sgx_status_t do_init_enclave(void *ms) { void *enclave_base = get_enclave_base(); @@ -130,7 +147,23 @@ sgx_status_t do_init_enclave(void *ms) { return SGX_ERROR_UNEXPECTED; } - memset(GET_PTR(void, enclave_base, g_global_data.heap_offset), 0, g_global_data.heap_size); + +#ifndef SE_SIM + /* for EDMM, we need to accept the trimming of the POST_REMOVE pages. */ + if (EDMM_supported) + { + if (0 != accept_post_remove(&g_global_data.layout_table[0], &g_global_data.layout_table[0] + g_global_data.layout_entry_num, 0)) + return SGX_ERROR_UNEXPECTED; + + size_t heap_min_size = get_heap_min_size(); + memset_s(GET_PTR(void, enclave_base, g_global_data.heap_offset), heap_min_size, 0, heap_min_size); + } + else +#endif + { + memset_s(GET_PTR(void, enclave_base, g_global_data.heap_offset), g_global_data.heap_size, 0, g_global_data.heap_size); + } + g_enclave_state = ENCLAVE_INIT_DONE; return SGX_SUCCESS; } diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/Makefile b/sgx-jvm/linux-sgx/sdk/trts/linux/Makefile index 176d5d1f98..f8db47df45 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/Makefile +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/Makefile @@ -50,7 +50,8 @@ LDCFLAGS := -shared -nostdlib -nodefaultlibs -nostartfiles CPP_SRCS := $(wildcard ../*.cpp) C_SRCS := $(wildcard *.c) -ASM_SRCS := $(wildcard *.S) +ASM_SRCS := $(wildcard *.S) \ + $(COMMON_DIR)/src/linux/xsave_gnu.S OBJS := $(CPP_SRCS:.cpp=.o) OBJS += $(C_SRCS:.c=.o) OBJS += $(ASM_SRCS:.S=.o) @@ -67,6 +68,7 @@ $(LIBTRTS): $(OBJS) setcontext.o $(AR) rsD $@ $(ARCH)/setcontext.o %.o: %.S + echo $(ASM_SRCS) $(CC) $(CFLAGS) $(TCFLAGS) -c $< -o $@ %.o: %.c diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.c b/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.c index 7c6edb45af..c5dd62fda5 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.c +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.c @@ -39,6 +39,8 @@ #include "util.h" #include "elf_util.h" #include "global_data.h" +#include "../trts_emodpr.h" +#include "trts_inst.h" static int elf_tls_aligned_virtual_size(const void *enclave_base, size_t *aligned_virtual_size); @@ -416,4 +418,121 @@ int elf_get_init_array(const void* enclave_base, return 0; } + +int elf_get_uninit_array(const void* enclave_base, + uintptr_t *uninit_array_addr, size_t *uninit_array_size) +{ + ElfW(Half) phnum = 0; + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr)*)enclave_base; + ElfW(Phdr) *phdr = get_phdr(ehdr); + + if (!uninit_array_addr || !uninit_array_size) + return -1; + + if (phdr == NULL) + return -1; /* Invalid image. */ + + *uninit_array_addr = 0; + *uninit_array_size = 0; + + /* Search for Dynamic segment */ + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + if (phdr->p_type == PT_DYNAMIC) + { + size_t count; + size_t n_dyn = phdr->p_filesz/sizeof(ElfW(Dyn)); + ElfW(Dyn) *dyn = GET_PTR(ElfW(Dyn), ehdr, phdr->p_paddr); + + for (count = 0; count < n_dyn; count++, dyn++) + { + switch (dyn->d_tag) + { + case DT_FINI_ARRAY: + *uninit_array_addr = dyn->d_un.d_ptr; + break; + case DT_FINI_ARRAYSZ: + *uninit_array_size = dyn->d_un.d_val; + break; + } + } + } + } + + return 0; +} + +static int has_text_relo(const ElfW(Ehdr) *ehdr, const ElfW(Phdr) *phdr, ElfW(Half) phnum) +{ + ElfW(Half) phi = 0; + int text_relo = 0; + + for (; phi < phnum; phi++, phdr++) + { + if (phdr->p_type == PT_DYNAMIC) + { + size_t count; + size_t n_dyn = phdr->p_filesz/sizeof(ElfW(Dyn)); + ElfW(Dyn) *dyn = GET_PTR(ElfW(Dyn), ehdr, phdr->p_paddr); + + for (count = 0; count < n_dyn; count++, dyn++) + { + if (dyn->d_tag == DT_NULL) + break; + + if (dyn->d_tag == DT_TEXTREL) + { + text_relo = 1; + break; + } + } + break; + } + } + return text_relo; +} + +sgx_status_t change_protection(void *enclave_base) +{ + ElfW(Half) phnum = 0; + const ElfW(Ehdr) *ehdr = (const ElfW(Ehdr)*)enclave_base; + const ElfW(Phdr) *phdr = get_phdr(ehdr); + uint64_t perms; + sgx_status_t status = SGX_ERROR_UNEXPECTED; + + if (phdr == NULL) + return status; + + int text_relocation = has_text_relo(ehdr, phdr, ehdr->e_phnum); + + for (; phnum < ehdr->e_phnum; phnum++, phdr++) + { + if (text_relocation && (phdr->p_type == PT_LOAD) && ((phdr->p_flags & PF_W) == 0)) + { + perms = 0; + size_t start = (size_t)enclave_base + (phdr->p_vaddr & (size_t)(~(SE_PAGE_SIZE-1))); + size_t end = (size_t)enclave_base + ((phdr->p_vaddr + phdr->p_memsz + SE_PAGE_SIZE - 1) & (size_t)(~(SE_PAGE_SIZE-1))); + + if (phdr->p_flags & PF_R) + perms |= SI_FLAG_R; + if (phdr->p_flags & PF_X) + perms |= SI_FLAG_X; + + if((status = sgx_trts_mprotect(start, end - start, perms)) != SGX_SUCCESS) + return status; + } + + if (phdr->p_type == PT_GNU_RELRO) + { + size_t start = (size_t)enclave_base + (phdr->p_vaddr & (size_t)(~(SE_PAGE_SIZE-1))); + size_t end = (size_t)enclave_base + ((phdr->p_vaddr + phdr->p_memsz + SE_PAGE_SIZE - 1) & (size_t)(~(SE_PAGE_SIZE-1))); + if ((start != end) && + (status = sgx_trts_mprotect(start, end - start, SI_FLAG_R)) != SGX_SUCCESS) + return status; + } + } + + return SGX_SUCCESS; +} + /* vim: set ts=4 sw=4 et cin: */ diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.h b/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.h index 4a732f7bdc..bac208e95e 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.h +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/elf_parser.h @@ -52,6 +52,9 @@ int elf_tls_info(const void* enclave_base, int elf_get_init_array(const void* enclave_base, uintptr_t *init_array_addr, size_t *init_array_size); + +int elf_get_uninit_array(const void* enclave_base, + uintptr_t *uninit_array_addr, size_t *uninit_array_size); #ifdef __cplusplus } #endif diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/global_init.c b/sgx-jvm/linux-sgx/sdk/trts/linux/global_init.c index 0723b2ba69..27f6cc3237 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/global_init.c +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/global_init.c @@ -32,6 +32,7 @@ #include "internal/global_init.h" #include "linux/elf_parser.h" +#include "sgx_spinlock.h" #include "global_data.h" #include "internal/util.h" #include "thread_data.h" @@ -39,6 +40,29 @@ #include #include +typedef void (*cxa_function_t)(void *para); + +typedef struct _exit_function_t +{ + struct + { + uintptr_t fun; + uintptr_t para; + void *dso_handle; + } cxa; + + struct _exit_function_t *next; +} exit_function_t; + +static exit_function_t *g_exit_function = NULL; +static sgx_spinlock_t g_exit_function_lock = SGX_SPINLOCK_INITIALIZER; + +static uintptr_t g_exit_function_cookie = 0; +#define ENC_CXA_FUNC_POINTER(x) (uintptr_t)(x) ^ g_exit_function_cookie +#define DEC_CXA_FUNC_POINTER(x) (cxa_function_t)((x) ^ g_exit_function_cookie) +#define ENC_CXA_PARA_POINTER(x) (uintptr_t)(x) ^ g_exit_function_cookie +#define DEC_CXA_PARA_POINTER(x) (void *)((x) ^ g_exit_function_cookie) + typedef void (*fp_t)(void); /* required by global constructor when -fuse-cxa-atexit is enabled */ @@ -46,13 +70,73 @@ void *__dso_handle __attribute__((weak)) = &(__dso_handle); int __cxa_atexit(void (*fun)(void *), void *para, void *dso) { - (void)(fun); - (void)(para); - (void)(dso); + if(unlikely(g_exit_function_cookie == 0)) + { + uintptr_t rand = 0; + do + { + if(SGX_SUCCESS != sgx_read_rand((unsigned char *)&rand, sizeof(rand))) + { + return -1; + } + } while(rand == 0); + + sgx_spin_lock(&g_exit_function_lock); + if(g_exit_function_cookie == 0) + { + g_exit_function_cookie = rand; + } + + sgx_spin_unlock(&g_exit_function_lock); + } + + if(!sgx_is_within_enclave(fun, 0)) + { + return -1; + } + + exit_function_t *exit_function = (exit_function_t *)malloc(sizeof(exit_function_t)); + if(!exit_function) + { + return -1; + } + + exit_function->cxa.fun = ENC_CXA_FUNC_POINTER(fun); + exit_function->cxa.para = ENC_CXA_PARA_POINTER(para); + exit_function->cxa.dso_handle = dso; + + sgx_spin_lock(&g_exit_function_lock); + exit_function->next = g_exit_function; + g_exit_function = exit_function; + sgx_spin_unlock(&g_exit_function_lock); return 0; } +int atexit(void (*fun)(void)) +{ + return __cxa_atexit((void (*)(void *))fun, NULL, __dso_handle); +} + +static void do_atexit_aux(void) +{ + sgx_spin_lock(&g_exit_function_lock); + exit_function_t *exit_function = g_exit_function; + g_exit_function = NULL; + sgx_spin_unlock(&g_exit_function_lock); + + while (exit_function != NULL) + { + cxa_function_t cxa_func = DEC_CXA_FUNC_POINTER(exit_function->cxa.fun); + void *para = DEC_CXA_PARA_POINTER(exit_function->cxa.para); + cxa_func(para); + + exit_function_t *tmp = exit_function; + exit_function = exit_function->next; + free(tmp); + } +} + /* auxiliary routines */ static void do_ctors_aux(void) { @@ -76,8 +160,37 @@ static void do_ctors_aux(void) } } +/* auxiliary routines */ +static void do_dtors_aux(void) +{ + fp_t *p = NULL; + uintptr_t uninit_array_addr; + size_t uninit_array_size; + const void *enclave_start = (const void*)&__ImageBase; + + elf_get_uninit_array(enclave_start, &uninit_array_addr, &uninit_array_size); + + if (uninit_array_addr == 0 || uninit_array_size == 0) + return; + + fp_t *fp_start = (fp_t*)(uninit_array_addr + (uintptr_t)(enclave_start)); + fp_t *fp_end = fp_start + (uninit_array_size / sizeof(fp_t)); + + /* traverse .fini_array in reverse order */ + for (p = fp_end - 1; p >= fp_start; p--) + { + (*p)(); + } +} + void init_global_object(void) { do_ctors_aux(); } +void uninit_global_object(void) +{ + do_atexit_aux(); + do_dtors_aux(); +} + diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/metadata_sec.S b/sgx-jvm/linux-sgx/sdk/trts/linux/metadata_sec.S index a478300c92..75a9b1fef7 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/metadata_sec.S +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/metadata_sec.S @@ -31,7 +31,7 @@ .file "metadata_sec.S" -#define METADATA_SIZE 4096 +#define METADATA_SIZE 0x3000 .section ".note.sgxmeta", "", @note .p2align 2 /* section alignment */ .long 1f - 0f /* name size (not including padding) */ diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.S b/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.S index 9ce3bdd8e0..60bf47f726 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.S +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.S @@ -145,15 +145,26 @@ DECLARE_GLOBAL_FUNC enclave_entry mov %rbx, %rdx #endif call enter_enclave + mov %xax, %xbx .Lexit_enclave: +/* clean extended feature registers */ + lea_pic SYNTHETIC_STATE, %xdi +#ifdef LINUX32 + mov %xdi, (%xsp) +#endif + call restore_xregs + +/* set xdi and xsi */ + mov $OCMD_ERET, %xdi + mov %xbx, %xsi + +/* restore stack */ mov -1*SE_WORDSIZE(%xbp), %xdx /* xdx: xsp_u */ mov %xbp, %xsp pop %xbp /* xbp_u */ pop %xbx /* ret_u */ mov %xdx, %xsp /* xsp_u */ - mov $OCMD_ERET, %xdi - mov %xax, %xsi .Lclear_and_exit_enclave: /* Clear all GPRs, except xax, xbx, xdi and xsi */ @@ -207,9 +218,14 @@ DECLARE_GLOBAL_FUNC enclave_entry * previous TD.last_sp -> | frames | * ----------------- * | ECALL frame | - * | do_ocall param 2| 21 - * | do_ocall param 1| 20 - * |do_ocall ret_addr| 19 + * | do_ocall param 2| 3 + * | do_ocall param 1| 2 + * |do_ocall ret_addr| 1 + * | xbp | 0 + xbp + * | .... | + * | xsave buffer | + * | .... | + * | xsave pointer | 19 * | ocall_depth | 18 * | reserved | 17 * | reserved | 16 @@ -228,7 +244,7 @@ DECLARE_GLOBAL_FUNC enclave_entry * | shadow | 3 * | shadow | 2 * | shadow | 1 - * TD.last_sp -> | shadow | 0 + * TD.last_sp -> | shadow | 0 + xsp * ----------------- * ------------------------------------------------------------------------- */ @@ -239,9 +255,26 @@ DECLARE_LOCAL_FUNC do_ocall * 1 for OCALL_FLAG, 4 for shadow space. * Stack Pointer is 16-byte aligned under x86_64. */ - sub $(19*SE_WORDSIZE), %xsp + push %xbp + mov %xsp, %xbp - /* save non-volatile registers, except xsp */ +/* save parameters in stack */ +#ifdef LINUX64 + mov %xdi, 2*SE_WORDSIZE(%xbp) + mov %xsi, 3*SE_WORDSIZE(%xbp) +#endif + +/* save and clean extended feature registers */ + READ_TD_DATA xsave_size + sub %xax, %xsp /* allocate buffer to save xregs */ + mov $0x3f, %xax + not %xax + and %xax, %xsp /* xsave requires 64 byte aligned */ + mov %xsp, %xcx # xsave pointer + + sub $(20*SE_WORDSIZE), %xsp /* 20 slots for GPRs and other info */ + mov %xcx, SE_WORDSIZE*19(%xsp) /* addr for xsave */ +/* save non-volatile registers, except xsp */ mov %xbx, SE_WORDSIZE*14(%xsp) mov %xsi, SE_WORDSIZE*13(%xsp) mov %xdi, SE_WORDSIZE*12(%xsp) @@ -254,17 +287,29 @@ DECLARE_LOCAL_FUNC do_ocall mov %r15, SE_WORDSIZE* 7(%rsp) #endif +/* save and clean extended feature registers */ + mov SE_WORDSIZE*19(%xsp), %xdi /* xsave pointer */ + READ_TD_DATA xsave_size + mov %xax, %xcx + shr $2, %xcx /* xsave size in dword */ + xor %xax, %xax + cld + rep stos %eax, %es:(%xdi) + + mov SE_WORDSIZE*19(%xsp), %xdi # xsave pointer + mov %xdi, (%xsp) + call save_xregs + lea_pic SYNTHETIC_STATE, %xdi + mov %xdi, (%xsp) + call restore_xregs + /* set xdi and xsi using the input parameters */ #ifdef LINUX64 - mov %edi, %edi /* it should clear the high 32bit word of RDI */ - /* - * rdi - param 1 (index), rsi - param 2 (ms) - * only use lower 32bit of rdi, rsi remains unchanged. - */ -#endif -#ifdef LINUX32 - mov SE_WORDSIZE*20(%esp), %edi - mov SE_WORDSIZE*21(%esp), %esi + mov SE_WORDSIZE*12(%xsp), %xdi + mov SE_WORDSIZE*13(%xsp), %xsi +#else + mov SE_WORDSIZE*2(%ebp), %edi + mov SE_WORDSIZE*3(%ebp), %esi #endif /* save ocall index to the stack */ @@ -357,12 +402,31 @@ DECLARE_LOCAL_FUNC __morestack .cfi_endproc DECLARE_GLOBAL_FUNC asm_oret -#ifdef LINUX32 - mov SE_WORDSIZE(%xsp), %xdi - mov 2*SE_WORDSIZE(%xsp), %xsi + mov %xsp, %xbx +#ifdef LINUX64 + mov %xdi, SE_WORDSIZE(%xsp) + mov %xsi, 2*SE_WORDSIZE(%xsp) #endif - mov %xdi, %xsp /* restore thread_data.last_sp */ - mov %xsi, %xax /* ocall return value */ + mov SE_WORDSIZE(%xbx), %xsp /* restore thread_data.last_sp */ + +/* restore extended feature registers */ + mov 19*SE_WORDSIZE(%xsp), %xdi +#ifdef LINUX32 + mov %xdi, (%xsp) +#endif + call restore_xregs + +/* memset_s */ + xor %xax, %xax + mov 11*SE_WORDSIZE(%xsp), %xcx + sub %xdi, %xcx + sub $SE_WORDSIZE, %xcx + shr $2, %xcx + cld + rep stos %eax,%es:(%xdi) + + mov 2*SE_WORDSIZE(%xbx), %xax /* ocall return value */ + #ifdef LINUX64 mov 7*SE_WORDSIZE(%xsp), %r15 mov 8*SE_WORDSIZE(%xsp), %r14 @@ -375,7 +439,8 @@ DECLARE_GLOBAL_FUNC asm_oret mov 13*SE_WORDSIZE(%xsp), %xsi mov 14*SE_WORDSIZE(%xsp), %xbx - add $(19*SE_WORDSIZE), %xsp + mov %xbp, %xsp + pop %xbp ret /* should not come here */ @@ -404,7 +469,6 @@ DECLARE_LOCAL_FUNC do_egetkey xor %xax, %xax .Legetkey_done: SE_EPILOG - ret /* @@ -420,8 +484,21 @@ DECLARE_LOCAL_FUNC do_ereport mov $SE_EREPORT, %xax /* EREPORT leaf */ ENCLU SE_EPILOG - ret +DECLARE_GLOBAL_FUNC do_eaccept + SE_PROLOG + mov $SE_EACCEPT, %eax + ENCLU + cmp $SGX_SUCCESS, %eax + jnz abort + SE_EPILOG + +DECLARE_GLOBAL_FUNC do_emodpe + SE_PROLOG + mov $SE_EMODPE, %eax + ENCLU + SE_EPILOG + #define _RDRAND_RETRY_TIMES 10 /* * ------------------------------------- diff --git a/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.h b/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.h index 39d4d41076..7c85af8011 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.h +++ b/sgx-jvm/linux-sgx/sdk/trts/linux/trts_pic.h @@ -40,7 +40,7 @@ #include "linux/linux-regs.h" #include "rts_cmd.h" -#define SE_GUARD_PAGE_SIZE 0x1000 +#define SE_GUARD_PAGE_SIZE 0x10000 #define ENCLAVE_INIT_NOT_STARTED 0 #define ENCLAVE_INIT_IN_PROGRESS 1 @@ -55,7 +55,7 @@ #define SGX_ERROR_ENCLAVE_CRASHED 0x000001006 // enclave is crashed #define SGX_ERROR_STACK_OVERRUN 0x000001009 // enclave is running out of stack -#define STATIC_STACK_SIZE (SE_WORDSIZE * 100) +#define STATIC_STACK_SIZE 688 /* Thread Data * c.f. data structure defintion for thread_data_t in `rts.h'. @@ -64,6 +64,7 @@ #define stack_base_addr (SE_WORDSIZE * 2) #define stack_limit_addr (SE_WORDSIZE * 3) #define first_ssa_gpr (SE_WORDSIZE * 4) +#define xsave_size (SE_WORDSIZE * 7) #define self_addr 0 #define stack_guard (SE_WORDSIZE * 5) diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts.cpp index 9bbdb5e951..3c4f70cbfb 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts.cpp @@ -37,7 +37,7 @@ #include "util.h" #include "thread_data.h" #include "global_data.h" - +#include "trts_internal.h" #include "internal/rts.h" #ifdef SE_SIM @@ -186,10 +186,14 @@ void * sgx_ocalloc(size_t size) // so use volatile to avoid optimization by the compiler for(volatile size_t page = first_page; page >= last_page; page -= SE_PAGE_SIZE) { + // OS may refuse to commit a physical page if the page fault address is smaller than RSP + // So update the outside stack address before probe the page + ssa_gpr->REG(sp_u) = page; + *reinterpret_cast(page) = 0; } - // update the outside stack address in the SSA + // update the outside stack address in the SSA to the allocated address ssa_gpr->REG(sp_u) = addr; return reinterpret_cast(addr); @@ -287,37 +291,14 @@ sgx_status_t sgx_read_rand(unsigned char *rand, size_t length_in_bytes) return SGX_SUCCESS; } -#include "trts_internal.h" -extern "C" int enter_enclave(int index, void *ms, void *tcs, int cssa) +extern uintptr_t __stack_chk_guard; +int check_static_stack_canary(void *tcs) { - if(get_enclave_state() == ENCLAVE_CRASHED) + size_t *canary = TCS2CANARY(tcs); + if ( *canary != (size_t)__stack_chk_guard) { - return SGX_ERROR_ENCLAVE_CRASHED; + return -1; } - - sgx_status_t error = SGX_ERROR_UNEXPECTED; - if(cssa == 0) - { - if(index >= 0) - { - error = do_ecall(index, ms, tcs); - } - else if(index == ECMD_INIT_ENCLAVE) - { - error = do_init_enclave(ms); - } - else if(index == ECMD_ORET) - { - error = do_oret(ms); - } - } - else if((cssa == 1) && (index == ECMD_EXCEPT)) - { - error = trts_handle_exception(tcs); - } - if(error == SGX_ERROR_UNEXPECTED) - { - set_enclave_state(ENCLAVE_CRASHED); - } - return error; + return 0; } + diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_add_trim.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_add_trim.cpp new file mode 100644 index 0000000000..d453c31cb4 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_add_trim.cpp @@ -0,0 +1,421 @@ +/* + * 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 "sgx_utils.h" +#include "trts_inst.h" +#include "util.h" +#include "trts_trim.h" +#include "trts_util.h" +#include "global_data.h" +#include "se_memcpy.h" +#include "se_page_attr.h" +#include "trts_internal.h" + +#ifndef SE_SIM + +struct dynamic_flags_attributes +{ + si_flags_t si_flags; + uint16_t attributes; +}; + +// Low level API to EACCEPT pages on grow-up region. +static int sgx_accept_backward(si_flags_t sfl, size_t lo, size_t hi) +{ + size_t addr = hi; + SE_DECLSPEC_ALIGN(sizeof(sec_info_t)) sec_info_t si; + si.flags = sfl; + for (uint16_t i = 0; i < (sizeof(si.reserved)/sizeof(si.reserved[0])); i++) + si.reserved[i] = 0; + + while (lo < addr) + { + int rc = do_eaccept(&si, addr -= SE_PAGE_SIZE); + if (rc != 0) + abort(); + } + return 0; +} + +// Low level API to EACCEPT pages on grow-up region during exception handling. +static int sgx_accept_forward_within_exception(size_t lo, size_t hi) +{ + size_t addr = lo; + SE_DECLSPEC_ALIGN(sizeof(sec_info_t)) sec_info_t si; + +#ifdef DEBUG + unsigned int sp_value = 0; + asm("mov %%esp, %0;" : "=r" (sp_value) :); + if ((sp_value & (SE_PAGE_SIZE -1)) <= (SE_PAGE_SIZE - (STATIC_STACK_SIZE % SE_PAGE_SIZE))) + return SGX_ERROR_UNEXPECTED; +#endif + + si.flags = SI_FLAGS_RW | SI_FLAG_PENDING; + for (uint16_t i = 0; i < (sizeof(si.reserved)/sizeof(si.reserved[0])); i++) + si.reserved[i] = 0; + + while (addr < hi) + { + int rc = do_eaccept(&si, addr); + if (rc != 0) + abort(); + addr += SE_PAGE_SIZE; + } + + return 0; +} + +const volatile layout_t *get_dynamic_layout_by_id(uint16_t id) +{ + for(uint32_t i = 0; i < g_global_data.layout_entry_num; i++) + { + if(g_global_data.layout_table[i].entry.id == id) + { + return &(g_global_data.layout_table[i]); + } + } + return NULL; +} + +// EACCEPT trim requests when the enclave completes initialization. +int accept_post_remove(const volatile layout_t *layout_start, const volatile layout_t *layout_end, size_t offset) +{ + int ret = -1; + for (const volatile layout_t *layout = layout_start; layout < layout_end; layout++) + { + if (!IS_GROUP_ID(layout->group.id) && (layout->entry.attributes & PAGE_ATTR_POST_REMOVE)) + { + size_t start_addr = (size_t)layout->entry.rva + offset + (size_t)get_enclave_base(); + uint32_t page_count = layout->entry.page_count; + + if (0 != (ret = sgx_accept_forward(SI_FLAG_TRIM | SI_FLAG_MODIFIED, start_addr, start_addr + ((size_t)page_count << SE_PAGE_SHIFT)))) + return ret; + } + else if (IS_GROUP_ID(layout->group.id)) + { + size_t step = 0; + for(uint32_t j = 0; j < layout->group.load_times; j++) + { + step += (size_t)layout->group.load_step; + if(0 != (ret = accept_post_remove(&layout[-layout->group.entry_count], layout, step))) + return ret; + } + } + } + return 0; +} + +static int check_dynamic_entry_range(void *addr, size_t page_count, uint16_t entry_id, size_t entry_offset, struct dynamic_flags_attributes *fa) +{ + const volatile layout_t *layout = NULL, *heap_max_layout; + size_t entry_start_addr; + uint32_t entry_page_count; + + if (entry_id < LAYOUT_ID_HEAP_MIN + || entry_id > LAYOUT_ID_STACK_DYN_MIN + || (NULL == (layout = get_dynamic_layout_by_id(entry_id)))) + { + return -1; + } + + entry_start_addr = (size_t)get_enclave_base() + (size_t)layout->entry.rva + entry_offset; + entry_page_count = layout->entry.page_count; + + // if there exists LAYOUT_ID_HEAP_MAX, we should include it as well + if ((entry_id == LAYOUT_ID_HEAP_INIT) + && (heap_max_layout = get_dynamic_layout_by_id(LAYOUT_ID_HEAP_MAX))) + { + entry_page_count += heap_max_layout->entry.page_count; + } + + if ((size_t)addr >= entry_start_addr + && (size_t)addr + (page_count << SE_PAGE_SHIFT) <= entry_start_addr + ((size_t)entry_page_count << SE_PAGE_SHIFT)) + { + if (fa != NULL) + { + fa->si_flags = layout->entry.si_flags; + fa->attributes = layout->entry.attributes; + } + return 0; + } + else + { + return -1; + } +} + +// Verify if the range specified belongs to a dynamic range recorded in metadata. +static int check_dynamic_range(void *addr, size_t page_count, size_t *offset, struct dynamic_flags_attributes *fa) +{ + const volatile layout_t *dt_layout = NULL; + + // check heap range + if (0 == check_dynamic_entry_range(addr, page_count, LAYOUT_ID_HEAP_INIT, 0, fa)) + return 0; + + // check dynamic thread entries range + if (NULL != (dt_layout = get_dynamic_layout_by_id(LAYOUT_ID_THREAD_GROUP_DYN))) + { + for (uint16_t id = LAYOUT_ID_TCS_DYN; id <= LAYOUT_ID_STACK_DYN_MIN; id++) + for (uint32_t i = 0; i < dt_layout->group.load_times + 1; i++) + { + if (0 == check_dynamic_entry_range(addr, page_count, id, i * ((size_t)dt_layout->group.load_step), fa)) + { + if (offset != NULL) *offset = i * ((size_t)dt_layout->group.load_step); + return 0; + } + } + } + else + { + // LAYOUT_ID_THREAD_GROUP_DYN does not exist, but possibly there is one single dynamic thead + for (uint16_t id = LAYOUT_ID_TCS_DYN; id <= LAYOUT_ID_STACK_DYN_MIN; id++) + if (0 == check_dynamic_entry_range(addr, page_count, id, 0, fa)) + { + if (offset != NULL) *offset = 0; + return 0; + } + } + return -1; +} + +int is_dynamic_thread(void *tcs) +{ + struct dynamic_flags_attributes fa; + + if ((tcs != NULL) && (check_dynamic_range(tcs, 1, NULL, &fa) == 0) && + (fa.si_flags == SI_FLAGS_TCS)) + { + return true; + } + + return false; +} + +uint32_t get_dynamic_stack_max_page() +{ + const volatile layout_t * layout = get_dynamic_layout_by_id(LAYOUT_ID_STACK_DYN_MAX); + if (!layout) + return 0; + else + return layout->entry.page_count; +} +#endif + +int sgx_accept_forward(si_flags_t sfl, size_t lo, size_t hi) +{ +#ifdef SE_SIM + (void)sfl; + (void)lo; + (void)hi; + return 0; +#else + size_t addr = lo; + SE_DECLSPEC_ALIGN(sizeof(sec_info_t)) sec_info_t si; + si.flags = sfl; + for (uint16_t i = 0; i < (sizeof(si.reserved)/sizeof(si.reserved[0])); i++) + si.reserved[i] = 0; + + while (addr < hi) + { + int rc = do_eaccept(&si, addr); + if (rc != 0) + abort(); + addr += SE_PAGE_SIZE; + } + + return 0; +#endif +} + +// High level API to EACCEPT pages, mainly used in exception handling +// to deal with stack expansion. +int apply_pages_within_exception(void *start_address, size_t page_count) +{ +#ifdef SE_SIM + (void)start_address; + (void)page_count; + return 0; +#else + int rc; + + if (start_address == NULL) + return -1; + + if (check_dynamic_range(start_address, page_count, NULL, NULL) != 0) + return -1; + + size_t start = (size_t)start_address; + size_t end = start + (page_count << SE_PAGE_SHIFT); + + rc = sgx_accept_forward_within_exception(start, end); + + return rc; +#endif + +} + +// High level API to EACCEPT pages +int apply_EPC_pages(void *start_address, size_t page_count) +{ +#ifdef SE_SIM + (void)start_address; + (void)page_count; + return 0; +#else + int rc; + struct dynamic_flags_attributes fa; + + if (start_address == NULL) + return -1; + + if (check_dynamic_range(start_address, page_count, NULL, &fa) != 0) + return -1; + + size_t start = (size_t)start_address; + size_t end = start + (page_count << SE_PAGE_SHIFT); + + if (fa.attributes & PAGE_DIR_GROW_DOWN) + { + rc = sgx_accept_forward(SI_FLAGS_RW | SI_FLAG_PENDING, start, end); + } + else + { + rc = sgx_accept_backward(SI_FLAGS_RW | SI_FLAG_PENDING, start, end); + } + + return rc; +#endif +} + +// High level API to trim previously EAUG-ed pages. +int trim_EPC_pages(void *start_address, size_t page_count) +{ +#ifdef SE_SIM + (void)start_address; + (void)page_count; + return 0; +#else + int rc; + + if (start_address == NULL) + return -1; + + // check range + if (check_dynamic_range(start_address, page_count, NULL, NULL) != 0) + return -1; + + size_t start = (size_t)start_address; + size_t end = start + (page_count << SE_PAGE_SHIFT); + + // trim ocall + rc = trim_range_ocall(start, end); + assert(rc == 0); + + rc = sgx_accept_forward(SI_FLAG_TRIM | SI_FLAG_MODIFIED, start, end); + assert(rc == 0); + + // trim commit ocall + size_t i = start; + while (i < end) + { + rc = trim_range_commit_ocall(i); + assert(rc == 0); + i += SE_PAGE_SIZE; + } + + return rc; +#endif +} + +// Create a thread dynamically. +// It will add necessary pages and transform one of them into type TCS. +sgx_status_t do_add_thread(void *ptcs) +{ +#ifdef SE_SIM + (void)ptcs; + return SGX_SUCCESS; +#else + int ret = SGX_ERROR_UNEXPECTED; + tcs_t *tcs = (tcs_t *)ptcs; + tcs_t *tcs_template = NULL; + size_t offset = 0; + size_t enclave_base = (size_t)get_enclave_base(); + + if ( 0 != check_dynamic_range((void *)tcs, 1, &offset, NULL)) + return SGX_ERROR_UNEXPECTED; + + // check if the tcs provided exactly matches the one in signtool + const volatile layout_t *tcs_layout = get_dynamic_layout_by_id(LAYOUT_ID_TCS_DYN); + if (!tcs_layout) + return SGX_ERROR_UNEXPECTED; + + if ((size_t)(enclave_base + tcs_layout->entry.rva + offset) != (size_t)(tcs)) + return SGX_ERROR_UNEXPECTED; + + // adding page for all the dynamic entries + for (uint16_t id = LAYOUT_ID_TCS_DYN; id <= LAYOUT_ID_STACK_DYN_MIN; id++) + { + const volatile layout_t *layout = get_dynamic_layout_by_id(id); + if (layout && (layout->entry.attributes & PAGE_ATTR_DYN_THREAD)) + { + ret = apply_EPC_pages((void *)(enclave_base + layout->entry.rva + offset), layout->entry.page_count); + if (ret != 0) + return SGX_ERROR_UNEXPECTED; + } + } + + //Copy and initialize TCS + tcs_template = (tcs_t *)g_global_data.tcs_template; + memcpy_s(tcs, TCS_SIZE, tcs_template, sizeof(g_global_data.tcs_template)); + + //Adjust the tcs fields + tcs->ossa = (size_t)GET_PTR(size_t, (void *)tcs, tcs->ossa) - enclave_base; + tcs->ofs_base = (size_t)GET_PTR(size_t, (void *)tcs, tcs->ofs_base) - enclave_base; + tcs->ogs_base = (size_t)GET_PTR(size_t, (void *)tcs, tcs->ogs_base) - enclave_base; + + //OCALL for MKTCS + ret = sgx_ocall(0, tcs); + if (ret != 0) + return SGX_ERROR_UNEXPECTED; + + //EACCEPT for MKTCS + ret = sgx_accept_backward(SI_FLAG_TCS | SI_FLAG_MODIFIED, (size_t)tcs, (size_t)tcs + SE_PAGE_SIZE); + if (ret != 0) + return SGX_ERROR_UNEXPECTED; + + return SGX_SUCCESS; + +#endif +} + diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_ecall.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_ecall.cpp index 1de3cfcac0..888cc538ff 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_ecall.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_ecall.cpp @@ -40,6 +40,11 @@ #include "sgx_spinlock.h" #include "global_init.h" #include "trts_internal.h" +#include "trts_inst.h" +#include "trts_emodpr.h" +#include "metadata.h" +# include "linux/elf_parser.h" +# define GET_TLS_INFO elf_tls_info // is_ecall_allowed() // check the index in the dynamic entry table @@ -95,12 +100,111 @@ static sgx_status_t get_func_addr(uint32_t ordinal, void **addr) return SGX_SUCCESS; } +typedef struct _tcs_node_t +{ + uintptr_t tcs; + struct _tcs_node_t *next; +} tcs_node_t; + +static tcs_node_t *g_tcs_node = NULL; +static sgx_spinlock_t g_tcs_node_lock = SGX_SPINLOCK_INITIALIZER; + +static uintptr_t g_tcs_cookie = 0; +#define ENC_TCS_POINTER(x) (uintptr_t)(x) ^ g_tcs_cookie +#define DEC_TCS_POINTER(x) (void *)((x) ^ g_tcs_cookie) + +// do_save_tcs() +// Save tcs while function do_ecall_add_thread invoked. +// Parameters: +// [IN] ptcs - the tcs_t pointer which need to be saved +// Return Value: +// zero - success +// non-zero - fail +// +static sgx_status_t do_save_tcs(void *ptcs) +{ + if(unlikely(g_tcs_cookie == 0)) + { + uintptr_t rand = 0; + do + { + if(SGX_SUCCESS != sgx_read_rand((unsigned char *)&rand, sizeof(rand))) + { + return SGX_ERROR_UNEXPECTED; + } + } while(rand == 0); + + sgx_spin_lock(&g_tcs_node_lock); + if(g_tcs_cookie == 0) + { + g_tcs_cookie = rand; + } + sgx_spin_unlock(&g_tcs_node_lock); + } + + tcs_node_t *tcs_node = (tcs_node_t *)malloc(sizeof(tcs_node_t)); + if(!tcs_node) + { + return SGX_ERROR_UNEXPECTED; + } + + tcs_node->tcs = ENC_TCS_POINTER(ptcs); + + sgx_spin_lock(&g_tcs_node_lock); + tcs_node->next = g_tcs_node; + g_tcs_node = tcs_node; + sgx_spin_unlock(&g_tcs_node_lock); + + return SGX_SUCCESS; +} + +// do_del_tcs() +// Delete tcs from the global tcs list. +// Parameters: +// [IN] ptcs - the tcs_t pointer which need to be deleted +// Return Value: +// N/A +// +static void do_del_tcs(void *ptcs) +{ + sgx_spin_lock(&g_tcs_node_lock); + if (g_tcs_node != NULL) + { + if (DEC_TCS_POINTER(g_tcs_node->tcs) == ptcs) + { + tcs_node_t *tmp = g_tcs_node; + g_tcs_node = g_tcs_node->next; + free(tmp); + } + else + { + tcs_node_t *tcs_node = g_tcs_node->next; + tcs_node_t *pre_tcs_node = g_tcs_node; + while (tcs_node != NULL) + { + if (DEC_TCS_POINTER(tcs_node->tcs) == ptcs) + { + pre_tcs_node->next = tcs_node->next; + free(tcs_node); + break; + } + + pre_tcs_node = tcs_node; + tcs_node = tcs_node->next; + } + } + } + sgx_spin_unlock(&g_tcs_node_lock); +} + static volatile bool g_is_first_ecall = true; static volatile sgx_spinlock_t g_ife_lock = SGX_SPINLOCK_INITIALIZER; typedef sgx_status_t (*ecall_func_t)(void *ms); static sgx_status_t trts_ecall(uint32_t ordinal, void *ms) { + sgx_status_t status = SGX_ERROR_UNEXPECTED; + if (unlikely(g_is_first_ecall)) { // The thread performing the global initialization cannot do a nested ECall @@ -113,6 +217,18 @@ static sgx_status_t trts_ecall(uint32_t ordinal, void *ms) sgx_spin_lock(&g_ife_lock); if (g_is_first_ecall) { +#ifndef SE_SIM + if(EDMM_supported) + { + //change back the page permission + size_t enclave_start = (size_t)&__ImageBase; + if((status = change_protection((void *)enclave_start)) != SGX_SUCCESS) + { + sgx_spin_unlock(&g_ife_lock); + return status; + } + } +#endif //invoke global object's construction init_global_object(); g_is_first_ecall = false; @@ -121,19 +237,77 @@ static sgx_status_t trts_ecall(uint32_t ordinal, void *ms) } void *addr = NULL; - sgx_status_t status = get_func_addr(ordinal, &addr); + status = get_func_addr(ordinal, &addr); if(status == SGX_SUCCESS) { ecall_func_t func = (ecall_func_t)addr; status = func(ms); } - - // clean extended registers, no need to save - CLEAN_XFEATURE_REGS + return status; } -extern "C" sgx_status_t do_init_thread(void *tcs); +extern "C" uintptr_t __stack_chk_guard; +static void init_static_stack_canary(void *tcs) +{ + size_t *canary = TCS2CANARY(tcs); + *canary = (size_t)__stack_chk_guard; +} + +static sgx_status_t do_init_thread(void *tcs) +{ + thread_data_t *thread_data = GET_PTR(thread_data_t, tcs, g_global_data.td_template.self_addr); +#ifndef SE_SIM + size_t saved_stack_commit_addr = thread_data->stack_commit_addr; + bool thread_first_init = (saved_stack_commit_addr == 0) ? true : false; +#endif + size_t stack_guard = thread_data->stack_guard; + memcpy_s(thread_data, SE_PAGE_SIZE, const_cast(&g_global_data.td_template), sizeof(thread_data_t)); + thread_data->last_sp += (size_t)tcs; + thread_data->self_addr += (size_t)tcs; + thread_data->stack_base_addr += (size_t)tcs; + thread_data->stack_limit_addr += (size_t)tcs; + thread_data->stack_commit_addr = thread_data->stack_limit_addr; + thread_data->first_ssa_gpr += (size_t)tcs; + thread_data->tls_array += (size_t)tcs; + thread_data->tls_addr += (size_t)tcs; + + thread_data->last_sp -= (size_t)STATIC_STACK_SIZE; + thread_data->stack_base_addr -= (size_t)STATIC_STACK_SIZE; + thread_data->stack_guard = stack_guard; + init_static_stack_canary(tcs); + +#ifndef SE_SIM + if (EDMM_supported && is_dynamic_thread(tcs)) + { + if (thread_first_init) + { + uint32_t page_count = get_dynamic_stack_max_page(); + thread_data->stack_commit_addr += ((sys_word_t)page_count << SE_PAGE_SHIFT); + } + else + { + thread_data->stack_commit_addr = saved_stack_commit_addr; + } + } +#endif + + uintptr_t tls_addr = 0; + size_t tdata_size = 0; + + if(0 != GET_TLS_INFO(&__ImageBase, &tls_addr, &tdata_size)) + { + return SGX_ERROR_UNEXPECTED; + } + if(tls_addr) + { + memset((void *)TRIM_TO_PAGE(thread_data->tls_addr), 0, ROUND_TO_PAGE(thread_data->self_addr - thread_data->tls_addr)); + memcpy_s((void *)(thread_data->tls_addr), thread_data->self_addr - thread_data->tls_addr, (void *)tls_addr, tdata_size); + } + + return SGX_SUCCESS; +} + sgx_status_t do_ecall(int index, void *ms, void *tcs) { sgx_status_t status = SGX_ERROR_UNEXPECTED; @@ -154,3 +328,128 @@ sgx_status_t do_ecall(int index, void *ms, void *tcs) return status; } +sgx_status_t do_ecall_add_thread(void *ms, void *tcs) +{ + sgx_status_t status = SGX_ERROR_UNEXPECTED; + + struct ms_tcs *ms_tcs = (struct ms_tcs*)ms; + if (ms_tcs == NULL) + { + return status; + } + + if (!sgx_is_outside_enclave(ms_tcs, sizeof(struct ms_tcs))) + { + abort(); + } + + void* ptcs = ms_tcs->ptcs; + if (ptcs == NULL) + { + return status; + } + + status = do_init_thread(tcs); + if(SGX_SUCCESS != status) + { + return status; + } + + status = do_save_tcs(ptcs); + if(SGX_SUCCESS != status) + { + return status; + } + + status = do_add_thread(ptcs); + if (SGX_SUCCESS != status) + { + do_del_tcs(ptcs); + return status; + } + + return status; +} + +// do_uninit_enclave() +// Run the global uninitialized functions when the enclave is destroyed. +// Parameters: +// [IN] tcs - used for running this task +// Return Value: +// zero - success +// non-zero - fail +// +sgx_status_t do_uninit_enclave(void *tcs) +{ + sgx_spin_lock(&g_tcs_node_lock); + tcs_node_t *tcs_node = g_tcs_node; + g_tcs_node = NULL; + sgx_spin_unlock(&g_tcs_node_lock); + + while (tcs_node != NULL) + { + if (DEC_TCS_POINTER(tcs_node->tcs) == tcs) + { + tcs_node_t *tmp = tcs_node; + tcs_node = tcs_node->next; + free(tmp); + continue; + } + + size_t start = (size_t)DEC_TCS_POINTER(tcs_node->tcs); + size_t end = start + (1 << SE_PAGE_SHIFT); + int rc = sgx_accept_forward(SI_FLAG_TRIM | SI_FLAG_MODIFIED, start, end); + if(rc != 0) + { + return SGX_ERROR_UNEXPECTED; + } + + tcs_node_t *tmp = tcs_node; + tcs_node = tcs_node->next; + free(tmp); + } + + sgx_spin_lock(&g_ife_lock); + if (!g_is_first_ecall) + { + uninit_global_object(); + } + sgx_spin_unlock(&g_ife_lock); + + set_enclave_state(ENCLAVE_CRASHED); + + return SGX_SUCCESS; +} + +extern "C" sgx_status_t sgx_trts_mprotect(size_t start, size_t size, uint64_t perms) +{ + int rc = -1; + size_t page; + sgx_status_t ret = SGX_SUCCESS; + SE_DECLSPEC_ALIGN(sizeof(sec_info_t)) sec_info_t si; + + //Error return if start or size is not page-aligned or size is zero. + if (!IS_PAGE_ALIGNED(start) || (size == 0) || !IS_PAGE_ALIGNED(size)) + return SGX_ERROR_INVALID_PARAMETER; + + ret = change_permissions_ocall(start, size, perms); + if (ret != SGX_SUCCESS) + return ret; + + si.flags = perms|SI_FLAG_REG|SI_FLAG_PR; + memset(&si.reserved, 0, sizeof(si.reserved)); + + for(page = start; page < start + size; page += SE_PAGE_SIZE) + { + do_emodpe(&si, page); + // If the target permission to set is RWX, no EMODPR, hence no EACCEPT. + if ((perms & (SI_FLAG_W|SI_FLAG_X)) != (SI_FLAG_W|SI_FLAG_X)) + { + rc = do_eaccept(&si, page); + if(rc != 0) + return (sgx_status_t)rc; + } + } + + return SGX_SUCCESS; +} diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.cpp new file mode 100644 index 0000000000..7c0be7f198 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.cpp @@ -0,0 +1,78 @@ +/* + * 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 "trts_emodpr.h" + +#include "sgx_trts.h" // for sgx_ocalloc, sgx_is_outside_enclave +#include "arch.h" +#include "sgx_edger8r.h" // for sgx_ocall etc. +#include "internal/rts.h" + +/* sgx_ocfree() just restores the original outside stack pointer. */ +#define OCALLOC(val, type, len) do { \ + void* __tmp = sgx_ocalloc(len); \ + if (__tmp == NULL) { \ + sgx_ocfree(); \ + return SGX_ERROR_UNEXPECTED;\ + } \ + (val) = (type)__tmp; \ +} while (0) + +typedef struct ms_change_permissions_ocall_t { + size_t ms_addr; + size_t ms_size; + uint64_t ms_epcm_perms; +} ms_change_permissions_ocall_t; + +sgx_status_t SGXAPI change_permissions_ocall(size_t addr, size_t size, uint64_t epcm_perms) +{ +#ifdef SE_SIM + (void)addr; + (void)size; + (void)epcm_perms; + return SGX_SUCCESS; +#else + sgx_status_t status = SGX_SUCCESS; + + ms_change_permissions_ocall_t* ms; + OCALLOC(ms, ms_change_permissions_ocall_t*, sizeof(*ms)); + + ms->ms_addr = addr; + ms->ms_size = size; + ms->ms_epcm_perms = epcm_perms; + status = sgx_ocall(EDMM_MODPR, ms); + + + sgx_ocfree(); + return status; +#endif +} diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.h b/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.h new file mode 100644 index 0000000000..acf64fc33a --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_emodpr.h @@ -0,0 +1,58 @@ +/* + * 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 MPROTECT_T_H__ +#define MPROTECT_T_H__ + +#include +#include +#include +#include "sgx_trts.h" + + +#include // for size_t + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t SGXAPI change_permissions_ocall(size_t addr, size_t size, uint64_t epcm_perms); + +sgx_status_t change_protection(void *enclave_base); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_internal.h b/sgx-jvm/linux-sgx/sdk/trts/trts_internal.h index 28c0f4854d..efd48add08 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_internal.h +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_internal.h @@ -33,13 +33,10 @@ #include "util.h" -#ifdef SE_64 -#define STATIC_STACK_SIZE 8*100 -#else -#define STATIC_STACK_SIZE 4*100 -#endif +#define STATIC_STACK_SIZE 688 #define TD2TCS(td) ((const void *)(((thread_data_t*)(td))->stack_base_addr + (size_t)STATIC_STACK_SIZE + (size_t)SE_GUARD_PAGE_SIZE)) +#define TCS2CANARY(addr) ((size_t *)((size_t)(addr)-(size_t)SE_GUARD_PAGE_SIZE-(size_t)STATIC_STACK_SIZE+sizeof(size_t))) typedef struct { const void *ecall_addr; @@ -72,6 +69,9 @@ sgx_status_t do_init_enclave(void *ms); sgx_status_t do_ecall(int index, void *ms, void *tcs); sgx_status_t do_oret(void *ms); sgx_status_t trts_handle_exception(void *tcs); +sgx_status_t do_ecall_add_thread(void *ms, void *tcs); +sgx_status_t do_uninit_enclave(void *tcs); +int check_static_stack_canary(void *tcs); #ifdef __cplusplus } #endif diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_nsp.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_nsp.cpp index e1d1d806d5..7a3e9a19f5 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_nsp.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_nsp.cpp @@ -31,7 +31,7 @@ /* Implement functions: * init_stack_guard() - * do_init_thread() + * enter_enclave() * * The functions in this source file will be called during the stack guard initialization. * They cannot be built with '-fstack-protector-strong'. Otherwise, stack guard check will @@ -46,13 +46,20 @@ #include "thread_data.h" #include "global_data.h" #include "trts_internal.h" +#include "internal/rts.h" -#include "linux/elf_parser.h" -#define GET_TLS_INFO elf_tls_info - -static void init_stack_guard(void) +static void init_stack_guard(void *tcs) { thread_data_t *thread_data = get_thread_data(); + if( (NULL == thread_data) || ((thread_data->stack_base_addr == thread_data->last_sp) && (0 != g_global_data.thread_policy))) + { + thread_data = GET_PTR(thread_data_t, tcs, g_global_data.td_template.self_addr); + } + else + { + return; + } + assert(thread_data != NULL); size_t tmp_stack_guard = 0; @@ -64,34 +71,52 @@ static void init_stack_guard(void) thread_data->stack_guard = tmp_stack_guard; } -extern "C" sgx_status_t do_init_thread(void *tcs) +extern "C" int enter_enclave(int index, void *ms, void *tcs, int cssa) { - thread_data_t *thread_data = GET_PTR(thread_data_t, tcs, g_global_data.td_template.self_addr); - memcpy_s(thread_data, SE_PAGE_SIZE, const_cast(&g_global_data.td_template), sizeof(thread_data_t)); - thread_data->last_sp += (size_t)tcs; - thread_data->self_addr += (size_t)tcs; - thread_data->stack_base_addr += (size_t)tcs; - thread_data->stack_limit_addr += (size_t)tcs; - thread_data->first_ssa_gpr += (size_t)tcs; - thread_data->tls_array += (size_t)tcs; - thread_data->tls_addr += (size_t)tcs; - - thread_data->last_sp -= (size_t)STATIC_STACK_SIZE; - thread_data->stack_base_addr -= (size_t)STATIC_STACK_SIZE; - - uintptr_t tls_addr = 0; - size_t tdata_size = 0; - - if(0 != GET_TLS_INFO(&__ImageBase, &tls_addr, &tdata_size)) + if(get_enclave_state() == ENCLAVE_CRASHED) { - return SGX_ERROR_UNEXPECTED; + return SGX_ERROR_ENCLAVE_CRASHED; } - if(tls_addr) + + sgx_status_t error = SGX_ERROR_UNEXPECTED; + if(cssa == 0) { - memset((void *)TRIM_TO_PAGE(thread_data->tls_addr), 0, ROUND_TO_PAGE(thread_data->self_addr - thread_data->tls_addr)); - memcpy_s((void *)(thread_data->tls_addr), thread_data->self_addr - thread_data->tls_addr, (void *)tls_addr, tdata_size); + if(index >= 0) + { + // Initialize stack guard if necessary + init_stack_guard(tcs); + error = do_ecall(index, ms, tcs); + } + else if(index == ECMD_INIT_ENCLAVE) + { + error = do_init_enclave(ms); + } + else if(index == ECMD_ORET) + { + error = do_oret(ms); + } + else if(index == ECMD_MKTCS) + { + // Initialize stack guard if necessary + init_stack_guard(tcs); + error = do_ecall_add_thread(ms, tcs); + } + else if(index == ECMD_UNINIT_ENCLAVE) + { + error = do_uninit_enclave(tcs); + } } - init_stack_guard(); - return SGX_SUCCESS; + else if((cssa == 1) && (index == ECMD_EXCEPT)) + { + error = trts_handle_exception(tcs); + if (check_static_stack_canary(tcs) != 0) + { + error = SGX_ERROR_STACK_OVERRUN; + } + } + if(error == SGX_ERROR_UNEXPECTED) + { + set_enclave_state(ENCLAVE_CRASHED); + } + return error; } - diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_ocall.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_ocall.cpp index c1eebe08f3..19371c2c0d 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_ocall.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_ocall.cpp @@ -36,7 +36,6 @@ #include "sgx_edger8r.h" #include "rts.h" #include "util.h" -#include "xsave.h" #include "trts_internal.h" extern "C" sgx_status_t asm_oret(uintptr_t sp, void *ms); @@ -61,23 +60,19 @@ sgx_status_t sgx_ocall(const unsigned int index, void *ms) return SGX_ERROR_OCALL_NOT_ALLOWED; } // the OCALL index should be within the ocall table range - if(static_cast(index) >= g_dyn_entry_table.nr_ocall) + // -2, -3 and -4 should be allowed to test SDK 2.0 features + if((index != 0) && + (index != (unsigned int)EDMM_TRIM) && + (index != (unsigned int)EDMM_TRIM_COMMIT) && + (index != (unsigned int)EDMM_MODPR) && + static_cast(index) >= g_dyn_entry_table.nr_ocall) { return SGX_ERROR_INVALID_FUNCTION; } - // save and clean extended feature registers - uint8_t buffer[FXSAVE_SIZE] = {0}; - save_and_clean_xfeature_regs(buffer); // do sgx_ocall sgx_status_t status = do_ocall(index, ms); - // restore extended feature registers - restore_xfeature_regs(buffer); - - // clear buffer to avoid secret leaking - memset_s(buffer, FXSAVE_SIZE, 0, FXSAVE_SIZE); - return status; } diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_trim.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_trim.cpp new file mode 100644 index 0000000000..33a2579204 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_trim.cpp @@ -0,0 +1,86 @@ +/* + * 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 "trts_trim.h" +#include "sgx_trts.h" // for sgx_ocalloc, sgx_is_outside_enclave +#include "internal/rts.h" + +/* sgx_ocfree() just restores the original outside stack pointer. */ +#define OCALLOC(val, type, len) do { \ + void* __tmp = sgx_ocalloc(len); \ + if (__tmp == NULL) { \ + sgx_ocfree(); \ + return SGX_ERROR_UNEXPECTED;\ + } \ + (val) = (type)__tmp; \ +} while (0) + +typedef struct ms_trim_range_ocall_t { + size_t ms_fromaddr; + size_t ms_toaddr; +} ms_trim_range_ocall_t; + +typedef struct ms_trim_range_commit_ocall_t { + size_t ms_addr; +} ms_trim_range_commit_ocall_t; + +sgx_status_t SGXAPI trim_range_ocall(size_t fromaddr, size_t toaddr) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_trim_range_ocall_t* ms; + OCALLOC(ms, ms_trim_range_ocall_t*, sizeof(*ms)); + + ms->ms_fromaddr = fromaddr; + ms->ms_toaddr = toaddr; + status = sgx_ocall(EDMM_TRIM, ms); + + + sgx_ocfree(); + return status; +} + +sgx_status_t SGXAPI trim_range_commit_ocall(size_t addr) +{ + sgx_status_t status = SGX_SUCCESS; + + ms_trim_range_commit_ocall_t* ms; + OCALLOC(ms, ms_trim_range_commit_ocall_t*, sizeof(*ms)); + + ms->ms_addr = addr; + status = sgx_ocall(EDMM_TRIM_COMMIT, ms); + + + sgx_ocfree(); + return status; +} + diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_trim.h b/sgx-jvm/linux-sgx/sdk/trts/trts_trim.h new file mode 100644 index 0000000000..c42343cc75 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_trim.h @@ -0,0 +1,57 @@ +/* + * 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 TRIM_RANGE_T_H__ +#define TRIM_RANGE_T_H__ + +#include +#include +#include +#include "sgx_edger8r.h" // for sgx_ocall etc. + + +#include // for size_t + +#define SGX_CAST(type, item) ((type)(item)) + +#ifdef __cplusplus +extern "C" { +#endif + +sgx_status_t SGXAPI trim_range_ocall(size_t fromaddr, size_t toaddr); +sgx_status_t SGXAPI trim_range_commit_ocall(size_t addr); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_util.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_util.cpp index ba7a1f5c7c..69b0d20f5a 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_util.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_util.cpp @@ -44,7 +44,32 @@ void * get_heap_base(void) size_t get_heap_size(void) { - return g_global_data.heap_size; + size_t heap_size = g_global_data.heap_size; + if (EDMM_supported) + { + for(uint32_t i = 0; i < g_global_data.layout_entry_num; i++) + { + if(g_global_data.layout_table[i].entry.id == LAYOUT_ID_HEAP_MAX) + { + heap_size += ((size_t)g_global_data.layout_table[i].entry.page_count << SE_PAGE_SHIFT); + } + } + } + return heap_size; +} + +size_t get_heap_min_size(void) +{ + size_t heap_size = 0; + for(uint32_t i = 0; i < g_global_data.layout_entry_num; i++) + { + if(g_global_data.layout_table[i].entry.id == LAYOUT_ID_HEAP_MIN) + { + heap_size = ((size_t)g_global_data.layout_table[i].entry.page_count << SE_PAGE_SHIFT); + break; + } + } + return heap_size; } int * get_errno_addr(void) @@ -53,6 +78,42 @@ int * get_errno_addr(void) return reinterpret_cast(&thread_data->last_error); } +//tRTS will receive a pointer to an array of uint64_t which indicates the +//features of the running system. This function can be used to query whether +//a certain feature (such as EDMM) is supported. +//It takes as input the pointer to the array and the feature bit location. +//The feature array coming from uRTS should be dealt with in the following way: +//Every bit except the MSb in each uint64 represents a certain feature. +//The MSb of each uint64_t, if set, indicates this is the last uint64_t to +//search for the feature's existance. +//For example, if we have two uint64_t elements in the array: +//array[0]: xxxxxxxxxxxxxxxx array[1] Xxxxxxxxxxxxxxxx +//MSb of array[1] should already be set to one by uRTS. Shown by capital 'X' here. +//Features listed in array[0], counting from right-most bit to left-most bit, +//have feature shift values 0 ~ 62, while features listed in array[1], have feature +//shift values 64 ~ 126. + +int feature_supported(const uint64_t *feature_set, uint32_t feature_shift) +{ + const uint64_t *f_set = feature_set; + uint32_t bit_position = 0, i = 0; + + if (!f_set) + return 0; + + while (((i+1) << 6) <= feature_shift) + { + if (f_set[i] & (0x1ULL << 63)) + return 0; + i++; + } + bit_position = feature_shift - (i << 6); + if (f_set[i] & (0x1ULL << bit_position)) + return 1; + else + return 0; +} + bool is_stack_addr(void *address, size_t size) { thread_data_t *thread_data = get_thread_data(); @@ -68,4 +129,3 @@ bool is_valid_sp(uintptr_t sp) && is_stack_addr((void*)sp, 0) ); // sp points to the top/bottom of stack are accepted } - diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_util.h b/sgx-jvm/linux-sgx/sdk/trts/trts_util.h index eefefaa92b..764e3c52e1 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_util.h +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_util.h @@ -43,10 +43,13 @@ extern "C" { void * get_heap_base(void); size_t get_heap_size(void); +size_t get_heap_min_size(void); int * get_errno_addr(void); bool is_stack_addr(void *address, size_t size); bool is_valid_sp(uintptr_t sp); +int heap_init(void *_heap_base, size_t _heap_size, size_t _heap_min_size, int _is_edmm_supported); +int feature_supported(const uint64_t *feature_set, uint32_t feature_shift); #ifdef __cplusplus } diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_veh.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_veh.cpp index a3dec187e8..baf29e8392 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_veh.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_veh.cpp @@ -45,6 +45,8 @@ #include "thread_data.h" #include "global_data.h" #include "trts_internal.h" +#include "trts_inst.h" +#include "util.h" #include "trts_util.h" typedef struct _handler_node_t @@ -279,6 +281,17 @@ failed_end: abort(); // throw abortion } +static int expand_stack_by_pages(void *start_addr, size_t page_count) +{ + int ret = -1; + + if ((start_addr == NULL) || (page_count == 0)) + return -1; + + ret = apply_pages_within_exception(start_addr, page_count); + return ret; +} + // trts_handle_exception(void *tcs) // the entry point for the exceptoin handling // Parameter @@ -286,7 +299,6 @@ failed_end: // Return Value // none zero - success // 0 - fail -#include "trts_internal.h" extern "C" sgx_status_t trts_handle_exception(void *tcs) { thread_data_t *thread_data = get_thread_data(); @@ -296,6 +308,8 @@ extern "C" sgx_status_t trts_handle_exception(void *tcs) size_t size = 0; if (tcs == NULL) goto default_handler; + if (check_static_stack_canary(tcs) != 0) + goto default_handler; if(get_enclave_state() != ENCLAVE_INIT_DONE) { @@ -340,14 +354,44 @@ extern "C" sgx_status_t trts_handle_exception(void *tcs) return SGX_ERROR_STACK_OVERRUN; } + info = (sgx_exception_info_t *)sp; + // decrease the stack to save the SSA[0]->ip + size = sizeof(uintptr_t); + sp -= size; + if(!is_stack_addr((void *)sp, size)) + { + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_STACK_OVERRUN; + } + + // sp is within limit_addr and commit_addr, currently only SGX 2.0 under hardware mode will enter this branch.^M + if((size_t)sp < thread_data->stack_commit_addr) + { + int ret = -1; + size_t page_aligned_delta = 0; + /* try to allocate memory dynamically */ + page_aligned_delta = ROUND_TO(thread_data->stack_commit_addr - (size_t)sp, SE_PAGE_SIZE); + if ((thread_data->stack_commit_addr > page_aligned_delta) + && ((thread_data->stack_commit_addr - page_aligned_delta) >= thread_data->stack_limit_addr)) + { + ret = expand_stack_by_pages((void *)(thread_data->stack_commit_addr - page_aligned_delta), (page_aligned_delta >> SE_PAGE_SHIFT)); + } + if (ret == 0) + { + thread_data->stack_commit_addr -= page_aligned_delta; + return SGX_SUCCESS; + } + else + { + g_enclave_state = ENCLAVE_CRASHED; + return SGX_ERROR_STACK_OVERRUN; + } + } + if(ssa_gpr->exit_info.valid != 1) { // exception handlers are not allowed to call in a non-exception state goto default_handler; } - - info = (sgx_exception_info_t *)sp; - - // No need to check the stack as it have already been checked by assembly code // initialize the info with SSA[0] info->exception_vector = (sgx_exception_vector_t)ssa_gpr->exit_info.vector; @@ -374,14 +418,7 @@ extern "C" sgx_status_t trts_handle_exception(void *tcs) info->cpu_context.r15 = ssa_gpr->r15; #endif - // decrease the stack to save the SSA[0]->ip - size = sizeof(uintptr_t); - new_sp = (uintptr_t *)(sp - size); - if(!is_stack_addr(new_sp, size)) - { - g_enclave_state = ENCLAVE_CRASHED; - return SGX_ERROR_STACK_OVERRUN; - } + new_sp = (uintptr_t *)sp; ssa_gpr->REG(ip) = (size_t)internal_handle_exception; // prepare the ip for 2nd phrase handling ssa_gpr->REG(sp) = (size_t)new_sp; // new stack for internal_handle_exception ssa_gpr->REG(ax) = (size_t)info; // 1st parameter (info) for LINUX32 diff --git a/sgx-jvm/linux-sgx/sdk/trts/trts_xsave.cpp b/sgx-jvm/linux-sgx/sdk/trts/trts_xsave.cpp index 7aa3d3d659..e5ee95795f 100644 --- a/sgx-jvm/linux-sgx/sdk/trts/trts_xsave.cpp +++ b/sgx-jvm/linux-sgx/sdk/trts/trts_xsave.cpp @@ -34,38 +34,52 @@ #include "xsave.h" #include "trts_inst.h" #include "util.h" +#include "global_data.h" +#include "stdlib.h" -// 'SYNTHETIC_STATE' buffer size is (512 + 64 + 256) bytes -// 512 for fxsave buffer, -// 64 for xsave header, -// 256 for YMM State (16 * 16 bytes of each YMMH-register) -// and the buffer should be 64 byte aligned. -#define SYNTHETIC_STATE_SIZE (512 + 64 + 256) - -se_static_assert(SYNTHETIC_STATE_SIZE <= SE_PAGE_SIZE); - -static SE_DECLSPEC_ALIGN(4096) const uint16_t -SYNTHETIC_STATE[SYNTHETIC_STATE_SIZE/sizeof(uint16_t)] = { - 0x037F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1F80, 0, 0xFFFF, 0 +#define SYNTHETIC_STATE_SIZE (512 + 64) // 512 for legacy regs, 64 for xsave header +//FXRSTOR only cares about the first 512 bytes, while +//XRSTOR in compacted mode will ignore the first 512 bytes. +extern "C" SE_DECLSPEC_ALIGN(XSAVE_ALIGN_SIZE) const uint32_t +SYNTHETIC_STATE[SYNTHETIC_STATE_SIZE/sizeof(uint32_t)] = { + 0x037F, 0, 0, 0, 0, 0, 0x1F80, 0xFFFF, 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, 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, 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, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // XCOMP_BV[63] = 1, compaction mode }; -static int g_xsave_enabled; // flag to indicate whether xsave is enabled or not +int g_xsave_enabled; // flag to indicate whether xsave is enabled or not // EENTER will set xcr0 with secs.attr.xfrm, // So use the xfeature mask from report instead of calling xgetbv +#ifdef __clang__ +#define SE_OPTIMIZE_OFF [[clang::optnone]] +#else +#define SE_OPTIMIZE_OFF +#endif + +SE_OPTIMIZE_OFF uint64_t get_xfeature_state() { + assert (REPORT_ALIGN_SIZE >= REPORT_DATA_ALIGN_SIZE); + assert (REPORT_ALIGN_SIZE >= TARGET_INFO_ALIGN_SIZE); + // target_info and report_data are useless // we only need to make sure their alignment and within enclave - // so set the pointers to SYNTHETIC_STATE - sgx_target_info_t *target_info = (sgx_target_info_t *)SYNTHETIC_STATE; - sgx_report_data_t *report_data = (sgx_report_data_t *)SYNTHETIC_STATE; uint8_t buffer[sizeof(sgx_report_t) + REPORT_ALIGN_SIZE -1]; for(size_t i=0; i< sizeof(sgx_report_t) + REPORT_ALIGN_SIZE -1; i++) { buffer[i] = 0; } sgx_report_t *report = (sgx_report_t *)ROUND_TO((size_t)buffer, REPORT_ALIGN_SIZE); + sgx_target_info_t *target_info = (sgx_target_info_t *)report; + sgx_report_data_t *report_data = (sgx_report_data_t *)report; + do_ereport(target_info, report_data, report); @@ -78,39 +92,4 @@ uint64_t get_xfeature_state() return xfrm; } -// save_and_clean_xfeature_regs() -// do fwait, fxsave, and then clean the extended feature registers -// Parameters: -// buffer - If the pointer is not NULL, save the CPU state to the memory -// Return Value: -// none -void save_and_clean_xfeature_regs(uint8_t *buffer) -{ - do_fwait(); - if(buffer != 0) - { - uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); - do_fxsave(buf); - } - - if(g_xsave_enabled) - { - do_xrstor(SYNTHETIC_STATE); - } - else - { - do_fxrstor(SYNTHETIC_STATE); - } -} -// restore_xfeature_regs() -// restore the extended feature registers -// -void restore_xfeature_regs(const uint8_t *buffer) -{ - if(buffer != 0) - { - uint8_t *buf = (uint8_t*)ROUND_TO((size_t)buffer, FXSAVE_ALIGN_SIZE); - do_fxrstor(buf); - } -} diff --git a/sgx-jvm/linux-sgx/external/crypto_px/Makefile b/sgx-jvm/linux-sgx/sdk/tsafecrt/Makefile similarity index 67% rename from sgx-jvm/linux-sgx/external/crypto_px/Makefile rename to sgx-jvm/linux-sgx/sdk/tsafecrt/Makefile index 963b221853..6bed89d92d 100644 --- a/sgx-jvm/linux-sgx/external/crypto_px/Makefile +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/Makefile @@ -31,34 +31,42 @@ include ../../buildenv.mk -CFLAGS += -fPIC -D_PX -ifeq ($(ARCH), x86_64) - CFLAGS += -D_ARCH_EM64T -else - CFLAGS += -D_ARCH_IA32 +CFLAGS += $(ENCLAVE_CFLAGS) -D _LIBSAFECRT_SGX_CONFIG +CFLAGS += -std=c99 +CXXFLAGS += $(ENCLAVE_CXXFLAGS) + +CPPFLAGS += -I. \ + -I$(COMMON_DIR)/inc \ + -I$(COMMON_DIR)/inc/tlibc \ + -I$(COMMON_DIR)/inc/internal \ + -I$(LINUX_SDK_DIR)/tsafecrt/pal/inc \ + + +ifneq ($(ARCH), x86) +CFLAGS += -D _WIN64 endif -INC := -I./include \ - -I./sources/include \ - -I./sources/ippcp/src +LIB_NAME = libsgx_tsafecrt.a +LIBC_SRCS := $(wildcard pal/src/safecrt/*.c) +LIBCPP_SRCS := $(wildcard pal/src/*.cpp) -SRCS := $(wildcard ./sources/ippcp/src/*.c) -OBJS := $(sort $(SRCS:.c=.o)) +LIB_OBJS := $(LIBC_SRCS:.c=.o) +LIB_OBJS += $(LIBCPP_SRCS:.cpp=.o) +LIB_OBJS := $(sort $(LIB_OBJS)) -libcrypto_px.a: $(OBJS) - ar crv $@ $^ - -%.o :%.c - $(CC) -c $(INC) $(CFLAGS) $< -o $@ .PHONY: all -all: libcrypto_px.a +all: $(LIB_NAME) +$(LIB_NAME): $(LIB_OBJS) + $(AR) rcs $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ + .PHONY: clean clean: - @$(RM) $(OBJS) libcrypto_px.a - -.PHONY: rebuild -rebuild: - $(MAKE) clean - $(MAKE) all + @$(RM) $(LIB_NAME) $(LIB_OBJS) diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/inc/pal_mstypes.h b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/inc/pal_mstypes.h new file mode 100644 index 0000000000..ef56bbb141 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/inc/pal_mstypes.h @@ -0,0 +1,709 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*++ + + + + + +--*/ + +//////////////////////////////////////////////////////////////////////// +// Extensions to the usual posix header files +//////////////////////////////////////////////////////////////////////// + +#ifndef __PAL_MSTYPES_H__ +#define __PAL_MSTYPES_H__ + +#define __MSTYPES_DEFINED + +#ifdef __cplusplus +extern "C" { +#endif + +#define BIGENDIAN 0 +//////////////////////////////////////////////////////////////////////// +// calling convention stuff +//////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif // __cplusplus + + +// Note: Win32-hosted GCC predefines __stdcall and __cdecl, but Unix- +// hosted GCC does not. + +#ifdef __i386__ + +#define __stdcall +#define _stdcall +#define __cdecl +#define _cdecl +#define CDECL + +#ifndef PAL_STDCPP_COMPAT +#undef __fastcall +#define __fastcall __stdcall +#undef _fastcall +#define _fastcall __fastcall +#endif // PAL_STDCPP_COMPAT + +#else // !defined(__i386__) + +#define __stdcall +#define _stdcall +#define __cdecl +#define _cdecl +#define CDECL + +// On ARM __fastcall is ignored and causes a compile error +#if !defined(PAL_STDCPP_COMPAT) || defined(__arm__) +# undef __fastcall +# undef _fastcall +# define __fastcall +# define _fastcall +#endif // !defined(PAL_STDCPP_COMPAT) || defined(__arm__) + +#endif // !defined(__i386__) + +#define CALLBACK __stdcall + +#if !defined(_declspec) +#define _declspec(e) __declspec(e) +#endif + +#if defined(_VAC_) && defined(__cplusplus) +#define __inline inline +#endif + + +#define PALIMPORT +#define PAL_NORETURN __attribute__((noreturn)) +#define PALAPI __stdcall +#define PALAPIV __cdecl + +//////////////////////////////////////////////////////////////////////// +// Type attribute stuff +//////////////////////////////////////////////////////////////////////// + +#define CONST const +#define IN +#define OUT +#define OPTIONAL +#define FAR + +#ifdef UNICODE +#define __TEXT(x) L##x +#else +#define __TEXT(x) x +#endif +#define TEXT(x) __TEXT(x) + +//////////////////////////////////////////////////////////////////////// +// Some special values +//////////////////////////////////////////////////////////////////////// + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +//////////////////////////////////////////////////////////////////////// +// Misc. type helpers +//////////////////////////////////////////////////////////////////////// + +// GCC's way of declaring large integer constants +// If you define these in one step, without the _HELPER macros, you +// get extra whitespace when composing these with other concatenating macros. +#define I64_HELPER(x) x ## LL +#define I64(x) I64_HELPER(x) + +#define UI64_HELPER(x) x ## ULL +#define UI64(x) UI64_HELPER(x) + +//////////////////////////////////////////////////////////////////////// +// Misc. types +//////////////////////////////////////////////////////////////////////// + + +// A bunch of source files (e.g. most of the ndp tree) include pal.h +// but are written to be LLP64, not LP64. (LP64 => long = 64 bits +// LLP64 => longs = 32 bits, long long = 64 bits) +// +// To handle this difference, we #define long to be int (and thus 32 bits) when +// compiling those files. (See the bottom of this file or search for +// #define long to see where we do this.) +// +// But this fix is more complicated than it seems, because we also use the +// preprocessor to #define __int64 to long for LP64 architectures (__int64 +// isn't a builtin in gcc). We don't want __int64 to be an int (by cascading +// macro rules). So we play this little trick below where we add +// __cppmungestrip before "long", which is what we're really #defining __int64 +// to. The preprocessor sees __cppmungestriplong as something different than +// long, so it doesn't replace it with int. The during the cppmunge phase, we +// remove the __cppmungestrip part, leaving long for the compiler to see. +// +// Note that we can't just use a typedef to define __int64 as long before +// #defining long because typedefed types can't be signedness-agnostic (i.e. +// they must be either signed or unsigned) and we want to be able to use +// __int64 as though it were intrinsic + +#ifdef BIT64 +#define __int64 long +#else // BIT64 +#define __int64 long long +#endif // BIT64 + +#define __int32 int +#define __int16 short int +#define __int8 char // assumes char is signed + +#ifndef _LIBSAFECRT_SGX_CONFIG +#ifndef PAL_STDCPP_COMPAT +// Defined in gnu's types.h. For non PAL_IMPLEMENTATION system +// includes are not included, so we need to define them. +// Types below are already defined by stdint.h on __APPLE__. +#if !defined(PAL_IMPLEMENTATION) && !defined(__APPLE__) +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int8 int8_t; +#define __int8_t_defined + +typedef unsigned __int8 uint8_t; +#endif // PAL_IMPLEMENTATION + + +#if _WIN64 +typedef long double LONG_DOUBLE; +#endif + +#endif // !PAL_STDCPP_COMPAT +#endif +typedef void VOID; + +#ifndef PLATFORM_UNIX +typedef long LONG; +typedef unsigned long ULONG; +#else +typedef int LONG; // NOTE: diff from windows.h, for LP64 compat +typedef unsigned int ULONG; // NOTE: diff from windows.h, for LP64 compat +#endif + +typedef __int64 LONGLONG; +typedef unsigned __int64 ULONGLONG; +typedef ULONGLONG DWORD64; +typedef DWORD64 *PDWORD64; +typedef LONGLONG *PLONG64; +typedef ULONGLONG *PULONG64; +typedef ULONGLONG *PULONGLONG; +typedef ULONG *PULONG; +typedef short SHORT; +typedef SHORT *PSHORT; +typedef unsigned short USHORT; +typedef USHORT *PUSHORT; +typedef unsigned char UCHAR; +typedef UCHAR *PUCHAR; +typedef char *PSZ; +typedef ULONGLONG DWORDLONG; + +#ifndef PLATFORM_UNIX +typedef unsigned long DWORD; +#else +typedef unsigned int DWORD; // NOTE: diff from windows.h, for LP64 compat +#endif + +typedef unsigned int DWORD32, *PDWORD32; + +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef float FLOAT; +typedef double DOUBLE; +typedef BOOL *PBOOL; +typedef BOOL *LPBOOL; +typedef BYTE *PBYTE; +typedef BYTE *LPBYTE; +typedef const BYTE *LPCBYTE; +typedef int *PINT; +typedef int *LPINT; +typedef WORD *PWORD; +typedef WORD *LPWORD; +typedef LONG *LPLONG; +typedef LPLONG PLONG; +typedef DWORD *PDWORD; +typedef DWORD *LPDWORD; +typedef void *PVOID; +typedef void *LPVOID; +typedef CONST void *LPCVOID; +typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; +typedef BYTE BOOLEAN; +typedef BOOLEAN *PBOOLEAN; + +typedef unsigned __int8 UINT8; +typedef signed __int8 INT8; +typedef unsigned __int16 UINT16; +typedef signed __int16 INT16; +typedef unsigned __int32 UINT32, *PUINT32; +typedef signed __int32 INT32, *PINT32; +typedef unsigned __int64 UINT64, *PUINT64; +typedef signed __int64 INT64, *PINT64; + +typedef unsigned __int32 ULONG32, *PULONG32; +typedef signed __int32 LONG32, *PLONG32; +typedef unsigned __int64 ULONG64; +typedef signed __int64 LONG64; + +#define _W64 + +#ifdef BIT64 +#define _atoi64 (__int64)atoll + +typedef __int64 INT_PTR, *PINT_PTR; +typedef unsigned __int64 UINT_PTR, *PUINT_PTR; +typedef __int64 LONG_PTR, *PLONG_PTR; +typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; +typedef unsigned __int64 DWORD_PTR, *PDWORD_PTR; + +/* maximum signed 64 bit value */ +#define LONG_PTR_MAX I64(9223372036854775807) +/* maximum unsigned 64 bit value */ +#define ULONG_PTR_MAX UI64(0xffffffffffffffff) + +#ifndef SIZE_MAX +#define SIZE_MAX _UI64_MAX +#endif + +#define __int3264 __int64 + +#if !defined(BIT64) +__inline +unsigned long +HandleToULong( + const void *h + ) +{ + return((unsigned long) (ULONG_PTR) h ); +} + +__inline +long +HandleToLong( + const void *h + ) +{ + return((long) (LONG_PTR) h ); +} + +__inline +void * +ULongToHandle( + const unsigned long h + ) +{ + return((void *) (UINT_PTR) h ); +} + + +__inline +void * +LongToHandle( + const long h + ) +{ + return((void *) (INT_PTR) h ); +} + + +__inline +unsigned long +PtrToUlong( + const void *p + ) +{ + return((unsigned long) (ULONG_PTR) p ); +} + +__inline +unsigned int +PtrToUint( + const void *p + ) +{ + return((unsigned int) (UINT_PTR) p ); +} + +__inline +unsigned short +PtrToUshort( + const void *p + ) +{ + return((unsigned short) (unsigned long) (ULONG_PTR) p ); +} + +__inline +long +PtrToLong( + const void *p + ) +{ + return((long) (LONG_PTR) p ); +} + +__inline +int +PtrToInt( + const void *p + ) +{ + return((int) (INT_PTR) p ); +} + +__inline +short +PtrToShort( + const void *p + ) +{ + return((short) (long) (LONG_PTR) p ); +} + +__inline +void * +IntToPtr( + const int i + ) +// Caution: IntToPtr() sign-extends the int value. +{ + return( (void *)(INT_PTR)i ); +} + +__inline +void * +UIntToPtr( + const unsigned int ui + ) +// Caution: UIntToPtr() zero-extends the unsigned int value. +{ + return( (void *)(UINT_PTR)ui ); +} + +__inline +void * +LongToPtr( + const long l + ) +// Caution: LongToPtr() sign-extends the long value. +{ + return( (void *)(LONG_PTR)l ); +} + +__inline +void * +ULongToPtr( + const unsigned long ul + ) +// Caution: ULongToPtr() zero-extends the unsigned long value. +{ + return( (void *)(ULONG_PTR)ul ); +} + +__inline +void * +ShortToPtr( + const short s + ) +// Caution: ShortToPtr() sign-extends the short value. +{ + return( (void *)(INT_PTR)s ); +} + +__inline +void * +UShortToPtr( + const unsigned short us + ) +// Caution: UShortToPtr() zero-extends the unsigned short value. +{ + return( (void *)(UINT_PTR)us ); +} + +#else // !defined(BIT64) +#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) ) +#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) +#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) ) +#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) ) +#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) +#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) +#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) +#define PtrToInt( p ) ((INT)(INT_PTR) (p) ) +#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) +#define PtrToShort( p ) ((short)(LONG_PTR)(p) ) +#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)(i))) +#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)(ui))) +#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)(l))) +#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)(ul))) +#define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)(s))) +#define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)(s))) +#endif // !defined(BIT64) + +#else + +typedef _W64 __int32 INT_PTR; +typedef _W64 unsigned __int32 UINT_PTR; + +typedef _W64 __int32 LONG_PTR; +typedef _W64 unsigned __int32 ULONG_PTR, *PULONG_PTR; +typedef _W64 unsigned __int32 DWORD_PTR, *PDWORD_PTR; + +/* maximum signed 32 bit value */ +#define LONG_PTR_MAX 2147483647L +/* maximum unsigned 32 bit value */ +#define ULONG_PTR_MAX 0xffffffffUL + +#define SIZE_MAX UINT_MAX + +#define __int3264 __int32 + +#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) ) +#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) +#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) ) +#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) ) +#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) +#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) +#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) +#define PtrToInt( p ) ((INT)(INT_PTR) (p) ) +#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) +#define PtrToShort( p ) ((short)(LONG_PTR)(p) ) +#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i)) +#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui)) +#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l)) +#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul)) +#define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)s)) +#define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)s)) + +#endif + +#define HandleToUlong(h) HandleToULong(h) +#define UlongToHandle(ul) ULongToHandle(ul) +#define UlongToPtr(ul) ULongToPtr(ul) +#define UintToPtr(ui) UIntToPtr(ui) + +typedef ULONG_PTR SIZE_T, *PSIZE_T; +typedef LONG_PTR SSIZE_T, *PSSIZE_T; + +#ifndef SIZE_T_MAX +#define SIZE_T_MAX ULONG_PTR_MAX +#endif // SIZE_T_MAX + +#ifndef SSIZE_T_MAX +#define SSIZE_T_MAX LONG_PTR_MAX +#endif + +#ifndef SSIZE_T_MIN +#define SSIZE_T_MIN I64(-9223372036854775808) +#endif +#ifndef _LIBSAFECRT_SGX_CONFIG +#ifndef PAL_STDCPP_COMPAT +#if defined(__APPLE__) || defined(__LINUX__) +#ifdef BIT64 +typedef unsigned long size_t; +typedef long ptrdiff_t; +#else // !BIT64 +typedef unsigned int size_t; +typedef int ptrdiff_t; +#endif // !BIT64 +#else +typedef ULONG_PTR size_t; +typedef LONG_PTR ptrdiff_t; +#endif +#endif // !PAL_STDCPP_COMPAT +#define _SIZE_T_DEFINED + +typedef LONG_PTR LPARAM; + +#define _PTRDIFF_T_DEFINED +#ifdef _MINGW_ +// We need to define _PTRDIFF_T to make sure ptrdiff_t doesn't get defined +// again by system headers - but only for MinGW. +#define _PTRDIFF_T +#endif +#endif + +#ifndef _LIBSAFECRT_SGX_CONFIG +#if !defined(__cplusplus) +#include +typedef wchar_t char16_t; +#endif // __cplusplus + + +typedef char16_t char16; +typedef char16_t WCHAR; + +#ifdef PAL_STDCPP_COMPAT + +#ifdef __APPLE__ +static_assert(sizeof(unsigned long) == sizeof(void*), "This platform is not supported"); +#else +#ifdef BIT64 +typedef unsigned long int uintptr_t; +#else // !BIT64 +typedef unsigned int uintptr_t; +#endif // !BIT64 +#endif + +#else // !PAL_STDCPP_COMPAT + +#if defined(__LINUX__) +#ifdef BIT64 +typedef long int intptr_t; +typedef unsigned long int uintptr_t; +#else // !BIT64 +typedef int intptr_t; +typedef unsigned int uintptr_t; +#endif // !BIT64 +#else +typedef INT_PTR intptr_t; +typedef UINT_PTR uintptr_t; +#endif + +#endif // PAL_STDCPP_COMPAT + +#define _INTPTR_T_DEFINED +#define _UINTPTR_T_DEFINED +#else +#include "mbusafecrt.h" +#if !defined(__cplusplus) +typedef wchar_t char16_t; +#endif // __cplusplus + +#endif +typedef DWORD LCID; +typedef PDWORD PLCID; +typedef WORD LANGID; + +typedef DWORD LCTYPE; + +typedef WCHAR *PWCHAR; +typedef WCHAR *LPWCH, *PWCH; +typedef CONST WCHAR *LPCWCH, *PCWCH; +typedef WCHAR *NWPSTR; +typedef WCHAR *LPWSTR, *PWSTR; + +typedef CONST WCHAR *LPCWSTR, *PCWSTR; + +typedef char CHAR; +typedef CHAR *PCHAR; +typedef CHAR *LPCH, *PCH; +typedef CONST CHAR *LPCCH, *PCCH; +typedef CHAR *NPSTR; +typedef CHAR *LPSTR, *PSTR; +typedef CONST CHAR *LPCSTR, *PCSTR; + +#ifdef UNICODE +typedef WCHAR TCHAR; +typedef WCHAR _TCHAR; +#else +typedef CHAR TCHAR; +typedef CHAR _TCHAR; +#endif +typedef TCHAR *PTCHAR; +typedef TCHAR *LPTSTR, *PTSTR; +typedef CONST TCHAR *LPCTSTR; + +#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8)) +#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16)) +#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff)) +#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) +#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff)) +#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8)) + +typedef VOID *HANDLE; +typedef HANDLE HWND; +typedef struct __PAL_RemoteHandle__ { HANDLE h; } *RHANDLE; +typedef HANDLE *PHANDLE; +typedef HANDLE *LPHANDLE; +#define INVALID_HANDLE_VALUE ((VOID *)(-1)) +#define INVALID_FILE_SIZE ((DWORD)0xFFFFFFFF) +#define INVALID_FILE_ATTRIBUTES ((DWORD) -1) +typedef HANDLE HMODULE; +typedef HANDLE HINSTANCE; +typedef HANDLE HGLOBAL; +typedef HANDLE HLOCAL; +typedef HANDLE HRSRC; + +typedef LONG HRESULT; +typedef LONG NTSTATUS; + +typedef union _LARGE_INTEGER { + struct { +#if BIGENDIAN + LONG HighPart; + DWORD LowPart; +#else + DWORD LowPart; + LONG HighPart; +#endif + }; + struct { +#if BIGENDIAN + LONG HighPart; + DWORD LowPart; +#else + DWORD LowPart; + LONG HighPart; +#endif + } u; + LONGLONG QuadPart; +} LARGE_INTEGER, *PLARGE_INTEGER; + +#ifndef GUID_DEFINED +typedef struct _GUID { + ULONG Data1; // NOTE: diff from Win32, for LP64 + USHORT Data2; + USHORT Data3; + UCHAR Data4[ 8 ]; +} GUID; +typedef const GUID *LPCGUID; +#define GUID_DEFINED +#endif // !GUID_DEFINED + +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME, *PFILETIME, *LPFILETIME; + +/* Code Page Default Values */ +#define CP_ACP 0 /* default to ANSI code page */ +#define CP_OEMCP 1 /* default to OEM code page */ +#define CP_MACCP 2 /* default to MAC code page */ +#define CP_THREAD_ACP 3 /* current thread's ANSI code page */ +#define CP_WINUNICODE 1200 +#define CP_UNICODE 1200 /* Unicode */ +#define CP_UNICODESWAP 1201 /* Unicode Big-Endian */ +#define CP_UTF7 65000 /* UTF-7 translation */ +#define CP_UTF8 65001 /* UTF-8 translation */ + +typedef PVOID PSID; + +#ifdef __cplusplus +} +#endif + +#endif // __PAL_MSTYPES_H__ diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/internal_securecrt.h b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/internal_securecrt.h new file mode 100644 index 0000000000..8a52925775 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/internal_securecrt.h @@ -0,0 +1,304 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*internal_securecrt.h - contains declarations of internal routines and variables for securecrt +* + +* +*Purpose: +* Declares routines and variables used internally in the SecureCRT implementation. +* In this include file we define the macros needed to implement the secure functions +* inlined in the *.inl files like tcscpy_s.inl, etc. +* Note that this file is used for the CRT implementation, while internal_safecrt is used +* to build the downlevel library safecrt.lib. +* +* [Internal] +* +****/ + +#pragma once + +#ifndef _INC_INTERNAL_SECURECRT +#define _INC_INTERNAL_SECURECRT + +/* more VS specific goodness */ +#define __out_ecount_z( x ) +#define __out_ecount( x ) +#define __in_opt +#define __in_z_opt +#define __out_ecount_z_opt( x ) +#define __in_z +#define __in + +/* + * The original SafeCRT implemention allows runtine control over buffer checking. + * For now we'll key this off the debug flag. + */ +#ifdef _DEBUG + #define _CrtGetCheckCount() ((int)1) +#else + #define _CrtGetCheckCount() ((int)0) +#endif + +/* Assert message and Invalid parameter */ +#ifdef _DEBUG +#ifdef _LIBSAFECRT_SGX_CONFIG +#include + #define _ASSERT_EXPR( val, exp ) \ + { \ + assert(val != 0); \ + } +#else + #define _ASSERT_EXPR( val, exp ) \ + { \ + if ( ( val ) == 0 ) \ + { \ + if ( sMBUSafeCRTAssertFunc != NULL ) \ + { \ + ( *sMBUSafeCRTAssertFunc )( #exp, "SafeCRT assert failed", __FILE__, __LINE__ ); \ + } \ + } \ + } +#endif + #define _INVALID_PARAMETER( exp ) _ASSERT_EXPR( 0, exp ) + #define _ASSERTE( exp ) _ASSERT_EXPR( exp, exp ) +#else + #define _ASSERT_EXPR( val, expr ) + #define _INVALID_PARAMETER( exp ) + #define _ASSERTE( exp ) +#endif + +/* _TRUNCATE */ +#if !defined (_TRUNCATE) +#define _TRUNCATE ((size_t)-1) +#endif /* !defined (_TRUNCATE) */ + +/* #include */ + +#define _VALIDATE_RETURN_VOID( expr, errorcode ) \ + { \ + int _Expr_val=!!(expr); \ + _ASSERT_EXPR( ( _Expr_val ), #expr ); \ + if ( !( _Expr_val ) ) \ + { \ + errno = errorcode; \ + _INVALID_PARAMETER(#expr); \ + return; \ + } \ + } + +/* + * Assert in debug builds. + * set errno and return value + */ + +#ifndef _VALIDATE_RETURN +#define _VALIDATE_RETURN( expr, errorcode, retexpr ) \ + { \ + int _Expr_val=!!(expr); \ + _ASSERT_EXPR( ( _Expr_val ), #expr ); \ + if ( !( _Expr_val ) ) \ + { \ + errno = errorcode; \ + _INVALID_PARAMETER(#expr ); \ + return ( retexpr ); \ + } \ + } +#endif /* _VALIDATE_RETURN */ + +#ifndef _VALIDATE_RETURN_NOEXC +#define _VALIDATE_RETURN_NOEXC( expr, errorcode, retexpr ) \ + { \ + if ( !(expr) ) \ + { \ + errno = errorcode; \ + return ( retexpr ); \ + } \ + } +#endif /* _VALIDATE_RETURN_NOEXC */ + +/* + * Assert in debug builds. + * set errno and return errorcode + */ + +#define _VALIDATE_RETURN_ERRCODE( expr, errorcode ) \ + { \ + int _Expr_val=!!(expr); \ + _ASSERT_EXPR( ( _Expr_val ), _CRT_WIDE(#expr) ); \ + if ( !( _Expr_val ) ) \ + { \ + errno = errorcode; \ + _INVALID_PARAMETER(_CRT_WIDE(#expr)); \ + return ( errorcode ); \ + } \ + } + +/* We completely fill the buffer only in debug (see _SECURECRT__FILL_STRING + * and _SECURECRT__FILL_BYTE macros). + */ +#if !defined (_SECURECRT_FILL_BUFFER) +#ifdef _DEBUG +#define _SECURECRT_FILL_BUFFER 1 +#else /* _DEBUG */ +#define _SECURECRT_FILL_BUFFER 0 +#endif /* _DEBUG */ +#endif /* !defined (_SECURECRT_FILL_BUFFER) */ + +/* _SECURECRT_FILL_BUFFER_PATTERN is the same as _bNoMansLandFill */ +#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD + +#if !defined (_SECURECRT_FILL_BUFFER_THRESHOLD) +#ifdef _DEBUG +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) +#else /* _DEBUG */ +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)0) +#endif /* _DEBUG */ +#endif /* !defined (_SECURECRT_FILL_BUFFER_THRESHOLD) */ + +#if _SECURECRT_FILL_BUFFER +#define _SECURECRT__FILL_STRING(_String, _Size, _Offset) \ + if ((_Size) != ((size_t)-1) && (_Size) != INT_MAX && \ + ((size_t)(_Offset)) < (_Size)) \ + { \ + memset((_String) + (_Offset), \ + _SECURECRT_FILL_BUFFER_PATTERN, \ + (_SECURECRT_FILL_BUFFER_THRESHOLD < ((size_t)((_Size) - (_Offset))) ? \ + _SECURECRT_FILL_BUFFER_THRESHOLD : \ + ((_Size) - (_Offset))) * sizeof(*(_String))); \ + } +#else /* _SECURECRT_FILL_BUFFER */ +#define _SECURECRT__FILL_STRING(_String, _Size, _Offset) +#endif /* _SECURECRT_FILL_BUFFER */ + +#if _SECURECRT_FILL_BUFFER +#define _SECURECRT__FILL_BYTE(_Position) \ + if (_SECURECRT_FILL_BUFFER_THRESHOLD > 0) \ + { \ + (_Position) = _SECURECRT_FILL_BUFFER_PATTERN; \ + } +#else /* _SECURECRT_FILL_BUFFER */ +#define _SECURECRT__FILL_BYTE(_Position) +#endif /* _SECURECRT_FILL_BUFFER */ + +/* string resetting */ +#define _FILL_STRING _SECURECRT__FILL_STRING + +#define _FILL_BYTE _SECURECRT__FILL_BYTE + +#define _RESET_STRING(_String, _Size) \ + { \ + *(_String) = 0; \ + _FILL_STRING((_String), (_Size), 1); \ + } + +/* validations */ +#define _VALIDATE_STRING_ERROR(_String, _Size, _Ret) \ + _VALIDATE_RETURN((_String) != NULL && (_Size) > 0, EINVAL, (_Ret)) + +#define _VALIDATE_STRING(_String, _Size) \ + _VALIDATE_STRING_ERROR((_String), (_Size), EINVAL) + +#define _VALIDATE_POINTER_ERROR_RETURN(_Pointer, _ErrorCode, _Ret) \ + _VALIDATE_RETURN((_Pointer) != NULL, (_ErrorCode), (_Ret)) + +#define _VALIDATE_POINTER_ERROR(_Pointer, _Ret) \ + _VALIDATE_POINTER_ERROR_RETURN((_Pointer), EINVAL, (_Ret)) + +#define _VALIDATE_POINTER(_Pointer) \ + _VALIDATE_POINTER_ERROR((_Pointer), EINVAL) + +#define _VALIDATE_CONDITION_ERROR_RETURN(_Condition, _ErrorCode, _Ret) \ + _VALIDATE_RETURN((_Condition), (_ErrorCode), (_Ret)) + +#define _VALIDATE_CONDITION_ERROR(_Condition, _Ret) \ + _VALIDATE_CONDITION_ERROR_RETURN((_Condition), EINVAL, (_Ret)) + +#define _VALIDATE_POINTER_RESET_STRING_ERROR(_Pointer, _String, _Size, _Ret) \ + if ((_Pointer) == NULL) \ + { \ + _RESET_STRING((_String), (_Size)); \ + _VALIDATE_POINTER_ERROR_RETURN((_Pointer), EINVAL, (_Ret)) \ + } + +#define _VALIDATE_POINTER_RESET_STRING(_Pointer, _String, _Size) \ + _VALIDATE_POINTER_RESET_STRING_ERROR((_Pointer), (_String), (_Size), EINVAL) + +#define _RETURN_BUFFER_TOO_SMALL_ERROR(_String, _Size, _Ret) \ + _VALIDATE_RETURN(("Buffer is too small" && 0), ERANGE, _Ret) + +#define _RETURN_BUFFER_TOO_SMALL(_String, _Size) \ + _RETURN_BUFFER_TOO_SMALL_ERROR((_String), (_Size), ERANGE) + +#define _RETURN_DEST_NOT_NULL_TERMINATED(_String, _Size) \ + _VALIDATE_RETURN(("String is not null terminated" && 0), EINVAL, EINVAL) + +#define _RETURN_EINVAL \ + _VALIDATE_RETURN(("Invalid parameter" && 0), EINVAL, EINVAL) + +#define _RETURN_ERROR(_Msg, _Ret) \ + _VALIDATE_RETURN(((_Msg), 0), EINVAL, _Ret) + +/* returns without calling _invalid_parameter */ +#define _RETURN_NO_ERROR \ + return 0 + +/* errno value that specific to SafeCRT */ +#define STRUNCATE 80 + +/* Note that _RETURN_TRUNCATE does not set errno */ +#define _RETURN_TRUNCATE \ + return STRUNCATE + +#define _SET_MBCS_ERROR \ + (errno = EILSEQ) + +#define _RETURN_MBCS_ERROR \ + return _SET_MBCS_ERROR + +/* locale dependent */ +#define _LOCALE_ARG \ + _LocInfo + +#define _LOCALE_ARG_DECL \ + _locale_t _LOCALE_ARG + +#define _LOCALE_UPDATE \ + _LocaleUpdate _LocUpdate(_LOCALE_ARG) + +#define _ISMBBLEAD(_Character) \ + _ismbblead_l((_Character), _LocUpdate.GetLocaleT()) + +#define _MBSDEC(_String, _Current) \ + _mbsdec((_String), (_Current)) + +#define _ISMBBLEADPREFIX(_Result, _StringStart, _BytePtr) \ + { \ + unsigned char *_Tmp_VAR, *_StringStart_VAR, *_BytePtr_VAR; \ + \ + _StringStart_VAR = (_StringStart); \ + _BytePtr_VAR = (_BytePtr); \ + _Tmp_VAR = _BytePtr_VAR; \ + while ((_Tmp_VAR >= _StringStart_VAR) && _ISMBBLEAD(*_Tmp_VAR)) \ + { \ + _Tmp_VAR--; \ + } \ + (_Result) = ((_BytePtr_VAR - _Tmp_VAR) & 1) != 0; \ + } + +#define _LOCALE_SHORTCUT_TEST \ + _LocUpdate.GetLocaleT()->mbcinfo->ismbcodepage == 0 + +#define _USE_LOCALE_ARG 1 + +/* misc */ +#define _ASSIGN_IF_NOT_NULL(_Pointer, _Value) \ + if ((_Pointer) != NULL) \ + { \ + *(_Pointer) = (_Value); \ + } + +#endif /* _INC_INTERNAL_SECURECRT */ diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt.c new file mode 100644 index 0000000000..d6ecea8187 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt.c @@ -0,0 +1,258 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +* mbusafecrt.c - implementaion of support functions and data for MBUSafeCRT +* + +* +* Purpose: +* This file contains the implementation of support functions and +* data for MBUSafeCRT declared in mbusafecrt.h and mbusafecrt_internal.h. +****/ +#ifndef _LIBSAFECRT_SGX_CONFIG +#include "pal/palinternal.h" +#endif +#include +#include +#include + +#include "mbusafecrt_internal.h" + +#ifndef _LIBSAFECRT_SGX_CONFIG +/* global data */ +tSafeCRT_AssertFuncPtr sMBUSafeCRTAssertFunc = NULL; + +/*** +* MBUSafeCRTSetAssertFunc - Set the function called when an assert fails. +****/ + +void MBUSafeCRTSetAssertFunc( tSafeCRT_AssertFuncPtr inAssertFuncPtr ) +{ + /* set it */ + sMBUSafeCRTAssertFunc = inAssertFuncPtr; +} +#endif +/*** +* _putc_nolock - putc for the miniFILE stream. +****/ + +int _putc_nolock( char inChar, miniFILE* inStream ) +{ + int returnValue = EOF; + + inStream->_cnt -= (int)sizeof( char ); + + if ( ( inStream->_cnt ) >= 0 ) + { + *( inStream->_ptr ) = inChar; + inStream->_ptr += (int)sizeof( char ); + returnValue = ( int )inChar; + } + + return returnValue; +} + +/*** +* _putwc_nolock - putwc for the miniFILE stream. +****/ + +int _putwc_nolock( char16_t inChar, miniFILE* inStream ) +{ + int returnValue = WEOF; + + inStream->_cnt -= (int)sizeof( char16_t ); + + if ( ( inStream->_cnt ) >= 0 ) + { + *( ( char16_t* )( inStream->_ptr ) ) = inChar; + inStream->_ptr += (int)sizeof( char16_t ); + returnValue = ( int )inChar; + } + + return returnValue; +} + +#ifndef _LIBSAFECRT_SGX_CONFIG +/*** +* _getc_nolock - getc for the miniFILE stream. +****/ + +int _getc_nolock( miniFILE* inStream ) +{ + int returnValue = EOF; + + if ( ( inStream->_cnt ) >= ( int )( sizeof( char ) ) ) + { + inStream->_cnt -= sizeof( char ); + returnValue = ( int )( *( inStream->_ptr ) ); + inStream->_ptr += sizeof( char ); + } + + return returnValue; +} + +/*** +* _getwc_nolock - getc for the miniFILE stream. +****/ + +int _getwc_nolock( miniFILE* inStream ) +{ + int returnValue = EOF; + + if ( ( inStream->_cnt ) >= ( int )( sizeof( char16_t ) ) ) + { + inStream->_cnt -= sizeof( char16_t ); + returnValue = ( int )( *( ( char16_t* )( inStream->_ptr ) ) ); + inStream->_ptr += sizeof( char16_t ); + } + + return returnValue; +} + +/*** +* _ungetc_nolock - ungetc for the miniFILE stream. +****/ + +int _ungetc_nolock( char inChar, miniFILE* inStream ) +{ + int returnValue = EOF; + + if ( ( size_t )( ( inStream->_ptr ) - ( inStream->_base ) ) >= ( sizeof( char ) ) ) + { + inStream->_cnt += sizeof( char ); + inStream->_ptr -= sizeof( char ); + return ( int )inChar; + } + + return returnValue; +} + +/*** +* _ungetwc_nolock - ungetwc for the miniFILE stream. +****/ + +int _ungetwc_nolock( char16_t inChar, miniFILE* inStream ) +{ + int returnValue = WEOF; + + if ( ( size_t )( ( inStream->_ptr ) - ( inStream->_base ) ) >= ( sizeof( char16_t ) ) ) + { + inStream->_cnt += sizeof( char16_t ); + inStream->_ptr -= sizeof( char16_t ); + returnValue = ( unsigned short )inChar; + } + + return returnValue; +} +#endif + +/*** +* _safecrt_cfltcvt - convert a float to an ascii string. +* Uses sprintf - this usage is OK. +****/ + +/* routine used for floating-point output */ +#define FORMATSIZE 30 + +#define _snprintf snprintf + +// taken from output.inl +#define FL_ALTERNATE 0x00080 /* alternate form requested */ + +errno_t _safecrt_cfltcvt(double *arg, char *buffer, size_t sizeInBytes, int type, int precision, int flags) +{ + char format[FORMATSIZE]; + size_t formatlen = 0; + int retvalue; + + if (flags & 1) + { + type -= 'a' - 'A'; + } + formatlen = 0; + format[formatlen++] = '%'; + if (flags & FL_ALTERNATE) + { + format[formatlen++] = '#'; + } + format[formatlen++] = '.'; + _itoa_s(precision, format + formatlen, FORMATSIZE - formatlen, 10); + formatlen = strlen(format); + format[formatlen++] = (char)type; + format[formatlen] = 0; + + buffer[sizeInBytes - 1] = 0; + retvalue = _snprintf(buffer, sizeInBytes, format, *arg); + if (buffer[sizeInBytes - 1] != 0 || retvalue <= 0) + { + buffer[0] = 0; + return EINVAL; + } + return 0; +} + +#ifndef _LIBSAFECRT_SGX_CONFIG +/*** +* _safecrt_fassign - convert a string into a float or double. +****/ + +void _safecrt_fassign(int flag, void* argument, char* number ) +{ + if ( flag != 0 ) // double + { + double dblValue = 0.0; + (void)sscanf( number, "%lf", &dblValue ); + *( ( double* )argument ) = dblValue; + } + else // float + { + float fltValue = 0.0; + (void)sscanf( number, "%f", &fltValue ); + *( ( float* )argument ) = fltValue; + } +} + + +/*** +* _safecrt_wfassign - convert a char16_t string into a float or double. +****/ + +void _safecrt_wfassign(int flag, void* argument, char16_t* number ) +{ + // We cannot use system functions for this - they + // assume that char16_t is four bytes, while we assume + // two. So, we need to convert to a regular char string + // without using any system functions. To do this, + // we'll assume that the numbers are in the 0-9 range and + // do a simple conversion. + + char* numberAsChars = ( char* )number; + int position = 0; + + // do the convert + while ( number[ position ] != 0 ) + { + numberAsChars[ position ] = ( char )( number[ position ] & 0x00FF ); + position++; + } + numberAsChars[ position ] = ( char )( number[ position ] & 0x00FF ); + + // call the normal char version + _safecrt_fassign( flag, argument, numberAsChars ); +} +#endif + +/*** +* _minimal_chartowchar - do a simple char to wchar conversion. +****/ + +int _minimal_chartowchar( char16_t* outWChar, const char* inChar ) +{ + *outWChar = ( char16_t )( ( unsigned short )( ( unsigned char )( *inChar ) ) ); + return 1; +} + + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt_internal.h b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt_internal.h new file mode 100644 index 0000000000..7db492cd2a --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/mbusafecrt_internal.h @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +* mbusafecrt_internal.h - internal declarations for SafeCRT functions +* + +* +* Purpose: +* This file contains the internal declarations SafeCRT +* functions ported to MacOS. These are the safe versions of +* functions standard functions banned by SWI +****/ + +/* shields! */ + +#ifndef MBUSAFECRT_INTERNAL_H +#define MBUSAFECRT_INTERNAL_H + +#include "pal_mstypes.h" +#ifdef _LIBSAFECRT_SGX_CONFIG +#include +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +#endif +#else +typedef __builtin_va_list va_list; + +// The ifdef below are to accommodate Unix build +// that complains about them being declared in stdarg.h already. +#ifndef va_start +#define va_start __builtin_va_start +#endif +#ifndef va_end +#define va_end __builtin_va_end +#endif +#endif +#include "mbusafecrt.h" +#ifdef _LIBSAFECRT_SGX_CONFIG +#include + +#ifdef EOF +#undef EOF +#endif +#define EOF -1 + +#ifdef WEOF +#undef WEOF +#endif +#define WEOF -1 + +#define _ASSERT_CONCAT(a, b) a##b +#define ASSERT_CONCAT(a, b) _ASSERT_CONCAT(a, b) + +#define CASSERT(p) extern int ASSERT_CONCAT(sanity_check_dummy, __LINE__)[1+((!(p))*(-2))]; +#else +#define CASSERT(p) extern int sanity_check_dummy[1+((!(p))*(-2))]; +extern tSafeCRT_AssertFuncPtr sMBUSafeCRTAssertFunc; +#endif + +typedef struct miniFILE_struct +{ + char* _ptr; + int _cnt; + char* _base; + int _flag; +} miniFILE; + +#define _IOSTRG 1 +#define _IOWRT 2 +#define _IOREAD 4 +#define _IOMYBUF 8 + +int _putc_nolock( char inChar, miniFILE* inStream ); +int _putwc_nolock( char16_t inChar, miniFILE* inStream ); +#ifndef _LIBSAFECRT_SGX_CONFIG +int _getc_nolock( miniFILE* inStream ); +int _getwc_nolock( miniFILE* inStream ); +int _ungetc_nolock( char inChar, miniFILE* inStream ); +int _ungetwc_nolock( char16_t inChar, miniFILE* inStream ); +#endif +errno_t _safecrt_cfltcvt(double *arg, char *buffer, size_t sizeInBytes, int type, int precision, int flags); +#ifndef _LIBSAFECRT_SGX_CONFIG +void _safecrt_fassign(int flag, void* argument, char * number ); +void _safecrt_wfassign(int flag, void* argument, char16_t * number ); +#endif +int _minimal_chartowchar( char16_t* outWChar, const char* inChar ); + +int _output_s( miniFILE* outfile, const char* _Format, va_list _ArgList); +int _woutput_s( miniFILE* outfile, const char16_t* _Format, va_list _ArgList); +int _output( miniFILE *outfile, const char* _Format, va_list _ArgList); + +int _soutput_s( char *_Dst, size_t _Size, const char *_Format, va_list _ArgList ); +int _swoutput_s( char16_t *_Dst, size_t _Size, const char16_t *_Format, va_list _ArgList ); + +int __tinput_s( miniFILE* inFile, const unsigned char * inFormat, va_list inArgList ); +int __twinput_s( miniFILE* inFile, const char16_t * inFormat, va_list inArgList ); + +#endif /* MBUSAFECRT_INTERNAL_H */ diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memcpy_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memcpy_s.c new file mode 100644 index 0000000000..a2f22a4ad2 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memcpy_s.c @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*memcpy_s.c - contains memcpy_s routine +* + +* +*Purpose: +* memcpy_s() copies a source memory buffer to a destination buffer. +* Overlapping buffers are not treated specially, so propagation may occur. +* +*Revision History: +* 10-07-03 AC Module created. +* 03-10-04 AC Return ERANGE when buffer is too small +* 01-14-05 AC Prefast (espx) fixes +* +*******************************************************************************/ + +#include +#include +#include "internal_securecrt.h" +#include "mbusafecrt_internal.h" + + +/*** +*memcpy_s - Copy source buffer to destination buffer +* +*Purpose: +* memcpy_s() copies a source memory buffer to a destination memory buffer. +* This routine does NOT recognize overlapping buffers, and thus can lead +* to propagation. +* +* For cases where propagation must be avoided, memmove_s() must be used. +* +*Entry: +* void *dst = pointer to destination buffer +* size_t sizeInBytes = size in bytes of the destination buffer +* const void *src = pointer to source buffer +* size_t count = number of bytes to copy +* +*Exit: +* Returns 0 if everything is ok, else return the error code. +* +*Exceptions: +* Input parameters are validated. Refer to the validation section of the function. +* On error, the error code is returned and the destination buffer is zeroed. +* +*******************************************************************************/ + +errno_t __cdecl memcpy_s( + void * dst, + size_t sizeInBytes, + const void * src, + size_t count +) +{ + if (count == 0) + { + /* nothing to do */ + return 0; + } + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(dst != NULL, EINVAL); + if (src == NULL || sizeInBytes < count) + { + /* zeroes the destination buffer */ + memset(dst, 0, sizeInBytes); + + _VALIDATE_RETURN_ERRCODE(src != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInBytes >= count, ERANGE); + /* useless, but prefast is confused */ + return EINVAL; + } + + memcpy(dst, src, count); + return 0; +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memomve_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memomve_s.c new file mode 100644 index 0000000000..8469c254b5 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/memomve_s.c @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*memmove_s.c - contains memmove_s routine +* +* +*Purpose: +* memmove_s() copies a source memory buffer to a destination buffer. +* Overlapping buffers are treated specially, to avoid propagation. +* +*Revision History: +* 10-07-03 AC Module created. +* 03-10-04 AC Return ERANGE when buffer is too small +* 17-08-16 OB Add additional buffer (unix) for overlapping src / dst +* Return ENOMEM when there is no memory for buffer +*******************************************************************************/ + +// use stdlib instead of PAL defined malloc to avoid forced Wint-to-pointer warning +#include +#include +#ifdef _LIBSAFECRT_SGX_CONFIG +#include "pal_mstypes.h" +#endif + + +#ifndef _VALIDATE_RETURN_ERRCODE +#define _VALIDATE_RETURN_ERRCODE(c, e) \ + if (!(c)) return e +#endif + +#ifndef ENOMEM +#define ENOMEM 12 +#endif + +#ifndef EINVAL +#define EINVAL 22 +#endif + +#ifndef ERANGE +#define ERANGE 34 +#endif + +/* +usage: see https://msdn.microsoft.com/en-us/library/8k35d1fx.aspx + +notes: uses extra buffer in case the src/dst overlaps (osx/bsd) + +dest + Destination object. + +src + Source object. + +count + Number of bytes (memmove) to copy. +*/ +void* __cdecl memmove_xplat( + void * dst, + const void * src, + size_t count +) +{ +#if defined(__APPLE__) || defined(__FreeBSD__) + if (src <= dst && src + count > dst) + { + char *temp = (char*) malloc(count); + _VALIDATE_RETURN_ERRCODE(temp != NULL, NULL); + + memcpy(temp, src, count); + memcpy(dst, temp, count); + + free(temp); + return dst; + } +#endif + + return memmove(dst, src, count); +} + + +/* +usage: see https://msdn.microsoft.com/en-us/library/e2851we8.aspx + +dest + Destination object. + +sizeInBytes + Size of the destination buffer. + +src + Source object. + +count + Number of bytes (memmove_s) or characters (wmemmove_s) to copy. +*/ +int __cdecl memmove_s( + void * dst, + size_t sizeInBytes, + const void * src, + size_t count +) +{ + if (count == 0) + { + /* nothing to do */ + return 0; + } + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(dst != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(src != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInBytes >= count, ERANGE); + + void *ret_val = memmove_xplat(dst, src, count); + return ret_val != NULL ? 0 : ENOMEM; // memmove_xplat returns `NULL` only if ENOMEM +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/output.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/output.inl new file mode 100644 index 0000000000..c3e50c4f07 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/output.inl @@ -0,0 +1,1744 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*output.c - printf style output to a FILE +* + +* +*Purpose: +* This file contains the code that does all the work for the +* printf family of functions. It should not be called directly, only +* by the *printf functions. We don't make any assumtions about the +* sizes of ints, longs, shorts, or long doubles, but if types do overlap, +* we also try to be efficient. We do assume that pointers are the same +* size as either ints or longs. +* If CPRFLAG is defined, defines _cprintf instead. +* **** DOESN'T CURRENTLY DO MTHREAD LOCKING **** +* +*Note: +* this file is included in safecrt.lib build directly, plese refer +* to safecrt_[w]output_s.c +* +*******************************************************************************/ + + +//typedef __int64_t __int64; + + +#define FORMAT_VALIDATIONS + +typedef double _CRT_DOUBLE; + +//typedef int* intptr_t; + +/* +Buffer size required to be passed to _gcvt, fcvt and other fp conversion routines +*/ +#define _CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */ + +/* temporary work-around for compiler without 64-bit support */ +#ifndef _INTEGRAL_MAX_BITS +#define _INTEGRAL_MAX_BITS 64 +#endif /* _INTEGRAL_MAX_BITS */ + +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include + +#define _MBTOWC(x,y,z) _minimal_chartowchar( x, y ) + +#ifndef _WCTOMB_S +#define _WCTOMB_S wctomb_s +#endif /* _WCTOMB_S */ + +#undef _malloc_crt +#define _malloc_crt malloc + +#undef _free_crt +#define _free_crt free + +/* Wrapper for _output_s so that we do not expose FILE in the _output_s signature. + * Always ensure null-termination. Returns the number of written chars, not including the terminating null. + * Returns -1 if something went wrong during the formatting (in _output_s), e.g. mbcs conversions. + * Returns -2 if the string has been truncated. + * _output_s calls _invalid_parameter (and returns -1, possibly) if the format string is malformed. + */ +#ifndef _UNICODE +int __cdecl _soutput_s(char *_Dst, size_t _Size, const char *_Format, va_list _ArgList) +#else /* _UNICODE */ +int __cdecl _swoutput_s(char16_t *_Dst, size_t _Size, const char16_t *_Format, va_list _ArgList) +#endif /* _UNICODE */ +{ + miniFILE stream; + miniFILE *outfile = &stream; + int written = -1; + + /* validation section */ +#ifndef _UNICODE + if(_Size==SIZE_MAX) + { + /* user is attempting to make us unbounded, but we don't fit that much */ + outfile->_cnt = INT_MAX; + } + else + { + _VALIDATE_RETURN(_Size <= INT_MAX, EINVAL, -1); + outfile->_cnt = (int)_Size; + } + outfile->_ptr = outfile->_base = _Dst; +#else /* _UNICODE */ + if(_Size==SIZE_MAX) + { + /* user is attempting to make us unbounded, but we don't fit that much */ + outfile->_cnt = INT_MAX; + } + else if(_Size>(INT_MAX/sizeof(char16_t))) + { + /* we can't represent the amount of output the user asked for */ + _VALIDATE_RETURN( 0 /* FALSE */, EINVAL, -1 ); + } + else + { + outfile->_cnt = (int)(_Size*sizeof(char16_t)); + } + outfile->_ptr = outfile->_base = (char*)_Dst; +#endif /* _UNICODE */ + outfile->_flag = _IOWRT | _IOSTRG; + +#ifndef _UNICODE + written = _output_s(outfile, _Format, _ArgList); +#else /* _UNICODE */ + written = _woutput_s(outfile, _Format, _ArgList); +#endif /* _UNICODE */ + _Dst[_Size - 1] = 0; + if (written < 0) + { + if (outfile->_cnt < 0) + { + /* the buffer was too small; we return -2 to indicate truncation */ + return -2; + } + /* otherwise, something else failed: we reset the string and we return */ + if (_Dst != NULL && _Size > 0) + { + *_Dst = 0; + } + return written; + } + +#ifndef _UNICODE + if ((_putc_nolock('\0', outfile) != EOF)) +#else /* _UNICODE */ + if ((_putc_nolock('\0', outfile) != EOF) && (_putc_nolock('\0', outfile) != EOF)) +#endif /* _UNICODE */ + { + return written; + } + /* the last putc failed, so it means there is not enough space in the buffer */ + return -2; +} + + +#ifndef _CFLTCVT +#define _CFLTCVT _cfltcvt +#endif /* _CFLTCVT */ + +#ifndef _CLDCVT +#define _CLDCVT _cldcvt +#endif /* _CLDCVT */ + +#ifdef _MBCS +#undef _MBCS +#endif /* _MBCS */ +//#include + +/* this macro defines a function which is private and as fast as possible: */ +/* for example, in C 6.0, it might be static _fastcall near. */ +#define LOCAL(x) static x __cdecl + +/* int/long/short/pointer sizes */ + +/* the following should be set depending on the sizes of various types */ +#if __LP64__ + #define LONG_IS_INT 0 + CASSERT(sizeof(long) > sizeof(int)); +#else + #define LONG_IS_INT 1 /* 1 means long is same size as int */ + CASSERT(sizeof(long) == sizeof(int)); +#endif + +#define SHORT_IS_INT 0 /* 1 means short is same size as int */ +#define LONGLONG_IS_INT64 1 /* 1 means long long is same as int64 */ +#if defined (_WIN64) + #define PTR_IS_INT 0 /* 1 means ptr is same size as int */ + CASSERT(sizeof(void *) != sizeof(int)); + #if __LP64__ + #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ + CASSERT(sizeof(void *) == sizeof(long)); + #else + #define PTR_IS_LONG 0 /* 1 means ptr is same size as long */ + CASSERT(sizeof(void *) != sizeof(long)); + #endif + #define PTR_IS_INT64 1 /* 1 means ptr is same size as int64 */ + CASSERT(sizeof(void *) == sizeof(int64_t)); +#else /* defined (_WIN64) */ + #define PTR_IS_INT 1 /* 1 means ptr is same size as int */ + CASSERT(sizeof(void *) == sizeof(int)); + #define PTR_IS_LONG 1 /* 1 means ptr is same size as long */ + CASSERT(sizeof(void *) == sizeof(long)); + #define PTR_IS_INT64 0 /* 1 means ptr is same size as int64 */ +#ifndef __APPLE__ + // todo : investigate + CASSERT(sizeof(void *) != sizeof(int64_t)); +#endif +#endif /* defined (_WIN64) */ + +#ifndef __GNUC_VA_LIST +#if LONGLONG_IS_INT64 + #define get_long_long_arg(x) (long long)get_int64_arg(x) +#endif /* LONGLONG_IS_INT64 */ + +#if LONG_IS_INT + #define get_long_arg(x) (long)get_int_arg(x) +#endif /* LONG_IS_INT */ + +#if PTR_IS_INT + #define get_ptr_arg(x) (void *)(intptr_t)get_int_arg(x) +#elif PTR_IS_LONG + #define get_ptr_arg(x) (void *)(intptr_t)get_long_arg(x) +#elif PTR_IS_INT64 + #define get_ptr_arg(x) (void *)get_int64_arg(x) +#else /* PTR_IS_INT64 */ + #error Size of pointer must be same as size of int or long +#endif /* PTR_IS_INT64 */ + +#endif // __GNUC_VA_LIST + +/* CONSTANTS */ + +/* size of conversion buffer (ANSI-specified minimum is 509) */ + +#define BUFFERSIZE 512 +#define MAXPRECISION BUFFERSIZE + +#if BUFFERSIZE < _CVTBUFSIZE + 6 +/* + * Buffer needs to be big enough for default minimum precision + * when converting floating point needs bigger buffer, and malloc + * fails + */ +#error Conversion buffer too small for max double. +#endif /* BUFFERSIZE < _CVTBUFSIZE + 6 */ + +/* flag definitions */ +#define FL_SIGN 0x00001 /* put plus or minus in front */ +#define FL_SIGNSP 0x00002 /* put space or minus in front */ +#define FL_LEFT 0x00004 /* left justify */ +#define FL_LEADZERO 0x00008 /* pad with leading zeros */ +#define FL_LONG 0x00010 /* long value given */ +#define FL_SHORT 0x00020 /* short value given */ +#define FL_SIGNED 0x00040 /* signed data given */ +#define FL_ALTERNATE 0x00080 /* alternate form requested */ +#define FL_NEGATIVE 0x00100 /* value is negative */ +#define FL_FORCEOCTAL 0x00200 /* force leading '0' for octals */ +#define FL_LONGDOUBLE 0x00400 /* long double value given */ +#define FL_WIDECHAR 0x00800 /* wide characters */ +#define FL_LONGLONG 0x01000 /* long long value given */ +#define FL_I64 0x08000 /* __int64 value given */ + +/* state definitions */ +enum STATE { + ST_NORMAL, /* normal state; outputting literal chars */ + ST_PERCENT, /* just read '%' */ + ST_FLAG, /* just read flag character */ + ST_WIDTH, /* just read width specifier */ + ST_DOT, /* just read '.' */ + ST_PRECIS, /* just read precision specifier */ + ST_SIZE, /* just read size specifier */ + ST_TYPE /* just read type specifier */ +#ifdef FORMAT_VALIDATIONS + ,ST_INVALID /* Invalid format */ +#endif /* FORMAT_VALIDATIONS */ + +}; + +#ifdef FORMAT_VALIDATIONS +#define NUMSTATES (ST_INVALID + 1) +#else /* FORMAT_VALIDATIONS */ +#define NUMSTATES (ST_TYPE + 1) +#endif /* FORMAT_VALIDATIONS */ + +/* character type values */ +enum CHARTYPE { + CH_OTHER, /* character with no special meaning */ + CH_PERCENT, /* '%' */ + CH_DOT, /* '.' */ + CH_STAR, /* '*' */ + CH_ZERO, /* '0' */ + CH_DIGIT, /* '1'..'9' */ + CH_FLAG, /* ' ', '+', '-', '#' */ + CH_SIZE, /* 'h', 'l', 'L', 'N', 'F', 'w' */ + CH_TYPE /* type specifying character */ +}; + +/* static data (read only, since we are re-entrant) */ +//#if defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) +//extern const char __nullstring[]; /* string to print on null ptr */ +//extern const char16_t __wnullstring[]; /* string to print on null ptr */ +//#else /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ +static const char __nullstring[] = "(null)"; /* string to print on null ptr */ +static const char16_t __wnullstring[] = {'(', 'n', 'u', 'l', 'l', ')', '\0'};/* string to print on null ptr */ +//#endif /* defined (_UNICODE) || defined (CPRFLAG) || defined (FORMAT_VALIDATIONS) */ + +/* The state table. This table is actually two tables combined into one. */ +/* The lower nybble of each byte gives the character class of any */ +/* character; while the uper nybble of the byte gives the next state */ +/* to enter. See the macros below the table for details. */ +/* */ +/* The table is generated by maketabc.c -- use this program to make */ +/* changes. */ + +#ifndef FORMAT_VALIDATIONS + +//#if defined (_UNICODE) || defined (CPRFLAG) +//extern const char __lookuptable[]; +//#else /* defined (_UNICODE) || defined (CPRFLAG) */ +extern const char __lookuptable[] = { + /* ' ' */ 0x06, + /* '!' */ 0x00, + /* '"' */ 0x00, + /* '#' */ 0x06, + /* '$' */ 0x00, + /* '%' */ 0x01, + /* '&' */ 0x00, + /* ''' */ 0x00, + /* '(' */ 0x10, + /* ')' */ 0x00, + /* '*' */ 0x03, + /* '+' */ 0x06, + /* ',' */ 0x00, + /* '-' */ 0x06, + /* '.' */ 0x02, + /* '/' */ 0x10, + /* '0' */ 0x04, + /* '1' */ 0x45, + /* '2' */ 0x45, + /* '3' */ 0x45, + /* '4' */ 0x05, + /* '5' */ 0x05, + /* '6' */ 0x05, + /* '7' */ 0x05, + /* '8' */ 0x05, + /* '9' */ 0x35, + /* ':' */ 0x30, + /* ';' */ 0x00, + /* '<' */ 0x50, + /* '=' */ 0x00, + /* '>' */ 0x00, + /* '?' */ 0x00, + /* '@' */ 0x00, + /* 'A' */ 0x20, // Disable %A format + /* 'B' */ 0x20, + /* 'C' */ 0x38, + /* 'D' */ 0x50, + /* 'E' */ 0x58, + /* 'F' */ 0x07, + /* 'G' */ 0x08, + /* 'H' */ 0x00, + /* 'I' */ 0x37, + /* 'J' */ 0x30, + /* 'K' */ 0x30, + /* 'L' */ 0x57, + /* 'M' */ 0x50, + /* 'N' */ 0x07, + /* 'O' */ 0x00, + /* 'P' */ 0x00, + /* 'Q' */ 0x20, + /* 'R' */ 0x20, + /* 'S' */ 0x08, + /* 'T' */ 0x00, + /* 'U' */ 0x00, + /* 'V' */ 0x00, + /* 'W' */ 0x00, + /* 'X' */ 0x08, + /* 'Y' */ 0x60, + /* 'Z' */ 0x68, + /* '[' */ 0x60, + /* '\' */ 0x60, + /* ']' */ 0x60, + /* '^' */ 0x60, + /* '_' */ 0x00, + /* '`' */ 0x00, + /* 'a' */ 0x70, // Disable %a format + /* 'b' */ 0x70, + /* 'c' */ 0x78, + /* 'd' */ 0x78, + /* 'e' */ 0x78, + /* 'f' */ 0x78, + /* 'g' */ 0x08, + /* 'h' */ 0x07, + /* 'i' */ 0x08, + /* 'j' */ 0x00, + /* 'k' */ 0x00, + /* 'l' */ 0x07, + /* 'm' */ 0x00, + /* 'n' */ 0x00, // Disable %n format + /* 'o' */ 0x08, + /* 'p' */ 0x08, + /* 'q' */ 0x00, + /* 'r' */ 0x00, + /* 's' */ 0x08, + /* 't' */ 0x00, + /* 'u' */ 0x08, + /* 'v' */ 0x00, + /* 'w' */ 0x07, + /* 'x' */ 0x08 +}; + +//#endif /* defined (_UNICODE) || defined (CPRFLAG) */ + +#else /* FORMAT_VALIDATIONS */ + +//#if defined (_UNICODE) || defined (CPRFLAG) +//extern const unsigned char __lookuptable_s[]; +//#else /* defined (_UNICODE) || defined (CPRFLAG) */ +static const unsigned char __lookuptable_s[] = { + /* ' ' */ 0x06, + /* '!' */ 0x80, + /* '"' */ 0x80, + /* '#' */ 0x86, + /* '$' */ 0x80, + /* '%' */ 0x81, + /* '&' */ 0x80, + /* ''' */ 0x00, + /* '(' */ 0x00, + /* ')' */ 0x10, + /* '*' */ 0x03, + /* '+' */ 0x86, + /* ',' */ 0x80, + /* '-' */ 0x86, + /* '.' */ 0x82, + /* '/' */ 0x80, + /* '0' */ 0x14, + /* '1' */ 0x05, + /* '2' */ 0x05, + /* '3' */ 0x45, + /* '4' */ 0x45, + /* '5' */ 0x45, + /* '6' */ 0x85, + /* '7' */ 0x85, + /* '8' */ 0x85, + /* '9' */ 0x05, + /* ':' */ 0x00, + /* ';' */ 0x00, + /* '<' */ 0x30, + /* '=' */ 0x30, + /* '>' */ 0x80, + /* '?' */ 0x50, + /* '@' */ 0x80, + /* 'A' */ 0x80, // Disable %A format + /* 'B' */ 0x00, + /* 'C' */ 0x08, + /* 'D' */ 0x00, + /* 'E' */ 0x28, + /* 'F' */ 0x27, + /* 'G' */ 0x38, + /* 'H' */ 0x50, + /* 'I' */ 0x57, + /* 'J' */ 0x80, + /* 'K' */ 0x00, + /* 'L' */ 0x07, + /* 'M' */ 0x00, + /* 'N' */ 0x37, + /* 'O' */ 0x30, + /* 'P' */ 0x30, + /* 'Q' */ 0x50, + /* 'R' */ 0x50, + /* 'S' */ 0x88, + /* 'T' */ 0x00, + /* 'U' */ 0x00, + /* 'V' */ 0x00, + /* 'W' */ 0x20, + /* 'X' */ 0x28, + /* 'Y' */ 0x80, + /* 'Z' */ 0x88, + /* '[' */ 0x80, + /* '\' */ 0x80, + /* ']' */ 0x00, + /* '^' */ 0x00, + /* '_' */ 0x00, + /* '`' */ 0x60, + /* 'a' */ 0x60, // Disable %a format + /* 'b' */ 0x60, + /* 'c' */ 0x68, + /* 'd' */ 0x68, + /* 'e' */ 0x68, + /* 'f' */ 0x08, + /* 'g' */ 0x08, + /* 'h' */ 0x07, + /* 'i' */ 0x78, + /* 'j' */ 0x70, + /* 'k' */ 0x70, + /* 'l' */ 0x77, + /* 'm' */ 0x70, + /* 'n' */ 0x70, + /* 'o' */ 0x08, + /* 'p' */ 0x08, + /* 'q' */ 0x00, + /* 'r' */ 0x00, + /* 's' */ 0x08, + /* 't' */ 0x00, + /* 'u' */ 0x08, + /* 'v' */ 0x00, + /* 'w' */ 0x07, + /* 'x' */ 0x08 +}; +//#endif /* defined (_UNICODE) || defined (CPRFLAG) */ + +#endif /* FORMAT_VALIDATIONS */ + +#define FIND_CHAR_CLASS(lookuptbl, c) \ + ((c) < _T(' ') || (c) > _T('x') ? \ + CH_OTHER \ + : \ + (enum CHARTYPE)(lookuptbl[(c)-_T(' ')] & 0xF)) + +#define FIND_NEXT_STATE(lookuptbl, class, state) \ + (enum STATE)(lookuptbl[(class) * NUMSTATES + (state)] >> 4) + +/* + * Note: CPRFLAG and _UNICODE cases are currently mutually exclusive. + */ + +/* prototypes */ + +#ifdef CPRFLAG + +#define WRITE_CHAR(ch, pnw) write_char(ch, pnw) +#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, pnw) +#define WRITE_STRING(s, len, pnw) write_string(s, len, pnw) + +LOCAL(void) write_char(_TCHAR ch, int *pnumwritten); +LOCAL(void) write_multi_char(_TCHAR ch, int num, int *pnumwritten); +LOCAL(void) write_string(const _TCHAR *string, int len, int *numwritten); + +#else /* CPRFLAG */ + +#define WRITE_CHAR(ch, pnw) write_char(ch, stream, pnw) +#define WRITE_MULTI_CHAR(ch, num, pnw) write_multi_char(ch, num, stream, pnw) +#define WRITE_STRING(s, len, pnw) write_string(s, len, stream, pnw) + +LOCAL(void) write_char(_TCHAR ch, miniFILE *f, int *pnumwritten); +LOCAL(void) write_multi_char(_TCHAR ch, int num, miniFILE *f, int *pnumwritten); +LOCAL(void) write_string(const _TCHAR *string, int len, miniFILE *f, int *numwritten); + +#endif /* CPRFLAG */ + +#ifdef __GNUC_VA_LIST + + #define get_int_arg(list) va_arg(*list, int) + #define get_long_arg(list) va_arg(*list, long) + #define get_long_long_arg(list) va_arg(*list, long long) + #define get_int64_arg(list) va_arg(*list, __int64) + #define get_crtdouble_arg(list) va_arg(*list, _CRT_DOUBLE) + #define get_ptr_arg(list) va_arg(*list, void *) + +#else // __GNUC_VA_LIST + +__inline int __cdecl get_int_arg(va_list *pargptr); + +#if !LONG_IS_INT +__inline long __cdecl get_long_arg(va_list *pargptr); +#endif /* !LONG_IS_INT */ + +#if !LONGLONG_IS_INT64 +__inline long long __cdecl get_long_long_arg(va_list *pargptr); +#endif /* !LONGLONG_IS_INT64 */ + +#if _INTEGRAL_MAX_BITS >= 64 +__inline __int64 __cdecl get_int64_arg(va_list *pargptr); +#endif /* _INTEGRAL_MAX_BITS >= 64 */ + +#endif // __GNUC_VA_LIST + +#ifdef CPRFLAG +LOCAL(int) output(const _TCHAR *, _locale_t , va_list); +_CRTIMP int __cdecl _vtcprintf_l (const _TCHAR *, _locale_t, va_list); +_CRTIMP int __cdecl _vtcprintf_s_l (const _TCHAR *, _locale_t, va_list); +_CRTIMP int __cdecl _vtcprintf_p_l (const _TCHAR *, _locale_t, va_list); + + +/*** +*int _cprintf(format, arglist) - write formatted output directly to console +* +*Purpose: +* Writes formatted data like printf, but uses console I/O functions. +* +*Entry: +* char *format - format string to determine data formats +* arglist - list of POINTERS to where to put data +* +*Exit: +* returns number of characters written +* +*Exceptions: +* +*******************************************************************************/ +#ifndef FORMAT_VALIDATIONS +_CRTIMP int __cdecl _tcprintf_l ( + const _TCHAR * format, + _locale_t plocinfo, + ... + ) +#else /* FORMAT_VALIDATIONS */ +_CRTIMP int __cdecl _tcprintf_s_l ( + const _TCHAR * format, + _locale_t plocinfo, + ... + ) +#endif /* FORMAT_VALIDATIONS */ + +{ + int ret; + va_list arglist; + va_start(arglist, plocinfo); + +#ifndef FORMAT_VALIDATIONS + ret = _vtcprintf_l(format, plocinfo, arglist); +#else /* FORMAT_VALIDATIONS */ + ret = _vtcprintf_s_l(format, plocinfo, arglist); + +#endif /* FORMAT_VALIDATIONS */ + + va_end(arglist); + + return ret; +} + +#ifndef FORMAT_VALIDATIONS +_CRTIMP int __cdecl _tcprintf ( + const _TCHAR * format, + ... + ) +#else /* FORMAT_VALIDATIONS */ +_CRTIMP int __cdecl _tcprintf_s ( + const _TCHAR * format, + ... + ) +#endif /* FORMAT_VALIDATIONS */ + +{ + int ret; + va_list arglist; + + va_start(arglist, format); + +#ifndef FORMAT_VALIDATIONS + ret = _vtcprintf_l(format, NULL, arglist); +#else /* FORMAT_VALIDATIONS */ + ret = _vtcprintf_s_l(format, NULL, arglist); + +#endif /* FORMAT_VALIDATIONS */ + + va_end(arglist); + + return ret; +} + +#endif /* CPRFLAG */ + + +/*** +*int _output(stream, format, argptr), static int output(format, argptr) +* +*Purpose: +* Output performs printf style output onto a stream. It is called by +* printf/fprintf/sprintf/vprintf/vfprintf/vsprintf to so the dirty +* work. In multi-thread situations, _output assumes that the given +* stream is already locked. +* +* Algorithm: +* The format string is parsed by using a finite state automaton +* based on the current state and the current character read from +* the format string. Thus, looping is on a per-character basis, +* not a per conversion specifier basis. Once the format specififying +* character is read, output is performed. +* +*Entry: +* FILE *stream - stream for output +* char *format - printf style format string +* va_list argptr - pointer to list of subsidiary arguments +* +*Exit: +* Returns the number of characters written, or -1 if an output error +* occurs. +*ifdef _UNICODE +* The wide-character flavour returns the number of wide-characters written. +*endif +* +*Exceptions: +* +*******************************************************************************/ +#ifdef CPRFLAG +#ifndef FORMAT_VALIDATIONS +_CRTIMP int __cdecl _vtcprintf ( + const _TCHAR *format, + va_list argptr + ) +{ + return _vtcprintf_l(format, NULL, argptr); +} + +#else /* FORMAT_VALIDATIONS */ +_CRTIMP int __cdecl _vtcprintf_s ( + const _TCHAR *format, + va_list argptr + ) +{ + return _vtcprintf_s_l(format, NULL, argptr); +} + +#endif /* FORMAT_VALIDATIONS */ +#endif /* CPRFLAG */ + +#ifdef CPRFLAG +#ifndef FORMAT_VALIDATIONS +_CRTIMP int __cdecl _vtcprintf_l ( +#else /* FORMAT_VALIDATIONS */ +_CRTIMP int __cdecl _vtcprintf_s_l ( +#endif /* FORMAT_VALIDATIONS */ +#else /* CPRFLAG */ + +#ifdef _UNICODE +#ifndef FORMAT_VALIDATIONS +int __cdecl _woutput ( + miniFILE *stream, +#else /* FORMAT_VALIDATIONS */ +int __cdecl _woutput_s ( + miniFILE *stream, +#endif /* FORMAT_VALIDATIONS */ +#else /* _UNICODE */ +#ifndef FORMAT_VALIDATIONS +int __cdecl _output ( + miniFILE *stream, +#else /* FORMAT_VALIDATIONS */ + int __cdecl _output_s ( + miniFILE *stream, + +#endif /* FORMAT_VALIDATIONS */ +#endif /* _UNICODE */ + +#endif /* CPRFLAG */ + const _TCHAR *format, + va_list argptr + ) +{ + int hexadd=0; /* offset to add to number to get 'a'..'f' */ + TCHAR ch; /* character just read */ + int flags=0; /* flag word -- see #defines above for flag values */ + enum STATE state; /* current state */ + enum CHARTYPE chclass; /* class of current character */ + int radix; /* current conversion radix */ + int charsout; /* characters currently written so far, -1 = IO error */ + int fldwidth = 0; /* selected field width -- 0 means default */ + int precision = 0; /* selected precision -- -1 means default */ + TCHAR prefix[2]; /* numeric prefix -- up to two characters */ + int prefixlen=0; /* length of prefix -- 0 means no prefix */ + int capexp = 0; /* non-zero = 'E' exponent signifient, zero = 'e' */ + int no_output=0; /* non-zero = prodcue no output for this specifier */ + union { + const char *sz; /* pointer text to be printed, not zero terminated */ + const char16_t *wz; + } text; + text.sz = NULL; + int textlen; /* length of the text in bytes/wchars to be printed. + textlen is in multibyte or wide chars if _UNICODE */ + union { + char sz[BUFFERSIZE]; +#ifdef _UNICODE + char16_t wz[BUFFERSIZE]; +#endif /* _UNICODE */ + } buffer; + char16_t wchar; /* temp char16_t */ + int buffersize; /* size of text.sz (used only for the call to _cfltcvt) */ + int bufferiswide=0; /* non-zero = buffer contains wide chars already */ + +#ifndef CPRFLAG + _VALIDATE_RETURN( (stream != NULL), EINVAL, -1); +#endif /* CPRFLAG */ + _VALIDATE_RETURN( (format != NULL), EINVAL, -1); + + charsout = 0; /* no characters written yet */ + textlen = 0; /* no text yet */ + state = ST_NORMAL; /* starting state */ + buffersize = 0; + + /* main loop -- loop while format character exist and no I/O errors */ + while ((ch = *format++) != _T('\0') && charsout >= 0) { +#ifndef FORMAT_VALIDATIONS + chclass = FIND_CHAR_CLASS(__lookuptable, ch); /* find character class */ + state = FIND_NEXT_STATE(__lookuptable, chclass, state); /* find next state */ +#else /* FORMAT_VALIDATIONS */ + chclass = FIND_CHAR_CLASS(__lookuptable_s, ch); /* find character class */ + state = FIND_NEXT_STATE(__lookuptable_s, chclass, state); /* find next state */ + + _VALIDATE_RETURN((state != ST_INVALID), EINVAL, -1); + +#endif /* FORMAT_VALIDATIONS */ + + /* execute code for each state */ + switch (state) { + + case ST_NORMAL: + + NORMAL_STATE: + + /* normal state -- just write character */ +#ifdef _UNICODE + bufferiswide = 1; +#else /* _UNICODE */ + bufferiswide = 0; +#endif /* _UNICODE */ + WRITE_CHAR(ch, &charsout); + break; + + case ST_PERCENT: + /* set default value of conversion parameters */ + prefixlen = fldwidth = no_output = capexp = 0; + flags = 0; + precision = -1; + bufferiswide = 0; /* default */ + break; + + case ST_FLAG: + /* set flag based on which flag character */ + switch (ch) { + case _T('-'): + flags |= FL_LEFT; /* '-' => left justify */ + break; + case _T('+'): + flags |= FL_SIGN; /* '+' => force sign indicator */ + break; + case _T(' '): + flags |= FL_SIGNSP; /* ' ' => force sign or space */ + break; + case _T('#'): + flags |= FL_ALTERNATE; /* '#' => alternate form */ + break; + case _T('0'): + flags |= FL_LEADZERO; /* '0' => pad with leading zeros */ + break; + } + break; + + case ST_WIDTH: + /* update width value */ + if (ch == _T('*')) { + /* get width from arg list */ + fldwidth = get_int_arg(&argptr); + if (fldwidth < 0) { + /* ANSI says neg fld width means '-' flag and pos width */ + flags |= FL_LEFT; + fldwidth = -fldwidth; + } + } + else { + /* add digit to current field width */ + fldwidth = fldwidth * 10 + (ch - _T('0')); + } + break; + + case ST_DOT: + /* zero the precision, since dot with no number means 0 + not default, according to ANSI */ + precision = 0; + break; + + case ST_PRECIS: + /* update precison value */ + if (ch == _T('*')) { + /* get precision from arg list */ + precision = get_int_arg(&argptr); + if (precision < 0) + precision = -1; /* neg precision means default */ + } + else { + /* add digit to current precision */ + precision = precision * 10 + (ch - _T('0')); + } + break; + + case ST_SIZE: + /* just read a size specifier, set the flags based on it */ + switch (ch) { + case _T('l'): + /* + * In order to handle the ll case, we depart from the + * simple deterministic state machine. + */ + if (*format == _T('l')) + { + ++format; + flags |= FL_LONGLONG; /* 'll' => long long */ + } + else + { + flags |= FL_LONG; /* 'l' => long int or char16_t */ + } + break; + + case _T('I'): + /* + * In order to handle the I, I32, and I64 size modifiers, we + * depart from the simple deterministic state machine. The + * code below scans for characters following the 'I', + * and defaults to 64 bit on WIN64 and 32 bit on WIN32 + */ +#if PTR_IS_INT64 + flags |= FL_I64; /* 'I' => __int64 on WIN64 systems */ +#endif /* PTR_IS_INT64 */ + if ( (*format == _T('6')) && (*(format + 1) == _T('4')) ) + { + format += 2; + flags |= FL_I64; /* I64 => __int64 */ + } + else if ( (*format == _T('3')) && (*(format + 1) == _T('2')) ) + { + format += 2; + flags &= ~FL_I64; /* I32 => __int32 */ + } + else if ( (*format == _T('d')) || + (*format == _T('i')) || + (*format == _T('o')) || + (*format == _T('u')) || + (*format == _T('x')) || + (*format == _T('X')) ) + { + /* + * Nothing further needed. %Id (et al) is + * handled just like %d, except that it defaults to 64 bits + * on WIN64. Fall through to the next iteration. + */ + } + else { + state = ST_NORMAL; + goto NORMAL_STATE; + } + break; + + case _T('h'): + flags |= FL_SHORT; /* 'h' => short int or char */ + break; + + case _T('w'): + flags |= FL_WIDECHAR; /* 'w' => wide character */ + break; + + } + break; + + case ST_TYPE: + /* we have finally read the actual type character, so we */ + /* now format and "print" the output. We use a big switch */ + /* statement that sets 'text' to point to the text that should */ + /* be printed, and 'textlen' to the length of this text. */ + /* Common code later on takes care of justifying it and */ + /* other miscellaneous chores. Note that cases share code, */ + /* in particular, all integer formatting is done in one place. */ + /* Look at those funky goto statements! */ + + switch (ch) { + + case _T('C'): /* ISO wide character */ + if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) +#ifdef _UNICODE + flags |= FL_SHORT; +#else /* _UNICODE */ + flags |= FL_WIDECHAR; /* ISO std. */ +#endif /* _UNICODE */ + /* fall into 'c' case */ + + case _T('c'): { + /* print a single character specified by int argument */ +#ifdef _UNICODE + bufferiswide = 1; + wchar = (char16_t) get_int_arg(&argptr); + if (flags & FL_SHORT) { + /* format multibyte character */ + /* this is an extension of ANSI */ + char tempchar[2]; + { + tempchar[0] = (char)(wchar & 0x00ff); + tempchar[1] = '\0'; + } + + if (_MBTOWC(buffer.wz,tempchar, MB_CUR_MAX) < 0) + { + /* ignore if conversion was unsuccessful */ + no_output = 1; + } + } else { + buffer.wz[0] = wchar; + } + text.wz = buffer.wz; + textlen = 1; /* print just a single character */ +#else /* _UNICODE */ + if (flags & (FL_LONG|FL_WIDECHAR)) { + wchar = (char16_t) get_int_arg(&argptr); + no_output = 1; + } else { + /* format multibyte character */ + /* this is an extension of ANSI */ + unsigned short temp; + wchar = (char16_t)get_int_arg(&argptr); + temp = (unsigned short)wchar; + { + buffer.sz[0] = (char) temp; + textlen = 1; + } + } + text.sz = buffer.sz; +#endif /* _UNICODE */ + } + break; + + case _T('Z'): { + /* print a Counted String */ + struct _count_string { + short Length; + short MaximumLength; + char *Buffer; + } *pstr; + + pstr = (struct _count_string *)get_ptr_arg(&argptr); + if (pstr == NULL || pstr->Buffer == NULL) { + /* null ptr passed, use special string */ + text.sz = __nullstring; + textlen = (int)strlen(text.sz); + } else { + if (flags & FL_WIDECHAR) { + text.wz = (char16_t *)pstr->Buffer; + textlen = pstr->Length / (int)sizeof(char16_t); + bufferiswide = 1; + } else { + bufferiswide = 0; + text.sz = pstr->Buffer; + textlen = pstr->Length; + } + } + } + break; + + case _T('S'): /* ISO wide character string */ +#ifndef _UNICODE + if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) + flags |= FL_WIDECHAR; +#else /* _UNICODE */ + if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR))) + flags |= FL_SHORT; +#endif /* _UNICODE */ + + case _T('s'): { + /* print a string -- */ + /* ANSI rules on how much of string to print: */ + /* all if precision is default, */ + /* min(precision, length) if precision given. */ + /* prints '(null)' if a null string is passed */ + + int i; + const char *p; /* temps */ + const char16_t *pwch; + + /* At this point it is tempting to use strlen(), but */ + /* if a precision is specified, we're not allowed to */ + /* scan past there, because there might be no null */ + /* at all. Thus, we must do our own scan. */ + + i = (precision == -1) ? INT_MAX : precision; + text.sz = (char *)get_ptr_arg(&argptr); + + /* scan for null upto i characters */ +#ifdef _UNICODE + if (flags & FL_SHORT) { + if (text.sz == NULL) /* NULL passed, use special string */ + text.sz = __nullstring; + p = text.sz; + for (textlen=0; textlen MAXPRECISION) + precision = MAXPRECISION; + + if (precision > BUFFERSIZE - _CVTBUFSIZE) { + /* cap precision further */ + precision = BUFFERSIZE - _CVTBUFSIZE; + } + + /* for safecrt, we pass along the FL_ALTERNATE flag to _safecrt_cfltcvt */ + if (flags & FL_ALTERNATE) + { + capexp |= FL_ALTERNATE; + } + + _CRT_DOUBLE tmp; + tmp=va_arg(argptr, _CRT_DOUBLE); + /* Note: assumes ch is in ASCII range */ + /* In safecrt, we provide a special version of _cfltcvt which internally calls printf (see safecrt_output_s.c) */ + _CFLTCVT(&tmp, buffer.sz, (size_t)buffersize, (char)ch, precision, capexp); + + /* check if result was negative, save '-' for later */ + /* and point to positive part (this is for '0' padding) */ + if (*text.sz == '-') { + flags |= FL_NEGATIVE; + ++text.sz; + } + + textlen = (int)strlen(text.sz); /* compute length of text */ + } + break; + + case _T('d'): + case _T('i'): + /* signed decimal output */ + flags |= FL_SIGNED; + radix = 10; + goto COMMON_INT; + + case _T('u'): + radix = 10; + goto COMMON_INT; + + case _T('p'): + /* write a pointer -- this is like an integer or long */ + /* except we force precision to pad with zeros and */ + /* output in big hex. */ + + precision = 2 * sizeof(void *); /* number of hex digits needed */ +#if PTR_IS_INT64 + flags |= FL_I64; /* assume we're converting an int64 */ +#elif !PTR_IS_INT + flags |= FL_LONG; /* assume we're converting a long */ +#endif /* !PTR_IS_INT */ + /* DROP THROUGH to hex formatting */ + + case _T('X'): + /* unsigned upper hex output */ + hexadd = _T('A') - _T('9') - 1; /* set hexadd for uppercase hex */ + goto COMMON_HEX; + + case _T('x'): + /* unsigned lower hex output */ + hexadd = _T('a') - _T('9') - 1; /* set hexadd for lowercase hex */ + /* DROP THROUGH TO COMMON_HEX */ + + COMMON_HEX: + radix = 16; + if (flags & FL_ALTERNATE) { + /* alternate form means '0x' prefix */ + prefix[0] = _T('0'); + prefix[1] = (TCHAR)(_T('x') - _T('a') + _T('9') + 1 + hexadd); /* 'x' or 'X' */ + prefixlen = 2; + } + goto COMMON_INT; + + case _T('o'): + /* unsigned octal output */ + radix = 8; + if (flags & FL_ALTERNATE) { + /* alternate form means force a leading 0 */ + flags |= FL_FORCEOCTAL; + } + /* DROP THROUGH to COMMON_INT */ + + COMMON_INT: { + /* This is the general integer formatting routine. */ + /* Basically, we get an argument, make it positive */ + /* if necessary, and convert it according to the */ + /* correct radix, setting text and textlen */ + /* appropriately. */ + +#if _INTEGRAL_MAX_BITS >= 64 + __uint64_t number; /* number to convert */ + int digit; /* ascii value of digit */ + __int64 l; /* temp long value */ +#else /* _INTEGRAL_MAX_BITS >= 64 */ + unsigned long number; /* number to convert */ + int digit; /* ascii value of digit */ + long l; /* temp long value */ +#endif /* _INTEGRAL_MAX_BITS >= 64 */ + + /* 1. read argument into l, sign extend as needed */ +#if _INTEGRAL_MAX_BITS >= 64 + if (flags & FL_I64) + l = get_int64_arg(&argptr); + else +#endif /* _INTEGRAL_MAX_BITS >= 64 */ + + if (flags & FL_LONGLONG) + l = get_long_long_arg(&argptr); + + else + +#if !LONG_IS_INT + if (flags & FL_LONG) + l = get_long_arg(&argptr); + else +#endif /* !LONG_IS_INT */ + +#if !SHORT_IS_INT + if (flags & FL_SHORT) { + if (flags & FL_SIGNED) + l = (short) get_int_arg(&argptr); /* sign extend */ + else + l = (unsigned short) get_int_arg(&argptr); /* zero-extend*/ + + } else +#endif /* !SHORT_IS_INT */ + { + if (flags & FL_SIGNED) + l = get_int_arg(&argptr); /* sign extend */ + else + l = (unsigned int) get_int_arg(&argptr); /* zero-extend*/ + } + + /* 2. check for negative; copy into number */ + if ( (flags & FL_SIGNED) && l < 0) { + number = (__uint64_t)(-l); + flags |= FL_NEGATIVE; /* remember negative sign */ + } else { + number = (__uint64_t)(l); + } + +#if _INTEGRAL_MAX_BITS >= 64 + if ( (flags & FL_I64) == 0 && (flags & FL_LONGLONG) == 0 ) { + /* + * Unless printing a full 64-bit value, insure values + * here are not in cananical longword format to prevent + * the sign extended upper 32-bits from being printed. + */ + number &= 0xffffffff; + } +#endif /* _INTEGRAL_MAX_BITS >= 64 */ + + /* 3. check precision value for default; non-default */ + /* turns off 0 flag, according to ANSI. */ + if (precision < 0) + precision = 1; /* default precision */ + else { + flags &= ~FL_LEADZERO; + if (precision > MAXPRECISION) + precision = MAXPRECISION; + } + + /* 4. Check if data is 0; if so, turn off hex prefix */ + if (number == 0) + prefixlen = 0; + + /* 5. Convert data to ASCII -- note if precision is zero */ + /* and number is zero, we get no digits at all. */ + + char *sz; + sz = &buffer.sz[BUFFERSIZE-1]; /* last digit at end of buffer */ + + while (precision-- > 0 || number != 0) { + digit = (int)(number % ((__uint64_t)(radix))) + '0'; + number /= ((__uint64_t)(radix)); /* reduce number */ + if (digit > '9') { + /* a hex digit, make it a letter */ + digit += hexadd; + } + *sz-- = (char)digit; /* store the digit */ + } + + textlen = (int)((char *)&buffer.sz[BUFFERSIZE-1] - sz); /* compute length of number */ + ++sz; /* text points to first digit now */ + + + /* 6. Force a leading zero if FORCEOCTAL flag set */ + if ((flags & FL_FORCEOCTAL) && (textlen == 0 || sz[0] != '0')) { + *--sz = '0'; + ++textlen; /* add a zero */ + } + + text.sz = sz; + } + break; + } + + + /* At this point, we have done the specific conversion, and */ + /* 'text' points to text to print; 'textlen' is length. Now we */ + /* justify it, put on prefixes, leading zeros, and then */ + /* print it. */ + + if (!no_output) { + int padding; /* amount of padding, negative means zero */ + + if (flags & FL_SIGNED) { + if (flags & FL_NEGATIVE) { + /* prefix is a '-' */ + prefix[0] = _T('-'); + prefixlen = 1; + } + else if (flags & FL_SIGN) { + /* prefix is '+' */ + prefix[0] = _T('+'); + prefixlen = 1; + } + else if (flags & FL_SIGNSP) { + /* prefix is ' ' */ + prefix[0] = _T(' '); + prefixlen = 1; + } + } + + /* calculate amount of padding -- might be negative, */ + /* but this will just mean zero */ + padding = fldwidth - textlen - prefixlen; + + /* put out the padding, prefix, and text, in the correct order */ + + if (!(flags & (FL_LEFT | FL_LEADZERO))) { + /* pad on left with blanks */ + WRITE_MULTI_CHAR(_T(' '), padding, &charsout); + } + + /* write prefix */ + WRITE_STRING(prefix, prefixlen, &charsout); + + if ((flags & FL_LEADZERO) && !(flags & FL_LEFT)) { + /* write leading zeros */ + WRITE_MULTI_CHAR(_T('0'), padding, &charsout); + } + + /* write text */ +#ifndef _UNICODE + if (bufferiswide && (textlen > 0)) { + charsout = -1; + } else { + WRITE_STRING(text.sz, textlen, &charsout); + } +#else /* _UNICODE */ + if (!bufferiswide && textlen > 0) { + const char *p; + int retval = 0; + int count; + + p = text.sz; + count = textlen; + while (count-- > 0) { + retval = _MBTOWC(&wchar, p, MB_CUR_MAX); + if (retval <= 0) { + charsout = -1; + break; + } + WRITE_CHAR(wchar, &charsout); + p += retval; + } + } else { + WRITE_STRING(text.wz, textlen, &charsout); + } +#endif /* _UNICODE */ + + if (charsout >= 0 && (flags & FL_LEFT)) { + /* pad on right with blanks */ + WRITE_MULTI_CHAR(_T(' '), padding, &charsout); + } + + /* we're done! */ + } + break; + case ST_INVALID: + _VALIDATE_RETURN(0 /* FALSE */, EINVAL, -1); + break; + } + } + +#ifdef FORMAT_VALIDATIONS + /* The format string shouldn't be incomplete - i.e. when we are finished + with the format string, the last thing we should have encountered + should have been a regular char to be output or a type specifier. Else + the format string was incomplete */ + _VALIDATE_RETURN(((state == ST_NORMAL) || (state == ST_TYPE)), EINVAL, -1); +#endif /* FORMAT_VALIDATIONS */ + + return charsout; /* return value = number of characters written */ +} + +/* + * Future Optimizations for swprintf: + * - Don't free the memory used for converting the buffer to wide chars. + * Use realloc if the memory is not sufficient. Free it at the end. + */ + +/*** +*void write_char(char ch, int *pnumwritten) +*ifdef _UNICODE +*void write_char(char16_t ch, FILE *f, int *pnumwritten) +*endif +*void write_char(char ch, FILE *f, int *pnumwritten) +* +*Purpose: +* Writes a single character to the given file/console. If no error occurs, +* then *pnumwritten is incremented; otherwise, *pnumwritten is set +* to -1. +* +*Entry: +* _TCHAR ch - character to write +* FILE *f - file to write to +* int *pnumwritten - pointer to integer to update with total chars written +* +*Exit: +* No return value. +* +*Exceptions: +* +*******************************************************************************/ + +#ifdef CPRFLAG + +LOCAL(void) write_char ( + _TCHAR ch, + int *pnumwritten + ) +{ +#ifdef _UNICODE + if (_putwch_nolock(ch) == WEOF) +#else /* _UNICODE */ + if (_putch_nolock(ch) == EOF) +#endif /* _UNICODE */ + *pnumwritten = -1; + else + ++(*pnumwritten); +} + +#else /* CPRFLAG */ + +LOCAL(void) write_char ( + _TCHAR ch, + miniFILE *f, + int *pnumwritten + ) +{ + if ( (f->_flag & _IOSTRG) && f->_base == NULL) + { + ++(*pnumwritten); + return; + } +#ifdef _UNICODE + if (_putwc_nolock(ch, f) == WEOF) +#else /* _UNICODE */ + if (_putc_nolock(ch, f) == EOF) +#endif /* _UNICODE */ + *pnumwritten = -1; + else + ++(*pnumwritten); +} + +#endif /* CPRFLAG */ + +/*** +*void write_multi_char(char ch, int num, int *pnumwritten) +*ifdef _UNICODE +*void write_multi_char(char16_t ch, int num, FILE *f, int *pnumwritten) +*endif +*void write_multi_char(char ch, int num, FILE *f, int *pnumwritten) +* +*Purpose: +* Writes num copies of a character to the given file/console. If no error occurs, +* then *pnumwritten is incremented by num; otherwise, *pnumwritten is set +* to -1. If num is negative, it is treated as zero. +* +*Entry: +* _TCHAR ch - character to write +* int num - number of times to write the characters +* FILE *f - file to write to +* int *pnumwritten - pointer to integer to update with total chars written +* +*Exit: +* No return value. +* +*Exceptions: +* +*******************************************************************************/ + +#ifdef CPRFLAG +LOCAL(void) write_multi_char ( + _TCHAR ch, + int num, + int *pnumwritten + ) +{ + while (num-- > 0) { + write_char(ch, pnumwritten); + if (*pnumwritten == -1) + break; + } +} + +#else /* CPRFLAG */ + +LOCAL(void) write_multi_char ( + _TCHAR ch, + int num, + miniFILE *f, + int *pnumwritten + ) +{ + while (num-- > 0) { + write_char(ch, f, pnumwritten); + if (*pnumwritten == -1) + break; + } +} + +#endif /* CPRFLAG */ + +/*** +*void write_string(const char *string, int len, int *pnumwritten) +*void write_string(const char *string, int len, FILE *f, int *pnumwritten) +*ifdef _UNICODE +*void write_string(const char16_t *string, int len, FILE *f, int *pnumwritten) +*endif +* +*Purpose: +* Writes a string of the given length to the given file. If no error occurs, +* then *pnumwritten is incremented by len; otherwise, *pnumwritten is set +* to -1. If len is negative, it is treated as zero. +* +*Entry: +* _TCHAR *string - string to write (NOT null-terminated) +* int len - length of string +* FILE *f - file to write to +* int *pnumwritten - pointer to integer to update with total chars written +* +*Exit: +* No return value. +* +*Exceptions: +* +*******************************************************************************/ + +#ifdef CPRFLAG + +LOCAL(void) write_string ( + const _TCHAR *string, + int len, + int *pnumwritten + ) +{ + while (len-- > 0) { + write_char(*string++, pnumwritten); + if (*pnumwritten == -1) + { + if (errno == EILSEQ) + write_char(_T('?'), pnumwritten); + else + break; + } + } +} + +#else /* CPRFLAG */ + +LOCAL(void) write_string ( + const _TCHAR *string, + int len, + miniFILE *f, + int *pnumwritten + ) +{ + if ( (f->_flag & _IOSTRG) && f->_base == NULL) + { + (*pnumwritten) += len; + return; + } + while (len-- > 0) { + write_char(*string++, f, pnumwritten); + if (*pnumwritten == -1) + { + if (errno == EILSEQ) + write_char(_T('?'), f, pnumwritten); + else + break; + } + } +} +#endif /* CPRFLAG */ + +// For GCC 64 bit, we can't cast to va_list *, so we need to make these functions defines. +#ifndef __GNUC_VA_LIST + +/*** +*int get_int_arg(va_list *pargptr) +* +*Purpose: +* Gets an int argument off the given argument list and updates *pargptr. +* +*Entry: +* va_list *pargptr - pointer to argument list; updated by function +* +*Exit: +* Returns the integer argument read from the argument list. +* +*Exceptions: +* +*******************************************************************************/ + +__inline int __cdecl get_int_arg ( + va_list *pargptr + ) +{ + return va_arg(*pargptr, int); +} + +/*** +*long get_long_arg(va_list *pargptr) +* +*Purpose: +* Gets an long argument off the given argument list and updates *pargptr. +* +*Entry: +* va_list *pargptr - pointer to argument list; updated by function +* +*Exit: +* Returns the long argument read from the argument list. +* +*Exceptions: +* +*******************************************************************************/ + +#if !LONG_IS_INT +__inline long __cdecl get_long_arg ( + va_list *pargptr + ) +{ + return va_arg(*pargptr, long); +} +#endif /* !LONG_IS_INT */ + +#if !LONGLONG_IS_INT64 +__inline long long __cdecl get_long_long_arg ( + va_list *pargptr + ) +{ + return va_arg(*pargptr, long long); +} +#endif /* !LONGLONG_IS_INT64 */ + +#if _INTEGRAL_MAX_BITS >= 64 +__inline __int64 __cdecl get_int64_arg ( + va_list *pargptr + ) +{ + return va_arg(*pargptr, __int64); +} +#endif /* _INTEGRAL_MAX_BITS >= 64 */ + +#ifndef _UNICODE + +#endif /* _UNICODE */ + +#endif // __GNUC_VA_LIST diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_output_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_output_s.c new file mode 100644 index 0000000000..68aecf6a24 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_output_s.c @@ -0,0 +1,47 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*safecrt_output_s.c - implementation of the _output family for safercrt.lib +* + +* +*Purpose: +* This file contains the implementation of the _output family for safercrt.lib. +* +*Revision History: +* 07-08-04 SJ Stub module created. +* 07-13-04 AC Added support for floating-point types. +* 07-29-04 AC Added macros for a safecrt version of mctowc and wctomb, which target ntdll.dll or msvcrt.dll +* based on the _NTSUBSET_ #define +* 09-24-04 MSL Prefix disallow NULL deref +* +****/ + +#define _SAFECRT_IMPL + +#define __STDC_LIMIT_MACROS +#ifndef _LIBSAFECRT_SGX_CONFIG +#include "pal/palinternal.h" +#endif +#include +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define FORMAT_VALIDATIONS +#define _CFLTCVT _safecrt_cfltcvt + +#define _TCHAR CRT_TCHAR +#define TCHAR CRTTCHAR + +typedef char _TCHAR; +typedef char TCHAR; +#define _T(x) x + +#include "output.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_woutput_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_woutput_s.c new file mode 100644 index 0000000000..89f986d6fe --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/safecrt_woutput_s.c @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*safecrt_woutput_s.c - implementation of the _woutput family for safercrt.lib +* + +* +*Purpose: +* This file contains the implementation of the _woutput family for safercrt.lib. +* +*Revision History: +* 07-08-04 SJ Stub module created. +* 07-13-04 AC Added support for floating-point types. +* 07-29-04 AC Added macros for a safecrt version of mctowc and wctomb, which target ntdll.dll or msvcrt.dll +* based on the _NTSUBSET_ #define +* +****/ + +#define _SAFECRT_IMPL + +#define __STDC_LIMIT_MACROS +#ifndef _LIBSAFECRT_SGX_CONFIG +#include "pal/palinternal.h" +#endif +#include +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#ifndef _UNICODE /* CRT flag */ +#define _UNICODE 1 +#endif + +#ifndef UNICODE /* NT flag */ +#define UNICODE 1 +#endif + +#define FORMAT_VALIDATIONS +#if defined(_NTSUBSET_) +#define _MBTOWC _safecrt_mbtowc +#endif +#define _WCTOMB_S _safecrt_wctomb_s +#define _CFLTCVT _safecrt_cfltcvt +#define _CLDCVT _safecrt_cldcvt + +#define _TCHAR CRT_TCHAR +#define TCHAR CRTTCHAR + +typedef char16_t _TCHAR; +typedef char16_t TCHAR; +#define _T(x) L##x + +#include "output.inl" + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/sprintf.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/sprintf.c new file mode 100644 index 0000000000..8f6c67e35f --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/sprintf.c @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*sprintf.c - print formatted to string +* + +* +*Purpose: +* defines sprintf() and _snprintf() - print formatted data to string +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" +#include + +/*** +*ifndef _COUNT_ +*int sprintf(string, format, ...) - print formatted data to string +*else +*int _snprintf(string, cnt, format, ...) - print formatted data to string +*endif +* +*Purpose: +* Prints formatted data to the using the format string to +* format data and getting as many arguments as called for +* Sets up a FILE so file i/o operations can be used, make +* string look like a huge buffer to it, but _flsbuf will +* refuse to flush it if it fills up. Appends '\0' to make +* it a true string. _output does the real work here +* +* Allocate the 'fake' _iob[] entry statically instead of on +* the stack so that other routines can assume that _iob[] +* entries are in are in DGROUP and, thus, are near. +* +*ifdef _COUNT_ +* The _snprintf() flavor takes a count argument that is +* the max number of bytes that should be written to the +* user's buffer. +*endif +* +* Multi-thread: (1) Since there is no stream, this routine must +* never try to get the stream lock (i.e., there is no stream +* lock either). (2) Also, since there is only one statically +* allocated 'fake' iob, we must lock/unlock to prevent collisions. +* +*Entry: +* char *string - pointer to place to put output +*ifdef _COUNT_ +* size_t count - max number of bytes to put in buffer +*endif +* char *format - format string to control data format/number +* of arguments followed by list of arguments, number and type +* controlled by format string +* +*Exit: +* returns number of characters printed +* +*Exceptions: +* +*******************************************************************************/ + +int sprintf_s ( + char *string, + size_t sizeInBytes, + const char *format, + ... + ) +{ + int ret; + va_list arglist; + va_start(arglist, format); + ret = _vsprintf_s(string, sizeInBytes, format, arglist); + va_end(arglist); + return ret; +} + +int _snprintf_s ( + char *string, + size_t sizeInBytes, + size_t count, + const char *format, + ... + ) +{ + int ret; + va_list arglist; + va_start(arglist, format); + ret = _vsnprintf_s(string, sizeInBytes, count, format, arglist); + va_end(arglist); + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcat_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcat_s.c new file mode 100644 index 0000000000..911a09c32c --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcat_s.c @@ -0,0 +1,34 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strcat_s.c - contains strcat_s() +* + +* +*Purpose: +* strcat_s() concatenates (appends) a copy of the source string to the +* end of the destination string. +* +*******************************************************************************/ + +#define _SECURECRT_FILL_BUFFER 1 +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME strcat_s +#define _CHAR char +#define _DEST _Dst +#define _SIZE _SizeInBytes +#define _SRC _Src + +#include "tcscat_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcpy_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcpy_s.c new file mode 100644 index 0000000000..8497f9de7f --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strcpy_s.c @@ -0,0 +1,30 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strcpy_s.c - contains strcpy_s() +* + +* +*Purpose: +* strcpy_s() copies one string onto another. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME strcpy_s +#define _CHAR char +#define _DEST _Dst +#define _SIZE _SizeInBytes +#define _SRC _Src + +#include "tcscpy_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncat_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncat_s.c new file mode 100644 index 0000000000..7b44eef83c --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncat_s.c @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strncat_s.c - append n chars of string to new string +* + +* +*Purpose: +* defines strncat_s() - appends n characters of string onto +* end of other string +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME strncat_s +#define _CHAR char +#define _DEST _Dst +#define _SIZE _SizeInBytes +#define _SRC _Src +#define _COUNT _Count + +#include "tcsncat_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncpy_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncpy_s.c new file mode 100644 index 0000000000..6c8d09332f --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strncpy_s.c @@ -0,0 +1,31 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strncpy_s.c - copy at most n characters of string +* + +* +*Purpose: +* defines strncpy_s() - copy at most n characters of string +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME strncpy_s +#define _CHAR char +#define _DEST _Dst +#define _SIZE _SizeInBytes +#define _SRC _Src +#define _COUNT _Count + +#include "tcsncpy_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strtok_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strtok_s.c new file mode 100644 index 0000000000..2622d0c1b4 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/strtok_s.c @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strtok_s.c - tokenize a string with given delimiters +* + +* +*Purpose: +* defines strtok_s() - breaks string into series of token +* via repeated calls. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME strtok_s +#define _CHAR char + +#include "tcstok_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/swprintf_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/swprintf_s.c new file mode 100644 index 0000000000..d90a2420d1 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/swprintf_s.c @@ -0,0 +1,121 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*swprintf.c - print formatted to string +* +*Purpose: +* defines _swprintf(), _swprintf_c and _snwprintf() - print formatted data +* to string +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" +#include +/*** +*ifndef _COUNT_ +*int _swprintf(string, format, ...) - print formatted data to string +*else +*ifndef _SWPRINTFS_ERROR_RETURN_FIX +*int _snwprintf(string, cnt, format, ...) - print formatted data to string +*else +*int _swprintf_c(string, cnt, format, ...) - print formatted data to string +*endif +*endif +* +*Purpose: +* Prints formatted data to the using the format string to +* format data and getting as many arguments as called for +* Sets up a FILE so file i/o operations can be used, make +* string look like a huge buffer to it, but _flsbuf will +* refuse to flush it if it fills up. Appends '\0' to make +* it a true string. _output does the real work here +* +* Allocate the 'fake' _iob[] entry statically instead of on +* the stack so that other routines can assume that _iob[] +* entries are in are in DGROUP and, thus, are near. +* +* We alias swprintf to _swprintf +* +*ifdef _COUNT_ +*ifndef _SWPRINTFS_ERROR_RETURN_FIX +* The _snwprintf() flavor takes a count argument that is +* the max number of wide characters that should be written to the +* user's buffer. +* We don't expose this function directly in the headers. +*else +* The _swprintf_c() flavor does the same thing as the _snwprintf +* above, but, it also fixes a issue in the return value in the case +* when there isn't enough space to write the null terminator +* We don't fix this issue in _snwprintf because of backward +* compatibility. In new code, however, _snwprintf is #defined to +* _swprintf_c so users get the fix. +* +*endif +* +* Multi-thread: (1) Since there is no stream, this routine must +* never try to get the stream lock (i.e., there is no stream +* lock either). (2) Also, since there is only one statically +* allocated 'fake' iob, we must lock/unlock to prevent collisions. +* +*Entry: +* char16_t *string - pointer to place to put output +*ifdef _COUNT_ +* size_t count - max number of wide characters to put in buffer +*endif +* char16_t *format - format string to control data format/number +* of arguments followed by list of arguments, number and type +* controlled by format string +* +*Exit: +* returns number of wide characters printed +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl swprintf_s ( + char16_t *string, + size_t sizeInWords, + const char16_t *format, + ... + ) +{ + int ret; + va_list arglist; + + va_start(arglist, format); + + ret = _vswprintf_s(string, sizeInWords, format, arglist); + + va_end(arglist); + + return ret; +} + +int __cdecl _snwprintf_s ( + char16_t *string, + size_t sizeInWords, + size_t count, + const char16_t *format, + ... + ) +{ + int ret; + va_list arglist; + + va_start(arglist, format); + + ret = _vsnwprintf_s(string, sizeInWords, count, format, arglist); + + va_end(arglist); + + return ret; +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscat_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscat_s.inl new file mode 100644 index 0000000000..00bd32c4f8 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscat_s.inl @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*tcscat_s.inl - general implementation of _tcscpy_s +* + +* +*Purpose: +* This file contains the general algorithm for strcat_s and its variants. +* +****/ + +_FUNC_PROLOGUE +errno_t __cdecl _FUNC_NAME(_CHAR *_DEST, size_t _SIZE, const _CHAR *_SRC) +{ + _CHAR *p; + size_t available; + + /* validation section */ + _VALIDATE_STRING(_DEST, _SIZE); + _VALIDATE_POINTER_RESET_STRING(_SRC, _DEST, _SIZE); + + p = _DEST; + available = _SIZE; + while (available > 0 && *p != 0) + { + p++; + available--; + } + + if (available == 0) + { + _RESET_STRING(_DEST, _SIZE); + _RETURN_DEST_NOT_NULL_TERMINATED(_DEST, _SIZE); + } + + while ((*p++ = *_SRC++) != 0 && --available > 0) + { + } + + if (available == 0) + { + _RESET_STRING(_DEST, _SIZE); + _RETURN_BUFFER_TOO_SMALL(_DEST, _SIZE); + } + _FILL_STRING(_DEST, _SIZE, _SIZE - available + 1); + _RETURN_NO_ERROR; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscpy_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscpy_s.inl new file mode 100644 index 0000000000..c5fbc1f7ef --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcscpy_s.inl @@ -0,0 +1,40 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*tcscpy_s.inl - general implementation of _tcscpy_s +* + +* +*Purpose: +* This file contains the general algorithm for strcpy_s and its variants. +* +****/ + +_FUNC_PROLOGUE +errno_t __cdecl _FUNC_NAME(_CHAR *_DEST, size_t _SIZE, const _CHAR *_SRC) +{ + _CHAR *p; + size_t available; + + /* validation section */ + _VALIDATE_STRING(_DEST, _SIZE); + _VALIDATE_POINTER_RESET_STRING(_SRC, _DEST, _SIZE); + + p = _DEST; + available = _SIZE; + while ((*p++ = *_SRC++) != 0 && --available > 0) + { + } + + if (available == 0) + { + _RESET_STRING(_DEST, _SIZE); + _RETURN_BUFFER_TOO_SMALL(_DEST, _SIZE); + } + _FILL_STRING(_DEST, _SIZE, _SIZE - available + 1); + _RETURN_NO_ERROR; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncat_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncat_s.inl new file mode 100644 index 0000000000..01368e73f6 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncat_s.inl @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*tcsncat_s.inl - general implementation of _tcscpy_s +* + +* +*Purpose: +* This file contains the general algorithm for strncat_s and its variants. +* +****/ + +_FUNC_PROLOGUE +errno_t __cdecl _FUNC_NAME(_CHAR *_DEST, size_t _SIZE, const _CHAR *_SRC, size_t _COUNT) +{ + _CHAR *p; + size_t available; + + if (_COUNT == 0 && _DEST == NULL && _SIZE == 0) + { + /* this case is allowed; nothing to do */ + _RETURN_NO_ERROR; + } + + /* validation section */ + _VALIDATE_STRING(_DEST, _SIZE); + if (_COUNT != 0) + { + _VALIDATE_POINTER_RESET_STRING(_SRC, _DEST, _SIZE); + } + + p = _DEST; + available = _SIZE; + while (available > 0 && *p != 0) + { + p++; + available--; + } + + if (available == 0) + { + _RESET_STRING(_DEST, _SIZE); + _RETURN_DEST_NOT_NULL_TERMINATED(_DEST, _SIZE); + } + + if (_COUNT == _TRUNCATE) + { + while ((*p++ = *_SRC++) != 0 && --available > 0) + { + } + } + else + { + _ASSERT_EXPR((!_CrtGetCheckCount() || _COUNT < available), "Buffer is too small"); + + while (_COUNT > 0 && (*p++ = *_SRC++) != 0 && --available > 0) + { + _COUNT--; + } + if (_COUNT == 0) + { + *p = 0; + } + } + + if (available == 0) + { + if (_COUNT == _TRUNCATE) + { + _DEST[_SIZE - 1] = 0; + _RETURN_TRUNCATE; + } + _RESET_STRING(_DEST, _SIZE); + _RETURN_BUFFER_TOO_SMALL(_DEST, _SIZE); + } + _FILL_STRING(_DEST, _SIZE, _SIZE - available + 1); + _RETURN_NO_ERROR; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncpy_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncpy_s.inl new file mode 100644 index 0000000000..6f33a4b55a --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcsncpy_s.inl @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*tcsncpy_s.inl - general implementation of _tcsncpy_s +* + +* +*Purpose: +* This file contains the general algorithm for strncpy_s and its variants. +* +****/ + +_FUNC_PROLOGUE +errno_t __cdecl _FUNC_NAME(_CHAR *_DEST, size_t _SIZE, const _CHAR *_SRC, size_t _COUNT) +{ + _CHAR *p; + size_t available; + + if (_COUNT == 0 && _DEST == NULL && _SIZE == 0) + { + /* this case is allowed; nothing to do */ + _RETURN_NO_ERROR; + } + + /* validation section */ + _VALIDATE_STRING(_DEST, _SIZE); + if (_COUNT == 0) + { + /* notice that the source string pointer can be NULL in this case */ + _RESET_STRING(_DEST, _SIZE); + _RETURN_NO_ERROR; + } + _VALIDATE_POINTER_RESET_STRING(_SRC, _DEST, _SIZE); + + p = _DEST; + available = _SIZE; + if (_COUNT == _TRUNCATE) + { + while ((*p++ = *_SRC++) != 0 && --available > 0) + { + } + } + else + { + _ASSERT_EXPR((!_CrtGetCheckCount() || _COUNT < _SIZE), "Buffer is too small"); + + while ((*p++ = *_SRC++) != 0 && --available > 0 && --_COUNT > 0) + { + } + if (_COUNT == 0) + { + *p = 0; + } + } + + if (available == 0) + { + if (_COUNT == _TRUNCATE) + { + _DEST[_SIZE - 1] = 0; + _RETURN_TRUNCATE; + } + _RESET_STRING(_DEST, _SIZE); + _RETURN_BUFFER_TOO_SMALL(_DEST, _SIZE); + } + _FILL_STRING(_DEST, _SIZE, _SIZE - available + 1); + _RETURN_NO_ERROR; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcstok_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcstok_s.inl new file mode 100644 index 0000000000..c95e2e5da2 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/tcstok_s.inl @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*tcstok_s.inl - general implementation of _tcstok_s +* + +* +*Purpose: +* This file contains the general algorithm for strtok_s and its variants. +* +****/ + +_FUNC_PROLOGUE +_CHAR * __cdecl _FUNC_NAME(_CHAR *_String, const _CHAR *_Control, _CHAR **_Context) +{ + _CHAR *token; + const _CHAR *ctl; + + /* validation section */ + _VALIDATE_POINTER_ERROR_RETURN(_Context, EINVAL, NULL); + _VALIDATE_POINTER_ERROR_RETURN(_Control, EINVAL, NULL); + _VALIDATE_CONDITION_ERROR_RETURN(_String != NULL || *_Context != NULL, EINVAL, NULL); + + /* If string==NULL, continue with previous string */ + if (!_String) + { + _String = *_Context; + } + + /* Find beginning of token (skip over leading delimiters). Note that + * there is no token iff this loop sets string to point to the terminal null. */ + for ( ; *_String != 0 ; _String++) + { + for (ctl = _Control; *ctl != 0 && *ctl != *_String; ctl++) + ; + if (*ctl == 0) + { + break; + } + } + + token = _String; + + /* Find the end of the token. If it is not the end of the string, + * put a null there. */ + for ( ; *_String != 0 ; _String++) + { + for (ctl = _Control; *ctl != 0 && *ctl != *_String; ctl++) + ; + if (*ctl != 0) + { + *_String++ = 0; + break; + } + } + + /* Update the context */ + *_Context = _String; + + /* Determine if a token has been found. */ + if (token == _String) + { + return NULL; + } + else + { + return token; + } +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vsprintf.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vsprintf.c new file mode 100644 index 0000000000..ab09c91e72 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vsprintf.c @@ -0,0 +1,223 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*vsprintf.c - print formatted data into a string from var arg list +* + +* +*Purpose: +* defines vsprintf(), _vsnprintf() and _vsnprintf_s() - print formatted output to +* a string, get the data from an argument ptr instead of explicit +* arguments. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +typedef int (*OUTPUTFN)(miniFILE *, const char *, va_list); + +static int _vsnprintf_helper( OUTPUTFN outfn, char *string, size_t count, const char *format, va_list ap ); + +/*** +*ifndef _COUNT_ +*int vsprintf(string, format, ap) - print formatted data to string from arg ptr +*else +*int _vsnprintf(string, cnt, format, ap) - print formatted data to string from arg ptr +*endif +* +*Purpose: +* Prints formatted data, but to a string and gets data from an argument +* pointer. +* Sets up a FILE so file i/o operations can be used, make string look +* like a huge buffer to it, but _flsbuf will refuse to flush it if it +* fills up. Appends '\0' to make it a true string. +* +* Allocate the 'fake' _iob[] entryit statically instead of on +* the stack so that other routines can assume that _iob[] entries are in +* are in DGROUP and, thus, are near. +* +*ifdef _COUNT_ +* The _vsnprintf() flavor takes a count argument that is +* the max number of bytes that should be written to the +* user's buffer. +*endif +* +* Multi-thread: (1) Since there is no stream, this routine must never try +* to get the stream lock (i.e., there is no stream lock either). (2) +* Also, since there is only one staticly allocated 'fake' iob, we must +* lock/unlock to prevent collisions. +* +*Entry: +* char *string - place to put destination string +*ifdef _COUNT_ +* size_t count - max number of bytes to put in buffer +*endif +* char *format - format string, describes format of data +* va_list ap - varargs argument pointer +* +*Exit: +* returns number of characters in string +* returns -2 if the string has been truncated (only in _vsnprintf_helper) +* returns -1 in other error cases +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _vsnprintf_helper ( + OUTPUTFN outfn, + char *string, + size_t count, + const char *format, + va_list ap + ) +{ + miniFILE str; + miniFILE *outfile = &str; + int retval; + + _VALIDATE_RETURN( (format != NULL), EINVAL, -1); + + _VALIDATE_RETURN( (count == 0) || (string != NULL), EINVAL, -1 ); + + if(count>INT_MAX) + { + /* old-style functions allow any large value to mean unbounded */ + outfile->_cnt = INT_MAX; + } + else + { + outfile->_cnt = (int)count; + } + + outfile->_flag = _IOWRT|_IOSTRG; + outfile->_ptr = outfile->_base = string; + + retval = outfn(outfile, format, ap ); + + if ( string==NULL) + return(retval); + + if((retval >= 0) && (_putc_nolock('\0',outfile) != EOF)) + return(retval); + + string[count - 1] = 0; + + if (outfile->_cnt < 0) + { + /* the buffer was too small; we return -2 to indicate truncation */ + return -2; + } + return -1; +} + +int __cdecl _vsprintf_s ( + char *string, + size_t sizeInBytes, + const char *format, + va_list ap + ) +{ + int retvalue = -1; + + /* validation section */ + _VALIDATE_RETURN(format != NULL, EINVAL, -1); + _VALIDATE_RETURN(string != NULL && sizeInBytes > 0, EINVAL, -1); + + retvalue = _vsnprintf_helper(_output_s, string, sizeInBytes, format, ap); + if (retvalue < 0) + { + string[0] = 0; + _SECURECRT__FILL_STRING(string, sizeInBytes, 1); + } + if (retvalue == -2) + { + _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); + } + if (retvalue >= 0) + { + _SECURECRT__FILL_STRING(string, sizeInBytes, retvalue + 1); + } + + return retvalue; +} + +int __cdecl vsprintf_s(char *_Dst, size_t _SizeInBytes, const char *_Format, va_list _ArgList) +{ + return _vsprintf_s(_Dst, _SizeInBytes, _Format, _ArgList); +} + +int __cdecl _vsnprintf_s ( + char *string, + size_t sizeInBytes, + size_t count, + const char *format, + va_list ap + ) +{ + int retvalue = -1; + errno_t save_errno = 0; + + /* validation section */ + _VALIDATE_RETURN(format != NULL, EINVAL, -1); + if (count == 0 && string == NULL && sizeInBytes == 0) + { + /* this case is allowed; nothing to do */ + return 0; + } + _VALIDATE_RETURN(string != NULL && sizeInBytes > 0, EINVAL, -1); + + if (sizeInBytes > count) + { + save_errno = errno; + retvalue = _vsnprintf_helper(_output_s, string, count + 1, format, ap); + if (retvalue == -2) + { + /* the string has been truncated, return -1 */ + _SECURECRT__FILL_STRING(string, sizeInBytes, count + 1); + if (errno == ERANGE) + { + errno = save_errno; + } + return -1; + } + } + else /* sizeInBytes <= count */ + { + save_errno = errno; + retvalue = _vsnprintf_helper(_output_s, string, sizeInBytes, format, ap); + string[sizeInBytes - 1] = 0; + /* we allow truncation if count == _TRUNCATE */ + if (retvalue == -2 && count == _TRUNCATE) + { + if (errno == ERANGE) + { + errno = save_errno; + } + return -1; + } + } + + if (retvalue < 0) + { + string[0] = 0; + _SECURECRT__FILL_STRING(string, sizeInBytes, 1); + if (retvalue == -2) + { + _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); + } + return -1; + } + + _SECURECRT__FILL_STRING(string, sizeInBytes, retvalue + 1); + + return (retvalue < 0 ? -1 : retvalue); +} diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vswprint.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vswprint.c new file mode 100644 index 0000000000..d172305610 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/vswprint.c @@ -0,0 +1,293 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*vswprint.c - print formatted data into a string from var arg list +* +*Purpose: +* defines vswprintf(), _vswprintf_c and _vsnwprintf() - print formatted output to +* a string, get the data from an argument ptr instead of explicit +* arguments. +* +*******************************************************************************/ + + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +typedef int (*WOUTPUTFN)(miniFILE *, const char16_t *, va_list); + +static int _vswprintf_helper( WOUTPUTFN outfn, char16_t *string, size_t count, const char16_t *format, va_list ap ); +static int _vscwprintf_helper (WOUTPUTFN outfn, const char16_t *format, va_list ap ); + +/*** +*ifndef _COUNT_ +*int _vswprintf(string, format, ap) - print formatted data to string from arg ptr +*else +*ifndef _SWPRINTFS_ERROR_RETURN_FIX +*int _vsnwprintf(string, cnt, format, ap) - print formatted data to string from arg ptr +*else +*int _vswprintf_c(string, cnt, format, ...) - print formatted data to string +*endif +*endif +* +*Purpose: +* Prints formatted data, but to a string and gets data from an argument +* pointer. +* Sets up a FILE so file i/o operations can be used, make string look +* like a huge buffer to it, but _flsbuf will refuse to flush it if it +* fills up. Appends '\0' to make it a true string. +* +* Allocate the 'fake' _iob[] entryit statically instead of on +* the stack so that other routines can assume that _iob[] entries are in +* are in DGROUP and, thus, are near. +* +*ifdef _COUNT_ +*ifndef _SWPRINTFS_ERROR_RETURN_FIX +* The _vsnwprintf() flavor takes a count argument that is +* the max number of bytes that should be written to the +* user's buffer. +* We don't expose this function directly in the headers. +*else +* The _vswprintf_c() flavor does the same thing as the _snwprintf +* above, but, it also fixes an issue in the return value in the case +* when there isn't enough space to write the null terminator +* We don't fix this issue in _vsnwprintf because of backward +* compatibility. In new code, however, _vsnwprintf is #defined to +* _vswprintf_c so users get the fix. +* +*endif +* +* Multi-thread: (1) Since there is no stream, this routine must never try +* to get the stream lock (i.e., there is no stream lock either). (2) +* Also, since there is only one statically allocated 'fake' iob, we must +* lock/unlock to prevent collisions. +* +*Entry: +* char16_t *string - place to put destination string +*ifdef _COUNT_ +* size_t count - max number of bytes to put in buffer +*endif +* char16_t *format - format string, describes format of data +* va_list ap - varargs argument pointer +* +*Exit: +* returns number of wide characters in string +* returns -2 if the string has been truncated (only in _vsnprintf_helper) +* returns -1 in other error cases +* +*Exceptions: +* +*******************************************************************************/ + +int __cdecl _vswprintf_helper ( + WOUTPUTFN woutfn, + char16_t *string, + size_t count, + const char16_t *format, + va_list ap + ) +{ + miniFILE str; + miniFILE *outfile = &str; + int retval; + + _VALIDATE_RETURN( (format != NULL), EINVAL, -1); + + _VALIDATE_RETURN( (count == 0) || (string != NULL), EINVAL, -1 ); + + outfile->_flag = _IOWRT|_IOSTRG; + outfile->_ptr = outfile->_base = (char *) string; + + if(count>(INT_MAX/sizeof(char16_t))) + { + /* old-style functions allow any large value to mean unbounded */ + outfile->_cnt = INT_MAX; + } + else + { + outfile->_cnt = (int)(count*sizeof(char16_t)); + } + + retval = woutfn(outfile, format, ap ); + + if(string==NULL) + { + return retval; + } + + if((retval >= 0) && (_putc_nolock('\0',outfile) != EOF) && (_putc_nolock('\0',outfile) != EOF)) + return(retval); + + string[count - 1] = 0; + if (outfile->_cnt < 0) + { + /* the buffer was too small; we return -2 to indicate truncation */ + return -2; + } + return -1; +} + +int __cdecl _vswprintf_s ( + char16_t *string, + size_t sizeInWords, + const char16_t *format, + va_list ap + ) +{ + int retvalue = -1; + + /* validation section */ + _VALIDATE_RETURN(format != NULL, EINVAL, -1); + _VALIDATE_RETURN(string != NULL && sizeInWords > 0, EINVAL, -1); + + retvalue = _vswprintf_helper(_woutput_s, string, sizeInWords, format, ap); + if (retvalue < 0) + { + string[0] = 0; + _SECURECRT__FILL_STRING(string, sizeInWords, 1); + } + if (retvalue == -2) + { + _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); + } + if (retvalue >= 0) + { + _SECURECRT__FILL_STRING(string, sizeInWords, retvalue + 1); + } + + return retvalue; +} + +int __cdecl vswprintf_s ( + char16_t *string, + size_t sizeInWords, + const char16_t *format, + va_list ap + ) +{ + return _vswprintf_s(string, sizeInWords, format, ap); +} + +int __cdecl _vsnwprintf_s ( + char16_t *string, + size_t sizeInWords, + size_t count, + const char16_t *format, + va_list ap + ) +{ + int retvalue = -1; + errno_t save_errno = 0; + + /* validation section */ + _VALIDATE_RETURN(format != NULL, EINVAL, -1); + if (count == 0 && string == NULL && sizeInWords == 0) + { + /* this case is allowed; nothing to do */ + return 0; + } + _VALIDATE_RETURN(string != NULL && sizeInWords > 0, EINVAL, -1); + + if (sizeInWords > count) + { + save_errno = errno; + retvalue = _vswprintf_helper(_woutput_s, string, count + 1, format, ap); + if (retvalue == -2) + { + /* the string has been truncated, return -1 */ + _SECURECRT__FILL_STRING(string, sizeInWords, count + 1); + if (errno == ERANGE) + { + errno = save_errno; + } + return -1; + } + } + else /* sizeInWords <= count */ + { + save_errno = errno; + retvalue = _vswprintf_helper(_woutput_s, string, sizeInWords, format, ap); + string[sizeInWords - 1] = 0; + /* we allow truncation if count == _TRUNCATE */ + if (retvalue == -2 && count == _TRUNCATE) + { + if (errno == ERANGE) + { + errno = save_errno; + } + return -1; + } + } + + if (retvalue < 0) + { + string[0] = 0; + _SECURECRT__FILL_STRING(string, sizeInWords, 1); + if (retvalue == -2) + { + _VALIDATE_RETURN(("Buffer too small" && 0), ERANGE, -1); + } + return -1; + } + + _SECURECRT__FILL_STRING(string, sizeInWords, retvalue + 1); + + return (retvalue < 0 ? -1 : retvalue); +} + +/*** +* _vscwprintf() - counts the number of character needed to print the formatted +* data +* +*Purpose: +* Counts the number of characters in the fotmatted data. +* +*Entry: +* char16_t *format - format string, describes format of data +* va_list ap - varargs argument pointer +* +*Exit: +* returns number of characters needed to print formatted data. +* +*Exceptions: +* +*******************************************************************************/ + +#ifndef _COUNT_ + +int __cdecl _vscwprintf_helper ( + WOUTPUTFN woutfn, + const char16_t *format, + va_list ap + ) +{ + miniFILE str; + miniFILE *outfile = &str; + int retval; + + _VALIDATE_RETURN( (format != NULL), EINVAL, -1); + + outfile->_cnt = INT_MAX; //MAXSTR; + outfile->_flag = _IOWRT|_IOSTRG; + outfile->_ptr = outfile->_base = NULL; + + retval = woutfn(outfile, format, ap); + return(retval); +} + +int __cdecl _vscwprintf ( + const char16_t *format, + va_list ap + ) +{ + return _vscwprintf_helper(_woutput_s, format, ap); +} + +#endif /* _COUNT_ */ diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscat_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscat_s.c new file mode 100644 index 0000000000..431adf3642 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscat_s.c @@ -0,0 +1,37 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*wcscat_s.c - contains wcscat_s() +* + +* +*Purpose: +* wcscat_s() appends one char16_t string onto another. +* +* wcscat() concatenates (appends) a copy of the source string to the +* end of the destination string. +* Strings are wide-character strings. +* +*******************************************************************************/ + +#define _SECURECRT_FILL_BUFFER 1 +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME wcscat_s +#define _CHAR char16_t +#define _DEST _Dst +#define _SIZE _SizeInBytes +#define _SRC _Src + +#include "tcscat_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscpy_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscpy_s.c new file mode 100644 index 0000000000..46c176e09a --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcscpy_s.c @@ -0,0 +1,34 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strcpy_s.c - contains wcscpy_s() +* + +* +*Purpose: +* wcscpy_s() copies one string onto another. +* +*******************************************************************************/ + +#define _SECURECRT_FILL_BUFFER 1 +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME wcscpy_s +#define _CHAR char16_t +#define _DEST _Dst +#define _SIZE _SizeInWords +#define _SRC _Src + +#include "tcscpy_s.inl" + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcslen_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcslen_s.c new file mode 100644 index 0000000000..0fa8d8358b --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcslen_s.c @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*wcslen_s.c - contains wcsnlen() routine +* + +* +*Purpose: +* wcslen returns the length of a null-terminated wide-character string, +* not including the null char16_t itself. +* +*******************************************************************************/ + + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +/*** +*wcsnlen - return the length of a null-terminated wide-character string +* +*Purpose: +* Finds the length in bytes of the given string, not including +* the final null character. Only the first maxsize characters +* are inspected: if the null character is not found, maxsize is +* returned. +* +*Entry: +* const char16_t * wcs - string whose length is to be computed +* size_t maxsize +* +*Exit: +* Length of the string "wcs", exclusive of the final null byte, or +* maxsize if the null character is not found. +* +*Exceptions: +* +*******************************************************************************/ + +size_t __cdecl wcsnlen(const char16_t *wcs, size_t maxsize) +{ + size_t n; + + /* Note that we do not check if s == NULL, because we do not + * return errno_t... + */ + + for (n = 0; n < maxsize && *wcs; n++, wcs++) + ; + + return n; +} + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncat_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncat_s.c new file mode 100644 index 0000000000..ad241cd1f4 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncat_s.c @@ -0,0 +1,36 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*wcsncat_s.c - append n chars of string to new string +* + +* +*Purpose: +* defines wcsncat_s() - appends n characters of string onto +* end of other string +* +*******************************************************************************/ + +#define _SECURECRT_FILL_BUFFER 1 +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME wcsncat_s +#define _CHAR char16_t +#define _DEST _Dst +#define _SIZE _SizeInWords +#define _SRC _Src +#define _COUNT _Count + +#include "tcsncat_s.inl" + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncpy_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncpy_s.c new file mode 100644 index 0000000000..561f5e682a --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcsncpy_s.c @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*wcsncpy_s.c - copy at most n characters of wide-character string +* + +* +*Purpose: +* defines wcsncpy_s() - copy at most n characters of char16_t string +* +*******************************************************************************/ + +#define _SECURECRT_FILL_BUFFER 1 +#define _SECURECRT_FILL_BUFFER_THRESHOLD ((size_t)8) + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME wcsncpy_s +#define _CHAR char16_t +#define _DEST _Dst +#define _SIZE _SizeInWords +#define _SRC _Src +#define _COUNT _Count + +#include "tcsncpy_s.inl" + diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcstok_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcstok_s.c new file mode 100644 index 0000000000..cc970204ed --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/wcstok_s.c @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*wcstok_s.c - tokenize a wide-character string with given delimiters +* + +* +*Purpose: +* defines wcstok_s() - breaks wide-character string into series of token +* via repeated calls. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _FUNC_PROLOGUE +#define _FUNC_NAME wcstok_s +#define _CHAR char16_t + +#include "tcstok_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtoa_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtoa_s.c new file mode 100644 index 0000000000..17adc98d57 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtoa_s.c @@ -0,0 +1,30 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strtok_s.c - tokenize a string with given delimiters +* + +* +*Purpose: +* defines strtok_s() - breaks string into series of token +* via repeated calls. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +//#define __int64 long long + +#define _SECURE_ITOA + +#define TCHAR char +#define _T(x) x +#include "xtox_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtow_s.c b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtow_s.c new file mode 100644 index 0000000000..0cdfd4ebb0 --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtow_s.c @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*strtok_s.c - tokenize a string with given delimiters +* + +* +*Purpose: +* defines strtok_s() - breaks string into series of token +* via repeated calls. +* +*******************************************************************************/ + +#include +#include +#include +#include "internal_securecrt.h" + +#include "mbusafecrt_internal.h" + +#define _SECURE_ITOA + +#define _UNICODE +#define TCHAR char16_t +#define _T(x) L##x +#include "xtox_s.inl" diff --git a/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtox_s.inl b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtox_s.inl new file mode 100644 index 0000000000..877b152aba --- /dev/null +++ b/sgx-jvm/linux-sgx/sdk/tsafecrt/pal/src/safecrt/xtox_s.inl @@ -0,0 +1,451 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +/*** +*xtoa.c - convert integers/longs to ASCII string +* + +* +*Purpose: +* The module has code to convert integers/longs to ASCII strings. See +* +*******************************************************************************/ + +#ifdef _UNICODE +#define xtox_s xtow_s +#define _itox_s _itow_s +#define _ltox_s _ltow_s +#define _ultox_s _ultow_s +#define x64tox_s x64tow_s +#define _i64tox_s _i64tow_s +#define _ui64tox_s _ui64tow_s +#define xtox xtow +#define _itox _itow +#define _ltox _ltow +#define _ultox _ultow +#define x64tox x64tow +#define _i64tox _i64tow +#define _ui64tox _ui64tow +#else /* _UNICODE */ +#define xtox_s xtoa_s +#define _itox_s _itoa_s +#define _ltox_s _ltoa_s +#define _ultox_s _ultoa_s +#define x64tox_s x64toa_s +#define _i64tox_s _i64toa_s +#define _ui64tox_s _ui64toa_s +#define xtox xtoa +#define _itox _itoa +#define _ltox _ltoa +#define _ultox _ultoa +#define x64tox x64toa +#define _i64tox _i64toa +#define _ui64tox _ui64toa +#endif /* _UNICODE */ + +/*** +*char *_itoa_s, *_ltoa_s, *_ultoa_s(val, buf, sizeInTChars, radix) - convert binary int to ASCII +* string +* +*Purpose: +* Converts an int to a character string. +* +*Entry: +* val - number to be converted (int, long or unsigned long) +* char *buf - ptr to buffer to place result +* size_t sizeInTChars - size of the destination buffer +* int radix - base to convert into +* +*Exit: +* Fills in space pointed to by buf with string result. +* Returns the errno_t: err != 0 means that something went wrong, and +* an empty string (buf[0] = 0) is returned. +* +*Exceptions: +* Input parameters and buffer length are validated. +* Refer to the validation section of the function. +* +*******************************************************************************/ + +/* helper routine that does the main job. */ +#ifdef _SECURE_ITOA +errno_t __stdcall xtox_s + ( + unsigned long val, + TCHAR *buf, + size_t sizeInTChars, + unsigned radix, + int is_neg + ) +#else /* _SECURE_ITOA */ +void __stdcall xtox + ( + unsigned long val, + TCHAR *buf, + unsigned radix, + int is_neg + ) +#endif /* _SECURE_ITOA */ +{ + TCHAR *p; /* pointer to traverse string */ + TCHAR *firstdig; /* pointer to first digit */ + TCHAR temp; /* temp char */ + unsigned digval; /* value of digit */ +#ifdef _SECURE_ITOA + size_t length; /* current length of the string */ + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(buf != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInTChars > 0, EINVAL); + _RESET_STRING(buf, sizeInTChars); + _VALIDATE_RETURN_ERRCODE(sizeInTChars > (size_t)(is_neg ? 2 : 1), ERANGE); + _VALIDATE_RETURN_ERRCODE(2 <= radix && radix <= 36, EINVAL); + length = 0; + +#endif /* _SECURE_ITOA */ + p = buf; + + if (is_neg) { + /* negative, so output '-' and negate */ + *p++ = _T('-'); +#ifdef _SECURE_ITOA + length++; +#endif /* _SECURE_ITOA */ + val = (unsigned long)(-(long)val); + } + + firstdig = p; /* save pointer to first digit */ + + do { + digval = (unsigned) (val % radix); + val /= radix; /* get next digit */ + + /* convert to ascii and store */ + if (digval > 9) + *p++ = (TCHAR) (digval - 10 + _T('a')); /* a letter */ + else + *p++ = (TCHAR) (digval + _T('0')); /* a digit */ +#ifndef _SECURE_ITOA + } while (val > 0); +#else /* _SECURE_ITOA */ + length++; + } while (val > 0 && length < sizeInTChars); + + /* Check for buffer overrun */ + if (length >= sizeInTChars) + { + buf[0] = '\0'; + _VALIDATE_RETURN_ERRCODE(length < sizeInTChars, ERANGE); + } +#endif /* _SECURE_ITOA */ + /* We now have the digit of the number in the buffer, but in reverse + order. Thus we reverse them now. */ + + *p-- = _T('\0'); /* terminate string; p points to last digit */ + + do { + temp = *p; + *p = *firstdig; + *firstdig = temp; /* swap *p and *firstdig */ + --p; + ++firstdig; /* advance to next two digits */ + } while (firstdig < p); /* repeat until halfway */ +#ifdef _SECURE_ITOA + return 0; +#endif /* _SECURE_ITOA */ +} + +/* Actual functions just call conversion helper with neg flag set correctly, + and return pointer to buffer. */ + +#ifdef _SECURE_ITOA +errno_t __cdecl _itox_s ( + int val, + TCHAR *buf, + size_t sizeInTChars, + int radix + ) +{ + errno_t e = 0; + + if (radix == 10 && val < 0) + e = xtox_s((unsigned long)val, buf, sizeInTChars, (unsigned)radix, 1); + else + e = xtox_s((unsigned long)(unsigned int)val, buf, sizeInTChars, (unsigned)radix, 0); + + return e; +} + +errno_t __cdecl _ltox_s ( + long val, + TCHAR *buf, + size_t sizeInTChars, + int radix + ) +{ + return xtox_s((unsigned long)val, buf, sizeInTChars, (unsigned)radix, (radix == 10 && val < 0)); +} + +errno_t __cdecl _ultox_s ( + unsigned long val, + TCHAR *buf, + size_t sizeInTChars, + int radix + ) +{ + return xtox_s(val, buf, sizeInTChars, (unsigned)radix, 0); +} + +#else /* _SECURE_ITOA */ + +/*** +*char *_itoa, *_ltoa, *_ultoa(val, buf, radix) - convert binary int to ASCII +* string +* +*Purpose: +* Converts an int to a character string. +* +*Entry: +* val - number to be converted (int, long or unsigned long) +* int radix - base to convert into +* char *buf - ptr to buffer to place result +* +*Exit: +* fills in space pointed to by buf with string result +* returns a pointer to this buffer +* +*Exceptions: +* Input parameters are validated. The buffer is assumed to be big enough to +* contain the string. Refer to the validation section of the function. +* +*******************************************************************************/ + +/* Actual functions just call conversion helper with neg flag set correctly, + and return pointer to buffer. */ + +TCHAR * __cdecl _itox ( + int val, + TCHAR *buf, + int radix + ) +{ + if (radix == 10 && val < 0) + xtox((unsigned long)val, buf, radix, 1); + else + xtox((unsigned long)(unsigned int)val, buf, radix, 0); + return buf; +} + +TCHAR * __cdecl _ltox ( + long val, + TCHAR *buf, + int radix + ) +{ + xtox((unsigned long)val, buf, radix, (radix == 10 && val < 0)); + return buf; +} + +TCHAR * __cdecl _ultox ( + unsigned long val, + TCHAR *buf, + int radix + ) +{ + xtox(val, buf, radix, 0); + return buf; +} + +#endif /* _SECURE_ITOA */ + +#ifndef _NO_INT64 + +/*** +*char *_i64toa_s(val, buf, sizeInTChars, radix) - convert binary int to ASCII +* string +* +*Purpose: +* Converts an int64 to a character string. +* +*Entry: +* val - number to be converted +* char *buf - ptr to buffer to place result +* size_t sizeInTChars - size of the destination buffer +* int radix - base to convert into +* +*Exit: +* Fills in space pointed to by buf with string result. +* Returns the errno_t: err != 0 means that something went wrong, and +* an empty string (buf[0] = 0) is returned. +* +*Exceptions: +* Input parameters and buffer length are validated. +* Refer to the validation section of the function. +* +*******************************************************************************/ + +#ifdef _SECURE_ITOA +errno_t __fastcall x64tox_s + (/* stdcall is faster and smaller... Might as well use it for the helper. */ + unsigned __int64 val, + TCHAR *buf, + size_t sizeInTChars, + unsigned radix, + int is_neg + ) +#else /* _SECURE_ITOA */ +void __fastcall x64tox + (/* stdcall is faster and smaller... Might as well use it for the helper. */ + unsigned __int64 val, + TCHAR *buf, + unsigned radix, + int is_neg + ) +#endif /* _SECURE_ITOA */ +{ + TCHAR *p; /* pointer to traverse string */ + TCHAR *firstdig; /* pointer to first digit */ + TCHAR temp; /* temp char */ + unsigned digval; /* value of digit */ +#ifdef _SECURE_ITOA + size_t length; /* current length of the string */ + + /* validation section */ + _VALIDATE_RETURN_ERRCODE(buf != NULL, EINVAL); + _VALIDATE_RETURN_ERRCODE(sizeInTChars > 0, EINVAL); + _RESET_STRING(buf, sizeInTChars); + _VALIDATE_RETURN_ERRCODE(sizeInTChars > (size_t)(is_neg ? 2 : 1), ERANGE); + _VALIDATE_RETURN_ERRCODE(2 <= radix && radix <= 36, EINVAL); + length = 0; +#endif /* _SECURE_ITOA */ + p = buf; + + if ( is_neg ) + { + *p++ = _T('-'); /* negative, so output '-' and negate */ +#ifdef _SECURE_ITOA + length++; +#endif /* _SECURE_ITOA */ + val = (unsigned __int64)(-(__int64)val); + } + + firstdig = p; /* save pointer to first digit */ + + do { + digval = (unsigned) (val % radix); + val /= radix; /* get next digit */ + + /* convert to ascii and store */ + if (digval > 9) + *p++ = (TCHAR) (digval - 10 + _T('a')); /* a letter */ + else + *p++ = (TCHAR) (digval + _T('0')); /* a digit */ + +#ifndef _SECURE_ITOA + } while (val > 0); +#else /* _SECURE_ITOA */ + length++; + } while (val > 0 && length < sizeInTChars); + + /* Check for buffer overrun */ + if (length >= sizeInTChars) + { + buf[0] = '\0'; + _VALIDATE_RETURN_ERRCODE(length < sizeInTChars, ERANGE); + } +#endif /* _SECURE_ITOA */ + /* We now have the digit of the number in the buffer, but in reverse + order. Thus we reverse them now. */ + + *p-- = _T('\0'); /* terminate string; p points to last digit */ + + do { + temp = *p; + *p = *firstdig; + *firstdig = temp; /* swap *p and *firstdig */ + --p; + ++firstdig; /* advance to next two digits */ + } while (firstdig < p); /* repeat until halfway */ + +#ifdef _SECURE_ITOA + return 0; +#endif /* _SECURE_ITOA */ +} + +#ifdef _SECURE_ITOA + +/* Actual functions just call conversion helper with neg flag set correctly, + and return pointer to buffer. */ + +errno_t __cdecl _i64tox_s ( + long long val, + TCHAR *buf, + size_t sizeInTChars, + int radix + ) +{ + return x64tox_s((unsigned __int64)val, buf, sizeInTChars, (unsigned)radix, (radix == 10 && val < 0)); +} + +errno_t __cdecl _ui64tox_s ( + unsigned long long val, + TCHAR *buf, + size_t sizeInTChars, + int radix + ) +{ + return x64tox_s(val, buf, sizeInTChars, (unsigned)radix, 0); +} + +#else /* _SECURE_ITOA */ + +/*** +*char *_i64toa(val, buf, radix) - convert binary int to ASCII +* string +* +*Purpose: +* Converts an int64 to a character string. +* +*Entry: +* val - number to be converted +* int radix - base to convert into +* char *buf - ptr to buffer to place result +* +*Exit: +* fills in space pointed to by buf with string result +* returns a pointer to this buffer +* +*Exceptions: +* Input parameters are validated. The buffer is assumed to be big enough to +* contain the string. Refer to the validation section of the function. +* +*******************************************************************************/ + +/* Actual functions just call conversion helper with neg flag set correctly, + and return pointer to buffer. */ + +TCHAR * __cdecl _i64tox ( + __int64 val, + TCHAR *buf, + int radix + ) +{ + x64tox((unsigned __int64)val, buf, radix, (radix == 10 && val < 0)); + return buf; +} + +TCHAR * __cdecl _ui64tox ( + unsigned __int64 val, + TCHAR *buf, + int radix + ) +{ + x64tox(val, buf, radix, 0); + return buf; +} + +#endif /* _SECURE_ITOA */ + +#endif /* _NO_INT64 */ diff --git a/sgx-jvm/linux-sgx/sdk/tsetjmp/Makefile b/sgx-jvm/linux-sgx/sdk/tsetjmp/Makefile index 7bf907ccf7..a9b6637a1d 100644 --- a/sgx-jvm/linux-sgx/sdk/tsetjmp/Makefile +++ b/sgx-jvm/linux-sgx/sdk/tsetjmp/Makefile @@ -33,8 +33,7 @@ include ../../buildenv.mk CFLAGS += $(ENCLAVE_CFLAGS) ASFLAGS := $(CFLAGS) -CFLAGS += -std=c99 -CXXFLAGS += $(ENCLAVE_CXXFLAGS) -fno-exceptions -fno-rtti -D_TLIBC_USE_INTEL_FAST_STRING_ +CXXFLAGS += $(ENCLAVE_CXXFLAGS) -fno-exceptions -fno-rtti -Werror CPPFLAGS += -I. \ -I$(COMMON_DIR)/inc \ @@ -54,8 +53,7 @@ LIBLONGJMP_OBJS += $(LIBLONGJMP_CPP_SRCS:.cpp=.o) LIBLONGJMP_NAME := libsgx_tsetjmp.a .PHONY: all -all: $(LIBLONGJMP_NAME) | $(BUILD_DIR) - $(CP) $(LIBLONGJMP_NAME) $| +all: $(LIBLONGJMP_NAME) $(LIBLONGJMP_NAME): $(LIBLONGJMP_OBJS) $(AR) rcs $@ $^ @@ -66,9 +64,13 @@ $(LIBLONGJMP_NAME): $(LIBLONGJMP_OBJS) %.o: %.S $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ -$(BUILD_DIR): - @$(MKDIR) $@ .PHONY: clean clean: - @$(RM) $(LIBLONGJMP_NAME) $(LIBLONGJMP_OBJS) $(BUILD_DIR)/$(LIBLONGJMP_NAME) + @$(RM) $(LIBLONGJMP_NAME) $(LIBLONGJMP_OBJS) + + +.PHONY: rebuild +rebuild: + $(MAKE) clean + $(MAKE) all diff --git a/sgx-jvm/linux-sgx/sdk/tsetjmp/_setjmp.S b/sgx-jvm/linux-sgx/sdk/tsetjmp/_setjmp.S index 1e62be69d0..33290fafa5 100644 --- a/sgx-jvm/linux-sgx/sdk/tsetjmp/_setjmp.S +++ b/sgx-jvm/linux-sgx/sdk/tsetjmp/_setjmp.S @@ -294,3 +294,7 @@ DECLARE_GLOBAL_FUNC set_sgx_tlongjmp_version lea_pic sgx_tsetjmp_version, %xax ret +.weak _setjmp +_setjmp=setjmp +.weak _longjmp +_longjmp=longjmp