Integrate Xilinx Versal

* add Versal specific glue
   The same structure of an "XSecure client" is used throughout the API's,
   therefor define it once and re-use in all clients.
* integrate Versal AES-GCM engine
* integrate Versal SHA3-384 engine
* add versal support to tests
  - There's no intermediate-hash API for Versal.
* add specific test with large AAD
   Test only with `n*16 byte` wide chunks of AAD, so it gets processed in the
   hardware engine.
* add specific test with misaligned AES-GCM arguments
* integrate Versal RSA engine
* disable failing RSA test-case when Xilinx Crypto is enabled
* introduce define `WOLFSSL_XILINX_CRYPT_VERSAL`
* integrate Versal TRNG engine
* allow using Versal TRNG w/o wolfcrypt DRBG
   Versal TRNG already provides a HRNG mode which does the same as the
   wolfcrypt DRBG implementation.
* add support for user-supplied nonce to Versal TRNG
* add `wc_XsecureErrorToString()` to map PLM error codes to messages.
* integrate Versal EcDSA engine
* update tests to work with Versal EcDSA
   If deterministic K is enabled, the tests failed here since the Versal
   EcDSA engine doesn't support the SECP256R1 curve yet.
* Xilinx crypto engines like aligned memory very much
   Make this a default choice, not via the user configuration.
* add Xilinx-specific `WOLFSSL_MSG()` equivalent
   `WOLFSSL_XIL_MSG()` does the same as `WOLFSSL_MSG()` besides waiting for
   1 second before printing to stdout, since the PLM maybe prints to same and
   outputs would be mixed up.
   This waiting can be disabled by defining `WOLFSSL_XIL_MSG_NO_SLEEP`.
* add option to enable DPA CounterMeasures in AES-GCM crypto engine
* add "command mode" to Xilinx bare-metal example
* update Xilinx default user settings
* add script to execute benchmarks
* add scripts to create graphics
* add Vitis 2022.1 example projects

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel 2022-05-20 14:28:39 +02:00 committed by Jacob Barthelmeh
parent f24cf38f01
commit 0e57e9858f
43 changed files with 7597 additions and 122 deletions

3
.gitignore vendored
View File

@ -379,6 +379,9 @@ IDE/XCODE/Index
/IDE/QNX/example-cmac/cmac-test
/IDE/QNX/CAAM-DRIVER/wolfCrypt
# Xilinx
/IDE/XilinxSDK/data
# Emacs
*~

9
IDE/XilinxSDK/2022_1/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
.analytics
.metadata/
_ide/
Debug/
Release/
*/.gitignore
vmk180/
*.ld

View File

@ -0,0 +1,436 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="xilinx.gnu.arm.a53.exe.debug.1474877702">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="xilinx.gnu.arm.a53.exe.debug.1474877702" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="com.xilinx.sdk.managedbuilder.XELF.arm.a53" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="xilinx.gnu.arm.a53.exe.debug.1474877702" name="Debug" parent="xilinx.gnu.arm.a53.exe.debug">
<folderInfo id="xilinx.gnu.arm.a53.exe.debug.1474877702." name="/" resourcePath="">
<toolChain id="xilinx.gnu.arm.a53.exe.debug.toolchain.1688387606" name="Xilinx ARM v8 GNU Toolchain" superClass="xilinx.gnu.arm.a53.exe.debug.toolchain">
<targetPlatform binaryParser="com.xilinx.sdk.managedbuilder.XELF.arm.a53" id="xilinx.arm.a53.target.gnu.base.debug.2106988235" isAbstract="false" name="Debug Platform" superClass="xilinx.arm.a53.target.gnu.base.debug"/>
<builder buildPath="${workspace_loc:/wolfCrypt_FreeRTOS_example}/Debug" enableAutoBuild="true" id="xilinx.gnu.arm.a53.toolchain.builder.debug.1760713905" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU make" superClass="xilinx.gnu.arm.a53.toolchain.builder.debug"/>
<tool id="xilinx.gnu.arm.a53.c.toolchain.assembler.debug.1583263664" name="ARM v8 gcc assembler" superClass="xilinx.gnu.arm.a53.c.toolchain.assembler.debug">
<inputType id="xilinx.gnu.assembler.input.1891087245" superClass="xilinx.gnu.assembler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.c.toolchain.compiler.debug.513792546" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.debug">
<option defaultValue="gnu.c.optimization.level.none" id="xilinx.gnu.compiler.option.optimization.level.243173779" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.1434559465" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.183582154" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.misc.other.1099870431" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -MT&quot;$@&quot; -mcpu=cortex-a72+crypto -mstrict-align" valueType="string"/>
<option id="xilinx.gnu.compiler.symbols.defined.707041736" name="Defined symbols (-D)" superClass="xilinx.gnu.compiler.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
<listOptionValue builtIn="false" value="FREERTOS"/>
</option>
<option id="xilinx.gnu.compiler.dircategory.includes.123126136" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspInclude}"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../../../.."/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../.."/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1351855" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.1551809650" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.compiler.debug.1504207709" name="ARM v8 g++ compiler" superClass="xilinx.gnu.arm.a53.cxx.toolchain.compiler.debug">
<option defaultValue="gnu.c.optimization.level.none" id="xilinx.gnu.compiler.option.optimization.level.2072170327" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.1090516066" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.1647155157" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.424275455" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" value="" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.toolchain.archiver.1979322941" name="ARM v8 archiver" superClass="xilinx.gnu.arm.a53.toolchain.archiver"/>
<tool id="xilinx.gnu.arm.a53.c.toolchain.linker.debug.1391654679" name="ARM v8 gcc linker" superClass="xilinx.gnu.arm.a53.c.toolchain.linker.debug">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1234789069" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1996043424" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lfreertos,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.1193342091" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" useByScannerDiscovery="false" value="../src/lscript.ld" valueType="string"/>
<option id="xilinx.gnu.c.link.option.ldflags.589962376" name="Linker Flags" superClass="xilinx.gnu.c.link.option.ldflags" useByScannerDiscovery="false" value=" -mcpu=cortex-a72" valueType="string"/>
<inputType id="xilinx.gnu.linker.input.2016062774" superClass="xilinx.gnu.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<inputType id="xilinx.gnu.linker.input.lscript.255576788" name="Linker Script" superClass="xilinx.gnu.linker.input.lscript"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.linker.debug.417768896" name="ARM v8 g++ linker" superClass="xilinx.gnu.arm.a53.cxx.toolchain.linker.debug">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.403817899" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.558971590" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lfreertos,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.1321668528" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.size.debug.389091694" name="ARM v8 Print Size" superClass="xilinx.gnu.arm.a53.size.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="_ide" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="xilinx.gnu.arm.a53.exe.release.1927748810">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="xilinx.gnu.arm.a53.exe.release.1927748810" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="com.xilinx.sdk.managedbuilder.XELF.arm.a53" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.exe.release.1927748810" name="Release" parent="xilinx.gnu.arm.a53.exe.release" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="xilinx.gnu.arm.a53.exe.release.1927748810." name="/" resourcePath="">
<toolChain errorParsers="" id="xilinx.gnu.arm.a53.exe.release.toolchain.366466512" name="Xilinx ARM v8 GNU Toolchain" superClass="xilinx.gnu.arm.a53.exe.release.toolchain">
<targetPlatform binaryParser="com.xilinx.sdk.managedbuilder.XELF.arm.a53" id="xilinx.arm.a53.target.gnu.base.release.1571305619" isAbstract="false" name="Release Platform" superClass="xilinx.arm.a53.target.gnu.base.release"/>
<builder buildPath="${workspace_loc:/wolfCrypt_FreeRTOS_example}/Release" enableAutoBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="xilinx.gnu.arm.a53.toolchain.builder.release.443454363" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU make" superClass="xilinx.gnu.arm.a53.toolchain.builder.release"/>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} -c ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.assembler.release.967166231" name="ARM v8 gcc assembler" superClass="xilinx.gnu.arm.a53.c.toolchain.assembler.release">
<inputType id="xilinx.gnu.assembler.input.479153327" superClass="xilinx.gnu.assembler.input"/>
</tool>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.release">
<option defaultValue="gnu.c.optimization.level.more" id="xilinx.gnu.compiler.option.optimization.level.626953214" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.184016610" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.690289163" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.misc.other.1270903165" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -MT&quot;$@&quot; -mcpu=cortex-a72+crypto -mstrict-align" valueType="string"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1824264778" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" useByScannerDiscovery="false" value="" valueType="string"/>
<option id="xilinx.gnu.compiler.dircategory.includes.1193599846" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${ProjDirPath}/../../../.."/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../.."/>
</option>
<option id="xilinx.gnu.compiler.symbols.defined.1824890829" name="Defined symbols (-D)" superClass="xilinx.gnu.compiler.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
<listOptionValue builtIn="false" value="FREERTOS"/>
</option>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.299904560" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.compiler.release.275801060" name="ARM v8 g++ compiler" superClass="xilinx.gnu.arm.a53.cxx.toolchain.compiler.release">
<option defaultValue="gnu.c.optimization.level.more" id="xilinx.gnu.compiler.option.optimization.level.544104803" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.640663069" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.136983938" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1153075161" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" value="" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.toolchain.archiver.1700366437" name="ARM v8 archiver" superClass="xilinx.gnu.arm.a53.toolchain.archiver"/>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.linker.release.1406437855" name="ARM v8 gcc linker" superClass="xilinx.gnu.arm.a53.c.toolchain.linker.release">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1863958225" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1301055908" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lfreertos,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.692734003" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" useByScannerDiscovery="false" value="../src/lscript.ld" valueType="string"/>
<option id="xilinx.gnu.c.link.option.ldflags.874339713" name="Linker Flags" superClass="xilinx.gnu.c.link.option.ldflags" useByScannerDiscovery="false" value=" -mcpu=cortex-a72" valueType="string"/>
<inputType id="xilinx.gnu.linker.input.1082738312" superClass="xilinx.gnu.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<inputType id="xilinx.gnu.linker.input.lscript.1855100381" name="Linker Script" superClass="xilinx.gnu.linker.input.lscript"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.linker.release.2088540295" name="ARM v8 g++ linker" superClass="xilinx.gnu.arm.a53.cxx.toolchain.linker.release">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1777967811" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_FreeRTOS_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1789803383" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lfreertos,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.380957067" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/>
</tool>
<tool command="aarch64-none-elf-size" commandLinePattern="${COMMAND} ${FLAGS} ${INPUTS} |tee ${OUTPUT}" errorParsers="" id="xilinx.gnu.arm.a53.size.release.1766287367" name="ARM v8 Print Size" superClass="xilinx.gnu.arm.a53.size.release"/>
</toolChain>
</folderInfo>
<fileInfo id="xilinx.gnu.arm.a53.exe.release.1927748810.1106497361" name="armv8-sha256.c" rcbsApplicability="disable" resourcePath="src/wolfcrypt/src/port/arm/armv8-sha256.c" toolsToInvoke="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922.1470558356">
<tool errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922.1470558356" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922">
<option id="xilinx.gnu.compiler.option.optimization.level.1787017462" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.optimize" valueType="enumerated"/>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.1167653127" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.681567385" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.2246108" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1055827109" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="_ide" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="wolfCrypt_FreeRTOS_example.xilinx.gnu.arm.a53.exe.1017512702" name="Xilinx ARM v8 Executable" projectType="xilinx.gnu.arm.a53.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.release.1927748810;xilinx.gnu.arm.a53.exe.release.1927748810.">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.debug.1474877702;xilinx.gnu.arm.a53.exe.debug.1474877702.">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.release.1927748810;xilinx.gnu.arm.a53.exe.release.1927748810.;xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922;xilinx.gnu.arm.a53.c.compiler.input.299904560">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.debug.1474877702;xilinx.gnu.arm.a53.exe.debug.1474877702.;xilinx.gnu.arm.a53.c.toolchain.compiler.debug.513792546;xilinx.gnu.arm.a53.c.compiler.input.1551809650">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/wolfCrypt_FreeRTOS_example"/>
</configuration>
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/wolfCrypt_FreeRTOS_example"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="ASCII"?>
<sdkproject:SdkProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdkproject="http://www.xilinx.com/sdkproject" name="wolfCrypt_FreeRTOS_example" platformUID="xilinx:vmk180::0.0(custom)" systemProject="wolfCrypt_FreeRTOS_example_system" sysConfig="vmk180" runtime="cpp" cpu="freertos" cpuInstance="versal_cips_0_pspmc_0_psv_cortexa72_0" os="freertos10_xilinx" mssSignature="69319cadb247104471151c20895b8098">
<configuration name="Debug" id="xilinx.gnu.arm.a53.exe.debug.1474877702" dirty="true">
<configBuildOptions xsi:type="sdkproject:SdkOptions"/>
<lastBuildOptions xsi:type="sdkproject:SdkOptions"/>
</configuration>
<configuration name="Release" id="xilinx.gnu.arm.a53.exe.release.1927748810">
<configBuildOptions xsi:type="sdkproject:SdkOptions"/>
<lastBuildOptions xsi:type="sdkproject:SdkOptions"/>
</configuration>
<template appTemplateName="empty_application"/>
</sdkproject:SdkProject>

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644" name="Debug" parent="com.xilinx.sdx.system.managedbuilder.debugConfiguration">
<folderInfo id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644." name="/" resourcePath="">
<toolChain id="com.xilinx.sdx.system.managedbuilder.debug.toolChain.1810994320" name="System Toolchain" superClass="com.xilinx.sdx.system.managedbuilder.debug.toolChain">
<targetPlatform id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644..2132586323" name=""/>
<builder buildPath="${workspace_loc:/wolfCrypt_FreeRTOS_example_system}/Debug" enableAutoBuild="true" id="com.xilinx.sdx.system.managedbuilder.systemBuilder.861022636" managedBuildOn="true" name="System Project Builder.Debug" superClass="com.xilinx.sdx.system.managedbuilder.systemBuilder"/>
<tool id="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool.1179083288" name="System Builder" superClass="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633" name="Release" parent="com.xilinx.sdx.system.managedbuilder.releaseConfiguration">
<folderInfo id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633." name="/" resourcePath="">
<toolChain id="com.xilinx.sdx.system.managedbuilder.release.toolChain.1719392334" name="System Toolchain" superClass="com.xilinx.sdx.system.managedbuilder.release.toolChain">
<targetPlatform id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633..326957413" name=""/>
<builder buildPath="${workspace_loc:/wolfCrypt_FreeRTOS_example_system}/Release" enableAutoBuild="true" id="com.xilinx.sdx.system.managedbuilder.systemBuilder.1659638366" managedBuildOn="true" name="System Project Builder.Release" superClass="com.xilinx.sdx.system.managedbuilder.systemBuilder"/>
<tool id="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool.615291826" name="System Builder" superClass="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="wolfCrypt_FreeRTOS_example_system.com.xilinx.sdx.system.managedbuilder.projectType.1223839149" name="Vitis Embedded System Project" projectType="com.xilinx.sdx.system.managedbuilder.projectType"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="refreshScope"/>
</cproject>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>wolfCrypt_FreeRTOS_example_system</name>
<comment></comment>
<projects>
<project>wolfCrypt_FreeRTOS_example</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.xilinx.sdx.system.core.embedded</nature>
<nature>com.xilinx.sdx.system.systemprojectnature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="ASCII"?>
<systemproject:SystemProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdkproject="http://www.xilinx.com/sdkproject" xmlns:systemproject="http://www.xilinx.com/systemproject" name="wolfCrypt_FreeRTOS_example_system" platformUID="xilinx:vmk180::0.0(custom)" sysConfig="vmk180" runtime="cpp" dimmRepoPath="" rootFSLocation="" linuxImage="" sysroot="">
<configuration name="Debug" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644">
<configBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_FreeRTOS_example" domainName="freertos" domainPrettyName="freertos" appBuildConfig="Debug"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</configBuildOptions>
<lastBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_FreeRTOS_example" domainName="freertos" domainPrettyName="freertos" appBuildConfig="Debug"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</lastBuildOptions>
</configuration>
<configuration name="Release" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633">
<configBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_FreeRTOS_example" domainName="freertos" domainPrettyName="freertos" appBuildConfig="Release"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</configBuildOptions>
<lastBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_FreeRTOS_example" domainName="freertos" domainPrettyName="freertos" appBuildConfig="Release"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</lastBuildOptions>
</configuration>
</systemproject:SystemProject>

View File

@ -0,0 +1,432 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="xilinx.gnu.arm.a53.exe.debug.1474877702">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="xilinx.gnu.arm.a53.exe.debug.1474877702" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="com.xilinx.sdk.managedbuilder.XELF.arm.a53" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="xilinx.gnu.arm.a53.exe.debug.1474877702" name="Debug" parent="xilinx.gnu.arm.a53.exe.debug">
<folderInfo id="xilinx.gnu.arm.a53.exe.debug.1474877702." name="/" resourcePath="">
<toolChain id="xilinx.gnu.arm.a53.exe.debug.toolchain.1688387606" name="Xilinx ARM v8 GNU Toolchain" superClass="xilinx.gnu.arm.a53.exe.debug.toolchain">
<targetPlatform binaryParser="com.xilinx.sdk.managedbuilder.XELF.arm.a53" id="xilinx.arm.a53.target.gnu.base.debug.2106988235" isAbstract="false" name="Debug Platform" superClass="xilinx.arm.a53.target.gnu.base.debug"/>
<builder buildPath="${workspace_loc:/wolfCrypt_example}/Debug" enableAutoBuild="true" id="xilinx.gnu.arm.a53.toolchain.builder.debug.1760713905" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU make" superClass="xilinx.gnu.arm.a53.toolchain.builder.debug"/>
<tool id="xilinx.gnu.arm.a53.c.toolchain.assembler.debug.1583263664" name="ARM v8 gcc assembler" superClass="xilinx.gnu.arm.a53.c.toolchain.assembler.debug">
<inputType id="xilinx.gnu.assembler.input.1891087245" superClass="xilinx.gnu.assembler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.c.toolchain.compiler.debug.513792546" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.debug">
<option defaultValue="gnu.c.optimization.level.none" id="xilinx.gnu.compiler.option.optimization.level.243173779" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.1434559465" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.183582154" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.misc.other.1099870431" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -MT&quot;$@&quot; -mcpu=cortex-a72+crypto -mstrict-align" valueType="string"/>
<option id="xilinx.gnu.compiler.symbols.defined.707041736" name="Defined symbols (-D)" superClass="xilinx.gnu.compiler.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
</option>
<option id="xilinx.gnu.compiler.dircategory.includes.123126136" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspInclude}"/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../../../.."/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../.."/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1351855" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.1551809650" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.compiler.debug.1504207709" name="ARM v8 g++ compiler" superClass="xilinx.gnu.arm.a53.cxx.toolchain.compiler.debug">
<option defaultValue="gnu.c.optimization.level.none" id="xilinx.gnu.compiler.option.optimization.level.2072170327" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.1090516066" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.1647155157" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.424275455" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" value="" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.toolchain.archiver.1979322941" name="ARM v8 archiver" superClass="xilinx.gnu.arm.a53.toolchain.archiver"/>
<tool id="xilinx.gnu.arm.a53.c.toolchain.linker.debug.1391654679" name="ARM v8 gcc linker" superClass="xilinx.gnu.arm.a53.c.toolchain.linker.debug">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1234789069" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1996043424" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.1193342091" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" useByScannerDiscovery="false" value="../src/lscript.ld" valueType="string"/>
<option id="xilinx.gnu.c.link.option.ldflags.589962376" name="Linker Flags" superClass="xilinx.gnu.c.link.option.ldflags" useByScannerDiscovery="false" value=" -mcpu=cortex-a72" valueType="string"/>
<inputType id="xilinx.gnu.linker.input.2016062774" superClass="xilinx.gnu.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<inputType id="xilinx.gnu.linker.input.lscript.255576788" name="Linker Script" superClass="xilinx.gnu.linker.input.lscript"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.linker.debug.417768896" name="ARM v8 g++ linker" superClass="xilinx.gnu.arm.a53.cxx.toolchain.linker.debug">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.403817899" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.558971590" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.1321668528" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.size.debug.389091694" name="ARM v8 Print Size" superClass="xilinx.gnu.arm.a53.size.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="_ide" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="xilinx.gnu.arm.a53.exe.release.1927748810">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="xilinx.gnu.arm.a53.exe.release.1927748810" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="com.xilinx.sdk.managedbuilder.XELF.arm.a53" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.exe.release.1927748810" name="Release" parent="xilinx.gnu.arm.a53.exe.release" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="xilinx.gnu.arm.a53.exe.release.1927748810." name="/" resourcePath="">
<toolChain errorParsers="" id="xilinx.gnu.arm.a53.exe.release.toolchain.366466512" name="Xilinx ARM v8 GNU Toolchain" superClass="xilinx.gnu.arm.a53.exe.release.toolchain">
<targetPlatform binaryParser="com.xilinx.sdk.managedbuilder.XELF.arm.a53" id="xilinx.arm.a53.target.gnu.base.release.1571305619" isAbstract="false" name="Release Platform" superClass="xilinx.arm.a53.target.gnu.base.release"/>
<builder buildPath="${workspace_loc:/wolfCrypt_example}/Release" enableAutoBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="xilinx.gnu.arm.a53.toolchain.builder.release.443454363" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU make" superClass="xilinx.gnu.arm.a53.toolchain.builder.release"/>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} -c ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.assembler.release.967166231" name="ARM v8 gcc assembler" superClass="xilinx.gnu.arm.a53.c.toolchain.assembler.release">
<inputType id="xilinx.gnu.assembler.input.479153327" superClass="xilinx.gnu.assembler.input"/>
</tool>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.release">
<option defaultValue="gnu.c.optimization.level.more" id="xilinx.gnu.compiler.option.optimization.level.626953214" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.184016610" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.690289163" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.misc.other.1270903165" name="Other flags" superClass="xilinx.gnu.compiler.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -MT&quot;$@&quot; -mcpu=cortex-a72+crypto -mstrict-align" valueType="string"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1824264778" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" useByScannerDiscovery="false" value="" valueType="string"/>
<option id="xilinx.gnu.compiler.dircategory.includes.1193599846" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="${ProjDirPath}/../../../.."/>
<listOptionValue builtIn="false" value="${ProjDirPath}/../.."/>
</option>
<option id="xilinx.gnu.compiler.symbols.defined.1824890829" name="Defined symbols (-D)" superClass="xilinx.gnu.compiler.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
</option>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.299904560" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.compiler.release.275801060" name="ARM v8 g++ compiler" superClass="xilinx.gnu.arm.a53.cxx.toolchain.compiler.release">
<option defaultValue="gnu.c.optimization.level.more" id="xilinx.gnu.compiler.option.optimization.level.544104803" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.option.debugging.level.640663069" name="Debug Level" superClass="xilinx.gnu.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="xilinx.gnu.compiler.inferred.swplatform.includes.136983938" name="Software Platform Include Path" superClass="xilinx.gnu.compiler.inferred.swplatform.includes" valueType="includePath">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspInclude}"/>
</option>
<option id="xilinx.gnu.compiler.inferred.swplatform.flags.1153075161" name="Software Platform Inferred Flags" superClass="xilinx.gnu.compiler.inferred.swplatform.flags" value="" valueType="string"/>
</tool>
<tool id="xilinx.gnu.arm.a53.toolchain.archiver.1700366437" name="ARM v8 archiver" superClass="xilinx.gnu.arm.a53.toolchain.archiver"/>
<tool command="aarch64-none-elf-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.linker.release.1406437855" name="ARM v8 gcc linker" superClass="xilinx.gnu.arm.a53.c.toolchain.linker.release">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1863958225" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1301055908" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.692734003" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" useByScannerDiscovery="false" value="../src/lscript.ld" valueType="string"/>
<option id="xilinx.gnu.c.link.option.ldflags.874339713" name="Linker Flags" superClass="xilinx.gnu.c.link.option.ldflags" useByScannerDiscovery="false" value=" -mcpu=cortex-a72" valueType="string"/>
<inputType id="xilinx.gnu.linker.input.1082738312" superClass="xilinx.gnu.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
<inputType id="xilinx.gnu.linker.input.lscript.1855100381" name="Linker Script" superClass="xilinx.gnu.linker.input.lscript"/>
</tool>
<tool id="xilinx.gnu.arm.a53.cxx.toolchain.linker.release.2088540295" name="ARM v8 g++ linker" superClass="xilinx.gnu.arm.a53.cxx.toolchain.linker.release">
<option id="xilinx.gnu.linker.inferred.swplatform.lpath.1777967811" name="Software Platform Library Path" superClass="xilinx.gnu.linker.inferred.swplatform.lpath" valueType="libPaths">
<listOptionValue builtIn="false" value="${resolvePlatformFile:project=wolfCrypt_example,fileType=bspLib}"/>
</option>
<option id="xilinx.gnu.linker.inferred.swplatform.flags.1789803383" name="Software Platform Inferred Flags" superClass="xilinx.gnu.linker.inferred.swplatform.flags" valueType="libs">
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilmailbox,-lxil,-lgcc,-lc,--end-group"/>
<listOptionValue builtIn="false" value="-Wl,--start-group,-lxilsecure,-lxil,-lgcc,-lc,--end-group"/>
</option>
<option id="xilinx.gnu.c.linker.option.lscript.380957067" name="Linker Script" superClass="xilinx.gnu.c.linker.option.lscript" value="../src/lscript.ld" valueType="string"/>
</tool>
<tool command="aarch64-none-elf-size" commandLinePattern="${COMMAND} ${FLAGS} ${INPUTS} |tee ${OUTPUT}" errorParsers="" id="xilinx.gnu.arm.a53.size.release.1766287367" name="ARM v8 Print Size" superClass="xilinx.gnu.arm.a53.size.release"/>
</toolChain>
</folderInfo>
<fileInfo id="xilinx.gnu.arm.a53.exe.release.1927748810.1106497361" name="armv8-sha256.c" rcbsApplicability="disable" resourcePath="src/wolfcrypt/src/port/arm/armv8-sha256.c" toolsToInvoke="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922.1470558356">
<tool errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922.1470558356" name="ARM v8 gcc compiler" superClass="xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922">
<option id="xilinx.gnu.compiler.option.optimization.level.1787017462" name="Optimization Level" superClass="xilinx.gnu.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.c.optimization.level.optimize" valueType="enumerated"/>
<inputType id="xilinx.gnu.arm.a53.c.compiler.input.1167653127" name="C source files" superClass="xilinx.gnu.arm.a53.c.compiler.input"/>
</tool>
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.681567385" name="Resource Custom Build Step">
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.2246108" name="Resource Custom Build Step Input Type">
<additionalInput kind="additionalinputdependency" paths=""/>
</inputType>
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1055827109" name="Resource Custom Build Step Output Type"/>
</tool>
</fileInfo>
<sourceEntries>
<entry excluding="_ide" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="wolfCrypt_example.xilinx.gnu.arm.a53.exe.1017512702" name="Xilinx ARM v8 Executable" projectType="xilinx.gnu.arm.a53.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.release.1927748810;xilinx.gnu.arm.a53.exe.release.1927748810.">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.debug.1474877702;xilinx.gnu.arm.a53.exe.debug.1474877702.">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.release.1927748810;xilinx.gnu.arm.a53.exe.release.1927748810.;xilinx.gnu.arm.a53.c.toolchain.compiler.release.1753928922;xilinx.gnu.arm.a53.c.compiler.input.299904560">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="xilinx.gnu.arm.a53.exe.debug.1474877702;xilinx.gnu.arm.a53.exe.debug.1474877702.;xilinx.gnu.arm.a53.c.toolchain.compiler.debug.513792546;xilinx.gnu.arm.a53.c.compiler.input.1551809650">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.xilinx.managedbuilder.ui.ARMA53GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/wolfCrypt_example"/>
</configuration>
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/wolfCrypt_example"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
</cproject>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="ASCII"?>
<sdkproject:SdkProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdkproject="http://www.xilinx.com/sdkproject" name="wolfCrypt_example" platformUID="xilinx:vmk180::0.0(custom)" systemProject="wolfCrypt_example_system" sysConfig="vmk180" runtime="cpp" cpu="standalone_domain" cpuInstance="versal_cips_0_pspmc_0_psv_cortexa72_0" os="standalone" mssSignature="69319cadb247104471151c20895b8098">
<configuration name="Debug" id="xilinx.gnu.arm.a53.exe.debug.1474877702" dirty="true">
<configBuildOptions xsi:type="sdkproject:SdkOptions"/>
<lastBuildOptions xsi:type="sdkproject:SdkOptions"/>
</configuration>
<configuration name="Release" id="xilinx.gnu.arm.a53.exe.release.1927748810">
<configBuildOptions xsi:type="sdkproject:SdkOptions"/>
<lastBuildOptions xsi:type="sdkproject:SdkOptions"/>
</configuration>
<template appTemplateName="empty_application"/>
</sdkproject:SdkProject>

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644" name="Debug" parent="com.xilinx.sdx.system.managedbuilder.debugConfiguration">
<folderInfo id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644." name="/" resourcePath="">
<toolChain id="com.xilinx.sdx.system.managedbuilder.debug.toolChain.1810994320" name="System Toolchain" superClass="com.xilinx.sdx.system.managedbuilder.debug.toolChain">
<targetPlatform id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644..2132586323" name=""/>
<builder buildPath="${workspace_loc:/wolfCrypt_example_system}/Debug" enableAutoBuild="true" id="com.xilinx.sdx.system.managedbuilder.systemBuilder.861022636" managedBuildOn="true" name="System Project Builder.Debug" superClass="com.xilinx.sdx.system.managedbuilder.systemBuilder"/>
<tool id="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool.1179083288" name="System Builder" superClass="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633" name="Release" parent="com.xilinx.sdx.system.managedbuilder.releaseConfiguration">
<folderInfo id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633." name="/" resourcePath="">
<toolChain id="com.xilinx.sdx.system.managedbuilder.release.toolChain.1719392334" name="System Toolchain" superClass="com.xilinx.sdx.system.managedbuilder.release.toolChain">
<targetPlatform id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633..326957413" name=""/>
<builder buildPath="${workspace_loc:/wolfCrypt_example_system}/Release" enableAutoBuild="true" id="com.xilinx.sdx.system.managedbuilder.systemBuilder.1659638366" managedBuildOn="true" name="System Project Builder.Release" superClass="com.xilinx.sdx.system.managedbuilder.systemBuilder"/>
<tool id="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool.615291826" name="System Builder" superClass="com.xilinx.sdx.system.managedbuilder.toolchain.cfjoinTool"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="wolfCrypt_example_system.com.xilinx.sdx.system.managedbuilder.projectType.1223839149" name="Vitis Embedded System Project" projectType="com.xilinx.sdx.system.managedbuilder.projectType"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="refreshScope"/>
</cproject>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>wolfCrypt_example_system</name>
<comment></comment>
<projects>
<project>wolfCrypt_example</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.xilinx.sdx.system.core.embedded</nature>
<nature>com.xilinx.sdx.system.systemprojectnature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="ASCII"?>
<systemproject:SystemProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdkproject="http://www.xilinx.com/sdkproject" xmlns:systemproject="http://www.xilinx.com/systemproject" name="wolfCrypt_example_system" platformUID="xilinx:vmk180::0.0(custom)" sysConfig="vmk180" runtime="cpp" dimmRepoPath="" rootFSLocation="" linuxImage="" sysroot="">
<configuration name="Debug" id="com.xilinx.sdx.system.managedbuilder.debugConfiguration.750862644">
<configBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_example" domainName="standalone_domain" domainPrettyName="standalone on versal_cips_0_pspmc_0_psv_cortexa72_0" appBuildConfig="Debug"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</configBuildOptions>
<lastBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_example" domainName="standalone_domain" domainPrettyName="standalone on versal_cips_0_pspmc_0_psv_cortexa72_0" appBuildConfig="Debug"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</lastBuildOptions>
</configuration>
<configuration name="Release" id="com.xilinx.sdx.system.managedbuilder.releaseConfiguration.687928633">
<configBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_example" domainName="standalone_psv_cortexa72_0" domainPrettyName="standalone_psv_cortexa72_0" appBuildConfig="Release"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</configBuildOptions>
<lastBuildOptions xsi:type="systemproject:SystemOptions">
<applications name="wolfCrypt_example" domainName="standalone_psv_cortexa72_0" domainPrettyName="standalone_psv_cortexa72_0" appBuildConfig="Release"/>
<options xsi:type="sdkproject:SdkOptions" generateSdCard="true"/>
</lastBuildOptions>
</configuration>
</systemproject:SystemProject>

View File

@ -1,6 +1,6 @@
# Common Gotcha's
- If compiling all code together (ie no separate wolfssl library) than the -fPIC compiler flag should be used. Without using -fPIC in this build setup there could be unexpected failures.
- If compiling all code together (ie no separate wolfssl library) then the -fPIC compiler flag should be used. Without using -fPIC in this build setup there could be unexpected failures.
- If building with ARMv8 crypto extensions then the compiler flags "-mstrict-align -mcpu=generic+crypto" must be used.
- Check that enough stack and heap memory is set for the operations if a crash or stall happens.
@ -30,6 +30,82 @@ To use this example project:
7. Select the root directory of `wolfssl/IDE/XilinxSDK/2019_2`, and select `wolfCrypt_example` and `wolfCrypt_example_system`. Then click "Finish"
# Detailed Instructions For Example Use With Vitis 2022.1
This shows the necessary steps on the basis of using the VMK180 development board.
1. Create a new workspace located in the directory `wolfssl/IDE/XilinxSDK/2022_1`.
2. Create a new platform project.
- On the welcome screen select "Create platform project".
- Give it a good name, e.g. `vmk180` and click 'Next'.
- In the Hardware Specification drop-down menu select "vmk180" and click 'Finish'.
3. Enable the necessary libraries in the bsp.
- Open `platform.spr` in the 'vmk180' platform project.
- In the tree-view select "Board Support Package" and click on "Modify BSP Settings...".
- Enable the `xilmailbox` and `xilsecure` libraries.
- In this tree-view on the left side under "Overview->standalone" appeared now a "xilsecure" entry.
- Select "xilsecure" and change the configuration of `cache_disable` to `false`. Press 'OK' to confirm the change.
- Build the platform project, either via "Project->Build All" or by the keyboard shortcut 'CTRL+b'.
4. Import the wolfcrypt example projects "File->Import->Eclipse workspace or zip file".
- Behind 'Select Root directory' click on 'Browse...'. You should already be in the correct directory, but still make sure that you're in `wolfssl/IDE/XilinxSDK/2022_1/`. Click 'Open'.
- Uncheck "Copy projects into workspace".
- Select the two example projects `wolfCrypt_example` and `wolfCrypt_example_system`, then click 'Finish'.
5. Fix the missing link from platform project and system project.
- In the 'Explorer' Window open the `wolfCrypt_example_system` and double-click `wolfCrypt_example_system.prj`.
- You should normally see a pop-up with the title "Platform invalid". Click on "Change referred platform", select your platform and click 'OK'.
- In case you didn't see the pop-up, you should see the 'System Project Settings'. Click on the `...` behind 'Platform', select your platform and click 'OK'.
- Vitis will now remind you that all build configurations will be cleaned, click 'Yes'.
6. Create a new linker script
- In the 'Explorer' Window open the `wolfCrypt_example_system` and right-click on the `wolfCrypt_example` project. Click 'Generate Linker Script'.
- Configure the memory sections you want to use, the default should be OK for this example.
- 'Heap Size' must be increased according to your use case. For this example to run it is sufficient to increase to `8 MB`. For benchmarks with big chunk sizes increase to `512 MB`.
- Increase 'Stack Size' to `32 KB`.
- Click 'Generate'
## FreeRTOS based example projects
1. In the previously created `vmk180` platform, one can see a tree where you can also find the "Board support package" settings.
- Click on the bold green `+` on the top to 'Add Domain'.
- Give the new domain the name "freertos" and change the "OS" in the drop-down menu to "freertos".
2. Repeat the same steps of the previous step 3 for the newly created domain.
- In the tree-view select "freertos10_xilinx" and then open the "kernel_behavior" sub-entry.
- Change `minimal_stack_size` to `8000`, `tick_rate` to `1000` and `total_heap_size` to `8388608`. "Big chunk sizes" have not been tested under FreeRTOS.
3. Repeat the same steps of the preivous steps 4 to 6, but with the `wolfCrypt_FreeRTOS_example` resp. `wolfCrypt_FreeRTOS_example_system`.
## Troubleshooting
* `make: *** No rule to make target '../src/lscript.ld', needed by 'wolfCrypt_example.elf'. Stop.`: You forgot to create the linker script
* `/path/to/wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h:30:10: fatal error: xsecure_mailbox.h: No such file or directory`: You forgot to add the `xilmailbox` and/or `xilsecure` libraries.
* `/path/to/wolfssl/wolfcrypt/src/port/xilinx/xil-aesgcm.c:90: undefined reference to 'Secure_AesInitialize'` (and others): You forgot to build the platform project after adding the libraries.
## Code formatter
In case one wants to write code in "wolfSSL style" in Vitis:
- go to "Window->Preferences->Additional->C/C++->Code Style->Formatter".
- Click on 'Import', navigate to `wolfssl/IDE/XilinxSDK/` and select the file `eclipse_formatter_profile.xml`, click on 'Apply and Close'.
## Configuration
All configuration is done through the header file in `wolfssl/IDE/XilinxSDK/user_settings.h`
### Build flavors
Define `WOLFSSL_XILINX_CRYPT` to enable the **crypto engines**. (This is the default)
Undefine `WOLFSSL_XILINX_CRYPT` and define `WOLFSSL_ARMASM` to enable the **ARMv8 Cryptographic Extensions**.
Undefine both `WOLFSSL_XILINX_CRYPT` and `WOLFSSL_ARMASM` to enable a **software-only build**.
### Further features
Define `WC_XIL_AESGCM_DPA_CM` to enable Counter Measures for Differential Power Analysis of the AES-GCM core. (Only available when using the crypto engines).
Undefine `HAVE_HASHDRBG` to enable usage of the DRBG in the crypto engine.
Define `WOLFSSL_ECDSA_DETERMINISTIC_K` to use "deterministic K" as of RFC6979. (Supported for all three build flavors).
# Steps For Creating Project From Scratch
1. Create a new workspace

76
IDE/XilinxSDK/bench.sh Executable file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Parametrisation to this script is as follows:
# * The first argument will be taken as suffix to the result folder
# e.g. `./bench.sh _config0`
# * It is possible to make its output a bit more verbose by setting
# the `VERBOSE` environment variable to '1', e.g. via
# `VERBOSE=1 ./bench.sh` or to make it quiet by setting it to '0'
# * Per default we read from /dev/ttyUSB2, by setting the `WC_TTY`
# environment variable this can adapted
# e.g. `WC_TTY=/dev/ttyACM0 ./bench.sh`
###
# Preamble
###
readonly my_path=$(dirname $(readlink -f $0))
readonly csv_path_suffix="$1"
readonly common_opts="-blocks 128"
readonly ccm_gcm_opts="-all_aad -aad_size 13"
# options used in `small_block()`
readonly cbc_opts="$common_opts"
readonly ccm_opts="$common_opts $ccm_gcm_opts"
readonly gcm_opts="$common_opts $ccm_gcm_opts"
readonly small_block_ciphers="cbc ccm gcm"
readonly small_block_ciphers_hw="gcm"
readonly small_block_sizes="16 528 1024 4112 7696 15888 32768 65536 131072"
# options used in `large_block()`
readonly ccm_fast_opts="$common_opts -all_aad"
readonly gcm_fast_opts="$common_opts -all_aad"
# 512 MiB transfer, 128 MiB max. blocksize
readonly large_block_ciphers="gcm"
readonly large_num_bytes=$((512 * 1024 * 1024))
readonly large_max_blocksize=$((128 * 1024 * 1024))
source "$my_path"/../../scripts/bench/bench_functions.sh
###
# Implementation
###
[ "$1" == "_HW" ] && small_block "$small_block_ciphers_hw" \
|| small_block "$small_block_ciphers"
# No large blocksizes for analysis
#[ "$1" == "_HW" ] && large_block
# Benchmark only on HW and SW
if [ "$1" != "_ARMv8" ]; then
bench "ecc" "-ecc -ecc-all -ecc-kg"
bench "sha3" "-sha3-384"
for keysize in 2048 3072 4096
do
bench "rsa" "-rsa-sz -rsa-kg $keysize" "_$keysize"
done
bench "rng" "-rng"
fi
# Benchmark only on ARMv8 and SW
if [ "$1" != "_HW" ]; then
bench "sha2" "-sha2"
bench "cmac" "-cmac"
fi
#eof

81
IDE/XilinxSDK/combine.sh Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Parametrisation to this script is as follows:
# * none yet
###
# Preamble
###
readonly my_path="$(dirname $(readlink -f $0))"
readonly csv_path="$my_path/data"
function cleanup() {
echo OK
}
trap cleanup EXIT
function error_out() {
exit 1
}
trap error_out INT TERM
###
# Functions
###
###
# Implementation
###
readonly configs=$(find $csv_path -maxdepth 1 -type d -name '*results_*' | sed 's@.*results_@@g')
declare -A algos
algos["asym"]="ecc rsa"
algos["hashes"]="sha2 sha3"
algos["mac"]="cmac"
algos["rng"]="rng"
algos["sym"]="cbc ccm gcm"
declare -A headers
headers["asym"]="config,keysize_2,algorithm,keysize,operation,avg ms,ops/sec,"
headers["hashes"]="config,unused,algorithm,MiB/s,"
headers["mac"]="config,unused,algorithm,keysize,MiB/s,"
headers["rng"]="config,unused,algorithm,MiB/s,"
headers["sym"]="config,chunksize,algorithm,blocksize,direction,AAD,MiB/s,"
# "... now you have two problems"
declare -A filters
filters["ccm"]="-e s/-\(enc\|dec\)-\(no_AAD\|custom\)/,128,\1,\2/g -e s/-\(enc\|dec\),/,128,\1,,/g"
filters["gcm"]="-e /-192-/d -e /GMAC/d -e s/-\(enc\|dec\)-\(no_AAD\|custom\)/,\1,\2/g -e s/-\(enc\|dec\),/,\1,default,/g -e s/\(128\|256\)-GCM/GCM,\1/g"
filters["cbc"]="-e /-192-/d -e s/-\(enc\|dec\),/,\1,,/g -e s/\(128\|256\)-CBC/CBC,\1/g"
filters["cmac"]="-e s/\(128\|256\)-CMAC/CMAC,\1/g"
filters["ecc"]='-e 1!{/SECP384R1\|SECP521R1/!d}'
filters["sha2"]="-e s/SHA-/SHA2-/g"
for t in ${!algos[@]}
do
for algo in ${algos[$t]}
do
outfile="$csv_path/combined_${algo}.csv"
echo ${headers[$t]} > "$outfile"
for cfg in $configs
do
for f in $(find $csv_path/results_${cfg} -name "*${algo}*.csv" | sort -V)
do
sz=$(basename $f | sed -e s/${algo}// -e s/_// -e s/\.csv//)
sz=",$sz"
for l in $(tail -n +2 $f | tr -d ' ')
do
echo "${cfg}${sz},${l}" >> "$outfile"
done
[ "${filters[$algo]}" == "" ] || sed -i "$outfile" ${filters[$algo]}
done
echo $algo $t $cfg
done
done
done

View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="1">
<profile kind="CodeFormatterProfile" name="wolfssl" version="1">
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_binary_expression" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="next_line_shifted"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_switch" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_member_access" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="82"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_declarator_list" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expression_list" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_enumerator_list" value="51"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
</profile>
</profiles>

327
IDE/XilinxSDK/graph.sh Executable file
View File

@ -0,0 +1,327 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Parametrisation to this script is as follows:
# * none yet
###
# Preamble
###
readonly my_path="$(dirname $(readlink -f $0))"
readonly csv_path="$my_path/data"
readonly log_path="$csv_path/logs"
readonly img_path="$csv_path/images"
readonly gnuplot_terminal="svg enhanced background rgb 'white' size 800 600"
mkdir -p "$log_path"
mkdir -p "$img_path"
function cleanup() {
echo OK
}
trap cleanup EXIT
function error_out() {
exit 1
}
trap error_out INT TERM
###
# Functions
###
function cg() {
csvgrep -c $1 -r $2 $3
}
###
# Implementation
###
readonly desc_block_ciphers="Benchmarks were done with growing sample size and averaging over\nprocessing of 128 samples of said sample size"
readonly desc_asymmetric="Benchmarks were done with averaging over\nas many repetitions possible of the benchmarked operation in 1s"
readonly desc_others="Benchmarks were done with 1MiB block size and averaging over\nas many repetitions possible of processing 5MiB data in 1s"
readonly configs=$(find $csv_path -type d -name '*results*' | sed 's@.*results_@@g')
###
# Symmetric crypto
readonly sym="cbc ccm gcm"
declare -A directions
directions["dec"]="decryption"
directions["enc"]="encryption"
declare -A aad_sizes
aad_sizes["no_AAD"]="0 Bytes"
aad_sizes["custom"]="13 Bytes"
aad_sizes["default"]="16 Bytes"
# not pretty but works for me :)
# CBC&GCM encryption is in software a lot faster than decryption,
# therefor use the same Range on the Y-Axis to also have a visual indication.
# This will break if something changes, so let the user override the value
cbc_yrange="${cbc_yrange:=1400}"
gcm_yrange="${gcm_yrange:=500}"
for mode in $sym
do
infile="$csv_path/combined_${mode}.csv"
for dir in ${!directions[@]}
do
plotstring=
more_style=
for cfg in $configs
do
for bsize in $(csvcut -c blocksize $infile | tail -n +2 | sort -u)
do
if [ "$mode" == "cbc" ]; then
outfile=$log_path/${mode}${bsize}_${cfg}_${dir}.log
val="$(cg config $cfg $infile | cg blocksize $bsize | cg direction $dir | csvcut -c chunksize,MiB/s | tail -n +2 | tr ',' ' ')"
if [ "$val" != "" ]; then
echo "$val" > $outfile
[ -z "$plotstring" ] && plotstring="plot" || plotstring="${plotstring},"
plotstring="${plotstring} '"$outfile"' smooth bezier title \"$cfg AES$bsize\""
fi
[ "$mode" == "cbc" -a "$cbc_yrange" != "" ] && more_style="set yrange [ 0 : $cbc_yrange ]"
else
for aad in ${!aad_sizes[@]}
do
outfile=$log_path/${mode}${bsize}_${cfg}_${dir}_${aad}.log
val="$(cg config $cfg $infile | cg blocksize $bsize | cg direction $dir | cg AAD $aad | csvcut -c chunksize,MiB/s | tail -n +2 | tr ',' ' ')"
if [ "$val" != "" ]; then
echo "$val" > $outfile
[ -z "$plotstring" ] && plotstring="plot" || plotstring="${plotstring},"
plotstring="${plotstring} '"$outfile"' smooth bezier title \"$cfg AES$bsize ${aad_sizes[$aad]} AAD\""
fi
done
[ "$mode" == "gcm" -a "$gcm_yrange" != "" ] && more_style="set yrange [ 0 : $gcm_yrange ]"
fi
done
done
modep=${mode^^}
gnuplot << EOF
set terminal $gnuplot_terminal
set title "${modep} ${directions[${dir}]} on Xilinx Versal"
set x2label "${desc_block_ciphers}"
set xlabel "Sample size"
set ylabel "MiB/s"
set style data lines
$more_style
set output "${img_path}/${mode}_${dir}.${gnuplot_terminal%% *}"
$plotstring
EOF
done
done
###
# Also create separate graphs for AES-GCM-128 and -256 since that's too many lines in one image
for mode in gcm
do
infile="$csv_path/combined_${mode}.csv"
for dir in ${!directions[@]}
do
for bsize in $(csvcut -c blocksize $infile | tail -n +2 | sort -u)
do
plotstring=
more_style="set yrange [ 0 : $gcm_yrange ]"
for cfg in $configs
do
for aad in ${!aad_sizes[@]}
do
outfile=$log_path/${mode}${bsize}_${cfg}_${dir}_${aad}.log
val="$(cg config $cfg $infile | cg blocksize $bsize | cg direction $dir | cg AAD $aad | csvcut -c chunksize,MiB/s | tail -n +2 | tr ',' ' ')"
if [ "$val" != "" ]; then
echo "$val" > $outfile
[ -z "$plotstring" ] && plotstring="plot" || plotstring="${plotstring},"
plotstring="${plotstring} '"$outfile"' smooth bezier title \"$cfg AES$bsize ${aad_sizes[$aad]} AAD\""
fi
done
done
modep=${mode^^}
gnuplot << EOF
set terminal $gnuplot_terminal
set title "${modep}-${bsize} ${directions[${dir}]} on Xilinx Versal"
set x2label "${desc_block_ciphers}"
set xlabel "Sample size"
set ylabel "MiB/s"
set style data lines
$more_style
set output "${img_path}/${mode}${bsize}_${dir}.${gnuplot_terminal%% *}"
$plotstring
EOF
done
done
done
###
# Asymmetric crypto
declare -A asym_operations
asym_operations["ecc"]="keygen agree sign verify"
asym_operations["rsa"]="keygen public private"
for algo in ${!asym_operations[@]}
do
infile="$csv_path/combined_${algo}.csv"
for op in ${asym_operations[$algo]}
do
outfile=$log_path/${algo}_${op}.log
echo -n "" > $outfile
for ksize in $(csvcut -c keysize $infile | tail -n +2 | sort -u)
do
for cfg in $configs
do
h="${algo^^}-$ksize"
v=$(cg config $cfg $infile | cg operation $op | cg keysize $ksize | csvcut -c "avg ms" | tail -n +2 | tr ',' ' ')
[ "$v" != "" ] && echo "$h\n$cfg $v" >> $outfile
done
done
algop=${algo^^}
gnuplot << EOF
set terminal $gnuplot_terminal
set title "${algop} ${op} on Xilinx Versal"
set x2label "${desc_asymmetric}"
set xlabel 'Configurations' offset 0,-1
set ylabel "ms per op"
set style fill solid
set style line 1 lc rgb "grey50"
set boxwidth 0.5
unset key
set output "${img_path}/${algo}_${op}.${gnuplot_terminal%% *}"
plot "$outfile" using :2:xtic(1) with boxes ls 1, \
'' using :2:2 w labels offset 0,0.7
EOF
done
done
###
# Hashes
declare -A hash_sizes
hash_sizes["sha2"]="224 256 384 512"
hash_sizes["sha3"]="384"
plotstring=
outfile=$log_path/sha.log
echo -n "" > $outfile
for algo in ${!hash_sizes[@]}
do
infile="$csv_path/combined_${algo}.csv"
for hsize in ${hash_sizes[$algo]}
do
for cfg in $configs
do
h="${algo^^}-$hsize"
v=$(cg config $cfg $infile | cg algorithm $h | csvcut -c MiB/s | tail -n +2 | sed 's@\..*$@@')
[ "$v" != "" ] && echo "$h\n$cfg $v" >> $outfile
done
echo >> $outfile
done
done
gnuplot << EOF
set terminal $gnuplot_terminal
set title "SHA2/SHA3 on Xilinx Versal"
set x2label "${desc_others}"
set xlabel 'Configurations' offset 0,-1
set ylabel "MiB/s"
set style fill solid
set style line 1 lc rgb "grey50"
set boxwidth 0.5
unset key
set output "${img_path}/sha.${gnuplot_terminal%% *}"
plot "$outfile" using :2:xtic(1) with boxes ls 1, \
'' using :2:2 w labels offset 0,0.7
EOF
###
# MACs
declare -A macs
macs["cmac"]="128 256"
plotstring=
outfile=$log_path/mac.log
echo -n "" > $outfile
for algo in ${!macs[@]}
do
infile="$csv_path/combined_${algo}.csv"
for hsize in ${macs[$algo]}
do
for cfg in $configs
do
h="${algo^^}-$hsize"
v=$(cg config $cfg $infile | cg keysize $hsize | csvcut -c MiB/s | tail -n +2 | sed 's@\..*$@@')
[ "$v" != "" ] && echo "$h\n$cfg $v" >> $outfile
done
echo >> $outfile
done
done
gnuplot << EOF
set terminal $gnuplot_terminal
set title "MAC's on Xilinx Versal"
set x2label "${desc_others}"
set xlabel 'Configurations' offset 0,-1
set ylabel "MiB/s"
set style fill solid
set style line 1 lc rgb "grey50"
set boxwidth 0.5
unset key
set yrange [ 0 : 500 ]
set output "${img_path}/mac.${gnuplot_terminal%% *}"
plot "$outfile" using :2:xtic(1) with boxes ls 1, \
'' using :2:2 w labels offset 0,0.7
EOF
###
# RNG
plotstring=
outfile=$log_path/rng.log
echo -n "" > $outfile
for algo in rng
do
infile="$csv_path/combined_${algo}.csv"
for cfg in $configs
do
h="${algo^^}"
v=$(cg config $cfg $infile | csvcut -c MiB/s | tail -n +2 | sed 's@\..*$@@')
[ "$v" != "" ] && echo "$h\n$cfg $v" >> $outfile
done
echo >> $outfile
done
gnuplot << EOF
set terminal $gnuplot_terminal
set title "RNG on Xilinx Versal"
set x2label "${desc_others}"
set xlabel 'Configurations' offset 0,-1
set ylabel "MiB/s"
set style fill solid
set style line 1 lc rgb "grey50"
set boxwidth 0.5
unset key
set yrange [ 0 : 50 ]
with_unit(Value,Unit) = sprintf("%d %s", Value, Unit)
set output "${img_path}/rng.${gnuplot_terminal%% *}"
plot "$outfile" using :2:xtic(1) with boxes ls 1, \
'' using :2:2 w labels offset 0,0.7
EOF
#eof

View File

@ -3,6 +3,10 @@
# All paths should be given relative to the root
EXTRA_DIST+= IDE/XilinxSDK/README.md
EXTRA_DIST+= IDE/XilinxSDK/bench.sh
EXTRA_DIST+= IDE/XilinxSDK/combine.sh
EXTRA_DIST+= IDE/XilinxSDK/eclipse_formatter_profile.xml
EXTRA_DIST+= IDE/XilinxSDK/graph.sh
EXTRA_DIST+= IDE/XilinxSDK/user_settings.h
EXTRA_DIST+= IDE/XilinxSDK/wolfssl_example.c
EXTRA_DIST+= IDE/XilinxSDK/2018_2/lscript.ld
@ -14,3 +18,10 @@ EXTRA_DIST+= IDE/XilinxSDK/2019_2/wolfCrypt_example/src/lscript.ld
EXTRA_DIST+= IDE/XilinxSDK/2019_2/wolfCrypt_example_system/.cproject
EXTRA_DIST+= IDE/XilinxSDK/2019_2/wolfCrypt_example_system/.project
EXTRA_DIST+= IDE/XilinxSDK/2019_2/wolfCrypt_example_system/wolfCrypt_example_system.sprj
EXTRA_DIST+= IDE/XilinxSDK/2022_1/.gitignore
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example/.cproject
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example/.project
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example/wolfCrypt_example.prj
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example_system/.cproject
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example_system/.project
EXTRA_DIST+= IDE/XilinxSDK/2022_1/wolfCrypt_example_system/wolfCrypt_example_system.sprj

View File

@ -23,32 +23,41 @@
* user_settings.h
*
* Created on: Mar 20, 2020
* Generated using:
* Generated using:
* ./configure --enable-cryptonly --enable-armasm --enable-ecc --enable-aesgcm --enable-pwdbased --enable-sp --enable-sp-asm \
* --disable-dh --disable-sha --disable-md5 --disable-sha224 --disable-aescbc --disable-shake256
* --disable-dh --disable-sha --disable-md5 --disable-sha224 --disable-aescbc --disable-shake256
* Result: wolfssl/options.h
*/
#ifndef SRC_USER_SETTINGS_H_
#define SRC_USER_SETTINGS_H_
#include <xparameters.h>
/* Disable all TLS support, only wolfCrypt features */
#define WOLFCRYPT_ONLY
/* Xilinx SDK */
#define WOLFSSL_XILINX
#define WOLFSSL_XILINX_CRYPT
#if defined(versal) && defined(WOLFSSL_XILINX_CRYPT)
#define WOLFSSL_XILINX_CRYPT_VERSAL
#endif
#ifndef FREERTOS
#define SINGLE_THREADED
#endif
#define NO_FILESYSTEM
#define HAVE_UINTPTR_T
/* Platform - remap printf */
#include "xil_printf.h"
#define XPRINTF xil_printf
#if !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* Enable ARMv8 (Aarch64) assembly speedups - SHA256 / AESGCM */
/* Note: Requires CFLAGS="-mcpu=generic+crypto -mstrict-align" */
#define WOLFSSL_ARMASM
#endif
/* Math */
#define USE_FAST_MATH
@ -61,20 +70,47 @@
#define WOLFSSL_HAVE_SP_ECC
#define WOLFSSL_HAVE_SP_RSA
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* Random: HashDRGB / P-RNG (SHA256) */
/* Versal supports both, with and w/o software-based HashDRGB.
* It's your choice */
#define HAVE_HASHDRBG
#define WOLFSSL_PSV_TRNG_DEV_ID XPAR_VERSAL_CIPS_0_PSPMC_0_PSV_PMC_TRNG_DEVICE_ID
#if !defined(HAVE_HASHDRBG)
#define CUSTOM_RAND_GENERATE_BLOCK wc_VersalTrngGenerate
#else
#define CUSTOM_RAND_GENERATE_SEED wc_VersalTrngGenerate
#endif
#else
/* If we don't use the Versal Crypto we need the HASHDRBG */
#define HAVE_HASHDRBG
extern unsigned char my_rng_seed_gen(void);
#define CUSTOM_RAND_GENERATE my_rng_seed_gen
#endif
/* Timing Resistance */
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
//#define WC_XIL_AESGCM_DPA_CM
/* ECC */
#define HAVE_ECC
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#define ECC_USER_CURVES
#define NO_ECC256
#define WOLFSSL_SP_NO_256
#define HAVE_ECC384
#define WOLFSSL_SP_384
#define HAVE_ECC521
#define WOLFSSL_SP_521
/* Versal also supports usage of RFC6979 if you want to */
//#define WOLFSSL_ECDSA_DETERMINISTIC_K
#else
#define TFM_ECC256
#define ECC_SHAMIR
#endif
/* DH */
#undef NO_DH
@ -94,15 +130,21 @@ extern unsigned char my_rng_seed_gen(void);
#define HAVE_CHACHA
#define HAVE_POLY1305
/* AES-GCM Only */
#define NO_AES_CBC
/* AES-CBC is enabled by default if not disabled
* The others have to be enabled */
#define HAVE_AESCCM
#define HAVE_AESGCM
#define WOLFSSL_AES_DIRECT
#define WOLFSSL_CMAC
/* Hashing */
#define WOLFSSL_SHA512
#define WOLFSSL_SHA384
#define WOLFSSL_SHA224
#define WOLFSSL_SHA3
#define WOLFSSL_NO_HASH_RAW /* not supported with ARMASM */
#define WOLFSSL_NO_SHAKE128
#define WOLFSSL_NO_SHAKE256
/* HKDF */
#define HAVE_HKDF
@ -118,8 +160,12 @@ extern unsigned char my_rng_seed_gen(void);
/* Other */
#define WOLFSSL_IGNORE_FILE_WARN /* Ignore file include warnings */
#define NO_MAIN_DRIVER /* User supplied "main" entry point */
#define BENCH_EMBEDDED /* Use smaller buffers for benchmarking */
#define NO_MAIN_FUNCTION /* User supplied "main" entry point */
//#define BENCH_EMBEDDED /* Use smaller buffers for benchmarking */
#define WOLFSSL_KEY_GEN
/* Pre-define AAD size to 16 for benchmarks. When executing the benchmarks we
* also use a custom size of 13 to measure "the default size". */
#define AES_AUTH_ADD_SZ 16
/* Test with "wolfssl/certs_test.h" buffers - no file system */
#define USE_CERT_BUFFERS_256
@ -127,7 +173,7 @@ extern unsigned char my_rng_seed_gen(void);
/* Debugging */
#if 0
#define DEBUG_WOLFSSL
#define DEBUG_WOLFSSL
#endif
#endif /* SRC_USER_SETTINGS_H_ */

View File

@ -48,26 +48,31 @@
/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/
typedef struct func_args {
int argc;
char** argv;
int return_code;
typedef struct func_args
{
int argc;
char **argv;
int return_code;
} func_args;
const char menu1[] = "\n"
"\tt. WolfCrypt Test\n"
"\tb. WolfCrypt Benchmark\n";
"\tb. WolfCrypt Benchmark\n"
"\tt. WolfCrypt Test\n"
"\n"
"\tc. Command mode\n";
/*****************************************************************************
* Private functions
****************************************************************************/
#if !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* Test RNG Seed Function */
/* TODO: Must provide real seed to RNG */
unsigned char my_rng_seed_gen(void)
{
static unsigned int kTestSeed = 1;
return kTestSeed++;
static unsigned int kTestSeed = 1;
return kTestSeed++;
}
#endif
/*****************************************************************************
* Public functions
@ -79,6 +84,8 @@ static TaskHandle_t xWolfsslTask;
int main( void )
{
xil_printf("\nStarting up FreeRTOS\n");
xTaskCreate(wolfssl_task, /* The function that implements the task. */
(const char*) "Tx", /* Text name for the task, provided to assist debugging only. */
configMINIMAL_STACK_SIZE, /* The stack allocated to the task. */
@ -103,8 +110,12 @@ static void wolfssl_task( void *pvParameters )
int main()
#endif
{
uint8_t cmd;
func_args args;
uint8_t cmd[128], c;
char *arg[sizeof(cmd)/2 + 1];
size_t cmdlen, argnum, n;
func_args args;
int (*func)(int argc, char** argv);
int command_mode = 0;
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
@ -117,38 +128,87 @@ int main()
memset(&args, 0, sizeof(args));
args.return_code = NOT_COMPILED_IN; /* default */
xil_printf("\n\t\t\t\tMENU\n");
xil_printf(menu1);
xil_printf("Please select one of the above options:\n");
if (!command_mode) {
xil_printf("\n\t\t\t\tMENU\n");
xil_printf(menu1);
xil_printf("Please select one of the above options:\n");
xil_printf("Both 'b' and 't' allow arguments as if you'd call the regular shell version.\n");
}
cmdlen = 0;
do {
cmd = inbyte();
} while (cmd == '\n' || cmd == '\r');
c = inbyte();
cmd[cmdlen] = c;
if (!command_mode) outbyte(c);
cmdlen++;
cmdlen %= sizeof(cmd);
} while (c != '\n' && c != '\r');
switch (cmd) {
case 't':
xil_printf("Running wolfCrypt Tests...\n");
#ifndef NO_CRYPT_TEST
args.return_code = 0;
wolfcrypt_test(&args);
#endif
xil_printf("Crypt Test: Return code %d\n", args.return_code);
break;
if (cmdlen > 2) {
outbyte('\n');
/* Poor man's argv parser */
XMEMSET(arg, 0, sizeof(arg));
if (cmd[1] == ' ') {
if (cmd[0] == 'b') {
arg[0] = "wolfcrypt_benchmark";
func = wolfcrypt_benchmark_main;
} else if (cmd[0] == 't') {
arg[0] = "wolfcrypt_test";
func = wolfcrypt_test_main;
}
if (arg[0] != NULL) {
argnum = 1;
for (n = 2; n < cmdlen; ++n) {
switch (cmd[n]) {
case ' ':
case '\t':
case '\r':
case '\n':
cmd[n] = '\0';
if (arg[argnum] != NULL)
argnum++;
break;
default:
if (arg[argnum] == NULL)
arg[argnum] = (char*)&cmd[n];
break;
}
}
func(argnum, arg);
}
}
} else {
switch (cmd[0]) {
case 't':
xil_printf("Running wolfCrypt Tests...\n");
#ifndef NO_CRYPT_TEST
args.return_code = 0;
wolfcrypt_test(&args);
#endif
xil_printf("Crypt Test: Return code %d\n", args.return_code);
break;
case 'b':
xil_printf("Running wolfCrypt Benchmarks...\n");
#ifndef NO_CRYPT_BENCHMARK
args.return_code = 0;
benchmark_test(&args);
#endif
xil_printf("Benchmark Test: Return code %d\n", args.return_code);
break;
case 'b':
xil_printf("Running wolfCrypt Benchmarks...\n");
#ifndef NO_CRYPT_BENCHMARK
args.return_code = 0;
benchmark_test(&args);
#endif
xil_printf("Benchmark Test: Return code %d\n", args.return_code);
break;
default:
xil_printf("\nSelection out of range\n");
break;
}
}
case 'c':
if (!command_mode) xil_printf("Entering command mode, enter 'c<enter>' to return to manual mode\n");
command_mode ^= 1;
break;
default:
if (!command_mode) xil_printf("\nSelection out of range\n");
break;
}
}
}
wolfCrypt_Cleanup();
#ifndef FREERTOS

137
scripts/bench/bench_functions.sh Executable file
View File

@ -0,0 +1,137 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Parametrisation to this script is as follows:
# * `my_path` MUST be set
# * `WC_TTY` can be set to override the default '/dev/ttyUSB2'
# * `csv_path_suffix` can be set to add a suffix to the output path
# * `VERBOSE` can be set to '0' to suppress all output
# or '1' to make the output more verbose
###
# Preamble
###
if (return 0 2>/dev/null); then
[ "$my_path" != "" ] || { echo "\$my_path must not be empty"; return 1; }
else
echo "This script shall only be sourced"
exit 1
fi
readonly tty="${WC_TTY:-/dev/ttyUSB2}"
readonly fifo="$(mktemp -u)"
readonly csv_path="${my_path}/data/results${csv_path_suffix}"
function status_echo() {
[ "$VERBOSE" = "0" ] || echo "$*"
}
function cleanup() {
wait
rm $fifo
}
mkfifo $fifo
trap cleanup EXIT
function error_out() {
exit 1
}
trap error_out INT TERM
mkdir -p $csv_path
status_echo "Writing to folder: $csv_path"
status_echo "Reading from TTY: $tty"
###
# Functions
###
function read_tty() {
while true; do
read -r l
$1 "$l"
$read_tty_ret
done < $tty
}
function wait_until_finished() {
while true; do
read -r ret
[ "$ret" == "finished" ] && break
done < $fifo
}
function process_csv() {
read_tty_ret=
case "$csv_state" in
"0")
case "$1" in
"Algorithm,MB/s,Cycles per byte," | \
"Algorithm,key size,operation,avg ms,ops/sec,")
echo "$1" > $csv
csv_state=1
;;
esac
;;
"1")
if [ "$1" != "Benchmark complete" ]; then
echo "$1" >> $csv
[ "$VERBOSE" = "1" ] && echo "$1"
else
echo "finished" > $fifo
read_tty_ret=return
fi
;;
esac
}
function csv_start() {
csv_state=0
csv=$csv_path/$1
read_tty process_csv &
}
function bench() {
status_echo "Benchmark ${1^^}$3"
csv_start ${1}${3}.csv
echo "b $2 -csv" > $tty
wait_until_finished
}
###
# Implementation
###
function small_block() {
for blocksize in $small_block_sizes
do
status_echo "Benchmark with $blocksize bytes sized blocks"
for mode in $1
do
local opts=${mode}_opts
bench "${mode}" "-aes-${mode} $blocksize ${!opts}" "_${blocksize}"
done
done
}
function large_block() {
# 1 MiB
local blocksize=$((1024 * 1024))
while [ $blocksize -lt $large_max_blocksize ]
do
local num_blocks=$(($large_num_bytes / $blocksize))
status_echo "Benchmark with $blocksize bytes sized blocks"
for mode in $large_block_ciphers
do
local opts=${mode}_fast_opts
bench "${mode}" "-aes-${mode} ${!opts} $blocksize -blocks $num_blocks" "_${blocksize}"
done
blocksize=$(($blocksize * 2))
done
}
#eof

View File

@ -118,3 +118,5 @@ if BUILD_DTLS13
EXTRA_DIST += scripts/dtls13.test
EXTRA_DIST += scripts/dtlscid.test
endif
EXTRA_DIST += scripts/bench/bench_functions.sh

View File

@ -197,6 +197,10 @@ ECC Curve Sizes:
#include <wolfssl/wolfcrypt/port/nxp/se050_port.h>
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <xsecure_ellipticclient.h>
#endif
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \
defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
#include <wolfssl/wolfcrypt/hmac.h>
@ -221,6 +225,9 @@ ECC Curve Sizes:
/* forward declarations */
static int wc_ecc_new_point_ex(ecc_point** point, void* heap);
static void wc_ecc_del_point_ex(ecc_point* p, void* heap);
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
static int deterministic_sign_helper(const byte* in, word32 inlen, ecc_key* key);
#endif
/* internal ECC states */
enum {
@ -1324,6 +1331,52 @@ enum ecc_curve_load_mask {
#endif
};
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
static const u32 xil_curve_type[ECC_CURVE_MAX] = {
[ECC_SECP384R1] = WOLFSSL_XSECURE_ECC_NIST_P384,
[ECC_SECP521R1] = WOLFSSL_XSECURE_ECC_NIST_P521,
};
static void buf_reverse(byte *outbuf, const byte *inbuf, word32 len)
{
word32 up, down;
up = 0;
down = len - 1;
while (up < len)
outbuf[up++] = inbuf[down--];
}
static int xil_mpi_import(mp_int *mpi,
const byte *inbuf,
word32 len,
void* heap)
{
int err;
#ifdef WOLFSSL_SMALL_STACK
byte* buf = NULL;
#else
byte buf[MAX_ECC_BYTES];
if (len > MAX_ECC_BYTES)
return BUFFER_E;
#endif
#ifdef WOLFSSL_SMALL_STACK
buf = (byte*)XMALLOC(len, heap, DYNAMIC_TYPE_PRIVATE_KEY);
if (buf == NULL)
return MEMORY_E;
#endif
buf_reverse(buf, inbuf, len);
err = mp_read_unsigned_bin(mpi, buf, len);
ForceZero(buf, len);
#ifdef WOLFSSL_SMALL_STACK
XFREE(buf, heap, DYNAMIC_TYPE_PRIVATE_KEY);
#endif
return err;
}
#endif
#ifdef ECC_CACHE_CURVE
/* cache (mp_int) of the curve parameters */
static ecc_curve_spec* ecc_curve_spec_cache[ECC_SET_COUNT];
@ -5282,6 +5335,59 @@ static int _ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key,
err = KcapiEcc_MakeKey(key, keysize, curve_id);
(void)rng;
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (xil_curve_type[key->dp->id] == 0)
return ECC_CURVE_OID_E;
err = wc_RNG_GenerateBlock(rng, key->privKey, key->dp->size);
if (err)
return err;
/* Make sure that private key is max. 521 bits */
if (key->dp->size == 66)
key->privKey[65] &= 0x1U;
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(key->privKey), key->dp->size);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(XIL_CAST_U64(key->keyRaw),
2 * key->dp->size);
err = XSecure_EllipticGenerateKey(&(key->xSec.cinst),
xil_curve_type[key->dp->id],
XIL_CAST_U64(key->privKey),
XIL_CAST_U64(key->keyRaw));
if (err != XST_SUCCESS) {
WOLFSSL_XIL_ERROR("Generate ECC key failed", err);
err = WC_HW_E;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(XIL_CAST_U64(key->keyRaw),
2 * key->dp->size);
#ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
if (err == 0)
err = XSecure_EllipticValidateKey(&(key->xSec.cinst),
xil_curve_type[key->dp->id],
XIL_CAST_U64(key->keyRaw));
#endif
if (err == 0)
err = xil_mpi_import(key->pubkey.x, key->keyRaw, key->dp->size,
key->heap);
if (err == 0)
err = xil_mpi_import(key->pubkey.y, key->keyRaw + key->dp->size,
key->dp->size, key->heap);
if (err == 0)
err = xil_mpi_import(&key->k, key->privKey, key->dp->size, key->heap);
if (err == 0)
err = mp_set(key->pubkey.z, 1);
if (err) {
key->privKey = NULL;
XMEMSET(key->keyRaw, 0, sizeof(key->keyRaw));
return err;
}
key->type = ECC_PRIVATEKEY;
#else
#ifdef WOLFSSL_HAVE_SP_ECC
@ -5649,6 +5755,15 @@ int wc_ecc_init_ex(ecc_key* key, void* heap, int devId)
mp_memzero_add("ECC k", &key->k);
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
key->privKey = key->keyRaw + (2 * ECC_MAX_CRYPTO_HW_SIZE);
if (wc_InitXsecure(&(key->xSec))) {
WOLFSSL_MSG("Can't initialize Xsecure");
return WC_HW_E;
}
#endif
return ret;
}
@ -5747,7 +5862,7 @@ static int wc_ecc_get_curve_order_bit_count(const ecc_set_type* dp)
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(PLUTON_CRYPTO_ECC) || defined(WOLFSSL_CRYPTOCELL) || \
defined(WOLFSSL_SILABS_SE_ACCEL) || defined(WOLFSSL_KCAPI_ECC) || \
defined(WOLFSSL_SE050)
defined(WOLFSSL_SE050) || defined(WOLFSSL_XILINX_CRYPT_VERSAL)
static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
mp_int* r, mp_int* s, byte* out, word32 *outlen, WC_RNG* rng,
ecc_key* key)
@ -5764,6 +5879,19 @@ static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
word32 msgLenInBytes = inlen;
CRYS_ECPKI_HASH_OpMode_t hash_mode;
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#ifdef WOLFSSL_SMALL_STACK
byte* K = NULL;
byte* incopy = NULL;
#else
byte K[MAX_ECC_BYTES] = {0};
byte incopy[MAX_ECC_BYTES] = {0};
#endif
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \
defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
word32 Ksize;
#endif
#endif
word32 keysize = (word32)key->dp->size;
#ifdef PLUTON_CRYPTO_ECC
word32 orderBits = wc_ecc_get_curve_order_bit_count(key->dp);
@ -5841,7 +5969,76 @@ static int wc_ecc_sign_hash_hw(const byte* in, word32 inlen,
return err;
}
(void)rng;
#endif
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#ifdef WOLFSSL_SMALL_STACK
K = (byte*)XMALLOC(keysize, key->heap, DYNAMIC_TYPE_PRIVATE_KEY);
incopy = (byte*)XMALLOC(inlen, key->heap, DYNAMIC_TYPE_HASH_TMP);
if (K == NULL || incopy == NULL) {
XFREE(incopy, key->heap, DYNAMIC_TYPE_HASH_TMP);
XFREE(K, key->heap, DYNAMIC_TYPE_PRIVATE_KEY);
return MEMORY_E;
}
#else
if (inlen > sizeof(incopy))
return ECC_BAD_ARG_E;
#endif
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \
defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
err = deterministic_sign_helper(in, inlen, key);
if (err)
return err;
Ksize = mp_unsigned_bin_size(key->sign_k);
if (Ksize > keysize) {
err = BUFFER_E;
goto error_out;
}
err = mp_to_unsigned_bin(key->sign_k, K);
if (err)
goto error_out;
mp_reverse(K, Ksize);
#else
err = wc_RNG_GenerateBlock(rng, K, keysize);
if (err)
goto error_out;
/* Make sure that K is max. 521 bits */
if (keysize == 66)
K[65] &= 0x1;
#endif
buf_reverse(incopy, in, inlen < keysize ? inlen : keysize);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(incopy), keysize);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(key->privKey), keysize);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(K), keysize);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(XIL_CAST_U64(out), keysize * 2);
err = XSecure_EllipticGenerateSign(&(key->xSec.cinst),
xil_curve_type[key->dp->id],
XIL_CAST_U64(incopy), keysize,
XIL_CAST_U64(key->privKey),
XIL_CAST_U64(K),
XIL_CAST_U64(out));
if (err) {
WOLFSSL_XIL_ERROR("Generate ECC signature failed", err);
err = WC_HW_E;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(XIL_CAST_U64(out), keysize * 2);
mp_reverse(&out[0], keysize);
mp_reverse(&out[keysize], keysize);
error_out:
ForceZero(K, MAX_ECC_BYTES);
#ifdef WOLFSSL_SMALL_STACK
XFREE(incopy, key->heap, DYNAMIC_TYPE_HASH_TMP);
XFREE(K, key->heap, DYNAMIC_TYPE_PRIVATE_KEY);
#endif
if (err) {
ForceZero(out, keysize * 2);
return err;
}
#endif /* HW-specific #if-#elif chain */
/* Load R and S */
err = mp_read_unsigned_bin(r, &out[0], keysize);
@ -6025,7 +6222,7 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(PLUTON_CRYPTO_ECC) || defined(WOLFSSL_CRYPTOCELL) || \
defined(WOLFSSL_SILABS_SE_ACCEL) || defined(WOLFSSL_KCAPI_ECC) || \
defined(WOLFSSL_SE050)
defined(WOLFSSL_SE050) || defined(WOLFSSL_XILINX_CRYPT_VERSAL)
err = wc_ecc_sign_hash_hw(in, inlen, r, s, out, outlen, rng, key);
#else
err = wc_ecc_sign_hash_ex(in, inlen, rng, key, r, s);
@ -7117,6 +7314,12 @@ int wc_ecc_free(ecc_key* key)
KcapiEcc_Free(key);
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
key->privKey = NULL;
ForceZero(key->keyRaw, sizeof(key->keyRaw));
ForceZero(&key->xSec, sizeof(key->xSec));
#endif
mp_clear(key->pubkey.x);
mp_clear(key->pubkey.y);
mp_clear(key->pubkey.z);
@ -7843,6 +8046,9 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
byte sigRS[MAX_ECC_BYTES*2];
#elif defined(WOLFSSL_SE050)
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
byte hashcopy[ECC_MAX_CRYPTO_HW_SIZE] = {0};
#elif !defined(WOLFSSL_SP_MATH) || defined(FREESCALE_LTC_ECC)
int did_init = 0;
ecc_point *mG = NULL, *mQ = NULL;
@ -7906,10 +8112,11 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(WOLFSSL_CRYPTOCELL) || defined(WOLFSSL_SILABS_SE_ACCEL) || \
defined(WOLFSSL_KCAPI_ECC) || defined(WOLFSSL_SE050)
defined(WOLFSSL_KCAPI_ECC) || defined(WOLFSSL_SE050) || \
defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* Extract R and S with front zero padding (if required) */
XMEMSET(sigRS, 0, keySz * 2);
XMEMSET(sigRS, 0, sizeof(sigRS));
err = mp_to_unsigned_bin(r, sigRS +
(keySz - mp_unsigned_bin_size(r)));
if (err != MP_OKAY) {
@ -7965,6 +8172,28 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
}
#elif defined(WOLFSSL_SE050)
err = se050_ecc_verify_hash_ex(hash, hashlen, sigRS, keySz * 2, key, res);
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (hashlen > sizeof(hashcopy))
return ECC_BAD_ARG_E;
buf_reverse(hashcopy, hash, (hashlen < keySz) ? hashlen : keySz);
mp_reverse(sigRS, keySz);
mp_reverse(sigRS + keySz, keySz);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(hashcopy), keySz);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(key->keyRaw), keySz * 2);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(sigRS), keySz * 2);
err = XSecure_EllipticVerifySign(&(key->xSec.cinst),
xil_curve_type[key->dp->id],
XIL_CAST_U64(hashcopy), keySz,
XIL_CAST_U64(key->keyRaw),
XIL_CAST_U64(sigRS));
if (err != XST_SUCCESS) {
WOLFSSL_XIL_ERROR("Verify ECC signature failed", err);
err = WC_HW_E;
} else {
*res = 1;
}
#endif
#else
@ -9412,7 +9641,8 @@ static int _ecc_validate_public_key(ecc_key* key, int partial, int priv)
#ifndef WOLFSSL_SP_MATH
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
defined(WOLFSSL_CRYPTOCELL) || defined(WOLFSSL_SILABS_SE_ACCEL) || \
defined(WOLFSSL_SE050) || defined(WOLF_CRYPTO_CB_ONLY_ECC)
defined(WOLFSSL_SE050) || defined(WOLF_CRYPTO_CB_ONLY_ECC) || \
defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* consider key check success on HW crypto
* ex: ATECC508/608A, CryptoCell and Silabs
@ -9813,6 +10043,15 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
if (err == MP_OKAY)
err = silabs_ecc_import(key, keysize);
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#ifndef HAVE_COMP_KEY
if (err == MP_OKAY) {
#else
if (err == MP_OKAY && !compressed) {
#endif
buf_reverse(&key->keyRaw[0], &in[0], keysize);
buf_reverse(&key->keyRaw[keysize], &in[keysize], keysize);
}
#endif
#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
if (err == MP_OKAY)
@ -10297,7 +10536,7 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
!defined(WOLFSSL_ATECC608A)
const CRYS_ECPKI_Domain_t* pDomain;
CRYS_ECPKI_BUILD_TempData_t tempBuff;
byte key_raw[ECC_MAX_CRYPTO_HW_SIZE*2 + 1];
byte keyRaw[ECC_MAX_CRYPTO_HW_SIZE*2 + 1];
#endif
#if defined(WOLFSSL_ATECC508A) || defined(WOLFSSL_ATECC608A) || \
@ -10396,12 +10635,12 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
}
#elif defined(WOLFSSL_CRYPTOCELL)
if (err == MP_OKAY) {
key_raw[0] = ECC_POINT_UNCOMP;
keyRaw[0] = ECC_POINT_UNCOMP;
keySz = (word32)key->dp->size;
err = wc_export_int(key->pubkey.x, &key_raw[1], &keySz, keySz,
err = wc_export_int(key->pubkey.x, &keyRaw[1], &keySz, keySz,
WC_TYPE_UNSIGNED_BIN);
if (err == MP_OKAY) {
err = wc_export_int(key->pubkey.y, &key_raw[1+keySz],
err = wc_export_int(key->pubkey.y, &keyRaw[1+keySz],
&keySz, keySz, WC_TYPE_UNSIGNED_BIN);
}
@ -10410,7 +10649,7 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
/* create public key from external key buffer */
err = CRYS_ECPKI_BuildPublKeyFullCheck(pDomain,
key_raw,
keyRaw,
keySz*2 + 1,
&key->ctx.pubKey,
&tempBuff);
@ -10432,6 +10671,34 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
WC_TYPE_UNSIGNED_BIN);
}
}
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (err == MP_OKAY) {
const word32 keySize = key->dp->size;
word32 bufSize = sizeof(key->keyRaw);
err = wc_export_int(key->pubkey.x, key->keyRaw, &bufSize, keySize,
WC_TYPE_UNSIGNED_BIN);
if (err == MP_OKAY) {
const word32 offset = bufSize;
bufSize = sizeof(key->keyRaw) - offset;
err = wc_export_int(key->pubkey.y, &key->keyRaw[offset], &bufSize,
keySize, WC_TYPE_UNSIGNED_BIN);
}
if (err == MP_OKAY) {
mp_reverse(key->keyRaw, keySize);
mp_reverse(&key->keyRaw[keySize], keySize);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE(XIL_CAST_U64(key->keyRaw),
keySize * 2);
#ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
err = XSecure_EllipticValidateKey(&(key->xSec.cinst),
xil_curve_type[key->dp->id],
XIL_CAST_U64(key->keyRaw));
if (err) {
WOLFSSL_XIL_ERROR("Validation of ECC key failed", err);
err = WC_HW_E;
}
#endif
}
}
#endif
#ifdef WOLFSSL_VALIDATE_ECC_IMPORT
@ -10457,14 +10724,14 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
err = mp_read_unsigned_bin(&key->k, (const byte*)d,
key->dp->size);
if (err == MP_OKAY) {
err = wc_export_int(&key->k, &key_raw[0], &keySz, keySz,
err = wc_export_int(&key->k, &keyRaw[0], &keySz, keySz,
WC_TYPE_UNSIGNED_BIN);
}
if (err == MP_OKAY) {
/* Create private key from external key buffer*/
err = CRYS_ECPKI_BuildPrivKey(pDomain,
key_raw,
keyRaw,
keySz,
&key->ctx.privKey);
@ -10491,10 +10758,20 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
key->dp->size);
}
}
#endif /* WOLFSSL_ATECC508A */
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (err == MP_OKAY) {
const word32 key_size = key->dp->size;
word32 buf_size = key_size;
err = wc_export_int(&key->k, key->privKey,
&buf_size, key_size, WC_TYPE_UNSIGNED_BIN);
mp_reverse(key->privKey, key_size);
}
#endif
#endif /* #else-case of custom HW-specific implementations */
if (mp_iszero(&key->k) || mp_isneg(&key->k)) {
WOLFSSL_MSG("Invalid private key");
return BAD_FUNC_ARG;
err = BAD_FUNC_ARG;
}
} else {
key->type = ECC_PUBLICKEY;
@ -10520,6 +10797,9 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
mp_clear(key->pubkey.y);
mp_clear(key->pubkey.z);
mp_clear(&key->k);
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
ForceZero(key->keyRaw, sizeof(key->keyRaw));
#endif
}
return err;

View File

@ -69,6 +69,8 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
wolfcrypt/src/port/atmel/README.md \
wolfcrypt/src/port/xilinx/xil-sha3.c \
wolfcrypt/src/port/xilinx/xil-aesgcm.c \
wolfcrypt/src/port/xilinx/xil-versal-glue.c \
wolfcrypt/src/port/xilinx/xil-versal-trng.c \
wolfcrypt/src/port/caam/caam_aes.c \
wolfcrypt/src/port/caam/caam_driver.c \
wolfcrypt/src/port/caam/caam_error.c \

View File

@ -26,14 +26,12 @@
#include <wolfssl/wolfcrypt/settings.h>
/* Make calls to Xilinx hardened AES-GCM crypto */
#if !defined(NO_AES) && defined(WOLFSSL_XILINX_CRYPT)
#include <wolfssl/wolfcrypt/aes.h>
#ifdef HAVE_AESGCM
/* Make calls to Xilinx hardened AES-GCM crypto */
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
@ -44,14 +42,438 @@
#include <wolfcrypt/src/misc.c>
#endif
#include "xparameters.h"
enum {
AEAD_NONCE_SZ = 12,
AES_GCM_AUTH_SZ = 16, /* AES-GCM Auth Tag length */
};
#ifdef HAVE_AESGCM
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include "xsecure_aesclient.h"
typedef int (*init_fn)(XSecure_ClientInstance *InstancePtr,
XSecure_AesKeySource KeySrc,
u32 Size,
u64 IvAddr);
enum aad_state {
SW_AAD,
HW_ENGINE_AAD
};
#define XIL_AESGCM_ALIGN 4u
#define NEEDS_ALIGNMENT(ptr, align) (((wc_ptr_t)ptr % align) != 0u)
static WC_INLINE int aligned_xmalloc(byte** buf, byte** aligned, void* heap, word32 size, word32 align)
{
#ifndef NO_WOLFSSL_ALLOC_ALIGN
byte* tmp = (byte*)XMALLOC(size + align, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (tmp == NULL)
return MEMORY_E;
*buf = tmp;
*aligned = tmp + (align - ((wc_ptr_t)tmp % align));
return 0;
#else
WOLFSSL_MSG("AES-ECB encrypt with bad alignment");
WOLFSSL_ERROR_VERBOSE(BAD_ALIGN_E);
return BAD_ALIGN_E;
#endif
}
static WC_INLINE void aligned_xfree(void* buf, void* heap)
{
if (buf == NULL)
return;
XFREE(buf, heap, DYNAMIC_TYPE_TMP_BUFFER);
}
static WC_INLINE int check_keysize(word32 len)
{
if (len != AES_128_KEY_SIZE && len != AES_256_KEY_SIZE) {
WOLFSSL_MSG("Expecting a 128 or 256 bit key");
return BAD_FUNC_ARG;
}
return 0;
}
int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len, word32 kup)
{
int ret;
if (aes == NULL || key == NULL) {
return BAD_FUNC_ARG;
}
if (check_keysize(len)) {
return BAD_FUNC_ARG;
}
ret = wc_InitXsecure(&(aes->xSec));
if (ret != 0) {
WOLFSSL_MSG("Unable to initialize xSecure for AES-GCM");
return ret;
}
ret = XSecure_AesInitialize(&(aes->xSec.cinst));
if (ret != XST_SUCCESS) {
WOLFSSL_XIL_ERROR("Failed to initialize AES client instance", ret);
return WC_HW_E;
}
#ifdef WC_XIL_AESGCM_DPA_CM
ret = XSecure_AesSetDpaCm(&(aes->xSec.cinst), 1);
if (ret != XST_SUCCESS) {
WOLFSSL_XIL_ERROR("Failed to enable AES DPA countermeasures", ret);
return WC_HW_E;
}
#endif
aes->keylen = len;
aes->kup = kup;
aes->xKeySize =
len == AES_128_KEY_SIZE ? XSECURE_AES_KEY_SIZE_128 :
XSECURE_AES_KEY_SIZE_256;
XMEMCPY(aes->keyInit, key, len);
return 0;
}
static WC_INLINE int setup(Aes* aes,
init_fn init,
const byte* iv,
const byte* authIn, word32 authInSz)
{
ALIGN64 byte iv_[AEAD_NONCE_SZ];
byte *piv = (byte*)iv;
byte *aad = (byte*)authIn;
byte *aad_buf = NULL;
int err;
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)aes->keyInit,
sizeof(aes->keyInit));
if (XSecure_AesWriteKey(&(aes->xSec.cinst), aes->kup, aes->xKeySize,
XIL_CAST_U64(aes->keyInit))) {
WOLFSSL_XIL_MSG("Failed to write key");
return 1;
}
if (NEEDS_ALIGNMENT(iv, XIL_AESGCM_ALIGN)) {
XMEMCPY(iv_, iv, AEAD_NONCE_SZ);
piv = iv_;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)piv, AEAD_NONCE_SZ);
if (init(&(aes->xSec.cinst), aes->kup, aes->xKeySize, XIL_CAST_U64(piv))) {
WOLFSSL_XIL_MSG("Failed to init");
return 1;
}
/* Stop here in case there's no AAD ...
*/
if (authIn == NULL || authInSz == 0) {
aes->aadStyle = HW_ENGINE_AAD;
return 0;
}
/* ... or the AAD length is no multiple of 16,
* as the HW-engine can't handle this.
*/
if ((authInSz % WOLFSSL_XSECURE_QWORD_SIZE) != 0) {
aes->aadStyle = SW_AAD;
return 0;
}
if (NEEDS_ALIGNMENT(authIn, XIL_AESGCM_ALIGN)) {
err = aligned_xmalloc(&aad_buf, (byte**)&aad, aes->heap, authInSz,
XIL_AESGCM_ALIGN);
if (err) {
WOLFSSL_MSG("Failed to alloc memory for AESGCM AAD alignment");
return 1;
}
XMEMCPY((void* )aad, authIn, authInSz);
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)aad, authInSz);
if (XSecure_AesUpdateAad(&(aes->xSec.cinst), XIL_CAST_U64(authIn),
authInSz)) {
WOLFSSL_XIL_MSG("Failed to set AAD");
err = 1;
} else {
aes->aadStyle = HW_ENGINE_AAD;
err = 0;
}
aligned_xfree(aad_buf, aes->heap);
return err;
}
static WC_INLINE int handle_aad( Aes* aes,
const byte* data, word32 sz,
const byte* iv,
byte* authTag,
const byte* authIn, word32 authInSz) {
int ret;
byte scratch[AES_BLOCK_SIZE];
byte initalCounter[AES_BLOCK_SIZE] = { 0 };
XMEMCPY(initalCounter, iv, AEAD_NONCE_SZ);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
GHASH(aes, authIn, authInSz, data, sz, authTag, AES_GCM_AUTH_SZ);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret == 0)
xorbuf(authTag, scratch, AES_GCM_AUTH_SZ);
return ret;
}
int wc_AesGcmEncrypt( Aes* aes, byte* out,
const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
int ret = 0;
ALIGN64 u8 tag[AES_GCM_AUTH_SZ];
byte *in_aligned;
byte *in_buf = NULL;
byte *out_aligned;
byte *out_buf = NULL;
if (aes == NULL || (in == NULL && sz > 0u) || iv == NULL || authTag == NULL
|| authTagSz != AES_GCM_AUTH_SZ) {
return BAD_FUNC_ARG;
}
if (ivSz != AEAD_NONCE_SZ) {
WOLFSSL_MSG("Expecting an IV size of 12");
return BAD_FUNC_ARG;
}
if (in == NULL || out == NULL || sz == 0u) {
return handle_aad(aes, NULL, 0u, iv, authTag, authIn, authInSz);
}
if (check_keysize(aes->keylen)) {
return BAD_FUNC_ARG;
}
if (setup(aes, XSecure_AesEncryptInit, iv, authIn, authInSz)) {
return WC_HW_E;
}
in_aligned = (byte*) in;
if (NEEDS_ALIGNMENT(in, XIL_AESGCM_ALIGN)) {
ret = aligned_xmalloc(&in_buf, &in_aligned, aes->heap, sz,
XIL_AESGCM_ALIGN);
if (ret) {
WOLFSSL_MSG(
"Failed to alloc memory for AESGCM Encrypt alignment (in)");
return 1;
}
XMEMCPY(in_aligned, in, sz);
}
if (NEEDS_ALIGNMENT(out, XIL_AESGCM_ALIGN)) {
if (in != in_aligned) {
/* In case `in` has been copied already, re-use that buffer
* and also write to it instead of allocating another one.
*/
out_aligned = in_aligned;
} else {
ret = aligned_xmalloc(&out_buf, &out_aligned, aes->heap, sz,
XIL_AESGCM_ALIGN);
if (ret) {
aligned_xfree(in_buf, aes->heap);
WOLFSSL_MSG(
"Failed to alloc memory for AESGCM Encrypt alignment (out)");
return 1;
}
XMEMCPY(out_aligned, out, sz);
}
} else {
out_aligned = out;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)in_aligned, sz);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out_aligned, sz);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)tag, sizeof(tag));
if (XSecure_AesEncryptUpdate(&(aes->xSec.cinst), XIL_CAST_U64(in_aligned),
XIL_CAST_U64(out_aligned), sz, TRUE)) {
WOLFSSL_XIL_MSG("Encrypt failed");
ret = WC_HW_E;
goto error_out;
}
ret = XSecure_AesEncryptFinal(&(aes->xSec.cinst), XIL_CAST_U64(tag));
if (ret != XST_SUCCESS) {
WOLFSSL_XIL_ERROR("EncryptFinal failed", ret);
ret = WC_HW_E;
ForceZero(authTag, authTagSz);
} else {
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out_aligned, sz);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)tag, sizeof(tag));
if (aes->aadStyle == SW_AAD) {
ret = handle_aad(aes, out_aligned, sz, iv, authTag, authIn,
authInSz);
} else {
XMEMCPY(authTag, tag, authTagSz);
}
if (out != out_aligned) {
XMEMCPY(out, out_aligned, sz);
}
}
error_out:
aligned_xfree(out_buf, aes->heap);
aligned_xfree(in_buf, aes->heap);
ForceZero(tag, sizeof(tag));
XSecure_AesKeyZero(&(aes->xSec.cinst), aes->kup);
return ret;
}
int wc_AesGcmDecrypt( Aes* aes, byte* out,
const byte* in, word32 sz,
const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz)
{
int ret = 0;
ALIGN64 u8 buf[AES_GCM_AUTH_SZ];
ALIGN64 u8 real_tag[AES_GCM_AUTH_SZ];
const u8 *tag;
byte *in_aligned;
byte *in_buf = NULL;
byte *out_aligned;
byte *out_buf = NULL;
if (aes == NULL || (in == NULL && sz > 0u) || iv == NULL || authTag == NULL
|| authTagSz != AES_GCM_AUTH_SZ) {
return BAD_FUNC_ARG;
}
if (ivSz != AEAD_NONCE_SZ) {
WOLFSSL_MSG("Expecting an IV size of 12");
return BAD_FUNC_ARG;
}
if (in == NULL || out == NULL || sz == 0u) {
ret = handle_aad(aes, NULL, 0u, iv, buf, authIn, authInSz);
if (ret == 0 && ConstantCompare(authTag, buf, authTagSz) != 0) {
ret = AES_GCM_AUTH_E;
}
return ret;
}
if (check_keysize(aes->keylen)) {
return BAD_FUNC_ARG;
}
if (setup(aes, XSecure_AesDecryptInit, iv, authIn, authInSz)) {
return WC_HW_E;
}
in_aligned = (byte*) in;
if (NEEDS_ALIGNMENT(in, XIL_AESGCM_ALIGN)) {
ret = aligned_xmalloc(&in_buf, &in_aligned, aes->heap, sz,
XIL_AESGCM_ALIGN);
if (ret) {
WOLFSSL_MSG(
"Failed to alloc memory for AESGCM Decrypt alignment (in)");
return 1;
}
XMEMCPY(in_aligned, in, sz);
}
if (NEEDS_ALIGNMENT(out, XIL_AESGCM_ALIGN)) {
if (in != in_aligned) {
/* In case `in` has been copied already, re-use that buffer
* and also write to it instead of allocating another one.
*/
out_aligned = in_aligned;
} else {
ret = aligned_xmalloc(&out_buf, &out_aligned, aes->heap, sz,
XIL_AESGCM_ALIGN);
if (ret) {
aligned_xfree(in_buf, aes->heap);
WOLFSSL_MSG(
"Failed to alloc memory for AESGCM Decrypt alignment (out)");
return 1;
}
XMEMCPY(out_aligned, out, sz);
}
} else {
out_aligned = out;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)in_aligned, sz);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out_aligned, sz);
if (aes->aadStyle == HW_ENGINE_AAD) {
/* Use the originally provided tag */
if (NEEDS_ALIGNMENT(authTag, XIL_AESGCM_ALIGN)) {
XMEMCPY(real_tag, authTag, AES_GCM_AUTH_SZ);
tag = real_tag;
} else {
tag = authTag;
}
} else {
/* Create a fake tag that will match, so the HW-engine is OK when comparing the tags */
ret = handle_aad(aes, in_aligned, sz, iv, buf, NULL, 0);
if (ret)
goto error_out;
tag = buf;
/* and create the real tag to compare against later */
ret = handle_aad(aes, in_aligned, sz, iv, real_tag, authIn, authInSz);
if (ret)
goto error_out;
}
if (XSecure_AesDecryptUpdate(&(aes->xSec.cinst), XIL_CAST_U64(in_aligned),
XIL_CAST_U64(out_aligned), sz, TRUE)) {
WOLFSSL_XIL_MSG("Decrypt failed");
ret = WC_HW_E;
goto error_out;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)tag, AES_GCM_AUTH_SZ);
if (XSecure_AesDecryptFinal(&(aes->xSec.cinst), XIL_CAST_U64(tag))) {
WOLFSSL_XIL_MSG("DecryptFinal failed");
ret = WC_HW_E;
} else {
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out_aligned, sz);
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)buf, sizeof(buf));
if (aes->aadStyle == SW_AAD) {
if (ConstantCompare(authTag, real_tag, authTagSz) != 0) {
ret = AES_GCM_AUTH_E;
}
}
if (out != out_aligned) {
XMEMCPY(out, out_aligned, sz);
}
}
error_out:
aligned_xfree(out_buf, aes->heap);
aligned_xfree(in_buf, aes->heap);
ForceZero(real_tag, sizeof(real_tag));
ForceZero(buf, sizeof(buf));
XSecure_AesKeyZero(&(aes->xSec.cinst), aes->kup);
return ret;
}
#else
int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len, word32 kup)
{
XCsuDma_Config* con;
@ -60,7 +482,7 @@ int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len, word32 kup)
return BAD_FUNC_ARG;
}
if (len != 32) {
if (len != AES_256_KEY_SIZE) {
WOLFSSL_MSG("Expecting a 256 bit key");
return BAD_FUNC_ARG;
}
@ -79,7 +501,7 @@ int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len, word32 kup)
aes->keylen = len;
aes->kup = kup;
XMEMCPY((byte*)(aes->key_init), key, len);
XMEMCPY((byte*)(aes->keyInit), key, len);
return 0;
}
@ -111,7 +533,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out,
* buffer is created to keep AES encrypt from writing over the end of
* out buffer. */
if (in != NULL) {
if (aes->keylen != 32) {
if (aes->keylen != AES_256_KEY_SIZE) {
WOLFSSL_MSG("Expecting 256 bit AES key");
return BAD_FUNC_ARG;
}
@ -123,7 +545,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out,
}
XSecure_AesInitialize(&(aes->xilAes), &(aes->dma), aes->kup, (word32*)iv,
aes->key_init);
aes->keyInit);
XSecure_AesEncryptData(&(aes->xilAes), tmp, in, sz);
XMEMCPY(out, tmp, sz);
XMEMCPY(authTag, tmp + sz, authTagSz);
@ -187,7 +609,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out,
/* calls to hardened crypto */
XSecure_AesInitialize(&(aes->xilAes), &(aes->dma), aes->kup,
(word32*)iv, aes->key_init);
(word32*)iv, aes->keyInit);
XSecure_AesDecryptData(&(aes->xilAes), out, in, sz, tag);
/* account for additional data */
@ -205,6 +627,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out,
return 0;
}
#endif /* versal */
#endif /* HAVE_AESGCM */
#endif

View File

@ -33,6 +33,83 @@
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <xsecure_shaclient.h>
/* Initialize hardware for SHA3 operations
*
* sha SHA3 structure to initialize
* heap memory heap hint to use
* devId used for async operations (currently not supported here)
*/
int wc_InitSha3_384(wc_Sha3* sha, void* heap, int devId)
{
(void) heap;
(void) devId;
if (sha == NULL) {
return BAD_FUNC_ARG;
}
if (wc_InitXsecure(&(sha->xSec))) {
WOLFSSL_MSG("Can't initialize Xsecure");
return BAD_STATE_E;
}
XSecure_Sha3Initialize();
return 0;
}
/* Update SHA3 state
*
* sha SHA3 structure to update
* data message to update SHA3 state with
* len length of data buffer
*/
int wc_Sha3_384_Update(wc_Sha3* sha, const byte* data, word32 len)
{
if (sha == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)data, len);
XSecure_Sha3Update(&(sha->xSec.cinst), XIL_CAST_U64(data), len);
return 0;
}
/* Finalize SHA3 state and get digest
*
* sha SHA3 structure to get hash
* out digest out, expected to be large enough to hold SHA3 digest
*/
int wc_Sha3_384_Final(wc_Sha3* sha, byte* out)
{
if (sha == NULL || out == NULL) {
return BAD_FUNC_ARG;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out, WC_SHA3_384_DIGEST_SIZE);
XSecure_Sha3Finish(&(sha->xSec.cinst), XIL_CAST_U64(out));
return wc_InitSha3_384(sha, NULL, INVALID_DEVID);
}
/* Free SHA3 structure
*
* sha SHA3 structure to free
*/
void wc_Sha3_384_Free(wc_Sha3* sha)
{
(void)sha;
/* nothing to free yet */
}
#else /* non-versal */
#if !defined(WOLFSSL_NOSHA3_224) || !defined(WOLFSSL_NOSHA3_256) \
|| !defined(WOLFSSL_NOSHA3_512)
#error sizes of SHA3 other than 384 are not supported
@ -163,5 +240,6 @@ int wc_Sha3_384_Copy(wc_Sha3* src, wc_Sha3* dst)
return -1;
#endif
}
#endif
#endif

View File

@ -0,0 +1,211 @@
/* xil-versal-glue.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL 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 Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#include <xil_cache.h>
/**
Initialize versal peripherals
xsec Xsecure structure to initialize
Returns 0 on success
*/
int wc_InitXsecure(wc_Xsecure* xsec)
{
#ifdef XSECURE_CACHE_DISABLE
static int cache_disabled = 0;
if (cache_disabled == 0) {
Xil_DCacheDisable();
cache_disabled = 1;
}
#endif
if (xsec == NULL) {
return BAD_FUNC_ARG;
}
if (XMailbox_Initialize(&(xsec->mb), 0U) != XST_SUCCESS) {
WOLFSSL_MSG("Can't initialize mailbox");
return WC_HW_E;
}
if (XSecure_ClientInit(&(xsec->cinst), &(xsec->mb)) != XST_SUCCESS) {
WOLFSSL_MSG("Can't initialize secure client");
return WC_HW_E;
}
/* Set shared memory */
if (XMailbox_SetSharedMem(&(xsec->mb), XIL_CAST_U64(xsec->mem),
sizeof(xsec->mem)) != XST_SUCCESS) {
WOLFSSL_MSG("Can't set shared mem");
return WC_HW_E;
}
return 0;
}
/**
Convert Xilinx specific error to string
err The error to convert
Returns a pointer to a string (always, never returns NULL).
*/
const char *wc_XsecureErrorToString(int err)
{
if (err == 0) {
return "Success";
}
if (err == 1) {
return "Generic \"Failure\".";
}
switch (err & 0xff) {
case 0x02:
return "Error when SHA3 init fails.";
case 0x03:
return "Error when SHA3 last update fails.";
case 0x04:
return "Error when DMA driver fails to update the data to SHA3.";
case 0x05:
return "Error when timeout.";
case 0x06:
return "Error when SHA3 hash not matched with expected hash.";
case 0x07:
return "Error when SHA3 finish fails.";
case 0x08:
return "SHA3 Invalid Argument.";
case 0x09:
return "SSS Invalid Argument.";
case 0x0A:
return "SHA3 State mismatch.";
case 0x40:
return "user provided GCM tag does not match calculated tag.";
case 0x41:
return "AES key clear error.";
case 0x42:
return "AES DPA CM is not supported on device.";
case 0x43:
return "Error when AES key write fails.";
case 0x44:
return "Error when AES decrypt init fails.";
case 0x45:
return "Error when GCM tag not matched with user provided tag.";
case 0x46:
return "Error when AES data not matched with expected data.";
case 0x47:
return "AES KAT fails.";
case 0x48:
return "Error when AESDPACM key write fails.";
case 0x49:
return "Error when AESDPACM key load fails.";
case 0x4A:
return "Error when AESDPACM sss config fails.";
case 0x4B:
return "AESDPACM KAT fails.";
case 0x4C:
return "Error 1 when AESDPACM data not matched with expected data.";
case 0x4D:
return "Error 2 when AESDPACM data not matched with expected data.";
case 0x4E:
return "Error 3 when AESDPACM data not matched with expected data.";
case 0x4F:
return "Error 4 when AESDPACM data not matched with expected data.";
case 0x50:
return "Error 5 when AESDPACM data not matched with expected data.";
case 0x51:
return "AES Invalid Argument.";
case 0x52:
return "AES KAT Invalid Argument.";
case 0x53:
return "AES State mismatch.";
case 0x54:
return "AES - Access to device keys is not allowed for IPI for any operations.";
case 0x80:
return "RSA KAT fails.";
case 0x81:
return "Error when RSA data not matched with expected data.";
case 0x82:
return "RSA Invalid Argument.";
case 0x83:
return "RSA KAT Invalid Argument.";
case 0x84:
return "RSA State mismatch.";
case 0xC0:
return "ECC key is not valid.";
case 0xC1:
return "Elliptic KAT fails.";
case 0xC2:
return "Elliptic Curve not supported.";
case 0xC3:
return "Public key is zero.";
case 0xC4:
return "Wrong order of Public key.";
case 0xC5:
return "Key not found on curve.";
case 0xC6:
return "Signature provided for verification is bad.";
case 0xC7:
return "Incorrect hash length for sign generation.";
case 0xC8:
return "Incorrect hash length for sign verification.";
case 0xC9:
return "Bad random number used for sign generation.";
case 0xCA:
return "Error in generating Public key.";
case 0xCB:
return "Invalid argument.";
case 0xCC:
return "R set to zero.";
case 0xCD:
return "S set to zero.";
case 0xCE:
return "R is not within ECC order.";
case 0xCF:
return "S is not within ECC order.";
case 0xD0:
return "Curve not supported for KAT.";
case 0xF0:
return "No tamper response when tamper interrupt is detected.";
case 0xF1:
return "Access to Xilsecure IPIs is disabled if IPI request is non secure.";
case 0xF2:
return "SHA3 busy with earlier operation, Kat can't be executed.";
case 0xF3:
return "AES busy with earlier operation, Kat can't be executed.";
default:
return "Unknown error code.";
}
}
#endif

View File

@ -0,0 +1,227 @@
/* xil-versal-trng.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL 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 Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#include <xtrngpsv.h>
#if !defined(HAVE_HASHDRBG)
/** How often shall the DRBG part be re-seeded */
#ifndef WC_RESEED_INTERVAL
#define WC_RESEED_INTERVAL (1000000)
#endif
/** How big shall the seed be */
#ifndef WC_XILINX_TRNG_DF_LEN_MUL
#ifdef DRBG_SEED_LEN
#define WC_XILINX_TRNG_DF_LEN_MUL (DRBG_SEED_LEN / BYTES_PER_BLOCK)
#else
/* Use the next best value to the default `DRBG_SEED_LEN` (= 440bits)
* WC_XILINX_TRNG_DF_LEN_MUL * BYTES_PER_BLOCK * BITS_PER_BYTE
* 4U * 16 * 8 = 512
*/
#define WC_XILINX_TRNG_DF_LEN_MUL 4U
#endif
#endif
#endif /* !defined(HAVE_HASHDRBG) */
static XTrngpsv trng;
static sword32 versal_trng_selftest(void)
{
sword32 ret = XTrngpsv_RunKAT(&trng);
if (ret == XTRNGPSV_SUCCESS)
ret = XTrngpsv_RunHealthTest(&trng);
return ret;
}
#if !defined(HAVE_HASHDRBG)
static WC_INLINE void array_add_one(byte* data, word32 dataSz)
{
int i;
for (i = dataSz - 1; i >= 0; i--) {
data[i]++;
if (data[i] != 0)
break;
}
}
static WC_INLINE void usercfg_add_nonce(XTrngpsv_UsrCfg* user_cfg,
byte* nonce,
word32 nonceSz)
{
word32 nonce_written = 0;
byte *pers_string = (byte*)user_cfg->PersString;
byte *nonce_rd = nonce;
do {
word32 to_write =
nonce_written + nonceSz <= sizeof(user_cfg->PersString) ?
nonceSz : sizeof(user_cfg->PersString) - nonce_written;
XMEMCPY(pers_string, nonce_rd, to_write);
if (nonce != nonce_rd)
array_add_one(pers_string, to_write);
nonce_rd = pers_string;
pers_string += to_write;
nonce_written += to_write;
} while (nonce_written < sizeof(user_cfg->PersString));
user_cfg->PersStrPresent = XTRNGPSV_TRUE;
}
#endif
/**
Initialize the Versal TRNG.
nonce Pointer to user-supplied nonce.
nonceSz Size of the user-supplied nonce.
Returns 0 on success
*/
int wc_VersalTrngInit(byte* nonce, word32 nonceSz)
{
#if !defined(HAVE_HASHDRBG)
/* Use the HRNG mode (with DF) which lets us extract FIPS compliant
* random data from the TRNG.
*/
XTrngpsv_UsrCfg user_cfg = {
.Mode = XTRNGPSV_HRNG,
.SeedLife = WC_RESEED_INTERVAL,
.PredResistanceEn = XTRNGPSV_FALSE,
.DFDisable = XTRNGPSV_FALSE,
.DFLenMul = WC_XILINX_TRNG_DF_LEN_MUL,
.InitSeedPresent = XTRNGPSV_FALSE,
.PersStrPresent = XTRNGPSV_FALSE
};
#else
/* Use the PTRNG mode (without DF) which lets us extract raw entropy
* to be used as a seed to the internal DRBG.
*/
const XTrngpsv_UsrCfg user_cfg = {
.Mode = XTRNGPSV_PTRNG,
.SeedLife = 0U,
.PredResistanceEn = XTRNGPSV_FALSE,
.DFDisable = XTRNGPSV_TRUE,
.DFLenMul = 0U,
.InitSeedPresent = XTRNGPSV_FALSE,
.PersStrPresent = XTRNGPSV_FALSE
};
#endif
int ret = WC_HW_E;
XTrngpsv_Config *cfg;
sword32 xret = 0;
if (trng.State == XTRNGPSV_HEALTHY) {
return 0;
}
cfg = XTrngpsv_LookupConfig(WOLFSSL_PSV_TRNG_DEV_ID);
if (!cfg) {
WOLFSSL_MSG("Could not lookup TRNG config");
goto out;
}
xret = XTrngpsv_CfgInitialize(&trng, cfg, cfg->BaseAddress);
if (xret)
goto out;
xret = versal_trng_selftest();
if (xret)
goto out;
#if !defined(HAVE_HASHDRBG)
if (nonce)
usercfg_add_nonce(&user_cfg, nonce, nonceSz);
#endif
xret = XTrngpsv_Instantiate(&trng, &user_cfg);
if (xret)
goto out;
ret = 0;
out:
if (xret) {
WOLFSSL_MSG_EX("Xilinx API returned 0x%08x", xret);
}
return ret;
}
/**
Reset the Versal TRNG.
Returns 0 on success
*/
int wc_VersalTrngReset(void)
{
sword32 xret = XTrngpsv_Uninstantiate(&trng);
if (xret) {
WOLFSSL_MSG_EX("XTrngpsv_Uninstantiate() returned 0x%08x", xret);
return WC_HW_E;
}
return 0;
}
/**
Run the Versal TRNG self-test.
Returns 0 on success
*/
int wc_VersalTrngSelftest(void)
{
return versal_trng_selftest() == XTRNGPSV_SUCCESS ? 0 : -1;
}
/**
Read from the Versal TRNG.
output Destination
sz Length of output
Returns 0 on success
*/
int wc_VersalTrngGenerate(byte* output, word32 sz)
{
/* The TRNG always generates exactly 32bytes of output */
byte buf[XTRNGPSV_SEC_STRENGTH_BYTES];
word32 bytes_generated = 0;
do {
word32 bytes_left = sz - bytes_generated;
word32 bytes_required =
bytes_left > XTRNGPSV_SEC_STRENGTH_BYTES ?
XTRNGPSV_SEC_STRENGTH_BYTES : bytes_left;
sword32 xret = XTrngpsv_Generate(&trng, buf,
XTRNGPSV_SEC_STRENGTH_BYTES,
XTRNGPSV_FALSE);
if (xret) {
WOLFSSL_MSG_EX("XTrngpsv_Generate() returned 0x%08x", xret);
return WC_HW_E;
}
XMEMCPY(&output[bytes_generated], buf, bytes_required);
bytes_generated += bytes_required;
} while (bytes_generated < sz);
return 0;
}
#endif

View File

@ -146,6 +146,8 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
#include <predef.h>
#include <basictypes.h>
#include <random.h>
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include "wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h"
#elif defined(NO_DEV_RANDOM)
#elif defined(CUSTOM_RAND_GENERATE)
#elif defined(CUSTOM_RAND_GENERATE_BLOCK)
@ -822,6 +824,12 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
return 0;
#endif
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
ret = wc_VersalTrngInit(nonce, nonceSz);
if (ret)
return ret;
#endif
#ifdef CUSTOM_RAND_GENERATE_BLOCK
ret = 0; /* success */
#else
@ -1113,6 +1121,12 @@ int wc_FreeRng(WC_RNG* rng)
rng->status = DRBG_NOT_INIT;
#endif /* HAVE_HASHDRBG */
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL\
/* don't overwrite previously set error */
if (wc_VersalTrngReset() && !ret)
ret = WC_HW_E;
#endif
return ret;
}

View File

@ -52,7 +52,9 @@ RSA keys can be used to encrypt, decrypt, sign and verify data.
#ifdef WOLFSSL_AFALG_XILINX_RSA
#include <wolfssl/wolfcrypt/port/af_alg/wc_afalg.h>
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <xsecure_rsaclient.h>
#endif
#ifdef WOLFSSL_HAVE_SP_RSA
#include <wolfssl/wolfcrypt/sp.h>
#endif
@ -410,13 +412,23 @@ int wc_InitRsaHw(RsaKey* key)
word32 e = 0; /* RSA public exponent */
int mSz;
int eSz;
int ret;
if (key == NULL) {
return BAD_FUNC_ARG;
}
mSz = mp_unsigned_bin_size(&(key->n));
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (mSz > WOLFSSL_XSECURE_RSA_KEY_SIZE) {
return BAD_FUNC_ARG;
}
/* Allocate 4 bytes more for the public exponent. */
m = (unsigned char*) XMALLOC(WOLFSSL_XSECURE_RSA_KEY_SIZE + 4, key->heap,
DYNAMIC_TYPE_KEY);
#else
m = (unsigned char*)XMALLOC(mSz, key->heap, DYNAMIC_TYPE_KEY);
#endif
if (m == NULL) {
return MEMORY_E;
}
@ -426,6 +438,9 @@ int wc_InitRsaHw(RsaKey* key)
XFREE(m, key->heap, DYNAMIC_TYPE_KEY);
return MP_READ_E;
}
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
XMEMSET(m + mSz, 0, WOLFSSL_XSECURE_RSA_KEY_SIZE + 4 - mSz);
#endif
eSz = mp_unsigned_bin_size(&(key->e));
if (eSz > MAX_E_SIZE) {
@ -449,6 +464,16 @@ int wc_InitRsaHw(RsaKey* key)
key->pubExp = e;
key->mod = m;
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
ret = wc_InitXsecure(&(key->xSec));
if (ret != 0) {
WOLFSSL_MSG("Unable to initialize xSecure for RSA");
XFREE(m, key->heap, DYNAMIC_TYPE_KEY);
return ret;
}
XMEMCPY(&m[WOLFSSL_XSECURE_RSA_KEY_SIZE], &e, sizeof(e));
key->mSz = mSz;
#else
if (XSecure_RsaInitialize(&(key->xRsa), key->mod, NULL,
(byte*)&(key->pubExp)) != XST_SUCCESS) {
WOLFSSL_MSG("Unable to initialize RSA on hardware");
@ -465,6 +490,7 @@ int wc_InitRsaHw(RsaKey* key)
return BAD_STATE_E;
}
}
#endif
#endif
return 0;
} /* WOLFSSL_XILINX_CRYPT*/
@ -2117,23 +2143,45 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
{
byte *d;
int dSz;
#if !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
XSecure_Rsa rsa;
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
dSz = WOLFSSL_XSECURE_RSA_KEY_SIZE * 2;
#else
dSz = mp_unsigned_bin_size(&key->d);
#endif
d = (byte*)XMALLOC(dSz, key->heap, DYNAMIC_TYPE_PRIVATE_KEY);
if (d == NULL) {
ret = MEMORY_E;
}
else {
} else {
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
XMEMSET(d, 0, dSz);
XMEMCPY(d, key->mod, key->mSz);
ret = mp_to_unsigned_bin(&key->d, &d[WOLFSSL_XSECURE_RSA_KEY_SIZE]);
#else
ret = mp_to_unsigned_bin(&key->d, d);
XSecure_RsaInitialize(&rsa, key->mod, NULL, d);
#endif
}
if (ret == 0) {
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
WOLFSSL_XIL_DCACHE_FLUSH_RANGE((UINTPTR)d, dSz);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE((UINTPTR)in, inLen);
if (XSecure_RsaPrivateDecrypt(&(key->xSec.cinst), XIL_CAST_U64(d),
XIL_CAST_U64(in), inLen,
XIL_CAST_U64(out)) != XST_SUCCESS) {
ret = BAD_STATE_E;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out, inLen);
#else
if (XSecure_RsaPrivateDecrypt(&rsa, (u8*)in, inLen, out) !=
XST_SUCCESS) {
ret = BAD_STATE_E;
}
#endif
}
if (d != NULL) {
@ -2144,7 +2192,19 @@ static int wc_RsaFunctionSync(const byte* in, word32 inLen, byte* out,
break;
case RSA_PUBLIC_ENCRYPT:
case RSA_PUBLIC_DECRYPT:
#ifdef WOLFSSL_XILINX_CRYPTO_OLD
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
WOLFSSL_XIL_DCACHE_FLUSH_RANGE((UINTPTR)key->mod,
WOLFSSL_XSECURE_RSA_KEY_SIZE + 4);
WOLFSSL_XIL_DCACHE_FLUSH_RANGE((UINTPTR)in, inLen);
if (XSecure_RsaPublicEncrypt(&(key->xSec.cinst),
XIL_CAST_U64(key->mod),
XIL_CAST_U64(in), inLen,
XIL_CAST_U64(out))) {
WOLFSSL_MSG("RSA public operation failed");
ret = BAD_STATE_E;
}
WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE((UINTPTR)out, inLen);
#elif defined(WOLFSSL_XILINX_CRYPTO_OLD)
if (XSecure_RsaDecrypt(&(key->xRsa), in, out) != XST_SUCCESS) {
ret = BAD_STATE_E;
}

View File

@ -201,7 +201,7 @@ int wc_SignatureVerifyHash(
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
byte *plain_data;
#else
byte plain_data[MAX_ENCODED_SIG_SZ];
ALIGN64 byte plain_data[MAX_ENCODED_SIG_SZ];
#endif
/* Make sure the plain text output is at least key size */

View File

@ -361,7 +361,7 @@
/* these cases do not have intermediate hashing support */
#if (defined(WOLFSSL_AFALG_XILINX_SHA3) && !defined(WOLFSSL_AFALG_HASH_KEEP)) \
&& !defined(WOLFSSL_XILINX_CRYPT)
&& !defined(WOLFSSL_XILINX_CRYPT) || defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#define NO_INTM_HASH_TEST
#endif
@ -3293,6 +3293,7 @@ static int sha3_384_test(void)
{
wc_Sha3 sha;
byte hash[WC_SHA3_384_DIGEST_SIZE];
byte buf[64];
#ifndef NO_INTM_HASH_TEST
byte hashcopy[WC_SHA3_384_DIGEST_SIZE];
#endif
@ -3310,7 +3311,7 @@ static int sha3_384_test(void)
a.inLen = XSTRLEN(a.input);
a.outLen = WC_SHA3_384_DIGEST_SIZE;
#if defined(WOLFSSL_AFALG_XILINX_SHA3) || defined(WOLFSSL_XILINX_CRYPT)
#if defined(WOLFSSL_AFALG_XILINX_SHA3) || defined(WOLFSSL_XILINX_CRYPT) && !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
/* NIST test vector with a length that is a multiple of 4 */
b.input = "\x7d\x80\xb1\x60\xc4\xb5\x36\xa3\xbe\xb7\x99\x80\x59\x93\x44"
"\x04\x7c\x5f\x82\xa1\xdf\xc3\xee\xd4";
@ -3337,8 +3338,8 @@ static int sha3_384_test(void)
c.inLen = XSTRLEN(c.input);
c.outLen = WC_SHA3_384_DIGEST_SIZE;
#ifdef WOLFSSL_XILINX_CRYPT
test_sha[0] = b; /* hardware acc. can not handle "" string */
#if defined(WOLFSSL_XILINX_CRYPT) && !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
test_sha[0] = b; /* hardware acc. pre-Versal can not handle "" string */
#else
test_sha[0] = a;
#endif
@ -3350,7 +3351,8 @@ static int sha3_384_test(void)
return -2800;
for (i = 0; i < times; ++i) {
ret = wc_Sha3_384_Update(&sha, (byte*)test_sha[i].input,
XMEMCPY(buf, test_sha[i].input, test_sha[i].inLen);
ret = wc_Sha3_384_Update(&sha, buf,
(word32)test_sha[i].inLen);
if (ret != 0)
ERROR_OUT(-2801 - (i * 10), exit);
@ -10790,7 +10792,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
#endif
#endif
byte resultT[sizeof(t1)];
byte resultT[sizeof(t1) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
int result = 0;
@ -10801,6 +10803,11 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
int plen;
#endif
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
byte buf[sizeof(p) + AES_BLOCK_SIZE];
byte bufA[sizeof(a) + 1];
byte *large_aad = (byte*)XMALLOC((size_t)1024 + 16, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM)
#if !defined(BENCH_AESGCM_LARGE)
@ -10853,7 +10860,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv1, sizeof(iv1),
resultT, sizeof(resultT), a, sizeof(a));
resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10861,7 +10868,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6303, out);
if (XMEMCMP(c1, resultC, sizeof(c1)))
ERROR_OUT(-6304, out);
if (XMEMCMP(t1, resultT, sizeof(resultT)))
if (XMEMCMP(t1, resultT, sizeof(t1)))
ERROR_OUT(-6305, out);
#ifdef HAVE_AES_DECRYPT
@ -10870,7 +10877,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6306, out);
result = wc_AesGcmDecrypt(dec, resultP, resultC, sizeof(c1),
iv1, sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
iv1, sizeof(iv1), resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10889,7 +10896,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, large_output, large_input,
BENCH_AESGCM_LARGE, iv1, sizeof(iv1),
resultT, sizeof(resultT), a, sizeof(a));
resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10899,7 +10906,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, large_outdec, large_output,
BENCH_AESGCM_LARGE, iv1, sizeof(iv1), resultT,
sizeof(resultT), a, sizeof(a));
sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10914,7 +10921,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
for (ivlen=1; ivlen<(int)sizeof(k1); ivlen++) {
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), k1,
(word32)ivlen, resultT, sizeof(resultT), a, sizeof(a));
(word32)ivlen, resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10922,7 +10929,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6312, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, resultP, resultC, sizeof(c1), k1,
(word32)ivlen, resultT, sizeof(resultT), a, sizeof(a));
(word32)ivlen, resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10937,7 +10944,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
for (alen=0; alen<(int)sizeof(p); alen++) {
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv1,
sizeof(iv1), resultT, sizeof(resultT), p, (word32)alen);
sizeof(iv1), resultT, sizeof(t1), p, (word32)alen);
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10945,7 +10952,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6314, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, resultP, resultC, sizeof(c1), iv1,
sizeof(iv1), resultT, sizeof(resultT), p, (word32)alen);
sizeof(iv1), resultT, sizeof(t1), p, (word32)alen);
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10953,6 +10960,56 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6315, out);
#endif /* HAVE_AES_DECRYPT */
}
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
if (! large_aad)
ERROR_OUT(MEMORY_E, out);
XMEMSET(large_aad, 0, 1024+16);
/* Variable authenticated data length test */
for (alen=0; alen<=1024; alen+=16) {
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv1,
sizeof(iv1), resultT, sizeof(t1), large_aad, (word32)alen);
if (result != 0)
ERROR_OUT(-6316, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, resultP, resultC, sizeof(c1), iv1,
sizeof(iv1), resultT, sizeof(t1), large_aad, (word32)alen);
if (result != 0)
ERROR_OUT(-6317, out);
#endif /* HAVE_AES_DECRYPT */
}
/* Test unaligned memory of all potential arguments */
result = wc_AesGcmSetKey(enc, k1, sizeof(k1));
if (result != 0)
ERROR_OUT(-6318, out);
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
XMEMCPY(&buf[1], p, sizeof(p));
XMEMCPY(&bufA[1], a, sizeof(a));
result = wc_AesGcmEncrypt(enc, &resultC[1], &buf[1], sizeof(p), iv1, sizeof(iv1),
&resultT[1], sizeof(t1), &bufA[1], sizeof(a));
if (result != 0)
ERROR_OUT(-6319, out);
if (XMEMCMP(c1, &resultC[1], sizeof(c1)))
ERROR_OUT(-6320, out);
if (XMEMCMP(t1, &resultT[1], sizeof(t1)))
ERROR_OUT(-6321, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmSetKey(dec, k1, sizeof(k1));
if (result != 0)
ERROR_OUT(-6322, out);
result = wc_AesGcmDecrypt(dec, &resultP[1], &resultC[1], sizeof(c1),
iv1, sizeof(iv1), &resultT[1], sizeof(t1), &bufA[1], sizeof(a));
if (result != 0)
ERROR_OUT(-6323, out);
if (XMEMCMP(p, &resultP[1], sizeof(p)))
ERROR_OUT(-6324, out);
#endif /* HAVE_AES_DECRYPT */
#endif /* Xilinx Versal */
#endif
#if !defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT)
@ -10962,7 +11019,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, large_output, large_input,
plen, iv1, sizeof(iv1), resultT,
sizeof(resultT), a, sizeof(a));
sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10972,7 +11029,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, large_outdec, large_output,
plen, iv1, sizeof(iv1), resultT,
sizeof(resultT), a, sizeof(a));
sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10985,7 +11042,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
for (plen=1; plen<(int)sizeof(p); plen++) {
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, (word32)plen, iv1,
sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
sizeof(iv1), resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -10993,7 +11050,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6318, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(dec, resultP, resultC, (word32)plen, iv1,
sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
sizeof(iv1), resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -11015,7 +11072,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
wc_AesGcmSetKey(enc, k2, sizeof(k2));
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv2, sizeof(iv2),
resultT, sizeof(resultT), a, sizeof(a));
resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -11023,12 +11080,12 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6320, out);
if (XMEMCMP(c2, resultC, sizeof(c2)))
ERROR_OUT(-6321, out);
if (XMEMCMP(t2, resultT, sizeof(resultT)))
if (XMEMCMP(t2, resultT, sizeof(t1)))
ERROR_OUT(-6322, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(enc, resultP, resultC, sizeof(c1),
iv2, sizeof(iv2), resultT, sizeof(resultT), a, sizeof(a));
iv2, sizeof(iv2), resultT, sizeof(t1), a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -11082,7 +11139,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
wc_AesGcmSetKey(enc, k1, sizeof(k1));
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p), iv1, sizeof(iv1),
resultT + 1, sizeof(resultT) - 1, a, sizeof(a));
resultT + 1, sizeof(t1) - 1, a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -11090,12 +11147,12 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
ERROR_OUT(-6330, out);
if (XMEMCMP(c1, resultC, sizeof(c1)))
ERROR_OUT(-6331, out);
if (XMEMCMP(t1, resultT + 1, sizeof(resultT) - 1))
if (XMEMCMP(t1, resultT + 1, sizeof(t1) - 1))
ERROR_OUT(-6332, out);
#ifdef HAVE_AES_DECRYPT
result = wc_AesGcmDecrypt(enc, resultP, resultC, sizeof(p),
iv1, sizeof(iv1), resultT + 1, sizeof(resultT) - 1, a, sizeof(a));
iv1, sizeof(iv1), resultT + 1, sizeof(t1) - 1, a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
#endif
@ -11132,7 +11189,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
result = wc_AesGcmEncrypt_ex(enc,
resultC, p, sizeof(p),
randIV, sizeof(randIV),
resultT, sizeof(resultT),
resultT, sizeof(t1),
a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &enc->asyncDev, WC_ASYNC_FLAG_NONE);
@ -11159,7 +11216,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
result = wc_AesGcmDecrypt(dec,
resultP, resultC, sizeof(c1),
randIV, sizeof(randIV),
resultT, sizeof(resultT),
resultT, sizeof(t1),
a, sizeof(a));
#if defined(WOLFSSL_ASYNC_CRYPT)
result = wc_AsyncWait(result, &dec->asyncDev, WC_ASYNC_FLAG_NONE);
@ -11184,7 +11241,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
result = wc_AesGcmEncryptUpdate(enc, resultC, p, sizeof(p), a, sizeof(a));
if (result != 0)
ERROR_OUT(-6361, out);
result = wc_AesGcmEncryptFinal(enc, resultT, sizeof(resultT));
result = wc_AesGcmEncryptFinal(enc, resultT, sizeof(t1));
if (result != 0)
ERROR_OUT(-6362, out);
if (XMEMCMP(resultC, c1, sizeof(c1)) != 0)
@ -11229,7 +11286,7 @@ WOLFSSL_TEST_SUBROUTINE int aesgcm_test(void)
if (result != 0)
ERROR_OUT(-6382, out);
}
result = wc_AesGcmEncryptFinal(enc, resultT, sizeof(resultT));
result = wc_AesGcmEncryptFinal(enc, resultT, sizeof(t1));
if (result != 0)
ERROR_OUT(-6383, out);
if (XMEMCMP(resultC, c1, sizeof(c1)) != 0)
@ -14951,7 +15008,8 @@ static int rsa_even_mod_test(WC_RNG* rng, RsaKey* key)
/* after loading in key use tmp as the test buffer */
#if !(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2) && \
(defined(WOLFSSL_SP_ARM64_ASM) || defined(WOLFSSL_SP_ARM32_ASM)))
(defined(WOLFSSL_SP_ARM64_ASM) || defined(WOLFSSL_SP_ARM32_ASM))) && \
!defined(WOLFSSL_XILINX_CRYPT)
/* The ARM64_ASM code that was FIPS validated did not return these expected
* failure codes. These tests cases were added after the assembly was
* in-lined in the module and validated, these tests will be available in
@ -22277,7 +22335,12 @@ WOLFSSL_TEST_SUBROUTINE int x963kdf_test(void)
#else
#define ECC_SHARED_SIZE MAX_ECC_BYTES
#endif
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
#define HAVE_ECC_DETERMINISTIC_K
#define ECC_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
#else
#define ECC_DIGEST_SIZE MAX_ECC_BYTES
#endif
#define ECC_SIG_SIZE ECC_MAX_SIG_SIZE
#ifndef NO_ECC_VECTOR_TEST
@ -22658,7 +22721,8 @@ static int ecc_test_vector(int keySize)
}
#endif /* WOLF_CRYPTO_CB_ONLY_ECC */
#if defined(HAVE_ECC_SIGN) && defined(WOLFSSL_ECDSA_DETERMINISTIC_K)
#if defined(HAVE_ECC_SIGN) && defined(HAVE_ECC_DETERMINISTIC_K)
#if defined(HAVE_ECC256)
static int ecc_test_deterministic_k(WC_RNG* rng)
{
int ret;
@ -22744,6 +22808,7 @@ done:
wc_ecc_free(&key);
return ret;
}
#endif
#ifdef WOLFSSL_PUBLIC_MP
#if defined(HAVE_ECC384)
@ -23249,7 +23314,7 @@ static int ecc_test_make_pub(WC_RNG* rng)
#if defined(HAVE_ECC_SIGN) && (!defined(ECC_TIMING_RESISTANT) || \
(defined(ECC_TIMING_RESISTANT) && !defined(WC_NO_RNG))) && \
!defined(WOLF_CRYPTO_CB_ONLY_ECC)
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(HAVE_ECC_DETERMINISTIC_K)
tmpSz = ECC_BUFSIZE;
ret = 0;
do {
@ -23941,8 +24006,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
ret = wc_AsyncWait(ret, &userA->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret == 0)
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
userA);
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng, userA);
} while (ret == WC_PENDING_E);
if (ret != 0)
ERROR_OUT(-9939, done);
@ -23956,8 +24020,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
ret = wc_AsyncWait(ret, &userA->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret == 0)
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
&verify, userA);
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE, &verify, userA);
} while (ret == WC_PENDING_E);
if (ret != 0)
ERROR_OUT(-9940, done);
@ -25889,7 +25952,8 @@ WOLFSSL_TEST_SUBROUTINE int ecc_test(void)
}
#endif
#if defined(HAVE_ECC_SIGN) && defined(WOLFSSL_ECDSA_DETERMINISTIC_K)
#if defined(HAVE_ECC_SIGN) && defined(HAVE_ECC256) \
&& defined(HAVE_ECC_DETERMINISTIC_K)
ret = ecc_test_deterministic_k(&rng);
if (ret != 0) {
printf("ecc_test_deterministic_k failed! %d\n", ret);

View File

@ -67,8 +67,14 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
#endif
#ifdef WOLFSSL_XILINX_CRYPT
#include "xsecure_aes.h"
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#include <xsecure_aesclient.h>
#define WOLFSSL_XILINX_AES_KEY_SRC XSECURE_AES_USER_KEY_0
#else /* versal */
#include <xsecure_aes.h>
#define WOLFSSL_XILINX_AES_KEY_SRC XSECURE_CSU_AES_KEY_SRC_KUP
#endif /* !versal */
#endif /* WOLFSSL_XILINX_CRYPT */
#if defined(WOLFSSL_XILINX_CRYPT) || defined(WOLFSSL_AFALG_XILINX_AES)
@ -236,9 +242,16 @@ struct Aes {
word32 left; /* unused bytes left from last call */
#endif
#ifdef WOLFSSL_XILINX_CRYPT
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
wc_Xsecure xSec;
XSecure_AesKeySize xKeySize;
int aadStyle;
byte keyInit[WOLFSSL_XSECURE_AES_KEY_SIZE] ALIGN64;
#else
XSecure_Aes xilAes;
XCsuDma dma;
word32 key_init[8];
word32 keyInit[8];
#endif
word32 kup;
#endif
#if defined(WOLFSSL_AFALG) || defined(WOLFSSL_AFALG_XILINX_AES)

View File

@ -70,6 +70,10 @@
#include <wolfssl/wolfcrypt/port/nxp/se050_port.h>
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#endif
#ifdef WOLFSSL_HAVE_SP_ECC
#include <wolfssl/wolfcrypt/sp_int.h>
#endif
@ -175,6 +179,8 @@ enum {
#elif defined(WOLFSSL_SE050)
ECC_MAX_CRYPTO_HW_SIZE = 32,
ECC_MAX_CRYPTO_HW_PUBKEY_SIZE = 64,
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
ECC_MAX_CRYPTO_HW_SIZE = MAX_ECC_BYTES,
#endif
@ -469,7 +475,11 @@ struct ecc_key {
struct kcapi_handle* handle;
byte pubkey_raw[MAX_ECC_BYTES * 2];
#endif
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
wc_Xsecure xSec;
byte keyRaw[3 * ECC_MAX_CRYPTO_HW_SIZE] ALIGN32;
byte* privKey;
#endif
#ifdef WOLFSSL_ASYNC_CRYPT
mp_int* r; /* sign/verify temps */
mp_int* s;

View File

@ -85,6 +85,8 @@ noinst_HEADERS+= \
wolfssl/wolfcrypt/port/nxp/dcp_port.h \
wolfssl/wolfcrypt/port/nxp/se050_port.h \
wolfssl/wolfcrypt/port/xilinx/xil-sha3.h \
wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h \
wolfssl/wolfcrypt/port/xilinx/xil-versal-trng.h \
wolfssl/wolfcrypt/port/caam/caam_driver.h \
wolfssl/wolfcrypt/port/caam/caam_error.h \
wolfssl/wolfcrypt/port/caam/caam_qnx.h \

View File

@ -23,8 +23,12 @@
#ifndef WOLF_XIL_CRYPT_SHA3_H
#define WOLF_XIL_CRYPT_SHA3_H
#ifdef WOLFSSL_SHA3
#include "xsecure_sha.h"
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_XILINX_CRYPT)
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#else
#include <xsecure_sha.h>
#endif
#ifdef __cplusplus
extern "C" {
@ -32,14 +36,18 @@
/* Sha3 digest */
typedef struct Sha3 {
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
wc_Xsecure xSec;
#else
XSecure_Sha3 hw;
XCsuDma dma;
#endif
} wc_Sha3;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLFSSL_SHA3 */
#endif /* WOLFSSL_SHA3 && WOLFSSL_XILINX_CRYPT */
#endif /* WOLF_XIL_CRYPT_SHA3_H */

View File

@ -0,0 +1,101 @@
/* xil-versal-glue.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL 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 Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLF_XIL_CRYPT_VERSAL_GLUE_H
#define WOLF_XIL_CRYPT_VERSAL_GLUE_H
#include <wolfssl/wolfcrypt/settings.h>
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
#include <xil_types.h>
#include <xsecure_mailbox.h>
#include <xsecure_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#define XIL_CAST_U64(v) ((u64)(UINTPTR)(v))
#ifdef XSECURE_CACHE_DISABLE
#define WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(p, l) do{}while(0)
#define WOLFSSL_XIL_DCACHE_FLUSH_RANGE(p, l) do{}while(0)
#else
#define WOLFSSL_XIL_DCACHE_INVALIDATE_RANGE(p, l) \
do{ Xil_DCacheInvalidateRange((p), (l)); }while(0)
#define WOLFSSL_XIL_DCACHE_FLUSH_RANGE(p, l) \
do{ Xil_DCacheFlushRange((p), (l)); }while(0)
#endif
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY) \
&& !defined(WOLFSSL_XIL_MSG_NO_SLEEP)
#include <unistd.h>
#define WOLFSSL_XIL_SLEEP(n) do{ sleep(n); }while(0)
#else
#define WOLFSSL_XIL_SLEEP(n) do{}while(0)
#endif
/* Provide our own message macro since the Versal PLM maybe
* prints an error message to the same console.
* In order to not mix those outputs up, sleep a little while
* before printing our message.
* This behavior can be disabled by defining `WOLFSSL_XIL_MSG_NO_SLEEP`
*/
#define WOLFSSL_XIL_MSG(msg) do { \
WOLFSSL_XIL_SLEEP(1); \
WOLFSSL_MSG(msg); \
} while(0)
#define WOLFSSL_XIL_ERROR(msg, err) do { \
WOLFSSL_XIL_MSG(msg); \
WOLFSSL_MSG_EX("Xilinx API returned 0x%08x: %s", (err), \
wc_XsecureErrorToString(err)); \
} while(0)
#define WOLFSSL_XSECURE_QWORD_SIZE 16u
#define WOLFSSL_XSECURE_AES_KEY_SIZE 32u
#define WOLFSSL_XSECURE_AES_IV_SIZE 12u
#define WOLFSSL_XSECURE_RSA_KEY_SIZE 512u
enum {
WOLFSSL_XSECURE_ECC_NIST_P384 = 4,
WOLFSSL_XSECURE_ECC_NIST_P521 = 5,
WOLFSSL_XSECURE_ECC_NUM
};
typedef struct Xsecure {
ALIGN64 u8 mem[XSECURE_SHARED_MEM_SIZE];
XMailbox mb;
XSecure_ClientInstance cinst;
} wc_Xsecure;
WOLFSSL_LOCAL int wc_InitXsecure(wc_Xsecure* xsec);
WOLFSSL_LOCAL const char *wc_XsecureErrorToString(int err);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLFSSL_XILINX_CRYPT_VERSAL */
#endif /* WOLF_XIL_CRYPT_VERSAL_GLUE_H */

View File

@ -0,0 +1,44 @@
/* xil-versal-trng.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL 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 Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLF_XIL_CRYPT_VERSAL_TRNG_H
#define WOLF_XIL_CRYPT_VERSAL_TRNG_H
#include <wolfssl/wolfcrypt/settings.h>
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
#ifdef __cplusplus
extern "C" {
#endif
WOLFSSL_LOCAL int wc_VersalTrngInit(byte* nonce, word32 nonceSz);
WOLFSSL_LOCAL int wc_VersalTrngReset(void);
WOLFSSL_LOCAL int wc_VersalTrngSelftest(void);
WOLFSSL_LOCAL int wc_VersalTrngGenerate(byte *output, word32 sz);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* versal */
#endif /* WOLF_XIL_CRYPT_VERSAL_TRNG_H */

View File

@ -83,7 +83,11 @@ RSA keys can be used to encrypt, decrypt, sign and verify data.
#include <wolfssl/wolfcrypt/hash.h>
#ifdef WOLFSSL_XILINX_CRYPT
#include "xsecure_rsa.h"
#ifdef WOLFSSL_XILINX_CRYPT_VERSAL
#include <wolfssl/wolfcrypt/port/xilinx/xil-versal-glue.h>
#else
#include <xsecure_rsa.h>
#endif
#endif
#if defined(WOLFSSL_CRYPTOCELL)
@ -214,8 +218,13 @@ struct RsaKey {
#ifdef WOLFSSL_XILINX_CRYPT
word32 pubExp; /* to keep values in scope they are here in struct */
byte* mod;
#if defined(WOLFSSL_XILINX_CRYPT_VERSAL)
int mSz;
wc_Xsecure xSec;
#else
XSecure_Rsa xRsa;
#endif
#endif
#if defined(WOLFSSL_KCAPI_RSA)
struct kcapi_handle* handle;
#endif

View File

@ -1641,8 +1641,10 @@ extern void uITRON4_free(void *p) ;
#if defined(WOLFSSL_XILINX)
#if !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
#define NO_DEV_RANDOM
#endif
#define NO_WOLFSSL_DIR
#define NO_DEV_RANDOM
#define HAVE_AESGCM
#endif

View File

@ -1131,7 +1131,8 @@ typedef struct w64wrapper {
/* AESNI requires alignment and ARMASM gains some performance from it
* Xilinx RSA operations require alignment */
#if defined(WOLFSSL_AESNI) || defined(WOLFSSL_ARMASM) || \
defined(USE_INTEL_SPEEDUP) || defined(WOLFSSL_AFALG_XILINX)
defined(USE_INTEL_SPEEDUP) || defined(WOLFSSL_AFALG_XILINX) || \
defined(WOLFSSL_XILINX)
#ifndef WOLFSSL_USE_ALIGN
#define WOLFSSL_USE_ALIGN
#endif